@forgeax/engine-app 0.1.4 → 0.1.7

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 (148) hide show
  1. package/README.md +20 -14
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/__tests__/create-app-error-retention.integration.test.d.ts +2 -0
  4. package/dist/__tests__/create-app-error-retention.integration.test.d.ts.map +1 -0
  5. package/dist/__tests__/create-app-physics-plugin-failure.integration.test.d.ts +2 -0
  6. package/dist/__tests__/create-app-physics-plugin-failure.integration.test.d.ts.map +1 -0
  7. package/dist/animation-asset-lookup.d.ts +1 -2
  8. package/dist/animation-asset-lookup.d.ts.map +1 -1
  9. package/dist/browser-frame-signal.d.ts +17 -0
  10. package/dist/browser-frame-signal.d.ts.map +1 -0
  11. package/dist/create-app.d.ts +31 -10
  12. package/dist/create-app.d.ts.map +1 -1
  13. package/dist/engine-worker-runtime.mjs +72 -129
  14. package/dist/engine-worker-runtime.mjs.map +1 -1
  15. package/dist/errors.d.ts +3 -12
  16. package/dist/errors.d.ts.map +1 -1
  17. package/dist/execution/attached-world-swap.d.ts +1 -12
  18. package/dist/execution/attached-world-swap.d.ts.map +1 -1
  19. package/dist/execution/bootstrap-url.d.ts +5 -0
  20. package/dist/execution/bootstrap-url.d.ts.map +1 -0
  21. package/dist/execution/control.d.ts +0 -2
  22. package/dist/execution/control.d.ts.map +1 -1
  23. package/dist/execution/engine-worker.d.ts +1 -0
  24. package/dist/execution/engine-worker.d.ts.map +1 -1
  25. package/dist/execution/host-controller.d.ts.map +1 -1
  26. package/dist/execution/index.d.ts +1 -1
  27. package/dist/execution/index.d.ts.map +1 -1
  28. package/dist/execution/protocol.d.ts +4 -1
  29. package/dist/execution/protocol.d.ts.map +1 -1
  30. package/dist/execution/types.d.ts +17 -1
  31. package/dist/execution/types.d.ts.map +1 -1
  32. package/dist/game-context.d.ts +1 -1
  33. package/dist/game-context.d.ts.map +1 -1
  34. package/dist/index.d.ts +5 -2
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.mjs +357 -359
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/internal/assembled-engine-profile.d.ts.map +1 -1
  39. package/dist/internal/assets-world-plugin.d.ts +3 -17
  40. package/dist/internal/assets-world-plugin.d.ts.map +1 -1
  41. package/dist/internal/browser-remote-bridge.d.ts +1 -2
  42. package/dist/internal/browser-remote-bridge.d.ts.map +1 -1
  43. package/dist/internal/browser-rhi-debug-runtime.d.ts +1 -1
  44. package/dist/internal/browser-rhi-debug-runtime.d.ts.map +1 -1
  45. package/dist/internal/debug-draw.d.ts +9 -0
  46. package/dist/internal/debug-draw.d.ts.map +1 -0
  47. package/dist/internal/engine-profile-common.d.ts +2 -2
  48. package/dist/internal/engine-profile-common.d.ts.map +1 -1
  49. package/dist/internal/frame-loop.d.ts +7 -4
  50. package/dist/internal/frame-loop.d.ts.map +1 -1
  51. package/dist/internal/main-engine-profile.d.ts +4 -0
  52. package/dist/internal/main-engine-profile.d.ts.map +1 -1
  53. package/dist/internal/remote-serve-flag.d.ts +3 -7
  54. package/dist/internal/remote-serve-flag.d.ts.map +1 -1
  55. package/dist/internal/rhi-capture.d.ts +1 -1
  56. package/dist/internal/rhi-capture.d.ts.map +1 -1
  57. package/dist/internal/worker-engine-profile.d.ts +2 -0
  58. package/dist/internal/worker-engine-profile.d.ts.map +1 -1
  59. package/dist/renderer-plugin.d.ts +25 -0
  60. package/dist/renderer-plugin.d.ts.map +1 -0
  61. package/dist/tool-preview/bootstrap.d.ts.map +1 -1
  62. package/dist/types.d.ts +21 -61
  63. package/dist/types.d.ts.map +1 -1
  64. package/package.json +25 -26
  65. package/src/__tests__/callback-inference.test-d.ts +7 -3
  66. package/src/__tests__/consumer-migration.unit.test.ts +13 -0
  67. package/src/__tests__/create-app-error-retention.integration.test.ts +125 -0
  68. package/src/__tests__/create-app-features.test.ts +21 -10
  69. package/src/__tests__/create-app-listener-sync.test.ts +23 -19
  70. package/src/__tests__/create-app-physics-plugin-failure.integration.test.ts +142 -0
  71. package/src/__tests__/create-app-stop.test.ts +4 -12
  72. package/src/__tests__/create-app.test-d.ts +12 -11
  73. package/src/__tests__/create-app.test.ts +1 -60
  74. package/src/__tests__/create-renderer-error.integration.test.ts +3 -2
  75. package/src/__tests__/create-renderer-lifecycle.integration.test.ts +10 -5
  76. package/src/__tests__/draw-source-injected-world-update-visibility.test.ts +7 -13
  77. package/src/__tests__/draw-source-single-world-regression.test.ts +23 -24
  78. package/src/__tests__/engine-worker-bootstrap-channel.unit.test.ts +8 -0
  79. package/src/__tests__/engine-worker-world-swap.unit.test.ts +15 -22
  80. package/src/__tests__/errors-pointer-lock-failed.test.ts +4 -7
  81. package/src/__tests__/execution-bootstrap-isolation.unit.test.ts +5 -6
  82. package/src/__tests__/execution-frame-order.unit.test.ts +2 -2
  83. package/src/__tests__/execution-frame-protocol.unit.test.ts +3 -4
  84. package/src/__tests__/execution-public-api.test-d.ts +4 -0
  85. package/src/__tests__/frame-loop-time-elapsed.test.ts +1 -1
  86. package/src/__tests__/frame-loop-time.unit.test.ts +1 -1
  87. package/src/__tests__/frame-loop-world-array.test.ts +82 -73
  88. package/src/__tests__/plugin-profiles.unit.test.ts +3 -3
  89. package/src/__tests__/profiler-default-off.test.ts +1 -1
  90. package/src/__tests__/profiler-frame-token.test.ts +17 -30
  91. package/src/__tests__/profiler-phase-integration.test.ts +15 -27
  92. package/src/__tests__/surface-handoff.test.ts +1 -4
  93. package/src/__tests__/visibility-remote.integration.test.ts +2 -5
  94. package/src/__tests__/worker-execution-stop.test.ts +64 -7
  95. package/src/animation-asset-lookup.ts +2 -2
  96. package/src/browser-frame-signal.ts +44 -0
  97. package/src/create-app.ts +208 -295
  98. package/src/errors.ts +27 -39
  99. package/src/execution/attached-world-swap.ts +4 -38
  100. package/src/execution/bootstrap-url.ts +25 -0
  101. package/src/execution/control.ts +3 -7
  102. package/src/execution/engine-worker-runtime.ts +23 -40
  103. package/src/execution/engine-worker.ts +2 -0
  104. package/src/execution/host-controller.ts +8 -2
  105. package/src/execution/index.ts +1 -0
  106. package/src/execution/protocol.ts +4 -1
  107. package/src/execution/types.ts +18 -1
  108. package/src/game-context.ts +1 -1
  109. package/src/index.ts +18 -4
  110. package/src/internal/assembled-engine-profile.ts +3 -11
  111. package/src/internal/assets-world-plugin.ts +7 -53
  112. package/src/internal/browser-remote-bridge.ts +2 -3
  113. package/src/internal/browser-rhi-debug-runtime.ts +1 -1
  114. package/src/internal/debug-draw.ts +38 -0
  115. package/src/internal/engine-profile-common.ts +2 -3
  116. package/src/internal/frame-loop.ts +77 -63
  117. package/src/internal/main-engine-profile.ts +21 -17
  118. package/src/internal/remote-serve-flag.ts +5 -14
  119. package/src/internal/rhi-capture.ts +1 -1
  120. package/src/internal/worker-engine-profile.ts +10 -10
  121. package/src/renderer-plugin.ts +96 -0
  122. package/src/tool-preview/bootstrap.ts +1 -14
  123. package/src/types.ts +22 -77
  124. package/src/vite-env.d.ts +0 -2
  125. package/dist/__tests__/app-rebuild.test.d.ts +0 -2
  126. package/dist/__tests__/app-rebuild.test.d.ts.map +0 -1
  127. package/dist/__tests__/asset-registry-types.test-d.d.ts +0 -2
  128. package/dist/__tests__/asset-registry-types.test-d.d.ts.map +0 -1
  129. package/dist/__tests__/assets-runtime-assembly.integration.test.d.ts +0 -2
  130. package/dist/__tests__/assets-runtime-assembly.integration.test.d.ts.map +0 -1
  131. package/dist/__tests__/draw-source-headless-full-chain.test.d.ts +0 -2
  132. package/dist/__tests__/draw-source-headless-full-chain.test.d.ts.map +0 -1
  133. package/dist/__tests__/ecs-import.unit.test.d.ts +0 -2
  134. package/dist/__tests__/ecs-import.unit.test.d.ts.map +0 -1
  135. package/dist/__tests__/execution-world-health-owner.test-d.d.ts +0 -2
  136. package/dist/__tests__/execution-world-health-owner.test-d.d.ts.map +0 -1
  137. package/dist/__tests__/remote-serve-flag.test.d.ts +0 -2
  138. package/dist/__tests__/remote-serve-flag.test.d.ts.map +0 -1
  139. package/dist/assets-runtime-assembly.d.ts +0 -19
  140. package/dist/assets-runtime-assembly.d.ts.map +0 -1
  141. package/src/__tests__/app-rebuild.test.ts +0 -31
  142. package/src/__tests__/asset-registry-types.test-d.ts +0 -16
  143. package/src/__tests__/assets-runtime-assembly.integration.test.ts +0 -68
  144. package/src/__tests__/draw-source-headless-full-chain.test.ts +0 -226
  145. package/src/__tests__/ecs-import.unit.test.ts +0 -40
  146. package/src/__tests__/execution-world-health-owner.test-d.ts +0 -9
  147. package/src/__tests__/remote-serve-flag.test.ts +0 -24
  148. package/src/assets-runtime-assembly.ts +0 -70
