@ankhorage/zora 21.0.23 → 21.1.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 (554) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +6 -2
  3. package/dist/features/authoring/allowedChildren.d.ts +5 -2
  4. package/dist/features/authoring/allowedChildren.d.ts.map +1 -1
  5. package/dist/features/authoring/allowedChildren.js +13 -2
  6. package/dist/features/authoring/allowedChildren.js.map +1 -1
  7. package/dist/features/authoring/componentMeta.d.ts.map +1 -1
  8. package/dist/features/authoring/componentMeta.js +21 -0
  9. package/dist/features/authoring/componentMeta.js.map +1 -1
  10. package/dist/features/authoring/constants.d.ts +3 -0
  11. package/dist/features/authoring/constants.d.ts.map +1 -1
  12. package/dist/features/authoring/constants.js +3 -0
  13. package/dist/features/authoring/constants.js.map +1 -1
  14. package/dist/features/card/cardMeta.d.ts +1 -1
  15. package/dist/features/card/cardMeta.d.ts.map +1 -1
  16. package/dist/features/card/cardMeta.js +7 -2
  17. package/dist/features/card/cardMeta.js.map +1 -1
  18. package/dist/features/chess/adapters/inbound/ChessBoard.d.ts +5 -0
  19. package/dist/features/chess/adapters/inbound/ChessBoard.d.ts.map +1 -0
  20. package/dist/features/chess/adapters/inbound/ChessBoard.js +119 -0
  21. package/dist/features/chess/adapters/inbound/ChessBoard.js.map +1 -0
  22. package/dist/features/chess/adapters/inbound/OpeningBook.d.ts +5 -0
  23. package/dist/features/chess/adapters/inbound/OpeningBook.d.ts.map +1 -0
  24. package/dist/features/chess/adapters/inbound/OpeningBook.js +94 -0
  25. package/dist/features/chess/adapters/inbound/OpeningBook.js.map +1 -0
  26. package/dist/features/chess/meta.d.ts +219 -0
  27. package/dist/features/chess/meta.d.ts.map +1 -0
  28. package/dist/features/chess/meta.js +165 -0
  29. package/dist/features/chess/meta.js.map +1 -0
  30. package/dist/features/chess/public.d.ts +12 -0
  31. package/dist/features/chess/public.d.ts.map +1 -0
  32. package/dist/features/chess/public.js +10 -0
  33. package/dist/features/chess/public.js.map +1 -0
  34. package/dist/features/chess/utils/chessSquares.d.ts +4 -0
  35. package/dist/features/chess/utils/chessSquares.d.ts.map +1 -0
  36. package/dist/features/chess/utils/chessSquares.js +3 -0
  37. package/dist/features/chess/utils/chessSquares.js.map +1 -0
  38. package/dist/features/chess/utils/createBoardSquares.d.ts +4 -0
  39. package/dist/features/chess/utils/createBoardSquares.d.ts.map +1 -0
  40. package/dist/features/chess/utils/createBoardSquares.js +9 -0
  41. package/dist/features/chess/utils/createBoardSquares.js.map +1 -0
  42. package/dist/features/chess/utils/createChessBoardColorScheme.d.ts +35 -0
  43. package/dist/features/chess/utils/createChessBoardColorScheme.d.ts.map +1 -0
  44. package/dist/features/chess/utils/createChessBoardColorScheme.js +26 -0
  45. package/dist/features/chess/utils/createChessBoardColorScheme.js.map +1 -0
  46. package/dist/features/chess/utils/createOpeningBookColorScheme.d.ts +11 -0
  47. package/dist/features/chess/utils/createOpeningBookColorScheme.d.ts.map +1 -0
  48. package/dist/features/chess/utils/createOpeningBookColorScheme.js +21 -0
  49. package/dist/features/chess/utils/createOpeningBookColorScheme.js.map +1 -0
  50. package/dist/features/chess/utils/getSquareFile.d.ts +4 -0
  51. package/dist/features/chess/utils/getSquareFile.d.ts.map +1 -0
  52. package/dist/features/chess/utils/getSquareFile.js +5 -0
  53. package/dist/features/chess/utils/getSquareFile.js.map +1 -0
  54. package/dist/features/chess/utils/getSquareRank.d.ts +4 -0
  55. package/dist/features/chess/utils/getSquareRank.d.ts.map +1 -0
  56. package/dist/features/chess/utils/getSquareRank.js +5 -0
  57. package/dist/features/chess/utils/getSquareRank.js.map +1 -0
  58. package/dist/features/chess/utils/isLightSquare.d.ts +4 -0
  59. package/dist/features/chess/utils/isLightSquare.d.ts.map +1 -0
  60. package/dist/features/chess/utils/isLightSquare.js +6 -0
  61. package/dist/features/chess/utils/isLightSquare.js.map +1 -0
  62. package/dist/features/game/adapters/inbound/Game.d.ts +5 -0
  63. package/dist/features/game/adapters/inbound/Game.d.ts.map +1 -0
  64. package/dist/features/game/adapters/inbound/Game.js +24 -0
  65. package/dist/features/game/adapters/inbound/Game.js.map +1 -0
  66. package/dist/features/game/adapters/inbound/GameEntity.d.ts +5 -0
  67. package/dist/features/game/adapters/inbound/GameEntity.d.ts.map +1 -0
  68. package/dist/features/game/adapters/inbound/GameEntity.js +29 -0
  69. package/dist/features/game/adapters/inbound/GameEntity.js.map +1 -0
  70. package/dist/features/game/adapters/inbound/GameField.d.ts +4 -0
  71. package/dist/features/game/adapters/inbound/GameField.d.ts.map +1 -0
  72. package/dist/features/game/adapters/inbound/GameField.js +32 -0
  73. package/dist/features/game/adapters/inbound/GameField.js.map +1 -0
  74. package/dist/features/game/adapters/inbound/GameInputZone.d.ts +4 -0
  75. package/dist/features/game/adapters/inbound/GameInputZone.d.ts.map +1 -0
  76. package/dist/features/game/adapters/inbound/GameInputZone.js +50 -0
  77. package/dist/features/game/adapters/inbound/GameInputZone.js.map +1 -0
  78. package/dist/features/game/adapters/inbound/GameMeasurementProbe.d.ts +4 -0
  79. package/dist/features/game/adapters/inbound/GameMeasurementProbe.d.ts.map +1 -0
  80. package/dist/features/game/adapters/inbound/GameMeasurementProbe.js +54 -0
  81. package/dist/features/game/adapters/inbound/GameMeasurementProbe.js.map +1 -0
  82. package/dist/features/game/adapters/inbound/GameOverlay.d.ts +4 -0
  83. package/dist/features/game/adapters/inbound/GameOverlay.d.ts.map +1 -0
  84. package/dist/features/game/adapters/inbound/GameOverlay.js +39 -0
  85. package/dist/features/game/adapters/inbound/GameOverlay.js.map +1 -0
  86. package/dist/features/game/adapters/inbound/createGameKeyboardEvent.d.ts +16 -0
  87. package/dist/features/game/adapters/inbound/createGameKeyboardEvent.d.ts.map +1 -0
  88. package/dist/features/game/adapters/inbound/createGameKeyboardEvent.js +16 -0
  89. package/dist/features/game/adapters/inbound/createGameKeyboardEvent.js.map +1 -0
  90. package/dist/features/game/adapters/inbound/createGameMeasurementEvent.d.ts +14 -0
  91. package/dist/features/game/adapters/inbound/createGameMeasurementEvent.d.ts.map +1 -0
  92. package/dist/features/game/adapters/inbound/createGameMeasurementEvent.js +25 -0
  93. package/dist/features/game/adapters/inbound/createGameMeasurementEvent.js.map +1 -0
  94. package/dist/features/game/adapters/inbound/createGamePointerEvent.d.ts +17 -0
  95. package/dist/features/game/adapters/inbound/createGamePointerEvent.d.ts.map +1 -0
  96. package/dist/features/game/adapters/inbound/createGamePointerEvent.js +20 -0
  97. package/dist/features/game/adapters/inbound/createGamePointerEvent.js.map +1 -0
  98. package/dist/features/game/adapters/inbound/measureGameEntity.d.ts +5 -0
  99. package/dist/features/game/adapters/inbound/measureGameEntity.d.ts.map +1 -0
  100. package/dist/features/game/adapters/inbound/measureGameEntity.js +22 -0
  101. package/dist/features/game/adapters/inbound/measureGameEntity.js.map +1 -0
  102. package/dist/features/game/adapters/inbound/useGameInputZoneResponder.d.ts +15 -0
  103. package/dist/features/game/adapters/inbound/useGameInputZoneResponder.d.ts.map +1 -0
  104. package/dist/features/game/adapters/inbound/useGameInputZoneResponder.js +67 -0
  105. package/dist/features/game/adapters/inbound/useGameInputZoneResponder.js.map +1 -0
  106. package/dist/features/game/composition/GameRuntimeContext.d.ts +5 -0
  107. package/dist/features/game/composition/GameRuntimeContext.d.ts.map +1 -0
  108. package/dist/features/game/composition/GameRuntimeContext.js +4 -0
  109. package/dist/features/game/composition/GameRuntimeContext.js.map +1 -0
  110. package/dist/features/game/composition/createGameBindingContext.d.ts +4 -0
  111. package/dist/features/game/composition/createGameBindingContext.d.ts.map +1 -0
  112. package/dist/features/game/composition/createGameBindingContext.js +10 -0
  113. package/dist/features/game/composition/createGameBindingContext.js.map +1 -0
  114. package/dist/features/game/composition/createGameMeasurementRegistry.d.ts +4 -0
  115. package/dist/features/game/composition/createGameMeasurementRegistry.d.ts.map +1 -0
  116. package/dist/features/game/composition/createGameMeasurementRegistry.js +15 -0
  117. package/dist/features/game/composition/createGameMeasurementRegistry.js.map +1 -0
  118. package/dist/features/game/composition/useGameRuntime.d.ts +5 -0
  119. package/dist/features/game/composition/useGameRuntime.d.ts.map +1 -0
  120. package/dist/features/game/composition/useGameRuntime.js +117 -0
  121. package/dist/features/game/composition/useGameRuntime.js.map +1 -0
  122. package/dist/features/game/composition/useGameScheduledEffects.d.ts +17 -0
  123. package/dist/features/game/composition/useGameScheduledEffects.d.ts.map +1 -0
  124. package/dist/features/game/composition/useGameScheduledEffects.js +40 -0
  125. package/dist/features/game/composition/useGameScheduledEffects.js.map +1 -0
  126. package/dist/features/game/meta/gameEntityMeta.d.ts +403 -0
  127. package/dist/features/game/meta/gameEntityMeta.d.ts.map +1 -0
  128. package/dist/features/game/meta/gameEntityMeta.js +224 -0
  129. package/dist/features/game/meta/gameEntityMeta.js.map +1 -0
  130. package/dist/features/game/meta/gameFieldMeta.d.ts +61 -0
  131. package/dist/features/game/meta/gameFieldMeta.d.ts.map +1 -0
  132. package/dist/features/game/meta/gameFieldMeta.js +48 -0
  133. package/dist/features/game/meta/gameFieldMeta.js.map +1 -0
  134. package/dist/features/game/meta/gameInputZoneMeta.d.ts +163 -0
  135. package/dist/features/game/meta/gameInputZoneMeta.d.ts.map +1 -0
  136. package/dist/features/game/meta/gameInputZoneMeta.js +138 -0
  137. package/dist/features/game/meta/gameInputZoneMeta.js.map +1 -0
  138. package/dist/features/game/meta/gameMeasurementProbeMeta.d.ts +112 -0
  139. package/dist/features/game/meta/gameMeasurementProbeMeta.d.ts.map +1 -0
  140. package/dist/features/game/meta/gameMeasurementProbeMeta.js +70 -0
  141. package/dist/features/game/meta/gameMeasurementProbeMeta.js.map +1 -0
  142. package/dist/features/game/meta/gameMeta.d.ts +130 -0
  143. package/dist/features/game/meta/gameMeta.d.ts.map +1 -0
  144. package/dist/features/game/meta/gameMeta.js +113 -0
  145. package/dist/features/game/meta/gameMeta.js.map +1 -0
  146. package/dist/features/game/meta/gameOverlayMeta.d.ts +55 -0
  147. package/dist/features/game/meta/gameOverlayMeta.d.ts.map +1 -0
  148. package/dist/features/game/meta/gameOverlayMeta.js +65 -0
  149. package/dist/features/game/meta/gameOverlayMeta.js.map +1 -0
  150. package/dist/features/game/public.d.ts +8 -0
  151. package/dist/features/game/public.d.ts.map +1 -0
  152. package/dist/features/game/public.js +7 -0
  153. package/dist/features/game/public.js.map +1 -0
  154. package/dist/features/game/utils/clampGamePercentage.d.ts +3 -0
  155. package/dist/features/game/utils/clampGamePercentage.d.ts.map +1 -0
  156. package/dist/features/game/utils/clampGamePercentage.js +5 -0
  157. package/dist/features/game/utils/clampGamePercentage.js.map +1 -0
  158. package/dist/features/game/utils/resolveGameEntityMotionPlan.d.ts +15 -0
  159. package/dist/features/game/utils/resolveGameEntityMotionPlan.d.ts.map +1 -0
  160. package/dist/features/game/utils/resolveGameEntityMotionPlan.js +31 -0
  161. package/dist/features/game/utils/resolveGameEntityMotionPlan.js.map +1 -0
  162. package/dist/features/game/utils/toGamePercentage.d.ts +3 -0
  163. package/dist/features/game/utils/toGamePercentage.d.ts.map +1 -0
  164. package/dist/features/game/utils/toGamePercentage.js +6 -0
  165. package/dist/features/game/utils/toGamePercentage.js.map +1 -0
  166. package/dist/features/game/utils/useAnimatedGameEntityValue.d.ts +5 -0
  167. package/dist/features/game/utils/useAnimatedGameEntityValue.d.ts.map +1 -0
  168. package/dist/features/game/utils/useAnimatedGameEntityValue.js +33 -0
  169. package/dist/features/game/utils/useAnimatedGameEntityValue.js.map +1 -0
  170. package/dist/features/game/utils/useGameEntityAnimatedStyle.d.ts +16 -0
  171. package/dist/features/game/utils/useGameEntityAnimatedStyle.d.ts.map +1 -0
  172. package/dist/features/game/utils/useGameEntityAnimatedStyle.js +52 -0
  173. package/dist/features/game/utils/useGameEntityAnimatedStyle.js.map +1 -0
  174. package/dist/features/game/utils/useGameEntityMeasurement.d.ts +5 -0
  175. package/dist/features/game/utils/useGameEntityMeasurement.d.ts.map +1 -0
  176. package/dist/features/game/utils/useGameEntityMeasurement.js +14 -0
  177. package/dist/features/game/utils/useGameEntityMeasurement.js.map +1 -0
  178. package/dist/features/game/utils/useGameEntityMotionProgress.d.ts +5 -0
  179. package/dist/features/game/utils/useGameEntityMotionProgress.d.ts.map +1 -0
  180. package/dist/features/game/utils/useGameEntityMotionProgress.js +87 -0
  181. package/dist/features/game/utils/useGameEntityMotionProgress.js.map +1 -0
  182. package/dist/features/game/utils/useGameReducedMotion.d.ts +3 -0
  183. package/dist/features/game/utils/useGameReducedMotion.d.ts.map +1 -0
  184. package/dist/features/game/utils/useGameReducedMotion.js +13 -0
  185. package/dist/features/game/utils/useGameReducedMotion.js.map +1 -0
  186. package/dist/features/layout/gridMeta.d.ts +1 -1
  187. package/dist/features/layout/gridMeta.d.ts.map +1 -1
  188. package/dist/features/layout/gridMeta.js +7 -2
  189. package/dist/features/layout/gridMeta.js.map +1 -1
  190. package/dist/features/layout/screenMeta.d.ts +1 -1
  191. package/dist/features/layout/viewMeta.d.ts +1 -1
  192. package/dist/features/layout/viewMeta.d.ts.map +1 -1
  193. package/dist/features/layout/viewMeta.js +6 -2
  194. package/dist/features/layout/viewMeta.js.map +1 -1
  195. package/dist/features/registry/ZORA_COMPONENT_REGISTRY.d.ts.map +1 -1
  196. package/dist/features/registry/ZORA_COMPONENT_REGISTRY.js +16 -0
  197. package/dist/features/registry/ZORA_COMPONENT_REGISTRY.js.map +1 -1
  198. package/dist/features/section/screenSectionMeta.d.ts +1 -1
  199. package/dist/features/tabletop/adapters/inbound/CardBack.d.ts +5 -0
  200. package/dist/features/tabletop/adapters/inbound/CardBack.d.ts.map +1 -0
  201. package/dist/features/tabletop/adapters/inbound/CardBack.js +47 -0
  202. package/dist/features/tabletop/adapters/inbound/CardBack.js.map +1 -0
  203. package/dist/features/tabletop/adapters/inbound/CardHand.d.ts +5 -0
  204. package/dist/features/tabletop/adapters/inbound/CardHand.d.ts.map +1 -0
  205. package/dist/features/tabletop/adapters/inbound/CardHand.js +28 -0
  206. package/dist/features/tabletop/adapters/inbound/CardHand.js.map +1 -0
  207. package/dist/features/tabletop/adapters/inbound/PlayingCard.d.ts +5 -0
  208. package/dist/features/tabletop/adapters/inbound/PlayingCard.d.ts.map +1 -0
  209. package/dist/features/tabletop/adapters/inbound/PlayingCard.js +64 -0
  210. package/dist/features/tabletop/adapters/inbound/PlayingCard.js.map +1 -0
  211. package/dist/features/tabletop/adapters/inbound/PokerTrainingTable.d.ts +5 -0
  212. package/dist/features/tabletop/adapters/inbound/PokerTrainingTable.d.ts.map +1 -0
  213. package/dist/features/tabletop/adapters/inbound/PokerTrainingTable.js +12 -0
  214. package/dist/features/tabletop/adapters/inbound/PokerTrainingTable.js.map +1 -0
  215. package/dist/features/tabletop/adapters/inbound/TabletopTable.d.ts +5 -0
  216. package/dist/features/tabletop/adapters/inbound/TabletopTable.d.ts.map +1 -0
  217. package/dist/features/tabletop/adapters/inbound/TabletopTable.js +206 -0
  218. package/dist/features/tabletop/adapters/inbound/TabletopTable.js.map +1 -0
  219. package/dist/features/tabletop/meta.d.ts +353 -0
  220. package/dist/features/tabletop/meta.d.ts.map +1 -0
  221. package/dist/features/tabletop/meta.js +252 -0
  222. package/dist/features/tabletop/meta.js.map +1 -0
  223. package/dist/features/tabletop/public.d.ts +10 -0
  224. package/dist/features/tabletop/public.d.ts.map +1 -0
  225. package/dist/features/tabletop/public.js +9 -0
  226. package/dist/features/tabletop/public.js.map +1 -0
  227. package/dist/features/tabletop/utils/createPokerTrainingTableState.d.ts +13 -0
  228. package/dist/features/tabletop/utils/createPokerTrainingTableState.d.ts.map +1 -0
  229. package/dist/features/tabletop/utils/createPokerTrainingTableState.js +112 -0
  230. package/dist/features/tabletop/utils/createPokerTrainingTableState.js.map +1 -0
  231. package/dist/features/tabletop/utils/createTabletopColorScheme.d.ts +36 -0
  232. package/dist/features/tabletop/utils/createTabletopColorScheme.d.ts.map +1 -0
  233. package/dist/features/tabletop/utils/createTabletopColorScheme.js +144 -0
  234. package/dist/features/tabletop/utils/createTabletopColorScheme.js.map +1 -0
  235. package/dist/features/tabletop/utils/createTabletopGameSeats.d.ts +13 -0
  236. package/dist/features/tabletop/utils/createTabletopGameSeats.d.ts.map +1 -0
  237. package/dist/features/tabletop/utils/createTabletopGameSeats.js +22 -0
  238. package/dist/features/tabletop/utils/createTabletopGameSeats.js.map +1 -0
  239. package/dist/features/tabletop/utils/getPlayingCardLabel.d.ts +4 -0
  240. package/dist/features/tabletop/utils/getPlayingCardLabel.d.ts.map +1 -0
  241. package/dist/features/tabletop/utils/getPlayingCardLabel.js +6 -0
  242. package/dist/features/tabletop/utils/getPlayingCardLabel.js.map +1 -0
  243. package/dist/features/tabletop/utils/getTabletopCardDimensions.d.ts +12 -0
  244. package/dist/features/tabletop/utils/getTabletopCardDimensions.d.ts.map +1 -0
  245. package/dist/features/tabletop/utils/getTabletopCardDimensions.js +35 -0
  246. package/dist/features/tabletop/utils/getTabletopCardDimensions.js.map +1 -0
  247. package/dist/features/tabletop/utils/getTabletopSeatPosition.d.ts +9 -0
  248. package/dist/features/tabletop/utils/getTabletopSeatPosition.d.ts.map +1 -0
  249. package/dist/features/tabletop/utils/getTabletopSeatPosition.js +88 -0
  250. package/dist/features/tabletop/utils/getTabletopSeatPosition.js.map +1 -0
  251. package/dist/index.d.ts +8 -0
  252. package/dist/index.d.ts.map +1 -1
  253. package/dist/index.js +4 -0
  254. package/dist/index.js.map +1 -1
  255. package/dist/types/chess.d.ts +83 -0
  256. package/dist/types/chess.d.ts.map +1 -0
  257. package/dist/types/chess.js +2 -0
  258. package/dist/types/chess.js.map +1 -0
  259. package/dist/types/gamePresentation.d.ts +94 -0
  260. package/dist/types/gamePresentation.d.ts.map +1 -0
  261. package/dist/types/gamePresentation.js +2 -0
  262. package/dist/types/gamePresentation.js.map +1 -0
  263. package/dist/types/gameRuntime.d.ts +29 -0
  264. package/dist/types/gameRuntime.d.ts.map +1 -0
  265. package/dist/types/gameRuntime.js +2 -0
  266. package/dist/types/gameRuntime.js.map +1 -0
  267. package/dist/types/tabletop.d.ts +129 -0
  268. package/dist/types/tabletop.d.ts.map +1 -0
  269. package/dist/types/tabletop.js +2 -0
  270. package/dist/types/tabletop.js.map +1 -0
  271. package/package.json +3 -1
  272. package/src/features/authoring/allowedChildren.ts +15 -2
  273. package/src/features/authoring/componentMeta.test.ts +93 -0
  274. package/src/features/authoring/componentMeta.ts +27 -0
  275. package/src/features/authoring/constants.ts +3 -0
  276. package/src/features/card/cardMeta.ts +12 -2
  277. package/src/features/chess/adapters/inbound/ChessBoard.tsx +169 -0
  278. package/src/features/chess/adapters/inbound/OpeningBook.tsx +131 -0
  279. package/src/features/chess/meta.ts +168 -0
  280. package/src/features/chess/public.test.tsx +165 -0
  281. package/src/features/chess/public.ts +27 -0
  282. package/src/features/chess/utils/chessSquares.ts +6 -0
  283. package/src/features/chess/utils/createBoardSquares.ts +13 -0
  284. package/src/features/chess/utils/createChessBoardColorScheme.ts +55 -0
  285. package/src/features/chess/utils/createOpeningBookColorScheme.ts +26 -0
  286. package/src/features/chess/utils/getSquareFile.ts +6 -0
  287. package/src/features/chess/utils/getSquareRank.ts +6 -0
  288. package/src/features/chess/utils/isLightSquare.ts +8 -0
  289. package/src/features/chessTabletopOwnership.test.ts +71 -0
  290. package/src/features/game/adapters/inbound/Game.tsx +43 -0
  291. package/src/features/game/adapters/inbound/GameEntity.tsx +44 -0
  292. package/src/features/game/adapters/inbound/GameField.tsx +52 -0
  293. package/src/features/game/adapters/inbound/GameInputZone.tsx +99 -0
  294. package/src/features/game/adapters/inbound/GameMeasurementProbe.tsx +83 -0
  295. package/src/features/game/adapters/inbound/GameOverlay.tsx +58 -0
  296. package/src/features/game/adapters/inbound/createGameKeyboardEvent.test.ts +51 -0
  297. package/src/features/game/adapters/inbound/createGameKeyboardEvent.ts +33 -0
  298. package/src/features/game/adapters/inbound/createGameMeasurementEvent.test.ts +56 -0
  299. package/src/features/game/adapters/inbound/createGameMeasurementEvent.ts +38 -0
  300. package/src/features/game/adapters/inbound/createGamePointerEvent.test.ts +56 -0
  301. package/src/features/game/adapters/inbound/createGamePointerEvent.ts +39 -0
  302. package/src/features/game/adapters/inbound/measureGameEntity.ts +28 -0
  303. package/src/features/game/adapters/inbound/useGameInputZoneResponder.ts +85 -0
  304. package/src/features/game/composition/GameRuntimeContext.ts +6 -0
  305. package/src/features/game/composition/createGameBindingContext.test.ts +66 -0
  306. package/src/features/game/composition/createGameBindingContext.ts +11 -0
  307. package/src/features/game/composition/createGameMeasurementRegistry.test.ts +35 -0
  308. package/src/features/game/composition/createGameMeasurementRegistry.ts +16 -0
  309. package/src/features/game/composition/useGameRuntime.test.tsx +173 -0
  310. package/src/features/game/composition/useGameRuntime.ts +200 -0
  311. package/src/features/game/composition/useGameScheduledEffects.ts +85 -0
  312. package/src/features/game/meta/gameEntityMeta.ts +226 -0
  313. package/src/features/game/meta/gameFieldMeta.ts +49 -0
  314. package/src/features/game/meta/gameInputZoneMeta.ts +140 -0
  315. package/src/features/game/meta/gameMeasurementProbeMeta.ts +72 -0
  316. package/src/features/game/meta/gameMeta.ts +115 -0
  317. package/src/features/game/meta/gameOverlayMeta.ts +66 -0
  318. package/src/features/game/public.test.tsx +64 -0
  319. package/src/features/game/public.ts +19 -0
  320. package/src/features/game/utils/clampGamePercentage.ts +4 -0
  321. package/src/features/game/utils/resolveGameEntityMotionPlan.test.ts +63 -0
  322. package/src/features/game/utils/resolveGameEntityMotionPlan.ts +53 -0
  323. package/src/features/game/utils/toGamePercentage.ts +6 -0
  324. package/src/features/game/utils/useAnimatedGameEntityValue.ts +41 -0
  325. package/src/features/game/utils/useGameEntityAnimatedStyle.ts +87 -0
  326. package/src/features/game/utils/useGameEntityMeasurement.ts +19 -0
  327. package/src/features/game/utils/useGameEntityMotionProgress.ts +114 -0
  328. package/src/features/game/utils/useGameReducedMotion.ts +15 -0
  329. package/src/features/layout/gridMeta.ts +12 -2
  330. package/src/features/layout/viewMeta.ts +10 -2
  331. package/src/features/registry/ZORA_COMPONENT_REGISTRY.ts +29 -0
  332. package/src/features/tabletop/adapters/inbound/CardBack.tsx +70 -0
  333. package/src/features/tabletop/adapters/inbound/CardHand.tsx +61 -0
  334. package/src/features/tabletop/adapters/inbound/PlayingCard.tsx +95 -0
  335. package/src/features/tabletop/adapters/inbound/PokerTrainingTable.tsx +34 -0
  336. package/src/features/tabletop/adapters/inbound/TabletopTable.tsx +264 -0
  337. package/src/features/tabletop/meta.ts +254 -0
  338. package/src/features/tabletop/public.test.tsx +127 -0
  339. package/src/features/tabletop/public.ts +32 -0
  340. package/src/features/tabletop/utils/createPokerTrainingTableState.ts +152 -0
  341. package/src/features/tabletop/utils/createTabletopColorScheme.ts +232 -0
  342. package/src/features/tabletop/utils/createTabletopGameSeats.ts +31 -0
  343. package/src/features/tabletop/utils/getPlayingCardLabel.ts +8 -0
  344. package/src/features/tabletop/utils/getTabletopCardDimensions.ts +45 -0
  345. package/src/features/tabletop/utils/getTabletopSeatPosition.ts +100 -0
  346. package/src/index.ts +83 -0
  347. package/src/types/chess.ts +95 -0
  348. package/src/types/gamePresentation.ts +103 -0
  349. package/src/types/gameRuntime.ts +34 -0
  350. package/src/types/tabletop.ts +131 -0
  351. package/web-dist/chunks/{Accordion-cscmtcn8.js → Accordion-0txegc16.js} +1 -1
  352. package/web-dist/chunks/{Accordion-06588rzn.js → Accordion-10xw59gm.js} +1 -1
  353. package/web-dist/chunks/{Accordion-8kgtg62g.js → Accordion-2zh15wt9.js} +6 -6
  354. package/web-dist/chunks/{Accordion-pkqj4g3r.js → Accordion-481bknsd.js} +5 -5
  355. package/web-dist/chunks/{Accordion-grfbz6f2.js → Accordion-4fkjn6r5.js} +1 -1
  356. package/web-dist/chunks/{Accordion-ftjkdjqs.js → Accordion-4gx45mn0.js} +3 -3
  357. package/web-dist/chunks/{Accordion-fjnck2tg.js → Accordion-4s69xvqy.js} +6 -6
  358. package/web-dist/chunks/{Accordion-jh7nxehr.js → Accordion-50jz5nhg.js} +1 -1
  359. package/web-dist/chunks/{Accordion-t6sdgmbz.js → Accordion-52xke54s.js} +1 -1
  360. package/web-dist/chunks/{Accordion-far6szrp.js → Accordion-6npzmbgk.js} +5 -5
  361. package/web-dist/chunks/{Accordion-q7c1ryf2.js → Accordion-6z4npcgf.js} +4 -4
  362. package/web-dist/chunks/{Accordion-gbba10rg.js → Accordion-8gw5tkfw.js} +6 -6
  363. package/web-dist/chunks/{Accordion-fmxygyb6.js → Accordion-8qteyww0.js} +4 -4
  364. package/web-dist/chunks/{Accordion-1pp37dtg.js → Accordion-9h5dx3ck.js} +4 -4
  365. package/web-dist/chunks/{Accordion-paha5aje.js → Accordion-9mmqf3wr.js} +2 -2
  366. package/web-dist/chunks/{Accordion-f5swy5bs.js → Accordion-b21zrnzj.js} +1 -1
  367. package/web-dist/chunks/{Accordion-ars389m1.js → Accordion-b8qd23hr.js} +3 -3
  368. package/web-dist/chunks/{Accordion-hxfa71g9.js → Accordion-c79y8g44.js} +7 -7
  369. package/web-dist/chunks/Accordion-ca2csh5r.js +321 -0
  370. package/web-dist/chunks/{Accordion-49gf1zb8.js → Accordion-cjht9dyv.js} +1 -1
  371. package/web-dist/chunks/{Accordion-sz21xsf4.js → Accordion-cq6hn45r.js} +1 -1
  372. package/web-dist/chunks/{Accordion-33rd76r7.js → Accordion-d90g9wcb.js} +8 -8
  373. package/web-dist/chunks/{Accordion-crx58d5n.js → Accordion-f5jb299b.js} +2 -2
  374. package/web-dist/chunks/{Accordion-h95wvyn5.js → Accordion-fe6vmbpf.js} +2 -2
  375. package/web-dist/chunks/{Accordion-jzbq36ec.js → Accordion-fqm027n3.js} +8 -8
  376. package/web-dist/chunks/{Accordion-0jkm3y3w.js → Accordion-gpccarct.js} +1 -1
  377. package/web-dist/chunks/{Accordion-v6ykq9hv.js → Accordion-h95h3xdb.js} +10 -10
  378. package/web-dist/chunks/{Accordion-t3p4ykg7.js → Accordion-j8ab9k8k.js} +8 -8
  379. package/web-dist/chunks/{Accordion-qpwhmqzd.js → Accordion-k5z591wx.js} +13 -13
  380. package/web-dist/chunks/{Accordion-rrpej6sv.js → Accordion-kdncjvc7.js} +7 -7
  381. package/web-dist/chunks/{Accordion-f05a7r28.js → Accordion-ks4a1c6w.js} +5 -5
  382. package/web-dist/chunks/{Accordion-x0j8b2by.js → Accordion-ma1sfe5z.js} +5 -5
  383. package/web-dist/chunks/{Accordion-2dws3778.js → Accordion-mhtyce1k.js} +4 -4
  384. package/web-dist/chunks/{Accordion-1vewf8aa.js → Accordion-n7gtb5ec.js} +2 -2
  385. package/web-dist/chunks/{Accordion-0psdn97s.js → Accordion-p42mm8rr.js} +1 -1
  386. package/web-dist/chunks/{Accordion-3404tth9.js → Accordion-panw5f0q.js} +7 -7
  387. package/web-dist/chunks/{Accordion-4a6wj3ez.js → Accordion-pxq8gfgg.js} +9 -9
  388. package/web-dist/chunks/{Accordion-xshn7k8f.js → Accordion-qwbshc4s.js} +4 -4
  389. package/web-dist/chunks/{Accordion-395r3wra.js → Accordion-r51wsmvy.js} +2 -2
  390. package/web-dist/chunks/Accordion-rt13cqr7.js +830 -0
  391. package/web-dist/chunks/{Accordion-hz4xaqjf.js → Accordion-s1f9hb5a.js} +9 -9
  392. package/web-dist/chunks/{Accordion-7ja4mtbz.js → Accordion-sv87mbqa.js} +1 -1
  393. package/web-dist/chunks/{Accordion-r4c9k9y7.js → Accordion-t4k9egq6.js} +2 -2
  394. package/web-dist/chunks/{Accordion-96cqeekv.js → Accordion-t64m1kca.js} +5 -5
  395. package/web-dist/chunks/Accordion-wg31jkvp.js +1559 -0
  396. package/web-dist/chunks/{Accordion-ch67q4t0.js → Accordion-y9zr4x2x.js} +4 -4
  397. package/web-dist/chunks/{Accordion-31aeqxak.js → Accordion-ye3k55r7.js} +3 -3
  398. package/web-dist/chunks/{Accordion-s42wwh6m.js → Accordion-z29agann.js} +6 -6
  399. package/web-dist/chunks/{Accordion-f1h2f05v.js → Accordion-ze26effy.js} +5 -5
  400. package/web-dist/chunks/{Accordion-tx78txec.js → Accordion-zqzcagxz.js} +5 -5
  401. package/web-dist/components/accordion/Accordion.js +12 -12
  402. package/web-dist/components/accordion-item/AccordionItem.js +12 -12
  403. package/web-dist/components/activity-indicator/ActivityIndicator.js +3 -3
  404. package/web-dist/components/app-bar/AppBar.js +19 -19
  405. package/web-dist/components/app-shell/AppShell.js +6 -6
  406. package/web-dist/components/avatar/Avatar.js +12 -12
  407. package/web-dist/components/avatar-group/AvatarGroup.js +12 -12
  408. package/web-dist/components/badge/Badge.js +7 -7
  409. package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +20 -20
  410. package/web-dist/components/bottom-sheet/BottomSheet.js +8 -8
  411. package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +8 -8
  412. package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +8 -8
  413. package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +8 -8
  414. package/web-dist/components/bottom-sheet-view/BottomSheetView.js +8 -8
  415. package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +8 -8
  416. package/web-dist/components/breadcrumbs/Breadcrumbs.js +15 -15
  417. package/web-dist/components/button/Button.js +12 -12
  418. package/web-dist/components/button-group/ButtonGroup.js +12 -12
  419. package/web-dist/components/camera-permission-view/CameraPermissionView.js +20 -20
  420. package/web-dist/components/card/Card.js +19 -19
  421. package/web-dist/components/card-back/CardBack.d.ts +7 -0
  422. package/web-dist/components/card-back/CardBack.js +19 -0
  423. package/web-dist/components/card-back/index.d.ts +1 -0
  424. package/web-dist/components/card-back/index.js +2 -0
  425. package/web-dist/components/card-hand/CardHand.d.ts +7 -0
  426. package/web-dist/components/card-hand/CardHand.js +19 -0
  427. package/web-dist/components/card-hand/index.d.ts +1 -0
  428. package/web-dist/components/card-hand/index.js +2 -0
  429. package/web-dist/components/chat-list-item/ChatListItem.js +16 -16
  430. package/web-dist/components/checkbox/Checkbox.js +12 -12
  431. package/web-dist/components/checkbox-group/CheckboxGroup.js +12 -12
  432. package/web-dist/components/chess-board/ChessBoard.d.ts +4 -0
  433. package/web-dist/components/chess-board/ChessBoard.js +13 -0
  434. package/web-dist/components/chess-board/index.d.ts +1 -0
  435. package/web-dist/components/chess-board/index.js +2 -0
  436. package/web-dist/components/chip/Chip.js +13 -13
  437. package/web-dist/components/chip-group/ChipGroup.js +13 -13
  438. package/web-dist/components/collection-editor/CollectionEditor.js +19 -19
  439. package/web-dist/components/content-rail/ContentRail.js +13 -13
  440. package/web-dist/components/data-table/DataTable.js +26 -26
  441. package/web-dist/components/date-picker/DatePicker.js +17 -17
  442. package/web-dist/components/dialog/Dialog.js +12 -12
  443. package/web-dist/components/divider/Divider.js +6 -6
  444. package/web-dist/components/empty-state/EmptyState.js +20 -20
  445. package/web-dist/components/field/Field.js +12 -12
  446. package/web-dist/components/flat-list/FlatList.js +13 -13
  447. package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +18 -18
  448. package/web-dist/components/form/Form.js +16 -16
  449. package/web-dist/components/form-actions/FormActions.js +16 -16
  450. package/web-dist/components/form-error/FormError.js +16 -16
  451. package/web-dist/components/game/Game.d.ts +8 -0
  452. package/web-dist/components/game/Game.js +25 -0
  453. package/web-dist/components/game/index.d.ts +1 -0
  454. package/web-dist/components/game/index.js +2 -0
  455. package/web-dist/components/game-entity/GameEntity.d.ts +8 -0
  456. package/web-dist/components/game-entity/GameEntity.js +25 -0
  457. package/web-dist/components/game-entity/index.d.ts +1 -0
  458. package/web-dist/components/game-entity/index.js +2 -0
  459. package/web-dist/components/game-field/GameField.d.ts +8 -0
  460. package/web-dist/components/game-field/GameField.js +25 -0
  461. package/web-dist/components/game-field/index.d.ts +1 -0
  462. package/web-dist/components/game-field/index.js +2 -0
  463. package/web-dist/components/game-input-zone/GameInputZone.d.ts +8 -0
  464. package/web-dist/components/game-input-zone/GameInputZone.js +25 -0
  465. package/web-dist/components/game-input-zone/index.d.ts +1 -0
  466. package/web-dist/components/game-input-zone/index.js +2 -0
  467. package/web-dist/components/game-measurement-probe/GameMeasurementProbe.d.ts +8 -0
  468. package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +25 -0
  469. package/web-dist/components/game-measurement-probe/index.d.ts +1 -0
  470. package/web-dist/components/game-measurement-probe/index.js +2 -0
  471. package/web-dist/components/game-overlay/GameOverlay.d.ts +8 -0
  472. package/web-dist/components/game-overlay/GameOverlay.js +25 -0
  473. package/web-dist/components/game-overlay/index.d.ts +1 -0
  474. package/web-dist/components/game-overlay/index.js +2 -0
  475. package/web-dist/components/gradient/Gradient.js +7 -7
  476. package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +7 -7
  477. package/web-dist/components/grid/Grid.js +6 -6
  478. package/web-dist/components/heading/Heading.js +6 -6
  479. package/web-dist/components/hero/Hero.js +19 -19
  480. package/web-dist/components/icon/Icon.js +4 -4
  481. package/web-dist/components/icon-button/IconButton.js +12 -12
  482. package/web-dist/components/image/Image.js +10 -10
  483. package/web-dist/components/keyboard-avoiding-view/KeyboardAvoidingView.js +2 -2
  484. package/web-dist/components/list/List.js +13 -13
  485. package/web-dist/components/list-item/ListItem.js +13 -13
  486. package/web-dist/components/list-section/ListSection.js +13 -13
  487. package/web-dist/components/media-card/MediaCard.js +19 -19
  488. package/web-dist/components/message-bubble/MessageBubble.js +16 -16
  489. package/web-dist/components/metric-card/MetricCard.js +19 -19
  490. package/web-dist/components/missing-element/MissingElement.js +11 -11
  491. package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +18 -18
  492. package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +18 -18
  493. package/web-dist/components/opening-book/OpeningBook.d.ts +4 -0
  494. package/web-dist/components/opening-book/OpeningBook.js +13 -0
  495. package/web-dist/components/opening-book/index.d.ts +1 -0
  496. package/web-dist/components/opening-book/index.js +2 -0
  497. package/web-dist/components/otp-form/OtpForm.js +18 -18
  498. package/web-dist/components/pagination/Pagination.js +13 -13
  499. package/web-dist/components/palette-item/PaletteItem.js +19 -19
  500. package/web-dist/components/playing-card/PlayingCard.d.ts +7 -0
  501. package/web-dist/components/playing-card/PlayingCard.js +19 -0
  502. package/web-dist/components/playing-card/index.d.ts +1 -0
  503. package/web-dist/components/playing-card/index.js +2 -0
  504. package/web-dist/components/poker-training-table/PokerTrainingTable.d.ts +7 -0
  505. package/web-dist/components/poker-training-table/PokerTrainingTable.js +19 -0
  506. package/web-dist/components/poker-training-table/index.d.ts +1 -0
  507. package/web-dist/components/poker-training-table/index.js +2 -0
  508. package/web-dist/components/popover-menu/PopoverMenu.js +14 -14
  509. package/web-dist/components/post-card/PostCard.js +19 -19
  510. package/web-dist/components/product-card/ProductCard.js +19 -19
  511. package/web-dist/components/progress/Progress.js +10 -10
  512. package/web-dist/components/progress-ring/ProgressRing.js +10 -10
  513. package/web-dist/components/radio/Radio.js +14 -14
  514. package/web-dist/components/radio-group/RadioGroup.js +14 -14
  515. package/web-dist/components/rating/Rating.js +9 -9
  516. package/web-dist/components/reader-surface/ReaderSurface.js +21 -21
  517. package/web-dist/components/scan-overlay/ScanOverlay.js +20 -20
  518. package/web-dist/components/screen/Screen.js +6 -6
  519. package/web-dist/components/screen-section/ScreenSection.js +10 -10
  520. package/web-dist/components/scroll-view/ScrollView.js +6 -6
  521. package/web-dist/components/search-input/SearchInput.js +13 -13
  522. package/web-dist/components/section-header/SectionHeader.js +10 -10
  523. package/web-dist/components/section-list/SectionList.js +13 -13
  524. package/web-dist/components/select/Select.js +16 -16
  525. package/web-dist/components/selectable-item/SelectableItem.js +5 -5
  526. package/web-dist/components/selection-provider/SelectionProvider.js +5 -5
  527. package/web-dist/components/sign-in-form/SignInForm.js +18 -18
  528. package/web-dist/components/sign-up-form/SignUpForm.js +18 -18
  529. package/web-dist/components/skeleton/Skeleton.js +22 -22
  530. package/web-dist/components/skeleton-card/SkeletonCard.js +22 -22
  531. package/web-dist/components/skeleton-list/SkeletonList.js +22 -22
  532. package/web-dist/components/skeleton-text/SkeletonText.js +22 -22
  533. package/web-dist/components/surface/Surface.js +7 -7
  534. package/web-dist/components/switch/Switch.js +7 -7
  535. package/web-dist/components/tab/Tab.js +7 -7
  536. package/web-dist/components/tab-list/TabList.js +7 -7
  537. package/web-dist/components/tab-panel/TabPanel.js +7 -7
  538. package/web-dist/components/tabletop-table/TabletopTable.d.ts +7 -0
  539. package/web-dist/components/tabletop-table/TabletopTable.js +19 -0
  540. package/web-dist/components/tabletop-table/index.d.ts +1 -0
  541. package/web-dist/components/tabletop-table/index.js +2 -0
  542. package/web-dist/components/tabs/Tabs.js +7 -7
  543. package/web-dist/components/text/Text.js +6 -6
  544. package/web-dist/components/text-input/TextInput.js +13 -13
  545. package/web-dist/components/time-picker/TimePicker.js +17 -17
  546. package/web-dist/components/timeline/Timeline.js +11 -11
  547. package/web-dist/components/toast/Toast.js +9 -9
  548. package/web-dist/components/toast-provider/ToastProvider.js +9 -9
  549. package/web-dist/components/toolbar/Toolbar.js +19 -19
  550. package/web-dist/components/tree-item/TreeItem.js +16 -16
  551. package/web-dist/components/uploader/Uploader.js +22 -22
  552. package/web-dist/components/view/View.js +6 -6
  553. package/web-dist/manifest.json +1650 -1379
  554. package/web-dist/runtime/ZoraProvider.js +8 -8
