@forgeax/engine-app 0.1.3 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -14
- package/dist/.tsbuildinfo +1 -1
- package/dist/__tests__/create-app-error-retention.integration.test.d.ts +2 -0
- package/dist/__tests__/create-app-error-retention.integration.test.d.ts.map +1 -0
- package/dist/__tests__/create-app-physics-plugin-failure.integration.test.d.ts +2 -0
- package/dist/__tests__/create-app-physics-plugin-failure.integration.test.d.ts.map +1 -0
- package/dist/animation-asset-lookup.d.ts +1 -2
- package/dist/animation-asset-lookup.d.ts.map +1 -1
- package/dist/create-app.d.ts +31 -10
- package/dist/create-app.d.ts.map +1 -1
- package/dist/engine-worker-runtime.mjs +72 -129
- package/dist/engine-worker-runtime.mjs.map +1 -1
- package/dist/errors.d.ts +3 -12
- package/dist/errors.d.ts.map +1 -1
- package/dist/execution/attached-world-swap.d.ts +1 -12
- package/dist/execution/attached-world-swap.d.ts.map +1 -1
- package/dist/execution/bootstrap-url.d.ts +5 -0
- package/dist/execution/bootstrap-url.d.ts.map +1 -0
- package/dist/execution/control.d.ts +0 -2
- package/dist/execution/control.d.ts.map +1 -1
- package/dist/execution/engine-worker.d.ts +1 -0
- package/dist/execution/engine-worker.d.ts.map +1 -1
- package/dist/execution/host-controller.d.ts.map +1 -1
- package/dist/execution/index.d.ts +1 -1
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/protocol.d.ts +4 -1
- package/dist/execution/protocol.d.ts.map +1 -1
- package/dist/execution/types.d.ts +17 -1
- package/dist/execution/types.d.ts.map +1 -1
- package/dist/game-context.d.ts +1 -1
- package/dist/game-context.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +332 -366
- package/dist/index.mjs.map +1 -1
- package/dist/internal/assembled-engine-profile.d.ts.map +1 -1
- package/dist/internal/assets-world-plugin.d.ts +3 -17
- package/dist/internal/assets-world-plugin.d.ts.map +1 -1
- package/dist/internal/browser-remote-bridge.d.ts +1 -2
- package/dist/internal/browser-remote-bridge.d.ts.map +1 -1
- package/dist/internal/browser-rhi-debug-runtime.d.ts +1 -1
- package/dist/internal/browser-rhi-debug-runtime.d.ts.map +1 -1
- package/dist/internal/debug-draw.d.ts +9 -0
- package/dist/internal/debug-draw.d.ts.map +1 -0
- package/dist/internal/engine-profile-common.d.ts +2 -2
- package/dist/internal/engine-profile-common.d.ts.map +1 -1
- package/dist/internal/frame-loop.d.ts +7 -4
- package/dist/internal/frame-loop.d.ts.map +1 -1
- package/dist/internal/main-engine-profile.d.ts +4 -0
- package/dist/internal/main-engine-profile.d.ts.map +1 -1
- package/dist/internal/remote-serve-flag.d.ts +3 -7
- package/dist/internal/remote-serve-flag.d.ts.map +1 -1
- package/dist/internal/rhi-capture.d.ts +1 -1
- package/dist/internal/rhi-capture.d.ts.map +1 -1
- package/dist/internal/worker-engine-profile.d.ts +2 -0
- package/dist/internal/worker-engine-profile.d.ts.map +1 -1
- package/dist/renderer-plugin.d.ts +25 -0
- package/dist/renderer-plugin.d.ts.map +1 -0
- package/dist/tool-preview/bootstrap.d.ts.map +1 -1
- package/dist/types.d.ts +21 -61
- package/dist/types.d.ts.map +1 -1
- package/package.json +25 -26
- package/src/__tests__/callback-inference.test-d.ts +7 -3
- package/src/__tests__/consumer-migration.unit.test.ts +13 -0
- package/src/__tests__/create-app-error-retention.integration.test.ts +125 -0
- package/src/__tests__/create-app-features.test.ts +21 -10
- package/src/__tests__/create-app-listener-sync.test.ts +23 -19
- package/src/__tests__/create-app-physics-plugin-failure.integration.test.ts +142 -0
- package/src/__tests__/create-app-stop.test.ts +4 -12
- package/src/__tests__/create-app.test-d.ts +12 -11
- package/src/__tests__/create-app.test.ts +1 -60
- package/src/__tests__/create-renderer-error.integration.test.ts +3 -2
- package/src/__tests__/create-renderer-lifecycle.integration.test.ts +10 -5
- package/src/__tests__/draw-source-injected-world-update-visibility.test.ts +7 -13
- package/src/__tests__/draw-source-single-world-regression.test.ts +23 -24
- package/src/__tests__/engine-worker-bootstrap-channel.unit.test.ts +8 -0
- package/src/__tests__/engine-worker-world-swap.unit.test.ts +15 -22
- package/src/__tests__/errors-pointer-lock-failed.test.ts +4 -7
- package/src/__tests__/execution-bootstrap-isolation.unit.test.ts +5 -6
- package/src/__tests__/execution-frame-order.unit.test.ts +2 -2
- package/src/__tests__/execution-frame-protocol.unit.test.ts +3 -4
- package/src/__tests__/execution-public-api.test-d.ts +4 -0
- package/src/__tests__/frame-loop-time-elapsed.test.ts +1 -1
- package/src/__tests__/frame-loop-time.unit.test.ts +1 -1
- package/src/__tests__/frame-loop-world-array.test.ts +82 -73
- package/src/__tests__/plugin-profiles.unit.test.ts +3 -3
- package/src/__tests__/profiler-default-off.test.ts +1 -1
- package/src/__tests__/profiler-frame-token.test.ts +17 -30
- package/src/__tests__/profiler-phase-integration.test.ts +15 -27
- package/src/__tests__/surface-handoff.test.ts +1 -4
- package/src/__tests__/visibility-remote.integration.test.ts +2 -5
- package/src/__tests__/worker-execution-stop.test.ts +64 -7
- package/src/animation-asset-lookup.ts +2 -2
- package/src/create-app.ts +197 -296
- package/src/errors.ts +27 -39
- package/src/execution/attached-world-swap.ts +4 -38
- package/src/execution/bootstrap-url.ts +25 -0
- package/src/execution/control.ts +3 -7
- package/src/execution/engine-worker-runtime.ts +23 -40
- package/src/execution/engine-worker.ts +2 -0
- package/src/execution/host-controller.ts +8 -2
- package/src/execution/index.ts +1 -0
- package/src/execution/protocol.ts +4 -1
- package/src/execution/types.ts +18 -1
- package/src/game-context.ts +1 -1
- package/src/index.ts +11 -4
- package/src/internal/assembled-engine-profile.ts +3 -11
- package/src/internal/assets-world-plugin.ts +7 -53
- package/src/internal/browser-remote-bridge.ts +12 -10
- package/src/internal/browser-rhi-debug-runtime.ts +1 -1
- package/src/internal/debug-draw.ts +38 -0
- package/src/internal/engine-profile-common.ts +2 -3
- package/src/internal/frame-loop.ts +77 -63
- package/src/internal/main-engine-profile.ts +21 -17
- package/src/internal/remote-serve-flag.ts +5 -14
- package/src/internal/rhi-capture.ts +1 -1
- package/src/internal/worker-engine-profile.ts +10 -10
- package/src/renderer-plugin.ts +96 -0
- package/src/tool-preview/bootstrap.ts +1 -14
- package/src/types.ts +22 -77
- package/src/vite-env.d.ts +0 -2
- package/dist/__tests__/app-rebuild.test.d.ts +0 -2
- package/dist/__tests__/app-rebuild.test.d.ts.map +0 -1
- package/dist/__tests__/asset-registry-types.test-d.d.ts +0 -2
- package/dist/__tests__/asset-registry-types.test-d.d.ts.map +0 -1
- package/dist/__tests__/assets-runtime-assembly.integration.test.d.ts +0 -2
- package/dist/__tests__/assets-runtime-assembly.integration.test.d.ts.map +0 -1
- package/dist/__tests__/draw-source-headless-full-chain.test.d.ts +0 -2
- package/dist/__tests__/draw-source-headless-full-chain.test.d.ts.map +0 -1
- package/dist/__tests__/ecs-import.unit.test.d.ts +0 -2
- package/dist/__tests__/ecs-import.unit.test.d.ts.map +0 -1
- package/dist/__tests__/execution-world-health-owner.test-d.d.ts +0 -2
- package/dist/__tests__/execution-world-health-owner.test-d.d.ts.map +0 -1
- package/dist/__tests__/remote-serve-flag.test.d.ts +0 -2
- package/dist/__tests__/remote-serve-flag.test.d.ts.map +0 -1
- package/dist/assets-runtime-assembly.d.ts +0 -19
- package/dist/assets-runtime-assembly.d.ts.map +0 -1
- package/src/__tests__/app-rebuild.test.ts +0 -31
- package/src/__tests__/asset-registry-types.test-d.ts +0 -16
- package/src/__tests__/assets-runtime-assembly.integration.test.ts +0 -68
- package/src/__tests__/draw-source-headless-full-chain.test.ts +0 -226
- package/src/__tests__/ecs-import.unit.test.ts +0 -40
- package/src/__tests__/execution-world-health-owner.test-d.ts +0 -9
- package/src/__tests__/remote-serve-flag.test.ts +0 -24
- package/src/assets-runtime-assembly.ts +0 -70
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/animation-asset-lookup.ts","../src/assets-runtime-assembly.ts","../src/canvas-policy.ts","../src/input-plugin.ts","../src/internal/assets-world-plugin.ts","../src/internal/worker-engine-profile.ts","../src/execution/attached-world-swap.ts","../src/errors.ts","../src/execution/bootstrap-entry.ts","../src/execution/kernel-pool.ts","../src/execution/engine-worker-runtime.ts"],"names":["renderer","ok","err","status"],"mappings":";;;;;;;;;;;;;;;AAQO,SAAS,6BACd,MAAA,EACwB;AACxB,EAAA,OAAO,CAAC,IAAA,KAAS,MAAA,EAAQ,MAAA,CAAsB,IAAI,CAAA;AACrD;ACYO,SAAS,oBAAA,CACd,UACA,aAAA,EACyD;AACzD,EAAA,MAAM,SAA8B,EAAC;AACrC,EAAA,MAAM,SAAA,GAAY,IAAI,GAAA,CAAI,aAAA,CAAc,GAAA,CAAI,CAAC,YAAA,KAAiB,YAAA,CAAa,IAAA,CAAK,IAAI,CAAC,CAAA;AACrF,EAAA,MAAM,QAAA,GAAW,oCAAoC,EAAC;AACtD,EAAA,MAAM,sBAAA,GAAyB;AAAA,IAC7B,GAAG,QAAA,CAAS,MAAA,CAAO,CAAC,YAAA,KAAiB,CAAC,SAAA,CAAU,GAAA,CAAI,YAAA,CAAa,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,IAC3E,GAAG;AAAA,GACL;AACA,EAAA,IAAI;AACF,IAAA,MAAM,cAAA,uBAAqB,GAAA,EAAY;AACvC,IAAA,KAAA,MAAW,gBAAgB,sBAAA,EAAwB;AACjD,MAAA,IAAI,cAAA,CAAe,GAAA,CAAI,YAAA,CAAa,IAAA,CAAK,IAAI,CAAA,EAAG;AAC9C,QAAA,MAAM,IAAI,SAAA,CAAU,CAAA,wBAAA,EAA2B,YAAA,CAAa,IAAA,CAAK,IAAI,CAAA,CAAA,CAAG,CAAA;AAAA,MAC1E;AACA,MAAA,cAAA,CAAe,GAAA,CAAI,YAAA,CAAa,IAAA,CAAK,IAAI,CAAA;AACzC,MAAA,MAAA,CAAO,IAAA;AAAA,QACL,QAAA,CAAS,cAAA;AAAA,UACP,YAAA,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AAA,EAClD,CAAA,MAAA,IAAW,OAAA,CAAQ,IAAA,KAAS,SAAA,EAAW;AACrC,IAAA,KAAA,CAAM,YAAY;AAChB,MAAA,IAAI,UAAU,MAAA,EAAW;AACvB,QAAA,MAAM,aAAa,KAAK,CAAA;AACxB,QAAA,KAAA,GAAQ,MAAA;AAAA,MACV;AACA,MAAA,KAAA,CAAM,KAAA,EAAM;AAAA,IACd,CAAA,GAAG;AAAA,EACL;AACF,CAAA","file":"engine-worker-runtime.mjs","sourcesContent":["import type { AnimationPayloadLookup } from '@forgeax/engine-animation';\nimport type { AnimationClip, Asset } from '@forgeax/engine-types';\n\nexport interface AnimationPayloadSource {\n lookup<T extends Asset = Asset>(guid: string): T | undefined;\n}\n\n/** Bridge the renderer-owned GUID catalogue into the animation plugin. */\nexport function createAnimationPayloadLookup(\n source: AnimationPayloadSource | undefined,\n): AnimationPayloadLookup {\n return (guid) => source?.lookup<AnimationClip>(guid);\n}\n","import type { AssetDecoderLease, AssetRegistry } from '@forgeax/engine-assets-runtime';\nimport { defaultAssetDecoderContributions } from '@forgeax/engine-runtime';\nimport {\n type AssetDecoderContributionRef,\n type AssetKind,\n err,\n ok,\n type Result,\n} from '@forgeax/engine-types';\n\nexport interface AssetRuntimeAssemblyError {\n readonly code: 'asset-assembly-failed';\n readonly expected: string;\n readonly hint: string;\n readonly detail: { readonly kind: string; readonly cause: unknown };\n}\n\nexport interface AssetRuntimeAssembly {\n readonly registry: AssetRegistry;\n readonly leases: readonly AssetDecoderLease[];\n dispose(): void;\n}\n\n/** Install owner decoder contributions into the realm's one asset registry. */\nexport function assembleAssetRuntime(\n registry: AssetRegistry,\n contributions: readonly AssetDecoderContributionRef[],\n): Result<AssetRuntimeAssembly, AssetRuntimeAssemblyError> {\n const leases: AssetDecoderLease[] = [];\n const overrides = new Set(contributions.map((contribution) => contribution.kind.kind));\n const defaults = defaultAssetDecoderContributions ?? [];\n const assembledContributions = [\n ...defaults.filter((contribution) => !overrides.has(contribution.kind.kind)),\n ...contributions,\n ];\n try {\n const installedKinds = new Set<string>();\n for (const contribution of assembledContributions) {\n if (installedKinds.has(contribution.kind.kind)) {\n throw new TypeError(`duplicate decoder kind \"${contribution.kind.kind}\"`);\n }\n installedKinds.add(contribution.kind.kind);\n leases.push(\n registry.installDecoder(\n contribution.kind as AssetKind<unknown, string>,\n contribution.decoder,\n ),\n );\n }\n } catch (cause) {\n for (const lease of leases) lease.dispose();\n const failed = assembledContributions[leases.length];\n return err({\n code: 'asset-assembly-failed',\n expected: 'each owner decoder contribution to install exactly once in the realm registry',\n hint: 'remove the conflicting owner contribution and assemble the current realm again',\n detail: { kind: failed?.kind.kind ?? 'unknown', cause },\n });\n }\n let disposed = false;\n return ok({\n registry,\n leases: Object.freeze([...leases]),\n dispose() {\n if (disposed) return;\n disposed = true;\n for (const lease of leases) lease.dispose();\n },\n });\n}\n","import type { World } from '@forgeax/engine-ecs';\nimport { CAMERA_PROJECTION_PERSPECTIVE, Camera } from '@forgeax/engine-render';\n\n/** Keep host-owned perspective camera aspect policy in one execution-tier seam. */\nexport function syncCameraAspect(world: World, canvasW: number, canvasH: number): void {\n if (canvasW <= 0 || canvasH <= 0) return;\n const aspect = canvasW / canvasH;\n const query = world.query({ with: [Camera] }).unwrap();\n for (const row of query) {\n const camera = world.get(row.entity, Camera);\n if (!camera.ok) continue;\n if (camera.value.autoAspect !== true) continue;\n if (camera.value.projection !== CAMERA_PROJECTION_PERSPECTIVE) continue;\n world.set(row.entity, Camera, { aspect });\n }\n}\n","import { Update } from '@forgeax/engine-ecs';\nimport { INPUT_BACKEND_KEY, InputFrameStartScan, InputSet } from '@forgeax/engine-input';\nimport type { Plugin } from '@forgeax/engine-plugin';\n\n/** Project one Host-owned input provider into reversible World contributions. */\nexport function inputPlugin(): Plugin {\n return {\n name: 'input',\n inject: ['world', 'input'],\n apply(ctx) {\n const world = ctx.world;\n const input = ctx.input;\n if (input === undefined) throw new Error('Cordis activated input without its provider');\n ctx.effect(() => {\n world.insertResource(INPUT_BACKEND_KEY, input);\n return () => {\n world.removeResource(INPUT_BACKEND_KEY);\n };\n }, 'input/resource');\n ctx.effect(() => {\n world.addSystems(Update, InputSet, [InputFrameStartScan]).unwrap();\n return () => world.removeSystem(Update, InputFrameStartScan.name);\n }, 'input/frame-start-scan');\n },\n };\n}\n","import type { AssetRegistry } from '@forgeax/engine-assets-runtime';\nimport type { Plugin } from '@forgeax/engine-plugin';\nimport type { RenderAssetPort } from '@forgeax/engine-render/internal';\nimport type { AssetRuntimeAssembly } from '../assets-runtime-assembly';\n\nconst RENDER_ASSET_PORT_RESOURCE_KEY = 'RenderAssetPort' as const;\nconst ASSET_REGISTRY_RESOURCE_KEY = 'AssetRegistry' as const;\n\n/** Project the Renderer-owned render-only asset view as a declared service. */\nexport function rendererAssetsPlugin(): Plugin {\n return {\n name: 'renderer-assets',\n inject: ['renderer'],\n provide: 'assets',\n apply(ctx) {\n if (ctx.renderer === undefined) throw new Error('assets require the renderer service');\n ctx.provide('assets', ctx.renderer.assets);\n },\n };\n}\n\n/** Adapt the Registry and its decoder leases to the App Fiber lifecycle. */\nexport function assetRegistryPlugin(assembly: AssetRuntimeAssembly): Plugin {\n return {\n name: 'asset-registry',\n provide: 'assetRegistry',\n apply(ctx) {\n ctx.provide('assetRegistry', assembly.registry);\n ctx.effect(\n () => () => {\n assembly.dispose();\n assembly.registry.dispose();\n },\n 'assets/registry',\n );\n },\n };\n}\n\n/** Project the render-only view into World resource lookup reversibly. */\nexport function assetsWorldPlugin(): Plugin {\n return {\n name: 'assets-world',\n inject: ['world', 'assets'],\n apply(ctx) {\n ctx.effect(() => {\n ctx.world.insertResource(RENDER_ASSET_PORT_RESOURCE_KEY, ctx.assets);\n return () => {\n ctx.world.removeResource(RENDER_ASSET_PORT_RESOURCE_KEY);\n };\n }, 'assets/world-render-projection');\n },\n };\n}\n\n/** Project the App-owned Registry into World resource lookup reversibly. */\nexport function assetRegistryWorldPlugin(): Plugin {\n return {\n name: 'asset-registry-world',\n inject: ['world', 'assetRegistry'],\n apply(ctx) {\n ctx.effect(() => {\n ctx.world.insertResource(ASSET_REGISTRY_RESOURCE_KEY, ctx.assetRegistry);\n return () => {\n ctx.world.removeResource(ASSET_REGISTRY_RESOURCE_KEY);\n };\n }, 'assets/world-registry');\n },\n };\n}\n\ndeclare module '@forgeax/engine-plugin' {\n interface EngineContextServices {\n /** Renderer-owned render projection; GameHost owns the load registry separately. */\n assets?: RenderAssetPort;\n /** App-owned typed runtime Registry for GUID loads and snapshots. */\n assetRegistry?: AssetRegistry;\n }\n}\n","import {\n type AnimationPayloadLookup,\n animationPayloadsPlugin,\n animationRuntimePlugin,\n} from '@forgeax/engine-animation';\nimport { type AudioBackend, audioBackendPlugin } from '@forgeax/engine-audio';\nimport { type InputBackend, inputBackendPlugin } from '@forgeax/engine-input';\nimport type { Plugin } from '@forgeax/engine-plugin';\nimport { ownedRendererPlugin, renderComponentsPlugin } from '@forgeax/engine-render';\nimport { scenePlugin } from '@forgeax/engine-scene';\nimport { statePlugin } from '@forgeax/engine-state';\n\nimport { inputPlugin } from '../input-plugin';\nimport {\n assetRegistryPlugin,\n assetRegistryWorldPlugin,\n assetsWorldPlugin,\n rendererAssetsPlugin,\n} from './assets-world-plugin';\nimport type { EngineProfileBase } from './engine-profile-common';\n\nexport interface WorkerEngineProfileOptions extends EngineProfileBase {\n readonly animationPayloads: AnimationPayloadLookup;\n readonly input: InputBackend;\n readonly audio: AudioBackend;\n}\n\n/** Static Engine Worker selection; Host-only acquisition stays outside this realm. */\nexport function workerEngineProfile(options: WorkerEngineProfileOptions): Plugin[] {\n return [\n ownedRendererPlugin(options.renderer),\n renderComponentsPlugin(),\n rendererAssetsPlugin(),\n ...(options.assetAssembly === undefined\n ? []\n : [assetRegistryPlugin(options.assetAssembly), assetRegistryWorldPlugin()]),\n assetsWorldPlugin(),\n inputBackendPlugin(options.input),\n audioBackendPlugin(options.audio),\n scenePlugin(),\n animationPayloadsPlugin(options.animationPayloads),\n animationRuntimePlugin(),\n statePlugin(),\n inputPlugin(),\n ...(options.extensions ?? []),\n ];\n}\n","import type { World } from '@forgeax/engine-ecs';\nimport type { Renderer } from '@forgeax/engine-render';\n\n/** Serialize realm rebuilds so candidate Worlds never overlap ownership. */\nexport class SerializedRebuildQueue {\n private tail: Promise<void> = Promise.resolve();\n\n enqueue(action: () => Promise<void>): Promise<void> {\n const current = this.tail.then(action, action);\n this.tail = current.catch(() => undefined);\n return current;\n }\n}\n\nexport interface RebuildCleanupFailure {\n readonly phase: 'candidate' | 'previous';\n readonly cause: unknown;\n}\n\n/** Primary rebuild failures stay first; cleanup failures are ordered detail. */\nexport class RebuildLifecycleError extends Error {\n readonly primary: unknown;\n readonly cleanup: readonly RebuildCleanupFailure[];\n\n constructor(primary: unknown, cleanup: readonly RebuildCleanupFailure[]) {\n super(\n 'World rebuild failed; cleanup details are attached without replacing the primary cause.',\n );\n this.name = 'RebuildLifecycleError';\n this.primary = primary;\n this.cleanup = cleanup;\n }\n}\n\nexport async function disposeWithOrderedDetail(\n phase: RebuildCleanupFailure['phase'],\n dispose: () => Promise<void> | void,\n failures: RebuildCleanupFailure[],\n): Promise<void> {\n try {\n await dispose();\n } catch (cause) {\n failures.push({ phase, cause });\n }\n}\n\n/** Transactionally replace one Renderer-attached World. */\nexport async function commitAttachedWorld(\n renderer: Pick<Renderer, 'attachWorld' | 'detachWorld'>,\n previousWorld: World | undefined,\n nextWorld: World,\n initializeCandidate: () => Promise<boolean>,\n): Promise<boolean> {\n const attached = renderer.attachWorld(nextWorld);\n if (!attached.ok) throw attached.error;\n try {\n if (!(await initializeCandidate())) {\n renderer.detachWorld(nextWorld);\n return false;\n }\n } catch (cause) {\n renderer.detachWorld(nextWorld);\n throw cause;\n }\n if (previousWorld !== undefined) renderer.detachWorld(previousWorld);\n return true;\n}\n","// @forgeax/engine-app -- AppError + closed AppErrorCode union (14 members) +\n// APP_ERROR_HINTS / APP_EXPECTED + discriminated AppErrorDetail per code.\n//\n// Shape:\n// - AppErrorCode = closed union 14 members (charter P4 closed-union\n// exhaustive switch needs no default fallback; tsc strict mode guards\n// completeness; AGENTS.md \"Errors are structured\" + AC-07).\n// Members:\n// - 'app-not-started'\n// - 'app-already-running'\n// - 'app-canvas-detached'\n// - 'app-system-update-failed'\n// - 'app-pointer-lock-failed'\n// Plan-strategy D-3 lock: device-lost stays on RhiErrorCode (18-member\n// union); the AppError surface does NOT add a seventh 'app-device-lost'\n// member. Host onError listener receives RhiError({code:'device-lost'})\n// verbatim through the fan-out.\n//\n// - AppError class = 4-field surface (.code / .expected / .hint /\n// .detail) byte-for-byte parallel to RhiError (packages/rhi/src/errors.ts).\n// The class extends Error so debug surfaces (stack, name) work in host\n// environments; AI users walk .code / .detail by property access (charter\n// P3 explicit failure: never parse the message string).\n//\n// - AppError is exposed as a discriminated union (variant per code) so AI\n// users get .detail narrowing for free after `if (err.code === '...')`:\n//\n// if (err.code === 'app-canvas-detached') {\n// console.warn('reattach canvas', err.detail.canvasId);\n// }\n//\n// Constructor accepts a generic args object and infers the variant from\n// the literal `code` argument; `detail` must satisfy the per-code\n// payload (`AppErrorDetailFor<C>`). Callers therefore cannot supply\n// non-canonical fields like `{ state: 'running' }` on the\n// 'app-already-running' arm.\n//\n// - APP_ERROR_HINTS / APP_EXPECTED are 14-key Records keyed by AppErrorCode;\n// one private policy owner supplies both projections. The focused policy-owner\n// proof asserts that every code has the exact expected and hint strings.\n//\n// Related: requirements AC-07 / AC-04 / AC-09; plan-strategy section 2 D-3\n// (6-member lock) + D-4 ('app-system-update-failed' detail = { cause,\n// systemName? }) + D-6 (dual-layer instanceof + switch consumption form);\n// research section 2.7 (AppErrorCode lands in AGENTS.md Error model table\n// alongside RhiErrorCode et al.); charter P3 (explicit failure) + P4\n// (closed-union exhaustive switch).\n\nimport type { RhiError } from '@forgeax/engine-rhi/errors';\nimport type { ExecutionCapabilityName, ExecutionTier } from './execution/types';\n\n/**\n * Closed AppErrorCode union (14 members).\n *\n * | code | trigger |\n * |:--|:--|\n * | `'app-not-started'` | `stop()` / `pause()` / `resume()` invoked while the rAF loop is in the terminal `'idle'` or `'stopped'` state (post-device-lost terminal sink). The handle has no live frame to interrupt; AI users either call `start()` first or accept that this handle is dead and rebuild via `createApp({...})`. |\n * | `'app-already-running'` | second `start()` invocation against an already-running handle; the call is a no-op state-machine-wise (state preserved). |\n * | `'app-canvas-detached'` | `createApp(canvas)` thin wrapper found `canvas.isConnected === false` at entry. Detail carries optional `canvasId` so the host can surface the offending canvas in a multi-canvas page (D-2 minor). |\n * | `'app-invalid-canvas-pixel-ratio'` | canvas-form Host policy supplied a non-finite or non-positive `maxCanvasPixelRatio`. Detail carries the rejected value. |\n * | `'app-system-update-failed'` | World update, renderer draw, or a frame-loop callback failed; the original failure value is forwarded on `detail.cause`. `detail.systemName` is optional when the call site can name the failing owner. |\n * | `'app-pointer-lock-failed'` | `attachInputAuto`'s `onLockError` callback received a lock failure from the input backend. `detail.path` carries `'w3c'` (W3C `requestPointerLock` rejection) or `'provider'` (host-injected `lockProvider.requestLock` throw/reject). `detail.cause` carries the original rejection value verbatim. The host recovers by remaining in unlocked state; the next trusted click will retry the lock request. |\n *\n * Plan-strategy D-4 locked the original lifecycle subset; device-lost rides RhiErrorCode.\n */\nexport type AppErrorCode = keyof typeof appErrorPolicy;\n\n/**\n * Detail variant for the `'app-canvas-detached'` arm.\n *\n * `canvasId` carries an optional identifier the host can surface to AI\n * users when multiple canvases live on the page (e.g. preview vs live\n * canvas). `undefined` when the host did not assign an id.\n */\nexport interface AppDetailCanvasDetached {\n readonly canvasId?: string | undefined;\n}\n\n/** Invalid host-owned canvas pixel-ratio cap. */\nexport interface AppDetailInvalidCanvasPixelRatio {\n readonly value: number;\n}\n\n/**\n * Detail variant for the `'app-system-update-failed'` arm (plan-strategy D-4).\n *\n * `cause` carries the original thrown value verbatim so AI users can\n * `cause instanceof EcsError` / `cause instanceof RhiError` narrow without\n * losing structure. `systemName` is populated when the call site can name\n * the offending system (input-attach cleanup path forwards\n * `FRAME_START_SCAN_SYSTEM_NAME`).\n */\nexport interface AppDetailSystemUpdateFailed {\n readonly cause: unknown;\n readonly systemName?: string | undefined;\n}\n\n/**\n * Detail variant for the `'app-pointer-lock-failed'` arm (plan-strategy D-4).\n *\n * `path` discriminates between W3C `requestPointerLock` rejections (`'w3c'`)\n * and host-injected `lockProvider.requestLock` throw/reject (`'provider'`).\n * `cause` carries the original rejection value verbatim so AI users can\n * narrow further (e.g. `cause instanceof DOMException` for W3C timeout\n * rejections).\n */\nexport interface AppDetailPointerLockFailed {\n readonly path: 'w3c' | 'provider';\n readonly cause: unknown;\n}\n\n/** Why a host-requested deterministic frame could not run. */\nexport interface AppDetailFrameStepInvalid {\n readonly state: 'idle' | 'running' | 'paused' | 'stopped';\n readonly deltaSeconds: number;\n readonly reason: 'state' | 'delta';\n}\n\nexport interface AppDetailExecutionTierUnavailable {\n readonly requestedTier: ExecutionTier;\n readonly missingCapabilities: readonly ExecutionCapabilityName[];\n readonly sharedEvidencePassed: boolean;\n}\n\nexport interface AppDetailExecutionBootstrapFailed {\n readonly phase: 'import' | 'export' | 'prepare' | 'bootstrap' | 'data';\n readonly moduleUrl: string;\n readonly cause: unknown;\n}\n\n/** Original startup failure thrown by a Cordis plugin fiber. */\nexport interface AppDetailPluginActivationFailed {\n readonly cause: unknown;\n}\n\nexport interface AppDetailExecutionDeadlineExceeded {\n readonly phase: 'startup' | 'handshake' | 'frame';\n readonly timeoutMs: number;\n}\n\nexport interface AppDetailExecutionKernelFailed {\n readonly kernelName: string;\n readonly worldIdentity: string;\n readonly cause: unknown;\n readonly partialWrite: true;\n readonly retryable: false;\n}\n\nexport interface AppDetailExecutionStaleWorld {\n readonly expectedIdentity: string;\n readonly receivedIdentity: string;\n readonly messageKind: string;\n}\n\nexport interface AppDetailExecutionRebuildFailed {\n readonly worldIdentity: string | null;\n readonly cause: unknown;\n}\n\n/**\n * Empty-detail shape for the 2 codes that carry no payload\n * (`'app-not-started'`, `'app-already-running'`).\n *\n * Modelled as `Readonly<Record<string, never>>` so literal builders use\n * `{}` while still narrowing under tsc strict (no extra property allowed).\n */\nexport type AppDetailEmpty = Readonly<Record<string, never>>;\n\n/**\n * Conditional resolver from `AppErrorCode` to its detail payload type.\n *\n * Used by the constructor signature so `new AppError({ code: 'X', ... })`\n * narrows the `detail` parameter to the variant payload at compile time.\n */\nexport type AppErrorDetailFor<C extends AppErrorCode> = C extends 'app-canvas-detached'\n ? AppDetailCanvasDetached\n : C extends 'app-invalid-canvas-pixel-ratio'\n ? AppDetailInvalidCanvasPixelRatio\n : C extends 'app-frame-step-invalid'\n ? AppDetailFrameStepInvalid\n : C extends 'app-system-update-failed'\n ? AppDetailSystemUpdateFailed\n : C extends 'app-pointer-lock-failed'\n ? AppDetailPointerLockFailed\n : C extends 'app-plugin-activation-failed'\n ? AppDetailPluginActivationFailed\n : C extends 'app-execution-tier-unavailable'\n ? AppDetailExecutionTierUnavailable\n : C extends 'app-execution-bootstrap-failed'\n ? AppDetailExecutionBootstrapFailed\n : C extends 'app-execution-deadline-exceeded'\n ? AppDetailExecutionDeadlineExceeded\n : C extends 'app-execution-kernel-failed'\n ? AppDetailExecutionKernelFailed\n : C extends 'app-execution-stale-world'\n ? AppDetailExecutionStaleWorld\n : C extends 'app-execution-rebuild-failed'\n ? AppDetailExecutionRebuildFailed\n : AppDetailEmpty;\n\n/**\n * Tagged union of `.detail` payloads carried by structured AppError.\n *\n * Each variant maps to its `AppErrorCode` arm via `AppErrorDetailFor<C>`;\n * the variants are unique by structural fields (`AppDetailCanvasDetached`\n * has `canvasId`, `AppDetailSystemUpdateFailed` has `cause`, the empty\n * shape has neither).\n */\nexport type AppErrorDetail = AppErrorDetailFor<AppErrorCode>;\n\n/**\n * Render a one-line summary of `detail.cause` for embedding in\n * `AppError.message`. `cause` is structurally typed (`unknown`) because\n * upstream may throw any value; callers downstream still get the verbatim\n * value via `err.detail.cause` — this helper exists so tools that only see\n * `err.message` (`console.error(err)`, raw stringification) still surface\n * the root cause without consumers manually expanding `detail`.\n *\n * Closed precedence:\n * 1. Structured engine errors (RhiError / EcsError / RenderGraphError /\n * AssetError / ShaderError / ...) carry `.code` + `.message`; render\n * `<Name> <code>: <message>`.\n * 2. Plain `Error`: render `<name>: <message>`.\n * 3. Anything else: `String(cause)` (covers thrown strings, numbers, null).\n *\n * Newlines are replaced with `' / '` so the final AppError message stays a\n * single line (callers already split on `\\n` in stack traces, so a multiline\n * message would corrupt their parsing).\n */\nfunction summarizeCause(cause: unknown): string {\n if (cause === null || cause === undefined) return String(cause);\n if (typeof cause !== 'object') return String(cause);\n const r = cause as { name?: unknown; message?: unknown; code?: unknown };\n const name = typeof r.name === 'string' && r.name.length > 0 ? r.name : 'Error';\n const code = typeof r.code === 'string' && r.code.length > 0 ? r.code : '';\n const message = typeof r.message === 'string' ? r.message : '';\n const head = code !== '' ? `${name} ${code}` : name;\n const body = message !== '' ? `: ${message}` : '';\n return `${head}${body}`.replace(/\\s*\\n+\\s*/g, ' / ');\n}\n\nclass AppErrorClass extends Error {\n readonly code: AppErrorCode;\n readonly expected: string;\n readonly hint: string;\n readonly detail: AppErrorDetail;\n\n constructor(args: {\n code: AppErrorCode;\n expected: string;\n hint: string;\n detail: AppErrorDetail;\n }) {\n // Surface `detail.cause` directly inside `.message` for the\n // `'app-system-update-failed'` arm. Without this, a generic\n // `console.error(err)` shows only the wrapper expected/hint and\n // hides the actual EcsError / RhiError / host-system Error that\n // tripped the frame loop. The verbatim `cause` value remains on\n // `err.detail.cause` for two-level-narrow consumers (charter P3).\n let causeSuffix = '';\n if (args.code === 'app-system-update-failed') {\n const d = args.detail as AppDetailSystemUpdateFailed;\n const sys =\n typeof d.systemName === 'string' && d.systemName.length > 0\n ? ` (system=${d.systemName})`\n : '';\n causeSuffix = `; cause: ${summarizeCause(d.cause)}${sys}`;\n } else if (args.code === 'app-pointer-lock-failed') {\n const d = args.detail as AppDetailPointerLockFailed;\n causeSuffix = `; path: ${d.path}; cause: ${summarizeCause(d.cause)}`;\n } else if (args.code === 'app-plugin-activation-failed') {\n const d = args.detail as AppDetailPluginActivationFailed;\n causeSuffix = `; cause: ${summarizeCause(d.cause)}`;\n } else if (args.code === 'app-execution-bootstrap-failed') {\n const d = args.detail as AppDetailExecutionBootstrapFailed;\n causeSuffix = `; phase: ${d.phase}; cause: ${summarizeCause(d.cause)}`;\n } else if (args.code === 'app-execution-kernel-failed') {\n const d = args.detail as AppDetailExecutionKernelFailed;\n causeSuffix = `; kernel: ${d.kernelName}; cause: ${summarizeCause(d.cause)}`;\n } else if (args.code === 'app-execution-rebuild-failed') {\n const d = args.detail as AppDetailExecutionRebuildFailed;\n causeSuffix = `; cause: ${summarizeCause(d.cause)}`;\n }\n super(`[AppError ${args.code}] expected: ${args.expected}; hint: ${args.hint}${causeSuffix}`);\n this.name = 'AppError';\n this.code = args.code;\n this.expected = args.expected;\n this.hint = args.hint;\n this.detail = args.detail;\n }\n}\n\n/**\n * Variant intersection: an `AppErrorClass` instance whose `code` literal\n * narrows to `C` and whose `detail` narrows to `AppErrorDetailFor<C>`. The\n * shape lets `if (err.code === 'X')` simultaneously narrow `err.detail` to\n * the per-code payload (charter P3 + AC-07 discriminated union).\n */\ntype AppErrorVariant<C extends AppErrorCode> = AppErrorClass & {\n readonly code: C;\n readonly detail: AppErrorDetailFor<C>;\n};\n\n/**\n * Public AppError type — discriminated union of the policy variants.\n *\n * AI-user form (charter P3 explicit failure):\n *\n * ```ts\n * function recover(err: AppError): string {\n * switch (err.code) {\n * case 'app-not-started': return 'call start() first';\n * case 'app-already-running': return 'state preserved; ignore';\n * case 'app-canvas-detached': return `reattach ${err.detail.canvasId ?? 'canvas'}`;\n * case 'app-system-update-failed':\n * return err.detail.cause instanceof Error ? err.detail.cause.message : 'unknown';\n * case 'app-pointer-lock-failed':\n * return `lock failed (${err.detail.path}): ${err.detail.cause}`;\n * }\n * }\n * ```\n */\nexport type AppError = {\n [C in AppErrorCode]: AppErrorVariant<C>;\n}[AppErrorCode];\n\ninterface AppErrorConstructor {\n new <C extends AppErrorCode>(args: {\n code: C;\n expected: string;\n hint: string;\n detail: AppErrorDetailFor<C>;\n }): AppErrorVariant<C>;\n readonly prototype: AppErrorClass;\n}\n\n/**\n * AppError constructor — `new AppError({ code, expected, hint, detail })`.\n *\n * The generic `C` is inferred from the literal `code` argument, which\n * narrows `detail` to the per-code payload (`AppErrorDetailFor<C>`) and\n * narrows the return type to the corresponding `AppErrorVariant<C>` so the\n * call site walks the discriminated union without manual cast.\n *\n * The constructor delegates to the `AppErrorClass` runtime; the typed-cast\n * here is the ergonomic affordance for AI users (TS class declarations\n * cannot directly express `<C> ... AppErrorVariant<C>` polymorphism).\n */\nexport const AppError: AppErrorConstructor = AppErrorClass as unknown as AppErrorConstructor;\n\n/**\n * `expected` table — the engine-side invariant that was violated when each\n * code surfaces. AI users read this as the L2 detail (charter F2 priority\n * text); `.hint` carries the recovery action.\n *\n * 14 keys; the focused policy-owner proof locks the exact key set and values.\n * locks the count and non-emptiness of every entry.\n */\ntype AppErrorPolicy = { readonly expected: string; readonly hint: string };\n\nconst appErrorPolicy = {\n 'app-not-started': {\n expected:\n 'state must be \"running\" or \"paused\" to accept stop/pause/resume; \"idle\" / \"stopped\" terminal sinks reject',\n hint: 'check getState() before calling stop/pause/resume; rebuild the handle via createApp({...}) when the previous one terminated on device-lost',\n },\n 'app-already-running': {\n expected:\n 'state must be \"idle\" or \"paused\" to start; \"running\" handles ignore subsequent start() calls',\n hint: 'call stop() first or audit start() call sites; the second start() is a no-op so state is preserved',\n },\n 'app-canvas-detached': {\n expected: 'canvas.isConnected === true at createApp(canvas) entry',\n hint: 'append the canvas to the document tree before calling createApp(canvas), or use the assemble entry createApp({ renderer, world }) when the host already manages canvas lifetime',\n },\n 'app-invalid-canvas-pixel-ratio': {\n expected: 'maxCanvasPixelRatio is finite and greater than 0',\n hint: 'omit maxCanvasPixelRatio to keep the device pixel ratio, or pass a finite value > 0 from the Host policy',\n },\n 'app-frame-step-invalid': {\n expected:\n 'stepFrame(deltaSeconds) runs only while the App is paused and deltaSeconds is finite and non-negative',\n hint: 'pause the App before deterministic stepping and pass an explicit finite delta; resume after the bounded step sequence completes',\n },\n 'app-system-update-failed': {\n expected:\n 'world.update(world), renderer.draw(world), and frame-loop callbacks complete without failure',\n hint: 'inspect detail.cause for the original thrown value (EcsError / RhiError / host system bug); detail.systemName names the offending system when the call site can supply it',\n },\n 'app-pointer-lock-failed': {\n expected:\n 'pointer-lock request (W3C requestPointerLock or host lockProvider.requestLock) to succeed; failure signals the browser rejected the lock or the host provider threw',\n hint: 'remain in unlocked state; the next trusted click will automatically retry the lock request. inspect detail.path (\"w3c\" or \"provider\") and detail.cause to determine the root cause',\n },\n 'app-plugin-activation-failed': {\n expected: 'every requested Cordis plugin fiber reaches a stable active or pending state',\n hint: 'inspect detail.cause and the plugin fiber effects; repair the failing activation before creating the App again',\n },\n 'app-execution-tier-unavailable': {\n expected:\n 'the explicitly requested execution tier has every required observed capability and the shipped shared evidence gate',\n hint: 'inspect detail.missingCapabilities and detail.sharedEvidencePassed; use tier=\"auto\" only when an observed fallback is acceptable',\n },\n 'app-execution-bootstrap-failed': {\n expected:\n 'the bootstrap URL imports a module whose default export completes as an ExecutionBootstrapEntry in the selected Engine Realm',\n hint: 'inspect detail.phase, moduleUrl and cause; export one default ExecutionBootstrapEntry that creates only realm-local engine state',\n },\n 'app-execution-deadline-exceeded': {\n expected:\n 'the execution startup, handshake or frame completes within its configured bounded deadline',\n hint: 'inspect detail.phase and timeoutMs; the timed-out Worker has been terminated, so fix startup or frame work before creating a new App',\n },\n 'app-execution-kernel-failed': {\n expected:\n 'a shared kernel completes every dispatched shard without leaving a possibly partial World write',\n hint: 'do not retry or draw the poisoned World; inspect detail.kernelName and cause, then call app.execution.rebuild()',\n },\n 'app-execution-stale-world': {\n expected:\n 'every execution message targets the currently active World identity before it can write',\n hint: 'discard the late message and keep the current World; inspect expectedIdentity, receivedIdentity and messageKind',\n },\n 'app-execution-rebuild-failed': {\n expected:\n 'explicit rebuild disposes the poisoned World and bootstraps a fresh World identity in the surviving Engine Realm',\n hint: 'inspect detail.cause; this App remains stopped, so fix the bootstrap failure or create a new App explicitly',\n },\n} satisfies Record<string, AppErrorPolicy>;\n\nexport const APP_EXPECTED: Readonly<Record<AppErrorCode, string>> = Object.fromEntries(\n Object.entries(appErrorPolicy).map(([code, policy]) => [code, policy.expected]),\n) as Readonly<Record<AppErrorCode, string>>;\n\nexport const APP_ERROR_HINTS: Readonly<Record<AppErrorCode, string>> = Object.fromEntries(\n Object.entries(appErrorPolicy).map(([code, policy]) => [code, policy.hint]),\n) as Readonly<Record<AppErrorCode, string>>;\n\n/**\n * Type guard for narrowing `CanvasAppError`-compatible mixed signals to AppError.\n *\n * The fan-out signature is `(err: CanvasAppError) => void`; AI users\n * who want to handle only the AppError leg call `if (isAppError(err)) ...`\n * before walking `.code`. Reverse-compatible with `instanceof AppError`\n * (the class is exposed); the function form is provided as the\n * canonical idiom in JSDoc / README so AI users do not need to reason\n * about cross-realm `instanceof` quirks.\n *\n * The parameter accepts the complete App/RHI boundary union so callers can\n * narrow the error without casts.\n */\nexport function isAppError(err: AppError | RhiError): err is AppError {\n return err instanceof AppErrorClass;\n}\n","import type { Plugin } from '@forgeax/engine-plugin';\nimport type { RenderFeature } from '@forgeax/engine-render';\nimport { err, ok, type Result } from '@forgeax/engine-types';\nimport { APP_ERROR_HINTS, APP_EXPECTED, AppError, type AppError as AppErrorType } from '../errors';\nimport type { ExecutionBootstrapValue } from './types';\n\n/** Realm-local engine assembly returned by an execution bootstrap module. */\nexport interface PreparedExecutionBootstrap {\n /** Render features constructed in the realm that will own the Renderer. */\n readonly features?: readonly RenderFeature<unknown>[];\n /** Plugins constructed in the realm that will own the World. */\n readonly plugins?: readonly Plugin[];\n}\n\n/** Realm-local Host bridge available to execution bootstrap plugins. */\nexport interface ExecutionBootstrapHost {\n readonly port?: MessagePort;\n setPointerLockAllowed(allowed: boolean): void;\n}\n\ndeclare module '@forgeax/engine-plugin' {\n interface EngineContextServices {\n executionBootstrapHost: ExecutionBootstrapHost;\n }\n}\n\n/** Bind the optional Host transport to the same Fiber that owns bootstrap plugins. */\nexport function executionBootstrapHostPlugin(host: ExecutionBootstrapHost): Plugin {\n return {\n name: 'execution-bootstrap-host',\n provide: 'executionBootstrapHost',\n apply(ctx) {\n ctx.provide('executionBootstrapHost', host);\n if (host.port !== undefined) {\n ctx.effect(() => () => host.port?.close(), 'execution/bootstrap-port');\n }\n },\n };\n}\n\n/** Default export contract for `ExecutionOptions.bootstrap`. */\nexport type ExecutionBootstrapEntry = (\n data: ExecutionBootstrapValue | undefined,\n) => PreparedExecutionBootstrap | Promise<PreparedExecutionBootstrap>;\n\nfunction bootstrapError(\n phase: 'import' | 'export' | 'prepare' | 'bootstrap' | 'data',\n moduleUrl: string,\n cause: unknown,\n): AppErrorType {\n return new AppError({\n code: 'app-execution-bootstrap-failed',\n expected: APP_EXPECTED['app-execution-bootstrap-failed'],\n hint: APP_ERROR_HINTS['app-execution-bootstrap-failed'],\n detail: { phase, moduleUrl, cause },\n });\n}\n\nexport function validateExecutionBootstrapData(\n data: ExecutionBootstrapValue | undefined,\n moduleUrl: string,\n): Result<void, AppErrorType> {\n if (data === undefined) return ok(undefined);\n try {\n structuredClone(data);\n return ok(undefined);\n } catch (cause) {\n return err(bootstrapError('data', moduleUrl, cause));\n }\n}\n\nexport async function loadBootstrapEntry(\n moduleUrl: string,\n): Promise<Result<ExecutionBootstrapEntry, AppErrorType>> {\n let loaded: unknown;\n try {\n loaded = await import(/* @vite-ignore */ moduleUrl);\n } catch (cause) {\n return err(bootstrapError('import', moduleUrl, cause));\n }\n const entry = (loaded as { default?: unknown }).default;\n if (typeof entry !== 'function') {\n return err(\n bootstrapError(\n 'export',\n moduleUrl,\n new TypeError('default export is not an ExecutionBootstrapEntry function'),\n ),\n );\n }\n return ok(entry as ExecutionBootstrapEntry);\n}\n\nexport async function prepareBootstrapEntry(\n moduleUrl: string,\n data: ExecutionBootstrapValue | undefined,\n): Promise<Result<PreparedExecutionBootstrap, AppErrorType>> {\n const valid = validateExecutionBootstrapData(data, moduleUrl);\n if (!valid.ok) return valid;\n const loaded = await loadBootstrapEntry(moduleUrl);\n if (!loaded.ok) return loaded;\n try {\n const prepared = await loaded.value(data);\n if (\n typeof prepared !== 'object' ||\n prepared === null ||\n (prepared.features !== undefined && !Array.isArray(prepared.features)) ||\n (prepared.plugins !== undefined && !Array.isArray(prepared.plugins))\n ) {\n return err(\n bootstrapError(\n 'prepare',\n moduleUrl,\n new TypeError('execution bootstrap must return an object with feature and plugin arrays'),\n ),\n );\n }\n return ok(prepared);\n } catch (cause) {\n return err(bootstrapError('prepare', moduleUrl, cause));\n }\n}\n","import type {\n KernelDispatchFailure,\n KernelDispatchResult,\n KernelDispatchSpan,\n SharedKernelDispatch,\n SharedKernelExecutor,\n SharedSpanBinding,\n} from '@forgeax/engine-ecs/shared';\nimport { bindSharedSpan, isSharedSpan, splitSharedSpan } from '@forgeax/engine-ecs/shared';\n\nexport interface KernelPool extends SharedKernelExecutor {\n readonly laneCount: number;\n ready(): Promise<void>;\n takeLastDispatch(): KernelDispatchResult | null;\n dispose(): void;\n}\n\ninterface KernelJobMessage {\n readonly kind: 'kernel-job';\n readonly moduleUrl: string;\n readonly binding: SharedSpanBinding;\n readonly control: Int32Array;\n readonly status: Int32Array;\n readonly jobIndex: number;\n}\n\ninterface KernelInitMessage {\n readonly kind: 'kernel-init';\n readonly ready: Int32Array;\n}\n\ninterface KernelPreloadMessage {\n readonly kind: 'kernel-preload';\n readonly moduleUrl: string;\n readonly control: Int32Array;\n readonly status: Int32Array;\n readonly jobIndex: number;\n}\n\ninterface KernelPreflight {\n readonly control: Int32Array;\n readonly status: Int32Array;\n}\n\nexport interface KernelPoolOptions {\n readonly lanes?: number;\n readonly timeoutMs?: number;\n readonly workerFactory?: () => Worker;\n}\n\nexport function createKernelPool(options: KernelPoolOptions = {}): KernelPool {\n const hardware = globalThis.navigator?.hardwareConcurrency ?? 2;\n const laneCount = Math.max(1, Math.min(options.lanes ?? hardware - 1, 8));\n const timeoutMs = options.timeoutMs ?? 5_000;\n const workers = Array.from(\n { length: laneCount },\n () =>\n options.workerFactory?.() ??\n new Worker(new URL('./kernel-worker-runtime.mjs', import.meta.url), {\n type: 'module',\n name: 'forgeax-kernel',\n }),\n );\n let latest: KernelDispatchResult | null = null;\n let ready = false;\n const preflights = new Map<string, KernelPreflight>();\n const readyControl = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));\n const initMessage: KernelInitMessage = { kind: 'kernel-init', ready: readyControl };\n for (const worker of workers) worker.postMessage(initMessage);\n const waitFor = (control: Int32Array, expected: number, label: string): Promise<void> =>\n new Promise<void>((resolve, reject) => {\n const started = performance.now();\n const poll = (): void => {\n if (Atomics.load(control, 0) === expected) {\n resolve();\n return;\n }\n if (performance.now() - started >= timeoutMs) {\n for (const worker of workers) worker.terminate();\n reject(new Error(`${label} did not complete within ${timeoutMs}ms.`));\n return;\n }\n setTimeout(poll, 1);\n };\n poll();\n });\n\n const readyPromise = waitFor(\n readyControl,\n workers.length,\n 'SharedKernel worker initialization',\n ).then(async () => {\n for (const [moduleUrl, preflight] of preflights) {\n await waitFor(\n preflight.control,\n workers.length,\n `SharedKernel module preflight for ${moduleUrl}`,\n );\n if (preflight.status.some((status) => status !== 1)) {\n throw new Error(`SharedKernel module preflight failed for ${moduleUrl}.`);\n }\n }\n ready = true;\n });\n\n return {\n laneCount,\n ready: () => readyPromise,\n warmup(kernel): void {\n if (preflights.has(kernel.moduleUrl)) return;\n const control = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));\n const status = new Int32Array(\n new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * workers.length),\n );\n preflights.set(kernel.moduleUrl, { control, status });\n for (const [jobIndex, worker] of workers.entries()) {\n const message: KernelPreloadMessage = {\n kind: 'kernel-preload',\n moduleUrl: kernel.moduleUrl,\n control,\n status,\n jobIndex,\n };\n worker.postMessage(message);\n }\n },\n takeLastDispatch: () => {\n const dispatch = latest;\n latest = null;\n return dispatch;\n },\n execute(\n kernel: SharedKernelDispatch,\n spans: readonly KernelDispatchSpan[],\n ): KernelDispatchResult | KernelDispatchFailure {\n const preflight = preflights.get(kernel.moduleUrl);\n if (preflight === undefined) {\n this.warmup?.(kernel);\n latest = { mode: 'forced-inline', dispatched: 0, completed: 0, waitMs: 0 };\n return {\n cause: new Error('SharedKernel module was not preflighted before frame dispatch.'),\n dispatched: 0,\n completed: 0,\n partialWrite: false,\n };\n }\n if (\n Atomics.load(preflight.control, 0) !== workers.length ||\n preflight.status.some((status) => status !== 1)\n ) {\n latest = { mode: 'forced-inline', dispatched: 0, completed: 0, waitMs: 0 };\n return {\n cause: new Error('SharedKernel module preflight is incomplete or failed.'),\n dispatched: 0,\n completed: 0,\n partialWrite: false,\n };\n }\n if (!ready && Atomics.load(readyControl, 0) === workers.length) ready = true;\n if (!ready) {\n latest = { mode: 'forced-inline', dispatched: 0, completed: 0, waitMs: 0 };\n return {\n cause: new Error('SharedKernel workers were not warmed before frame dispatch.'),\n dispatched: 0,\n completed: 0,\n partialWrite: false,\n };\n }\n const bindings = spans.flatMap(({ queryIndex, span }) =>\n splitSharedSpan(bindSharedSpan(kernel, span, queryIndex), laneCount),\n );\n if (bindings.length === 0) {\n latest = { mode: 'forced-inline', dispatched: 0, completed: 0, waitMs: 0 };\n return latest;\n }\n if (!bindings.every(isSharedSpan)) {\n latest = { mode: 'forced-inline', dispatched: 0, completed: 0, waitMs: 0 };\n return {\n cause: new Error('SharedKernel received a non-SAB QuerySpan.'),\n dispatched: 0,\n completed: 0,\n partialWrite: false,\n };\n }\n const control = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));\n const status = new Int32Array(\n new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * bindings.length),\n );\n const started = performance.now();\n for (const [index, binding] of bindings.entries()) {\n const message: KernelJobMessage = {\n kind: 'kernel-job',\n moduleUrl: kernel.moduleUrl,\n binding,\n control,\n status,\n jobIndex: index,\n };\n workers[index % workers.length]?.postMessage(message);\n }\n while (Atomics.load(control, 0) < bindings.length) {\n const observed = Atomics.load(control, 0);\n const wait = Atomics.wait(control, 0, observed, timeoutMs);\n if (wait === 'timed-out') {\n for (const worker of workers) worker.terminate();\n return {\n cause: new Error(`SharedKernel deadline exceeded after ${timeoutMs}ms.`),\n dispatched: bindings.length,\n completed: observed,\n partialWrite: bindings.length > 0,\n };\n }\n }\n const completed = status.reduce((count, value) => count + (value === 1 ? 1 : 0), 0);\n const failed = status.some((value) => value === -1);\n if (failed) {\n return {\n cause: new Error('SharedKernel worker failed.'),\n dispatched: bindings.length,\n completed,\n partialWrite: bindings.length > 0,\n };\n }\n latest = {\n mode: 'shared',\n dispatched: bindings.length,\n completed,\n waitMs: performance.now() - started,\n };\n return latest;\n },\n dispose(): void {\n for (const worker of workers) worker.terminate();\n },\n };\n}\n","import { createAssetRegistry, createCatalogSource } from '@forgeax/engine-assets-runtime';\nimport { type AudioIntent, createAudioIntentBackend } from '@forgeax/engine-audio';\nimport { createWorldContext, World } from '@forgeax/engine-ecs';\nimport type { SharedKernelExecutor } from '@forgeax/engine-ecs/shared';\nimport type { InputBackend, InputBackendSample } from '@forgeax/engine-input';\nimport type { Context, Plugin } from '@forgeax/engine-plugin';\nimport type { Renderer } from '@forgeax/engine-render';\nimport { createRenderer } from '@forgeax/engine-runtime';\nimport { createAnimationPayloadLookup } from '../animation-asset-lookup';\nimport { type AssetRuntimeAssembly, assembleAssetRuntime } from '../assets-runtime-assembly';\nimport { syncCameraAspect } from '../canvas-policy';\nimport { workerEngineProfile } from '../internal/worker-engine-profile';\nimport { commitAttachedWorld, SerializedRebuildQueue } from './attached-world-swap';\nimport {\n executionBootstrapHostPlugin,\n type PreparedExecutionBootstrap,\n prepareBootstrapEntry,\n} from './bootstrap-entry';\nimport { createKernelPool, type KernelPool } from './kernel-pool';\nimport type {\n EngineToHostMessage,\n ExecutionFrameMessage,\n ExecutionInitMessage,\n ExecutionRebuildMessage,\n HostToEngineMessage,\n} from './protocol';\n\nconst scope = globalThis as unknown as {\n postMessage(message: EngineToHostMessage): void;\n onmessage: ((event: MessageEvent<HostToEngineMessage>) => void) | null;\n close(): void;\n};\n\nlet renderer: Renderer | undefined;\nlet currentSample: InputBackendSample = {\n downKeys: new Set(),\n upKeys: new Set(),\n buttons: [false, false, false],\n movementX: 0,\n movementY: 0,\n wheelDelta: 0,\n focused: true,\n pointerLocked: false,\n};\nlet lastFrameId = 0;\nlet engineCanvas: OffscreenCanvas | undefined;\ninterface WorkerRealm {\n readonly world: World;\n readonly init: ExecutionInitMessage;\n pendingAudioIntents: AudioIntent[];\n kernelPool: KernelPool | undefined;\n pluginContext: Context | undefined;\n}\n\nlet realm: WorkerRealm | undefined;\nconst rebuildQueue = new SerializedRebuildQueue();\nconst inputBackend: InputBackend = {\n sample: () => currentSample,\n detach: () => {},\n};\n\nfunction sharedKernelPlugin(target: WorkerRealm): Plugin {\n return {\n name: 'shared-kernel-executor',\n inject: ['world'],\n apply(ctx) {\n const executor: SharedKernelExecutor = {\n warmup(kernel) {\n target.kernelPool ??= createKernelPool();\n target.kernelPool.warmup?.(kernel);\n },\n execute(kernel, spans) {\n target.kernelPool ??= createKernelPool();\n return target.kernelPool.execute(kernel, spans);\n },\n };\n ctx.effect(() => {\n ctx.world.insertResource('SharedKernelExecutor', executor);\n return () => {\n ctx.world.removeResource('SharedKernelExecutor');\n target.kernelPool?.dispose();\n target.kernelPool = undefined;\n };\n }, 'execution/shared-kernel');\n },\n };\n}\n\nfunction serializableCause(cause: unknown): { readonly name: string; readonly message: string } {\n return cause instanceof Error\n ? { name: cause.name, message: cause.message }\n : { name: 'Error', message: String(cause) };\n}\n\nfunction serializableDetail(cause: unknown): unknown {\n if (cause instanceof Error) return serializableCause(cause);\n if (Array.isArray(cause)) return cause.map(serializableDetail);\n if (typeof cause === 'object' && cause !== null) {\n const named = cause as { readonly name?: unknown; readonly message?: unknown };\n if (typeof named.name === 'string' || typeof named.message === 'string') {\n return {\n name: typeof named.name === 'string' ? named.name : 'Error',\n message: typeof named.message === 'string' ? named.message : String(cause),\n };\n }\n return Object.fromEntries(\n Object.entries(cause).map(([key, value]) => [key, serializableDetail(value)]),\n );\n }\n return cause;\n}\n\nfunction postFault(\n source: 'bootstrap' | 'runtime' | 'world' | 'rebuild',\n code: string,\n expected: string,\n hint: string,\n cause: unknown,\n partialWrite = false,\n): void {\n scope.postMessage({\n kind: 'fault',\n worldIdentity: realm?.world.identity ?? null,\n source,\n code,\n expected,\n hint,\n detail: serializableDetail(cause),\n partialWrite,\n retryable: false,\n });\n}\n\nasync function disposeRealm(target: WorkerRealm): Promise<void> {\n await target.pluginContext?.fiber.dispose();\n target.pluginContext = undefined;\n target.pendingAudioIntents = [];\n}\n\nfunction postBootstrapFault(error: {\n readonly code: string;\n readonly expected: string;\n readonly hint: string;\n readonly detail: unknown;\n}): void {\n postFault('bootstrap', error.code, error.expected, error.hint, error.detail);\n}\n\nasync function createRealm(init: ExecutionInitMessage): Promise<boolean> {\n const preparedResult = await prepareBootstrapEntry(init.bootstrapUrl, init.bootstrapData);\n if (!preparedResult.ok) {\n postBootstrapFault(preparedResult.error);\n return false;\n }\n const prepared: PreparedExecutionBootstrap = preparedResult.value;\n const nextWorld = new World({\n ...(init.time !== undefined ? { time: init.time } : {}),\n storage: init.tier === 'shared' ? 'shared' : 'local',\n });\n const candidate: WorkerRealm = {\n world: nextWorld,\n init,\n pendingAudioIntents: [],\n kernelPool: undefined,\n pluginContext: undefined,\n };\n const audioBackend = createAudioIntentBackend({\n emit: (intent) => candidate.pendingAudioIntents.push(intent),\n });\n let candidateRenderer: Renderer | undefined;\n let assetAssembly: AssetRuntimeAssembly | undefined;\n let rendererLifecycleTransferred = false;\n const previousRenderer = renderer;\n let previousSurfaceReleased = false;\n try {\n if (previousRenderer !== undefined) {\n const released = previousRenderer.releaseSurface();\n if (!released.ok) throw released.error;\n previousSurfaceReleased = true;\n }\n candidateRenderer = await createRenderer(\n init.canvas,\n prepared.features === undefined ? {} : { features: prepared.features },\n init.shaderManifestUrl === undefined\n ? undefined\n : { shaderManifestUrl: init.shaderManifestUrl },\n );\n const ready = await candidateRenderer.ready;\n if (!ready.ok) throw ready.error;\n rendererLifecycleTransferred = true;\n const assetRegistry = createAssetRegistry({\n catalog: createCatalogSource({\n url: new URL('pack-index.json', globalThis.location?.href ?? 'http://localhost/').href,\n }),\n });\n const assembledAssets = assembleAssetRuntime(assetRegistry, []);\n if (!assembledAssets.ok) {\n assetRegistry.dispose();\n throw assembledAssets.error;\n }\n assetAssembly = assembledAssets.value;\n const pluginContext = await createWorldContext(\n nextWorld,\n workerEngineProfile({\n renderer: candidateRenderer,\n assetAssembly,\n input: inputBackend,\n audio: audioBackend,\n animationPayloads: createAnimationPayloadLookup(candidateRenderer.assets),\n extensions: [\n ...(init.tier === 'shared' ? [sharedKernelPlugin(candidate)] : []),\n executionBootstrapHostPlugin({\n ...(init.bootstrapPort === undefined ? {} : { port: init.bootstrapPort }),\n setPointerLockAllowed(allowed): void {\n scope.postMessage({\n kind: 'host-control',\n command: 'set-pointer-lock-allowed',\n allowed,\n });\n },\n }),\n ...(prepared.plugins ?? []),\n ],\n }),\n );\n candidate.pluginContext = pluginContext;\n const activeRenderer = candidateRenderer;\n const previousRealm = realm;\n const committed = await commitAttachedWorld(\n candidateRenderer,\n previousRealm?.world,\n nextWorld,\n async () => {\n await candidate.kernelPool?.ready();\n return true;\n },\n );\n if (!committed) {\n await disposeRealm(candidate);\n if (previousSurfaceReleased) previousRenderer?.restoreSurface();\n return false;\n }\n realm = candidate;\n renderer = activeRenderer;\n lastFrameId = 0;\n if (previousRealm !== undefined) await disposeRealm(previousRealm);\n return true;\n } catch (cause) {\n await disposeRealm(candidate);\n assetAssembly?.dispose();\n assetAssembly?.registry.dispose();\n if (!rendererLifecycleTransferred) candidateRenderer?.dispose();\n if (previousSurfaceReleased) previousRenderer?.restoreSurface();\n throw cause;\n }\n}\n\nasync function initialize(message: ExecutionInitMessage): Promise<void> {\n try {\n engineCanvas = message.canvas;\n if (!(await createRealm(message))) return;\n scope.postMessage({\n kind: 'ready',\n worldIdentity: realm?.world.identity ?? '',\n realm: 'worker',\n workerWebGpu: typeof navigator === 'object' && navigator.gpu !== undefined,\n });\n } catch (cause) {\n postFault(\n 'bootstrap',\n 'app-execution-bootstrap-failed',\n 'Engine Worker creates a realm-local World, Renderer and GPU owner',\n 'inspect the worker bootstrap cause and module URL',\n cause,\n );\n }\n}\n\nfunction runFrame(message: ExecutionFrameMessage): void {\n const activeRealm = realm;\n if (activeRealm === undefined || renderer === undefined) return;\n const { world } = activeRealm;\n if (message.worldIdentity !== world.identity || message.frameId <= lastFrameId) return;\n currentSample = message.inputSample;\n const canvasWidth =\n Number.isFinite(message.canvasWidth) && message.canvasWidth > 0\n ? Math.max(1, Math.floor(message.canvasWidth))\n : undefined;\n const canvasHeight =\n Number.isFinite(message.canvasHeight) && message.canvasHeight > 0\n ? Math.max(1, Math.floor(message.canvasHeight))\n : undefined;\n if (canvasWidth !== undefined && canvasHeight !== undefined) {\n if (engineCanvas !== undefined) {\n if (engineCanvas.width !== canvasWidth) engineCanvas.width = canvasWidth;\n if (engineCanvas.height !== canvasHeight) engineCanvas.height = canvasHeight;\n }\n syncCameraAspect(world, canvasWidth, canvasHeight);\n }\n const started = performance.now();\n try {\n const update = world.update(message.deltaSeconds);\n if (!update.ok) throw update.error;\n if (world.execution.health === 'poisoned') {\n const fault = world.execution.fault;\n postFault(\n 'world',\n fault?.code ?? 'world-poisoned',\n 'World remains healthy through update',\n 'rebuild the poisoned World explicitly',\n fault,\n fault?.partialWrite ?? true,\n );\n return;\n }\n const updateFinished = performance.now();\n const draw = renderer.draw([world], { cameraOwner: 0, resourceOwner: 0 });\n if (draw !== undefined && !draw.ok) throw draw.error;\n lastFrameId = message.frameId;\n const kernelDispatch = activeRealm.kernelPool?.takeLastDispatch() ?? null;\n const audioIntents = activeRealm.pendingAudioIntents;\n activeRealm.pendingAudioIntents = [];\n scope.postMessage({\n kind: 'frame-complete',\n worldIdentity: world.identity,\n frameId: message.frameId,\n engineUpdateMs: updateFinished - started,\n kernelWaitMs: kernelDispatch?.waitMs ?? 0,\n ...(audioIntents.length > 0 ? { audioIntents } : {}),\n ...(kernelDispatch !== null\n ? {\n kernelDispatch: {\n eligible: true,\n usedShared: kernelDispatch.mode === 'shared',\n reason:\n kernelDispatch.mode === 'shared' ? ('shared' as const) : ('forced-inline' as const),\n dispatched: kernelDispatch.dispatched,\n completed: kernelDispatch.completed,\n },\n }\n : {}),\n });\n } catch (cause) {\n const fault = world.execution.fault;\n postFault(\n fault === null ? 'runtime' : 'world',\n fault?.code ?? 'app-system-update-failed',\n 'World update completes before Renderer draw',\n fault === null ? 'inspect the runtime cause' : 'rebuild the poisoned World explicitly',\n cause,\n fault?.partialWrite ?? false,\n );\n }\n}\n\nasync function rebuild(message: ExecutionRebuildMessage): Promise<void> {\n const activeRealm = realm;\n if (\n activeRealm === undefined ||\n renderer === undefined ||\n message.worldIdentity !== activeRealm.world.identity\n )\n return;\n const previousWorldIdentity = activeRealm.world.identity;\n try {\n if (engineCanvas === undefined) return;\n const init: ExecutionInitMessage = { ...activeRealm.init, canvas: engineCanvas };\n if (!(await createRealm(init))) return;\n scope.postMessage({\n kind: 'rebuilt',\n previousWorldIdentity,\n worldIdentity: realm?.world.identity ?? '',\n });\n } catch (cause) {\n postFault(\n 'rebuild',\n 'app-execution-rebuild-failed',\n 'bootstrap creates a fresh World identity',\n 'inspect the bootstrap cause or create a new App',\n cause,\n );\n }\n}\n\nscope.onmessage = (event): void => {\n const message = event.data;\n if (message.kind === 'init') void initialize(message);\n else if (message.kind === 'frame') runFrame(message);\n else if (message.kind === 'rebuild') {\n void rebuildQueue.enqueue(() => rebuild(message));\n } else if (message.kind === 'dispose') {\n void (async () => {\n if (realm !== undefined) {\n await disposeRealm(realm);\n realm = undefined;\n }\n scope.close();\n })();\n }\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/animation-asset-lookup.ts","../src/canvas-policy.ts","../src/input-plugin.ts","../src/renderer-plugin.ts","../src/internal/assets-world-plugin.ts","../src/internal/worker-engine-profile.ts","../src/execution/attached-world-swap.ts","../src/errors.ts","../src/execution/bootstrap-entry.ts","../src/execution/kernel-pool.ts","../src/execution/engine-worker-runtime.ts"],"names":["renderer","assets","status"],"mappings":";;;;;;;;;;;;;;AAQO,SAAS,6BACd,MAAA,EACwB;AACxB,EAAA,OAAO,CAAC,IAAA,KAAS,MAAA,EAAQ,MAAA,CAAsB,IAAI,CAAA;AACrD;ACRO,SAAS,gBAAA,CAAiB,KAAA,EAAc,OAAA,EAAiB,OAAA,EAAuB;AACrF,EAAA,IAAI,OAAA,IAAW,CAAA,IAAK,OAAA,IAAW,CAAA,EAAG;AAClC,EAAA,MAAM,SAAS,OAAA,GAAU,OAAA;AACzB,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,KAAA,CAAM,EAAE,IAAA,EAAM,CAAC,MAAM,CAAA,EAAG,CAAA,CAAE,MAAA,EAAO;AACrD,EAAA,KAAA,MAAW,OAAO,KAAA,EAAO;AACvB,IAAA,MAAM,MAAA,GAAS,KAAA,CAAM,GAAA,CAAI,GAAA,CAAI,QAAQ,MAAM,CAAA;AAC3C,IAAA,IAAI,CAAC,OAAO,EAAA,EAAI;AAChB,IAAA,IAAI,MAAA,CAAO,KAAA,CAAM,UAAA,KAAe,IAAA,EAAM;AACtC,IAAA,IAAI,MAAA,CAAO,KAAA,CAAM,UAAA,KAAe,6BAAA,EAA+B;AAC/D,IAAA,KAAA,CAAM,IAAI,GAAA,CAAI,MAAA,EAAQ,MAAA,EAAQ,EAAE,QAAQ,CAAA;AAAA,EAC1C;AACF;ACVO,SAAS,WAAA,GAAsB;AACpC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,MAAA,EAAQ,CAAC,OAAA,EAAS,OAAO,CAAA;AAA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AAA,OAAA,IAC3C,OAAA,CAAQ,IAAA,KAAS,OAAA,EAAS,QAAA,CAAS,OAAO,CAAA;AAAA,OAAA,IAC1C,OAAA,CAAQ,SAAS,SAAA,EAAW;AACnC,IAAA,KAAK,YAAA,CAAa,OAAA,CAAQ,MAAM,OAAA,CAAQ,OAAO,CAAC,CAAA;AAAA,EAClD,CAAA,MAAA,IAAW,OAAA,CAAQ,IAAA,KAAS,SAAA,EAAW;AACrC,IAAA,KAAA,CAAM,YAAY;AAChB,MAAA,IAAI,UAAU,MAAA,EAAW;AACvB,QAAA,MAAM,aAAa,KAAK,CAAA;AACxB,QAAA,KAAA,GAAQ,MAAA;AAAA,MACV;AACA,MAAA,KAAA,CAAM,KAAA,EAAM;AAAA,IACd,CAAA,GAAG;AAAA,EACL;AACF,CAAA","file":"engine-worker-runtime.mjs","sourcesContent":["import type { AnimationPayloadLookup } from '@forgeax/engine-animation';\nimport type { AnimationClip } from '@forgeax/engine-types';\n\nexport interface AnimationPayloadSource {\n lookup<T = unknown>(guid: string): T | undefined;\n}\n\n/** Bridge the renderer-owned GUID catalogue into the animation plugin. */\nexport function createAnimationPayloadLookup(\n source: AnimationPayloadSource | undefined,\n): AnimationPayloadLookup {\n return (guid) => source?.lookup<AnimationClip>(guid);\n}\n","import type { World } from '@forgeax/engine-ecs';\nimport { CAMERA_PROJECTION_PERSPECTIVE, Camera } from '@forgeax/engine-render';\n\n/** Keep host-owned perspective camera aspect policy in one execution-tier seam. */\nexport function syncCameraAspect(world: World, canvasW: number, canvasH: number): void {\n if (canvasW <= 0 || canvasH <= 0) return;\n const aspect = canvasW / canvasH;\n const query = world.query({ with: [Camera] }).unwrap();\n for (const row of query) {\n const camera = world.get(row.entity, Camera);\n if (!camera.ok) continue;\n if (camera.value.autoAspect !== true) continue;\n if (camera.value.projection !== CAMERA_PROJECTION_PERSPECTIVE) continue;\n world.set(row.entity, Camera, { aspect });\n }\n}\n","import { Update } from '@forgeax/engine-ecs';\nimport { INPUT_BACKEND_KEY, InputFrameStartScan, InputSet } from '@forgeax/engine-input';\nimport type { Plugin } from '@forgeax/engine-plugin';\n\n/** Project one Host-owned input provider into reversible World contributions. */\nexport function inputPlugin(): Plugin {\n return {\n name: 'input',\n inject: ['world', 'input'],\n apply(ctx) {\n const world = ctx.world;\n const input = ctx.input;\n if (input === undefined) throw new Error('Cordis activated input without its provider');\n ctx.effect(() => {\n world.insertResource(INPUT_BACKEND_KEY, input);\n return () => {\n world.removeResource(INPUT_BACKEND_KEY);\n };\n }, 'input/resource');\n ctx.effect(() => {\n world.addSystems(Update, InputSet, [InputFrameStartScan]).unwrap();\n return () => world.removeSystem(Update, InputFrameStartScan.name);\n }, 'input/frame-start-scan');\n },\n };\n}\n","import type { Plugin } from '@forgeax/engine-plugin';\nimport type { RenderError, Renderer, RenderFeature, RenderResult } from '@forgeax/engine-render';\nimport type { RendererFeatureAssemblyHost } from '@forgeax/engine-render/internal/construct-renderer';\n\nexport interface RenderFeatureHost {\n installFeature(\n feature: RenderFeature<unknown>,\n ): Promise<RenderResult<RenderFeatureLease, RenderError>>;\n}\n\nexport interface RenderFeatureLease {\n release(): Promise<RenderResult<void, RenderError>>;\n}\n\nexport function createRenderFeatureHost(host: RendererFeatureAssemblyHost): RenderFeatureHost {\n return {\n async installFeature(feature) {\n const installed = await host.installRenderFeature(feature);\n if (!installed.ok) return installed;\n let released = false;\n return {\n ok: true,\n value: {\n release: async () => {\n if (released) return { ok: true, value: undefined };\n released = true;\n return host.uninstallRenderFeature(feature);\n },\n },\n };\n },\n };\n}\n\ndeclare module '@forgeax/engine-plugin' {\n interface EngineContextServices {\n renderer?: Renderer;\n renderFeatureHost?: RenderFeatureHost;\n }\n}\n\n/** Provide the renderer without transferring its host-owned lifetime. */\nexport function rendererPlugin(renderer: Renderer): Plugin {\n return {\n name: 'renderer',\n provide: 'renderer',\n apply(ctx) {\n ctx.provide('renderer', renderer);\n },\n };\n}\n\n/** Provide an App/Worker-owned Renderer and release it after dependent Fibers. */\nexport function ownedRendererPlugin(renderer: Renderer): Plugin {\n return {\n name: 'renderer',\n provide: 'renderer',\n apply(ctx) {\n ctx.provide('renderer', renderer);\n ctx.effect(() => () => renderer.dispose(), 'render/renderer');\n },\n };\n}\n\n/** Provide the App-owned late RenderFeature assembly capability. */\nexport function renderFeatureHostPlugin(host: RenderFeatureHost): Plugin {\n return {\n name: 'render-feature-host',\n provide: 'renderFeatureHost',\n apply(ctx) {\n ctx.provide('renderFeatureHost', host);\n },\n };\n}\n\n/** Install a producer feature under the same Cordis Fiber that owns the caller. */\nexport function renderFeaturePlugin(feature: RenderFeature<unknown>): Plugin {\n return {\n name: `render-feature:${feature.identity}`,\n inject: ['renderFeatureHost'],\n async apply(ctx) {\n if (ctx.renderFeatureHost === undefined) {\n throw new Error('render-feature host capability is unavailable in this App realm');\n }\n const installed = await ctx.renderFeatureHost.installFeature(feature);\n if (!installed.ok) throw installed.error;\n ctx.effect(\n () => async () => {\n const removed = await installed.value.release();\n if (!removed.ok) throw removed.error;\n },\n `render-feature/${feature.identity}`,\n );\n },\n };\n}\n","import type { AssetRegistry } from '@forgeax/engine-assets-runtime';\nimport type { Plugin } from '@forgeax/engine-plugin';\n\nconst ASSET_REGISTRY_RESOURCE_KEY = 'AssetRegistry' as const;\n\n/** Project the Renderer-owned AssetRegistry as a declared dependent service. */\nexport function rendererAssetsPlugin(assets: AssetRegistry | undefined): Plugin {\n return {\n name: 'renderer-assets',\n inject: ['renderer'],\n provide: 'assets',\n apply(ctx) {\n if (assets !== undefined) ctx.provide('assets', assets);\n },\n };\n}\n\n/** Project the realm AssetRegistry into legacy World resource lookup reversibly. */\nexport function assetsWorldPlugin(): Plugin {\n return {\n name: 'assets-world',\n inject: ['world', 'assets'],\n apply(ctx) {\n if (ctx.assets === undefined) return;\n ctx.effect(() => {\n ctx.world.insertResource(ASSET_REGISTRY_RESOURCE_KEY, ctx.assets);\n return () => {\n ctx.world.removeResource(ASSET_REGISTRY_RESOURCE_KEY);\n };\n }, 'assets/world-resource');\n },\n };\n}\n","import {\n type AnimationPayloadLookup,\n animationPayloadsPlugin,\n animationRuntimePlugin,\n} from '@forgeax/engine-animation';\nimport { type AudioBackend, audioBackendPlugin } from '@forgeax/engine-audio';\nimport { type InputBackend, inputBackendPlugin } from '@forgeax/engine-input';\nimport type { Plugin } from '@forgeax/engine-plugin';\nimport { renderComponentsPlugin } from '@forgeax/engine-render';\nimport { scenePlugin } from '@forgeax/engine-scene';\nimport { statePlugin } from '@forgeax/engine-state';\nimport { inputPlugin } from '../input-plugin';\nimport {\n ownedRendererPlugin,\n type RenderFeatureHost,\n renderFeatureHostPlugin,\n} from '../renderer-plugin';\nimport { assetsWorldPlugin, rendererAssetsPlugin } from './assets-world-plugin';\nimport type { EngineProfileBase } from './engine-profile-common';\n\nexport interface WorkerEngineProfileOptions extends EngineProfileBase {\n readonly animationPayloads: AnimationPayloadLookup;\n readonly input: InputBackend;\n readonly audio: AudioBackend;\n readonly rendererFeatureHost?: RenderFeatureHost;\n}\n\n/** Static Engine Worker selection; Host-only acquisition stays outside this realm. */\nexport function workerEngineProfile(options: WorkerEngineProfileOptions): Plugin[] {\n return [\n ownedRendererPlugin(options.renderer),\n renderComponentsPlugin(),\n ...(options.rendererFeatureHost === undefined\n ? []\n : [renderFeatureHostPlugin(options.rendererFeatureHost)]),\n rendererAssetsPlugin(options.assets),\n assetsWorldPlugin(),\n inputBackendPlugin(options.input),\n audioBackendPlugin(options.audio),\n scenePlugin(),\n animationPayloadsPlugin(options.animationPayloads),\n animationRuntimePlugin(),\n statePlugin(),\n inputPlugin(),\n ...(options.extensions ?? []),\n ];\n}\n","import type { World } from '@forgeax/engine-ecs';\nimport type { Renderer } from '@forgeax/engine-render';\n\n/** Serialize realm rebuilds so candidate Worlds never overlap ownership. */\nexport class SerializedRebuildQueue {\n private tail: Promise<void> = Promise.resolve();\n\n enqueue(action: () => Promise<void>): Promise<void> {\n const current = this.tail.then(action, action);\n this.tail = current.catch(() => undefined);\n return current;\n }\n}\n\n/** Transactionally replace one Renderer-attached World. */\nexport async function commitAttachedWorld(\n renderer: Pick<Renderer, 'attach'>,\n nextWorld: World,\n initializeCandidate: () => Promise<boolean>,\n): Promise<boolean> {\n const attached = renderer.attach(nextWorld);\n if (!attached.ok) throw attached.error;\n try {\n if (!(await initializeCandidate())) {\n attached.value.dispose();\n return false;\n }\n } catch (cause) {\n attached.value.dispose();\n throw cause;\n }\n return true;\n}\n","// @forgeax/engine-app -- AppError + closed AppErrorCode union (12 members) +\n// APP_ERROR_HINTS / APP_EXPECTED + discriminated AppErrorDetail per code.\n//\n// Shape:\n// - AppErrorCode = closed union 12 members (charter P4 closed-union\n// exhaustive switch needs no default fallback; tsc strict mode guards\n// completeness; AGENTS.md \"Errors are structured\" + AC-07).\n// Members:\n// - 'app-not-started'\n// - 'app-already-running'\n// - 'app-canvas-detached'\n// - 'app-system-update-failed'\n// - 'app-pointer-lock-failed'\n// Plan-strategy D-3 lock: device-lost stays on RhiErrorCode (18-member\n// union); the AppError surface does NOT add a seventh 'app-device-lost'\n// member. Host onError listener receives RhiError({code:'device-lost'})\n// verbatim through the fan-out.\n//\n// - AppError class = 4-field surface (.code / .expected / .hint /\n// .detail) byte-for-byte parallel to RhiError (packages/rhi/src/errors.ts).\n// The class extends Error so debug surfaces (stack, name) work in host\n// environments; AI users walk .code / .detail by property access (charter\n// P3 explicit failure: never parse the message string).\n//\n// - AppError is exposed as a discriminated union (variant per code) so AI\n// users get .detail narrowing for free after `if (err.code === '...')`:\n//\n// if (err.code === 'app-canvas-detached') {\n// console.warn('reattach canvas', err.detail.canvasId);\n// }\n//\n// Constructor accepts a generic args object and infers the variant from\n// the literal `code` argument; `detail` must satisfy the per-code\n// payload (`AppErrorDetailFor<C>`). Callers therefore cannot supply\n// non-canonical fields like `{ state: 'running' }` on the\n// 'app-already-running' arm.\n//\n// - APP_ERROR_HINTS / APP_EXPECTED are 12-key Records keyed by AppErrorCode;\n// one private policy owner supplies both projections. The focused policy-owner\n// proof asserts that every code has the exact expected and hint strings.\n//\n// Related: requirements AC-07 / AC-04 / AC-09; plan-strategy section 2 D-3\n// (6-member lock) + D-4 ('app-system-update-failed' detail = { cause,\n// systemName? }) + D-6 (dual-layer instanceof + switch consumption form);\n// research section 2.7 (AppErrorCode lands in AGENTS.md Error model table\n// alongside RhiErrorCode et al.); charter P3 (explicit failure) + P4\n// (closed-union exhaustive switch).\n\nimport type { RhiError } from '@forgeax/engine-rhi/errors';\nimport type { ExecutionCapabilityName, ExecutionTier } from './execution/types';\n\n/**\n * Closed AppErrorCode union (12 members).\n *\n * | code | trigger |\n * |:--|:--|\n * | `'app-not-started'` | `stop()` / `pause()` / `resume()` invoked while the rAF loop is in the terminal `'idle'` or `'stopped'` state (post-device-lost terminal sink). The handle has no live frame to interrupt; AI users either call `start()` first or accept that this handle is dead and rebuild via `createApp({...})`. |\n * | `'app-already-running'` | second `start()` invocation against an already-running handle; the call is a no-op state-machine-wise (state preserved). |\n * | `'app-canvas-detached'` | `createApp(canvas)` thin wrapper found `canvas.isConnected === false` at entry. Detail carries optional `canvasId` so the host can surface the offending canvas in a multi-canvas page (D-2 minor). |\n * | `'app-system-update-failed'` | World update, renderer draw, or a frame-loop callback failed; the original failure value is forwarded on `detail.cause`. `detail.systemName` is optional when the call site can name the failing owner. |\n * | `'app-pointer-lock-failed'` | `attachInputAuto`'s `onLockError` callback received a lock failure from the input backend. `detail.path` carries `'w3c'` (W3C `requestPointerLock` rejection) or `'provider'` (host-injected `lockProvider.requestLock` throw/reject). `detail.cause` carries the original rejection value verbatim. The host recovers by remaining in unlocked state; the next trusted click will retry the lock request. |\n *\n * Plan-strategy D-4 locked the count at 6; device-lost rides RhiErrorCode.\n */\nexport type AppErrorCode = keyof typeof appErrorPolicy;\n\n/**\n * Detail variant for the `'app-canvas-detached'` arm.\n *\n * `canvasId` carries an optional identifier the host can surface to AI\n * users when multiple canvases live on the page (e.g. preview vs live\n * canvas). `undefined` when the host did not assign an id.\n */\nexport interface AppDetailCanvasDetached {\n readonly canvasId?: string | undefined;\n}\n\n/**\n * Detail variant for the `'app-system-update-failed'` arm (plan-strategy D-4).\n *\n * `cause` carries the original thrown value verbatim so AI users can\n * `cause instanceof EcsError` / `cause instanceof RhiError` narrow without\n * losing structure. `systemName` is populated when the call site can name\n * the offending system (input-attach cleanup path forwards\n * `FRAME_START_SCAN_SYSTEM_NAME`).\n */\nexport interface AppDetailSystemUpdateFailed {\n readonly cause: unknown;\n readonly systemName?: string | undefined;\n}\n\n/**\n * Detail variant for the `'app-pointer-lock-failed'` arm (plan-strategy D-4).\n *\n * `path` discriminates between W3C `requestPointerLock` rejections (`'w3c'`)\n * and host-injected `lockProvider.requestLock` throw/reject (`'provider'`).\n * `cause` carries the original rejection value verbatim so AI users can\n * narrow further (e.g. `cause instanceof DOMException` for W3C timeout\n * rejections).\n */\nexport interface AppDetailPointerLockFailed {\n readonly path: 'w3c' | 'provider';\n readonly cause: unknown;\n}\n\n/** Why a host-requested deterministic frame could not run. */\nexport interface AppDetailFrameStepInvalid {\n readonly state: 'idle' | 'running' | 'paused' | 'stopped';\n readonly deltaSeconds: number;\n readonly reason: 'state' | 'delta';\n}\n\nexport interface AppDetailExecutionTierUnavailable {\n readonly requestedTier: ExecutionTier;\n readonly missingCapabilities: readonly ExecutionCapabilityName[];\n readonly sharedEvidencePassed: boolean;\n}\n\nexport interface AppDetailExecutionBootstrapFailed {\n readonly phase: 'import' | 'export' | 'prepare' | 'bootstrap' | 'data';\n readonly moduleUrl: string;\n readonly cause: unknown;\n}\n\n/** Original startup failure thrown by a Cordis plugin fiber. */\nexport interface AppDetailPluginActivationFailed {\n readonly cause: unknown;\n}\n\nexport interface AppDetailExecutionDeadlineExceeded {\n readonly phase: 'startup' | 'handshake' | 'frame';\n readonly timeoutMs: number;\n}\n\nexport interface AppDetailExecutionKernelFailed {\n readonly kernelName: string;\n readonly worldIdentity: string;\n readonly cause: unknown;\n readonly partialWrite: true;\n readonly retryable: false;\n}\n\nexport interface AppDetailExecutionStaleWorld {\n readonly expectedIdentity: string;\n readonly receivedIdentity: string;\n readonly messageKind: string;\n}\n\nexport interface AppDetailExecutionRebuildFailed {\n readonly worldIdentity: string | null;\n readonly cause: unknown;\n}\n\n/**\n * Empty-detail shape for the 2 codes that carry no payload\n * (`'app-not-started'`, `'app-already-running'`).\n *\n * Modelled as `Readonly<Record<string, never>>` so literal builders use\n * `{}` while still narrowing under tsc strict (no extra property allowed).\n */\nexport type AppDetailEmpty = Readonly<Record<string, never>>;\n\n/**\n * Conditional resolver from `AppErrorCode` to its detail payload type.\n *\n * Used by the constructor signature so `new AppError({ code: 'X', ... })`\n * narrows the `detail` parameter to the variant payload at compile time.\n */\nexport type AppErrorDetailFor<C extends AppErrorCode> = C extends 'app-canvas-detached'\n ? AppDetailCanvasDetached\n : C extends 'app-frame-step-invalid'\n ? AppDetailFrameStepInvalid\n : C extends 'app-system-update-failed'\n ? AppDetailSystemUpdateFailed\n : C extends 'app-pointer-lock-failed'\n ? AppDetailPointerLockFailed\n : C extends 'app-plugin-activation-failed'\n ? AppDetailPluginActivationFailed\n : C extends 'app-execution-tier-unavailable'\n ? AppDetailExecutionTierUnavailable\n : C extends 'app-execution-bootstrap-failed'\n ? AppDetailExecutionBootstrapFailed\n : C extends 'app-execution-deadline-exceeded'\n ? AppDetailExecutionDeadlineExceeded\n : C extends 'app-execution-kernel-failed'\n ? AppDetailExecutionKernelFailed\n : C extends 'app-execution-stale-world'\n ? AppDetailExecutionStaleWorld\n : C extends 'app-execution-rebuild-failed'\n ? AppDetailExecutionRebuildFailed\n : AppDetailEmpty;\n\n/**\n * Tagged union of `.detail` payloads carried by structured AppError.\n *\n * Each variant maps to its `AppErrorCode` arm via `AppErrorDetailFor<C>`;\n * the variants are unique by structural fields (`AppDetailCanvasDetached`\n * has `canvasId`, `AppDetailSystemUpdateFailed` has `cause`, the empty\n * shape has neither).\n */\nexport type AppErrorDetail = AppErrorDetailFor<AppErrorCode>;\n\n/**\n * Render a one-line summary of `detail.cause` for embedding in\n * `AppError.message`. `cause` is structurally typed (`unknown`) because\n * upstream may throw any value; callers downstream still get the verbatim\n * value via `err.detail.cause` — this helper exists so tools that only see\n * `err.message` (`console.error(err)`, raw stringification) still surface\n * the root cause without consumers manually expanding `detail`.\n *\n * Closed precedence:\n * 1. Structured engine errors (RhiError / EcsError / RenderGraphError /\n * AssetError / ShaderError / ...) carry `.code` + `.message`; render\n * `<Name> <code>: <message>`.\n * 2. Plain `Error`: render `<name>: <message>`.\n * 3. Anything else: `String(cause)` (covers thrown strings, numbers, null).\n *\n * Newlines are replaced with `' / '` so the final AppError message stays a\n * single line (callers already split on `\\n` in stack traces, so a multiline\n * message would corrupt their parsing).\n */\nfunction summarizeCause(cause: unknown): string {\n if (cause === null || cause === undefined) return String(cause);\n if (typeof cause !== 'object') return String(cause);\n const r = cause as { name?: unknown; message?: unknown; code?: unknown };\n const name = typeof r.name === 'string' && r.name.length > 0 ? r.name : 'Error';\n const code = typeof r.code === 'string' && r.code.length > 0 ? r.code : '';\n const message = typeof r.message === 'string' ? r.message : '';\n const head = code !== '' ? `${name} ${code}` : name;\n const body = message !== '' ? `: ${message}` : '';\n return `${head}${body}`.replace(/\\s*\\n+\\s*/g, ' / ');\n}\n\nclass AppErrorClass extends Error {\n readonly code: AppErrorCode;\n readonly expected: string;\n readonly hint: string;\n readonly detail: AppErrorDetail;\n\n constructor(args: {\n code: AppErrorCode;\n expected: string;\n hint: string;\n detail: AppErrorDetail;\n }) {\n // Surface `detail.cause` directly inside `.message` for the\n // `'app-system-update-failed'` arm. Without this, a generic\n // `console.error(err)` shows only the wrapper expected/hint and\n // hides the actual EcsError / RhiError / host-system Error that\n // tripped the frame loop. The verbatim `cause` value remains on\n // `err.detail.cause` for two-level-narrow consumers (charter P3).\n let causeSuffix = '';\n if (args.code === 'app-system-update-failed') {\n const d = args.detail as AppDetailSystemUpdateFailed;\n const sys =\n typeof d.systemName === 'string' && d.systemName.length > 0\n ? ` (system=${d.systemName})`\n : '';\n causeSuffix = `; cause: ${summarizeCause(d.cause)}${sys}`;\n } else if (args.code === 'app-pointer-lock-failed') {\n const d = args.detail as AppDetailPointerLockFailed;\n causeSuffix = `; path: ${d.path}; cause: ${summarizeCause(d.cause)}`;\n } else if (args.code === 'app-plugin-activation-failed') {\n const d = args.detail as AppDetailPluginActivationFailed;\n causeSuffix = `; cause: ${summarizeCause(d.cause)}`;\n } else if (args.code === 'app-execution-bootstrap-failed') {\n const d = args.detail as AppDetailExecutionBootstrapFailed;\n causeSuffix = `; phase: ${d.phase}; cause: ${summarizeCause(d.cause)}`;\n } else if (args.code === 'app-execution-kernel-failed') {\n const d = args.detail as AppDetailExecutionKernelFailed;\n causeSuffix = `; kernel: ${d.kernelName}; cause: ${summarizeCause(d.cause)}`;\n } else if (args.code === 'app-execution-rebuild-failed') {\n const d = args.detail as AppDetailExecutionRebuildFailed;\n causeSuffix = `; cause: ${summarizeCause(d.cause)}`;\n }\n super(`[AppError ${args.code}] expected: ${args.expected}; hint: ${args.hint}${causeSuffix}`);\n this.name = 'AppError';\n this.code = args.code;\n this.expected = args.expected;\n this.hint = args.hint;\n this.detail = args.detail;\n }\n}\n\n/**\n * Variant intersection: an `AppErrorClass` instance whose `code` literal\n * narrows to `C` and whose `detail` narrows to `AppErrorDetailFor<C>`. The\n * shape lets `if (err.code === 'X')` simultaneously narrow `err.detail` to\n * the per-code payload (charter P3 + AC-07 discriminated union).\n */\ntype AppErrorVariant<C extends AppErrorCode> = AppErrorClass & {\n readonly code: C;\n readonly detail: AppErrorDetailFor<C>;\n};\n\n/**\n * Public AppError type — discriminated union of the policy variants.\n *\n * AI-user form (charter P3 explicit failure):\n *\n * ```ts\n * function recover(err: AppError): string {\n * switch (err.code) {\n * case 'app-not-started': return 'call start() first';\n * case 'app-already-running': return 'state preserved; ignore';\n * case 'app-canvas-detached': return `reattach ${err.detail.canvasId ?? 'canvas'}`;\n * case 'app-system-update-failed':\n * return err.detail.cause instanceof Error ? err.detail.cause.message : 'unknown';\n * case 'app-pointer-lock-failed':\n * return `lock failed (${err.detail.path}): ${err.detail.cause}`;\n * }\n * }\n * ```\n */\nexport type AppError = {\n [C in AppErrorCode]: AppErrorVariant<C>;\n}[AppErrorCode];\n\ninterface AppErrorConstructor {\n new <C extends AppErrorCode>(args: {\n code: C;\n expected: string;\n hint: string;\n detail: AppErrorDetailFor<C>;\n }): AppErrorVariant<C>;\n readonly prototype: AppErrorClass;\n}\n\n/**\n * AppError constructor — `new AppError({ code, expected, hint, detail })`.\n *\n * The generic `C` is inferred from the literal `code` argument, which\n * narrows `detail` to the per-code payload (`AppErrorDetailFor<C>`) and\n * narrows the return type to the corresponding `AppErrorVariant<C>` so the\n * call site walks the discriminated union without manual cast.\n *\n * The constructor delegates to the `AppErrorClass` runtime; the typed-cast\n * here is the ergonomic affordance for AI users (TS class declarations\n * cannot directly express `<C> ... AppErrorVariant<C>` polymorphism).\n */\nexport const AppError: AppErrorConstructor = AppErrorClass as unknown as AppErrorConstructor;\n\n/**\n * `expected` table — the engine-side invariant that was violated when each\n * code surfaces. AI users read this as the L2 detail (charter F2 priority\n * text); `.hint` carries the recovery action.\n *\n * 12 keys; the focused policy-owner proof locks the exact key set and values.\n * locks the count and non-emptiness of every entry.\n */\ntype AppErrorPolicy = { readonly expected: string; readonly hint: string };\n\nconst appErrorPolicy = {\n 'app-not-started': {\n expected:\n 'state must be \"running\" or \"paused\" to accept stop/pause/resume; \"idle\" / \"stopped\" terminal sinks reject',\n hint: 'check getState() before calling stop/pause/resume; rebuild the handle via createApp({...}) when the previous one terminated on device-lost',\n },\n 'app-already-running': {\n expected:\n 'state must be \"idle\" or \"paused\" to start; \"running\" handles ignore subsequent start() calls',\n hint: 'call stop() first or audit start() call sites; the second start() is a no-op so state is preserved',\n },\n 'app-canvas-detached': {\n expected: 'canvas.isConnected === true at createApp(canvas) entry',\n hint: 'append the canvas to the document tree before calling createApp(canvas), or use the assemble entry createApp({ renderer, world }) when the host already manages canvas lifetime',\n },\n 'app-frame-step-invalid': {\n expected:\n 'stepFrame(deltaSeconds) runs only while the App is paused and deltaSeconds is finite and non-negative',\n hint: 'pause the App before deterministic stepping and pass an explicit finite delta; resume after the bounded step sequence completes',\n },\n 'app-system-update-failed': {\n expected:\n 'world.update(world), renderer.draw(world), and frame-loop callbacks complete without failure',\n hint: 'inspect detail.cause for the original thrown value (EcsError / RhiError / host system bug); detail.systemName names the offending system when the call site can supply it',\n },\n 'app-pointer-lock-failed': {\n expected:\n 'pointer-lock request (W3C requestPointerLock or host lockProvider.requestLock) to succeed; failure signals the browser rejected the lock or the host provider threw',\n hint: 'remain in unlocked state; the next trusted click will automatically retry the lock request. inspect detail.path (\"w3c\" or \"provider\") and detail.cause to determine the root cause',\n },\n 'app-plugin-activation-failed': {\n expected: 'every requested Cordis plugin fiber reaches a stable active or pending state',\n hint: 'inspect detail.cause and the plugin fiber effects; repair the failing activation before creating the App again',\n },\n 'app-execution-tier-unavailable': {\n expected:\n 'the explicitly requested execution tier has every required observed capability and the shipped shared evidence gate',\n hint: 'inspect detail.missingCapabilities and detail.sharedEvidencePassed; use tier=\"auto\" only when an observed fallback is acceptable',\n },\n 'app-execution-bootstrap-failed': {\n expected:\n 'the bootstrap URL imports a module whose default export completes as an ExecutionBootstrapEntry in the selected Engine Realm',\n hint: 'inspect detail.phase, moduleUrl and cause; export one default ExecutionBootstrapEntry that creates only realm-local engine state',\n },\n 'app-execution-deadline-exceeded': {\n expected:\n 'the execution startup, handshake or frame completes within its configured bounded deadline',\n hint: 'inspect detail.phase and timeoutMs; the timed-out Worker has been terminated, so fix startup or frame work before creating a new App',\n },\n 'app-execution-kernel-failed': {\n expected:\n 'a shared kernel completes every dispatched shard without leaving a possibly partial World write',\n hint: 'do not retry or draw the poisoned World; inspect detail.kernelName and cause, then call app.execution.rebuild()',\n },\n 'app-execution-stale-world': {\n expected:\n 'every execution message targets the currently active World identity before it can write',\n hint: 'discard the late message and keep the current World; inspect expectedIdentity, receivedIdentity and messageKind',\n },\n 'app-execution-rebuild-failed': {\n expected:\n 'explicit rebuild disposes the poisoned World and bootstraps a fresh World identity in the surviving Engine Realm',\n hint: 'inspect detail.cause; this App remains stopped, so fix the bootstrap failure or create a new App explicitly',\n },\n} satisfies Record<string, AppErrorPolicy>;\n\nexport const APP_EXPECTED: Readonly<Record<AppErrorCode, string>> = Object.fromEntries(\n Object.entries(appErrorPolicy).map(([code, policy]) => [code, policy.expected]),\n) as Readonly<Record<AppErrorCode, string>>;\n\nexport const APP_ERROR_HINTS: Readonly<Record<AppErrorCode, string>> = Object.fromEntries(\n Object.entries(appErrorPolicy).map(([code, policy]) => [code, policy.hint]),\n) as Readonly<Record<AppErrorCode, string>>;\n\n/**\n * Type guard for narrowing `CanvasAppError`-compatible mixed signals to AppError.\n *\n * The fan-out signature is `(err: CanvasAppError) => void`; AI users\n * who want to handle only the AppError leg call `if (isAppError(err)) ...`\n * before walking `.code`. Reverse-compatible with `instanceof AppError`\n * (the class is exposed); the function form is provided as the\n * canonical idiom in JSDoc / README so AI users do not need to reason\n * about cross-realm `instanceof` quirks.\n *\n * The parameter accepts the complete App/RHI boundary union so callers can\n * narrow the error without casts.\n */\nexport function isAppError(err: AppError | RhiError): err is AppError {\n return err instanceof AppErrorClass;\n}\n","import type { Plugin } from '@forgeax/engine-plugin';\nimport type { RenderFeature } from '@forgeax/engine-render';\nimport { err, ok, type Result } from '@forgeax/engine-types';\nimport { APP_ERROR_HINTS, APP_EXPECTED, AppError, type AppError as AppErrorType } from '../errors';\nimport type { ExecutionBootstrapValue } from './types';\n\n/** Realm-local engine assembly returned by an execution bootstrap module. */\nexport interface PreparedExecutionBootstrap {\n /** Render features constructed in the realm that will own the Renderer. */\n readonly features?: readonly RenderFeature<unknown>[];\n /** Plugins constructed in the realm that will own the World. */\n readonly plugins?: readonly Plugin[];\n}\n\n/** Realm-local Host bridge available to execution bootstrap plugins. */\nexport interface ExecutionBootstrapHost {\n readonly port?: MessagePort;\n setPointerLockAllowed(allowed: boolean): void;\n}\n\ndeclare module '@forgeax/engine-plugin' {\n interface EngineContextServices {\n executionBootstrapHost: ExecutionBootstrapHost;\n }\n}\n\n/** Bind the optional Host transport to the same Fiber that owns bootstrap plugins. */\nexport function executionBootstrapHostPlugin(host: ExecutionBootstrapHost): Plugin {\n return {\n name: 'execution-bootstrap-host',\n provide: 'executionBootstrapHost',\n apply(ctx) {\n ctx.provide('executionBootstrapHost', host);\n if (host.port !== undefined) {\n ctx.effect(() => () => host.port?.close(), 'execution/bootstrap-port');\n }\n },\n };\n}\n\n/** Default export contract for `ExecutionOptions.bootstrap`. */\nexport type ExecutionBootstrapEntry = (\n data: ExecutionBootstrapValue | undefined,\n) => PreparedExecutionBootstrap | Promise<PreparedExecutionBootstrap>;\n\nfunction bootstrapError(\n phase: 'import' | 'export' | 'prepare' | 'bootstrap' | 'data',\n moduleUrl: string,\n cause: unknown,\n): AppErrorType {\n return new AppError({\n code: 'app-execution-bootstrap-failed',\n expected: APP_EXPECTED['app-execution-bootstrap-failed'],\n hint: APP_ERROR_HINTS['app-execution-bootstrap-failed'],\n detail: { phase, moduleUrl, cause },\n });\n}\n\nexport function validateExecutionBootstrapData(\n data: ExecutionBootstrapValue | undefined,\n moduleUrl: string,\n): Result<void, AppErrorType> {\n if (data === undefined) return ok(undefined);\n try {\n structuredClone(data);\n return ok(undefined);\n } catch (cause) {\n return err(bootstrapError('data', moduleUrl, cause));\n }\n}\n\nexport async function loadBootstrapEntry(\n moduleUrl: string,\n): Promise<Result<ExecutionBootstrapEntry, AppErrorType>> {\n let loaded: unknown;\n try {\n loaded = await import(/* @vite-ignore */ moduleUrl);\n } catch (cause) {\n return err(bootstrapError('import', moduleUrl, cause));\n }\n const entry = (loaded as { default?: unknown }).default;\n if (typeof entry !== 'function') {\n return err(\n bootstrapError(\n 'export',\n moduleUrl,\n new TypeError('default export is not an ExecutionBootstrapEntry function'),\n ),\n );\n }\n return ok(entry as ExecutionBootstrapEntry);\n}\n\nexport async function prepareBootstrapEntry(\n moduleUrl: string,\n data: ExecutionBootstrapValue | undefined,\n): Promise<Result<PreparedExecutionBootstrap, AppErrorType>> {\n const valid = validateExecutionBootstrapData(data, moduleUrl);\n if (!valid.ok) return valid;\n const loaded = await loadBootstrapEntry(moduleUrl);\n if (!loaded.ok) return loaded;\n try {\n const prepared = await loaded.value(data);\n if (\n typeof prepared !== 'object' ||\n prepared === null ||\n (prepared.features !== undefined && !Array.isArray(prepared.features)) ||\n (prepared.plugins !== undefined && !Array.isArray(prepared.plugins))\n ) {\n return err(\n bootstrapError(\n 'prepare',\n moduleUrl,\n new TypeError('execution bootstrap must return an object with feature and plugin arrays'),\n ),\n );\n }\n return ok(prepared);\n } catch (cause) {\n return err(bootstrapError('prepare', moduleUrl, cause));\n }\n}\n","import type {\n KernelDispatchFailure,\n KernelDispatchResult,\n KernelDispatchSpan,\n SharedKernelDispatch,\n SharedKernelExecutor,\n SharedSpanBinding,\n} from '@forgeax/engine-ecs/shared';\nimport { bindSharedSpan, isSharedSpan, splitSharedSpan } from '@forgeax/engine-ecs/shared';\n\nexport interface KernelPool extends SharedKernelExecutor {\n readonly laneCount: number;\n ready(): Promise<void>;\n takeLastDispatch(): KernelDispatchResult | null;\n dispose(): void;\n}\n\ninterface KernelJobMessage {\n readonly kind: 'kernel-job';\n readonly moduleUrl: string;\n readonly binding: SharedSpanBinding;\n readonly control: Int32Array;\n readonly status: Int32Array;\n readonly jobIndex: number;\n}\n\ninterface KernelInitMessage {\n readonly kind: 'kernel-init';\n readonly ready: Int32Array;\n}\n\ninterface KernelPreloadMessage {\n readonly kind: 'kernel-preload';\n readonly moduleUrl: string;\n readonly control: Int32Array;\n readonly status: Int32Array;\n readonly jobIndex: number;\n}\n\ninterface KernelPreflight {\n readonly control: Int32Array;\n readonly status: Int32Array;\n}\n\nexport interface KernelPoolOptions {\n readonly lanes?: number;\n readonly timeoutMs?: number;\n readonly workerFactory?: () => Worker;\n}\n\nexport function createKernelPool(options: KernelPoolOptions = {}): KernelPool {\n const hardware = globalThis.navigator?.hardwareConcurrency ?? 2;\n const laneCount = Math.max(1, Math.min(options.lanes ?? hardware - 1, 8));\n const timeoutMs = options.timeoutMs ?? 5_000;\n const workers = Array.from(\n { length: laneCount },\n () =>\n options.workerFactory?.() ??\n new Worker(new URL('./kernel-worker-runtime.mjs', import.meta.url), {\n type: 'module',\n name: 'forgeax-kernel',\n }),\n );\n let latest: KernelDispatchResult | null = null;\n let ready = false;\n const preflights = new Map<string, KernelPreflight>();\n const readyControl = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));\n const initMessage: KernelInitMessage = { kind: 'kernel-init', ready: readyControl };\n for (const worker of workers) worker.postMessage(initMessage);\n const waitFor = (control: Int32Array, expected: number, label: string): Promise<void> =>\n new Promise<void>((resolve, reject) => {\n const started = performance.now();\n const poll = (): void => {\n if (Atomics.load(control, 0) === expected) {\n resolve();\n return;\n }\n if (performance.now() - started >= timeoutMs) {\n for (const worker of workers) worker.terminate();\n reject(new Error(`${label} did not complete within ${timeoutMs}ms.`));\n return;\n }\n setTimeout(poll, 1);\n };\n poll();\n });\n\n const readyPromise = waitFor(\n readyControl,\n workers.length,\n 'SharedKernel worker initialization',\n ).then(async () => {\n for (const [moduleUrl, preflight] of preflights) {\n await waitFor(\n preflight.control,\n workers.length,\n `SharedKernel module preflight for ${moduleUrl}`,\n );\n if (preflight.status.some((status) => status !== 1)) {\n throw new Error(`SharedKernel module preflight failed for ${moduleUrl}.`);\n }\n }\n ready = true;\n });\n\n return {\n laneCount,\n ready: () => readyPromise,\n warmup(kernel): void {\n if (preflights.has(kernel.moduleUrl)) return;\n const control = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));\n const status = new Int32Array(\n new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * workers.length),\n );\n preflights.set(kernel.moduleUrl, { control, status });\n for (const [jobIndex, worker] of workers.entries()) {\n const message: KernelPreloadMessage = {\n kind: 'kernel-preload',\n moduleUrl: kernel.moduleUrl,\n control,\n status,\n jobIndex,\n };\n worker.postMessage(message);\n }\n },\n takeLastDispatch: () => {\n const dispatch = latest;\n latest = null;\n return dispatch;\n },\n execute(\n kernel: SharedKernelDispatch,\n spans: readonly KernelDispatchSpan[],\n ): KernelDispatchResult | KernelDispatchFailure {\n const preflight = preflights.get(kernel.moduleUrl);\n if (preflight === undefined) {\n this.warmup?.(kernel);\n latest = { mode: 'forced-inline', dispatched: 0, completed: 0, waitMs: 0 };\n return {\n cause: new Error('SharedKernel module was not preflighted before frame dispatch.'),\n dispatched: 0,\n completed: 0,\n partialWrite: false,\n };\n }\n if (\n Atomics.load(preflight.control, 0) !== workers.length ||\n preflight.status.some((status) => status !== 1)\n ) {\n latest = { mode: 'forced-inline', dispatched: 0, completed: 0, waitMs: 0 };\n return {\n cause: new Error('SharedKernel module preflight is incomplete or failed.'),\n dispatched: 0,\n completed: 0,\n partialWrite: false,\n };\n }\n if (!ready && Atomics.load(readyControl, 0) === workers.length) ready = true;\n if (!ready) {\n latest = { mode: 'forced-inline', dispatched: 0, completed: 0, waitMs: 0 };\n return {\n cause: new Error('SharedKernel workers were not warmed before frame dispatch.'),\n dispatched: 0,\n completed: 0,\n partialWrite: false,\n };\n }\n const bindings = spans.flatMap(({ queryIndex, span }) =>\n splitSharedSpan(bindSharedSpan(kernel, span, queryIndex), laneCount),\n );\n if (bindings.length === 0) {\n latest = { mode: 'forced-inline', dispatched: 0, completed: 0, waitMs: 0 };\n return latest;\n }\n if (!bindings.every(isSharedSpan)) {\n latest = { mode: 'forced-inline', dispatched: 0, completed: 0, waitMs: 0 };\n return {\n cause: new Error('SharedKernel received a non-SAB QuerySpan.'),\n dispatched: 0,\n completed: 0,\n partialWrite: false,\n };\n }\n const control = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));\n const status = new Int32Array(\n new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * bindings.length),\n );\n const started = performance.now();\n for (const [index, binding] of bindings.entries()) {\n const message: KernelJobMessage = {\n kind: 'kernel-job',\n moduleUrl: kernel.moduleUrl,\n binding,\n control,\n status,\n jobIndex: index,\n };\n workers[index % workers.length]?.postMessage(message);\n }\n while (Atomics.load(control, 0) < bindings.length) {\n const observed = Atomics.load(control, 0);\n const wait = Atomics.wait(control, 0, observed, timeoutMs);\n if (wait === 'timed-out') {\n for (const worker of workers) worker.terminate();\n return {\n cause: new Error(`SharedKernel deadline exceeded after ${timeoutMs}ms.`),\n dispatched: bindings.length,\n completed: observed,\n partialWrite: bindings.length > 0,\n };\n }\n }\n const completed = status.reduce((count, value) => count + (value === 1 ? 1 : 0), 0);\n const failed = status.some((value) => value === -1);\n if (failed) {\n return {\n cause: new Error('SharedKernel worker failed.'),\n dispatched: bindings.length,\n completed,\n partialWrite: bindings.length > 0,\n };\n }\n latest = {\n mode: 'shared',\n dispatched: bindings.length,\n completed,\n waitMs: performance.now() - started,\n };\n return latest;\n },\n dispose(): void {\n for (const worker of workers) worker.terminate();\n },\n };\n}\n","import { type AudioIntent, createAudioIntentBackend } from '@forgeax/engine-audio';\nimport { createWorldContext, World } from '@forgeax/engine-ecs';\nimport type { SharedKernelExecutor } from '@forgeax/engine-ecs/shared';\nimport type { InputBackend, InputBackendSample } from '@forgeax/engine-input';\nimport type { Context, Plugin } from '@forgeax/engine-plugin';\nimport type { Renderer } from '@forgeax/engine-render';\nimport { constructRuntimeRendererHost } from '@forgeax/engine-runtime/internal/renderer-host';\nimport { createAnimationPayloadLookup } from '../animation-asset-lookup';\nimport { syncCameraAspect } from '../canvas-policy';\nimport { workerEngineProfile } from '../internal/worker-engine-profile';\nimport { createRenderFeatureHost } from '../renderer-plugin';\nimport { commitAttachedWorld, SerializedRebuildQueue } from './attached-world-swap';\nimport {\n executionBootstrapHostPlugin,\n type PreparedExecutionBootstrap,\n prepareBootstrapEntry,\n} from './bootstrap-entry';\nimport { createKernelPool, type KernelPool } from './kernel-pool';\nimport type {\n EngineToHostMessage,\n ExecutionFrameMessage,\n ExecutionInitMessage,\n ExecutionRebuildMessage,\n HostToEngineMessage,\n} from './protocol';\n\nconst scope = globalThis as unknown as {\n postMessage(message: EngineToHostMessage): void;\n onmessage: ((event: MessageEvent<HostToEngineMessage>) => void) | null;\n close(): void;\n};\n\nlet renderer: Renderer | undefined;\nlet assets: import('@forgeax/engine-assets-runtime').AssetRegistry | undefined;\nlet currentSample: InputBackendSample = {\n downKeys: new Set(),\n upKeys: new Set(),\n buttons: [false, false, false],\n movementX: 0,\n movementY: 0,\n wheelDelta: 0,\n focused: true,\n pointerLocked: false,\n};\nlet lastFrameId = 0;\nlet engineCanvas: OffscreenCanvas | undefined;\ninterface WorkerRealm {\n readonly world: World;\n readonly init: ExecutionInitMessage;\n pendingAudioIntents: AudioIntent[];\n kernelPool: KernelPool | undefined;\n pluginContext: Context | undefined;\n}\n\nlet realm: WorkerRealm | undefined;\nconst rebuildQueue = new SerializedRebuildQueue();\n\nconst inputBackend: InputBackend = {\n sample: () => currentSample,\n detach: () => {},\n};\n\nfunction sharedKernelPlugin(target: WorkerRealm): Plugin {\n return {\n name: 'shared-kernel-executor',\n inject: ['world'],\n apply(ctx) {\n const executor: SharedKernelExecutor = {\n warmup(kernel) {\n target.kernelPool ??= createKernelPool();\n target.kernelPool.warmup?.(kernel);\n },\n execute(kernel, spans) {\n target.kernelPool ??= createKernelPool();\n return target.kernelPool.execute(kernel, spans);\n },\n };\n ctx.effect(() => {\n ctx.world.insertResource('SharedKernelExecutor', executor);\n return () => {\n ctx.world.removeResource('SharedKernelExecutor');\n target.kernelPool?.dispose();\n target.kernelPool = undefined;\n };\n }, 'execution/shared-kernel');\n },\n };\n}\n\nfunction serializableCause(cause: unknown): { readonly name: string; readonly message: string } {\n return cause instanceof Error\n ? { name: cause.name, message: cause.message }\n : { name: 'Error', message: String(cause) };\n}\n\nfunction serializableDetail(cause: unknown): unknown {\n if (cause instanceof Error) return serializableCause(cause);\n if (Array.isArray(cause)) return cause.map(serializableDetail);\n if (typeof cause === 'object' && cause !== null) {\n return Object.fromEntries(\n Object.entries(cause).map(([key, value]) => [key, serializableDetail(value)]),\n );\n }\n return cause;\n}\n\nfunction postFault(\n source: 'bootstrap' | 'runtime' | 'world' | 'rebuild',\n code: string,\n expected: string,\n hint: string,\n cause: unknown,\n partialWrite = false,\n): void {\n scope.postMessage({\n kind: 'fault',\n worldIdentity: realm?.world.identity ?? null,\n source,\n code,\n expected,\n hint,\n detail: serializableDetail(cause),\n partialWrite,\n retryable: false,\n });\n}\n\nasync function disposeRealm(target: WorkerRealm): Promise<void> {\n await target.pluginContext?.fiber.dispose();\n target.pluginContext = undefined;\n target.pendingAudioIntents = [];\n}\n\nfunction postBootstrapFault(error: {\n readonly code: string;\n readonly expected: string;\n readonly hint: string;\n readonly detail: unknown;\n}): void {\n postFault('bootstrap', error.code, error.expected, error.hint, error.detail);\n}\n\nasync function createRealm(init: ExecutionInitMessage): Promise<boolean> {\n const preparedResult = await prepareBootstrapEntry(init.bootstrapUrl, init.bootstrapData);\n if (!preparedResult.ok) {\n postBootstrapFault(preparedResult.error);\n return false;\n }\n const prepared: PreparedExecutionBootstrap = preparedResult.value;\n const nextWorld = new World({\n ...(init.time !== undefined ? { time: init.time } : {}),\n storage: init.tier === 'shared' ? 'shared' : 'local',\n });\n const candidate: WorkerRealm = {\n world: nextWorld,\n init,\n pendingAudioIntents: [],\n kernelPool: undefined,\n pluginContext: undefined,\n };\n const audioBackend = createAudioIntentBackend({\n emit: (intent) => candidate.pendingAudioIntents.push(intent),\n });\n let candidateRenderer: Renderer | undefined;\n let rendererLifecycleTransferred = false;\n const previousRenderer = renderer;\n let previousSurfaceReleased = false;\n try {\n if (previousRenderer !== undefined) {\n const released = previousRenderer.releaseSurface();\n if (!released.ok) throw released.error;\n previousSurfaceReleased = true;\n }\n const constructed = await constructRuntimeRendererHost(\n init.canvas,\n prepared.features === undefined ? {} : { features: prepared.features },\n init.shaderManifestUrl === undefined\n ? undefined\n : { shaderManifestUrl: init.shaderManifestUrl },\n );\n if (!constructed.ok) throw constructed.error;\n candidateRenderer = constructed.value.renderer;\n assets = constructed.value.assets;\n rendererLifecycleTransferred = true;\n const pluginContext = await createWorldContext(\n nextWorld,\n workerEngineProfile({\n renderer: candidateRenderer,\n rendererFeatureHost: createRenderFeatureHost(constructed.value.featureHost),\n assets,\n input: inputBackend,\n audio: audioBackend,\n animationPayloads: createAnimationPayloadLookup(assets),\n extensions: [\n ...(init.tier === 'shared' ? [sharedKernelPlugin(candidate)] : []),\n executionBootstrapHostPlugin({\n ...(init.bootstrapPort === undefined ? {} : { port: init.bootstrapPort }),\n setPointerLockAllowed(allowed): void {\n scope.postMessage({\n kind: 'host-control',\n command: 'set-pointer-lock-allowed',\n allowed,\n });\n },\n }),\n ...(prepared.plugins ?? []),\n ],\n }),\n );\n candidate.pluginContext = pluginContext;\n const activeRenderer = candidateRenderer;\n const previousRealm = realm;\n const committed = await commitAttachedWorld(candidateRenderer, nextWorld, async () => {\n await candidate.kernelPool?.ready();\n return true;\n });\n if (!committed) {\n await disposeRealm(candidate);\n if (previousSurfaceReleased) previousRenderer?.restoreSurface();\n return false;\n }\n realm = candidate;\n renderer = activeRenderer;\n lastFrameId = 0;\n if (previousRealm !== undefined) await disposeRealm(previousRealm);\n return true;\n } catch (cause) {\n await disposeRealm(candidate);\n if (!rendererLifecycleTransferred) candidateRenderer?.dispose();\n if (previousSurfaceReleased) previousRenderer?.restoreSurface();\n throw cause;\n }\n}\n\nasync function initialize(message: ExecutionInitMessage): Promise<void> {\n try {\n engineCanvas = message.canvas;\n if (!(await createRealm(message))) return;\n scope.postMessage({\n kind: 'ready',\n worldIdentity: realm?.world.identity ?? '',\n realm: 'worker',\n workerWebGpu: typeof navigator === 'object' && navigator.gpu !== undefined,\n });\n } catch (cause) {\n postFault(\n 'bootstrap',\n 'app-execution-bootstrap-failed',\n 'Engine Worker creates a realm-local World, Renderer and GPU owner',\n 'inspect the worker bootstrap cause and module URL',\n cause,\n );\n }\n}\n\nfunction runFrame(message: ExecutionFrameMessage): void {\n const activeRealm = realm;\n if (activeRealm === undefined || renderer === undefined) return;\n const { world } = activeRealm;\n if (message.worldIdentity !== world.identity || message.frameId <= lastFrameId) return;\n currentSample = message.inputSample;\n const canvasWidth =\n Number.isFinite(message.canvasWidth) && message.canvasWidth > 0\n ? Math.max(1, Math.floor(message.canvasWidth))\n : undefined;\n const canvasHeight =\n Number.isFinite(message.canvasHeight) && message.canvasHeight > 0\n ? Math.max(1, Math.floor(message.canvasHeight))\n : undefined;\n if (canvasWidth !== undefined && canvasHeight !== undefined) {\n if (engineCanvas !== undefined) {\n if (engineCanvas.width !== canvasWidth) engineCanvas.width = canvasWidth;\n if (engineCanvas.height !== canvasHeight) engineCanvas.height = canvasHeight;\n }\n syncCameraAspect(world, canvasWidth, canvasHeight);\n }\n const started = performance.now();\n try {\n const update = world.update(message.deltaSeconds);\n if (!update.ok) throw update.error;\n if (world.execution.health === 'poisoned') {\n const fault = world.execution.fault;\n postFault(\n 'world',\n fault?.code ?? 'world-poisoned',\n 'World remains healthy through update',\n 'rebuild the poisoned World explicitly',\n fault,\n fault?.partialWrite ?? true,\n );\n return;\n }\n const updateFinished = performance.now();\n const attached = renderer.attach(world);\n if (!attached.ok) throw attached.error;\n const draw = renderer.draw({\n leases: [attached.value],\n camera: { lease: attached.value },\n environment: { lease: attached.value },\n });\n if (!draw.ok) throw draw.error;\n lastFrameId = message.frameId;\n const kernelDispatch = activeRealm.kernelPool?.takeLastDispatch() ?? null;\n const audioIntents = activeRealm.pendingAudioIntents;\n activeRealm.pendingAudioIntents = [];\n scope.postMessage({\n kind: 'frame-complete',\n worldIdentity: world.identity,\n frameId: message.frameId,\n engineUpdateMs: updateFinished - started,\n kernelWaitMs: kernelDispatch?.waitMs ?? 0,\n ...(audioIntents.length > 0 ? { audioIntents } : {}),\n ...(kernelDispatch !== null\n ? {\n kernelDispatch: {\n eligible: true,\n usedShared: kernelDispatch.mode === 'shared',\n reason:\n kernelDispatch.mode === 'shared' ? ('shared' as const) : ('forced-inline' as const),\n dispatched: kernelDispatch.dispatched,\n completed: kernelDispatch.completed,\n },\n }\n : {}),\n });\n } catch (cause) {\n const fault = world.execution.fault;\n postFault(\n fault === null ? 'runtime' : 'world',\n fault?.code ?? 'app-system-update-failed',\n 'World update completes before Renderer draw',\n fault === null ? 'inspect the runtime cause' : 'rebuild the poisoned World explicitly',\n cause,\n fault?.partialWrite ?? false,\n );\n }\n}\n\nasync function rebuild(message: ExecutionRebuildMessage): Promise<void> {\n const activeRealm = realm;\n if (\n activeRealm === undefined ||\n renderer === undefined ||\n message.worldIdentity !== activeRealm.world.identity\n )\n return;\n const previousWorldIdentity = activeRealm.world.identity;\n try {\n if (engineCanvas === undefined) return;\n const init: ExecutionInitMessage = { ...activeRealm.init, canvas: engineCanvas };\n if (!(await createRealm(init))) return;\n scope.postMessage({\n kind: 'rebuilt',\n previousWorldIdentity,\n worldIdentity: realm?.world.identity ?? '',\n });\n } catch (cause) {\n postFault(\n 'rebuild',\n 'app-execution-rebuild-failed',\n 'bootstrap creates a fresh World identity',\n 'inspect the bootstrap cause or create a new App',\n cause,\n );\n }\n}\n\nscope.onmessage = (event): void => {\n const message = event.data;\n if (message.kind === 'init') void initialize(message);\n else if (message.kind === 'frame') runFrame(message);\n else if (message.kind === 'rebuild') {\n void rebuildQueue.enqueue(() => rebuild(message));\n } else if (message.kind === 'dispose') {\n void (async () => {\n if (realm !== undefined) {\n await disposeRealm(realm);\n realm = undefined;\n }\n scope.close();\n })();\n }\n};\n"]}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import type { RhiError } from '@forgeax/engine-rhi/errors';
|
|
2
2
|
import type { ExecutionCapabilityName, ExecutionTier } from './execution/types';
|
|
3
3
|
/**
|
|
4
|
-
* Closed AppErrorCode union (
|
|
4
|
+
* Closed AppErrorCode union (12 members).
|
|
5
5
|
*
|
|
6
6
|
* | code | trigger |
|
|
7
7
|
* |:--|:--|
|
|
8
8
|
* | `'app-not-started'` | `stop()` / `pause()` / `resume()` invoked while the rAF loop is in the terminal `'idle'` or `'stopped'` state (post-device-lost terminal sink). The handle has no live frame to interrupt; AI users either call `start()` first or accept that this handle is dead and rebuild via `createApp({...})`. |
|
|
9
9
|
* | `'app-already-running'` | second `start()` invocation against an already-running handle; the call is a no-op state-machine-wise (state preserved). |
|
|
10
10
|
* | `'app-canvas-detached'` | `createApp(canvas)` thin wrapper found `canvas.isConnected === false` at entry. Detail carries optional `canvasId` so the host can surface the offending canvas in a multi-canvas page (D-2 minor). |
|
|
11
|
-
* | `'app-invalid-canvas-pixel-ratio'` | canvas-form Host policy supplied a non-finite or non-positive `maxCanvasPixelRatio`. Detail carries the rejected value. |
|
|
12
11
|
* | `'app-system-update-failed'` | World update, renderer draw, or a frame-loop callback failed; the original failure value is forwarded on `detail.cause`. `detail.systemName` is optional when the call site can name the failing owner. |
|
|
13
12
|
* | `'app-pointer-lock-failed'` | `attachInputAuto`'s `onLockError` callback received a lock failure from the input backend. `detail.path` carries `'w3c'` (W3C `requestPointerLock` rejection) or `'provider'` (host-injected `lockProvider.requestLock` throw/reject). `detail.cause` carries the original rejection value verbatim. The host recovers by remaining in unlocked state; the next trusted click will retry the lock request. |
|
|
14
13
|
*
|
|
15
|
-
* Plan-strategy D-4 locked the
|
|
14
|
+
* Plan-strategy D-4 locked the count at 6; device-lost rides RhiErrorCode.
|
|
16
15
|
*/
|
|
17
16
|
export type AppErrorCode = keyof typeof appErrorPolicy;
|
|
18
17
|
/**
|
|
@@ -25,10 +24,6 @@ export type AppErrorCode = keyof typeof appErrorPolicy;
|
|
|
25
24
|
export interface AppDetailCanvasDetached {
|
|
26
25
|
readonly canvasId?: string | undefined;
|
|
27
26
|
}
|
|
28
|
-
/** Invalid host-owned canvas pixel-ratio cap. */
|
|
29
|
-
export interface AppDetailInvalidCanvasPixelRatio {
|
|
30
|
-
readonly value: number;
|
|
31
|
-
}
|
|
32
27
|
/**
|
|
33
28
|
* Detail variant for the `'app-system-update-failed'` arm (plan-strategy D-4).
|
|
34
29
|
*
|
|
@@ -109,7 +104,7 @@ export type AppDetailEmpty = Readonly<Record<string, never>>;
|
|
|
109
104
|
* Used by the constructor signature so `new AppError({ code: 'X', ... })`
|
|
110
105
|
* narrows the `detail` parameter to the variant payload at compile time.
|
|
111
106
|
*/
|
|
112
|
-
export type AppErrorDetailFor<C extends AppErrorCode> = C extends 'app-canvas-detached' ? AppDetailCanvasDetached : C extends 'app-
|
|
107
|
+
export type AppErrorDetailFor<C extends AppErrorCode> = C extends 'app-canvas-detached' ? AppDetailCanvasDetached : C extends 'app-frame-step-invalid' ? AppDetailFrameStepInvalid : C extends 'app-system-update-failed' ? AppDetailSystemUpdateFailed : C extends 'app-pointer-lock-failed' ? AppDetailPointerLockFailed : C extends 'app-plugin-activation-failed' ? AppDetailPluginActivationFailed : C extends 'app-execution-tier-unavailable' ? AppDetailExecutionTierUnavailable : C extends 'app-execution-bootstrap-failed' ? AppDetailExecutionBootstrapFailed : C extends 'app-execution-deadline-exceeded' ? AppDetailExecutionDeadlineExceeded : C extends 'app-execution-kernel-failed' ? AppDetailExecutionKernelFailed : C extends 'app-execution-stale-world' ? AppDetailExecutionStaleWorld : C extends 'app-execution-rebuild-failed' ? AppDetailExecutionRebuildFailed : AppDetailEmpty;
|
|
113
108
|
/**
|
|
114
109
|
* Tagged union of `.detail` payloads carried by structured AppError.
|
|
115
110
|
*
|
|
@@ -198,10 +193,6 @@ declare const appErrorPolicy: {
|
|
|
198
193
|
expected: string;
|
|
199
194
|
hint: string;
|
|
200
195
|
};
|
|
201
|
-
'app-invalid-canvas-pixel-ratio': {
|
|
202
|
-
expected: string;
|
|
203
|
-
hint: string;
|
|
204
|
-
};
|
|
205
196
|
'app-frame-step-invalid': {
|
|
206
197
|
expected: string;
|
|
207
198
|
hint: string;
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],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AC;AAEhB,UAAU,mBAAmB;IAC3B,KAAK,CAAC,SAAS,YAAY,EAAE,IAAI,EAAE;QACjC,IAAI,EAAE,CAAC,CAAC;QACR,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;KAC9B,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;CACnC;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,EAAE,mBAAqE,CAAC;AAY7F,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgEsB,CAAC;AAE3C,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAErB,CAAC;AAE5C,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAExB,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,GAAG,GAAG,IAAI,QAAQ,CAEpE"}
|
|
@@ -5,17 +5,6 @@ export declare class SerializedRebuildQueue {
|
|
|
5
5
|
private tail;
|
|
6
6
|
enqueue(action: () => Promise<void>): Promise<void>;
|
|
7
7
|
}
|
|
8
|
-
export interface RebuildCleanupFailure {
|
|
9
|
-
readonly phase: 'candidate' | 'previous';
|
|
10
|
-
readonly cause: unknown;
|
|
11
|
-
}
|
|
12
|
-
/** Primary rebuild failures stay first; cleanup failures are ordered detail. */
|
|
13
|
-
export declare class RebuildLifecycleError extends Error {
|
|
14
|
-
readonly primary: unknown;
|
|
15
|
-
readonly cleanup: readonly RebuildCleanupFailure[];
|
|
16
|
-
constructor(primary: unknown, cleanup: readonly RebuildCleanupFailure[]);
|
|
17
|
-
}
|
|
18
|
-
export declare function disposeWithOrderedDetail(phase: RebuildCleanupFailure['phase'], dispose: () => Promise<void> | void, failures: RebuildCleanupFailure[]): Promise<void>;
|
|
19
8
|
/** Transactionally replace one Renderer-attached World. */
|
|
20
|
-
export declare function commitAttachedWorld(renderer: Pick<Renderer, '
|
|
9
|
+
export declare function commitAttachedWorld(renderer: Pick<Renderer, 'attach'>, nextWorld: World, initializeCandidate: () => Promise<boolean>): Promise<boolean>;
|
|
21
10
|
//# sourceMappingURL=attached-world-swap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attached-world-swap.d.ts","sourceRoot":"","sources":["../../src/execution/attached-world-swap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,4EAA4E;AAC5E,qBAAa,sBAAsB;IACjC,OAAO,CAAC,IAAI,CAAoC;IAEhD,OAAO,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAKpD;AAED,
|
|
1
|
+
{"version":3,"file":"attached-world-swap.d.ts","sourceRoot":"","sources":["../../src/execution/attached-world-swap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,4EAA4E;AAC5E,qBAAa,sBAAsB;IACjC,OAAO,CAAC,IAAI,CAAoC;IAEhD,OAAO,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAKpD;AAED,2DAA2D;AAC3D,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAClC,SAAS,EAAE,KAAK,EAChB,mBAAmB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAC1C,OAAO,CAAC,OAAO,CAAC,CAalB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Result } from '@forgeax/engine-types';
|
|
2
|
+
import { type AppError as AppErrorType } from '../errors';
|
|
3
|
+
/** Normalize a bootstrap module before any realm probing or worker startup. */
|
|
4
|
+
export declare function normalizeExecutionBootstrapUrl(bootstrap: string | URL): Result<string, AppErrorType>;
|
|
5
|
+
//# sourceMappingURL=bootstrap-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap-url.d.ts","sourceRoot":"","sources":["../../src/execution/bootstrap-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAA2C,KAAK,QAAQ,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AAEnG,+EAA+E;AAC/E,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,GAAG,GAAG,GACtB,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAkB9B"}
|
|
@@ -7,8 +7,6 @@ export interface LocalExecutionControl extends ExecutionControl {
|
|
|
7
7
|
export interface LocalExecutionReportProviders {
|
|
8
8
|
readonly audio?: () => AudioState;
|
|
9
9
|
readonly world?: () => ExecutionReport['world'];
|
|
10
|
-
/** Host-owned poisoned-World replacement transaction. */
|
|
11
|
-
readonly rebuild?: ExecutionControl['rebuild'];
|
|
12
10
|
}
|
|
13
11
|
export declare function createLocalExecutionControl(initial: ExecutionReport, providers?: LocalExecutionReportProviders): LocalExecutionControl;
|
|
14
12
|
//# sourceMappingURL=control.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/execution/control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAExF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAE7E;AAED,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,UAAU,CAAC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../../src/execution/control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAExF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAE7E;AAED,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,UAAU,CAAC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;CACjD;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,eAAe,EACxB,SAAS,GAAE,6BAAkC,GAC5C,qBAAqB,CAyBvB"}
|
|
@@ -13,6 +13,7 @@ export interface StartEngineWorkerOptions {
|
|
|
13
13
|
readonly bootstrapUrl: string;
|
|
14
14
|
readonly bootstrapData?: import('./types').ExecutionBootstrapValue;
|
|
15
15
|
readonly bootstrapPort?: MessagePort;
|
|
16
|
+
readonly assetCatalog?: import('./types').ExecutionAssetCatalog;
|
|
16
17
|
readonly shaderManifestUrl?: string;
|
|
17
18
|
readonly time?: import('@forgeax/engine-ecs').TimePolicy;
|
|
18
19
|
readonly timeoutMs: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine-worker.d.ts","sourceRoot":"","sources":["../../src/execution/engine-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAA2C,KAAK,QAAQ,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AAEnG,OAAO,KAAK,EACV,mBAAmB,EAGnB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;IACtC,IAAI,CAAC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,CAAC,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IACpE,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACrE,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,SAAS,EAAE,uBAAuB,CAAC;IACnE,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAC;IACrC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,qBAAqB,EAAE,UAAU,CAAC;IACzD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,SAA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AAO,qBAAqB,EAAE,UAAU,CAAC;IACzD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,SAAS,EAAE,aAAa,CAAC;IAC/C,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,MAAM,CAAC;CACvC;AAoBD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC,CA8GpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-controller.d.ts","sourceRoot":"","sources":["../../src/execution/host-controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAA2C,KAAK,QAAQ,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AAEnG,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"host-controller.d.ts","sourceRoot":"","sources":["../../src/execution/host-controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAA2C,KAAK,QAAQ,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AAEnG,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAWlB,OAAO,KAAK,EACV,qBAAqB,EAGrB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,6EAA6E;IAC7E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,uBAAuB,CAAC;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,qBAAqB,CAAC;IAC7C,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;CACxC;AAkCD,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC,CAkY7C"}
|
|
@@ -5,6 +5,6 @@ export { cloneExecutionReport } from './control';
|
|
|
5
5
|
export { createExecutionReport } from './report';
|
|
6
6
|
export { EXECUTION_REPORT_SCHEMA_VERSION, isExecutionReport } from './schema';
|
|
7
7
|
export { type ExecutionSelectionInput, selectExecutionTier } from './selector';
|
|
8
|
-
export type { ExecutionBootstrapValue, ExecutionCapabilities, ExecutionCapabilityFact, ExecutionCapabilityName, ExecutionControl, ExecutionEngineHealth, ExecutionFault, ExecutionMeasurement, ExecutionOptions, ExecutionReport, ExecutionRequestedTier, ExecutionSelection, ExecutionSelectionReason, ExecutionTier, ExecutionWorldHealth, KernelDispatchReason, } from './types';
|
|
8
|
+
export type { ExecutionAssetCatalog, ExecutionBootstrapValue, ExecutionCapabilities, ExecutionCapabilityFact, ExecutionCapabilityName, ExecutionControl, ExecutionEngineHealth, ExecutionFault, ExecutionMeasurement, ExecutionOptions, ExecutionReport, ExecutionRequestedTier, ExecutionSelection, ExecutionSelectionReason, ExecutionTier, ExecutionWorldHealth, KernelDispatchReason, } from './types';
|
|
9
9
|
export { EXECUTION_CAPABILITY_NAMES, EXECUTION_REQUESTED_TIERS, EXECUTION_TIERS, } from './types';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|