rn-gamekit 0.1.0 → 0.2.0

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 (601) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +95 -14
  3. package/lib/module/assets/defineAssets.js +28 -3
  4. package/lib/module/assets/defineAssets.js.map +1 -1
  5. package/lib/module/assets.js +11 -0
  6. package/lib/module/assets.js.map +1 -0
  7. package/lib/module/audio/createGameAudio.js +784 -0
  8. package/lib/module/audio/createGameAudio.js.map +1 -0
  9. package/lib/module/audio/errors.js +12 -0
  10. package/lib/module/audio/errors.js.map +1 -0
  11. package/lib/module/audio/index.js +5 -0
  12. package/lib/module/audio/index.js.map +1 -0
  13. package/lib/module/audio/resolver.js +37 -0
  14. package/lib/module/audio/resolver.js.map +1 -0
  15. package/lib/module/audio/types.js +4 -0
  16. package/lib/module/audio/types.js.map +1 -0
  17. package/lib/module/audio.js +9 -0
  18. package/lib/module/audio.js.map +1 -0
  19. package/lib/module/camera2d/bounds.js +59 -0
  20. package/lib/module/camera2d/bounds.js.map +1 -0
  21. package/lib/module/camera2d/extents.js +25 -0
  22. package/lib/module/camera2d/extents.js.map +1 -0
  23. package/lib/module/camera2d/follow.js +138 -0
  24. package/lib/module/camera2d/follow.js.map +1 -0
  25. package/lib/module/camera2d/index.js +20 -0
  26. package/lib/module/camera2d/index.js.map +1 -0
  27. package/lib/module/camera2d/interpolation.js +98 -0
  28. package/lib/module/camera2d/interpolation.js.map +1 -0
  29. package/lib/module/camera2d/shake.js +85 -0
  30. package/lib/module/camera2d/shake.js.map +1 -0
  31. package/lib/module/camera2d/transform.js +151 -0
  32. package/lib/module/camera2d/transform.js.map +1 -0
  33. package/lib/module/camera2d/types.js +4 -0
  34. package/lib/module/camera2d/types.js.map +1 -0
  35. package/lib/module/camera2d/validation.js +98 -0
  36. package/lib/module/camera2d/validation.js.map +1 -0
  37. package/lib/module/camera2d/visibility.js +138 -0
  38. package/lib/module/camera2d/visibility.js.map +1 -0
  39. package/lib/module/camera2d.js +9 -0
  40. package/lib/module/camera2d.js.map +1 -0
  41. package/lib/module/collision2d/colliders.js +266 -0
  42. package/lib/module/collision2d/colliders.js.map +1 -0
  43. package/lib/module/collision2d/debug.js +105 -0
  44. package/lib/module/collision2d/debug.js.map +1 -0
  45. package/lib/module/collision2d/filters.js +40 -0
  46. package/lib/module/collision2d/filters.js.map +1 -0
  47. package/lib/module/collision2d/index.js +12 -0
  48. package/lib/module/collision2d/index.js.map +1 -0
  49. package/lib/module/collision2d/intersections.js +67 -0
  50. package/lib/module/collision2d/intersections.js.map +1 -0
  51. package/lib/module/collision2d/manifolds.js +218 -0
  52. package/lib/module/collision2d/manifolds.js.map +1 -0
  53. package/lib/module/collision2d/segments.js +187 -0
  54. package/lib/module/collision2d/segments.js.map +1 -0
  55. package/lib/module/collision2d/spatialHash.js +167 -0
  56. package/lib/module/collision2d/spatialHash.js.map +1 -0
  57. package/lib/module/collision2d/sweeps.js +255 -0
  58. package/lib/module/collision2d/sweeps.js.map +1 -0
  59. package/lib/module/collision2d.js +9 -0
  60. package/lib/module/collision2d.js.map +1 -0
  61. package/lib/module/core/input/buttonPad.js +214 -0
  62. package/lib/module/core/input/buttonPad.js.map +1 -0
  63. package/lib/module/core/input/createInputBuffer.js +66 -14
  64. package/lib/module/core/input/createInputBuffer.js.map +1 -1
  65. package/lib/module/core/session/createGameSession.js +454 -50
  66. package/lib/module/core/session/createGameSession.js.map +1 -1
  67. package/lib/module/core/session/deepFreeze.js +92 -2
  68. package/lib/module/core/session/deepFreeze.js.map +1 -1
  69. package/lib/module/core/session/types.js +12 -0
  70. package/lib/module/core/session/types.js.map +1 -1
  71. package/lib/module/definition/defineGame.js +23 -0
  72. package/lib/module/definition/defineGame.js.map +1 -1
  73. package/lib/module/events/defineGameEvents.js +46 -0
  74. package/lib/module/events/defineGameEvents.js.map +1 -0
  75. package/lib/module/events/errors.js +16 -0
  76. package/lib/module/events/errors.js.map +1 -0
  77. package/lib/module/events/index.js +7 -0
  78. package/lib/module/events/index.js.map +1 -0
  79. package/lib/module/events/payload.js +219 -0
  80. package/lib/module/events/payload.js.map +1 -0
  81. package/lib/module/events/seed.js +33 -0
  82. package/lib/module/events/seed.js.map +1 -0
  83. package/lib/module/events/types.js +4 -0
  84. package/lib/module/events/types.js.map +1 -0
  85. package/lib/module/events.js +13 -0
  86. package/lib/module/events.js.map +1 -0
  87. package/lib/module/geometry/helpers.js +140 -0
  88. package/lib/module/geometry/helpers.js.map +1 -0
  89. package/lib/module/geometry/index.js +5 -0
  90. package/lib/module/geometry/index.js.map +1 -0
  91. package/lib/module/geometry/validation.js +104 -0
  92. package/lib/module/geometry/validation.js.map +1 -0
  93. package/lib/module/geometry.js +9 -0
  94. package/lib/module/geometry.js.map +1 -0
  95. package/lib/module/haptics/createGameHaptics.js +214 -0
  96. package/lib/module/haptics/createGameHaptics.js.map +1 -0
  97. package/lib/module/haptics/errors.js +12 -0
  98. package/lib/module/haptics/errors.js.map +1 -0
  99. package/lib/module/haptics/index.js +5 -0
  100. package/lib/module/haptics/index.js.map +1 -0
  101. package/lib/module/haptics/resolver.js +37 -0
  102. package/lib/module/haptics/resolver.js.map +1 -0
  103. package/lib/module/haptics/types.js +4 -0
  104. package/lib/module/haptics/types.js.map +1 -0
  105. package/lib/module/haptics.js +9 -0
  106. package/lib/module/haptics.js.map +1 -0
  107. package/lib/module/index.js +8 -1
  108. package/lib/module/index.js.map +1 -1
  109. package/lib/module/particles/createParticleSystem.js +481 -0
  110. package/lib/module/particles/createParticleSystem.js.map +1 -0
  111. package/lib/module/particles/defineParticleEffect.js +178 -0
  112. package/lib/module/particles/defineParticleEffect.js.map +1 -0
  113. package/lib/module/particles/errors.js +9 -0
  114. package/lib/module/particles/errors.js.map +1 -0
  115. package/lib/module/particles/index.js +8 -0
  116. package/lib/module/particles/index.js.map +1 -0
  117. package/lib/module/particles/sampling.js +121 -0
  118. package/lib/module/particles/sampling.js.map +1 -0
  119. package/lib/module/particles/types.js +4 -0
  120. package/lib/module/particles/types.js.map +1 -0
  121. package/lib/module/particles.js +4 -0
  122. package/lib/module/particles.js.map +1 -0
  123. package/lib/module/react/GameButtonPad.js +344 -0
  124. package/lib/module/react/GameButtonPad.js.map +1 -0
  125. package/lib/module/react/GamePointerInput.js +74 -16
  126. package/lib/module/react/GamePointerInput.js.map +1 -1
  127. package/lib/module/react/GameView.js +139 -60
  128. package/lib/module/react/GameView.js.map +1 -1
  129. package/lib/module/react/assets/createGameAssetStore.js +145 -95
  130. package/lib/module/react/assets/createGameAssetStore.js.map +1 -1
  131. package/lib/module/react/assets/useGameAssets.js +60 -35
  132. package/lib/module/react/assets/useGameAssets.js.map +1 -1
  133. package/lib/module/react/bindAppLifecycle.js +46 -17
  134. package/lib/module/react/bindAppLifecycle.js.map +1 -1
  135. package/lib/module/react/bindGameSession.js +13 -2
  136. package/lib/module/react/bindGameSession.js.map +1 -1
  137. package/lib/module/react/camera2d/GameLayer2D.js +50 -0
  138. package/lib/module/react/camera2d/GameLayer2D.js.map +1 -0
  139. package/lib/module/react/camera2d/defineGameCamera2D.js +30 -0
  140. package/lib/module/react/camera2d/defineGameCamera2D.js.map +1 -0
  141. package/lib/module/react/camera2d/usePresentedCameraBinding.js +177 -0
  142. package/lib/module/react/camera2d/usePresentedCameraBinding.js.map +1 -0
  143. package/lib/module/react/cleanupList.js +38 -0
  144. package/lib/module/react/cleanupList.js.map +1 -0
  145. package/lib/module/react/lifecycleSource.js +49 -0
  146. package/lib/module/react/lifecycleSource.js.map +1 -0
  147. package/lib/module/react/particles/ParticleView.js +308 -0
  148. package/lib/module/react/particles/ParticleView.js.map +1 -0
  149. package/lib/module/react/particles/culling.js +115 -0
  150. package/lib/module/react/particles/culling.js.map +1 -0
  151. package/lib/module/react/particles/index.js +7 -0
  152. package/lib/module/react/particles/index.js.map +1 -0
  153. package/lib/module/react/particles/spriteXForm.js +45 -0
  154. package/lib/module/react/particles/spriteXForm.js.map +1 -0
  155. package/lib/module/react/particles/useParticlePresentation.js +204 -0
  156. package/lib/module/react/particles/useParticlePresentation.js.map +1 -0
  157. package/lib/module/react/pointerBinding.js +55 -17
  158. package/lib/module/react/pointerBinding.js.map +1 -1
  159. package/lib/module/react/pointerCamera.js +28 -0
  160. package/lib/module/react/pointerCamera.js.map +1 -0
  161. package/lib/module/react/pointerCoalescer.js +16 -9
  162. package/lib/module/react/pointerCoalescer.js.map +1 -1
  163. package/lib/module/react/sprites/GameSprite.js +5 -17
  164. package/lib/module/react/sprites/GameSprite.js.map +1 -1
  165. package/lib/module/react/sprites/GameWorld2D.js +112 -9
  166. package/lib/module/react/sprites/GameWorld2D.js.map +1 -1
  167. package/lib/module/react/sprites/Sprite.js +48 -63
  168. package/lib/module/react/sprites/Sprite.js.map +1 -1
  169. package/lib/module/react/sprites/SpriteBatch.js +53 -28
  170. package/lib/module/react/sprites/SpriteBatch.js.map +1 -1
  171. package/lib/module/react/sprites/batchVisibility.js +58 -0
  172. package/lib/module/react/sprites/batchVisibility.js.map +1 -0
  173. package/lib/module/react/sprites/spriteSelection.js +103 -0
  174. package/lib/module/react/sprites/spriteSelection.js.map +1 -0
  175. package/lib/module/react/sprites/spriteTransform.js +46 -25
  176. package/lib/module/react/sprites/spriteTransform.js.map +1 -1
  177. package/lib/module/react/tilemap/TileMapLayer2D.js +217 -0
  178. package/lib/module/react/tilemap/TileMapLayer2D.js.map +1 -0
  179. package/lib/module/react/tilemap/tilePresentation.js +374 -0
  180. package/lib/module/react/tilemap/tilePresentation.js.map +1 -0
  181. package/lib/module/react/useGameSession.js +70 -0
  182. package/lib/module/react/useGameSession.js.map +1 -0
  183. package/lib/module/react/useGameSessionStatus.js +46 -0
  184. package/lib/module/react/useGameSessionStatus.js.map +1 -0
  185. package/lib/module/react/viewportBinding.js +5 -1
  186. package/lib/module/react/viewportBinding.js.map +1 -1
  187. package/lib/module/react.js +12 -1
  188. package/lib/module/react.js.map +1 -1
  189. package/lib/module/scene/defineScene.js +17 -0
  190. package/lib/module/scene/defineScene.js.map +1 -1
  191. package/lib/module/sprites/sampleSpriteClip.js +66 -6
  192. package/lib/module/sprites/sampleSpriteClip.js.map +1 -1
  193. package/lib/module/sprites/spriteAnimationState.js +10 -20
  194. package/lib/module/sprites/spriteAnimationState.js.map +1 -1
  195. package/lib/module/sprites.js +11 -0
  196. package/lib/module/sprites.js.map +1 -0
  197. package/lib/module/storage/adapters/asyncStorage.js +57 -0
  198. package/lib/module/storage/adapters/asyncStorage.js.map +1 -0
  199. package/lib/module/storage/adapters/memory.js +50 -0
  200. package/lib/module/storage/adapters/memory.js.map +1 -0
  201. package/lib/module/storage/errors.js +34 -0
  202. package/lib/module/storage/errors.js.map +1 -0
  203. package/lib/module/storage/index.js +11 -0
  204. package/lib/module/storage/index.js.map +1 -0
  205. package/lib/module/storage/schema.js +151 -0
  206. package/lib/module/storage/schema.js.map +1 -0
  207. package/lib/module/storage/serialization.js +249 -0
  208. package/lib/module/storage/serialization.js.map +1 -0
  209. package/lib/module/storage/store.js +387 -0
  210. package/lib/module/storage/store.js.map +1 -0
  211. package/lib/module/storage/types.js +16 -0
  212. package/lib/module/storage/types.js.map +1 -0
  213. package/lib/module/storage/validation.js +111 -0
  214. package/lib/module/storage/validation.js.map +1 -0
  215. package/lib/module/storage.js +4 -0
  216. package/lib/module/storage.js.map +1 -0
  217. package/lib/module/testing.js +4 -0
  218. package/lib/module/testing.js.map +1 -1
  219. package/lib/module/tilemap/chunkStats.js +27 -0
  220. package/lib/module/tilemap/chunkStats.js.map +1 -0
  221. package/lib/module/tilemap/definitions.js +308 -0
  222. package/lib/module/tilemap/definitions.js.map +1 -0
  223. package/lib/module/tilemap/errors.js +13 -0
  224. package/lib/module/tilemap/errors.js.map +1 -0
  225. package/lib/module/tilemap/index.js +10 -0
  226. package/lib/module/tilemap/index.js.map +1 -0
  227. package/lib/module/tilemap/movement.js +379 -0
  228. package/lib/module/tilemap/movement.js.map +1 -0
  229. package/lib/module/tilemap/queries.js +114 -0
  230. package/lib/module/tilemap/queries.js.map +1 -0
  231. package/lib/module/tilemap/tiledAdapter.js +141 -0
  232. package/lib/module/tilemap/tiledAdapter.js.map +1 -0
  233. package/lib/module/tilemap/types.js +4 -0
  234. package/lib/module/tilemap/types.js.map +1 -0
  235. package/lib/module/tilemap.js +4 -0
  236. package/lib/module/tilemap.js.map +1 -0
  237. package/lib/typescript/src/assets/defineAssets.d.ts +1 -1
  238. package/lib/typescript/src/assets/defineAssets.d.ts.map +1 -1
  239. package/lib/typescript/src/assets.d.ts +11 -0
  240. package/lib/typescript/src/assets.d.ts.map +1 -0
  241. package/lib/typescript/src/audio/createGameAudio.d.ts +5 -0
  242. package/lib/typescript/src/audio/createGameAudio.d.ts.map +1 -0
  243. package/lib/typescript/src/audio/errors.d.ts +6 -0
  244. package/lib/typescript/src/audio/errors.d.ts.map +1 -0
  245. package/lib/typescript/src/audio/index.d.ts +4 -0
  246. package/lib/typescript/src/audio/index.d.ts.map +1 -0
  247. package/lib/typescript/src/audio/resolver.d.ts +44 -0
  248. package/lib/typescript/src/audio/resolver.d.ts.map +1 -0
  249. package/lib/typescript/src/audio/types.d.ts +42 -0
  250. package/lib/typescript/src/audio/types.d.ts.map +1 -0
  251. package/lib/typescript/src/audio.d.ts +8 -0
  252. package/lib/typescript/src/audio.d.ts.map +1 -0
  253. package/lib/typescript/src/camera2d/bounds.d.ts +25 -0
  254. package/lib/typescript/src/camera2d/bounds.d.ts.map +1 -0
  255. package/lib/typescript/src/camera2d/extents.d.ts +17 -0
  256. package/lib/typescript/src/camera2d/extents.d.ts.map +1 -0
  257. package/lib/typescript/src/camera2d/follow.d.ts +24 -0
  258. package/lib/typescript/src/camera2d/follow.d.ts.map +1 -0
  259. package/lib/typescript/src/camera2d/index.d.ts +19 -0
  260. package/lib/typescript/src/camera2d/index.d.ts.map +1 -0
  261. package/lib/typescript/src/camera2d/interpolation.d.ts +17 -0
  262. package/lib/typescript/src/camera2d/interpolation.d.ts.map +1 -0
  263. package/lib/typescript/src/camera2d/shake.d.ts +20 -0
  264. package/lib/typescript/src/camera2d/shake.d.ts.map +1 -0
  265. package/lib/typescript/src/camera2d/transform.d.ts +44 -0
  266. package/lib/typescript/src/camera2d/transform.d.ts.map +1 -0
  267. package/lib/typescript/src/camera2d/types.d.ts +74 -0
  268. package/lib/typescript/src/camera2d/types.d.ts.map +1 -0
  269. package/lib/typescript/src/camera2d/validation.d.ts +30 -0
  270. package/lib/typescript/src/camera2d/validation.d.ts.map +1 -0
  271. package/lib/typescript/src/camera2d/visibility.d.ts +47 -0
  272. package/lib/typescript/src/camera2d/visibility.d.ts.map +1 -0
  273. package/lib/typescript/src/camera2d.d.ts +7 -0
  274. package/lib/typescript/src/camera2d.d.ts.map +1 -0
  275. package/lib/typescript/src/collision2d/colliders.d.ts +120 -0
  276. package/lib/typescript/src/collision2d/colliders.d.ts.map +1 -0
  277. package/lib/typescript/src/collision2d/debug.d.ts +67 -0
  278. package/lib/typescript/src/collision2d/debug.d.ts.map +1 -0
  279. package/lib/typescript/src/collision2d/filters.d.ts +28 -0
  280. package/lib/typescript/src/collision2d/filters.d.ts.map +1 -0
  281. package/lib/typescript/src/collision2d/index.d.ts +17 -0
  282. package/lib/typescript/src/collision2d/index.d.ts.map +1 -0
  283. package/lib/typescript/src/collision2d/intersections.d.ts +24 -0
  284. package/lib/typescript/src/collision2d/intersections.d.ts.map +1 -0
  285. package/lib/typescript/src/collision2d/manifolds.d.ts +39 -0
  286. package/lib/typescript/src/collision2d/manifolds.d.ts.map +1 -0
  287. package/lib/typescript/src/collision2d/segments.d.ts +24 -0
  288. package/lib/typescript/src/collision2d/segments.d.ts.map +1 -0
  289. package/lib/typescript/src/collision2d/spatialHash.d.ts +50 -0
  290. package/lib/typescript/src/collision2d/spatialHash.d.ts.map +1 -0
  291. package/lib/typescript/src/collision2d/sweeps.d.ts +60 -0
  292. package/lib/typescript/src/collision2d/sweeps.d.ts.map +1 -0
  293. package/lib/typescript/src/collision2d.d.ts +7 -0
  294. package/lib/typescript/src/collision2d.d.ts.map +1 -0
  295. package/lib/typescript/src/core/input/buttonPad.d.ts +59 -0
  296. package/lib/typescript/src/core/input/buttonPad.d.ts.map +1 -0
  297. package/lib/typescript/src/core/input/createInputBuffer.d.ts +1 -1
  298. package/lib/typescript/src/core/input/createInputBuffer.d.ts.map +1 -1
  299. package/lib/typescript/src/core/input/types.d.ts +7 -0
  300. package/lib/typescript/src/core/input/types.d.ts.map +1 -1
  301. package/lib/typescript/src/core/session/createGameSession.d.ts +4 -2
  302. package/lib/typescript/src/core/session/createGameSession.d.ts.map +1 -1
  303. package/lib/typescript/src/core/session/deepFreeze.d.ts +21 -1
  304. package/lib/typescript/src/core/session/deepFreeze.d.ts.map +1 -1
  305. package/lib/typescript/src/core/session/diagnostics.d.ts +2 -0
  306. package/lib/typescript/src/core/session/diagnostics.d.ts.map +1 -1
  307. package/lib/typescript/src/core/session/types.d.ts +69 -4
  308. package/lib/typescript/src/core/session/types.d.ts.map +1 -1
  309. package/lib/typescript/src/definition/defineGame.d.ts +12 -1
  310. package/lib/typescript/src/definition/defineGame.d.ts.map +1 -1
  311. package/lib/typescript/src/definition/types.d.ts +10 -1
  312. package/lib/typescript/src/definition/types.d.ts.map +1 -1
  313. package/lib/typescript/src/events/defineGameEvents.d.ts +26 -0
  314. package/lib/typescript/src/events/defineGameEvents.d.ts.map +1 -0
  315. package/lib/typescript/src/events/errors.d.ts +12 -0
  316. package/lib/typescript/src/events/errors.d.ts.map +1 -0
  317. package/lib/typescript/src/events/index.d.ts +6 -0
  318. package/lib/typescript/src/events/index.d.ts.map +1 -0
  319. package/lib/typescript/src/events/payload.d.ts +21 -0
  320. package/lib/typescript/src/events/payload.d.ts.map +1 -0
  321. package/lib/typescript/src/events/seed.d.ts +3 -0
  322. package/lib/typescript/src/events/seed.d.ts.map +1 -0
  323. package/lib/typescript/src/events/types.d.ts +42 -0
  324. package/lib/typescript/src/events/types.d.ts.map +1 -0
  325. package/lib/typescript/src/events.d.ts +12 -0
  326. package/lib/typescript/src/events.d.ts.map +1 -0
  327. package/lib/typescript/src/geometry/helpers.d.ts +35 -0
  328. package/lib/typescript/src/geometry/helpers.d.ts.map +1 -0
  329. package/lib/typescript/src/geometry/index.d.ts +4 -0
  330. package/lib/typescript/src/geometry/index.d.ts.map +1 -0
  331. package/lib/typescript/src/geometry/types.d.ts +49 -0
  332. package/lib/typescript/src/geometry/types.d.ts.map +1 -1
  333. package/lib/typescript/src/geometry/validation.d.ts +44 -0
  334. package/lib/typescript/src/geometry/validation.d.ts.map +1 -0
  335. package/lib/typescript/src/geometry.d.ts +7 -0
  336. package/lib/typescript/src/geometry.d.ts.map +1 -0
  337. package/lib/typescript/src/haptics/createGameHaptics.d.ts +3 -0
  338. package/lib/typescript/src/haptics/createGameHaptics.d.ts.map +1 -0
  339. package/lib/typescript/src/haptics/errors.d.ts +6 -0
  340. package/lib/typescript/src/haptics/errors.d.ts.map +1 -0
  341. package/lib/typescript/src/haptics/index.d.ts +4 -0
  342. package/lib/typescript/src/haptics/index.d.ts.map +1 -0
  343. package/lib/typescript/src/haptics/resolver.d.ts +22 -0
  344. package/lib/typescript/src/haptics/resolver.d.ts.map +1 -0
  345. package/lib/typescript/src/haptics/types.d.ts +37 -0
  346. package/lib/typescript/src/haptics/types.d.ts.map +1 -0
  347. package/lib/typescript/src/haptics.d.ts +8 -0
  348. package/lib/typescript/src/haptics.d.ts.map +1 -0
  349. package/lib/typescript/src/index.d.ts +10 -2
  350. package/lib/typescript/src/index.d.ts.map +1 -1
  351. package/lib/typescript/src/particles/createParticleSystem.d.ts +5 -0
  352. package/lib/typescript/src/particles/createParticleSystem.d.ts.map +1 -0
  353. package/lib/typescript/src/particles/defineParticleEffect.d.ts +3 -0
  354. package/lib/typescript/src/particles/defineParticleEffect.d.ts.map +1 -0
  355. package/lib/typescript/src/particles/errors.d.ts +5 -0
  356. package/lib/typescript/src/particles/errors.d.ts.map +1 -0
  357. package/lib/typescript/src/particles/index.d.ts +6 -0
  358. package/lib/typescript/src/particles/index.d.ts.map +1 -0
  359. package/lib/typescript/src/particles/sampling.d.ts +54 -0
  360. package/lib/typescript/src/particles/sampling.d.ts.map +1 -0
  361. package/lib/typescript/src/particles/types.d.ts +292 -0
  362. package/lib/typescript/src/particles/types.d.ts.map +1 -0
  363. package/lib/typescript/src/particles.d.ts +2 -0
  364. package/lib/typescript/src/particles.d.ts.map +1 -0
  365. package/lib/typescript/src/react/GameButtonPad.d.ts +84 -0
  366. package/lib/typescript/src/react/GameButtonPad.d.ts.map +1 -0
  367. package/lib/typescript/src/react/GamePointerInput.d.ts.map +1 -1
  368. package/lib/typescript/src/react/GameView.d.ts +27 -1
  369. package/lib/typescript/src/react/GameView.d.ts.map +1 -1
  370. package/lib/typescript/src/react/assets/createGameAssetStore.d.ts.map +1 -1
  371. package/lib/typescript/src/react/assets/useGameAssets.d.ts.map +1 -1
  372. package/lib/typescript/src/react/bindAppLifecycle.d.ts +7 -1
  373. package/lib/typescript/src/react/bindAppLifecycle.d.ts.map +1 -1
  374. package/lib/typescript/src/react/bindGameSession.d.ts.map +1 -1
  375. package/lib/typescript/src/react/camera2d/GameLayer2D.d.ts +24 -0
  376. package/lib/typescript/src/react/camera2d/GameLayer2D.d.ts.map +1 -0
  377. package/lib/typescript/src/react/camera2d/defineGameCamera2D.d.ts +44 -0
  378. package/lib/typescript/src/react/camera2d/defineGameCamera2D.d.ts.map +1 -0
  379. package/lib/typescript/src/react/camera2d/usePresentedCameraBinding.d.ts +22 -0
  380. package/lib/typescript/src/react/camera2d/usePresentedCameraBinding.d.ts.map +1 -0
  381. package/lib/typescript/src/react/cleanupList.d.ts +21 -0
  382. package/lib/typescript/src/react/cleanupList.d.ts.map +1 -0
  383. package/lib/typescript/src/react/instrumentation.d.ts +33 -3
  384. package/lib/typescript/src/react/instrumentation.d.ts.map +1 -1
  385. package/lib/typescript/src/react/lifecycleSource.d.ts +21 -0
  386. package/lib/typescript/src/react/lifecycleSource.d.ts.map +1 -0
  387. package/lib/typescript/src/react/particles/ParticleView.d.ts +65 -0
  388. package/lib/typescript/src/react/particles/ParticleView.d.ts.map +1 -0
  389. package/lib/typescript/src/react/particles/culling.d.ts +70 -0
  390. package/lib/typescript/src/react/particles/culling.d.ts.map +1 -0
  391. package/lib/typescript/src/react/particles/index.d.ts +7 -0
  392. package/lib/typescript/src/react/particles/index.d.ts.map +1 -0
  393. package/lib/typescript/src/react/particles/spriteXForm.d.ts +28 -0
  394. package/lib/typescript/src/react/particles/spriteXForm.d.ts.map +1 -0
  395. package/lib/typescript/src/react/particles/useParticlePresentation.d.ts +48 -0
  396. package/lib/typescript/src/react/particles/useParticlePresentation.d.ts.map +1 -0
  397. package/lib/typescript/src/react/pointerBinding.d.ts +38 -8
  398. package/lib/typescript/src/react/pointerBinding.d.ts.map +1 -1
  399. package/lib/typescript/src/react/pointerCamera.d.ts +20 -0
  400. package/lib/typescript/src/react/pointerCamera.d.ts.map +1 -0
  401. package/lib/typescript/src/react/pointerCoalescer.d.ts +17 -1
  402. package/lib/typescript/src/react/pointerCoalescer.d.ts.map +1 -1
  403. package/lib/typescript/src/react/sprites/GameSprite.d.ts +3 -10
  404. package/lib/typescript/src/react/sprites/GameSprite.d.ts.map +1 -1
  405. package/lib/typescript/src/react/sprites/GameWorld2D.d.ts +51 -6
  406. package/lib/typescript/src/react/sprites/GameWorld2D.d.ts.map +1 -1
  407. package/lib/typescript/src/react/sprites/Sprite.d.ts.map +1 -1
  408. package/lib/typescript/src/react/sprites/SpriteBatch.d.ts +22 -1
  409. package/lib/typescript/src/react/sprites/SpriteBatch.d.ts.map +1 -1
  410. package/lib/typescript/src/react/sprites/batchVisibility.d.ts +28 -0
  411. package/lib/typescript/src/react/sprites/batchVisibility.d.ts.map +1 -0
  412. package/lib/typescript/src/react/sprites/spriteSelection.d.ts +58 -0
  413. package/lib/typescript/src/react/sprites/spriteSelection.d.ts.map +1 -0
  414. package/lib/typescript/src/react/sprites/spriteTransform.d.ts +27 -12
  415. package/lib/typescript/src/react/sprites/spriteTransform.d.ts.map +1 -1
  416. package/lib/typescript/src/react/tilemap/TileMapLayer2D.d.ts +69 -0
  417. package/lib/typescript/src/react/tilemap/TileMapLayer2D.d.ts.map +1 -0
  418. package/lib/typescript/src/react/tilemap/tilePresentation.d.ts +217 -0
  419. package/lib/typescript/src/react/tilemap/tilePresentation.d.ts.map +1 -0
  420. package/lib/typescript/src/react/useGameSession.d.ts +48 -0
  421. package/lib/typescript/src/react/useGameSession.d.ts.map +1 -0
  422. package/lib/typescript/src/react/useGameSessionStatus.d.ts +23 -0
  423. package/lib/typescript/src/react/useGameSessionStatus.d.ts.map +1 -0
  424. package/lib/typescript/src/react/viewportBinding.d.ts +5 -1
  425. package/lib/typescript/src/react/viewportBinding.d.ts.map +1 -1
  426. package/lib/typescript/src/react.d.ts +18 -1
  427. package/lib/typescript/src/react.d.ts.map +1 -1
  428. package/lib/typescript/src/scene/defineScene.d.ts +22 -2
  429. package/lib/typescript/src/scene/defineScene.d.ts.map +1 -1
  430. package/lib/typescript/src/scene/types.d.ts +24 -4
  431. package/lib/typescript/src/scene/types.d.ts.map +1 -1
  432. package/lib/typescript/src/sprites/sampleSpriteClip.d.ts +26 -2
  433. package/lib/typescript/src/sprites/sampleSpriteClip.d.ts.map +1 -1
  434. package/lib/typescript/src/sprites/spriteAnimationState.d.ts +6 -7
  435. package/lib/typescript/src/sprites/spriteAnimationState.d.ts.map +1 -1
  436. package/lib/typescript/src/sprites.d.ts +10 -0
  437. package/lib/typescript/src/sprites.d.ts.map +1 -0
  438. package/lib/typescript/src/storage/adapters/asyncStorage.d.ts +18 -0
  439. package/lib/typescript/src/storage/adapters/asyncStorage.d.ts.map +1 -0
  440. package/lib/typescript/src/storage/adapters/memory.d.ts +16 -0
  441. package/lib/typescript/src/storage/adapters/memory.d.ts.map +1 -0
  442. package/lib/typescript/src/storage/errors.d.ts +37 -0
  443. package/lib/typescript/src/storage/errors.d.ts.map +1 -0
  444. package/lib/typescript/src/storage/index.d.ts +11 -0
  445. package/lib/typescript/src/storage/index.d.ts.map +1 -0
  446. package/lib/typescript/src/storage/schema.d.ts +22 -0
  447. package/lib/typescript/src/storage/schema.d.ts.map +1 -0
  448. package/lib/typescript/src/storage/serialization.d.ts +23 -0
  449. package/lib/typescript/src/storage/serialization.d.ts.map +1 -0
  450. package/lib/typescript/src/storage/store.d.ts +3 -0
  451. package/lib/typescript/src/storage/store.d.ts.map +1 -0
  452. package/lib/typescript/src/storage/types.d.ts +69 -0
  453. package/lib/typescript/src/storage/types.d.ts.map +1 -0
  454. package/lib/typescript/src/storage/validation.d.ts +24 -0
  455. package/lib/typescript/src/storage/validation.d.ts.map +1 -0
  456. package/lib/typescript/src/storage.d.ts +2 -0
  457. package/lib/typescript/src/storage.d.ts.map +1 -0
  458. package/lib/typescript/src/testing.d.ts +1 -0
  459. package/lib/typescript/src/testing.d.ts.map +1 -1
  460. package/lib/typescript/src/tilemap/chunkStats.d.ts +14 -0
  461. package/lib/typescript/src/tilemap/chunkStats.d.ts.map +1 -0
  462. package/lib/typescript/src/tilemap/definitions.d.ts +38 -0
  463. package/lib/typescript/src/tilemap/definitions.d.ts.map +1 -0
  464. package/lib/typescript/src/tilemap/errors.d.ts +7 -0
  465. package/lib/typescript/src/tilemap/errors.d.ts.map +1 -0
  466. package/lib/typescript/src/tilemap/index.d.ts +8 -0
  467. package/lib/typescript/src/tilemap/index.d.ts.map +1 -0
  468. package/lib/typescript/src/tilemap/movement.d.ts +52 -0
  469. package/lib/typescript/src/tilemap/movement.d.ts.map +1 -0
  470. package/lib/typescript/src/tilemap/queries.d.ts +21 -0
  471. package/lib/typescript/src/tilemap/queries.d.ts.map +1 -0
  472. package/lib/typescript/src/tilemap/tiledAdapter.d.ts +32 -0
  473. package/lib/typescript/src/tilemap/tiledAdapter.d.ts.map +1 -0
  474. package/lib/typescript/src/tilemap/types.d.ts +127 -0
  475. package/lib/typescript/src/tilemap/types.d.ts.map +1 -0
  476. package/lib/typescript/src/tilemap.d.ts +2 -0
  477. package/lib/typescript/src/tilemap.d.ts.map +1 -0
  478. package/package.json +94 -4
  479. package/src/assets/defineAssets.ts +31 -5
  480. package/src/assets.ts +27 -0
  481. package/src/audio/createGameAudio.ts +749 -0
  482. package/src/audio/errors.ts +12 -0
  483. package/src/audio/index.ts +9 -0
  484. package/src/audio/resolver.ts +74 -0
  485. package/src/audio/types.ts +47 -0
  486. package/src/audio.ts +13 -0
  487. package/src/camera2d/bounds.ts +69 -0
  488. package/src/camera2d/extents.ts +25 -0
  489. package/src/camera2d/follow.ts +165 -0
  490. package/src/camera2d/index.ts +29 -0
  491. package/src/camera2d/interpolation.ts +113 -0
  492. package/src/camera2d/shake.ts +90 -0
  493. package/src/camera2d/transform.ts +148 -0
  494. package/src/camera2d/types.ts +73 -0
  495. package/src/camera2d/validation.ts +126 -0
  496. package/src/camera2d/visibility.ts +181 -0
  497. package/src/camera2d.ts +6 -0
  498. package/src/collision2d/colliders.ts +292 -0
  499. package/src/collision2d/debug.ts +133 -0
  500. package/src/collision2d/filters.ts +48 -0
  501. package/src/collision2d/index.ts +74 -0
  502. package/src/collision2d/intersections.ts +82 -0
  503. package/src/collision2d/manifolds.ts +191 -0
  504. package/src/collision2d/segments.ts +176 -0
  505. package/src/collision2d/spatialHash.ts +211 -0
  506. package/src/collision2d/sweeps.ts +269 -0
  507. package/src/collision2d.ts +6 -0
  508. package/src/core/input/buttonPad.ts +235 -0
  509. package/src/core/input/createInputBuffer.ts +95 -14
  510. package/src/core/input/types.ts +7 -0
  511. package/src/core/session/createGameSession.ts +480 -53
  512. package/src/core/session/deepFreeze.ts +104 -3
  513. package/src/core/session/diagnostics.ts +2 -0
  514. package/src/core/session/types.ts +77 -4
  515. package/src/definition/defineGame.ts +61 -3
  516. package/src/definition/types.ts +10 -0
  517. package/src/events/defineGameEvents.ts +46 -0
  518. package/src/events/errors.ts +14 -0
  519. package/src/events/index.ts +14 -0
  520. package/src/events/payload.ts +234 -0
  521. package/src/events/seed.ts +33 -0
  522. package/src/events/types.ts +53 -0
  523. package/src/events.ts +20 -0
  524. package/src/geometry/helpers.ts +136 -0
  525. package/src/geometry/index.ts +14 -0
  526. package/src/geometry/types.ts +54 -0
  527. package/src/geometry/validation.ts +131 -0
  528. package/src/geometry.ts +6 -0
  529. package/src/haptics/createGameHaptics.ts +214 -0
  530. package/src/haptics/errors.ts +12 -0
  531. package/src/haptics/index.ts +3 -0
  532. package/src/haptics/resolver.ts +58 -0
  533. package/src/haptics/types.ts +48 -0
  534. package/src/haptics.ts +7 -0
  535. package/src/index.ts +37 -1
  536. package/src/particles/createParticleSystem.ts +505 -0
  537. package/src/particles/defineParticleEffect.ts +164 -0
  538. package/src/particles/errors.ts +6 -0
  539. package/src/particles/index.ts +5 -0
  540. package/src/particles/sampling.ts +141 -0
  541. package/src/particles/types.ts +327 -0
  542. package/src/particles.ts +1 -0
  543. package/src/react/GameButtonPad.tsx +436 -0
  544. package/src/react/GamePointerInput.tsx +73 -8
  545. package/src/react/GameView.tsx +160 -61
  546. package/src/react/assets/createGameAssetStore.ts +140 -107
  547. package/src/react/assets/useGameAssets.ts +63 -31
  548. package/src/react/bindAppLifecycle.ts +55 -19
  549. package/src/react/bindGameSession.ts +12 -2
  550. package/src/react/camera2d/GameLayer2D.tsx +43 -0
  551. package/src/react/camera2d/defineGameCamera2D.ts +59 -0
  552. package/src/react/camera2d/usePresentedCameraBinding.ts +185 -0
  553. package/src/react/cleanupList.ts +48 -0
  554. package/src/react/instrumentation.ts +31 -3
  555. package/src/react/lifecycleSource.ts +58 -0
  556. package/src/react/particles/ParticleView.tsx +358 -0
  557. package/src/react/particles/culling.ts +145 -0
  558. package/src/react/particles/index.ts +6 -0
  559. package/src/react/particles/spriteXForm.ts +72 -0
  560. package/src/react/particles/useParticlePresentation.ts +261 -0
  561. package/src/react/pointerBinding.ts +74 -16
  562. package/src/react/pointerCamera.ts +33 -0
  563. package/src/react/pointerCoalescer.ts +36 -10
  564. package/src/react/sprites/GameSprite.tsx +4 -33
  565. package/src/react/sprites/GameWorld2D.tsx +113 -7
  566. package/src/react/sprites/Sprite.tsx +51 -72
  567. package/src/react/sprites/SpriteBatch.tsx +74 -22
  568. package/src/react/sprites/batchVisibility.ts +76 -0
  569. package/src/react/sprites/spriteSelection.ts +133 -0
  570. package/src/react/sprites/spriteTransform.ts +46 -26
  571. package/src/react/tilemap/TileMapLayer2D.tsx +274 -0
  572. package/src/react/tilemap/tilePresentation.ts +491 -0
  573. package/src/react/useGameSession.ts +90 -0
  574. package/src/react/useGameSessionStatus.ts +53 -0
  575. package/src/react/viewportBinding.ts +5 -1
  576. package/src/react.ts +18 -1
  577. package/src/scene/defineScene.ts +47 -5
  578. package/src/scene/types.ts +37 -3
  579. package/src/sprites/sampleSpriteClip.ts +82 -14
  580. package/src/sprites/spriteAnimationState.ts +29 -25
  581. package/src/sprites.ts +22 -0
  582. package/src/storage/adapters/asyncStorage.ts +77 -0
  583. package/src/storage/adapters/memory.ts +58 -0
  584. package/src/storage/errors.ts +88 -0
  585. package/src/storage/index.ts +18 -0
  586. package/src/storage/schema.ts +147 -0
  587. package/src/storage/serialization.ts +248 -0
  588. package/src/storage/store.ts +380 -0
  589. package/src/storage/types.ts +76 -0
  590. package/src/storage/validation.ts +102 -0
  591. package/src/storage.ts +1 -0
  592. package/src/testing.ts +4 -0
  593. package/src/tilemap/chunkStats.ts +24 -0
  594. package/src/tilemap/definitions.ts +327 -0
  595. package/src/tilemap/errors.ts +11 -0
  596. package/src/tilemap/index.ts +10 -0
  597. package/src/tilemap/movement.ts +368 -0
  598. package/src/tilemap/queries.ts +136 -0
  599. package/src/tilemap/tiledAdapter.ts +165 -0
  600. package/src/tilemap/types.ts +119 -0
  601. package/src/tilemap.ts +1 -0
