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,58 @@
1
+ "use strict";
2
+
3
+ /** Minimal AppState-like source used to keep this seam platform-neutral. */
4
+
5
+ /** Session operations the lifecycle binding may drive. */
6
+
7
+ /**
8
+ * Pause a running session when the app becomes inactive or backgrounded and
9
+ * resume it on foreground only when this binding performed that pause.
10
+ *
11
+ * Platform-neutral: the React adapter supplies React Native's `AppState`.
12
+ * The initial `currentState` is synchronized at bind time, so an app that
13
+ * mounts while already backgrounded never leaves a session running
14
+ * invisibly. Manual pauses that precede backgrounding are never claimed, and
15
+ * a session that another actor resumed (or disposed) meanwhile is not
16
+ * resumed again. Cleanup clears the binding flag so a late foreground event
17
+ * cannot restart an unmounted game.
18
+ */
19
+ export function bindAppLifecycle(source, session) {
20
+ let pausedByLifecycle = false;
21
+ const pauseForBackground = () => {
22
+ if (session.getStatus() === 'running') {
23
+ session.pause();
24
+ pausedByLifecycle = true;
25
+ }
26
+ };
27
+
28
+ // Synchronize the initial app state before any change event arrives.
29
+ if (source.currentState === 'inactive' || source.currentState === 'background') {
30
+ pauseForBackground();
31
+ }
32
+ const subscription = source.addEventListener('change', next => {
33
+ if (next === 'active') {
34
+ if (pausedByLifecycle) {
35
+ pausedByLifecycle = false;
36
+ // Resume only if the session is still paused; a different actor may
37
+ // have resumed or disposed it while the app was backgrounded.
38
+ if (session.getStatus() === 'paused') {
39
+ session.resume();
40
+ }
41
+ }
42
+ return;
43
+ }
44
+ if (next === 'inactive' || next === 'background') {
45
+ pauseForBackground();
46
+ }
47
+ });
48
+ let cleanedUp = false;
49
+ return () => {
50
+ if (cleanedUp) {
51
+ return;
52
+ }
53
+ cleanedUp = true;
54
+ subscription.remove();
55
+ pausedByLifecycle = false;
56
+ };
57
+ }
58
+ //# sourceMappingURL=bindAppLifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["bindAppLifecycle","source","session","pausedByLifecycle","pauseForBackground","getStatus","pause","currentState","subscription","addEventListener","next","resume","cleanedUp","remove"],"sourceRoot":"../../../src","sources":["react/bindAppLifecycle.ts"],"mappings":";;AAEA;;AAUA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,gBAAgBA,CAC9BC,MAA0B,EAC1BC,OAA4B,EAChB;EACZ,IAAIC,iBAAiB,GAAG,KAAK;EAE7B,MAAMC,kBAAkB,GAAGA,CAAA,KAAM;IAC/B,IAAIF,OAAO,CAACG,SAAS,CAAC,CAAC,KAAK,SAAS,EAAE;MACrCH,OAAO,CAACI,KAAK,CAAC,CAAC;MACfH,iBAAiB,GAAG,IAAI;IAC1B;EACF,CAAC;;EAED;EACA,IAAIF,MAAM,CAACM,YAAY,KAAK,UAAU,IAAIN,MAAM,CAACM,YAAY,KAAK,YAAY,EAAE;IAC9EH,kBAAkB,CAAC,CAAC;EACtB;EAEA,MAAMI,YAAY,GAAGP,MAAM,CAACQ,gBAAgB,CAAC,QAAQ,EAAGC,IAAI,IAAK;IAC/D,IAAIA,IAAI,KAAK,QAAQ,EAAE;MACrB,IAAIP,iBAAiB,EAAE;QACrBA,iBAAiB,GAAG,KAAK;QACzB;QACA;QACA,IAAID,OAAO,CAACG,SAAS,CAAC,CAAC,KAAK,QAAQ,EAAE;UACpCH,OAAO,CAACS,MAAM,CAAC,CAAC;QAClB;MACF;MACA;IACF;IACA,IAAID,IAAI,KAAK,UAAU,IAAIA,IAAI,KAAK,YAAY,EAAE;MAChDN,kBAAkB,CAAC,CAAC;IACtB;EACF,CAAC,CAAC;EAEF,IAAIQ,SAAS,GAAG,KAAK;EACrB,OAAO,MAAM;IACX,IAAIA,SAAS,EAAE;MACb;IACF;IACAA,SAAS,GAAG,IAAI;IAChBJ,YAAY,CAACK,MAAM,CAAC,CAAC;IACrBV,iBAAiB,GAAG,KAAK;EAC3B,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
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 function bindGameSession(game, present) {
14
+ let lastRevision = -1;
15
+ const presentIfNewer = frame => {
16
+ if (frame.revision <= lastRevision) {
17
+ return;
18
+ }
19
+ lastRevision = frame.revision;
20
+ present(frame);
21
+ };
22
+ presentIfNewer(game.getRenderFrame());
23
+ const subscription = game.addCommitListener(presentIfNewer);
24
+ game.start();
25
+ let cleanedUp = false;
26
+ return () => {
27
+ if (cleanedUp) {
28
+ return;
29
+ }
30
+ cleanedUp = true;
31
+ subscription.remove();
32
+ if (game.status !== 'disposed') {
33
+ game.pause();
34
+ }
35
+ };
36
+ }
37
+ //# sourceMappingURL=bindGameSession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["bindGameSession","game","present","lastRevision","presentIfNewer","frame","revision","getRenderFrame","subscription","addCommitListener","start","cleanedUp","remove","status","pause"],"sourceRoot":"../../../src","sources":["react/bindGameSession.ts"],"mappings":";;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAeA,CAC7BC,IAAkC,EAClCC,OAA8C,EAClC;EACZ,IAAIC,YAAY,GAAG,CAAC,CAAC;EACrB,MAAMC,cAAc,GAAIC,KAA2B,IAAK;IACtD,IAAIA,KAAK,CAACC,QAAQ,IAAIH,YAAY,EAAE;MAClC;IACF;IACAA,YAAY,GAAGE,KAAK,CAACC,QAAQ;IAC7BJ,OAAO,CAACG,KAAK,CAAC;EAChB,CAAC;EACDD,cAAc,CAACH,IAAI,CAACM,cAAc,CAAC,CAAC,CAAC;EACrC,MAAMC,YAAY,GAAGP,IAAI,CAACQ,iBAAiB,CAACL,cAAc,CAAC;EAC3DH,IAAI,CAACS,KAAK,CAAC,CAAC;EACZ,IAAIC,SAAS,GAAG,KAAK;EAErB,OAAO,MAAM;IACX,IAAIA,SAAS,EAAE;MACb;IACF;IACAA,SAAS,GAAG,IAAI;IAChBH,YAAY,CAACI,MAAM,CAAC,CAAC;IACrB,IAAIX,IAAI,CAACY,MAAM,KAAK,UAAU,EAAE;MAC9BZ,IAAI,CAACa,KAAK,CAAC,CAAC;IACd;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ /** RN-side mirror of whether the trailing-flush sampler should be mounted. */
4
+
5
+ /**
6
+ * Manual-gesture terminal lifecycle (F3).
7
+ *
8
+ * The RNGH 3 manual recognizer is activated explicitly on touch-down and
9
+ * must be returned to its terminal state explicitly: it stays active across
10
+ * separate touches and screen lifecycles otherwise. This pure decision
11
+ * drives the deactivation call in `GamePointerInput`; the recognizer-state
12
+ * operations themselves stay on the UI runtime.
13
+ */
14
+
15
+ /** A single-pointer binding begins only with the first native touch. */
16
+ export function canBeginPrimaryPointer(nativeTouchCount) {
17
+ 'worklet';
18
+
19
+ return nativeTouchCount === 1;
20
+ }
21
+
22
+ /** After an up edge, deactivate once RNGH reports that no touches remain. */
23
+ export function deactivateAfterUp(remainingTouches) {
24
+ 'worklet';
25
+
26
+ return remainingTouches === 0;
27
+ }
28
+
29
+ /** Unexpected finalization while a pointer is still active must neutralize ownership. */
30
+ export function cancelOnActiveFinalize(activePointerId) {
31
+ 'worklet';
32
+
33
+ return activePointerId !== undefined;
34
+ }
35
+
36
+ /**
37
+ * Sampler mirror for the F2 trailing flush (F2 lifecycle).
38
+ *
39
+ * The trailing-flush frame callback must stay active exactly while the
40
+ * coalescer owns a pointer. Returns `true` when a begin crossed (pointer
41
+ * owned), `false` when a terminal edge crossed (pointer released), and
42
+ * `undefined` for empty batches (secondary touches — never toggle the
43
+ * sampler) and flushed moves (the pointer stays owned).
44
+ */
45
+ export function samplerMirrorFromBatch(batch) {
46
+ 'worklet';
47
+
48
+ if (batch.length === 0) {
49
+ return undefined;
50
+ }
51
+ const kind = batch[batch.length - 1]?.kind;
52
+ if (kind === 'begin') {
53
+ return true;
54
+ }
55
+ if (kind === 'end' || kind === 'cancel') {
56
+ return false;
57
+ }
58
+ return undefined;
59
+ }
60
+
61
+ /**
62
+ * Apply a UI-originated sampler update only when it belongs to the current
63
+ * binding generation.
64
+ */
65
+ export function reduceSamplerMirrorState(currentGeneration, previous, next) {
66
+ return next.generation === currentGeneration ? next : previous;
67
+ }
68
+ //# sourceMappingURL=gestureLifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["canBeginPrimaryPointer","nativeTouchCount","deactivateAfterUp","remainingTouches","cancelOnActiveFinalize","activePointerId","undefined","samplerMirrorFromBatch","batch","length","kind","reduceSamplerMirrorState","currentGeneration","previous","next","generation"],"sourceRoot":"../../../src","sources":["react/gestureLifecycle.ts"],"mappings":";;AAEA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,SAASA,sBAAsBA,CAACC,gBAAwB,EAAW;EACxE,SAAS;;EACT,OAAOA,gBAAgB,KAAK,CAAC;AAC/B;;AAEA;AACA,OAAO,SAASC,iBAAiBA,CAACC,gBAAwB,EAAW;EACnE,SAAS;;EACT,OAAOA,gBAAgB,KAAK,CAAC;AAC/B;;AAEA;AACA,OAAO,SAASC,sBAAsBA,CAACC,eAAmC,EAAW;EACnF,SAAS;;EACT,OAAOA,eAAe,KAAKC,SAAS;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCC,KAAuC,EAClB;EACrB,SAAS;;EACT,IAAIA,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;IACtB,OAAOH,SAAS;EAClB;EACA,MAAMI,IAAI,GAAGF,KAAK,CAACA,KAAK,CAACC,MAAM,GAAG,CAAC,CAAC,EAAEC,IAAI;EAC1C,IAAIA,IAAI,KAAK,OAAO,EAAE;IACpB,OAAO,IAAI;EACb;EACA,IAAIA,IAAI,KAAK,KAAK,IAAIA,IAAI,KAAK,QAAQ,EAAE;IACvC,OAAO,KAAK;EACd;EACA,OAAOJ,SAAS;AAClB;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASK,wBAAwBA,CACtCC,iBAAyB,EACzBC,QAA4B,EAC5BC,IAAwB,EACJ;EACpB,OAAOA,IAAI,CAACC,UAAU,KAAKH,iBAAiB,GAAGE,IAAI,GAAGD,QAAQ;AAChE","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=instrumentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["react/instrumentation.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+
3
+ import { containsSurfacePoint, surfaceToWorld } from "../viewport2d/index.js";
4
+
5
+ /**
6
+ * A coalesced pointer event stamped with the binding epoch it was scheduled
7
+ * under (F6). Packets scheduled before a layout revision or binding
8
+ * replacement carry the old epoch and are rejected on the RN runtime, so a
9
+ * stale begin cannot reacquire input with old coordinates and a stale
10
+ * terminal edge cannot release a newer capture that reused the pointer id.
11
+ */
12
+
13
+ /** Monotonic generation source for factory-created bindings (F3). */
14
+ let nextFactoryGeneration = 1;
15
+
16
+ /** The identity a pointer binding is scoped to. */
17
+
18
+ /** A binding plus the identity it was created for. */
19
+
20
+ /**
21
+ * Reuse the previous binding when the identity is unchanged, otherwise dispose
22
+ * it and create a fresh binding. Returns whether a new binding was created.
23
+ */
24
+ export function createPointerBinding(identity, getViewport, previous) {
25
+ if (previous !== undefined && previous.identity.input === identity.input && previous.identity.action === identity.action && previous.identity.viewport === identity.viewport) {
26
+ return {
27
+ entry: previous,
28
+ created: false
29
+ };
30
+ }
31
+ if (previous !== undefined) {
32
+ previous.binding.dispose();
33
+ }
34
+ return {
35
+ entry: {
36
+ binding: new PointerBinding(identity.action, identity.input, getViewport, nextFactoryGeneration++),
37
+ identity
38
+ },
39
+ created: true
40
+ };
41
+ }
42
+
43
+ /**
44
+ * Platform-neutral pointer binding seam.
45
+ *
46
+ * It converts gesture positions from surface coordinates into logical world
47
+ * coordinates through the current resolved viewport, rejects begins that
48
+ * start in `fit` letterbox space, and forwards semantic events into the
49
+ * session input buffer. The high-level `handleTouches*` methods mirror the
50
+ * adapter's touch dispatch (including forwarding the final up position) so
51
+ * the full adapter behavior is testable without mounting native gesture
52
+ * views. Ownership and neutralization live in the input buffer.
53
+ */
54
+ export class PointerBinding {
55
+ #action;
56
+ #input;
57
+ #getViewport;
58
+ #generation;
59
+ #disposed = false;
60
+ constructor(action, input, getViewport, generation) {
61
+ this.#action = action;
62
+ this.#input = input;
63
+ this.#getViewport = getViewport;
64
+ this.#generation = generation;
65
+ }
66
+
67
+ /**
68
+ * The monotonic adapter-owned generation this binding belongs to (F3).
69
+ * Generations never reset to zero, so a replacement binding and the
70
+ * worklet closures that stamp its packets agree by construction — no
71
+ * post-commit synchronization is needed.
72
+ */
73
+ get generation() {
74
+ return this.#generation;
75
+ }
76
+
77
+ /**
78
+ * Dispatch a coalesced packet stamped with its scheduling generation.
79
+ *
80
+ * Returns `false` (and forwards nothing) when the binding is disposed or
81
+ * the packet belongs to a different generation; the active gesture's
82
+ * packets keep flowing under the current generation with the latest
83
+ * viewport. Layout-epoch rejection happens on the adapter side (the epoch
84
+ * is adapter-owned and never resets, so it cannot desynchronize).
85
+ */
86
+ dispatch(packet) {
87
+ if (this.#disposed || packet.generation !== this.#generation) {
88
+ return false;
89
+ }
90
+ switch (packet.kind) {
91
+ case 'begin':
92
+ this.handleTouchesDown(packet.pointerId, packet.x, packet.y);
93
+ break;
94
+ case 'move':
95
+ this.handleTouchesMove(packet.pointerId, packet.x, packet.y);
96
+ break;
97
+ case 'end':
98
+ this.handleTouchesUp(packet.pointerId, packet.x, packet.y);
99
+ break;
100
+ case 'cancel':
101
+ this.handleTouchesCancelled();
102
+ break;
103
+ }
104
+ return true;
105
+ }
106
+
107
+ /**
108
+ * Begin a pointer at a surface point.
109
+ *
110
+ * Returns `false` when the layout is invalid or the point starts in
111
+ * letterbox space; the gesture must be rejected and never becomes the owner.
112
+ */
113
+ begin(pointerId, surfacePoint) {
114
+ if (this.#disposed) {
115
+ return false;
116
+ }
117
+ const viewport = this.#getViewport();
118
+ if (viewport === undefined) {
119
+ return false;
120
+ }
121
+ if (!containsSurfacePoint(viewport, surfacePoint)) {
122
+ return false;
123
+ }
124
+ this.#input.begin(this.#action, pointerId, surfaceToWorld(viewport, surfacePoint));
125
+ return true;
126
+ }
127
+
128
+ /** Move a pointer. Conversion remains unbounded outside content bounds. */
129
+ move(pointerId, surfacePoint) {
130
+ if (this.#disposed) {
131
+ return;
132
+ }
133
+ const viewport = this.#getViewport();
134
+ if (viewport === undefined) {
135
+ return;
136
+ }
137
+ this.#input.move(this.#action, pointerId, surfaceToWorld(viewport, surfacePoint));
138
+ }
139
+
140
+ /** End a pointer. The owning pointer is released by the input buffer. */
141
+ end(pointerId) {
142
+ if (this.#disposed) {
143
+ return;
144
+ }
145
+ this.#input.end(this.#action, pointerId);
146
+ }
147
+
148
+ /** Cancel the active pointer (gesture cancellation, layout change, unmount). */
149
+ cancel() {
150
+ if (this.#disposed) {
151
+ return;
152
+ }
153
+ this.#input.cancel(this.#action);
154
+ }
155
+
156
+ /** Handle a touch-down gesture event with a surface position. */
157
+ handleTouchesDown(pointerId, x, y) {
158
+ return this.begin(pointerId, {
159
+ x,
160
+ y
161
+ });
162
+ }
163
+
164
+ /** Handle a touch-move gesture event with a surface position. */
165
+ handleTouchesMove(pointerId, x, y) {
166
+ this.move(pointerId, {
167
+ x,
168
+ y
169
+ });
170
+ }
171
+
172
+ /**
173
+ * Handle a touch-up gesture event with its final surface position.
174
+ *
175
+ * The final position is forwarded before ownership ends so the documented
176
+ * release frame contains the actual point where the pointer lifted.
177
+ */
178
+ handleTouchesUp(pointerId, x, y) {
179
+ this.move(pointerId, {
180
+ x,
181
+ y
182
+ });
183
+ this.end(pointerId);
184
+ }
185
+
186
+ /** Handle a platform touch cancellation. */
187
+ handleTouchesCancelled() {
188
+ this.cancel();
189
+ }
190
+
191
+ /** Stop forwarding events. Safe to call repeatedly. */
192
+ dispose() {
193
+ this.#disposed = true;
194
+ }
195
+ }
196
+ //# sourceMappingURL=pointerBinding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["containsSurfacePoint","surfaceToWorld","nextFactoryGeneration","createPointerBinding","identity","getViewport","previous","undefined","input","action","viewport","entry","created","binding","dispose","PointerBinding","generation","disposed","constructor","dispatch","packet","kind","handleTouchesDown","pointerId","x","y","handleTouchesMove","handleTouchesUp","handleTouchesCancelled","begin","surfacePoint","move","end","cancel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,SAAS,EAAE;MAAEC,CAAC;MAAEC;IAAE,CAAC,CAAC;EAChC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEE,eAAeA,CAACJ,SAAiB,EAAEC,CAAS,EAAEC,CAAS,EAAQ;IAC7D,IAAI,CAACM,IAAI,CAACR,SAAS,EAAE;MAAEC,CAAC;MAAEC;IAAE,CAAC,CAAC;IAC9B,IAAI,CAACO,GAAG,CAACT,SAAS,CAAC;EACrB;;EAEA;EACAK,sBAAsBA,CAAA,EAAS;IAC7B,IAAI,CAACK,MAAM,CAAC,CAAC;EACf;;EAEA;EACAnB,OAAOA,CAAA,EAAS;IACd,IAAI,CAAC,CAACG,QAAQ,GAAG,IAAI;EACvB;AACF","ignoreList":[]}
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Pointer coalescer (T7).
5
+ *
6
+ * Pure, worklet-safe state machine that throttles move forwarding from the
7
+ * UI runtime: at most one move crosses runtimes per configured interval
8
+ * (default: one fixed step), always carrying the latest dirty position.
9
+ * Edges are never throttled or dropped:
10
+ *
11
+ * - `down` forwards the begin immediately (latency-critical) and establishes
12
+ * the single active pointer; a secondary pointer is ignored.
13
+ * - `move` updates the latest dirty position and forwards it at most once
14
+ * per interval.
15
+ * - `flush` forwards the latest deferred move even if native touch movement
16
+ * has paused.
17
+ * - `up` forwards the final position in the terminal edge and releases the
18
+ * active pointer.
19
+ * - `cancel` neutralizes exactly once.
20
+ * - `reset` drops all queued state (layout revision, unmount).
21
+ *
22
+ * The coalescer is not the authoritative owner: ownership, edge sampling,
23
+ * and containment re-validation stay on the JS side (input buffer).
24
+ * Time is injected so ordering and frequency are testable without a device.
25
+ */
26
+
27
+ /** Explicit coalescer state stored in one UI-runtime SharedValue. */
28
+
29
+ /** One native touch input consumed by the pure coalescer reducer. */
30
+
31
+ /** Immutable state plus the ordered events produced by one coalescer input. */
32
+
33
+ /** Create fresh state for a UI-runtime coalescer. */
34
+ export function createPointerCoalescerState(maxMoveIntervalMs) {
35
+ 'worklet';
36
+
37
+ return {
38
+ maxMoveIntervalMs,
39
+ active: undefined
40
+ };
41
+ }
42
+
43
+ /**
44
+ * Advance pointer coalescing without relying on mutable worklet closures.
45
+ *
46
+ * RNGH registers each touch callback as a separate worklet. Closure-captured
47
+ * objects may therefore be serialized into independent copies; callers must
48
+ * keep the returned state in one SharedValue and pass it into every handler.
49
+ */
50
+ export function reducePointerCoalescer(state, input) {
51
+ 'worklet';
52
+
53
+ if (input.kind === 'reset') {
54
+ return {
55
+ state: createPointerCoalescerState(state.maxMoveIntervalMs),
56
+ events: []
57
+ };
58
+ }
59
+ if (input.kind === 'down') {
60
+ if (state.active !== undefined) {
61
+ return {
62
+ state,
63
+ events: []
64
+ };
65
+ }
66
+ return {
67
+ state: {
68
+ ...state,
69
+ active: {
70
+ pointerId: input.pointerId,
71
+ lastForwardMs: input.nowMs,
72
+ pendingMove: undefined
73
+ }
74
+ },
75
+ events: [{
76
+ kind: 'begin',
77
+ pointerId: input.pointerId,
78
+ x: input.x,
79
+ y: input.y
80
+ }]
81
+ };
82
+ }
83
+ if (input.kind === 'cancel') {
84
+ if (state.active === undefined) {
85
+ return {
86
+ state,
87
+ events: []
88
+ };
89
+ }
90
+ return {
91
+ state: {
92
+ ...state,
93
+ active: undefined
94
+ },
95
+ events: [{
96
+ kind: 'cancel'
97
+ }]
98
+ };
99
+ }
100
+ const active = state.active;
101
+ if (input.kind === 'flush') {
102
+ if (active === undefined || active.pendingMove === undefined) {
103
+ return {
104
+ state,
105
+ events: []
106
+ };
107
+ }
108
+ if (input.nowMs - active.lastForwardMs < state.maxMoveIntervalMs) {
109
+ return {
110
+ state,
111
+ events: []
112
+ };
113
+ }
114
+ return {
115
+ state: {
116
+ ...state,
117
+ active: {
118
+ ...active,
119
+ lastForwardMs: input.nowMs,
120
+ pendingMove: undefined
121
+ }
122
+ },
123
+ events: [{
124
+ kind: 'move',
125
+ pointerId: active.pointerId,
126
+ x: active.pendingMove.x,
127
+ y: active.pendingMove.y
128
+ }]
129
+ };
130
+ }
131
+ if (active === undefined || active.pointerId !== input.pointerId) {
132
+ return {
133
+ state,
134
+ events: []
135
+ };
136
+ }
137
+ if (input.kind === 'up') {
138
+ return {
139
+ state: {
140
+ ...state,
141
+ active: undefined
142
+ },
143
+ // The terminal event carries the newest point, subsuming a deferred move.
144
+ events: [{
145
+ kind: 'end',
146
+ pointerId: input.pointerId,
147
+ x: input.x,
148
+ y: input.y
149
+ }]
150
+ };
151
+ }
152
+ const shouldForward = input.nowMs - active.lastForwardMs >= state.maxMoveIntervalMs;
153
+ const nextActive = {
154
+ pointerId: input.pointerId,
155
+ lastForwardMs: shouldForward ? input.nowMs : active.lastForwardMs,
156
+ pendingMove: shouldForward ? undefined : {
157
+ x: input.x,
158
+ y: input.y
159
+ }
160
+ };
161
+ return {
162
+ state: {
163
+ ...state,
164
+ active: nextActive
165
+ },
166
+ events: shouldForward ? [{
167
+ kind: 'move',
168
+ pointerId: input.pointerId,
169
+ x: input.x,
170
+ y: input.y
171
+ }] : []
172
+ };
173
+ }
174
+
175
+ /**
176
+ * Stateful RN-runtime adapter retained for pure tests and non-worklet callers.
177
+ * UI gesture handlers use `reducePointerCoalescer` with a SharedValue instead.
178
+ */
179
+ export function createPointerCoalescer(maxMoveIntervalMs) {
180
+ let state = createPointerCoalescerState(maxMoveIntervalMs);
181
+ const dispatch = input => {
182
+ const transition = reducePointerCoalescer(state, input);
183
+ state = transition.state;
184
+ return transition.events;
185
+ };
186
+ const coalescer = {
187
+ down: (pointerId, x, y, nowMs) => dispatch({
188
+ kind: 'down',
189
+ pointerId,
190
+ x,
191
+ y,
192
+ nowMs
193
+ }),
194
+ move: (pointerId, x, y, nowMs) => dispatch({
195
+ kind: 'move',
196
+ pointerId,
197
+ x,
198
+ y,
199
+ nowMs
200
+ }),
201
+ flush: nowMs => dispatch({
202
+ kind: 'flush',
203
+ nowMs
204
+ }),
205
+ up: (pointerId, x, y, nowMs) => dispatch({
206
+ kind: 'up',
207
+ pointerId,
208
+ x,
209
+ y,
210
+ nowMs
211
+ }),
212
+ cancel: nowMs => dispatch({
213
+ kind: 'cancel',
214
+ nowMs
215
+ }),
216
+ reset: () => {
217
+ dispatch({
218
+ kind: 'reset'
219
+ });
220
+ }
221
+ };
222
+ return Object.freeze(coalescer);
223
+ }
224
+ //# sourceMappingURL=pointerCoalescer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createPointerCoalescerState","maxMoveIntervalMs","active","undefined","reducePointerCoalescer","state","input","kind","events","pointerId","lastForwardMs","nowMs","pendingMove","x","y","shouldForward","nextActive","createPointerCoalescer","dispatch","transition","coalescer","down","move","flush","up","cancel","reset","Object","freeze"],"sourceRoot":"../../../src","sources":["react/pointerCoalescer.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA+BA;;AAMA;;AAaA;;AAMA;AACA,OAAO,SAASA,2BAA2BA,CACzCC,iBAAyB,EACF;EACvB,SAAS;;EACT,OAAO;IAAEA,iBAAiB;IAAEC,MAAM,EAAEC;EAAU,CAAC;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCC,KAA4B,EAC5BC,KAA4B,EACA;EAC5B,SAAS;;EACT,IAAIA,KAAK,CAACC,IAAI,KAAK,OAAO,EAAE;IAC1B,OAAO;MAAEF,KAAK,EAAEL,2BAA2B,CAACK,KAAK,CAACJ,iBAAiB,CAAC;MAAEO,MAAM,EAAE;IAAG,CAAC;EACpF;EAEA,IAAIF,KAAK,CAACC,IAAI,KAAK,MAAM,EAAE;IACzB,IAAIF,KAAK,CAACH,MAAM,KAAKC,SAAS,EAAE;MAC9B,OAAO;QAAEE,KAAK;QAAEG,MAAM,EAAE;MAAG,CAAC;IAC9B;IACA,OAAO;MACLH,KAAK,EAAE;QACL,GAAGA,KAAK;QACRH,M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MAAQ,CAAC,CAAC;IAC7B;EACF,CAAC;EACD,OAAOoB,MAAM,CAACC,MAAM,CAACR,SAAS,CAAC;AACjC","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * UI-side containment mirror (T7).
5
+ *
6
+ * The exact same viewport formula the JS binding uses to reject begins in
7
+ * `fit` letterbox space, workletized so the Manual gesture can fail before
8
+ * activation. JS re-validates on receipt; this mirror only prevents an
9
+ * obviously invalid begin from activating the gesture at all.
10
+ */
11
+
12
+ /** Whether a surface point may begin a gesture in the interactive content. */
13
+ export function isBeginAllowed(viewport, x, y) {
14
+ 'worklet';
15
+
16
+ if (viewport === undefined) {
17
+ return false;
18
+ }
19
+ const {
20
+ x: boundsX,
21
+ y: boundsY,
22
+ width,
23
+ height
24
+ } = viewport.contentBounds;
25
+ return x >= boundsX && y >= boundsY && x <= boundsX + width && y <= boundsY + height;
26
+ }
27
+ //# sourceMappingURL=pointerContainment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isBeginAllowed","viewport","x","y","undefined","boundsX","boundsY","width","height","contentBounds"],"sourceRoot":"../../../src","sources":["react/pointerContainment.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA,OAAO,SAASA,cAAcA,CAC5BC,QAAwC,EACxCC,CAAS,EACTC,CAAS,EACA;EACT,SAAS;;EACT,IAAIF,QAAQ,KAAKG,SAAS,EAAE;IAC1B,OAAO,KAAK;EACd;EACA,MAAM;IAAEF,CAAC,EAAEG,OAAO;IAAEF,CAAC,EAAEG,OAAO;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGP,QAAQ,CAACQ,aAAa;EACxE,OAAOP,CAAC,IAAIG,OAAO,IAAIF,CAAC,IAAIG,OAAO,IAAIJ,CAAC,IAAIG,OAAO,GAAGE,KAAK,IAAIJ,CAAC,IAAIG,OAAO,GAAGE,MAAM;AACtF","ignoreList":[]}