package/README.md CHANGED
@@ -128,6 +128,14 @@ the execution Fiber. Keep DOM UI on the Host side of that typed channel.
128
128
  `ExecutionBootstrapHost.setPointerLockAllowed` is the one built-in
129
129
  realm-to-Host control because browser input ownership remains on the Host.
130
130
 
131
+ > [!IMPORTANT]
132
+ > Runtime asset delivery in an execution realm uses `execution.assetCatalog`,
133
+ > a serializable `{ url, expectedScope? }` descriptor. Engine constructs the
134
+ > `CatalogSource` and `AssetRegistry` inside the selected realm, so an Engine
135
+ > Worker never captures a Host-side registry. `expectedScope` keeps a scoped
136
+ > game catalog tied to its `scopeId` and `generation`; `CreateAppOptions.assetCatalog`
137
+ > remains realm-bound and is rejected when `execution` is requested.
138
+
131
139
  When `execution` is present, realm-bound `CreateAppOptions` (`features`,
132
140
  `plugins`, RHI injection, draw source, membership
133
141
  timing, and bundler import transport) are rejected instead of working only in a
@@ -151,21 +159,13 @@ therefore remains the owner of its feature and lifecycle:
151
159
  ```ts
152
160
  import { createApp } from '@forgeax/engine-app';
153
161
  import { createVfxRuntimeHost } from '@forgeax/engine-vfx-render';
154
- import { vfxGpuEffectContribution } from '@forgeax/engine-vfx';
155
162
 
156
163
  declare const canvas: HTMLCanvasElement;
157
164
  declare const camera: import('@forgeax/engine-vfx-render').ParticleRenderCameraSource;
158
165
  declare const bundler: import('@forgeax/engine-app').BundlerOptions;
159
166
 
160
167
  const vfxHost = createVfxRuntimeHost({ camera });
161
- const result = await createApp(
162
- canvas,
163
- {
164
- features: [vfxHost.feature],
165
- assetDecoders: [vfxGpuEffectContribution],
166
- },
167
- bundler,
168
- );
168
+ const result = await createApp(canvas, { features: [vfxHost.feature] }, bundler);
169
169
  if (!result.ok) {
170
170
  console.error(result.error.code, result.error.hint);
171
171
  throw result.error;
@@ -179,11 +179,6 @@ The app does not attach a VFX World or registry. Call
179
179
  errors by `code`, `expected`, `hint`, and `detail`; do not treat a successful App
180
180
  construction as proof that a particle asset is ready or visible.
181
181
 
182
- The App default assembly includes a device-neutral `particle-effect` decoder.
183
- VFX rendering selects the artifact-backed GPU owner explicitly with
184
- `assetDecoders: [vfxGpuEffectContribution]`; the host then shares that decoder
185
- lease instead of installing a competing kind.
186
-
187
182
  ## Frame-loop responsibility
188
183
 
189
184
  Every frame follows one host-owned sequence:
@@ -212,6 +207,16 @@ app.stop();
212
207
  await app.dispose();
213
208
  ```
