@forgeax/engine-app 0.0.0-dev.8d955ade1c79

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.
Files changed (348) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +424 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/__tests__/animation-asset-lookup.unit.test.d.ts +2 -0
  5. package/dist/__tests__/animation-asset-lookup.unit.test.d.ts.map +1 -0
  6. package/dist/__tests__/callback-deletion.unit.test.d.ts +2 -0
  7. package/dist/__tests__/callback-deletion.unit.test.d.ts.map +1 -0
  8. package/dist/__tests__/callback-inference.test-d.d.ts +2 -0
  9. package/dist/__tests__/callback-inference.test-d.d.ts.map +1 -0
  10. package/dist/__tests__/component-introspection.unit.test.d.ts +2 -0
  11. package/dist/__tests__/component-introspection.unit.test.d.ts.map +1 -0
  12. package/dist/__tests__/consumer-migration.unit.test.d.ts +2 -0
  13. package/dist/__tests__/consumer-migration.unit.test.d.ts.map +1 -0
  14. package/dist/__tests__/create-app-error-retention.integration.test.d.ts +2 -0
  15. package/dist/__tests__/create-app-error-retention.integration.test.d.ts.map +1 -0
  16. package/dist/__tests__/create-app-features.test.d.ts +2 -0
  17. package/dist/__tests__/create-app-features.test.d.ts.map +1 -0
  18. package/dist/__tests__/create-app-listener-sync.test.d.ts +2 -0
  19. package/dist/__tests__/create-app-listener-sync.test.d.ts.map +1 -0
  20. package/dist/__tests__/create-app-lock-provider.test.d.ts +2 -0
  21. package/dist/__tests__/create-app-lock-provider.test.d.ts.map +1 -0
  22. package/dist/__tests__/create-app-physics-plugin-failure.integration.test.d.ts +2 -0
  23. package/dist/__tests__/create-app-physics-plugin-failure.integration.test.d.ts.map +1 -0
  24. package/dist/__tests__/create-app-plugin.test.d.ts +2 -0
  25. package/dist/__tests__/create-app-plugin.test.d.ts.map +1 -0
  26. package/dist/__tests__/create-app-stop.test.d.ts +2 -0
  27. package/dist/__tests__/create-app-stop.test.d.ts.map +1 -0
  28. package/dist/__tests__/create-app-time.unit.test.d.ts +2 -0
  29. package/dist/__tests__/create-app-time.unit.test.d.ts.map +1 -0
  30. package/dist/__tests__/create-app.test-d.d.ts +2 -0
  31. package/dist/__tests__/create-app.test-d.d.ts.map +1 -0
  32. package/dist/__tests__/create-app.test.d.ts +2 -0
  33. package/dist/__tests__/create-app.test.d.ts.map +1 -0
  34. package/dist/__tests__/create-renderer-error.integration.test.d.ts +2 -0
  35. package/dist/__tests__/create-renderer-error.integration.test.d.ts.map +1 -0
  36. package/dist/__tests__/create-renderer-lifecycle.integration.test.d.ts +2 -0
  37. package/dist/__tests__/create-renderer-lifecycle.integration.test.d.ts.map +1 -0
  38. package/dist/__tests__/docs-gate-green.unit.test.d.ts +2 -0
  39. package/dist/__tests__/docs-gate-green.unit.test.d.ts.map +1 -0
  40. package/dist/__tests__/draw-source-injected-world-update-visibility.test.d.ts +2 -0
  41. package/dist/__tests__/draw-source-injected-world-update-visibility.test.d.ts.map +1 -0
  42. package/dist/__tests__/draw-source-single-world-regression.test.d.ts +2 -0
  43. package/dist/__tests__/draw-source-single-world-regression.test.d.ts.map +1 -0
  44. package/dist/__tests__/engine-worker-bootstrap-channel.unit.test.d.ts +2 -0
  45. package/dist/__tests__/engine-worker-bootstrap-channel.unit.test.d.ts.map +1 -0
  46. package/dist/__tests__/engine-worker-world-swap.unit.test.d.ts +2 -0
  47. package/dist/__tests__/engine-worker-world-swap.unit.test.d.ts.map +1 -0
  48. package/dist/__tests__/errors-pointer-lock-failed.test.d.ts +2 -0
  49. package/dist/__tests__/errors-pointer-lock-failed.test.d.ts.map +1 -0
  50. package/dist/__tests__/execution-bootstrap-isolation.unit.test.d.ts +2 -0
  51. package/dist/__tests__/execution-bootstrap-isolation.unit.test.d.ts.map +1 -0
  52. package/dist/__tests__/execution-error-detail.test-d.d.ts +2 -0
  53. package/dist/__tests__/execution-error-detail.test-d.d.ts.map +1 -0
  54. package/dist/__tests__/execution-error-detail.unit.test.d.ts +2 -0
  55. package/dist/__tests__/execution-error-detail.unit.test.d.ts.map +1 -0
  56. package/dist/__tests__/execution-frame-order.unit.test.d.ts +2 -0
  57. package/dist/__tests__/execution-frame-order.unit.test.d.ts.map +1 -0
  58. package/dist/__tests__/execution-frame-protocol.unit.test.d.ts +2 -0
  59. package/dist/__tests__/execution-frame-protocol.unit.test.d.ts.map +1 -0
  60. package/dist/__tests__/execution-input-sample.contract.test.d.ts +2 -0
  61. package/dist/__tests__/execution-input-sample.contract.test.d.ts.map +1 -0
  62. package/dist/__tests__/execution-measurement.unit.test.d.ts +2 -0
  63. package/dist/__tests__/execution-measurement.unit.test.d.ts.map +1 -0
  64. package/dist/__tests__/execution-public-api.test-d.d.ts +2 -0
  65. package/dist/__tests__/execution-public-api.test-d.d.ts.map +1 -0
  66. package/dist/__tests__/execution-public-api.unit.test.d.ts +2 -0
  67. package/dist/__tests__/execution-public-api.unit.test.d.ts.map +1 -0
  68. package/dist/__tests__/execution-rebuild.contract.test.d.ts +2 -0
  69. package/dist/__tests__/execution-rebuild.contract.test.d.ts.map +1 -0
  70. package/dist/__tests__/execution-report.contract.test.d.ts +2 -0
  71. package/dist/__tests__/execution-report.contract.test.d.ts.map +1 -0
  72. package/dist/__tests__/execution-report.types.test-d.d.ts +2 -0
  73. package/dist/__tests__/execution-report.types.test-d.d.ts.map +1 -0
  74. package/dist/__tests__/execution-schema-freshness.unit.test.d.ts +2 -0
  75. package/dist/__tests__/execution-schema-freshness.unit.test.d.ts.map +1 -0
  76. package/dist/__tests__/execution-selector.unit.test.d.ts +2 -0
  77. package/dist/__tests__/execution-selector.unit.test.d.ts.map +1 -0
  78. package/dist/__tests__/execution-shared-kernel.unit.test.d.ts +2 -0
  79. package/dist/__tests__/execution-shared-kernel.unit.test.d.ts.map +1 -0
  80. package/dist/__tests__/fallback-camera.unit.test.d.ts +2 -0
  81. package/dist/__tests__/fallback-camera.unit.test.d.ts.map +1 -0
  82. package/dist/__tests__/frame-loop-time-elapsed.test.d.ts +2 -0
  83. package/dist/__tests__/frame-loop-time-elapsed.test.d.ts.map +1 -0
  84. package/dist/__tests__/frame-loop-time.unit.test.d.ts +2 -0
  85. package/dist/__tests__/frame-loop-time.unit.test.d.ts.map +1 -0
  86. package/dist/__tests__/frame-loop-world-array.test.d.ts +2 -0
  87. package/dist/__tests__/frame-loop-world-array.test.d.ts.map +1 -0
  88. package/dist/__tests__/kernel-worker-runtime.unit.test.d.ts +2 -0
  89. package/dist/__tests__/kernel-worker-runtime.unit.test.d.ts.map +1 -0
  90. package/dist/__tests__/migration-surface-inventory.unit.test.d.ts +2 -0
  91. package/dist/__tests__/migration-surface-inventory.unit.test.d.ts.map +1 -0
  92. package/dist/__tests__/plugin-policy.integration.test.d.ts +2 -0
  93. package/dist/__tests__/plugin-policy.integration.test.d.ts.map +1 -0
  94. package/dist/__tests__/plugin-profiles.unit.test.d.ts +2 -0
  95. package/dist/__tests__/plugin-profiles.unit.test.d.ts.map +1 -0
  96. package/dist/__tests__/profiler-default-off.test.d.ts +2 -0
  97. package/dist/__tests__/profiler-default-off.test.d.ts.map +1 -0
  98. package/dist/__tests__/profiler-frame-token.test.d.ts +2 -0
  99. package/dist/__tests__/profiler-frame-token.test.d.ts.map +1 -0
  100. package/dist/__tests__/profiler-phase-catalog.test.d.ts +2 -0
  101. package/dist/__tests__/profiler-phase-catalog.test.d.ts.map +1 -0
  102. package/dist/__tests__/profiler-phase-integration.test.d.ts +2 -0
  103. package/dist/__tests__/profiler-phase-integration.test.d.ts.map +1 -0
  104. package/dist/__tests__/profiler-remote-bridge.test.d.ts +2 -0
  105. package/dist/__tests__/profiler-remote-bridge.test.d.ts.map +1 -0
  106. package/dist/__tests__/remote-integration.test.d.ts +2 -0
  107. package/dist/__tests__/remote-integration.test.d.ts.map +1 -0
  108. package/dist/__tests__/rhi-capture-capability.test-d.d.ts +2 -0
  109. package/dist/__tests__/rhi-capture-capability.test-d.d.ts.map +1 -0
  110. package/dist/__tests__/rhi-capture-host.integration.test.d.ts +2 -0
  111. package/dist/__tests__/rhi-capture-host.integration.test.d.ts.map +1 -0
  112. package/dist/__tests__/rhi-capture.browser.test.d.ts +2 -0
  113. package/dist/__tests__/rhi-capture.browser.test.d.ts.map +1 -0
  114. package/dist/__tests__/surface-handoff.test.d.ts +2 -0
  115. package/dist/__tests__/surface-handoff.test.d.ts.map +1 -0
  116. package/dist/__tests__/types-m2.test-d.d.ts +2 -0
  117. package/dist/__tests__/types-m2.test-d.d.ts.map +1 -0
  118. package/dist/__tests__/visibility-remote.integration.test.d.ts +2 -0
  119. package/dist/__tests__/visibility-remote.integration.test.d.ts.map +1 -0
  120. package/dist/__tests__/worker-execution-stop.test.d.ts +2 -0
  121. package/dist/__tests__/worker-execution-stop.test.d.ts.map +1 -0
  122. package/dist/animation-asset-lookup.d.ts +7 -0
  123. package/dist/animation-asset-lookup.d.ts.map +1 -0
  124. package/dist/browser-frame-signal.d.ts +17 -0
  125. package/dist/browser-frame-signal.d.ts.map +1 -0
  126. package/dist/canvas-policy.d.ts +4 -0
  127. package/dist/canvas-policy.d.ts.map +1 -0
  128. package/dist/create-app.d.ts +78 -0
  129. package/dist/create-app.d.ts.map +1 -0
  130. package/dist/engine-worker-runtime.mjs +827 -0
  131. package/dist/engine-worker-runtime.mjs.map +1 -0
  132. package/dist/errors.d.ts +254 -0
  133. package/dist/errors.d.ts.map +1 -0
  134. package/dist/execution/attached-world-swap.d.ts +10 -0
  135. package/dist/execution/attached-world-swap.d.ts.map +1 -0
  136. package/dist/execution/bootstrap-entry.d.ts +30 -0
  137. package/dist/execution/bootstrap-entry.d.ts.map +1 -0
  138. package/dist/execution/bootstrap-url.d.ts +5 -0
  139. package/dist/execution/bootstrap-url.d.ts.map +1 -0
  140. package/dist/execution/capabilities.d.ts +5 -0
  141. package/dist/execution/capabilities.d.ts.map +1 -0
  142. package/dist/execution/control.d.ts +12 -0
  143. package/dist/execution/control.d.ts.map +1 -0
  144. package/dist/execution/engine-worker-runtime.d.ts +2 -0
  145. package/dist/execution/engine-worker-runtime.d.ts.map +1 -0
  146. package/dist/execution/engine-worker.d.ts +24 -0
  147. package/dist/execution/engine-worker.d.ts.map +1 -0
  148. package/dist/execution/host-controller.d.ts +16 -0
  149. package/dist/execution/host-controller.d.ts.map +1 -0
  150. package/dist/execution/index.d.ts +10 -0
  151. package/dist/execution/index.d.ts.map +1 -0
  152. package/dist/execution/kernel-pool.d.ts +14 -0
  153. package/dist/execution/kernel-pool.d.ts.map +1 -0
  154. package/dist/execution/kernel-worker-runtime.d.ts +2 -0
  155. package/dist/execution/kernel-worker-runtime.d.ts.map +1 -0
  156. package/dist/execution/measurement.d.ts +7 -0
  157. package/dist/execution/measurement.d.ts.map +1 -0
  158. package/dist/execution/protocol.d.ts +87 -0
  159. package/dist/execution/protocol.d.ts.map +1 -0
  160. package/dist/execution/report.d.ts +5 -0
  161. package/dist/execution/report.d.ts.map +1 -0
  162. package/dist/execution/schema.d.ts +4 -0
  163. package/dist/execution/schema.d.ts.map +1 -0
  164. package/dist/execution/selector.d.ts +10 -0
  165. package/dist/execution/selector.d.ts.map +1 -0
  166. package/dist/execution/types.d.ts +123 -0
  167. package/dist/execution/types.d.ts.map +1 -0
  168. package/dist/fallback-camera.d.ts +8 -0
  169. package/dist/fallback-camera.d.ts.map +1 -0
  170. package/dist/game-context.d.ts +98 -0
  171. package/dist/game-context.d.ts.map +1 -0
  172. package/dist/index.d.ts +27 -0
  173. package/dist/index.d.ts.map +1 -0
  174. package/dist/index.mjs +3980 -0
  175. package/dist/index.mjs.map +1 -0
  176. package/dist/input-map-plugin.d.ts +5 -0
  177. package/dist/input-map-plugin.d.ts.map +1 -0
  178. package/dist/input-plugin.d.ts +4 -0
  179. package/dist/input-plugin.d.ts.map +1 -0
  180. package/dist/internal/assembled-engine-profile.d.ts +5 -0
  181. package/dist/internal/assembled-engine-profile.d.ts.map +1 -0
  182. package/dist/internal/assets-world-plugin.d.ts +7 -0
  183. package/dist/internal/assets-world-plugin.d.ts.map +1 -0
  184. package/dist/internal/browser-remote-bridge.d.ts +24 -0
  185. package/dist/internal/browser-remote-bridge.d.ts.map +1 -0
  186. package/dist/internal/browser-rhi-debug-runtime.d.ts +18 -0
  187. package/dist/internal/browser-rhi-debug-runtime.d.ts.map +1 -0
  188. package/dist/internal/component-introspection.d.ts +24 -0
  189. package/dist/internal/component-introspection.d.ts.map +1 -0
  190. package/dist/internal/debug-draw.d.ts +9 -0
  191. package/dist/internal/debug-draw.d.ts.map +1 -0
  192. package/dist/internal/ecs-import.d.ts +6 -0
  193. package/dist/internal/ecs-import.d.ts.map +1 -0
  194. package/dist/internal/engine-profile-common.d.ts +9 -0
  195. package/dist/internal/engine-profile-common.d.ts.map +1 -0
  196. package/dist/internal/error-fanout.d.ts +66 -0
  197. package/dist/internal/error-fanout.d.ts.map +1 -0
  198. package/dist/internal/frame-loop.d.ts +38 -0
  199. package/dist/internal/frame-loop.d.ts.map +1 -0
  200. package/dist/internal/input-attach.d.ts +44 -0
  201. package/dist/internal/input-attach.d.ts.map +1 -0
  202. package/dist/internal/main-engine-profile.d.ts +19 -0
  203. package/dist/internal/main-engine-profile.d.ts.map +1 -0
  204. package/dist/internal/remote-serve-flag.d.ts +19 -0
  205. package/dist/internal/remote-serve-flag.d.ts.map +1 -0
  206. package/dist/internal/remote-server-plugin.d.ts +8 -0
  207. package/dist/internal/remote-server-plugin.d.ts.map +1 -0
  208. package/dist/internal/rhi-capture.d.ts +19 -0
  209. package/dist/internal/rhi-capture.d.ts.map +1 -0
  210. package/dist/internal/rhi-debug-flag.d.ts +18 -0
  211. package/dist/internal/rhi-debug-flag.d.ts.map +1 -0
  212. package/dist/internal/worker-engine-profile.d.ts +15 -0
  213. package/dist/internal/worker-engine-profile.d.ts.map +1 -0
  214. package/dist/kernel-worker-runtime.mjs +69 -0
  215. package/dist/kernel-worker-runtime.mjs.map +1 -0
  216. package/dist/load-game-errors.d.ts +131 -0
  217. package/dist/load-game-errors.d.ts.map +1 -0
  218. package/dist/load-game.d.ts +34 -0
  219. package/dist/load-game.d.ts.map +1 -0
  220. package/dist/plugin-factories.d.ts +3 -0
  221. package/dist/plugin-factories.d.ts.map +1 -0
  222. package/dist/renderer-plugin.d.ts +25 -0
  223. package/dist/renderer-plugin.d.ts.map +1 -0
  224. package/dist/tool-preview/bootstrap.d.ts +113 -0
  225. package/dist/tool-preview/bootstrap.d.ts.map +1 -0
  226. package/dist/tool-preview/evidence.d.ts +20 -0
  227. package/dist/tool-preview/evidence.d.ts.map +1 -0
  228. package/dist/tool-preview/framing.d.ts +13 -0
  229. package/dist/tool-preview/framing.d.ts.map +1 -0
  230. package/dist/tool-preview/recipe.d.ts +54 -0
  231. package/dist/tool-preview/recipe.d.ts.map +1 -0
  232. package/dist/types.d.ts +404 -0
  233. package/dist/types.d.ts.map +1 -0
  234. package/package.json +85 -0
  235. package/schema/execution-report.schema.json +168 -0
  236. package/src/__tests__/animation-asset-lookup.unit.test.ts +20 -0
  237. package/src/__tests__/callback-deletion.unit.test.ts +14 -0
  238. package/src/__tests__/callback-inference.test-d.ts +36 -0
  239. package/src/__tests__/component-introspection.unit.test.ts +56 -0
  240. package/src/__tests__/consumer-migration.unit.test.ts +34 -0
  241. package/src/__tests__/create-app-error-retention.integration.test.ts +125 -0
  242. package/src/__tests__/create-app-features.test.ts +51 -0
  243. package/src/__tests__/create-app-listener-sync.test.ts +381 -0
  244. package/src/__tests__/create-app-lock-provider.test.ts +212 -0
  245. package/src/__tests__/create-app-physics-plugin-failure.integration.test.ts +142 -0
  246. package/src/__tests__/create-app-plugin.test.ts +217 -0
  247. package/src/__tests__/create-app-stop.test.ts +609 -0
  248. package/src/__tests__/create-app-time.unit.test.ts +26 -0
  249. package/src/__tests__/create-app.test-d.ts +83 -0
  250. package/src/__tests__/create-app.test.ts +287 -0
  251. package/src/__tests__/create-renderer-error.integration.test.ts +25 -0
  252. package/src/__tests__/create-renderer-lifecycle.integration.test.ts +24 -0
  253. package/src/__tests__/docs-gate-green.unit.test.ts +61 -0
  254. package/src/__tests__/draw-source-injected-world-update-visibility.test.ts +176 -0
  255. package/src/__tests__/draw-source-single-world-regression.test.ts +184 -0
  256. package/src/__tests__/engine-worker-bootstrap-channel.unit.test.ts +82 -0
  257. package/src/__tests__/engine-worker-world-swap.unit.test.ts +69 -0
  258. package/src/__tests__/errors-pointer-lock-failed.test.ts +265 -0
  259. package/src/__tests__/execution-bootstrap-isolation.unit.test.ts +79 -0
  260. package/src/__tests__/execution-error-detail.test-d.ts +13 -0
  261. package/src/__tests__/execution-error-detail.unit.test.ts +35 -0
  262. package/src/__tests__/execution-frame-order.unit.test.ts +38 -0
  263. package/src/__tests__/execution-frame-protocol.unit.test.ts +60 -0
  264. package/src/__tests__/execution-input-sample.contract.test.ts +23 -0
  265. package/src/__tests__/execution-measurement.unit.test.ts +20 -0
  266. package/src/__tests__/execution-public-api.test-d.ts +14 -0
  267. package/src/__tests__/execution-public-api.unit.test.ts +9 -0
  268. package/src/__tests__/execution-rebuild.contract.test.ts +36 -0
  269. package/src/__tests__/execution-report.contract.test.ts +50 -0
  270. package/src/__tests__/execution-report.types.test-d.ts +16 -0
  271. package/src/__tests__/execution-schema-freshness.unit.test.ts +20 -0
  272. package/src/__tests__/execution-selector.unit.test.ts +72 -0
  273. package/src/__tests__/execution-shared-kernel.unit.test.ts +180 -0
  274. package/src/__tests__/fallback-camera.unit.test.ts +32 -0
  275. package/src/__tests__/frame-loop-time-elapsed.test.ts +115 -0
  276. package/src/__tests__/frame-loop-time.unit.test.ts +61 -0
  277. package/src/__tests__/frame-loop-world-array.test.ts +450 -0
  278. package/src/__tests__/kernel-worker-runtime.unit.test.ts +50 -0
  279. package/src/__tests__/migration-surface-inventory.unit.test.ts +13 -0
  280. package/src/__tests__/plugin-policy.integration.test.ts +15 -0
  281. package/src/__tests__/plugin-profiles.unit.test.ts +190 -0
  282. package/src/__tests__/profiler-default-off.test.ts +53 -0
  283. package/src/__tests__/profiler-frame-token.test.ts +235 -0
  284. package/src/__tests__/profiler-phase-catalog.test.ts +30 -0
  285. package/src/__tests__/profiler-phase-integration.test.ts +117 -0
  286. package/src/__tests__/profiler-remote-bridge.test.ts +31 -0
  287. package/src/__tests__/remote-integration.test.ts +224 -0
  288. package/src/__tests__/rhi-capture-capability.test-d.ts +22 -0
  289. package/src/__tests__/rhi-capture-host.integration.test.ts +157 -0
  290. package/src/__tests__/rhi-capture.browser.test.ts +51 -0
  291. package/src/__tests__/surface-handoff.test.ts +89 -0
  292. package/src/__tests__/types-m2.test-d.ts +81 -0
  293. package/src/__tests__/visibility-remote.integration.test.ts +116 -0
  294. package/src/__tests__/worker-execution-stop.test.ts +173 -0
  295. package/src/animation-asset-lookup.ts +13 -0
  296. package/src/browser-frame-signal.ts +44 -0
  297. package/src/canvas-policy.ts +16 -0
  298. package/src/create-app.ts +1264 -0
  299. package/src/errors.ts +442 -0
  300. package/src/execution/attached-world-swap.ts +33 -0
  301. package/src/execution/bootstrap-entry.ts +122 -0
  302. package/src/execution/bootstrap-url.ts +25 -0
  303. package/src/execution/capabilities.ts +102 -0
  304. package/src/execution/control.ts +48 -0
  305. package/src/execution/engine-worker-runtime.ts +383 -0
  306. package/src/execution/engine-worker.ts +163 -0
  307. package/src/execution/host-controller.ts +460 -0
  308. package/src/execution/index.ts +44 -0
  309. package/src/execution/kernel-pool.ts +236 -0
  310. package/src/execution/kernel-worker-runtime.ts +103 -0
  311. package/src/execution/measurement.ts +39 -0
  312. package/src/execution/protocol.ts +134 -0
  313. package/src/execution/report.ts +66 -0
  314. package/src/execution/schema.ts +168 -0
  315. package/src/execution/selector.ts +98 -0
  316. package/src/execution/types.ts +163 -0
  317. package/src/fallback-camera.ts +20 -0
  318. package/src/game-context.ts +126 -0
  319. package/src/index.ts +190 -0
  320. package/src/input-map-plugin.ts +21 -0
  321. package/src/input-plugin.ts +26 -0
  322. package/src/internal/assembled-engine-profile.ts +14 -0
  323. package/src/internal/assets-world-plugin.ts +33 -0
  324. package/src/internal/browser-remote-bridge.ts +269 -0
  325. package/src/internal/browser-rhi-debug-runtime.ts +67 -0
  326. package/src/internal/component-introspection.ts +116 -0
  327. package/src/internal/debug-draw.ts +38 -0
  328. package/src/internal/ecs-import.ts +41 -0
  329. package/src/internal/engine-profile-common.ts +9 -0
  330. package/src/internal/error-fanout.ts +129 -0
  331. package/src/internal/frame-loop.ts +539 -0
  332. package/src/internal/input-attach.ts +104 -0
  333. package/src/internal/main-engine-profile.ts +84 -0
  334. package/src/internal/remote-serve-flag.ts +41 -0
  335. package/src/internal/remote-server-plugin.ts +16 -0
  336. package/src/internal/rhi-capture.ts +211 -0
  337. package/src/internal/rhi-debug-flag.ts +40 -0
  338. package/src/internal/worker-engine-profile.ts +47 -0
  339. package/src/load-game-errors.ts +211 -0
  340. package/src/load-game.ts +115 -0
  341. package/src/plugin-factories.ts +2 -0
  342. package/src/renderer-plugin.ts +96 -0
  343. package/src/tool-preview/bootstrap.ts +835 -0
  344. package/src/tool-preview/evidence.ts +59 -0
  345. package/src/tool-preview/framing.ts +52 -0
  346. package/src/tool-preview/recipe.ts +137 -0
  347. package/src/types.ts +450 -0
  348. package/src/vite-env.d.ts +10 -0
