()
| 526 | |
| 527 | const backend: RuntimeBackend = { |
| 528 | async start(): Promise<void> { |
| 529 | if (disposed) throw new Error("NodeBackend(inline): disposed"); |
| 530 | if (fatal !== null) throw fatal; |
| 531 | if (started) return; |
| 532 | if (startDef !== null) { |
| 533 | await startDef.promise; |
| 534 | return; |
| 535 | } |
| 536 | |
| 537 | startDef = deferred<void>(); |
| 538 | startSettled = false; |
| 539 | stopRequested = false; |
| 540 | |
| 541 | try { |
| 542 | if (initConfigResolved === null) { |
| 543 | const resolvedEmojiWidthPolicy = await resolveBackendEmojiWidthPolicy( |
| 544 | cfg.emojiWidthPolicy, |
| 545 | nativeConfig, |
| 546 | ); |
| 547 | const nativeWidthPolicy = applyEmojiWidthPolicy(resolvedEmojiWidthPolicy); |
| 548 | initConfigResolved = { |
| 549 | ...initConfigBase, |
| 550 | widthPolicy: nativeWidthPolicy, |
| 551 | }; |
| 552 | } else { |
| 553 | const widthPolicy = initConfigResolved[WIDTH_POLICY_KEY]; |
| 554 | if (typeof widthPolicy === "number") { |
| 555 | setTextMeasureEmojiPolicy(widthPolicy === 0 ? "narrow" : "wide"); |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | const api = await ensureNativeLoaded(); |
| 560 | let id = 0; |
| 561 | try { |
| 562 | id = api.engineCreate(initConfigResolved); |
| 563 | } catch (err) { |
| 564 | throw new Error(`engine_create threw: ${safeDetail(err)}`); |
| 565 | } |
| 566 | if (!Number.isInteger(id) || id <= 0) { |
| 567 | throw new Error(`engine_create failed: code=${String(id)}`); |
| 568 | } |
| 569 | engineId = id; |
| 570 | started = true; |
| 571 | if (frameAudit.enabled) { |
| 572 | frameAudit.emit("engine.ready", { |
| 573 | engineId: id, |
| 574 | executionMode: "inline", |
| 575 | fpsCap, |
| 576 | maxEventBytes, |
| 577 | }); |
| 578 | } |
| 579 | cachedCaps = null; |
| 580 | eventQueue = []; |
| 581 | eventPool = []; |
| 582 | for (let i = 0; i < EVENT_POOL_SIZE; i++) { |
| 583 | eventPool.push(new ArrayBuffer(maxEventBytes)); |
| 584 | } |
| 585 | discardBuffer = new ArrayBuffer(maxEventBytes); |
nothing calls this directly
no test coverage detected