@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,159 @@
1
+ // The S-D composer (design lineage Stage S-D). Builds ON `mount-manifest.ts`'s
2
+ // `mountManifestRoots` (never duplicates its per-kind dispatch/validation) to add
3
+ // the one thing that module deliberately does NOT have: a KIND REGISTRY, so a
4
+ // project doesn't have to hand-build an `entries` map inline in its own `main.ts`
5
+ // every time — it registers a `AdapterSurfaceFactory` per kind it uses (once, at
6
+ // module load) and then mounts with a single `mountGameFromManifest(manifest,
7
+ // host)` call.
8
+ //
9
+ // Engine-core react/pixi-free discipline (mirrors `mount-manifest.ts`'s own
10
+ // header comment, and the HARD INVARIANT this file was built under): this
11
+ // registry is pure mechanism — it holds whatever `AdapterSurfaceFactory` functions
12
+ // callers register, but it registers NONE itself. In particular there is no
13
+ // built-in 'canvas'/'react' registration here (that would require this file
14
+ // to value-import `pixi.js`/`react`/`react-dom`, exactly what `mount-manifest
15
+ // .ts` forbids); a project that has a canvas or react world MUST register a
16
+ // factory for that kind itself — see `defaultThreeAdapterFactory` below for why
17
+ // even the 'three' convenience export is a plain function the CALLER
18
+ // registers, not something this module wires up automatically.
19
+ import { mountManifestRoots, resolveManifest } from './mount-manifest';
20
+ import { assertExportedOrInEditor } from './unexported-game-trap';
21
+ // ---------------------------------------------------------------------------
22
+ // The registry
23
+ // ---------------------------------------------------------------------------
24
+ const registry = new Map();
25
+ /**
26
+ * Register a `AdapterSurfaceFactory` for a manifest world `kind` (`'three'` /
27
+ * `'canvas'` / `'react'`, or any future kind the manifest schema grows).
28
+ * Call once, at module load — mirrors `registerSceneUIRenderer()`'s existing
29
+ * "call before mounting" convention (`packages/editor/template/src/main.ts`).
30
+ *
31
+ * Throws on double-registration of the SAME kind: an accidental duplicate
32
+ * (two side-effect imports of the same registration module, or a copy-paste)
33
+ * is far more likely than an intentional runtime swap — a caller that really
34
+ * wants to replace a registration must `unregisterAdapter` first, making
35
+ * the intent explicit.
36
+ */
37
+ export function registerAdapter(kind, factory) {
38
+ if (registry.has(kind)) {
39
+ throw new Error(`registerAdapter: a factory is already registered for kind "${kind}" — ` +
40
+ 'call unregisterAdapter(kind) first if you intend to replace it (an accidental ' +
41
+ 'double-registration, e.g. two side-effect imports of the same registration module, ' +
42
+ 'is far more common than an intentional swap).');
43
+ }
44
+ registry.set(kind, factory);
45
+ }
46
+ /** Remove a kind's registration (e.g. before re-registering a replacement). */
47
+ export function unregisterAdapter(kind) {
48
+ registry.delete(kind);
49
+ }
50
+ /** Whether a factory is currently registered for `kind`. */
51
+ export function isAdapterRegistered(kind) {
52
+ return registry.has(kind);
53
+ }
54
+ /**
55
+ * Test-only escape hatch: clears every registration. Registrations are
56
+ * meant to be one-time, process-lifetime — production code should never
57
+ * call this; it exists so unit tests can start each case from a clean
58
+ * registry without cross-test leakage.
59
+ */
60
+ export function __clearAdapterSurfaceRegistryForTests() {
61
+ registry.clear();
62
+ }
63
+ /**
64
+ * A ready-to-register {@link AdapterSurfaceFactory} for `kind: 'three'` roots
65
+ * that follow the first-party entry-module convention (`export const
66
+ * adapter` and/or `export async function setup`). Threejs is safe to
67
+ * ship as an exported convenience (unlike canvas/react) because `three`/
68
+ * `SetupThreeRootAdapter` are already unconditional engine dependencies —
69
+ * see `mount-manifest.ts`'s header comment. Still never auto-registered:
70
+ * the registry itself stays zero-policy (see this file's header comment) —
71
+ * a caller opts in with `registerAdapter('three', defaultThreeAdapterFactory)`.
72
+ *
73
+ * Resolution mirrors `mount-manifest.ts`'s own `resolveThreeAdapter` branch
74
+ * order: an entry module's `adapter` export wins outright; else its `setup`
75
+ * export (wrapping via `fromSetup` happens inside `mountManifestRoots`
76
+ * itself — this factory just returns the `MountEntry` shape).
77
+ */
78
+ export const defaultThreeAdapterFactory = (world, ctx) => {
79
+ const mod = ctx.entryModule;
80
+ if (mod?.adapter)
81
+ return { kind: 'three', adapter: mod.adapter };
82
+ if (mod?.setup)
83
+ return { kind: 'three', setup: mod.setup };
84
+ if (world.entry !== undefined) {
85
+ throw new Error(`defaultThreeAdapterFactory: entry module "${world.entry}" for world "${world.id}" exports ` +
86
+ 'neither `adapter` nor `setup` — every first-party entry module exports at least one ' +
87
+ '(export one from the declared entry module).');
88
+ }
89
+ throw new Error(`defaultThreeAdapterFactory: world "${world.id}" declares no \`entry\` — a three root is ` +
90
+ 'authored as a TSX/R3F world module; point `entry` at it.');
91
+ };
92
+ /** True for the one shape `mountManifestRoots` can ALREADY mount with zero
93
+ * `entries[id]` at all.
94
+ *
95
+ * WO-8: nothing is self-sufficient any more. The one shape that was — a plain
96
+ * `default`-adapter, SCENE-driven, no-`entry` three world, which
97
+ * `resolveThreeAdapter`'s scene branch could mount from the manifest alone —
98
+ * died with the `.vscn.json` format. `load.ts` now rejects a three root with no
99
+ * `entry` outright, so every world needs a registered factory or an explicit
100
+ * entry, and this predicate is retained only to keep the loud-degrade error the
101
+ * documented outcome rather than a silent skip. */
102
+ function worldIsSelfSufficient(_world) {
103
+ return false;
104
+ }
105
+ /**
106
+ * Mount every world declared by a `vgai.project.json` manifest onto `host
107
+ * .container`, resolving each world's kind through the `registerAdapter`
108
+ * registry — falling back to an explicit `opts.entries[id]` where supplied,
109
+ * exactly like `mountManifestRoots` (so a caller can migrate one world at a
110
+ * time, or never touch the registry if it prefers hand-building entries).
111
+ *
112
+ * This is the "one call" scaffold/example projects mount through (E4
113
+ * acceptance): register whatever kinds you need once, then
114
+ * `await mountGameFromManifest(manifest, host)` — see
115
+ * `packages/editor/template/src/main.ts` for the worked single-world
116
+ * example and `examples/tri-world/src/main.ts` for a multi-kind one.
117
+ *
118
+ * Degrades loudly (carried into E4): a world whose kind has no registered
119
+ * factory AND no explicit entry, and which cannot self-mount from the
120
+ * manifest alone, throws a named `Error` identifying the world id + kind and
121
+ * BOTH ways to fix it (`registerAdapter` or `opts.entries`) — never a silent
122
+ * skip.
123
+ */
124
+ export async function mountGameFromManifest(manifestInput, host, opts = {}) {
125
+ // Owner invariant: an unexported game never mounts outside the editor. The
126
+ // editor mounts through its own resolver, so every caller of THIS function
127
+ // is a standalone page — and on a dev server, that page refuses to boot
128
+ // (see unexported-game-trap.ts for why this is a trap and not a rule).
129
+ assertExportedOrInEditor();
130
+ const manifest = resolveManifest(manifestInput);
131
+ const entries = { ...opts.entries };
132
+ for (const world of manifest.roots) {
133
+ if (entries[world.id] !== undefined)
134
+ continue; // explicit entry always wins
135
+ const factory = registry.get(world.adapter.identity);
136
+ if (factory) {
137
+ const entryModule = world.entry !== undefined && host.loadEntryModule
138
+ ? await host.loadEntryModule(world.entry)
139
+ : undefined;
140
+ entries[world.id] = await factory(world, { host, entryModule });
141
+ continue;
142
+ }
143
+ if (worldIsSelfSufficient(world))
144
+ continue; // mountManifestRoots needs nothing further
145
+ throw new Error(`mountGameFromManifest: root "${world.id}" (adapter "${world.adapter.identity}") has no registered ` +
146
+ `adapter factory and no explicit entries["${world.id}"] — call ` +
147
+ `registerAdapter("${world.adapter.identity}", factory) before mounting (see ` +
148
+ '`defaultThreeAdapterFactory` for a worked three example), or pass ' +
149
+ `opts.entries["${world.id}"] directly (see mount-manifest.ts's \`MountEntry\`).`);
150
+ }
151
+ return mountManifestRoots({
152
+ manifest,
153
+ container: host.container,
154
+ entries,
155
+ width: host.width,
156
+ height: host.height,
157
+ headless: host.headless,
158
+ });
159
+ }
@@ -0,0 +1,174 @@
1
+ import type { RootAdapter } from '../adapter/root-adapter';
2
+ import { type ResolvedGameManifest } from '../manifest/load';
3
+ import { type GameSession } from './create-runtime';
4
+ import { type DebugBridgeWindowTarget } from './debug-bridge';
5
+ import type { GameSetupFn, PlaytestContext } from './types';
6
+ /**
7
+ * A caller-supplied entry for a `kind: 'three'` world — two ways to satisfy
8
+ * it, matching the two shapes `resolveDefaultThreeAdapter` supports (an
9
+ * `entry`-module `setup`, or full caller control via a pre-built adapter):
10
+ *
11
+ * - `{ adapter }` — a fully-constructed {@link RootAdapter} (first-party or
12
+ * not). Always wins if present, regardless of the world's `entry` field —
13
+ * full caller control, including for a `{ module }`-adapter world
14
+ * (mountManifestRoots cannot import an arbitrary module path itself).
15
+ * - `{ setup }` — for an `entry`-declaring world: the project's own
16
+ * `entry` module's exported `setup` function (the same `GameSetupFn`
17
+ * shape `loadProjectScripts` extracts editor-side). Wrapped in a
18
+ * `SetupThreeRootAdapter` here, mirroring `resolveDefaultThreeAdapter`'s
19
+ * entry branch exactly.
20
+ *
21
+ * The former third shape, `{ componentRegistry }` for a `scene`-declaring
22
+ * world, went with the `.vscn.json` format in WO-8.
23
+ */
24
+ export interface ThreeMountEntry {
25
+ readonly kind: 'three';
26
+ readonly adapter?: RootAdapter | undefined;
27
+ readonly setup?: GameSetupFn | undefined;
28
+ }
29
+ /**
30
+ * A caller-supplied entry for a `kind: 'canvas'` world — ALWAYS a
31
+ * fully-constructed `RootAdapter<'canvas'>`, built by the caller's own module
32
+ * graph. There is no "mountManifestRoots builds it for
33
+ * you" branch here — doing so would require this file to value-import
34
+ * `pixi.js`, which it deliberately never does (see this file's header
35
+ * comment).
36
+ */
37
+ export interface PixiMountEntry {
38
+ readonly kind: 'canvas';
39
+ readonly adapter: RootAdapter<'canvas'>;
40
+ }
41
+ /**
42
+ * A caller-supplied entry for a `kind: 'dom'` world — ALWAYS a
43
+ * fully-constructed `RootAdapter<'dom'>` (the caller's own module graph
44
+ * calls `createRoot(host.container).render(<WorldProvider game={host.game}>
45
+ * <Entry/></WorldProvider>)` itself, exactly like `tri-world`'s original
46
+ * hand-mount did). A standalone build has ONE module graph, so there is no
47
+ * context-identity hazard the editor's per-project `WorldProvider`
48
+ * indirection exists to solve — the caller's own `<WorldProvider>` import
49
+ * is already the single canonical instance its `Entry` component's own
50
+ * hooks resolve against. This file never value-imports `react`/`react-dom`
51
+ * itself (see this file's header comment) — building the adapter is
52
+ * entirely the caller's job.
53
+ */
54
+ export interface ReactMountEntry {
55
+ readonly kind: 'dom';
56
+ readonly adapter: RootAdapter<'dom'>;
57
+ }
58
+ export type MountEntry = ThreeMountEntry | PixiMountEntry | ReactMountEntry;
59
+ export interface MountManifestOptions {
60
+ /**
61
+ * A raw (unparsed) manifest value OR an already-`loadGameManifest`d
62
+ * {@link ResolvedGameManifest}. `mountManifestRoots` NEVER fetches or
63
+ * fs-reads the manifest itself (stays environment-neutral — Node CLI,
64
+ * browser, or headless test alike): the caller owns getting the JSON off
65
+ * disk/network (`loadGameManifestFile` for Node, a plain `fetch()` for a
66
+ * browser build) and may pass either the raw parsed JSON (run through the
67
+ * pure `loadGameManifest` here) or its own already-resolved manifest.
68
+ */
69
+ readonly manifest: unknown;
70
+ /** The host creates one absolutely-positioned surface per world inside
71
+ * this element — see `RootsRuntimeConfig.container`. */
72
+ readonly container: HTMLElement;
73
+ /** Caller-supplied, already-imported entries keyed by manifest world id.
74
+ * Optional overall — a manifest whose every world is scene-driven
75
+ * three with no custom component registry needs none at all. */
76
+ readonly entries?: Readonly<Record<string, MountEntry>> | undefined;
77
+ /** Defaults to the manifest's own `resolution` field if declared, else
78
+ * the container's own size (`RootsRuntimeConfig`'s existing default). */
79
+ readonly width?: number | undefined;
80
+ readonly height?: number | undefined;
81
+ /** Forwarded to `createGameRuntime` — Node/headless test harnesses only,
82
+ * never a real host. See `RootsRuntimeConfig.headless`. */
83
+ readonly headless?: boolean | undefined;
84
+ /**
85
+ * Task 2.1: overrides for the `?vgai-debug=1` bridge `mountManifestRoots`
86
+ * installs at the tail of every mount — the engine-owned install point so
87
+ * every standalone project gets it with zero template edits. Omit both in
88
+ * a real host (defaults to `window.location`/ `window`); a headless test
89
+ * supplies fakes here instead of touching the global object, mirroring
90
+ * `render-control.ts`'s own `location`/`target` override precedent.
91
+ */
92
+ readonly debugBridge?: {
93
+ readonly url?: {
94
+ readonly search: string;
95
+ } | undefined;
96
+ readonly window?: DebugBridgeWindowTarget | undefined;
97
+ } | undefined;
98
+ /**
99
+ * D15 (T-D15.1) — the "explicit config" leg of the boot-time seed
100
+ * precedence (`manifest.determinism.defaultSeed` → `?vgai-seed=` → this),
101
+ * highest-precedence, for a caller that already knows the exact seed it
102
+ * wants (a future CLI `--seed`/probe fixture `seed` option, T-D15.6).
103
+ * Ignored entirely unless the manifest declares
104
+ * `determinism.seededRandom` — see `resolveDeterminismSeed` below.
105
+ */
106
+ readonly seed?: number | undefined;
107
+ /** Host identity for a private play run or coordinated Team Test. */
108
+ readonly playtest?: PlaytestContext | null | undefined;
109
+ /**
110
+ * The explicit per-mount answer to "are dev layers enabled" — forwarded
111
+ * verbatim to `devLayersEnabled` (`runtime/dev-layers.ts`), the ONE owner of
112
+ * that question. Omit it and the build decides (dev build ⇒ on; production
113
+ * build ⇒ off unless `VITE_VGAI_DEV_LAYERS=true`). A root declaring
114
+ * `dev: true` is simply not mounted when the answer is `false`, so a shipped
115
+ * build carries no dev GUI at all.
116
+ */
117
+ readonly devLayers?: boolean | undefined;
118
+ /** Where to read `?vgai-seed=` from for the boot-time seed reader. Same
119
+ * override precedent as `debugBridge.url` (defaults to `window.location`
120
+ * when a real `window` exists; a headless caller with no override gets no
121
+ * query-param seed, same as `maybeInstallDebugBridge`'s own url default). */
122
+ readonly seedUrl?: {
123
+ readonly search: string;
124
+ } | undefined;
125
+ }
126
+ /**
127
+ * D15 (T-D15.1) boot-time seed reader — resolves the root seed
128
+ * `mountManifestRoots` threads into `createGameRuntime` (and therefore
129
+ * `createGame`, BEFORE any world's `mount()`/`setup()` runs). Returns
130
+ * `undefined` when the manifest doesn't declare `determinism.seededRandom`
131
+ * at all — `?vgai-seed=` and `defaultSeed` are both ignored in that case
132
+ * (§2.a: "the mount path seeds ctx.random ... iff declared"; an undeclared
133
+ * project's `ctx.random` still exists, just boots from `createGame`'s own
134
+ * fixed default, unaffected by the manifest or the URL).
135
+ *
136
+ * Precedence when declared (highest wins): `explicitSeed` (a caller-supplied
137
+ * config value) → `?vgai-seed=<int>` on `url` → `manifest.determinism
138
+ * .defaultSeed`.
139
+ */
140
+ export declare function resolveDeterminismSeed(opts: {
141
+ readonly determinism: ResolvedGameManifest['determinism'];
142
+ readonly explicitSeed: number | undefined;
143
+ readonly url: {
144
+ readonly search: string;
145
+ } | undefined;
146
+ }): number | undefined;
147
+ export type MountedManifestSession = GameSession;
148
+ /**
149
+ * Exported (E4) so `mount-game.ts`'s `mountGameFromManifest` composer can
150
+ * share this exact raw-vs-resolved detection instead of re-implementing it
151
+ * — the two modules must always agree on what "already resolved" means.
152
+ */
153
+ export declare function resolveManifest(raw: unknown): ResolvedGameManifest;
154
+ /**
155
+ * Mount every world declared by a `vgai.project.json` manifest onto `container`,
156
+ * standalone — no editor, no dev server. The generalization of
157
+ * `examples/tri-world/src/main.ts`'s hand-built `RootMountSpec[]` (D-Z2). Reuses
158
+ * the pure `loadGameManifest` + `createGameRuntime({ roots })` and mirrors
159
+ * `resolveAllRoots`'s per-kind dispatch — but every entry the manifest needs
160
+ * beyond what a `default`- adapter scene/entry can express on its own comes from
161
+ * the caller's OWN already-imported module graph (`opts.entries`), never a
162
+ * dynamic import this file performs itself.
163
+ *
164
+ * Degrades loudly: a missing entry, a kind/shape mismatch, a `{ module }`/`{
165
+ * ingest }` adapter with no caller-supplied adapter, or an empty manifest all
166
+ * throw a named `Error` identifying the world id, its kind, and what was
167
+ * expected — never a silent skip or a partially-mounted session.
168
+ *
169
+ * The ONE root that IS skipped silently is a `dev: true` dev layer when dev
170
+ * layers are disabled (`devLayersEnabled`) — that skip is the feature: it is
171
+ * what makes a dev GUI safe to leave in the game.
172
+ */
173
+ export declare function mountManifestRoots(opts: MountManifestOptions): Promise<GameSession>;
174
+ //# sourceMappingURL=mount-manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount-manifest.d.ts","sourceRoot":"","sources":["../../src/runtime/mount-manifest.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAI3D,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAqB,KAAK,WAAW,EAAsB,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,KAAK,uBAAuB,EAA2B,MAAM,gBAAgB,CAAC;AAKvF,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAM5D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAC1C;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;CACzC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;CACtC;AAED,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,cAAc,GAAG,eAAe,CAAC;AAM5E,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;OAQG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B;6DACyD;IACzD,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;IAChC;;qEAEiE;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAAG,SAAS,CAAC;IACpE;8EAC0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC;gEAC4D;IAC5D,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACxC;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,CAAC,EACjB;QACE,QAAQ,CAAC,GAAG,CAAC,EAAE;YAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;SAAE,GAAG,SAAS,CAAC;QACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,uBAAuB,GAAG,SAAS,CAAC;KACvD,GACD,SAAS,CAAC;IACd;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;IACvD;;;;;;;OAOG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzC;;;kFAG8E;IAC9E,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CAC5D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC,aAAa,CAAC,CAAC;IAC1D,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,GAAG,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CACvD,GAAG,MAAM,GAAG,SAAS,CAIrB;AAkBD,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC;AA8BjD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,CAGlE;AA8HD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,CAkGzF"}
@@ -0,0 +1,304 @@
1
+ // The standalone manifest-mount helper: an ENGINE-side generalization of
2
+ // `examples/tri-world/src/main.ts`'s hand-built `RootMountSpec[]`.
3
+ //
4
+ // `resolveAllRoots`/`resolveRootAdapter` (`packages/editor/src/
5
+ // adapter-resolver.ts`) already do this translation for the EDITOR, but they
6
+ // are Vite-coupled by construction (`/@fs/` dynamic imports of project files
7
+ // through the dev server, §0.1/§0.5 of the design doc) — unusable from a
8
+ // plain static build. This module mirrors their per-kind dispatch
9
+ // (`default-three`/`default-pixi`/`default-react`, `{ module }`, `{ ingest }`)
10
+ // but never imports a project file itself: the caller's OWN bundler already
11
+ // resolved whatever module graph the manifest's roots need, and hands the
12
+ // already-built pieces in via `entries` (keyed by world id) — no `/@fs/`, no
13
+ // dev server, no editor import.
14
+ //
15
+ // Engine-core react/pixi-free discipline (§0.6, mirrored from
16
+ // `create-runtime.ts`'s own documented rule for its `ReactRootAdapter`
17
+ // type-only import): this file never value-imports
18
+ // `pixi.js`, `react`, or `react-dom` — a
19
+ // canvas or react world's adapter is ALWAYS supplied already-constructed via
20
+ // `entries[id].adapter` (the caller's own module graph built it). Threejs is
21
+ // different: `three`/
22
+ // `SetupThreeRootAdapter` are already unconditional dependencies of every
23
+ // caller of `createGameRuntime`'s legacy path (this same file's sibling,
24
+ // immediately below in this directory), so wrapping a `setup` with
25
+ // `fromSetup` here adds no NEW bundle weight — only pixi/react are avoided.
26
+ import { assertNever } from '../adapter/adapter-surface';
27
+ // Value-imported from the implementer's OWN path, not the type-only
28
+ // `../adapter` barrel (P-6).
29
+ import { fromSetup } from '../adapter/setup-three-root-adapter';
30
+ import { loadGameManifest, } from '../manifest/load';
31
+ import { createGameRuntime } from './create-runtime';
32
+ import { maybeInstallDebugBridge } from './debug-bridge';
33
+ import { getDebugRegistry } from './debug-registry';
34
+ import { devLayersEnabled } from './dev-layers';
35
+ import { getGameplayRngTrapControl } from './gameplay-rng-trap';
36
+ import { RENDER_SEED_QUERY_PARAM } from './render-seed';
37
+ /**
38
+ * D15 (T-D15.1) boot-time seed reader — resolves the root seed
39
+ * `mountManifestRoots` threads into `createGameRuntime` (and therefore
40
+ * `createGame`, BEFORE any world's `mount()`/`setup()` runs). Returns
41
+ * `undefined` when the manifest doesn't declare `determinism.seededRandom`
42
+ * at all — `?vgai-seed=` and `defaultSeed` are both ignored in that case
43
+ * (§2.a: "the mount path seeds ctx.random ... iff declared"; an undeclared
44
+ * project's `ctx.random` still exists, just boots from `createGame`'s own
45
+ * fixed default, unaffected by the manifest or the URL).
46
+ *
47
+ * Precedence when declared (highest wins): `explicitSeed` (a caller-supplied
48
+ * config value) → `?vgai-seed=<int>` on `url` → `manifest.determinism
49
+ * .defaultSeed`.
50
+ */
51
+ export function resolveDeterminismSeed(opts) {
52
+ if (opts.determinism?.seededRandom !== true)
53
+ return undefined;
54
+ const querySeed = opts.url ? readSeedQueryParam(opts.url) : undefined;
55
+ return opts.explicitSeed ?? querySeed ?? opts.determinism.defaultSeed;
56
+ }
57
+ function readSeedQueryParam(url) {
58
+ const raw = new URLSearchParams(url.search).get(RENDER_SEED_QUERY_PARAM);
59
+ if (raw === null || raw === '')
60
+ return undefined;
61
+ const parsed = Number(raw);
62
+ return Number.isFinite(parsed) ? parsed : undefined;
63
+ }
64
+ function hasRealWindow() {
65
+ return typeof window !== 'undefined';
66
+ }
67
+ // ---------------------------------------------------------------------------
68
+ // Raw-vs-resolved manifest detection
69
+ // ---------------------------------------------------------------------------
70
+ /**
71
+ * Distinguish an already-`loadGameManifest`d {@link ResolvedGameManifest}
72
+ * from a raw (pre-Zod-parse) manifest value. The two shapes differ in
73
+ * exactly one load-bearing way for this check: a `ResolvedAdapterRoot.adapter`
74
+ * is `{ type: 'default' | 'module' | 'ingest', identity, ... }`, while a raw
75
+ * `AdapterRoot.adapter` is the literal string `'default'` or a bare `{module}`/
76
+ * `{ingest}` object with NO `type`/`identity` fields (`schema.ts`'s
77
+ * `RootAdapterSchema`). An empty `roots` array is treated as "not resolved"
78
+ * (falls through to `loadGameManifest`, whose own Zod validation reports the
79
+ * empty-array error, if any, more precisely than a guess here could).
80
+ */
81
+ function looksAlreadyResolved(value) {
82
+ if (typeof value !== 'object' || value === null)
83
+ return false;
84
+ const roots = value.roots;
85
+ if (!Array.isArray(roots) || roots.length === 0)
86
+ return false;
87
+ return roots.every((world) => {
88
+ if (typeof world !== 'object' || world === null)
89
+ return false;
90
+ const adapter = world.adapter;
91
+ if (typeof adapter !== 'object' || adapter === null)
92
+ return false;
93
+ const type = adapter.type;
94
+ return type === 'builtin' || type === 'module' || type === 'ingest';
95
+ });
96
+ }
97
+ /**
98
+ * Exported (E4) so `mount-game.ts`'s `mountGameFromManifest` composer can
99
+ * share this exact raw-vs-resolved detection instead of re-implementing it
100
+ * — the two modules must always agree on what "already resolved" means.
101
+ */
102
+ export function resolveManifest(raw) {
103
+ if (looksAlreadyResolved(raw))
104
+ return raw;
105
+ return loadGameManifest(raw);
106
+ }
107
+ // ---------------------------------------------------------------------------
108
+ // Per-kind entry -> adapter resolution (mirrors `resolveRootAdapter`'s
109
+ // per-identity dispatch, `packages/editor/src/adapter-resolver.ts`)
110
+ // ---------------------------------------------------------------------------
111
+ function resolveThreeAdapter(world, entry) {
112
+ if (entry?.adapter)
113
+ return entry.adapter;
114
+ if (world.adapter.type === 'module') {
115
+ throw new Error(`mountManifestRoots: world "${world.id}" (three) declares a { module } adapter ` +
116
+ `("${world.adapter.module}") — mountManifestRoots never imports an arbitrary module ` +
117
+ 'path itself (no `/@fs/`, no dev server). Import the module yourself and supply the ' +
118
+ `constructed adapter via entries["${world.id}"] = { kind: 'three', adapter }.`);
119
+ }
120
+ if (world.adapter.type === 'ingest') {
121
+ throw new Error(`mountManifestRoots: world "${world.id}" (three) declares an { ingest } adapter — ` +
122
+ "ingest roots require the editor's dev-server-backed mount machinery (an EditorStore " +
123
+ "plus iframe/DOM capture, see adapter-resolver.ts's resolveIngestThreeAdapter) and are " +
124
+ 'not supported by mountManifestRoots (no porting aids, no hosted ingest routes).');
125
+ }
126
+ // type === 'default'
127
+ if (world.entry !== undefined) {
128
+ if (!entry?.setup) {
129
+ throw new Error(`mountManifestRoots: world "${world.id}" (three) declares \`entry\` "${world.entry}" ` +
130
+ `— supply entries["${world.id}"] = { kind: 'three', setup } (the entry module's ` +
131
+ "exported `setup` function) or { kind: 'three', adapter } for full control. Got " +
132
+ `${entry === undefined ? 'no entry at all' : 'an entry with neither `setup` nor `adapter`'}.`);
133
+ }
134
+ return fromSetup(world.id, entry.setup);
135
+ }
136
+ // Unreachable in practice: `load.ts`'s `checkAdapterSceneEntryRules` requires
137
+ // `entry` for every 'default' THREE adapter world at manifest-load time (and
138
+ // rejects `scene` outright — the `.vscn.json` format was removed in WO-8).
139
+ throw new Error(`mountManifestRoots: world "${world.id}" is default-three with no \`entry\` — this ` +
140
+ 'should have been rejected by manifest validation.');
141
+ }
142
+ function resolvePixiAdapter(world, entry) {
143
+ if (entry?.adapter)
144
+ return entry.adapter;
145
+ throw new Error(`mountManifestRoots: world "${world.id}" (canvas) has no entries["${world.id}"] — a canvas ` +
146
+ 'world always needs a caller-supplied, already-constructed adapter ' +
147
+ `(entries["${world.id}"] = { kind: 'canvas', adapter }, constructed from your own ` +
148
+ 'already-imported pixi module graph) — mountManifestRoots never ' +
149
+ "value-imports pixi.js (mirrors create-runtime.ts's own pixi-free-core discipline).");
150
+ }
151
+ function resolveReactAdapter(world, entry) {
152
+ if (entry?.adapter)
153
+ return entry.adapter;
154
+ throw new Error(`mountManifestRoots: world "${world.id}" (react) has no entries["${world.id}"] — a react ` +
155
+ "world always needs a caller-supplied, already-constructed `RootAdapter<'dom'>` " +
156
+ `(entries["${world.id}"] = { kind: 'dom', adapter }, mounting via your own already-imported ` +
157
+ 'react-dom `createRoot` + your own `<WorldProvider>`) — mountManifestRoots never ' +
158
+ "value-imports react/react-dom (mirrors create-runtime.ts's own react-free-core discipline).");
159
+ }
160
+ function buildRootMountSpec(world, entry) {
161
+ if (entry !== undefined && entry.kind !== world.surface) {
162
+ throw new Error(`mountManifestRoots: entries["${world.id}"] declares kind "${entry.kind}" but the ` +
163
+ `manifest's root "${world.id}" uses surface "${world.surface}" — fix the entries key (or the ` +
164
+ 'manifest) so the two agree.');
165
+ }
166
+ const base = {
167
+ id: world.id,
168
+ zOrder: world.zOrder,
169
+ pausable: world.pausable,
170
+ dev: world.dev,
171
+ loop: world.loop,
172
+ };
173
+ // `entry`'s `kind` is guaranteed to agree with `world.kind` past the guard
174
+ // above (or `entry` is `undefined`) — TS can't narrow a `Record` lookup
175
+ // through that runtime check, so each branch casts to its own entry shape;
176
+ // the actual safety comes from the mismatch guard, not from the cast.
177
+ if (world.surface === 'three') {
178
+ const threeEntry = entry;
179
+ return { ...base, kind: 'three', adapter: resolveThreeAdapter(world, threeEntry) };
180
+ }
181
+ if (world.surface === 'canvas') {
182
+ const pixiEntry = entry;
183
+ return { ...base, kind: 'canvas', adapter: resolvePixiAdapter(world, pixiEntry) };
184
+ }
185
+ if (world.surface === 'dom') {
186
+ const reactEntry = entry;
187
+ return { ...base, kind: 'dom', adapter: resolveReactAdapter(world, reactEntry) };
188
+ }
189
+ // Exhaustiveness guard (§7.4-2, same idiom as `resolveAllRoots`'s own
190
+ // dispatch loop): `world.kind` is the closed `AdapterRoot['kind']` union
191
+ // (`z.enum(['three','canvas','react'])`), so a hypothetical 4th kind
192
+ // must fail to compile here, not silently fall through.
193
+ return assertNever(world.surface, 'mountManifestRoots');
194
+ }
195
+ // ---------------------------------------------------------------------------
196
+ // Entry point
197
+ // ---------------------------------------------------------------------------
198
+ /**
199
+ * Mount every world declared by a `vgai.project.json` manifest onto `container`,
200
+ * standalone — no editor, no dev server. The generalization of
201
+ * `examples/tri-world/src/main.ts`'s hand-built `RootMountSpec[]` (D-Z2). Reuses
202
+ * the pure `loadGameManifest` + `createGameRuntime({ roots })` and mirrors
203
+ * `resolveAllRoots`'s per-kind dispatch — but every entry the manifest needs
204
+ * beyond what a `default`- adapter scene/entry can express on its own comes from
205
+ * the caller's OWN already-imported module graph (`opts.entries`), never a
206
+ * dynamic import this file performs itself.
207
+ *
208
+ * Degrades loudly: a missing entry, a kind/shape mismatch, a `{ module }`/`{
209
+ * ingest }` adapter with no caller-supplied adapter, or an empty manifest all
210
+ * throw a named `Error` identifying the world id, its kind, and what was
211
+ * expected — never a silent skip or a partially-mounted session.
212
+ *
213
+ * The ONE root that IS skipped silently is a `dev: true` dev layer when dev
214
+ * layers are disabled (`devLayersEnabled`) — that skip is the feature: it is
215
+ * what makes a dev GUI safe to leave in the game.
216
+ */
217
+ export async function mountManifestRoots(opts) {
218
+ const manifest = resolveManifest(opts.manifest);
219
+ if (manifest.roots.length === 0) {
220
+ throw new Error('mountManifestRoots: manifest declares no roots — nothing to mount.');
221
+ }
222
+ const entries = opts.entries ?? {};
223
+ // The SHIP GATE. A `dev: true` root is the game's own dev GUI; it mounts
224
+ // only when dev layers are enabled, so a production build carries no dev
225
+ // GUI. The answer comes from `devLayersEnabled` and nowhere else — see that
226
+ // function's header for why there is exactly one owner. Dropping the root
227
+ // here (rather than mounting it hidden) is deliberate: nothing of the dev
228
+ // layer is constructed, so its entry module's cost and its DOM never exist
229
+ // in a shipped build.
230
+ const devEnabled = devLayersEnabled(opts.devLayers);
231
+ const mountable = devEnabled ? manifest.roots : manifest.roots.filter((world) => !world.dev);
232
+ if (mountable.length === 0) {
233
+ throw new Error('mountManifestRoots: every root in this manifest is a dev layer (`dev: true`) and dev ' +
234
+ 'layers are disabled for this build — there is no game to mount.');
235
+ }
236
+ const roots = mountable.map((world) => buildRootMountSpec(world, entries[world.id]));
237
+ // D15 (T-D15.1) — resolved BEFORE `createGameRuntime` (which constructs the
238
+ // Game, and therefore `ctx.random`, before any world's `mount()`/`setup()`
239
+ // runs — see `createGame`'s own doc comment): the seed must be baked in at
240
+ // construction time, not patched in afterward, or a world's `setup()`
241
+ // would already have drawn from the wrong (default) sequence before any
242
+ // post-hoc reseed could take effect.
243
+ const seedUrl = opts.seedUrl ?? (hasRealWindow() ? window.location : undefined);
244
+ const resolvedSeed = resolveDeterminismSeed({
245
+ determinism: manifest.determinism,
246
+ explicitSeed: opts.seed,
247
+ url: seedUrl,
248
+ });
249
+ const session = await createGameRuntime({
250
+ container: opts.container,
251
+ roots,
252
+ width: opts.width ?? manifest.resolution?.width,
253
+ height: opts.height ?? manifest.resolution?.height,
254
+ headless: opts.headless,
255
+ seed: resolvedSeed,
256
+ playtest: opts.playtest,
257
+ });
258
+ // D15 (T-D15.3) — the dev-mode Math.random phase trap: only while the
259
+ // manifest declares the contract AND this is a dev build (mirrors D18's
260
+ // debug-bridge gate — `import.meta.env.DEV`, never a production build
261
+ // unless something ELSE explicitly opts in, which this trap has no
262
+ // opt-in for at all: it is dev-only, full stop). `getGameplayRngTrapControl`
263
+ // returns `null` only for a bare `Game`-shaped test stand-in predating
264
+ // T7.1 — real mounts always have one (same precedent as `getDebugRegistry`
265
+ // just below).
266
+ if (manifest.determinism?.seededRandom === true && Boolean(import.meta.env?.DEV)) {
267
+ getGameplayRngTrapControl(session.game)?.setEnabled(true);
268
+ }
269
+ // Task 2.1 — install the `?vgai-debug=1` bridge at the TAIL of every
270
+ // manifest mount (engine-owned, so a standalone project gets it with zero
271
+ // template edits). `getDebugRegistry` returns `null` only for a bare
272
+ // `Game`-shaped test stand-in predating T7.1 — real mounts always have one.
273
+ const debugRegistry = getDebugRegistry(session.game);
274
+ if (debugRegistry) {
275
+ // Defect 3 fix: `setRoomDeclared` (the locus-required rule — a project
276
+ // with a Colyseus room must declare `locus: 'client' | 'server'` on every
277
+ // debug command) was never actually called from a real mount path — this
278
+ // is that wiring. `manifest.server` (`ResolvedGameManifest.server`,
279
+ // `manifest/load.ts`) is `{ room, module } | undefined`; its mere presence
280
+ // is the "this project declares a room" signal, independent of
281
+ // whether/when the game actually joins it.
282
+ if (manifest.server) {
283
+ debugRegistry.setRoomDeclared(true);
284
+ }
285
+ // Defect 5 fix: `maybeInstallDebugBridge` adds `window` listeners and
286
+ // publishes `window.__vgai` with no way to undo either — wire its
287
+ // `uninstall()` into THIS session's own `stop()` so a caller that tears
288
+ // this mount down doesn't leave the bridge (and its listeners) live.
289
+ const bridgeHandle = maybeInstallDebugBridge({
290
+ registry: debugRegistry,
291
+ manifest,
292
+ url: opts.debugBridge?.url,
293
+ window: opts.debugBridge?.window,
294
+ });
295
+ if (bridgeHandle) {
296
+ const stopSession = session.stop;
297
+ session.stop = () => {
298
+ bridgeHandle.uninstall();
299
+ stopSession();
300
+ };
301
+ }
302
+ }
303
+ return session;
304
+ }