MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / start

Function start

packages/node/src/backend/nodeBackendInline.ts:528–602  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 13

applyEmojiWidthPolicyFunction · 0.85
ensureNativeLoadedFunction · 0.85
schedulePollFunction · 0.85
safeErrFunction · 0.85
rejectWaitersFunction · 0.85
resolveMethod · 0.80
safeDetailFunction · 0.70
deferredFunction · 0.50
emitMethod · 0.45

Tested by

no test coverage detected