214
209
 
210
+ `App.lastError` retains the most recent dispatch failure after the listener
211
+ callback runs, so an AI host can inspect the same object without scraping
212
+ console output:
213
+
214
+ | Fact | Recovery surface |
215
+ |:--|:--|
216
+ | `app-system-update-failed` | `detail.cause` preserves the original failure and `detail.systemName` identifies the owner when known. |
217
+ | Renderer or device failure | `app.onError` and `lastError` expose the closed error code with `expected`, `hint`, and discriminated `detail`. |
218
+ | No failure observed | `lastError` is `undefined`; do not infer readiness from App construction alone. |
219
+
215
220
  Hosts that discover additional Worlds during bootstrap can update the routing pull
216
221
  without creating a second frame loop:
217
222
 
@@ -368,6 +373,7 @@ the App owns the Cordis realm it assembled around them.
368
373
  | `CreateAppOptions.time` | `TimePolicy` | Policy used only for the newly created canvas-form World. |
369
374
  | `CreateAppOptions.features` | `readonly RenderFeature<unknown>[]` | Existing renderer feature seam, forwarded by reference and order. |
370
375
  | `CreateAppOptions.execution` | `ExecutionOptions` | Selects `auto`, `main-serial`, `engine-worker`, or `shared` and names the bootstrap module. |
376
+ | `ExecutionOptions.assetCatalog` | `ExecutionAssetCatalog` | Supplies the serializable catalog URL and optional scope fence to the selected Engine realm. |
371
377
  | `App.execution.report()` | `ExecutionReport` | Returns the schema-valid requested/actual tier, capabilities, health, performance, audio, and fault projection. |
372
378
  | `App.execution.rebuild()` | `Promise<Result<ExecutionReport, AppError>>` | Rebuilds only a poisoned Worker World with a new identity. |
373
379
  | `App.start()` | `Result<void, AppError>` | Arms the rAF loop. |