@@ -0,0 +1,374 @@
1
+ "use strict";
2
+
3
+ import { rotatedHalfExtents2D } from "../../camera2d/extents.js";
4
+
5
+ /**
6
+ * Tile presentation binding (T16-F3/F4).
7
+ *
8
+ * Pure module shared between the JS thread and UI-runtime worklets:
9
+ *
10
+ * - `buildFrameTable` runs ONCE on JS at bind time and produces a flat,
11
+ * worklet-safe numeric lookup (`frameFlat[id*4..id*4+3]`) — no `Map`,
12
+ * no objects, no per-frame lookups on the UI runtime.
13
+ * - `buildTileWindowSnapshot` runs on JS whenever the visible cell window
14
+ * or source binding changes and produces a BOUNDED snapshot sized by the
15
+ * viewport capacity, never by map dimensions.
16
+ * - `writeLayerVisibleBounds` / `fillTileSlots` are worklet-callable and
17
+ * allocation-free: camera interpolation inside the transferred window
18
+ * only reads scalars and pre-transferred arrays.
19
+ *
20
+ * Full map authority stays on the simulation side; the UI runtime never
21
+ * sees `layer.data`, the chunk index, or the map value itself.
22
+ */
23
+
24
+ /** Flat numeric frame lookup: frameFlat[tileId*4] = x, [+1]=y, [+2]=w, [+3]=h. */
25
+
26
+ /**
27
+ * Resolve every declared tile to sheet-frame rectangles ONCE at bind time.
28
+ *
29
+ * Throws a structured error when a referenced frame is missing from the
30
+ * bound sheet OR when its size differs from the map cell — v1 requires
31
+ * frame dimensions to equal cell dimensions (T16-F3).
32
+ */
33
+ export function buildFrameTable(tileset, frames, cellWidth, cellHeight) {
34
+ const maxId = tileset.names.length;
35
+ const flat = new Array((maxId + 1) * 4).fill(0);
36
+ for (let id = 1; id <= maxId; id++) {
37
+ const name = tileset.nameOfId[id];
38
+ const def = tileset.tiles[name];
39
+ const rect = frames[def.frame];
40
+ if (rect === undefined) {
41
+ throw new Error(`[rn-gamekit/tilemap] frame "${def.frame}" for tile "${name}" is missing from the bound sheet`);
42
+ }
43
+ if (rect.width !== cellWidth || rect.height !== cellHeight) {
44
+ throw new Error(`[rn-gamekit/tilemap] frame "${def.frame}" for tile "${name}" is ${rect.width}x${rect.height} but the map cell is ${cellWidth}x${cellHeight}; v1 requires frame dimensions to equal cell dimensions`);
45
+ }
46
+ flat[id * 4] = rect.x;
47
+ flat[id * 4 + 1] = rect.y;
48
+ flat[id * 4 + 2] = rect.width;
49
+ flat[id * 4 + 3] = rect.height;
50
+ }
51
+ return Object.freeze(flat);
52
+ }
53
+
54
+ /** Bounded visible-window snapshot transferred to the UI runtime. */
55
+
56
+ export const EMPTY_TILE_WINDOW = Object.freeze({
57
+ x0: 0,
58
+ y0: 0,
59
+ w: 0,
60
+ h: 0,
61
+ ids: Object.freeze([]),
62
+ frameFlat: Object.freeze([])
63
+ });
64
+
65
+ /**
66
+ * Build a bounded snapshot for the inclusive cell range [x0..x1]×[y0..y1].
67
+ * The range is clamped to the layer; the result size depends ONLY on the
68
+ * requested range (bounded by viewport capacity), never on map size.
69
+ */
70
+ export function buildTileWindowSnapshot(map, layerId, x0, y0, x1, y1, frameFlat) {
71
+ const layer = map.layerById[layerId];
72
+ if (layer === undefined) return EMPTY_TILE_WINDOW;
73
+ const cx0 = Math.max(0, Math.min(x0, x1));
74
+ const cy0 = Math.max(0, Math.min(y0, y1));
75
+ const cx1 = Math.min(layer.width - 1, Math.max(x0, x1));
76
+ const cy1 = Math.min(layer.height - 1, Math.max(y0, y1));
77
+ if (cx0 > cx1 || cy0 > cy1) return EMPTY_TILE_WINDOW;
78
+ const w = cx1 - cx0 + 1;
79
+ const h = cy1 - cy0 + 1;
80
+ const ids = new Array(w * h).fill(0);
81
+ for (let cy = cy0; cy <= cy1; cy++) {
82
+ for (let cx = cx0; cx <= cx1; cx++) {
83
+ const id = layer.data[cy * layer.width + cx];
84
+ if (id !== 0) ids[(cy - cy0) * w + (cx - cx0)] = id;
85
+ }
86
+ }
87
+ return Object.freeze({
88
+ x0: cx0,
89
+ y0: cy0,
90
+ w,
91
+ h,
92
+ ids: Object.freeze(ids),
93
+ frameFlat
94
+ });
95
+ }
96
+
97
+ /** Whether the snapshot fully covers the inclusive cell range. */
98
+ export function windowCovers(snap, x0, y0, x1, y1) {
99
+ 'worklet';
100
+
101
+ if (snap.w === 0 || snap.h === 0) return false;
102
+ return snap.x0 <= x0 && snap.y0 <= y0 && snap.x0 + snap.w - 1 >= x1 && snap.y0 + snap.h - 1 >= y1;
103
+ }
104
+
105
+ // Minimal structural mirrors of the shared refs, keeping this pure module
106
+ // free of Reanimated/RN imports while accepting real SharedValues.
107
+
108
+ /**
109
+ * Write the conservative world-space bounds visible through the PRESENTED
110
+ * camera into `out` (T16-F3, reworked per T16-RF2).
111
+ *
112
+ * - With a presented camera: the logical view rect is rotated/zoomed by the
113
+ * camera, so its axis-aligned world bounds are the center plus rotated
114
+ * half-extents; the GameLayer2D parallax model applies ONCE afterwards
115
+ * (effective layer center C′ = L + (C − L)·p; zoom and rotation apply
116
+ * fully at every factor). Padding is world units.
117
+ * - WITHOUT a presented camera, GameWorld2D's viewport-only path applies:
118
+ * the bounds are `viewport.visibleLogicalBounds` expanded by the padding.
119
+ *
120
+ * Worklet-callable and allocation-free on the steady path: scalars only,
121
+ * results written into the caller-owned `out` scratch object. Returns false
122
+ * when no viewport bounds exist yet.
123
+ */
124
+ export function writeLayerVisibleBounds(camera, viewport, parallaxX, parallaxY, paddingWorld) {
125
+ 'worklet';
126
+
127
+ const view = viewport?.value?.visibleLogicalBounds;
128
+ if (view === undefined) return null;
129
+ const cam = camera?.value?.camera;
130
+ if (cam === undefined) {
131
+ // Viewport-only world: no zoom, no rotation, no parallax correction.
132
+ return {
133
+ minX: view.x - paddingWorld,
134
+ minY: view.y - paddingWorld,
135
+ maxX: view.x + view.width + paddingWorld,
136
+ maxY: view.y + view.height + paddingWorld
137
+ };
138
+ }
139
+ const hx = view.width / (2 * cam.zoom);
140
+ const hy = view.height / (2 * cam.zoom);
141
+ const extent = rotatedHalfExtents2D(hx, hy, cam.rotationRadians);
142
+ const ex = extent.x + paddingWorld;
143
+ const ey = extent.y + paddingWorld;
144
+ // Parallax AFTER base bounds: shift the center contribution only.
145
+ let centerX = cam.center.x;
146
+ let centerY = cam.center.y;
147
+ if (parallaxX !== 1 || parallaxY !== 1) {
148
+ const logicalCx = view.x + view.width / 2;
149
+ const logicalCy = view.y + view.height / 2;
150
+ centerX = logicalCx + (centerX - logicalCx) * parallaxX;
151
+ centerY = logicalCy + (centerY - logicalCy) * parallaxY;
152
+ }
153
+ return {
154
+ minX: centerX - ex,
155
+ minY: centerY - ey,
156
+ maxX: centerX + ex,
157
+ maxY: centerY + ey
158
+ };
159
+ }
160
+
161
+ /** Slot-buffer contract shared by the component and tests. */
162
+
163
+ /**
164
+ * Fill Atlas slot buffers from the transferred window for the currently
165
+ * visible cell span (worklet-callable, T16-F3/F4).
166
+ *
167
+ * - Cell range derives from `bounds` (already camera+parallax+padding).
168
+ * - Tiles place UNROTATED at their CELL TOP-LEFT: the RSXform translation
169
+ * is the cell's world top-left corner.
170
+ * - Stale slots past the filled count are hidden atomically (zero-size).
171
+ * - Returns the filled slot count on success; returns -1 when the window
172
+ * does not cover the visible span (caller should request a new window)
173
+ * and -2 when the visible span exceeds the fixed capacity (caller must
174
+ * hide the whole layer and never claim partial success) — T16-SF2.
175
+ */
176
+ export function fillTileSlots(snap, bounds, rects, xforms, params) {
177
+ 'worklet';
178
+
179
+ const {
180
+ cw,
181
+ ch,
182
+ originX,
183
+ originY,
184
+ layerWidth,
185
+ layerHeight,
186
+ capacity
187
+ } = params;
188
+ let cx0 = Math.floor((bounds.minX - originX) / cw);
189
+ let cy0 = Math.floor((bounds.minY - originY) / ch);
190
+ let cx1 = Math.floor((bounds.maxX - originX) / cw);
191
+ let cy1 = Math.floor((bounds.maxY - originY) / ch);
192
+ cx0 = Math.max(0, cx0);
193
+ cy0 = Math.max(0, cy0);
194
+ cx1 = Math.min(layerWidth - 1, cx1);
195
+ cy1 = Math.min(layerHeight - 1, cy1);
196
+ if (cx0 > cx1 || cy0 > cy1) {
197
+ hideRange(rects, 0, capacity);
198
+ return 0;
199
+ }
200
+ // Preflight the span against capacity so a rotated AABB never produces a
201
+ // partial visible region (T16-SF2). Every cell in the span could be
202
+ // occupied, so compare the worst-case span size to the fixed buffer.
203
+ const spanCells = (cx1 - cx0 + 1) * (cy1 - cy0 + 1);
204
+ if (spanCells > capacity) {
205
+ hideRange(rects, 0, capacity);
206
+ return -2;
207
+ }
208
+ if (!windowCovers(snap, cx0, cy0, cx1, cy1)) {
209
+ return -1;
210
+ }
211
+ let slot = 0;
212
+ for (let cy = cy0; cy <= cy1; cy++) {
213
+ for (let cx = cx0; cx <= cx1; cx++) {
214
+ const id = snap.ids[(cy - snap.y0) * snap.w + (cx - snap.x0)];
215
+ if (id === 0) continue;
216
+ if (slot >= capacity) {
217
+ hideRange(rects, 0, capacity);
218
+ return -2;
219
+ }
220
+ const rectSlot = rects[slot];
221
+ const xformSlot = xforms[slot];
222
+ if (rectSlot === undefined || xformSlot === undefined) continue;
223
+ rectSlot.setXYWH(snap.frameFlat[id * 4], snap.frameFlat[id * 4 + 1], snap.frameFlat[id * 4 + 2], snap.frameFlat[id * 4 + 3]);
224
+ // Unrotated placement at the cell's world TOP-LEFT corner.
225
+ xformSlot.set(1, 0, originX + cx * cw, originY + cy * ch);
226
+ slot++;
227
+ }
228
+ }
229
+ // Hide remaining stale slots atomically.
230
+ for (let i = slot; i < capacity; i++) {
231
+ rects[i]?.setXYWH(0, 0, 0, 0);
232
+ }
233
+ return slot;
234
+ }
235
+ function hideRange(rects, from, to) {
236
+ 'worklet';
237
+
238
+ for (let i = from; i < to; i++) {
239
+ rects[i]?.setXYWH(0, 0, 0, 0);
240
+ }
241
+ }
242
+
243
+ /** Stable per-binding generation from object identity (GS-TILE-01). */
244
+ const bindingGenerations = new WeakMap();
245
+ let nextBindingGeneration = 1;
246
+
247
+ /**
248
+ * Mint (or recall) the generation for one binding identity object. The
249
+ * component creates a fresh identity per binding-affecting prop change, so
250
+ * each binding gets a distinct generation with no counters in React state.
251
+ */
252
+ export function bindingGeneration(binding) {
253
+ let gen = bindingGenerations.get(binding);
254
+ if (gen === undefined) {
255
+ gen = nextBindingGeneration;
256
+ nextBindingGeneration += 1;
257
+ bindingGenerations.set(binding, gen);
258
+ }
259
+ return gen;
260
+ }
261
+
262
+ /** Shared-value mirrors kept structural so headless fakes can drive updates. */
263
+
264
+ /**
265
+ * Inputs for one tile-layer UI update (GS-TILE-01).
266
+ *
267
+ * Everything the update may touch is listed here: scalars, shared values,
268
+ * buffers, and callbacks. Map, layer, and frame-table objects are
269
+ * deliberately absent — the UI closure provably cannot capture layer data
270
+ * because it is never passed (scalar layer dims travel in `layerWidth` /
271
+ * `layerHeight`). The binding `generation` gates every window and request.
272
+ */
273
+
274
+ /**
275
+ * One tile-layer UI update: the body of the layer's derived value,
276
+ * extracted so binding identity, stale-request rejection, and capacity
277
+ * policy execute identically in tests and on the UI runtime (GS-TILE-01).
278
+ *
279
+ * Returns the filled slot count; -1 when a window was requested, -2 when
280
+ * the span exceeds capacity or zoom left the declared bounds, 0 when
281
+ * nothing is visible. A window whose generation stamp differs from the
282
+ * live binding is treated exactly like a missing window.
283
+ */
284
+ export function updateTileLayerUI(params) {
285
+ 'worklet';
286
+
287
+ const {
288
+ camera,
289
+ viewport,
290
+ window,
291
+ pendingGen,
292
+ warnedCapacity,
293
+ capacityWarnPending,
294
+ rects,
295
+ xforms,
296
+ requestWindow,
297
+ scheduleOnRN,
298
+ onBeyondCapacity,
299
+ generation,
300
+ capacity,
301
+ originX,
302
+ originY,
303
+ cw,
304
+ ch,
305
+ layerWidth,
306
+ layerHeight,
307
+ padWorld,
308
+ px,
309
+ py,
310
+ minZoom
311
+ } = params;
312
+ // Rejected camera state: zoomed out beyond the declared capacity.
313
+ const camZoom = camera?.value?.camera?.zoom;
314
+ if (camZoom !== undefined && camZoom < minZoom * (1 - 1e-3)) {
315
+ for (let i = 0; i < capacity; i++) {
316
+ rects.value[i]?.setXYWH(0, 0, 0, 0);
317
+ }
318
+ if (!warnedCapacity.value && !capacityWarnPending.value) {
319
+ capacityWarnPending.value = true;
320
+ scheduleOnRN(onBeyondCapacity);
321
+ }
322
+ return -2;
323
+ }
324
+ const bounds = writeLayerVisibleBounds(camera, viewport, px, py, padWorld);
325
+ if (bounds === null) {
326
+ return 0;
327
+ }
328
+ const cx0 = Math.max(0, Math.floor((bounds.minX - originX) / cw));
329
+ const cy0 = Math.max(0, Math.floor((bounds.minY - originY) / ch));
330
+ const cx1 = Math.min(layerWidth - 1, Math.floor((bounds.maxX - originX) / cw));
331
+ const cy1 = Math.min(layerHeight - 1, Math.floor((bounds.maxY - originY) / ch));
332
+ if (cx0 > cx1 || cy0 > cy1) {
333
+ // Off-map view: hide everything.
334
+ for (let i = 0; i < capacity; i++) {
335
+ rects.value[i]?.setXYWH(0, 0, 0, 0);
336
+ }
337
+ return 0;
338
+ }
339
+ const snap = window.value;
340
+ // GS-TILE-01: the generation stamp decides before coordinates do. A stale
341
+ // window (same-size replacement, remount, late delivery) takes the
342
+ // request path exactly like a missing window.
343
+ if (snap.gen !== generation) {
344
+ if (pendingGen.value !== generation) {
345
+ pendingGen.value = generation;
346
+ scheduleOnRN(() => requestWindow(generation, cx0, cy0, cx1, cy1));
347
+ }
348
+ return -1;
349
+ }
350
+ const filled = fillTileSlots(snap, bounds, rects.value, xforms.value, {
351
+ cw,
352
+ ch,
353
+ originX,
354
+ originY,
355
+ layerWidth,
356
+ layerHeight,
357
+ capacity
358
+ });
359
+ if (filled === -1 && pendingGen.value !== generation) {
360
+ pendingGen.value = generation;
361
+ scheduleOnRN(() => requestWindow(generation, cx0, cy0, cx1, cy1));
362
+ return -1;
363
+ }
364
+ if (filled === -2) {
365
+ // Capacity insufficient even at a valid zoom (e.g. extreme rotation
366
+ // on a fully occupied span) — hide everything, never partial.
367
+ for (let i = 0; i < capacity; i++) {
368
+ rects.value[i]?.setXYWH(0, 0, 0, 0);
369
+ }
370
+ return -2;
371
+ }
372
+ return filled;
373
+ }
374
+ //# sourceMappingURL=tilePresentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["rotatedHalfExtents2D","buildFrameTable","tileset","frames","cellWidth","cellHeight","maxId","names","length","flat","Array","fill","id","name","nameOfId","def","tiles","rect","frame","undefined","Error","width","height","x","y","Object","freeze","EMPTY_TILE_WINDOW","x0","y0","w","h","ids","frameFlat","buildTileWindowSnapshot","map","layerId","x1","y1","layer","layerById","cx0","Math","max","min","cy0","cx1","cy1","cy","cx","data","windowCovers","snap","writeLayerVisibleBounds","camera","viewport","parallaxX","parallaxY","paddingWorld","view","value","visibleLogicalBounds","cam","minX","minY","maxX","maxY","hx","zoom","hy","extent","rotationRadians","ex","ey","centerX","center","centerY","logicalCx","logicalCy","fillTileSlots","bounds","rects","xforms","params","cw","ch","originX","originY","layerWidth","layerHeight","capacity","floor","hideRange","spanCells","slot","rectSlot","xformSlot","setXYWH","set","i","from","to","bindingGenerations","WeakMap","nextBindingGeneration","bindingGeneration","binding","gen","get","updateTileLayerUI","window","pendingGen","warnedCapacity","capacityWarnPending","requestWindow","scheduleOnRN","onBeyondCapacity","generation","padWorld","px","py","minZoom","camZoom","filled"],"sourceRoot":"../../../../src","sources":["react/tilemap/tilePresentation.ts"],"mappings":";;AACA,SAASA,oBAAoB,QAAQ,2BAAwB;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC7BC,OAAkB,EAClBC,MAAyF,EACzFC,SAAiB,EACjBC,UAAkB,EACF;EAChB,MAAMC,KAAK,GAAGJ,OAAO,CAACK,KAAK,CAACC,MAAM;EAClC,MAAMC,IAAc,GAAG,IAAIC,KAAK,CAAC,CAACJ,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAACK,IAAI,CAAC,CAAC,CAAC;EACzD,KAAK,IAAIC,EAAE,GAAG,CAAC,EAAEA,EAAE,IAAIN,KAAK,EAAEM,EAAE,EAAE,EAAE;IAClC,MAAMC,IAAI,GAAGX,OAAO,CAACY,QAAQ,CAACF,EAAE,CAAE;IAClC,MAAMG,GAAG,GAAGb,OAAO,CAACc,KAAK,CAACH,IAAI,CAAE;IAChC,MAAMI,IAAI,GAAGd,MAAM,CAACY,GAAG,CAACG,KAAK,CAAC;IAC9B,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EACA;EACA,IAAIR,IAAI,CAACuD,GAAG,KAAKU,UAAU,EAAE;IAC3B,IAAIN,UAAU,CAACnD,KAAK,KAAKyD,UAAU,EAAE;MACnCN,UAAU,CAACnD,KAAK,GAAGyD,UAAU;MAC7BF,YAAY,CAAC,MAAMD,aAAa,CAACG,UAAU,EAAE5E,GAAG,EAAEI,GAAG,EAAEC,GAAG,EAAEC,GAAG,CAAC,CAAC;IACnE;IACA,OAAO,CAAC,CAAC;EACX;EACA,MAAM4E,MAAM,GAAG5C,aAAa,CAC1B3B,IAAI,EACJ4B,MAAM,EACNC,KAAK,CAACrB,KAAK,EACXsB,MAAM,CAACtB,KAAK,EACZ;IAAEwB,EAAE;IAAEC,EAAE;IAAEC,OAAO;IAAEC,OAAO;IAAEC,UAAU;IAAEC,WAAW;IAAEC;EAAS,CAChE,CAAC;EACD,IAAIiC,MAAM,KAAK,CAAC,CAAC,IAAIZ,UAAU,CAACnD,KAAK,KAAKyD,UAAU,EAAE;IACpDN,UAAU,CAACnD,KAAK,GAAGyD,UAAU;IAC7BF,YAAY,CAAC,MAAMD,aAAa,CAACG,UAAU,EAAE5E,GAAG,EAAEI,GAAG,EAAEC,GAAG,EAAEC,GAAG,CAAC,CAAC;IACjE,OAAO,CAAC,CAAC;EACX;EACA,IAAI4E,MAAM,KAAK,CAAC,CAAC,EAAE;IACjB;IACA;IACA,KAAK,IAAIxB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGT,QAAQ,EAAES,CAAC,EAAE,EAAE;MACjClB,KAAK,CAACrB,KAAK,CAACuC,CAAC,CAAC,EAAEF,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACrC;IACA,OAAO,CAAC,CAAC;EACX;EACA,OAAO0B,MAAM;AACf","ignoreList":[]}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ import { useEffect, useState } from 'react';
4
+ import { createGameSession } from "../core/session/createGameSession.js";
5
+ /**
6
+ * Create and own a `GameSession` for a `GameDefinition`, with React
7
+ * ownership.
8
+ *
9
+ * The hook creates an idle session during the commit phase, publishes it,
10
+ * and disposes it exactly once when it is replaced or the owner unmounts.
11
+ * React Strict Mode's development setup/cleanup rehearsal is safe: every
12
+ * rehearsal session is disposed exactly once and a disposed session is never
13
+ * published.
14
+ *
15
+ * Ownership rules:
16
+ *
17
+ * - The return value is `undefined` until React commits a live session for
18
+ * the current definition: the initial render, and the boundary while a
19
+ * definition replacement is being created. Render a deliberate fallback
20
+ * instead of hiding it.
21
+ * - The same definition object returns the same session across re-renders.
22
+ * A different definition object unpublishes the old session, disposes it,
23
+ * and publishes a fresh one. Disposed sessions are never revived, so
24
+ * declaring definitions at module scope keeps identity stable.
25
+ * - The hook owns terminal disposal. Do not call `session.dispose()` on a
26
+ * hook-owned session.
27
+ * - The hook does not start the session. Pass it to `GameView`, which binds,
28
+ * starts, pauses on unmount/backgrounding, and never terminally disposes a
29
+ * borrowed session.
30
+ * - For an asset-backed game, mount the component that calls this hook only
31
+ * after `useGameAssets()` reports `ready`; this hook does not load assets.
32
+ *
33
+ * Use `createGameSession()` with explicit `try/finally` disposal for headless
34
+ * tests, non-React programs, and custom surface controllers that need to own
35
+ * sessions imperatively.
36
+ */
37
+ export function useGameSession(definition) {
38
+ return useOwnedGameSession(definition, createGameSession);
39
+ }
40
+
41
+ /**
42
+ * @internal
43
+ *
44
+ * The injectable-creator seam behind `useGameSession`, exported from this
45
+ * module only (never from the `rn-gamekit/react` barrel). Tests supply a
46
+ * deterministic creator (for example `createGameSessionWithDriver` with a
47
+ * `ManualFrameDriver`, since node has no `requestAnimationFrame`) and must
48
+ * pass a stable factory identity across renders.
49
+ */
50
+ export function useOwnedGameSession(definition, create) {
51
+ const [owned, setOwned] = useState(undefined);
52
+
53
+ // Render-phase selector: publish a session only while its definition is
54
+ // the current prop and its status is not disposed. A replacement render
55
+ // therefore unpublishes the old session before any effect runs, and
56
+ // `undefined` is the only other value.
57
+ const session = owned !== undefined && owned.definition === definition && owned.session.status !== 'disposed' ? owned.session : undefined;
58
+ useEffect(() => {
59
+ const next = create(definition);
60
+ setOwned({
61
+ definition,
62
+ session: next
63
+ });
64
+ return () => {
65
+ next.dispose();
66
+ };
67
+ }, [definition, create]);
68
+ return session;
69
+ }
70
+ //# sourceMappingURL=useGameSession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useState","createGameSession","useGameSession","definition","useOwnedGameSession","create","owned","setOwned","undefined","session","status","next","dispose"],"sourceRoot":"../../../src","sources":["react/useGameSession.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,iBAAiB,QAAQ,sCAAmC;AAerE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,UAA2C,EACD;EAC1C,OAAOC,mBAAmB,CAACD,UAAU,EAAEF,iBAAiB,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,mBAAmBA,CACjCD,UAA2C,EAC3CE,MAAuC,EACG;EAC1C,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGP,QAAQ,CAA4CQ,SAAS,CAAC;;EAExF;EACA;EACA;EACA;EACA,MAAMC,OAAO,GACXH,KAAK,KAAKE,SAAS,IACnBF,KAAK,CAACH,UAAU,KAAKA,UAAU,IAC/BG,KAAK,CAACG,OAAO,CAACC,MAAM,KAAK,UAAU,GAC/BJ,KAAK,CAACG,OAAO,GACbD,SAAS;EAEfT,SAAS,CAAC,MAAM;IACd,MAAMY,IAAI,GAAGN,MAAM,CAACF,UAAU,CAAC;IAC/BI,QAAQ,CAAC;MAAEJ,UAAU;MAAEM,OAAO,EAAEE;IAAK,CAAC,CAAC;IACvC,OAAO,MAAM;MACXA,IAAI,CAACC,OAAO,CAAC,CAAC;IAChB,CAAC;EACH,CAAC,EAAE,CAACT,UAAU,EAAEE,MAAM,CAAC,CAAC;EAExB,OAAOI,OAAO;AAChB","ignoreList":[]}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ import { useCallback, useSyncExternalStore } from 'react';
4
+ /** Stable no-op cleanup for the absent/disposed session branch. */
5
+ const unsubscribeNothing = () => {};
6
+
7
+ /**
8
+ * Observe a session's lifecycle status from React.
9
+ *
10
+ * Returns the current `session.status` on the render that observes a
11
+ * session, and re-renders once per actual lifecycle transition. `undefined`
12
+ * means no session is currently available — the same meaning Task 9's
13
+ * `useGameSession()` gives its pre-commit value, so both hooks compose
14
+ * unconditionally:
15
+ *
16
+ * ```ts
17
+ * const session = useGameSession(game);
18
+ * const status = useGameSessionStatus(session);
19
+ * ```
20
+ *
21
+ * The hook subscribes through `addStatusListener` and never polls; it owns
22
+ * no session and never disposes one. Replacing the session argument detaches
23
+ * the old subscription before the replacement's status is reported, and
24
+ * idempotent lifecycle commands do not cause redundant re-renders.
25
+ */
26
+ export function useGameSessionStatus(session) {
27
+ // The callbacks are memoized on the session identity only, so unrelated
28
+ // parent renders never tear down and recreate the subscription; a session
29
+ // prop change produces new identities and React detaches the old session
30
+ // before attaching the replacement.
31
+ const subscribe = useCallback(onStoreChange => {
32
+ // Never subscribe to a disposed session: its terminal notification is
33
+ // already delivered, and addStatusListener follows the disposed-error
34
+ // policy for new subscribers.
35
+ if (session === undefined || session.status === 'disposed') {
36
+ return unsubscribeNothing;
37
+ }
38
+ const subscription = session.addStatusListener(onStoreChange);
39
+ return () => {
40
+ subscription.remove();
41
+ };
42
+ }, [session]);
43
+ const getSnapshot = useCallback(() => session?.status, [session]);
44
+ return useSyncExternalStore(subscribe, getSnapshot);
45
+ }
46
+ //# sourceMappingURL=useGameSessionStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useSyncExternalStore","unsubscribeNothing","useGameSessionStatus","session","subscribe","onStoreChange","undefined","status","subscription","addStatusListener","remove","getSnapshot"],"sourceRoot":"../../../src","sources":["react/useGameSessionStatus.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,oBAAoB,QAAQ,OAAO;AAIzD;AACA,MAAMC,kBAAkB,GAAGA,CAAA,KAAY,CAAC,CAAC;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAGlCC,OAAiD,EAAiC;EAClF;EACA;EACA;EACA;EACA,MAAMC,SAAS,GAAGL,WAAW,CAC1BM,aAAyB,IAAK;IAC7B;IACA;IACA;IACA,IAAIF,OAAO,KAAKG,SAAS,IAAIH,OAAO,CAACI,MAAM,KAAK,UAAU,EAAE;MAC1D,OAAON,kBAAkB;IAC3B;IACA,MAAMO,YAAY,GAAGL,OAAO,CAACM,iBAAiB,CAACJ,aAAa,CAAC;IAC7D,OAAO,MAAM;MACXG,YAAY,CAACE,MAAM,CAAC,CAAC;IACvB,CAAC;EACH,CAAC,EACD,CAACP,OAAO,CACV,CAAC;EACD,MAAMQ,WAAW,GAAGZ,WAAW,CAAC,MAAMI,OAAO,EAAEI,MAAM,EAAE,CAACJ,OAAO,CAAC,CAAC;EAEjE,OAAOH,oBAAoB,CAACI,SAAS,EAAEO,WAAW,CAAC;AACrD","ignoreList":[]}
@@ -76,7 +76,11 @@ export class ViewportBinding {
76
76
  };
