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,554 @@
1
+ "use strict";
2
+
3
+ import { createAnimationFrameDriver } from "../frameDriver.js";
4
+ import { createInputBuffer } from "../input/createInputBuffer.js";
5
+ import { GameSessionDisposedError, GameSessionLifecycleError } from "./types.js";
6
+ import { createDeepFreeze } from "./deepFreeze.js";
7
+ const DEFAULT_FIXED_STEP_MS = 1000 / 60;
8
+ const DEFAULT_MAX_CATCH_UP_STEPS = 5;
9
+ function now() {
10
+ return typeof performance !== 'undefined' ? performance.now() : 0;
11
+ }
12
+ function freezeObject(value) {
13
+ return typeof value === 'object' && value !== null ? Object.freeze(value) : value;
14
+ }
15
+ function describeIntent(intent) {
16
+ return intent.kind === 'restart' ? 'restartScene()' : `setScene("${intent.name}")`;
17
+ }
18
+ function sameIntent(a, b) {
19
+ if (a.kind === 'restart') {
20
+ return b.kind === 'restart';
21
+ }
22
+ return b.kind === 'setScene' && a.name === b.name;
23
+ }
24
+
25
+ /** Create a live session using the platform animation-frame driver. */
26
+ export function createGameSession(definition) {
27
+ return createGameSessionWithDriver(definition, {
28
+ frameDriver: createAnimationFrameDriver()
29
+ });
30
+ }
31
+
32
+ /** @internal Deterministic construction seam used by the headless test suite. */
33
+ export function createGameSessionWithDriver(definition, options) {
34
+ const fixedStepMs = options.fixedStepMs ?? DEFAULT_FIXED_STEP_MS;
35
+ const maxCatchUpSteps = options.maxCatchUpSteps ?? DEFAULT_MAX_CATCH_UP_STEPS;
36
+ const maxFrameDeltaMs = options.maxFrameDeltaMs ?? fixedStepMs * DEFAULT_MAX_CATCH_UP_STEPS;
37
+ // F4: keep diagnostics optional and guard every measurement — the disabled
38
+ // path must perform no timing reads, callbacks, or wrapper allocations.
39
+ const diagnostics = options.diagnostics;
40
+ const deepFreeze = createDeepFreeze();
41
+ if (!(fixedStepMs > 0) || !Number.isFinite(fixedStepMs)) {
42
+ throw new RangeError('fixedStepMs must be a finite positive number');
43
+ }
44
+ if (!Number.isInteger(maxCatchUpSteps) || maxCatchUpSteps < 1) {
45
+ throw new RangeError('maxCatchUpSteps must be a positive integer');
46
+ }
47
+ if (!(maxFrameDeltaMs > 0) || !Number.isFinite(maxFrameDeltaMs)) {
48
+ throw new RangeError('maxFrameDeltaMs must be a finite positive number');
49
+ }
50
+ const erasedSceneMap = {};
51
+ for (const [name, scene] of Object.entries(definition.scenes)) {
52
+ const erased = scene;
53
+ for (const action of erased.actions) {
54
+ if (!Object.hasOwn(definition.input, action)) {
55
+ throw new Error(`Scene "${name}" uses undeclared input action: ${action}`);
56
+ }
57
+ }
58
+ for (const target of erased.transitions ?? []) {
59
+ if (!Object.hasOwn(definition.scenes, target)) {
60
+ throw new Error(`Scene "${name}" declares an unknown transition target: ${target}`);
61
+ }
62
+ }
63
+ erasedSceneMap[name] = erased;
64
+ }
65
+
66
+ // Create the initial scene instance synchronously.
67
+ const initialSceneName = String(definition.initialScene);
68
+ const initialDefinition = erasedSceneMap[initialSceneName];
69
+ if (initialDefinition === undefined) {
70
+ throw new Error(`Unknown initial scene: ${initialSceneName}`);
71
+ }
72
+ const initialState = freezeObject(initialDefinition.create());
73
+ let initialSnapshot;
74
+ try {
75
+ initialSnapshot = deepFreeze(initialDefinition.snapshot({
76
+ state: initialState
77
+ }));
78
+ } catch (error) {
79
+ initialDefinition.dispose?.(initialState);
80
+ throw error;
81
+ }
82
+ let activeScene = {
83
+ name: initialSceneName,
84
+ definition: initialDefinition,
85
+ state: initialState,
86
+ sceneTick: 0
87
+ };
88
+ let sceneName = initialSceneName;
89
+ let currentSnapshot = initialSnapshot;
90
+ let previousSnapshot = initialSnapshot;
91
+ let status = 'idle';
92
+ let generation = 0;
93
+ let frameHandle;
94
+ let previousTimestampMs;
95
+ let accumulatorMs = 0;
96
+ let tick = 0;
97
+ let pendingTransition;
98
+ let hardCutPending = false;
99
+ let publishedThisCallback = false;
100
+ let updateInProgress = false;
101
+ let revision = 0;
102
+ let commitFrame = Object.freeze({
103
+ scene: sceneName,
104
+ previous: previousSnapshot,
105
+ current: currentSnapshot,
106
+ tick: 0,
107
+ elapsedSeconds: 0,
108
+ revision: 0,
109
+ hardCut: false,
110
+ stepMs: fixedStepMs
111
+ });
112
+ const listeners = new Set();
113
+ const assertLive = () => {
114
+ if (status === 'disposed') {
115
+ throw new GameSessionDisposedError();
116
+ }
117
+ };
118
+ const isDisposed = () => status === 'disposed';
119
+ const inputBuffer = createInputBuffer(definition.input, assertLive);
120
+
121
+ // Simulation commits are the only presentation updates (T5): a commit
122
+ // happens on the initial baseline, after every presentation callback that
123
+ // ran at least one fixed step (one commit per callback, carrying the final
124
+ // adjacent snapshot pair), and on every transition/restart. Zero-step
125
+ // callbacks allocate nothing beyond scheduling their successor.
126
+ const commit = () => {
127
+ const hardCut = hardCutPending;
128
+ hardCutPending = false;
129
+ publishedThisCallback = true;
130
+ const publishStart = diagnostics === undefined ? 0 : now();
131
+ const frame = Object.freeze({
132
+ scene: sceneName,
133
+ previous: previousSnapshot,
134
+ current: currentSnapshot,
135
+ tick,
136
+ elapsedSeconds: tick * fixedStepMs / 1000,
137
+ revision: ++revision,
138
+ hardCut,
139
+ stepMs: fixedStepMs
140
+ });
141
+ commitFrame = frame;
142
+ for (const listener of [...listeners]) {
143
+ listener(frame);
144
+ }
145
+ if (diagnostics !== undefined) {
146
+ diagnostics.onPublish(now() - publishStart);
147
+ diagnostics.onCommitNotification();
148
+ diagnostics.onListenerCount(listeners.size);
149
+ }
150
+ };
151
+ const pauseInternal = () => {
152
+ if (status !== 'running') {
153
+ return;
154
+ }
155
+ status = 'paused';
156
+ generation += 1;
157
+ if (frameHandle !== undefined) {
158
+ options.frameDriver.cancelFrame(frameHandle);
159
+ frameHandle = undefined;
160
+ }
161
+ previousTimestampMs = undefined;
162
+ accumulatorMs = 0;
163
+ inputBuffer.reset();
164
+ };
165
+ const commitOrPause = () => {
166
+ try {
167
+ commit();
168
+ } catch (error) {
169
+ pauseInternal();
170
+ throw error;
171
+ }
172
+ };
173
+
174
+ /**
175
+ * Transition to `targetName` following the deterministic ordering:
176
+ * prepare the target -> dispose the outgoing scene exactly once -> advance
177
+ * session time when the request came from a successful update -> install
178
+ * the new scene with scene-local time reset -> clear scene-local input edges
179
+ * and interpolation debt -> install hard-cut snapshots. An update-scoped
180
+ * transition may retain a physically active pointer when the target scene
181
+ * consumes the same action; external transitions still perform a full reset.
182
+ *
183
+ * On any preparation or disposal failure the old scene and its state are
184
+ * retained, session tick/time are left unchanged, and the original error is
185
+ * rethrown after cleaning up any partially created target.
186
+ */
187
+ const commitTransition = (intent, outgoingFinalState, advanceTimeTick, preserveActivePointers = false) => {
188
+ const targetName = intent.kind === 'restart' ? activeScene.name : intent.name;
189
+ const targetDefinition = erasedSceneMap[targetName];
190
+ if (targetDefinition === undefined) {
191
+ throw new GameSessionLifecycleError(`Unknown scene: ${targetName}`);
192
+ }
193
+ let targetState;
194
+ let targetCreated = false;
195
+ let targetSnapshot;
196
+ try {
197
+ targetState = freezeObject(targetDefinition.create());
198
+ targetCreated = true;
199
+ targetSnapshot = deepFreeze(targetDefinition.snapshot({
200
+ state: targetState
201
+ }));
202
+ } catch (error) {
203
+ if (targetCreated) {
204
+ try {
205
+ targetDefinition.dispose?.(targetState);
206
+ } catch {
207
+ // Cleanup failures during failure handling are best effort.
208
+ }
209
+ }
210
+ throw error;
211
+ }
212
+ try {
213
+ activeScene.definition.dispose?.(outgoingFinalState);
214
+ } catch (error) {
215
+ // The outgoing scene's dispose already ran (possibly partially) and is
216
+ // not retried; the old scene remains active with that honest caveat.
217
+ if (targetCreated) {
218
+ try {
219
+ targetDefinition.dispose?.(targetState);
220
+ } catch {
221
+ // Best effort.
222
+ }
223
+ }
224
+ throw error;
225
+ }
226
+ if (advanceTimeTick !== undefined) {
227
+ tick = advanceTimeTick;
228
+ }
229
+ activeScene = {
230
+ name: targetName,
231
+ definition: targetDefinition,
232
+ state: targetState,
233
+ sceneTick: 0
234
+ };
235
+ sceneName = targetName;
236
+ currentSnapshot = targetSnapshot;
237
+ previousSnapshot = targetSnapshot;
238
+ if (preserveActivePointers) {
239
+ inputBuffer.resetForTransition(targetDefinition.actions);
240
+ } else {
241
+ inputBuffer.reset();
242
+ }
243
+ // Keep the accumulated timing fraction: discarding it would make the tick
244
+ // count depend on presentation rate (acceptance criterion 11). The hard cut
245
+ // is still published with alpha 0 via `hardCutPending`.
246
+ hardCutPending = true;
247
+ };
248
+ const requestPendingTransition = intent => {
249
+ if (pendingTransition !== undefined && !sameIntent(pendingTransition, intent)) {
250
+ throw new GameSessionLifecycleError(`Conflicting pending scene transition (${describeIntent(pendingTransition)} then ${describeIntent(intent)})`);
251
+ }
252
+ pendingTransition = intent;
253
+ };
254
+ let activeUpdateScope;
255
+ const makeTransitionController = scope => {
256
+ const assertActive = () => {
257
+ if (activeUpdateScope !== scope) {
258
+ throw new GameSessionLifecycleError('Scene transition controller is only valid during its owning scene update');
259
+ }
260
+ };
261
+ return Object.freeze({
262
+ setScene(name) {
263
+ assertActive();
264
+ if (name === activeScene.name) {
265
+ return; // Idempotent no-op.
266
+ }
267
+ if (!Object.hasOwn(definition.scenes, name)) {
268
+ throw new GameSessionLifecycleError(`Unknown scene: ${name}`);
269
+ }
270
+ const declared = activeScene.definition.transitions ?? [];
271
+ if (!declared.includes(name)) {
272
+ throw new GameSessionLifecycleError(`Scene "${activeScene.name}" can only transition to its declared targets (missing "${name}")`);
273
+ }
274
+ if (scope.intent !== undefined && !(scope.intent.kind === 'setScene' && scope.intent.name === name)) {
275
+ throw new GameSessionLifecycleError(`Conflicting scene transition requests in one update (${describeIntent(scope.intent)} then setScene("${name}"))`);
276
+ }
277
+ scope.intent = {
278
+ kind: 'setScene',
279
+ name
280
+ };
281
+ },
282
+ restartScene() {
283
+ assertActive();
284
+ if (scope.intent !== undefined && scope.intent.kind !== 'restart') {
285
+ throw new GameSessionLifecycleError(`Conflicting scene transition requests in one update (${describeIntent(scope.intent)} then restartScene())`);
286
+ }
287
+ scope.intent = {
288
+ kind: 'restart'
289
+ };
290
+ }
291
+ });
292
+ };
293
+ const schedule = activeGeneration => {
294
+ frameHandle = options.frameDriver.requestFrame(timestampMs => {
295
+ if (status !== 'running' || generation !== activeGeneration) {
296
+ return;
297
+ }
298
+ frameHandle = undefined;
299
+ publishedThisCallback = false;
300
+ if (diagnostics !== undefined) {
301
+ diagnostics.onDisplayCallback();
302
+ }
303
+
304
+ // A pending external transition commits at the next fixed-step boundary
305
+ // without advancing simulation tick/time.
306
+ if (pendingTransition !== undefined) {
307
+ const pending = pendingTransition;
308
+ pendingTransition = undefined;
309
+ try {
310
+ commitTransition(pending, activeScene.state, undefined);
311
+ } catch (error) {
312
+ pauseInternal();
313
+ throw error;
314
+ }
315
+ commitOrPause();
316
+ if (status !== 'running' || generation !== activeGeneration) {
317
+ return;
318
+ }
319
+ }
320
+ if (previousTimestampMs === undefined) {
321
+ previousTimestampMs = timestampMs;
322
+ if (!publishedThisCallback) {
323
+ commitOrPause();
324
+ }
325
+ if (status === 'running' && generation === activeGeneration) {
326
+ schedule(activeGeneration);
327
+ }
328
+ return;
329
+ }
330
+ const wallDeltaMs = Math.max(0, timestampMs - previousTimestampMs);
331
+ previousTimestampMs = timestampMs;
332
+ accumulatorMs += Math.min(wallDeltaMs, maxFrameDeltaMs);
333
+ const tolerance = fixedStepMs * 1e-9;
334
+ let catchUpSteps = 0;
335
+ let stepsRan = false;
336
+ try {
337
+ while (accumulatorMs + tolerance >= fixedStepMs && catchUpSteps < maxCatchUpSteps && status === 'running' && generation === activeGeneration) {
338
+ stepsRan = true;
339
+ const nextTick = tick + 1;
340
+ const nextSceneTick = activeScene.sceneTick + 1;
341
+ const sampleStart = diagnostics === undefined ? 0 : now();
342
+ const input = inputBuffer.sample();
343
+ if (diagnostics !== undefined) {
344
+ diagnostics.onInputSample(now() - sampleStart);
345
+ }
346
+ const scope = {};
347
+ activeUpdateScope = scope;
348
+ updateInProgress = true;
349
+ const updateStart = diagnostics === undefined ? 0 : now();
350
+ const nextState = freezeObject(activeScene.definition.update({
351
+ state: activeScene.state,
352
+ input,
353
+ transition: makeTransitionController(scope),
354
+ tick: nextTick,
355
+ sceneTick: nextSceneTick,
356
+ deltaSeconds: fixedStepMs / 1000,
357
+ elapsedSeconds: nextTick * fixedStepMs / 1000,
358
+ sceneElapsedSeconds: nextSceneTick * fixedStepMs / 1000
359
+ }));
360
+ activeUpdateScope = undefined;
361
+ updateInProgress = false;
362
+ if (diagnostics !== undefined) {
363
+ diagnostics.onUpdate(now() - updateStart);
364
+ }
365
+ const intent = scope.intent;
366
+ if (isDisposed()) {
367
+ return;
368
+ }
369
+ if (intent !== undefined) {
370
+ // A transition requested during update commits after this update
371
+ // completes successfully. The update consumed one fixed step; the
372
+ // hard-cut frame publishes at the end of this presentation callback.
373
+ commitTransition(intent, nextState, nextTick, true);
374
+ accumulatorMs = Math.max(0, accumulatorMs - fixedStepMs);
375
+ // F4: the transition consumed one fixed step; report it as such
376
+ // and never as a zero-step callback (zero-step fires only when
377
+ // no step ran at all).
378
+ if (diagnostics !== undefined) {
379
+ diagnostics.onFixedStep();
380
+ }
381
+ break;
382
+ }
383
+ const snapshotStart = diagnostics === undefined ? 0 : now();
384
+ const rawSnapshot = activeScene.definition.snapshot({
385
+ state: nextState
386
+ });
387
+ if (diagnostics !== undefined) {
388
+ diagnostics.onSnapshot(now() - snapshotStart);
389
+ }
390
+ const freezeStart = diagnostics === undefined ? 0 : now();
391
+ const nextSnapshot = deepFreeze(rawSnapshot);
392
+ if (diagnostics !== undefined) {
393
+ diagnostics.onDeepFreeze(now() - freezeStart);
394
+ }
395
+ if (isDisposed()) {
396
+ return;
397
+ }
398
+ activeScene.state = nextState;
399
+ activeScene.sceneTick = nextSceneTick;
400
+ previousSnapshot = currentSnapshot;
401
+ currentSnapshot = nextSnapshot;
402
+ tick = nextTick;
403
+ accumulatorMs = Math.max(0, accumulatorMs - fixedStepMs);
404
+ catchUpSteps += 1;
405
+ if (diagnostics !== undefined) {
406
+ diagnostics.onFixedStep();
407
+ if (catchUpSteps > 1) {
408
+ diagnostics.onCatchUpStep();
409
+ }
410
+ }
411
+ }
412
+ } catch (error) {
413
+ activeUpdateScope = undefined;
414
+ updateInProgress = false;
415
+ pauseInternal();
416
+ throw error;
417
+ }
418
+ if (catchUpSteps === maxCatchUpSteps && accumulatorMs >= fixedStepMs) {
419
+ const droppedSteps = Math.floor(accumulatorMs / fixedStepMs);
420
+ accumulatorMs %= fixedStepMs;
421
+ if (diagnostics !== undefined) {
422
+ diagnostics.onDroppedDebt(droppedSteps);
423
+ }
424
+ }
425
+ if (catchUpSteps === 0 && !stepsRan) {
426
+ if (diagnostics !== undefined) {
427
+ diagnostics.onZeroStepCallback();
428
+ }
429
+ }
430
+ if (stepsRan && !publishedThisCallback) {
431
+ // One commit per presentation callback, with the final adjacent pair:
432
+ // `previous`/`current` already hold the last two committed snapshots.
433
+ // A transition inside the loop also counts as a run step: its hard
434
+ // cut commits here (zero-step callbacks never reach this branch).
435
+ commitOrPause();
436
+ }
437
+ if (status === 'running' && generation === activeGeneration) {
438
+ schedule(activeGeneration);
439
+ }
440
+ });
441
+ };
442
+ const session = {
443
+ get status() {
444
+ return status;
445
+ },
446
+ get scene() {
447
+ return sceneName;
448
+ },
449
+ viewport: definition.viewport,
450
+ input: inputBuffer.controller,
451
+ start() {
452
+ assertLive();
453
+ if (status === 'running') {
454
+ return;
455
+ }
456
+ status = 'running';
457
+ previousTimestampMs = undefined;
458
+ accumulatorMs = 0;
459
+ const activeGeneration = ++generation;
460
+ schedule(activeGeneration);
461
+ },
462
+ pause() {
463
+ assertLive();
464
+ pauseInternal();
465
+ if (pendingTransition !== undefined) {
466
+ const pending = pendingTransition;
467
+ pendingTransition = undefined;
468
+ commitTransition(pending, activeScene.state, undefined);
469
+ commitOrPause();
470
+ }
471
+ },
472
+ setScene(name) {
473
+ assertLive();
474
+ if (updateInProgress) {
475
+ throw new GameSessionLifecycleError('External scene transitions cannot be requested during a scene update');
476
+ }
477
+ const nameString = String(name);
478
+ if (nameString === sceneName) {
479
+ return; // Idempotent no-op.
480
+ }
481
+ if (!Object.hasOwn(definition.scenes, nameString)) {
482
+ throw new GameSessionLifecycleError(`Unknown scene: ${nameString}`);
483
+ }
484
+ if (status === 'running') {
485
+ requestPendingTransition({
486
+ kind: 'setScene',
487
+ name: nameString
488
+ });
489
+ return;
490
+ }
491
+ commitTransition({
492
+ kind: 'setScene',
493
+ name: nameString
494
+ }, activeScene.state, undefined);
495
+ commitOrPause();
496
+ },
497
+ restartScene() {
498
+ assertLive();
499
+ if (updateInProgress) {
500
+ throw new GameSessionLifecycleError('External scene transitions cannot be requested during a scene update');
501
+ }
502
+ if (status === 'running') {
503
+ requestPendingTransition({
504
+ kind: 'restart'
505
+ });
506
+ return;
507
+ }
508
+ commitTransition({
509
+ kind: 'restart'
510
+ }, activeScene.state, undefined);
511
+ commitOrPause();
512
+ },
513
+ dispose() {
514
+ if (status === 'disposed') {
515
+ return;
516
+ }
517
+ if (frameHandle !== undefined) {
518
+ options.frameDriver.cancelFrame(frameHandle);
519
+ frameHandle = undefined;
520
+ }
521
+ status = 'disposed';
522
+ generation += 1;
523
+ previousTimestampMs = undefined;
524
+ accumulatorMs = 0;
525
+ pendingTransition = undefined;
526
+ inputBuffer.reset();
527
+ listeners.clear();
528
+ activeScene.definition.dispose?.(activeScene.state);
529
+ },
530
+ getRenderFrame() {
531
+ const alpha = commitFrame.hardCut ? 0 : Math.max(0, Math.min(accumulatorMs / fixedStepMs, 1 - Number.EPSILON));
532
+ return Object.freeze({
533
+ ...commitFrame,
534
+ alpha
535
+ });
536
+ },
537
+ addCommitListener(listener) {
538
+ assertLive();
539
+ listeners.add(listener);
540
+ let removed = false;
541
+ return Object.freeze({
542
+ remove() {
543
+ if (removed) {
544
+ return;
545
+ }
546
+ removed = true;
547
+ listeners.delete(listener);
548
+ }
549
+ });
550
+ }
551
+ };
552
+ return Object.freeze(session);
553
+ }
554
+ //# sourceMappingURL=createGameSession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createAnimationFrameDriver","createInputBuffer","GameSessionDisposedError","GameSessionLifecycleError","createDeepFreeze","DEFAULT_FIXED_STEP_MS","DEFAULT_MAX_CATCH_UP_STEPS","now","performance","freezeObject","value","Object","freeze","describeIntent","intent","kind","name","sameIntent","a","b","createGameSession","definition","createGameSessionWithDriver","frameDriver","options","fixedStepMs","maxCatchUpSteps","maxFrameDeltaMs","diagnostics","deepFreeze","Number","isFinite","RangeError","isInteger","erasedSceneMap","scene","entries","scenes","erased","action","actions","hasOwn","input","Error","target","transitions","initialSceneName","String","initialScene","initialDefinition","undefined","initialState","create","initialSnapshot","snapshot","state","error","dispose","activeScene","sceneTick","sceneName","currentSnapshot","previousSnapshot","status","generation","frameHandle","previousTimestampMs","accumulatorMs","tick","pendingTransition","hardCutPending","publishedThisCallback","updateInProgress","revision","commitFrame","previous","current","elapsedSeconds","hardCut","stepMs","listeners","Set","assertLive","isDisposed","inputBuffer","commit","publishStart","frame","listener","onPublish","onCommitNotification","onListenerCount","size","pauseInternal","cancelFrame","reset","commitOrPause","commitTransition","outgoingFinalState","advanceTimeTick","preserveActivePointers","targetName","targetDefinition","targetState","targetCreated","targetSnapshot","resetForTransition","requestPendingTransition","activeUpdateScope","makeTransitionController","scope","assertActive","setScene","declared","includes","restartScene","schedule","activeGeneration","requestFrame","timestampMs","onDisplayCallback","pending","wallDeltaMs","Math","max","min","tolerance","catchUpSteps","stepsRan","nextTick","nextSceneTick","sampleStart","sample","onInputSample","updateStart","nextState","update","transition","deltaSeconds","sceneElapsedSeconds","onUpdate","onFixedStep","snapshotStart","rawSnapshot","onSnapshot","freezeStart","nextSnapshot","onDeepFreeze","onCatchUpStep","droppedSteps","floor","onDroppedDebt","onZeroStepCallback","session","viewport","controller","start","pause","nameString","clear","getRenderFrame","alpha","EPSILON","addCommitListener","add","removed","remove","delete"],"sourceRoot":"../../../../src","sources":["core/session/createGameSession.ts"],"mappings":";;AAEA,SAASA,0BAA0B,QAA4C,mBAAgB;AAC/F,SAASC,iBAAiB,QAAQ,+BAA4B;AAE9D,SACEC,wBAAwB,EACxBC,yBAAyB,QAMpB,YAAS;AAEhB,SAASC,gBAAgB,QAA0B,iBAAc;AAEjE,MAAMC,qBAAqB,GAAG,IAAI,GAAG,EAAE;AACvC,MAAMC,0BAA0B,GAAG,CAAC;AA4CpC,SAASC,GAAGA,CAAA,EAAW;EACrB,OAAO,OAAOC,WAAW,KAAK,WAAW,GAAGA,WAAW,CAACD,GAAG,CAAC,CAAC,GAAG,CAAC;AACnE;AAEA,SAASE,YAAYA,CAAIC,KAAQ,EAAK;EACpC,OAAO,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,GAAGC,MAAM,CAACC,MAAM,CAACF,KAAK,CAAC,GAAGA,KAAK;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