@@ -0,0 +1,25 @@
1
+ /*** Create one raw geometry event without deciding collision semantics. */
2
+ export function createGameMeasurementEvent(input) {
3
+ return {
4
+ type: input.eventType,
5
+ entityId: input.entityId ?? input.sourceId,
6
+ payload: {
7
+ sourceId: input.sourceId,
8
+ targetId: input.targetId,
9
+ source: toGameMeasurementRecord(input.source),
10
+ target: toGameMeasurementRecord(input.target),
11
+ },
12
+ };
13
+ }
14
+ /*** Convert measured geometry into a serializable Game record. */
15
+ function toGameMeasurementRecord(bounds) {
16
+ return {
17
+ left: bounds.left,
18
+ right: bounds.right,
19
+ top: bounds.top,
20
+ bottom: bounds.bottom,
21
+ width: bounds.width,
22
+ height: bounds.height,
23
+ };
24
+ }
25
+ //# sourceMappingURL=createGameMeasurementEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGameMeasurementEvent.js","sourceRoot":"","sources":["../../../../../src/features/game/adapters/inbound/createGameMeasurementEvent.ts"],"names":[],"mappings":"AAIA,2EAA2E;AAC3E,MAAM,UAAU,0BAA0B,CAAC,KAAsC;IAC/E,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,SAAS;QACrB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ;QAC1C,OAAO,EAAE;YACP,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,MAAM,EAAE,uBAAuB,CAAC,KAAK,CAAC,MAAM,CAAC;YAC7C,MAAM,EAAE,uBAAuB,CAAC,KAAK,CAAC,MAAM,CAAC;SAC9C;KACF,CAAC;AACJ,CAAC;AAWD,kEAAkE;AAClE,SAAS,uBAAuB,CAAC,MAA6B;IAC5D,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;AACJ,CAAC","sourcesContent":["import type { GameEvent, GameRecord } from '@ankhorage/game';\n\nimport type { GameMeasurementBounds } from '../../../../types/gameRuntime';\n\n/*** Create one raw geometry event without deciding collision semantics. */\nexport function createGameMeasurementEvent(input: CreateGameMeasurementEventInput): GameEvent {\n return {\n type: input.eventType,\n entityId: input.entityId ?? input.sourceId,\n payload: {\n sourceId: input.sourceId,\n targetId: input.targetId,\n source: toGameMeasurementRecord(input.source),\n target: toGameMeasurementRecord(input.target),\n },\n };\n}\n\ninterface CreateGameMeasurementEventInput {\n readonly eventType: string;\n readonly entityId?: string;\n readonly sourceId: string;\n readonly targetId: string;\n readonly source: GameMeasurementBounds;\n readonly target: GameMeasurementBounds;\n}\n\n/*** Convert measured geometry into a serializable Game record. */\nfunction toGameMeasurementRecord(bounds: GameMeasurementBounds): GameRecord {\n return {\n left: bounds.left,\n right: bounds.right,\n top: bounds.top,\n bottom: bounds.bottom,\n width: bounds.width,\n height: bounds.height,\n };\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { GameEvent } from '@ankhorage/game';
2
+ interface GamePointerEventInput {
3
+ readonly eventType: string;
4
+ readonly entityId?: string;
5
+ readonly localX: number;
6
+ readonly localY: number;
7
+ readonly measuredWidth: number;
8
+ readonly measuredHeight: number;
9
+ readonly zoneX: number;
10
+ readonly zoneY: number;
11
+ readonly zoneWidth: number;
12
+ readonly zoneHeight: number;
13
+ }
14
+ /*** Normalize one measured pointer/touch position into a field-relative generic Game event. */
15
+ export declare function createGamePointerEvent(input: GamePointerEventInput): GameEvent | undefined;
16
+ export {};
17
+ //# sourceMappingURL=createGamePointerEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGamePointerEvent.d.ts","sourceRoot":"","sources":["../../../../../src/features/game/adapters/inbound/createGamePointerEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIjD,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,+FAA+F;AAC/F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,GAAG,SAAS,CAoB1F"}
@@ -0,0 +1,20 @@
1
+ import { clampGamePercentage } from '../../utils/clampGamePercentage';
2
+ /*** Normalize one measured pointer/touch position into a field-relative generic Game event. */
3
+ export function createGamePointerEvent(input) {
4
+ if (!Number.isFinite(input.measuredWidth) ||
5
+ !Number.isFinite(input.measuredHeight) ||
6
+ input.measuredWidth <= 0 ||
7
+ input.measuredHeight <= 0) {
8
+ return undefined;
9
+ }
10
+ const localX = clampGamePercentage((input.localX / input.measuredWidth) * 100);
11
+ const localY = clampGamePercentage((input.localY / input.measuredHeight) * 100);
12
+ const x = clampGamePercentage(input.zoneX + (localX * input.zoneWidth) / 100);
13
+ const y = clampGamePercentage(input.zoneY + (localY * input.zoneHeight) / 100);
14
+ return {
15
+ type: input.eventType,
16
+ ...(input.entityId === undefined ? {} : { entityId: input.entityId }),
17
+ payload: { x, y },
18
+ };
19
+ }
20
+ //# sourceMappingURL=createGamePointerEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGamePointerEvent.js","sourceRoot":"","sources":["../../../../../src/features/game/adapters/inbound/createGamePointerEvent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAetE,+FAA+F;AAC/F,MAAM,UAAU,sBAAsB,CAAC,KAA4B;IACjE,IACE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC;QACrC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC;QACtC,KAAK,CAAC,aAAa,IAAI,CAAC;QACxB,KAAK,CAAC,cAAc,IAAI,CAAC,EACzB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAG,mBAAmB,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC,CAAC;IAC/E,MAAM,MAAM,GAAG,mBAAmB,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,GAAG,CAAC,CAAC;IAChF,MAAM,CAAC,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,CAAC;IAC9E,MAAM,CAAC,GAAG,mBAAmB,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC;IAE/E,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,SAAS;QACrB,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrE,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE;KAClB,CAAC;AACJ,CAAC","sourcesContent":["import type { GameEvent } from '@ankhorage/game';\n\nimport { clampGamePercentage } from '../../utils/clampGamePercentage';\n\ninterface GamePointerEventInput {\n readonly eventType: string;\n readonly entityId?: string;\n readonly localX: number;\n readonly localY: number;\n readonly measuredWidth: number;\n readonly measuredHeight: number;\n readonly zoneX: number;\n readonly zoneY: number;\n readonly zoneWidth: number;\n readonly zoneHeight: number;\n}\n\n/*** Normalize one measured pointer/touch position into a field-relative generic Game event. */\nexport function createGamePointerEvent(input: GamePointerEventInput): GameEvent | undefined {\n if (\n !Number.isFinite(input.measuredWidth) ||\n !Number.isFinite(input.measuredHeight) ||\n input.measuredWidth <= 0 ||\n input.measuredHeight <= 0\n ) {\n return undefined;\n }\n\n const localX = clampGamePercentage((input.localX / input.measuredWidth) * 100);\n const localY = clampGamePercentage((input.localY / input.measuredHeight) * 100);\n const x = clampGamePercentage(input.zoneX + (localX * input.zoneWidth) / 100);\n const y = clampGamePercentage(input.zoneY + (localY * input.zoneHeight) / 100);\n\n return {\n type: input.eventType,\n ...(input.entityId === undefined ? {} : { entityId: input.entityId }),\n payload: { x, y },\n };\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { View } from 'react-native';
2
+ import type { GameMeasurementBounds } from '../../../../types/gameRuntime';
3
+ /*** Measure one rendered React Native or React Native Web game entity in window coordinates. */
4
+ export declare function measureGameEntity(element: View | null): Promise<GameMeasurementBounds | undefined>;
5
+ //# sourceMappingURL=measureGameEntity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measureGameEntity.d.ts","sourceRoot":"","sources":["../../../../../src/features/game/adapters/inbound/measureGameEntity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAE3E,gGAAgG;AAChG,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,IAAI,GAAG,IAAI,GACnB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAoB5C"}
@@ -0,0 +1,22 @@
1
+ /*** Measure one rendered React Native or React Native Web game entity in window coordinates. */
2
+ export function measureGameEntity(element) {
3
+ if (element === null)
4
+ return Promise.resolve(undefined);
5
+ return new Promise((resolve) => {
6
+ element.measureInWindow((left, top, width, height) => {
7
+ if (![left, top, width, height].every(Number.isFinite) || width < 0 || height < 0) {
8
+ resolve(undefined);
9
+ return;
10
+ }
11
+ resolve({
12
+ left,
13
+ right: left + width,
14
+ top,
15
+ bottom: top + height,
16
+ width,
17
+ height,
18
+ });
19
+ });
20
+ });
21
+ }
22
+ //# sourceMappingURL=measureGameEntity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measureGameEntity.js","sourceRoot":"","sources":["../../../../../src/features/game/adapters/inbound/measureGameEntity.ts"],"names":[],"mappings":"AAIA,gGAAgG;AAChG,MAAM,UAAU,iBAAiB,CAC/B,OAAoB;IAEpB,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAExD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,OAAO,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YACnD,IAAI,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClF,OAAO,CAAC,SAAS,CAAC,CAAC;gBACnB,OAAO;YACT,CAAC;YAED,OAAO,CAAC;gBACN,IAAI;gBACJ,KAAK,EAAE,IAAI,GAAG,KAAK;gBACnB,GAAG;gBACH,MAAM,EAAE,GAAG,GAAG,MAAM;gBACpB,KAAK;gBACL,MAAM;aACP,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { View } from 'react-native';\n\nimport type { GameMeasurementBounds } from '../../../../types/gameRuntime';\n\n/*** Measure one rendered React Native or React Native Web game entity in window coordinates. */\nexport function measureGameEntity(\n element: View | null,\n): Promise<GameMeasurementBounds | undefined> {\n if (element === null) return Promise.resolve(undefined);\n\n return new Promise((resolve) => {\n element.measureInWindow((left, top, width, height) => {\n if (![left, top, width, height].every(Number.isFinite) || width < 0 || height < 0) {\n resolve(undefined);\n return;\n }\n\n resolve({\n left,\n right: left + width,\n top,\n bottom: top + height,\n width,\n height,\n });\n });\n });\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import type { GestureResponderEvent, LayoutChangeEvent } from 'react-native';
2
+ import type { GameInputZoneProps } from '../../../../types/gamePresentation';
3
+ interface GameKeyboardInputEvent {
4
+ readonly key: string;
5
+ preventDefault(): void;
6
+ }
7
+ /*** Own React Native responder measurement and event dispatch for one Game input zone. */
8
+ export declare function useGameInputZoneResponder(props: GameInputZoneProps): {
9
+ dispatchKeyboard: (event: GameKeyboardInputEvent) => void;
10
+ dispatchPointer: (event: GestureResponderEvent) => void;
11
+ handleLayout: (event: LayoutChangeEvent) => void;
12
+ shouldSetResponder: () => boolean;
13
+ };
14
+ export {};
15
+ //# sourceMappingURL=useGameInputZoneResponder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGameInputZoneResponder.d.ts","sourceRoot":"","sources":["../../../../../src/features/game/adapters/inbound/useGameInputZoneResponder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAK7E,UAAU,sBAAsB;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,cAAc,IAAI,IAAI,CAAC;CACxB;AAOD,0FAA0F;AAC1F,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,kBAAkB;8BAyCvD,sBAAsB;6BA9BtB,qBAAqB;0BANgB,iBAAiB;;EA4DjE"}
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import { GameRuntimeContext } from '../../composition/GameRuntimeContext';
3
+ import { createGameKeyboardEvent } from './createGameKeyboardEvent';
4
+ import { createGamePointerEvent } from './createGamePointerEvent';
5
+ /*** Own React Native responder measurement and event dispatch for one Game input zone. */
6
+ export function useGameInputZoneResponder(props) {
7
+ const runtime = React.useContext(GameRuntimeContext);
8
+ if (runtime === null)
9
+ throw new Error('GameInputZone must be rendered inside Game.');
10
+ const measuredSizeRef = React.useRef({ width: 0, height: 0 });
11
+ const handleLayout = React.useCallback((event) => {
12
+ const { width, height } = event.nativeEvent.layout;
13
+ measuredSizeRef.current = { width, height };
14
+ }, []);
15
+ const dispatchPointer = React.useCallback((event) => {
16
+ if (runtime.interactionPolicy === 'passive' || props.interactionPolicy === 'passive')
17
+ return;
18
+ const measured = measuredSizeRef.current;
19
+ const gameEvent = createGamePointerEvent({
20
+ eventType: props.eventType,
21
+ ...(props.entityId === undefined ? {} : { entityId: props.entityId }),
22
+ localX: event.nativeEvent.locationX,
23
+ localY: event.nativeEvent.locationY,
24
+ measuredWidth: measured.width,
25
+ measuredHeight: measured.height,
26
+ zoneX: props.x ?? 0,
27
+ zoneY: props.y ?? 0,
28
+ zoneWidth: props.width ?? 100,
29
+ zoneHeight: props.height ?? 100,
30
+ });
31
+ if (gameEvent !== undefined)
32
+ runtime.dispatch(gameEvent);
33
+ }, [
34
+ props.entityId,
35
+ props.eventType,
36
+ props.height,
37
+ props.interactionPolicy,
38
+ props.width,
39
+ props.x,
40
+ props.y,
41
+ runtime,
42
+ ]);
43
+ const dispatchKeyboard = React.useCallback((event) => {
44
+ if (runtime.interactionPolicy === 'passive' || props.interactionPolicy === 'passive')
45
+ return;
46
+ const result = createGameKeyboardEvent({
47
+ bindings: props.keyboardBindings ?? [],
48
+ fallbackEventType: props.eventType,
49
+ ...(props.entityId === undefined ? {} : { fallbackEntityId: props.entityId }),
50
+ key: event.key,
51
+ });
52
+ if (result === undefined)
53
+ return;
54
+ if (result.preventDefault)
55
+ event.preventDefault();
56
+ runtime.dispatch(result.event);
57
+ }, [props.entityId, props.eventType, props.interactionPolicy, props.keyboardBindings, runtime]);
58
+ return {
59
+ dispatchKeyboard,
60
+ dispatchPointer,
61
+ handleLayout,
62
+ shouldSetResponder: () => (props.enabled ?? true) &&
63
+ props.interactionPolicy !== 'passive' &&
64
+ runtime.interactionPolicy !== 'passive',
65
+ };
66
+ }
67
+ //# sourceMappingURL=useGameInputZoneResponder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGameInputZoneResponder.js","sourceRoot":"","sources":["../../../../../src/features/game/adapters/inbound/useGameInputZoneResponder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,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,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAC5F,CAAC;IAEF,OAAO;QACL,gBAAgB;QAChB,eAAe;QACf,YAAY;QACZ,kBAAkB,EAAE,GAAG,EAAE,CACvB,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC;YACvB,KAAK,CAAC,iBAAiB,KAAK,SAAS;YACrC,OAAO,CAAC,iBAAiB,KAAK,SAAS;KAC1C,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport type { GestureResponderEvent, LayoutChangeEvent } from 'react-native';\n\nimport type { GameInputZoneProps } from '../../../../types/gamePresentation';\nimport { GameRuntimeContext } from '../../composition/GameRuntimeContext';\nimport { createGameKeyboardEvent } from './createGameKeyboardEvent';\nimport { createGamePointerEvent } from './createGamePointerEvent';\n\ninterface GameKeyboardInputEvent {\n readonly key: string;\n preventDefault(): void;\n}\n\ninterface MeasuredSize {\n readonly width: number;\n readonly height: number;\n}\n\n/*** Own React Native responder measurement and event dispatch for one Game input zone. */\nexport function useGameInputZoneResponder(props: GameInputZoneProps) {\n const runtime = React.useContext(GameRuntimeContext);\n if (runtime === null) throw new Error('GameInputZone must be rendered inside Game.');\n\n const measuredSizeRef = React.useRef<MeasuredSize>({ width: 0, height: 0 });\n const handleLayout = React.useCallback((event: LayoutChangeEvent) => {\n const { width, height } = event.nativeEvent.layout;\n measuredSizeRef.current = { width, height };\n }, []);\n\n const dispatchPointer = React.useCallback(\n (event: GestureResponderEvent) => {\n if (runtime.interactionPolicy === 'passive' || props.interactionPolicy === 'passive') return;\n const measured = measuredSizeRef.current;\n const gameEvent = createGamePointerEvent({\n eventType: props.eventType,\n ...(props.entityId === undefined ? {} : { entityId: props.entityId }),\n localX: event.nativeEvent.locationX,\n localY: event.nativeEvent.locationY,\n measuredWidth: measured.width,\n measuredHeight: measured.height,\n zoneX: props.x ?? 0,\n zoneY: props.y ?? 0,\n zoneWidth: props.width ?? 100,\n zoneHeight: props.height ?? 100,\n });\n if (gameEvent !== undefined) runtime.dispatch(gameEvent);\n },\n [\n props.entityId,\n props.eventType,\n props.height,\n props.interactionPolicy,\n props.width,\n props.x,\n props.y,\n runtime,\n ],\n );\n\n const dispatchKeyboard = React.useCallback(\n (event: GameKeyboardInputEvent) => {\n if (runtime.interactionPolicy === 'passive' || props.interactionPolicy === 'passive') return;\n const result = createGameKeyboardEvent({\n bindings: props.keyboardBindings ?? [],\n fallbackEventType: props.eventType,\n ...(props.entityId === undefined ? {} : { fallbackEntityId: props.entityId }),\n key: event.key,\n });\n if (result === undefined) return;\n if (result.preventDefault) event.preventDefault();\n runtime.dispatch(result.event);\n },\n [props.entityId, props.eventType, props.interactionPolicy, props.keyboardBindings, runtime],\n );\n\n return {\n dispatchKeyboard,\n dispatchPointer,\n handleLayout,\n shouldSetResponder: () =>\n (props.enabled ?? true) &&\n props.interactionPolicy !== 'passive' &&\n runtime.interactionPolicy !== 'passive',\n };\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { GameRuntimeContextValue } from '../../../types/gameRuntime';
3
+ /*** Provide the local transient game session and event dispatcher to presentation adapters. */
4
+ export declare const GameRuntimeContext: React.Context<GameRuntimeContextValue | null>;
5
+ //# sourceMappingURL=GameRuntimeContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GameRuntimeContext.d.ts","sourceRoot":"","sources":["../../../../src/features/game/composition/GameRuntimeContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAE1E,+FAA+F;AAC/F,eAAO,MAAM,kBAAkB,+CAA4D,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ /*** Provide the local transient game session and event dispatcher to presentation adapters. */
3
+ export const GameRuntimeContext = React.createContext(null);
4
+ //# sourceMappingURL=GameRuntimeContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GameRuntimeContext.js","sourceRoot":"","sources":["../../../../src/features/game/composition/GameRuntimeContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,+FAA+F;AAC/F,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAAiC,IAAI,CAAC,CAAC","sourcesContent":["import React from 'react';\n\nimport type { GameRuntimeContextValue } from '../../../types/gameRuntime';\n\n/*** Provide the local transient game session and event dispatcher to presentation adapters. */\nexport const GameRuntimeContext = React.createContext<GameRuntimeContextValue | null>(null);\n"]}
@@ -0,0 +1,4 @@
1
+ import type { GameSession } from '@ankhorage/game';
2
+ /*** Create the canonical Runtime context namespace for one local game session. */
3
+ export declare function createGameBindingContext(session: GameSession): Record<string, unknown>;
4
+ //# sourceMappingURL=createGameBindingContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGameBindingContext.d.ts","sourceRoot":"","sources":["../../../../src/features/game/composition/createGameBindingContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,kFAAkF;AAClF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOtF"}
@@ -0,0 +1,10 @@
1
+ /*** Create the canonical Runtime context namespace for one local game session. */
2
+ export function createGameBindingContext(session) {
3
+ return {
4
+ game: {
5
+ entities: Object.values(session.entities),
6
+ session,
7
+ },
8
+ };
9
+ }
10
+ //# sourceMappingURL=createGameBindingContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGameBindingContext.js","sourceRoot":"","sources":["../../../../src/features/game/composition/createGameBindingContext.ts"],"names":[],"mappings":"AAEA,kFAAkF;AAClF,MAAM,UAAU,wBAAwB,CAAC,OAAoB;IAC3D,OAAO;QACL,IAAI,EAAE;YACJ,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;YACzC,OAAO;SACR;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { GameSession } from '@ankhorage/game';\n\n/*** Create the canonical Runtime context namespace for one local game session. */\nexport function createGameBindingContext(session: GameSession): Record<string, unknown> {\n return {\n game: {\n entities: Object.values(session.entities),\n session,\n },\n };\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { GameMeasurementRegistry } from '../../../types/gameRuntime';
2
+ /*** Create one isolated measurement registry for an embeddable Game instance. */
3
+ export declare function createGameMeasurementRegistry(): GameMeasurementRegistry;
4
+ //# sourceMappingURL=createGameMeasurementRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGameMeasurementRegistry.d.ts","sourceRoot":"","sources":["../../../../src/features/game/composition/createGameMeasurementRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAEjG,iFAAiF;AACjF,wBAAgB,6BAA6B,IAAI,uBAAuB,CAYvE"}
@@ -0,0 +1,15 @@
1
+ /*** Create one isolated measurement registry for an embeddable Game instance. */
2
+ export function createGameMeasurementRegistry() {
3
+ const readers = new Map();
4
+ return {
5
+ registerMeasurement: (id, reader) => {
6
+ readers.set(id, reader);
7
+ return () => {
8
+ if (readers.get(id) === reader)
9
+ readers.delete(id);
10
+ };
11
+ },
12
+ measure: (id) => readers.get(id)?.() ?? Promise.resolve(undefined),
13
+ };
14
+ }
15
+ //# sourceMappingURL=createGameMeasurementRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGameMeasurementRegistry.js","sourceRoot":"","sources":["../../../../src/features/game/composition/createGameMeasurementRegistry.ts"],"names":[],"mappings":"AAEA,iFAAiF;AACjF,MAAM,UAAU,6BAA6B;IAC3C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAiC,CAAC;IAEzD,OAAO;QACL,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE;YAClC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YACxB,OAAO,GAAG,EAAE;gBACV,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,MAAM;oBAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACrD,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;KACnE,CAAC;AACJ,CAAC","sourcesContent":["import type { GameMeasurementReader, GameMeasurementRegistry } from '../../../types/gameRuntime';\n\n/*** Create one isolated measurement registry for an embeddable Game instance. */\nexport function createGameMeasurementRegistry(): GameMeasurementRegistry {\n const readers = new Map<string, GameMeasurementReader>();\n\n return {\n registerMeasurement: (id, reader) => {\n readers.set(id, reader);\n return () => {\n if (readers.get(id) === reader) readers.delete(id);\n };\n },\n measure: (id) => readers.get(id)?.() ?? Promise.resolve(undefined),\n };\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { GameProps } from '../../../types/gamePresentation';
2
+ import type { GameRuntimeValue } from '../../../types/gameRuntime';
3
+ /*** Own one local transient Game session while delegating all domain transitions to @ankhorage/game. */
4
+ export declare function useGameRuntime(props: GameProps): GameRuntimeValue;
5
+ //# sourceMappingURL=useGameRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGameRuntime.d.ts","sourceRoot":"","sources":["../../../../src/features/game/composition/useGameRuntime.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAoB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAKrF,wGAAwG;AACxG,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,gBAAgB,CAsDjE"}
@@ -0,0 +1,117 @@
1
+ import { advanceGameTime, applyGameEvent, createGameSession, } from '@ankhorage/game';
2
+ import React from 'react';
3
+ import { useGameScheduledEffects } from './useGameScheduledEffects';
4
+ const EMPTY_GAME_INPUT = {};
5
+ /*** Own one local transient Game session while delegating all domain transitions to @ankhorage/game. */
6
+ export function useGameRuntime(props) {
7
+ const { definition, input = EMPTY_GAME_INPUT, seed = 0, resetKey = '' } = props;
8
+ const definitionRef = useLatestValue(definition);
9
+ const inputRef = useLatestValue(input);
10
+ const outputRef = useLatestValue(props.onOutput);
11
+ const autoAdvanceTime = props.autoAdvanceTime ?? true;
12
+ const clockRef = React.useRef(0);
13
+ const runtimeKey = createRuntimeKey(definition.id, resetKey, seed);
14
+ const [runtime, setRuntime] = React.useState(() => createRuntimeState(definition, input, seed, runtimeKey, 0));
15
+ useGameRuntimeReset({
16
+ clockRef,
17
+ definitionRef,
18
+ inputRef,
19
+ runtimeKey,
20
+ seed,
21
+ setRuntime,
22
+ });
23
+ useGameAutoAdvanceClock(autoAdvanceTime, clockRef);
24
+ useGameOutputEmitter(runtime, outputRef, setRuntime);
25
+ const dispatch = React.useCallback((event) => {
26
+ const now = Date.now();
27
+ setRuntime((current) => applyRuntimeEvent({
28
+ autoAdvanceTime,
29
+ current,
30
+ definition: definitionRef.current,
31
+ elapsedMs: Math.max(0, now - clockRef.current),
32
+ event,
33
+ input: inputRef.current,
34
+ runtimeKey,
35
+ seed,
36
+ }));
37
+ clockRef.current = now;
38
+ }, [autoAdvanceTime, definitionRef, inputRef, runtimeKey, seed]);
39
+ useGameScheduledEffects({
40
+ clockRef,
41
+ definitionRef,
42
+ enabled: autoAdvanceTime,
43
+ inputRef,
44
+ runtimeKey,
45
+ scheduled: runtime.session.scheduled,
46
+ setRuntime,
47
+ });
48
+ return React.useMemo(() => ({ session: runtime.session, dispatch }), [dispatch, runtime.session]);
49
+ }
50
+ /*** Reset the transient session only when its explicit serializable runtime identity changes. */
51
+ function useGameRuntimeReset({ clockRef, definitionRef, inputRef, runtimeKey, seed, setRuntime, }) {
52
+ React.useEffect(() => {
53
+ clockRef.current = Date.now();
54
+ setRuntime((current) => current.key === runtimeKey
55
+ ? current
56
+ : createRuntimeState(definitionRef.current, inputRef.current, seed, runtimeKey, current.revision + 1));
57
+ }, [clockRef, definitionRef, inputRef, runtimeKey, seed, setRuntime]);
58
+ }
59
+ /*** Rebase elapsed-time tracking when automatic game-time advancement resumes. */
60
+ function useGameAutoAdvanceClock(enabled, clockRef) {
61
+ const previousEnabledRef = React.useRef(enabled);
62
+ React.useEffect(() => {
63
+ if (enabled && !previousEnabledRef.current) {
64
+ clockRef.current = Date.now();
65
+ }
66
+ previousEnabledRef.current = enabled;
67
+ }, [clockRef, enabled]);
68
+ }
69
+ /*** Emit each committed runtime output once and clear the delivered queue. */
70
+ function useGameOutputEmitter(runtime, outputRef, setRuntime) {
71
+ React.useEffect(() => {
72
+ if (runtime.outputs.length === 0)
73
+ return;
74
+ setRuntime((current) => current.revision === runtime.revision ? { ...current, outputs: [] } : current);
75
+ emitGameOutputs(runtime.outputs, outputRef.current);
76
+ }, [outputRef, runtime.outputs, runtime.revision, setRuntime]);
77
+ }
78
+ /*** Apply elapsed time and one explicit game event against the matching local session. */
79
+ function applyRuntimeEvent(args) {
80
+ const base = args.current.key === args.runtimeKey
81
+ ? args.current
82
+ : createRuntimeState(args.definition, args.input, args.seed, args.runtimeKey, args.current.revision);
83
+ const timed = args.autoAdvanceTime
84
+ ? advanceGameTime(args.definition, base.session, args.elapsedMs, args.input)
85
+ : { session: base.session, outputs: [] };
86
+ const result = applyGameEvent(args.definition, timed.session, args.event, args.input);
87
+ return {
88
+ key: args.runtimeKey,
89
+ session: result.session,
90
+ outputs: [...base.outputs, ...timed.outputs, ...result.outputs],
91
+ revision: args.current.revision + 1,
92
+ };
93
+ }
94
+ /*** Create one transient runtime state through the published Game owner API. */
95
+ function createRuntimeState(definition, input, seed, key, revision) {
96
+ const result = createGameSession(definition, { input, seed });
97
+ return { key, session: result.session, outputs: result.outputs, revision };
98
+ }
99
+ /*** Create one runtime identity from serializable definition/session initialization inputs. */
100
+ function createRuntimeKey(definitionId, resetKey, seed) {
101
+ return `${definitionId}:${resetKey}:${seed}`;
102
+ }
103
+ /*** Emit runtime outputs through the ZORA event callback boundary. */
104
+ function emitGameOutputs(outputs, onOutput) {
105
+ if (onOutput === undefined)
106
+ return;
107
+ outputs.forEach((output) => onOutput(output));
108
+ }
109
+ /*** Keep a stable ref object updated with the latest adapter input. */
110
+ function useLatestValue(value) {
111
+ const ref = React.useRef(value);
112
+ React.useEffect(() => {
113
+ ref.current = value;
114
+ }, [value]);
115
+ return ref;
116
+ }
117
+ //# sourceMappingURL=useGameRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGameRuntime.js","sourceRoot":"","sources":["../../../../src/features/game/composition/useGameRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,GAGlB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,MAAM,gBAAgB,GAAc,EAAE,CAAC;AAEvC,wGAAwG;AACxG,MAAM,UAAU,cAAc,CAAC,KAAgB;IAC7C,MAAM,EAAE,UAAU,EAAE,KAAK,GAAG,gBAAgB,EAAE,IAAI,GAAG,CAAC,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC;IAChF,MAAM,aAAa,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,SAAS,GAAG,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,eAAe,GAAG,KAAK,CAAC,eAAe,IAAI,IAAI,CAAC;IACtD,MAAM,QAAQ,GAAG,KAAK,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AC,OAAO,GAAG,KAAK,CAAC;IACtB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import {\n advanceGameTime,\n applyGameEvent,\n createGameSession,\n type GameInput,\n type GameOutput,\n} from '@ankhorage/game';\nimport React from 'react';\n\nimport type { GameProps } from '../../../types/gamePresentation';\nimport type { GameRuntimeState, GameRuntimeValue } from '../../../types/gameRuntime';\nimport { useGameScheduledEffects } from './useGameScheduledEffects';\n\nconst EMPTY_GAME_INPUT: GameInput = {};\n\n/*** Own one local transient Game session while delegating all domain transitions to @ankhorage/game. */\nexport function useGameRuntime(props: GameProps): GameRuntimeValue {\n const { definition, input = EMPTY_GAME_INPUT, seed = 0, resetKey = '' } = props;\n const definitionRef = useLatestValue(definition);\n const inputRef = useLatestValue(input);\n const outputRef = useLatestValue(props.onOutput);\n const autoAdvanceTime = props.autoAdvanceTime ?? true;\n const clockRef = React.useRef(0);\n const runtimeKey = createRuntimeKey(definition.id, resetKey, seed);\n const [runtime, setRuntime] = React.useState<GameRuntimeState>(() =>\n createRuntimeState(definition, input, seed, runtimeKey, 0),\n );\n\n useGameRuntimeReset({\n clockRef,\n definitionRef,\n inputRef,\n runtimeKey,\n seed,\n setRuntime,\n });\n useGameAutoAdvanceClock(autoAdvanceTime, clockRef);\n useGameOutputEmitter(runtime, outputRef, setRuntime);\n\n const dispatch = React.useCallback<GameRuntimeValue['dispatch']>(\n (event) => {\n const now = Date.now();\n setRuntime((current) =>\n applyRuntimeEvent({\n autoAdvanceTime,\n current,\n definition: definitionRef.current,\n elapsedMs: Math.max(0, now - clockRef.current),\n event,\n input: inputRef.current,\n runtimeKey,\n seed,\n }),\n );\n clockRef.current = now;\n },\n [autoAdvanceTime, definitionRef, inputRef, runtimeKey, seed],\n );\n\n useGameScheduledEffects({\n clockRef,\n definitionRef,\n enabled: autoAdvanceTime,\n inputRef,\n runtimeKey,\n scheduled: runtime.session.scheduled,\n setRuntime,\n });\n\n return React.useMemo(() => ({ session: runtime.session, dispatch }), [dispatch, runtime.session]);\n}\n\ninterface GameRuntimeResetArgs {\n readonly clockRef: React.RefObject<number>;\n readonly definitionRef: React.RefObject<GameProps['definition']>;\n readonly inputRef: React.RefObject<GameInput>;\n readonly runtimeKey: string;\n readonly seed: number;\n readonly setRuntime: React.Dispatch<React.SetStateAction<GameRuntimeState>>;\n}\n\n/*** Reset the transient session only when its explicit serializable runtime identity changes. */\nfunction useGameRuntimeReset({\n clockRef,\n definitionRef,\n inputRef,\n runtimeKey,\n seed,\n setRuntime,\n}: GameRuntimeResetArgs): void {\n React.useEffect(() => {\n clockRef.current = Date.now();\n setRuntime((current) =>\n current.key === runtimeKey\n ? current\n : createRuntimeState(\n definitionRef.current,\n inputRef.current,\n seed,\n runtimeKey,\n current.revision + 1,\n ),\n );\n }, [clockRef, definitionRef, inputRef, runtimeKey, seed, setRuntime]);\n}\n\n/*** Rebase elapsed-time tracking when automatic game-time advancement resumes. */\nfunction useGameAutoAdvanceClock(enabled: boolean, clockRef: React.RefObject<number>): void {\n const previousEnabledRef = React.useRef(enabled);\n\n React.useEffect(() => {\n if (enabled && !previousEnabledRef.current) {\n clockRef.current = Date.now();\n }\n previousEnabledRef.current = enabled;\n }, [clockRef, enabled]);\n}\n\n/*** Emit each committed runtime output once and clear the delivered queue. */\nfunction useGameOutputEmitter(\n runtime: GameRuntimeState,\n outputRef: React.RefObject<GameProps['onOutput']>,\n setRuntime: React.Dispatch<React.SetStateAction<GameRuntimeState>>,\n): void {\n React.useEffect(() => {\n if (runtime.outputs.length === 0) return;\n\n setRuntime((current) =>\n current.revision === runtime.revision ? { ...current, outputs: [] } : current,\n );\n emitGameOutputs(runtime.outputs, outputRef.current);\n }, [outputRef, runtime.outputs, runtime.revision, setRuntime]);\n}\n\ninterface ApplyRuntimeEventArgs {\n readonly autoAdvanceTime: boolean;\n readonly current: GameRuntimeState;\n readonly definition: GameProps['definition'];\n readonly elapsedMs: number;\n readonly event: Parameters<typeof applyGameEvent>[2];\n readonly input: GameInput;\n readonly runtimeKey: string;\n readonly seed: number;\n}\n\n/*** Apply elapsed time and one explicit game event against the matching local session. */\nfunction applyRuntimeEvent(args: ApplyRuntimeEventArgs): GameRuntimeState {\n const base =\n args.current.key === args.runtimeKey\n ? args.current\n : createRuntimeState(\n args.definition,\n args.input,\n args.seed,\n args.runtimeKey,\n args.current.revision,\n );\n const timed = args.autoAdvanceTime\n ? advanceGameTime(args.definition, base.session, args.elapsedMs, args.input)\n : { session: base.session, outputs: [] };\n const result = applyGameEvent(args.definition, timed.session, args.event, args.input);\n return {\n key: args.runtimeKey,\n session: result.session,\n outputs: [...base.outputs, ...timed.outputs, ...result.outputs],\n revision: args.current.revision + 1,\n };\n}\n\n/*** Create one transient runtime state through the published Game owner API. */\nfunction createRuntimeState(\n definition: GameProps['definition'],\n input: GameInput,\n seed: number,\n key: string,\n revision: number,\n): GameRuntimeState {\n const result = createGameSession(definition, { input, seed });\n return { key, session: result.session, outputs: result.outputs, revision };\n}\n\n/*** Create one runtime identity from serializable definition/session initialization inputs. */\nfunction createRuntimeKey(definitionId: string, resetKey: string, seed: number): string {\n return `${definitionId}:${resetKey}:${seed}`;\n}\n\n/*** Emit runtime outputs through the ZORA event callback boundary. */\nfunction emitGameOutputs(outputs: readonly GameOutput[], onOutput: GameProps['onOutput']): void {\n if (onOutput === undefined) return;\n outputs.forEach((output) => onOutput(output));\n}\n\n/*** Keep a stable ref object updated with the latest adapter input. */\nfunction useLatestValue<TValue>(value: TValue): React.RefObject<TValue> {\n const ref = React.useRef(value);\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import { type GameDefinition, type GameInput } from '@ankhorage/game';
2
+ import React from 'react';
3
+ import type { GameRuntimeState } from '../../../types/gameRuntime';
4
+ type SetGameRuntime = React.Dispatch<React.SetStateAction<GameRuntimeState>>;
5
+ /*** Advance the nearest scheduled game effects through one platform timer. */
6
+ export declare function useGameScheduledEffects({ clockRef, definitionRef, enabled, inputRef, runtimeKey, scheduled, setRuntime, }: UseGameScheduledEffectsArgs): void;
7
+ interface UseGameScheduledEffectsArgs {
8
+ readonly clockRef: React.RefObject<number>;
9
+ readonly definitionRef: React.RefObject<GameDefinition>;
10
+ readonly enabled: boolean;
11
+ readonly inputRef: React.RefObject<GameInput>;
12
+ readonly runtimeKey: string;
13
+ readonly scheduled: GameRuntimeState['session']['scheduled'];
14
+ readonly setRuntime: SetGameRuntime;
15
+ }
16
+ export {};
17
+ //# sourceMappingURL=useGameScheduledEffects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGameScheduledEffects.d.ts","sourceRoot":"","sources":["../../../../src/features/game/composition/useGameScheduledEffects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,KAAK,cAAc,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAE7E,8EAA8E;AAC9E,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,aAAa,EACb,OAAO,EACP,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,GACX,EAAE,2BAA2B,GAAG,IAAI,CAsBpC;AAED,UAAU,2BAA2B;IACnC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACxD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC;IAC7D,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;CACrC"}
@@ -0,0 +1,40 @@
1
+ import { advanceGameTime } from '@ankhorage/game';
2
+ import React from 'react';
3
+ /*** Advance the nearest scheduled game effects through one platform timer. */
4
+ export function useGameScheduledEffects({ clockRef, definitionRef, enabled, inputRef, runtimeKey, scheduled, setRuntime, }) {
5
+ React.useEffect(() => {
6
+ if (!enabled || scheduled.length === 0)
7
+ return undefined;
8
+ const delayMs = resolveNextScheduledDelay(scheduled);
9
+ const timer = setTimeout(() => {
10
+ const now = Date.now();
11
+ const elapsedMs = Math.max(0, now - clockRef.current);
12
+ clockRef.current = now;
13
+ setRuntime((current) => advanceScheduledRuntime({
14
+ current,
15
+ definition: definitionRef.current,
16
+ elapsedMs,
17
+ input: inputRef.current,
18
+ runtimeKey,
19
+ }));
20
+ }, delayMs);
21
+ return () => clearTimeout(timer);
22
+ }, [clockRef, definitionRef, enabled, inputRef, runtimeKey, scheduled, setRuntime]);
23
+ }
24
+ /*** Advance one matching runtime state while preserving sessions that have already reset. */
25
+ function advanceScheduledRuntime({ current, definition, elapsedMs, input, runtimeKey, }) {
26
+ if (current.key !== runtimeKey)
27
+ return current;
28
+ const result = advanceGameTime(definition, current.session, elapsedMs, input);
29
+ return {
30
+ key: runtimeKey,
31
+ session: result.session,
32
+ outputs: [...current.outputs, ...result.outputs],
33
+ revision: current.revision + 1,
34
+ };
35
+ }
36
+ /*** Resolve the nearest scheduled game consequence without owning domain timing rules. */
37
+ function resolveNextScheduledDelay(scheduledEffects) {
38
+ return scheduledEffects.reduce((nearest, scheduled) => Math.min(nearest, scheduled.remainingMs), Number.POSITIVE_INFINITY);
39
+ }
40
+ //# sourceMappingURL=useGameScheduledEffects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGame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,SAAS,EACT,KAAK,EACL,UAAU,GACkB;IAC5B,IAAI,OAAO,CAAC,GAAG,KAAK,UAAU;QAAE,OAAO,OAAO,CAAC;IAC/C,MAAM,MAAM,GAAG,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAC9E,OAAO;QACL,GAAG,EAAE,UAAU;QACf,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;QAChD,QAAQ,EAAE,OAAO,CAAC,QAAQ,GAAG,CAAC;KAC/B,CAAC;AACJ,CAAC;AAED,0FAA0F;AAC1F,SAAS,yBAAyB,CAChC,gBAA0D;IAE1D,OAAO,gBAAgB,CAAC,MAAM,CAC5B,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,EAChE,MAAM,CAAC,iBAAiB,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import { advanceGameTime, type GameDefinition, type GameInput } from '@ankhorage/game';\nimport React from 'react';\n\nimport type { GameRuntimeState } from '../../../types/gameRuntime';\n\ntype SetGameRuntime = React.Dispatch<React.SetStateAction<GameRuntimeState>>;\n\n/*** Advance the nearest scheduled game effects through one platform timer. */\nexport function useGameScheduledEffects({\n clockRef,\n definitionRef,\n enabled,\n inputRef,\n runtimeKey,\n scheduled,\n setRuntime,\n}: UseGameScheduledEffectsArgs): void {\n React.useEffect(() => {\n if (!enabled || scheduled.length === 0) return undefined;\n const delayMs = resolveNextScheduledDelay(scheduled);\n\n const timer = setTimeout(() => {\n const now = Date.now();\n const elapsedMs = Math.max(0, now - clockRef.current);\n clockRef.current = now;\n setRuntime((current) =>\n advanceScheduledRuntime({\n current,\n definition: definitionRef.current,\n elapsedMs,\n input: inputRef.current,\n runtimeKey,\n }),\n );\n }, delayMs);\n\n return () => clearTimeout(timer);\n }, [clockRef, definitionRef, enabled, inputRef, runtimeKey, scheduled, setRuntime]);\n}\n\ninterface UseGameScheduledEffectsArgs {\n readonly clockRef: React.RefObject<number>;\n readonly definitionRef: React.RefObject<GameDefinition>;\n readonly enabled: boolean;\n readonly inputRef: React.RefObject<GameInput>;\n readonly runtimeKey: string;\n readonly scheduled: GameRuntimeState['session']['scheduled'];\n readonly setRuntime: SetGameRuntime;\n}\n\ninterface AdvanceScheduledRuntimeArgs {\n readonly current: GameRuntimeState;\n readonly definition: GameDefinition;\n readonly elapsedMs: number;\n readonly input: GameInput;\n readonly runtimeKey: string;\n}\n\n/*** Advance one matching runtime state while preserving sessions that have already reset. */\nfunction advanceScheduledRuntime({\n current,\n definition,\n elapsedMs,\n input,\n runtimeKey,\n}: AdvanceScheduledRuntimeArgs): GameRuntimeState {\n if (current.key !== runtimeKey) return current;\n const result = advanceGameTime(definition, current.session, elapsedMs, input);\n return {\n key: runtimeKey,\n session: result.session,\n outputs: [...current.outputs, ...result.outputs],\n revision: current.revision + 1,\n };\n}\n\n/*** Resolve the nearest scheduled game consequence without owning domain timing rules. */\nfunction resolveNextScheduledDelay(\n scheduledEffects: GameRuntimeState['session']['scheduled'],\n): number {\n return scheduledEffects.reduce(\n (nearest, scheduled) => Math.min(nearest, scheduled.remainingMs),\n Number.POSITIVE_INFINITY,\n );\n}\n"]}