@@ -0,0 +1 @@
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,SA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ookup } 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"]}
@@ -0,0 +1,254 @@
1
+ import type { RhiError } from '@forgeax/engine-rhi/errors';
2
+ import type { ExecutionCapabilityName, ExecutionTier } from './execution/types';
3
+ /**
4
+ * Closed AppErrorCode union (12 members).
5
+ *
6
+ * | code | trigger |
7
+ * |:--|:--|
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
+ * | `'app-already-running'` | second `start()` invocation against an already-running handle; the call is a no-op state-machine-wise (state preserved). |
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-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. |
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. |
13
+ *
14
+ * Plan-strategy D-4 locked the count at 6; device-lost rides RhiErrorCode.
15
+ */
16
+ export type AppErrorCode = keyof typeof appErrorPolicy;
17
+ /**
18
+ * Detail variant for the `'app-canvas-detached'` arm.
19
+ *
20
+ * `canvasId` carries an optional identifier the host can surface to AI
21
+ * users when multiple canvases live on the page (e.g. preview vs live
22
+ * canvas). `undefined` when the host did not assign an id.
23
+ */
24
+ export interface AppDetailCanvasDetached {
25
+ readonly canvasId?: string | undefined;
26
+ }
27
+ /**
28
+ * Detail variant for the `'app-system-update-failed'` arm (plan-strategy D-4).
29
+ *
30
+ * `cause` carries the original thrown value verbatim so AI users can
31
+ * `cause instanceof EcsError` / `cause instanceof RhiError` narrow without
32
+ * losing structure. `systemName` is populated when the call site can name
33
+ * the offending system (input-attach cleanup path forwards
34
+ * `FRAME_START_SCAN_SYSTEM_NAME`).
35
+ */
36
+ export interface AppDetailSystemUpdateFailed {
37
+ readonly cause: unknown;
38
+ readonly systemName?: string | undefined;
39
+ }
40
+ /**
41
+ * Detail variant for the `'app-pointer-lock-failed'` arm (plan-strategy D-4).
42
+ *
43
+ * `path` discriminates between W3C `requestPointerLock` rejections (`'w3c'`)
44
+ * and host-injected `lockProvider.requestLock` throw/reject (`'provider'`).
45
+ * `cause` carries the original rejection value verbatim so AI users can
46
+ * narrow further (e.g. `cause instanceof DOMException` for W3C timeout
47
+ * rejections).
48
+ */
49
+ export interface AppDetailPointerLockFailed {
50
+ readonly path: 'w3c' | 'provider';
51
+ readonly cause: unknown;
52
+ }
53
+ /** Why a host-requested deterministic frame could not run. */
54
+ export interface AppDetailFrameStepInvalid {
55
+ readonly state: 'idle' | 'running' | 'paused' | 'stopped';
56
+ readonly deltaSeconds: number;
57
+ readonly reason: 'state' | 'delta';
58
+ }
59
+ export interface AppDetailExecutionTierUnavailable {
60
+ readonly requestedTier: ExecutionTier;
61
+ readonly missingCapabilities: readonly ExecutionCapabilityName[];
62
+ readonly sharedEvidencePassed: boolean;
63
+ }
64
+ export interface AppDetailExecutionBootstrapFailed {
65
+ readonly phase: 'import' | 'export' | 'prepare' | 'bootstrap' | 'data';
66
+ readonly moduleUrl: string;
67
+ readonly cause: unknown;
68
+ }
69
+ /** Original startup failure thrown by a Cordis plugin fiber. */
70
+ export interface AppDetailPluginActivationFailed {
71
+ readonly cause: unknown;
72
+ }
73
+ export interface AppDetailExecutionDeadlineExceeded {
74
+ readonly phase: 'startup' | 'handshake' | 'frame';
75
+ readonly timeoutMs: number;
76
+ }
77
+ export interface AppDetailExecutionKernelFailed {
78
+ readonly kernelName: string;
79
+ readonly worldIdentity: string;
80
+ readonly cause: unknown;
81
+ readonly partialWrite: true;
82
+ readonly retryable: false;
83
+ }
84
+ export interface AppDetailExecutionStaleWorld {
85
+ readonly expectedIdentity: string;
86
+ readonly receivedIdentity: string;
87
+ readonly messageKind: string;
88
+ }
89
+ export interface AppDetailExecutionRebuildFailed {
90
+ readonly worldIdentity: string | null;
91
+ readonly cause: unknown;
92
+ }
93
+ /**
94
+ * Empty-detail shape for the 2 codes that carry no payload
95
+ * (`'app-not-started'`, `'app-already-running'`).
96
+ *
97
+ * Modelled as `Readonly<Record<string, never>>` so literal builders use
98
+ * `{}` while still narrowing under tsc strict (no extra property allowed).
99
+ */
100
+ export type AppDetailEmpty = Readonly<Record<string, never>>;
101
+ /**
102
+ * Conditional resolver from `AppErrorCode` to its detail payload type.
103
+ *
104
+ * Used by the constructor signature so `new AppError({ code: 'X', ... })`
105
+ * narrows the `detail` parameter to the variant payload at compile time.
106
+ */
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;
108
+ /**
109
+ * Tagged union of `.detail` payloads carried by structured AppError.
110
+ *
111
+ * Each variant maps to its `AppErrorCode` arm via `AppErrorDetailFor<C>`;
112
+ * the variants are unique by structural fields (`AppDetailCanvasDetached`
113
+ * has `canvasId`, `AppDetailSystemUpdateFailed` has `cause`, the empty
114
+ * shape has neither).
115
+ */
116
+ export type AppErrorDetail = AppErrorDetailFor<AppErrorCode>;
117
+ declare class AppErrorClass extends Error {
118
+ readonly code: AppErrorCode;
119
+ readonly expected: string;
120
+ readonly hint: string;
121
+ readonly detail: AppErrorDetail;
122
+ constructor(args: {
123
+ code: AppErrorCode;
124
+ expected: string;
125
+ hint: string;
126
+ detail: AppErrorDetail;
127
+ });
128
+ }
129
+ /**
130
+ * Variant intersection: an `AppErrorClass` instance whose `code` literal
131
+ * narrows to `C` and whose `detail` narrows to `AppErrorDetailFor<C>`. The
132
+ * shape lets `if (err.code === 'X')` simultaneously narrow `err.detail` to
133
+ * the per-code payload (charter P3 + AC-07 discriminated union).
134
+ */
135
+ type AppErrorVariant<C extends AppErrorCode> = AppErrorClass & {
136
+ readonly code: C;
137
+ readonly detail: AppErrorDetailFor<C>;
138
+ };
139
+ /**
140
+ * Public AppError type — discriminated union of the policy variants.
141
+ *
142
+ * AI-user form (charter P3 explicit failure):
143
+ *
144
+ * ```ts
145
+ * function recover(err: AppError): string {
146
+ * switch (err.code) {
147
+ * case 'app-not-started': return 'call start() first';
148
+ * case 'app-already-running': return 'state preserved; ignore';
149
+ * case 'app-canvas-detached': return `reattach ${err.detail.canvasId ?? 'canvas'}`;
150
+ * case 'app-system-update-failed':
151
+ * return err.detail.cause instanceof Error ? err.detail.cause.message : 'unknown';
152
+ * case 'app-pointer-lock-failed':
153
+ * return `lock failed (${err.detail.path}): ${err.detail.cause}`;
154
+ * }
155
+ * }
156
+ * ```
157
+ */
158
+ export type AppError = {
159
+ [C in AppErrorCode]: AppErrorVariant<C>;
160
+ }[AppErrorCode];
161
+ interface AppErrorConstructor {
162
+ new <C extends AppErrorCode>(args: {
163
+ code: C;
164
+ expected: string;
165
+ hint: string;
166
+ detail: AppErrorDetailFor<C>;
167
+ }): AppErrorVariant<C>;
168
+ readonly prototype: AppErrorClass;
169
+ }
170
+ /**
171
+ * AppError constructor — `new AppError({ code, expected, hint, detail })`.
172
+ *
173
+ * The generic `C` is inferred from the literal `code` argument, which
174
+ * narrows `detail` to the per-code payload (`AppErrorDetailFor<C>`) and
175
+ * narrows the return type to the corresponding `AppErrorVariant<C>` so the
176
+ * call site walks the discriminated union without manual cast.
177
+ *
178
+ * The constructor delegates to the `AppErrorClass` runtime; the typed-cast
179
+ * here is the ergonomic affordance for AI users (TS class declarations
180
+ * cannot directly express `<C> ... AppErrorVariant<C>` polymorphism).
181
+ */
182
+ export declare const AppError: AppErrorConstructor;
183
+ declare const appErrorPolicy: {
184
+ 'app-not-started': {
185
+ expected: string;
186
+ hint: string;
187
+ };
188
+ 'app-already-running': {
189
+ expected: string;
190
+ hint: string;
191
+ };
192
+ 'app-canvas-detached': {
193
+ expected: string;
194
+ hint: string;
195
+ };
196
+ 'app-frame-step-invalid': {
197
+ expected: string;
198
+ hint: string;
199
+ };
200
+ 'app-system-update-failed': {
201
+ expected: string;
202
+ hint: string;
203
+ };
204
+ 'app-pointer-lock-failed': {
205
+ expected: string;
206
+ hint: string;
207
+ };
208
+ 'app-plugin-activation-failed': {
209
+ expected: string;
210
+ hint: string;
211
+ };
212
+ 'app-execution-tier-unavailable': {
213
+ expected: string;
214
+ hint: string;
215
+ };
216
+ 'app-execution-bootstrap-failed': {
217
+ expected: string;
218
+ hint: string;
219
+ };
220
+ 'app-execution-deadline-exceeded': {
221
+ expected: string;
222
+ hint: string;
223
+ };
224
+ 'app-execution-kernel-failed': {
225
+ expected: string;
226
+ hint: string;
227
+ };
228
+ 'app-execution-stale-world': {
229
+ expected: string;
230
+ hint: string;
231
+ };
232
+ 'app-execution-rebuild-failed': {
233
+ expected: string;
234
+ hint: string;
235
+ };
236
+ };
237
+ export declare const APP_EXPECTED: Readonly<Record<AppErrorCode, string>>;
238
+ export declare const APP_ERROR_HINTS: Readonly<Record<AppErrorCode, string>>;
239
+ /**
240
+ * Type guard for narrowing `CanvasAppError`-compatible mixed signals to AppError.
241
+ *
242
+ * The fan-out signature is `(err: CanvasAppError) => void`; AI users
243
+ * who want to handle only the AppError leg call `if (isAppError(err)) ...`
244
+ * before walking `.code`. Reverse-compatible with `instanceof AppError`
245
+ * (the class is exposed); the function form is provided as the
246
+ * canonical idiom in JSDoc / README so AI users do not need to reason
247
+ * about cross-realm `instanceof` quirks.
248
+ *
249
+ * The parameter accepts the complete App/RHI boundary union so callers can
250
+ * narrow the error without casts.
251
+ */
252
+ export declare function isAppError(err: AppError | RhiError): err is AppError;
253
+ export {};
254
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAgDA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEhF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,cAAc,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS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;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,GAAG,GAAG,IAAI,QAAQ,CAEpE"}
@@ -0,0 +1,10 @@
1
+ import type { World } from '@forgeax/engine-ecs';
2
+ import type { Renderer } from '@forgeax/engine-render';
3
+ /** Serialize realm rebuilds so candidate Worlds never overlap ownership. */
4
+ export declare class SerializedRebuildQueue {
5
+ private tail;
6
+ enqueue(action: () => Promise<void>): Promise<void>;
7
+ }
8
+ /** Transactionally replace one Renderer-attached World. */
9
+ export declare function commitAttachedWorld(renderer: Pick<Renderer, 'attach'>, nextWorld: World, initializeCandidate: () => Promise<boolean>): Promise<boolean>;
10
+ //# sourceMappingURL=attached-world-swap.d.ts.map
@@ -0,0 +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,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,30 @@
1
+ import type { Plugin } from '@forgeax/engine-plugin';
2
+ import type { RenderFeature } from '@forgeax/engine-render';
3
+ import { type Result } from '@forgeax/engine-types';
4
+ import { type AppError as AppErrorType } from '../errors';
5
+ import type { ExecutionBootstrapValue } from './types';
6
+ /** Realm-local engine assembly returned by an execution bootstrap module. */
7
+ export interface PreparedExecutionBootstrap {
8
+ /** Render features constructed in the realm that will own the Renderer. */
9
+ readonly features?: readonly RenderFeature<unknown>[];
10
+ /** Plugins constructed in the realm that will own the World. */
11
+ readonly plugins?: readonly Plugin[];
12
+ }
13
+ /** Realm-local Host bridge available to execution bootstrap plugins. */
14
+ export interface ExecutionBootstrapHost {
15
+ readonly port?: MessagePort;
16
+ setPointerLockAllowed(allowed: boolean): void;
17
+ }
18
+ declare module '@forgeax/engine-plugin' {
19
+ interface EngineContextServices {
20
+ executionBootstrapHost: ExecutionBootstrapHost;
21
+ }
22
+ }
23
+ /** Bind the optional Host transport to the same Fiber that owns bootstrap plugins. */
24
+ export declare function executionBootstrapHostPlugin(host: ExecutionBootstrapHost): Plugin;
25
+ /** Default export contract for `ExecutionOptions.bootstrap`. */
26
+ export type ExecutionBootstrapEntry = (data: ExecutionBootstrapValue | undefined) => PreparedExecutionBootstrap | Promise<PreparedExecutionBootstrap>;
27
+ export declare function validateExecutionBootstrapData(data: ExecutionBootstrapValue | undefined, moduleUrl: string): Result<void, AppErrorType>;
28
+ export declare function loadBootstrapEntry(moduleUrl: string): Promise<Result<ExecutionBootstrapEntry, AppErrorType>>;
29
+ export declare function prepareBootstrapEntry(moduleUrl: string, data: ExecutionBootstrapValue | undefined): Promise<Result<PreparedExecutionBootstrap, AppErrorType>>;
30
+ //# sourceMappingURL=bootstrap-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap-entry.d.ts","sourceRoot":"","sources":["../../src/execution/bootstrap-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAA2C,KAAK,QAAQ,IAAI,YAAY,EAAE,MAAM,WA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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"}
@@ -0,0 +1,5 @@
1
+ import { type ExecutionCapabilities, type ExecutionCapabilityName } from './types';
2
+ export declare function unavailableExecutionCapabilities(reason: string): ExecutionCapabilities;
3
+ export declare function missingExecutionCapabilities(capabilities: ExecutionCapabilities, required: readonly ExecutionCapabilityName[]): readonly ExecutionCapabilityName[];
4
+ export declare function probeExecutionCapabilities(canvas: HTMLCanvasElement, timeoutMs?: number): Promise<ExecutionCapabilities>;
5
+ //# sourceMappingURL=capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/execution/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC7B,MAAM,SAAS,CAAC;AAEjB,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,qBAAqB,CAItF;AAED,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,qBAAqB,EACnC,QAAQ,EAAE,SAAS,uBAAuB,EAAE,GAC3C,SAAS,uBAAuB,EAAE,CAEpC;AAiCD,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,iBAAiB,EACzB,SAAS,SAAQ,GAChB,OAAO,CAAC,qBAAqB,CAAC,CAgDhC"}
@@ -0,0 +1,12 @@
1
+ import type { AudioState } from '@forgeax/engine-audio';
2
+ import type { ExecutionControl, ExecutionEngineHealth, ExecutionReport } from './types';
3
+ export declare function cloneExecutionReport(report: ExecutionReport): ExecutionReport;
4
+ export interface LocalExecutionControl extends ExecutionControl {
5
+ setEngineHealth(health: ExecutionEngineHealth): void;
6
+ }
7
+ export interface LocalExecutionReportProviders {
8
+ readonly audio?: () => AudioState;
9
+ readonly world?: () => ExecutionReport['world'];
10
+ }
11
+ export declare function createLocalExecutionControl(initial: ExecutionReport, providers?: LocalExecutionReportProviders): LocalExecutionControl;
12
+ //# sourceMappingURL=control.d.ts.map
@@ -0,0 +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;CACjD;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,eAAe,EACxB,SAAS,GAAE,6BAAkC,GAC5C,qBAAqB,CAyBvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=engine-worker-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-worker-runtime.d.ts","sourceRoot":"","sources":["../../src/execution/engine-worker-runtime.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import { type Result } from '@forgeax/engine-types';
2
+ import { type AppError as AppErrorType } from '../errors';
3
+ import type { EngineToHostMessage, ExecutionReadyMessage, HostToEngineMessage } from './protocol';
4
+ export interface EngineWorkerSession {
5
+ readonly worker: Worker;
6
+ readonly ready: ExecutionReadyMessage;
7
+ post(message: HostToEngineMessage, transfer?: Transferable[]): void;
8
+ listen(listener: (message: EngineToHostMessage) => void): () => void;
9
+ dispose(): void;
10
+ }
11
+ export interface StartEngineWorkerOptions {
12
+ readonly canvas: HTMLCanvasElement;
13
+ readonly bootstrapUrl: string;
14
+ readonly bootstrapData?: import('./types').ExecutionBootstrapValue;
15
+ readonly bootstrapPort?: MessagePort;
16
+ readonly assetCatalog?: import('./types').ExecutionAssetCatalog;
17
+ readonly shaderManifestUrl?: string;
18
+ readonly time?: import('@forgeax/engine-ecs').TimePolicy;
19
+ readonly timeoutMs: number;
20
+ readonly tier: import('./types').ExecutionTier;
21
+ readonly workerFactory?: () => Worker;
22
+ }
23
+ export declare function startEngineWorker(options: StartEngineWorkerOptions): Promise<Result<EngineWorkerSession, AppErrorType>>;
24
+ //# sourceMappingURL=engine-worker.d.ts.map
@@ -0,0 +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,YAAY,CAAC,EAAE,OAAO,SAAS,EAAE,qBAAqB,CAAC;IAChE,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,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"}
@@ -0,0 +1,16 @@
1
+ import { type Result } from '@forgeax/engine-types';
2
+ import { type AppError as AppErrorType } from '../errors';
3
+ import type { BundlerOptions, CanvasDrawingBufferSize } from '../types';
4
+ import { type CreateAppOptions, type ExecutionApp } from '../types';
5
+ import type { ExecutionCapabilities, ExecutionSelection } from './types';
6
+ export interface CreateWorkerExecutionAppOptions {
7
+ readonly canvas: HTMLCanvasElement;
8
+ readonly appOptions: CreateAppOptions;
9
+ /** Host-owned resize policy applied before each frame sent to the worker. */
10
+ readonly syncCanvas?: () => CanvasDrawingBufferSize;
11
+ readonly bundler?: BundlerOptions;
12
+ readonly capabilities: ExecutionCapabilities;
13
+ readonly selection: ExecutionSelection;
14
+ }
15
+ export declare function createWorkerExecutionApp(options: CreateWorkerExecutionAppOptions): Promise<Result<ExecutionApp, AppErrorType>>;
16
+ //# sourceMappingURL=host-controller.d.ts.map
@@ -0,0 +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;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"}