@vgai/engine 0.5.15 → 0.5.17

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 (220) hide show
  1. package/dist/adapter/adapter-module.d.ts +229 -33
  2. package/dist/adapter/adapter-module.d.ts.map +1 -1
  3. package/dist/adapter/adapter-module.js +222 -50
  4. package/dist/adapter/authoring-seam-contract.d.ts +530 -0
  5. package/dist/adapter/authoring-seam-contract.d.ts.map +1 -0
  6. package/dist/adapter/authoring-seam-contract.js +162 -0
  7. package/dist/adapter/authoring.d.ts +237 -50
  8. package/dist/adapter/authoring.d.ts.map +1 -1
  9. package/dist/adapter/authoring.js +2 -1
  10. package/dist/adapter/entrypoint-selection-source.d.ts +35 -0
  11. package/dist/adapter/entrypoint-selection-source.d.ts.map +1 -0
  12. package/dist/adapter/entrypoint-selection-source.js +151 -0
  13. package/dist/adapter/finders/scenes-from-entrypoint-selection.d.ts +7 -3
  14. package/dist/adapter/finders/scenes-from-entrypoint-selection.d.ts.map +1 -1
  15. package/dist/adapter/finders/scenes-from-entrypoint-selection.js +145 -27
  16. package/dist/adapter/first-party-systems.d.ts +13 -3
  17. package/dist/adapter/first-party-systems.d.ts.map +1 -1
  18. package/dist/adapter/first-party-systems.js +10 -3
  19. package/dist/adapter/index.d.ts +7 -2
  20. package/dist/adapter/index.d.ts.map +1 -1
  21. package/dist/adapter/index.js +4 -0
  22. package/dist/adapter/ingest/contract-system-adapters.d.ts +1 -1
  23. package/dist/adapter/ingest/contract-system-adapters.d.ts.map +1 -1
  24. package/dist/adapter/ingest/contract-system-adapters.js +13 -25
  25. package/dist/adapter/ingest/game-contract-seams.d.ts +214 -0
  26. package/dist/adapter/ingest/game-contract-seams.d.ts.map +1 -0
  27. package/dist/adapter/ingest/game-contract-seams.js +62 -0
  28. package/dist/adapter/ingest/game-contract.d.ts +5 -3
  29. package/dist/adapter/ingest/game-contract.d.ts.map +1 -1
  30. package/dist/adapter/ingest/game-contract.js +4 -1
  31. package/dist/adapter/ingest/merge-debug-adapters.d.ts +52 -0
  32. package/dist/adapter/ingest/merge-debug-adapters.d.ts.map +1 -0
  33. package/dist/adapter/ingest/merge-debug-adapters.js +141 -0
  34. package/dist/adapter/ingest/observation-debug-adapter.d.ts +56 -0
  35. package/dist/adapter/ingest/observation-debug-adapter.d.ts.map +1 -0
  36. package/dist/adapter/ingest/observation-debug-adapter.js +131 -0
  37. package/dist/adapter/ingest/scene-capture.d.ts +38 -13
  38. package/dist/adapter/ingest/scene-capture.d.ts.map +1 -1
  39. package/dist/adapter/ingest/scene-capture.js +101 -24
  40. package/dist/adapter/ingest/visible-capture-window.d.ts +22 -5
  41. package/dist/adapter/ingest/visible-capture-window.d.ts.map +1 -1
  42. package/dist/adapter/ingest/visible-capture-window.js +46 -7
  43. package/dist/adapter/native-debug-module.d.ts +43 -0
  44. package/dist/adapter/native-debug-module.d.ts.map +1 -0
  45. package/dist/adapter/native-debug-module.js +230 -0
  46. package/dist/adapter/object3d-authoring-subject.d.ts +32 -0
  47. package/dist/adapter/object3d-authoring-subject.d.ts.map +1 -0
  48. package/dist/adapter/object3d-authoring-subject.js +25 -0
  49. package/dist/adapter/root-adapter.d.ts +25 -56
  50. package/dist/adapter/root-adapter.d.ts.map +1 -1
  51. package/dist/adapter/root-adapter.js +4 -20
  52. package/dist/adapter/root-seam-contract.d.ts +129 -0
  53. package/dist/adapter/root-seam-contract.d.ts.map +1 -0
  54. package/dist/adapter/root-seam-contract.js +37 -0
  55. package/dist/adapter/seam-evidence.d.ts +118 -0
  56. package/dist/adapter/seam-evidence.d.ts.map +1 -0
  57. package/dist/adapter/seam-evidence.js +231 -0
  58. package/dist/adapter/setup-three-root-adapter.d.ts +2 -3
  59. package/dist/adapter/setup-three-root-adapter.d.ts.map +1 -1
  60. package/dist/adapter/setup-three-root-adapter.js +11 -12
  61. package/dist/adapter/system-adapter.d.ts +6 -1
  62. package/dist/adapter/system-adapter.d.ts.map +1 -1
  63. package/dist/adapter/system-seam-contract.d.ts +354 -0
  64. package/dist/adapter/system-seam-contract.d.ts.map +1 -0
  65. package/dist/adapter/system-seam-contract.js +95 -0
  66. package/dist/animation/xstate-animation-binding.d.ts +6 -0
  67. package/dist/animation/xstate-animation-binding.d.ts.map +1 -1
  68. package/dist/animation/xstate-animation-binding.js +142 -4
  69. package/dist/asset-formats/collider.d.ts +1 -1
  70. package/dist/asset-formats/mesh.d.ts +2 -2
  71. package/dist/asset-formats/particles.d.ts +1 -1
  72. package/dist/canvas-react/engine-bridge.d.ts +6 -6
  73. package/dist/canvas-react/engine-bridge.d.ts.map +1 -1
  74. package/dist/canvas-react/engine-bridge.js +2 -2
  75. package/dist/canvas-react/index.d.ts +2 -2
  76. package/dist/canvas-react/index.d.ts.map +1 -1
  77. package/dist/canvas-react/index.js +1 -1
  78. package/dist/canvas-react/pixi-react-adapter.d.ts +15 -9
  79. package/dist/canvas-react/pixi-react-adapter.d.ts.map +1 -1
  80. package/dist/canvas-react/pixi-react-adapter.js +129 -64
  81. package/dist/canvas-react/pixi-react-root-factory.d.ts.map +1 -1
  82. package/dist/canvas-react/pixi-react-root-factory.js +4 -0
  83. package/dist/canvas-react/world-context.d.ts +22 -12
  84. package/dist/canvas-react/world-context.d.ts.map +1 -1
  85. package/dist/canvas-react/world-context.js +12 -51
  86. package/dist/data/curve.d.ts +1 -1
  87. package/dist/data/curve.js +2 -2
  88. package/dist/dev/instruments.d.ts +4 -4
  89. package/dist/dev/instruments.js +4 -4
  90. package/dist/dev/register-render-vitals.d.ts +2 -2
  91. package/dist/dev/register-render-vitals.js +2 -2
  92. package/dist/dev/static-batch-advisor.d.ts +1 -1
  93. package/dist/dev/static-batch-advisor.js +2 -2
  94. package/dist/ecs/user-data.d.ts +5 -0
  95. package/dist/ecs/user-data.d.ts.map +1 -1
  96. package/dist/ecs/user-data.js +3 -0
  97. package/dist/input/input-manager.d.ts +64 -0
  98. package/dist/input/input-manager.d.ts.map +1 -1
  99. package/dist/input/input-manager.js +149 -0
  100. package/dist/manifest/load.d.ts +0 -3
  101. package/dist/manifest/load.d.ts.map +1 -1
  102. package/dist/manifest/load.js +0 -4
  103. package/dist/manifest/schema.d.ts +9 -11
  104. package/dist/manifest/schema.d.ts.map +1 -1
  105. package/dist/manifest/schema.js +2 -23
  106. package/dist/pixi/authoring.d.ts +33 -0
  107. package/dist/pixi/authoring.d.ts.map +1 -1
  108. package/dist/pixi/authoring.js +301 -2
  109. package/dist/pixi/ingest.d.ts +2 -1
  110. package/dist/pixi/ingest.d.ts.map +1 -1
  111. package/dist/pixi/ingest.js +4 -2
  112. package/dist/pixi/scene-capture.d.ts +9 -1
  113. package/dist/pixi/scene-capture.d.ts.map +1 -1
  114. package/dist/pixi/scene-capture.js +9 -6
  115. package/dist/react/world-state.d.ts +12 -0
  116. package/dist/react/world-state.d.ts.map +1 -1
  117. package/dist/react/world-state.js +14 -0
  118. package/dist/render/particles-factory.d.ts +13 -6
  119. package/dist/render/particles-factory.d.ts.map +1 -1
  120. package/dist/render/particles-factory.js +6 -3
  121. package/dist/render/soft-particle-depth.d.ts +3 -3
  122. package/dist/render/soft-particle-depth.d.ts.map +1 -1
  123. package/dist/render/soft-particle-depth.js +8 -13
  124. package/dist/runtime/create-runtime.d.ts +25 -62
  125. package/dist/runtime/create-runtime.d.ts.map +1 -1
  126. package/dist/runtime/create-runtime.js +58 -105
  127. package/dist/runtime/dev-build.d.ts +37 -0
  128. package/dist/runtime/dev-build.d.ts.map +1 -0
  129. package/dist/runtime/dev-build.js +49 -0
  130. package/dist/runtime/game.d.ts +38 -72
  131. package/dist/runtime/game.d.ts.map +1 -1
  132. package/dist/runtime/game.js +40 -55
  133. package/dist/runtime/mount-game.d.ts.map +1 -1
  134. package/dist/runtime/mount-game.js +12 -1
  135. package/dist/runtime/mount-manifest.d.ts +0 -13
  136. package/dist/runtime/mount-manifest.d.ts.map +1 -1
  137. package/dist/runtime/mount-manifest.js +5 -25
  138. package/dist/runtime/types.d.ts +18 -0
  139. package/dist/runtime/types.d.ts.map +1 -1
  140. package/dist/setup/setup-renderer.d.ts +3 -4
  141. package/dist/setup/setup-renderer.d.ts.map +1 -1
  142. package/dist/setup/setup-renderer.js +3 -4
  143. package/dist/world3d-react/engine-bridge.d.ts +1 -1
  144. package/dist/world3d-react/engine-bridge.d.ts.map +1 -1
  145. package/dist/world3d-react/engine-bridge.js +29 -4
  146. package/dist/world3d-react/index.d.ts +1 -1
  147. package/dist/world3d-react/index.js +1 -1
  148. package/dist/world3d-react/r3f-adapter.d.ts +7 -0
  149. package/dist/world3d-react/r3f-adapter.d.ts.map +1 -1
  150. package/dist/world3d-react/r3f-adapter.js +132 -28
  151. package/dist/world3d-react/r3f-root-factory.d.ts.map +1 -1
  152. package/dist/world3d-react/r3f-root-factory.js +14 -0
  153. package/dist/world3d-react/rapier-physics-bridge.d.ts +4 -4
  154. package/dist/world3d-react/rapier-physics-bridge.js +3 -3
  155. package/dist/world3d-react/world-context.d.ts +52 -3
  156. package/dist/world3d-react/world-context.d.ts.map +1 -1
  157. package/dist/world3d-react/world-context.js +94 -64
  158. package/dist-config/config.js.map +1 -1
  159. package/package.json +1 -1
  160. package/schemas/engine-capabilities.json +8 -8
  161. package/schemas/vgai-project.schema.json +1 -6
  162. package/src/adapter/adapter-module.ts +405 -72
  163. package/src/adapter/authoring-seam-contract.ts +211 -0
  164. package/src/adapter/authoring.ts +242 -50
  165. package/src/adapter/entrypoint-selection-source.ts +159 -0
  166. package/src/adapter/finders/scenes-from-entrypoint-selection.ts +162 -36
  167. package/src/adapter/first-party-systems.ts +17 -3
  168. package/src/adapter/index.ts +51 -1
  169. package/src/adapter/ingest/contract-system-adapters.ts +26 -30
  170. package/src/adapter/ingest/game-contract-seams.ts +85 -0
  171. package/src/adapter/ingest/game-contract.ts +9 -4
  172. package/src/adapter/ingest/merge-debug-adapters.ts +193 -0
  173. package/src/adapter/ingest/observation-debug-adapter.ts +158 -0
  174. package/src/adapter/ingest/scene-capture.ts +126 -23
  175. package/src/adapter/ingest/visible-capture-window.ts +63 -9
  176. package/src/adapter/native-debug-module.ts +307 -0
  177. package/src/adapter/object3d-authoring-subject.ts +50 -0
  178. package/src/adapter/root-adapter.ts +25 -56
  179. package/src/adapter/root-seam-contract.ts +57 -0
  180. package/src/adapter/seam-evidence.ts +336 -0
  181. package/src/adapter/setup-three-root-adapter.ts +13 -15
  182. package/src/adapter/system-adapter.ts +6 -1
  183. package/src/adapter/system-seam-contract.ts +121 -0
  184. package/src/animation/xstate-animation-binding.ts +151 -4
  185. package/src/canvas-react/engine-bridge.ts +6 -6
  186. package/src/canvas-react/index.ts +2 -1
  187. package/src/canvas-react/pixi-react-adapter.tsx +143 -77
  188. package/src/canvas-react/pixi-react-root-factory.tsx +4 -0
  189. package/src/canvas-react/world-context.ts +26 -101
  190. package/src/data/curve.ts +2 -2
  191. package/src/dev/instruments.ts +4 -4
  192. package/src/dev/register-render-vitals.ts +2 -2
  193. package/src/dev/static-batch-advisor.ts +2 -2
  194. package/src/ecs/user-data.ts +5 -0
  195. package/src/input/input-manager.ts +145 -0
  196. package/src/manifest/load.ts +0 -7
  197. package/src/manifest/schema.ts +2 -25
  198. package/src/pixi/authoring.ts +329 -2
  199. package/src/pixi/ingest.ts +9 -2
  200. package/src/pixi/scene-capture.ts +20 -5
  201. package/src/react/world-state.tsx +15 -0
  202. package/src/render/particles-factory.ts +16 -6
  203. package/src/render/soft-particle-depth.ts +8 -13
  204. package/src/runtime/create-runtime.ts +79 -158
  205. package/src/runtime/dev-build.ts +49 -0
  206. package/src/runtime/game.ts +72 -113
  207. package/src/runtime/mount-game.ts +19 -1
  208. package/src/runtime/mount-manifest.ts +5 -37
  209. package/src/runtime/types.ts +22 -0
  210. package/src/setup/setup-renderer.ts +3 -4
  211. package/src/world3d-react/engine-bridge.ts +29 -4
  212. package/src/world3d-react/index.ts +1 -1
  213. package/src/world3d-react/r3f-adapter.tsx +140 -31
  214. package/src/world3d-react/r3f-root-factory.tsx +14 -0
  215. package/src/world3d-react/rapier-physics-bridge.tsx +4 -4
  216. package/src/world3d-react/world-context.ts +111 -87
  217. package/dist/runtime/dev-layers.d.ts +0 -34
  218. package/dist/runtime/dev-layers.d.ts.map +0 -1
  219. package/dist/runtime/dev-layers.js +0 -46
  220. package/src/runtime/dev-layers.ts +0 -46
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
2
  export declare const MeshDescriptorSchema: z.ZodObject<{
3
3
  type: z.ZodEnum<{
4
- capsule: "capsule";
5
- box: "box";
6
4
  sphere: "sphere";
5
+ box: "box";
6
+ capsule: "capsule";
7
7
  plane: "plane";
8
8
  cylinder: "cylinder";
9
9
  gltf: "gltf";
@@ -1387,8 +1387,8 @@ export declare const ParticlesDescriptorSchema: z.ZodObject<{
1387
1387
  anisotropy: z.ZodOptional<z.ZodNumber>;
1388
1388
  }, z.core.$strip>>;
1389
1389
  blending: z.ZodOptional<z.ZodEnum<{
1390
- additive: "additive";
1391
1390
  normal: "normal";
1391
+ additive: "additive";
1392
1392
  }>>;
1393
1393
  transparent: z.ZodOptional<z.ZodBoolean>;
1394
1394
  depthWrite: z.ZodOptional<z.ZodBoolean>;
@@ -12,17 +12,17 @@
12
12
  * engine services, `@pixi/react`'s own `useTick` is the per-frame hook, and
13
13
  * `useApplication` is the door to the live `Application`.
14
14
  */
15
- import type { GameContext } from '../runtime/types';
15
+ import type { CanvasGameContext } from './world-context';
16
16
  export interface EngineBridgeValue {
17
- /** This root's `GameContext` — `input`, `debug`, `random`, `clock`, `game`,
17
+ /** This root's `CanvasGameContext` — `input`, `debug`, `random`, `clock`, `game`,
18
18
  * `roots`, `systems`, `registerSystemAdapter`. Present so ordinary
19
19
  * components can reach engine services with a HOOK (see
20
20
  * {@link useGameContext}). */
21
- readonly ctx?: GameContext | undefined;
21
+ readonly ctx?: CanvasGameContext | undefined;
22
22
  }
23
23
  export declare const EngineBridge: import("react").Context<EngineBridgeValue | null>;
24
24
  /**
25
- * This canvas root's `GameContext`, for use inside any component in the tree.
25
+ * This canvas root's `CanvasGameContext`, for use inside any component in the tree.
26
26
  *
27
27
  * An ordinary component does what a model would write:
28
28
  *
@@ -31,7 +31,7 @@ export declare const EngineBridge: import("react").Context<EngineBridgeValue | n
31
31
  * const { input } = useGameContext();
32
32
  * const ref = useRef<Sprite>(null);
33
33
  * useTick(({ deltaMS }) => {
34
- * if (input.isPressed('move_right')) ref.current!.x += speed * (deltaMS / 1000);
34
+ * if (input?.isPressed('move_right')) ref.current!.x += speed * (deltaMS / 1000);
35
35
  * });
36
36
  * return <pixiSprite ref={ref} texture={Texture.WHITE} />;
37
37
  * }
@@ -41,5 +41,5 @@ export declare const EngineBridge: import("react").Context<EngineBridgeValue | n
41
41
  * `createPixiReactAdapter` — absent context is a wiring bug, and a silent
42
42
  * `null` would surface as a mystery `undefined` deep in a tick callback.
43
43
  */
44
- export declare function useGameContext(): GameContext;
44
+ export declare function useGameContext(): CanvasGameContext;
45
45
  //# sourceMappingURL=engine-bridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-bridge.d.ts","sourceRoot":"","sources":["../../src/canvas-react/engine-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IAChC;;;mCAG+B;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACxC;AAED,eAAO,MAAM,YAAY,mDAAgD,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAU5C"}
1
+ {"version":3,"file":"engine-bridge.d.ts","sourceRoot":"","sources":["../../src/canvas-react/engine-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,WAAW,iBAAiB;IAChC;;;mCAG+B;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;CAC9C;AAED,eAAO,MAAM,YAAY,mDAAgD,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,IAAI,iBAAiB,CAUlD"}
@@ -15,7 +15,7 @@
15
15
  import { createContext, useContext } from 'react';
16
16
  export const EngineBridge = createContext(null);
17
17
  /**
18
- * This canvas root's `GameContext`, for use inside any component in the tree.
18
+ * This canvas root's `CanvasGameContext`, for use inside any component in the tree.
19
19
  *
20
20
  * An ordinary component does what a model would write:
21
21
  *
@@ -24,7 +24,7 @@ export const EngineBridge = createContext(null);
24
24
  * const { input } = useGameContext();
25
25
  * const ref = useRef<Sprite>(null);
26
26
  * useTick(({ deltaMS }) => {
27
- * if (input.isPressed('move_right')) ref.current!.x += speed * (deltaMS / 1000);
27
+ * if (input?.isPressed('move_right')) ref.current!.x += speed * (deltaMS / 1000);
28
28
  * });
29
29
  * return <pixiSprite ref={ref} texture={Texture.WHITE} />;
30
30
  * }
@@ -22,7 +22,7 @@
22
22
  * - `PixiPrimitive` / `adoptNow` — the canvas surface's `<primitive object={…}>`:
23
23
  * render a container the game already owns, and place a spawn in the
24
24
  * display tree ahead of the commit that renders it.
25
- * - `useGameContext()` — this root's `GameContext` (`input`, `debug`,
25
+ * - `useGameContext()` — this root's `CanvasGameContext` (`input`, `debug`,
26
26
  * `random`, `clock`, `game`, `roots`) from inside any component in the tree.
27
27
  * Behavior in a canvas world is components + hooks, never a class under a
28
28
  * string key.
@@ -38,5 +38,5 @@ export { EngineBridge, type EngineBridgeValue, useGameContext } from './engine-b
38
38
  export { adoptNow, PixiPrimitive, type PixiPrimitiveProps } from './pixi-primitive';
39
39
  export { type CreatePixiReactAdapterOptions, createPixiReactAdapter, } from './pixi-react-adapter';
40
40
  export { pixiReactRootFactory, resolveCanvasEntryAdapter } from './pixi-react-root-factory';
41
- export { type CanvasRootContextOptions, type CanvasRootRuntime, createCanvasRootContext, DEFAULT_INPUT_MAP_PATH, } from './world-context';
41
+ export { type CanvasGameContext, type CanvasRootContextOptions, type CanvasRootRuntime, createCanvasRootContext, DEFAULT_INPUT_MAP_PATH, } from './world-context';
42
42
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canvas-react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,KAAK,6BAA6B,EAClC,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canvas-react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,KAAK,6BAA6B,EAClC,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC"}
@@ -22,7 +22,7 @@
22
22
  * - `PixiPrimitive` / `adoptNow` — the canvas surface's `<primitive object={…}>`:
23
23
  * render a container the game already owns, and place a spawn in the
24
24
  * display tree ahead of the commit that renders it.
25
- * - `useGameContext()` — this root's `GameContext` (`input`, `debug`,
25
+ * - `useGameContext()` — this root's `CanvasGameContext` (`input`, `debug`,
26
26
  * `random`, `clock`, `game`, `roots`) from inside any component in the tree.
27
27
  * Behavior in a canvas world is components + hooks, never a class under a
28
28
  * string key.
@@ -6,20 +6,20 @@
6
6
  * this returns a `MountedPixiRoot` (`../adapter/root-adapter.ts`) whose `stage`
7
7
  * is the REAL `PIXI.Container` the reconciler renders into.
8
8
  *
9
- * This is the canvas surface's exact sibling of `world3d-react`'s
9
+ * This is the canvas surface's sibling of `world3d-react`'s
10
10
  * `createR3FAdapter`, with `@pixi/react` where that one has
11
- * react-three-fiber. Everything structural is the same, because the seam is
12
- * the same: one loop (the host's), one canvas (the host's), a world-local
13
- * `SystemRunner` ticked in engine phase order before the renderer advances,
14
- * and a `GameContext` threaded into the tree through `EngineBridge`.
11
+ * react-three-fiber. The explicit factory still supplies the engine context
12
+ * used by the current first-party Canvas examples while their app-owned input
13
+ * and debugger migration remains tracked in `docs/WORK.md`; `useTick` hooks
14
+ * stay registered on Pixi's real ticker throughout that migration.
15
15
  *
16
16
  * ## The loop contract
17
17
  *
18
18
  * `Application` is initialized with `autoStart: false` and `sharedTicker:
19
- * false`, so it owns a ticker that is NEVER started and therefore never
20
- * requests an animation frame. `mounted.update(dt)` is the only thing that
21
- * advances it, and it feeds GAME time, not wall time — which is what makes the
22
- * world freeze exactly when the host freezes it, and what makes
19
+ * false`, so it owns a native Pixi ticker that is NEVER started and therefore
20
+ * never requests an animation frame. `mounted.update(dt)` is the only thing
21
+ * that advances that ticker, and it feeds GAME time, not wall time — which is
22
+ * what makes the world freeze exactly when the host freezes it, and what makes
23
23
  * `game.waitSimTime` work in a hidden tab (a hidden tab has no rAF; the engine
24
24
  * loop's own catch-up still calls `update`, and Pixi has no independent clock
25
25
  * to disagree with it).
@@ -50,6 +50,12 @@ export interface CreatePixiReactAdapterOptions {
50
50
  * actions). A missing/invalid map degrades loudly without failing the
51
51
  * mount — see `world-context.ts`. */
52
52
  readonly inputMapPath?: string | null | undefined;
53
+ /**
54
+ * Transitional compatibility for component trees that still consume the
55
+ * engine context. Native trees opt out once their input, observation and
56
+ * debugger state are application-owned.
57
+ */
58
+ readonly engineRuntime?: boolean | undefined;
53
59
  /**
54
60
  * Extra `Application.init` options merged UNDER this adapter's own — e.g.
55
61
  * `{ antialias: false }`, `{ roundPixels: true }`. The loop-critical ones
@@ -1 +1 @@
1
- {"version":3,"file":"pixi-react-adapter.d.ts","sourceRoot":"","sources":["../../src/canvas-react/pixi-react-adapter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,KAAK,EAAe,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE/D,OAAO,EAAiB,KAAK,SAAS,EAAmB,MAAM,OAAO,CAAC;AACvE,OAAO,KAAK,EAAsC,WAAW,EAAE,MAAM,YAAY,CAAC;AAyBlF,sFAAsF;AACtF,MAAM,WAAW,6BAA6B;IAC5C,qEAAqE;IACrE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;yDACqD;IACrD,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B;;;;0CAIsC;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClD;;;;;;;;OAQG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC;CACvE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,6BAA6B,GACrC,WAAW,CAAC,QAAQ,CAAC,CA8LvB"}
1
+ {"version":3,"file":"pixi-react-adapter.d.ts","sourceRoot":"","sources":["../../src/canvas-react/pixi-react-adapter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,KAAK,EAAe,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE/D,OAAO,EAA2B,KAAK,SAAS,EAA8B,MAAM,OAAO,CAAC;AAC5F,OAAO,KAAK,EAAsC,WAAW,EAAE,MAAM,YAAY,CAAC;AA2BlF,sFAAsF;AACtF,MAAM,WAAW,6BAA6B;IAC5C,qEAAqE;IACrE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;yDACqD;IACrD,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B;;;;0CAIsC;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClD;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7C;;;;;;;;OAQG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC;CACvE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,6BAA6B,GACrC,WAAW,CAAC,QAAQ,CAAC,CAwPvB"}
@@ -6,20 +6,20 @@
6
6
  * this returns a `MountedPixiRoot` (`../adapter/root-adapter.ts`) whose `stage`
7
7
  * is the REAL `PIXI.Container` the reconciler renders into.
8
8
  *
9
- * This is the canvas surface's exact sibling of `world3d-react`'s
9
+ * This is the canvas surface's sibling of `world3d-react`'s
10
10
  * `createR3FAdapter`, with `@pixi/react` where that one has
11
- * react-three-fiber. Everything structural is the same, because the seam is
12
- * the same: one loop (the host's), one canvas (the host's), a world-local
13
- * `SystemRunner` ticked in engine phase order before the renderer advances,
14
- * and a `GameContext` threaded into the tree through `EngineBridge`.
11
+ * react-three-fiber. The explicit factory still supplies the engine context
12
+ * used by the current first-party Canvas examples while their app-owned input
13
+ * and debugger migration remains tracked in `docs/WORK.md`; `useTick` hooks
14
+ * stay registered on Pixi's real ticker throughout that migration.
15
15
  *
16
16
  * ## The loop contract
17
17
  *
18
18
  * `Application` is initialized with `autoStart: false` and `sharedTicker:
19
- * false`, so it owns a ticker that is NEVER started and therefore never
20
- * requests an animation frame. `mounted.update(dt)` is the only thing that
21
- * advances it, and it feeds GAME time, not wall time — which is what makes the
22
- * world freeze exactly when the host freezes it, and what makes
19
+ * false`, so it owns a native Pixi ticker that is NEVER started and therefore
20
+ * never requests an animation frame. `mounted.update(dt)` is the only thing
21
+ * that advances that ticker, and it feeds GAME time, not wall time — which is
22
+ * what makes the world freeze exactly when the host freezes it, and what makes
23
23
  * `game.waitSimTime` work in a hidden tab (a hidden tab has no rAF; the engine
24
24
  * loop's own catch-up still calls `update`, and Pixi has no independent clock
25
25
  * to disagree with it).
@@ -36,8 +36,9 @@
36
36
  */
37
37
  import { createRoot, extend } from '@pixi/react';
38
38
  import * as PIXI from 'pixi.js';
39
- import { createElement, useLayoutEffect } from 'react';
39
+ import { createElement, Fragment, useEffect, useLayoutEffect } from 'react';
40
40
  import { WorldProvider } from '../react/world-state';
41
+ import { getDebugRegistry } from '../runtime/debug-registry';
41
42
  import { EngineBridge } from './engine-bridge';
42
43
  import { createCanvasRootContext } from './world-context';
43
44
  /** How long `mount()` waits for the tree's first commit before failing loudly
@@ -61,18 +62,18 @@ const MOUNTED_CANVASES = new WeakSet();
61
62
  * `requestAnimationFrame` loop.
62
63
  */
63
64
  export function createPixiReactAdapter(options) {
64
- const { id, content, inputMapPath, applicationOptions } = options;
65
+ const { id, content, inputMapPath, engineRuntime = true, applicationOptions } = options;
65
66
  return {
66
67
  id,
67
68
  async mount(host) {
68
- const runtime = createCanvasRootContext(host, { id, inputMapPath });
69
- const bridge = { ctx: runtime.ctx };
69
+ const runtime = engineRuntime ? createCanvasRootContext(host, { id, inputMapPath }) : null;
70
+ const bridge = runtime ? { ctx: runtime.ctx } : null;
70
71
  // Actions must exist before any component's first tick reads them — wait
71
72
  // for the (never-rejecting) input-map load before the first commit.
72
- await runtime.inputMapReady;
73
+ await runtime?.inputMapReady;
73
74
  const canvas = host.canvas;
74
75
  if (MOUNTED_CANVASES.has(canvas)) {
75
- runtime.dispose();
76
+ runtime?.dispose();
76
77
  throw new Error(`createPixiReactAdapter: root "${id}" was handed a canvas this lane has already ` +
77
78
  'mounted. @pixi/react keys its reconciler roots off the canvas element, so re-using ' +
78
79
  'one would resurrect a root whose Application is destroyed. Hand each mount a fresh ' +
@@ -85,6 +86,10 @@ export function createPixiReactAdapter(options) {
85
86
  const committed = new Promise((resolve) => {
86
87
  resolveCommitted = resolve;
87
88
  });
89
+ let resolveEffectsReady;
90
+ const effectsReady = new Promise((resolve) => {
91
+ resolveEffectsReady = resolve;
92
+ });
88
93
  let resolveUnmounted;
89
94
  const unmounted = new Promise((resolve) => {
90
95
  resolveUnmounted = resolve;
@@ -108,16 +113,38 @@ export function createPixiReactAdapter(options) {
108
113
  resolveCommitted();
109
114
  return resolveUnmounted;
110
115
  }, []);
116
+ // This component is the last sibling. Reaching its passive effect
117
+ // means the initial tree's useDebugProvider/useDebugCommand effects
118
+ // have registered, so mount() can truthfully back Play's ack.
119
+ useEffect(resolveEffectsReady, []);
111
120
  return null;
112
121
  }
113
- const game = runtime.ctx.game;
114
122
  // The React seam every dom root already has — `useWorldState`,
115
123
  // `useDebugProvider`/`useDebugCommand`/`useDebugEmit`
116
124
  // (`../react/world-state`) — works identically inside a canvas root
117
125
  // because a canvas root IS React. `host.game` is genuinely absent in
118
126
  // bare/foreign hosts, so the provider is conditional and those hooks
119
127
  // stay the inert no-ops they already document themselves to be.
120
- const element = createElement(EngineBridge.Provider, { value: bridge }, game ? createElement(WorldProvider, { game }, content) : content, createElement(Lifecycle));
128
+ //
129
+ // READ FROM `host.game`, NEVER FROM `runtime` — the same rule, and the
130
+ // same reasoning, as the three lane's (`../world3d-react/r3f-adapter.tsx`,
131
+ // beside its own `const game = host.game`). The two providers answer
132
+ // different questions: `EngineBridge` rides `bridge` (the vgai runtime
133
+ // CONTEXT, which must not enter an ecosystem-native tree), `WorldProvider`
134
+ // rides the Game handle the host already holds. Keyed off `runtime`, a
135
+ // world mounted with `engineRuntime: false` gets no `WorldProvider` at
136
+ // all and every `useDebugProvider` in it no-ops IN SILENCE — no error, and
137
+ // `vgai eval 'await game.providers()'` lists only the built-ins. That is
138
+ // exactly what happened on the three lane. It has never fired here only
139
+ // because `pixi-react-root-factory.tsx` still leaves the runtime on;
140
+ // that flag is the tracked component-root migration's to flip, and this
141
+ // seam must not be waiting for it.
142
+ const game = host.game;
143
+ const world = createElement(Fragment, null, content, createElement(Lifecycle));
144
+ const provided = game ? createElement(WorldProvider, { game }, world) : world;
145
+ const element = bridge
146
+ ? createElement(EngineBridge.Provider, { value: bridge }, provided)
147
+ : provided;
121
148
  const root = createRoot(canvas);
122
149
  // The host owns size, dpr, transparency and capture cost; the loop
123
150
  // contract owns `autoStart`/`sharedTicker`. Both are applied AFTER the
@@ -136,69 +163,101 @@ export function createPixiReactAdapter(options) {
136
163
  autoStart: false,
137
164
  sharedTicker: false,
138
165
  };
139
- // `root.render` is async: it awaits `Application.init()` (which is what
140
- // creates the renderer) and only then hands the tree to the reconciler.
141
- // A crash inside init rejects here, which is the loud failure we want.
142
- const app = await root.render(element, initOptions);
143
- runtime.setApplication(app);
144
- // A reconcile-time crash (e.g. an un-extended component) surfaces as an
145
- // uncaught window error and the first commit never lands — without this
146
- // guard `mount()` would await `committed` forever. Convert that class of
147
- // failure into a loud mount error.
148
- await new Promise((resolve, reject) => {
149
- const fail = (why) => {
150
- cleanup();
151
- try {
152
- app.destroy(false, { children: true });
153
- }
154
- catch {
155
- /* the world never fully came up; teardown failure must not mask why */
156
- }
157
- runtime.dispose();
158
- reject(new Error(`createPixiReactAdapter: root "${id}" — ${why}`));
159
- };
160
- const onError = (event) => fail(`the Pixi tree crashed before its first commit — ${event.message} ` +
166
+ // Install the reconcile-error listener BEFORE `root.render`: Pixi hands
167
+ // the Application back after `init()` but React can already have thrown
168
+ // during that same turn. Attaching after the await loses the real error
169
+ // and turns it into a misleading ten-second timeout.
170
+ let reportReconcileFailure;
171
+ const reconcileFailure = new Promise((resolve) => {
172
+ reportReconcileFailure = resolve;
173
+ });
174
+ const onError = (event) => {
175
+ reportReconcileFailure(`the Pixi tree crashed before its first commit — ${event.message} ` +
161
176
  '(mount() fails loudly instead of hanging)');
162
- const timer = setTimeout(() => fail(`no first commit within ${FIRST_COMMIT_TIMEOUT_MS / 1000}s ` +
163
- '(mount() fails loudly instead of hanging)'), FIRST_COMMIT_TIMEOUT_MS);
164
- const cleanup = () => {
165
- clearTimeout(timer);
166
- globalThis.removeEventListener?.('error', onError);
167
- };
168
- globalThis.addEventListener?.('error', onError);
169
- void committed.then(() => {
170
- cleanup();
171
- resolve();
177
+ };
178
+ globalThis.addEventListener?.('error', onError);
179
+ let app;
180
+ let timer;
181
+ try {
182
+ // `root.render` is async: it awaits `Application.init()` (which is what
183
+ // creates the renderer) and only then hands the tree to the reconciler.
184
+ // A crash inside init rejects here, which is the loud failure we want.
185
+ const renderedApp = await root.render(element, initOptions);
186
+ app = renderedApp;
187
+ runtime?.setApplication(renderedApp);
188
+ // A reconcile-time crash (e.g. an un-extended component) surfaces as
189
+ // an uncaught window error and the first commit never lands. Race that
190
+ // exact signal against the commit and the last-resort ceiling.
191
+ const timeout = new Promise((resolve) => {
192
+ timer = setTimeout(() => resolve(`no first commit within ${FIRST_COMMIT_TIMEOUT_MS / 1000}s ` +
193
+ '(mount() fails loudly instead of hanging)'), FIRST_COMMIT_TIMEOUT_MS);
172
194
  });
173
- });
195
+ const failure = await Promise.race([
196
+ Promise.all([committed, effectsReady]).then(() => null),
197
+ reconcileFailure,
198
+ timeout,
199
+ ]);
200
+ if (failure !== null) {
201
+ throw new Error(`createPixiReactAdapter: root "${id}" — ${failure}`);
202
+ }
203
+ }
204
+ catch (error) {
205
+ try {
206
+ app?.destroy(false, { children: true });
207
+ }
208
+ catch {
209
+ /* the world never fully came up; teardown failure must not mask why */
210
+ }
211
+ runtime?.dispose();
212
+ throw error;
213
+ }
214
+ finally {
215
+ if (timer !== undefined)
216
+ clearTimeout(timer);
217
+ globalThis.removeEventListener?.('error', onError);
218
+ }
219
+ // `app` is assigned before the first-commit race. Reaching here proves
220
+ // both initialization and commit succeeded, so narrow once for the live
221
+ // mounted-root methods below.
222
+ if (app === undefined) {
223
+ runtime?.dispose();
224
+ throw new Error(`createPixiReactAdapter: root "${id}" initialized without an Application`);
225
+ }
226
+ const mountedApp = app;
174
227
  // Pin the ticker's clock to GAME time. `Ticker.lastTime` starts at -1, so
175
228
  // without this the first `update()` would report a 1ms phantom delta on
176
229
  // top of the real one. From here every `deltaMS` a `useTick` callback
177
230
  // sees is exactly the `dt` the host handed us — no wall clock anywhere,
178
231
  // which is what makes a paused world's resume frame ordinary rather than
179
232
  // one giant catch-up step.
180
- app.ticker.lastTime = 0;
233
+ mountedApp.ticker.lastTime = 0;
181
234
  let elapsedMs = 0;
182
235
  let disposed = false;
236
+ const registry = host.game ? getDebugRegistry(host.game) : null;
237
+ const systemAdapters = runtime?.systemAdapters ?? (registry ? { debug: registry.adapter } : {});
238
+ const disposeComplete = unmounted.then(() => {
239
+ mountedApp.destroy(false, { children: true });
240
+ });
183
241
  return {
184
242
  kind: 'canvas',
185
243
  // The reconciler's real root container — the same `PIXI.Container`
186
244
  // `RootInstance.pixiStage()` hands the editor.
187
- stage: app.stage,
245
+ stage: mountedApp.stage,
188
246
  drivesOwnLoop: false,
189
- // Adapter surface: `debug` pre-seeded (the shared game registry's
190
- // adapter); game code adds capabilities via `ctx.registerSystemAdapter`.
191
- systems: runtime.systemAdapters,
247
+ // Adapter surface: the host's shared debug registry. A native component
248
+ // tree registers nothing; its entry-module `debug` export is projected
249
+ // after mount by the shared native adapter.
250
+ systems: systemAdapters,
251
+ disposeComplete,
192
252
  update(dt) {
193
253
  if (disposed)
194
254
  return;
195
255
  elapsedMs += dt * 1000;
196
- // Engine phases FIRST (registered systems mutate transforms), then
197
- // the ticker so `useTick` callbacks and the render that follows
198
- // them at `UPDATE_PRIORITY.LOW` both see the fresh state. Both are
199
- // host-gated: neither runs while this world is frozen.
200
- runtime.systems.run(dt);
201
- app.ticker.update(elapsedMs);
256
+ // The optional legacy runtime drains first when explicitly enabled;
257
+ // the native path has none. The real Pixi ticker remains the one
258
+ // scheduler `useTick` observes, and the host only gates/advances it.
259
+ runtime?.systems.run(dt);
260
+ mountedApp.ticker.update(elapsedMs);
202
261
  },
203
262
  resize(width, height) {
204
263
  if (disposed)
@@ -206,12 +265,19 @@ export function createPixiReactAdapter(options) {
206
265
  // `autoDensity: true` makes Pixi re-stamp `canvas.style.width`/
207
266
  // `.height` from this call, so the on-screen box follows the logical
208
267
  // size with no explicit CSS write from the host.
209
- app.renderer.resize(width, height);
268
+ mountedApp.renderer.resize(width, height);
210
269
  },
211
270
  dispose() {
212
271
  if (disposed)
213
272
  return;
214
273
  disposed = true;
274
+ // Pixi's EventSystem owns document.pointermove + window.pointerup
275
+ // (and its event ticker's global listener). React's deletion commit
276
+ // is asynchronous, so waiting to destroy the Application leaves
277
+ // those listeners live when the host audits this game realm. Detach
278
+ // the input target synchronously; the later Application.destroy()
279
+ // repeats this idempotently after every useTick cleanup has landed.
280
+ mountedApp.renderer.events.setTargetElement(null);
215
281
  // Rendering `null` children is the only unmount path `@pixi/react`
216
282
  // exposes publicly (its `unmountRoot` helper is internal), and React
217
283
  // commits that deletion on its own schedule — NOT synchronously. So
@@ -220,8 +286,7 @@ export function createPixiReactAdapter(options) {
220
286
  // a ticker destroyed before it lands throws inside React's commit.
221
287
  // `removeView` stays false — the canvas belongs to the HOST.
222
288
  void root.render(null, initOptions);
223
- void unmounted.then(() => app.destroy(false, { children: true }));
224
- runtime.dispose();
289
+ runtime?.dispose();
225
290
  },
226
291
  };
227
292
  },
@@ -1 +1 @@
1
- {"version":3,"file":"pixi-react-root-factory.d.ts","sourceRoot":"","sources":["../../src/canvas-react/pixi-react-root-factory.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAUnE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,MAAM,GACb,WAAW,CAAC,QAAQ,CAAC,GAAG,IAAI,CAU9B;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,qBAQlC,CAAC"}
1
+ {"version":3,"file":"pixi-react-root-factory.d.ts","sourceRoot":"","sources":["../../src/canvas-react/pixi-react-root-factory.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAUnE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,MAAM,GACb,WAAW,CAAC,QAAQ,CAAC,GAAG,IAAI,CAc9B;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,qBAQlC,CAAC"}
@@ -53,6 +53,10 @@ export function resolveCanvasEntryAdapter(entryModule, rootId) {
53
53
  return createPixiReactAdapter({
54
54
  id: rootId,
55
55
  content: createElement(mod.default),
56
+ // The supported Canvas portfolio still consumes the compatibility
57
+ // context. Removing it belongs to the tracked component-root migration;
58
+ // disabling it here first made every current default-exported game fail
59
+ // to mount before that migration had happened.
56
60
  });
57
61
  }
58
62
  return null;
@@ -11,7 +11,8 @@
11
11
  * the ONE game-scoped registry (`getDebugRegistry(host.game)`), so a
12
12
  * component's effect can `ctx.debug.registerStateProvider(...)` and be
13
13
  * visible to `vgai eval`/the editor's debug panels.
14
- * 2. **`ctx.input` is the game-owned `InputManager`** (`host.game.input` the
14
+ * 2. **`ctx.input` is the game-owned `InputManager` when a Game hosts the
15
+ * root** (`host.game.input` — the
15
16
  * same instance every sibling root shares), and this module registers the
16
17
  * per-world debug-registry seams (`setVirtualInputTarget`/
17
18
  * `setInputActionsSource`/`setInputTraceSource`) that make `game.input.*`
@@ -19,13 +20,14 @@
19
20
  * `DEBUG_INPUT_UNAVAILABLE`. The project's input map loads through
20
21
  * `Game.loadInputMap` (the game-owned, load-once path every root shares).
21
22
  * A missing/unparseable map degrades LOUDLY without failing the mount — a
22
- * canvas world with no declared actions is legal.
23
- * 3. **Absent subsystems fail loudly at the ctx surface.** A canvas world
24
- * builds no THREE scene/camera, no Rapier world, no composer, no first-party
25
- * audio/particles/debug-draw, and is handed no `AssetCache` (the canvas host
26
- * context carries none — see `adapter/host-context.ts`). Reading those
27
- * `ctx` fields yields a throwing getter naming the limitation and the
28
- * sanctioned alternative, never a silent `undefined`.
23
+ * canvas world with no declared actions is legal. A bare/foreign mount
24
+ * receives `null`, visibly in the type, rather than a throwing getter.
25
+ * 3. **Absent subsystems are absent from the type.** A canvas world builds no
26
+ * THREE scene/camera, Rapier world, composer, first-party audio/particles/
27
+ * debug-draw, or Three-flavoured `AssetCache`. Its explicit
28
+ * {@link CanvasGameContext} cannot name those fields, so misuse fails at
29
+ * the call site during typechecking instead of from a throwing getter at
30
+ * runtime.
29
31
  *
30
32
  * The Pixi handles themselves are deliberately NOT re-exposed here: a component
31
33
  * reaches the live `Application` (and therefore `app.stage`, `app.renderer`,
@@ -36,8 +38,9 @@
36
38
  import type { Application } from 'pixi.js';
37
39
  import type { CanvasHostContext } from '../adapter';
38
40
  import type { SystemAdapters } from '../adapter/system-adapter';
41
+ import type { SimClock } from '../core/sim-clock';
39
42
  import { createSystemRunner } from '../core/system-runner';
40
- import type { GameContext } from '../runtime/types';
43
+ import type { ComponentContextBase } from '../runtime/types';
41
44
  /** The conventional input-map location every scaffolded project ships. Shared
42
45
  * verbatim with the three lane — a project has ONE input map, whatever surface
43
46
  * reads it. */
@@ -55,12 +58,19 @@ export interface CanvasRootContextOptions {
55
58
  */
56
59
  readonly inputMapPath?: string | null | undefined;
57
60
  }
61
+ /** The engine services a Canvas component genuinely receives. Pixi's own
62
+ * `useApplication()` and `Assets` remain the doors to rendering and assets.
63
+ * `disposeAfter` is excluded because it accepts a `THREE.Object3D`; Canvas
64
+ * code schedules `displayObject.destroy()` with `clock.after()` instead. */
65
+ export type CanvasGameContext = ComponentContextBase & {
66
+ readonly clock: Omit<SimClock, 'disposeAfter'>;
67
+ };
58
68
  /** What {@link createCanvasRootContext} returns — the engine runtime one canvas
59
69
  * world owns, plus the wiring hooks the adapter's `mount()` drives. */
60
70
  export interface CanvasRootRuntime {
61
- /** The (partial, loud-on-absence) `GameContext` this world's components read
62
- * through `useGameContext`. See this module's header for what is present. */
63
- readonly ctx: GameContext;
71
+ /** The explicit Canvas context this world's components read through
72
+ * `useGameContext`. See {@link CanvasGameContext}. */
73
+ readonly ctx: CanvasGameContext;
64
74
  /** The world-local phase runner `mount().update(dt)` ticks. */
65
75
  readonly systems: ReturnType<typeof createSystemRunner>;
66
76
  /** The mounted world's `SystemAdapters` bag (`mounted.systems`) —
@@ -1 +1 @@
1
- {"version":3,"file":"world-context.d.ts","sourceRoot":"","sources":["../../src/canvas-react/world-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAOhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAM3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;gBAEgB;AAChB,eAAO,MAAM,sBAAsB,qCAAqC,CAAC;AAEzE,MAAM,WAAW,wBAAwB;IACvC;6BACyB;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACnD;AAED;wEACwE;AACxE,MAAM,WAAW,iBAAiB;IAChC;kFAC8E;IAC9E,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;IACxD;6EACyE;IACzE,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC;qEACiE;IACjE,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC;gFAC4E;IAC5E,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC,6EAA6E;IAC7E,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC;;8CAE0C;IAC1C,OAAO,IAAI,IAAI,CAAC;CACjB;AA4BD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,wBAAwB,GAChC,iBAAiB,CAoMnB"}
1
+ {"version":3,"file":"world-context.d.ts","sourceRoot":"","sources":["../../src/canvas-react/world-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAM3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D;;gBAEgB;AAChB,eAAO,MAAM,sBAAsB,qCAAqC,CAAC;AAEzE,MAAM,WAAW,wBAAwB;IACvC;6BACyB;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACnD;AAED;;;4EAG4E;AAC5E,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAAG;IACrD,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;CAChD,CAAC;AAEF;wEACwE;AACxE,MAAM,WAAW,iBAAiB;IAChC;2DACuD;IACvD,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;IAChC,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;IACxD;6EACyE;IACzE,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC;qEACiE;IACjE,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC;gFAC4E;IAC5E,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC,6EAA6E;IAC7E,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC;;8CAE0C;IAC1C,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,wBAAwB,GAChC,iBAAiB,CAwInB"}