@vgai/engine 0.5.5 → 0.5.6

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,47 @@
1
+ /**
2
+ * The dev-mode `Math.random` phase trap (enforcer 3, T-D15.3). A project that
3
+ * declares `determinism.seededRandom` is claiming ALL gameplay RNG flows
4
+ * through `ctx.random` — the burn-down scan (`test/gameplay-rng-ban.test.ts`)
5
+ * catches raw `Math.random()`/`Date.now()`/`performance.now()` call sites it
6
+ * can SEE in source; this trap catches what the scan structurally can't: a
7
+ * TRANSITIVE draw made by a third-party library the game calls into during a
8
+ * gameplay tick.
9
+ *
10
+ * Scope is exactly one fixed-step frame (`GameInternal.runFrame`'s whole
11
+ * body — see `game.ts`'s `runFrameImpl`, which brackets its entire call with
12
+ * `profiler.beginFrame()`/`endFrame()`; this trap's `enable()`/`disable()`
13
+ * are called at those exact two points) — code that runs OUTSIDE a frame
14
+ * (module-load-time library init, an unrelated timer callback) never trips
15
+ * it. Warn-once PER CALL SITE (not once ever, not once per call) — a
16
+ * third-party library that draws from several different internal call sites
17
+ * gets one warning per site, so nothing is silently swallowed after the
18
+ * first hit, but a hot per-frame draw from the SAME site doesn't spam.
19
+ * Never throws: a cosmetic third-party draw is legal, just outside the
20
+ * contract (the design doc is explicit about this — "warn, never throw").
21
+ */
22
+ export interface GameplayRngTrap {
23
+ /** Wrap `Math.random` for the duration of one frame — call at frame start. */
24
+ enable(): void;
25
+ /** Restore whatever `Math.random` was immediately before `enable()` — call
26
+ * at frame end. A no-op if something else already replaced `Math.random`
27
+ * out from under this trap between `enable()` and `disable()` (defensive;
28
+ * should not happen in practice). */
29
+ disable(): void;
30
+ }
31
+ /**
32
+ * Construct a fresh trap. `warn` defaults to `console.warn`; tests (and any
33
+ * caller that wants to assert on the message) can override it to a plain
34
+ * capturing function instead of spying on the global console.
35
+ */
36
+ export declare function createGameplayRngTrap(warn?: (message: string) => void): GameplayRngTrap;
37
+ export interface GameplayRngTrapControl {
38
+ setEnabled(enabled: boolean): void;
39
+ readonly enabled: boolean;
40
+ }
41
+ /** Called once by `createGame`, alongside `registerSeededRandom`/
42
+ * `registerDebugRegistry`. */
43
+ export declare function registerGameplayRngTrapControl(owner: object, control: GameplayRngTrapControl): void;
44
+ /** `null` for an owner built without one — same absence precedent as
45
+ * `getSeededRandom`/`getDebugRegistry`. */
46
+ export declare function getGameplayRngTrapControl(owner: object): GameplayRngTrapControl | null;
47
+ //# sourceMappingURL=gameplay-rng-trap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gameplay-rng-trap.d.ts","sourceRoot":"","sources":["../../src/runtime/gameplay-rng-trap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,MAAM,IAAI,IAAI,CAAC;IACf;;;0CAGsC;IACtC,OAAO,IAAI,IAAI,CAAC;CACjB;AAcD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAG1B,GACA,eAAe,CA6CjB;AAaD,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAID;+BAC+B;AAC/B,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,sBAAsB,GAC9B,IAAI,CAEN;AAED;4CAC4C;AAC5C,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,sBAAsB,GAAG,IAAI,CAEtF"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * The dev-mode `Math.random` phase trap (enforcer 3, T-D15.3). A project that
3
+ * declares `determinism.seededRandom` is claiming ALL gameplay RNG flows
4
+ * through `ctx.random` — the burn-down scan (`test/gameplay-rng-ban.test.ts`)
5
+ * catches raw `Math.random()`/`Date.now()`/`performance.now()` call sites it
6
+ * can SEE in source; this trap catches what the scan structurally can't: a
7
+ * TRANSITIVE draw made by a third-party library the game calls into during a
8
+ * gameplay tick.
9
+ *
10
+ * Scope is exactly one fixed-step frame (`GameInternal.runFrame`'s whole
11
+ * body — see `game.ts`'s `runFrameImpl`, which brackets its entire call with
12
+ * `profiler.beginFrame()`/`endFrame()`; this trap's `enable()`/`disable()`
13
+ * are called at those exact two points) — code that runs OUTSIDE a frame
14
+ * (module-load-time library init, an unrelated timer callback) never trips
15
+ * it. Warn-once PER CALL SITE (not once ever, not once per call) — a
16
+ * third-party library that draws from several different internal call sites
17
+ * gets one warning per site, so nothing is silently swallowed after the
18
+ * first hit, but a hot per-frame draw from the SAME site doesn't spam.
19
+ * Never throws: a cosmetic third-party draw is legal, just outside the
20
+ * contract (the design doc is explicit about this — "warn, never throw").
21
+ */
22
+ /** Pull a single representative "call site" line out of a captured stack —
23
+ * the warn-once dedupe key. `stack[0]` is the `Error:` header line,
24
+ * `stack[1]` is this trap's OWN wrapper frame — the caller's frame is the
25
+ * next one down. Falls back to a fixed string when `Error().stack` isn't
26
+ * populated (some non-V8 engines) so the trap still functions, just with
27
+ * coarser (single-bucket) deduping. */
28
+ function callSiteFromStack(stack) {
29
+ if (!stack)
30
+ return '<unknown call site — no stack captured>';
31
+ const lines = stack.split('\n');
32
+ return (lines[2] ?? lines[1] ?? lines[0] ?? '<unknown call site>').trim();
33
+ }
34
+ /**
35
+ * Construct a fresh trap. `warn` defaults to `console.warn`; tests (and any
36
+ * caller that wants to assert on the message) can override it to a plain
37
+ * capturing function instead of spying on the global console.
38
+ */
39
+ export function createGameplayRngTrap(warn = (message) => {
40
+ // biome-ignore lint/suspicious/noConsole: the trap's entire purpose is a structured, greppable dev-mode warning (D15) — this IS the console sink, not incidental debug output.
41
+ console.warn(message);
42
+ }) {
43
+ const warnedSites = new Set();
44
+ let previous;
45
+ function trapped() {
46
+ const site = callSiteFromStack(new Error().stack);
47
+ if (!warnedSites.has(site)) {
48
+ warnedSites.add(site);
49
+ warn(
50
+ // Deliberately NOT the literal substring "Math.random(" (the phrasing
51
+ // below reads fine without it) — this engine repo's OWN gameplay-rng-
52
+ // ban scan (`test/gameplay-rng-ban.test.ts`) greps engine src/ for
53
+ // that exact pattern, and a plain-text mention of the call inside
54
+ // this warning STRING would otherwise false-positive against itself.
55
+ '[determinism] the global Math.random generator was drawn from during a gameplay frame ' +
56
+ 'while this project declares determinism.seededRandom — use ctx.random() / ' +
57
+ `ctx.random.stream(name) instead. Call site:\n${site}`);
58
+ }
59
+ // `previous` is always set by the time `trapped` can run — `enable()`
60
+ // assigns it before installing `trapped` as `Math.random`, and nothing
61
+ // else can invoke this function reference.
62
+ return previous();
63
+ }
64
+ return {
65
+ enable() {
66
+ previous = Math.random;
67
+ Math.random = trapped;
68
+ },
69
+ disable() {
70
+ if (Math.random === trapped && previous) {
71
+ Math.random = previous;
72
+ previous = undefined;
73
+ }
74
+ // else: something else replaced `Math.random` out from under this trap
75
+ // between `enable()` and `disable()` — leave `previous` untouched.
76
+ // `trapped` may still be reachable via a chain built on top of it (e.g.
77
+ // a third party did `const wrapped = Math.random; Math.random = () =>
78
+ // { ...; return wrapped(); }` while `wrapped` was `trapped`) — nulling
79
+ // `previous` here would make that still-chained call to `trapped()`
80
+ // throw (`previous!()` on undefined) instead of quietly forwarding to
81
+ // the real original generator.
82
+ },
83
+ };
84
+ }
85
+ const controlByOwner = new WeakMap();
86
+ /** Called once by `createGame`, alongside `registerSeededRandom`/
87
+ * `registerDebugRegistry`. */
88
+ export function registerGameplayRngTrapControl(owner, control) {
89
+ controlByOwner.set(owner, control);
90
+ }
91
+ /** `null` for an owner built without one — same absence precedent as
92
+ * `getSeededRandom`/`getDebugRegistry`. */
93
+ export function getGameplayRngTrapControl(owner) {
94
+ return controlByOwner.get(owner) ?? null;
95
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The delegating input router (D5 §2a) —
3
+ * `createGameRuntime`'s roots path (T6.1 slice 1) uses this to route
4
+ * pointer input across N stacked world canvases with exactly ONE root
5
+ * listener.
6
+ *
7
+ * Split into two layers so the decision logic is unit-testable with plain
8
+ * fake roots — no real DOM/canvas needed:
9
+ *
10
+ * - `stackOrder` / `resolveClaimingRoot`: pure functions over
11
+ * `{id, zOrder, hitTest?}` — "who claims this point".
12
+ * - `applyPointerEventsStacking` / `createInputRouter`: the DOM wiring —
13
+ * sets `pointer-events` CSS per D5 §2a and forwards a claimed event to
14
+ * the claiming world's own canvas.
15
+ *
16
+ * Per-event fall-through (D5 §2b — the sanctioned mechanism for an
17
+ * authoring surface's own interior drag affordances, e.g. a canvas
18
+ * editor's gizmos) is explicitly NOT this file's job — it stays inside
19
+ * whatever authoring surface needs it.
20
+ */
21
+ /** The pure decision inputs — no DOM. */
22
+ export interface ClaimEntry {
23
+ readonly id: string;
24
+ readonly zOrder: number;
25
+ /**
26
+ * Optional claim predicate over a point RELATIVE TO THE CONTAINER. Absent
27
+ * means: "this world claims only if it is the bottom (lowest zOrder)
28
+ * world" — D5 §2a's stated default ("transparent upper roots do not
29
+ * claim, the bottom world claims everything").
30
+ */
31
+ readonly hitTest?: ((x: number, y: number) => boolean) | undefined;
32
+ }
33
+ /** The DOM-wiring inputs — one real canvas per world. */
34
+ export interface RouterAdapterRoot extends ClaimEntry {
35
+ readonly canvas: HTMLCanvasElement;
36
+ }
37
+ /**
38
+ * Bottom-to-top paint order: ascending `zOrder`, ties -> original array
39
+ * order — the SAME rule `manifest/load.ts`'s `loadGameManifest` sorts
40
+ * roots by, so a world's DOM stacking position always matches its
41
+ * manifest-resolved zOrder. The last element is the topmost (visually on
42
+ * top / highest z-index).
43
+ */
44
+ export declare function stackOrder<T extends ClaimEntry>(entries: readonly T[]): T[];
45
+ /**
46
+ * Resolve which world's id claims a container-relative point `(x, y)` — D5
47
+ * §2a: walk top-down (topmost first); the first world whose `hitTest`
48
+ * returns true wins ("topmost-claim wins"). A world with no `hitTest` never
49
+ * claims UNLESS it is the bottom-most world, which claims unconditionally
50
+ * (or via its own `hitTest`, if it declares one) — "no-claim falls to
51
+ * bottom". Returns `null` only when `entries` is empty.
52
+ */
53
+ export declare function resolveClaimingRoot(entries: readonly ClaimEntry[], x: number, y: number): string | null;
54
+ /**
55
+ * Sets `canvas.style.pointerEvents` per D5 §1/§2a: the bottom (lowest
56
+ * zOrder) world's canvas is `'auto'` (real user input DOM-hit-tests it by
57
+ * default); every canvas above it is `'none'` (real user input never
58
+ * DOM-hit-tests it — the router's JS-level `hitTest` is what still lets it
59
+ * claim a point via `createInputRouter`'s forwarding).
60
+ */
61
+ export declare function applyPointerEventsStacking(entries: readonly RouterAdapterRoot[]): void;
62
+ export interface InputRouterHandle {
63
+ /** Resolve which world claims a container-relative point right now — the
64
+ * pure decision, exposed for callers/tests that don't want to simulate a
65
+ * real DOM event. */
66
+ resolveClaim(x: number, y: number): string | null;
67
+ /** Detach the container listener(s). Idempotent. */
68
+ dispose(): void;
69
+ }
70
+ /**
71
+ * Wire the delegating router onto `container` for `entries` (D5 §2a): apply
72
+ * the pointer-events stacking, then attach ONE capture-phase listener per
73
+ * routed event type that resolves the claiming world and forwards the event
74
+ * to ITS canvas when that world isn't already the natural DOM target (the
75
+ * bottom world, whose canvas is the only one with `pointer-events:auto`).
76
+ */
77
+ export declare function createInputRouter(container: HTMLElement, entries: readonly RouterAdapterRoot[]): InputRouterHandle;
78
+ //# sourceMappingURL=input-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-router.d.ts","sourceRoot":"","sources":["../../src/runtime/input-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,yCAAyC;AACzC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC;CACpE;AAED,yDAAyD;AACzD,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;CACpC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE,CAK3E;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,MAAM,GAAG,IAAI,CAWf;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,GAAG,IAAI,CAKtF;AAyED,MAAM,WAAW,iBAAiB;IAChC;;0BAEsB;IACtB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAClD,oDAAoD;IACpD,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE,SAAS,iBAAiB,EAAE,GACpC,iBAAiB,CA8BnB"}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * The delegating input router (D5 §2a) —
3
+ * `createGameRuntime`'s roots path (T6.1 slice 1) uses this to route
4
+ * pointer input across N stacked world canvases with exactly ONE root
5
+ * listener.
6
+ *
7
+ * Split into two layers so the decision logic is unit-testable with plain
8
+ * fake roots — no real DOM/canvas needed:
9
+ *
10
+ * - `stackOrder` / `resolveClaimingRoot`: pure functions over
11
+ * `{id, zOrder, hitTest?}` — "who claims this point".
12
+ * - `applyPointerEventsStacking` / `createInputRouter`: the DOM wiring —
13
+ * sets `pointer-events` CSS per D5 §2a and forwards a claimed event to
14
+ * the claiming world's own canvas.
15
+ *
16
+ * Per-event fall-through (D5 §2b — the sanctioned mechanism for an
17
+ * authoring surface's own interior drag affordances, e.g. a canvas
18
+ * editor's gizmos) is explicitly NOT this file's job — it stays inside
19
+ * whatever authoring surface needs it.
20
+ */
21
+ /**
22
+ * Bottom-to-top paint order: ascending `zOrder`, ties -> original array
23
+ * order — the SAME rule `manifest/load.ts`'s `loadGameManifest` sorts
24
+ * roots by, so a world's DOM stacking position always matches its
25
+ * manifest-resolved zOrder. The last element is the topmost (visually on
26
+ * top / highest z-index).
27
+ */
28
+ export function stackOrder(entries) {
29
+ return entries
30
+ .map((entry, index) => ({ entry, index }))
31
+ .sort((a, b) => a.entry.zOrder - b.entry.zOrder || a.index - b.index)
32
+ .map(({ entry }) => entry);
33
+ }
34
+ /**
35
+ * Resolve which world's id claims a container-relative point `(x, y)` — D5
36
+ * §2a: walk top-down (topmost first); the first world whose `hitTest`
37
+ * returns true wins ("topmost-claim wins"). A world with no `hitTest` never
38
+ * claims UNLESS it is the bottom-most world, which claims unconditionally
39
+ * (or via its own `hitTest`, if it declares one) — "no-claim falls to
40
+ * bottom". Returns `null` only when `entries` is empty.
41
+ */
42
+ export function resolveClaimingRoot(entries, x, y) {
43
+ if (entries.length === 0)
44
+ return null;
45
+ const order = stackOrder(entries); // bottom -> top
46
+ for (let i = order.length - 1; i >= 1; i--) {
47
+ const entry = order[i];
48
+ if (entry.hitTest?.(x, y))
49
+ return entry.id;
50
+ }
51
+ // No upper world claimed (or there is only one world) -> the bottom world
52
+ // claims — honoring its own hitTest if it declares one (rare: the bottom
53
+ // world usually claims everything unconditionally per D5 §2a's default).
54
+ return order[0].id;
55
+ }
56
+ /**
57
+ * Sets `canvas.style.pointerEvents` per D5 §1/§2a: the bottom (lowest
58
+ * zOrder) world's canvas is `'auto'` (real user input DOM-hit-tests it by
59
+ * default); every canvas above it is `'none'` (real user input never
60
+ * DOM-hit-tests it — the router's JS-level `hitTest` is what still lets it
61
+ * claim a point via `createInputRouter`'s forwarding).
62
+ */
63
+ export function applyPointerEventsStacking(entries) {
64
+ const order = stackOrder(entries);
65
+ order.forEach((entry, i) => {
66
+ entry.canvas.style.pointerEvents = i === 0 ? 'auto' : 'none';
67
+ });
68
+ }
69
+ const ROUTED_EVENT_TYPES = ['pointerdown', 'pointerup', 'pointermove', 'click', 'wheel'];
70
+ /** Common pointer/mouse/wheel event fields this router knows how to carry
71
+ * over when forwarding a claimed event to a different canvas (see
72
+ * `forwardEvent` below) — not an exhaustive Event surface, just the fields
73
+ * games/libraries actually read for hit-testing and input state. */
74
+ function pickEventInit(original) {
75
+ const src = original;
76
+ const keys = [
77
+ 'clientX',
78
+ 'clientY',
79
+ 'screenX',
80
+ 'screenY',
81
+ 'offsetX',
82
+ 'offsetY',
83
+ 'button',
84
+ 'buttons',
85
+ 'ctrlKey',
86
+ 'altKey',
87
+ 'shiftKey',
88
+ 'metaKey',
89
+ 'pointerId',
90
+ 'pointerType',
91
+ 'pressure',
92
+ 'isPrimary',
93
+ 'deltaX',
94
+ 'deltaY',
95
+ 'deltaZ',
96
+ 'deltaMode',
97
+ ];
98
+ const init = { bubbles: false, cancelable: true, composed: true };
99
+ for (const key of keys)
100
+ if (key in src)
101
+ init[key] = src[key];
102
+ return init;
103
+ }
104
+ /**
105
+ * Forward `original` onto `canvas` as a NEW, non-bubbling event of the same
106
+ * event-type family — so a canvas with `pointer-events:none` (never a
107
+ * native DOM hit-test target) still receives the interaction its own event
108
+ * pipeline (Pixi's `EventSystem`, a raycast-driven three controller, …)
109
+ * listens for on ITS canvas. `bubbles:false` is deliberate: it stops the
110
+ * clone from re-triggering the container's own capture listener (an
111
+ * infinite loop) — re-dispatching the SAME event object is not an option
112
+ * either (the DOM forbids re-dispatching an event still being dispatched).
113
+ *
114
+ * Best-effort: environments with no `PointerEvent`/`MouseEvent`/
115
+ * `WheelEvent` global (Node unit tests) skip forwarding silently — those
116
+ * tests exercise the pure claim-resolution logic above instead, which needs
117
+ * no real `Event` objects at all.
118
+ */
119
+ function forwardEvent(canvas, original) {
120
+ const g = globalThis;
121
+ const Ctor = original.type === 'wheel'
122
+ ? g.WheelEvent
123
+ : original.type.startsWith('pointer')
124
+ ? g.PointerEvent
125
+ : (g.MouseEvent ?? g.PointerEvent);
126
+ if (!Ctor || typeof canvas.dispatchEvent !== 'function')
127
+ return;
128
+ try {
129
+ canvas.dispatchEvent(new Ctor(original.type, pickEventInit(original)));
130
+ }
131
+ catch {
132
+ // Best-effort forwarding — a construction failure here must never break
133
+ // the (already-delivered) original event's own handling.
134
+ }
135
+ }
136
+ /**
137
+ * Wire the delegating router onto `container` for `entries` (D5 §2a): apply
138
+ * the pointer-events stacking, then attach ONE capture-phase listener per
139
+ * routed event type that resolves the claiming world and forwards the event
140
+ * to ITS canvas when that world isn't already the natural DOM target (the
141
+ * bottom world, whose canvas is the only one with `pointer-events:auto`).
142
+ */
143
+ export function createInputRouter(container, entries) {
144
+ applyPointerEventsStacking(entries);
145
+ const byId = new Map(entries.map((e) => [e.id, e]));
146
+ const bottomId = stackOrder(entries)[0]?.id;
147
+ const handler = (evt) => {
148
+ const rect = container.getBoundingClientRect?.() ?? { left: 0, top: 0 };
149
+ const clientX = evt.clientX ?? 0;
150
+ const clientY = evt.clientY ?? 0;
151
+ const x = clientX - rect.left;
152
+ const y = clientY - rect.top;
153
+ const claimant = resolveClaimingRoot(entries, x, y);
154
+ if (claimant && claimant !== bottomId) {
155
+ const entry = byId.get(claimant);
156
+ if (entry)
157
+ forwardEvent(entry.canvas, evt);
158
+ }
159
+ };
160
+ for (const type of ROUTED_EVENT_TYPES) {
161
+ container.addEventListener?.(type, handler, true);
162
+ }
163
+ return {
164
+ resolveClaim: (x, y) => resolveClaimingRoot(entries, x, y),
165
+ dispose() {
166
+ for (const type of ROUTED_EVENT_TYPES) {
167
+ container.removeEventListener?.(type, handler, true);
168
+ }
169
+ },
170
+ };
171
+ }
@@ -0,0 +1,126 @@
1
+ import type { ResolvedAdapterRoot } from '../manifest/load';
2
+ import type { GameSession } from './create-runtime';
3
+ import { type MountEntry } from './mount-manifest';
4
+ /**
5
+ * What a caller of `mountGameFromManifest` provides. Deliberately minimal —
6
+ * this file never fetches/reads the manifest itself (same rule
7
+ * `mount-manifest.ts` follows: the caller already has a parsed manifest or a
8
+ * raw JSON value in hand).
9
+ */
10
+ export interface ManifestHost {
11
+ /** The host creates one absolutely-positioned surface per world inside
12
+ * this element — see `RootsRuntimeConfig.container`. */
13
+ readonly container: HTMLElement;
14
+ /**
15
+ * Resolve a manifest-declared `entry` (a project-relative module path,
16
+ * e.g. `"src/scripts/main.ts"`) to the ALREADY-IMPORTED module namespace a
17
+ * registered {@link AdapterSurfaceFactory} needs to build a `MountEntry` from.
18
+ *
19
+ * Deliberately NOT "import this arbitrary string path" — a static bundler
20
+ * (Vite/rollup building a `dist/`) cannot resolve a runtime-computed import
21
+ * specifier, so the recommended shape is a small caller-owned lookup table
22
+ * of STATIC imports keyed by the manifest's own `entry` strings (see
23
+ * `packages/editor/template/src/main.ts` for the worked pattern) rather
24
+ * than a literal `import(path)`. Optional — a manifest whose every world
25
+ * either declares no `entry` or is fully satisfied by an explicit
26
+ * `opts.entries` needs none at all.
27
+ */
28
+ loadEntryModule?(path: string): Promise<unknown>;
29
+ /** Resolve asset/scene URLs relative to the project — forwarded to a
30
+ * registered {@link AdapterSurfaceFactory} via {@link AdapterSurfaceFactoryContext},
31
+ * never called by this module itself (a factory only needs it for a
32
+ * non-default resolution scheme, e.g. a hosted-editor iframe). */
33
+ resolveUrl?(path: string): string;
34
+ readonly width?: number | undefined;
35
+ readonly height?: number | undefined;
36
+ /** Forwarded to `createGameRuntime` — Node/headless test harnesses only,
37
+ * never a real host. See `RootsRuntimeConfig.headless`. */
38
+ readonly headless?: boolean | undefined;
39
+ }
40
+ /** What a registered {@link AdapterSurfaceFactory} is handed for one world. */
41
+ export interface AdapterSurfaceFactoryContext {
42
+ readonly host: ManifestHost;
43
+ /**
44
+ * The result of `host.loadEntryModule(world.entry)`, if the world declares
45
+ * an `entry` AND the host supports loading it — `undefined` for a
46
+ * scene-only world, or when the host has no `loadEntryModule`.
47
+ */
48
+ readonly entryModule?: unknown;
49
+ }
50
+ /**
51
+ * A caller-registered per-kind mount strategy: given the world's resolved
52
+ * manifest entry and the loaded entry module (if any), produce the
53
+ * `MountEntry` `mountManifestRoots` needs to mount it (exactly what a
54
+ * project used to hand-build inline as its own `entries[id]` — see
55
+ * `examples/tri-world/src/main.ts`'s pre-E4 shape). May be async (loading an
56
+ * asset, fetching a scene file, etc.).
57
+ */
58
+ export type AdapterSurfaceFactory = (world: ResolvedAdapterRoot, ctx: AdapterSurfaceFactoryContext) => MountEntry | Promise<MountEntry>;
59
+ /**
60
+ * Register a `AdapterSurfaceFactory` for a manifest world `kind` (`'three'` /
61
+ * `'canvas'` / `'react'`, or any future kind the manifest schema grows).
62
+ * Call once, at module load — mirrors `registerSceneUIRenderer()`'s existing
63
+ * "call before mounting" convention (`packages/editor/template/src/main.ts`).
64
+ *
65
+ * Throws on double-registration of the SAME kind: an accidental duplicate
66
+ * (two side-effect imports of the same registration module, or a copy-paste)
67
+ * is far more likely than an intentional runtime swap — a caller that really
68
+ * wants to replace a registration must `unregisterAdapter` first, making
69
+ * the intent explicit.
70
+ */
71
+ export declare function registerAdapter(kind: string, factory: AdapterSurfaceFactory): void;
72
+ /** Remove a kind's registration (e.g. before re-registering a replacement). */
73
+ export declare function unregisterAdapter(kind: string): void;
74
+ /** Whether a factory is currently registered for `kind`. */
75
+ export declare function isAdapterRegistered(kind: string): boolean;
76
+ /**
77
+ * Test-only escape hatch: clears every registration. Registrations are
78
+ * meant to be one-time, process-lifetime — production code should never
79
+ * call this; it exists so unit tests can start each case from a clean
80
+ * registry without cross-test leakage.
81
+ */
82
+ export declare function __clearAdapterSurfaceRegistryForTests(): void;
83
+ /**
84
+ * A ready-to-register {@link AdapterSurfaceFactory} for `kind: 'three'` roots
85
+ * that follow the first-party entry-module convention (`export const
86
+ * adapter` and/or `export async function setup`). Threejs is safe to
87
+ * ship as an exported convenience (unlike canvas/react) because `three`/
88
+ * `SetupThreeRootAdapter` are already unconditional engine dependencies —
89
+ * see `mount-manifest.ts`'s header comment. Still never auto-registered:
90
+ * the registry itself stays zero-policy (see this file's header comment) —
91
+ * a caller opts in with `registerAdapter('three', defaultThreeAdapterFactory)`.
92
+ *
93
+ * Resolution mirrors `mount-manifest.ts`'s own `resolveThreeAdapter` branch
94
+ * order: an entry module's `adapter` export wins outright; else its `setup`
95
+ * export (wrapping via `fromSetup` happens inside `mountManifestRoots`
96
+ * itself — this factory just returns the `MountEntry` shape).
97
+ */
98
+ export declare const defaultThreeAdapterFactory: AdapterSurfaceFactory;
99
+ export interface MountGameOptions {
100
+ /** Explicit per-world entries, same shape `mountManifestRoots` accepts —
101
+ * ALWAYS wins over a registered kind factory for that world id (backward
102
+ * compat: a caller mid-migration, or one that just prefers building one
103
+ * entry by hand, never has to touch the registry at all). */
104
+ readonly entries?: Readonly<Record<string, MountEntry>> | undefined;
105
+ }
106
+ /**
107
+ * Mount every world declared by a `vgai.project.json` manifest onto `host
108
+ * .container`, resolving each world's kind through the `registerAdapter`
109
+ * registry — falling back to an explicit `opts.entries[id]` where supplied,
110
+ * exactly like `mountManifestRoots` (so a caller can migrate one world at a
111
+ * time, or never touch the registry if it prefers hand-building entries).
112
+ *
113
+ * This is the "one call" scaffold/example projects mount through (E4
114
+ * acceptance): register whatever kinds you need once, then
115
+ * `await mountGameFromManifest(manifest, host)` — see
116
+ * `packages/editor/template/src/main.ts` for the worked single-world
117
+ * example and `examples/tri-world/src/main.ts` for a multi-kind one.
118
+ *
119
+ * Degrades loudly (carried into E4): a world whose kind has no registered
120
+ * factory AND no explicit entry, and which cannot self-mount from the
121
+ * manifest alone, throws a named `Error` identifying the world id + kind and
122
+ * BOTH ways to fix it (`registerAdapter` or `opts.entries`) — never a silent
123
+ * skip.
124
+ */
125
+ export declare function mountGameFromManifest(manifestInput: unknown, host: ManifestHost, opts?: MountGameOptions): Promise<GameSession>;
126
+ //# sourceMappingURL=mount-game.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount-game.d.ts","sourceRoot":"","sources":["../../src/runtime/mount-game.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,UAAU,EAAuC,MAAM,kBAAkB,CAAC;AAQxF;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B;6DACyD;IACzD,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;IAChC;;;;;;;;;;;;;OAaG;IACH,eAAe,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD;;;uEAGmE;IACnE,UAAU,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,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;CACzC;AAED,+EAA+E;AAC/E,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,KAAK,EAAE,mBAAmB,EAC1B,GAAG,EAAE,4BAA4B,KAC9B,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAQtC;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAUlF;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEpD;AAED,4DAA4D;AAC5D,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;;;GAKG;AACH,wBAAgB,qCAAqC,IAAI,IAAI,CAE5D;AAcD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,0BAA0B,EAAE,qBAexC,CAAC;AAMF,MAAM,WAAW,gBAAgB;IAC/B;;;kEAG8D;IAC9D,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAAG,SAAS,CAAC;CACrE;AAgBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,qBAAqB,CACzC,aAAa,EAAE,OAAO,EACtB,IAAI,EAAE,YAAY,EAClB,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAyCtB"}