@vgai/engine 0.5.22 → 0.5.24

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 (303) hide show
  1. package/README.md +6 -3
  2. package/dist/adapter/adapter-module.d.ts.map +1 -1
  3. package/dist/adapter/adapter-module.js +2 -4
  4. package/dist/adapter/adapter-surface.d.ts +1 -1
  5. package/dist/adapter/adapter-surface.js +1 -1
  6. package/dist/adapter/authoring.d.ts +19 -21
  7. package/dist/adapter/authoring.d.ts.map +1 -1
  8. package/dist/adapter/authoring.js +2 -2
  9. package/dist/adapter/binding.d.ts +341 -0
  10. package/dist/adapter/binding.d.ts.map +1 -0
  11. package/dist/adapter/binding.js +148 -0
  12. package/dist/adapter/colyseus-networking-adapter.d.ts.map +1 -1
  13. package/dist/adapter/colyseus-networking-adapter.js +23 -4
  14. package/dist/adapter/entrypoint-selection-readers.d.ts +24 -0
  15. package/dist/adapter/entrypoint-selection-readers.d.ts.map +1 -0
  16. package/dist/adapter/entrypoint-selection-readers.js +63 -0
  17. package/dist/adapter/entrypoint-selection-source.d.ts.map +1 -1
  18. package/dist/adapter/entrypoint-selection-source.js +1 -44
  19. package/dist/adapter/finders/scenes-from-entrypoint-selection.d.ts.map +1 -1
  20. package/dist/adapter/finders/scenes-from-entrypoint-selection.js +1 -52
  21. package/dist/adapter/host-context.d.ts +46 -15
  22. package/dist/adapter/host-context.d.ts.map +1 -1
  23. package/dist/adapter/host-context.js +2 -9
  24. package/dist/adapter/index.d.ts +11 -12
  25. package/dist/adapter/index.d.ts.map +1 -1
  26. package/dist/adapter/index.js +9 -10
  27. package/dist/adapter/ingest/game-contract-seams.d.ts +5 -0
  28. package/dist/adapter/ingest/game-contract-seams.d.ts.map +1 -1
  29. package/dist/adapter/ingest/game-contract-seams.js +1 -0
  30. package/dist/adapter/ingest/game-contract.d.ts +22 -3
  31. package/dist/adapter/ingest/game-contract.d.ts.map +1 -1
  32. package/dist/adapter/ingest/game-contract.js +0 -3
  33. package/dist/adapter/ingest/scene-capture.d.ts +19 -23
  34. package/dist/adapter/ingest/scene-capture.d.ts.map +1 -1
  35. package/dist/adapter/ingest/scene-capture.js +143 -17
  36. package/dist/adapter/ingest/visible-capture-window.d.ts +34 -0
  37. package/dist/adapter/ingest/visible-capture-window.d.ts.map +1 -1
  38. package/dist/adapter/native-debug-module.d.ts +40 -5
  39. package/dist/adapter/native-debug-module.d.ts.map +1 -1
  40. package/dist/adapter/native-debug-module.js +36 -9
  41. package/dist/adapter/rapier-physics-adapter.d.ts +31 -1
  42. package/dist/adapter/rapier-physics-adapter.d.ts.map +1 -1
  43. package/dist/adapter/rapier-physics-adapter.js +50 -36
  44. package/dist/adapter/renderer-config.d.ts +2 -2
  45. package/dist/adapter/renderer-config.js +2 -2
  46. package/dist/adapter/root-adapter.d.ts +7 -7
  47. package/dist/adapter/root-adapter.js +4 -4
  48. package/dist/adapter/system-adapter.d.ts +45 -7
  49. package/dist/adapter/system-adapter.d.ts.map +1 -1
  50. package/dist/adapter/system-seam-contract.d.ts +3 -3
  51. package/dist/adapter/system-seam-contract.js +3 -3
  52. package/dist/adapter/system-slot.d.ts +168 -0
  53. package/dist/adapter/system-slot.d.ts.map +1 -0
  54. package/dist/adapter/system-slot.js +229 -0
  55. package/dist/adapter/transform.d.ts +11 -1
  56. package/dist/adapter/transform.d.ts.map +1 -1
  57. package/dist/ai/navigation.d.ts +17 -1
  58. package/dist/ai/navigation.d.ts.map +1 -1
  59. package/dist/ai/navigation.js +26 -5
  60. package/dist/animation/anim-graph-types.d.ts +11 -3
  61. package/dist/animation/anim-graph-types.d.ts.map +1 -1
  62. package/dist/animation/theatre-clock-binding.d.ts +4 -4
  63. package/dist/animation/theatre-clock-binding.js +4 -4
  64. package/dist/animation/xstate-animation-binding.d.ts.map +1 -1
  65. package/dist/animation/xstate-animation-binding.js +2 -2
  66. package/dist/animation/xstate-animation-meta.d.ts +13 -0
  67. package/dist/animation/xstate-animation-meta.d.ts.map +1 -1
  68. package/dist/animation/xstate-animation-meta.js +14 -0
  69. package/dist/asset-formats/index.d.ts +4 -7
  70. package/dist/asset-formats/index.d.ts.map +1 -1
  71. package/dist/asset-formats/index.js +4 -7
  72. package/dist/asset-formats/render-env.d.ts +5 -8
  73. package/dist/asset-formats/render-env.d.ts.map +1 -1
  74. package/dist/asset-formats/render-env.js +3 -6
  75. package/dist/asset-parse-error.d.ts +2 -5
  76. package/dist/asset-parse-error.d.ts.map +1 -1
  77. package/dist/asset-parse-error.js +2 -5
  78. package/dist/audio/bus-mixer.d.ts +101 -0
  79. package/dist/audio/bus-mixer.d.ts.map +1 -0
  80. package/dist/audio/bus-mixer.js +115 -0
  81. package/dist/core/frame-pacing.d.ts +1 -1
  82. package/dist/core/frame-pacing.js +2 -2
  83. package/dist/core/game-loop.d.ts +1 -3
  84. package/dist/core/game-loop.d.ts.map +1 -1
  85. package/dist/core/game-loop.js +1 -3
  86. package/dist/core/seeded-random.d.ts +1 -1
  87. package/dist/core/sim-clock.d.ts +5 -6
  88. package/dist/core/sim-clock.d.ts.map +1 -1
  89. package/dist/core/sim-clock.js +4 -5
  90. package/dist/core/types.d.ts +1 -3
  91. package/dist/core/types.d.ts.map +1 -1
  92. package/dist/defaults.d.ts +6 -14
  93. package/dist/defaults.d.ts.map +1 -1
  94. package/dist/defaults.js +6 -14
  95. package/dist/dev/register-render-vitals.d.ts +1 -4
  96. package/dist/dev/register-render-vitals.d.ts.map +1 -1
  97. package/dist/dev/register-render-vitals.js +1 -4
  98. package/dist/dev/render-debug-adapter.d.ts +2 -3
  99. package/dist/dev/render-debug-adapter.d.ts.map +1 -1
  100. package/dist/dev/render-debug-adapter.js +2 -3
  101. package/dist/dev/render-vitals.d.ts +3 -3
  102. package/dist/dev/render-vitals.js +3 -3
  103. package/dist/dev/webgl-frame-capture.d.ts +1 -1
  104. package/dist/dev/webgl-frame-capture.js +1 -1
  105. package/dist/index.d.ts +2 -5
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +2 -4
  108. package/dist/input/host-pointer.d.ts +122 -0
  109. package/dist/input/host-pointer.d.ts.map +1 -0
  110. package/dist/input/host-pointer.js +160 -0
  111. package/dist/input/input-manager.d.ts +18 -5
  112. package/dist/input/input-manager.d.ts.map +1 -1
  113. package/dist/input/input-manager.js +33 -13
  114. package/dist/input/rebind-controller.d.ts.map +1 -1
  115. package/dist/input/rebind-controller.js +6 -8
  116. package/dist/input/schema.d.ts.map +1 -1
  117. package/dist/input/schema.js +56 -28
  118. package/dist/manifest/filename.d.ts.map +1 -1
  119. package/dist/manifest/filename.js +8 -12
  120. package/dist/manifest/load.d.ts +10 -10
  121. package/dist/manifest/load.d.ts.map +1 -1
  122. package/dist/manifest/load.js +9 -6
  123. package/dist/manifest/schema.d.ts +17 -21
  124. package/dist/manifest/schema.d.ts.map +1 -1
  125. package/dist/manifest/schema.js +45 -35
  126. package/dist/physics/collider-dimensions.d.ts +8 -12
  127. package/dist/physics/collider-dimensions.d.ts.map +1 -1
  128. package/dist/physics/collider-dimensions.js +8 -12
  129. package/dist/pixi/scene-capture.d.ts +11 -13
  130. package/dist/pixi/scene-capture.d.ts.map +1 -1
  131. package/dist/react/world-state.d.ts +1 -1
  132. package/dist/react/world-state.d.ts.map +1 -1
  133. package/dist/render/light-camera-factory.d.ts +5 -7
  134. package/dist/render/light-camera-factory.d.ts.map +1 -1
  135. package/dist/render/light-camera-factory.js +8 -11
  136. package/dist/render/material-factory.js +1 -1
  137. package/dist/render/render-batch-system.d.ts.map +1 -1
  138. package/dist/render/render-features.d.ts +17 -6
  139. package/dist/render/render-features.d.ts.map +1 -1
  140. package/dist/render/render-features.js +0 -28
  141. package/dist/runtime/create-runtime.d.ts +34 -25
  142. package/dist/runtime/create-runtime.d.ts.map +1 -1
  143. package/dist/runtime/create-runtime.js +218 -93
  144. package/dist/runtime/debug-bridge.d.ts +12 -0
  145. package/dist/runtime/debug-bridge.d.ts.map +1 -1
  146. package/dist/runtime/debug-bridge.js +4 -0
  147. package/dist/runtime/debug-registry.d.ts +95 -8
  148. package/dist/runtime/debug-registry.d.ts.map +1 -1
  149. package/dist/runtime/debug-registry.js +24 -3
  150. package/dist/runtime/dev-build.d.ts +2 -2
  151. package/dist/runtime/dev-build.js +2 -2
  152. package/dist/runtime/game-input-seams.d.ts +2 -2
  153. package/dist/runtime/game-input-seams.d.ts.map +1 -1
  154. package/dist/runtime/game.d.ts +102 -41
  155. package/dist/runtime/game.d.ts.map +1 -1
  156. package/dist/runtime/game.js +80 -54
  157. package/dist/runtime/mount-game.d.ts +0 -16
  158. package/dist/runtime/mount-game.d.ts.map +1 -1
  159. package/dist/runtime/mount-game.js +8 -39
  160. package/dist/runtime/mount-manifest.d.ts +22 -14
  161. package/dist/runtime/mount-manifest.d.ts.map +1 -1
  162. package/dist/runtime/mount-manifest.js +18 -18
  163. package/dist/runtime/playtest.d.ts +22 -0
  164. package/dist/runtime/playtest.d.ts.map +1 -0
  165. package/dist/runtime/playtest.js +12 -0
  166. package/dist/runtime/run-ticks-settled.d.ts +34 -0
  167. package/dist/runtime/run-ticks-settled.d.ts.map +1 -0
  168. package/dist/runtime/run-ticks-settled.js +59 -0
  169. package/dist/runtime/state-bridge.d.ts +2 -3
  170. package/dist/runtime/state-bridge.d.ts.map +1 -1
  171. package/dist/runtime/state-bridge.js +1 -0
  172. package/dist/setup/setup-audio.d.ts +12 -0
  173. package/dist/setup/setup-audio.d.ts.map +1 -1
  174. package/dist/setup/setup-audio.js +9 -10
  175. package/dist/setup/setup-renderer.d.ts +2 -25
  176. package/dist/setup/setup-renderer.d.ts.map +1 -1
  177. package/dist/setup/setup-renderer.js +2 -31
  178. package/dist/world3d-react/r3f-root-factory.d.ts +7 -7
  179. package/dist/world3d-react/r3f-root-factory.js +7 -7
  180. package/dist/world3d-react/rapier-physics-bridge.d.ts +9 -8
  181. package/dist/world3d-react/rapier-physics-bridge.d.ts.map +1 -1
  182. package/dist/world3d-react/rapier-physics-bridge.js +100 -48
  183. package/package.json +1 -1
  184. package/schemas/engine-capabilities.json +16 -14
  185. package/schemas/vgai-project.schema.json +35 -26
  186. package/src/adapter/adapter-module.ts +2 -4
  187. package/src/adapter/adapter-surface.ts +1 -1
  188. package/src/adapter/authoring.ts +19 -21
  189. package/src/adapter/binding.ts +468 -0
  190. package/src/adapter/colyseus-networking-adapter.ts +20 -5
  191. package/src/adapter/entrypoint-selection-readers.ts +66 -0
  192. package/src/adapter/entrypoint-selection-source.ts +1 -40
  193. package/src/adapter/finders/scenes-from-entrypoint-selection.ts +1 -48
  194. package/src/adapter/host-context.ts +45 -15
  195. package/src/adapter/index.ts +23 -11
  196. package/src/adapter/ingest/game-contract-seams.ts +1 -0
  197. package/src/adapter/ingest/game-contract.ts +22 -3
  198. package/src/adapter/ingest/scene-capture.ts +190 -39
  199. package/src/adapter/ingest/visible-capture-window.ts +35 -0
  200. package/src/adapter/native-debug-module.ts +66 -9
  201. package/src/adapter/rapier-physics-adapter.ts +76 -20
  202. package/src/adapter/renderer-config.ts +2 -2
  203. package/src/adapter/root-adapter.ts +7 -7
  204. package/src/adapter/system-adapter.ts +43 -8
  205. package/src/adapter/system-seam-contract.ts +3 -3
  206. package/src/adapter/system-slot.ts +291 -0
  207. package/src/adapter/transform.ts +18 -1
  208. package/src/ai/navigation.ts +30 -3
  209. package/src/animation/anim-graph-types.ts +11 -3
  210. package/src/animation/theatre-clock-binding.ts +4 -4
  211. package/src/animation/xstate-animation-binding.ts +2 -2
  212. package/src/animation/xstate-animation-meta.ts +16 -0
  213. package/src/asset-formats/index.ts +4 -7
  214. package/src/asset-formats/render-env.ts +3 -6
  215. package/src/asset-parse-error.ts +2 -5
  216. package/src/audio/bus-mixer.ts +161 -0
  217. package/src/core/frame-pacing.ts +2 -2
  218. package/src/core/game-loop.ts +1 -3
  219. package/src/core/seeded-random.ts +1 -1
  220. package/src/core/sim-clock.ts +5 -6
  221. package/src/core/types.ts +1 -3
  222. package/src/defaults.ts +6 -14
  223. package/src/dev/register-render-vitals.ts +1 -4
  224. package/src/dev/render-debug-adapter.ts +2 -3
  225. package/src/dev/render-vitals.ts +3 -3
  226. package/src/dev/webgl-frame-capture.ts +1 -1
  227. package/src/index.ts +2 -5
  228. package/src/input/host-pointer.ts +230 -0
  229. package/src/input/input-manager.ts +34 -13
  230. package/src/input/input-types.ts +1 -1
  231. package/src/input/rebind-controller.ts +6 -8
  232. package/src/input/schema.ts +216 -188
  233. package/src/manifest/filename.ts +8 -12
  234. package/src/manifest/load.ts +17 -13
  235. package/src/manifest/schema.ts +55 -47
  236. package/src/physics/collider-dimensions.ts +8 -12
  237. package/src/pixi/scene-capture.ts +12 -15
  238. package/src/react/world-state.tsx +1 -1
  239. package/src/render/light-camera-factory.ts +8 -11
  240. package/src/render/material-factory.ts +1 -1
  241. package/src/render/render-batch-system.ts +14 -6
  242. package/src/render/render-features.ts +17 -35
  243. package/src/runtime/create-runtime.ts +270 -108
  244. package/src/runtime/debug-bridge.ts +16 -0
  245. package/src/runtime/debug-registry.ts +121 -8
  246. package/src/runtime/dev-build.ts +2 -2
  247. package/src/runtime/game-input-seams.ts +2 -2
  248. package/src/runtime/game.ts +180 -80
  249. package/src/runtime/mount-game.ts +8 -56
  250. package/src/runtime/mount-manifest.ts +43 -34
  251. package/src/runtime/playtest.ts +22 -0
  252. package/src/runtime/run-ticks-settled.ts +72 -0
  253. package/src/runtime/state-bridge.ts +3 -3
  254. package/src/setup/setup-audio.ts +21 -11
  255. package/src/setup/setup-renderer.ts +2 -61
  256. package/src/world3d-react/r3f-root-factory.tsx +7 -7
  257. package/src/world3d-react/rapier-physics-bridge.tsx +107 -50
  258. package/dist/adapter/setup-three-root-adapter.d.ts +0 -86
  259. package/dist/adapter/setup-three-root-adapter.d.ts.map +0 -1
  260. package/dist/adapter/setup-three-root-adapter.js +0 -908
  261. package/dist/animation/clip-map.d.ts +0 -12
  262. package/dist/animation/clip-map.d.ts.map +0 -1
  263. package/dist/animation/clip-map.js +0 -31
  264. package/dist/asset-registry.d.ts +0 -38
  265. package/dist/asset-registry.d.ts.map +0 -1
  266. package/dist/asset-registry.js +0 -66
  267. package/dist/canvas-react/engine-bridge.d.ts +0 -45
  268. package/dist/canvas-react/engine-bridge.d.ts.map +0 -1
  269. package/dist/canvas-react/engine-bridge.js +0 -45
  270. package/dist/canvas-react/pixi-react-adapter.d.ts +0 -77
  271. package/dist/canvas-react/pixi-react-adapter.d.ts.map +0 -1
  272. package/dist/canvas-react/pixi-react-adapter.js +0 -294
  273. package/dist/canvas-react/world-context.d.ts +0 -98
  274. package/dist/canvas-react/world-context.d.ts.map +0 -1
  275. package/dist/canvas-react/world-context.js +0 -173
  276. package/dist/dev/debug-draw.d.ts +0 -24
  277. package/dist/dev/debug-draw.d.ts.map +0 -1
  278. package/dist/dev/debug-draw.js +0 -73
  279. package/dist/render/auto-batcher.d.ts +0 -34
  280. package/dist/render/auto-batcher.d.ts.map +0 -1
  281. package/dist/render/auto-batcher.js +0 -140
  282. package/dist/render/lod.d.ts +0 -13
  283. package/dist/render/lod.d.ts.map +0 -1
  284. package/dist/render/lod.js +0 -16
  285. package/dist/runtime/types.d.ts +0 -303
  286. package/dist/runtime/types.d.ts.map +0 -1
  287. package/dist/runtime/types.js +0 -1
  288. package/dist/world3d-react/engine-bridge.d.ts +0 -47
  289. package/dist/world3d-react/engine-bridge.d.ts.map +0 -1
  290. package/dist/world3d-react/engine-bridge.js +0 -73
  291. package/dist/world3d-react/r3f-adapter.d.ts +0 -58
  292. package/dist/world3d-react/r3f-adapter.d.ts.map +0 -1
  293. package/dist/world3d-react/r3f-adapter.js +0 -634
  294. package/dist/world3d-react/world-context.d.ts +0 -182
  295. package/dist/world3d-react/world-context.d.ts.map +0 -1
  296. package/dist/world3d-react/world-context.js +0 -235
  297. package/src/adapter/setup-three-root-adapter.ts +0 -1032
  298. package/src/animation/clip-map.ts +0 -34
  299. package/src/asset-registry.ts +0 -89
  300. package/src/dev/debug-draw.ts +0 -80
  301. package/src/render/auto-batcher.ts +0 -168
  302. package/src/render/lod.ts +0 -17
  303. package/src/runtime/types.ts +0 -328
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The game-scoped debug/synthetic-player registry. ONE registry per `Game` root —
3
- * every world's `ctx.debug` (see `DebugCtxSurface`, `runtime/types.ts`) feeds the
3
+ * every world's `ctx.debug` (see {@link DebugCtxSurface} below) feeds the
4
4
  * SAME registry via {@link DebugRegistry.forRoot}, so a name a game registers is
