@vgai/engine 0.5.0 → 0.5.2

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 (538) hide show
  1. package/package.json +1 -1
  2. package/schemas/engine-capabilities.json +4 -4
  3. package/schemas/vgai-game.schema.json +2 -2
  4. package/src/adapter/authoring.ts +42 -0
  5. package/src/adapter/index.ts +3 -0
  6. package/src/adapter/ingest/overlay-apply.ts +50 -6
  7. package/src/adapter/ingest/scene-capture.ts +51 -2
  8. package/src/adapter/vgai-scene-game-adapter.ts +24 -0
  9. package/src/manifest/schema.ts +7 -3
  10. package/src/runtime/create-runtime.ts +97 -0
  11. package/src/runtime/game.ts +11 -1
  12. package/src/scene/asset-ref-check.ts +1 -1
  13. package/src/scene/scene-loader.ts +2 -2
  14. package/src/scene/user-data.ts +18 -0
  15. package/src/world3d-react/behavior.tsx +19 -11
  16. package/src/world3d-react/r3f-adapter.tsx +8 -0
  17. package/dist/adapter/adapter-surface.d.ts +0 -30
  18. package/dist/adapter/adapter-surface.d.ts.map +0 -1
  19. package/dist/adapter/adapter-surface.js +0 -18
  20. package/dist/adapter/authoring.d.ts +0 -461
  21. package/dist/adapter/authoring.d.ts.map +0 -1
  22. package/dist/adapter/authoring.js +0 -22
  23. package/dist/adapter/colyseus-networking-adapter.d.ts +0 -43
  24. package/dist/adapter/colyseus-networking-adapter.d.ts.map +0 -1
  25. package/dist/adapter/colyseus-networking-adapter.js +0 -38
  26. package/dist/adapter/first-party-systems.d.ts +0 -38
  27. package/dist/adapter/first-party-systems.d.ts.map +0 -1
  28. package/dist/adapter/first-party-systems.js +0 -77
  29. package/dist/adapter/game-adapter.d.ts +0 -133
  30. package/dist/adapter/game-adapter.d.ts.map +0 -1
  31. package/dist/adapter/game-adapter.js +0 -10
  32. package/dist/adapter/host-context.d.ts +0 -71
  33. package/dist/adapter/host-context.d.ts.map +0 -1
  34. package/dist/adapter/host-context.js +0 -16
  35. package/dist/adapter/index.d.ts +0 -22
  36. package/dist/adapter/index.d.ts.map +0 -1
  37. package/dist/adapter/index.js +0 -15
  38. package/dist/adapter/ingest/game-contract.d.ts +0 -53
  39. package/dist/adapter/ingest/game-contract.d.ts.map +0 -1
  40. package/dist/adapter/ingest/game-contract.js +0 -30
  41. package/dist/adapter/ingest/overlay-applier.d.ts +0 -118
  42. package/dist/adapter/ingest/overlay-applier.d.ts.map +0 -1
  43. package/dist/adapter/ingest/overlay-applier.js +0 -132
  44. package/dist/adapter/ingest/overlay-apply.d.ts +0 -60
  45. package/dist/adapter/ingest/overlay-apply.d.ts.map +0 -1
  46. package/dist/adapter/ingest/overlay-apply.js +0 -101
  47. package/dist/adapter/ingest/overlay-file.d.ts +0 -79
  48. package/dist/adapter/ingest/overlay-file.d.ts.map +0 -1
  49. package/dist/adapter/ingest/overlay-file.js +0 -66
  50. package/dist/adapter/ingest/overlay-report.d.ts +0 -113
  51. package/dist/adapter/ingest/overlay-report.d.ts.map +0 -1
  52. package/dist/adapter/ingest/overlay-report.js +0 -103
  53. package/dist/adapter/ingest/scene-capture.d.ts +0 -97
  54. package/dist/adapter/ingest/scene-capture.d.ts.map +0 -1
  55. package/dist/adapter/ingest/scene-capture.js +0 -248
  56. package/dist/adapter/ingest/upstream-pin.d.ts +0 -47
  57. package/dist/adapter/ingest/upstream-pin.d.ts.map +0 -1
  58. package/dist/adapter/ingest/upstream-pin.js +0 -50
  59. package/dist/adapter/loop-gate-report.d.ts +0 -34
  60. package/dist/adapter/loop-gate-report.d.ts.map +0 -1
  61. package/dist/adapter/loop-gate-report.js +0 -37
  62. package/dist/adapter/rapier-physics-adapter.d.ts +0 -12
  63. package/dist/adapter/rapier-physics-adapter.d.ts.map +0 -1
  64. package/dist/adapter/rapier-physics-adapter.js +0 -46
  65. package/dist/adapter/system-adapter.d.ts +0 -206
  66. package/dist/adapter/system-adapter.d.ts.map +0 -1
  67. package/dist/adapter/system-adapter.js +0 -13
  68. package/dist/adapter/transform.d.ts +0 -18
  69. package/dist/adapter/transform.d.ts.map +0 -1
  70. package/dist/adapter/transform.js +0 -1
  71. package/dist/adapter/vgai-scene-game-adapter.d.ts +0 -108
  72. package/dist/adapter/vgai-scene-game-adapter.d.ts.map +0 -1
  73. package/dist/adapter/vgai-scene-game-adapter.js +0 -762
  74. package/dist/ai/navigation.d.ts +0 -64
  75. package/dist/ai/navigation.d.ts.map +0 -1
  76. package/dist/ai/navigation.js +0 -133
  77. package/dist/animation/anim-graph-types.d.ts +0 -25
  78. package/dist/animation/anim-graph-types.d.ts.map +0 -1
  79. package/dist/animation/anim-graph-types.js +0 -1
  80. package/dist/animation/animation-clock.d.ts +0 -213
  81. package/dist/animation/animation-clock.d.ts.map +0 -1
  82. package/dist/animation/animation-clock.js +0 -301
  83. package/dist/animation/blend-node.d.ts +0 -22
  84. package/dist/animation/blend-node.d.ts.map +0 -1
  85. package/dist/animation/blend-node.js +0 -97
  86. package/dist/animation/camera-ownership.d.ts +0 -250
  87. package/dist/animation/camera-ownership.d.ts.map +0 -1
  88. package/dist/animation/camera-ownership.js +0 -169
  89. package/dist/animation/cinematic-cues.d.ts +0 -200
  90. package/dist/animation/cinematic-cues.d.ts.map +0 -1
  91. package/dist/animation/cinematic-cues.js +0 -213
  92. package/dist/animation/clip-map.d.ts +0 -12
  93. package/dist/animation/clip-map.d.ts.map +0 -1
  94. package/dist/animation/clip-map.js +0 -37
  95. package/dist/animation/gsap-registration.d.ts +0 -119
  96. package/dist/animation/gsap-registration.d.ts.map +0 -1
  97. package/dist/animation/gsap-registration.js +0 -92
  98. package/dist/animation/theatre-clock-binding.d.ts +0 -89
  99. package/dist/animation/theatre-clock-binding.d.ts.map +0 -1
  100. package/dist/animation/theatre-clock-binding.js +0 -29
  101. package/dist/animation/theatre-director.d.ts +0 -242
  102. package/dist/animation/theatre-director.d.ts.map +0 -1
  103. package/dist/animation/theatre-director.js +0 -235
  104. package/dist/animation/theatre-object-binding.d.ts +0 -305
  105. package/dist/animation/theatre-object-binding.d.ts.map +0 -1
  106. package/dist/animation/theatre-object-binding.js +0 -351
  107. package/dist/animation/xstate-animation-binding.d.ts +0 -56
  108. package/dist/animation/xstate-animation-binding.d.ts.map +0 -1
  109. package/dist/animation/xstate-animation-binding.js +0 -331
  110. package/dist/animation/xstate-animation-meta.d.ts +0 -266
  111. package/dist/animation/xstate-animation-meta.d.ts.map +0 -1
  112. package/dist/animation/xstate-animation-meta.js +0 -252
  113. package/dist/assets.d.ts +0 -26
  114. package/dist/assets.d.ts.map +0 -1
  115. package/dist/assets.js +0 -55
  116. package/dist/audio/index.d.ts +0 -4
  117. package/dist/audio/index.d.ts.map +0 -1
  118. package/dist/audio/index.js +0 -24
  119. package/dist/audio/tone-clock-binding.d.ts +0 -75
  120. package/dist/audio/tone-clock-binding.d.ts.map +0 -1
  121. package/dist/audio/tone-clock-binding.js +0 -29
  122. package/dist/audio/tone-context.d.ts +0 -114
  123. package/dist/audio/tone-context.d.ts.map +0 -1
  124. package/dist/audio/tone-context.js +0 -39
  125. package/dist/audio/tone-offline-render.d.ts +0 -90
  126. package/dist/audio/tone-offline-render.d.ts.map +0 -1
  127. package/dist/audio/tone-offline-render.js +0 -56
  128. package/dist/audio/wav-encode.d.ts +0 -38
  129. package/dist/audio/wav-encode.d.ts.map +0 -1
  130. package/dist/audio/wav-encode.js +0 -97
  131. package/dist/character/cloth-sim.d.ts +0 -179
  132. package/dist/character/cloth-sim.d.ts.map +0 -1
  133. package/dist/character/cloth-sim.js +0 -334
  134. package/dist/character/spring-chain.d.ts +0 -135
  135. package/dist/character/spring-chain.d.ts.map +0 -1
  136. package/dist/character/spring-chain.js +0 -165
  137. package/dist/core/game-loop.d.ts +0 -42
  138. package/dist/core/game-loop.d.ts.map +0 -1
  139. package/dist/core/game-loop.js +0 -167
  140. package/dist/core/seeded-random.d.ts +0 -69
  141. package/dist/core/seeded-random.d.ts.map +0 -1
  142. package/dist/core/seeded-random.js +0 -121
  143. package/dist/core/system-runner.d.ts +0 -120
  144. package/dist/core/system-runner.d.ts.map +0 -1
  145. package/dist/core/system-runner.js +0 -297
  146. package/dist/core/types.d.ts +0 -92
  147. package/dist/core/types.d.ts.map +0 -1
  148. package/dist/core/types.js +0 -25
  149. package/dist/data/data-asset.d.ts +0 -101
  150. package/dist/data/data-asset.d.ts.map +0 -1
  151. package/dist/data/data-asset.js +0 -122
  152. package/dist/data/data-check-core.d.ts +0 -110
  153. package/dist/data/data-check-core.d.ts.map +0 -1
  154. package/dist/data/data-check-core.js +0 -178
  155. package/dist/data/data-ref.d.ts +0 -79
  156. package/dist/data/data-ref.d.ts.map +0 -1
  157. package/dist/data/data-ref.js +0 -130
  158. package/dist/data/vite-plugin-data.d.ts +0 -79
  159. package/dist/data/vite-plugin-data.d.ts.map +0 -1
  160. package/dist/data/vite-plugin-data.js +0 -217
  161. package/dist/dev/console-bridge.d.ts +0 -22
  162. package/dist/dev/console-bridge.d.ts.map +0 -1
  163. package/dist/dev/console-bridge.js +0 -71
  164. package/dist/dev/debug-draw.d.ts +0 -24
  165. package/dist/dev/debug-draw.d.ts.map +0 -1
  166. package/dist/dev/debug-draw.js +0 -73
  167. package/dist/dev/logger.d.ts +0 -30
  168. package/dist/dev/logger.d.ts.map +0 -1
  169. package/dist/dev/logger.js +0 -90
  170. package/dist/dev/performance-profiler.d.ts +0 -60
  171. package/dist/dev/performance-profiler.d.ts.map +0 -1
  172. package/dist/dev/performance-profiler.js +0 -181
  173. package/dist/dev/webgl-gpu-timer.d.ts +0 -8
  174. package/dist/dev/webgl-gpu-timer.d.ts.map +0 -1
  175. package/dist/dev/webgl-gpu-timer.js +0 -52
  176. package/dist/ecs/component-manager.d.ts +0 -205
  177. package/dist/ecs/component-manager.d.ts.map +0 -1
  178. package/dist/ecs/component-manager.js +0 -706
  179. package/dist/ecs/game-component.d.ts +0 -146
  180. package/dist/ecs/game-component.d.ts.map +0 -1
  181. package/dist/ecs/game-component.js +0 -141
  182. package/dist/ecs/hmr-swap-report.d.ts +0 -53
  183. package/dist/ecs/hmr-swap-report.d.ts.map +0 -1
  184. package/dist/ecs/hmr-swap-report.js +0 -55
  185. package/dist/humanoid/bake.operation.d.ts +0 -119
  186. package/dist/humanoid/bake.operation.d.ts.map +0 -1
  187. package/dist/humanoid/bake.operation.js +0 -228
  188. package/dist/humanoid/body.d.ts +0 -101
  189. package/dist/humanoid/body.d.ts.map +0 -1
  190. package/dist/humanoid/body.js +0 -530
  191. package/dist/humanoid/clips.d.ts +0 -62
  192. package/dist/humanoid/clips.d.ts.map +0 -1
  193. package/dist/humanoid/clips.js +0 -121
  194. package/dist/humanoid/compose.d.ts +0 -75
  195. package/dist/humanoid/compose.d.ts.map +0 -1
  196. package/dist/humanoid/compose.js +0 -176
  197. package/dist/humanoid/generate.d.ts +0 -92
  198. package/dist/humanoid/generate.d.ts.map +0 -1
  199. package/dist/humanoid/generate.js +0 -124
  200. package/dist/humanoid/index.d.ts +0 -24
  201. package/dist/humanoid/index.d.ts.map +0 -1
  202. package/dist/humanoid/index.js +0 -18
  203. package/dist/humanoid/schema.d.ts +0 -35
  204. package/dist/humanoid/schema.d.ts.map +0 -1
  205. package/dist/humanoid/schema.js +0 -87
  206. package/dist/humanoid/skeleton.d.ts +0 -103
  207. package/dist/humanoid/skeleton.d.ts.map +0 -1
  208. package/dist/humanoid/skeleton.js +0 -289
  209. package/dist/index.d.ts +0 -37
  210. package/dist/index.d.ts.map +0 -1
  211. package/dist/index.js +0 -30
  212. package/dist/input/input-manager.d.ts +0 -945
  213. package/dist/input/input-manager.d.ts.map +0 -1
  214. package/dist/input/input-manager.js +0 -2207
  215. package/dist/input/input-types.d.ts +0 -174
  216. package/dist/input/input-types.d.ts.map +0 -1
  217. package/dist/input/input-types.js +0 -1
  218. package/dist/input/prompt-labels.d.ts +0 -21
  219. package/dist/input/prompt-labels.d.ts.map +0 -1
  220. package/dist/input/prompt-labels.js +0 -121
  221. package/dist/input/rebind-controller.d.ts +0 -59
  222. package/dist/input/rebind-controller.d.ts.map +0 -1
  223. package/dist/input/rebind-controller.js +0 -85
  224. package/dist/input/schema.d.ts +0 -16
  225. package/dist/input/schema.d.ts.map +0 -1
  226. package/dist/input/schema.js +0 -228
  227. package/dist/loader.d.ts +0 -43
  228. package/dist/loader.d.ts.map +0 -1
  229. package/dist/loader.js +0 -59
  230. package/dist/manifest/index.d.ts +0 -5
  231. package/dist/manifest/index.d.ts.map +0 -1
  232. package/dist/manifest/index.js +0 -8
  233. package/dist/manifest/load-file.d.ts +0 -4
  234. package/dist/manifest/load-file.d.ts.map +0 -1
  235. package/dist/manifest/load-file.js +0 -14
  236. package/dist/manifest/load.d.ts +0 -144
  237. package/dist/manifest/load.d.ts.map +0 -1
  238. package/dist/manifest/load.js +0 -273
  239. package/dist/manifest/schema.d.ts +0 -230
  240. package/dist/manifest/schema.d.ts.map +0 -1
  241. package/dist/manifest/schema.js +0 -394
  242. package/dist/physics/collision-system.d.ts +0 -41
  243. package/dist/physics/collision-system.d.ts.map +0 -1
  244. package/dist/physics/collision-system.js +0 -64
  245. package/dist/physics/physics-registry.d.ts +0 -45
  246. package/dist/physics/physics-registry.d.ts.map +0 -1
  247. package/dist/physics/physics-registry.js +0 -65
  248. package/dist/physics/transform-writer.d.ts +0 -16
  249. package/dist/physics/transform-writer.d.ts.map +0 -1
  250. package/dist/physics/transform-writer.js +0 -38
  251. package/dist/physics/trigger-dispatch.d.ts +0 -24
  252. package/dist/physics/trigger-dispatch.d.ts.map +0 -1
  253. package/dist/physics/trigger-dispatch.js +0 -80
  254. package/dist/react/game-state.d.ts +0 -156
  255. package/dist/react/game-state.d.ts.map +0 -1
  256. package/dist/react/game-state.js +0 -222
  257. package/dist/react/root-adapter.d.ts +0 -11
  258. package/dist/react/root-adapter.d.ts.map +0 -1
  259. package/dist/react/root-adapter.js +0 -41
  260. package/dist/react/unmanaged-root-detector.d.ts +0 -12
  261. package/dist/react/unmanaged-root-detector.d.ts.map +0 -1
  262. package/dist/react/unmanaged-root-detector.js +0 -45
  263. package/dist/react/use-data.d.ts +0 -60
  264. package/dist/react/use-data.d.ts.map +0 -1
  265. package/dist/react/use-data.js +0 -101
  266. package/dist/react/use-selection.d.ts +0 -75
  267. package/dist/react/use-selection.d.ts.map +0 -1
  268. package/dist/react/use-selection.js +0 -90
  269. package/dist/render/auto-batcher.d.ts +0 -34
  270. package/dist/render/auto-batcher.d.ts.map +0 -1
  271. package/dist/render/auto-batcher.js +0 -140
  272. package/dist/render/render-batch-system.d.ts +0 -33
  273. package/dist/render/render-batch-system.d.ts.map +0 -1
  274. package/dist/render/render-batch-system.js +0 -230
  275. package/dist/render/render-features.d.ts +0 -47
  276. package/dist/render/render-features.d.ts.map +0 -1
  277. package/dist/render/render-features.js +0 -105
  278. package/dist/render/render-settings.d.ts +0 -36
  279. package/dist/render/render-settings.d.ts.map +0 -1
  280. package/dist/render/render-settings.js +0 -51
  281. package/dist/runtime/create-runtime.d.ts +0 -249
  282. package/dist/runtime/create-runtime.d.ts.map +0 -1
  283. package/dist/runtime/create-runtime.js +0 -641
  284. package/dist/runtime/debug-bridge.d.ts +0 -257
  285. package/dist/runtime/debug-bridge.d.ts.map +0 -1
  286. package/dist/runtime/debug-bridge.js +0 -224
  287. package/dist/runtime/debug-registry.d.ts +0 -288
  288. package/dist/runtime/debug-registry.d.ts.map +0 -1
  289. package/dist/runtime/debug-registry.js +0 -513
  290. package/dist/runtime/frame-selector-cache.d.ts +0 -41
  291. package/dist/runtime/frame-selector-cache.d.ts.map +0 -1
  292. package/dist/runtime/frame-selector-cache.js +0 -65
  293. package/dist/runtime/game.d.ts +0 -496
  294. package/dist/runtime/game.d.ts.map +0 -1
  295. package/dist/runtime/game.js +0 -741
  296. package/dist/runtime/gameplay-rng-trap.d.ts +0 -48
  297. package/dist/runtime/gameplay-rng-trap.d.ts.map +0 -1
  298. package/dist/runtime/gameplay-rng-trap.js +0 -96
  299. package/dist/runtime/input-router.d.ts +0 -78
  300. package/dist/runtime/input-router.d.ts.map +0 -1
  301. package/dist/runtime/input-router.js +0 -171
  302. package/dist/runtime/mount-game.d.ts +0 -129
  303. package/dist/runtime/mount-game.d.ts.map +0 -1
  304. package/dist/runtime/mount-game.js +0 -152
  305. package/dist/runtime/mount-manifest.d.ts +0 -173
  306. package/dist/runtime/mount-manifest.d.ts.map +0 -1
  307. package/dist/runtime/mount-manifest.js +0 -297
  308. package/dist/runtime/render-audio-control.d.ts +0 -110
  309. package/dist/runtime/render-audio-control.d.ts.map +0 -1
  310. package/dist/runtime/render-audio-control.js +0 -111
  311. package/dist/runtime/render-control.d.ts +0 -291
  312. package/dist/runtime/render-control.d.ts.map +0 -1
  313. package/dist/runtime/render-control.js +0 -264
  314. package/dist/runtime/render-seed.d.ts +0 -57
  315. package/dist/runtime/render-seed.d.ts.map +0 -1
  316. package/dist/runtime/render-seed.js +0 -74
  317. package/dist/runtime/state-bridge.d.ts +0 -61
  318. package/dist/runtime/state-bridge.d.ts.map +0 -1
  319. package/dist/runtime/state-bridge.js +0 -63
  320. package/dist/runtime/types.d.ts +0 -253
  321. package/dist/runtime/types.d.ts.map +0 -1
  322. package/dist/runtime/types.js +0 -1
  323. package/dist/scene/asset-loaders.d.ts +0 -79
  324. package/dist/scene/asset-loaders.d.ts.map +0 -1
  325. package/dist/scene/asset-loaders.js +0 -141
  326. package/dist/scene/asset-paths.d.ts +0 -11
  327. package/dist/scene/asset-paths.d.ts.map +0 -1
  328. package/dist/scene/asset-paths.js +0 -108
  329. package/dist/scene/asset-ref-check.d.ts +0 -88
  330. package/dist/scene/asset-ref-check.d.ts.map +0 -1
  331. package/dist/scene/asset-ref-check.js +0 -214
  332. package/dist/scene/asset-registry.d.ts +0 -38
  333. package/dist/scene/asset-registry.d.ts.map +0 -1
  334. package/dist/scene/asset-registry.js +0 -66
  335. package/dist/scene/collider-dimensions.d.ts +0 -63
  336. package/dist/scene/collider-dimensions.d.ts.map +0 -1
  337. package/dist/scene/collider-dimensions.js +0 -98
  338. package/dist/scene/component-registry.d.ts +0 -22
  339. package/dist/scene/component-registry.d.ts.map +0 -1
  340. package/dist/scene/component-registry.js +0 -37
  341. package/dist/scene/defaults.d.ts +0 -252
  342. package/dist/scene/defaults.d.ts.map +0 -1
  343. package/dist/scene/defaults.js +0 -151
  344. package/dist/scene/geometries/index.d.ts +0 -8
  345. package/dist/scene/geometries/index.d.ts.map +0 -1
  346. package/dist/scene/geometries/index.js +0 -7
  347. package/dist/scene/geometries/terrain.d.ts +0 -2
  348. package/dist/scene/geometries/terrain.d.ts.map +0 -1
  349. package/dist/scene/geometries/terrain.js +0 -37
  350. package/dist/scene/geometry-registry.d.ts +0 -24
  351. package/dist/scene/geometry-registry.d.ts.map +0 -1
  352. package/dist/scene/geometry-registry.js +0 -20
  353. package/dist/scene/instance-registry.d.ts +0 -36
  354. package/dist/scene/instance-registry.d.ts.map +0 -1
  355. package/dist/scene/instance-registry.js +0 -55
  356. package/dist/scene/instancers/grid.d.ts +0 -2
  357. package/dist/scene/instancers/grid.d.ts.map +0 -1
  358. package/dist/scene/instancers/grid.js +0 -36
  359. package/dist/scene/instancers/index.d.ts +0 -8
  360. package/dist/scene/instancers/index.d.ts.map +0 -1
  361. package/dist/scene/instancers/index.js +0 -7
  362. package/dist/scene/light-camera-factory.d.ts +0 -23
  363. package/dist/scene/light-camera-factory.d.ts.map +0 -1
  364. package/dist/scene/light-camera-factory.js +0 -68
  365. package/dist/scene/material-factory.d.ts +0 -17
  366. package/dist/scene/material-factory.d.ts.map +0 -1
  367. package/dist/scene/material-factory.js +0 -197
  368. package/dist/scene/material-registry.d.ts +0 -40
  369. package/dist/scene/material-registry.d.ts.map +0 -1
  370. package/dist/scene/material-registry.js +0 -44
  371. package/dist/scene/materials/index.d.ts +0 -8
  372. package/dist/scene/materials/index.d.ts.map +0 -1
  373. package/dist/scene/materials/index.js +0 -7
  374. package/dist/scene/materials/water.d.ts +0 -2
  375. package/dist/scene/materials/water.d.ts.map +0 -1
  376. package/dist/scene/materials/water.js +0 -54
  377. package/dist/scene/parse.d.ts +0 -23
  378. package/dist/scene/parse.d.ts.map +0 -1
  379. package/dist/scene/parse.js +0 -179
  380. package/dist/scene/particles-factory.d.ts +0 -33
  381. package/dist/scene/particles-factory.d.ts.map +0 -1
  382. package/dist/scene/particles-factory.js +0 -282
  383. package/dist/scene/scene-apply.d.ts +0 -109
  384. package/dist/scene/scene-apply.d.ts.map +0 -1
  385. package/dist/scene/scene-apply.js +0 -370
  386. package/dist/scene/scene-diff-schema.d.ts +0 -285
  387. package/dist/scene/scene-diff-schema.d.ts.map +0 -1
  388. package/dist/scene/scene-diff-schema.js +0 -92
  389. package/dist/scene/scene-diff-types.d.ts +0 -40
  390. package/dist/scene/scene-diff-types.d.ts.map +0 -1
  391. package/dist/scene/scene-diff-types.js +0 -14
  392. package/dist/scene/scene-loader.d.ts +0 -167
  393. package/dist/scene/scene-loader.d.ts.map +0 -1
  394. package/dist/scene/scene-loader.js +0 -1211
  395. package/dist/scene/scene-query.d.ts +0 -11
  396. package/dist/scene/scene-query.d.ts.map +0 -1
  397. package/dist/scene/scene-query.js +0 -63
  398. package/dist/scene/scene-types.d.ts +0 -10
  399. package/dist/scene/scene-types.d.ts.map +0 -1
  400. package/dist/scene/scene-types.js +0 -8
  401. package/dist/scene/scene-version.d.ts +0 -26
  402. package/dist/scene/scene-version.d.ts.map +0 -1
  403. package/dist/scene/scene-version.js +0 -34
  404. package/dist/scene/schema/animation.d.ts +0 -8
  405. package/dist/scene/schema/animation.d.ts.map +0 -1
  406. package/dist/scene/schema/animation.js +0 -42
  407. package/dist/scene/schema/audio.d.ts +0 -13
  408. package/dist/scene/schema/audio.d.ts.map +0 -1
  409. package/dist/scene/schema/audio.js +0 -22
  410. package/dist/scene/schema/camera.d.ts +0 -28
  411. package/dist/scene/schema/camera.d.ts.map +0 -1
  412. package/dist/scene/schema/camera.js +0 -17
  413. package/dist/scene/schema/collider.d.ts +0 -40
  414. package/dist/scene/schema/collider.d.ts.map +0 -1
  415. package/dist/scene/schema/collider.js +0 -55
  416. package/dist/scene/schema/entity-ref.d.ts +0 -31
  417. package/dist/scene/schema/entity-ref.d.ts.map +0 -1
  418. package/dist/scene/schema/entity-ref.js +0 -61
  419. package/dist/scene/schema/entity.d.ts +0 -1036
  420. package/dist/scene/schema/entity.d.ts.map +0 -1
  421. package/dist/scene/schema/entity.js +0 -153
  422. package/dist/scene/schema/environment.d.ts +0 -425
  423. package/dist/scene/schema/environment.d.ts.map +0 -1
  424. package/dist/scene/schema/environment.js +0 -357
  425. package/dist/scene/schema/index.d.ts +0 -37
  426. package/dist/scene/schema/index.d.ts.map +0 -1
  427. package/dist/scene/schema/index.js +0 -19
  428. package/dist/scene/schema/instances.d.ts +0 -14
  429. package/dist/scene/schema/instances.d.ts.map +0 -1
  430. package/dist/scene/schema/instances.js +0 -28
  431. package/dist/scene/schema/joint.d.ts +0 -23
  432. package/dist/scene/schema/joint.d.ts.map +0 -1
  433. package/dist/scene/schema/joint.js +0 -23
  434. package/dist/scene/schema/light.d.ts +0 -38
  435. package/dist/scene/schema/light.d.ts.map +0 -1
  436. package/dist/scene/schema/light.js +0 -26
  437. package/dist/scene/schema/material.d.ts +0 -199
  438. package/dist/scene/schema/material.d.ts.map +0 -1
  439. package/dist/scene/schema/material.js +0 -103
  440. package/dist/scene/schema/mesh.d.ts +0 -48
  441. package/dist/scene/schema/mesh.d.ts.map +0 -1
  442. package/dist/scene/schema/mesh.js +0 -82
  443. package/dist/scene/schema/particles.d.ts +0 -2178
  444. package/dist/scene/schema/particles.d.ts.map +0 -1
  445. package/dist/scene/schema/particles.js +0 -321
  446. package/dist/scene/schema/physics.d.ts +0 -56
  447. package/dist/scene/schema/physics.d.ts.map +0 -1
  448. package/dist/scene/schema/physics.js +0 -37
  449. package/dist/scene/schema/scene-file.d.ts +0 -303
  450. package/dist/scene/schema/scene-file.d.ts.map +0 -1
  451. package/dist/scene/schema/scene-file.js +0 -256
  452. package/dist/scene/schema/shadow.d.ts +0 -28
  453. package/dist/scene/schema/shadow.d.ts.map +0 -1
  454. package/dist/scene/schema/shadow.js +0 -20
  455. package/dist/scene/schema/spline.d.ts +0 -25
  456. package/dist/scene/schema/spline.d.ts.map +0 -1
  457. package/dist/scene/schema/spline.js +0 -15
  458. package/dist/scene/schema/tuples.d.ts +0 -12
  459. package/dist/scene/schema/tuples.d.ts.map +0 -1
  460. package/dist/scene/schema/tuples.js +0 -14
  461. package/dist/scene/user-data.d.ts +0 -185
  462. package/dist/scene/user-data.d.ts.map +0 -1
  463. package/dist/scene/user-data.js +0 -144
  464. package/dist/setup/setup-audio.d.ts +0 -20
  465. package/dist/setup/setup-audio.d.ts.map +0 -1
  466. package/dist/setup/setup-audio.js +0 -41
  467. package/dist/setup/setup-particles.d.ts +0 -17
  468. package/dist/setup/setup-particles.d.ts.map +0 -1
  469. package/dist/setup/setup-particles.js +0 -16
  470. package/dist/setup/setup-physics.d.ts +0 -25
  471. package/dist/setup/setup-physics.d.ts.map +0 -1
  472. package/dist/setup/setup-physics.js +0 -51
  473. package/dist/setup/setup-renderer.d.ts +0 -69
  474. package/dist/setup/setup-renderer.d.ts.map +0 -1
  475. package/dist/setup/setup-renderer.js +0 -363
  476. package/dist/tools/define-tool.d.ts +0 -130
  477. package/dist/tools/define-tool.d.ts.map +0 -1
  478. package/dist/tools/define-tool.js +0 -96
  479. package/dist/world2d/authoring-2d.d.ts +0 -80
  480. package/dist/world2d/authoring-2d.d.ts.map +0 -1
  481. package/dist/world2d/authoring-2d.js +0 -195
  482. package/dist/world2d/capture-to-scene2d.d.ts +0 -5
  483. package/dist/world2d/capture-to-scene2d.d.ts.map +0 -1
  484. package/dist/world2d/capture-to-scene2d.js +0 -49
  485. package/dist/world2d/collision-2d.d.ts +0 -52
  486. package/dist/world2d/collision-2d.d.ts.map +0 -1
  487. package/dist/world2d/collision-2d.js +0 -70
  488. package/dist/world2d/components-2d.d.ts +0 -47
  489. package/dist/world2d/components-2d.d.ts.map +0 -1
  490. package/dist/world2d/components-2d.js +0 -77
  491. package/dist/world2d/index.d.ts +0 -34
  492. package/dist/world2d/index.d.ts.map +0 -1
  493. package/dist/world2d/index.js +0 -32
  494. package/dist/world2d/ingest-iframe-2d.d.ts +0 -82
  495. package/dist/world2d/ingest-iframe-2d.d.ts.map +0 -1
  496. package/dist/world2d/ingest-iframe-2d.js +0 -166
  497. package/dist/world2d/ingest2d.d.ts +0 -97
  498. package/dist/world2d/ingest2d.d.ts.map +0 -1
  499. package/dist/world2d/ingest2d.js +0 -40
  500. package/dist/world2d/physics2d-registry.d.ts +0 -24
  501. package/dist/world2d/physics2d-registry.d.ts.map +0 -1
  502. package/dist/world2d/physics2d-registry.js +0 -38
  503. package/dist/world2d/pixi-game-adapter.d.ts +0 -107
  504. package/dist/world2d/pixi-game-adapter.d.ts.map +0 -1
  505. package/dist/world2d/pixi-game-adapter.js +0 -210
  506. package/dist/world2d/pixi-surface.d.ts +0 -39
  507. package/dist/world2d/pixi-surface.d.ts.map +0 -1
  508. package/dist/world2d/pixi-surface.js +0 -47
  509. package/dist/world2d/scene-capture-2d.d.ts +0 -43
  510. package/dist/world2d/scene-capture-2d.d.ts.map +0 -1
  511. package/dist/world2d/scene-capture-2d.js +0 -92
  512. package/dist/world2d/scene2d-loader.d.ts +0 -27
  513. package/dist/world2d/scene2d-loader.d.ts.map +0 -1
  514. package/dist/world2d/scene2d-loader.js +0 -275
  515. package/dist/world2d/schema/entity2d.d.ts +0 -102
  516. package/dist/world2d/schema/entity2d.d.ts.map +0 -1
  517. package/dist/world2d/schema/entity2d.js +0 -119
  518. package/dist/world2d/schema/physics2d.d.ts +0 -46
  519. package/dist/world2d/schema/physics2d.d.ts.map +0 -1
  520. package/dist/world2d/schema/physics2d.js +0 -45
  521. package/dist/world2d/schema/sprite.d.ts +0 -42
  522. package/dist/world2d/schema/sprite.d.ts.map +0 -1
  523. package/dist/world2d/schema/sprite.js +0 -63
  524. package/dist/world2d/schema/tilemap.d.ts +0 -15
  525. package/dist/world2d/schema/tilemap.d.ts.map +0 -1
  526. package/dist/world2d/schema/tilemap.js +0 -19
  527. package/dist/world2d/schema/tuples2d.d.ts +0 -20
  528. package/dist/world2d/schema/tuples2d.d.ts.map +0 -1
  529. package/dist/world2d/schema/tuples2d.js +0 -19
  530. package/dist/world2d/system-adapters-2d.d.ts +0 -16
  531. package/dist/world2d/system-adapters-2d.d.ts.map +0 -1
  532. package/dist/world2d/system-adapters-2d.js +0 -37
  533. package/dist/world2d/transform-writer-2d.d.ts +0 -16
  534. package/dist/world2d/transform-writer-2d.d.ts.map +0 -1
  535. package/dist/world2d/transform-writer-2d.js +0 -22
  536. package/dist/world2d/types.d.ts +0 -59
  537. package/dist/world2d/types.d.ts.map +0 -1
  538. package/dist/world2d/types.js +0 -1
