()
| 621 | |
| 622 | const backend: RuntimeBackend = { |
| 623 | async start(): Promise<void> { |
| 624 | if (disposed) throw new Error("NodeBackend: disposed"); |
| 625 | if (fatal !== null) throw fatal; |
| 626 | if (started) return; |
| 627 | assertWorkerEnvironmentSupported(opts.nativeShimModule); |
| 628 | |
| 629 | if (worker === null) { |
| 630 | if (initConfigResolved === null) { |
| 631 | const resolvedEmojiWidthPolicy = await resolveBackendEmojiWidthPolicy( |
| 632 | cfg.emojiWidthPolicy, |
| 633 | nativeConfig, |
| 634 | ); |
| 635 | const nativeWidthPolicy = applyEmojiWidthPolicy(resolvedEmojiWidthPolicy); |
| 636 | initConfigResolved = { |
| 637 | ...initConfigBase, |
| 638 | widthPolicy: nativeWidthPolicy, |
| 639 | }; |
| 640 | } else { |
| 641 | // Keep core measurement policy deterministic across stop/start cycles. |
| 642 | const widthPolicy = initConfigResolved[WIDTH_POLICY_KEY]; |
| 643 | if (typeof widthPolicy === "number") { |
| 644 | setTextMeasureEmojiPolicy(widthPolicy === 0 ? "narrow" : "wide"); |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | startDef = deferred<void>(); |
| 649 | startSettled = false; |
| 650 | stopDef = null; |
| 651 | stopSettled = false; |
| 652 | stopRequested = false; |
| 653 | if (sabFrameTransport !== null) resetSabFrameTransport(sabFrameTransport); |
| 654 | |
| 655 | const workerData = |
| 656 | opts.nativeShimModule === undefined |
| 657 | ? undefined |
| 658 | : { nativeShimModule: opts.nativeShimModule }; |
| 659 | const workerEntry = resolveWorkerEntry(workerData); |
| 660 | worker = new Worker(workerEntry.entry, workerEntry.options); |
| 661 | if (frameAudit.enabled) { |
| 662 | frameAudit.emit("worker.spawn", { |
| 663 | frameTransport: frameTransportWire.kind, |
| 664 | frameSabSlotCount: frameSabSlotCount, |
| 665 | frameSabSlotBytes: frameSabSlotBytes, |
| 666 | workerEntry: workerEntry.entry.href, |
| 667 | }); |
| 668 | } |
| 669 | exitDef = deferred<void>(); |
| 670 | worker.on("message", handleWorkerMessage); |
| 671 | worker.on("error", (err) => { |
| 672 | if (fatal !== null) return; |
| 673 | fatal = new ZrUiError("ZRUI_BACKEND_ERROR", safeErr(err).message); |
| 674 | failAll(fatal); |
| 675 | }); |
| 676 | worker.on("exit", (code) => { |
| 677 | handleWorkerExit(code); |
| 678 | }); |
| 679 | |
| 680 | send({ type: "init", config: initConfigResolved }); |
nothing calls this directly
no test coverage detected