5
5
  * visible (and name-collision-checked) across every world, not just the one that
6
6
  * registered it. `createGame` (`runtime/game.ts`) constructs the registry
@@ -10,8 +10,8 @@
10
10
  * rather than threading it through every call site.
11
11
  *
12
12
  * Provenance note: a registration's "world" is the MOUNT's adapter id (the
13
- * `fromSetup(id, ...)` / `SetupThreeRootConfig.id` a project already names each
14
- * world's entry with) rather than the `RootInstance.id` `registerThreeRoot`
13
+ * id a project's root adapter already carries) rather than the
14
+ * `RootInstance.id` `registerThreeRoot`
15
15
  * assigns — that id isn't known until AFTER `mount()` resolves (`create-
16
16
  * runtime.ts` calls `registerThreeRoot` with it only once `mount()` returns),
17
17
  * which is after every `setup()`-time registration has already run. For the
@@ -25,7 +25,83 @@ import type { DebugAdapter, DebugCommandInfo, TickStampedEvent } from '../adapte
25
25
  import { createGameScopedSlot } from '../core/game-scoped-slot';
26
26
  import type { GameLoopLiveness } from '../core/types';
27
27
  import type { Game } from './game';
28
- import type { DebugCommandArgs, DebugCtxSurface, DebugRoomHandle } from './types';
28
+
29
+ /**
30
+ * The minimal structural shape `ctx.debug.attachRoom` needs from a joined
31
+ * Colyseus room: just enough to send the reserved `__vgai:debugCommand`
32
+ * message and listen for its `__vgai:debugCommandResult` reply. Structural,
33
+ * not a Colyseus type import — the same seam-boundary style every other
34
+ * `DebugCtxSurface` member uses (no wrapper around Colyseus itself, D2).
35
+ * `onMessage`'s return type is `unknown` because Colyseus's own return shape
36
+ * (void in some client versions, an unsubscribe function in others) isn't
37
+ * load-bearing here: the registry calls it defensively (invokes it on detach
38
+ * only if it's actually a function).
39
+ */
40
+ export interface DebugRoomHandle {
41
+ send(type: string, message?: unknown): void;
42
+ onMessage(type: string, cb: (message: unknown) => void): unknown;
43
+ }
44
+
45
+ /**
46
+ * Infers a `registerCommand`/`registerReactCommand`/`useDebugCommand`
47
+ * handler's parameter tuple from its declared Zod `args` tuple (dry-run
48
+ * finding, ledger — "`registerCommand` fn typing forces `unknown[]` casts"):
49
+ * a real `z.ZodTuple` infers its element types (`z.tuple([z.number(),
50
+ * z.string()])` → `(n: number, s: string) => ...`), while omitting `args`
51
+ * (the generic's `undefined` default) resolves to the original permissive
52
+ * `(...args: unknown[]) => ...` shape every command had before this generic
53
+ * existed. That permissive fallback is deliberate, not just a placeholder —
54
+ * it keeps every existing no-schema registration (including ones whose
55
+ * handler reads positional args the runtime never validates, since
56
+ * `invoke()` only parses `args` against a schema when one is declared)
57
+ * compiling byte-for-byte unchanged.
58
+ */
59
+ export type DebugCommandArgs<T extends z.ZodTuple | undefined = undefined> = T extends z.ZodTuple
60
+ ? z.infer<T>
61
+ : unknown[];
62
+
63
+ /**
64
+ * The authoring half of the debug/synthetic-player seam — the read/actuate half is
65
+ * `SystemAdapters.DebugAdapter` (`adapter/system-adapter.ts`). Callable from any
66
+ * `init` (one file per new provider/command), or from a react world's
67
+ * `useDebugProvider`/`useDebugCommand`/`useDebugEmit` hooks. Every registration feeds the ONE
68
+ * game-scoped registry (`runtime/debug-registry.ts`) — never a per-world accumulator.
69
+ */
70
+ export interface DebugCtxSurface {
71
+ /** Register (or replace) a named, JSON-serializable state read. Duplicate
72
+ * names from the SAME world replace + warn once; the SAME name from a
73
+ * DIFFERENT world throws (`DebugError` code `DEBUG_NAME_COLLISION`). */
74
+ registerStateProvider(
75
+ name: string,
76
+ fn: () => unknown,
77
+ opts?: { tier?: 'observable' | 'assisted' },
78
+ ): void;
79
+ /** Register (or replace) an invokable command. `locus` is REQUIRED once the
80
+ * project declares a Colyseus room (`DebugRegistry.setRoomDeclared`) — a
81
+ * fixture must say whether it mutates authoritative (server) or predicted
82
+ * (client) state.
83
+ *
84
+ * Generic over the declared `args` Zod tuple ({@link DebugCommandArgs}) so
85
+ * `fn`'s parameters INFER from it: `registerCommand('setHp', { args:
86
+ * z.tuple([z.number()]) }, (hp) => ...)` types `hp` as `number` with no
87
+ * cast. Leaving `args` off keeps `fn` typed `(...args: unknown[]) => ...`,
88
+ * same as before this generic existed. */
89
+ registerCommand<T extends z.ZodTuple | undefined = undefined>(
90
+ name: string,
91
+ spec: { description?: string; args?: T; locus?: 'client' | 'server' },
92
+ fn: (...args: DebugCommandArgs<T>) => unknown | Promise<unknown>,
93
+ ): void;
94
+ /** Push a tick-stamped event onto the debug event ring (spec §3.3) — the
95
+ * engine stamps `tick`/`simT` at emission, not at read time. */
96
+ emit(event: string, detail?: unknown): void;
97
+ /**
98
+ * Task 2.2 — server-locus command routing (client leg). Call once your
99
+ * game code has joined its Colyseus room, so `locus: 'server'` commands
100
+ * have somewhere to send `__vgai:debugCommand`. Returns a detach function
101
+ * (call on room leave/dispose) — game-scoped, last-attached room wins.
102
+ */
103
+ attachRoom(room: DebugRoomHandle): () => void;
104
+ }
29
105
 
30
106
  /** Engine-local error for the debug seam — mirrors the `code` + `data` shape
31
107
  * `packages/vgai-sdk/src/errors.ts` uses (no import: the engine does not
@@ -74,7 +150,7 @@ const SERVER_COMMAND_TIMEOUT_MS = 10_000;
74
150
  * actuates through — the SAME three methods `InputManager` exposes
75
151
  * (`setVirtualAction`/`tapVirtualAction`/`clearVirtualActions`, Task 1.4),
76
152
  * typed narrowly here so this module never imports `InputManager` itself.
77
- * Wired once by the hosting adapter (`setup-three-root-adapter.ts`, at the
153
+ * Wired once by the hosting adapter (`world3d-react/r3f-root-factory.tsx`, at the
78
154
  * same seed spot as `setInputActionsSource`) — absent until then. */
79
155
  export interface DebugVirtualInputTarget {
80
156
  setVirtualAction(
@@ -187,7 +263,7 @@ interface CommandEntry {
187
263
 
188
264
  /** What {@link createDebugRegistry} returns — the adapter half (`DebugAdapter`,
189
265
  * for `SystemAdapters.debug`) plus the registration/lifecycle surface the
190
- * hosting adapter (`setup-three-root-adapter.ts`) and `createGame` drive. */
266
+ * hosting adapter (`world3d-react/r3f-root-factory.tsx`) and `createGame` drive. */
191
267
  export interface DebugRegistry {
192
268
  /** The `SystemAdapters.debug` implementer — one shared instance, seeded
193
269
  * onto every world's adapter bag. */
@@ -238,7 +314,7 @@ export interface DebugRegistry {
238
314
  * `{version: 1, seed: null, fixedDt: null, ticks: []}`. `seed`/`fixedDt`
239
315
  * are the two replay-critical metadata fields the design doc's format
240
316
  * sketch (§2.c) calls for beside the raw per-tick deltas — the wiring
241
- * adapter (`setup-three-root-adapter.ts`) assembles them from
317
+ * adapter (`world3d-react/r3f-root-factory.tsx`) assembles them from
242
318
  * `getSeededRandom(game)?.seed`/`host.game?.loop.fixedDt` alongside
243
319
  * `InputManager.getInputTrace()`'s own `{version, ticks}`. An `engine`
244
320
  * (package version) stamp remains a KNOWN GAP — no build-time version
@@ -294,10 +370,28 @@ export interface DebugRegistry {
294
370
  * error in that case rather than silently no-op-ing — see
295
371
  * `debug-bridge.ts`'s `runTicks` method. */
296
372
  getRunTicksTarget(): RunTicksTarget | null;
373
+ /**
374
+ * Register a WORLD-SETTLED probe: `false` while this game is intentionally
375
+ * between worlds — a scene remount in flight (`reload_current_scene`'s
376
+ * React remount commits asynchronously). The game declares it through the
377
+ * `settled` key of its `debug` entry export (`native-debug-module.ts`);
378
+ * session tick drivers ({@link runTicksWhenSettled} behind BOTH run-ticks
379
+ * doors) wait for every probe to answer `true` before each tick, so WHICH
380
+ * tick first runs a freshly remounted scene is a function of the sim, not
381
+ * of wall timing between driver calls — measured before this seam: the
382
+ * same drive script produced 7 or 8 post-respawn walked ticks depending on
383
+ * how long the driver idled between ticks. Returns the deregistration.
384
+ */
385
+ registerWorldSettledProbe(probe: () => boolean): () => void;
386
+ /** `true` when every registered probe answers `true` (and vacuously with
387
+ * none registered). A probe that THROWS counts as settled=false — a
388
+ * broken probe must stall the driver loudly (its bounded wait names the
389
+ * timeout), never silently un-gate it. */
390
+ worldSettled(): boolean;
297
391
  /** D15/T-D15.3/.5 — the CURRENT shared game tick (the same counter the
298
392
  * built-in `time` provider's `tick` field reads), for a per-world
299
393
  * `InputManager.poll(tick)` call to key its `scheduleActionAtTick`
300
- * numbering off — see `setup-three-root-adapter.ts`'s `systems.add('input',
394
+ * numbering off — see `world3d-react/r3f-root-factory.tsx`'s `systems.add('input',
301
395
  * ...)` wiring. `0` for a bare `createDebugRegistry()` test stand-in with
302
396
  * no real `Game`/tick counter behind it (matching `getTick`'s own
303
397
  * constructor-supplied default in that case). */
@@ -382,6 +476,7 @@ export function createDebugRegistry(opts: {
382
476
  const inputTraceSources = new Map<string, () => InputTraceSnapshot>();
383
477
  const virtualInputTargets = new Map<string, DebugVirtualInputTarget>();
384
478
  let runTicksTarget: RunTicksTarget | null = null;
479
+ const worldSettledProbes = new Set<() => boolean>();
385
480
  let attachedRoom: DebugRoomHandle | null = null;
386
481
  const pendingServerCommands = new Map<string, PendingServerCommand>();
387
482
  let requestCounter = 0;
@@ -831,6 +926,24 @@ export function createDebugRegistry(opts: {
831
926
  getRunTicksTarget() {
832
927
  return runTicksTarget;
833
928
  },
929
+ registerWorldSettledProbe(probe: () => boolean) {
930
+ worldSettledProbes.add(probe);
931
+ return () => {
932
+ worldSettledProbes.delete(probe);
933
+ };
934
+ },
935
+ worldSettled() {
936
+ for (const probe of worldSettledProbes) {
937
+ try {
938
+ if (!probe()) return false;
939
+ } catch {
940
+ // A throwing probe stalls the driver LOUDLY (the bounded wait's
941
+ // timeout names it) rather than silently un-gating the tick.
942
+ return false;
943
+ }
944
+ }
945
+ return true;
946
+ },
834
947
  getGameTick() {
835
948
  return opts.getTick();
836
949
  },
@@ -9,8 +9,8 @@
9
9
  *
10
10
  * Ownership, stated in one place (the build rule):
11
11
  * - OWNER: this function. It resolves the answer; nothing else derives it.
12
- * - SHARERS: the two three-root adapters (`adapter/setup-three-root-adapter.ts`
13
- * and `world3d-react/r3f-adapter.tsx`), which seed live render vitals only
12
+ * - SHARERS: the three-root adapter (`world3d-react/r3f-root-factory.tsx`),
13
+ * which seeds live render vitals only
14
14
  * under it, and the `static-batch` capability's mutation watch and `Frozen`
15
15
  * warning. Any future dev-only instrument calls this too, with its own
16
16
  * `override`.
@@ -33,9 +33,9 @@
33
33
  * `strip` to actually do it.
34
34
  */
35
35
 
36
+ import type { HostGameHandle } from '../adapter/host-context';
36
37
  import { getSeededRandom } from '../core/seeded-random';
37
38
  import type { DebugRegistry } from './debug-registry';
38
- import type { GameInternal } from './game';
39
39
 
40
40
  /** The conventional input-map location every scaffolded project ships
41
41
  * (`public/inputmaps/default.inputmap.json`). */
@@ -44,7 +44,7 @@ export const DEFAULT_INPUT_MAP_PATH = '/inputmaps/default.inputmap.json';
44
44
  /** The slice of a host context this wiring reads — satisfied structurally by
45
45
  * both `ThreeHostContext` and `CanvasHostContext`. */
46
46
  export interface GameInputSeamHost {
47
- readonly game?: GameInternal | null | undefined;
47
+ readonly game?: HostGameHandle | null | undefined;
48
48
  readonly headless?: boolean | undefined;
49
49
  }
50
50