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

Function loadNative

packages/node/src/backend/nodeBackendInline.ts:196–218  ·  view source on GitHub ↗
(shimModule: string | undefined)

Source from the content-addressed store, hash-verified

194}
195
196async function loadNative(shimModule: string | undefined): Promise<NativeApi> {
197 const unwrap = (m: unknown): NativeApi => {
198 if (typeof m === "object" && m !== null) {
199 const rec = m as { native?: unknown; default?: unknown };
200 const candidate = (rec.native ?? rec.default ?? rec) as unknown;
201 return candidate as NativeApi;
202 }
203 return m as NativeApi;
204 };
205
206 if (typeof shimModule === "string" && shimModule.length > 0) {
207 return unwrap((await import(shimModule)) as unknown);
208 }
209
210 try {
211 return unwrap((await import("@rezi-ui/native")) as unknown);
212 } catch (err) {
213 const detail = safeDetail(err);
214 throw new Error(
215 `Failed to load @rezi-ui/native.\n\nThis usually means the native addon was not built or not installed for this platform.\n\n${detail}`,
216 );
217 }
218}
219
220export function createNodeBackendInlineInternal(opts: NodeBackendInternalOpts = {}): NodeBackend {
221 const frameAudit = createFrameAuditLogger("backend-inline");

Callers 1

ensureNativeLoadedFunction · 0.70

Calls 2

unwrapFunction · 0.70
safeDetailFunction · 0.70

Tested by

no test coverage detected