(shimModule: string | undefined)
| 194 | } |
| 195 | |
| 196 | async 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 | |
| 220 | export function createNodeBackendInlineInternal(opts: NodeBackendInternalOpts = {}): NodeBackend { |
| 221 | const frameAudit = createFrameAuditLogger("backend-inline"); |
no test coverage detected