@vgai/engine 0.5.0 → 0.5.2

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 (538) hide show
  1. package/package.json +1 -1
  2. package/schemas/engine-capabilities.json +4 -4
  3. package/schemas/vgai-game.schema.json +2 -2
  4. package/src/adapter/authoring.ts +42 -0
  5. package/src/adapter/index.ts +3 -0
  6. package/src/adapter/ingest/overlay-apply.ts +50 -6
  7. package/src/adapter/ingest/scene-capture.ts +51 -2
  8. package/src/adapter/vgai-scene-game-adapter.ts +24 -0
  9. package/src/manifest/schema.ts +7 -3
  10. package/src/runtime/create-runtime.ts +97 -0
  11. package/src/runtime/game.ts +11 -1
  12. package/src/scene/asset-ref-check.ts +1 -1
  13. package/src/scene/scene-loader.ts +2 -2
  14. package/src/scene/user-data.ts +18 -0
  15. package/src/world3d-react/behavior.tsx +19 -11
  16. package/src/world3d-react/r3f-adapter.tsx +8 -0
  17. package/dist/adapter/adapter-surface.d.ts +0 -30
  18. package/dist/adapter/adapter-surface.d.ts.map +0 -1
  19. package/dist/adapter/adapter-surface.js +0 -18
  20. package/dist/adapter/authoring.d.ts +0 -461
  21. package/dist/adapter/authoring.d.ts.map +0 -1
  22. package/dist/adapter/authoring.js +0 -22
  23. package/dist/adapter/colyseus-networking-adapter.d.ts +0 -43
  24. package/dist/adapter/colyseus-networking-adapter.d.ts.map +0 -1
  25. package/dist/adapter/colyseus-networking-adapter.js +0 -38
  26. package/dist/adapter/first-party-systems.d.ts +0 -38
  27. package/dist/adapter/first-party-systems.d.ts.map +0 -1
  28. package/dist/adapter/first-party-systems.js +0 -77
  29. package/dist/adapter/game-adapter.d.ts +0 -133
  30. package/dist/adapter/game-adapter.d.ts.map +0 -1
  31. package/dist/adapter/game-adapter.js +0 -10
  32. package/dist/adapter/host-context.d.ts +0 -71
  33. package/dist/adapter/host-context.d.ts.map +0 -1
  34. package/dist/adapter/host-context.js +0 -16
  35. package/dist/adapter/index.d.ts +0 -22
  36. package/dist/adapter/index.d.ts.map +0 -1
  37. package/dist/adapter/index.js +0 -15
  38. package/dist/adapter/ingest/game-contract.d.ts +0 -53
  39. package/dist/adapter/ingest/game-contract.d.ts.map +0 -1
  40. package/dist/adapter/ingest/game-contract.js +0 -30
  41. package/dist/adapter/ingest/overlay-applier.d.ts +0 -118
  42. package/dist/adapter/ingest/overlay-applier.d.ts.map +0 -1
  43. package/dist/adapter/ingest/overlay-applier.js +0 -132
  44. package/dist/adapter/ingest/overlay-apply.d.ts +0 -60
  45. package/dist/adapter/ingest/overlay-apply.d.ts.map +0 -1
  46. package/dist/adapter/ingest/overlay-apply.js +0 -101
  47. package/dist/adapter/ingest/overlay-file.d.ts +0 -79
  48. package/dist/adapter/ingest/overlay-file.d.ts.map +0 -1
  49. package/dist/adapter/ingest/overlay-file.js +0 -66
  50. package/dist/adapter/ingest/overlay-report.d.ts +0 -113
  51. package/dist/adapter/ingest/overlay-report.d.ts.map +0 -1
  52. package/dist/adapter/ingest/overlay-report.js +0 -103
  53. package/dist/adapter/ingest/scene-capture.d.ts +0 -97
  54. package/dist/adapter/ingest/scene-capture.d.ts.map +0 -1
  55. package/dist/adapter/ingest/scene-capture.js +0 -248
  56. package/dist/adapter/ingest/upstream-pin.d.ts +0 -47
  57. package/dist/adapter/ingest/upstream-pin.d.ts.map +0 -1
  58. package/dist/adapter/ingest/upstream-pin.js +0 -50
  59. package/dist/adapter/loop-gate-report.d.ts +0 -34
  60. package/dist/adapter/loop-gate-report.d.ts.map +0 -1
  61. package/dist/adapter/loop-gate-report.js +0 -37
  62. package/dist/adapter/rapier-physics-adapter.d.ts +0 -12
  63. package/dist/adapter/rapier-physics-adapter.d.ts.map +0 -1
  64. package/dist/adapter/rapier-physics-adapter.js +0 -46
  65. package/dist/adapter/system-adapter.d.ts +0 -206
  66. package/dist/adapter/system-adapter.d.ts.map +0 -1
  67. package/dist/adapter/system-adapter.js +0 -13
  68. package/dist/adapter/transform.d.ts +0 -18
  69. package/dist/adapter/transform.d.ts.map +0 -1
  70. package/dist/adapter/transform.js +0 -1
  71. package/dist/adapter/vgai-scene-game-adapter.d.ts +0 -108
  72. package/dist/adapter/vgai-scene-game-adapter.d.ts.map +0 -1
  73. package/dist/adapter/vgai-scene-game-adapter.js +0 -762
  74. package/dist/ai/navigation.d.ts +0 -64
  75. package/dist/ai/navigation.d.ts.map +0 -1
  76. package/dist/ai/navigation.js +0 -133
  77. package/dist/animation/anim-graph-types.d.ts +0 -25
  78. package/dist/animation/anim-graph-types.d.ts.map +0 -1
  79. package/dist/animation/anim-graph-types.js +0 -1
  80. package/dist/animation/animation-clock.d.ts +0 -213
  81. package/dist/animation/animation-clock.d.ts.map +0 -1
  82. package/dist/animation/animation-clock.js +0 -301
  83. package/dist/animation/blend-node.d.ts +0 -22
  84. package/dist/animation/blend-node.d.ts.map +0 -1
  85. package/dist/animation/blend-node.js +0 -97
  86. package/dist/animation/camera-ownership.d.ts +0 -250
  87. package/dist/animation/camera-ownership.d.ts.map +0 -1
  88. package/dist/animation/camera-ownership.js +0 -169
  89. package/dist/animation/cinematic-cues.d.ts +0 -200
  90. package/dist/animation/cinematic-cues.d.ts.map +0 -1
  91. package/dist/animation/cinematic-cues.js +0 -213
  92. package/dist/animation/clip-map.d.ts +0 -12
  93. package/dist/animation/clip-map.d.ts.map +0 -1
  94. package/dist/animation/clip-map.js +0 -37
  95. package/dist/animation/gsap-registration.d.ts +0 -119
  96. package/dist/animation/gsap-registration.d.ts.map +0 -1
  97. package/dist/animation/gsap-registration.js +0 -92
  98. package/dist/animation/theatre-clock-binding.d.ts +0 -89
  99. package/dist/animation/theatre-clock-binding.d.ts.map +0 -1
  100. package/dist/animation/theatre-clock-binding.js +0 -29
  101. package/dist/animation/theatre-director.d.ts +0 -242
  102. package/dist/animation/theatre-director.d.ts.map +0 -1
  103. package/dist/animation/theatre-director.js +0 -235
  104. package/dist/animation/theatre-object-binding.d.ts +0 -305
  105. package/dist/animation/theatre-object-binding.d.ts.map +0 -1
  106. package/dist/animation/theatre-object-binding.js +0 -351
  107. package/dist/animation/xstate-animation-binding.d.ts +0 -56
  108. package/dist/animation/xstate-animation-binding.d.ts.map +0 -1
  109. package/dist/animation/xstate-animation-binding.js +0 -331
  110. package/dist/animation/xstate-animation-meta.d.ts +0 -266
  111. package/dist/animation/xstate-animation-meta.d.ts.map +0 -1
  112. package/dist/animation/xstate-animation-meta.js +0 -252
  113. package/dist/assets.d.ts +0 -26
  114. package/dist/assets.d.ts.map +0 -1
  115. package/dist/assets.js +0 -55
  116. package/dist/audio/index.d.ts +0 -4
  117. package/dist/audio/index.d.ts.map +0 -1
  118. package/dist/audio/index.js +0 -24
  119. package/dist/audio/tone-clock-binding.d.ts +0 -75
  120. package/dist/audio/tone-clock-binding.d.ts.map +0 -1
  121. package/dist/audio/tone-clock-binding.js +0 -29
  122. package/dist/audio/tone-context.d.ts +0 -114
  123. package/dist/audio/tone-context.d.ts.map +0 -1
  124. package/dist/audio/tone-context.js +0 -39
  125. package/dist/audio/tone-offline-render.d.ts +0 -90
  126. package/dist/audio/tone-offline-render.d.ts.map +0 -1
  127. package/dist/audio/tone-offline-render.js +0 -56
  128. package/dist/audio/wav-encode.d.ts +0 -38
  129. package/dist/audio/wav-encode.d.ts.map +0 -1
  130. package/dist/audio/wav-encode.js +0 -97
  131. package/dist/character/cloth-sim.d.ts +0 -179
  132. package/dist/character/cloth-sim.d.ts.map +0 -1
  133. package/dist/character/cloth-sim.js +0 -334
  134. package/dist/character/spring-chain.d.ts +0 -135
  135. package/dist/character/spring-chain.d.ts.map +0 -1
  136. package/dist/character/spring-chain.js +0 -165
  137. package/dist/core/game-loop.d.ts +0 -42
  138. package/dist/core/game-loop.d.ts.map +0 -1
  139. package/dist/core/game-loop.js +0 -167
  140. package/dist/core/seeded-random.d.ts +0 -69
  141. package/dist/core/seeded-random.d.ts.map +0 -1
  142. package/dist/core/seeded-random.js +0 -121
  143. package/dist/core/system-runner.d.ts +0 -120
  144. package/dist/core/system-runner.d.ts.map +0 -1
  145. package/dist/core/system-runner.js +0 -297
  146. package/dist/core/types.d.ts +0 -92
  147. package/dist/core/types.d.ts.map +0 -1
  148. package/dist/core/types.js +0 -25
  149. package/dist/data/data-asset.d.ts +0 -101
  150. package/dist/data/data-asset.d.ts.map +0 -1
  151. package/dist/data/data-asset.js +0 -122
  152. package/dist/data/data-check-core.d.ts +0 -110
  153. package/dist/data/data-check-core.d.ts.map +0 -1
  154. package/dist/data/data-check-core.js +0 -178
  155. package/dist/data/data-ref.d.ts +0 -79
  156. package/dist/data/data-ref.d.ts.map +0 -1
  157. package/dist/data/data-ref.js +0 -130
  158. package/dist/data/vite-plugin-data.d.ts +0 -79
  159. package/dist/data/vite-plugin-data.d.ts.map +0 -1
  160. package/dist/data/vite-plugin-data.js +0 -217
  161. package/dist/dev/console-bridge.d.ts +0 -22
  162. package/dist/dev/console-bridge.d.ts.map +0 -1
  163. package/dist/dev/console-bridge.js +0 -71
  164. package/dist/dev/debug-draw.d.ts +0 -24
  165. package/dist/dev/debug-draw.d.ts.map +0 -1
  166. package/dist/dev/debug-draw.js +0 -73
  167. package/dist/dev/logger.d.ts +0 -30
  168. package/dist/dev/logger.d.ts.map +0 -1
  169. package/dist/dev/logger.js +0 -90
  170. package/dist/dev/performance-profiler.d.ts +0 -60
  171. package/dist/dev/performance-profiler.d.ts.map +0 -1
  172. package/dist/dev/performance-profiler.js +0 -181
  173. package/dist/dev/webgl-gpu-timer.d.ts +0 -8
  174. package/dist/dev/webgl-gpu-timer.d.ts.map +0 -1
  175. package/dist/dev/webgl-gpu-timer.js +0 -52
  176. package/dist/ecs/component-manager.d.ts +0 -205
  177. package/dist/ecs/component-manager.d.ts.map +0 -1
  178. package/dist/ecs/component-manager.js +0 -706
  179. package/dist/ecs/game-component.d.ts +0 -146
  180. package/dist/ecs/game-component.d.ts.map +0 -1
  181. package/dist/ecs/game-component.js +0 -141
  182. package/dist/ecs/hmr-swap-report.d.ts +0 -53
  183. package/dist/ecs/hmr-swap-report.d.ts.map +0 -1
  184. package/dist/ecs/hmr-swap-report.js +0 -55
  185. package/dist/humanoid/bake.operation.d.ts +0 -119
  186. package/dist/humanoid/bake.operation.d.ts.map +0 -1
  187. package/dist/humanoid/bake.operation.js +0 -228
  188. package/dist/humanoid/body.d.ts +0 -101
  189. package/dist/humanoid/body.d.ts.map +0 -1
  190. package/dist/humanoid/body.js +0 -530
  191. package/dist/humanoid/clips.d.ts +0 -62
  192. package/dist/humanoid/clips.d.ts.map +0 -1
  193. package/dist/humanoid/clips.js +0 -121
  194. package/dist/humanoid/compose.d.ts +0 -75
  195. package/dist/humanoid/compose.d.ts.map +0 -1
  196. package/dist/humanoid/compose.js +0 -176
  197. package/dist/humanoid/generate.d.ts +0 -92
  198. package/dist/humanoid/generate.d.ts.map +0 -1
  199. package/dist/humanoid/generate.js +0 -124
  200. package/dist/humanoid/index.d.ts +0 -24
  201. package/dist/humanoid/index.d.ts.map +0 -1
  202. package/dist/humanoid/index.js +0 -18
  203. package/dist/humanoid/schema.d.ts +0 -35
  204. package/dist/humanoid/schema.d.ts.map +0 -1
  205. package/dist/humanoid/schema.js +0 -87
  206. package/dist/humanoid/skeleton.d.ts +0 -103
  207. package/dist/humanoid/skeleton.d.ts.map +0 -1
  208. package/dist/humanoid/skeleton.js +0 -289
  209. package/dist/index.d.ts +0 -37
  210. package/dist/index.d.ts.map +0 -1
  211. package/dist/index.js +0 -30
  212. package/dist/input/input-manager.d.ts +0 -945
  213. package/dist/input/input-manager.d.ts.map +0 -1
  214. package/dist/input/input-manager.js +0 -2207
  215. package/dist/input/input-types.d.ts +0 -174
  216. package/dist/input/input-types.d.ts.map +0 -1
  217. package/dist/input/input-types.js +0 -1
  218. package/dist/input/prompt-labels.d.ts +0 -21
  219. package/dist/input/prompt-labels.d.ts.map +0 -1
  220. package/dist/input/prompt-labels.js +0 -121
  221. package/dist/input/rebind-controller.d.ts +0 -59
  222. package/dist/input/rebind-controller.d.ts.map +0 -1
  223. package/dist/input/rebind-controller.js +0 -85
  224. package/dist/input/schema.d.ts +0 -16
  225. package/dist/input/schema.d.ts.map +0 -1
  226. package/dist/input/schema.js +0 -228
  227. package/dist/loader.d.ts +0 -43
  228. package/dist/loader.d.ts.map +0 -1
  229. package/dist/loader.js +0 -59
  230. package/dist/manifest/index.d.ts +0 -5
  231. package/dist/manifest/index.d.ts.map +0 -1
  232. package/dist/manifest/index.js +0 -8
  233. package/dist/manifest/load-file.d.ts +0 -4
  234. package/dist/manifest/load-file.d.ts.map +0 -1
  235. package/dist/manifest/load-file.js +0 -14
  236. package/dist/manifest/load.d.ts +0 -144
  237. package/dist/manifest/load.d.ts.map +0 -1
  238. package/dist/manifest/load.js +0 -273
  239. package/dist/manifest/schema.d.ts +0 -230
  240. package/dist/manifest/schema.d.ts.map +0 -1
  241. package/dist/manifest/schema.js +0 -394
  242. package/dist/physics/collision-system.d.ts +0 -41
  243. package/dist/physics/collision-system.d.ts.map +0 -1
  244. package/dist/physics/collision-system.js +0 -64
  245. package/dist/physics/physics-registry.d.ts +0 -45
  246. package/dist/physics/physics-registry.d.ts.map +0 -1
  247. package/dist/physics/physics-registry.js +0 -65
  248. package/dist/physics/transform-writer.d.ts +0 -16
  249. package/dist/physics/transform-writer.d.ts.map +0 -1
  250. package/dist/physics/transform-writer.js +0 -38
  251. package/dist/physics/trigger-dispatch.d.ts +0 -24
  252. package/dist/physics/trigger-dispatch.d.ts.map +0 -1
  253. package/dist/physics/trigger-dispatch.js +0 -80
  254. package/dist/react/game-state.d.ts +0 -156
  255. package/dist/react/game-state.d.ts.map +0 -1
  256. package/dist/react/game-state.js +0 -222
  257. package/dist/react/root-adapter.d.ts +0 -11
  258. package/dist/react/root-adapter.d.ts.map +0 -1
  259. package/dist/react/root-adapter.js +0 -41
  260. package/dist/react/unmanaged-root-detector.d.ts +0 -12
  261. package/dist/react/unmanaged-root-detector.d.ts.map +0 -1
  262. package/dist/react/unmanaged-root-detector.js +0 -45
  263. package/dist/react/use-data.d.ts +0 -60
  264. package/dist/react/use-data.d.ts.map +0 -1
  265. package/dist/react/use-data.js +0 -101
  266. package/dist/react/use-selection.d.ts +0 -75
  267. package/dist/react/use-selection.d.ts.map +0 -1
  268. package/dist/react/use-selection.js +0 -90
  269. package/dist/render/auto-batcher.d.ts +0 -34
  270. package/dist/render/auto-batcher.d.ts.map +0 -1
  271. package/dist/render/auto-batcher.js +0 -140
  272. package/dist/render/render-batch-system.d.ts +0 -33
  273. package/dist/render/render-batch-system.d.ts.map +0 -1
  274. package/dist/render/render-batch-system.js +0 -230
  275. package/dist/render/render-features.d.ts +0 -47
  276. package/dist/render/render-features.d.ts.map +0 -1
  277. package/dist/render/render-features.js +0 -105
  278. package/dist/render/render-settings.d.ts +0 -36
  279. package/dist/render/render-settings.d.ts.map +0 -1
  280. package/dist/render/render-settings.js +0 -51
  281. package/dist/runtime/create-runtime.d.ts +0 -249
  282. package/dist/runtime/create-runtime.d.ts.map +0 -1
  283. package/dist/runtime/create-runtime.js +0 -641
  284. package/dist/runtime/debug-bridge.d.ts +0 -257
  285. package/dist/runtime/debug-bridge.d.ts.map +0 -1
  286. package/dist/runtime/debug-bridge.js +0 -224
  287. package/dist/runtime/debug-registry.d.ts +0 -288
  288. package/dist/runtime/debug-registry.d.ts.map +0 -1
  289. package/dist/runtime/debug-registry.js +0 -513
  290. package/dist/runtime/frame-selector-cache.d.ts +0 -41
  291. package/dist/runtime/frame-selector-cache.d.ts.map +0 -1
  292. package/dist/runtime/frame-selector-cache.js +0 -65
  293. package/dist/runtime/game.d.ts +0 -496
  294. package/dist/runtime/game.d.ts.map +0 -1
  295. package/dist/runtime/game.js +0 -741
  296. package/dist/runtime/gameplay-rng-trap.d.ts +0 -48
  297. package/dist/runtime/gameplay-rng-trap.d.ts.map +0 -1
  298. package/dist/runtime/gameplay-rng-trap.js +0 -96
  299. package/dist/runtime/input-router.d.ts +0 -78
  300. package/dist/runtime/input-router.d.ts.map +0 -1
  301. package/dist/runtime/input-router.js +0 -171
  302. package/dist/runtime/mount-game.d.ts +0 -129
  303. package/dist/runtime/mount-game.d.ts.map +0 -1
  304. package/dist/runtime/mount-game.js +0 -152
  305. package/dist/runtime/mount-manifest.d.ts +0 -173
  306. package/dist/runtime/mount-manifest.d.ts.map +0 -1
  307. package/dist/runtime/mount-manifest.js +0 -297
  308. package/dist/runtime/render-audio-control.d.ts +0 -110
  309. package/dist/runtime/render-audio-control.d.ts.map +0 -1
  310. package/dist/runtime/render-audio-control.js +0 -111
  311. package/dist/runtime/render-control.d.ts +0 -291
  312. package/dist/runtime/render-control.d.ts.map +0 -1
  313. package/dist/runtime/render-control.js +0 -264
  314. package/dist/runtime/render-seed.d.ts +0 -57
  315. package/dist/runtime/render-seed.d.ts.map +0 -1
  316. package/dist/runtime/render-seed.js +0 -74
  317. package/dist/runtime/state-bridge.d.ts +0 -61
  318. package/dist/runtime/state-bridge.d.ts.map +0 -1
  319. package/dist/runtime/state-bridge.js +0 -63
  320. package/dist/runtime/types.d.ts +0 -253
  321. package/dist/runtime/types.d.ts.map +0 -1
  322. package/dist/runtime/types.js +0 -1
  323. package/dist/scene/asset-loaders.d.ts +0 -79
  324. package/dist/scene/asset-loaders.d.ts.map +0 -1
  325. package/dist/scene/asset-loaders.js +0 -141
  326. package/dist/scene/asset-paths.d.ts +0 -11
  327. package/dist/scene/asset-paths.d.ts.map +0 -1
  328. package/dist/scene/asset-paths.js +0 -108
  329. package/dist/scene/asset-ref-check.d.ts +0 -88
  330. package/dist/scene/asset-ref-check.d.ts.map +0 -1
  331. package/dist/scene/asset-ref-check.js +0 -214
  332. package/dist/scene/asset-registry.d.ts +0 -38
  333. package/dist/scene/asset-registry.d.ts.map +0 -1
  334. package/dist/scene/asset-registry.js +0 -66
  335. package/dist/scene/collider-dimensions.d.ts +0 -63
  336. package/dist/scene/collider-dimensions.d.ts.map +0 -1
  337. package/dist/scene/collider-dimensions.js +0 -98
  338. package/dist/scene/component-registry.d.ts +0 -22
  339. package/dist/scene/component-registry.d.ts.map +0 -1
  340. package/dist/scene/component-registry.js +0 -37
  341. package/dist/scene/defaults.d.ts +0 -252
  342. package/dist/scene/defaults.d.ts.map +0 -1
  343. package/dist/scene/defaults.js +0 -151
  344. package/dist/scene/geometries/index.d.ts +0 -8
  345. package/dist/scene/geometries/index.d.ts.map +0 -1
  346. package/dist/scene/geometries/index.js +0 -7
  347. package/dist/scene/geometries/terrain.d.ts +0 -2
  348. package/dist/scene/geometries/terrain.d.ts.map +0 -1
  349. package/dist/scene/geometries/terrain.js +0 -37
  350. package/dist/scene/geometry-registry.d.ts +0 -24
  351. package/dist/scene/geometry-registry.d.ts.map +0 -1
  352. package/dist/scene/geometry-registry.js +0 -20
  353. package/dist/scene/instance-registry.d.ts +0 -36
  354. package/dist/scene/instance-registry.d.ts.map +0 -1
  355. package/dist/scene/instance-registry.js +0 -55
  356. package/dist/scene/instancers/grid.d.ts +0 -2
  357. package/dist/scene/instancers/grid.d.ts.map +0 -1
  358. package/dist/scene/instancers/grid.js +0 -36
  359. package/dist/scene/instancers/index.d.ts +0 -8
  360. package/dist/scene/instancers/index.d.ts.map +0 -1
  361. package/dist/scene/instancers/index.js +0 -7
  362. package/dist/scene/light-camera-factory.d.ts +0 -23
  363. package/dist/scene/light-camera-factory.d.ts.map +0 -1
  364. package/dist/scene/light-camera-factory.js +0 -68
  365. package/dist/scene/material-factory.d.ts +0 -17
  366. package/dist/scene/material-factory.d.ts.map +0 -1
  367. package/dist/scene/material-factory.js +0 -197
  368. package/dist/scene/material-registry.d.ts +0 -40
  369. package/dist/scene/material-registry.d.ts.map +0 -1
  370. package/dist/scene/material-registry.js +0 -44
  371. package/dist/scene/materials/index.d.ts +0 -8
  372. package/dist/scene/materials/index.d.ts.map +0 -1
  373. package/dist/scene/materials/index.js +0 -7
  374. package/dist/scene/materials/water.d.ts +0 -2
  375. package/dist/scene/materials/water.d.ts.map +0 -1
  376. package/dist/scene/materials/water.js +0 -54
  377. package/dist/scene/parse.d.ts +0 -23
  378. package/dist/scene/parse.d.ts.map +0 -1
  379. package/dist/scene/parse.js +0 -179
  380. package/dist/scene/particles-factory.d.ts +0 -33
  381. package/dist/scene/particles-factory.d.ts.map +0 -1
  382. package/dist/scene/particles-factory.js +0 -282
  383. package/dist/scene/scene-apply.d.ts +0 -109
  384. package/dist/scene/scene-apply.d.ts.map +0 -1
  385. package/dist/scene/scene-apply.js +0 -370
  386. package/dist/scene/scene-diff-schema.d.ts +0 -285
  387. package/dist/scene/scene-diff-schema.d.ts.map +0 -1
  388. package/dist/scene/scene-diff-schema.js +0 -92
  389. package/dist/scene/scene-diff-types.d.ts +0 -40
  390. package/dist/scene/scene-diff-types.d.ts.map +0 -1
  391. package/dist/scene/scene-diff-types.js +0 -14
  392. package/dist/scene/scene-loader.d.ts +0 -167
  393. package/dist/scene/scene-loader.d.ts.map +0 -1
  394. package/dist/scene/scene-loader.js +0 -1211
  395. package/dist/scene/scene-query.d.ts +0 -11
  396. package/dist/scene/scene-query.d.ts.map +0 -1
  397. package/dist/scene/scene-query.js +0 -63
  398. package/dist/scene/scene-types.d.ts +0 -10
  399. package/dist/scene/scene-types.d.ts.map +0 -1
  400. package/dist/scene/scene-types.js +0 -8
  401. package/dist/scene/scene-version.d.ts +0 -26
  402. package/dist/scene/scene-version.d.ts.map +0 -1
  403. package/dist/scene/scene-version.js +0 -34
  404. package/dist/scene/schema/animation.d.ts +0 -8
  405. package/dist/scene/schema/animation.d.ts.map +0 -1
  406. package/dist/scene/schema/animation.js +0 -42
  407. package/dist/scene/schema/audio.d.ts +0 -13
  408. package/dist/scene/schema/audio.d.ts.map +0 -1
  409. package/dist/scene/schema/audio.js +0 -22
  410. package/dist/scene/schema/camera.d.ts +0 -28
  411. package/dist/scene/schema/camera.d.ts.map +0 -1
  412. package/dist/scene/schema/camera.js +0 -17
  413. package/dist/scene/schema/collider.d.ts +0 -40
  414. package/dist/scene/schema/collider.d.ts.map +0 -1
  415. package/dist/scene/schema/collider.js +0 -55
  416. package/dist/scene/schema/entity-ref.d.ts +0 -31
  417. package/dist/scene/schema/entity-ref.d.ts.map +0 -1
  418. package/dist/scene/schema/entity-ref.js +0 -61
  419. package/dist/scene/schema/entity.d.ts +0 -1036
  420. package/dist/scene/schema/entity.d.ts.map +0 -1
  421. package/dist/scene/schema/entity.js +0 -153
  422. package/dist/scene/schema/environment.d.ts +0 -425
  423. package/dist/scene/schema/environment.d.ts.map +0 -1
  424. package/dist/scene/schema/environment.js +0 -357
  425. package/dist/scene/schema/index.d.ts +0 -37
  426. package/dist/scene/schema/index.d.ts.map +0 -1
  427. package/dist/scene/schema/index.js +0 -19
  428. package/dist/scene/schema/instances.d.ts +0 -14
  429. package/dist/scene/schema/instances.d.ts.map +0 -1
  430. package/dist/scene/schema/instances.js +0 -28
  431. package/dist/scene/schema/joint.d.ts +0 -23
  432. package/dist/scene/schema/joint.d.ts.map +0 -1
  433. package/dist/scene/schema/joint.js +0 -23
  434. package/dist/scene/schema/light.d.ts +0 -38
  435. package/dist/scene/schema/light.d.ts.map +0 -1
  436. package/dist/scene/schema/light.js +0 -26
  437. package/dist/scene/schema/material.d.ts +0 -199
  438. package/dist/scene/schema/material.d.ts.map +0 -1
  439. package/dist/scene/schema/material.js +0 -103
  440. package/dist/scene/schema/mesh.d.ts +0 -48
  441. package/dist/scene/schema/mesh.d.ts.map +0 -1
  442. package/dist/scene/schema/mesh.js +0 -82
  443. package/dist/scene/schema/particles.d.ts +0 -2178
  444. package/dist/scene/schema/particles.d.ts.map +0 -1
  445. package/dist/scene/schema/particles.js +0 -321
  446. package/dist/scene/schema/physics.d.ts +0 -56
  447. package/dist/scene/schema/physics.d.ts.map +0 -1
  448. package/dist/scene/schema/physics.js +0 -37
  449. package/dist/scene/schema/scene-file.d.ts +0 -303
  450. package/dist/scene/schema/scene-file.d.ts.map +0 -1
  451. package/dist/scene/schema/scene-file.js +0 -256
  452. package/dist/scene/schema/shadow.d.ts +0 -28
  453. package/dist/scene/schema/shadow.d.ts.map +0 -1
  454. package/dist/scene/schema/shadow.js +0 -20
  455. package/dist/scene/schema/spline.d.ts +0 -25
  456. package/dist/scene/schema/spline.d.ts.map +0 -1
  457. package/dist/scene/schema/spline.js +0 -15
  458. package/dist/scene/schema/tuples.d.ts +0 -12
  459. package/dist/scene/schema/tuples.d.ts.map +0 -1
  460. package/dist/scene/schema/tuples.js +0 -14
  461. package/dist/scene/user-data.d.ts +0 -185
  462. package/dist/scene/user-data.d.ts.map +0 -1
  463. package/dist/scene/user-data.js +0 -144
  464. package/dist/setup/setup-audio.d.ts +0 -20
  465. package/dist/setup/setup-audio.d.ts.map +0 -1
  466. package/dist/setup/setup-audio.js +0 -41
  467. package/dist/setup/setup-particles.d.ts +0 -17
  468. package/dist/setup/setup-particles.d.ts.map +0 -1
  469. package/dist/setup/setup-particles.js +0 -16
  470. package/dist/setup/setup-physics.d.ts +0 -25
  471. package/dist/setup/setup-physics.d.ts.map +0 -1
  472. package/dist/setup/setup-physics.js +0 -51
  473. package/dist/setup/setup-renderer.d.ts +0 -69
  474. package/dist/setup/setup-renderer.d.ts.map +0 -1
  475. package/dist/setup/setup-renderer.js +0 -363
  476. package/dist/tools/define-tool.d.ts +0 -130
  477. package/dist/tools/define-tool.d.ts.map +0 -1
  478. package/dist/tools/define-tool.js +0 -96
  479. package/dist/world2d/authoring-2d.d.ts +0 -80
  480. package/dist/world2d/authoring-2d.d.ts.map +0 -1
  481. package/dist/world2d/authoring-2d.js +0 -195
  482. package/dist/world2d/capture-to-scene2d.d.ts +0 -5
  483. package/dist/world2d/capture-to-scene2d.d.ts.map +0 -1
  484. package/dist/world2d/capture-to-scene2d.js +0 -49
  485. package/dist/world2d/collision-2d.d.ts +0 -52
  486. package/dist/world2d/collision-2d.d.ts.map +0 -1
  487. package/dist/world2d/collision-2d.js +0 -70
  488. package/dist/world2d/components-2d.d.ts +0 -47
  489. package/dist/world2d/components-2d.d.ts.map +0 -1
  490. package/dist/world2d/components-2d.js +0 -77
  491. package/dist/world2d/index.d.ts +0 -34
  492. package/dist/world2d/index.d.ts.map +0 -1
  493. package/dist/world2d/index.js +0 -32
  494. package/dist/world2d/ingest-iframe-2d.d.ts +0 -82
  495. package/dist/world2d/ingest-iframe-2d.d.ts.map +0 -1
  496. package/dist/world2d/ingest-iframe-2d.js +0 -166
  497. package/dist/world2d/ingest2d.d.ts +0 -97
  498. package/dist/world2d/ingest2d.d.ts.map +0 -1
  499. package/dist/world2d/ingest2d.js +0 -40
  500. package/dist/world2d/physics2d-registry.d.ts +0 -24
  501. package/dist/world2d/physics2d-registry.d.ts.map +0 -1
  502. package/dist/world2d/physics2d-registry.js +0 -38
  503. package/dist/world2d/pixi-game-adapter.d.ts +0 -107
  504. package/dist/world2d/pixi-game-adapter.d.ts.map +0 -1
  505. package/dist/world2d/pixi-game-adapter.js +0 -210
  506. package/dist/world2d/pixi-surface.d.ts +0 -39
  507. package/dist/world2d/pixi-surface.d.ts.map +0 -1
  508. package/dist/world2d/pixi-surface.js +0 -47
  509. package/dist/world2d/scene-capture-2d.d.ts +0 -43
  510. package/dist/world2d/scene-capture-2d.d.ts.map +0 -1
  511. package/dist/world2d/scene-capture-2d.js +0 -92
  512. package/dist/world2d/scene2d-loader.d.ts +0 -27
  513. package/dist/world2d/scene2d-loader.d.ts.map +0 -1
  514. package/dist/world2d/scene2d-loader.js +0 -275
  515. package/dist/world2d/schema/entity2d.d.ts +0 -102
  516. package/dist/world2d/schema/entity2d.d.ts.map +0 -1
  517. package/dist/world2d/schema/entity2d.js +0 -119
  518. package/dist/world2d/schema/physics2d.d.ts +0 -46
  519. package/dist/world2d/schema/physics2d.d.ts.map +0 -1
  520. package/dist/world2d/schema/physics2d.js +0 -45
  521. package/dist/world2d/schema/sprite.d.ts +0 -42
  522. package/dist/world2d/schema/sprite.d.ts.map +0 -1
  523. package/dist/world2d/schema/sprite.js +0 -63
  524. package/dist/world2d/schema/tilemap.d.ts +0 -15
  525. package/dist/world2d/schema/tilemap.d.ts.map +0 -1
  526. package/dist/world2d/schema/tilemap.js +0 -19
  527. package/dist/world2d/schema/tuples2d.d.ts +0 -20
  528. package/dist/world2d/schema/tuples2d.d.ts.map +0 -1
  529. package/dist/world2d/schema/tuples2d.js +0 -19
  530. package/dist/world2d/system-adapters-2d.d.ts +0 -16
  531. package/dist/world2d/system-adapters-2d.d.ts.map +0 -1
  532. package/dist/world2d/system-adapters-2d.js +0 -37
  533. package/dist/world2d/transform-writer-2d.d.ts +0 -16
  534. package/dist/world2d/transform-writer-2d.d.ts.map +0 -1
  535. package/dist/world2d/transform-writer-2d.js +0 -22
  536. package/dist/world2d/types.d.ts +0 -59
  537. package/dist/world2d/types.d.ts.map +0 -1
  538. package/dist/world2d/types.js +0 -1