@@ -1,945 +0,0 @@
1
- import type { ActionValueOf, ActionValueSource, ActionValueType, BindingConflict, BindingPrompt, InputBinding, InputMapFile, PromptDevice, Vector2 } from './input-types';
2
- /**
3
- * Thrown by `InputManager.setVirtualAction`/`tapVirtualAction` (Task 1.4,
4
- * ACCEPTANCE-DRIVER-BUILD-PLAN.md / SYNTHETIC-PLAYER-SPEC.md §3.2) for an
5
- * action name that was never `registerAction`/`loadMap`-ed. Carries a
6
- * machine-readable `code` and `data.registered` (every declared action name)
7
- * rather than requiring a caller to parse the message.
8
- */
9
- export declare class InputActionError extends Error {
10
- readonly code: "INPUT_ACTION_NOT_FOUND";
11
- readonly data: {
12
- registered: string[];
13
- };
14
- constructor(action: string, method: string, registered: string[]);
15
- }
16
- /**
17
- * Thrown by `InputManager.scheduleActionAtTick` (D15/T-D15.5,
18
- * docs/D15-DETERMINISM-DESIGN.md §2.c) when the named `tick` has already
19
- * elapsed — scheduling only ever applies to the CURRENT or a future tick,
20
- * never one already serviced by `poll()`. Carries `data.currentTick` — the
21
- * NEXT tick `poll()` will service (not the tick that just elapsed) — so a
22
- * caller can retry by scheduling for `data.currentTick` or later.
23
- */
24
- export declare class InputTickError extends Error {
25
- readonly code: "TICK_ALREADY_PASSED";
26
- readonly data: {
27
- currentTick: number;
28
- };
29
- constructor(tick: number, currentTick: number);
30
- }
31
- /**
32
- * Maps raw keyboard/mouse/gamepad events → named actions.
33
- *
34
- * Usage:
35
- * const input = new InputManager();
36
- * await input.loadMap('inputmaps/default.inputmap.json');
37
- * // In game loop:
38
- * input.poll(); // call at start of frame
39
- * if (input.isPressed('jump')) { ... }
40
- * if (input.isJustPressed('attack')) { ... }
41
- * input.endFrame(); // call at end of frame
42
- *
43
- * F1 (spec §12 "Define Typed Action Values") — typed action values:
44
- *
45
- * Every action DECLARES a value shape (`InputAction.valueType`, defaulted to
46
- * `'digital'` — see `input-types.ts`'s `ActionValueType`). Each shape has its
47
- * own typed getter, none of which return `any`:
48
- *
49
- * - `'digital'` — `isPressed`/`isJustPressed`/`isJustReleased` -> `boolean`
50
- * - `'scalar'` — `getScalar` -> `number`
51
- * - `'vector2'` — `getVector2` -> `Vector2` ({x,y})
52
- * - `'pointerDelta'` — `getPointerDelta` -> `Vector2`
53
- * - `'pointerPosition'` — `getPointerPosition` -> `Vector2`
54
- *
55
- * Reading an action through the WRONG getter (e.g. `getScalar` on a
56
- * `'digital'` action) throws — that's the type-safety enforcement point,
57
- * since actions are declared in data (JSON), not TS types, so there's no
58
- * compiler backstop otherwise. `readAction(name, expectedType)` is a generic
59
- * entry point over the same getters, typed via `ActionValueOf<T>`.
60
- *
61
- * Each typed getter has a `*Source` sibling (e.g. `getScalarSource`) that
62
- * returns `ActionValueSource | null` — which binding (and, for gamepad
63
- * bindings, which connected gamepad, or for injected test bindings, which
64
- * named source) produced the current value. That's the "device/source
65
- * metadata" AC.
66
- *
67
- * Deadzone + normalization:
68
- * - scalar: below `deadzone` magnitude -> 0; at/above it, rescaled from 0
69
- * (at the deadzone edge) to ±1 (at |raw| = 1), sign preserved
70
- * (`rescaleScalar`).
71
- * - vector2: below `deadzone` magnitude -> {0,0}; at/above it, direction is
72
- * preserved and magnitude is rescaled the same way, then the result is
73
- * clamped to the unit circle — magnitude never exceeds 1 even for a raw
74
- * diagonal input like {1,1} (`rescaleVector2`).
75
- *
76
- * Simultaneous-binding combine rules (documented here, spec §12 F1
77
- * "simultaneous bindings combine predictably"):
78
- * - digital: OR — any one satisfied binding makes the action pressed
79
- * (pre-existing behavior, unchanged).
80
- * - scalar: max-magnitude across contributing bindings' (deadzone-applied)
81
- * values, sign preserved; ties keep the first-listed binding
82
- * (deterministic given binding array order).
83
- * - vector2: sum contributing (deadzone-applied) {x,y} values component-
84
- * wise, then clamp the sum to the unit circle (never renormalized UP —
85
- * only ever scaled down if the sum exceeds magnitude 1).
86
- * - pointerDelta: sum contributing deltas (matches the existing
87
- * mouseDeltaX/Y + lookStick accumulation precedent below).
88
- * - pointerPosition: last-write-wins — the contributing source most
89
- * recently updated (by injection call order) wins; position isn't
90
- * additive so summing would be meaningless.
91
- *
92
- * Synthetic input injection (test hook, also the shape of F2's "injected
93
- * test input" backend): `injectAxis`/`injectVector2`/`injectPointerDelta`/
94
- * `injectPointerPosition` push a raw value into a named source, read back by
95
- * binding an action to `{ type: 'test_axis' | 'test_vector2' |
96
- * 'test_pointer_delta' | 'test_pointer_position', sourceId }` — the exact
97
- * same aggregation path (deadzone/normalize/combine) real device bindings
98
- * use.
99
- *
100
- * F2 (spec §12 "Complete Device Backends") completes the real-device side of
101
- * that same typed-value path:
102
- *
103
- * - `mouse_move` — un-rejected (schema.ts). Feeds `getPointerDelta` (raw
104
- * accumulated `mouseDeltaX/Y`, no deadzone) and `getVector2` (the same
105
- * delta, deadzone-rescaled + unit-circle-clamped).
106
- * - `gamepad_axis_pair` — un-rejected (schema.ts). Feeds `getVector2` with
107
- * the coupled `(xAxis, yAxis)` reading, deadzone-rescaled like a real
108
- * stick (default deadzone 0.15, matching `gamepad_axis`).
109
- * - `touch_button`/`touch_stick` — new binding kinds for touch/virtual
110
- * controls. `setTouchButton(sourceId, pressed)` feeds a digital action
111
- * (edge-tracked like `mouse_button`); `setTouchStick(sourceId, value)`
112
- * feeds a vector2 action (deadzone-rescaled like a gamepad stick). These
113
- * are the injectable entry points a real on-screen touch UI's own
114
- * touchstart/touchmove/touchend handlers would call — that DOM wiring is
115
- * a thin adapter at the edge (browser-verified separately, e.g. F4/e2e);
116
- * the mapping logic here is unit-tested headlessly with no DOM.
117
- * - Focus gating — `blur`/`focus` on `window` (guarded, real DOM only) now
118
- * drop input the same way `setEnabled(false)` does (flushing held
119
- * key/mouse/touch-button state) without touching the `enabled` flag the
120
- * editor drives — see `focused`/`inputActive` below. This is what stops
121
- * a stuck key/button when the user alt-tabs away mid-press.
122
- * - Pointer lock — `pointerlockchange` on `document` (guarded) tracks
123
- * `isPointerLocked()`; losing lock flushes mouse-button state (a click
124
- * held at the moment lock exits must not stick).
125
- * - Gamepad device identity — `getGamepadInfo(index)` exposes `{index, id,
126
- * mapping, connected}`; `ActionValueSource.gamepadId` (in addition to the
127
- * pre-existing `gamepadIndex`) is populated for every
128
- * gamepad_button/gamepad_axis/gamepad_axis_pair source.
129
- * - Disconnection/reconnection needs no new tracking: `poll()` already
130
- * re-reads `navigator.getGamepads()` every frame and every read (digital
131
- * edges, scalar/vector2 contributions) already skips a `null` gamepad
132
- * entry, so a disconnected gamepad's bound actions go neutral (and a
133
- * previously-held button correctly fires `isJustReleased`) with no
134
- * special-cased code — see the state-transition tests.
135
- *
136
- * F3 (spec §12 "Add Rebinding and Prompts") completes the input system with
137
- * rebinding, structural conflict detection, and device-prompt resolution:
138
- *
139
- * - Listing/mutating: `getBindings`/`setBindings`/`addBinding`/
140
- * `removeBinding`/`replaceBinding` — the same `this.actions` map F1/F2
141
- * already read, now with a public read + mutation surface (there was
142
- * previously none — every existing call site either loaded a map once or
143
- * read through the typed getters).
144
- * - Reset-to-defaults: `registerAction`/`loadMap`/`loadMapObject` snapshot
145
- * each action's bindings into `defaultBindings` (a deep clone) at
146
- * registration/load time; `resetBindings`/`resetAllBindings` restore from
147
- * that snapshot. Later rebinding calls do NOT touch the snapshot, so
148
- * "reset" always means "back to what was authored/loaded", not "back to
149
- * the last reset".
150
- * - Persist: `toInputMapFile()` serializes the live action set back into
151
- * the exact `.inputmap.json` shape (`InputMapFile`) `loadMap` reads;
152
- * `loadMapObject(data)` is `loadMap`'s synchronous, no-`fetch` sibling —
153
- * both funnel through the same `InputMapFileSchema`-validated
154
- * `applyParsedMap`. This is the round-trip seam: serialize, write/hand to
155
- * something else, reload, and rebound actions survive. It complements —
156
- * doesn't replace — the SDK's `project.inputMap.read/validate/update`
157
- * operations (B2, `packages/vgai-sdk/src/project/input-map-operations.ts`):
158
- * those are FILE-level (a CLI/agent editing the `.inputmap.json` on disk,
159
- * no running game involved); this is RUNTIME-level (a live game rebinding
160
- * while playing). Both validate through the identical
161
- * `InputMapFileSchema`, so a file B2 wrote loads here unchanged, and a
162
- * map this class serializes is a valid document for B2 to read back.
163
- * - Conflicts: `findConflicts(proposed, excludeActionName?)` scans every
164
- * OTHER registered action's bindings for one that's structurally
165
- * equivalent to `proposed` (see the private `bindingsCollide` — same
166
- * physical input identity: same key code, same mouse button, the same
167
- * gamepad button/axis/axis-pair, the same touch `sourceId`, etc.) and
168
- * returns the (possibly empty) list as plain `BindingConflict` data —
169
- * never throws. A rebinding UI calls this BEFORE calling
170
- * `addBinding`/`replaceBinding`/`setBindings` and decides what to do with
171
- * a non-empty result (block, warn, let the user steal the binding by
172
- * removing it from the other action first).
173
- * - Prompts: `getPrompt(actionName, device?, gamepadIndex?)` resolves a
174
- * `BindingPrompt` (display label + icon name) for whichever of the
175
- * action's bindings belongs to the requested `PromptDevice` family
176
- * (keyboard/mouse/gamepad/touch — `bindingDeviceFamily` in
177
- * `prompt-labels.ts`), using `getGamepadInfo` to prefer the standard
178
- * mapping's canonical glyph names (`'A'`, `'LB'`, ...) for gamepad
179
- * buttons and falling back to a raw index label (or a "disconnected"
180
- * label) when the pad isn't in standard mapping or isn't connected.
181
- * `device` is optional (F4 below) — omit it to resolve against
182
- * `getLastActiveDevice()` instead.
183
- *
184
- * F4 (spec §12 "Schema and Examples") closes F3's one open gap — a
185
- * current-ACTIVE-device tracker, so a prompt UI can switch its displayed
186
- * label as the player switches controllers instead of the caller having to
187
- * track that itself:
188
- *
189
- * - `getLastActiveDevice()` returns the `PromptDevice` family of whichever
190
- * input arrived most recently — keyboard on `keydown`, mouse on
191
- * `mousedown`/a real `mousemove`, gamepad on a button press or a stick
192
- * pushed meaningfully off-center (checked in `poll()`), touch on
193
- * `setTouchButton(_, true)` or `setTouchStick` pushed meaningfully
194
- * off-center. `null` before any input has arrived.
195
- * - `getPrompt(actionName)` (device omitted) resolves against it directly,
196
- * falling back to `'keyboard'` before any input has arrived — a HUD can
197
- * call it every frame with no extra bookkeeping and the label switches on
198
- * its own.
199
- */
200
- export declare class InputManager {
201
- private actions;
202
- private actionValueTypes;
203
- private defaultBindings;
204
- private loadedMapVersion;
205
- private keysDown;
206
- private keysJustDown;
207
- private keysJustUp;
208
- private mouseButtons;
209
- private mouseButtonsJustDown;
210
- private mouseButtonsJustUp;
211
- private mouseDeltaX;
212
- private mouseDeltaY;
213
- private gamepads;
214
- private gamepadButtonsDown;
215
- private gamepadButtonsPrev;
216
- private gamepadButtonsJustDown;
217
- private gamepadButtonsJustUp;
218
- private gamepadAxesCurrent;
219
- private gamepadAxesPrev;
220
- private lookStickX;
221
- private lookStickY;
222
- private testAxisValues;
223
- private testVector2Values;
224
- private testPointerDeltaAccum;
225
- private testPointerPositionValues;
226
- private pointerPositionSeq;
227
- private touchButtonsDown;
228
- private touchButtonsJustDown;
229
- private touchButtonsJustUp;
230
- private touchStickValues;
231
- private lastActiveDevice;
232
- /** Coarse "is this stick meaningfully off-center" check shared by the
233
- * gamepad and touch-stick active-device heuristics above — deliberately a
234
- * higher bar than a binding's own (often much smaller) configured
235
- * deadzone, since this is "did the player just grab this control", not
236
- * "does this binding's value count as non-zero". */
237
- private static isStickActive;
238
- private virtualDigitalHeld;
239
- private virtualDigitalTapQueued;
240
- private virtualDigitalTapActive;
241
- /** pulse-runner friction #4 — the release-edge mirror of
242
- * `virtualDigitalTapActive`: a direct `setVirtualAction(action, false)` (or
243
- * `clearVirtualActions()`) on an action that WAS held writes here so
244
- * `isJustReleased` fires exactly once, mirroring real `onKeyUp`'s
245
- * immediate `keysJustUp` write (no queue/promotion needed — unlike the
246
- * press edge, nothing in `poll()` reassigns this set out from under a
247
- * write that lands before `poll()` runs). Cleared every `endFrame()`,
248
- * same bracket as every other just-* edge set. */
249
- private virtualDigitalJustReleased;
250
- private virtualScalarValues;
251
- private virtualVector2Values;
252
- private currentTick;
253
- /** The last tick value `poll()` actually serviced, or `-1` before the
254
- * first call. Used to detect a GAP (this world's input phase didn't run
255
- * for one or more intervening ticks — e.g. frozen/paused while other
256
- * roots kept advancing the shared game tick) so any schedule entries
257
- * inside that gap can be dropped (with an observable event) instead of
258
- * silently rotting in {@link scheduledActions} forever. */
259
- private lastServicedTick;
260
- /** Pending `scheduleActionAtTick` actuations, grouped by their exact target
261
- * tick. Applied (and removed) at the START of that tick's `poll()` — see
262
- * `applyScheduledActionsForTick`. A tick whose input phase is skipped
263
- * entirely (this world paused/frozen, or a gap between two serviced
264
- * ticks) never reaches it — its scheduled entries are dropped, each
265
- * emitting one `'input.schedule.dropped'` debug event (`{tick, action}`)
266
- * via {@link setDebugEmit}'s sink if one is wired — NOT retried on a
267
- * later tick (mirrors `clearVirtualActions`-on-gate-close: no stuck
268
- * actuation ever silently fires late). */
269
- private scheduledActions;
270
- /** Optional sink for the `'input.schedule.dropped'` debug event (`{tick,
271
- * action}`) emitted whenever a scheduled entry is discarded because its
272
- * target tick's input phase never ran. Wired by whoever constructs this
273
- * `InputManager` with access to a `DebugRegistry`
274
- * (`vgai-scene-game-adapter.ts`, the same seed spot as
275
- * `setVirtualInputTarget`/`setInputActionsSource`) — `null` (the
276
- * default) for a bare/headless `InputManager`, in which case a drop
277
- * stays silent (matching pre-D15/T-D15.5 behavior). */
278
- private debugEmit;
279
- /** D15/T-D15.5 recording toggle — see {@link startInputRecording}. */
280
- private inputRecording;
281
- /** The post-gate action-delta trace (§2.c's format sketch) — capped so an
282
- * accidentally-long recording session can't grow this unboundedly. */
283
- private inputTrace;
284
- /** Last value recorded per action, so `recordPostGateTick` only ever
285
- * appends a DELTA (the format sketch's "deltas only" line), not a full
286
- * snapshot every tick. Cleared on `startInputRecording()`. */
287
- private lastTraceSnapshot;
288
- private disposed;
289
- /**
290
- * When false, all raw input is ignored and held/transient state is cleared.
291
- * The editor host drives this (T6.3, `packages/editor/src/play-mode.ts`) so
292
- * the running game only receives input while its viewport is the active,
293
- * focused surface — keystrokes typed into the editor (Scene tab, inspector
294
- * fields) must not leak into the game. A standalone game leaves this true
295
- * for its whole lifetime.
296
- */
297
- private enabled;
298
- /**
299
- * F2 — real window focus, distinct from `enabled` (which is the editor's
300
- * explicit play-mode gate). `false` while the tab/window is blurred (real
301
- * `blur`/`focus` events — see the constructor). Held keyboard/mouse/touch
302
- * state is flushed on blur so a key/button held at alt-tab time doesn't
303
- * stick (the browser stops delivering keyup/mouseup while blurred).
304
- */
305
- private focused;
306
- /** Both gates a standalone game must pass for input to be live (spec §12
307
- * F2 "focus gating"): the editor's explicit `enabled` flag AND real
308
- * window focus. Used everywhere `enabled` alone used to be checked. */
309
- private get inputActive();
310
- /** #144 — the gate MACHINE input passes (virtual actions and
311
- * tick-scheduled actuations): the editor's explicit `enabled` flag ONLY.
312
- * Window focus deliberately does not participate: a synthetic player
313
- * drives the shared editor tab precisely while the human's focus is
314
- * elsewhere (their terminal, another window) — the first live in-editor
315
- * probe run froze mid-suite the moment the owner started typing to their
316
- * agent, which is the bug this gate split fixes. Real-device input keeps
317
- * the stricter `inputActive` (enabled AND focused) gate above. */
318
- private get machineInputActive();
319
- /** F2 — real pointer-lock state (`document.pointerLockElement`), tracked via
320
- * `pointerlockchange` (see the constructor). */
321
- private pointerLocked;
322
- /** Element currently wired for click-to-pointer-lock, and its listener. */
323
- private pointerLockElement;
324
- private onPointerLockClick;
325
- private onPointerLockChange;
326
- private onKeyDown;
327
- private onKeyUp;
328
- private onMouseDown;
329
- private onMouseUp;
330
- private onMouseMove;
331
- /** F2 — real window blur: drop focus and flush held REAL-device state
332
- * (the browser stops delivering keyup/mouseup while blurred, so a key
333
- * held at alt-tab time would stick). #144: virtual-action state is
334
- * deliberately NOT flushed here — a bot's held action survives the human
335
- * looking away (see `machineInputActive`); only `setEnabled(false)`
336
- * clears it. */
337
- private onWindowBlur;
338
- /** F2 — real window focus regain. No flush needed (there's nothing held to
339
- * flush — a fresh keydown/mousedown is required to register pressed
340
- * again, exactly like re-enabling via `setEnabled(true)`). */
341
- private onWindowFocus;
342
- /** Clear held/transient REAL-device state (keyboard/mouse/touch-button) —
343
- * shared by `setEnabled(false)` (via `flushHeldState`) and real blur
344
- * (`onWindowBlur`), so a key/button physically held when input is
345
- * suspended doesn't linger. Level values (gamepad axes, touch sticks,
346
- * injected test axes) are deliberately NOT flushed here — they are gated
347
- * at READ time instead (see `inputActive` checks in `poll()`/the
348
- * `collect*Contributions` methods), matching the pre-existing
349
- * gamepad-axis convention. */
350
- private flushRealHeldState;
351
- /** The full flush `setEnabled(false)` performs: real-device state AND
352
- * virtual-action state. Task 1.4's rule ("a bot's held action must not
353
- * survive input being suspended") now applies only to the editor's
354
- * explicit gate — #144 moved real window blur onto `flushRealHeldState`
355
- * alone, so machine input survives the human's focus leaving the tab.
356
- * No release edge is manufactured here (`manufactureReleaseEdge: false`,
357
- * the default) — this is a SUSPEND, not a deliberate release, and mirrors
358
- * `flushRealHeldState`'s own silence (a key physically held at
359
- * suspend/blur time is wiped with no `keysJustUp`, "flush held state,
360
- * don't corrupt history", see `poll()`'s doc comment). */
361
- private flushHeldState;
362
- /** Shared by the public `clearVirtualActions()` and `flushHeldState()`
363
- * above — clears every virtual-action store (held digitals, queued/active
364
- * taps, scalar/vector2 values, the release-edge set itself).
365
- *
366
- * `manufactureReleaseEdge` (default `false`): when `true` — only
367
- * `clearVirtualActions()`'s own deliberate "let go" passes this — every
368
- * currently-held digital in `virtualDigitalHeld` first gets an
369
- * `isJustReleased` edge written to `virtualDigitalJustReleased`, mirroring
370
- * a real key-up (`onKeyUp` → `keysJustUp`). `flushHeldState()` (the
371
- * editor-gate suspend path) deliberately passes `false` — see its own doc
372
- * comment for why a suspend must stay silent. */
373
- private clearVirtualActionState;
374
- constructor();
375
- /**
376
- * Load action map from a .inputmap.json file. Validated via
377
- * `InputMapFileSchema` (T4.6) — a malformed input map throws a
378
- * `SceneParseError` naming the file, not a deep TypeError once the bad
379
- * data reaches `isPressed`/`isJustPressed`/`isJustReleased`.
380
- */
381
- loadMap(url: string): Promise<void>;
382
- /**
383
- * F3 — `loadMap`'s synchronous, no-`fetch` sibling: apply an already-in-
384
- * memory (or freshly-deserialized) input-map DOCUMENT, validated through
385
- * the identical `InputMapFileSchema` (throws `SceneParseError` naming no
386
- * file, matching `loadMap`'s error shape minus the URL). This is the other
387
- * half of the F3 persist round-trip: `toInputMapFile()` serializes,
388
- * `loadMapObject` re-applies — no network/file I/O required, so it's also
389
- * how a headless test proves a rebind survives a save/reload cycle.
390
- */
391
- loadMapObject(data: unknown): InputMapFile;
392
- /** Shared apply step for `loadMap`/`loadMapObject`: copy each action's
393
- * bindings + declared valueType into the live maps, and snapshot the
394
- * bindings as that action's F3 reset-to-defaults baseline. */
395
- private applyParsedMap;
396
- /** Register an action programmatically. `valueType` declares the action's
397
- * value shape (F1) — defaults to `'digital'`, matching every call site
398
- * written before F1. F3 — also snapshots `bindings` as this action's
399
- * reset-to-defaults baseline (see `resetBindings`). */
400
- registerAction(name: string, bindings: InputBinding[], valueType?: ActionValueType): void;
401
- /** The declared value type for a registered/loaded action (F1) — `'digital'`
402
- * for an action that never specified one (including an unregistered/typo'd
403
- * name — harmless, since every typed getter already treats an unknown
404
- * action as inert). */
405
- getActionValueType(actionName: string): ActionValueType;
406
- /** Enforces the F1 type-safety AC: reading an action through a typed getter
407
- * whose value type doesn't match the action's DECLARED `valueType` throws,
408
- * naming both. Unknown actions (never registered/loaded) are exempt — they
409
- * already read as inert/zeroed by every getter, matching pre-F1 behavior
410
- * for a typo'd action name. */
411
- private assertValueType;
412
- /** The names of all registered actions (for the InputAdapter to enumerate). */
413
- actionNames(): string[];
414
- /**
415
- * Poll gamepads and virtual look stick (call at start of frame).
416
- *
417
- * `tick` (D15/T-D15.3/.5) — the GAME tick this call services. Pass the
418
- * live, shared `Game` tick counter here (`vgai-scene-game-adapter.ts` does,
419
- * via `DebugRegistry.getGameTick()`) so `scheduleActionAtTick`'s numbering
420
- * never drifts from the actual game tick — the bug an earlier revision of
421
- * this feature had: an InputManager-LOCAL counter, incremented once per
422
- * `poll()` call, undercounts for a paused/frozen world (its `poll()` isn't
423
- * called every game tick while frozen), so a schedule set against "tick
424
- * 500" could fire at the wrong wall-tick once the world resumed. Omit it
425
- * (every existing bare/headless caller does) to fall back to the
426
- * self-incrementing `currentTick` counter — unchanged pre-D15 behavior.
427
- */
428
- poll(tick?: number): void;
429
- /**
430
- * D15/T-D15.5 — apply every actuation `scheduleActionAtTick` queued for
431
- * exactly `tick`, then forget them (a tick is serviced at most once).
432
- *
433
- * Digital `true` gets SPECIAL handling (the objection-1 fix): it promotes
434
- * the action into this tick's `virtualDigitalTapActive` set directly — the
435
- * same one-tick "active" pulse `tapVirtualAction` uses — so `isJustPressed`
436
- * reads true for EXACTLY this tick (false on the next, per `endFrame()`'s
437
- * clear) while `isPressed` keeps reading true afterward (still held) until
438
- * a later scheduled/explicit `false` releases it. This direct write is
439
- * safe here (unlike `applyVirtualActionValue`'s equivalent direct-path
440
- * case — see its doc comment) specifically because this method only ever
441
- * runs from inside `poll()`, AFTER `poll()`'s own tap-queue-promotion
442
- * reassignment of `virtualDigitalTapActive` has already happened for this
443
- * tick (see `poll()`'s own comment on why it's placed after) — so there's
444
- * no risk of this write being silently wiped by that reassignment.
445
- *
446
- * pulse-runner friction #4: a prior revision of this comment
447
- * used to say `setVirtualAction`'s plain write "never produces a
448
- * just-pressed edge at all" and that the edge fix landed ONLY here, for
449
- * this scheduled path — true at the time, and exactly the gap a blind
450
- * dogfood run (pulse-runner) hit through the direct `setVirtualAction`/
451
- * `holdFor` path. `applyVirtualActionValue` now manufactures the same kind
452
- * of edge for THAT path too (queued instead of written directly, for the
453
- * timing reason above) — this is no longer the only path that does.
454
- *
455
- * A digital `false` here simply releases the hold — no edge is
456
- * manufactured for it at a SCHEDULED tick (no caller needs a virtual
457
- * `isJustReleased` fired at an exact future tick today); the direct
458
- * `setVirtualAction(action, false)`/`clearVirtualActions()` paths DO
459
- * manufacture one now (see `applyVirtualActionValue`/
460
- * `clearVirtualActionState`). Scalar/vector2 values apply directly,
461
- * unchanged.
462
- */
463
- private applyScheduledActionsForTick;
464
- /** D15/T-D15.5 — append this tick's action-value DELTA to the recording
465
- * ring, iff a recording is active. Reads every declared digital/scalar/
466
- * vector2 action through the exact same typed getters gameplay code would
467
- * (`readAction`), so the trace reflects what a component reading these
468
- * actions THIS tick actually sees post-gate — never a raw/ungated value.
469
- * `pointerDelta`/`pointerPosition` actions are skipped (a different,
470
- * frame-accumulated shape, and not part of the virtual-action/schedule
471
- * surface this trace exists to prove).
472
- *
473
- * Two replay-affecting caveats a future SP5 consumer must know:
474
- * 1. A gated stretch never calls this at all (`poll()`'s gated branch
475
- * returns before reaching it) — no entries are recorded for ticks
476
- * input was suspended. Any change only OBSERVABLE once re-enabled (a
477
- * delta against `lastTraceSnapshot`) lands as a delta AT the re-enable
478
- * tick, not at whatever tick it actually happened.
479
- * 2. This ring is capped (`INPUT_TRACE_CAP`) and evicts via `shift()` once
480
- * it fills — dropping the OLDEST entry. Because entries are DELTAS,
481
- * evicting the earliest entries drops the base state later deltas were
482
- * relative to — this ring is not safe to replay from its start once it
483
- * has ever been capped. */
484
- private recordPostGateTick;
485
- /** Has a `gamepad_axis` binding's raw value crossed its direction+deadzone
486
- * threshold (positive: `value > deadzone`; negative: `value < -deadzone`)? */
487
- private static axisThresholdMet;
488
- /** Is an action currently held down? */
489
- isPressed(actionName: string): boolean;
490
- /** Was an action pressed this frame (not held from previous)? */
491
- isJustPressed(actionName: string): boolean;
492
- /** Was an action released this frame (held last frame, up now)? */
493
- isJustReleased(actionName: string): boolean;
494
- /** Device/source metadata (F1 AC) for a digital action: which binding is
495
- * CURRENTLY satisfying `isPressed`, or `null` if none is (including an
496
- * unknown action). First-satisfied-binding-wins, mirroring isPressed's own
497
- * iteration order. */
498
- getDigitalSource(actionName: string): ActionValueSource | null;
499
- /** 1D deadzone rescale: magnitudes below `deadzone` become 0; magnitudes
500
- * at/above it rescale from 0 (at the deadzone edge) to ±1 (at |raw| = 1),
501
- * sign preserved. `raw` is clamped to [-1, 1] first so an out-of-range
502
- * input can't overshoot past ±1 the other end. */
503
- private static rescaleScalar;
504
- /** Radial deadzone + unit-circle normalization for a Vector2: magnitude
505
- * below `deadzone` snaps to {0,0}; at/above it, direction is preserved and
506
- * magnitude is rescaled the same way `rescaleScalar` rescales a 1D
507
- * magnitude (never renormalized UP past 1 — only ever scaled down). */
508
- private static rescaleVector2;
509
- /** Clamp a Vector2's magnitude to at most 1 (unit circle), preserving
510
- * direction — the second half of the vector2 "sum-then-clamp" combine
511
- * rule (a diagonal sum like {0.8, 0.8} has magnitude > 1). */
512
- private static clampVector2;
513
- /** Every `scalar`-relevant binding's (deadzone-applied) contribution for
514
- * `actionName`, one entry per binding that can produce a scalar value —
515
- * `gamepad_axis` (real device, already implemented pre-F1 for digital
516
- * thresholding — F1 additionally reads its raw signed value for scalar
517
- * actions, ignoring the binding's `direction` field, which is a digital-
518
- * only hint) and `test_axis` (F1's injected-test-input source). `mouse_move`
519
- * deliberately does NOT feed scalar (spec §12 F2 — no natural single-axis
520
- * selector field is defined for it; it feeds pointerDelta/vector2 only —
521
- * see `collectPointerDeltaContributions`/`collectVector2Contributions`). */
522
- private collectScalarContributions;
523
- private computeScalar;
524
- /** Read a `'scalar'`-valueType action's current value: max-magnitude across
525
- * contributing (deadzone-applied) bindings, sign preserved (combine rule —
526
- * see the class doc comment). Throws if the action is declared a
527
- * different valueType. */
528
- getScalar(actionName: string): number;
529
- /** Device/source metadata for {@link getScalar} — which binding is
530
- * currently driving the combined value, or `null` if every contribution is
531
- * zero (including an unknown action). */
532
- getScalarSource(actionName: string): ActionValueSource | null;
533
- /** `gamepad_axis_pair` contribution(s) for {@link collectVector2Contributions} — one entry
534
- * per connected gamepad, deadzone-rescaled (default 0.15, matching `gamepad_axis`). Broken
535
- * out to a helper so the per-gamepad loop doesn't add to the main dispatcher's complexity. */
536
- private contributeGamepadAxisPair;
537
- /** Every `vector2`-relevant binding's (deadzone-applied) contribution:
538
- * `test_vector2` (F1's injected-test-input source), plus F2's real-device
539
- * cases — `gamepad_axis_pair` (see {@link contributeGamepadAxisPair}), `mouse_move` (the
540
- * accumulated mouse delta, deadzone default 0 — raw pixel deltas have no natural "at rest"
541
- * jitter floor the way an analog stick does), and `touch_stick` (a virtual on-screen stick,
542
- * deadzone default 0). */
543
- private collectVector2Contributions;
544
- private computeVector2;
545
- /** Read a `'vector2'`-valueType action's current value: sum contributing
546
- * (deadzone-applied) {x,y} values component-wise, then clamp to the unit
547
- * circle (combine rule — see the class doc comment). Throws if the action
548
- * is declared a different valueType. */
549
- getVector2(actionName: string): Vector2;
550
- /** Device/source metadata for {@link getVector2} — the contributing binding
551
- * with the largest (pre-combine) magnitude, or `null` if the combined
552
- * value is {0,0} (including an unknown action). */
553
- getVector2Source(actionName: string): ActionValueSource | null;
554
- /** Every `pointerDelta`-relevant binding's contribution: `test_pointer_delta`
555
- * (F1's injected-test-input source) and — F2 — `mouse_move`, reading the
556
- * real accumulated `mouseDeltaX/Y` (the same accumulator `onMouseMove`
557
- * fills and `getMouseDelta()` reads). No deadzone for either (deltas are
558
- * not deadzoned). */
559
- private collectPointerDeltaContributions;
560
- private computePointerDelta;
561
- /** Read a `'pointerDelta'`-valueType action's this-frame movement: sum of
562
- * contributing bindings' deltas (combine rule — see the class doc
563
- * comment). Throws if the action is declared a different valueType. */
564
- getPointerDelta(actionName: string): Vector2;
565
- /** Device/source metadata for {@link getPointerDelta}. */
566
- getPointerDeltaSource(actionName: string): ActionValueSource | null;
567
- /** Every `pointerPosition`-relevant binding's contribution, each tagged
568
- * with the injection-order sequence number used to break ties (last-
569
- * write-wins) — today only `test_pointer_position` (F1's injected-test-
570
- * input source). */
571
- private collectPointerPositionContributions;
572
- private computePointerPosition;
573
- /** Read a `'pointerPosition'`-valueType action's current absolute position:
574
- * last-write-wins across contributing bindings (combine rule — see the
575
- * class doc comment; position isn't additive, so it is never summed).
576
- * Throws if the action is declared a different valueType. */
577
- getPointerPosition(actionName: string): Vector2;
578
- /** Device/source metadata for {@link getPointerPosition} — the most
579
- * recently-written contributing source. */
580
- getPointerPositionSource(actionName: string): ActionValueSource | null;
581
- /** Generic typed read (F1): dispatches to the matching typed getter based
582
- * on `expectedType`, returning `ActionValueOf<T>` — a caller with a
583
- * statically-known action-value-type map gets a fully-inferred, non-`any`
584
- * return type. Throws the same mismatch error as the dedicated getters if
585
- * the action's declared valueType disagrees with `expectedType`. */
586
- readAction<T extends ActionValueType>(actionName: string, expectedType: T): ActionValueOf<T>;
587
- /** Inject a synthetic scalar value for a named test source (F1's injected-
588
- * test-input hook — also the shape of F2's "injected test input" backend).
589
- * Bind an action to `{ type: 'test_axis', sourceId }` (`valueType:
590
- * 'scalar'`) to read it back via {@link getScalar}. The value PERSISTS
591
- * across frames (like a real analog stick held in position) until changed
592
- * or cleared via {@link clearAxis}. */
593
- injectAxis(sourceId: string, value: number): void;
594
- /** Clear an injected scalar source (e.g. simulating an at-rest/disconnected
595
- * device). */
596
- clearAxis(sourceId: string): void;
597
- /** Inject a synthetic {x,y} value for a named test source. Bind an action
598
- * to `{ type: 'test_vector2', sourceId }` (`valueType: 'vector2'`) to read
599
- * it back via {@link getVector2}. Persists across frames until changed or
600
- * cleared via {@link clearVector2}. */
601
- injectVector2(sourceId: string, value: Vector2): void;
602
- /** Clear an injected Vector2 source. */
603
- clearVector2(sourceId: string): void;
604
- /** Accumulate a synthetic pointer delta for a named test source — mirrors
605
- * real mouse-move delta accumulation (`onMouseMove` above): multiple calls
606
- * within the same frame sum, and the accumulator is cleared in
607
- * {@link endFrame}. Bind an action to `{ type: 'test_pointer_delta',
608
- * sourceId }` (`valueType: 'pointerDelta'`) to read it back via
609
- * {@link getPointerDelta}. */
610
- injectPointerDelta(sourceId: string, delta: Vector2): void;
611
- /** Set a synthetic absolute pointer position for a named test source.
612
- * Persists (last-write-wins across contributing sources on read — see the
613
- * pointerPosition combine rule) until changed. Bind an action to `{ type:
614
- * 'test_pointer_position', sourceId }` (`valueType: 'pointerPosition'`) to
615
- * read it back via {@link getPointerPosition}. */
616
- injectPointerPosition(sourceId: string, value: Vector2): void;
617
- /** Whether input capture is currently enabled (see {@link setEnabled}). */
618
- isEnabled(): boolean;
619
- /**
620
- * Enable/disable input capture. The editor host disables the running game's
621
- * input while its viewport isn't focused so keystrokes don't leak in from
622
- * the editor. Disabling clears all held/transient keyboard/mouse/touch-button
623
- * state (via {@link flushHeldState}) so nothing sticks (e.g. a held movement
624
- * key when you switch back to the Scene tab mid-flight) — gamepad state
625
- * doesn't need clearing here since `poll()` itself stops reading it while
626
- * disabled (see poll()'s doc comment).
627
- */
628
- setEnabled(enabled: boolean): void;
629
- /** Whether the window/tab is currently focused (F2, spec §12 "focus
630
- * gating") — `false` while blurred (real `blur`/`focus` events; see the
631
- * constructor). Distinct from {@link isEnabled}, which is the editor's
632
- * explicit play-mode gate. */
633
- isFocused(): boolean;
634
- /** Whether the pointer is currently locked to {@link requestPointerLock}'s
635
- * element (F2, spec §12 "pointer lock") — tracked via the real
636
- * `pointerlockchange` event. */
637
- isPointerLocked(): boolean;
638
- /** Device identity for a connected gamepad slot (F2, spec §12 "expose
639
- * device identity" + "prefer the standard mapping"), or `null` if nothing
640
- * is connected at `index` (including while input is disabled/unfocused,
641
- * since `poll()` empties `this.gamepads` then). `mapping` is the Gamepad
642
- * API's own `'standard'`/`''` value — bindings author button/axis indices
643
- * assuming the W3C Standard Gamepad layout, so a non-`'standard'` mapping
644
- * means those indices may not correspond as documented. */
645
- getGamepadInfo(index: number): {
646
- index: number;
647
- id: string;
648
- mapping: string;
649
- connected: boolean;
650
- } | null;
651
- /** Get mouse movement delta this frame */
652
- getMouseDelta(): {
653
- x: number;
654
- y: number;
655
- };
656
- /**
657
- * F4 (spec §12 "Schema and Examples" — the F3 prompt-switching gap): which
658
- * device family most recently produced real input, or `null` before any
659
- * input has arrived. A prompt UI polls this (or lets {@link getPrompt}
660
- * consult it automatically by omitting `device`) to switch its displayed
661
- * label as the player switches controllers — e.g. showing `'Space'` while
662
- * they're on keyboard, then `'A'` the moment they touch a gamepad.
663
- */
664
- getLastActiveDevice(): PromptDevice | null;
665
- /** The current bindings for `actionName` (F3 AC "listed") — a defensive
666
- * deep clone, so mutating the returned array/objects never affects the
667
- * live binding list. `[]` for an unknown/never-registered action. */
668
- getBindings(actionName: string): InputBinding[];
669
- /** Wholesale-replace `actionName`'s bindings array (F3 AC "replaced"). Does
670
- * NOT touch the reset-to-defaults snapshot — see `resetBindings`. A no-op
671
- * target for an action that was never registered is allowed (it simply
672
- * registers one with `valueType: 'digital'`, matching `registerAction`'s
673
- * own default) since a rebinding UI operates on actions it already knows
674
- * about, but shouldn't have to special-case "brand new action" separately. */
675
- setBindings(actionName: string, bindings: InputBinding[]): void;
676
- /** Append one binding to `actionName` (F3 AC "added"). */
677
- addBinding(actionName: string, binding: InputBinding): void;
678
- /** Remove the binding at `index` from `actionName` (F3 AC "removed"). A
679
- * no-op if the action is unknown or `index` is out of range (rather than
680
- * throwing) — mirrors every other getter's "unknown action is inert"
681
- * convention, so a UI doesn't need a separate existence check first. */
682
- removeBinding(actionName: string, index: number): void;
683
- /** Replace a single binding slot at `index` on `actionName` — the shape a
684
- * rebinding UI actually wants ("rebind THIS control"), built on
685
- * `getBindings`/`setBindings`. A no-op if the action is unknown or `index`
686
- * is out of range. */
687
- replaceBinding(actionName: string, index: number, binding: InputBinding): void;
688
- /** Restore `actionName`'s bindings to the snapshot taken at
689
- * `registerAction`/`loadMap`/`loadMapObject` time (F3 AC "reset"). A no-op
690
- * for an action with no snapshot (never registered/loaded — there is no
691
- * "default" to reset to). */
692
- resetBindings(actionName: string): void;
693
- /** Reset every action that has a snapshot back to its registered/loaded
694
- * defaults. Convenience batch form of `resetBindings`. */
695
- resetAllBindings(): void;
696
- /**
697
- * Whether `a` and `b` are the SAME physical input (F3's structural-conflict
698
- * identity check — see `findConflicts`). Deliberately narrower than deep
699
- * equality: `deadzone` never participates (two bindings on the same key
700
- * with different deadzones are still the same physical control), and a
701
- * `gamepad_axis`'s `direction` DOES participate — opposite directions of one
702
- * physical axis (e.g. "accelerate" on positive, "brake" on negative) are a
703
- * legitimate, non-conflicting pair, not a collision.
704
- */
705
- private static bindingsCollide;
706
- /**
707
- * Every EXISTING binding, on every OTHER registered action, that is
708
- * structurally the same physical input as `proposed` (F3 AC "conflicts are
709
- * detected and returned structurally") — never throws, always a plain
710
- * (possibly empty) array a rebinding UI inspects before committing a
711
- * rebind. `excludeActionName` is normally the action being rebound itself
712
- * (so an action isn't reported as conflicting with its own current
713
- * binding when re-proposing an unchanged value).
714
- */
715
- findConflicts(proposed: InputBinding, excludeActionName?: string): BindingConflict[];
716
- /**
717
- * Serialize every registered/loaded action back into the `.inputmap.json`
718
- * document shape (F3 AC "persisted") — the exact `InputMapFile` shape
719
- * `loadMap`/`loadMapObject` read, so `manager.loadMapObject(manager.toInputMapFile())`
720
- * on a fresh instance reproduces the same live bindings. `version` is
721
- * carried forward from the last loaded map when known, else `1` (a
722
- * manager built purely via `registerAction` calls, never `loadMap`, has no
723
- * file-format version to preserve).
724
- */
725
- toInputMapFile(): InputMapFile;
726
- /**
727
- * Resolve a display prompt (F3 AC: labels/icons like `'Space'`, `'A'`, or a
728
- * touch control's name) for whichever of `actionName`'s bindings belongs to
729
- * the requested `device` family. `null` when the action has no binding for
730
- * that device (including an unknown action). `gamepadIndex` (default 0)
731
- * selects which connected pad's `mapping`/connected state to consult for a
732
- * `gamepad_*` binding — see `getGamepadInfo`.
733
- *
734
- * F4 — `device` is now OPTIONAL: omit it (or pass `undefined`) to resolve
735
- * against {@link getLastActiveDevice} instead (falling back to `'keyboard'`
736
- * before any input has arrived), so a prompt UI that wants "show whatever
737
- * the player is actually holding right now" doesn't have to track the
738
- * active device itself — it can just call `getPrompt(actionName)` every
739
- * frame and the label switches on its own as the player changes controllers.
740
- * Passing an explicit `device` (as every pre-F4 caller does) is unaffected.
741
- */
742
- getPrompt(actionName: string, device?: PromptDevice, gamepadIndex?: number): BindingPrompt | null;
743
- /** Call at end of frame to clear per-frame state */
744
- endFrame(): void;
745
- /** Inject synthetic key state from touch controls */
746
- setVirtualKey(code: string, pressed: boolean): void;
747
- /** Set virtual look stick position (-1..1). Injected as mouse delta during poll(). */
748
- setLookStick(x: number, y: number): void;
749
- /** Inject synthetic mouse delta (e.g. from touch controls) */
750
- addMouseDelta(dx: number, dy: number): void;
751
- /**
752
- * F2 (spec §12 "Complete Device Backends") — the touch/virtual-control
753
- * digital backend. Set a named virtual button's (`sourceId` — a zone/knob
754
- * id the touch UI chooses) pressed state; edge-tracked exactly like a real
755
- * mouse button (`onMouseDown`/`onMouseUp` above) so `isJustPressed`/
756
- * `isJustReleased` work for `{ type: 'touch_button', sourceId }` bindings.
757
- * This is the injectable entry point a real on-screen button's own
758
- * touchstart/touchend handler would call — that DOM wiring is a thin
759
- * adapter at the edge (browser-verified separately); this method is the
760
- * MAPPING logic, unit-tested headlessly with no DOM.
761
- */
762
- setTouchButton(sourceId: string, pressed: boolean): void;
763
- /**
764
- * F2 — the touch/virtual-control analog backend. Set a named virtual
765
- * stick's (`sourceId`) raw `{x,y}` position (e.g. -1..1 per axis, like a
766
- * gamepad stick); read back via `getVector2` on a `{ type: 'touch_stick',
767
- * sourceId }` binding, deadzone-rescaled the same way a gamepad stick is.
768
- * Persists across frames (a level value, like a real analog stick held in
769
- * position) until changed or cleared via {@link clearTouchStick}.
770
- */
771
- setTouchStick(sourceId: string, value: Vector2): void;
772
- /** Clear a virtual stick's value (e.g. simulating the touch point lifting —
773
- * the knob returns to center). */
774
- clearTouchStick(sourceId: string): void;
775
- /** Existence check shared by `setVirtualAction`/`tapVirtualAction` — throws
776
- * `InputActionError` (`code: 'INPUT_ACTION_NOT_FOUND'`, `data.registered`
777
- * = every declared action name) for a name that was never
778
- * `registerAction`/`loadMap`-ed. */
779
- private assertActionExists;
780
- /** Which declared `ActionValueType` a `setVirtualAction` value shape
781
- * corresponds to — the type-safety check mirrors every typed getter's
782
- * `assertValueType` (F1). `pointerDelta`/`pointerPosition` actions aren't
783
- * drivable through `setVirtualAction` (no boolean/number/Vector2 call
784
- * shape maps to them) — use `injectPointerDelta`/`injectPointerPosition`. */
785
- private static virtualValueCategory;
786
- /**
787
- * Set a virtual value for `action`, OR'd/summed into the same action reads
788
- * humans drive (see the section doc comment above). A `boolean` holds a
789
- * digital action pressed until set `false`/cleared; a `number` or `{x,y}`
790
- * is a level value combined via the action's own scalar max-magnitude /
791
- * vector2 sum-then-clamp rule.
792
- *
793
- * A digital `false`→`true` transition manufactures a genuine `isJustPressed`
794
- * edge, exactly one real key-down does (pulse-runner friction #4 —
795
- * previously this write-half only ever held the action pressed with NO
796
- * edge at all; every edge-triggered ability driven through this direct
797
- * path was unprovable). Re-setting `true` while already held (auto-repeat)
798
- * does NOT re-fire it — see {@link applyVirtualActionValue}. The mirror
799
- * `true`→`false` transition manufactures an `isJustReleased` edge the same
800
- * way a real key-up does.
801
- *
802
- * Throws `InputActionError` for an unregistered `action`, and the same
803
- * valueType-mismatch error every typed getter throws (`assertValueType`)
804
- * when `value`'s shape doesn't match the action's declared `valueType`.
805
- *
806
- * Gated (`setEnabled(false)` — play stopped or editor-gated; #144: window
807
- * focus no longer gates machine input): writes NOTHING — matching
808
- * `setTouchButton`'s write-gate precedent above — and returns
809
- * `{delivered: false, reason}` rather than a silent no-op, so a probe/bot
810
- * never mistakes a swallowed actuation for a delivered one.
811
- */
812
- setVirtualAction(action: string, value: boolean | number | {
813
- x: number;
814
- y: number;
815
- }): {
816
- delivered: boolean;
817
- reason?: string;
818
- };
819
- /**
820
- * The write half of {@link setVirtualAction} — extracted so D15/T-D15.5's
821
- * `scheduleActionAtTick` can apply a non-boolean (scalar/vector2) queued
822
- * actuation through the exact same code path (no gate check here: the two
823
- * callers gate differently — `setVirtualAction` above checks
824
- * `inputActive` before calling this; `applyScheduledActionsForTick` is
825
- * only ever reached from inside `poll()` AFTER its own gate check has
826
- * already returned early on a gated tick). `applyScheduledActionsForTick`
827
- * still handles digital `true` itself rather than calling here (its
828
- * one-tick edge must land EXACTLY at the scheduled tick — see its own doc
829
- * comment) — this method's digital branch is `setVirtualAction`'s direct
830
- * path, called at an arbitrary point relative to the poll()/endFrame()
831
- * bracket.
832
- *
833
- * pulse-runner friction #4 — the digital branch used to be a bare held-flag
834
- * write with no manufactured edge at all (the comment that used to sit
835
- * here read: "A digital value is handled by `applyScheduledActionsForTick`
836
- * itself (it needs the extra just-pressed edge a plain held-value write
837
- * doesn't produce)" — i.e. the edge fix shipped ONLY for the scheduled
838
- * path, never for this one, which is exactly the gap a blind dogfood run
839
- * hit: `setVirtualAction('jump', true)` held the action down but
840
- * `isJustPressed('jump')` never fired). Fixed here by reusing
841
- * `tapVirtualAction`'s exact one-tick-pulse queue mechanism for this
842
- * DIRECT case, specifically because this method's caller can land at any
843
- * point relative to `poll()`: writing `virtualDigitalTapActive` directly
844
- * here (as the scheduled path safely does, from inside `poll()` itself)
845
- * would risk being silently wiped by `poll()`'s own unconditional
846
- * `virtualDigitalTapActive = virtualDigitalTapQueued` reassignment,
847
- * depending on timing. Queueing side-steps that hazard by construction —
848
- * the same reason `tapVirtualAction` queues instead of writing directly. A
849
- * redundant `true` while already held (`virtualDigitalHeld` already has
850
- * `action`) does not queue again, matching a real key's auto-repeat never
851
- * re-firing `isJustPressed`. The `false` branch mirrors real `onKeyUp`
852
- * instead (immediate write, no queue needed — nothing in `poll()`
853
- * reassigns `virtualDigitalJustReleased`), and only fires when the action
854
- * was actually held (no released→released re-fire).
855
- */
856
- private applyVirtualActionValue;
857
- /**
858
- * One-frame press of a `'digital'` action (Task 1.4): queues `action` so it
859
- * reads `isJustPressed`/`isPressed` true for EXACTLY the next `poll()`'s
860
- * frame — promoted to the "active" set at the top of `poll()`, cleared in
861
- * `endFrame()` alongside every other just-pressed edge set (see both
862
- * above). Hollowstone's `queued`/`beginFrame` tap contract, ported onto
863
- * this engine's existing fixed-step `poll()`/`endFrame()` bracket instead
864
- * of a bespoke `beginFrame()` hook.
865
- *
866
- * Throws the same errors as {@link setVirtualAction} (unknown action;
867
- * non-digital valueType). A gated tap does NOT queue — it must not fire on
868
- * a later frame once input becomes active again — and returns
869
- * `{delivered: false, reason}`.
870
- */
871
- tapVirtualAction(action: string): {
872
- delivered: boolean;
873
- reason?: string;
874
- };
875
- /** Clear all virtual-action state — held digitals, queued/active taps, and
876
- * scalar/vector2 values. `flushHeldState()` (the same flush
877
- * `setEnabled(false)`/real blur apply to held keys/mouse/touch buttons)
878
- * shares the underlying wipe, so a bot's held action never survives input
879
- * being suspended — but only THIS public entry point (a deliberate "let
880
- * go", the mirror of `setVirtualAction(action, false)` below) manufactures
881
- * an `isJustReleased` edge for whatever was held; the suspend path stays
882
- * silent (see `flushHeldState`'s own doc comment). */
883
- clearVirtualActions(): void;
884
- /**
885
- * D15/T-D15.5 (`docs/D15-DETERMINISM-DESIGN.md` §2.c) — schedule a virtual
886
- * actuation for exactly `tick`: applied at the START of that tick's
887
- * `poll()` (composing with `runTicks` — a schedule for tick 500 fires
888
- * exactly once the sim has been driven through tick 500, regardless of
889
- * burst size). A digital `true` produces a genuine `isJustPressed` edge
890
- * exactly at the target tick (not merely a held value — see
891
- * `applyScheduledActionsForTick`).
892
- *
893
- * Throws `InputActionError` for an unregistered `action` and the same
894
- * valueType-mismatch error every typed getter throws (`assertValueType`) —
895
- * both checked EAGERLY, at schedule time, not deferred to the target tick.
896
- * Throws `InputTickError` (`code: 'TICK_ALREADY_PASSED'`) when `tick` is
897
- * strictly less than the tick `poll()` will service NEXT — scheduling only
898
- * ever reaches the current or a future tick. A tick whose input phase
899
- * never runs (this world paused/frozen at that point, or a multi-tick gap
900
- * — see `poll()`) drops its scheduled entries rather than replaying them
901
- * late — each drop emits one `'input.schedule.dropped'` debug event
902
- * (`{tick, action}`) via {@link setDebugEmit}'s sink, if one is wired.
903
- */
904
- scheduleActionAtTick(tick: number, action: string, value: boolean | number | {
905
- x: number;
906
- y: number;
907
- }): void;
908
- /** Wire (or clear, via `null`) the sink `poll()` calls with
909
- * `'input.schedule.dropped'` (`{tick, action}`) whenever it discards a
910
- * scheduled entry for a tick whose input phase never ran. Called once by
911
- * whoever constructs this `InputManager` with a `DebugRegistry` behind it
912
- * (`vgai-scene-game-adapter.ts`), the same seed spot as
913
- * `setVirtualInputTarget`/`setInputActionsSource` — never called directly
914
- * by gameplay code. */
915
- setDebugEmit(fn: ((event: string, detail?: unknown) => void) | null): void;
916
- /** D15/T-D15.5 — start (or restart) recording the post-gate action-delta
917
- * trace: clears any prior trace/snapshot, so a fresh recording session
918
- * never carries over stale deltas from an earlier one. */
919
- startInputRecording(): void;
920
- /** D15/T-D15.5 — stop recording (the trace accumulated so far stays
921
- * readable via {@link getInputTrace} until the next `startInputRecording`
922
- * clears it). Idempotent. */
923
- stopInputRecording(): void;
924
- /** D15/T-D15.5 — whether a recording is currently active. */
925
- isInputRecording(): boolean;
926
- /** D15/T-D15.5 — the recorded trace so far (a defensive copy), versioned
927
- * per the design doc's format sketch (§2.c). SP5 (out of scope here) is
928
- * the eventual consumer that replays this; this module only ever
929
- * RECORDS. */
930
- getInputTrace(): {
931
- version: 1;
932
- ticks: {
933
- tick: number;
934
- actions: Record<string, boolean | number | {
935
- x: number;
936
- y: number;
937
- }>;
938
- }[];
939
- };
940
- /** Request pointer lock for FPS-style mouse control */
941
- requestPointerLock(element: HTMLElement): void;
942
- /** Clean up event listeners */
943
- dispose(): void;
944
- }
945
- //# sourceMappingURL=input-manager.d.ts.map