@vgai/engine 0.2.0 → 0.3.0

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 (541) hide show
  1. package/README.md +3 -1
  2. package/dist/adapter/authoring.d.ts +404 -0
  3. package/dist/adapter/authoring.d.ts.map +1 -0
  4. package/dist/adapter/authoring.js +22 -0
  5. package/dist/adapter/colyseus-networking-adapter.d.ts +43 -0
  6. package/dist/adapter/colyseus-networking-adapter.d.ts.map +1 -0
  7. package/dist/adapter/colyseus-networking-adapter.js +38 -0
  8. package/dist/adapter/first-party-systems.d.ts +38 -0
  9. package/dist/adapter/first-party-systems.d.ts.map +1 -0
  10. package/dist/adapter/first-party-systems.js +77 -0
  11. package/dist/adapter/game-adapter.d.ts +133 -0
  12. package/dist/adapter/game-adapter.d.ts.map +1 -0
  13. package/dist/adapter/game-adapter.js +10 -0
  14. package/dist/adapter/host-context.d.ts +73 -0
  15. package/dist/adapter/host-context.d.ts.map +1 -0
  16. package/dist/adapter/host-context.js +16 -0
  17. package/dist/adapter/index.d.ts +22 -0
  18. package/dist/adapter/index.d.ts.map +1 -0
  19. package/dist/adapter/index.js +15 -0
  20. package/dist/adapter/ingest/game-contract.d.ts +53 -0
  21. package/dist/adapter/ingest/game-contract.d.ts.map +1 -0
  22. package/dist/adapter/ingest/game-contract.js +30 -0
  23. package/dist/adapter/ingest/overlay-applier.d.ts +118 -0
  24. package/dist/adapter/ingest/overlay-applier.d.ts.map +1 -0
  25. package/dist/adapter/ingest/overlay-applier.js +132 -0
  26. package/dist/adapter/ingest/overlay-apply.d.ts +60 -0
  27. package/dist/adapter/ingest/overlay-apply.d.ts.map +1 -0
  28. package/dist/adapter/ingest/overlay-apply.js +101 -0
  29. package/dist/adapter/ingest/overlay-file.d.ts +79 -0
  30. package/dist/adapter/ingest/overlay-file.d.ts.map +1 -0
  31. package/dist/adapter/ingest/overlay-file.js +66 -0
  32. package/dist/adapter/ingest/overlay-report.d.ts +113 -0
  33. package/dist/adapter/ingest/overlay-report.d.ts.map +1 -0
  34. package/dist/adapter/ingest/overlay-report.js +103 -0
  35. package/dist/adapter/ingest/scene-capture.d.ts +97 -0
  36. package/dist/adapter/ingest/scene-capture.d.ts.map +1 -0
  37. package/dist/adapter/ingest/scene-capture.js +248 -0
  38. package/dist/adapter/ingest/upstream-pin.d.ts +47 -0
  39. package/dist/adapter/ingest/upstream-pin.d.ts.map +1 -0
  40. package/dist/adapter/ingest/upstream-pin.js +50 -0
  41. package/dist/adapter/loop-gate-report.d.ts +34 -0
  42. package/dist/adapter/loop-gate-report.d.ts.map +1 -0
  43. package/dist/adapter/loop-gate-report.js +37 -0
  44. package/dist/adapter/rapier-physics-adapter.d.ts +12 -0
  45. package/dist/adapter/rapier-physics-adapter.d.ts.map +1 -0
  46. package/dist/adapter/rapier-physics-adapter.js +46 -0
  47. package/dist/adapter/system-adapter.d.ts +133 -0
  48. package/dist/adapter/system-adapter.d.ts.map +1 -0
  49. package/dist/adapter/system-adapter.js +13 -0
  50. package/dist/adapter/transform.d.ts +18 -0
  51. package/dist/adapter/transform.d.ts.map +1 -0
  52. package/dist/adapter/transform.js +1 -0
  53. package/dist/adapter/vgai-scene-game-adapter.d.ts +116 -0
  54. package/dist/adapter/vgai-scene-game-adapter.d.ts.map +1 -0
  55. package/dist/adapter/vgai-scene-game-adapter.js +714 -0
  56. package/dist/adapter/world-kind.d.ts +30 -0
  57. package/dist/adapter/world-kind.d.ts.map +1 -0
  58. package/dist/adapter/world-kind.js +18 -0
  59. package/dist/ai/navigation.d.ts +64 -0
  60. package/dist/ai/navigation.d.ts.map +1 -0
  61. package/dist/ai/navigation.js +133 -0
  62. package/dist/animation/anim-graph-types.d.ts +25 -0
  63. package/dist/animation/anim-graph-types.d.ts.map +1 -0
  64. package/dist/animation/anim-graph-types.js +1 -0
  65. package/dist/animation/animation-clock.d.ts +213 -0
  66. package/dist/animation/animation-clock.d.ts.map +1 -0
  67. package/dist/animation/animation-clock.js +301 -0
  68. package/dist/animation/blend-node.d.ts +22 -0
  69. package/dist/animation/blend-node.d.ts.map +1 -0
  70. package/dist/animation/blend-node.js +97 -0
  71. package/dist/animation/camera-ownership.d.ts +250 -0
  72. package/dist/animation/camera-ownership.d.ts.map +1 -0
  73. package/dist/animation/camera-ownership.js +169 -0
  74. package/dist/animation/cinematic-cues.d.ts +200 -0
  75. package/dist/animation/cinematic-cues.d.ts.map +1 -0
  76. package/dist/animation/cinematic-cues.js +213 -0
  77. package/dist/animation/clip-map.d.ts +12 -0
  78. package/dist/animation/clip-map.d.ts.map +1 -0
  79. package/dist/animation/clip-map.js +37 -0
  80. package/dist/animation/gsap-registration.d.ts +119 -0
  81. package/dist/animation/gsap-registration.d.ts.map +1 -0
  82. package/dist/animation/gsap-registration.js +92 -0
  83. package/dist/animation/theatre-clock-binding.d.ts +89 -0
  84. package/dist/animation/theatre-clock-binding.d.ts.map +1 -0
  85. package/dist/animation/theatre-clock-binding.js +29 -0
  86. package/dist/animation/theatre-director.d.ts +242 -0
  87. package/dist/animation/theatre-director.d.ts.map +1 -0
  88. package/dist/animation/theatre-director.js +235 -0
  89. package/dist/animation/theatre-object-binding.d.ts +305 -0
  90. package/dist/animation/theatre-object-binding.d.ts.map +1 -0
  91. package/dist/animation/theatre-object-binding.js +351 -0
  92. package/dist/animation/xstate-animation-binding.d.ts +111 -0
  93. package/dist/animation/xstate-animation-binding.d.ts.map +1 -0
  94. package/dist/animation/xstate-animation-binding.js +307 -0
  95. package/dist/animation/xstate-animation-meta.d.ts +228 -0
  96. package/dist/animation/xstate-animation-meta.d.ts.map +1 -0
  97. package/dist/animation/xstate-animation-meta.js +221 -0
  98. package/dist/assets.d.ts +26 -0
  99. package/dist/assets.d.ts.map +1 -0
  100. package/dist/assets.js +55 -0
  101. package/dist/audio/index.d.ts +4 -0
  102. package/dist/audio/index.d.ts.map +1 -0
  103. package/dist/audio/index.js +24 -0
  104. package/dist/audio/tone-clock-binding.d.ts +75 -0
  105. package/dist/audio/tone-clock-binding.d.ts.map +1 -0
  106. package/dist/audio/tone-clock-binding.js +29 -0
  107. package/dist/audio/tone-context.d.ts +114 -0
  108. package/dist/audio/tone-context.d.ts.map +1 -0
  109. package/dist/audio/tone-context.js +39 -0
  110. package/dist/audio/tone-offline-render.d.ts +90 -0
  111. package/dist/audio/tone-offline-render.d.ts.map +1 -0
  112. package/dist/audio/tone-offline-render.js +56 -0
  113. package/dist/audio/wav-encode.d.ts +38 -0
  114. package/dist/audio/wav-encode.d.ts.map +1 -0
  115. package/dist/audio/wav-encode.js +97 -0
  116. package/dist/core/game-loop.d.ts +21 -0
  117. package/dist/core/game-loop.d.ts.map +1 -0
  118. package/dist/core/game-loop.js +130 -0
  119. package/dist/core/system-runner.d.ts +120 -0
  120. package/dist/core/system-runner.d.ts.map +1 -0
  121. package/dist/core/system-runner.js +286 -0
  122. package/dist/core/types.d.ts +58 -0
  123. package/dist/core/types.d.ts.map +1 -0
  124. package/dist/core/types.js +25 -0
  125. package/dist/data/data-asset.d.ts +101 -0
  126. package/dist/data/data-asset.d.ts.map +1 -0
  127. package/dist/data/data-asset.js +122 -0
  128. package/dist/data/data-check-core.d.ts +110 -0
  129. package/dist/data/data-check-core.d.ts.map +1 -0
  130. package/dist/data/data-check-core.js +178 -0
  131. package/dist/data/data-ref.d.ts +79 -0
  132. package/dist/data/data-ref.d.ts.map +1 -0
  133. package/dist/data/data-ref.js +130 -0
  134. package/dist/data/vite-plugin-data.d.ts +79 -0
  135. package/dist/data/vite-plugin-data.d.ts.map +1 -0
  136. package/dist/data/vite-plugin-data.js +217 -0
  137. package/dist/dev/console-bridge.d.ts +22 -0
  138. package/dist/dev/console-bridge.d.ts.map +1 -0
  139. package/dist/dev/console-bridge.js +71 -0
  140. package/dist/dev/debug-draw.d.ts +24 -0
  141. package/dist/dev/debug-draw.d.ts.map +1 -0
  142. package/dist/dev/debug-draw.js +73 -0
  143. package/dist/dev/logger.d.ts +30 -0
  144. package/dist/dev/logger.d.ts.map +1 -0
  145. package/dist/dev/logger.js +90 -0
  146. package/dist/ecs/component-manager.d.ts +189 -0
  147. package/dist/ecs/component-manager.d.ts.map +1 -0
  148. package/dist/ecs/component-manager.js +676 -0
  149. package/dist/ecs/game-component.d.ts +97 -0
  150. package/dist/ecs/game-component.d.ts.map +1 -0
  151. package/dist/ecs/game-component.js +80 -0
  152. package/dist/ecs/hmr-swap-report.d.ts +53 -0
  153. package/dist/ecs/hmr-swap-report.d.ts.map +1 -0
  154. package/dist/ecs/hmr-swap-report.js +55 -0
  155. package/dist/index.d.ts +37 -0
  156. package/dist/index.d.ts.map +1 -0
  157. package/dist/index.js +30 -0
  158. package/dist/input/input-manager.d.ts +596 -0
  159. package/dist/input/input-manager.d.ts.map +1 -0
  160. package/dist/input/input-manager.js +1564 -0
  161. package/dist/input/input-types.d.ts +171 -0
  162. package/dist/input/input-types.d.ts.map +1 -0
  163. package/dist/input/input-types.js +1 -0
  164. package/dist/input/prompt-labels.d.ts +21 -0
  165. package/dist/input/prompt-labels.d.ts.map +1 -0
  166. package/dist/input/prompt-labels.js +121 -0
  167. package/dist/input/rebind-controller.d.ts +59 -0
  168. package/dist/input/rebind-controller.d.ts.map +1 -0
  169. package/dist/input/rebind-controller.js +85 -0
  170. package/dist/input/schema.d.ts +16 -0
  171. package/dist/input/schema.d.ts.map +1 -0
  172. package/dist/input/schema.js +228 -0
  173. package/dist/loader.d.ts +43 -0
  174. package/dist/loader.d.ts.map +1 -0
  175. package/dist/loader.js +59 -0
  176. package/dist/manifest/index.d.ts +5 -0
  177. package/dist/manifest/index.d.ts.map +1 -0
  178. package/dist/manifest/index.js +8 -0
  179. package/dist/manifest/load-file.d.ts +4 -0
  180. package/dist/manifest/load-file.d.ts.map +1 -0
  181. package/dist/manifest/load-file.js +14 -0
  182. package/dist/manifest/load.d.ts +117 -0
  183. package/dist/manifest/load.d.ts.map +1 -0
  184. package/dist/manifest/load.js +255 -0
  185. package/dist/manifest/schema.d.ts +173 -0
  186. package/dist/manifest/schema.d.ts.map +1 -0
  187. package/dist/manifest/schema.js +302 -0
  188. package/dist/physics/collision-system.d.ts +41 -0
  189. package/dist/physics/collision-system.d.ts.map +1 -0
  190. package/dist/physics/collision-system.js +64 -0
  191. package/dist/physics/physics-registry.d.ts +45 -0
  192. package/dist/physics/physics-registry.d.ts.map +1 -0
  193. package/dist/physics/physics-registry.js +65 -0
  194. package/dist/physics/transform-writer.d.ts +16 -0
  195. package/dist/physics/transform-writer.d.ts.map +1 -0
  196. package/dist/physics/transform-writer.js +38 -0
  197. package/dist/physics/trigger-dispatch.d.ts +24 -0
  198. package/dist/physics/trigger-dispatch.d.ts.map +1 -0
  199. package/dist/physics/trigger-dispatch.js +80 -0
  200. package/dist/react/game-state.d.ts +105 -0
  201. package/dist/react/game-state.d.ts.map +1 -0
  202. package/dist/react/game-state.js +144 -0
  203. package/dist/react/use-data.d.ts +60 -0
  204. package/dist/react/use-data.d.ts.map +1 -0
  205. package/dist/react/use-data.js +96 -0
  206. package/dist/react/use-selection.d.ts +75 -0
  207. package/dist/react/use-selection.d.ts.map +1 -0
  208. package/dist/react/use-selection.js +90 -0
  209. package/dist/render/auto-batcher.d.ts +34 -0
  210. package/dist/render/auto-batcher.d.ts.map +1 -0
  211. package/dist/render/auto-batcher.js +140 -0
  212. package/dist/render/render-batch-system.d.ts +33 -0
  213. package/dist/render/render-batch-system.d.ts.map +1 -0
  214. package/dist/render/render-batch-system.js +230 -0
  215. package/dist/render/render-features.d.ts +47 -0
  216. package/dist/render/render-features.d.ts.map +1 -0
  217. package/dist/render/render-features.js +105 -0
  218. package/dist/render/render-settings.d.ts +36 -0
  219. package/dist/render/render-settings.d.ts.map +1 -0
  220. package/dist/render/render-settings.js +51 -0
  221. package/dist/runtime/create-runtime.d.ts +280 -0
  222. package/dist/runtime/create-runtime.d.ts.map +1 -0
  223. package/dist/runtime/create-runtime.js +795 -0
  224. package/dist/runtime/frame-selector-cache.d.ts +41 -0
  225. package/dist/runtime/frame-selector-cache.d.ts.map +1 -0
  226. package/dist/runtime/frame-selector-cache.js +65 -0
  227. package/dist/runtime/game.d.ts +433 -0
  228. package/dist/runtime/game.d.ts.map +1 -0
  229. package/dist/runtime/game.js +569 -0
  230. package/dist/runtime/input-router.d.ts +78 -0
  231. package/dist/runtime/input-router.d.ts.map +1 -0
  232. package/dist/runtime/input-router.js +171 -0
  233. package/dist/runtime/mount-game.d.ts +129 -0
  234. package/dist/runtime/mount-game.d.ts.map +1 -0
  235. package/dist/runtime/mount-game.js +152 -0
  236. package/dist/runtime/mount-manifest.d.ts +119 -0
  237. package/dist/runtime/mount-manifest.d.ts.map +1 -0
  238. package/dist/runtime/mount-manifest.js +204 -0
  239. package/dist/runtime/render-audio-control.d.ts +110 -0
  240. package/dist/runtime/render-audio-control.d.ts.map +1 -0
  241. package/dist/runtime/render-audio-control.js +111 -0
  242. package/dist/runtime/render-control.d.ts +291 -0
  243. package/dist/runtime/render-control.d.ts.map +1 -0
  244. package/dist/runtime/render-control.js +264 -0
  245. package/dist/runtime/render-seed.d.ts +57 -0
  246. package/dist/runtime/render-seed.d.ts.map +1 -0
  247. package/dist/runtime/render-seed.js +74 -0
  248. package/dist/runtime/scene-ui-bridge.d.ts +69 -0
  249. package/dist/runtime/scene-ui-bridge.d.ts.map +1 -0
  250. package/dist/runtime/scene-ui-bridge.js +23 -0
  251. package/dist/runtime/scene-ui-data.d.ts +13 -0
  252. package/dist/runtime/scene-ui-data.d.ts.map +1 -0
  253. package/dist/runtime/scene-ui-data.js +92 -0
  254. package/dist/runtime/state-bridge.d.ts +47 -0
  255. package/dist/runtime/state-bridge.d.ts.map +1 -0
  256. package/dist/runtime/state-bridge.js +53 -0
  257. package/dist/runtime/types.d.ts +179 -0
  258. package/dist/runtime/types.d.ts.map +1 -0
  259. package/dist/runtime/types.js +1 -0
  260. package/dist/scene/asset-loaders.d.ts +79 -0
  261. package/dist/scene/asset-loaders.d.ts.map +1 -0
  262. package/dist/scene/asset-loaders.js +141 -0
  263. package/dist/scene/asset-paths.d.ts +11 -0
  264. package/dist/scene/asset-paths.d.ts.map +1 -0
  265. package/dist/scene/asset-paths.js +108 -0
  266. package/dist/scene/asset-ref-check.d.ts +88 -0
  267. package/dist/scene/asset-ref-check.d.ts.map +1 -0
  268. package/dist/scene/asset-ref-check.js +214 -0
  269. package/dist/scene/asset-registry.d.ts +30 -0
  270. package/dist/scene/asset-registry.d.ts.map +1 -0
  271. package/dist/scene/asset-registry.js +50 -0
  272. package/dist/scene/collider-dimensions.d.ts +63 -0
  273. package/dist/scene/collider-dimensions.d.ts.map +1 -0
  274. package/dist/scene/collider-dimensions.js +98 -0
  275. package/dist/scene/component-registry.d.ts +17 -0
  276. package/dist/scene/component-registry.d.ts.map +1 -0
  277. package/dist/scene/component-registry.js +28 -0
  278. package/dist/scene/defaults.d.ts +252 -0
  279. package/dist/scene/defaults.d.ts.map +1 -0
  280. package/dist/scene/defaults.js +151 -0
  281. package/dist/scene/geometries/index.d.ts +8 -0
  282. package/dist/scene/geometries/index.d.ts.map +1 -0
  283. package/dist/scene/geometries/index.js +7 -0
  284. package/dist/scene/geometries/terrain.d.ts +2 -0
  285. package/dist/scene/geometries/terrain.d.ts.map +1 -0
  286. package/dist/scene/geometries/terrain.js +37 -0
  287. package/dist/scene/geometry-registry.d.ts +24 -0
  288. package/dist/scene/geometry-registry.d.ts.map +1 -0
  289. package/dist/scene/geometry-registry.js +20 -0
  290. package/dist/scene/instance-registry.d.ts +36 -0
  291. package/dist/scene/instance-registry.d.ts.map +1 -0
  292. package/dist/scene/instance-registry.js +55 -0
  293. package/dist/scene/instancers/grid.d.ts +2 -0
  294. package/dist/scene/instancers/grid.d.ts.map +1 -0
  295. package/dist/scene/instancers/grid.js +36 -0
  296. package/dist/scene/instancers/index.d.ts +8 -0
  297. package/dist/scene/instancers/index.d.ts.map +1 -0
  298. package/dist/scene/instancers/index.js +7 -0
  299. package/dist/scene/light-camera-factory.d.ts +23 -0
  300. package/dist/scene/light-camera-factory.d.ts.map +1 -0
  301. package/dist/scene/light-camera-factory.js +68 -0
  302. package/dist/scene/material-factory.d.ts +17 -0
  303. package/dist/scene/material-factory.d.ts.map +1 -0
  304. package/dist/scene/material-factory.js +197 -0
  305. package/dist/scene/material-registry.d.ts +40 -0
  306. package/dist/scene/material-registry.d.ts.map +1 -0
  307. package/dist/scene/material-registry.js +44 -0
  308. package/dist/scene/materials/index.d.ts +8 -0
  309. package/dist/scene/materials/index.d.ts.map +1 -0
  310. package/dist/scene/materials/index.js +7 -0
  311. package/dist/scene/materials/water.d.ts +2 -0
  312. package/dist/scene/materials/water.d.ts.map +1 -0
  313. package/dist/scene/materials/water.js +54 -0
  314. package/dist/scene/parse.d.ts +23 -0
  315. package/dist/scene/parse.d.ts.map +1 -0
  316. package/dist/scene/parse.js +179 -0
  317. package/dist/scene/particles-factory.d.ts +33 -0
  318. package/dist/scene/particles-factory.d.ts.map +1 -0
  319. package/dist/scene/particles-factory.js +282 -0
  320. package/dist/scene/scene-apply.d.ts +109 -0
  321. package/dist/scene/scene-apply.d.ts.map +1 -0
  322. package/dist/scene/scene-apply.js +326 -0
  323. package/dist/scene/scene-diff-schema.d.ts +285 -0
  324. package/dist/scene/scene-diff-schema.d.ts.map +1 -0
  325. package/dist/scene/scene-diff-schema.js +92 -0
  326. package/dist/scene/scene-diff-types.d.ts +40 -0
  327. package/dist/scene/scene-diff-types.d.ts.map +1 -0
  328. package/dist/scene/scene-diff-types.js +14 -0
  329. package/dist/scene/scene-loader.d.ts +177 -0
  330. package/dist/scene/scene-loader.d.ts.map +1 -0
  331. package/dist/scene/scene-loader.js +1213 -0
  332. package/dist/scene/scene-query.d.ts +11 -0
  333. package/dist/scene/scene-query.d.ts.map +1 -0
  334. package/dist/scene/scene-query.js +63 -0
  335. package/dist/scene/scene-types.d.ts +10 -0
  336. package/dist/scene/scene-types.d.ts.map +1 -0
  337. package/dist/scene/scene-types.js +8 -0
  338. package/dist/scene/scene-version.d.ts +26 -0
  339. package/dist/scene/scene-version.d.ts.map +1 -0
  340. package/dist/scene/scene-version.js +34 -0
  341. package/dist/scene/schema/animation.d.ts +8 -0
  342. package/dist/scene/schema/animation.d.ts.map +1 -0
  343. package/dist/scene/schema/animation.js +42 -0
  344. package/dist/scene/schema/audio.d.ts +13 -0
  345. package/dist/scene/schema/audio.d.ts.map +1 -0
  346. package/dist/scene/schema/audio.js +22 -0
  347. package/dist/scene/schema/camera.d.ts +28 -0
  348. package/dist/scene/schema/camera.d.ts.map +1 -0
  349. package/dist/scene/schema/camera.js +17 -0
  350. package/dist/scene/schema/collider.d.ts +40 -0
  351. package/dist/scene/schema/collider.d.ts.map +1 -0
  352. package/dist/scene/schema/collider.js +55 -0
  353. package/dist/scene/schema/entity-ref.d.ts +31 -0
  354. package/dist/scene/schema/entity-ref.d.ts.map +1 -0
  355. package/dist/scene/schema/entity-ref.js +61 -0
  356. package/dist/scene/schema/entity.d.ts +1036 -0
  357. package/dist/scene/schema/entity.d.ts.map +1 -0
  358. package/dist/scene/schema/entity.js +153 -0
  359. package/dist/scene/schema/environment.d.ts +425 -0
  360. package/dist/scene/schema/environment.d.ts.map +1 -0
  361. package/dist/scene/schema/environment.js +357 -0
  362. package/dist/scene/schema/index.d.ts +39 -0
  363. package/dist/scene/schema/index.d.ts.map +1 -0
  364. package/dist/scene/schema/index.js +20 -0
  365. package/dist/scene/schema/instances.d.ts +14 -0
  366. package/dist/scene/schema/instances.d.ts.map +1 -0
  367. package/dist/scene/schema/instances.js +28 -0
  368. package/dist/scene/schema/joint.d.ts +23 -0
  369. package/dist/scene/schema/joint.d.ts.map +1 -0
  370. package/dist/scene/schema/joint.js +23 -0
  371. package/dist/scene/schema/light.d.ts +38 -0
  372. package/dist/scene/schema/light.d.ts.map +1 -0
  373. package/dist/scene/schema/light.js +26 -0
  374. package/dist/scene/schema/material.d.ts +199 -0
  375. package/dist/scene/schema/material.d.ts.map +1 -0
  376. package/dist/scene/schema/material.js +99 -0
  377. package/dist/scene/schema/mesh.d.ts +48 -0
  378. package/dist/scene/schema/mesh.d.ts.map +1 -0
  379. package/dist/scene/schema/mesh.js +82 -0
  380. package/dist/scene/schema/particles.d.ts +2178 -0
  381. package/dist/scene/schema/particles.d.ts.map +1 -0
  382. package/dist/scene/schema/particles.js +321 -0
  383. package/dist/scene/schema/physics.d.ts +56 -0
  384. package/dist/scene/schema/physics.d.ts.map +1 -0
  385. package/dist/scene/schema/physics.js +37 -0
  386. package/dist/scene/schema/scene-file.d.ts +304 -0
  387. package/dist/scene/schema/scene-file.d.ts.map +1 -0
  388. package/dist/scene/schema/scene-file.js +262 -0
  389. package/dist/scene/schema/shadow.d.ts +28 -0
  390. package/dist/scene/schema/shadow.d.ts.map +1 -0
  391. package/dist/scene/schema/shadow.js +20 -0
  392. package/dist/scene/schema/spline.d.ts +25 -0
  393. package/dist/scene/schema/spline.d.ts.map +1 -0
  394. package/dist/scene/schema/spline.js +15 -0
  395. package/dist/scene/schema/tuples.d.ts +12 -0
  396. package/dist/scene/schema/tuples.d.ts.map +1 -0
  397. package/dist/scene/schema/tuples.js +14 -0
  398. package/dist/scene/schema/ui.d.ts +880 -0
  399. package/dist/scene/schema/ui.d.ts.map +1 -0
  400. package/dist/scene/schema/ui.js +506 -0
  401. package/dist/scene/user-data.d.ts +171 -0
  402. package/dist/scene/user-data.d.ts.map +1 -0
  403. package/dist/scene/user-data.js +137 -0
  404. package/dist/setup/setup-audio.d.ts +20 -0
  405. package/dist/setup/setup-audio.d.ts.map +1 -0
  406. package/dist/setup/setup-audio.js +41 -0
  407. package/dist/setup/setup-particles.d.ts +17 -0
  408. package/dist/setup/setup-particles.d.ts.map +1 -0
  409. package/dist/setup/setup-particles.js +16 -0
  410. package/dist/setup/setup-physics.d.ts +25 -0
  411. package/dist/setup/setup-physics.d.ts.map +1 -0
  412. package/dist/setup/setup-physics.js +51 -0
  413. package/dist/setup/setup-renderer.d.ts +69 -0
  414. package/dist/setup/setup-renderer.d.ts.map +1 -0
  415. package/dist/setup/setup-renderer.js +363 -0
  416. package/dist/tools/define-tool.d.ts +105 -0
  417. package/dist/tools/define-tool.d.ts.map +1 -0
  418. package/dist/tools/define-tool.js +82 -0
  419. package/dist/world2d/authoring-2d.d.ts +76 -0
  420. package/dist/world2d/authoring-2d.d.ts.map +1 -0
  421. package/dist/world2d/authoring-2d.js +176 -0
  422. package/dist/world2d/capture-to-scene2d.d.ts +5 -0
  423. package/dist/world2d/capture-to-scene2d.d.ts.map +1 -0
  424. package/dist/world2d/capture-to-scene2d.js +49 -0
  425. package/dist/world2d/collision-2d.d.ts +52 -0
  426. package/dist/world2d/collision-2d.d.ts.map +1 -0
  427. package/dist/world2d/collision-2d.js +70 -0
  428. package/dist/world2d/components-2d.d.ts +47 -0
  429. package/dist/world2d/components-2d.d.ts.map +1 -0
  430. package/dist/world2d/components-2d.js +77 -0
  431. package/dist/world2d/index.d.ts +34 -0
  432. package/dist/world2d/index.d.ts.map +1 -0
  433. package/dist/world2d/index.js +32 -0
  434. package/dist/world2d/ingest-iframe-2d.d.ts +82 -0
  435. package/dist/world2d/ingest-iframe-2d.d.ts.map +1 -0
  436. package/dist/world2d/ingest-iframe-2d.js +166 -0
  437. package/dist/world2d/ingest2d.d.ts +97 -0
  438. package/dist/world2d/ingest2d.d.ts.map +1 -0
  439. package/dist/world2d/ingest2d.js +40 -0
  440. package/dist/world2d/physics2d-registry.d.ts +24 -0
  441. package/dist/world2d/physics2d-registry.d.ts.map +1 -0
  442. package/dist/world2d/physics2d-registry.js +38 -0
  443. package/dist/world2d/pixi-game-adapter.d.ts +107 -0
  444. package/dist/world2d/pixi-game-adapter.d.ts.map +1 -0
  445. package/dist/world2d/pixi-game-adapter.js +211 -0
  446. package/dist/world2d/pixi-surface.d.ts +39 -0
  447. package/dist/world2d/pixi-surface.d.ts.map +1 -0
  448. package/dist/world2d/pixi-surface.js +47 -0
  449. package/dist/world2d/scene-capture-2d.d.ts +43 -0
  450. package/dist/world2d/scene-capture-2d.d.ts.map +1 -0
  451. package/dist/world2d/scene-capture-2d.js +92 -0
  452. package/dist/world2d/scene2d-loader.d.ts +27 -0
  453. package/dist/world2d/scene2d-loader.d.ts.map +1 -0
  454. package/dist/world2d/scene2d-loader.js +274 -0
  455. package/dist/world2d/schema/entity2d.d.ts +102 -0
  456. package/dist/world2d/schema/entity2d.d.ts.map +1 -0
  457. package/dist/world2d/schema/entity2d.js +119 -0
  458. package/dist/world2d/schema/physics2d.d.ts +46 -0
  459. package/dist/world2d/schema/physics2d.d.ts.map +1 -0
  460. package/dist/world2d/schema/physics2d.js +45 -0
  461. package/dist/world2d/schema/sprite.d.ts +42 -0
  462. package/dist/world2d/schema/sprite.d.ts.map +1 -0
  463. package/dist/world2d/schema/sprite.js +63 -0
  464. package/dist/world2d/schema/tilemap.d.ts +15 -0
  465. package/dist/world2d/schema/tilemap.d.ts.map +1 -0
  466. package/dist/world2d/schema/tilemap.js +19 -0
  467. package/dist/world2d/schema/tuples2d.d.ts +20 -0
  468. package/dist/world2d/schema/tuples2d.d.ts.map +1 -0
  469. package/dist/world2d/schema/tuples2d.js +19 -0
  470. package/dist/world2d/system-adapters-2d.d.ts +16 -0
  471. package/dist/world2d/system-adapters-2d.d.ts.map +1 -0
  472. package/dist/world2d/system-adapters-2d.js +37 -0
  473. package/dist/world2d/transform-writer-2d.d.ts +16 -0
  474. package/dist/world2d/transform-writer-2d.d.ts.map +1 -0
  475. package/dist/world2d/transform-writer-2d.js +22 -0
  476. package/dist/world2d/types.d.ts +53 -0
  477. package/dist/world2d/types.d.ts.map +1 -0
  478. package/dist/world2d/types.js +1 -0
  479. package/package.json +18 -4
  480. package/src/adapter/authoring.ts +10 -0
  481. package/src/adapter/first-party-systems.ts +23 -34
  482. package/src/adapter/index.ts +1 -3
  483. package/src/adapter/system-adapter.ts +15 -22
  484. package/src/adapter/vgai-scene-game-adapter.ts +5 -14
  485. package/src/animation/anim-graph-types.ts +12 -43
  486. package/src/animation/animation-clock.ts +479 -0
  487. package/src/animation/camera-ownership.ts +467 -0
  488. package/src/animation/cinematic-cues.ts +451 -0
  489. package/src/animation/clip-map.ts +41 -0
  490. package/src/animation/gsap-registration.ts +184 -0
  491. package/src/animation/theatre-clock-binding.ts +111 -0
  492. package/src/animation/theatre-director.ts +347 -0
  493. package/src/animation/theatre-object-binding.ts +661 -0
  494. package/src/animation/xstate-animation-binding.ts +398 -0
  495. package/src/animation/xstate-animation-meta.ts +282 -0
  496. package/src/audio/index.ts +39 -7
  497. package/src/audio/tone-clock-binding.ts +98 -0
  498. package/src/audio/tone-context.ts +129 -0
  499. package/src/audio/tone-offline-render.ts +167 -0
  500. package/src/audio/wav-encode.ts +119 -0
  501. package/src/core/game-loop.ts +17 -0
  502. package/src/core/types.ts +13 -0
  503. package/src/data/data-asset.ts +167 -0
  504. package/src/data/data-check-core.ts +242 -0
  505. package/src/data/data-ref.ts +145 -0
  506. package/src/data/vite-plugin-data.ts +290 -0
  507. package/src/index.ts +48 -0
  508. package/src/input/input-manager.ts +1206 -32
  509. package/src/input/input-types.ts +155 -3
  510. package/src/input/prompt-labels.ts +122 -0
  511. package/src/input/rebind-controller.ts +105 -0
  512. package/src/input/schema.ts +206 -52
  513. package/src/react/use-data.ts +114 -0
  514. package/src/react/use-selection.tsx +135 -0
  515. package/src/runtime/create-runtime.ts +30 -9
  516. package/src/runtime/render-audio-control.ts +168 -0
  517. package/src/runtime/render-control.ts +522 -0
  518. package/src/runtime/render-seed.ts +79 -0
  519. package/src/runtime/types.ts +0 -5
  520. package/src/scene/asset-loaders.ts +10 -36
  521. package/src/scene/asset-paths.ts +0 -2
  522. package/src/scene/asset-ref-check.ts +248 -0
  523. package/src/scene/parse.ts +133 -0
  524. package/src/scene/scene-loader.ts +81 -96
  525. package/src/scene/schema/animation.ts +30 -79
  526. package/src/scene/schema/entity.ts +20 -0
  527. package/src/scene/schema/index.ts +2 -12
  528. package/src/scene/user-data.ts +8 -9
  529. package/src/setup/setup-renderer.ts +9 -2
  530. package/src/tools/define-tool.ts +152 -0
  531. package/src/animation/anim-graph.ts +0 -406
  532. package/src/animation/anim-system.ts +0 -28
  533. package/src/animation/property-track.ts +0 -178
  534. package/src/animation/schema.ts +0 -204
  535. package/src/audio/ambient.ts +0 -300
  536. package/src/audio/impacts.ts +0 -212
  537. package/src/audio/movement.ts +0 -140
  538. package/src/audio/musical.ts +0 -200
  539. package/src/audio/ui-sounds.ts +0 -171
  540. package/src/audio/vehicle.ts +0 -235
  541. package/src/audio/weapons.ts +0 -152
