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.
- package/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +131 -0
- package/lib/module/assets/defineAssets.js +48 -0
- package/lib/module/assets/defineAssets.js.map +1 -0
- package/lib/module/assets/errors.js +38 -0
- package/lib/module/assets/errors.js.map +1 -0
- package/lib/module/assets/types.js +2 -0
- package/lib/module/assets/types.js.map +1 -0
- package/lib/module/assets/validation.js +99 -0
- package/lib/module/assets/validation.js.map +1 -0
- package/lib/module/core/frameDriver.js +20 -0
- package/lib/module/core/frameDriver.js.map +1 -0
- package/lib/module/core/input/createInputBuffer.js +296 -0
- package/lib/module/core/input/createInputBuffer.js.map +1 -0
- package/lib/module/core/input/types.js +4 -0
- package/lib/module/core/input/types.js.map +1 -0
- package/lib/module/core/session/createGameSession.js +554 -0
- package/lib/module/core/session/createGameSession.js.map +1 -0
- package/lib/module/core/session/deepFreeze.js +155 -0
- package/lib/module/core/session/deepFreeze.js.map +1 -0
- package/lib/module/core/session/diagnostics.js +2 -0
- package/lib/module/core/session/diagnostics.js.map +1 -0
- package/lib/module/core/session/types.js +43 -0
- package/lib/module/core/session/types.js.map +1 -0
- package/lib/module/definition/defineGame.js +57 -0
- package/lib/module/definition/defineGame.js.map +1 -0
- package/lib/module/definition/types.js +4 -0
- package/lib/module/definition/types.js.map +1 -0
- package/lib/module/geometry/types.js +2 -0
- package/lib/module/geometry/types.js.map +1 -0
- package/lib/module/index.js +12 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/react/GamePointerInput.js +385 -0
- package/lib/module/react/GamePointerInput.js.map +1 -0
- package/lib/module/react/GameView.js +223 -0
- package/lib/module/react/GameView.js.map +1 -0
- package/lib/module/react/alphaClock.js +42 -0
- package/lib/module/react/alphaClock.js.map +1 -0
- package/lib/module/react/assets/createGameAssetStore.js +358 -0
- package/lib/module/react/assets/createGameAssetStore.js.map +1 -0
- package/lib/module/react/assets/decodeSkiaImage.js +54 -0
- package/lib/module/react/assets/decodeSkiaImage.js.map +1 -0
- package/lib/module/react/assets/errors.js +10 -0
- package/lib/module/react/assets/errors.js.map +1 -0
- package/lib/module/react/assets/useGameAssets.js +160 -0
- package/lib/module/react/assets/useGameAssets.js.map +1 -0
- package/lib/module/react/bindAppLifecycle.js +58 -0
- package/lib/module/react/bindAppLifecycle.js.map +1 -0
- package/lib/module/react/bindGameSession.js +37 -0
- package/lib/module/react/bindGameSession.js.map +1 -0
- package/lib/module/react/gestureLifecycle.js +68 -0
- package/lib/module/react/gestureLifecycle.js.map +1 -0
- package/lib/module/react/instrumentation.js +4 -0
- package/lib/module/react/instrumentation.js.map +1 -0
- package/lib/module/react/pointerBinding.js +196 -0
- package/lib/module/react/pointerBinding.js.map +1 -0
- package/lib/module/react/pointerCoalescer.js +224 -0
- package/lib/module/react/pointerCoalescer.js.map +1 -0
- package/lib/module/react/pointerContainment.js +27 -0
- package/lib/module/react/pointerContainment.js.map +1 -0
- package/lib/module/react/sprites/GameSprite.js +116 -0
- package/lib/module/react/sprites/GameSprite.js.map +1 -0
- package/lib/module/react/sprites/GameWorld2D.js +44 -0
- package/lib/module/react/sprites/GameWorld2D.js.map +1 -0
- package/lib/module/react/sprites/Sprite.js +147 -0
- package/lib/module/react/sprites/Sprite.js.map +1 -0
- package/lib/module/react/sprites/SpriteBatch.js +173 -0
- package/lib/module/react/sprites/SpriteBatch.js.map +1 -0
- package/lib/module/react/sprites/spriteBatchPolicy.js +25 -0
- package/lib/module/react/sprites/spriteBatchPolicy.js.map +1 -0
- package/lib/module/react/sprites/spriteTransform.js +135 -0
- package/lib/module/react/sprites/spriteTransform.js.map +1 -0
- package/lib/module/react/viewportBinding.js +101 -0
- package/lib/module/react/viewportBinding.js.map +1 -0
- package/lib/module/react.js +13 -0
- package/lib/module/react.js.map +1 -0
- package/lib/module/scene/defineScene.js +29 -0
- package/lib/module/scene/defineScene.js.map +1 -0
- package/lib/module/scene/types.js +4 -0
- package/lib/module/scene/types.js.map +1 -0
- package/lib/module/sprites/sampleSpriteClip.js +50 -0
- package/lib/module/sprites/sampleSpriteClip.js.map +1 -0
- package/lib/module/sprites/spriteAnimationState.js +165 -0
- package/lib/module/sprites/spriteAnimationState.js.map +1 -0
- package/lib/module/testing.js +57 -0
- package/lib/module/testing.js.map +1 -0
- package/lib/module/viewport2d/index.js +4 -0
- package/lib/module/viewport2d/index.js.map +1 -0
- package/lib/module/viewport2d/math.js +129 -0
- package/lib/module/viewport2d/math.js.map +1 -0
- package/lib/module/viewport2d/types.js +2 -0
- package/lib/module/viewport2d/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/assets/defineAssets.d.ts +20 -0
- package/lib/typescript/src/assets/defineAssets.d.ts.map +1 -0
- package/lib/typescript/src/assets/errors.d.ts +20 -0
- package/lib/typescript/src/assets/errors.d.ts.map +1 -0
- package/lib/typescript/src/assets/types.d.ts +138 -0
- package/lib/typescript/src/assets/types.d.ts.map +1 -0
- package/lib/typescript/src/assets/validation.d.ts +15 -0
- package/lib/typescript/src/assets/validation.d.ts.map +1 -0
- package/lib/typescript/src/core/frameDriver.d.ts +12 -0
- package/lib/typescript/src/core/frameDriver.d.ts.map +1 -0
- package/lib/typescript/src/core/input/createInputBuffer.d.ts +12 -0
- package/lib/typescript/src/core/input/createInputBuffer.d.ts.map +1 -0
- package/lib/typescript/src/core/input/types.d.ts +64 -0
- package/lib/typescript/src/core/input/types.d.ts.map +1 -0
- package/lib/typescript/src/core/session/createGameSession.d.ts +18 -0
- package/lib/typescript/src/core/session/createGameSession.d.ts.map +1 -0
- package/lib/typescript/src/core/session/deepFreeze.d.ts +27 -0
- package/lib/typescript/src/core/session/deepFreeze.d.ts.map +1 -0
- package/lib/typescript/src/core/session/diagnostics.d.ts +36 -0
- package/lib/typescript/src/core/session/diagnostics.d.ts.map +1 -0
- package/lib/typescript/src/core/session/types.d.ts +104 -0
- package/lib/typescript/src/core/session/types.d.ts.map +1 -0
- package/lib/typescript/src/definition/defineGame.d.ts +66 -0
- package/lib/typescript/src/definition/defineGame.d.ts.map +1 -0
- package/lib/typescript/src/definition/types.d.ts +56 -0
- package/lib/typescript/src/definition/types.d.ts.map +1 -0
- package/lib/typescript/src/geometry/types.d.ts +8 -0
- package/lib/typescript/src/geometry/types.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +18 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/react/GamePointerInput.d.ts +37 -0
- package/lib/typescript/src/react/GamePointerInput.d.ts.map +1 -0
- package/lib/typescript/src/react/GameView.d.ts +61 -0
- package/lib/typescript/src/react/GameView.d.ts.map +1 -0
- package/lib/typescript/src/react/alphaClock.d.ts +29 -0
- package/lib/typescript/src/react/alphaClock.d.ts.map +1 -0
- package/lib/typescript/src/react/assets/createGameAssetStore.d.ts +33 -0
- package/lib/typescript/src/react/assets/createGameAssetStore.d.ts.map +1 -0
- package/lib/typescript/src/react/assets/decodeSkiaImage.d.ts +12 -0
- package/lib/typescript/src/react/assets/decodeSkiaImage.d.ts.map +1 -0
- package/lib/typescript/src/react/assets/errors.d.ts +8 -0
- package/lib/typescript/src/react/assets/errors.d.ts.map +1 -0
- package/lib/typescript/src/react/assets/useGameAssets.d.ts +35 -0
- package/lib/typescript/src/react/assets/useGameAssets.d.ts.map +1 -0
- package/lib/typescript/src/react/bindAppLifecycle.d.ts +32 -0
- package/lib/typescript/src/react/bindAppLifecycle.d.ts.map +1 -0
- package/lib/typescript/src/react/bindGameSession.d.ts +14 -0
- package/lib/typescript/src/react/bindGameSession.d.ts.map +1 -0
- package/lib/typescript/src/react/gestureLifecycle.d.ts +37 -0
- package/lib/typescript/src/react/gestureLifecycle.d.ts.map +1 -0
- package/lib/typescript/src/react/instrumentation.d.ts +47 -0
- package/lib/typescript/src/react/instrumentation.d.ts.map +1 -0
- package/lib/typescript/src/react/pointerBinding.d.ts +104 -0
- package/lib/typescript/src/react/pointerBinding.d.ts.map +1 -0
- package/lib/typescript/src/react/pointerCoalescer.d.ts +106 -0
- package/lib/typescript/src/react/pointerCoalescer.d.ts.map +1 -0
- package/lib/typescript/src/react/pointerContainment.d.ts +12 -0
- package/lib/typescript/src/react/pointerContainment.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/GameSprite.d.ts +75 -0
- package/lib/typescript/src/react/sprites/GameSprite.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/GameWorld2D.d.ts +29 -0
- package/lib/typescript/src/react/sprites/GameWorld2D.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/Sprite.d.ts +43 -0
- package/lib/typescript/src/react/sprites/Sprite.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/SpriteBatch.d.ts +41 -0
- package/lib/typescript/src/react/sprites/SpriteBatch.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/spriteBatchPolicy.d.ts +10 -0
- package/lib/typescript/src/react/sprites/spriteBatchPolicy.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/spriteTransform.d.ts +86 -0
- package/lib/typescript/src/react/sprites/spriteTransform.d.ts.map +1 -0
- package/lib/typescript/src/react/viewportBinding.d.ts +42 -0
- package/lib/typescript/src/react/viewportBinding.d.ts.map +1 -0
- package/lib/typescript/src/react.d.ts +20 -0
- package/lib/typescript/src/react.d.ts.map +1 -0
- package/lib/typescript/src/scene/defineScene.d.ts +26 -0
- package/lib/typescript/src/scene/defineScene.d.ts.map +1 -0
- package/lib/typescript/src/scene/types.d.ts +71 -0
- package/lib/typescript/src/scene/types.d.ts.map +1 -0
- package/lib/typescript/src/sprites/sampleSpriteClip.d.ts +24 -0
- package/lib/typescript/src/sprites/sampleSpriteClip.d.ts.map +1 -0
- package/lib/typescript/src/sprites/spriteAnimationState.d.ts +45 -0
- package/lib/typescript/src/sprites/spriteAnimationState.d.ts.map +1 -0
- package/lib/typescript/src/testing.d.ts +28 -0
- package/lib/typescript/src/testing.d.ts.map +1 -0
- package/lib/typescript/src/viewport2d/index.d.ts +3 -0
- package/lib/typescript/src/viewport2d/index.d.ts.map +1 -0
- package/lib/typescript/src/viewport2d/math.d.ts +25 -0
- package/lib/typescript/src/viewport2d/math.d.ts.map +1 -0
- package/lib/typescript/src/viewport2d/types.d.ts +59 -0
- package/lib/typescript/src/viewport2d/types.d.ts.map +1 -0
- package/package.json +120 -0
- package/src/assets/defineAssets.ts +62 -0
- package/src/assets/errors.ts +64 -0
- package/src/assets/types.ts +164 -0
- package/src/assets/validation.ts +158 -0
- package/src/core/frameDriver.ts +31 -0
- package/src/core/input/createInputBuffer.ts +337 -0
- package/src/core/input/types.ts +67 -0
- package/src/core/session/createGameSession.ts +652 -0
- package/src/core/session/deepFreeze.ts +158 -0
- package/src/core/session/diagnostics.ts +35 -0
- package/src/core/session/types.ts +122 -0
- package/src/definition/defineGame.ts +94 -0
- package/src/definition/types.ts +67 -0
- package/src/geometry/types.ts +7 -0
- package/src/index.ts +84 -0
- package/src/react/GamePointerInput.tsx +478 -0
- package/src/react/GameView.tsx +317 -0
- package/src/react/alphaClock.ts +59 -0
- package/src/react/assets/createGameAssetStore.ts +459 -0
- package/src/react/assets/decodeSkiaImage.ts +64 -0
- package/src/react/assets/errors.ts +7 -0
- package/src/react/assets/useGameAssets.ts +171 -0
- package/src/react/bindAppLifecycle.ts +79 -0
- package/src/react/bindGameSession.ts +41 -0
- package/src/react/gestureLifecycle.ts +73 -0
- package/src/react/instrumentation.ts +54 -0
- package/src/react/pointerBinding.ts +226 -0
- package/src/react/pointerCoalescer.ts +234 -0
- package/src/react/pointerContainment.ts +23 -0
- package/src/react/sprites/GameSprite.tsx +192 -0
- package/src/react/sprites/GameWorld2D.tsx +46 -0
- package/src/react/sprites/Sprite.tsx +194 -0
- package/src/react/sprites/SpriteBatch.tsx +219 -0
- package/src/react/sprites/spriteBatchPolicy.ts +21 -0
- package/src/react/sprites/spriteTransform.ts +163 -0
- package/src/react/viewportBinding.ts +104 -0
- package/src/react.ts +37 -0
- package/src/scene/defineScene.ts +38 -0
- package/src/scene/types.ts +79 -0
- package/src/sprites/sampleSpriteClip.ts +51 -0
- package/src/sprites/spriteAnimationState.ts +176 -0
- package/src/testing.ts +61 -0
- package/src/viewport2d/index.ts +7 -0
- package/src/viewport2d/math.ts +134 -0
- package/src/viewport2d/types.ts +63 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CoalescedPointerEvent } from './pointerCoalescer.js';
|
|
2
|
+
/** RN-side mirror of whether the trailing-flush sampler should be mounted. */
|
|
3
|
+
export interface SamplerMirrorState {
|
|
4
|
+
readonly generation: number;
|
|
5
|
+
readonly active: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Manual-gesture terminal lifecycle (F3).
|
|
9
|
+
*
|
|
10
|
+
* The RNGH 3 manual recognizer is activated explicitly on touch-down and
|
|
11
|
+
* must be returned to its terminal state explicitly: it stays active across
|
|
12
|
+
* separate touches and screen lifecycles otherwise. This pure decision
|
|
13
|
+
* drives the deactivation call in `GamePointerInput`; the recognizer-state
|
|
14
|
+
* operations themselves stay on the UI runtime.
|
|
15
|
+
*/
|
|
16
|
+
/** A single-pointer binding begins only with the first native touch. */
|
|
17
|
+
export declare function canBeginPrimaryPointer(nativeTouchCount: number): boolean;
|
|
18
|
+
/** After an up edge, deactivate once RNGH reports that no touches remain. */
|
|
19
|
+
export declare function deactivateAfterUp(remainingTouches: number): boolean;
|
|
20
|
+
/** Unexpected finalization while a pointer is still active must neutralize ownership. */
|
|
21
|
+
export declare function cancelOnActiveFinalize(activePointerId: number | undefined): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Sampler mirror for the F2 trailing flush (F2 lifecycle).
|
|
24
|
+
*
|
|
25
|
+
* The trailing-flush frame callback must stay active exactly while the
|
|
26
|
+
* coalescer owns a pointer. Returns `true` when a begin crossed (pointer
|
|
27
|
+
* owned), `false` when a terminal edge crossed (pointer released), and
|
|
28
|
+
* `undefined` for empty batches (secondary touches — never toggle the
|
|
29
|
+
* sampler) and flushed moves (the pointer stays owned).
|
|
30
|
+
*/
|
|
31
|
+
export declare function samplerMirrorFromBatch(batch: readonly CoalescedPointerEvent[]): boolean | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Apply a UI-originated sampler update only when it belongs to the current
|
|
34
|
+
* binding generation.
|
|
35
|
+
*/
|
|
36
|
+
export declare function reduceSamplerMirrorState(currentGeneration: number, previous: SamplerMirrorState, next: SamplerMirrorState): SamplerMirrorState;
|
|
37
|
+
//# sourceMappingURL=gestureLifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestureLifecycle.d.ts","sourceRoot":"","sources":["../../../../src/react/gestureLifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAoB,CAAC;AAEhE,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;GAQG;AAEH,wEAAwE;AACxE,wBAAgB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAGxE;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAGnE;AAED,yFAAyF;AACzF,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAGnF;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,qBAAqB,EAAE,GACtC,OAAO,GAAG,SAAS,CAarB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,iBAAiB,EAAE,MAAM,EACzB,QAAQ,EAAE,kBAAkB,EAC5B,IAAI,EAAE,kBAAkB,GACvB,kBAAkB,CAEpB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional measurement seams for the mounted game pipeline (F1).
|
|
3
|
+
*
|
|
4
|
+
* These callbacks let the Performance Lab attribute results to the real
|
|
5
|
+
* mounted components — GameView presentation, RNGH raw touches, and
|
|
6
|
+
* UI→RN forwarding — instead of headless substitutes. They are optional,
|
|
7
|
+
* cost nothing when absent (a single optional chain at event sites, never
|
|
8
|
+
* per-frame), and are not part of the gameplay API contract: the playground
|
|
9
|
+
* lab is their only consumer until the device matrix approves them.
|
|
10
|
+
*
|
|
11
|
+
* Runtime ownership:
|
|
12
|
+
* - Pointer callbacks run on the **UI runtime** (inside gesture worklets);
|
|
13
|
+
* pass stable workletized closures and only touch worklet-safe state
|
|
14
|
+
* (shared values, counters).
|
|
15
|
+
* - `onPresentCommit` runs on the **RN runtime** (inside the commit
|
|
16
|
+
* binding); pass a plain JS callback.
|
|
17
|
+
*/
|
|
18
|
+
import type { CoalescedPointerEvent } from './pointerCoalescer.js';
|
|
19
|
+
/** Raw touch kinds as observed by the manual gesture callbacks. */
|
|
20
|
+
export type PointerStageKind = 'down' | 'move' | 'up' | 'cancel';
|
|
21
|
+
/** Pointer pipeline instrumentation (UI runtime callbacks). */
|
|
22
|
+
export interface GamePointerInstrumentation {
|
|
23
|
+
/** A raw touch reached the manual gesture handlers. */
|
|
24
|
+
readonly onRawTouch?: (kind: PointerStageKind, pointerId: number, atMs: number) => void;
|
|
25
|
+
/** A coalesced event crossed from the UI runtime into the RN runtime. */
|
|
26
|
+
readonly onForwarded?: (kind: CoalescedPointerEvent['kind'], pointerId: number, atMs: number) => void;
|
|
27
|
+
/**
|
|
28
|
+
* RN runtime: the binding's verdict for a dispatched packet (F1). Only
|
|
29
|
+
* accepted packets may become latency samples; stale/rejected packets are
|
|
30
|
+
* counted but never sampled.
|
|
31
|
+
*/
|
|
32
|
+
readonly onDispatchResult?: (seq: number, atMs: number, accepted: boolean) => void;
|
|
33
|
+
/** The trailing-flush sampler mounted (true) or unmounted (false). */
|
|
34
|
+
readonly onSamplerChanged?: (mounted: boolean) => void;
|
|
35
|
+
}
|
|
36
|
+
/** GameView presentation instrumentation (RN runtime callback). */
|
|
37
|
+
export interface GameViewInstrumentation {
|
|
38
|
+
/** A commit was presented to the canvas frame shared value. */
|
|
39
|
+
readonly onPresentCommit?: (revision: number, atMs: number) => void;
|
|
40
|
+
/**
|
|
41
|
+
* UI runtime: the first UI frame that observed a new commit revision (the
|
|
42
|
+
* alpha clock's reset detects it). Skia GPU presentation is not proven by
|
|
43
|
+
* this hook, so latency consumers must name the stage honestly.
|
|
44
|
+
*/
|
|
45
|
+
readonly onUiRevisionObserved?: (revision: number, atMs: number) => void;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../../src/react/instrumentation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAoB,CAAC;AAEhE,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;AAEjE,+DAA+D;AAC/D,MAAM,WAAW,0BAA0B;IACzC,uDAAuD;IACvD,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACxF,yEAAyE;IACzE,QAAQ,CAAC,WAAW,CAAC,EAAE,CACrB,IAAI,EAAE,qBAAqB,CAAC,MAAM,CAAC,EACnC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,KACT,IAAI,CAAC;IACV;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACnF,sEAAsE;IACtE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACxD;AAED,mEAAmE;AACnE,MAAM,WAAW,uBAAuB;IACtC,+DAA+D;IAC/D,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpE;;;;OAIG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1E"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { InputController } from '../core/input/types.js';
|
|
2
|
+
import type { Point2D } from '../geometry/types.js';
|
|
3
|
+
import { type ResolvedViewport2D } from '../viewport2d/index.js';
|
|
4
|
+
import type { CoalescedPointerEvent } from './pointerCoalescer.js';
|
|
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
|
+
export type PointerPacket = CoalescedPointerEvent & {
|
|
13
|
+
/** Monotonic adapter-owned binding generation (F3 follow-up). */
|
|
14
|
+
readonly generation: number;
|
|
15
|
+
/** Adapter-owned layout epoch; bumped on layout revisions and unmount. */
|
|
16
|
+
readonly layoutEpoch: number;
|
|
17
|
+
/** Monotonic UI-runtime forward sequence (F1 latency causality). */
|
|
18
|
+
readonly seq: number;
|
|
19
|
+
/** UI-runtime timestamp of the forward (F1 latency causality). */
|
|
20
|
+
readonly atMs: number;
|
|
21
|
+
};
|
|
22
|
+
/** The identity a pointer binding is scoped to. */
|
|
23
|
+
export interface PointerBindingIdentity<TName extends string> {
|
|
24
|
+
/** The session input controller (identity changes when the session changes). */
|
|
25
|
+
readonly input: InputController<TName>;
|
|
26
|
+
/** The declared pointer action name. */
|
|
27
|
+
readonly action: TName;
|
|
28
|
+
/** Identity token for the viewport provider (changes on layout owner swaps). */
|
|
29
|
+
readonly viewport: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** A binding plus the identity it was created for. */
|
|
32
|
+
export interface PointerBindingEntry<TName extends string> {
|
|
33
|
+
readonly binding: PointerBinding<TName>;
|
|
34
|
+
readonly identity: PointerBindingIdentity<TName>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reuse the previous binding when the identity is unchanged, otherwise dispose
|
|
38
|
+
* it and create a fresh binding. Returns whether a new binding was created.
|
|
39
|
+
*/
|
|
40
|
+
export declare function createPointerBinding<TName extends string>(identity: PointerBindingIdentity<TName>, getViewport: () => ResolvedViewport2D | undefined, previous: PointerBindingEntry<TName> | undefined): {
|
|
41
|
+
readonly entry: PointerBindingEntry<TName>;
|
|
42
|
+
readonly created: boolean;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Platform-neutral pointer binding seam.
|
|
46
|
+
*
|
|
47
|
+
* It converts gesture positions from surface coordinates into logical world
|
|
48
|
+
* coordinates through the current resolved viewport, rejects begins that
|
|
49
|
+
* start in `fit` letterbox space, and forwards semantic events into the
|
|
50
|
+
* session input buffer. The high-level `handleTouches*` methods mirror the
|
|
51
|
+
* adapter's touch dispatch (including forwarding the final up position) so
|
|
52
|
+
* the full adapter behavior is testable without mounting native gesture
|
|
53
|
+
* views. Ownership and neutralization live in the input buffer.
|
|
54
|
+
*/
|
|
55
|
+
export declare class PointerBinding<TActionName extends string> {
|
|
56
|
+
#private;
|
|
57
|
+
constructor(action: TActionName, input: InputController<TActionName>, getViewport: () => ResolvedViewport2D | undefined, generation: number);
|
|
58
|
+
/**
|
|
59
|
+
* The monotonic adapter-owned generation this binding belongs to (F3).
|
|
60
|
+
* Generations never reset to zero, so a replacement binding and the
|
|
61
|
+
* worklet closures that stamp its packets agree by construction — no
|
|
62
|
+
* post-commit synchronization is needed.
|
|
63
|
+
*/
|
|
64
|
+
get generation(): number;
|
|
65
|
+
/**
|
|
66
|
+
* Dispatch a coalesced packet stamped with its scheduling generation.
|
|
67
|
+
*
|
|
68
|
+
* Returns `false` (and forwards nothing) when the binding is disposed or
|
|
69
|
+
* the packet belongs to a different generation; the active gesture's
|
|
70
|
+
* packets keep flowing under the current generation with the latest
|
|
71
|
+
* viewport. Layout-epoch rejection happens on the adapter side (the epoch
|
|
72
|
+
* is adapter-owned and never resets, so it cannot desynchronize).
|
|
73
|
+
*/
|
|
74
|
+
dispatch(packet: PointerPacket): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Begin a pointer at a surface point.
|
|
77
|
+
*
|
|
78
|
+
* Returns `false` when the layout is invalid or the point starts in
|
|
79
|
+
* letterbox space; the gesture must be rejected and never becomes the owner.
|
|
80
|
+
*/
|
|
81
|
+
begin(pointerId: number, surfacePoint: Point2D): boolean;
|
|
82
|
+
/** Move a pointer. Conversion remains unbounded outside content bounds. */
|
|
83
|
+
move(pointerId: number, surfacePoint: Point2D): void;
|
|
84
|
+
/** End a pointer. The owning pointer is released by the input buffer. */
|
|
85
|
+
end(pointerId: number): void;
|
|
86
|
+
/** Cancel the active pointer (gesture cancellation, layout change, unmount). */
|
|
87
|
+
cancel(): void;
|
|
88
|
+
/** Handle a touch-down gesture event with a surface position. */
|
|
89
|
+
handleTouchesDown(pointerId: number, x: number, y: number): boolean;
|
|
90
|
+
/** Handle a touch-move gesture event with a surface position. */
|
|
91
|
+
handleTouchesMove(pointerId: number, x: number, y: number): void;
|
|
92
|
+
/**
|
|
93
|
+
* Handle a touch-up gesture event with its final surface position.
|
|
94
|
+
*
|
|
95
|
+
* The final position is forwarded before ownership ends so the documented
|
|
96
|
+
* release frame contains the actual point where the pointer lifted.
|
|
97
|
+
*/
|
|
98
|
+
handleTouchesUp(pointerId: number, x: number, y: number): void;
|
|
99
|
+
/** Handle a platform touch cancellation. */
|
|
100
|
+
handleTouchesCancelled(): void;
|
|
101
|
+
/** Stop forwarding events. Safe to call repeatedly. */
|
|
102
|
+
dispose(): void;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=pointerBinding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointerBinding.d.ts","sourceRoot":"","sources":["../../../../src/react/pointerBinding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAmB,CAAC;AACjD,OAAO,EAAwC,KAAK,kBAAkB,EAAE,MAAM,wBAAe,CAAC;AAC9F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAoB,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,qBAAqB,GAAG;IAClD,iEAAiE;IACjE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAKF,mDAAmD;AACnD,MAAM,WAAW,sBAAsB,CAAC,KAAK,SAAS,MAAM;IAC1D,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC;IACvC,wCAAwC;IACxC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IACvB,gFAAgF;IAChF,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,sDAAsD;AACtD,MAAM,WAAW,mBAAmB,CAAC,KAAK,SAAS,MAAM;IACvD,QAAQ,CAAC,OAAO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,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAIhE;;;;;OAKG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAK9D,4CAA4C;IAC5C,sBAAsB,IAAI,IAAI;IAI9B,uDAAuD;IACvD,OAAO,IAAI,IAAI;CAGhB"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pointer coalescer (T7).
|
|
3
|
+
*
|
|
4
|
+
* Pure, worklet-safe state machine that throttles move forwarding from the
|
|
5
|
+
* UI runtime: at most one move crosses runtimes per configured interval
|
|
6
|
+
* (default: one fixed step), always carrying the latest dirty position.
|
|
7
|
+
* Edges are never throttled or dropped:
|
|
8
|
+
*
|
|
9
|
+
* - `down` forwards the begin immediately (latency-critical) and establishes
|
|
10
|
+
* the single active pointer; a secondary pointer is ignored.
|
|
11
|
+
* - `move` updates the latest dirty position and forwards it at most once
|
|
12
|
+
* per interval.
|
|
13
|
+
* - `flush` forwards the latest deferred move even if native touch movement
|
|
14
|
+
* has paused.
|
|
15
|
+
* - `up` forwards the final position in the terminal edge and releases the
|
|
16
|
+
* active pointer.
|
|
17
|
+
* - `cancel` neutralizes exactly once.
|
|
18
|
+
* - `reset` drops all queued state (layout revision, unmount).
|
|
19
|
+
*
|
|
20
|
+
* The coalescer is not the authoritative owner: ownership, edge sampling,
|
|
21
|
+
* and containment re-validation stay on the JS side (input buffer).
|
|
22
|
+
* Time is injected so ordering and frequency are testable without a device.
|
|
23
|
+
*/
|
|
24
|
+
export type CoalescedPointerEvent = {
|
|
25
|
+
readonly kind: 'begin';
|
|
26
|
+
readonly pointerId: number;
|
|
27
|
+
readonly x: number;
|
|
28
|
+
readonly y: number;
|
|
29
|
+
} | {
|
|
30
|
+
readonly kind: 'move';
|
|
31
|
+
readonly pointerId: number;
|
|
32
|
+
readonly x: number;
|
|
33
|
+
readonly y: number;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: 'end';
|
|
36
|
+
readonly pointerId: number;
|
|
37
|
+
readonly x: number;
|
|
38
|
+
readonly y: number;
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: 'cancel';
|
|
41
|
+
};
|
|
42
|
+
export interface PointerCoalescer {
|
|
43
|
+
/** A pointer went down at a surface point. Returns the events to forward. */
|
|
44
|
+
down(pointerId: number, x: number, y: number, nowMs: number): readonly CoalescedPointerEvent[];
|
|
45
|
+
/** A pointer moved. Returns at most one (coalesced) move per interval. */
|
|
46
|
+
move(pointerId: number, x: number, y: number, nowMs: number): readonly CoalescedPointerEvent[];
|
|
47
|
+
/** Forward a deferred move when the frame clock reaches the interval. */
|
|
48
|
+
flush(nowMs: number): readonly CoalescedPointerEvent[];
|
|
49
|
+
/** A pointer lifted. Returns the final point and the terminal edge together. */
|
|
50
|
+
up(pointerId: number, x: number, y: number, nowMs: number): readonly CoalescedPointerEvent[];
|
|
51
|
+
/** Neutralize the active pointer. Returns the cancel event exactly once. */
|
|
52
|
+
cancel(nowMs: number): readonly CoalescedPointerEvent[];
|
|
53
|
+
/** Drop all queued state without emitting anything (layout/unmount). */
|
|
54
|
+
reset(): void;
|
|
55
|
+
}
|
|
56
|
+
interface ActivePointer {
|
|
57
|
+
readonly pointerId: number;
|
|
58
|
+
readonly lastForwardMs: number;
|
|
59
|
+
readonly pendingMove: {
|
|
60
|
+
readonly x: number;
|
|
61
|
+
readonly y: number;
|
|
62
|
+
} | undefined;
|
|
63
|
+
}
|
|
64
|
+
/** Explicit coalescer state stored in one UI-runtime SharedValue. */
|
|
65
|
+
export interface PointerCoalescerState {
|
|
66
|
+
readonly maxMoveIntervalMs: number;
|
|
67
|
+
readonly active: ActivePointer | undefined;
|
|
68
|
+
}
|
|
69
|
+
/** One native touch input consumed by the pure coalescer reducer. */
|
|
70
|
+
export type PointerCoalescerInput = {
|
|
71
|
+
readonly kind: 'down' | 'move' | 'up';
|
|
72
|
+
readonly pointerId: number;
|
|
73
|
+
readonly x: number;
|
|
74
|
+
readonly y: number;
|
|
75
|
+
readonly nowMs: number;
|
|
76
|
+
} | {
|
|
77
|
+
readonly kind: 'cancel';
|
|
78
|
+
readonly nowMs: number;
|
|
79
|
+
} | {
|
|
80
|
+
readonly kind: 'flush';
|
|
81
|
+
readonly nowMs: number;
|
|
82
|
+
} | {
|
|
83
|
+
readonly kind: 'reset';
|
|
84
|
+
};
|
|
85
|
+
/** Immutable state plus the ordered events produced by one coalescer input. */
|
|
86
|
+
export interface PointerCoalescerTransition {
|
|
87
|
+
readonly state: PointerCoalescerState;
|
|
88
|
+
readonly events: readonly CoalescedPointerEvent[];
|
|
89
|
+
}
|
|
90
|
+
/** Create fresh state for a UI-runtime coalescer. */
|
|
91
|
+
export declare function createPointerCoalescerState(maxMoveIntervalMs: number): PointerCoalescerState;
|
|
92
|
+
/**
|
|
93
|
+
* Advance pointer coalescing without relying on mutable worklet closures.
|
|
94
|
+
*
|
|
95
|
+
* RNGH registers each touch callback as a separate worklet. Closure-captured
|
|
96
|
+
* objects may therefore be serialized into independent copies; callers must
|
|
97
|
+
* keep the returned state in one SharedValue and pass it into every handler.
|
|
98
|
+
*/
|
|
99
|
+
export declare function reducePointerCoalescer(state: PointerCoalescerState, input: PointerCoalescerInput): PointerCoalescerTransition;
|
|
100
|
+
/**
|
|
101
|
+
* Stateful RN-runtime adapter retained for pure tests and non-worklet callers.
|
|
102
|
+
* UI gesture handlers use `reducePointerCoalescer` with a SharedValue instead.
|
|
103
|
+
*/
|
|
104
|
+
export declare function createPointerCoalescer(maxMoveIntervalMs: number): PointerCoalescer;
|
|
105
|
+
export {};
|
|
106
|
+
//# sourceMappingURL=pointerCoalescer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointerCoalescer.d.ts","sourceRoot":"","sources":["../../../../src/react/pointerCoalescer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,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ED,qDAAqD;AACrD,wBAAgB,2BAA2B,CACzC,iBAAiB,EAAE,MAAM,GACxB,qBAAqB,CAGvB;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,qBAAqB,GAC3B,0BAA0B,CA4G5B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,iBAAiB,EAAE,MAAM,GAAG,gBAAgB,CAuBlF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI-side containment mirror (T7).
|
|
3
|
+
*
|
|
4
|
+
* The exact same viewport formula the JS binding uses to reject begins in
|
|
5
|
+
* `fit` letterbox space, workletized so the Manual gesture can fail before
|
|
6
|
+
* activation. JS re-validates on receipt; this mirror only prevents an
|
|
7
|
+
* obviously invalid begin from activating the gesture at all.
|
|
8
|
+
*/
|
|
9
|
+
import type { ResolvedViewport2D } from '../viewport2d/index.js';
|
|
10
|
+
/** Whether a surface point may begin a gesture in the interactive content. */
|
|
11
|
+
export declare function isBeginAllowed(viewport: ResolvedViewport2D | undefined, x: number, y: number): boolean;
|
|
12
|
+
//# sourceMappingURL=pointerContainment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointerContainment.d.ts","sourceRoot":"","sources":["../../../../src/react/pointerContainment.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAe,CAAC;AAExD,8EAA8E;AAC9E,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,kBAAkB,GAAG,SAAS,EACxC,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,OAAO,CAOT"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GameSprite` — the common GameKit sprite integration (T7.6).
|
|
3
|
+
*
|
|
4
|
+
* Accepts the renderer's commit/alpha shared values, narrows the snapshot
|
|
5
|
+
* by `scene`, invokes one worklet `select` mapper, and drives the
|
|
6
|
+
* underlying `Sprite` through coherent derived values. The selector's scene
|
|
7
|
+
* typing is exact — a `scene="play"` selector receives only the play
|
|
8
|
+
* snapshot without casts.
|
|
9
|
+
*/
|
|
10
|
+
import { type SharedValue } from 'react-native-reanimated';
|
|
11
|
+
import type { CommitFrame } from '../../core/session/types.js';
|
|
12
|
+
import type { SceneSnapshot } from '../../scene/types.js';
|
|
13
|
+
import type { SceneMap } from '../../definition/types.js';
|
|
14
|
+
import type { LoadedImage, LoadedSpriteSheet } from '../../assets/types.js';
|
|
15
|
+
/** Interpolation context for the select mapper. */
|
|
16
|
+
export interface GameSpriteSelectContext<TScenes extends SceneMap, TSceneName extends Extract<keyof TScenes, string>> {
|
|
17
|
+
/** The previous commit's snapshot for the selected scene. */
|
|
18
|
+
readonly previous: SceneSnapshot<TScenes[TSceneName]>;
|
|
19
|
+
/** The current commit's snapshot for the selected scene. */
|
|
20
|
+
readonly current: SceneSnapshot<TScenes[TSceneName]>;
|
|
21
|
+
/** Presentation interpolation alpha in [0, 1]. */
|
|
22
|
+
readonly alpha: number;
|
|
23
|
+
}
|
|
24
|
+
/** The discrete + interpolated presentation selection. */
|
|
25
|
+
export interface GameSpriteSelection {
|
|
26
|
+
/** World position (interpolated when the selector requests it). */
|
|
27
|
+
readonly x: number;
|
|
28
|
+
readonly y: number;
|
|
29
|
+
/** Rotation in radians around the anchor. */
|
|
30
|
+
readonly rotation?: number;
|
|
31
|
+
/** Uniform scale around the anchor. */
|
|
32
|
+
readonly scale?: number;
|
|
33
|
+
/** The clip to select from the sprite sheet (discrete). */
|
|
34
|
+
readonly clip?: string;
|
|
35
|
+
/** Elapsed time within the clip in milliseconds (discrete). */
|
|
36
|
+
readonly elapsedMs?: number;
|
|
37
|
+
/** The exact frame name (discrete; overrides clip + elapsedMs). */
|
|
38
|
+
readonly frame?: string;
|
|
39
|
+
/** Explicit flips (discrete). */
|
|
40
|
+
readonly flipX?: boolean;
|
|
41
|
+
readonly flipY?: boolean;
|
|
42
|
+
/** Opacity in [0, 1]. */
|
|
43
|
+
readonly opacity?: number;
|
|
44
|
+
/** Hide the sprite. */
|
|
45
|
+
readonly visible?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface GameSpriteProps<TScenes extends SceneMap, TSceneName extends Extract<keyof TScenes, string>> {
|
|
48
|
+
/** The scene whose snapshot the selector reads. */
|
|
49
|
+
readonly scene: TSceneName;
|
|
50
|
+
/** The renderer's latest commit. */
|
|
51
|
+
readonly commit: SharedValue<CommitFrame<TScenes>>;
|
|
52
|
+
/** The renderer's presentation alpha. */
|
|
53
|
+
readonly alpha: SharedValue<number>;
|
|
54
|
+
/** The loaded asset; the renderer borrows and never disposes it. */
|
|
55
|
+
readonly source: LoadedImage | LoadedSpriteSheet;
|
|
56
|
+
/** Normalized anchor in [0, 1] relative to the selected frame. */
|
|
57
|
+
readonly anchor?: {
|
|
58
|
+
readonly x: number;
|
|
59
|
+
readonly y: number;
|
|
60
|
+
};
|
|
61
|
+
/** Worklet mapper from the scene snapshots to presentation values. */
|
|
62
|
+
readonly select: (context: GameSpriteSelectContext<TScenes, TSceneName>) => GameSpriteSelection;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Select the frame name for a clip + elapsed time (loop/once semantics).
|
|
66
|
+
* Reads the descriptor's animation table; the result is resolved against
|
|
67
|
+
* the frame rectangles by the caller. Reuses the pure sampler's semantics.
|
|
68
|
+
*/
|
|
69
|
+
export declare function spriteFrameNameForClip(animations: Readonly<Record<string, {
|
|
70
|
+
readonly frames: readonly string[];
|
|
71
|
+
readonly frameDurationMs: number;
|
|
72
|
+
readonly mode: 'loop' | 'once';
|
|
73
|
+
}>>, clip: string, elapsedMs: number): string;
|
|
74
|
+
export declare function GameSprite<TScenes extends SceneMap, TSceneName extends Extract<keyof TScenes, string>>({ scene, commit, alpha, source, anchor, select, }: GameSpriteProps<TScenes, TSceneName>): import("react").JSX.Element;
|
|
75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AQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC,CACF,CACF,EACD,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,MAAM,CAaR;AAED,wBAAgB,UAAU,CACxB,OAAO,SAAS,QAAQ,EACxB,UAAU,SAAS,OAAO,CAAC,MAAM,OAAO,EAAE,MAAM,CAAC,EACjD,EACA,KAAK,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,GACP,EAAE,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,+BA4EtC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GameWorld2D` — the viewport transform group (T7.6).
|
|
3
|
+
*
|
|
4
|
+
* Applies the resolved viewport offset/scale exactly once to all child
|
|
5
|
+
* sprites. It adds no camera state, subscribes no React per frame, and is
|
|
6
|
+
* not a camera API. Raw Skia nodes may be nested inside.
|
|
7
|
+
*/
|
|
8
|
+
import type { ReactNode } from 'react';
|
|
9
|
+
import { type SharedValue } from 'react-native-reanimated';
|
|
10
|
+
import type { ResolvedViewport2D } from '../../viewport2d/types.js';
|
|
11
|
+
/**
|
|
12
|
+
* The viewport transform as a Skia element list:
|
|
13
|
+
* `T(offset) · S(scale)` — logical units map to surface points.
|
|
14
|
+
*/
|
|
15
|
+
export declare function viewportTransform(viewport: ResolvedViewport2D | undefined): readonly ({
|
|
16
|
+
readonly translateX: number;
|
|
17
|
+
} | {
|
|
18
|
+
readonly translateY: number;
|
|
19
|
+
} | {
|
|
20
|
+
readonly scaleX: number;
|
|
21
|
+
} | {
|
|
22
|
+
readonly scaleY: number;
|
|
23
|
+
})[];
|
|
24
|
+
export declare function GameWorld2D({ viewport, children, }: {
|
|
25
|
+
/** The resolved viewport shared value supplied to the renderer. */
|
|
26
|
+
readonly viewport: SharedValue<ResolvedViewport2D | undefined>;
|
|
27
|
+
readonly children: ReactNode;
|
|
28
|
+
}): import("react").JSX.Element;
|
|
29
|
+
//# sourceMappingURL=GameWorld2D.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GameWorld2D.d.ts","sourceRoot":"","sources":["../../../../../src/react/sprites/GameWorld2D.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAAwB,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,GAAG,SAAS,CAClF;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAC9B,EAAE,CAWF;AAED,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;IAC/D,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC9B,+BAGA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type SamplingOptions } from '@shopify/react-native-skia';
|
|
2
|
+
import { type SharedValue } from 'react-native-reanimated';
|
|
3
|
+
import type { LoadedImage, LoadedSpriteSheet } from '../../assets/types.js';
|
|
4
|
+
export { resolveSpriteFrameRect, type SpriteFrameRect } from './spriteTransform.js';
|
|
5
|
+
export type SpriteAnimatable = number | SharedValue<number>;
|
|
6
|
+
export type SpriteAnimatableBoolean = boolean | SharedValue<boolean>;
|
|
7
|
+
export type SpriteAnimatableString = string | SharedValue<string>;
|
|
8
|
+
export interface SpriteProps {
|
|
9
|
+
/** The loaded asset; the renderer borrows and never disposes it. */
|
|
10
|
+
readonly source: LoadedImage | LoadedSpriteSheet;
|
|
11
|
+
/** Frame name for sprite sheets; ignored for full images. A shared value
|
|
12
|
+
* may carry undefined while the selection has not been published. */
|
|
13
|
+
readonly frame?: SpriteAnimatableString | SharedValue<string | undefined>;
|
|
14
|
+
/** Clip name for sprite sheets; the frame is selected from it. */
|
|
15
|
+
readonly clip?: SpriteAnimatableString;
|
|
16
|
+
/** Elapsed milliseconds within the clip (frame selection). */
|
|
17
|
+
readonly elapsedMs?: SpriteAnimatable;
|
|
18
|
+
/** World position in logical units. */
|
|
19
|
+
readonly x?: SpriteAnimatable;
|
|
20
|
+
readonly y?: SpriteAnimatable;
|
|
21
|
+
/** Rotation in radians around the anchor. */
|
|
22
|
+
readonly rotation?: SpriteAnimatable;
|
|
23
|
+
/** Uniform scale around the anchor. */
|
|
24
|
+
readonly scale?: SpriteAnimatable;
|
|
25
|
+
/** Normalized anchor in [0, 1] relative to the selected frame. */
|
|
26
|
+
readonly anchor?: {
|
|
27
|
+
readonly x: number;
|
|
28
|
+
readonly y: number;
|
|
29
|
+
};
|
|
30
|
+
/** Explicit flips preserve the anchor. */
|
|
31
|
+
readonly flipX?: SpriteAnimatableBoolean;
|
|
32
|
+
readonly flipY?: SpriteAnimatableBoolean;
|
|
33
|
+
/** Opacity in [0, 1]. */
|
|
34
|
+
readonly opacity?: SpriteAnimatable;
|
|
35
|
+
/** Optional tint color applied to the draw. */
|
|
36
|
+
readonly tint?: string;
|
|
37
|
+
/** Sampling for the texture; pixel-art defaults to nearest. */
|
|
38
|
+
readonly sampling?: SamplingOptions;
|
|
39
|
+
/** Hide the sprite without unmounting it. */
|
|
40
|
+
readonly visible?: SpriteAnimatableBoolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function Sprite({ source, frame, clip, elapsedMs, x, y, rotation, scale, anchor, flipX, flipY, opacity, tint, sampling, visible, }: SpriteProps): import("react").JSX.Element;
|
|
43
|
+
//# sourceMappingURL=Sprite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sprite.d.ts","sourceRoot":"","sources":["../../../../../src/react/sprites/Sprite.tsx"],"names":[],"mappings":"AAYA,OAAO,EAA8B,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG5E,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,uBAAoB,CAAC;AAQzE,OAAO,EAAE,sBAAsB,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAmB,CAAC;AAEjF,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAC5D,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AACrE,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAElE,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,iBAAiB,CAAC;IACjD;yEACqE;IACrE,QAAQ,CAAC,KAAK,CAAC,EAAE,sBAAsB,GAAG,WAAW,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC1E,kEAAkE;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,sBAAsB,CAAC;IACvC,8DAA8D;IAC9D,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IACtC,uCAAuC;IACvC,QAAQ,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC;IAC9B,QAAQ,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC;IAC9B,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IACrC,uCAAuC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAClC,kEAAkE;IAClE,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,uBAAuB,CAAC;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,uBAAuB,CAAC;IACzC,yBAAyB;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC;IACpC,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,CAAC,EAAE,uBAAuB,CAAC;CAC5C;AAED,wBAAgB,MAAM,CAAC,EACrB,MAAM,EACN,KAAK,EACL,IAAI,EACJ,SAAa,EACb,CAAK,EACL,CAAK,EACL,QAAY,EACZ,KAAS,EACT,MAAuB,EACvB,KAAa,EACb,KAAa,EACb,OAAW,EACX,IAAI,EACJ,QAAQ,EACR,OAAc,GACf,EAAE,WAAW,+BAmHb"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type SharedValue } from 'react-native-reanimated';
|
|
2
|
+
import type { CommitFrame } from '../../core/session/types.js';
|
|
3
|
+
import type { SceneSnapshot } from '../../scene/types.js';
|
|
4
|
+
import type { SceneMap } from '../../definition/types.js';
|
|
5
|
+
import type { LoadedImage, LoadedSpriteSheet } from '../../assets/types.js';
|
|
6
|
+
/** The per-item write surface handed to the author's `write` mapper. */
|
|
7
|
+
export interface SpriteBatchWrite {
|
|
8
|
+
/**
|
|
9
|
+
* Write one batch slot. `frame` names the sheet frame; `x`/`y` are world
|
|
10
|
+
* logical units; `rotation` is radians around the batch anchor; `scale`
|
|
11
|
+
* is uniform; `visible: false` hides the slot (zero-size rect). Writes
|
|
12
|
+
* past capacity fail in development.
|
|
13
|
+
*/
|
|
14
|
+
readonly set: (index: number, frame: string, x: number, y: number, rotation: number, scale: number, visible?: boolean) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface SpriteBatchProps<TScenes extends SceneMap, TSceneName extends Extract<keyof TScenes, string>, TItem> {
|
|
17
|
+
/** The scene whose snapshot `select` reads. */
|
|
18
|
+
readonly scene: TSceneName;
|
|
19
|
+
/** The renderer's latest commit. */
|
|
20
|
+
readonly commit: SharedValue<CommitFrame<TScenes>>;
|
|
21
|
+
/** The renderer's presentation alpha. */
|
|
22
|
+
readonly alpha: SharedValue<number>;
|
|
23
|
+
/** One decoded sheet shared by every instance. */
|
|
24
|
+
readonly source: LoadedImage | LoadedSpriteSheet;
|
|
25
|
+
/** Fixed slot capacity for the mounted batch. */
|
|
26
|
+
readonly capacity: number;
|
|
27
|
+
/** Map the committed snapshot to the item array. */
|
|
28
|
+
readonly select: (context: {
|
|
29
|
+
readonly current: SceneSnapshot<TScenes[TSceneName]>;
|
|
30
|
+
readonly alpha: number;
|
|
31
|
+
}) => readonly TItem[];
|
|
32
|
+
/** Write each item into its batch slot (UI runtime). */
|
|
33
|
+
readonly write: (write: SpriteBatchWrite, item: TItem, index: number) => void;
|
|
34
|
+
/** Uniform anchor in [0, 1] relative to the selected frame. */
|
|
35
|
+
readonly anchor?: {
|
|
36
|
+
readonly x: number;
|
|
37
|
+
readonly y: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export declare function SpriteBatch<TScenes extends SceneMap, TSceneName extends Extract<keyof TScenes, string>, TItem>({ scene, commit, alpha, source, capacity, select, write, anchor, }: SpriteBatchProps<TScenes, TSceneName, TItem>): import("react").JSX.Element;
|
|
41
|
+
//# sourceMappingURL=SpriteBatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpriteBatch.d.ts","sourceRoot":"","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,CAAC,UAAU,CAAC,CAAC,CAAC;QACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACxB,KAAK,SAAS,KAAK,EAAE,CAAC;IACvB,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9E,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9D;AAcD,wBAAgB,WAAW,CACzB,OAAO,SAAS,QAAQ,EACxB,UAAU,SAAS,OAAO,CAAC,MAAM,OAAO,EAAE,MAAM,CAAC,EACjD,KAAK,EACL,EACA,KAAK,EACL,MAAM,EACN,KAAK,EACL,MAAM,EACN,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAuB,GACxB,EAAE,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,+BAuH9C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Pure SpriteBatch update policy (RF8): the overflow decision and the
|
|
2
|
+
* active count. Development reports a structured error; production clamps
|
|
3
|
+
* and hides the overflow so the UI runtime never crashes for ordinary data
|
|
4
|
+
* growth. Runs inside the batch's update worklet, so it carries the worklet
|
|
5
|
+
* directive. */
|
|
6
|
+
export declare function batchUpdatePolicy(itemsCount: number, capacity: number, dev: boolean): {
|
|
7
|
+
readonly overflow: boolean;
|
|
8
|
+
readonly activeCount: number;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=spriteBatchPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spriteBatchPolicy.d.ts","sourceRoot":"","sources":["../../../../../src/react/sprites/spriteBatchPolicy.ts"],"names":[],"mappings":"AAAA;;;;gBAIgB;AAChB,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,OAAO,GACX;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAW9D"}
|