rn-gamekit 0.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 (231) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +21 -0
  3. package/README.md +131 -0
  4. package/lib/module/assets/defineAssets.js +48 -0
  5. package/lib/module/assets/defineAssets.js.map +1 -0
  6. package/lib/module/assets/errors.js +38 -0
  7. package/lib/module/assets/errors.js.map +1 -0
  8. package/lib/module/assets/types.js +2 -0
  9. package/lib/module/assets/types.js.map +1 -0
  10. package/lib/module/assets/validation.js +99 -0
  11. package/lib/module/assets/validation.js.map +1 -0
  12. package/lib/module/core/frameDriver.js +20 -0
  13. package/lib/module/core/frameDriver.js.map +1 -0
  14. package/lib/module/core/input/createInputBuffer.js +296 -0
  15. package/lib/module/core/input/createInputBuffer.js.map +1 -0
  16. package/lib/module/core/input/types.js +4 -0
  17. package/lib/module/core/input/types.js.map +1 -0
  18. package/lib/module/core/session/createGameSession.js +554 -0
  19. package/lib/module/core/session/createGameSession.js.map +1 -0
  20. package/lib/module/core/session/deepFreeze.js +155 -0
  21. package/lib/module/core/session/deepFreeze.js.map +1 -0
  22. package/lib/module/core/session/diagnostics.js +2 -0
  23. package/lib/module/core/session/diagnostics.js.map +1 -0
  24. package/lib/module/core/session/types.js +43 -0
  25. package/lib/module/core/session/types.js.map +1 -0
  26. package/lib/module/definition/defineGame.js +57 -0
  27. package/lib/module/definition/defineGame.js.map +1 -0
  28. package/lib/module/definition/types.js +4 -0
  29. package/lib/module/definition/types.js.map +1 -0
  30. package/lib/module/geometry/types.js +2 -0
  31. package/lib/module/geometry/types.js.map +1 -0
  32. package/lib/module/index.js +12 -0
  33. package/lib/module/index.js.map +1 -0
  34. package/lib/module/package.json +1 -0
  35. package/lib/module/react/GamePointerInput.js +385 -0
  36. package/lib/module/react/GamePointerInput.js.map +1 -0
  37. package/lib/module/react/GameView.js +223 -0
  38. package/lib/module/react/GameView.js.map +1 -0
  39. package/lib/module/react/alphaClock.js +42 -0
  40. package/lib/module/react/alphaClock.js.map +1 -0
  41. package/lib/module/react/assets/createGameAssetStore.js +358 -0
  42. package/lib/module/react/assets/createGameAssetStore.js.map +1 -0
  43. package/lib/module/react/assets/decodeSkiaImage.js +54 -0
  44. package/lib/module/react/assets/decodeSkiaImage.js.map +1 -0
  45. package/lib/module/react/assets/errors.js +10 -0
  46. package/lib/module/react/assets/errors.js.map +1 -0
  47. package/lib/module/react/assets/useGameAssets.js +160 -0
  48. package/lib/module/react/assets/useGameAssets.js.map +1 -0
  49. package/lib/module/react/bindAppLifecycle.js +58 -0
  50. package/lib/module/react/bindAppLifecycle.js.map +1 -0
  51. package/lib/module/react/bindGameSession.js +37 -0
  52. package/lib/module/react/bindGameSession.js.map +1 -0
  53. package/lib/module/react/gestureLifecycle.js +68 -0
  54. package/lib/module/react/gestureLifecycle.js.map +1 -0
  55. package/lib/module/react/instrumentation.js +4 -0
  56. package/lib/module/react/instrumentation.js.map +1 -0
  57. package/lib/module/react/pointerBinding.js +196 -0
  58. package/lib/module/react/pointerBinding.js.map +1 -0
  59. package/lib/module/react/pointerCoalescer.js +224 -0
  60. package/lib/module/react/pointerCoalescer.js.map +1 -0
  61. package/lib/module/react/pointerContainment.js +27 -0
  62. package/lib/module/react/pointerContainment.js.map +1 -0
  63. package/lib/module/react/sprites/GameSprite.js +116 -0
  64. package/lib/module/react/sprites/GameSprite.js.map +1 -0
  65. package/lib/module/react/sprites/GameWorld2D.js +44 -0
  66. package/lib/module/react/sprites/GameWorld2D.js.map +1 -0
  67. package/lib/module/react/sprites/Sprite.js +147 -0
  68. package/lib/module/react/sprites/Sprite.js.map +1 -0
  69. package/lib/module/react/sprites/SpriteBatch.js +173 -0
  70. package/lib/module/react/sprites/SpriteBatch.js.map +1 -0
  71. package/lib/module/react/sprites/spriteBatchPolicy.js +25 -0
  72. package/lib/module/react/sprites/spriteBatchPolicy.js.map +1 -0
  73. package/lib/module/react/sprites/spriteTransform.js +135 -0
  74. package/lib/module/react/sprites/spriteTransform.js.map +1 -0
  75. package/lib/module/react/viewportBinding.js +101 -0
  76. package/lib/module/react/viewportBinding.js.map +1 -0
  77. package/lib/module/react.js +13 -0
  78. package/lib/module/react.js.map +1 -0
  79. package/lib/module/scene/defineScene.js +29 -0
  80. package/lib/module/scene/defineScene.js.map +1 -0
  81. package/lib/module/scene/types.js +4 -0
  82. package/lib/module/scene/types.js.map +1 -0
  83. package/lib/module/sprites/sampleSpriteClip.js +50 -0
  84. package/lib/module/sprites/sampleSpriteClip.js.map +1 -0
  85. package/lib/module/sprites/spriteAnimationState.js +165 -0
  86. package/lib/module/sprites/spriteAnimationState.js.map +1 -0
  87. package/lib/module/testing.js +57 -0
  88. package/lib/module/testing.js.map +1 -0
  89. package/lib/module/viewport2d/index.js +4 -0
  90. package/lib/module/viewport2d/index.js.map +1 -0
  91. package/lib/module/viewport2d/math.js +129 -0
  92. package/lib/module/viewport2d/math.js.map +1 -0
  93. package/lib/module/viewport2d/types.js +2 -0
  94. package/lib/module/viewport2d/types.js.map +1 -0
  95. package/lib/typescript/package.json +1 -0
  96. package/lib/typescript/src/assets/defineAssets.d.ts +20 -0
  97. package/lib/typescript/src/assets/defineAssets.d.ts.map +1 -0
  98. package/lib/typescript/src/assets/errors.d.ts +20 -0
  99. package/lib/typescript/src/assets/errors.d.ts.map +1 -0
  100. package/lib/typescript/src/assets/types.d.ts +138 -0
  101. package/lib/typescript/src/assets/types.d.ts.map +1 -0
  102. package/lib/typescript/src/assets/validation.d.ts +15 -0
  103. package/lib/typescript/src/assets/validation.d.ts.map +1 -0
  104. package/lib/typescript/src/core/frameDriver.d.ts +12 -0
  105. package/lib/typescript/src/core/frameDriver.d.ts.map +1 -0
  106. package/lib/typescript/src/core/input/createInputBuffer.d.ts +12 -0
  107. package/lib/typescript/src/core/input/createInputBuffer.d.ts.map +1 -0
  108. package/lib/typescript/src/core/input/types.d.ts +64 -0
  109. package/lib/typescript/src/core/input/types.d.ts.map +1 -0
  110. package/lib/typescript/src/core/session/createGameSession.d.ts +18 -0
  111. package/lib/typescript/src/core/session/createGameSession.d.ts.map +1 -0
  112. package/lib/typescript/src/core/session/deepFreeze.d.ts +27 -0
  113. package/lib/typescript/src/core/session/deepFreeze.d.ts.map +1 -0
  114. package/lib/typescript/src/core/session/diagnostics.d.ts +36 -0
  115. package/lib/typescript/src/core/session/diagnostics.d.ts.map +1 -0
  116. package/lib/typescript/src/core/session/types.d.ts +104 -0
  117. package/lib/typescript/src/core/session/types.d.ts.map +1 -0
  118. package/lib/typescript/src/definition/defineGame.d.ts +66 -0
  119. package/lib/typescript/src/definition/defineGame.d.ts.map +1 -0
  120. package/lib/typescript/src/definition/types.d.ts +56 -0
  121. package/lib/typescript/src/definition/types.d.ts.map +1 -0
  122. package/lib/typescript/src/geometry/types.d.ts +8 -0
  123. package/lib/typescript/src/geometry/types.d.ts.map +1 -0
  124. package/lib/typescript/src/index.d.ts +18 -0
  125. package/lib/typescript/src/index.d.ts.map +1 -0
  126. package/lib/typescript/src/react/GamePointerInput.d.ts +37 -0
  127. package/lib/typescript/src/react/GamePointerInput.d.ts.map +1 -0
  128. package/lib/typescript/src/react/GameView.d.ts +61 -0
  129. package/lib/typescript/src/react/GameView.d.ts.map +1 -0
  130. package/lib/typescript/src/react/alphaClock.d.ts +29 -0
  131. package/lib/typescript/src/react/alphaClock.d.ts.map +1 -0
  132. package/lib/typescript/src/react/assets/createGameAssetStore.d.ts +33 -0
  133. package/lib/typescript/src/react/assets/createGameAssetStore.d.ts.map +1 -0
  134. package/lib/typescript/src/react/assets/decodeSkiaImage.d.ts +12 -0
  135. package/lib/typescript/src/react/assets/decodeSkiaImage.d.ts.map +1 -0
  136. package/lib/typescript/src/react/assets/errors.d.ts +8 -0
  137. package/lib/typescript/src/react/assets/errors.d.ts.map +1 -0
  138. package/lib/typescript/src/react/assets/useGameAssets.d.ts +35 -0
  139. package/lib/typescript/src/react/assets/useGameAssets.d.ts.map +1 -0
  140. package/lib/typescript/src/react/bindAppLifecycle.d.ts +32 -0
  141. package/lib/typescript/src/react/bindAppLifecycle.d.ts.map +1 -0
  142. package/lib/typescript/src/react/bindGameSession.d.ts +14 -0
  143. package/lib/typescript/src/react/bindGameSession.d.ts.map +1 -0
  144. package/lib/typescript/src/react/gestureLifecycle.d.ts +37 -0
  145. package/lib/typescript/src/react/gestureLifecycle.d.ts.map +1 -0
  146. package/lib/typescript/src/react/instrumentation.d.ts +47 -0
  147. package/lib/typescript/src/react/instrumentation.d.ts.map +1 -0
  148. package/lib/typescript/src/react/pointerBinding.d.ts +104 -0
  149. package/lib/typescript/src/react/pointerBinding.d.ts.map +1 -0
  150. package/lib/typescript/src/react/pointerCoalescer.d.ts +106 -0
  151. package/lib/typescript/src/react/pointerCoalescer.d.ts.map +1 -0
  152. package/lib/typescript/src/react/pointerContainment.d.ts +12 -0
  153. package/lib/typescript/src/react/pointerContainment.d.ts.map +1 -0
  154. package/lib/typescript/src/react/sprites/GameSprite.d.ts +75 -0
  155. package/lib/typescript/src/react/sprites/GameSprite.d.ts.map +1 -0
  156. package/lib/typescript/src/react/sprites/GameWorld2D.d.ts +29 -0
  157. package/lib/typescript/src/react/sprites/GameWorld2D.d.ts.map +1 -0
  158. package/lib/typescript/src/react/sprites/Sprite.d.ts +43 -0
  159. package/lib/typescript/src/react/sprites/Sprite.d.ts.map +1 -0
  160. package/lib/typescript/src/react/sprites/SpriteBatch.d.ts +41 -0
  161. package/lib/typescript/src/react/sprites/SpriteBatch.d.ts.map +1 -0
  162. package/lib/typescript/src/react/sprites/spriteBatchPolicy.d.ts +10 -0
  163. package/lib/typescript/src/react/sprites/spriteBatchPolicy.d.ts.map +1 -0
  164. package/lib/typescript/src/react/sprites/spriteTransform.d.ts +86 -0
  165. package/lib/typescript/src/react/sprites/spriteTransform.d.ts.map +1 -0
  166. package/lib/typescript/src/react/viewportBinding.d.ts +42 -0
  167. package/lib/typescript/src/react/viewportBinding.d.ts.map +1 -0
  168. package/lib/typescript/src/react.d.ts +20 -0
  169. package/lib/typescript/src/react.d.ts.map +1 -0
  170. package/lib/typescript/src/scene/defineScene.d.ts +26 -0
  171. package/lib/typescript/src/scene/defineScene.d.ts.map +1 -0
  172. package/lib/typescript/src/scene/types.d.ts +71 -0
  173. package/lib/typescript/src/scene/types.d.ts.map +1 -0
  174. package/lib/typescript/src/sprites/sampleSpriteClip.d.ts +24 -0
  175. package/lib/typescript/src/sprites/sampleSpriteClip.d.ts.map +1 -0
  176. package/lib/typescript/src/sprites/spriteAnimationState.d.ts +45 -0
  177. package/lib/typescript/src/sprites/spriteAnimationState.d.ts.map +1 -0
  178. package/lib/typescript/src/testing.d.ts +28 -0
  179. package/lib/typescript/src/testing.d.ts.map +1 -0
  180. package/lib/typescript/src/viewport2d/index.d.ts +3 -0
  181. package/lib/typescript/src/viewport2d/index.d.ts.map +1 -0
  182. package/lib/typescript/src/viewport2d/math.d.ts +25 -0
  183. package/lib/typescript/src/viewport2d/math.d.ts.map +1 -0
  184. package/lib/typescript/src/viewport2d/types.d.ts +59 -0
  185. package/lib/typescript/src/viewport2d/types.d.ts.map +1 -0
  186. package/package.json +120 -0
  187. package/src/assets/defineAssets.ts +62 -0
  188. package/src/assets/errors.ts +64 -0
  189. package/src/assets/types.ts +164 -0
  190. package/src/assets/validation.ts +158 -0
  191. package/src/core/frameDriver.ts +31 -0
  192. package/src/core/input/createInputBuffer.ts +337 -0
  193. package/src/core/input/types.ts +67 -0
  194. package/src/core/session/createGameSession.ts +652 -0
  195. package/src/core/session/deepFreeze.ts +158 -0
  196. package/src/core/session/diagnostics.ts +35 -0
  197. package/src/core/session/types.ts +122 -0
  198. package/src/definition/defineGame.ts +94 -0
  199. package/src/definition/types.ts +67 -0
  200. package/src/geometry/types.ts +7 -0
  201. package/src/index.ts +84 -0
  202. package/src/react/GamePointerInput.tsx +478 -0
  203. package/src/react/GameView.tsx +317 -0
  204. package/src/react/alphaClock.ts +59 -0
  205. package/src/react/assets/createGameAssetStore.ts +459 -0
  206. package/src/react/assets/decodeSkiaImage.ts +64 -0
  207. package/src/react/assets/errors.ts +7 -0
  208. package/src/react/assets/useGameAssets.ts +171 -0
  209. package/src/react/bindAppLifecycle.ts +79 -0
  210. package/src/react/bindGameSession.ts +41 -0
  211. package/src/react/gestureLifecycle.ts +73 -0
  212. package/src/react/instrumentation.ts +54 -0
  213. package/src/react/pointerBinding.ts +226 -0
  214. package/src/react/pointerCoalescer.ts +234 -0
  215. package/src/react/pointerContainment.ts +23 -0
  216. package/src/react/sprites/GameSprite.tsx +192 -0
  217. package/src/react/sprites/GameWorld2D.tsx +46 -0
  218. package/src/react/sprites/Sprite.tsx +194 -0
  219. package/src/react/sprites/SpriteBatch.tsx +219 -0
  220. package/src/react/sprites/spriteBatchPolicy.ts +21 -0
  221. package/src/react/sprites/spriteTransform.ts +163 -0
  222. package/src/react/viewportBinding.ts +104 -0
  223. package/src/react.ts +37 -0
  224. package/src/scene/defineScene.ts +38 -0
  225. package/src/scene/types.ts +79 -0
  226. package/src/sprites/sampleSpriteClip.ts +51 -0
  227. package/src/sprites/spriteAnimationState.ts +176 -0
  228. package/src/testing.ts +61 -0
  229. package/src/viewport2d/index.ts +7 -0
  230. package/src/viewport2d/math.ts +134 -0
  231. package/src/viewport2d/types.ts +63 -0