@@ -0,0 +1,286 @@
1
+ import { PHASE_ORDER } from './types';
2
+ /**
3
+ * Ordered system execution by named phase.
4
+ *
5
+ * Systems are registered with a phase name. When `run(dt)` is called, all
6
+ * phases execute in `PHASE_ORDER` via `runPhase(phase, dt)`. Within a phase,
7
+ * `runPhase` executes three ordered buckets (GAME-ROOT-DESIGN.md §4, T7.1
8
+ * slice 2):
9
+ *
10
+ * 1. **engine** — everything `add()`/`register()`ed at or before the last
11
+ * `markEngineBoundary()` call, or EVERYTHING if no boundary has ever
12
+ * been marked (the world2d-silo case: it never calls
13
+ * `markEngineBoundary`, so its systems are all "engine").
14
+ * 2. **componentTick** — the single per-phase slot set via
15
+ * `setComponentTick(phase, fn)`. Component ticks are engine
16
+ * infrastructure: they always run after every engine system and before
17
+ * every game system in that phase, REGARDLESS of when
18
+ * `setComponentTick` was called relative to other `add()` calls. This
19
+ * is what makes "engine systems run before component ticks" a
20
+ * structural guarantee rather than a registration-order convention
21
+ * (see `component-manager.ts`, which registers its tick this way).
22
+ * 3. **game** — everything `add()`/`register()`ed AFTER the last
23
+ * `markEngineBoundary()` call.
24
+ *
25
+ * Within each bucket, systems run in registration order.
26
+ */
27
+ export function createSystemRunner() {
28
+ const systems = new Map();
29
+ const registered = [];
30
+ const componentTicks = new Map();
31
+ // Initialize all phases with empty arrays / no component tick.
32
+ for (const phase of PHASE_ORDER) {
33
+ systems.set(phase, []);
34
+ componentTicks.set(phase, null);
35
+ }
36
+ // Membership bookkeeping for `markEngineBoundary()` (T7.2 review fix —
37
+ // replaces the old length/index-snapshot bookkeeping, which broke if a
38
+ // pre-boundary "engine" entry was ever removed: shrinking the list would
39
+ // shift a later "game" entry underneath the recorded length, misclassifying
40
+ // it as engine). `engineFns`/`engineRegistered` instead record WHICH
41
+ // specific function/system was present at the last `markEngineBoundary()`
42
+ // call — membership survives arbitrary removal of any other entry,
43
+ // regardless of position. `boundaryMarked` is false until the first mark
44
+ // (mirrors the old `boundary === null`: everything is "engine" pre-mark —
45
+ // the world2d-silo case, which never marks a boundary). Component-tick
46
+ // slots (`setComponentTick`) are NOT part of this bookkeeping at all — they
47
+ // are engine infrastructure and survive `removeAllNonEngine()`
48
+ // unconditionally.
49
+ let boundaryMarked = false;
50
+ const engineFns = new Map();
51
+ for (const phase of PHASE_ORDER)
52
+ engineFns.set(phase, new Set());
53
+ const engineRegistered = new Set();
54
+ /** Run one system function, isolating a throw so it never wedges the frame. */
55
+ function runOne(fn, phase, dt) {
56
+ try {
57
+ fn(dt);
58
+ }
59
+ catch (err) {
60
+ const label = fn.name ? `"${fn.name}"` : '(anonymous)';
61
+ console.error(`[system-runner] system ${label} in phase "${phase}" threw:`, err);
62
+ }
63
+ }
64
+ return {
65
+ /**
66
+ * Register a bare system function in a specific phase.
67
+ * Systems within the same phase run in the order they were added.
68
+ */
69
+ add(phase, fn) {
70
+ const list = systems.get(phase);
71
+ if (!list) {
72
+ throw new Error(`Unknown phase: ${phase}. Valid phases: ${PHASE_ORDER.join(', ')}`);
73
+ }
74
+ list.push(fn);
75
+ },
76
+ /**
77
+ * Remove a bare system function from a phase. Also drops it from the
78
+ * engine-membership set (if present) — the fix for the length-based
79
+ * bookkeeping bug: removing this has no effect on how any OTHER entry
80
+ * (before or after it) is classified, since classification is now
81
+ * per-function membership, not position.
82
+ */
83
+ remove(phase, fn) {
84
+ const list = systems.get(phase);
85
+ if (!list)
86
+ return;
87
+ const idx = list.indexOf(fn);
88
+ if (idx !== -1)
89
+ list.splice(idx, 1);
90
+ engineFns.get(phase)?.delete(fn);
91
+ },
92
+ /**
93
+ * Register a lifecycle system. Adds its update to the correct phase.
94
+ * Call runInit() after all systems are registered to invoke init hooks.
95
+ */
96
+ register(system) {
97
+ const list = systems.get(system.phase);
98
+ if (!list) {
99
+ throw new Error(`Unknown phase: ${system.phase}. Valid phases: ${PHASE_ORDER.join(', ')}`);
100
+ }
101
+ list.push(system.update);
102
+ registered.push(system);
103
+ },
104
+ /**
105
+ * Unregister a lifecycle system. Removes its update and calls dispose.
106
+ */
107
+ unregister(system) {
108
+ const list = systems.get(system.phase);
109
+ if (list) {
110
+ const idx = list.indexOf(system.update);
111
+ if (idx !== -1)
112
+ list.splice(idx, 1);
113
+ }
114
+ engineFns.get(system.phase)?.delete(system.update);
115
+ const regIdx = registered.indexOf(system);
116
+ if (regIdx !== -1)
117
+ registered.splice(regIdx, 1);
118
+ engineRegistered.delete(system);
119
+ system.dispose?.();
120
+ },
121
+ /**
122
+ * Register the ONE component-tick function for a phase (T7.1 slice 2).
123
+ * Component ticks are engine infrastructure, not a bare `add()`ed
124
+ * system: they always execute after every engine-bucket system and
125
+ * before every game-bucket system in that phase (see `runPhase`),
126
+ * they are never touched by `removeAllNonEngine()`, and they do not
127
+ * count toward `markEngineBoundary()`'s bookkeeping. Throws if a tick
128
+ * is already set for this phase — at most one component manager may
129
+ * own a phase's tick slot.
130
+ */
131
+ setComponentTick(phase, fn) {
132
+ if (!componentTicks.has(phase)) {
133
+ throw new Error(`Unknown phase: ${phase}. Valid phases: ${PHASE_ORDER.join(', ')}`);
134
+ }
135
+ if (componentTicks.get(phase)) {
136
+ throw new Error(`[system-runner] setComponentTick: phase "${phase}" already has a component tick registered`);
137
+ }
138
+ componentTicks.set(phase, fn);
139
+ },
140
+ /**
141
+ * Call init() on all registered lifecycle systems, in phase order.
142
+ * Call once after scene load, before the first game loop tick.
143
+ */
144
+ runInit() {
145
+ const sorted = [...registered].sort((a, b) => PHASE_ORDER.indexOf(a.phase) - PHASE_ORDER.indexOf(b.phase));
146
+ for (const sys of sorted) {
147
+ sys.init?.();
148
+ }
149
+ },
150
+ /**
151
+ * Call dispose() on all registered lifecycle systems and remove them.
152
+ */
153
+ runDispose() {
154
+ for (const sys of registered) {
155
+ const list = systems.get(sys.phase);
156
+ if (list) {
157
+ const idx = list.indexOf(sys.update);
158
+ if (idx !== -1)
159
+ list.splice(idx, 1);
160
+ }
161
+ sys.dispose?.();
162
+ }
163
+ registered.length = 0;
164
+ },
165
+ /**
166
+ * Run ONE phase's three ordered buckets — engine, componentTick, game
167
+ * (see the module doc comment). Each system call is isolated: a
168
+ * throwing system is loudly logged (never swallowed) but does not stop
169
+ * its siblings in the same bucket, a later bucket in this phase, or a
170
+ * later phase, from running this frame.
171
+ *
172
+ * Public — the Game root's frame executor (`runtime/game.ts`) calls this
173
+ * directly per (phase, world); `run(dt)` below is just a loop over it,
174
+ * preserved for the world2d silo and any direct caller.
175
+ */
176
+ runPhase(phase, dt) {
177
+ const list = systems.get(phase);
178
+ if (!list) {
179
+ throw new Error(`Unknown phase: ${phase}. Valid phases: ${PHASE_ORDER.join(', ')}`);
180
+ }
181
+ // Partition by MEMBERSHIP, not position: everything in this phase's
182
+ // `engineFns` set (or, if no boundary has ever been marked, everything —
183
+ // the world2d-silo case) runs immediately, in list order, as it's
184
+ // encountered; everything else is queued into `gameFns` (also in list
185
+ // order) and run after the component tick. Because classification is
186
+ // per-function rather than "index < some remembered length", removing
187
+ // ANY entry via `remove()` — including a pre-boundary "engine" one —
188
+ // cannot shift a later game system into the engine bucket.
189
+ const engineSet = engineFns.get(phase);
190
+ const gameFns = [];
191
+ for (const fn of list) {
192
+ if (boundaryMarked && !engineSet.has(fn)) {
193
+ gameFns.push(fn);
194
+ }
195
+ else {
196
+ runOne(fn, phase, dt);
197
+ }
198
+ }
199
+ const tick = componentTicks.get(phase);
200
+ if (tick)
201
+ runOne(tick, phase, dt);
202
+ for (const fn of gameFns) {
203
+ runOne(fn, phase, dt);
204
+ }
205
+ },
206
+ /**
207
+ * Run all phases in order, via `runPhase`.
208
+ */
209
+ run(dt) {
210
+ for (const phase of PHASE_ORDER) {
211
+ this.runPhase(phase, dt);
212
+ }
213
+ },
214
+ /**
215
+ * Mark everything registered so far (via `add()`/`register()`, in every
216
+ * phase) as "engine" — infrastructure that must survive a warm restart.
217
+ * Call once, right after mount finishes wiring engine-level systems and
218
+ * BEFORE any game (`setup()`/scene load) registers its own. `hotReload`
219
+ * calls `removeAllNonEngine()` on every restart, which only ever removes
220
+ * what was added after this mark. Component-tick slots (`setComponentTick`)
221
+ * are unaffected — they are never part of this boundary.
222
+ */
223
+ markEngineBoundary() {
224
+ for (const phase of PHASE_ORDER) {
225
+ const set = engineFns.get(phase);
226
+ for (const fn of systems.get(phase))
227
+ set.add(fn);
228
+ }
229
+ for (const sys of registered)
230
+ engineRegistered.add(sys);
231
+ boundaryMarked = true;
232
+ },
233
+ /**
234
+ * Bulk-remove every system registered after the last `markEngineBoundary()`
235
+ * call — both bare `add()`ed functions and lifecycle `register()`ed systems
236
+ * (the latter get `dispose()`d, mirroring `unregister()`). A no-op if no
237
+ * boundary has been marked. Idempotent: calling it again with nothing new
238
+ * registered since is a safe no-op. Component-tick slots are NEVER cleared
239
+ * by this — they are engine infrastructure, not game content.
240
+ *
241
+ * This is what makes a warm restart (`hotReload`) safe to call N times
242
+ * without accumulating duplicate systems/listeners — each restart's
243
+ * outgoing game systems are fully removed before the new one registers its
244
+ * own, while the engine systems (input/physics/render/the ComponentManager
245
+ * tick/...) registered before the boundary are never touched.
246
+ */
247
+ removeAllNonEngine() {
248
+ if (!boundaryMarked)
249
+ return;
250
+ // Membership-based, same reasoning as runPhase: partition by whether
251
+ // each entry is in the engine set, not by a remembered length/index.
252
+ const keptRegistered = registered.filter((sys) => engineRegistered.has(sys));
253
+ const removedRegistered = registered.filter((sys) => !engineRegistered.has(sys));
254
+ registered.length = 0;
255
+ registered.push(...keptRegistered);
256
+ for (const sys of removedRegistered) {
257
+ sys.dispose?.();
258
+ }
259
+ for (const phase of PHASE_ORDER) {
260
+ const list = systems.get(phase);
261
+ const engineSet = engineFns.get(phase);
262
+ const kept = list.filter((fn) => engineSet.has(fn));
263
+ list.length = 0;
264
+ list.push(...kept);
265
+ }
266
+ },
267
+ /**
268
+ * Total system-function count, optionally scoped to one phase. Includes
269
+ * component-tick slots (a set slot counts as 1 per phase it occupies).
270
+ * Test/introspection helper — used to assert a warm restart doesn't
271
+ * accumulate systems (see `removeAllNonEngine`).
272
+ */
273
+ count(phase) {
274
+ if (phase) {
275
+ return (systems.get(phase)?.length ?? 0) + (componentTicks.get(phase) ? 1 : 0);
276
+ }
277
+ let total = 0;
278
+ for (const [p, list] of systems) {
279
+ total += list.length;
280
+ if (componentTicks.get(p))
281
+ total += 1;
282
+ }
283
+ return total;
284
+ },
285
+ };
286
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * System execution phases, in order.
3
+ * Each frame, systems run in this exact sequence.
4
+ */
5
+ export declare const SystemPhase: {
6
+ readonly INPUT: "input";
7
+ readonly PRE_PHYSICS: "prePhysics";
8
+ readonly PHYSICS: "physics";
9
+ readonly POST_PHYSICS: "postPhysics";
10
+ readonly GAME_LOGIC: "gameLogic";
11
+ readonly ANIMATION: "animation";
12
+ readonly PRE_RENDER: "preRender";
13
+ readonly RENDER: "render";
14
+ };
15
+ export type SystemPhaseName = (typeof SystemPhase)[keyof typeof SystemPhase];
16
+ /** Order of phase execution */
17
+ export declare const PHASE_ORDER: SystemPhaseName[];
18
+ /** A system is just a function that takes delta time */
19
+ export type SystemFn = (dt: number) => void;
20
+ /** A lifecycle system with init/update/dispose hooks. */
21
+ export interface SystemDef {
22
+ /** Which phase the update function runs in */
23
+ phase: SystemPhaseName;
24
+ /** One-time setup after all entities are spawned, before the first frame */
25
+ init?(): void;
26
+ /** Per-frame update */
27
+ update: SystemFn;
28
+ /** Cleanup when the system is removed or the scene unloads */
29
+ dispose?(): void;
30
+ }
31
+ export interface GameLoopConfig {
32
+ /** Fixed timestep in seconds (default: 1/60) */
33
+ fixedTimestep?: number;
34
+ /** Max physics substeps per frame to prevent spiral of death (default: 8) */
35
+ maxSubSteps?: number;
36
+ /**
37
+ * Called once per consumed fixed substep. Rendering (the `render` phase,
38
+ * last in `PHASE_ORDER`) runs *inside* this call — rendering is
39
+ * deliberately fixed-rate (decided — D1, `docs/DECISIONS-PENDING.md`),
40
+ * not a separate per-real-frame step. A real frame whose accumulator
41
+ * produces zero substeps calls `update` zero times and renders zero times.
42
+ */
43
+ update: (dt: number) => void;
44
+ /**
45
+ * External-drive mode (I2, `docs/AI-NATIVE-AUTHORING-IMPLEMENTATION-SPEC.md`
46
+ * §15 I2): when `true`, `start()` never arms a `requestAnimationFrame`
47
+ * chain and never installs the `visibilitychange`/`document.hidden`
48
+ * auto-stop handler — so a headless/backgrounded capture page cannot have
49
+ * its loop silently killed by the tab-hidden guard, and `config.update`
50
+ * is never invoked by wall-clock/RAF timing at all. The caller (a render
51
+ * harness) drives frames itself instead — see `runtime/render-control.ts`,
52
+ * which calls a world's phase hooks directly rather than going through
53
+ * this loop's `update` callback. Default `false` (normal wall-clock RAF
54
+ * playback, unchanged).
55
+ */
56
+ externalDrive?: boolean;
57
+ }
58
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;;;CASd,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAE7E,+BAA+B;AAC/B,eAAO,MAAM,WAAW,EAAE,eAAe,EASxC,CAAC;AAEF,wDAAwD;AACxD,MAAM,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;AAE5C,yDAAyD;AACzD,MAAM,WAAW,SAAS;IACxB,8CAA8C;IAC9C,KAAK,EAAE,eAAe,CAAC;IACvB,4EAA4E;IAC5E,IAAI,CAAC,IAAI,IAAI,CAAC;IACd,uBAAuB;IACvB,MAAM,EAAE,QAAQ,CAAC;IACjB,8DAA8D;IAC9D,OAAO,CAAC,IAAI,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;OAMG;IACH,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * System execution phases, in order.
3
+ * Each frame, systems run in this exact sequence.
4
+ */
5
+ export const SystemPhase = {
6
+ INPUT: 'input',
7
+ PRE_PHYSICS: 'prePhysics',
8
+ PHYSICS: 'physics',
9
+ POST_PHYSICS: 'postPhysics',
10
+ GAME_LOGIC: 'gameLogic',
11
+ ANIMATION: 'animation',
12
+ PRE_RENDER: 'preRender',
13
+ RENDER: 'render',
14
+ };
15
+ /** Order of phase execution */
16
+ export const PHASE_ORDER = [
17
+ SystemPhase.INPUT,
18
+ SystemPhase.PRE_PHYSICS,
19
+ SystemPhase.PHYSICS,
20
+ SystemPhase.POST_PHYSICS,
21
+ SystemPhase.GAME_LOGIC,
22
+ SystemPhase.ANIMATION,
23
+ SystemPhase.PRE_RENDER,
24
+ SystemPhase.RENDER,
25
+ ];
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Data assets — W1 of `docs/DATA-TOOLS-DESIGN.md` (§2.3 consumption API).
3
+ *
4
+ * A data asset is designer-tunable game data: a JSON file in the project's
5
+ * `src/data/`, governed by a Zod schema (`*.schema.ts`, engineer-owned) whose
6
+ * emitted JSON Schema (`*.schema.json`, see {@link toDataJsonSchema}) gives
7
+ * VS Code validation via the data file's `"$schema"` first line. Data assets
8
+ * are immutable at runtime — definitions, not state (§2.1).
9
+ *
10
+ * The blessed consumption shape, scaffolded working-at-birth by the project
11
+ * template (`src/data/` there is the worked example — §6.2):
12
+ *
13
+ * ```ts
14
+ * import raw from './tuning.data.json';
15
+ * import { TuningSchema } from './tuning.schema';
16
+ * import { defineData } from '@engine/data/data-asset';
17
+ *
18
+ * export const tuning = defineData(TuningSchema, raw, 'src/data/tuning.data.json');
19
+ * // Vite HMR needs the literal dep path in THIS module (static analysis) —
20
+ * // this one line is the entire live-tuning wiring (['default'] not .default:
21
+ * // strict tsconfigs index-signature ModuleNamespace):
22
+ * import.meta.hot?.accept('./tuning.data.json', (m) => tuning.hotSwap(m?.['default']));
23
+ * ```
24
+ *
25
+ * Game code reads `tuning.get()` inside its update loop (never cache fields
26
+ * across frames) or `subscribe()`s; an edit to the `.data.json` — from
27
+ * VS Code, an agent, or the future editor Data tab (W2) — flows through Vite
28
+ * HMR into the running game with no remount. React worlds/tools get a
29
+ * `useData` hook with W3's tool-hooks package (deferred with it: the engine
30
+ * core stays React-free).
31
+ */
32
+ import { z } from 'zod';
33
+ /**
34
+ * A live handle to one data asset (§2.3). `get`/`subscribe` are the whole
35
+ * runtime surface; `hotSwap` exists only for the owning module's
36
+ * `import.meta.hot.accept` callback.
37
+ */
38
+ export interface DataHandle<T> {
39
+ /** Current parsed values. Read every frame — HMR swaps them under you. */
40
+ get(): T;
41
+ /**
42
+ * Called with the new value after every successful hot swap (NOT with the
43
+ * initial value). Returns an unsubscribe function.
44
+ */
45
+ subscribe(fn: (value: T) => void): () => void;
46
+ /**
47
+ * HMR entry point — call from the owning module's
48
+ * `import.meta.hot.accept('<file>.data.json', (m) => handle.hotSwap(m?.default))`.
49
+ * Parses like load, but a FAILING edit keeps the last good value and
50
+ * `console.error`s instead of throwing: a typo mid-live-tune must not
51
+ * crash the running game. Fix the file and save again.
52
+ */
53
+ hotSwap(next: unknown): void;
54
+ /**
55
+ * The project-relative path this handle was defined with (`defineData`'s
56
+ * own `sourcePath` argument, populated automatically below) — OPTIONAL so
57
+ * any hand-rolled structural implementer stays valid. `getRef`
58
+ * (`./data-ref.ts`) reads this to catch a `getRef(wrongHandle, "stem#key")`
59
+ * mismatch with a teaching error instead of silently resolving against the
60
+ * wrong asset; without it, `getRef` just skips that one check.
61
+ */
62
+ readonly sourcePath?: string;
63
+ }
64
+ /**
65
+ * Define a data asset from its Zod schema, the statically imported JSON, and
66
+ * its project-relative path (used verbatim in error messages, so pass the
67
+ * real one). Parse-on-load: an invalid file fails loud at import time, naming
68
+ * the file, every bad path, and the fix (§2.3, §6.5 "errors teach").
69
+ *
70
+ * Schema fields should carry `.min/.max/.default/.describe` — the same
71
+ * annotations `GameComponent.static schema` uses — so the emitted JSON Schema
72
+ * documents the file and (W2+) the editor renders real widgets.
73
+ */
74
+ export declare function defineData<S extends z.ZodType>(schema: S, initial: unknown, sourcePath: string): DataHandle<z.output<S>>;
75
+ /**
76
+ * Emit the JSON Schema interchange artifact for a data asset's Zod schema
77
+ * (§2.1: `*.schema.json` is EMITTED, never hand-written; D4: generated and
78
+ * committed by default so VS Code works with no dev server running).
79
+ *
80
+ * Wraps `z.toJSONSchema` with `io: 'input'` — the one non-obvious knob:
81
+ * defaulted fields must be OPTIONAL in the file schema (a data file may omit
82
+ * them), whereas the default output mode would mark every field `required`
83
+ * and make VS Code reject valid files. The template's root `emit-schemas.ts`
84
+ * is the blessed caller (`npm run emit-schemas`).
85
+ *
86
+ * The emitted root schema also explicitly ALLOWS the `"$schema"` string
87
+ * property, mirroring the parse-side strip below: without it, a TABLE
88
+ * asset's emitted schema (`z.record` → `additionalProperties: <rowSchema>`)
89
+ * makes VS Code flag the data file's own `"$schema"` line as an invalid row.
90
+ */
91
+ export declare function toDataJsonSchema(schema: z.ZodType): Record<string, unknown>;
92
+ /**
93
+ * Parse a raw `.data.json` payload: strips the `"$schema"` interchange line,
94
+ * validates through the Zod schema, throws the teaching error on failure.
95
+ * `defineData` uses this internally on load and hot swap; it is exported for
96
+ * emit/doctor-style scripts (the template's `emit-schemas.ts` validates every
97
+ * data file through it, so file validation and runtime validation can never
98
+ * disagree).
99
+ */
100
+ export declare function parseDataJson<S extends z.ZodType>(schema: S, data: unknown, sourcePath: string): z.output<S>;
101
+ //# sourceMappingURL=data-asset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-asset.d.ts","sourceRoot":"","sources":["../../src/data/data-asset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,0EAA0E;IAC1E,GAAG,IAAI,CAAC,CAAC;IACT;;;OAGG;IACH,SAAS,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC9C;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAC5C,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,GACjB,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAwBzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQ3E;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAC/C,MAAM,EAAE,CAAC,EACT,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,MAAM,GACjB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAsBb"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Data assets — W1 of `docs/DATA-TOOLS-DESIGN.md` (§2.3 consumption API).
3
+ *
4
+ * A data asset is designer-tunable game data: a JSON file in the project's
5
+ * `src/data/`, governed by a Zod schema (`*.schema.ts`, engineer-owned) whose
6
+ * emitted JSON Schema (`*.schema.json`, see {@link toDataJsonSchema}) gives
7
+ * VS Code validation via the data file's `"$schema"` first line. Data assets
8
+ * are immutable at runtime — definitions, not state (§2.1).
9
+ *
10
+ * The blessed consumption shape, scaffolded working-at-birth by the project
11
+ * template (`src/data/` there is the worked example — §6.2):
12
+ *
13
+ * ```ts
14
+ * import raw from './tuning.data.json';
15
+ * import { TuningSchema } from './tuning.schema';
16
+ * import { defineData } from '@engine/data/data-asset';
17
+ *
18
+ * export const tuning = defineData(TuningSchema, raw, 'src/data/tuning.data.json');
19
+ * // Vite HMR needs the literal dep path in THIS module (static analysis) —
20
+ * // this one line is the entire live-tuning wiring (['default'] not .default:
21
+ * // strict tsconfigs index-signature ModuleNamespace):
22
+ * import.meta.hot?.accept('./tuning.data.json', (m) => tuning.hotSwap(m?.['default']));
23
+ * ```
24
+ *
25
+ * Game code reads `tuning.get()` inside its update loop (never cache fields
26
+ * across frames) or `subscribe()`s; an edit to the `.data.json` — from
27
+ * VS Code, an agent, or the future editor Data tab (W2) — flows through Vite
28
+ * HMR into the running game with no remount. React worlds/tools get a
29
+ * `useData` hook with W3's tool-hooks package (deferred with it: the engine
30
+ * core stays React-free).
31
+ */
32
+ import { z } from 'zod';
33
+ /**
34
+ * Define a data asset from its Zod schema, the statically imported JSON, and
35
+ * its project-relative path (used verbatim in error messages, so pass the
36
+ * real one). Parse-on-load: an invalid file fails loud at import time, naming
37
+ * the file, every bad path, and the fix (§2.3, §6.5 "errors teach").
38
+ *
39
+ * Schema fields should carry `.min/.max/.default/.describe` — the same
40
+ * annotations `GameComponent.static schema` uses — so the emitted JSON Schema
41
+ * documents the file and (W2+) the editor renders real widgets.
42
+ */
43
+ export function defineData(schema, initial, sourcePath) {
44
+ let current = parseDataJson(schema, initial, sourcePath);
45
+ const subscribers = new Set();
46
+ return {
47
+ get: () => current,
48
+ sourcePath,
49
+ subscribe(fn) {
50
+ subscribers.add(fn);
51
+ return () => subscribers.delete(fn);
52
+ },
53
+ hotSwap(next) {
54
+ let parsed;
55
+ try {
56
+ parsed = parseDataJson(schema, next, sourcePath);
57
+ }
58
+ catch (err) {
59
+ // Keep the last good value alive — see the JSDoc on DataHandle.hotSwap.
60
+ // biome-ignore lint/suspicious/noConsole: deliberate, greppable — a rejected live-tune edit must be loud without crashing the running game (mirrors overlay-report.ts's direct console use)
61
+ console.error(`[data] hot edit rejected, keeping previous values.\n${String(err)}`);
62
+ return;
63
+ }
64
+ current = parsed;
65
+ for (const fn of subscribers)
66
+ fn(current);
67
+ },
68
+ };
69
+ }
70
+ /**
71
+ * Emit the JSON Schema interchange artifact for a data asset's Zod schema
72
+ * (§2.1: `*.schema.json` is EMITTED, never hand-written; D4: generated and
73
+ * committed by default so VS Code works with no dev server running).
74
+ *
75
+ * Wraps `z.toJSONSchema` with `io: 'input'` — the one non-obvious knob:
76
+ * defaulted fields must be OPTIONAL in the file schema (a data file may omit
77
+ * them), whereas the default output mode would mark every field `required`
78
+ * and make VS Code reject valid files. The template's root `emit-schemas.ts`
79
+ * is the blessed caller (`npm run emit-schemas`).
80
+ *
81
+ * The emitted root schema also explicitly ALLOWS the `"$schema"` string
82
+ * property, mirroring the parse-side strip below: without it, a TABLE
83
+ * asset's emitted schema (`z.record` → `additionalProperties: <rowSchema>`)
84
+ * makes VS Code flag the data file's own `"$schema"` line as an invalid row.
85
+ */
86
+ export function toDataJsonSchema(schema) {
87
+ const emitted = z.toJSONSchema(schema, { io: 'input' });
88
+ if (emitted['type'] === 'object') {
89
+ const properties = (emitted['properties'] ?? {});
90
+ properties['$schema'] ??= { type: 'string' };
91
+ emitted['properties'] = properties;
92
+ }
93
+ return emitted;
94
+ }
95
+ /**
96
+ * Parse a raw `.data.json` payload: strips the `"$schema"` interchange line,
97
+ * validates through the Zod schema, throws the teaching error on failure.
98
+ * `defineData` uses this internally on load and hot swap; it is exported for
99
+ * emit/doctor-style scripts (the template's `emit-schemas.ts` validates every
100
+ * data file through it, so file validation and runtime validation can never
101
+ * disagree).
102
+ */
103
+ export function parseDataJson(schema, data, sourcePath) {
104
+ // Strip the data file's `"$schema"` interchange line before validating —
105
+ // singleton (z.object, strip-mode) schemas ignored it by luck, but a TABLE
106
+ // asset (z.record) would try to validate it as a row and fail.
107
+ const payload = data !== null && typeof data === 'object' && !Array.isArray(data) && '$schema' in data
108
+ ? Object.fromEntries(Object.entries(data).filter(([key]) => key !== '$schema'))
109
+ : data;
110
+ const result = schema.safeParse(payload);
111
+ if (!result.success) {
112
+ const issues = result.error.issues
113
+ .map((issue) => ` - ${issue.path.join('.') || '(root)'}: ${issue.message}`)
114
+ .join('\n');
115
+ throw new Error(`Data asset "${sourcePath}" failed its schema:\n${issues}\n` +
116
+ `Fix the JSON to match the Zod schema (its emitted twin, ` +
117
+ `"${sourcePath.replace(/\.data\.json$/, '.schema.json')}", documents every field — ` +
118
+ `re-emit with \`npm run emit-schemas\` if the schema changed). ` +
119
+ `Worked example: the template's src/data/.`);
120
+ }
121
+ return result.data;
122
+ }