77
77
  }
78
78
 
79
- /** Release subscribers. The binding becomes inert. */
79
+ /**
80
+ * Release current subscribers (GS-VIEWPORT-01). This is not a lifecycle
81
+ * gate: late subscriptions still register and setSurfaceSize still
82
+ * resolves. Discard the binding after disposal instead of reusing it.
83
+ */
80
84
  dispose() {
81
85
  this.#listeners.clear();
82
86
  }
@@ -1 +1 @@
1
- {"version":3,"names":["resolveViewport2D","ViewportBinding","config","resolved","lastSurfaceSize","revision","listeners","Set","constructor","surfaceSize","setSurfaceSize","size","undefined","width","height","Object","freeze","listener","subscribe","add","removed","delete","dispose","clear","bindingForViewport","previous","replacement"],"sourceRoot":"../../../src","sources":["react/viewportBinding.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAkE,wBAAe;;AAE3G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAAe,CAAC;EAClB,CAACC,MAAM;EAChB,CAACC,QAAQ;EACT,CAACC,eAAe;EAChB,CAACC,QAAQ,GAAG,CAAC;EACb,CAACC,SAAS,GAAG,IAAIC,GAAG,CAAa,CAAC;EAElCC,WAAWA,CAACN,MAAgB,EAAE;IAC5B,IAAI,CAAC,CAACA,MAAM,GAAGA,MAAM;EACvB;;EAEA;EACA,IAAIA,MAAMA,CAAA,EAAa;IACrB,OAAO,IAAI,CAAC,CAACA,MAAM;EACrB;;EAEA;EACA,IAAIC,QAAQA,CAAA,EAAmC;IAC7C,OAAO,IAAI,CAAC,CAACA,QAAQ;EACvB;;EAEA;EACA,IAAIM,WAAWA,CAAA,EAA4B;IACzC,OAAO,IAAI,CAAC,CAACL,eAAe;EAC9B;;EAEA;EACA,IAAIC,QAAQA,CAAA,EAAW;IACrB,OAAO,IAAI,CAAC,CAACA,QAAQ;EACvB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEK,cAAcA,CAACC,IAAiB,EAAQ;IACtC,IACE,IAAI,CAAC,CAACP,eAAe,KAAKQ,SAAS,IACnC,IAAI,CAAC,CAACR,eAAe,CAACS,KAAK,KAAKF,IAAI,CAACE,KAAK,IAC1C,IAAI,CAAC,CAACT,eAAe,CAACU,MAAM,KAAKH,IAAI,CAACG,MAAM,EAC5C;MACA;IACF;IACA,IAAI,CAAC,CAACV,eAAe,GAAGW,MAAM,CAACC,MAAM,CAAC;MAAEH,KAAK,EAAEF,IAAI,CAACE,KAAK;MAAEC,MAAM,EAAEH,IAAI,CAACG;IAAO,CAAC,CAAC;IACjF,IAAI,CAAC,CAACX,QAAQ,GAAGH,iBAAiB,CAAC,IAAI,CAAC,CAACE,MAAM,EAAES,IAAI,CAAC;IACtD,IAAI,CAAC,CAACN,QAAQ,IAAI,CAAC;IACnB,KAAK,MAAMY,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,CAACX,SAAS,CAAC,EAAE;MAC3CW,QAAQ,CAAC,CAAC;IACZ;EACF;;EAEA;EACAC,SAASA,CAACD,QAAoB,EAAc;IAC1C,IAAI,CAAC,CAACX,SAAS,CAACa,GAAG,CAACF,QAAQ,CAAC;IAC7B,IAAIG,OAAO,GAAG,KAAK;IACnB,OAAO,MAAM;MACX,IAAIA,OAAO,EAAE;QACX;MACF;MACAA,OAAO,GAAG,IAAI;MACd,IAAI,CAAC,CAACd,SAAS,CAACe,MAAM,CAACJ,QAAQ,CAAC;IAClC,CAAC;EACH;;EAEA;EACAK,OAAOA,CAAA,EAAS;IACd,IAAI,CAAC,CAAChB,SAAS,CAACiB,KAAK,CAAC,CAAC;EACzB;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAChCtB,MAAgB,EAChBuB,QAAgC,EACf;EACjB,IAAIA,QAAQ,EAAEvB,MAAM,KAAKA,MAAM,EAAE;IAC/B,OAAOuB,QAAQ;EACjB;EAEA,MAAMC,WAAW,GAAG,IAAIzB,eAAe,CAACC,MAAM,CAAC;EAC/C,IAAIuB,QAAQ,EAAEhB,WAAW,KAAKG,SAAS,EAAE;IACvCc,WAAW,CAAChB,cAAc,CAACe,QAAQ,CAAChB,WAAW,CAAC;EAClD;EACA,OAAOiB,WAAW;AACpB","ignoreList":[]}
1
+ {"version":3,"names":["resolveViewport2D","ViewportBinding","config","resolved","lastSurfaceSize","revision","listeners","Set","constructor","surfaceSize","setSurfaceSize","size","undefined","width","height","Object","freeze","listener","subscribe","add","removed","delete","dispose","clear","bindingForViewport","previous","replacement"],"sourceRoot":"../../../src","sources":["react/viewportBinding.ts"],"mappings":";;A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AMY,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,CAACX,SAAS,CAAC,EAAE;MAC3CW,QAAQ,CAAC,CAAC;IACZ;EACF;;EAEA;EACAC,SAASA,CAACD,QAAoB,EAAc;IAC1C,IAAI,CAAC,CAACX,SAAS,CAACa,GAAG,CAACF,QAAQ,CAAC;IAC7B,IAAIG,OAAO,GAAG,KAAK;IACnB,OAAO,MAAM;MACX,IAAIA,OAAO,EAAE;QACX;MACF;MACAA,OAAO,GAAG,IAAI;MACd,IAAI,CAAC,CAACd,SAAS,CAACe,MAAM,CAACJ,QAAQ,CAAC;IAClC,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;EACEK,OAAOA,CAAA,EAAS;IACd,IAAI,CAAC,CAAChB,SAAS,CAACiB,KAAK,CAAC,CAAC;EACzB;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAChCtB,MAAgB,EAChBuB,QAAgC,EACf;EACjB,IAAIA,QAAQ,EAAEvB,MAAM,KAAKA,MAAM,EAAE;IAC/B,OAAOuB,QAAQ;EACjB;EAEA,MAAMC,WAAW,GAAG,IAAIzB,eAAe,CAACC,MAAM,CAAC;EAC/C,IAAIuB,QAAQ,EAAEhB,WAAW,KAAKG,SAAS,EAAE;IACvCc,WAAW,CAAChB,cAAc,CAACe,QAAQ,CAAChB,WAAW,CAAC;EAClD;EACA,OAAOiB,WAAW;AACpB","ignoreList":[]}
@@ -1,13 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  export { GameView } from "./react/GameView.js";
4
+ export { useGameSession } from "./react/useGameSession.js";
5
+ export { useGameSessionStatus } from "./react/useGameSessionStatus.js";
6
+ export { createGameLifecycleSource, GameLifecycleProvider, useGameLifecycleSource } from "./react/lifecycleSource.js";
4
7
  export { createGameAssetStore } from "./react/assets/decodeSkiaImage.js";
5
8
  export { useGameAssets, stableGroupsKey } from "./react/assets/useGameAssets.js";
6
- export { GameWorld2D, viewportTransform } from "./react/sprites/GameWorld2D.js";
9
+ export { GameWorld2D, viewportTransform, cameraViewportTransform2D, layerParallaxTransform2D } from "./react/sprites/GameWorld2D.js";
10
+ export { GameLayer2D } from "./react/camera2d/GameLayer2D.js";
11
+ export { defineGameCamera2D } from "./react/camera2d/defineGameCamera2D.js";
7
12
  export { Sprite, resolveSpriteFrameRect } from "./react/sprites/Sprite.js";
8
13
  export { GameSprite, spriteFrameNameForClip } from "./react/sprites/GameSprite.js";
9
14
  export { SpriteBatch } from "./react/sprites/SpriteBatch.js";
10
15
  export { computeSpriteRsxform, spriteAnchorWorld, spriteGroupCorrection } from "./react/sprites/spriteTransform.js";
11
16
  export { createGameAssetStoreCore } from "./react/assets/createGameAssetStore.js";
12
17
  export { GamePointerInput } from "./react/GamePointerInput.js";
18
+ export { GameButtonPad, GameButton } from "./react/GameButtonPad.js";
19
+ export { ParticleView } from "./react/particles/ParticleView.js";
20
+ export { useParticlePresentation } from "./react/particles/useParticlePresentation.js";
21
+ export { particleSpriteXform, assertUniformParticleSpriteRatio } from "./react/particles/spriteXForm.js";
22
+ export { cameraVisibleWorldBounds, visibleInBounds, PARTICLE_CULL_PADDING } from "./react/particles/culling.js";
23
+ export { TileMapLayer2D } from "./react/tilemap/TileMapLayer2D.js";
13
24
  //# sourceMappingURL=react.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["GameView","createGameAssetStore","useGameAssets","stableGroupsKey","GameWorld2D","viewportTransform","Sprite","resolveSpriteFrameRect","GameSprite","spriteFrameNameForClip","SpriteBatch","computeSpriteRsxform","spriteAnchorWorld","spriteGroupCorrection","createGameAssetStoreCore","GamePointerInput"],"sourceRoot":"../../src","sources":["react.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,qBAAkB;AAC3C,SAASC,oBAAoB,QAAQ,mCAAgC;AACrE,SAASC,aAAa,EAAEC,eAAe,QAAQ,iCAA8B;AAE7E,SAASC,WAAW,EAAEC,iBAAiB,QAAQ,gCAA6B;AAC5E,SAASC,MAAM,EAAEC,sBAAsB,QAAQ,2BAAwB;AAEvE,SAASC,UAAU,EAAEC,sBAAsB,QAAQ,+BAA4B;AAM/E,SAASC,WAAW,QAAQ,gCAA6B;AAEzD,SACEC,oBAAoB,EACpBC,iBAAiB,EACjBC,qBAAqB,QAChB,oCAAiC;AAMxC,SAASC,wBAAwB,QAAQ,wCAAqC;AAS9E,SAASC,gBAAgB,QAAQ,6BAA0B","ignoreList":[]}
1
+ {"version":3,"names":["GameView","useGameSession","useGameSessionStatus","createGameLifecycleSource","GameLifecycleProvider","useGameLifecycleSource","createGameAssetStore","useGameAssets","stableGroupsKey","GameWorld2D","viewportTransform","cameraViewportTransform2D","layerParallaxTransform2D","GameLayer2D","defineGameCamera2D","Sprite","resolveSpriteFrameRect","GameSprite","spriteFrameNameForClip","SpriteBatch","computeSpriteRsxform","spriteAnchorWorld","spriteGroupCorrection","createGameAssetStoreCore","GamePointerInput","GameButtonPad","GameButton","ParticleView","useParticlePresentation","particleSpriteXform","assertUniformParticleSpriteRatio","cameraVisibleWorldBounds","visibleInBounds","PARTICLE_CULL_PADDING","TileMapLayer2D"],"sourceRoot":"../../src","sources":["react.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,qBAAkB;AAC3C,SAASC,cAAc,QAAQ,2BAAwB;AACvD,SAASC,oBAAoB,QAAQ,iCAA8B;AACnE,SAASC,yBAAyB,EAAEC,qBAAqB,EAAEC,sBAAsB,QAAQ,4BAAyB;AAElH,SAASC,oBAAoB,QAAQ,mCAAgC;AACrE,SAASC,aAAa,EAAEC,eAAe,QAAQ,iCAA8B;AAE7E,SAASC,WAAW,EAAEC,iBAAiB,EAAEC,yBAAyB,EAAEC,wBAAwB,QAAQ,gCAA6B;AACjI,SAASC,WAAW,QAAQ,iCAA8B;AAC1D,SAASC,kBAAkB,QAAQ,wCAAqC;AAExE,SAASC,MAAM,EAAEC,sBAAsB,QAAQ,2BAAwB;AAEvE,SAASC,UAAU,EAAEC,sBAAsB,QAAQ,+BAA4B;AAM/E,SAASC,WAAW,QAAQ,gCAA6B;AAEzD,SACEC,oBAAoB,EACpBC,iBAAiB,EACjBC,qBAAqB,QAChB,oCAAiC;AAMxC,SAASC,wBAAwB,QAAQ,wCAAqC;AAS9E,SAASC,gBAAgB,QAAQ,6BAA0B;AAE3D,SAASC,aAAa,EAAEC,UAAU,QAAQ,0BAAuB;AAGjE,SAASC,YAAY,QAAQ,mCAAgC;AAE7D,SAASC,uBAAuB,QAAQ,8CAA2C;AAEnF,SAASC,mBAAmB,EAAEC,gCAAgC,QAAQ,kCAA+B;AACrG,SAASC,wBAAwB,EAAEC,eAAe,EAAEC,qBAAqB,QAAQ,8BAA2B;AAC5G,SAASC,cAAc,QAAQ,mCAAgC","ignoreList":[]}
@@ -4,6 +4,23 @@
4
4
  * Define a synchronous functional scene while inferring its state, snapshot,
5
5
  * action, and transition types.
6
6
  *
7
+ * To get typed event emission in a standalone scene, pass the same
8
+ * `events` object that will be passed to `defineGame({ events })`:
9
+ *
10
+ * ```ts
11
+ * const events = defineGameEvents({ 'brick-hit': gameEvent<{ id: string }>() });
12
+ * const play = defineScene({
13
+ * actions: ['primary'],
14
+ * emits: ['brick-hit'],
15
+ * events,
16
+ * update: ({ events }) => {
17
+ * events.emit('brick-hit', { id: '1' }); // typed, wrong payload fails
18
+ * },
19
+ * // ...
20
+ * });
21
+ * const game = defineGame({ events, scenes: { play }, initialScene: 'play' });
22
+ * ```
23
+ *
7
24
  * @example
8
25
  * ```ts
9
26
  * const ready = defineScene({
@@ -1 +1 @@
1
- {"version":3,"names":["defineScene","definition","kind"],"sourceRoot":"../../../src","sources":["scene/defineScene.ts"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,WAAWA,CAMzBC,UAGuE,EACK;EAC5E,OAAO;IACLC,IAAI,EAAE,eAAe;IACrB,GAAGD;EACL,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["defineScene","definition","kind"],"sourceRoot":"../../../src","sources":["scene/defineScene.ts"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,WAAWA,CAQzBC,UAyBC,EACuG;EACxG,OAAO;IACLC,IAAI,EAAE,eAAe;IACrB,GAAGD;EACL,CAAC;AACH","ignoreList":[]}