@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,80 @@
1
+ /**
2
+ * Build a {@link CollisionHandler} that turns Rapier sensor overlaps into
3
+ * `onTriggerEnter` / `onTriggerExit` callbacks on the GameComponents of the two
4
+ * involved Object3Ds.
5
+ *
6
+ * Rapier collision events report collider *handles*; we resolve each to its
7
+ * Object3D via the physics registry's reverse index, then notify each side's
8
+ * components with the *other* Object3D. Only sensor-involved collisions dispatch
9
+ * triggers (a solid-vs-solid contact is a regular collision, not a trigger).
10
+ *
11
+ * Tracks currently-active trigger partners so that if one side is unregistered
12
+ * (despawned) from the physics registry before Rapier's own exit event is
13
+ * drained, the still-live side still gets its `onTriggerExit` (T1.12d) — see
14
+ * `physics.onRemove` below.
15
+ *
16
+ * Register with `collisions.onCollision(createTriggerDispatch(...))`.
17
+ */
18
+ export function createTriggerDispatch(physics, components, rapierWorld, ctx) {
19
+ const activePartners = new Map();
20
+ const link = (a, b) => {
21
+ let set = activePartners.get(a);
22
+ if (!set) {
23
+ set = new Set();
24
+ activePartners.set(a, set);
25
+ }
26
+ set.add(b);
27
+ };
28
+ const unlink = (a, b) => {
29
+ const set = activePartners.get(a);
30
+ if (!set)
31
+ return;
32
+ set.delete(b);
33
+ if (set.size === 0)
34
+ activePartners.delete(a);
35
+ };
36
+ // Flush pending exits at unregister: an entity removed from the physics
37
+ // registry (e.g. despawned) may still have queued Rapier "stopped" events
38
+ // that never reach drain(), or may never generate one at all (the collider
39
+ // is simply gone). Either way, any object still tracked as its trigger
40
+ // partner must get its onTriggerExit now, not silently never.
41
+ physics.onRemove((object3D) => {
42
+ const partners = activePartners.get(object3D);
43
+ if (!partners || partners.size === 0)
44
+ return;
45
+ for (const other of partners) {
46
+ notify(components, other, object3D, false, ctx);
47
+ notify(components, object3D, other, false, ctx);
48
+ unlink(other, object3D);
49
+ }
50
+ activePartners.delete(object3D);
51
+ });
52
+ return (handleA, handleB, started) => {
53
+ const colA = rapierWorld.getCollider(handleA);
54
+ const colB = rapierWorld.getCollider(handleB);
55
+ if (!colA?.isSensor() && !colB?.isSensor())
56
+ return;
57
+ const objA = physics.getByColliderHandle(handleA);
58
+ const objB = physics.getByColliderHandle(handleB);
59
+ if (!objA || !objB)
60
+ return;
61
+ if (started) {
62
+ link(objA, objB);
63
+ link(objB, objA);
64
+ }
65
+ else {
66
+ unlink(objA, objB);
67
+ unlink(objB, objA);
68
+ }
69
+ notify(components, objA, objB, started, ctx);
70
+ notify(components, objB, objA, started, ctx);
71
+ };
72
+ }
73
+ function notify(components, self, other, started, ctx) {
74
+ for (const inst of components.getComponents(self)) {
75
+ if (started)
76
+ inst.onTriggerEnter?.(other, ctx);
77
+ else
78
+ inst.onTriggerExit?.(other, ctx);
79
+ }
80
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Engine-PUBLISHED `GameProvider`/`useGame`/`useGameState`/`useWorldObservation`
3
+ * (D-Z5, `docs/WAVE3-ADAPTER-PLUMBING-DESIGN.md` §D-Z5) — the canonical,
4
+ * opt-in react entry for the T7.4 state bridge (`docs/REACT-STATE-BRIDGE.md`
5
+ * §3). This is a SEPARATE, react-value-importing module under
6
+ * `packages/engine/src/react/` — colocated per REACT-STATE-BRIDGE §3's own
7
+ * "colocate the react-facing hooks with the HUD seam, not the react-free
8
+ * core" rule, just now living IN the engine package rather than only in the
9
+ * project template. It is imported by NOTHING in the engine core import
10
+ * graph (`packages/engine/src/` outside this `react/` directory) — that
11
+ * invariant is proved by `packages/engine/test/react-core-import-ban.test.ts`
12
+ * (AC-F1).
13
+ *
14
+ * This module is the SPEC others port faithfully: it was originally authored
15
+ * as `packages/editor/template/src/ui/game-state.tsx` (T7.4); that file is
16
+ * now a thin re-export of this one (D-Z5 step 3) so every NEW scaffolded
17
+ * project gets ONE canonical context, while existing projects with their own
18
+ * full copy (their own `createContext`) keep working untouched — adoption of
19
+ * THIS module is an option, never a forced migration (D-Z5).
20
+ *
21
+ * Context-identity landmine (unchanged from the template file's own history,
22
+ * still the reason `loadProjectGameProvider`/the virtual-module plugin exist
23
+ * in `packages/editor/src/adapter-resolver.ts` /
24
+ * `packages/editor/vite-plugin-react-world-provider.ts`): `<GameProvider>`
25
+ * and `useGame()` must resolve against the SAME `createContext()` call. A
26
+ * project that ships its OWN `src/ui/game-state.tsx` (its own
27
+ * `createContext`) must be wrapped by ITS OWN `GameProvider` — wrapping it
28
+ * with THIS module's `GameProvider` instead would split context and
29
+ * `useGame()` would throw "no Game in context" even though a `<GameProvider>`
30
+ * genuinely wraps the tree (proved by
31
+ * `packages/editor/test/game-state-context-split.test.tsx`, AC-F1). This is
32
+ * exactly why the engine-published fallback (`resolveIngestReactAdapter`'s
33
+ * D-Y3 upgrade, `default-react`'s optional fallback) only ever fires when the
34
+ * project's OWN `src/ui/game-state.tsx` is ABSENT — an unmodified foreign
35
+ * entry that imports no vgai hooks has no context to split.
36
+ */
37
+ import { type ReactNode } from 'react';
38
+ import type { WorldStateObserver } from '../adapter';
39
+ import { type Equals, shallow } from '../runtime/frame-selector-cache';
40
+ import type { Game } from '../runtime/game';
41
+ /** Re-exported for convenience — the opt-in equality for selectors that
42
+ * return a fresh object/array/tuple every call (default is `Object.is`). */
43
+ export { shallow };
44
+ /** Provide the `Game` to `useGameState`/`useGame` for everything mounted
45
+ * beneath it. Compose it around whatever renders your tree (`mountUI`, a
46
+ * react world's `createRoot(...).render(...)`, etc.) — see the module doc
47
+ * comment above for the context-identity rule this hook family depends on. */
48
+ export declare function GameProvider({ game, children }: {
49
+ game: Game;
50
+ children: ReactNode;
51
+ }): import("react/jsx-runtime").JSX.Element;
52
+ /** Read the `Game` provided by the nearest `GameProvider`. Throws
53
+ * descriptively when called outside one — matching the repo's loud-failure
54
+ * habit rather than silently returning `null`. */
55
+ export declare function useGame(): Game;
56
+ /**
57
+ * Subscribe to a selected slice of game state (`docs/REACT-STATE-BRIDGE.md`
58
+ * §3). Re-renders only when the selected value changes: the selector re-runs
59
+ * at most once per completed frame (`game.state.frameVersion`), and
60
+ * `equals` (default `Object.is`; pass {@link shallow} for tuples/objects)
61
+ * gates whether the fresh result actually counts as a change.
62
+ *
63
+ * `selector` reads the live graph (e.g.
64
+ * `g => g.queryByComponent(Hp)[0]?.hp`) at post-frame quiescence — no
65
+ * copies. A selector that returns a fresh object every call must pass
66
+ * `shallow` (or an equivalent `equals`), or it will re-render every frame.
67
+ *
68
+ * Note: `equals` is captured once, when this hook first mounts (in the
69
+ * per-instance cache created below) — pass a stable function (module-level
70
+ * `shallow`/`Object.is`, or a value that doesn't change across renders),
71
+ * not a fresh inline arrow every render.
72
+ */
73
+ export declare function useGameState<T>(selector: (game: Game) => T, equals?: Equals<T>): T;
74
+ /**
75
+ * Pure, react-free lookup for the `useWorldObservation` hook below — factored
76
+ * out so the hook body stays a thin `useSyncExternalStore` wrapper. Throws
77
+ * descriptively (loud, not `undefined`-forever) when `worldId` doesn't name a
78
+ * registered world, or that world's mount has no `observe`
79
+ * (`WorldStateObserver`, `@engine/adapter`) — matching the `Game.registerWorld`
80
+ * "no state bridge" report (`runtime/game.ts`) this is the react-side half of.
81
+ */
82
+ export declare function requireWorldObserver(game: Game, worldId: string): WorldStateObserver;
83
+ /**
84
+ * Subscribe to a selected slice of a FOREIGN (non-first-party) world's
85
+ * observed state (`docs/REACT-STATE-BRIDGE.md` §4) — the ingested-world
86
+ * counterpart of `useGameState` above; both are sugar over the same
87
+ * subscribe/snapshot shape, so a react HUD reads native and ingested sources
88
+ * through one mental model.
89
+ *
90
+ * `selector` runs over that world's `snapshot()` — NOT the `Game` — since a
91
+ * foreign world hosts no `GameComponent`s to query. Re-renders only when the
92
+ * selected value changes (`equals`, default `Object.is`; pass {@link shallow}
93
+ * for tuples/objects returned fresh every call).
94
+ *
95
+ * Cadence note: unlike `useGameState`, this does NOT key its cache off
96
+ * `game.state.frameVersion` — a foreign/self-driven world may notify on its
97
+ * OWN rAF cadence, unrelated to our frame timing (§4's "consumers must not
98
+ * assume our frame timing"). Instead this keeps a local version counter,
99
+ * bumped once per `onChange` notification from the observer itself.
100
+ *
101
+ * Throws (loud, not a silently-undefined subscription) if `worldId` isn't
102
+ * registered, or its mount has no `observe` — see `requireWorldObserver`.
103
+ */
104
+ export declare function useWorldObservation<T>(worldId: string, selector: (snapshot: unknown) => T, equals?: Equals<T>): T;
105
+ //# sourceMappingURL=game-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-state.d.ts","sourceRoot":"","sources":["../../src/react/game-state.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAiB,KAAK,SAAS,EAA4C,MAAM,OAAO,CAAC;AAChG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAA4B,KAAK,MAAM,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AACjG,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C;6EAC6E;AAC7E,OAAO,EAAE,OAAO,EAAE,CAAC;AAInB;;;+EAG+E;AAC/E,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAEnF;AAED;;mDAEmD;AACnD,wBAAgB,OAAO,IAAI,IAAI,CAQ9B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,EAAE,MAAM,GAAE,MAAM,CAAC,CAAC,CAAa,GAAG,CAAC,CAW7F;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAiBpF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,CAAC,EAClC,MAAM,GAAE,MAAM,CAAC,CAAC,CAAa,GAC5B,CAAC,CAoBH"}
@@ -0,0 +1,144 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Engine-PUBLISHED `GameProvider`/`useGame`/`useGameState`/`useWorldObservation`
4
+ * (D-Z5, `docs/WAVE3-ADAPTER-PLUMBING-DESIGN.md` §D-Z5) — the canonical,
5
+ * opt-in react entry for the T7.4 state bridge (`docs/REACT-STATE-BRIDGE.md`
6
+ * §3). This is a SEPARATE, react-value-importing module under
7
+ * `packages/engine/src/react/` — colocated per REACT-STATE-BRIDGE §3's own
8
+ * "colocate the react-facing hooks with the HUD seam, not the react-free
9
+ * core" rule, just now living IN the engine package rather than only in the
10
+ * project template. It is imported by NOTHING in the engine core import
11
+ * graph (`packages/engine/src/` outside this `react/` directory) — that
12
+ * invariant is proved by `packages/engine/test/react-core-import-ban.test.ts`
13
+ * (AC-F1).
14
+ *
15
+ * This module is the SPEC others port faithfully: it was originally authored
16
+ * as `packages/editor/template/src/ui/game-state.tsx` (T7.4); that file is
17
+ * now a thin re-export of this one (D-Z5 step 3) so every NEW scaffolded
18
+ * project gets ONE canonical context, while existing projects with their own
19
+ * full copy (their own `createContext`) keep working untouched — adoption of
20
+ * THIS module is an option, never a forced migration (D-Z5).
21
+ *
22
+ * Context-identity landmine (unchanged from the template file's own history,
23
+ * still the reason `loadProjectGameProvider`/the virtual-module plugin exist
24
+ * in `packages/editor/src/adapter-resolver.ts` /
25
+ * `packages/editor/vite-plugin-react-world-provider.ts`): `<GameProvider>`
26
+ * and `useGame()` must resolve against the SAME `createContext()` call. A
27
+ * project that ships its OWN `src/ui/game-state.tsx` (its own
28
+ * `createContext`) must be wrapped by ITS OWN `GameProvider` — wrapping it
29
+ * with THIS module's `GameProvider` instead would split context and
30
+ * `useGame()` would throw "no Game in context" even though a `<GameProvider>`
31
+ * genuinely wraps the tree (proved by
32
+ * `packages/editor/test/game-state-context-split.test.tsx`, AC-F1). This is
33
+ * exactly why the engine-published fallback (`resolveIngestReactAdapter`'s
34
+ * D-Y3 upgrade, `default-react`'s optional fallback) only ever fires when the
35
+ * project's OWN `src/ui/game-state.tsx` is ABSENT — an unmodified foreign
36
+ * entry that imports no vgai hooks has no context to split.
37
+ */
38
+ import { createContext, useContext, useRef, useSyncExternalStore } from 'react';
39
+ import { createFrameSelectorCache, shallow } from '../runtime/frame-selector-cache';
40
+ /** Re-exported for convenience — the opt-in equality for selectors that
41
+ * return a fresh object/array/tuple every call (default is `Object.is`). */
42
+ export { shallow };
43
+ const GameContext = createContext(null);
44
+ /** Provide the `Game` to `useGameState`/`useGame` for everything mounted
45
+ * beneath it. Compose it around whatever renders your tree (`mountUI`, a
46
+ * react world's `createRoot(...).render(...)`, etc.) — see the module doc
47
+ * comment above for the context-identity rule this hook family depends on. */
48
+ export function GameProvider({ game, children }) {
49
+ return _jsx(GameContext.Provider, { value: game, children: children });
50
+ }
51
+ /** Read the `Game` provided by the nearest `GameProvider`. Throws
52
+ * descriptively when called outside one — matching the repo's loud-failure
53
+ * habit rather than silently returning `null`. */
54
+ export function useGame() {
55
+ const game = useContext(GameContext);
56
+ if (!game) {
57
+ throw new Error('useGame: no Game in context — wrap this component in <GameProvider game={ctx.game!}>.');
58
+ }
59
+ return game;
60
+ }
61
+ /**
62
+ * Subscribe to a selected slice of game state (`docs/REACT-STATE-BRIDGE.md`
63
+ * §3). Re-renders only when the selected value changes: the selector re-runs
64
+ * at most once per completed frame (`game.state.frameVersion`), and
65
+ * `equals` (default `Object.is`; pass {@link shallow} for tuples/objects)
66
+ * gates whether the fresh result actually counts as a change.
67
+ *
68
+ * `selector` reads the live graph (e.g.
69
+ * `g => g.queryByComponent(Hp)[0]?.hp`) at post-frame quiescence — no
70
+ * copies. A selector that returns a fresh object every call must pass
71
+ * `shallow` (or an equivalent `equals`), or it will re-render every frame.
72
+ *
73
+ * Note: `equals` is captured once, when this hook first mounts (in the
74
+ * per-instance cache created below) — pass a stable function (module-level
75
+ * `shallow`/`Object.is`, or a value that doesn't change across renders),
76
+ * not a fresh inline arrow every render.
77
+ */
78
+ export function useGameState(selector, equals = Object.is) {
79
+ const game = useGame();
80
+ const cacheRef = useRef(null);
81
+ if (cacheRef.current === null) {
82
+ cacheRef.current = createFrameSelectorCache(equals);
83
+ }
84
+ return useSyncExternalStore((onStoreChange) => game.state.subscribe(onStoreChange), () => cacheRef.current.get(game.state.frameVersion, () => selector(game)));
85
+ }
86
+ /**
87
+ * Pure, react-free lookup for the `useWorldObservation` hook below — factored
88
+ * out so the hook body stays a thin `useSyncExternalStore` wrapper. Throws
89
+ * descriptively (loud, not `undefined`-forever) when `worldId` doesn't name a
90
+ * registered world, or that world's mount has no `observe`
91
+ * (`WorldStateObserver`, `@engine/adapter`) — matching the `Game.registerWorld`
92
+ * "no state bridge" report (`runtime/game.ts`) this is the react-side half of.
93
+ */
94
+ export function requireWorldObserver(game, worldId) {
95
+ const world = game.world(worldId);
96
+ if (!world) {
97
+ throw new Error(`useWorldObservation: no world registered with id "${worldId}" — check game.worlds for the ` +
98
+ 'ids actually registered.');
99
+ }
100
+ const observer = world.mounted.observe;
101
+ if (!observer) {
102
+ throw new Error(`useWorldObservation: world "${worldId}" (kind: ${world.kind}, adapter: "${world.adapter.id}") ` +
103
+ 'has no state bridge — its mount has no `observe` (WorldStateObserver). This world cannot ' +
104
+ 'be observed from React (docs/REACT-STATE-BRIDGE.md §4).');
105
+ }
106
+ return observer;
107
+ }
108
+ /**
109
+ * Subscribe to a selected slice of a FOREIGN (non-first-party) world's
110
+ * observed state (`docs/REACT-STATE-BRIDGE.md` §4) — the ingested-world
111
+ * counterpart of `useGameState` above; both are sugar over the same
112
+ * subscribe/snapshot shape, so a react HUD reads native and ingested sources
113
+ * through one mental model.
114
+ *
115
+ * `selector` runs over that world's `snapshot()` — NOT the `Game` — since a
116
+ * foreign world hosts no `GameComponent`s to query. Re-renders only when the
117
+ * selected value changes (`equals`, default `Object.is`; pass {@link shallow}
118
+ * for tuples/objects returned fresh every call).
119
+ *
120
+ * Cadence note: unlike `useGameState`, this does NOT key its cache off
121
+ * `game.state.frameVersion` — a foreign/self-driven world may notify on its
122
+ * OWN rAF cadence, unrelated to our frame timing (§4's "consumers must not
123
+ * assume our frame timing"). Instead this keeps a local version counter,
124
+ * bumped once per `onChange` notification from the observer itself.
125
+ *
126
+ * Throws (loud, not a silently-undefined subscription) if `worldId` isn't
127
+ * registered, or its mount has no `observe` — see `requireWorldObserver`.
128
+ */
129
+ export function useWorldObservation(worldId, selector, equals = Object.is) {
130
+ const game = useGame();
131
+ const observer = requireWorldObserver(game, worldId);
132
+ const cacheRef = useRef(null);
133
+ if (cacheRef.current === null) {
134
+ cacheRef.current = createFrameSelectorCache(equals);
135
+ }
136
+ // Local notification-version counter — see the cadence note above. A
137
+ // plain mutable ref (not React state): bumping it must not itself trigger
138
+ // a render, `useSyncExternalStore`'s `onStoreChange` is what does that.
139
+ const versionRef = useRef(0);
140
+ return useSyncExternalStore((onStoreChange) => observer.subscribe(() => {
141
+ versionRef.current++;
142
+ onStoreChange();
143
+ }), () => cacheRef.current.get(versionRef.current, () => selector(observer.snapshot())));
144
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * React hooks for data assets — the tool-hooks half of
3
+ * `docs/DATA-TOOLS-DESIGN.md` §3.3, shipped with W4 (dock tools).
4
+ *
5
+ * Lives under `packages/engine/src/react/` deliberately: this is the ONE
6
+ * directory of the engine allowed to value-import react (colocated with
7
+ * `game-state.tsx` per the react-free-core rule proved by
8
+ * `test/react-core-import-ban.test.ts`). Game worlds that aren't react keep
9
+ * using `DataHandle.get()`/`subscribe()` directly (§2.3).
10
+ *
11
+ * - {@link useData} — subscribe a component to any W1 `DataHandle`; works in
12
+ * project tools, react worlds, and HUD overlays alike.
13
+ * - {@link writeData} — EDITOR-TOOL plumbing: write a whole `.data.json`
14
+ * back through the editor dev server, closing the live-tuning loop
15
+ * (widget → file write → Vite HMR → `hotSwap` → {@link useData} re-render
16
+ * → the running game reads the new value). Not for game code.
17
+ */
18
+ import type { DataHandle } from '../data/data-asset';
19
+ /**
20
+ * Read a data asset's current values and re-render whenever a hot edit lands
21
+ * (§3.3). A thin `useSyncExternalStore` over the handle's
22
+ * `subscribe`/`get` — any `defineData` handle works, no provider needed:
23
+ *
24
+ * ```tsx
25
+ * import { tuning } from '../data/tuning';
26
+ * const values = useData(tuning); // fresh parsed object after every hotSwap
27
+ * ```
28
+ *
29
+ * `get()` returns the same reference between successful hot swaps, so this
30
+ * re-renders exactly once per accepted edit and never in between.
31
+ */
32
+ export declare function useData<T>(handle: DataHandle<T>): T;
33
+ /**
34
+ * Write a data asset's ENTIRE new value back to its `.data.json` — the write
35
+ * half of a project tool's live-tuning loop (§3.3, D1: writes are file
36
+ * writes, always). POSTs to the editor dev server's `/__editor/data-file`
37
+ * route (see its doc comment in `packages/editor/server/editor-server.ts`),
38
+ * which accepts only `src/data/**\/*.data.json` and writes immediately; the
39
+ * running game then receives the change through the normal `.data.json` HMR
40
+ * path, exactly as if VS Code had saved the file.
41
+ *
42
+ * ```tsx
43
+ * // inside a tool's onChange — spread the live values, replace one field:
44
+ * void writeData('src/data/tuning.data.json', { ...tuning.get(), gravity: v });
45
+ * ```
46
+ *
47
+ * FOR TOOLS, NOT GAME CODE: data assets are immutable at runtime (§2.1) —
48
+ * runtime state belongs in your game's own store, never written back into
49
+ * data files. Outside a running editor there is no `/__editor` server, so
50
+ * this rejects with a teaching error (a shipped game could never reach the
51
+ * route anyway — builds strip `src/tools/` entirely, §4).
52
+ *
53
+ * Serialization matches the editor Data panel's diff-minimal contract:
54
+ * `"$schema"` first, 2-space indent, trailing newline. When `value` carries
55
+ * no `"$schema"` key (the common case — `DataHandle.get()` strips it), the
56
+ * conventional sibling reference (`./<name>.schema.json`, §2.1) is restored
57
+ * so a tool write never silently drops VS Code validation from the file.
58
+ */
59
+ export declare function writeData(projectRelativePath: string, value: Record<string, unknown>): Promise<void>;
60
+ //# sourceMappingURL=use-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-data.d.ts","sourceRoot":"","sources":["../../src/react/use-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAKnD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,SAAS,CAC7B,mBAAmB,EAAE,MAAM,EAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,IAAI,CAAC,CA2Cf"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * React hooks for data assets — the tool-hooks half of
3
+ * `docs/DATA-TOOLS-DESIGN.md` §3.3, shipped with W4 (dock tools).
4
+ *
5
+ * Lives under `packages/engine/src/react/` deliberately: this is the ONE
6
+ * directory of the engine allowed to value-import react (colocated with
7
+ * `game-state.tsx` per the react-free-core rule proved by
8
+ * `test/react-core-import-ban.test.ts`). Game worlds that aren't react keep
9
+ * using `DataHandle.get()`/`subscribe()` directly (§2.3).
10
+ *
11
+ * - {@link useData} — subscribe a component to any W1 `DataHandle`; works in
12
+ * project tools, react worlds, and HUD overlays alike.
13
+ * - {@link writeData} — EDITOR-TOOL plumbing: write a whole `.data.json`
14
+ * back through the editor dev server, closing the live-tuning loop
15
+ * (widget → file write → Vite HMR → `hotSwap` → {@link useData} re-render
16
+ * → the running game reads the new value). Not for game code.
17
+ */
18
+ import { useSyncExternalStore } from 'react';
19
+ /**
20
+ * Read a data asset's current values and re-render whenever a hot edit lands
21
+ * (§3.3). A thin `useSyncExternalStore` over the handle's
22
+ * `subscribe`/`get` — any `defineData` handle works, no provider needed:
23
+ *
24
+ * ```tsx
25
+ * import { tuning } from '../data/tuning';
26
+ * const values = useData(tuning); // fresh parsed object after every hotSwap
27
+ * ```
28
+ *
29
+ * `get()` returns the same reference between successful hot swaps, so this
30
+ * re-renders exactly once per accepted edit and never in between.
31
+ */
32
+ export function useData(handle) {
33
+ return useSyncExternalStore((onStoreChange) => handle.subscribe(() => onStoreChange()), () => handle.get());
34
+ }
35
+ /**
36
+ * Write a data asset's ENTIRE new value back to its `.data.json` — the write
37
+ * half of a project tool's live-tuning loop (§3.3, D1: writes are file
38
+ * writes, always). POSTs to the editor dev server's `/__editor/data-file`
39
+ * route (see its doc comment in `packages/editor/server/editor-server.ts`),
40
+ * which accepts only `src/data/**\/*.data.json` and writes immediately; the
41
+ * running game then receives the change through the normal `.data.json` HMR
42
+ * path, exactly as if VS Code had saved the file.
43
+ *
44
+ * ```tsx
45
+ * // inside a tool's onChange — spread the live values, replace one field:
46
+ * void writeData('src/data/tuning.data.json', { ...tuning.get(), gravity: v });
47
+ * ```
48
+ *
49
+ * FOR TOOLS, NOT GAME CODE: data assets are immutable at runtime (§2.1) —
50
+ * runtime state belongs in your game's own store, never written back into
51
+ * data files. Outside a running editor there is no `/__editor` server, so
52
+ * this rejects with a teaching error (a shipped game could never reach the
53
+ * route anyway — builds strip `src/tools/` entirely, §4).
54
+ *
55
+ * Serialization matches the editor Data panel's diff-minimal contract:
56
+ * `"$schema"` first, 2-space indent, trailing newline. When `value` carries
57
+ * no `"$schema"` key (the common case — `DataHandle.get()` strips it), the
58
+ * conventional sibling reference (`./<name>.schema.json`, §2.1) is restored
59
+ * so a tool write never silently drops VS Code validation from the file.
60
+ */
61
+ export async function writeData(projectRelativePath, value) {
62
+ if (!projectRelativePath.startsWith('src/data/') || !projectRelativePath.endsWith('.data.json')) {
63
+ throw new Error(`writeData: invalid path ${JSON.stringify(projectRelativePath)} — data assets live at ` +
64
+ 'src/data/**/*.data.json, addressed project-relative (docs/DATA-TOOLS-DESIGN.md §2.1), ' +
65
+ "e.g. writeData('src/data/tuning.data.json', next).");
66
+ }
67
+ // "$schema" first for minimal diffs; restore the conventional sibling
68
+ // reference when the caller's object (typically `{ ...handle.get() }`,
69
+ // which never carries it) omits the line.
70
+ const { $schema, ...rest } = value;
71
+ const schemaRef = $schema ??
72
+ `./${projectRelativePath
73
+ .split('/')
74
+ .pop()
75
+ ?.replace(/\.data\.json$/, '')}.schema.json`;
76
+ const content = `${JSON.stringify({ $schema: schemaRef, ...rest }, null, 2)}\n`;
77
+ let res;
78
+ try {
79
+ res = await fetch('/__editor/data-file', {
80
+ method: 'POST',
81
+ headers: { 'Content-Type': 'application/json' },
82
+ body: JSON.stringify({ path: projectRelativePath, content }),
83
+ });
84
+ }
85
+ catch (err) {
86
+ throw new Error('writeData: could not reach the editor dev server (/__editor/data-file) — this helper is ' +
87
+ 'editor-tool plumbing (docs/DATA-TOOLS-DESIGN.md §3.3) and only works inside the running ' +
88
+ 'editor. Game code must not write data assets: they are immutable at runtime (§2.1) — ' +
89
+ `keep runtime state in your game's own store. (${String(err)})`);
90
+ }
91
+ if (!res.ok) {
92
+ const detail = await res.text().catch(() => '');
93
+ throw new Error(`writeData: the editor rejected the write to "${projectRelativePath}" ` +
94
+ `(HTTP ${res.status}${detail ? `: ${detail}` : ''}).`);
95
+ }
96
+ }
@@ -0,0 +1,75 @@
1
+ /**
2
+ * W3.1 of docs/DATA-TOOLS-DESIGN.md §3.3 — `useSelection()`, the third
3
+ * tool-hooks contract member (alongside `useData`/`writeData` from
4
+ * `use-data.ts`). Where those two hooks are about DATA ASSETS, this one is
5
+ * about the currently-selected ENTITY and the components authored on it —
6
+ * the gap a real consumer (`critter-types-w3b`'s `critter-type.tool.tsx`,
7
+ * §9.4) hit hard: with no way to read a component's own authored config, it
8
+ * had to recover species from `node.label` (a display string, not data).
9
+ *
10
+ * Scope, v1:
11
+ * - INSPECTOR-placement tools only (`placement: 'inspector'`,
12
+ * `define-tool.ts`). `EditorSelectionProvider` is host plumbing —
13
+ * `InspectorToolSection` wraps every tool render in it; dock tools
14
+ * (`ToolHost`/`BottomPanel`) have no adapter/selection in scope and never
15
+ * get a provider. Calling `useSelection()` there throws a teaching error,
16
+ * contained by the tool's `ToolErrorBoundary` (the editor survives).
17
+ * - READ-only. `config` is a shallow copy of the authored record; write
18
+ * through `InspectorProvider.set('components.<Type>.<field>', v)` /
19
+ * `writeData` (the existing paths), never by mutating what this hook
20
+ * returns. Per-entity WRITE-from-tool is deferred with `useTunable` (§10).
21
+ * - Honest degrades, not errors, when the adapter is thinner than the vgai
22
+ * first-party one: no `components` provider at all ⇒ `components: []`;
23
+ * a `components` provider present but with no optional `config()`
24
+ * accessor ⇒ each entry still appears (from `list()`) but with
25
+ * `config: null`. Both mirror the `AuthoringAdapter` optional-provider
26
+ * doctrine (§4) — an ingest/UI adapter that never implements `components`
27
+ * was already legal, and stays legal.
28
+ *
29
+ * Liveness — two existing paths reused, no new mechanism (§4's "reuse that
30
+ * path" rule):
31
+ * 1. Selection changes: `Inspector.tsx`'s own
32
+ * `useSyncExternalStore(store.subscribe, store.getSnapshot)` re-renders
33
+ * the panel, each matched `Section` gets the new `nodeId` prop, and
34
+ * `InspectorToolSection` re-creates this provider's context value.
35
+ * 2. Config edits while the SAME node stays selected: `adapter.subscribe`
36
+ * fires (the vgai adapter's store notifies on every `updateEntity`,
37
+ * which is what `InspectorProvider.set` goes through) — this hook keeps
38
+ * a local version counter bumped per notification (exactly
39
+ * `game-state.tsx`'s `useWorldObservation` pattern: the adapter has no
40
+ * snapshot/version of its own, `subscribe` is fire-only) and recomputes.
41
+ */
42
+ import { type ReactNode } from 'react';
43
+ import type { AuthoringAdapter, EditorNode } from '../adapter';
44
+ /**
45
+ * EDITOR-side host plumbing: `InspectorToolSection` wraps a tool's rendered
46
+ * `<Component/>` in this, passing the adapter + nodeId it already holds.
47
+ * Project tools never render this themselves — it exists so `useSelection()`
48
+ * has something to read.
49
+ */
50
+ export declare function EditorSelectionProvider({ adapter, nodeId, children, }: {
51
+ adapter: AuthoringAdapter;
52
+ nodeId: string | null;
53
+ children: ReactNode;
54
+ }): import("react/jsx-runtime").JSX.Element;
55
+ /** One component attached to the selected entity, with its authored config
56
+ * if the adapter can produce one (see the module doc's degrade rules). */
57
+ export interface SelectedComponent {
58
+ type: string;
59
+ config: Record<string, unknown> | null;
60
+ }
61
+ export interface EditorSelection {
62
+ nodeId: string | null;
63
+ node: EditorNode | null;
64
+ components: SelectedComponent[];
65
+ }
66
+ /**
67
+ * The selected entity, live: its node, and every component attached to it
68
+ * with that component's own authored config (read-only — see module doc).
69
+ *
70
+ * Throws outside an `EditorSelectionProvider` — inspector tools always render
71
+ * inside one; a dock tool or game-code caller does not, and the error names
72
+ * the fix rather than failing silently.
73
+ */
74
+ export declare function useSelection(): EditorSelection;
75
+ //# sourceMappingURL=use-selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-selection.d.ts","sourceRoot":"","sources":["../../src/react/use-selection.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAS/D;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,OAAO,EACP,MAAM,EACN,QAAQ,GACT,EAAE;IACD,OAAO,EAAE,gBAAgB,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB,2CAGA;AAED;2EAC2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,iBAAiB,EAAE,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI,eAAe,CAmC9C"}