@@ -1,264 +0,0 @@
1
- /**
2
- * Render-control runtime seam (I2, `docs/AI-NATIVE-AUTHORING-IMPLEMENTATION-SPEC.md`
3
- * §15 I2). This is the harness a deterministic-capture host (Playwright/CDP,
4
- * I0/I3/I4) drives: exact-time seeks against the canonical
5
- * `AnimationClock` (`animation/animation-clock.ts`), and single
6
- * `preRender`+`render` phase passes across every world on a `Game`
7
- * (`runtime/game.ts`) — WITHOUT ever advancing gameplay fixed-step substeps
8
- * (`input`/`prePhysics`/`physics`/`postPhysics`/`gameLogic`/`animation` are
9
- * never invoked by this seam; `--simulate` (I5) is a different, later, path
10
- * that deliberately drives `game.runFrame(fixedDt)` instead).
11
- *
12
- * This module does NOT reuse `PlayState.step()` (`Game.play.step()`) — that
13
- * surface only advances the currently-FROZEN (paused) set of roots and is a
14
- * whole-call no-op while unpaused (see its doc comment in `runtime/game.ts`);
15
- * the spec review explicitly flagged it as the wrong seam. `renderOnce`
16
- * instead walks `game.roots` directly and calls each world's own
17
- * `WorldFrameHooks.runPhase` for exactly two phases.
18
- *
19
- * Also does NOT install anything by default — a caller must explicitly call
20
- * {@link installRenderControlHarness}, and even then it only actually
21
- * publishes `window.__vgaiRender` when the page's URL opts in via
22
- * `?vgai-render=1` (AC 4: unavailable/protected in normal production
23
- * gameplay unless explicitly enabled). See `render-seed.ts` for the
24
- * matching `Math.random` determinism hardening, which must run BEFORE this
25
- * module (or any other game module) is even imported.
26
- *
27
- * I5 (`--simulate` render, §15 I5) is implemented HERE, alongside `renderOnce`:
28
- * {@link VgaiRenderHarness.simulateSubsteps} drives `game.runFrame(fixedDt)` a
29
- * fixed integer number of times — the FULL fixed-step gameplay frame (every
30
- * phase in `PHASE_ORDER`, including `physics`/`gameLogic`/`animation`), unlike
31
- * `renderOnce`'s deliberately gameplay-free `preRender`+`render`-only pass.
32
- * A caller that never invokes `simulateSubsteps` (the default, sequence-
33
- * controlled render — I4) gets byte-identical behavior to before this method
34
- * existed: `renderOnce`/`seek`/`seekFrame`/`advanceFrame` are untouched by
35
- * this addition.
36
- */
37
- import { SystemPhase } from '../core/types';
38
- import { RENDER_MODE_QUERY_PARAM } from './render-seed';
39
- /** Shared by {@link installRenderControlHarness} and any caller that wants
40
- * to check the opt-in flag before doing render-mode-only setup work (e.g.
41
- * `render-seed.ts`'s own gate uses the same query param name). */
42
- export function isRenderModeRequested(location) {
43
- return new URLSearchParams(location.search).get(RENDER_MODE_QUERY_PARAM) === '1';
44
- }
45
- const RENDER_ONLY_PHASES = [SystemPhase.PRE_RENDER, SystemPhase.RENDER];
46
- /**
47
- * Run exactly one `preRender`+`render` phase pass across every host-driven
48
- * (`!drivesOwnLoop`) world on `game`, then await the GPU/DOM composition
49
- * fence. This is the ENTIRE frame this call drives — no `input`,
50
- * `prePhysics`, `physics`, `postPhysics`, `gameLogic`, or `animation` phase
51
- * is ever touched, which is what makes this safe to call from a paused-or-
52
- * stopped clock without silently ticking gameplay. Phases are run as global
53
- * barriers across roots (mirroring `GameInternal.runFrame`'s own phase-then-
54
- * world nesting in `runtime/game.ts`): every world's `preRender` runs before
55
- * any world's `render`, in `game.roots` declaration order.
56
- *
57
- * Ordering within a phase mirrors `GameInternal.runFrame` EXACTLY (see its
58
- * doc comment in `runtime/game.ts`): the game-scoped `SystemRunner`
59
- * (`game.systems`) runs FIRST, before any world's frame hooks. `game.systems`
60
- * is empty for every game today (nothing registers against it yet), so this
61
- * is a no-op in practice — but a later slice that registers a Game-scoped
62
- * `preRender`/`render` system (e.g. a cinematic camera crossfade that must
63
- * paint once per captured frame) would otherwise be silently MISSED by
64
- * capture while running fine in live playback, since live playback goes
65
- * through `runFrame`. Running it here keeps the seam a faithful subset of
66
- * `runFrame`'s phase pass, not a divergent one.
67
- *
68
- * A `drivesOwnLoop` world (self-driven, raw-rAF) has no phase hooks this
69
- * seam can drive — it is skipped with a loud, once-per-call warning rather
70
- * than silently omitted, mirroring this file's "fail loudly, never a silent
71
- * no-op" convention. A host-driven world with no `frame` (an opaque/foreign
72
- * mount) is skipped the same way — there is no phase hook to call. Both
73
- * checks happen ONCE, up front (see {@link renderableWorlds}), not per
74
- * phase — a world unrenderable in `preRender` is unrenderable in `render`
75
- * too, so warning twice would just be noise.
76
- */
77
- async function renderOnce(game) {
78
- const roots = renderableWorlds(game);
79
- for (const phase of RENDER_ONLY_PHASES) {
80
- // Game-scoped systems first, then per-world frame hooks — the SAME order
81
- // GameInternal.runFrame uses (runtime/game.ts). See doc comment above.
82
- game.systems.runPhase(phase, 0);
83
- for (const world of roots) {
84
- world.frame.runPhase(phase, 0);
85
- }
86
- }
87
- await compositionFence();
88
- }
89
- /** Filter `game.roots` down to the ones {@link renderOnce} can actually
90
- * drive (host-driven, with real `WorldFrameHooks`) — see that function's
91
- * doc comment for why an excluded world is warned about loudly, not
92
- * silently dropped. */
93
- function renderableWorlds(game) {
94
- const result = [];
95
- for (const world of game.roots) {
96
- if (world.mounted.drivesOwnLoop) {
97
- warnUnrenderable(world.id, 'drives its own loop — renderOnce() cannot frame-gate it ' +
98
- '(docs/AI-NATIVE-AUTHORING-IMPLEMENTATION-SPEC.md §15 I5 names this policy)');
99
- continue;
100
- }
101
- if (!world.frame) {
102
- warnUnrenderable(world.id, `(kind: ${world.kind}) has no phase hooks — renderOnce() cannot drive it (opaque/foreign ` +
103
- 'mount with no frame-gated entry point)');
104
- continue;
105
- }
106
- result.push({ id: world.id, frame: world.frame });
107
- }
108
- return result;
109
- }
110
- function warnUnrenderable(worldLabel, reason) {
111
- // biome-ignore lint/suspicious/noConsole: structured, greppable — mirrors runtime/game.ts's own direct console.warn idiom for "cannot gate this world" capability shortfalls.
112
- console.warn(`[render-control] world "${worldLabel}" ${reason}.`);
113
- }
114
- /**
115
- * I5 AC 5 policy text for the two conditions {@link renderableWorlds} skips —
116
- * shared so {@link VgaiRenderHarness.excludedFromDeterminism} names the SAME
117
- * roots `renderOnce()` warns about, in the SAME words, rather than
118
- * maintaining a second, driftable description of the same two checks.
119
- */
120
- function computeWorldExclusionReasons(game) {
121
- const reasons = [];
122
- for (const world of game.roots) {
123
- if (world.mounted.drivesOwnLoop) {
124
- reasons.push(`world "${world.id}" drives its own loop — cannot be frame-gated for deterministic ` +
125
- 'capture (docs/AI-NATIVE-AUTHORING-IMPLEMENTATION-SPEC.md §15 I5 names this policy: ' +
126
- 'FAIL LOUDLY or be excluded only by an explicit declared policy).');
127
- continue;
128
- }
129
- if (!world.frame) {
130
- reasons.push(`world "${world.id}" (kind: ${world.kind}) has no phase hooks — an opaque/foreign mount ` +
131
- 'with no frame-gated entry point cannot participate in deterministic capture.');
132
- }
133
- }
134
- return reasons;
135
- }
136
- function nextAnimationFrame() {
137
- return new Promise((resolve) => {
138
- requestAnimationFrame(() => resolve());
139
- });
140
- }
141
- /**
142
- * GPU/DOM composition fence (I2 AC: "waits for GPU/DOM composition
143
- * (double-rAF fence ... ) rather than an arbitrary sleep"). Two nested
144
- * `requestAnimationFrame` callbacks: the first fires once the browser has
145
- * scheduled a new frame after our `render()` calls above; the second fires
146
- * once THAT frame has itself been produced and composited — by the time the
147
- * second callback runs, the compositor has committed the frame our render
148
- * calls painted, so a screenshot taken immediately after this resolves
149
- * reflects the seeked state, not a stale one. (The CDP screenshot
150
- * compositor-commit wait itself is the capture host's job — I0/I3 — this
151
- * fence is the runtime-side half.)
152
- */
153
- async function compositionFence() {
154
- await nextAnimationFrame();
155
- await nextAnimationFrame();
156
- }
157
- async function resolveHook(hook) {
158
- if (!hook)
159
- return { status: 'not-applicable' };
160
- try {
161
- await hook();
162
- return { status: 'ready' };
163
- }
164
- catch (err) {
165
- return { status: 'error', detail: err instanceof Error ? err.message : String(err) };
166
- }
167
- }
168
- async function checkFontsReady() {
169
- if (typeof document === 'undefined' || !document.fonts)
170
- return { status: 'not-applicable' };
171
- try {
172
- await document.fonts.ready;
173
- return { status: 'ready' };
174
- }
175
- catch (err) {
176
- return { status: 'error', detail: err instanceof Error ? err.message : String(err) };
177
- }
178
- }
179
- async function buildReadinessReport(hooks) {
180
- const [assets, shaders, fonts, theatre, tone, scene] = await Promise.all([
181
- resolveHook(hooks.assets),
182
- resolveHook(hooks.shaders),
183
- checkFontsReady(),
184
- resolveHook(hooks.theatre),
185
- resolveHook(hooks.tone),
186
- resolveHook(hooks.scene),
187
- ]);
188
- return { assets, shaders, fonts, theatre, tone, scene };
189
- }
190
- /**
191
- * Build (and, when render mode is actually requested, publish) the
192
- * `window.__vgaiRender` harness. AC 4 — production protection — lives HERE,
193
- * not just at the call site: even if a host application calls this
194
- * unconditionally on every boot, the harness is only ever constructed *and*
195
- * attached to `target` when `isRenderModeRequested(location)` is true;
196
- * otherwise this is a no-op that returns `undefined`. A normal production
197
- * gameplay page therefore never gets `window.__vgaiRender` no matter how
198
- * this function is wired into its entry point.
199
- */
200
- export function installRenderControlHarness(opts) {
201
- const location = opts.location ?? window.location;
202
- if (!isRenderModeRequested(location))
203
- return undefined;
204
- const { game, clock, readiness = {} } = opts;
205
- const target = opts.target ?? window;
206
- const frameAdvancers = opts.frameAdvancers ?? [];
207
- const simulateFixedDt = opts.simulateFixedDt ?? 1 / 60;
208
- const declaredExclusions = opts.excludedFromDeterminism ?? [];
209
- const harness = {
210
- seek(t) {
211
- clock.seek(t);
212
- },
213
- seekFrame(n, fps) {
214
- clock.seekFrame(n, fps);
215
- },
216
- advanceFrame(dt) {
217
- for (const advancer of frameAdvancers)
218
- advancer(dt);
219
- },
220
- renderOnce() {
221
- return renderOnce(game);
222
- },
223
- ready() {
224
- return buildReadinessReport(readiness);
225
- },
226
- simulateSubsteps(steps) {
227
- for (let i = 0; i < steps; i++) {
228
- game.runFrame(simulateFixedDt);
229
- }
230
- },
231
- excludedFromDeterminism() {
232
- return [...declaredExclusions, ...computeWorldExclusionReasons(game)];
233
- },
234
- simulateFixedDt() {
235
- return simulateFixedDt;
236
- },
237
- };
238
- target['__vgaiRender'] = harness;
239
- return harness;
240
- }
241
- /**
242
- * Defensive assertion for the I2 AC "Pixi roots are pinned to the WebGL
243
- * renderer (not WebGPU) in render mode". In THIS engine that invariant
244
- * already holds unconditionally — `world2d/pixi-surface.ts`'s
245
- * `createPixiSurface` hardcodes `preference: 'webgl'` on every
246
- * `Application.init()` call it makes, and `setup/setup-renderer.ts` never
247
- * constructs a `WebGPURenderer` for threejs roots either — so there is no
248
- * live WebGPU code path for a first-party render-mode page to disable.
249
- * This helper exists for a render-mode installer that mounts a CUSTOM/
250
- * foreign pixi adapter (`create-runtime.ts`'s `{ module }` pixi path) this
251
- * engine did not construct itself, to assert the invariant against the
252
- * live mounted renderer rather than merely trusting it. Duck-typed against
253
- * pixi.js v8's numeric `RendererType` (`WEBGL = 1`, `WEBGPU = 2`,
254
- * `CANVAS = 4`) so this file never value-imports `pixi.js` (the same
255
- * type-only-pixi rule `runtime/game.ts`/`create-runtime.ts` document for
256
- * themselves).
257
- */
258
- export function assertPixiWorldIsWebGL(rendererType, worldId) {
259
- const isWebGPU = rendererType === 2 || (typeof rendererType === 'string' && /webgpu/i.test(rendererType));
260
- if (isWebGPU) {
261
- throw new Error(`[render-control] world "${worldId}": Pixi renderer is WebGPU in render mode — ` +
262
- 'render-control requires WebGL (docs/AI-NATIVE-AUTHORING-IMPLEMENTATION-SPEC.md §15 I2).');
263
- }
264
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * Deterministic `Math.random` seeding for render-control mode (I2 AC,
3
- * `docs/AI-NATIVE-AUTHORING-IMPLEMENTATION-SPEC.md` §15 I2: "`Math.random`
4
- * is deterministically seeded/stubbed page-wide before any game module
5
- * executes").
6
- *
7
- * Deliberately a ZERO-IMPORT module (no `three`, no other engine file) so
8
- * its own evaluation is instantaneous — a render-mode entry page loads this
9
- * as its FIRST `<script type="module">` tag, before the tag that pulls in
10
- * the actual game/runtime modules. Per the HTML module-script ordering
11
- * rules, sibling `<script type="module">` tags without `async` execute in
12
- * document order, and each one's own dependency graph (here, empty) is
13
- * fully evaluated before the browser moves to the next tag — so calling
14
- * {@link maybeInstallRenderModeRandom} from this module's importer, in a
15
- * script tag placed before the game's own entry tag, guarantees every
16
- * subsequent module's top-level code (and everything it does at runtime)
17
- * observes the seeded generator, never the platform's real
18
- * cryptographically-random `Math.random`.
19
- *
20
- * This module does not decide WHETHER to seed on its own (importing it has
21
- * no side effect) — the caller decides, by calling
22
- * {@link maybeInstallRenderModeRandom} (query-param gated) or
23
- * {@link installDeterministicRandom} (unconditional) from a tiny bootstrap
24
- * entry. See `packages/engine/e2e/fixture/render-seed-entry.ts` for the
25
- * worked bootstrap this module is designed to be loaded from.
26
- */
27
- /**
28
- * mulberry32 — a small, fast, deterministic 32-bit PRNG. Not cryptographic;
29
- * this is explicitly a determinism tool (reproducible capture), not a
30
- * security primitive. Returns a function with the same call signature as
31
- * `Math.random` (no arguments, `[0, 1)` float).
32
- */
33
- export declare function createMulberry32(seed: number): () => number;
34
- /**
35
- * Replace the global `Math.random` with a seeded, deterministic generator.
36
- * Idempotent to call more than once (each call re-seeds from scratch — the
37
- * last call wins), which matters for HMR-style re-execution the same way
38
- * `main.ts`'s `registerAdapterSurface` guard does elsewhere in this runtime.
39
- */
40
- export declare function installDeterministicRandom(seed: number): void;
41
- /** Query-param name that opts a page into render-control mode (I2 AC 4: the
42
- * mode must be unavailable/protected in normal production gameplay unless
43
- * explicitly enabled). Shared with `render-control.ts`'s own production
44
- * guard so both checks agree on the same flag. */
45
- export declare const RENDER_MODE_QUERY_PARAM = "vgai-render";
46
- /** Optional query param to pin a specific seed (default below when absent). */
47
- export declare const RENDER_SEED_QUERY_PARAM = "vgai-seed";
48
- /**
49
- * Seed `Math.random` iff the page's URL opts into render mode
50
- * (`?vgai-render=1`), reading an optional `?vgai-seed=<int>` override.
51
- * Returns whether it seeded, purely for the caller's own diagnostics/log —
52
- * the bootstrap entry doesn't need to branch on it.
53
- */
54
- export declare function maybeInstallRenderModeRandom(location?: {
55
- search: string;
56
- }): boolean;
57
- //# sourceMappingURL=render-seed.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"render-seed.d.ts","sourceRoot":"","sources":["../../src/runtime/render-seed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,MAAM,CAS3D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE7D;AAED;;;mDAGmD;AACnD,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AACrD,+EAA+E;AAC/E,eAAO,MAAM,uBAAuB,cAAc,CAAC;AAGnD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,GAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAoB,GAC7C,OAAO,CAOT"}
@@ -1,74 +0,0 @@
1
- /**
2
- * Deterministic `Math.random` seeding for render-control mode (I2 AC,
3
- * `docs/AI-NATIVE-AUTHORING-IMPLEMENTATION-SPEC.md` §15 I2: "`Math.random`
4
- * is deterministically seeded/stubbed page-wide before any game module
5
- * executes").
6
- *
7
- * Deliberately a ZERO-IMPORT module (no `three`, no other engine file) so
8
- * its own evaluation is instantaneous — a render-mode entry page loads this
9
- * as its FIRST `<script type="module">` tag, before the tag that pulls in
10
- * the actual game/runtime modules. Per the HTML module-script ordering
11
- * rules, sibling `<script type="module">` tags without `async` execute in
12
- * document order, and each one's own dependency graph (here, empty) is
13
- * fully evaluated before the browser moves to the next tag — so calling
14
- * {@link maybeInstallRenderModeRandom} from this module's importer, in a
15
- * script tag placed before the game's own entry tag, guarantees every
16
- * subsequent module's top-level code (and everything it does at runtime)
17
- * observes the seeded generator, never the platform's real
18
- * cryptographically-random `Math.random`.
19
- *
20
- * This module does not decide WHETHER to seed on its own (importing it has
21
- * no side effect) — the caller decides, by calling
22
- * {@link maybeInstallRenderModeRandom} (query-param gated) or
23
- * {@link installDeterministicRandom} (unconditional) from a tiny bootstrap
24
- * entry. See `packages/engine/e2e/fixture/render-seed-entry.ts` for the
25
- * worked bootstrap this module is designed to be loaded from.
26
- */
27
- /**
28
- * mulberry32 — a small, fast, deterministic 32-bit PRNG. Not cryptographic;
29
- * this is explicitly a determinism tool (reproducible capture), not a
30
- * security primitive. Returns a function with the same call signature as
31
- * `Math.random` (no arguments, `[0, 1)` float).
32
- */
33
- export function createMulberry32(seed) {
34
- let state = seed >>> 0;
35
- return function mulberry32() {
36
- state = (state + 0x6d2b79f5) | 0;
37
- let t = state;
38
- t = Math.imul(t ^ (t >>> 15), t | 1);
39
- t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
40
- return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
41
- };
42
- }
43
- /**
44
- * Replace the global `Math.random` with a seeded, deterministic generator.
45
- * Idempotent to call more than once (each call re-seeds from scratch — the
46
- * last call wins), which matters for HMR-style re-execution the same way
47
- * `main.ts`'s `registerAdapterSurface` guard does elsewhere in this runtime.
48
- */
49
- export function installDeterministicRandom(seed) {
50
- Math.random = createMulberry32(seed);
51
- }
52
- /** Query-param name that opts a page into render-control mode (I2 AC 4: the
53
- * mode must be unavailable/protected in normal production gameplay unless
54
- * explicitly enabled). Shared with `render-control.ts`'s own production
55
- * guard so both checks agree on the same flag. */
56
- export const RENDER_MODE_QUERY_PARAM = 'vgai-render';
57
- /** Optional query param to pin a specific seed (default below when absent). */
58
- export const RENDER_SEED_QUERY_PARAM = 'vgai-seed';
59
- const DEFAULT_RENDER_SEED = 0x9e3779b9; // golden-ratio constant — an arbitrary but fixed default
60
- /**
61
- * Seed `Math.random` iff the page's URL opts into render mode
62
- * (`?vgai-render=1`), reading an optional `?vgai-seed=<int>` override.
63
- * Returns whether it seeded, purely for the caller's own diagnostics/log —
64
- * the bootstrap entry doesn't need to branch on it.
65
- */
66
- export function maybeInstallRenderModeRandom(location = window.location) {
67
- const params = new URLSearchParams(location.search);
68
- if (params.get(RENDER_MODE_QUERY_PARAM) !== '1')
69
- return false;
70
- const seedParam = params.get(RENDER_SEED_QUERY_PARAM);
71
- const seed = seedParam !== null && seedParam !== '' ? Number(seedParam) : DEFAULT_RENDER_SEED;
72
- installDeterministicRandom(Number.isFinite(seed) ? seed : DEFAULT_RENDER_SEED);
73
- return true;
74
- }
@@ -1,61 +0,0 @@
1
- /**
2
- * Frame-versioned game state bridge (T7.4 slice 1 — `docs/REACT-STATE-BRIDGE.md`
3
- * §2, the D7 remainder). Components mutate state on `this` freely during
4
- * ticks — there is no proxy, no dirty tracking, no event per mutation (Track
5
- * A: no mirror, no sync layer). So the unit of change a subscriber can
6
- * observe is the FRAME: `GameInternal.runFrame` bumps `frameVersion` and
7
- * notifies subscribers at most once, at its tail, AFTER every phase of every
8
- * world and every world's `endFrame` hook has run (see the wiring in
9
- * `runtime/game.ts`) — mirroring the D7 "from `gameLogic` onward, every
10
- * world's post-step state is readable" guarantee, extended to "after the
11
- * frame, ALL state is readable".
12
- *
13
- * This file is plain, react-free TypeScript any consumer could use — no
14
- * react import here, or anywhere under `runtime/` (the react-facing
15
- * `useGameState` hook, which DOES import React, lives at
16
- * `packages/engine/src/react/game-state.tsx`).
17
- *
18
- * SECOND trigger for `bump()` (`Game.registerWorld`, `runtime/game.ts`): the
19
- * `roots` list is also state a `useGameState` selector can read
20
- * (`g.roots.map(...)`, the T6.2 two-world-compose gate), and it changes
21
- * OUTSIDE the frame loop — `registerWorld` is called as each world finishes
22
- * mounting, which can happen well before the host's loop has ticked even
23
- * once. Without an immediate notification here, a selector that first reads
24
- * `g.roots` before every world has registered stays stuck on that stale
25
- * snapshot until the next completed frame — which, on a slow/contended host
26
- * or a backgrounded tab, may be arbitrarily delayed. See `registerWorld`'s
27
- * own doc comment for the concrete CI failure this closes.
28
- */
29
- /** Frame-versioned, react-free subscription surface — `docs/REACT-STATE-BRIDGE.md` §2. */
30
- export interface GameStateBridge {
31
- /** Monotonic; bumped once per completed `runFrame`, AND once per
32
- * `Game.registerWorld` call (world-list changes are observable state too
33
- * — see this file's module doc comment). Starts at 0 before the first of
34
- * either has happened. Never treat this as a literal frame COUNT — only
35
- * "did it change" is a contract any consumer may rely on. */
36
- readonly frameVersion: number;
37
- /** Notified at most once per frame, after ALL phases of ALL roots (and
38
- * their `endFrame` hooks) have run. Returns an unsubscribe function. */
39
- subscribe(onFrame: () => void): () => void;
40
- }
41
- /** Host-internal extension of {@link GameStateBridge}: adds `bump`, called
42
- * both by `GameInternal.runFrame` at its tail AND by `Game.registerWorld`
43
- * when the world list changes (see this file's module doc comment). NOT
44
- * part of the game-facing `Game.state` surface (typed as the narrower
45
- * `GameStateBridge` there) — games/components/hooks never call `bump`
46
- * directly; only the frame executor and the world registry do. */
47
- export interface GameStateBridgeInternal extends GameStateBridge {
48
- /** Bump `frameVersion` by one and notify every current subscriber, in
49
- * subscription order. Subscriber errors are isolated (per-subscriber
50
- * try/catch, loud `console.error`, never swallowed silently) — mirrors
51
- * the error-isolation idiom in `ecs/component-manager.ts`'s per-component
52
- * `update()` calls: one offending subscriber must not stop its siblings
53
- * from being notified, and must not break the frame loop. */
54
- bump(): void;
55
- }
56
- /**
57
- * Construct a fresh bridge. One per `Game` (created alongside the other
58
- * game-scoped state in `createGame`, `runtime/game.ts`).
59
- */
60
- export declare function createStateBridge(): GameStateBridgeInternal;
61
- //# sourceMappingURL=state-bridge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state-bridge.d.ts","sourceRoot":"","sources":["../../src/runtime/state-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,0FAA0F;AAC1F,MAAM,WAAW,eAAe;IAC9B;;;;kEAI8D;IAC9D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;6EACyE;IACzE,SAAS,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC5C;AAED;;;;;mEAKmE;AACnE,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D;;;;;kEAK8D;IAC9D,IAAI,IAAI,IAAI,CAAC;CACd;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,uBAAuB,CA8B3D"}
@@ -1,63 +0,0 @@
1
- /**
2
- * Frame-versioned game state bridge (T7.4 slice 1 — `docs/REACT-STATE-BRIDGE.md`
3
- * §2, the D7 remainder). Components mutate state on `this` freely during
4
- * ticks — there is no proxy, no dirty tracking, no event per mutation (Track
5
- * A: no mirror, no sync layer). So the unit of change a subscriber can
6
- * observe is the FRAME: `GameInternal.runFrame` bumps `frameVersion` and
7
- * notifies subscribers at most once, at its tail, AFTER every phase of every
8
- * world and every world's `endFrame` hook has run (see the wiring in
9
- * `runtime/game.ts`) — mirroring the D7 "from `gameLogic` onward, every
10
- * world's post-step state is readable" guarantee, extended to "after the
11
- * frame, ALL state is readable".
12
- *
13
- * This file is plain, react-free TypeScript any consumer could use — no
14
- * react import here, or anywhere under `runtime/` (the react-facing
15
- * `useGameState` hook, which DOES import React, lives at
16
- * `packages/engine/src/react/game-state.tsx`).
17
- *
18
- * SECOND trigger for `bump()` (`Game.registerWorld`, `runtime/game.ts`): the
19
- * `roots` list is also state a `useGameState` selector can read
20
- * (`g.roots.map(...)`, the T6.2 two-world-compose gate), and it changes
21
- * OUTSIDE the frame loop — `registerWorld` is called as each world finishes
22
- * mounting, which can happen well before the host's loop has ticked even
23
- * once. Without an immediate notification here, a selector that first reads
24
- * `g.roots` before every world has registered stays stuck on that stale
25
- * snapshot until the next completed frame — which, on a slow/contended host
26
- * or a backgrounded tab, may be arbitrarily delayed. See `registerWorld`'s
27
- * own doc comment for the concrete CI failure this closes.
28
- */
29
- /**
30
- * Construct a fresh bridge. One per `Game` (created alongside the other
31
- * game-scoped state in `createGame`, `runtime/game.ts`).
32
- */
33
- export function createStateBridge() {
34
- let frameVersion = 0;
35
- const subscribers = new Set();
36
- return {
37
- get frameVersion() {
38
- return frameVersion;
39
- },
40
- subscribe(onFrame) {
41
- subscribers.add(onFrame);
42
- return () => {
43
- subscribers.delete(onFrame);
44
- };
45
- },
46
- bump() {
47
- frameVersion++;
48
- // Snapshot before iterating (same idiom as ComponentManager's
49
- // per-phase `list = byPhase.get(phase)!.slice()`): a subscriber that
50
- // subscribes/unsubscribes from WITHIN a notification must not affect
51
- // which of ITS SIBLINGS get notified this same bump.
52
- const notified = Array.from(subscribers);
53
- for (const onFrame of notified) {
54
- try {
55
- onFrame();
56
- }
57
- catch (err) {
58
- console.error('[state-bridge] subscriber threw:', err);
59
- }
60
- }
61
- },
62
- };
63
- }