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

Function createNodeBackendInternal

packages/node/src/backend/nodeBackend.ts:126–1266  ·  view source on GitHub ↗
(opts: NodeBackendInternalOpts = {})

Source from the content-addressed store, hash-verified

124export { selectNodeBackendExecutionMode };
125
126export function createNodeBackendInternal(opts: NodeBackendInternalOpts = {}): NodeBackend {
127 const frameAudit = createFrameAuditLogger("backend");
128 const cfg = opts.config ?? {};
129 const fpsCap = parseBoundedPositiveIntOrThrow(
130 "fpsCap",
131 cfg.fpsCap,
132 DEFAULT_FPS_CAP,
133 MAX_SAFE_FPS_CAP,
134 );
135 const requestedExecutionMode = cfg.executionMode ?? "auto";
136 const executionModeSelection = selectNodeBackendExecutionMode({
137 requestedExecutionMode,
138 fpsCap,
139 hasAnyTty: hasInteractiveTty(),
140 ...(opts.nativeShimModule === undefined ? {} : { nativeShimModule: opts.nativeShimModule }),
141 });
142 const executionMode = executionModeSelection.selectedExecutionMode;
143 if (executionModeSelection.fallbackReason !== null && frameAudit.enabled) {
144 frameAudit.emit("backend.executionModeFallback", {
145 requestedExecutionMode,
146 resolvedExecutionMode: executionModeSelection.resolvedExecutionMode,
147 selectedExecutionMode: executionMode,
148 reason: executionModeSelection.fallbackReason,
149 });
150 }
151 if (executionMode === "inline") {
152 return createNodeBackendInlineInternal(opts);
153 }
154 const requestedDrawlistVersion = ZR_DRAWLIST_VERSION_V1;
155 const maxEventBytes = parseBoundedPositiveIntOrThrow(
156 "maxEventBytes",
157 cfg.maxEventBytes,
158 DEFAULT_MAX_EVENT_BYTES,
159 MAX_SAFE_EVENT_BYTES,
160 );
161 const frameTransportMode =
162 cfg.frameTransport === "transfer" || cfg.frameTransport === "sab" ? cfg.frameTransport : "auto";
163 const frameSabSlotCount = parsePositiveIntOr(cfg.frameSabSlotCount, FRAME_SAB_SLOT_COUNT_DEFAULT);
164 const frameSabSlotBytes = parsePositiveIntOr(cfg.frameSabSlotBytes, FRAME_SAB_SLOT_BYTES_DEFAULT);
165 const sabFrameTransport =
166 frameTransportMode === "transfer"
167 ? null
168 : createSabFrameTransport(frameSabSlotCount, frameSabSlotBytes);
169 const frameTransportWire: FrameTransportConfig =
170 sabFrameTransport !== null
171 ? {
172 kind: FRAME_TRANSPORT_SAB_V1,
173 version: FRAME_TRANSPORT_VERSION,
174 slotCount: sabFrameTransport.slotCount,
175 slotBytes: sabFrameTransport.slotBytes,
176 control: sabFrameTransport.control,
177 data: sabFrameTransport.data,
178 }
179 : {
180 kind: FRAME_TRANSPORT_TRANSFER_V1,
181 version: FRAME_TRANSPORT_VERSION,
182 };
183 const nativeConfig = mergeScreenIntoNativeConfig(

Calls 15

severityToNumFunction · 0.90
parsePositiveIntFunction · 0.90
createFrameAuditLoggerFunction · 0.85
hasInteractiveTtyFunction · 0.85
parsePositiveIntOrFunction · 0.85
createSabFrameTransportFunction · 0.85
resolveTargetFpsFunction · 0.85

Tested by

no test coverage detected