@@ -0,0 +1,104 @@
1
+ import type { InputMap, SceneMap } from '../../definition/types.js';
2
+ import type { SceneSnapshot } from '../../scene/types.js';
3
+ import type { Viewport } from '../../viewport2d/types.js';
4
+ import type { InputController } from '../input/types.js';
5
+ /** Recursively readonly view of renderer snapshot data. */
6
+ export type DeepReadonly<T> = T extends (...arguments_: never[]) => unknown ? T : T extends readonly (infer TItem)[] ? readonly DeepReadonly<TItem>[] : T extends object ? {
7
+ readonly [TKey in keyof T]: DeepReadonly<T[TKey]>;
8
+ } : T;
9
+ /** Lifecycle states of a headless game session. */
10
+ export type GameSessionStatus = 'idle' | 'running' | 'paused' | 'disposed';
11
+ /** One renderer-neutral simulation commit produced by a game session. */
12
+ export interface CommitFrameBase<TSnapshot> {
13
+ /** Snapshot immediately before the latest simulation update. */
14
+ readonly previous: DeepReadonly<TSnapshot>;
15
+ /** Snapshot produced by the latest simulation update. */
16
+ readonly current: DeepReadonly<TSnapshot>;
17
+ /** Number of completed global simulation updates. */
18
+ readonly tick: number;
19
+ /** Deterministic elapsed global simulation time in seconds. */
20
+ readonly elapsedSeconds: number;
21
+ /** Monotonic commit counter; increments on every simulation commit. */
22
+ readonly revision: number;
23
+ /** True when this commit is a transition hard cut (previous === current). */
24
+ readonly hardCut: boolean;
25
+ /** Fixed simulation step duration in milliseconds (UI alpha clock input). */
26
+ readonly stepMs: number;
27
+ }
28
+ /**
29
+ * A simulation commit discriminated by its scene name.
30
+ *
31
+ * Narrowing on `frame.scene` narrows both `previous` and `current` to the
32
+ * snapshot type of that scene. A transition commits a hard cut where both
33
+ * snapshots come from the new scene; frames never interpolate between two
34
+ * scene types.
35
+ */
36
+ export type CommitFrame<TScenes extends SceneMap> = {
37
+ [TName in keyof TScenes]: CommitFrameBase<SceneSnapshot<TScenes[TName]>> & {
38
+ readonly scene: TName;
39
+ };
40
+ }[keyof TScenes];
41
+ /** A commit frame plus a presentation fraction computed on demand. */
42
+ export type GameRenderFrame<TScenes extends SceneMap> = CommitFrame<TScenes> & {
43
+ /** Live fixed-step fraction at call time; renderers use the UI clock. */
44
+ readonly alpha: number;
45
+ };
46
+ /** An idempotently removable render-frame subscription. */
47
+ export interface GameSubscription {
48
+ /** Stop future notifications. Safe to call repeatedly. */
49
+ remove(): void;
50
+ }
51
+ /** A closure-backed, headless running instance of one game definition. */
52
+ export interface GameSession<TScenes extends SceneMap = SceneMap, TInput extends InputMap = InputMap> {
53
+ /** Current lifecycle status. */
54
+ readonly status: GameSessionStatus;
55
+ /** The active scene name, updated by transitions and restarts. */
56
+ readonly scene: keyof TScenes;
57
+ /** The authored viewport configuration of this game. */
58
+ readonly viewport: Viewport;
59
+ /** Semantic input controller constrained to declared action names. */
60
+ readonly input: InputController<Extract<keyof TInput, string>>;
61
+ /** Start an idle session or resume a paused session. */
62
+ start(): void;
63
+ /** Pause simulation and discard suspended wall time. */
64
+ pause(): void;
65
+ /**
66
+ * Transition to a declared scene.
67
+ *
68
+ * While running, the transition commits at the next fixed-step boundary.
69
+ * While idle or paused, it commits synchronously and publishes the new
70
+ * frame. Setting the current scene is an idempotent no-op.
71
+ */
72
+ setScene(name: keyof TScenes): void;
73
+ /** Recreate the active scene with fresh state. */
74
+ restartScene(): void;
75
+ /** Permanently stop the session and release the active scene. */
76
+ dispose(): void;
77
+ /**
78
+ * Read the latest immutable simulation commit with a live presentation
79
+ * fraction.
80
+ *
81
+ * Freshness contract: `alpha` is computed on demand from the session's
82
+ * accumulated timing fraction at call time and is only meaningful for
83
+ * headless inspection. Rendering uses the UI-owned alpha clock; the
84
+ * envelope fields never change between commits.
85
+ */
86
+ getRenderFrame(): GameRenderFrame<TScenes>;
87
+ /** Observe simulation commits at commit frequency (never per display frame). */
88
+ addCommitListener(listener: (frame: CommitFrame<TScenes>) => void): GameSubscription;
89
+ }
90
+ /** Error thrown when live work is requested from a disposed session. */
91
+ export declare class GameSessionDisposedError extends Error {
92
+ readonly name = "GameSessionDisposedError";
93
+ constructor();
94
+ }
95
+ /**
96
+ * Error thrown for lifecycle violations: conflicting transition requests,
97
+ * transition controllers used outside their update, unknown runtime scene
98
+ * names, and pending transition conflicts.
99
+ */
100
+ export declare class GameSessionLifecycleError extends Error {
101
+ readonly name = "GameSessionLifecycleError";
102
+ constructor(message: string);
103
+ }
104
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/core/session/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,2BAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,E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AACxE,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,SAAkB,IAAI,8BAA8B;;CAKrD;AAED;;;;GAIG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,SAAkB,IAAI,+BAA+B;gBAEzC,OAAO,EAAE,MAAM;CAG5B"}
@@ -0,0 +1,66 @@
1
+ import type { AssetGroupMap } from '../assets/types.js';
2
+ import type { GameDefinition, InputMap, SceneMap } from './types.js';
3
+ type SceneActions<TScene> = TScene extends {
4
+ readonly __actionType?: infer TAction;
5
+ } ? Exclude<TAction, undefined> : never;
6
+ type SceneTransitions<TScene> = TScene extends {
7
+ readonly __transitionType?: infer TTransition;
8
+ } ? Exclude<TTransition, undefined> : never;
9
+ type UndeclaredSceneActions<TScenes extends SceneMap, TInput extends InputMap> = Exclude<SceneActions<TScenes[keyof TScenes]>, Extract<keyof TInput, string>>;
10
+ type UndeclaredSceneTransitions<TScenes extends SceneMap> = Exclude<SceneTransitions<TScenes[keyof TScenes]>, keyof TScenes>;
11
+ type ValidateSceneActions<TScenes extends SceneMap, TInput extends InputMap> = UndeclaredSceneActions<TScenes, TInput> extends never ? unknown : {
12
+ readonly __undeclaredSceneActions: UndeclaredSceneActions<TScenes, TInput>;
13
+ };
14
+ type ValidateSceneTransitions<TScenes extends SceneMap> = UndeclaredSceneTransitions<TScenes> extends never ? unknown : {
15
+ readonly __undeclaredSceneTransitions: UndeclaredSceneTransitions<TScenes>;
16
+ };
17
+ /**
18
+ * Declare a game.
19
+ *
20
+ * `defineGame` is the entry point of the provisional GameKit API. It
21
+ * validates the definition at the type level — scene names are inferred so
22
+ * `initialScene` must be one of the keys of `scenes`, every scene action must
23
+ * exist in the game input map, and every declared transition target must be a
24
+ * declared scene — and preserves and returns the supplied definition.
25
+ *
26
+ * This function creates no runtime state: it does not start a scheduler,
27
+ * allocate a session, load assets, or register input. Pass the definition to
28
+ * `createGameSession` to create a live instance. The shape is provisional
29
+ * until reference games validate it.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const game = defineGame({
34
+ * viewport: {
35
+ * logicalSize: { width: 390, height: 844 },
36
+ * mode: 'fit',
37
+ * },
38
+ * assets: [],
39
+ * input: { primary: { type: 'pointer' } },
40
+ * scenes: {
41
+ * ready: defineScene({
42
+ * actions: ['primary'],
43
+ * transitions: ['play'],
44
+ * create: () => ({ ready: true }),
45
+ * update: ({ state, input, transition }) => {
46
+ * if (input.pointer('primary').pressed) {
47
+ * transition.setScene('play');
48
+ * }
49
+ * return state;
50
+ * },
51
+ * snapshot: ({ state }) => state,
52
+ * }),
53
+ * play: defineScene({
54
+ * actions: [],
55
+ * create: () => ({ x: 0 }),
56
+ * update: ({ state }) => ({ x: state.x + 1 }),
57
+ * snapshot: ({ state }) => ({ x: state.x }),
58
+ * }),
59
+ * },
60
+ * initialScene: 'ready',
61
+ * });
62
+ * ```
63
+ */
64
+ export declare function defineGame<const TScenes extends SceneMap, const TInput extends InputMap = InputMap, const TInitialScene extends keyof TScenes = keyof TScenes, const TAssets extends AssetGroupMap = AssetGroupMap>(definition: GameDefinition<TScenes, TInput, TInitialScene, TAssets> & ValidateSceneActions<TScenes, TInput> & ValidateSceneTransitions<TScenes>): GameDefinition<TScenes, TInput, TInitialScene, TAssets>;
65
+ export {};
66
+ //# sourceMappingURL=defineGame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineGame.d.ts","sourceRoot":"","sources":["../../../../src/definition/defineGame.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAS,CAAC;AAElE,KAAK,YAAY,CAAC,MAAM,IAAI,MAAM,SAAS;IAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,OAAO,CAAA;CAAE,GAChF,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,GAC3B,KAAK,CAAC;AAEV,KAAK,gBAAgB,C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,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,GACjE,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC,GACrC,wBAAwB,CAAC,OAAO,CAAC,GAClC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,CAMzD"}
@@ -0,0 +1,56 @@
1
+ import type { AssetGroupMap, GameAssetManifest } from '../assets/types.js';
2
+ import type { Viewport } from '../viewport2d/types.js';
3
+ /** The button action supported by the runtime. */
4
+ export interface ButtonInputAction {
5
+ /** Discriminant for a digital button action. */
6
+ readonly type: 'button';
7
+ /** Optional human-readable description for diagnostics and tooling. */
8
+ readonly description?: string;
9
+ }
10
+ /** A single primary pointer action driven by touch or a mouse pointer. */
11
+ export interface PointerInputAction {
12
+ /** Discriminant for a pointer action. */
13
+ readonly type: 'pointer';
14
+ /** Optional human-readable description for diagnostics and tooling. */
15
+ readonly description?: string;
16
+ }
17
+ /** A named semantic input action. */
18
+ export type InputAction = ButtonInputAction | PointerInputAction;
19
+ /** The collection of semantic input actions declared by a game. */
20
+ export type InputMap = Readonly<Record<string, InputAction>>;
21
+ /**
22
+ * Structural marker shared by all definitions created with `defineScene`.
23
+ *
24
+ * It lets `defineGame` retain each scene's inferred state, snapshot, action,
25
+ * and transition types without erasing them into a universal world or
26
+ * renderer shape.
27
+ */
28
+ export interface SceneDefinitionMarker {
29
+ /** Internal scene-definition discriminator. */
30
+ readonly kind: 'gamekit.scene';
31
+ /** @internal Type witness for actions consumed by this scene. */
32
+ readonly __actionType?: string;
33
+ /** @internal Type witness for transition targets declared by this scene. */
34
+ readonly __transitionType?: string;
35
+ }
36
+ /** The collection of functional scenes declared by a game. */
37
+ export type SceneMap = Readonly<Record<string, SceneDefinitionMarker>>;
38
+ /**
39
+ * A complete static game definition produced by `defineGame`.
40
+ *
41
+ * Creating a definition allocates no runtime state. Pass it to
42
+ * `createGameSession` when a live headless session is required.
43
+ */
44
+ export interface GameDefinition<TScenes extends SceneMap = SceneMap, TInput extends InputMap = InputMap, TInitialScene extends keyof TScenes = keyof TScenes, TAssets extends AssetGroupMap = AssetGroupMap> {
45
+ /** The viewport configuration of the game. */
46
+ readonly viewport: Viewport;
47
+ /** Typed asset manifest; optional for shape-only games. */
48
+ readonly assets?: GameAssetManifest<TAssets>;
49
+ /** Semantic input actions declared by the game. */
50
+ readonly input: TInput;
51
+ /** Functional scenes keyed by stable scene name. */
52
+ readonly scenes: TScenes;
53
+ /** The scene created first when a session starts. */
54
+ readonly initialScene: TInitialScene;
55
+ }
56
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/definition/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAqB,CAAC;AAEpD,kDAAkD;AAClD,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,uEAAuE;IACvE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,0EAA0E;AAC1E,MAAM,WAAW,kBAAkB;IACjC,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,uEAAuE;IACvE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,qCAAqC;AACrC,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;AAEjE,mEAAmE;AACnE,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,iEAAiE;IACjE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,8DAA8D;AAC9D,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,WAAW,cAAc,CAC7B,OAAO,SAAS,QAAQ,GAAG,QAAQ,EACnC,MAAM,SAAS,QAAQ,GAAG,QAAQ,EAClC,aAAa,SAAS,MAAM,OAAO,GAAG,MAAM,OAAO,EACnD,OAAO,SAAS,aAAa,GAAG,aAAa;IAE7C,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC7C,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,qDAAqD;IACrD,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;CACtC"}
@@ -0,0 +1,8 @@
1
+ /** A plain 2D point in logical/world or surface coordinate space. */
2
+ export interface Point2D {
3
+ /** Horizontal coordinate. */
4
+ readonly x: number;
5
+ /** Vertical coordinate. */
6
+ readonly y: number;
7
+ }
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/geometry/types.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,MAAM,WAAW,OAAO;IACtB,6BAA6B;IAC7B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,18 @@
1
+ export { createGameSession } from './core/session/createGameSession.js';
2
+ export { GameSessionDisposedError, GameSessionLifecycleError } from './core/session/types.js';
3
+ export type { ButtonState, InputController, InputFrame, PointerState, } from './core/input/types.js';
4
+ export type { DeepReadonly, CommitFrame, GameRenderFrame, GameSession, GameSessionStatus, GameSubscription, } from './core/session/types.js';
5
+ export { advanceSpriteAnimation, pauseSpriteAnimation, playSpriteAnimation, resetSpriteAnimation, resumeSpriteAnimation, setSpriteAnimationSpeed, startSpriteAnimation, } from './sprites/spriteAnimationState.js';
6
+ export { sampleSpriteClipFrame, sampleSpriteClipFrameName, spriteClipDurationMs, } from './sprites/sampleSpriteClip.js';
7
+ export type { SpriteAnimationState, SpriteClipNames } from './sprites/spriteAnimationState.js';
8
+ export { defineAssets, image, spriteSheet } from './assets/defineAssets.js';
9
+ export { GameAssetError } from './assets/errors.js';
10
+ export type { AssetDescriptor, AssetGroup, AssetGroupMap, AssetSourceHandle, BrandedAssetDescriptor, GameAssetLease, GameAssetManifest, ImageDescriptor, LoadedAssets, LoadedImage, LoadedSpriteSheet, ManifestOf, SpriteAnimationMode, SpriteClip, SpriteFrameRect, SpriteSheetDescriptor, } from './assets/types.js';
11
+ export { defineGame } from './definition/defineGame.js';
12
+ export type { ButtonInputAction, GameDefinition, InputAction, InputMap, PointerInputAction, SceneDefinitionMarker, SceneMap, } from './definition/types.js';
13
+ export type { Point2D } from './geometry/types.js';
14
+ export { defineScene } from './scene/defineScene.js';
15
+ export type { SceneDefinition, SceneSnapshot, SceneSnapshotContext, SceneTransitionController, SceneUpdate, } from './scene/types.js';
16
+ export { containsSurfacePoint, resolveViewport2D, surfaceToWorld, worldToSurface, } from './viewport2d/index.js';
17
+ export type { LogicalSize, Rect, ResolvedViewport2D, SurfaceSize, Viewport, ViewportMode, } from './viewport2d/index.js';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,O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AClD,YAAY,EACV,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,yBAAyB,EACzB,WAAW,GACZ,MAAM,kBAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,cAAc,GACf,MAAM,uBAAc,CAAC;AACtB,YAAY,EACV,WAAW,EACX,IAAI,EACJ,kBAAkB,EAClB,WAAW,EACX,QAAQ,EACR,YAAY,GACb,MAAM,uBAAc,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { InputMap, PointerInputAction, SceneMap } from '../definition/types.js';
2
+ import type { GameSession } from '../core/session/types.js';
3
+ import type { GamePointerInstrumentation } from './instrumentation.js';
4
+ /** Declared pointer action names of an input map. */
5
+ type PointerActionName<TInput extends InputMap> = {
6
+ [TName in Extract<keyof TInput, string>]: TInput[TName] extends PointerInputAction ? TName : never;
7
+ }[Extract<keyof TInput, string>];
8
+ /** Props for the pointer input adapter that covers the game surface. */
9
+ export interface GamePointerInputProps<TScenes extends SceneMap, TInput extends InputMap> {
10
+ /** The session whose input buffer receives pointer events. */
11
+ readonly game: GameSession<TScenes, TInput>;
12
+ /** A declared pointer action on the game. */
13
+ readonly action: PointerActionName<TInput>;
14
+ /** Optional measurement callbacks for the Performance Lab (F1). */
15
+ readonly instrumentation?: GamePointerInstrumentation;
16
+ }
17
+ /**
18
+ * Bind one primary pointer to a declared pointer action.
19
+ *
20
+ * Gesture Handler is an implementation detail: the manual gesture activates
21
+ * explicitly on touch down, mirrors the letterbox containment check on the UI
22
+ * runtime (failing the gesture before activation), forwards plain touch data
23
+ * through a coalescer that crosses runtimes at most once per fixed step
24
+ * (latest dirty position only; edges never throttled or dropped), and ends
25
+ * explicitly when the last touch lifts. Ownership and edge sampling stay
26
+ * authoritative in the session input buffer, which re-validates every
27
+ * forwarded event on the JS side.
28
+ *
29
+ * All separately registered touch-handler worklets share one explicit
30
+ * coalescer SharedValue; closure-local mutation is not used because each
31
+ * handler can receive its own serialized closure copy. The binding is stable
32
+ * across ordinary React renders and is recreated only when its semantic
33
+ * session, action, or viewport owner changes.
34
+ */
35
+ export declare function GamePointerInput<TScenes extends SceneMap, TInput extends InputMap>({ game, action, instrumentation, }: GamePointerInputProps<TScenes, TInput>): import("react").JSX.Element;
36
+ export {};
37
+ //# sourceMappingURL=GamePointerInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GamePointerInput.d.ts","sourceRoot":"","sources":["../../../../src/react/GamePointerInput.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,wBAAqB,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAAuB,CAAC;AAUzD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAmB,CAAC;AAWpE,qDAAqD;AACrD,KAAK,iBAAiB,CAAC,MAAM,SAAS,QAAQ,IAAI;KAC/C,KAAK,IAAI,OAAO,CAAC,MAAM,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,kBAAkB,GAAG,KAAK,GAAG,KAAK;CACnG,CAAC,OAAO,CAAC,MAAM,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAQjC,wEAAwE;AACxE,MAAM,WAAW,qBAAqB,CAAC,OAAO,SAAS,QAAQ,EAAE,MAAM,SAAS,QAAQ;IACtF,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5C,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC3C,mEAAmE;IACnE,QAAQ,CAAC,eAAe,CAAC,EAAE,0BAA0B,CAAC;CACvD;AAwED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,QAAQ,EAAE,MAAM,SAAS,QAAQ,EAAE,EAClF,IAAI,EACJ,MAAM,EACN,eAAe,GAChB,EAAE,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,+BA2UxC"}
@@ -0,0 +1,61 @@
1
+ import { type ComponentType, type ReactNode } from 'react';
2
+ import { type StyleProp, type ViewStyle } from 'react-native';
3
+ import { type SharedValue } from 'react-native-reanimated';
4
+ import type { InputMap, SceneMap } from '../definition/types.js';
5
+ import type { AssetGroupMap, LoadedAssets } from '../assets/types.js';
6
+ import type { CommitFrame, GameSession } from '../core/session/types.js';
7
+ import type { ResolvedViewport2D } from '../viewport2d/index.js';
8
+ import type { GameViewInstrumentation } from './instrumentation.js';
9
+ import { type ViewportBinding } from './viewportBinding.js';
10
+ /** Stable imperative values supplied to a Skia renderer component. */
11
+ export interface GameRendererProps<TScenes extends SceneMap, TAssets extends AssetGroupMap = AssetGroupMap> {
12
+ /** Latest simulation commit, updated at commit frequency only. */
13
+ readonly frame: SharedValue<CommitFrame<TScenes>>;
14
+ /**
15
+ * UI-owned presentation fraction: advances on the UI runtime and resets
16
+ * to zero on every new commit. Never extrapolates past 1.
17
+ */
18
+ readonly alpha: SharedValue<number>;
19
+ /** Latest resolved viewport shared with the input adapter. */
20
+ readonly viewport: SharedValue<ResolvedViewport2D | undefined>;
21
+ /** The stable loaded asset lease (T7.5); shape-only renderers omit it. */
22
+ readonly assets?: LoadedAssets<TAssets>;
23
+ }
24
+ /** Props for the Skia-backed GameKit view. */
25
+ export interface GameViewProps<TScenes extends SceneMap, TInput extends InputMap, TAssets extends AssetGroupMap = AssetGroupMap> {
26
+ /** Externally owned headless game session. */
27
+ readonly game: GameSession<TScenes, TInput>;
28
+ /**
29
+ * Explicit presentation key (RF6): remounts the per-session presentation
30
+ * when the session changes. The fallback is a stable per-session identity
31
+ * allocated from a WeakMap (T8.6) — never object stringification, which
32
+ * maps every session to the same value.
33
+ */
34
+ readonly presentationKey?: string | number;
35
+ /** The stable loaded asset lease; shape-only games omit it. */
36
+ readonly assets?: LoadedAssets<TAssets>;
37
+ /** Stable Skia renderer component for the session's scene snapshots. */
38
+ readonly renderer: ComponentType<GameRendererProps<TScenes, TAssets>>;
39
+ /** Optional measurement callbacks for the Performance Lab (F1). */
40
+ readonly instrumentation?: GameViewInstrumentation;
41
+ /** Static React HUD and controls mounted above the canvas. */
42
+ readonly children?: ReactNode;
43
+ /** Optional style for the mounted surface. */
44
+ readonly style?: StyleProp<ViewStyle>;
45
+ }
46
+ /**
47
+ * Context supplying the resolved viewport to pointer input children.
48
+ *
49
+ * `GamePointerInput` consumes the binding for JS-side conversion and the
50
+ * shared value for the UI-side containment mirror, so drawing and hit
51
+ * testing always use the same resolved viewport instance for a layout
52
+ * revision.
53
+ */
54
+ export interface GameViewport {
55
+ readonly binding: ViewportBinding;
56
+ /** Resolved viewport shared value (layout-only updates). */
57
+ readonly viewport: SharedValue<ResolvedViewport2D | undefined>;
58
+ }
59
+ export declare const GameViewportContext: import("react").Context<GameViewport | null>;
60
+ export declare function GameView<TScenes extends SceneMap, TInput extends InputMap, TAssets extends AssetGroupMap = AssetGroupMap>({ game, presentationKey, assets, renderer: Renderer, children, style, instrumentation, }: GameViewProps<TScenes, TInput, TAssets>): import("react").JSX.Element;
61
+ //# sourceMappingURL=GameView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GameView.d.ts","sourceRoot":"","sources":["../../../../src/react/GameView.tsx"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAoC,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG7F,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,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;IAC9D,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;CAChE;AAED,eAAO,MAAM,mBAAmB,8CAA2C,CAAC;AAsJ5E,wBAAgB,QAAQ,CACtB,OAAO,SAAS,QAAQ,EACxB,MAAM,SAAS,QAAQ,EACvB,OAAO,SAAS,aAAa,GAAG,aAAa,EAC7C,EACA,IAAI,EACJ,eAAe,EACf,MAAM,EACN,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EACR,KAAK,EACL,eAAe,GAChB,EAAE,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,+BA2DzC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * UI-owned alpha clock (T5).
3
+ *
4
+ * Pure, worklet-safe presentation clock: `alpha` advances from UI frame
5
+ * deltas against the simulation step duration and resets to zero whenever a
6
+ * newer commit arrives. It never extrapolates past the current snapshot
7
+ * (clamped at 1, then held) and ignores stale or duplicate commits so a
8
+ * delayed write cannot reset presentation backward.
9
+ *
10
+ * The `epoch` guards session replacement: a new GameView binding carries a
11
+ * fresh epoch, so a replacement session whose revision restarts at zero is
12
+ * still accepted, while a delayed write from an old epoch is ignored.
13
+ */
14
+ export interface AlphaClockCommit {
15
+ /** Monotonic binding epoch; new epoch accepts any revision. */
16
+ readonly epoch: number;
17
+ /** Session commit revision; new revisions reset the clock. */
18
+ readonly revision: number;
19
+ /** Fixed simulation step duration in milliseconds. */
20
+ readonly stepMs: number;
21
+ }
22
+ export interface AlphaClockState {
23
+ readonly epoch: number;
24
+ readonly revision: number;
25
+ readonly alpha: number;
26
+ }
27
+ /** Advance the clock by one UI frame; returns the next alpha state. */
28
+ export declare function advanceAlpha(previous: AlphaClockState, commit: AlphaClockCommit, frameDeltaMs: number): AlphaClockState;
29
+ //# sourceMappingURL=alphaClock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alphaClock.d.ts","sourceRoot":"","sources":["../../../../src/react/alphaClock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,uEAAuE;AACvE,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,MAAM,GACnB,eAAe,CAwBjB"}
@@ -0,0 +1,33 @@
1
+ import type { AssetGroupMap, GameAssetLease } from '../../assets/types.js';
2
+ /** Opaque decoded-image handle (Skia's SkImage satisfies this structurally). */
3
+ export interface NativeImageHandle {
4
+ /** Decoded width in pixels. */
5
+ width(): number;
6
+ /** Decoded height in pixels. */
7
+ height(): number;
8
+ /** Release the native handle; exactly once per resource. */
9
+ dispose(): void;
10
+ }
11
+ /** Injected source resolution and decode pipelines. */
12
+ export interface AssetPipelines {
13
+ /** Resolve a static module handle to a canonical local URI. */
14
+ readonly resolve: (source: number) => Promise<string>;
15
+ /** Decode a canonical local URI into an image handle. */
16
+ readonly decode: (uri: string) => Promise<NativeImageHandle>;
17
+ }
18
+ /** Acquisition options for `acquire`. */
19
+ export interface AcquireOptions {
20
+ /** Logical groups to load; an empty set resolves immediately. */
21
+ readonly groups: readonly string[];
22
+ /** Detach the caller; late results are ignored, never resurrected. */
23
+ readonly signal?: AbortSignal;
24
+ /** Monotonic progress in [0, 1], one update per completed logical asset. */
25
+ readonly onProgress?: (progress: number) => void;
26
+ }
27
+ export declare function createGameAssetStoreCore<TManifest extends AssetGroupMap>(manifest: TManifest, pipelines: AssetPipelines): {
28
+ readonly acquire: (options: AcquireOptions) => Promise<GameAssetLease<TManifest>>;
29
+ readonly dispose: () => void;
30
+ readonly isDisposed: () => boolean;
31
+ };
32
+ export type GameAssetStore = ReturnType<typeof createGameAssetStoreCore>;
33
+ //# sourceMappingURL=createGameAssetStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createGameAssetStore.d.ts","sourceRoot":"","sources":["../../../../../src/react/assets/createGameAssetStore.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,aAAa,EAEb,cAAc,EAOf,MAAM,uBAAoB,CAAC;AAI5B,gFAAgF;AAChF,MAAM,WAAW,iBAAiB;IAChC,+BAA+B;IAC/B,KAAK,IAAI,MAAM,CAAC;IAChB,gCAAgC;IAChC,MAAM,IAAI,MAAM,CAAC;IACjB,4DAA4D;IAC5D,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACtD,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC9D;AAED,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAClD;AAmED,wBAAgB,wBAAwB,CAAC,SAAS,SAAS,aAAa,EACtE,QAAQ,EAAE,SAAS,EACnB,SAAS,EAAE,cAAc,GACxB;IACD,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;IAClF,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,OAAO,CAAC;CACpC,CA+TA;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { AssetGroupMap } from '../../assets/types.js';
2
+ /**
3
+ * Create the explicit asset-store owner for a manifest using the default
4
+ * Expo/Skia pipelines. Callers dispose the lease then the store in
5
+ * `finally`.
6
+ */
7
+ export declare function createGameAssetStore<TManifest extends AssetGroupMap>(manifest: TManifest): {
8
+ readonly acquire: (options: import("./createGameAssetStore.js").AcquireOptions) => Promise<import("../../index.js").GameAssetLease<TManifest>>;
9
+ readonly dispose: () => void;
10
+ readonly isDisposed: () => boolean;
11
+ };
12
+ //# sourceMappingURL=decodeSkiaImage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decodeSkiaImage.d.ts","sourceRoot":"","sources":["../../../../../src/react/assets/decodeSkiaImage.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAoB,CAAC;AAiCxD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,SAAS,aAAa,EAClE,QAAQ,EAAE,SAAS;;;;EAOpB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Asset store errors (T7.4).
3
+ *
4
+ * The store adds no error codes of its own: every failure is a structured
5
+ * `GameAssetError` with a stable code and field path.
6
+ */
7
+ export { GameAssetError } from '../../assets/errors.js';
8
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../src/react/assets/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAqB,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { GameAssetError } from '../../assets/errors.js';
2
+ import type { AssetGroupMap, GameAssetLease, LoadedAssets } from '../../assets/types.js';
3
+ import type { AcquireOptions } from './createGameAssetStore.js';
4
+ /** The store surface the hook needs, kept generic over the manifest. */
5
+ export interface HookStore<TManifest extends AssetGroupMap> {
6
+ readonly acquire: (options: AcquireOptions) => Promise<GameAssetLease<TManifest>>;
7
+ readonly dispose: () => void;
8
+ }
9
+ /** The discriminated loading state machine. Every state carries the
10
+ * normalized request key (RF7) so a rendered request that differs from the
11
+ * state's request can never expose a stale lease. */
12
+ export type GameAssetsState<TManifest extends AssetGroupMap> = {
13
+ readonly status: 'loading';
14
+ readonly progress: number;
15
+ readonly retry: () => void;
16
+ readonly requestKey: string;
17
+ } | {
18
+ readonly status: 'error';
19
+ readonly error: GameAssetError;
20
+ readonly retry: () => void;
21
+ readonly requestKey: string;
22
+ } | {
23
+ readonly status: 'ready';
24
+ readonly assets: LoadedAssets<TManifest>;
25
+ readonly requestKey: string;
26
+ };
27
+ /** Deduplicate and sort groups so equivalent reordered/duplicated arrays
28
+ * map to one key and one acquisition (R6). */
29
+ export declare function dedupeGroups(groups: readonly string[]): readonly string[];
30
+ /** Order-independent group key: equivalent arrays map to one key. */
31
+ export declare function stableGroupsKey(groups: readonly string[]): string;
32
+ export declare function useGameAssets<TManifest extends AssetGroupMap>(manifest: TManifest, options: {
33
+ readonly groups: readonly (Extract<keyof TManifest, string>)[];
34
+ }, storeFactory?: (manifest: TManifest) => HookStore<TManifest>): GameAssetsState<TManifest>;
35
+ //# sourceMappingURL=useGameAssets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGameAssets.d.ts","sourceRoot":"","sources":["../../../../../src/react/assets/useGameAssets.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAoB,CAAC;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAAwB,CAAC;AAE7D,wEAAwE;AACxE,MAAM,WAAW,SAAS,CAAC,SAAS,SAAS,aAAa;IACxD,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;IAClF,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAiBD;;qDAEqD;AACrD,MAAM,MAAM,eAAe,CAAC,SAAS,SAAS,aAAa,IACvD;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAClH;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACrH;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAExG;8CAC8C;AAC9C,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,CAEzE;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEjE;AAED,wBAAgB,aAAa,CAAC,SAAS,SAAS,aAAa,EAC3D,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,MAAM,SAAS,EAAE,MAAM,CAAC,CAAC,EAAE,CAAA;CAAE,EAC3E,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,SAAS,CAAC,SAAS,CAAC,GAC3D,eAAe,CAAC,SAAS,CAAC,CAoG5B"}
@@ -0,0 +1,32 @@
1
+ import type { GameSessionStatus } from '../core/session/types.js';
2
+ /** Minimal AppState-like source used to keep this seam platform-neutral. */
3
+ export interface AppLifecycleSource {
4
+ /** The current app state, read synchronously at bind time. */
5
+ readonly currentState: string | null | undefined;
6
+ addEventListener(state: 'change', listener: (next: string) => void): {
7
+ remove(): void;
8
+ };
9
+ }
10
+ /** Session operations the lifecycle binding may drive. */
11
+ export interface AppLifecycleSession {
12
+ /** Read the current session status. */
13
+ getStatus(): GameSessionStatus;
14
+ /** Pause simulation and discard suspended wall time. */
15
+ pause(): void;
16
+ /** Resume a paused session. */
17
+ resume(): void;
18
+ }
19
+ /**
20
+ * Pause a running session when the app becomes inactive or backgrounded and
21
+ * resume it on foreground only when this binding performed that pause.
22
+ *
23
+ * Platform-neutral: the React adapter supplies React Native's `AppState`.
24
+ * The initial `currentState` is synchronized at bind time, so an app that
25
+ * mounts while already backgrounded never leaves a session running
26
+ * invisibly. Manual pauses that precede backgrounding are never claimed, and
27
+ * a session that another actor resumed (or disposed) meanwhile is not
28
+ * resumed again. Cleanup clears the binding flag so a late foreground event
29
+ * cannot restart an unmounted game.
30
+ */
31
+ export declare function bindAppLifecycle(source: AppLifecycleSource, session: AppLifecycleSession): () => void;
32
+ //# sourceMappingURL=bindAppLifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindAppLifecycle.d.ts","sourceRoot":"","sources":["../../../../src/react/bindAppLifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAAuB,CAAC;AAE/D,4EAA4E;AAC5E,MAAM,WAAW,kBAAkB;IACjC,8DAA8D;IAC9D,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,gBAAgB,CACd,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAC/B;QAAE,MAAM,IAAI,IAAI,CAAA;KAAE,CAAC;CACvB;AAED,0DAA0D;AAC1D,MAAM,WAAW,mBAAmB;IAClC,uCAAuC;IACvC,SAAS,IAAI,iBAAiB,CAAC;IAC/B,wDAAwD;IACxD,KAAK,IAAI,IAAI,CAAC;IACd,+BAA+B;IAC/B,MAAM,IAAI,IAAI,CAAC;CAChB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,mBAAmB,GAC3B,MAAM,IAAI,CAyCZ"}
@@ -0,0 +1,14 @@
1
+ import type { InputMap, SceneMap } from '../definition/types.js';
2
+ import type { CommitFrame, GameSession } from '../core/session/types.js';
3
+ /**
4
+ * Bind a live session to an imperative presentation sink.
5
+ *
6
+ * This platform-neutral lifecycle seam keeps the React adapter testable
7
+ * without loading React Native or Skia in the headless test runner. The sink
8
+ * receives commit frames only (simulation frequency), never per-display
9
+ * frames, and a stale write can never replace a newer commit: revisions are
10
+ * strictly increasing per session, and the initial envelope is presented
11
+ * through the same guard.
12
+ */
13
+ export declare function bindGameSession<TScenes extends SceneMap, TInput extends InputMap>(game: GameSession<TScenes, TInput>, present: (frame: CommitFrame<TScenes>) => void): () => void;
14
+ //# sourceMappingURL=bindGameSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindGameSession.d.ts","sourceRoot":"","sources":["../../../../src/react/bindGameSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,0BAAuB,CAAC;AAEtE;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,SAAS,QAAQ,EAAE,MAAM,SAAS,QAAQ,EAC/E,IAAI,EAAE,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,EAClC,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,IAAI,GAC7C,MAAM,IAAI,CAwBZ"}