@vgai/engine 0.5.5 → 0.5.7

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 (446) hide show
  1. package/dist/adapter/adapter-surface.d.ts +30 -0
  2. package/dist/adapter/adapter-surface.d.ts.map +1 -0
  3. package/dist/adapter/adapter-surface.js +18 -0
  4. package/dist/adapter/authoring.d.ts +597 -0
  5. package/dist/adapter/authoring.d.ts.map +1 -0
  6. package/dist/adapter/authoring.js +22 -0
  7. package/dist/adapter/colyseus-networking-adapter.d.ts +77 -0
  8. package/dist/adapter/colyseus-networking-adapter.d.ts.map +1 -0
  9. package/dist/adapter/colyseus-networking-adapter.js +76 -0
  10. package/dist/adapter/first-party-systems.d.ts +23 -0
  11. package/dist/adapter/first-party-systems.d.ts.map +1 -0
  12. package/dist/adapter/first-party-systems.js +196 -0
  13. package/dist/adapter/host-context.d.ts +194 -0
  14. package/dist/adapter/host-context.d.ts.map +1 -0
  15. package/dist/adapter/host-context.js +80 -0
  16. package/dist/adapter/index.d.ts +33 -0
  17. package/dist/adapter/index.d.ts.map +1 -0
  18. package/dist/adapter/index.js +25 -0
  19. package/dist/adapter/ingest/game-contract.d.ts +53 -0
  20. package/dist/adapter/ingest/game-contract.d.ts.map +1 -0
  21. package/dist/adapter/ingest/game-contract.js +30 -0
  22. package/dist/adapter/ingest/scene-capture.d.ts +121 -0
  23. package/dist/adapter/ingest/scene-capture.d.ts.map +1 -0
  24. package/dist/adapter/ingest/scene-capture.js +270 -0
  25. package/dist/adapter/ingest/structural-ids.d.ts +64 -0
  26. package/dist/adapter/ingest/structural-ids.d.ts.map +1 -0
  27. package/dist/adapter/ingest/structural-ids.js +110 -0
  28. package/dist/adapter/ingest/upstream-pin.d.ts +44 -0
  29. package/dist/adapter/ingest/upstream-pin.d.ts.map +1 -0
  30. package/dist/adapter/ingest/upstream-pin.js +47 -0
  31. package/dist/adapter/loop-gate-report.d.ts +34 -0
  32. package/dist/adapter/loop-gate-report.d.ts.map +1 -0
  33. package/dist/adapter/loop-gate-report.js +37 -0
  34. package/dist/adapter/rapier-physics-adapter.d.ts +69 -0
  35. package/dist/adapter/rapier-physics-adapter.d.ts.map +1 -0
  36. package/dist/adapter/rapier-physics-adapter.js +135 -0
  37. package/dist/adapter/root-adapter.d.ts +195 -0
  38. package/dist/adapter/root-adapter.d.ts.map +1 -0
  39. package/dist/adapter/root-adapter.js +25 -0
  40. package/dist/adapter/setup-three-root-adapter.d.ts +87 -0
  41. package/dist/adapter/setup-three-root-adapter.d.ts.map +1 -0
  42. package/dist/adapter/setup-three-root-adapter.js +791 -0
  43. package/dist/adapter/system-adapter.d.ts +453 -0
  44. package/dist/adapter/system-adapter.d.ts.map +1 -0
  45. package/dist/adapter/system-adapter.js +13 -0
  46. package/dist/adapter/transform.d.ts +18 -0
  47. package/dist/adapter/transform.d.ts.map +1 -0
  48. package/dist/adapter/transform.js +1 -0
  49. package/dist/ai/navigation.d.ts +78 -0
  50. package/dist/ai/navigation.d.ts.map +1 -0
  51. package/dist/ai/navigation.js +152 -0
  52. package/dist/animation/anim-graph-types.d.ts +25 -0
  53. package/dist/animation/anim-graph-types.d.ts.map +1 -0
  54. package/dist/animation/anim-graph-types.js +1 -0
  55. package/dist/animation/animation-clock.d.ts +213 -0
  56. package/dist/animation/animation-clock.d.ts.map +1 -0
  57. package/dist/animation/animation-clock.js +301 -0
  58. package/dist/animation/blend-node.d.ts +22 -0
  59. package/dist/animation/blend-node.d.ts.map +1 -0
  60. package/dist/animation/blend-node.js +97 -0
  61. package/dist/animation/camera-ownership.d.ts +249 -0
  62. package/dist/animation/camera-ownership.d.ts.map +1 -0
  63. package/dist/animation/camera-ownership.js +169 -0
  64. package/dist/animation/cinematic-cues.d.ts +200 -0
  65. package/dist/animation/cinematic-cues.d.ts.map +1 -0
  66. package/dist/animation/cinematic-cues.js +213 -0
  67. package/dist/animation/clip-map.d.ts +12 -0
  68. package/dist/animation/clip-map.d.ts.map +1 -0
  69. package/dist/animation/clip-map.js +31 -0
  70. package/dist/animation/cubic-spline-interpolant.d.ts +54 -0
  71. package/dist/animation/cubic-spline-interpolant.d.ts.map +1 -0
  72. package/dist/animation/cubic-spline-interpolant.js +111 -0
  73. package/dist/animation/theatre-clock-binding.d.ts +89 -0
  74. package/dist/animation/theatre-clock-binding.d.ts.map +1 -0
  75. package/dist/animation/theatre-clock-binding.js +29 -0
  76. package/dist/animation/theatre-director.d.ts +277 -0
  77. package/dist/animation/theatre-director.d.ts.map +1 -0
  78. package/dist/animation/theatre-director.js +248 -0
  79. package/dist/animation/theatre-object-binding.d.ts +305 -0
  80. package/dist/animation/theatre-object-binding.d.ts.map +1 -0
  81. package/dist/animation/theatre-object-binding.js +351 -0
  82. package/dist/animation/xstate-animation-binding.d.ts +119 -0
  83. package/dist/animation/xstate-animation-binding.d.ts.map +1 -0
  84. package/dist/animation/xstate-animation-binding.js +349 -0
  85. package/dist/animation/xstate-animation-meta.d.ts +266 -0
  86. package/dist/animation/xstate-animation-meta.d.ts.map +1 -0
  87. package/dist/animation/xstate-animation-meta.js +252 -0
  88. package/dist/asset-formats/camera.d.ts +15 -0
  89. package/dist/asset-formats/camera.d.ts.map +1 -0
  90. package/dist/asset-formats/camera.js +15 -0
  91. package/dist/asset-formats/collider.d.ts +21 -0
  92. package/dist/asset-formats/collider.d.ts.map +1 -0
  93. package/dist/asset-formats/collider.js +53 -0
  94. package/dist/asset-formats/index.d.ts +46 -0
  95. package/dist/asset-formats/index.d.ts.map +1 -0
  96. package/dist/asset-formats/index.js +36 -0
  97. package/dist/asset-formats/instances.d.ts +17 -0
  98. package/dist/asset-formats/instances.d.ts.map +1 -0
  99. package/dist/asset-formats/instances.js +31 -0
  100. package/dist/asset-formats/light.d.ts +21 -0
  101. package/dist/asset-formats/light.d.ts.map +1 -0
  102. package/dist/asset-formats/light.js +35 -0
  103. package/dist/asset-formats/material.d.ts +129 -0
  104. package/dist/asset-formats/material.d.ts.map +1 -0
  105. package/dist/asset-formats/material.js +88 -0
  106. package/dist/asset-formats/mesh.d.ts +22 -0
  107. package/dist/asset-formats/mesh.d.ts.map +1 -0
  108. package/dist/asset-formats/mesh.js +64 -0
  109. package/dist/asset-formats/parse.d.ts +20 -0
  110. package/dist/asset-formats/parse.d.ts.map +1 -0
  111. package/dist/asset-formats/parse.js +34 -0
  112. package/dist/asset-formats/particles.d.ts +1390 -0
  113. package/dist/asset-formats/particles.d.ts.map +1 -0
  114. package/dist/asset-formats/particles.js +319 -0
  115. package/dist/asset-formats/render-env.d.ts +387 -0
  116. package/dist/asset-formats/render-env.d.ts.map +1 -0
  117. package/dist/asset-formats/render-env.js +300 -0
  118. package/dist/asset-formats/tuples.d.ts +12 -0
  119. package/dist/asset-formats/tuples.d.ts.map +1 -0
  120. package/dist/asset-formats/tuples.js +14 -0
  121. package/dist/asset-loaders.d.ts +97 -0
  122. package/dist/asset-loaders.d.ts.map +1 -0
  123. package/dist/asset-loaders.js +209 -0
  124. package/dist/asset-parse-error.d.ts +24 -0
  125. package/dist/asset-parse-error.d.ts.map +1 -0
  126. package/dist/asset-parse-error.js +29 -0
  127. package/dist/asset-registry.d.ts +38 -0
  128. package/dist/asset-registry.d.ts.map +1 -0
  129. package/dist/asset-registry.js +66 -0
  130. package/dist/assets.d.ts +26 -0
  131. package/dist/assets.d.ts.map +1 -0
  132. package/dist/assets.js +55 -0
  133. package/dist/audio/wav-encode.d.ts +38 -0
  134. package/dist/audio/wav-encode.d.ts.map +1 -0
  135. package/dist/audio/wav-encode.js +97 -0
  136. package/dist/canvas-react/engine-bridge.d.ts +45 -0
  137. package/dist/canvas-react/engine-bridge.d.ts.map +1 -0
  138. package/dist/canvas-react/engine-bridge.js +45 -0
  139. package/dist/canvas-react/index.d.ts +42 -0
  140. package/dist/canvas-react/index.d.ts.map +1 -0
  141. package/dist/canvas-react/index.js +41 -0
  142. package/dist/canvas-react/pixi-primitive.d.ts +85 -0
  143. package/dist/canvas-react/pixi-primitive.d.ts.map +1 -0
  144. package/dist/canvas-react/pixi-primitive.js +181 -0
  145. package/dist/canvas-react/pixi-react-adapter.d.ts +71 -0
  146. package/dist/canvas-react/pixi-react-adapter.d.ts.map +1 -0
  147. package/dist/canvas-react/pixi-react-adapter.js +229 -0
  148. package/dist/canvas-react/pixi-react-root-factory.d.ts +56 -0
  149. package/dist/canvas-react/pixi-react-root-factory.d.ts.map +1 -0
  150. package/dist/canvas-react/pixi-react-root-factory.js +73 -0
  151. package/dist/canvas-react/world-context.d.ts +88 -0
  152. package/dist/canvas-react/world-context.d.ts.map +1 -0
  153. package/dist/canvas-react/world-context.js +212 -0
  154. package/dist/config.d.ts +9 -0
  155. package/dist/config.d.ts.map +1 -0
  156. package/dist/config.js +8 -0
  157. package/dist/core/frame-pacing.d.ts +90 -0
  158. package/dist/core/frame-pacing.d.ts.map +1 -0
  159. package/dist/core/frame-pacing.js +89 -0
  160. package/dist/core/game-loop.d.ts +62 -0
  161. package/dist/core/game-loop.d.ts.map +1 -0
  162. package/dist/core/game-loop.js +189 -0
  163. package/dist/core/seeded-random.d.ts +69 -0
  164. package/dist/core/seeded-random.d.ts.map +1 -0
  165. package/dist/core/seeded-random.js +121 -0
  166. package/dist/core/sim-clock.d.ts +199 -0
  167. package/dist/core/sim-clock.d.ts.map +1 -0
  168. package/dist/core/sim-clock.js +291 -0
  169. package/dist/core/system-runner.d.ts +96 -0
  170. package/dist/core/system-runner.d.ts.map +1 -0
  171. package/dist/core/system-runner.js +253 -0
  172. package/dist/core/types.d.ts +111 -0
  173. package/dist/core/types.d.ts.map +1 -0
  174. package/dist/core/types.js +25 -0
  175. package/dist/data/data-asset.d.ts +101 -0
  176. package/dist/data/data-asset.d.ts.map +1 -0
  177. package/dist/data/data-asset.js +122 -0
  178. package/dist/data/data-check-core.d.ts +109 -0
  179. package/dist/data/data-check-core.d.ts.map +1 -0
  180. package/dist/data/data-check-core.js +177 -0
  181. package/dist/data/data-ref.d.ts +79 -0
  182. package/dist/data/data-ref.d.ts.map +1 -0
  183. package/dist/data/data-ref.js +130 -0
  184. package/dist/data/vite-plugin-data.d.ts +79 -0
  185. package/dist/data/vite-plugin-data.d.ts.map +1 -0
  186. package/dist/data/vite-plugin-data.js +217 -0
  187. package/dist/defaults.d.ts +233 -0
  188. package/dist/defaults.d.ts.map +1 -0
  189. package/dist/defaults.js +137 -0
  190. package/dist/dev/chrome-trace.d.ts +45 -0
  191. package/dist/dev/chrome-trace.d.ts.map +1 -0
  192. package/dist/dev/chrome-trace.js +114 -0
  193. package/dist/dev/console-bridge.d.ts +22 -0
  194. package/dist/dev/console-bridge.d.ts.map +1 -0
  195. package/dist/dev/console-bridge.js +71 -0
  196. package/dist/dev/debug-draw.d.ts +24 -0
  197. package/dist/dev/debug-draw.d.ts.map +1 -0
  198. package/dist/dev/debug-draw.js +73 -0
  199. package/dist/dev/instruments.d.ts +133 -0
  200. package/dist/dev/instruments.d.ts.map +1 -0
  201. package/dist/dev/instruments.js +231 -0
  202. package/dist/dev/logger.d.ts +30 -0
  203. package/dist/dev/logger.d.ts.map +1 -0
  204. package/dist/dev/logger.js +90 -0
  205. package/dist/dev/performance-profiler.d.ts +111 -0
  206. package/dist/dev/performance-profiler.d.ts.map +1 -0
  207. package/dist/dev/performance-profiler.js +215 -0
  208. package/dist/dev/render-debug-adapter.d.ts +57 -0
  209. package/dist/dev/render-debug-adapter.d.ts.map +1 -0
  210. package/dist/dev/render-debug-adapter.js +141 -0
  211. package/dist/dev/render-memory.d.ts +53 -0
  212. package/dist/dev/render-memory.d.ts.map +1 -0
  213. package/dist/dev/render-memory.js +190 -0
  214. package/dist/dev/webgl-frame-capture.d.ts +134 -0
  215. package/dist/dev/webgl-frame-capture.d.ts.map +1 -0
  216. package/dist/dev/webgl-frame-capture.js +270 -0
  217. package/dist/dev/webgl-gpu-timer.d.ts +8 -0
  218. package/dist/dev/webgl-gpu-timer.d.ts.map +1 -0
  219. package/dist/dev/webgl-gpu-timer.js +52 -0
  220. package/dist/ecs/scene-index.d.ts +179 -0
  221. package/dist/ecs/scene-index.d.ts.map +1 -0
  222. package/dist/ecs/scene-index.js +331 -0
  223. package/dist/ecs/scene-query.d.ts +6 -0
  224. package/dist/ecs/scene-query.d.ts.map +1 -0
  225. package/dist/ecs/scene-query.js +40 -0
  226. package/dist/ecs/user-data.d.ts +193 -0
  227. package/dist/ecs/user-data.d.ts.map +1 -0
  228. package/dist/ecs/user-data.js +145 -0
  229. package/dist/index.d.ts +35 -0
  230. package/dist/index.d.ts.map +1 -0
  231. package/dist/index.js +29 -0
  232. package/dist/input/input-manager.d.ts +944 -0
  233. package/dist/input/input-manager.d.ts.map +1 -0
  234. package/dist/input/input-manager.js +2209 -0
  235. package/dist/input/input-types.d.ts +174 -0
  236. package/dist/input/input-types.d.ts.map +1 -0
  237. package/dist/input/input-types.js +1 -0
  238. package/dist/input/prompt-labels.d.ts +21 -0
  239. package/dist/input/prompt-labels.d.ts.map +1 -0
  240. package/dist/input/prompt-labels.js +121 -0
  241. package/dist/input/rebind-controller.d.ts +59 -0
  242. package/dist/input/rebind-controller.d.ts.map +1 -0
  243. package/dist/input/rebind-controller.js +85 -0
  244. package/dist/input/schema.d.ts +16 -0
  245. package/dist/input/schema.d.ts.map +1 -0
  246. package/dist/input/schema.js +228 -0
  247. package/dist/loader.d.ts +76 -0
  248. package/dist/loader.d.ts.map +1 -0
  249. package/dist/loader.js +114 -0
  250. package/dist/manifest/editor-port.d.ts +53 -0
  251. package/dist/manifest/editor-port.d.ts.map +1 -0
  252. package/dist/manifest/editor-port.js +67 -0
  253. package/dist/manifest/filename.d.ts +14 -0
  254. package/dist/manifest/filename.d.ts.map +1 -0
  255. package/dist/manifest/filename.js +43 -0
  256. package/dist/manifest/index.d.ts +6 -0
  257. package/dist/manifest/index.d.ts.map +1 -0
  258. package/dist/manifest/index.js +9 -0
  259. package/dist/manifest/load-file.d.ts +7 -0
  260. package/dist/manifest/load-file.d.ts.map +1 -0
  261. package/dist/manifest/load-file.js +23 -0
  262. package/dist/manifest/load.d.ts +161 -0
  263. package/dist/manifest/load.d.ts.map +1 -0
  264. package/dist/manifest/load.js +269 -0
  265. package/dist/manifest/locate.d.ts +24 -0
  266. package/dist/manifest/locate.d.ts.map +1 -0
  267. package/dist/manifest/locate.js +48 -0
  268. package/dist/manifest/schema.d.ts +293 -0
  269. package/dist/manifest/schema.d.ts.map +1 -0
  270. package/dist/manifest/schema.js +633 -0
  271. package/dist/physics/collider-dimensions.d.ts +63 -0
  272. package/dist/physics/collider-dimensions.d.ts.map +1 -0
  273. package/dist/physics/collider-dimensions.js +98 -0
  274. package/dist/physics/collision-system.d.ts +41 -0
  275. package/dist/physics/collision-system.d.ts.map +1 -0
  276. package/dist/physics/collision-system.js +64 -0
  277. package/dist/physics/physics-registry.d.ts +45 -0
  278. package/dist/physics/physics-registry.d.ts.map +1 -0
  279. package/dist/physics/physics-registry.js +65 -0
  280. package/dist/physics/transform-writer.d.ts +16 -0
  281. package/dist/physics/transform-writer.d.ts.map +1 -0
  282. package/dist/physics/transform-writer.js +38 -0
  283. package/dist/pixi/authoring.d.ts +93 -0
  284. package/dist/pixi/authoring.d.ts.map +1 -0
  285. package/dist/pixi/authoring.js +207 -0
  286. package/dist/pixi/index.d.ts +16 -0
  287. package/dist/pixi/index.d.ts.map +1 -0
  288. package/dist/pixi/index.js +15 -0
  289. package/dist/pixi/ingest-iframe.d.ts +82 -0
  290. package/dist/pixi/ingest-iframe.d.ts.map +1 -0
  291. package/dist/pixi/ingest-iframe.js +166 -0
  292. package/dist/pixi/ingest.d.ts +97 -0
  293. package/dist/pixi/ingest.d.ts.map +1 -0
  294. package/dist/pixi/ingest.js +40 -0
  295. package/dist/pixi/physics-registry.d.ts +24 -0
  296. package/dist/pixi/physics-registry.d.ts.map +1 -0
  297. package/dist/pixi/physics-registry.js +38 -0
  298. package/dist/pixi/scene-capture.d.ts +43 -0
  299. package/dist/pixi/scene-capture.d.ts.map +1 -0
  300. package/dist/pixi/scene-capture.js +92 -0
  301. package/dist/pixi/system-adapters.d.ts +16 -0
  302. package/dist/pixi/system-adapters.d.ts.map +1 -0
  303. package/dist/pixi/system-adapters.js +37 -0
  304. package/dist/react/unmanaged-root-detector.d.ts +18 -0
  305. package/dist/react/unmanaged-root-detector.d.ts.map +1 -0
  306. package/dist/react/unmanaged-root-detector.js +70 -0
  307. package/dist/react/use-data.d.ts +60 -0
  308. package/dist/react/use-data.d.ts.map +1 -0
  309. package/dist/react/use-data.js +101 -0
  310. package/dist/react/use-selection.d.ts +54 -0
  311. package/dist/react/use-selection.d.ts.map +1 -0
  312. package/dist/react/use-selection.js +71 -0
  313. package/dist/react/world-state.d.ts +154 -0
  314. package/dist/react/world-state.d.ts.map +1 -0
  315. package/dist/react/world-state.js +220 -0
  316. package/dist/render/auto-batcher.d.ts +34 -0
  317. package/dist/render/auto-batcher.d.ts.map +1 -0
  318. package/dist/render/auto-batcher.js +140 -0
  319. package/dist/render/instance-mesh.d.ts +5 -0
  320. package/dist/render/instance-mesh.d.ts.map +1 -0
  321. package/dist/render/instance-mesh.js +19 -0
  322. package/dist/render/light-camera-factory.d.ts +24 -0
  323. package/dist/render/light-camera-factory.d.ts.map +1 -0
  324. package/dist/render/light-camera-factory.js +71 -0
  325. package/dist/render/lod.d.ts +13 -0
  326. package/dist/render/lod.d.ts.map +1 -0
  327. package/dist/render/lod.js +16 -0
  328. package/dist/render/material-factory.d.ts +15 -0
  329. package/dist/render/material-factory.d.ts.map +1 -0
  330. package/dist/render/material-factory.js +186 -0
  331. package/dist/render/mesh-shadow.d.ts +11 -0
  332. package/dist/render/mesh-shadow.d.ts.map +1 -0
  333. package/dist/render/mesh-shadow.js +19 -0
  334. package/dist/render/particles-factory.d.ts +99 -0
  335. package/dist/render/particles-factory.d.ts.map +1 -0
  336. package/dist/render/particles-factory.js +361 -0
  337. package/dist/render/render-batch-system.d.ts +33 -0
  338. package/dist/render/render-batch-system.d.ts.map +1 -0
  339. package/dist/render/render-batch-system.js +223 -0
  340. package/dist/render/render-features.d.ts +47 -0
  341. package/dist/render/render-features.d.ts.map +1 -0
  342. package/dist/render/render-features.js +105 -0
  343. package/dist/render/render-settings.d.ts +35 -0
  344. package/dist/render/render-settings.d.ts.map +1 -0
  345. package/dist/render/render-settings.js +51 -0
  346. package/dist/render/spark-renderer-lifecycle.d.ts +18 -0
  347. package/dist/render/spark-renderer-lifecycle.d.ts.map +1 -0
  348. package/dist/render/spark-renderer-lifecycle.js +57 -0
  349. package/dist/render/viewport-shading.d.ts +17 -0
  350. package/dist/render/viewport-shading.d.ts.map +1 -0
  351. package/dist/render/viewport-shading.js +87 -0
  352. package/dist/runtime/create-runtime.d.ts +259 -0
  353. package/dist/runtime/create-runtime.d.ts.map +1 -0
  354. package/dist/runtime/create-runtime.js +666 -0
  355. package/dist/runtime/debug-bridge.d.ts +288 -0
  356. package/dist/runtime/debug-bridge.d.ts.map +1 -0
  357. package/dist/runtime/debug-bridge.js +277 -0
  358. package/dist/runtime/debug-registry.d.ts +287 -0
  359. package/dist/runtime/debug-registry.d.ts.map +1 -0
  360. package/dist/runtime/debug-registry.js +528 -0
  361. package/dist/runtime/dev-layers.d.ts +34 -0
  362. package/dist/runtime/dev-layers.d.ts.map +1 -0
  363. package/dist/runtime/dev-layers.js +40 -0
  364. package/dist/runtime/frame-selector-cache.d.ts +41 -0
  365. package/dist/runtime/frame-selector-cache.d.ts.map +1 -0
  366. package/dist/runtime/frame-selector-cache.js +65 -0
  367. package/dist/runtime/game.d.ts +576 -0
  368. package/dist/runtime/game.d.ts.map +1 -0
  369. package/dist/runtime/game.js +1003 -0
  370. package/dist/runtime/gameplay-rng-trap.d.ts +47 -0
  371. package/dist/runtime/gameplay-rng-trap.d.ts.map +1 -0
  372. package/dist/runtime/gameplay-rng-trap.js +95 -0
  373. package/dist/runtime/input-router.d.ts +78 -0
  374. package/dist/runtime/input-router.d.ts.map +1 -0
  375. package/dist/runtime/input-router.js +171 -0
  376. package/dist/runtime/mount-game.d.ts +126 -0
  377. package/dist/runtime/mount-game.d.ts.map +1 -0
  378. package/dist/runtime/mount-game.js +159 -0
  379. package/dist/runtime/mount-manifest.d.ts +174 -0
  380. package/dist/runtime/mount-manifest.d.ts.map +1 -0
  381. package/dist/runtime/mount-manifest.js +304 -0
  382. package/dist/runtime/presentation.d.ts +85 -0
  383. package/dist/runtime/presentation.d.ts.map +1 -0
  384. package/dist/runtime/presentation.js +92 -0
  385. package/dist/runtime/render-audio-control.d.ts +126 -0
  386. package/dist/runtime/render-audio-control.d.ts.map +1 -0
  387. package/dist/runtime/render-audio-control.js +116 -0
  388. package/dist/runtime/render-control.d.ts +347 -0
  389. package/dist/runtime/render-control.d.ts.map +1 -0
  390. package/dist/runtime/render-control.js +317 -0
  391. package/dist/runtime/render-seed.d.ts +56 -0
  392. package/dist/runtime/render-seed.d.ts.map +1 -0
  393. package/dist/runtime/render-seed.js +73 -0
  394. package/dist/runtime/state-bridge.d.ts +60 -0
  395. package/dist/runtime/state-bridge.d.ts.map +1 -0
  396. package/dist/runtime/state-bridge.js +62 -0
  397. package/dist/runtime/types.d.ts +285 -0
  398. package/dist/runtime/types.d.ts.map +1 -0
  399. package/dist/runtime/types.js +1 -0
  400. package/dist/runtime/unexported-game-trap.d.ts +36 -0
  401. package/dist/runtime/unexported-game-trap.d.ts.map +1 -0
  402. package/dist/runtime/unexported-game-trap.js +80 -0
  403. package/dist/setup/setup-audio.d.ts +20 -0
  404. package/dist/setup/setup-audio.d.ts.map +1 -0
  405. package/dist/setup/setup-audio.js +41 -0
  406. package/dist/setup/setup-particles.d.ts +17 -0
  407. package/dist/setup/setup-particles.d.ts.map +1 -0
  408. package/dist/setup/setup-particles.js +16 -0
  409. package/dist/setup/setup-physics.d.ts +25 -0
  410. package/dist/setup/setup-physics.d.ts.map +1 -0
  411. package/dist/setup/setup-physics.js +51 -0
  412. package/dist/setup/setup-renderer.d.ts +82 -0
  413. package/dist/setup/setup-renderer.d.ts.map +1 -0
  414. package/dist/setup/setup-renderer.js +381 -0
  415. package/dist/world3d-react/engine-bridge.d.ts +47 -0
  416. package/dist/world3d-react/engine-bridge.d.ts.map +1 -0
  417. package/dist/world3d-react/engine-bridge.js +48 -0
  418. package/dist/world3d-react/index.d.ts +47 -0
  419. package/dist/world3d-react/index.d.ts.map +1 -0
  420. package/dist/world3d-react/index.js +46 -0
  421. package/dist/world3d-react/r3f-adapter.d.ts +51 -0
  422. package/dist/world3d-react/r3f-adapter.d.ts.map +1 -0
  423. package/dist/world3d-react/r3f-adapter.js +368 -0
  424. package/dist/world3d-react/r3f-root-factory.d.ts +62 -0
  425. package/dist/world3d-react/r3f-root-factory.d.ts.map +1 -0
  426. package/dist/world3d-react/r3f-root-factory.js +79 -0
  427. package/dist/world3d-react/rapier-physics-bridge.d.ts +76 -0
  428. package/dist/world3d-react/rapier-physics-bridge.d.ts.map +1 -0
  429. package/dist/world3d-react/rapier-physics-bridge.js +120 -0
  430. package/dist/world3d-react/renderer-config.d.ts +58 -0
  431. package/dist/world3d-react/renderer-config.d.ts.map +1 -0
  432. package/dist/world3d-react/renderer-config.js +96 -0
  433. package/dist/world3d-react/world-context.d.ts +123 -0
  434. package/dist/world3d-react/world-context.d.ts.map +1 -0
  435. package/dist/world3d-react/world-context.js +204 -0
  436. package/dist-config/config.js +303 -0
  437. package/dist-config/config.js.map +7 -0
  438. package/package.json +14 -3
  439. package/src/adapter/rapier-physics-adapter.ts +77 -34
  440. package/src/config.ts +8 -0
  441. package/src/core/frame-pacing.ts +26 -0
  442. package/src/core/game-loop.ts +4 -3
  443. package/src/dev/instruments.ts +302 -0
  444. package/src/setup/setup-renderer.ts +2 -0
  445. package/src/world3d-react/index.ts +9 -0
  446. package/src/world3d-react/rapier-physics-bridge.tsx +137 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"physics-registry.d.ts","sourceRoot":"","sources":["../../src/pixi/physics-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB;iBAKtB,SAAS,QAAQ,MAAM,CAAC,SAAS,YAAY,MAAM,CAAC,QAAQ,GAAG,IAAI;iBAInE,SAAS,GAAG,aAAa,GAAG,SAAS;gCAGtB,MAAM,GAAG,SAAS,GAAG,SAAS;oBAG1C,SAAS,GAAG,IAAI;eAKrB,gBAAgB,CAAC,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;mBAG3C,MAAM;aAGT,IAAI;EAKhB;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Maps PixiJS display objects to their Rapier 2D bodies/colliders and back —
3
+ * the Pixi analog of `PhysicsRegistry`. Two indexes:
4
+ * - `Container → {body, collider}` for the postPhysics transform writer.
5
+ * - `colliderHandle → Container` reverse index for collision/trigger dispatch.
6
+ */
7
+ export function createPhysics2DRegistry() {
8
+ const byObject = new Map();
9
+ const byColliderHandle = new Map();
10
+ return {
11
+ add(display, body, collider) {
12
+ byObject.set(display, { body, collider });
13
+ byColliderHandle.set(collider.handle, display);
14
+ },
15
+ get(display) {
16
+ return byObject.get(display);
17
+ },
18
+ getByColliderHandle(handle) {
19
+ return byColliderHandle.get(handle);
20
+ },
21
+ remove(display) {
22
+ const refs = byObject.get(display);
23
+ if (refs)
24
+ byColliderHandle.delete(refs.collider.handle);
25
+ byObject.delete(display);
26
+ },
27
+ entries() {
28
+ return byObject.entries();
29
+ },
30
+ get size() {
31
+ return byObject.size;
32
+ },
33
+ clear() {
34
+ byObject.clear();
35
+ byColliderHandle.clear();
36
+ },
37
+ };
38
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Scene capture for the Pixi surface — the PixiJS analog of the three.js render
3
+ * accessor-trap (`adapter/ingest/scene-capture.ts`).
4
+ *
5
+ * An unmodified PixiJS game owns its own `Application`, `stage`, renderer, and
6
+ * ticker. To inspect/host that live scene with ZERO edits to the game, we trap the
7
+ * render call and capture the game's `stage` + renderer + app on its first frame.
8
+ *
9
+ * Unlike three.js's `WebGLRenderer` (whose `render` is an own-instance property,
10
+ * forcing a prototype getter/setter), PixiJS's `Application.prototype.render` is a
11
+ * normal prototype method — the standard ticker render path (`ticker → app.render()`)
12
+ * goes through it — so a direct prototype wrap suffices.
13
+ *
14
+ * CRITICAL (same module-identity gatekeeper as the 3D path): the trap must be
15
+ * installed on the SAME `pixi.js` module instance the game uses. A bundler/dev-server
16
+ * that dedupes `pixi.js` makes an ESM game's `import 'pixi.js'` resolve to the host
17
+ * instance, so it is trapped; a game bundling its own pixi cannot be captured this
18
+ * way (degrade to iframe-reachable or opaque-embed tiers — see the spec).
19
+ */
20
+ /** A live Pixi runtime captured from an external PixiJS game. */
21
+ export interface CapturedRuntime2D {
22
+ /** The game's root stage Container. */
23
+ stage: unknown;
24
+ /** The game's PixiJS renderer. */
25
+ renderer: unknown;
26
+ /** The game's Application (so the host can pause/resume its ticker). */
27
+ app: unknown;
28
+ }
29
+ export interface SceneCapture2DHandle {
30
+ readonly captured: CapturedRuntime2D | null;
31
+ waitForCapture(timeoutMs?: number): Promise<CapturedRuntime2D>;
32
+ getDrawCount(): number;
33
+ /** Pause/resume the captured game's own ticker (loop-host gating). */
34
+ setPaused(paused: boolean): void;
35
+ uninstall(): void;
36
+ }
37
+ /**
38
+ * Install the render trap on `pixiNamespace.Application.prototype.render`. Pass the
39
+ * host's `pixi.js` namespace so a shared-instance game is trapped. Install once per
40
+ * ingest session; `uninstall()` on teardown.
41
+ */
42
+ export declare function installSceneCapture2D(pixiNamespace: unknown): SceneCapture2DHandle;
43
+ //# sourceMappingURL=scene-capture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene-capture.d.ts","sourceRoot":"","sources":["../../src/pixi/scene-capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,uCAAuC;IACvC,KAAK,EAAE,OAAO,CAAC;IACf,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,wEAAwE;IACxE,GAAG,EAAE,OAAO,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC/D,YAAY,IAAI,MAAM,CAAC;IACvB,sEAAsE;IACtE,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,SAAS,IAAI,IAAI,CAAC;CACnB;AAMD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,OAAO,GAAG,oBAAoB,CAoElF"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Scene capture for the Pixi surface — the PixiJS analog of the three.js render
3
+ * accessor-trap (`adapter/ingest/scene-capture.ts`).
4
+ *
5
+ * An unmodified PixiJS game owns its own `Application`, `stage`, renderer, and
6
+ * ticker. To inspect/host that live scene with ZERO edits to the game, we trap the
7
+ * render call and capture the game's `stage` + renderer + app on its first frame.
8
+ *
9
+ * Unlike three.js's `WebGLRenderer` (whose `render` is an own-instance property,
10
+ * forcing a prototype getter/setter), PixiJS's `Application.prototype.render` is a
11
+ * normal prototype method — the standard ticker render path (`ticker → app.render()`)
12
+ * goes through it — so a direct prototype wrap suffices.
13
+ *
14
+ * CRITICAL (same module-identity gatekeeper as the 3D path): the trap must be
15
+ * installed on the SAME `pixi.js` module instance the game uses. A bundler/dev-server
16
+ * that dedupes `pixi.js` makes an ESM game's `import 'pixi.js'` resolve to the host
17
+ * instance, so it is trapped; a game bundling its own pixi cannot be captured this
18
+ * way (degrade to iframe-reachable or opaque-embed tiers — see the spec).
19
+ */
20
+ /**
21
+ * Install the render trap on `pixiNamespace.Application.prototype.render`. Pass the
22
+ * host's `pixi.js` namespace so a shared-instance game is trapped. Install once per
23
+ * ingest session; `uninstall()` on teardown.
24
+ */
25
+ export function installSceneCapture2D(pixiNamespace) {
26
+ const PIXI = pixiNamespace;
27
+ const proto = PIXI.Application.prototype;
28
+ let captured = null;
29
+ let drawCount = 0;
30
+ const waiters = [];
31
+ const priorRender = Object.getOwnPropertyDescriptor(proto, 'render');
32
+ const realRender = proto['render'];
33
+ Object.defineProperty(proto, 'render', {
34
+ configurable: true,
35
+ writable: true,
36
+ value: function (...args) {
37
+ drawCount++;
38
+ const stage = this['stage'];
39
+ if (!captured && stage) {
40
+ captured = { stage, renderer: this['renderer'], app: this };
41
+ for (const resolve of waiters.splice(0))
42
+ resolve(captured);
43
+ }
44
+ return realRender?.apply(this, args);
45
+ },
46
+ });
47
+ return {
48
+ get captured() {
49
+ return captured;
50
+ },
51
+ getDrawCount() {
52
+ return drawCount;
53
+ },
54
+ setPaused(paused) {
55
+ const app = captured?.app;
56
+ if (!app?.ticker)
57
+ return;
58
+ if (paused)
59
+ app.ticker.stop();
60
+ else
61
+ app.ticker.start();
62
+ },
63
+ waitForCapture(timeoutMs = 10_000) {
64
+ if (captured)
65
+ return Promise.resolve(captured);
66
+ return new Promise((resolve, reject) => {
67
+ const timer = setTimeout(() => {
68
+ const i = waiters.indexOf(wrapped);
69
+ if (i >= 0)
70
+ waiters.splice(i, 1);
71
+ reject(new Error(`pixi scene capture timed out after ${timeoutMs}ms — the game never ` +
72
+ `rendered, or it bundles its own (un-shared) copy of pixi.js.`));
73
+ }, timeoutMs);
74
+ const wrapped = (rt) => {
75
+ clearTimeout(timer);
76
+ resolve(rt);
77
+ };
78
+ waiters.push(wrapped);
79
+ });
80
+ },
81
+ uninstall() {
82
+ if (priorRender)
83
+ Object.defineProperty(proto, 'render', priorRender);
84
+ else if (realRender)
85
+ Object.defineProperty(proto, 'render', {
86
+ configurable: true,
87
+ writable: true,
88
+ value: realRender,
89
+ });
90
+ },
91
+ };
92
+ }
@@ -0,0 +1,16 @@
1
+ import type { Container } from 'pixi.js';
2
+ import type { Physics2DRegistry } from './physics-registry';
3
+ /**
4
+ * PhysicsAdapter2D — the Pixi analog of the 3D PhysicsAdapter (rapier-physics-adapter).
5
+ * Lets the editor coordinate editing of a Rapier-2D-driven entity WITHOUT owning the
6
+ * simulation: report transform ownership, then freeze → commit → unfreeze so a drag
7
+ * sticks instead of being stomped by the next physics step.
8
+ */
9
+ export interface PhysicsAdapter2D {
10
+ ownerOf(display: Container): 'physics' | 'none';
11
+ freeze(display: Container): void;
12
+ commit(display: Container, position: [number, number], rotation: number): void;
13
+ unfreeze(display: Container): void;
14
+ }
15
+ export declare function createPhysicsAdapter2D(physics: Physics2DRegistry): PhysicsAdapter2D;
16
+ //# sourceMappingURL=system-adapters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-adapters.d.ts","sourceRoot":"","sources":["../../src/pixi/system-adapters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IAChD,MAAM,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/E,QAAQ,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;CACpC;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAgCnF"}
@@ -0,0 +1,37 @@
1
+ export function createPhysicsAdapter2D(physics) {
2
+ // Remember each frozen body's prior type so unfreeze restores it.
3
+ const frozen = new WeakMap();
4
+ return {
5
+ ownerOf(display) {
6
+ const refs = physics.get(display);
7
+ if (!refs)
8
+ return 'none';
9
+ return refs.body.isDynamic() || refs.body.isKinematic() ? 'physics' : 'none';
10
+ },
11
+ freeze(display) {
12
+ const refs = physics.get(display);
13
+ if (!refs)
14
+ return;
15
+ frozen.set(display, refs.body.bodyType());
16
+ // Kinematic-position bodies hold a pose without being driven by forces.
17
+ refs.body.setBodyType(2 /* KinematicPositionBased */, true);
18
+ },
19
+ commit(display, position, rotation) {
20
+ const refs = physics.get(display);
21
+ if (!refs)
22
+ return;
23
+ refs.body.setTranslation({ x: position[0], y: position[1] }, true);
24
+ refs.body.setRotation(rotation, true);
25
+ },
26
+ unfreeze(display) {
27
+ const refs = physics.get(display);
28
+ if (!refs)
29
+ return;
30
+ const prior = frozen.get(display);
31
+ if (prior !== undefined) {
32
+ refs.body.setBodyType(prior, true);
33
+ frozen.delete(display);
34
+ }
35
+ },
36
+ };
37
+ }
@@ -0,0 +1,18 @@
1
+ export interface UnmanagedReactRootFinding {
2
+ readonly file: string;
3
+ readonly line: number;
4
+ readonly api: 'createRoot' | 'hydrateRoot' | 'ReactDOM.render';
5
+ }
6
+ /**
7
+ * Find project-owned React DOM root creation. VGAI hosts React through
8
+ * manifest adapter roots, so any of these calls in game source creates an
9
+ * unmanaged second lifecycle and is a hard validation error — except in the
10
+ * project's own dom-root adapter (see {@link DOM_ROOT_ADAPTER_DIR}).
11
+ *
12
+ * The exemption lives HERE, in the detector, rather than in either caller:
13
+ * the editor's validate-on-change watcher and `vgai validate` both scan the
14
+ * same tree, and a rule that means two different things depending on who asks
15
+ * is worse than no rule.
16
+ */
17
+ export declare function detectUnmanagedReactRoots(source: string, file: string): UnmanagedReactRootFinding[];
18
+ //# sourceMappingURL=unmanaged-root-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unmanaged-root-detector.d.ts","sourceRoot":"","sources":["../../src/react/unmanaged-root-detector.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,YAAY,GAAG,aAAa,GAAG,iBAAiB,CAAC;CAChE;AAwBD;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,yBAAyB,EAAE,CAgD7B"}
@@ -0,0 +1,70 @@
1
+ function lineAt(source, offset) {
2
+ return source.slice(0, offset).split('\n').length;
3
+ }
4
+ /**
5
+ * The project's own `dom`-root adapter implementation, which is ALLOWED to
6
+ * create a React root because creating it is the whole job.
7
+ *
8
+ * The rule here is "a React root must come from a declared manifest root, not
9
+ * from game code mounting a second lifecycle beside it". That held trivially
10
+ * while the only `createRoot` in existence lived in the engine. It stopped
11
+ * holding when the `react-root` capability moved INTO the project (`vgai add
12
+ * react-root`): its `createRoot` is precisely what serves a declared `dom`
13
+ * root — the opposite of bypassing the manifest.
14
+ *
15
+ * Matched on the capability's DIRECTORY rather than a filename, so that
16
+ * editing the copied source — the entire point of the copied-source model —
17
+ * cannot re-arm the rule against itself. A Vue or Svelte replacement never
18
+ * trips it at all: only React DOM's own API is detected.
19
+ */
20
+ const DOM_ROOT_ADAPTER_DIR = /(^|[/\\])src[/\\]lib[/\\]react-root[/\\]/;
21
+ /**
22
+ * Find project-owned React DOM root creation. VGAI hosts React through
23
+ * manifest adapter roots, so any of these calls in game source creates an
24
+ * unmanaged second lifecycle and is a hard validation error — except in the
25
+ * project's own dom-root adapter (see {@link DOM_ROOT_ADAPTER_DIR}).
26
+ *
27
+ * The exemption lives HERE, in the detector, rather than in either caller:
28
+ * the editor's validate-on-change watcher and `vgai validate` both scan the
29
+ * same tree, and a rule that means two different things depending on who asks
30
+ * is worse than no rule.
31
+ */
32
+ export function detectUnmanagedReactRoots(source, file) {
33
+ if (DOM_ROOT_ADAPTER_DIR.test(file))
34
+ return [];
35
+ const findings = [];
36
+ const aliases = new Map();
37
+ for (const match of source.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]react-dom\/client['"]/g)) {
38
+ for (const member of (match[1] ?? '').split(',')) {
39
+ const parsed = member.trim().match(/^(createRoot|hydrateRoot)(?:\s+as\s+([\w$]+))?$/);
40
+ if (parsed)
41
+ aliases.set(parsed[2] ?? parsed[1], parsed[1]);
42
+ }
43
+ }
44
+ for (const [alias, api] of aliases) {
45
+ const call = new RegExp(`\\b${alias.replace(/[$]/g, '\\$&')}\\s*\\(`, 'g');
46
+ for (const match of source.matchAll(call)) {
47
+ findings.push({ file, line: lineAt(source, match.index ?? 0), api });
48
+ }
49
+ }
50
+ const namespaceNames = new Set();
51
+ for (const match of source.matchAll(/import\s+(?:\*\s+as\s+|)([\w$]+)\s+from\s*['"]react-dom(?:\/client)?['"]/g)) {
52
+ namespaceNames.add(match[1]);
53
+ }
54
+ namespaceNames.add('ReactDOM');
55
+ for (const name of namespaceNames) {
56
+ for (const api of ['createRoot', 'hydrateRoot', 'render']) {
57
+ const call = new RegExp(`\\b${name}\\.${api}\\s*\\(`, 'g');
58
+ for (const match of source.matchAll(call)) {
59
+ findings.push({
60
+ file,
61
+ line: lineAt(source, match.index ?? 0),
62
+ api: api === 'render' ? 'ReactDOM.render' : api,
63
+ });
64
+ }
65
+ }
66
+ }
67
+ return findings.filter((finding, index) => findings.findIndex((candidate) => candidate.file === finding.file &&
68
+ candidate.line === finding.line &&
69
+ candidate.api === finding.api) === index);
70
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * React hooks for data assets — the tool-hooks half, shipped with W4 (dock
3
+ * 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 roots 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 roots, 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,CAqDf"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * React hooks for data assets — the tool-hooks half, shipped with W4 (dock
3
+ * 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 roots 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 roots, 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, ' +
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
+ const transactionalWriter = globalThis.__vgaiHistoryWriteData;
78
+ if (transactionalWriter) {
79
+ await transactionalWriter(projectRelativePath, content);
80
+ return;
81
+ }
82
+ let res;
83
+ try {
84
+ res = await fetch('/__editor/data-file', {
85
+ method: 'POST',
86
+ headers: { 'Content-Type': 'application/json' },
87
+ body: JSON.stringify({ path: projectRelativePath, content }),
88
+ });
89
+ }
90
+ catch (err) {
91
+ throw new Error('writeData: could not reach the editor dev server (/__editor/data-file) — this helper is ' +
92
+ 'editor-tool plumbing and only works inside the running ' +
93
+ 'editor. Game code must not write data assets: they are immutable at runtime — ' +
94
+ `keep runtime state in your game's own store. (${String(err)})`);
95
+ }
96
+ if (!res.ok) {
97
+ const detail = await res.text().catch(() => '');
98
+ throw new Error(`writeData: the editor rejected the write to "${projectRelativePath}" ` +
99
+ `(HTTP ${res.status}${detail ? `: ${detail}` : ''}).`);
100
+ }
101
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * W3.1 — `useSelection()`, the third tool-hooks contract member (alongside
3
+ * `useData`/`writeData` from `use-data.ts`). Where those two hooks are about
4
+ * DATA ASSETS, this one is about the currently-selected ENTITY.
5
+ *
6
+ * Scope, v1:
7
+ * - INSPECTOR-placement tools only (`placement: 'inspector'`,
8
+ * `define-tool.ts`). `EditorSelectionProvider` is host plumbing —
9
+ * `InspectorToolSection` wraps every tool render in it; dock tools
10
+ * (`ToolHost`/`BottomPanel`) have no adapter/selection in scope and never
11
+ * get a provider. Calling `useSelection()` there throws a teaching error,
12
+ * contained by the tool's `ToolErrorBoundary` (the editor survives).
13
+ * - READ-only. Write through `InspectorProvider.set` / `writeData` (the
14
+ * existing paths), never by mutating what this hook returns. Per-entity
15
+ * WRITE-from-tool is deferred with `useTunable` (§10).
16
+ *
17
+ * Liveness — two existing paths reused, no new mechanism (§4's "reuse that
18
+ * path" rule):
19
+ * 1. Selection changes: `Inspector.tsx`'s own
20
+ * `useSyncExternalStore(store.subscribe, store.getSnapshot)` re-renders
21
+ * the panel, each matched `Section` gets the new `nodeId` prop, and
22
+ * `InspectorToolSection` re-creates this provider's context value.
23
+ * 2. Edits while the SAME node stays selected: `adapter.subscribe` fires —
24
+ * this hook keeps a local version counter bumped per notification
25
+ * (exactly `game-state.tsx`'s `useRootObservation` pattern: the adapter
26
+ * has no snapshot/version of its own, `subscribe` is fire-only) and
27
+ * recomputes.
28
+ */
29
+ import { type ReactNode } from 'react';
30
+ import type { AuthoringAdapter, EditorNode } from '../adapter';
31
+ /**
32
+ * EDITOR-side host plumbing: `InspectorToolSection` wraps a tool's rendered
33
+ * `<Component/>` in this, passing the adapter + nodeId it already holds.
34
+ * Project tools never render this themselves — it exists so `useSelection()`
35
+ * has something to read.
36
+ */
37
+ export declare function EditorSelectionProvider({ adapter, nodeId, children, }: {
38
+ adapter: AuthoringAdapter;
39
+ nodeId: string | null;
40
+ children: ReactNode;
41
+ }): import("react").JSX.Element;
42
+ export interface EditorSelection {
43
+ nodeId: string | null;
44
+ node: EditorNode | null;
45
+ }
46
+ /**
47
+ * The selected entity, live (read-only — see module doc).
48
+ *
49
+ * Throws outside an `EditorSelectionProvider` — inspector tools always render
50
+ * inside one; a dock tool or game-code caller does not, and the error names
51
+ * the fix rather than failing silently.
52
+ */
53
+ export declare function useSelection(): EditorSelection;
54
+ //# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;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,+BAGA;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,eAAe,CA8B9C"}
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * W3.1 — `useSelection()`, the third tool-hooks contract member (alongside
4
+ * `useData`/`writeData` from `use-data.ts`). Where those two hooks are about
5
+ * DATA ASSETS, this one is about the currently-selected ENTITY.
6
+ *
7
+ * Scope, v1:
8
+ * - INSPECTOR-placement tools only (`placement: 'inspector'`,
9
+ * `define-tool.ts`). `EditorSelectionProvider` is host plumbing —
10
+ * `InspectorToolSection` wraps every tool render in it; dock tools
11
+ * (`ToolHost`/`BottomPanel`) have no adapter/selection in scope and never
12
+ * get a provider. Calling `useSelection()` there throws a teaching error,
13
+ * contained by the tool's `ToolErrorBoundary` (the editor survives).
14
+ * - READ-only. Write through `InspectorProvider.set` / `writeData` (the
15
+ * existing paths), never by mutating what this hook returns. Per-entity
16
+ * WRITE-from-tool is deferred with `useTunable` (§10).
17
+ *
18
+ * Liveness — two existing paths reused, no new mechanism (§4's "reuse that
19
+ * path" rule):
20
+ * 1. Selection changes: `Inspector.tsx`'s own
21
+ * `useSyncExternalStore(store.subscribe, store.getSnapshot)` re-renders
22
+ * the panel, each matched `Section` gets the new `nodeId` prop, and
23
+ * `InspectorToolSection` re-creates this provider's context value.
24
+ * 2. Edits while the SAME node stays selected: `adapter.subscribe` fires —
25
+ * this hook keeps a local version counter bumped per notification
26
+ * (exactly `game-state.tsx`'s `useRootObservation` pattern: the adapter
27
+ * has no snapshot/version of its own, `subscribe` is fire-only) and
28
+ * recomputes.
29
+ */
30
+ import { createContext, useContext, useMemo, useRef, useSyncExternalStore, } from 'react';
31
+ const SelectionContext = createContext(null);
32
+ /**
33
+ * EDITOR-side host plumbing: `InspectorToolSection` wraps a tool's rendered
34
+ * `<Component/>` in this, passing the adapter + nodeId it already holds.
35
+ * Project tools never render this themselves — it exists so `useSelection()`
36
+ * has something to read.
37
+ */
38
+ export function EditorSelectionProvider({ adapter, nodeId, children, }) {
39
+ const value = useMemo(() => ({ adapter, nodeId }), [adapter, nodeId]);
40
+ return _jsx(SelectionContext.Provider, { value: value, children: children });
41
+ }
42
+ /**
43
+ * The selected entity, live (read-only — see module doc).
44
+ *
45
+ * Throws outside an `EditorSelectionProvider` — inspector tools always render
46
+ * inside one; a dock tool or game-code caller does not, and the error names
47
+ * the fix rather than failing silently.
48
+ */
49
+ export function useSelection() {
50
+ const ctx = useContext(SelectionContext);
51
+ if (!ctx) {
52
+ throw new Error('useSelection: no editor selection in context — this hook only works inside an editor-hosted ' +
53
+ "INSPECTOR tool (placement: 'inspector'). Dock tools and " +
54
+ 'game code have no selection to read.');
55
+ }
56
+ const { adapter, nodeId } = ctx;
57
+ // Local version counter bumped per adapter notification — the adapter has
58
+ // no snapshot/version of its own, `subscribe` is fire-only (same pattern
59
+ // as `useRootObservation`'s `versionRef`, game-state.tsx).
60
+ const versionRef = useRef(0);
61
+ const version = useSyncExternalStore((onStoreChange) => adapter.subscribe?.(() => {
62
+ versionRef.current++;
63
+ onStoreChange();
64
+ }) ?? (() => { }), () => versionRef.current);
65
+ return useMemo(() => {
66
+ const node = nodeId ? adapter.hierarchy.node(nodeId) : null;
67
+ return { nodeId, node };
68
+ // `version` has no value of its own — only its CHANGE matters, as the
69
+ // liveness signal described above.
70
+ }, [adapter, nodeId, version]);
71
+ }