@vgai/engine 0.5.4 → 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 (448) 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/runtime/mount-game.ts +6 -0
  445. package/src/runtime/unexported-game-trap.ts +82 -0
  446. package/src/setup/setup-renderer.ts +2 -0
  447. package/src/world3d-react/index.ts +9 -0
  448. package/src/world3d-react/rapier-physics-bridge.tsx +137 -0
@@ -0,0 +1,85 @@
1
+ /**
2
+ * `<PixiPrimitive>` and `adoptNow` — the canvas surface's seam for an object React did NOT create.
3
+ *
4
+ * ## Why this exists
5
+ *
6
+ * A first-party canvas world is a `@pixi/react` tree, and every element in one is built by the
7
+ * reconciler: `createInstance` does `new PixiComponent(props)` and there is no escape hatch for an
8
+ * existing `Container`. That is fine until something OUTSIDE React owns an object the tree has to
9
+ * render — which is the ordinary case the moment a world has a runtime, not just a picture:
10
+ *
11
+ * - a translated Godot scene's own root, written to by a script (`mob.position = …`) in the same
12
+ * statement sequence that constructs it, BEFORE anything has rendered;
13
+ * - a container a game's own module or an asset pipeline handed over whole.
14
+ *
15
+ * three's lane answers this with `<primitive object={…}>`. This is that element for Pixi, and the
16
+ * three properties it must have are the three that make it not a mirror: the props go on the SAME
17
+ * object, the children go UNDER the same object, and unmount DETACHES it rather than destroying it
18
+ * — because React never owned it.
19
+ *
20
+ * ## How it is wired, and what @pixi/react actually offers
21
+ *
22
+ * Through `extend()`, which is @pixi/react's own documented extension point — the catalogue it
23
+ * resolves an intrinsic tag against. A registered class is constructed with the element's props, and
24
+ * a JS constructor that RETURNS an object hands back that object instead of the one `new` made: so
25
+ * the element's instance IS the adopted container, and from there every host-config path is the
26
+ * library's own (`appendChild` -> `parent.addChild`, `applyProps` -> the same property writes every
27
+ * other element gets, `insertBefore` -> `addChildAt`). No parallel reconciler, no re-implemented
28
+ * host config, no patched package.
29
+ *
30
+ * ONE path could not be wired through: `removeChild` unconditionally calls `childInstance.destroy()`
31
+ * (`@pixi/react` 8.0.5, `lib/helpers/removeChild.mjs`), there is no per-instance opt-out, and the
32
+ * host config is module-private (the package's `exports` map has only `"."`, so its
33
+ * `lib/core/reconciler` cannot be imported). {@link PixiPrimitive} therefore arms a ONE-SHOT
34
+ * `destroy` on the object in its own layout-effect cleanup — which React runs, synchronously,
35
+ * immediately before the `removeChild` that would destroy it — and that override detaches, restores
36
+ * the real method and is gone. It is disarmed on the next microtask regardless, so a deletion that
37
+ * never reaches this node (React calls `removeChild` only for the OUTERMOST host node of a deleted
38
+ * subtree) cannot leave the override installed.
39
+ *
40
+ * ## What `adoptNow` is for
41
+ *
42
+ * @pixi/react exports no reconciler `flushSync` — every `react-reconciler` instance closes over its
43
+ * own scheduler state (`module.exports = function ($$$config) { … }`), so no second instance and no
44
+ * other renderer can flush this one's work. A state update made from inside a frame therefore
45
+ * commits on React's own schedule rather than inside the call that made it.
46
+ *
47
+ * {@link adoptNow} is what the seam CAN offer for that: the half of the guarantee that is about the
48
+ * DISPLAY TREE rather than about React. A caller that has just created an object and asked React to
49
+ * render it places it now, and the commit that follows is an idempotent re-adoption of the same
50
+ * object under the same parent — `<PixiPrimitive>` renders the object the caller already placed, so
51
+ * there is one object and one tree, never a second insertion. What it does not do is run the
52
+ * object's own mount work early: whatever the rendering component does in its layout effect still
53
+ * happens when React commits, and a caller that needs that ordering must say so.
54
+ */
55
+ import { Container } from 'pixi.js';
56
+ import { type ReactNode } from 'react';
57
+ export interface PixiPrimitiveProps {
58
+ /** The container to adopt. It must not change for the life of one element — see below. */
59
+ readonly object: Container;
60
+ readonly children?: ReactNode;
61
+ /** Everything else is an ordinary `@pixi/react` prop, applied to {@link object} itself. */
62
+ readonly [prop: string]: unknown;
63
+ }
64
+ /**
65
+ * Render an EXISTING `PIXI.Container` as an element of this tree.
66
+ *
67
+ * ```tsx
68
+ * <PixiPrimitive object={scene.node} label={'Main'} x={0} y={0}>
69
+ * <pixiSprite label={'Background'} texture={background} />
70
+ * </PixiPrimitive>
71
+ * ```
72
+ *
73
+ * The props land on `scene.node`, the children become its children, and when this unmounts
74
+ * `scene.node` leaves the display tree intact — its lifetime belongs to whoever made it.
75
+ */
76
+ export declare function PixiPrimitive(props: PixiPrimitiveProps): React.JSX.Element;
77
+ /**
78
+ * Put `child` under `parent` NOW, ahead of the commit that will render it.
79
+ *
80
+ * The canvas surface's answer to a reconciler `flushSync`, which @pixi/react does not expose (see
81
+ * this module's header). Idempotent with {@link PixiPrimitive}: re-adopting the same object under
82
+ * the same parent is what the commit does, and Pixi's own `addChild` treats it as a no-op reorder.
83
+ */
84
+ export declare function adoptNow(parent: Container, child: Container): void;
85
+ //# sourceMappingURL=pixi-primitive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pixi-primitive.d.ts","sourceRoot":"","sources":["../../src/canvas-react/pixi-primitive.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAGL,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AA+Cf,MAAM,WAAW,kBAAkB;IACjC,0FAA0F;IAC1F,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,2FAA2F;IAC3F,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAClC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA8B1E;AA+BD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAGlE"}
@@ -0,0 +1,181 @@
1
+ /**
2
+ * `<PixiPrimitive>` and `adoptNow` — the canvas surface's seam for an object React did NOT create.
3
+ *
4
+ * ## Why this exists
5
+ *
6
+ * A first-party canvas world is a `@pixi/react` tree, and every element in one is built by the
7
+ * reconciler: `createInstance` does `new PixiComponent(props)` and there is no escape hatch for an
8
+ * existing `Container`. That is fine until something OUTSIDE React owns an object the tree has to
9
+ * render — which is the ordinary case the moment a world has a runtime, not just a picture:
10
+ *
11
+ * - a translated Godot scene's own root, written to by a script (`mob.position = …`) in the same
12
+ * statement sequence that constructs it, BEFORE anything has rendered;
13
+ * - a container a game's own module or an asset pipeline handed over whole.
14
+ *
15
+ * three's lane answers this with `<primitive object={…}>`. This is that element for Pixi, and the
16
+ * three properties it must have are the three that make it not a mirror: the props go on the SAME
17
+ * object, the children go UNDER the same object, and unmount DETACHES it rather than destroying it
18
+ * — because React never owned it.
19
+ *
20
+ * ## How it is wired, and what @pixi/react actually offers
21
+ *
22
+ * Through `extend()`, which is @pixi/react's own documented extension point — the catalogue it
23
+ * resolves an intrinsic tag against. A registered class is constructed with the element's props, and
24
+ * a JS constructor that RETURNS an object hands back that object instead of the one `new` made: so
25
+ * the element's instance IS the adopted container, and from there every host-config path is the
26
+ * library's own (`appendChild` -> `parent.addChild`, `applyProps` -> the same property writes every
27
+ * other element gets, `insertBefore` -> `addChildAt`). No parallel reconciler, no re-implemented
28
+ * host config, no patched package.
29
+ *
30
+ * ONE path could not be wired through: `removeChild` unconditionally calls `childInstance.destroy()`
31
+ * (`@pixi/react` 8.0.5, `lib/helpers/removeChild.mjs`), there is no per-instance opt-out, and the
32
+ * host config is module-private (the package's `exports` map has only `"."`, so its
33
+ * `lib/core/reconciler` cannot be imported). {@link PixiPrimitive} therefore arms a ONE-SHOT
34
+ * `destroy` on the object in its own layout-effect cleanup — which React runs, synchronously,
35
+ * immediately before the `removeChild` that would destroy it — and that override detaches, restores
36
+ * the real method and is gone. It is disarmed on the next microtask regardless, so a deletion that
37
+ * never reaches this node (React calls `removeChild` only for the OUTERMOST host node of a deleted
38
+ * subtree) cannot leave the override installed.
39
+ *
40
+ * ## What `adoptNow` is for
41
+ *
42
+ * @pixi/react exports no reconciler `flushSync` — every `react-reconciler` instance closes over its
43
+ * own scheduler state (`module.exports = function ($$$config) { … }`), so no second instance and no
44
+ * other renderer can flush this one's work. A state update made from inside a frame therefore
45
+ * commits on React's own schedule rather than inside the call that made it.
46
+ *
47
+ * {@link adoptNow} is what the seam CAN offer for that: the half of the guarantee that is about the
48
+ * DISPLAY TREE rather than about React. A caller that has just created an object and asked React to
49
+ * render it places it now, and the commit that follows is an idempotent re-adoption of the same
50
+ * object under the same parent — `<PixiPrimitive>` renders the object the caller already placed, so
51
+ * there is one object and one tree, never a second insertion. What it does not do is run the
52
+ * object's own mount work early: whatever the rendering component does in its layout effect still
53
+ * happens when React commits, and a caller that needs that ordering must say so.
54
+ */
55
+ import { extend } from '@pixi/react';
56
+ import { Container } from 'pixi.js';
57
+ import { createElement, useLayoutEffect, useRef, } from 'react';
58
+ /** The prop the adoption element carries its object on. */
59
+ const OBJECT_PROP = 'object';
60
+ /**
61
+ * The catalogue entry, and the whole of the adoption mechanism.
62
+ *
63
+ * It is never instantiated: a constructor that returns an object hands that object back to the
64
+ * caller, so `new AdoptedPixiObject({ object })` IS `object`. That is the one thing @pixi/react's
65
+ * `createInstance` cannot do on its own and the only thing this class exists for.
66
+ */
67
+ class AdoptedPixiObject {
68
+ constructor(props) {
69
+ const object = props[OBJECT_PROP];
70
+ if (!(object instanceof Container)) {
71
+ throw new Error('PixiPrimitive: `object` must be a PIXI.Container (got ' +
72
+ `${object === null ? 'null' : typeof object}). This element adopts an object the game ` +
73
+ 'already owns; it does not create one.');
74
+ }
75
+ // `applyProps` writes every prop it is given onto the instance, and the instance here is the
76
+ // GAME'S object. A non-enumerable accessor answers with the object and swallows that write, so
77
+ // adoption never plants a self-reference on something the game holds.
78
+ Object.defineProperty(object, OBJECT_PROP, {
79
+ configurable: true,
80
+ enumerable: false,
81
+ get: () => object,
82
+ set: () => { },
83
+ });
84
+ // The returned object IS the mechanism — see this module's header. @pixi/react's
85
+ // `createInstance` has exactly one way to produce an element's instance
86
+ // (`new PixiComponent(props)`), so a constructor that hands back an existing object is the only
87
+ // door an existing one can be adopted through, and this class exists for nothing else. Nobody
88
+ // ever reads an `AdoptedPixiObject`; the catalogue is its only caller.
89
+ // biome-ignore lint/correctness/noConstructorReturn: adoption is exactly this return
90
+ return object;
91
+ }
92
+ }
93
+ extend({ VgaiAdopted: AdoptedPixiObject });
94
+ /** The intrinsic `extend` above registered. Typed as a component so this module is the ONE place
95
+ * that knows the tag; nothing else in the repo, and no game, ever spells it. */
96
+ const ADOPTION_ELEMENT = 'pixiVgaiAdopted';
97
+ /**
98
+ * Render an EXISTING `PIXI.Container` as an element of this tree.
99
+ *
100
+ * ```tsx
101
+ * <PixiPrimitive object={scene.node} label={'Main'} x={0} y={0}>
102
+ * <pixiSprite label={'Background'} texture={background} />
103
+ * </PixiPrimitive>
104
+ * ```
105
+ *
106
+ * The props land on `scene.node`, the children become its children, and when this unmounts
107
+ * `scene.node` leaves the display tree intact — its lifetime belongs to whoever made it.
108
+ */
109
+ export function PixiPrimitive(props) {
110
+ const { object, children, ...rest } = props;
111
+ // The adopted object is the element's INSTANCE, and an instance is fixed for the life of an
112
+ // element — a changed `object` would silently keep rendering the old one. Refuse by name instead.
113
+ const adopted = useRef(object);
114
+ if (adopted.current !== object) {
115
+ throw new Error('PixiPrimitive: `object` changed on a mounted element. The adopted container IS this ' +
116
+ "element's instance, so it cannot be swapped; give the element a `key` derived from the " +
117
+ 'object instead, so React remounts it.');
118
+ }
119
+ useLayoutEffect(() => {
120
+ // React runs this cleanup, synchronously, just before the `removeChild` that would destroy the
121
+ // object — see this module's header.
122
+ return () => armDetach(object);
123
+ // `object` is invariant for this element (asserted above), so this is once per mount.
124
+ }, [object]);
125
+ // An `undefined` prop is DROPPED, so absent means "keep what the game set". @pixi/react's mount
126
+ // diff compares element props against the instance's OWN-enumerable snapshot, and for an own
127
+ // property (a v8 `Container`'s `label`) that snapshot shows the live value — so a forwarded-but-
128
+ // unset prop (`label={props.label}` on a spawned scene root) would diff `'Mob' -> undefined` and
129
+ // write `undefined` onto the game's object. Dropping the key instead also gives a later
130
+ // defined -> undefined transition the library's own REMOVAL semantics (reset to the class
131
+ // default) rather than a literal `undefined` write.
132
+ const applied = { [OBJECT_PROP]: object };
133
+ for (const [key, value] of Object.entries(rest)) {
134
+ if (value !== undefined)
135
+ applied[key] = value;
136
+ }
137
+ return createElement(ADOPTION_ELEMENT, applied, children);
138
+ }
139
+ /**
140
+ * Turn the next `destroy()` on `object` into a detach, then restore the real method.
141
+ *
142
+ * One shot and self-disarming: the override removes itself before doing anything, and a microtask
143
+ * removes it in any case, so the window in which it can answer is exactly React's own (synchronous)
144
+ * commit.
145
+ */
146
+ function armDetach(object) {
147
+ const target = object;
148
+ const previous = Object.getOwnPropertyDescriptor(object, 'destroy');
149
+ let armed = true;
150
+ const disarm = () => {
151
+ if (!armed)
152
+ return;
153
+ armed = false;
154
+ if (previous === undefined)
155
+ delete target.destroy;
156
+ else
157
+ Object.defineProperty(object, 'destroy', previous);
158
+ };
159
+ Object.defineProperty(object, 'destroy', {
160
+ configurable: true,
161
+ enumerable: false,
162
+ writable: true,
163
+ value: function detachInsteadOfDestroy() {
164
+ disarm();
165
+ this.removeFromParent();
166
+ },
167
+ });
168
+ queueMicrotask(disarm);
169
+ }
170
+ /**
171
+ * Put `child` under `parent` NOW, ahead of the commit that will render it.
172
+ *
173
+ * The canvas surface's answer to a reconciler `flushSync`, which @pixi/react does not expose (see
174
+ * this module's header). Idempotent with {@link PixiPrimitive}: re-adopting the same object under
175
+ * the same parent is what the commit does, and Pixi's own `addChild` treats it as a no-op reorder.
176
+ */
177
+ export function adoptNow(parent, child) {
178
+ if (child.parent === parent)
179
+ return;
180
+ parent.addChild(child);
181
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * `createPixiReactAdapter` — wraps a `@pixi/react` tree as a first-party
3
+ * `RootAdapter<'canvas'>` so a Pixi world mounts as an ordinary
4
+ * `surface: "canvas"` root: the engine hands `mount()` a `CanvasHostContext`
5
+ * (its own canvas + size + compositing hints, per `../adapter/host-context.ts`);
6
+ * this returns a `MountedPixiRoot` (`../adapter/root-adapter.ts`) whose `stage`
7
+ * is the REAL `PIXI.Container` the reconciler renders into.
8
+ *
9
+ * This is the canvas surface's exact sibling of `world3d-react`'s
10
+ * `createR3FAdapter`, with `@pixi/react` where that one has
11
+ * react-three-fiber. Everything structural is the same, because the seam is
12
+ * the same: one loop (the host's), one canvas (the host's), a world-local
13
+ * `SystemRunner` ticked in engine phase order before the renderer advances,
14
+ * and a `GameContext` threaded into the tree through `EngineBridge`.
15
+ *
16
+ * ## The loop contract
17
+ *
18
+ * `Application` is initialized with `autoStart: false` and `sharedTicker:
19
+ * false`, so it owns a ticker that is NEVER started and therefore never
20
+ * requests an animation frame. `mounted.update(dt)` is the only thing that
21
+ * advances it, and it feeds GAME time, not wall time — which is what makes the
22
+ * world freeze exactly when the host freezes it, and what makes
23
+ * `game.waitSimTime` work in a hidden tab (a hidden tab has no rAF; the engine
24
+ * loop's own catch-up still calls `update`, and Pixi has no independent clock
25
+ * to disagree with it).
26
+ *
27
+ * ## Component catalogue
28
+ *
29
+ * `@pixi/react` resolves `<pixiSprite>` etc. through a module-global catalogue
30
+ * that starts EMPTY — the first intrinsic in an un-extended tree throws
31
+ * "X is not part of the PIXI namespace! Did you forget to extend?". This
32
+ * module extends it with the whole `pixi.js` namespace once per mount
33
+ * (idempotent `Object.assign`), the same thing `createR3FAdapter` does with
34
+ * `extend(host.three)`. A world that adds its own classes (`@pixi/tilemap`,
35
+ * a custom `Container` subclass) calls `extend`/`useExtend` itself.
36
+ */
37
+ import type { ApplicationOptions } from 'pixi.js';
38
+ import { type ReactNode } from 'react';
39
+ import type { RootAdapter } from '../adapter';
40
+ /** What {@link createPixiReactAdapter} needs to build one `RootAdapter<'canvas'>`. */
41
+ export interface CreatePixiReactAdapterOptions {
42
+ /** Stable id (telemetry/registry/conformance) — `RootAdapter.id`. */
43
+ readonly id: string;
44
+ /** The Pixi tree to mount — `useTick` hooks, `useApplication`, Pixi filters
45
+ * and any extended component all work unchanged. */
46
+ readonly content: ReactNode;
47
+ /** Input map loaded through the game-owned `Game.loadInputMap` (load-once
48
+ * across roots). Defaults to the conventional
49
+ * `/inputmaps/default.inputmap.json`; `null` opts out (a world with no
50
+ * actions). A missing/invalid map degrades loudly without failing the
51
+ * mount — see `world-context.ts`. */
52
+ readonly inputMapPath?: string | null | undefined;
53
+ /**
54
+ * Extra `Application.init` options merged UNDER this adapter's own — e.g.
55
+ * `{ antialias: false }`, `{ roundPixels: true }`. The loop-critical ones
56
+ * (`autoStart`, `sharedTicker`) and the ones the host owns (size, dpr,
57
+ * transparency, `preserveDrawingBuffer`) are applied after this and cannot
58
+ * be overridden: a world that starts its own ticker or clears an opaque
59
+ * background under a stacked sibling breaks the host's contract, not just
60
+ * its own frame.
61
+ */
62
+ readonly applicationOptions?: Partial<ApplicationOptions> | undefined;
63
+ }
64
+ /**
65
+ * Build a `RootAdapter<'canvas'>` that mounts `options.content` through
66
+ * `@pixi/react`, gated entirely by the host's own loop and rendering into the
67
+ * host's own canvas — never a second canvas, never a second
68
+ * `requestAnimationFrame` loop.
69
+ */
70
+ export declare function createPixiReactAdapter(options: CreatePixiReactAdapterOptions): RootAdapter<'canvas'>;
71
+ //# sourceMappingURL=pixi-react-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pixi-react-adapter.d.ts","sourceRoot":"","sources":["../../src/canvas-react/pixi-react-adapter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,KAAK,EAAe,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE/D,OAAO,EAAiB,KAAK,SAAS,EAAmB,MAAM,OAAO,CAAC;AACvE,OAAO,KAAK,EAAsC,WAAW,EAAE,MAAM,YAAY,CAAC;AAyBlF,sFAAsF;AACtF,MAAM,WAAW,6BAA6B;IAC5C,qEAAqE;IACrE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;yDACqD;IACrD,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B;;;;0CAIsC;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClD;;;;;;;;OAQG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC;CACvE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,6BAA6B,GACrC,WAAW,CAAC,QAAQ,CAAC,CA8LvB"}
@@ -0,0 +1,229 @@
1
+ /**
2
+ * `createPixiReactAdapter` — wraps a `@pixi/react` tree as a first-party
3
+ * `RootAdapter<'canvas'>` so a Pixi world mounts as an ordinary
4
+ * `surface: "canvas"` root: the engine hands `mount()` a `CanvasHostContext`
5
+ * (its own canvas + size + compositing hints, per `../adapter/host-context.ts`);
6
+ * this returns a `MountedPixiRoot` (`../adapter/root-adapter.ts`) whose `stage`
7
+ * is the REAL `PIXI.Container` the reconciler renders into.
8
+ *
9
+ * This is the canvas surface's exact sibling of `world3d-react`'s
10
+ * `createR3FAdapter`, with `@pixi/react` where that one has
11
+ * react-three-fiber. Everything structural is the same, because the seam is
12
+ * the same: one loop (the host's), one canvas (the host's), a world-local
13
+ * `SystemRunner` ticked in engine phase order before the renderer advances,
14
+ * and a `GameContext` threaded into the tree through `EngineBridge`.
15
+ *
16
+ * ## The loop contract
17
+ *
18
+ * `Application` is initialized with `autoStart: false` and `sharedTicker:
19
+ * false`, so it owns a ticker that is NEVER started and therefore never
20
+ * requests an animation frame. `mounted.update(dt)` is the only thing that
21
+ * advances it, and it feeds GAME time, not wall time — which is what makes the
22
+ * world freeze exactly when the host freezes it, and what makes
23
+ * `game.waitSimTime` work in a hidden tab (a hidden tab has no rAF; the engine
24
+ * loop's own catch-up still calls `update`, and Pixi has no independent clock
25
+ * to disagree with it).
26
+ *
27
+ * ## Component catalogue
28
+ *
29
+ * `@pixi/react` resolves `<pixiSprite>` etc. through a module-global catalogue
30
+ * that starts EMPTY — the first intrinsic in an un-extended tree throws
31
+ * "X is not part of the PIXI namespace! Did you forget to extend?". This
32
+ * module extends it with the whole `pixi.js` namespace once per mount
33
+ * (idempotent `Object.assign`), the same thing `createR3FAdapter` does with
34
+ * `extend(host.three)`. A world that adds its own classes (`@pixi/tilemap`,
35
+ * a custom `Container` subclass) calls `extend`/`useExtend` itself.
36
+ */
37
+ import { createRoot, extend } from '@pixi/react';
38
+ import * as PIXI from 'pixi.js';
39
+ import { createElement, useLayoutEffect } from 'react';
40
+ import { WorldProvider } from '../react/world-state';
41
+ import { EngineBridge } from './engine-bridge';
42
+ import { createCanvasRootContext } from './world-context';
43
+ /** How long `mount()` waits for the tree's first commit before failing loudly
44
+ * rather than hanging (and wedging every root declared after this one, since
45
+ * roots mount sequentially). */
46
+ const FIRST_COMMIT_TIMEOUT_MS = 10_000;
47
+ /**
48
+ * `@pixi/react` keys its reconciler roots off the canvas element in a
49
+ * module-global map, and its own unmount path (which would clear that key) is
50
+ * not exported. So a canvas this lane has already mounted must never be handed
51
+ * to a second mount: `createRoot` would silently hand back the FIRST root,
52
+ * whose `Application` this lane already destroyed. Every host in this repo
53
+ * builds a fresh canvas per mount, so this only ever fires on a genuine bug —
54
+ * and it fires as a named error rather than as a dead world.
55
+ */
56
+ const MOUNTED_CANVASES = new WeakSet();
57
+ /**
58
+ * Build a `RootAdapter<'canvas'>` that mounts `options.content` through
59
+ * `@pixi/react`, gated entirely by the host's own loop and rendering into the
60
+ * host's own canvas — never a second canvas, never a second
61
+ * `requestAnimationFrame` loop.
62
+ */
63
+ export function createPixiReactAdapter(options) {
64
+ const { id, content, inputMapPath, applicationOptions } = options;
65
+ return {
66
+ id,
67
+ async mount(host) {
68
+ const runtime = createCanvasRootContext(host, { id, inputMapPath });
69
+ const bridge = { ctx: runtime.ctx };
70
+ // Actions must exist before any component's first tick reads them — wait
71
+ // for the (never-rejecting) input-map load before the first commit.
72
+ await runtime.inputMapReady;
73
+ const canvas = host.canvas;
74
+ if (MOUNTED_CANVASES.has(canvas)) {
75
+ runtime.dispose();
76
+ throw new Error(`createPixiReactAdapter: root "${id}" was handed a canvas this lane has already ` +
77
+ 'mounted. @pixi/react keys its reconciler roots off the canvas element, so re-using ' +
78
+ 'one would resurrect a root whose Application is destroyed. Hand each mount a fresh ' +
79
+ 'canvas (every vgai host already does).');
80
+ }
81
+ MOUNTED_CANVASES.add(canvas);
82
+ // The catalogue is module-global and starts empty; this is idempotent.
83
+ extend(PIXI);
84
+ let resolveCommitted;
85
+ const committed = new Promise((resolve) => {
86
+ resolveCommitted = resolve;
87
+ });
88
+ let resolveUnmounted;
89
+ const unmounted = new Promise((resolve) => {
90
+ resolveUnmounted = resolve;
91
+ });
92
+ /**
93
+ * Signals the tree's FIRST COMMIT and its LAST. A layout effect,
94
+ * deliberately, and rendered as the LAST child, deliberately:
95
+ *
96
+ * - mount: layout effects run synchronously inside the commit, before
97
+ * any passive effect and before any tick can be scheduled;
98
+ * - unmount: React commits deletion effects in tree order, each node
99
+ * before its own children, so the LAST sibling's cleanup is the last
100
+ * to run. That is what makes this a reliable "every component has
101
+ * finished tearing down" signal — and it is load-bearing, because
102
+ * `useTick`'s own cleanup calls `ticker.remove()`. Destroying the
103
+ * Application before that cleanup lands throws inside React's commit
104
+ * on every teardown of any world with a tick hook.
105
+ */
106
+ function Lifecycle() {
107
+ useLayoutEffect(() => {
108
+ resolveCommitted();
109
+ return resolveUnmounted;
110
+ }, []);
111
+ return null;
112
+ }
113
+ const game = runtime.ctx.game;
114
+ // The React seam every dom root already has — `useWorldState`,
115
+ // `useDebugProvider`/`useDebugCommand`/`useDebugEmit`
116
+ // (`../react/world-state`) — works identically inside a canvas root
117
+ // because a canvas root IS React. `host.game` is genuinely absent in
118
+ // bare/foreign hosts, so the provider is conditional and those hooks
119
+ // stay the inert no-ops they already document themselves to be.
120
+ const element = createElement(EngineBridge.Provider, { value: bridge }, game ? createElement(WorldProvider, { game }, content) : content, createElement(Lifecycle));
121
+ const root = createRoot(canvas);
122
+ // The host owns size, dpr, transparency and capture cost; the loop
123
+ // contract owns `autoStart`/`sharedTicker`. Both are applied AFTER the
124
+ // caller's own options so neither can be overridden from a world file.
125
+ const initOptions = {
126
+ antialias: true,
127
+ ...applicationOptions,
128
+ width: host.width,
129
+ height: host.height,
130
+ resolution: host.dpr ?? globalThis.devicePixelRatio ?? 1,
131
+ autoDensity: true,
132
+ // Stacked ABOVE a sibling root -> clear with alpha 0 so the layer below
133
+ // shows through (COMPOSITION-DESIGN D5 §1).
134
+ backgroundAlpha: host.transparent ? 0 : 1,
135
+ preserveDrawingBuffer: host.preserveDrawingBuffer ?? false,
136
+ autoStart: false,
137
+ sharedTicker: false,
138
+ };
139
+ // `root.render` is async: it awaits `Application.init()` (which is what
140
+ // creates the renderer) and only then hands the tree to the reconciler.
141
+ // A crash inside init rejects here, which is the loud failure we want.
142
+ const app = await root.render(element, initOptions);
143
+ runtime.setApplication(app);
144
+ // A reconcile-time crash (e.g. an un-extended component) surfaces as an
145
+ // uncaught window error and the first commit never lands — without this
146
+ // guard `mount()` would await `committed` forever. Convert that class of
147
+ // failure into a loud mount error.
148
+ await new Promise((resolve, reject) => {
149
+ const fail = (why) => {
150
+ cleanup();
151
+ try {
152
+ app.destroy(false, { children: true });
153
+ }
154
+ catch {
155
+ /* the world never fully came up; teardown failure must not mask why */
156
+ }
157
+ runtime.dispose();
158
+ reject(new Error(`createPixiReactAdapter: root "${id}" — ${why}`));
159
+ };
160
+ const onError = (event) => fail(`the Pixi tree crashed before its first commit — ${event.message} ` +
161
+ '(mount() fails loudly instead of hanging)');
162
+ const timer = setTimeout(() => fail(`no first commit within ${FIRST_COMMIT_TIMEOUT_MS / 1000}s ` +
163
+ '(mount() fails loudly instead of hanging)'), FIRST_COMMIT_TIMEOUT_MS);
164
+ const cleanup = () => {
165
+ clearTimeout(timer);
166
+ globalThis.removeEventListener?.('error', onError);
167
+ };
168
+ globalThis.addEventListener?.('error', onError);
169
+ void committed.then(() => {
170
+ cleanup();
171
+ resolve();
172
+ });
173
+ });
174
+ // Pin the ticker's clock to GAME time. `Ticker.lastTime` starts at -1, so
175
+ // without this the first `update()` would report a 1ms phantom delta on
176
+ // top of the real one. From here every `deltaMS` a `useTick` callback
177
+ // sees is exactly the `dt` the host handed us — no wall clock anywhere,
178
+ // which is what makes a paused world's resume frame ordinary rather than
179
+ // one giant catch-up step.
180
+ app.ticker.lastTime = 0;
181
+ let elapsedMs = 0;
182
+ let disposed = false;
183
+ return {
184
+ kind: 'canvas',
185
+ // The reconciler's real root container — the same `PIXI.Container`
186
+ // `RootInstance.pixiStage()` hands the editor.
187
+ stage: app.stage,
188
+ drivesOwnLoop: false,
189
+ // Adapter surface: `debug` pre-seeded (the shared game registry's
190
+ // adapter); game code adds capabilities via `ctx.registerSystemAdapter`.
191
+ systems: runtime.systemAdapters,
192
+ update(dt) {
193
+ if (disposed)
194
+ return;
195
+ elapsedMs += dt * 1000;
196
+ // Engine phases FIRST (registered systems mutate transforms), then
197
+ // the ticker — so `useTick` callbacks and the render that follows
198
+ // them at `UPDATE_PRIORITY.LOW` both see the fresh state. Both are
199
+ // host-gated: neither runs while this world is frozen.
200
+ runtime.systems.run(dt);
201
+ app.ticker.update(elapsedMs);
202
+ },
203
+ resize(width, height) {
204
+ if (disposed)
205
+ return;
206
+ // `autoDensity: true` makes Pixi re-stamp `canvas.style.width`/
207
+ // `.height` from this call, so the on-screen box follows the logical
208
+ // size with no explicit CSS write from the host.
209
+ app.renderer.resize(width, height);
210
+ },
211
+ dispose() {
212
+ if (disposed)
213
+ return;
214
+ disposed = true;
215
+ // Rendering `null` children is the only unmount path `@pixi/react`
216
+ // exposes publicly (its `unmountRoot` helper is internal), and React
217
+ // commits that deletion on its own schedule — NOT synchronously. So
218
+ // the Application is destroyed on the `Lifecycle` cleanup signal
219
+ // instead of inline: `useTick`'s cleanup calls `ticker.remove()`, and
220
+ // a ticker destroyed before it lands throws inside React's commit.
221
+ // `removeView` stays false — the canvas belongs to the HOST.
222
+ void root.render(null, initOptions);
223
+ void unmounted.then(() => app.destroy(false, { children: true }));
224
+ runtime.dispose();
225
+ },
226
+ };
227
+ },
228
+ };
229
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * `pixiReactRootFactory` — mount a `canvas` root whose entry module
3
+ * DEFAULT-EXPORTS a React component.
4
+ *
5
+ * A model asked for a 2D world writes:
6
+ *
7
+ * ```tsx
8
+ * export default function World() {
9
+ * return <pixiContainer><pixiSprite texture={Texture.WHITE} /></pixiContainer>;
10
+ * }
11
+ * ```
12
+ *
13
+ * It does NOT write `export const adapter = createPixiReactAdapter({ id, content })`.
14
+ * That export is vgai ceremony wrapped around a component the author already
15
+ * wrote. The `three` and `dom` roots both settled this convention — read
16
+ * `entryModule.default` and wrap it — and this is the same contract for canvas
17
+ * roots, so all three surfaces answer "what do I export?" the same way.
18
+ *
19
+ * ## Why this is NOT in `mount-game.ts`
20
+ *
21
+ * The kind registry beside `mount-game.ts` is deliberately dependency-free:
22
+ * registering a canvas factory there would make `pixi.js` + `@pixi/react`
23
+ * unconditional for every game, including three-only ones. `canvas-react` is
24
+ * the opt-in module that owns those dependencies, so the factory lives here and
25
+ * a project opts in with `registerAdapter('canvas', pixiReactRootFactory)`.
26
+ *
27
+ * ## Compatibility
28
+ *
29
+ * An `adapter` export still wins, so a game needing full control over its own
30
+ * `RootAdapter<'canvas'>` keeps it.
31
+ */
32
+ import type { RootAdapter } from '../adapter/root-adapter';
33
+ import type { AdapterSurfaceFactory } from '../runtime/mount-game';
34
+ /**
35
+ * What a canvas entry module MEANS, in one place.
36
+ *
37
+ * Two callers need this answer and must never disagree about it: the runtime
38
+ * mount ({@link pixiReactRootFactory}, below) and the EDITOR, which resolves
39
+ * the same entry for play mode and for the design-time layer. When only one
40
+ * side knows about the default-export shape, a world plays fine and shows
41
+ * "(no scene loaded)" in edit mode — the exact split the three lane already
42
+ * paid for.
43
+ *
44
+ * Returns `null` when the module is neither shape — the callers differ on what
45
+ * to do about that (the factory throws; the editor reports a mount failure on
46
+ * that root's boundary node and leaves every sibling working).
47
+ */
48
+ export declare function resolveCanvasEntryAdapter(entryModule: unknown, rootId: string): RootAdapter<'canvas'> | null;
49
+ /**
50
+ * Register with `registerAdapter('canvas', pixiReactRootFactory)`.
51
+ *
52
+ * Resolution order mirrors the three lane's (explicit adapter wins) and then
53
+ * accepts the default-exported component.
54
+ */
55
+ export declare const pixiReactRootFactory: AdapterSurfaceFactory;
56
+ //# sourceMappingURL=pixi-react-root-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pixi-react-root-factory.d.ts","sourceRoot":"","sources":["../../src/canvas-react/pixi-react-root-factory.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAUnE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,OAAO,EACpB,MAAM,EAAE,MAAM,GACb,WAAW,CAAC,QAAQ,CAAC,GAAG,IAAI,CAU9B;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,qBAQlC,CAAC"}