@flare-engine/react 0.3.1 → 0.4.1
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/README.md +10 -2
- package/dist/index.d.mts +17 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +17 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -5,10 +5,18 @@ React Native integration — `<GameView>` (Skia Canvas + game loop + input), `<V
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
bun add @flare-engine/react @shopify/react-native-skia react-native-safe-area-context
|
|
8
|
+
bun add @flare-engine/react @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-safe-area-context
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Peer deps: `react` (>=19), `react-native` (>=0.79), `@shopify/react-native-skia` (>=2), `react-native-safe-area-context` (>=4).
|
|
11
|
+
Peer deps: `react` (>=19), `react-native` (>=0.79), `@shopify/react-native-skia` (>=2), `react-native-reanimated` (>=4), `react-native-worklets` (>=0.7), `react-native-safe-area-context` (>=4). `react-native-reanimated`, `react-native-worklets` and `react-native-safe-area-context` are all value imports in `<GameView>` — a project without any of them fails to resolve at runtime.
|
|
12
|
+
|
|
13
|
+
> **The New Architecture is required.** Reanimated 4 is New-Architecture-only, so an app using
|
|
14
|
+
> `<GameView>` must run with `newArchEnabled=true`. This costs nothing in practice — it has been
|
|
15
|
+
> RN's default since 0.76, and every `@flare-engine/create` template pins Expo 57 / RN 0.86, which
|
|
16
|
+
> force it on. Old-architecture support was dropped deliberately in
|
|
17
|
+
> [ADR-0002](https://github.com/grzott/flare-engine/blob/main/docs/design/adr-0002-worklets-migration-and-new-arch-floor.md):
|
|
18
|
+
> the previous `>=3.19.1` floor promised something no scaffolder template could produce, so it was
|
|
19
|
+
> never verifiable.
|
|
12
20
|
|
|
13
21
|
## Usage
|
|
14
22
|
|
package/dist/index.d.mts
CHANGED
|
@@ -71,7 +71,7 @@ interface PostFxPassDescriptor {
|
|
|
71
71
|
readonly uniforms: Record<string, number | readonly number[]>;
|
|
72
72
|
/**
|
|
73
73
|
* Extra child shader slots beyond the implicit scene sampler. Empty for every
|
|
74
|
-
* built-in
|
|
74
|
+
* built-in effect; only color-grading-lut would populate it. Each entry
|
|
75
75
|
* is an SkImage that GameView wraps in `<ImageShader>`.
|
|
76
76
|
*/
|
|
77
77
|
readonly children: readonly SkImage[];
|
|
@@ -203,8 +203,19 @@ interface GameConfig {
|
|
|
203
203
|
* RN siblings on certain Android devices/Fabric configurations.
|
|
204
204
|
*
|
|
205
205
|
* Implies the canvas content is opaque — the clearColor's alpha must be
|
|
206
|
-
* fully opaque (0xFF)
|
|
207
|
-
* iOS-equivalent behavior.
|
|
206
|
+
* fully opaque (0xFF), which the default `0xff000000` already satisfies.
|
|
207
|
+
* Defaults to `false` to preserve the current iOS-equivalent behavior.
|
|
208
|
+
*
|
|
209
|
+
* **Recommended on Android.** Measured on a Pixel 7 (Android 17, release
|
|
210
|
+
* build, XR-1c): with the default TextureView path RN-Skia logs its
|
|
211
|
+
* `updateTexImage: LegacySurfaceTexture is not attached!` /
|
|
212
|
+
* `updateAndRelease() failed` pair **22 028 times per 60 s** — 90% of all
|
|
213
|
+
* logcat output, saturating the 256 KiB ring buffer so unrelated diagnostics
|
|
214
|
+
* are lost. With `opaque: true` the same build over three 60 s windows logs
|
|
215
|
+
* the pair **zero** times and total log volume drops ~10x. RN-Skia labels the
|
|
216
|
+
* pair ignorable and rendering is correct either way, so this is log noise
|
|
217
|
+
* and TextureView overhead, not a correctness fix. Native memory is flat
|
|
218
|
+
* across a 6-minute soak on both paths.
|
|
208
219
|
*/
|
|
209
220
|
opaque?: boolean;
|
|
210
221
|
}
|
|
@@ -218,9 +229,9 @@ interface GameViewProps {
|
|
|
218
229
|
style?: ViewStyle;
|
|
219
230
|
/** Optional overlay children (e.g. VirtualJoystick, VirtualButton). */
|
|
220
231
|
children?: React.ReactNode;
|
|
221
|
-
/** Explicit safe-area insets. If omitted, resolved
|
|
222
|
-
*
|
|
223
|
-
*
|
|
232
|
+
/** Explicit safe-area insets. If omitted, resolved via `useContext(SafeAreaInsetsContext)`
|
|
233
|
+
* from react-native-safe-area-context; falls back to `{ top: 0, right: 0, bottom: 0,
|
|
234
|
+
* left: 0 }` when no `<SafeAreaProvider>` ancestor is mounted. */
|
|
224
235
|
safeArea?: SafeArea;
|
|
225
236
|
}
|
|
226
237
|
/**
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/game-context.ts","../src/skia-bridge.ts","../src/safe-area.ts","../src/game-view.tsx","../src/hooks.ts","../src/loading-screen.tsx","../src/overlay-hooks.ts","../src/skia-atlas.ts","../src/virtual-button.tsx","../src/virtual-joystick.tsx"],"mappings":";;;;;;;;;;;;;UAUiB;;EAEf,OAAO;;EAEP,QAAQ;;EAER,OAAO;;EAEP,OAAO;;EAEP,QAAQ;;EAER,QAAQ;;EAER,MAAM;;EAEN,UAAU;;EAEV,OAAO;;;;;;cAOI,6BAAW,QAAA;;;;UCrBP;EACf,YAAY;EACZ,cAAc,gBAAgB,cAAc,cAAc;EAC1D,SAAS,eAAe;EACxB,MAAM;;;UAIS;EACf,aAAa;EACb,qBAAqB;;;;EAIrB;;;;;;UAOe;;WAEN;;WAEA,QAAQ;;;;;;WAMR,UAAU;;;;;;WAMV,mBAAmB;;;UAuBb;WACN;WACA;WACA;WACA;;WAEA;;;UAIM;WACN;WACA;;WAEA;WACA,iBAAiB;;;;;;;;;;KAWhB,iBAAiB;EAC3B;IAAkB,KAAK,eAAe;;EACtC;IACE,KAAK,eAAe,iBAAiB;IACrC,eAAe,eAAe,iBAAiB;;;EAGjD;IACE,eACE,YACA,YACA,gBACA,gBACA,OAAO,SACP,OAAO,uBACN;;;;;;;KAQK,mBAAmB;;;;;KAMnB,oBAAoB;;KAGpB,kBAAkB;;;;;;KAOlB,oBAAoB;;;;;;;;;;;iBAYhB,wBAAwB,MAAM,iBAAiB;;;;;;;iBAc/C,oBACd,MAAM,gBACN,MAAM,mBACL;;;UCtKc;EACf;EACA;EACA;EACA;;cAGW,iCAAe,QAAA;iBAEZ,eAAe;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/game-context.ts","../src/skia-bridge.ts","../src/safe-area.ts","../src/game-view.tsx","../src/hooks.ts","../src/loading-screen.tsx","../src/overlay-hooks.ts","../src/skia-atlas.ts","../src/virtual-button.tsx","../src/virtual-joystick.tsx"],"mappings":";;;;;;;;;;;;;UAUiB;;EAEf,OAAO;;EAEP,QAAQ;;EAER,OAAO;;EAEP,OAAO;;EAEP,QAAQ;;EAER,QAAQ;;EAER,MAAM;;EAEN,UAAU;;EAEV,OAAO;;;;;;cAOI,6BAAW,QAAA;;;;UCrBP;EACf,YAAY;EACZ,cAAc,gBAAgB,cAAc,cAAc;EAC1D,SAAS,eAAe;EACxB,MAAM;;;UAIS;EACf,aAAa;EACb,qBAAqB;;;;EAIrB;;;;;;UAOe;;WAEN;;WAEA,QAAQ;;;;;;WAMR,UAAU;;;;;;WAMV,mBAAmB;;;UAuBb;WACN;WACA;WACA;WACA;;WAEA;;;UAIM;WACN;WACA;;WAEA;WACA,iBAAiB;;;;;;;;;;KAWhB,iBAAiB;EAC3B;IAAkB,KAAK,eAAe;;EACtC;IACE,KAAK,eAAe,iBAAiB;IACrC,eAAe,eAAe,iBAAiB;;;EAGjD;IACE,eACE,YACA,YACA,gBACA,gBACA,OAAO,SACP,OAAO,uBACN;;;;;;;KAQK,mBAAmB;;;;;KAMnB,oBAAoB;;KAGpB,kBAAkB;;;;;;KAOlB,oBAAoB;;;;;;;;;;;iBAYhB,wBAAwB,MAAM,iBAAiB;;;;;;;iBAc/C,oBACd,MAAM,gBACN,MAAM,mBACL;;;UCtKc;EACf;EACA;EACA;EACA;;cAGW,iCAAe,QAAA;iBAEZ,eAAe;;;;;;;KCuDnB,cAAc,KAAK,kBAAkB;;;;;;;KAQrC,oBACV,KAAK,kBACL,iBACA,QAFK;;UAMU;;EAEf;;EAEA;;EAEA;;EAEA,cAAc;;;EAGd,qBAAqB;;;;;EAKrB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BjB;;;UAIe;;EAEf,SAAS;;EAET,WAAW,KAAK;;EAEhB,QAAQ;;EAER,WAAW,MAAM;;;;EAIjB,WAAW;;;;;;;;;iBAUG,WACd,QACA,SACA,OACA,UACA,YACC,gBAAgB,MAAM;;;;;;;iBCnJT,WAAW;;;;;;;iBAcX,UAAU,OAAO;;;;;;;;iBA4BjB,YAAY,WAAW;;;;UC7CtB;;EAEf;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;;;;;;;;;;iBAWc,gBACd,UACA,OACA,UACA,YACA,mBACC,qBAAqB,MAAM;;;iBC5Bd,eAAe,kBAAkB;iBAoCjC,WAAW,gBAAgB;iBAmC3B,eAAe,GAAG,QAAQ,OAAO,IAAI,SAAS,IAAI;;;;;;;cCpErD,iBAAiB;;;;UCMb;;EAEf,iBAAiB,OAAO;;EAExB,QAAQ;;EAER,WAAW,MAAM;;;;;;;;;iBAUH,gBACd,eACA,OACA,YACC,qBAAqB,MAAM;;;;UCpBb;;EAEf,SAAS;;EAET,iBAAiB,OAAO;;EAExB,QAAQ;;EAER,OAAO,MAAM;;EAEb,QAAQ,MAAM;;;;;;;;;iBAUA,kBACd,QACA,eACA,OACA,MACA,SACC,uBAAuB,MAAM"}
|
package/dist/index.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ interface PostFxPassDescriptor {
|
|
|
71
71
|
readonly uniforms: Record<string, number | readonly number[]>;
|
|
72
72
|
/**
|
|
73
73
|
* Extra child shader slots beyond the implicit scene sampler. Empty for every
|
|
74
|
-
* built-in
|
|
74
|
+
* built-in effect; only color-grading-lut would populate it. Each entry
|
|
75
75
|
* is an SkImage that GameView wraps in `<ImageShader>`.
|
|
76
76
|
*/
|
|
77
77
|
readonly children: readonly SkImage[];
|
|
@@ -203,8 +203,19 @@ interface GameConfig {
|
|
|
203
203
|
* RN siblings on certain Android devices/Fabric configurations.
|
|
204
204
|
*
|
|
205
205
|
* Implies the canvas content is opaque — the clearColor's alpha must be
|
|
206
|
-
* fully opaque (0xFF)
|
|
207
|
-
* iOS-equivalent behavior.
|
|
206
|
+
* fully opaque (0xFF), which the default `0xff000000` already satisfies.
|
|
207
|
+
* Defaults to `false` to preserve the current iOS-equivalent behavior.
|
|
208
|
+
*
|
|
209
|
+
* **Recommended on Android.** Measured on a Pixel 7 (Android 17, release
|
|
210
|
+
* build, XR-1c): with the default TextureView path RN-Skia logs its
|
|
211
|
+
* `updateTexImage: LegacySurfaceTexture is not attached!` /
|
|
212
|
+
* `updateAndRelease() failed` pair **22 028 times per 60 s** — 90% of all
|
|
213
|
+
* logcat output, saturating the 256 KiB ring buffer so unrelated diagnostics
|
|
214
|
+
* are lost. With `opaque: true` the same build over three 60 s windows logs
|
|
215
|
+
* the pair **zero** times and total log volume drops ~10x. RN-Skia labels the
|
|
216
|
+
* pair ignorable and rendering is correct either way, so this is log noise
|
|
217
|
+
* and TextureView overhead, not a correctness fix. Native memory is flat
|
|
218
|
+
* across a 6-minute soak on both paths.
|
|
208
219
|
*/
|
|
209
220
|
opaque?: boolean;
|
|
210
221
|
}
|
|
@@ -218,9 +229,9 @@ interface GameViewProps {
|
|
|
218
229
|
style?: ViewStyle;
|
|
219
230
|
/** Optional overlay children (e.g. VirtualJoystick, VirtualButton). */
|
|
220
231
|
children?: React.ReactNode;
|
|
221
|
-
/** Explicit safe-area insets. If omitted, resolved
|
|
222
|
-
*
|
|
223
|
-
*
|
|
232
|
+
/** Explicit safe-area insets. If omitted, resolved via `useContext(SafeAreaInsetsContext)`
|
|
233
|
+
* from react-native-safe-area-context; falls back to `{ top: 0, right: 0, bottom: 0,
|
|
234
|
+
* left: 0 }` when no `<SafeAreaProvider>` ancestor is mounted. */
|
|
224
235
|
safeArea?: SafeArea;
|
|
225
236
|
}
|
|
226
237
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/game-context.ts","../src/skia-bridge.ts","../src/safe-area.ts","../src/game-view.tsx","../src/hooks.ts","../src/loading-screen.tsx","../src/overlay-hooks.ts","../src/skia-atlas.ts","../src/virtual-button.tsx","../src/virtual-joystick.tsx"],"mappings":";;;;;;;;;;;;;UAUiB;;EAEf,OAAO;;EAEP,QAAQ;;EAER,OAAO;;EAEP,OAAO;;EAEP,QAAQ;;EAER,QAAQ;;EAER,MAAM;;EAEN,UAAU;;EAEV,OAAO;;;;;;cAOI,6BAAW,QAAA;;;;UCrBP;EACf,YAAY;EACZ,cAAc,gBAAgB,cAAc,cAAc;EAC1D,SAAS,eAAe;EACxB,MAAM;;;UAIS;EACf,aAAa;EACb,qBAAqB;;;;EAIrB;;;;;;UAOe;;WAEN;;WAEA,QAAQ;;;;;;WAMR,UAAU;;;;;;WAMV,mBAAmB;;;UAuBb;WACN;WACA;WACA;WACA;;WAEA;;;UAIM;WACN;WACA;;WAEA;WACA,iBAAiB;;;;;;;;;;KAWhB,iBAAiB;EAC3B;IAAkB,KAAK,eAAe;;EACtC;IACE,KAAK,eAAe,iBAAiB;IACrC,eAAe,eAAe,iBAAiB;;;EAGjD;IACE,eACE,YACA,YACA,gBACA,gBACA,OAAO,SACP,OAAO,uBACN;;;;;;;KAQK,mBAAmB;;;;;KAMnB,oBAAoB;;KAGpB,kBAAkB;;;;;;KAOlB,oBAAoB;;;;;;;;;;;iBAYhB,wBAAwB,MAAM,iBAAiB;;;;;;;iBAc/C,oBACd,MAAM,gBACN,MAAM,mBACL;;;UCtKc;EACf;EACA;EACA;EACA;;cAGW,iCAAe,QAAA;iBAEZ,eAAe;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/game-context.ts","../src/skia-bridge.ts","../src/safe-area.ts","../src/game-view.tsx","../src/hooks.ts","../src/loading-screen.tsx","../src/overlay-hooks.ts","../src/skia-atlas.ts","../src/virtual-button.tsx","../src/virtual-joystick.tsx"],"mappings":";;;;;;;;;;;;;UAUiB;;EAEf,OAAO;;EAEP,QAAQ;;EAER,OAAO;;EAEP,OAAO;;EAEP,QAAQ;;EAER,QAAQ;;EAER,MAAM;;EAEN,UAAU;;EAEV,OAAO;;;;;;cAOI,6BAAW,QAAA;;;;UCrBP;EACf,YAAY;EACZ,cAAc,gBAAgB,cAAc,cAAc;EAC1D,SAAS,eAAe;EACxB,MAAM;;;UAIS;EACf,aAAa;EACb,qBAAqB;;;;EAIrB;;;;;;UAOe;;WAEN;;WAEA,QAAQ;;;;;;WAMR,UAAU;;;;;;WAMV,mBAAmB;;;UAuBb;WACN;WACA;WACA;WACA;;WAEA;;;UAIM;WACN;WACA;;WAEA;WACA,iBAAiB;;;;;;;;;;KAWhB,iBAAiB;EAC3B;IAAkB,KAAK,eAAe;;EACtC;IACE,KAAK,eAAe,iBAAiB;IACrC,eAAe,eAAe,iBAAiB;;;EAGjD;IACE,eACE,YACA,YACA,gBACA,gBACA,OAAO,SACP,OAAO,uBACN;;;;;;;KAQK,mBAAmB;;;;;KAMnB,oBAAoB;;KAGpB,kBAAkB;;;;;;KAOlB,oBAAoB;;;;;;;;;;;iBAYhB,wBAAwB,MAAM,iBAAiB;;;;;;;iBAc/C,oBACd,MAAM,gBACN,MAAM,mBACL;;;UCtKc;EACf;EACA;EACA;EACA;;cAGW,iCAAe,QAAA;iBAEZ,eAAe;;;;;;;KCuDnB,cAAc,KAAK,kBAAkB;;;;;;;KAQrC,oBACV,KAAK,kBACL,iBACA,QAFK;;UAMU;;EAEf;;EAEA;;EAEA;;EAEA,cAAc;;;EAGd,qBAAqB;;;;;EAKrB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BjB;;;UAIe;;EAEf,SAAS;;EAET,WAAW,KAAK;;EAEhB,QAAQ;;EAER,WAAW,MAAM;;;;EAIjB,WAAW;;;;;;;;;iBAUG,WACd,QACA,SACA,OACA,UACA,YACC,gBAAgB,MAAM;;;;;;;iBCnJT,WAAW;;;;;;;iBAcX,UAAU,OAAO;;;;;;;;iBA4BjB,YAAY,WAAW;;;;UC7CtB;;EAEf;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;;;;;;;;;;iBAWc,gBACd,UACA,OACA,UACA,YACA,mBACC,qBAAqB,MAAM;;;iBC5Bd,eAAe,kBAAkB;iBAoCjC,WAAW,gBAAgB;iBAmC3B,eAAe,GAAG,QAAQ,OAAO,IAAI,SAAS,IAAI;;;;;;;cCpErD,iBAAiB;;;;UCMb;;EAEf,iBAAiB,OAAO;;EAExB,QAAQ;;EAER,WAAW,MAAM;;;;;;;;;iBAUH,gBACd,eACA,OACA,YACC,qBAAqB,MAAM;;;;UCpBb;;EAEf,SAAS;;EAET,iBAAiB,OAAO;;EAExB,QAAQ;;EAER,OAAO,MAAM;;EAEb,QAAQ,MAAM;;;;;;;;;iBAUA,kBACd,QACA,eACA,OACA,MACA,SACC,uBAAuB,MAAM"}
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,9 @@ let _flare_engine_render = require("@flare-engine/render");
|
|
|
9
9
|
let _flare_engine_scene = require("@flare-engine/scene");
|
|
10
10
|
let _shopify_react_native_skia = require("@shopify/react-native-skia");
|
|
11
11
|
let react_native = require("react-native");
|
|
12
|
+
let react_native_reanimated = require("react-native-reanimated");
|
|
12
13
|
let react_native_safe_area_context = require("react-native-safe-area-context");
|
|
14
|
+
let react_native_worklets = require("react-native-worklets");
|
|
13
15
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
16
|
let _flare_engine_math = require("@flare-engine/math");
|
|
15
17
|
//#region src/game-context.ts
|
|
@@ -103,8 +105,9 @@ function createSceneSurfaceCache(Skia) {
|
|
|
103
105
|
* released once the ring exceeds depth 3, ensuring the canvas's rAF always has
|
|
104
106
|
* a live image to paint from.
|
|
105
107
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
function createSceneCapture(Skia, opts) {
|
|
109
|
+
const useNonTexture = opts?.nonTextureImage ?? true;
|
|
110
|
+
const retentionDepth = opts?.retentionDepth ?? 3;
|
|
108
111
|
const surfaces = createSceneSurfaceCache(Skia);
|
|
109
112
|
const ring = [];
|
|
110
113
|
return {
|
|
@@ -115,10 +118,10 @@ function createSceneCapture(Skia) {
|
|
|
115
118
|
surface.flush();
|
|
116
119
|
const snapshot = surface.makeImageSnapshot();
|
|
117
120
|
const detachable = snapshot;
|
|
118
|
-
const detached = detachable.makeNonTextureImage ? detachable.makeNonTextureImage() : snapshot;
|
|
121
|
+
const detached = useNonTexture && detachable.makeNonTextureImage ? detachable.makeNonTextureImage() : snapshot;
|
|
119
122
|
if (detached !== snapshot) releaseSkiaObject(snapshot);
|
|
120
123
|
ring.push(detached);
|
|
121
|
-
if (ring.length >
|
|
124
|
+
if (ring.length > retentionDepth) releaseSkiaObject(ring.shift());
|
|
122
125
|
return detached;
|
|
123
126
|
},
|
|
124
127
|
dispose() {
|
|
@@ -128,54 +131,6 @@ function createSceneCapture(Skia) {
|
|
|
128
131
|
}
|
|
129
132
|
};
|
|
130
133
|
}
|
|
131
|
-
/**
|
|
132
|
-
* Web scene texture (imperative form): expose a `capture` callback that
|
|
133
|
-
* `GameView`'s `onPreRender` frame callback invokes directly instead of pushing
|
|
134
|
-
* a picture through React state.
|
|
135
|
-
*
|
|
136
|
-
* The previous reactive form called `setImage` from a `useEffect` keyed on
|
|
137
|
-
* `[Skia, picture, width, height]`. `onPreRender` would call `setPicture`,
|
|
138
|
-
* React would re-render, the effect would re-run, `setImage` would re-render
|
|
139
|
-
* again. That is a setState-in-a-passive-effect cascade; React's
|
|
140
|
-
* NESTED_PASSIVE_UPDATE_LIMIT (50) trips and logs `Maximum update depth
|
|
141
|
-
* exceeded` on every web load. It also costs two React renders per frame and
|
|
142
|
-
* delays the captured image by two hops.
|
|
143
|
-
*
|
|
144
|
-
* `GameLoop` schedules via `requestAnimationFrame`, so calling `setImage`
|
|
145
|
-
* directly from `onPreRender` is an ordinary root update that never touches the
|
|
146
|
-
* passive-update counter. Both hooks still run on both platforms so hook order
|
|
147
|
-
* never varies, but this hook is now inert on native simply because nothing
|
|
148
|
-
* calls `capture` on that platform.
|
|
149
|
-
*
|
|
150
|
-
* `makeNonTextureImage()` is required regardless of reuse: the offscreen surface
|
|
151
|
-
* has its own WebGL context, and a texture-backed image cannot be sampled by the
|
|
152
|
-
* on-screen canvas's context. It also makes reuse safe — the snapshot is copied
|
|
153
|
-
* off the GPU so next frame's draw into the same surface cannot disturb the image
|
|
154
|
-
* React still holds.
|
|
155
|
-
*
|
|
156
|
-
* The surface is never cleared here: `Renderer.begin()` records
|
|
157
|
-
* `canvas.clear(clearColor)` into the picture itself (packages/render
|
|
158
|
-
* `renderer.ts:75`), so replaying the picture repaints the full surface.
|
|
159
|
-
*/
|
|
160
|
-
function useWebSceneTexture(Skia) {
|
|
161
|
-
const captureRef = (0, react.useRef)(null);
|
|
162
|
-
const [image, setImage] = (0, react.useState)(null);
|
|
163
|
-
(0, react.useEffect)(() => {
|
|
164
|
-
return () => {
|
|
165
|
-
captureRef.current?.dispose();
|
|
166
|
-
captureRef.current = null;
|
|
167
|
-
};
|
|
168
|
-
}, []);
|
|
169
|
-
return {
|
|
170
|
-
image,
|
|
171
|
-
capture: (0, react.useCallback)((picture, width, height) => {
|
|
172
|
-
if (picture === null || picture === void 0) return;
|
|
173
|
-
if (captureRef.current === null) captureRef.current = createSceneCapture(Skia);
|
|
174
|
-
const next = captureRef.current.capture(picture, width, height);
|
|
175
|
-
if (next !== null) setImage(next);
|
|
176
|
-
}, [Skia])
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
134
|
//#endregion
|
|
180
135
|
//#region src/skia-bridge.ts
|
|
181
136
|
/**
|
|
@@ -240,6 +195,38 @@ function unpackArgb(out, argb) {
|
|
|
240
195
|
//#endregion
|
|
241
196
|
//#region src/game-view.tsx
|
|
242
197
|
/**
|
|
198
|
+
* Capture the frame's picture into an offscreen surface **on the UI thread**.
|
|
199
|
+
*
|
|
200
|
+
* The thread is the entire point, and getting it wrong is invisible to every
|
|
201
|
+
* test in this repo. RN-Skia's own `usePictureAsTexture` does exactly this work
|
|
202
|
+
* inside `runOnUI` (`external/reanimated/textures.ts`), and it must: a surface
|
|
203
|
+
* built on the JS thread belongs to a different GL context than the on-screen
|
|
204
|
+
* `<Canvas>`, so the `<Image>` samples nothing and the app renders a black
|
|
205
|
+
* frame while the game loop runs happily. Building the surface here — same
|
|
206
|
+
* thread, same context as the canvas that samples it — is what makes the
|
|
207
|
+
* snapshot drawable without a `makeNonTextureImage()` GPU→CPU readback.
|
|
208
|
+
*
|
|
209
|
+
* Verified on device (Pixel 7 / Android 17): JS-thread capture → black canvas;
|
|
210
|
+
* this path → renders. See external-review-2026-08.md §11.4b.
|
|
211
|
+
*
|
|
212
|
+
* The surface is cached across frames in a shared value rather than rebuilt per
|
|
213
|
+
* frame (RN-Skia rebuilds it every call; that is NEW-2). `surfaceKey` packs the
|
|
214
|
+
* pixel size so a viewport change reallocates exactly once.
|
|
215
|
+
*/
|
|
216
|
+
const captureSceneOnUI = (target, surfaceSV, surfaceKey, picture, w, h) => {
|
|
217
|
+
"worklet";
|
|
218
|
+
const key = w * 65536 + h;
|
|
219
|
+
if (surfaceSV.value === null || surfaceKey.value !== key) {
|
|
220
|
+
surfaceSV.value = _shopify_react_native_skia.Skia.Surface.MakeOffscreen(w, h);
|
|
221
|
+
surfaceKey.value = key;
|
|
222
|
+
}
|
|
223
|
+
const surface = surfaceSV.value;
|
|
224
|
+
if (surface === null) return;
|
|
225
|
+
surface.getCanvas().drawPicture(picture);
|
|
226
|
+
surface.flush();
|
|
227
|
+
target.value = surface.makeImageSnapshot();
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
243
230
|
* GameView — root component that sets up the Skia canvas, game loop,
|
|
244
231
|
* and all core game systems. Provides GameContext to descendants.
|
|
245
232
|
*
|
|
@@ -247,28 +234,20 @@ function unpackArgb(out, argb) {
|
|
|
247
234
|
* as children; they render on top of the Skia canvas.
|
|
248
235
|
*/
|
|
249
236
|
function GameView({ config, onReady, style, children, safeArea }) {
|
|
250
|
-
const
|
|
251
|
-
const resolvedSafeArea = safeArea ??
|
|
237
|
+
const contextInsets = (0, react.useContext)(react_native_safe_area_context.SafeAreaInsetsContext);
|
|
238
|
+
const resolvedSafeArea = safeArea ?? contextInsets ?? ZERO_INSETS;
|
|
252
239
|
const canvasRef = (0, _shopify_react_native_skia.useCanvasRef)();
|
|
253
|
-
const [picture, setPicture] = (0, react.useState)(null);
|
|
254
240
|
const [passes, setPasses] = (0, react.useState)(EMPTY_PASSES);
|
|
255
241
|
const [viewportSize, setViewportSize] = (0, react.useState)({
|
|
256
242
|
w: 0,
|
|
257
243
|
h: 0
|
|
258
244
|
});
|
|
259
245
|
const pd = react_native.PixelRatio.get();
|
|
260
|
-
const sceneSize = (0, react.useMemo)(() => ({
|
|
261
|
-
width: viewportSize.w * pd,
|
|
262
|
-
height: viewportSize.h * pd
|
|
263
|
-
}), [
|
|
264
|
-
viewportSize.w,
|
|
265
|
-
viewportSize.h,
|
|
266
|
-
pd
|
|
267
|
-
]);
|
|
268
246
|
const isWeb = react_native.Platform.OS === "web";
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
const
|
|
247
|
+
const sceneImage = (0, react_native_reanimated.useSharedValue)(null);
|
|
248
|
+
const captureRef = (0, react.useRef)(null);
|
|
249
|
+
const uiSurface = (0, react_native_reanimated.useSharedValue)(null);
|
|
250
|
+
const uiSurfaceKey = (0, react_native_reanimated.useSharedValue)(0);
|
|
272
251
|
const ctx = (0, react.useMemo)(() => {
|
|
273
252
|
const loop = new _flare_engine_core.GameLoop({
|
|
274
253
|
fixedDt: config?.fixedDt,
|
|
@@ -317,8 +296,14 @@ function GameView({ config, onReady, style, children, safeArea }) {
|
|
|
317
296
|
if (onRenderPostFx) onRenderPostFx(ctx, ctx.renderer.canvas, bridge);
|
|
318
297
|
ctx.renderer.end();
|
|
319
298
|
const pic = bridge.endFrame();
|
|
320
|
-
if (pic !== null) if (isWeb)
|
|
321
|
-
|
|
299
|
+
if (pic !== null) if (isWeb) {
|
|
300
|
+
if (captureRef.current === null) captureRef.current = createSceneCapture(_shopify_react_native_skia.Skia, {
|
|
301
|
+
nonTextureImage: true,
|
|
302
|
+
retentionDepth: 3
|
|
303
|
+
});
|
|
304
|
+
const img = captureRef.current.capture(pic, w * pd, h * pd);
|
|
305
|
+
if (img !== null) sceneImage.value = img;
|
|
306
|
+
} else (0, react_native_worklets.scheduleOnUI)(captureSceneOnUI, sceneImage, uiSurface, uiSurfaceKey, pic, w * pd, h * pd);
|
|
322
307
|
if (!isWeb) {
|
|
323
308
|
const built = bridge.buildPostFxPasses(null, null, w, h);
|
|
324
309
|
if (!samePasses(prevBuilt, built)) {
|
|
@@ -336,6 +321,8 @@ function GameView({ config, onReady, style, children, safeArea }) {
|
|
|
336
321
|
return () => {
|
|
337
322
|
unsubscribeLate();
|
|
338
323
|
unsubscribePre();
|
|
324
|
+
captureRef.current?.dispose();
|
|
325
|
+
captureRef.current = null;
|
|
339
326
|
ctx.loop.stop();
|
|
340
327
|
};
|
|
341
328
|
}, []);
|
|
@@ -405,8 +392,8 @@ function GameView({ config, onReady, style, children, safeArea }) {
|
|
|
405
392
|
style: react_native.StyleSheet.absoluteFill,
|
|
406
393
|
pointerEvents: "none",
|
|
407
394
|
opaque: config?.opaque ?? false,
|
|
408
|
-
children: viewportSize.w === 0
|
|
409
|
-
image:
|
|
395
|
+
children: viewportSize.w === 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_shopify_react_native_skia.Image, {
|
|
396
|
+
image: sceneImage,
|
|
410
397
|
x: 0,
|
|
411
398
|
y: 0,
|
|
412
399
|
width: viewportSize.w,
|
|
@@ -425,6 +412,13 @@ function returnTrue$1() {
|
|
|
425
412
|
/** Stable empty-chain reference — an empty `buildPostFxPasses` result collapses
|
|
426
413
|
* to this so the `passes` state never changes for a postfx-free GameView. */
|
|
427
414
|
const EMPTY_PASSES = [];
|
|
415
|
+
/** Fallback insets when no `<SafeAreaProvider>` ancestor supplies a context value. */
|
|
416
|
+
const ZERO_INSETS = {
|
|
417
|
+
top: 0,
|
|
418
|
+
right: 0,
|
|
419
|
+
bottom: 0,
|
|
420
|
+
left: 0
|
|
421
|
+
};
|
|
428
422
|
/**
|
|
429
423
|
* Shallow structural equality of two pass lists. The signature is length +
|
|
430
424
|
* per-pass `id` + shader ref + child-image refs + uniform values. Uniforms are
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["PixelRatio","Platform","Skia","GameLoop","World","Camera2D","InputManager","AudioManager","AssetManager","SceneManager","Renderer","SpriteBatch","Position","Sprite","styles","RuntimeShader","View","returnTrue","Canvas","StyleSheet","Image","View","styles","StyleSheet","Skia","View","styles","StyleSheet","View","StyleSheet"],"sources":["../src/game-context.ts","../src/safe-area.ts","../src/scene-texture.ts","../src/skia-bridge.ts","../src/game-view.tsx","../src/hooks.ts","../src/loading-screen.tsx","../src/overlay-hooks.ts","../src/skia-atlas.ts","../src/virtual-button.tsx","../src/virtual-joystick.tsx"],"sourcesContent":["import type { AssetManager } from '@flare-engine/assets';\nimport type { AudioManager } from '@flare-engine/audio';\nimport type { GameLoop } from '@flare-engine/core';\nimport type { World } from '@flare-engine/ecs';\nimport type { InputManager } from '@flare-engine/input';\nimport type { Camera2D, Renderer, SpriteBatch } from '@flare-engine/render';\nimport type { SceneManager } from '@flare-engine/scene';\nimport { createContext } from 'react';\n\n/** The value exposed via GameContext. */\nexport interface GameContextValue {\n /** ECS world. */\n world: World;\n /** Primary 2D camera. */\n camera: Camera2D;\n /** Input manager (pointer, touches). */\n input: InputManager;\n /** Audio manager. */\n audio: AudioManager;\n /** Asset manager. */\n assets: AssetManager;\n /** Scene manager. */\n scenes: SceneManager;\n /** Game loop. */\n loop: GameLoop;\n /** Frame renderer (owns the draw phase). */\n renderer: Renderer;\n /** Sprite batch — queue `draw()` calls from systems or custom logic. */\n batch: SpriteBatch;\n}\n\n/**\n * React context that provides access to core game objects.\n * Null if accessed outside a <GameView>.\n */\nexport const GameContext = createContext<GameContextValue | null>(null);\n","import { createContext, useContext } from 'react';\n\nexport interface SafeArea {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport const SafeAreaContext = createContext<SafeArea | null>(null);\n\nexport function useSafeArea(): SafeArea {\n const value = useContext(SafeAreaContext);\n if (value === null) {\n throw new Error('useSafeArea must be used inside a <GameView>');\n }\n return value;\n}\n","import type { SkImageLike } from '@flare-engine/assets';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\n/**\n * Structural offscreen surface — the subset `GameView`'s scene capture needs.\n * Declared locally so this module does not depend on RN-Skia's concrete types.\n */\nexport interface SceneSurfaceLike<TImage = SkImageLike> {\n getCanvas(): SceneSurfaceCanvasLike;\n makeImageSnapshot(): TImage;\n flush(): void;\n}\n\n/** The canvas subset used when capturing a frame's picture. */\nexport interface SceneSurfaceCanvasLike {\n drawPicture(picture: unknown): void;\n}\n\n/** Structural Skia module — only the offscreen-surface factory is needed. */\nexport interface SceneSurfaceModuleLike<TImage = SkImageLike> {\n Surface: {\n MakeOffscreen(width: number, height: number): SceneSurfaceLike<TImage> | null;\n };\n}\n\n/** A size-keyed offscreen surface holder. */\nexport interface SceneSurfaceCache<TImage = SkImageLike> {\n /**\n * The surface for this viewport size, allocating only when the size actually\n * changed. Returns null for a zero-sized viewport, or when Skia refuses the\n * allocation.\n */\n acquire(width: number, height: number): SceneSurfaceLike<TImage> | null;\n /** Release the live surface. Safe to call repeatedly. */\n dispose(): void;\n}\n\n/**\n * `Symbol.dispose` is not in this project's ES2022 lib, so the well-known\n * symbol is looked up at runtime instead of written as a computed key.\n */\nconst DISPOSE = (Symbol as unknown as { dispose?: symbol }).dispose;\n\nfunction releaseSkiaObject(target: unknown): void {\n if (DISPOSE === undefined || target === null || target === undefined) return;\n const disposer = (target as Record<symbol, unknown>)[DISPOSE];\n if (typeof disposer === 'function') {\n (disposer as () => void).call(target);\n }\n}\n\n/**\n * Reuse one offscreen surface across frames instead of allocating per frame.\n *\n * On **web** this is a correctness requirement, not an optimisation. RN-Skia's\n * web `MakeOffscreen` builds a fresh `OffscreenCanvas` and a fresh WebGL\n * context on every call and releases neither; Chrome caps a page at 16 live\n * WebGL contexts and evicts the oldest, which is the on-screen `<Canvas>`.\n * A per-frame allocation therefore kills the visible canvas within ~16 frames\n * while the game loop keeps running — the app looks alive and paints nothing.\n * Measured and written up in docs/plans/web-target-2026-08.md §12.\n */\nexport function createSceneSurfaceCache<TImage>(\n Skia: SceneSurfaceModuleLike<TImage>,\n): SceneSurfaceCache<TImage> {\n let surface: SceneSurfaceLike<TImage> | null = null;\n let currentWidth = 0;\n let currentHeight = 0;\n\n const dispose = (): void => {\n if (surface === null) return;\n releaseSkiaObject(surface);\n surface = null;\n currentWidth = 0;\n currentHeight = 0;\n };\n\n return {\n acquire(width: number, height: number): SceneSurfaceLike<TImage> | null {\n if (width <= 0 || height <= 0) return null;\n if (surface !== null && currentWidth === width && currentHeight === height) {\n return surface;\n }\n dispose();\n const next = Skia.Surface.MakeOffscreen(width, height);\n if (next === null) return null;\n surface = next;\n currentWidth = width;\n currentHeight = height;\n return surface;\n },\n dispose,\n };\n}\n\n/** A snapshot that can be detached from its GL context (RN-Skia web SkImage). */\ninterface DetachableImage<TImage> {\n makeNonTextureImage?(): TImage;\n}\n\n/** Per-frame scene capture over a reused surface. */\nexport interface SceneCapture<TImage> {\n /**\n * Draw `picture` into the reused surface and return an image detached from\n * that surface's GL context. Returns null for a zero-sized viewport.\n */\n capture(picture: unknown, width: number, height: number): TImage | null;\n /** Release the surface and the frame image still held. */\n dispose(): void;\n}\n\n/**\n * Capture the scene into a reused offscreen surface, releasing Skia objects as\n * it goes.\n *\n * Two leaks have to be avoided here, and both were measured in a browser\n * (docs/plans/web-target-2026-08.md §12):\n *\n * 1. **Per-frame surfaces.** RN-Skia's web `MakeOffscreen` builds an\n * `OffscreenCanvas` + WebGL context per call and releases neither; Chrome\n * caps a page at 16 live contexts and evicts the on-screen canvas. Hence the\n * surface cache.\n * 2. **Per-frame images.** `makeNonTextureImage()` reads the whole viewport back\n * into the wasm heap. Leaving old CPU images unreleased exhausts that heap.\n * A single-slot release strategy is not enough: RN-Skia's web `<Canvas>`\n * paints on its own rAF, which fires *after* the capture, so the image handed\n * to React on frame N is still in use when frame N+1 runs. Releasing it\n * immediately causes `BindingError: Cannot pass deleted object as a pointer of\n * type Image const*` from `JsiSkImage.width` every frame and a blank canvas.\n * Measured at 2560×1215 / Chrome (WEB-3):\n * hold=1 (one slot — what shipped at WEB-2) → blank, BindingError every frame\n * hold=2 → blank\n * hold=3 → 1378 frames, zero errors\n * A FIFO ring of depth 3 is the measured minimum.\n *\n * The snapshot is released as soon as it has been copied. Frame images are\n * released once the ring exceeds depth 3, ensuring the canvas's rAF always has\n * a live image to paint from.\n */\n\nconst RETENTION_DEPTH = 3;\n\nexport function createSceneCapture<TImage>(\n Skia: SceneSurfaceModuleLike<TImage>,\n): SceneCapture<TImage> {\n const surfaces = createSceneSurfaceCache(Skia);\n const ring: TImage[] = [];\n\n return {\n capture(picture: unknown, width: number, height: number): TImage | null {\n const surface = surfaces.acquire(width, height);\n if (surface === null) return null;\n\n surface.getCanvas().drawPicture(picture);\n surface.flush();\n\n const snapshot = surface.makeImageSnapshot();\n const detachable = snapshot as DetachableImage<TImage>;\n const detached = detachable.makeNonTextureImage ? detachable.makeNonTextureImage() : snapshot;\n\n if (detached !== snapshot) releaseSkiaObject(snapshot);\n ring.push(detached);\n if (ring.length > RETENTION_DEPTH) {\n releaseSkiaObject(ring.shift()!);\n }\n return detached;\n },\n dispose(): void {\n for (const img of ring) {\n releaseSkiaObject(img);\n }\n ring.length = 0;\n surfaces.dispose();\n },\n };\n}\n\n/**\n * Returned by `useWebSceneTexture`. `image` is the latest captured frame (null\n * until the first capture). `capture` is the imperative callback `GameView`'s\n * frame callback invokes directly each frame.\n */\nexport interface WebSceneTexture<TImage> {\n image: TImage | null;\n capture(picture: unknown, width: number, height: number): void;\n}\n\n/**\n * Web scene texture (imperative form): expose a `capture` callback that\n * `GameView`'s `onPreRender` frame callback invokes directly instead of pushing\n * a picture through React state.\n *\n * The previous reactive form called `setImage` from a `useEffect` keyed on\n * `[Skia, picture, width, height]`. `onPreRender` would call `setPicture`,\n * React would re-render, the effect would re-run, `setImage` would re-render\n * again. That is a setState-in-a-passive-effect cascade; React's\n * NESTED_PASSIVE_UPDATE_LIMIT (50) trips and logs `Maximum update depth\n * exceeded` on every web load. It also costs two React renders per frame and\n * delays the captured image by two hops.\n *\n * `GameLoop` schedules via `requestAnimationFrame`, so calling `setImage`\n * directly from `onPreRender` is an ordinary root update that never touches the\n * passive-update counter. Both hooks still run on both platforms so hook order\n * never varies, but this hook is now inert on native simply because nothing\n * calls `capture` on that platform.\n *\n * `makeNonTextureImage()` is required regardless of reuse: the offscreen surface\n * has its own WebGL context, and a texture-backed image cannot be sampled by the\n * on-screen canvas's context. It also makes reuse safe — the snapshot is copied\n * off the GPU so next frame's draw into the same surface cannot disturb the image\n * React still holds.\n *\n * The surface is never cleared here: `Renderer.begin()` records\n * `canvas.clear(clearColor)` into the picture itself (packages/render\n * `renderer.ts:75`), so replaying the picture repaints the full surface.\n */\nexport function useWebSceneTexture<TImage>(\n Skia: SceneSurfaceModuleLike<TImage>,\n): WebSceneTexture<TImage> {\n const captureRef = useRef<SceneCapture<TImage> | null>(null);\n const [image, setImage] = useState<TImage | null>(null);\n\n useEffect(() => {\n return () => {\n captureRef.current?.dispose();\n captureRef.current = null;\n };\n }, []);\n\n const capture = useCallback(\n (picture: unknown, width: number, height: number): void => {\n if (picture === null || picture === undefined) return;\n if (captureRef.current === null) {\n captureRef.current = createSceneCapture(Skia);\n }\n const next = captureRef.current.capture(picture, width, height);\n if (next !== null) setImage(next);\n },\n [Skia],\n );\n\n return { image, capture };\n}\n","import type { SkImageLike } from '@flare-engine/assets';\nimport {\n createFrameRenderer,\n type FrameRenderer,\n type FrameRendererCompiledPass,\n type FrameRendererModule,\n type FrameRendererPostFxChain,\n type FrameRendererPostFxDescriptor,\n type FrameRendererPostFxRuntime,\n type SpriteDrawCommand,\n} from '@flare-engine/render';\nimport type { SkColor, SkImage, SkImageFilter, SkRuntimeEffect } from '@shopify/react-native-skia';\n\n/** Structural canvas — minimal subset needed for offscreen rendering. */\nexport interface SkOffscreenCanvasLike {\n drawPicture(picture: unknown): void;\n drawImageRect(image: unknown, src: unknown, dst: unknown, paint: unknown): void;\n drawRect(rect: unknown, paint: unknown): void;\n clear(color: unknown): void;\n}\n\n/** Structural canvas surface — minimal subset needed for offscreen capture. */\nexport interface SkSurfaceLike {\n getCanvas(): SkOffscreenCanvasLike;\n makeImageSnapshot(): SkImageLike;\n /** Force queued draws to execute. Required for GPU-backed surfaces before\n * makeImageSnapshot is called, otherwise the snapshot may capture\n * uninitialized texture content. See Skia's SkSurface.flush docs. */\n flush(): void;\n}\n\n/**\n * A single post-processing pass descriptor built by `buildPostFxPasses`.\n * GameView maps each descriptor to a `<RuntimeShader>` child of `<Image>`.\n */\nexport interface PostFxPassDescriptor {\n /** Stable id, used as React key. */\n readonly id: string;\n /** The compiled SkRuntimeEffect passed as `<RuntimeShader source={…}/>`. */\n readonly source: SkRuntimeEffect;\n /**\n * Uniform map keyed by SkSL uniform name. Vector uniforms are `number[]`\n * whose length equals `columns * rows`; scalar uniforms are `number`.\n * Built by zipping `shader.getUniformName(i)` → sliced Float32Array values.\n */\n readonly uniforms: Record<string, number | readonly number[]>;\n /**\n * Extra child shader slots beyond the implicit scene sampler. Empty for every\n * built-in PT effect; only color-grading-lut would populate it. Each entry\n * is an SkImage that GameView wraps in `<ImageShader>`.\n */\n readonly children: readonly SkImage[];\n}\n\n/**\n * Take a snapshot of `surface` and detach it from the GPU context so it can\n * be safely sampled from a different GrDirectContext (e.g. the on-screen\n * Canvas). RN-Skia's MakeOffscreen allocates a private Gr context per\n * surface; without this step Skia silently renders black when the texture is\n * read from any other context.\n *\n * Calls `makeNonTextureImage()` when available (RN-Skia ≥ 0.1 on device).\n * Falls back to the raw snapshot when the method is absent (CPU surfaces,\n * test mocks) — no behavioural change in those paths.\n */\nfunction detachSnapshot(surface: SkSurfaceLike): SkImageLike {\n const snap = surface.makeImageSnapshot();\n if (typeof snap.makeNonTextureImage === 'function') {\n return snap.makeNonTextureImage();\n }\n return snap;\n}\n\n/** A single axis-aligned rectangle shape to draw into an offscreen surface. */\nexport interface ShapeRect {\n readonly x: number;\n readonly y: number;\n readonly w: number;\n readonly h: number;\n /** ARGB packed integer: 0xAARRGGBB */\n readonly color: number;\n}\n\n/** Options for `renderShapesToImage`. */\nexport interface RenderShapesOpts {\n readonly width: number;\n readonly height: number;\n /** ARGB packed integer: 0xAARRGGBB */\n readonly clearColor: number;\n readonly shapes: readonly ShapeRect[];\n}\n\n/**\n * Narrow view of the Skia module — only the factories the bridge needs.\n * Declared as its own type so tests can pass a plain mock without pulling\n * in the full `@shopify/react-native-skia` surface.\n *\n * Extends `FrameRendererModule` from `@flare-engine/render` with the\n * native Surface and ImageFilter that are not needed in render-web.\n */\nexport type SkiaModuleLike = FrameRendererModule & {\n RuntimeEffect?: { Make(sksl: string): SkRuntimeEffect | null };\n Surface?: {\n Make(width: number, height: number): SkSurfaceLike | null;\n MakeOffscreen?(width: number, height: number): SkSurfaceLike | null;\n };\n /** Optional — present on device builds; absent in CPU/test mocks (drop-shadow falls back to the default paint). */\n ImageFilter?: {\n MakeDropShadow(\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null,\n ): SkImageFilter;\n };\n};\n\n/**\n * A single compiled postfx pass descriptor produced by the runtime.\n * Re-exported from render's FrameRendererCompiledPass for consumer compatibility.\n */\nexport type CompiledPassLike = FrameRendererCompiledPass;\n\n/**\n * Minimal structural view of a PostFxRuntime that the bridge needs.\n * Re-exported from render's FrameRendererPostFxRuntime for consumer compatibility.\n */\nexport type PostFxRuntimeLike = FrameRendererPostFxRuntime;\n\n/** Minimal structural view of an EffectChain the bridge needs. */\nexport type PostFxChainLike = FrameRendererPostFxChain;\n\n/**\n * Frame renderer that bridges a `SpriteBatch` to a Skia `<Picture>`.\n * The implementation lives in `@flare-engine/render` (`createFrameRenderer`);\n * this interface narrows the return type for native-Skia consumers.\n */\nexport type SkiaFrameRenderer = FrameRenderer;\n\n/**\n * Create a `SkiaFrameRenderer`.\n *\n * `Skia` is passed in (rather than imported) so unit tests can supply a\n * mock. Production code constructs this once inside `<GameView>` using the\n * real `Skia` import from `@shopify/react-native-skia`.\n *\n * Delegates to `createFrameRenderer` from `@flare-engine/render` — the\n * frame-renderer body is backend-neutral and shared with render-web.\n */\nexport function createSkiaFrameRenderer(Skia: SkiaModuleLike): SkiaFrameRenderer {\n return createFrameRenderer(Skia);\n}\n\n// Scratch buffer for ARGB → RGBA-float unpacking in renderShapesToImage.\n// Allocated once per call (not module-level) so concurrent callers are safe.\n// Hot paths inside createSkiaFrameRenderer use their own pre-allocated buffers.\n\n/**\n * Render a list of solid rectangles into a fresh offscreen surface and return\n * the resulting image snapshot. Returns `null` if `Surface` factory is absent or\n * fails. The surface is not cached — callers that need reuse should cache the\n * returned image themselves.\n */\nexport function renderShapesToImage(\n skia: SkiaModuleLike,\n opts: RenderShapesOpts,\n): SkImageLike | null {\n if (skia.Surface === undefined) return null;\n const surface = skia.Surface.Make(opts.width, opts.height);\n if (surface === null) return null;\n\n const scratch = new Float32Array(4);\n const canvas = surface.getCanvas();\n\n unpackArgb(scratch, opts.clearColor);\n canvas.clear(scratch);\n\n const paint = skia.Paint();\n for (const shape of opts.shapes) {\n unpackArgb(scratch, shape.color);\n if (paint.setColor) paint.setColor(scratch);\n const rect = skia.XYWHRect(shape.x, shape.y, shape.w, shape.h);\n canvas.drawRect(rect, paint);\n }\n\n return detachSnapshot(surface);\n}\n\n/** Unpack a 0xAARRGGBB integer into a Float32Array [r, g, b, a] in 0..1 range. */\nfunction unpackArgb(out: Float32Array, argb: number): void {\n out[0] = ((argb >>> 16) & 0xff) / 255;\n out[1] = ((argb >>> 8) & 0xff) / 255;\n out[2] = (argb & 0xff) / 255;\n out[3] = ((argb >>> 24) & 0xff) / 255;\n}\n\n// Re-export the PostFxPassDescriptor shape for GameView consumers.\n// The type is defined above in this file so it carries the concrete SkRuntimeEffect/SkImage\n// types that GameView needs — unlike the generic FrameRendererPostFxDescriptor from render.\n// Alias for clarity at call-sites.\nexport type { FrameRendererPostFxDescriptor, SpriteDrawCommand };\n","import type { AssetLoader } from '@flare-engine/assets';\nimport { AssetManager } from '@flare-engine/assets';\nimport { AudioManager } from '@flare-engine/audio';\nimport { GameLoop } from '@flare-engine/core';\nimport { Position, World } from '@flare-engine/ecs';\nimport { InputManager } from '@flare-engine/input';\nimport { Camera2D, createRenderSystem, Renderer, Sprite, SpriteBatch } from '@flare-engine/render';\nimport { SceneManager } from '@flare-engine/scene';\nimport type { CanvasRef, SkImage, SkPicture } from '@shopify/react-native-skia';\nimport {\n Canvas,\n Image,\n RuntimeShader,\n Skia,\n useCanvasRef,\n usePictureAsTexture,\n} from '@shopify/react-native-skia';\nimport type React from 'react';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { GestureResponderEvent, LayoutChangeEvent, ViewStyle } from 'react-native';\nimport { PixelRatio, Platform, StyleSheet, View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { GameContext, type GameContextValue } from './game-context.js';\nimport { type SafeArea, SafeAreaContext } from './safe-area.js';\nimport { useWebSceneTexture } from './scene-texture.js';\nimport { createSkiaFrameRenderer, type PostFxPassDescriptor } from './skia-bridge.js';\n\n/** Render hook invoked during the frame — receives the game context and\n * the active Skia canvas for direct draw calls. Hooks run between\n * `renderer.applyCamera()` and `renderer.end()`, so the camera transform\n * is already applied. */\nexport type RenderHook = (ctx: GameContextValue, canvas: unknown) => void;\n\n/** Render hook for post-processing passes. Receives the game context, the\n * active Skia canvas, and the `SkiaFrameRenderer` bridge so the hook can\n * call `bridge.setPostFxBinding(runtime, chain)` to register the runtime\n * and chain for the current frame.\n * `bridge` is `null` only on platforms where no Skia renderer was created\n * (future web fallback). */\nexport type PostFxRenderHook = (\n ctx: GameContextValue,\n canvas: unknown,\n bridge: import('./skia-bridge.js').SkiaFrameRenderer | null,\n) => void;\n\n/** Configuration passed to <GameView>. */\nexport interface GameConfig {\n /** Fixed timestep in seconds (default 1/60). */\n fixedDt?: number;\n /** Maximum dt cap in seconds (default 0.25). */\n maxDt?: number;\n /** Background clear color as 32-bit ARGB int (default 0xFF000000). */\n clearColor?: number;\n /** Asset loader function — injected into AssetManager at construction. */\n assetLoader?: AssetLoader;\n /** Called after camera transform and before the sprite render system.\n * Intended for tilemap / background layer rendering. */\n onRenderBackground?: RenderHook;\n /** Called after the sprite batch has been flushed, before `renderer.end()`.\n * Receives the bridge as 3rd arg so the hook can call\n * `bridge.setPostFxBinding(runtime, chain)` to register the postfx runtime\n * and chain for the current frame. */\n onRenderPostFx?: PostFxRenderHook;\n /**\n * Promote the underlying Skia surface from a TextureView (default) to a\n * SurfaceView on Android. With `opaque: true`, SurfaceView paints in a\n * separate compositing layer below the regular RN view tree, which lets\n * full-screen RN overlays (HUDs, menus) render on top without needing\n * elevation/zIndex tricks.\n *\n * Without this, RN-Skia's TextureView can clip overlapping full-screen\n * RN siblings on certain Android devices/Fabric configurations.\n *\n * Implies the canvas content is opaque — the clearColor's alpha must be\n * fully opaque (0xFF). Defaults to `false` to preserve the current\n * iOS-equivalent behavior.\n */\n opaque?: boolean;\n}\n\n/** Props for the <GameView> component. */\nexport interface GameViewProps {\n /** Game configuration. */\n config?: GameConfig;\n /** Called once the game context is ready (loop not yet started). */\n onReady?: (ctx: GameContextValue) => void;\n /** Style applied to the outer View container. */\n style?: ViewStyle;\n /** Optional overlay children (e.g. VirtualJoystick, VirtualButton). */\n children?: React.ReactNode;\n /** Explicit safe-area insets. If omitted, resolved from react-native-safe-area-context\n * via `useSafeAreaInsets()` (requires a `<SafeAreaProvider>` ancestor; falls back to\n * zero insets when no provider is mounted). */\n safeArea?: SafeArea;\n}\n\n/**\n * GameView — root component that sets up the Skia canvas, game loop,\n * and all core game systems. Provides GameContext to descendants.\n *\n * Overlay controls (VirtualJoystick, VirtualButton) should be placed\n * as children; they render on top of the Skia canvas.\n */\nexport function GameView({\n config,\n onReady,\n style,\n children,\n safeArea,\n}: GameViewProps): React.ReactElement {\n const insets = useSafeAreaInsets();\n const resolvedSafeArea: SafeArea = safeArea ?? insets;\n const canvasRef = useCanvasRef();\n const [picture, setPicture] = useState<SkPicture | null>(null);\n const [passes, setPasses] = useState<readonly PostFxPassDescriptor[]>(EMPTY_PASSES);\n const [viewportSize, setViewportSize] = useState({ w: 0, h: 0 });\n const pd = PixelRatio.get();\n const sceneSize = useMemo(\n () => ({ width: viewportSize.w * pd, height: viewportSize.h * pd }),\n [viewportSize.w, viewportSize.h, pd],\n );\n // Web and native capture the scene differently, but BOTH hooks run on both\n // platforms so hook order never varies.\n //\n // Native: usePictureAsTexture converts the SkPicture → texture each frame.\n // Web: useWebSceneTexture is now imperative — GameView's onPreRender frame\n // callback calls its capture(picture, width, height) directly instead of\n // pushing the picture through React state. The old reactive approach\n // (setState-in-a-passive-effect) tripped React's NESTED_PASSIVE_UPDATE_LIMIT\n // (50) and logged \"Maximum update depth exceeded\" on every web load. It also\n // cost two React renders per frame and added one hop of image latency. The\n // web hook is inert on native because nothing calls capture there.\n //\n // usePictureAsTexture calls MakeOffscreen per picture on web, allocating an\n // unreleased WebGL context every frame and evicting the on-screen canvas at\n // Chrome's 16-context cap; the web path reuses one surface instead.\n // See docs/plans/web-target-2026-08.md §12.\n const isWeb = Platform.OS === 'web';\n const nativeTexture = usePictureAsTexture(isWeb ? null : picture, sceneSize);\n const { image: webTexture, capture: captureWebScene } = useWebSceneTexture<SkImage>(Skia);\n const sceneTexture = isWeb ? webTexture : nativeTexture;\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: intentional mount-only\n const ctx = useMemo<GameContextValue>(() => {\n const loop = new GameLoop({\n fixedDt: config?.fixedDt,\n maxDt: config?.maxDt,\n });\n const world = new World();\n const camera = new Camera2D();\n const input = new InputManager();\n const audio = new AudioManager();\n const noop: AssetLoader = () => Promise.resolve(null);\n const assets = new AssetManager(config?.assetLoader ?? noop);\n const scenes = new SceneManager();\n const renderer = new Renderer();\n const batch = new SpriteBatch();\n return { world, camera, input, audio, assets, scenes, loop, renderer, batch };\n }, []);\n\n // Warn once per <GameView> instance (not per page load) so each independently\n // mounted instance with a postfx binding gets its own one-time notice.\n const webPostFxWarnedRef = useRef(false);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: intentional mount-only\n useEffect(() => {\n const bridge = createSkiaFrameRenderer(Skia);\n ctx.renderer.setCanvas(bridge.canvas);\n\n const clearColor = config?.clearColor ?? 0xff000000;\n const onRenderBackground = config?.onRenderBackground;\n const onRenderPostFx = config?.onRenderPostFx;\n\n const spriteQuery = ctx.world.query(Position, Sprite);\n const renderSystem = createRenderSystem(ctx.world, spriteQuery, Position, Sprite, ctx.batch);\n\n // Last passes signature pushed to state; gates setPasses so an unchanged\n // (or empty) chain does not churn a fresh array + RuntimeShader tree every\n // frame. Seeded to the same EMPTY_PASSES the state holds, so an empty chain\n // never triggers a re-render from passes.\n let prevBuilt: readonly PostFxPassDescriptor[] = EMPTY_PASSES;\n\n const unsubscribeLate = ctx.loop.onLateUpdate.add((dt) => {\n ctx.camera.update(dt);\n ctx.input.update();\n });\n\n const unsubscribePre = ctx.loop.onPreRender.add(() => {\n const w = ctx.camera.viewportWidth;\n const h = ctx.camera.viewportHeight;\n bridge.beginFrame(w, h, ctx.loop.clock.elapsed, pd);\n ctx.renderer.begin(clearColor);\n ctx.renderer.applyCamera(\n ctx.camera.effectiveX,\n ctx.camera.effectiveY,\n ctx.camera.zoom,\n ctx.camera.rotation,\n w,\n h,\n );\n if (onRenderBackground) onRenderBackground(ctx, ctx.renderer.canvas);\n renderSystem();\n ctx.batch.flush(bridge.drawAtlas, ctx.renderer);\n if (onRenderPostFx) onRenderPostFx(ctx, ctx.renderer.canvas, bridge);\n ctx.renderer.end();\n const pic = bridge.endFrame() as SkPicture | null;\n if (pic !== null) {\n if (isWeb) captureWebScene(pic, w * pd, h * pd);\n else setPicture(pic);\n }\n if (!isWeb) {\n const built = bridge.buildPostFxPasses(null, null, w, h) as readonly PostFxPassDescriptor[];\n if (!samePasses(prevBuilt, built)) {\n prevBuilt = built.length === 0 ? EMPTY_PASSES : built;\n setPasses(prevBuilt);\n }\n } else if (bridge.hasPostFxBinding() && !webPostFxWarnedRef.current) {\n console.warn(\n 'postfx chain skipped: Skia.RuntimeShaderBuilder and' +\n ' ImageFilter.MakeRuntimeShaderWithChildren both throw' +\n ' \"Not implemented on React Native Web\".',\n );\n webPostFxWarnedRef.current = true;\n }\n canvasRef.current?.redraw();\n });\n\n onReady?.(ctx);\n ctx.loop.start();\n return () => {\n unsubscribeLate();\n unsubscribePre();\n ctx.loop.stop();\n };\n }, []);\n\n const handleLayout = useCallback(\n (event: LayoutChangeEvent): void => {\n const { width, height } = event.nativeEvent.layout;\n ctx.camera.setViewport(width, height);\n setViewportSize({ w: width, h: height });\n },\n [ctx],\n );\n\n const onGrant = useCallback(\n (e: GestureResponderEvent): void => {\n const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;\n if (changedTouches.length === 0) {\n ctx.input.onPointerDown(Number(identifier), locationX, locationY);\n return;\n }\n for (let i = 0; i < changedTouches.length; i++) {\n const t = changedTouches[i];\n if (t === undefined) continue;\n ctx.input.onPointerDown(Number(t.identifier), t.locationX, t.locationY);\n }\n },\n [ctx],\n );\n const onMove = useCallback(\n (e: GestureResponderEvent): void => {\n const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;\n if (changedTouches.length === 0) {\n ctx.input.onPointerMove(Number(identifier), locationX, locationY);\n return;\n }\n for (let i = 0; i < changedTouches.length; i++) {\n const t = changedTouches[i];\n if (t === undefined) continue;\n ctx.input.onPointerMove(Number(t.identifier), t.locationX, t.locationY);\n }\n },\n [ctx],\n );\n const onRelease = useCallback(\n (e: GestureResponderEvent): void => {\n const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;\n if (changedTouches.length === 0) {\n ctx.input.onPointerUp(Number(identifier), locationX, locationY);\n return;\n }\n for (let i = 0; i < changedTouches.length; i++) {\n const t = changedTouches[i];\n if (t === undefined) continue;\n ctx.input.onPointerUp(Number(t.identifier), t.locationX, t.locationY);\n }\n },\n [ctx],\n );\n\n const containerStyle = useMemo(() => [styles.container, style], [style]);\n const passElements = useMemo(\n () => passes.map((p) => <RuntimeShader key={p.id} source={p.source} uniforms={p.uniforms} />),\n [passes],\n );\n\n return (\n <SafeAreaContext.Provider value={resolvedSafeArea}>\n <GameContext.Provider value={ctx}>\n <View\n style={containerStyle}\n onLayout={handleLayout}\n onStartShouldSetResponder={returnTrue}\n onResponderGrant={onGrant}\n onResponderMove={onMove}\n onResponderRelease={onRelease}\n onResponderTerminate={onRelease}\n >\n <Canvas\n ref={canvasRef as React.Ref<CanvasRef>}\n style={StyleSheet.absoluteFill}\n pointerEvents=\"none\"\n opaque={config?.opaque ?? false}\n >\n {viewportSize.w === 0 || sceneTexture == null ? null : (\n <Image\n image={sceneTexture}\n x={0}\n y={0}\n width={viewportSize.w}\n height={viewportSize.h}\n fit=\"cover\"\n >\n {passElements}\n </Image>\n )}\n </Canvas>\n {children}\n </View>\n </GameContext.Provider>\n </SafeAreaContext.Provider>\n );\n}\n\nfunction returnTrue(): boolean {\n return true;\n}\n\n/** Stable empty-chain reference — an empty `buildPostFxPasses` result collapses\n * to this so the `passes` state never changes for a postfx-free GameView. */\nconst EMPTY_PASSES: readonly PostFxPassDescriptor[] = [];\n\n/**\n * Shallow structural equality of two pass lists. The signature is length +\n * per-pass `id` + shader ref + child-image refs + uniform values. Uniforms are\n * compared (not just `id`/`source`) because animating effects — the hit-flash\n * decay and timed triggers — keep a constant `id`/`source` while only their\n * uniform values change frame to frame; excluding them would freeze those\n * animations. Cost is trivial: postfx chains hold a handful of scalar/short-vec\n * uniforms.\n */\nfunction samePasses(\n a: readonly PostFxPassDescriptor[],\n b: readonly PostFxPassDescriptor[],\n): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n const pa = a[i];\n const pb = b[i];\n if (pa === undefined || pb === undefined) return false;\n if (pa.id !== pb.id || pa.source !== pb.source) return false;\n if (!sameChildren(pa.children, pb.children)) return false;\n if (!sameUniforms(pa.uniforms, pb.uniforms)) return false;\n }\n return true;\n}\n\nfunction sameChildren(a: readonly unknown[], b: readonly unknown[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\nfunction sameUniforms(\n a: PostFxPassDescriptor['uniforms'],\n b: PostFxPassDescriptor['uniforms'],\n): boolean {\n const aKeys = Object.keys(a);\n if (aKeys.length !== Object.keys(b).length) return false;\n for (const key of aKeys) {\n const va = a[key];\n const vb = b[key];\n if (va === undefined || vb === undefined) return false;\n if (typeof va === 'number') {\n if (va !== vb) return false;\n } else {\n if (typeof vb === 'number' || va.length !== vb.length) return false;\n for (let i = 0; i < va.length; i++) {\n if (va[i] !== vb[i]) return false;\n }\n }\n }\n return true;\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n});\n","import type { Query } from '@flare-engine/ecs';\nimport { useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport { GameContext, type GameContextValue } from './game-context.js';\n\n/**\n * useGame — returns the GameContextValue from the nearest <GameView>.\n * Throws if called outside a <GameView>.\n */\nexport function useGame(): GameContextValue {\n const ctx = useContext(GameContext);\n if (!ctx) {\n throw new Error('useGame must be used inside a <GameView>');\n }\n return ctx;\n}\n\n/**\n * useEntity — subscribes to an ECS Query and returns the current entity list.\n * Re-renders when entities are added to or removed from the query.\n *\n * @param query An active Query obtained from world.query(...)\n */\nexport function useEntity(query: Query): readonly number[] {\n const [entities, setEntities] = useState<readonly number[]>(() => Array.from(query));\n\n useEffect(() => {\n const refresh = () => setEntities(Array.from(query));\n\n const unsubAdd = query.onEntityAdded.add(refresh);\n const unsubRemove = query.onEntityRemoved.add(refresh);\n\n // Sync initial state (query may have changed between render and effect)\n refresh();\n\n return () => {\n unsubAdd();\n unsubRemove();\n };\n }, [query]);\n\n return entities;\n}\n\n/**\n * useGameLoop — registers a per-frame callback on the game loop's onUpdate signal.\n * The callback is called each frame with delta time in seconds.\n * Automatically unregisters on unmount.\n *\n * @param callback Function called each frame with dt in seconds.\n */\nexport function useGameLoop(callback: (dt: number) => void): void {\n const { loop } = useGame();\n const callbackRef = useRef(callback);\n callbackRef.current = callback;\n\n const stable = useCallback((dt: number) => {\n callbackRef.current(dt);\n }, []);\n\n useEffect(() => {\n const unsub = loop.onUpdate.add(stable);\n return () => {\n unsub();\n };\n }, [loop, stable]);\n}\n","import type React from 'react';\nimport type { ViewStyle } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\n/** Props for the <LoadingScreen> component. */\nexport interface LoadingScreenProps {\n /** Progress in [0, 1]. Values outside this range are clamped. */\n progress: number;\n /** Style applied to the outer container (covers parent by default). */\n style?: ViewStyle;\n /** Filled portion color. */\n barColor?: string;\n /** Track color. */\n trackColor?: string;\n /** Background color behind the track. */\n backgroundColor?: string;\n}\n\n/**\n * LoadingScreen — full-screen asset-load overlay.\n *\n * Renders before `<GameView>` mounts its Skia canvas (or alongside it\n * while `AssetManager.load()` resolves). Pure RN Views so it works\n * without a live Skia context. Consumers drive `progress` from the\n * AssetManager progress callback.\n */\nexport function LoadingScreen({\n progress,\n style,\n barColor = '#ffffff',\n trackColor = 'rgba(255,255,255,0.2)',\n backgroundColor = '#000000',\n}: LoadingScreenProps): React.ReactElement {\n const clamped = progress < 0 ? 0 : progress > 1 ? 1 : progress;\n const percent = `${Math.round(clamped * 100)}%` as `${number}%`;\n\n return (\n <View style={[styles.container, { backgroundColor }, style]}>\n <View style={[styles.track, { backgroundColor: trackColor }]}>\n <View style={[styles.bar, { width: percent, backgroundColor: barColor }]} />\n </View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 32,\n },\n track: {\n width: '80%',\n height: 6,\n borderRadius: 3,\n overflow: 'hidden',\n },\n bar: {\n height: '100%',\n },\n});\n","import type { Signal } from '@flare-engine/events';\nimport { easeOutCubic } from '@flare-engine/math';\nimport { useEffect, useRef, useState } from 'react';\n\nexport function useOverlayFade(visible: boolean, durationMs = 300): number {\n const target = visible ? 1 : 0;\n const [opacity, setOpacity] = useState<number>(target);\n const opacityRef = useRef<number>(opacity);\n const startRef = useRef<number | null>(null);\n const rafRef = useRef<number | null>(null);\n\n // Keep ref in sync with state (runs before effect)\n opacityRef.current = opacity;\n\n useEffect(() => {\n if (typeof requestAnimationFrame === 'undefined') {\n setOpacity(target);\n return;\n }\n const from = opacityRef.current;\n startRef.current = null;\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n\n const step = (now: number) => {\n if (startRef.current === null) startRef.current = now;\n const t = Math.min((now - startRef.current) / durationMs, 1);\n setOpacity(from + (target - from) * t);\n if (t < 1) {\n rafRef.current = requestAnimationFrame(step);\n }\n };\n rafRef.current = requestAnimationFrame(step);\n return () => {\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n };\n }, [target, durationMs]);\n\n return opacity;\n}\n\nexport function useCountUp(target: number, durationMs = 600): number {\n const [value, setValue] = useState<number>(target);\n const valueRef = useRef<number>(value);\n const startRef = useRef<number | null>(null);\n const rafRef = useRef<number | null>(null);\n\n // Keep ref in sync with state (runs before effect)\n valueRef.current = value;\n\n useEffect(() => {\n if (typeof requestAnimationFrame === 'undefined') {\n setValue(target);\n return;\n }\n const from = valueRef.current;\n startRef.current = null;\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n\n const step = (now: number) => {\n if (startRef.current === null) startRef.current = now;\n const t = Math.min((now - startRef.current) / durationMs, 1);\n setValue(from + (target - from) * easeOutCubic(t));\n if (t < 1) {\n rafRef.current = requestAnimationFrame(step);\n }\n };\n rafRef.current = requestAnimationFrame(step);\n return () => {\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n };\n }, [target, durationMs]);\n\n return value;\n}\n\nexport function useSignalState<T>(signal: Signal<T>, initial: T): T {\n const [state, setState] = useState<T>(initial);\n\n useEffect(() => {\n const disposer = signal.add(setState);\n return disposer;\n }, [signal]);\n\n return state;\n}\n","import type { SkiaAtlasModuleLike } from '@flare-engine/assets';\nimport { Skia } from '@shopify/react-native-skia';\n\n/**\n * The RN-Skia module adapted to the engine's structural atlas interface.\n * Centralises the one boundary assertion so template code stays cast-free.\n */\nexport const skiaAtlasModule: SkiaAtlasModuleLike = Skia as unknown as SkiaAtlasModuleLike;\n","import {\n createButtonState,\n pressButton,\n releaseButton,\n resetButtonFrame,\n type VirtualButtonState,\n} from '@flare-engine/input';\nimport type React from 'react';\nimport { useCallback, useRef } from 'react';\nimport type { ViewStyle } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\n/** Props for the <VirtualButton> component. */\nexport interface VirtualButtonProps {\n /** Called on each state change. */\n onStateChange?: (state: VirtualButtonState) => void;\n /** Style applied to the button. */\n style?: ViewStyle;\n /** Button label / overlay content. */\n children?: React.ReactNode;\n}\n\n/**\n * VirtualButton — an on-screen button overlay component.\n *\n * Uses raw `onTouchStart`/`onTouchEnd` so press and release fire regardless\n * of which ancestor holds the RN responder — enabling simultaneous use with\n * `<VirtualJoystick>` without responder conflicts.\n */\nexport function VirtualButton({\n onStateChange,\n style,\n children,\n}: VirtualButtonProps): React.ReactElement {\n const stateRef = useRef<VirtualButtonState>(createButtonState());\n\n const handlePress = useCallback(() => {\n resetButtonFrame(stateRef.current);\n pressButton(stateRef.current);\n onStateChange?.(stateRef.current);\n }, [onStateChange]);\n\n const handleRelease = useCallback(() => {\n resetButtonFrame(stateRef.current);\n releaseButton(stateRef.current);\n onStateChange?.(stateRef.current);\n }, [onStateChange]);\n\n return (\n <View\n style={[styles.button, style]}\n onTouchStart={handlePress}\n onTouchEnd={handleRelease}\n onTouchCancel={handleRelease}\n >\n {children}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n button: {\n width: 60,\n height: 60,\n borderRadius: 30,\n backgroundColor: 'rgba(255,255,255,0.3)',\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n","import {\n createJoystickState,\n releaseJoystick,\n updateJoystick,\n type VirtualJoystickConfig,\n type VirtualJoystickState,\n} from '@flare-engine/input';\nimport type React from 'react';\nimport { useCallback, useRef, useState } from 'react';\nimport type { GestureResponderEvent, ViewStyle } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\n/** Props for the <VirtualJoystick> component. */\nexport interface VirtualJoystickProps {\n /** Joystick configuration (dead zone, max radius). */\n config?: VirtualJoystickConfig;\n /** Called on each state change. */\n onStateChange?: (state: VirtualJoystickState) => void;\n /** Style applied to the outer container. */\n style?: ViewStyle;\n /** Custom node rendered in place of the default base circle View. */\n base?: React.ReactNode;\n /** Custom node rendered in place of the default knob View. */\n thumb?: React.ReactNode;\n}\n\n/**\n * VirtualJoystick — an on-screen joystick overlay component.\n *\n * Renders a base circle and a knob that follows the user's touch.\n * Claims the React Native touch responder so children of a parent that\n * also claims the responder (e.g. <GameView>) still receive move/end events.\n */\nexport function VirtualJoystick({\n config,\n onStateChange,\n style,\n base,\n thumb,\n}: VirtualJoystickProps): React.ReactElement {\n const stateRef = useRef<VirtualJoystickState>(createJoystickState());\n const sizeRef = useRef<{ w: number; h: number }>({ w: 0, h: 0 });\n const [knob, setKnob] = useState({ x: 0, y: 0 });\n\n const handleLayout = useCallback(\n (e: { nativeEvent: { layout: { width: number; height: number } } }) => {\n sizeRef.current = { w: e.nativeEvent.layout.width, h: e.nativeEvent.layout.height };\n },\n [],\n );\n\n const handleTouch = useCallback(\n (e: GestureResponderEvent) => {\n const { locationX, locationY } = e.nativeEvent;\n const { w, h } = sizeRef.current;\n updateJoystick(stateRef.current, w / 2, h / 2, locationX, locationY, config);\n onStateChange?.(stateRef.current);\n const { x, y } = stateRef.current.offset;\n setKnob((prev) => (prev.x === x && prev.y === y ? prev : { x, y }));\n },\n [config, onStateChange],\n );\n\n const handleRelease = useCallback(() => {\n releaseJoystick(stateRef.current);\n onStateChange?.(stateRef.current);\n setKnob((prev) => (prev.x === 0 && prev.y === 0 ? prev : { x: 0, y: 0 }));\n }, [onStateChange]);\n\n const maxRadius = config?.maxRadius ?? 50;\n\n return (\n <View\n style={[\n styles.center,\n ...(base ? [] : [styles.baseBg]),\n {\n width: maxRadius * 2,\n height: maxRadius * 2,\n borderRadius: maxRadius,\n },\n style,\n ]}\n onLayout={handleLayout}\n onStartShouldSetResponder={returnTrue}\n onMoveShouldSetResponder={returnTrue}\n onResponderGrant={handleTouch}\n onResponderMove={handleTouch}\n onResponderRelease={handleRelease}\n onResponderTerminate={handleRelease}\n onResponderTerminationRequest={returnFalse}\n >\n {base ? (\n <View style={StyleSheet.absoluteFill} pointerEvents=\"none\">\n {base}\n </View>\n ) : null}\n {thumb ? (\n <View\n style={{ transform: [{ translateX: knob.x }, { translateY: knob.y }] }}\n pointerEvents=\"none\"\n >\n {thumb}\n </View>\n ) : (\n <View\n style={[styles.knob, { transform: [{ translateX: knob.x }, { translateY: knob.y }] }]}\n />\n )}\n </View>\n );\n}\n\nfunction returnTrue(): boolean {\n return true;\n}\n\nfunction returnFalse(): boolean {\n return false;\n}\n\nconst styles = StyleSheet.create({\n center: {\n alignItems: 'center',\n justifyContent: 'center',\n },\n baseBg: {\n backgroundColor: 'rgba(255,255,255,0.2)',\n },\n knob: {\n width: 40,\n height: 40,\n borderRadius: 20,\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oB;EACpB,sBAAsB;EACtB,+BAA+B;YAlBjC,CAoBG,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACA,aAAAA,MAAD;GAAM,OAAOC,aAAAA,WAAW;GAAc,eAAc;aACjD;EACG,CAAA,IACJ,MACH,QACC,iBAAA,GAAA,kBAAA,IAAA,CAACD,aAAAA,MAAD;GACE,OAAO,EAAE,WAAW,CAAC,EAAE,YAAY,KAAK,EAAE,GAAG,EAAE,YAAY,KAAK,EAAE,CAAC,EAAE;GACrE,eAAc;aAEb;EACG,CAAA,IAEN,iBAAA,GAAA,kBAAA,IAAA,CAACA,aAAAA,MAAD,EACE,OAAO,CAAC,OAAO,MAAM,EAAE,WAAW,CAAC,EAAE,YAAY,KAAK,EAAE,GAAG,EAAE,YAAY,KAAK,EAAE,CAAC,EAAE,CAAC,EACrF,CAAA,CAEC;;AAEV;AAEA,SAAS,aAAsB;CAC7B,OAAO;AACT;AAEA,SAAS,cAAuB;CAC9B,OAAO;AACT;AAEA,MAAM,SAASC,aAAAA,WAAW,OAAO;CAC/B,QAAQ;EACN,YAAY;EACZ,gBAAgB;CAClB;CACA,QAAQ,EACN,iBAAiB,wBACnB;CACA,MAAM;EACJ,OAAO;EACP,QAAQ;EACR,cAAc;EACd,iBAAiB;CACnB;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Skia","SafeAreaInsetsContext","PixelRatio","Platform","GameLoop","World","Camera2D","InputManager","AudioManager","AssetManager","SceneManager","Renderer","SpriteBatch","Position","Sprite","styles","RuntimeShader","View","returnTrue","Canvas","StyleSheet","Image","View","styles","StyleSheet","Skia","View","styles","StyleSheet","View","StyleSheet"],"sources":["../src/game-context.ts","../src/safe-area.ts","../src/scene-texture.ts","../src/skia-bridge.ts","../src/game-view.tsx","../src/hooks.ts","../src/loading-screen.tsx","../src/overlay-hooks.ts","../src/skia-atlas.ts","../src/virtual-button.tsx","../src/virtual-joystick.tsx"],"sourcesContent":["import type { AssetManager } from '@flare-engine/assets';\nimport type { AudioManager } from '@flare-engine/audio';\nimport type { GameLoop } from '@flare-engine/core';\nimport type { World } from '@flare-engine/ecs';\nimport type { InputManager } from '@flare-engine/input';\nimport type { Camera2D, Renderer, SpriteBatch } from '@flare-engine/render';\nimport type { SceneManager } from '@flare-engine/scene';\nimport { createContext } from 'react';\n\n/** The value exposed via GameContext. */\nexport interface GameContextValue {\n /** ECS world. */\n world: World;\n /** Primary 2D camera. */\n camera: Camera2D;\n /** Input manager (pointer, touches). */\n input: InputManager;\n /** Audio manager. */\n audio: AudioManager;\n /** Asset manager. */\n assets: AssetManager;\n /** Scene manager. */\n scenes: SceneManager;\n /** Game loop. */\n loop: GameLoop;\n /** Frame renderer (owns the draw phase). */\n renderer: Renderer;\n /** Sprite batch — queue `draw()` calls from systems or custom logic. */\n batch: SpriteBatch;\n}\n\n/**\n * React context that provides access to core game objects.\n * Null if accessed outside a <GameView>.\n */\nexport const GameContext = createContext<GameContextValue | null>(null);\n","import { createContext, useContext } from 'react';\n\nexport interface SafeArea {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport const SafeAreaContext = createContext<SafeArea | null>(null);\n\nexport function useSafeArea(): SafeArea {\n const value = useContext(SafeAreaContext);\n if (value === null) {\n throw new Error('useSafeArea must be used inside a <GameView>');\n }\n return value;\n}\n","import type { SkImageLike } from '@flare-engine/assets';\n\n/**\n * Structural offscreen surface — the subset `GameView`'s scene capture needs.\n * Declared locally so this module does not depend on RN-Skia's concrete types.\n */\nexport interface SceneSurfaceLike<TImage = SkImageLike> {\n getCanvas(): SceneSurfaceCanvasLike;\n makeImageSnapshot(): TImage;\n flush(): void;\n}\n\n/** The canvas subset used when capturing a frame's picture. */\nexport interface SceneSurfaceCanvasLike {\n drawPicture(picture: unknown): void;\n}\n\n/** Structural Skia module — only the offscreen-surface factory is needed. */\nexport interface SceneSurfaceModuleLike<TImage = SkImageLike> {\n Surface: {\n MakeOffscreen(width: number, height: number): SceneSurfaceLike<TImage> | null;\n };\n}\n\n/** A size-keyed offscreen surface holder. */\nexport interface SceneSurfaceCache<TImage = SkImageLike> {\n /**\n * The surface for this viewport size, allocating only when the size actually\n * changed. Returns null for a zero-sized viewport, or when Skia refuses the\n * allocation.\n */\n acquire(width: number, height: number): SceneSurfaceLike<TImage> | null;\n /** Release the live surface. Safe to call repeatedly. */\n dispose(): void;\n}\n\n/**\n * `Symbol.dispose` is not in this project's ES2022 lib, so the well-known\n * symbol is looked up at runtime instead of written as a computed key.\n */\nconst DISPOSE = (Symbol as unknown as { dispose?: symbol }).dispose;\n\nfunction releaseSkiaObject(target: unknown): void {\n if (DISPOSE === undefined || target === null || target === undefined) return;\n const disposer = (target as Record<symbol, unknown>)[DISPOSE];\n if (typeof disposer === 'function') {\n (disposer as () => void).call(target);\n }\n}\n\n/**\n * Reuse one offscreen surface across frames instead of allocating per frame.\n *\n * On **web** this is a correctness requirement, not an optimisation. RN-Skia's\n * web `MakeOffscreen` builds a fresh `OffscreenCanvas` and a fresh WebGL\n * context on every call and releases neither; Chrome caps a page at 16 live\n * WebGL contexts and evicts the oldest, which is the on-screen `<Canvas>`.\n * A per-frame allocation therefore kills the visible canvas within ~16 frames\n * while the game loop keeps running — the app looks alive and paints nothing.\n * Measured and written up in docs/plans/web-target-2026-08.md §12.\n */\nexport function createSceneSurfaceCache<TImage>(\n Skia: SceneSurfaceModuleLike<TImage>,\n): SceneSurfaceCache<TImage> {\n let surface: SceneSurfaceLike<TImage> | null = null;\n let currentWidth = 0;\n let currentHeight = 0;\n\n const dispose = (): void => {\n if (surface === null) return;\n releaseSkiaObject(surface);\n surface = null;\n currentWidth = 0;\n currentHeight = 0;\n };\n\n return {\n acquire(width: number, height: number): SceneSurfaceLike<TImage> | null {\n if (width <= 0 || height <= 0) return null;\n if (surface !== null && currentWidth === width && currentHeight === height) {\n return surface;\n }\n dispose();\n const next = Skia.Surface.MakeOffscreen(width, height);\n if (next === null) return null;\n surface = next;\n currentWidth = width;\n currentHeight = height;\n return surface;\n },\n dispose,\n };\n}\n\n/** A snapshot that can be detached from its GL context (RN-Skia web SkImage). */\ninterface DetachableImage<TImage> {\n makeNonTextureImage?(): TImage;\n}\n\n/** Per-frame scene capture over a reused surface. */\nexport interface SceneCapture<TImage> {\n /**\n * Draw `picture` into the reused surface and return an image detached from\n * that surface's GL context. Returns null for a zero-sized viewport.\n */\n capture(picture: unknown, width: number, height: number): TImage | null;\n /** Release the surface and the frame image still held. */\n dispose(): void;\n}\n\n/**\n * Options for `createSceneCapture`.\n *\n * `nonTextureImage` defaults to `true` (web semantics: call\n * `makeNonTextureImage()` to copy the snapshot off the surface's GL context so\n * the on-screen canvas can sample it).\n *\n * **This factory is web-only since XR-1c.** An earlier revision said the\n * snapshot \"is a true copy on native\", so `false` was safe there. That is\n * wrong: the native snapshot is GPU-backed and belongs to whichever context\n * created the surface. What actually makes it sampleable is building the\n * surface on the **UI thread**, which `game-view.tsx` does through\n * `scheduleOnUI`, not through a call into this module. Passing `false` here on native\n * yields a black frame; passing `true` fixes it only by forcing a per-frame\n * GPU→CPU readback. Verified on a Pixel 7 — external-review-2026-08.md §11.4b.\n *\n * `retentionDepth` defaults to 3 — the web-measured minimum, and the only\n * platform this runs on.\n */\nexport interface SceneCaptureOptions {\n nonTextureImage?: boolean;\n retentionDepth?: number;\n}\n\n/**\n * Capture the scene into a reused offscreen surface, releasing Skia objects as\n * it goes.\n *\n * Two leaks have to be avoided here, and both were measured in a browser\n * (docs/plans/web-target-2026-08.md §12):\n *\n * 1. **Per-frame surfaces.** RN-Skia's web `MakeOffscreen` builds an\n * `OffscreenCanvas` + WebGL context per call and releases neither; Chrome\n * caps a page at 16 live contexts and evicts the on-screen canvas. Hence the\n * surface cache.\n * 2. **Per-frame images.** `makeNonTextureImage()` reads the whole viewport back\n * into the wasm heap. Leaving old CPU images unreleased exhausts that heap.\n * A single-slot release strategy is not enough: RN-Skia's web `<Canvas>`\n * paints on its own rAF, which fires *after* the capture, so the image handed\n * to React on frame N is still in use when frame N+1 runs. Releasing it\n * immediately causes `BindingError: Cannot pass deleted object as a pointer of\n * type Image const*` from `JsiSkImage.width` every frame and a blank canvas.\n * Measured at 2560×1215 / Chrome (WEB-3):\n * hold=1 (one slot — what shipped at WEB-2) → blank, BindingError every frame\n * hold=2 → blank\n * hold=3 → 1378 frames, zero errors\n * A FIFO ring of depth 3 is the measured minimum.\n *\n * The snapshot is released as soon as it has been copied. Frame images are\n * released once the ring exceeds depth 3, ensuring the canvas's rAF always has\n * a live image to paint from.\n */\n\nexport function createSceneCapture<TImage>(\n Skia: SceneSurfaceModuleLike<TImage>,\n opts?: SceneCaptureOptions,\n): SceneCapture<TImage> {\n const useNonTexture = opts?.nonTextureImage ?? true;\n const retentionDepth = opts?.retentionDepth ?? 3;\n const surfaces = createSceneSurfaceCache(Skia);\n const ring: TImage[] = [];\n\n return {\n capture(picture: unknown, width: number, height: number): TImage | null {\n const surface = surfaces.acquire(width, height);\n if (surface === null) return null;\n\n surface.getCanvas().drawPicture(picture);\n surface.flush();\n\n const snapshot = surface.makeImageSnapshot();\n const detachable = snapshot as DetachableImage<TImage>;\n const detached =\n useNonTexture && detachable.makeNonTextureImage\n ? detachable.makeNonTextureImage()\n : snapshot;\n\n if (detached !== snapshot) releaseSkiaObject(snapshot);\n ring.push(detached);\n if (ring.length > retentionDepth) {\n releaseSkiaObject(ring.shift()!);\n }\n return detached;\n },\n dispose(): void {\n for (const img of ring) {\n releaseSkiaObject(img);\n }\n ring.length = 0;\n surfaces.dispose();\n },\n };\n}\n","import type { SkImageLike } from '@flare-engine/assets';\nimport {\n createFrameRenderer,\n type FrameRenderer,\n type FrameRendererCompiledPass,\n type FrameRendererModule,\n type FrameRendererPostFxChain,\n type FrameRendererPostFxDescriptor,\n type FrameRendererPostFxRuntime,\n type SpriteDrawCommand,\n} from '@flare-engine/render';\nimport type { SkColor, SkImage, SkImageFilter, SkRuntimeEffect } from '@shopify/react-native-skia';\n\n/** Structural canvas — minimal subset needed for offscreen rendering. */\nexport interface SkOffscreenCanvasLike {\n drawPicture(picture: unknown): void;\n drawImageRect(image: unknown, src: unknown, dst: unknown, paint: unknown): void;\n drawRect(rect: unknown, paint: unknown): void;\n clear(color: unknown): void;\n}\n\n/** Structural canvas surface — minimal subset needed for offscreen capture. */\nexport interface SkSurfaceLike {\n getCanvas(): SkOffscreenCanvasLike;\n makeImageSnapshot(): SkImageLike;\n /** Force queued draws to execute. Required for GPU-backed surfaces before\n * makeImageSnapshot is called, otherwise the snapshot may capture\n * uninitialized texture content. See Skia's SkSurface.flush docs. */\n flush(): void;\n}\n\n/**\n * A single post-processing pass descriptor built by `buildPostFxPasses`.\n * GameView maps each descriptor to a `<RuntimeShader>` child of `<Image>`.\n */\nexport interface PostFxPassDescriptor {\n /** Stable id, used as React key. */\n readonly id: string;\n /** The compiled SkRuntimeEffect passed as `<RuntimeShader source={…}/>`. */\n readonly source: SkRuntimeEffect;\n /**\n * Uniform map keyed by SkSL uniform name. Vector uniforms are `number[]`\n * whose length equals `columns * rows`; scalar uniforms are `number`.\n * Built by zipping `shader.getUniformName(i)` → sliced Float32Array values.\n */\n readonly uniforms: Record<string, number | readonly number[]>;\n /**\n * Extra child shader slots beyond the implicit scene sampler. Empty for every\n * built-in effect; only color-grading-lut would populate it. Each entry\n * is an SkImage that GameView wraps in `<ImageShader>`.\n */\n readonly children: readonly SkImage[];\n}\n\n/**\n * Take a snapshot of `surface` and detach it from the GPU context so it can\n * be safely sampled from a different GrDirectContext (e.g. the on-screen\n * Canvas). RN-Skia's MakeOffscreen allocates a private Gr context per\n * surface; without this step Skia silently renders black when the texture is\n * read from any other context.\n *\n * Calls `makeNonTextureImage()` when available (RN-Skia ≥ 0.1 on device).\n * Falls back to the raw snapshot when the method is absent (CPU surfaces,\n * test mocks) — no behavioural change in those paths.\n */\nfunction detachSnapshot(surface: SkSurfaceLike): SkImageLike {\n const snap = surface.makeImageSnapshot();\n if (typeof snap.makeNonTextureImage === 'function') {\n return snap.makeNonTextureImage();\n }\n return snap;\n}\n\n/** A single axis-aligned rectangle shape to draw into an offscreen surface. */\nexport interface ShapeRect {\n readonly x: number;\n readonly y: number;\n readonly w: number;\n readonly h: number;\n /** ARGB packed integer: 0xAARRGGBB */\n readonly color: number;\n}\n\n/** Options for `renderShapesToImage`. */\nexport interface RenderShapesOpts {\n readonly width: number;\n readonly height: number;\n /** ARGB packed integer: 0xAARRGGBB */\n readonly clearColor: number;\n readonly shapes: readonly ShapeRect[];\n}\n\n/**\n * Narrow view of the Skia module — only the factories the bridge needs.\n * Declared as its own type so tests can pass a plain mock without pulling\n * in the full `@shopify/react-native-skia` surface.\n *\n * Extends `FrameRendererModule` from `@flare-engine/render` with the\n * native Surface and ImageFilter that are not needed in render-web.\n */\nexport type SkiaModuleLike = FrameRendererModule & {\n RuntimeEffect?: { Make(sksl: string): SkRuntimeEffect | null };\n Surface?: {\n Make(width: number, height: number): SkSurfaceLike | null;\n MakeOffscreen?(width: number, height: number): SkSurfaceLike | null;\n };\n /** Optional — present on device builds; absent in CPU/test mocks (drop-shadow falls back to the default paint). */\n ImageFilter?: {\n MakeDropShadow(\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null,\n ): SkImageFilter;\n };\n};\n\n/**\n * A single compiled postfx pass descriptor produced by the runtime.\n * Re-exported from render's FrameRendererCompiledPass for consumer compatibility.\n */\nexport type CompiledPassLike = FrameRendererCompiledPass;\n\n/**\n * Minimal structural view of a PostFxRuntime that the bridge needs.\n * Re-exported from render's FrameRendererPostFxRuntime for consumer compatibility.\n */\nexport type PostFxRuntimeLike = FrameRendererPostFxRuntime;\n\n/** Minimal structural view of an EffectChain the bridge needs. */\nexport type PostFxChainLike = FrameRendererPostFxChain;\n\n/**\n * Frame renderer that bridges a `SpriteBatch` to a Skia `<Picture>`.\n * The implementation lives in `@flare-engine/render` (`createFrameRenderer`);\n * this interface narrows the return type for native-Skia consumers.\n */\nexport type SkiaFrameRenderer = FrameRenderer;\n\n/**\n * Create a `SkiaFrameRenderer`.\n *\n * `Skia` is passed in (rather than imported) so unit tests can supply a\n * mock. Production code constructs this once inside `<GameView>` using the\n * real `Skia` import from `@shopify/react-native-skia`.\n *\n * Delegates to `createFrameRenderer` from `@flare-engine/render` — the\n * frame-renderer body is backend-neutral and shared with render-web.\n */\nexport function createSkiaFrameRenderer(Skia: SkiaModuleLike): SkiaFrameRenderer {\n return createFrameRenderer(Skia);\n}\n\n// Scratch buffer for ARGB → RGBA-float unpacking in renderShapesToImage.\n// Allocated once per call (not module-level) so concurrent callers are safe.\n// Hot paths inside createSkiaFrameRenderer use their own pre-allocated buffers.\n\n/**\n * Render a list of solid rectangles into a fresh offscreen surface and return\n * the resulting image snapshot. Returns `null` if `Surface` factory is absent or\n * fails. The surface is not cached — callers that need reuse should cache the\n * returned image themselves.\n */\nexport function renderShapesToImage(\n skia: SkiaModuleLike,\n opts: RenderShapesOpts,\n): SkImageLike | null {\n if (skia.Surface === undefined) return null;\n const surface = skia.Surface.Make(opts.width, opts.height);\n if (surface === null) return null;\n\n const scratch = new Float32Array(4);\n const canvas = surface.getCanvas();\n\n unpackArgb(scratch, opts.clearColor);\n canvas.clear(scratch);\n\n const paint = skia.Paint();\n for (const shape of opts.shapes) {\n unpackArgb(scratch, shape.color);\n if (paint.setColor) paint.setColor(scratch);\n const rect = skia.XYWHRect(shape.x, shape.y, shape.w, shape.h);\n canvas.drawRect(rect, paint);\n }\n\n return detachSnapshot(surface);\n}\n\n/** Unpack a 0xAARRGGBB integer into a Float32Array [r, g, b, a] in 0..1 range. */\nfunction unpackArgb(out: Float32Array, argb: number): void {\n out[0] = ((argb >>> 16) & 0xff) / 255;\n out[1] = ((argb >>> 8) & 0xff) / 255;\n out[2] = (argb & 0xff) / 255;\n out[3] = ((argb >>> 24) & 0xff) / 255;\n}\n\n// Re-export the PostFxPassDescriptor shape for GameView consumers.\n// The type is defined above in this file so it carries the concrete SkRuntimeEffect/SkImage\n// types that GameView needs — unlike the generic FrameRendererPostFxDescriptor from render.\n// Alias for clarity at call-sites.\nexport type { FrameRendererPostFxDescriptor, SpriteDrawCommand };\n","import type { AssetLoader } from '@flare-engine/assets';\nimport { AssetManager } from '@flare-engine/assets';\nimport { AudioManager } from '@flare-engine/audio';\nimport { GameLoop } from '@flare-engine/core';\nimport { Position, World } from '@flare-engine/ecs';\nimport { InputManager } from '@flare-engine/input';\nimport { Camera2D, createRenderSystem, Renderer, Sprite, SpriteBatch } from '@flare-engine/render';\nimport { SceneManager } from '@flare-engine/scene';\nimport type { CanvasRef, SkImage, SkPicture, SkSurface } from '@shopify/react-native-skia';\nimport { Canvas, Image, RuntimeShader, Skia, useCanvasRef } from '@shopify/react-native-skia';\nimport type React from 'react';\nimport { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport type { GestureResponderEvent, LayoutChangeEvent, ViewStyle } from 'react-native';\nimport { PixelRatio, Platform, StyleSheet, View } from 'react-native';\nimport { type SharedValue, useSharedValue } from 'react-native-reanimated';\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport { scheduleOnUI } from 'react-native-worklets';\nimport { GameContext, type GameContextValue } from './game-context.js';\nimport { type SafeArea, SafeAreaContext } from './safe-area.js';\nimport { createSceneCapture, type SceneCapture } from './scene-texture.js';\nimport { createSkiaFrameRenderer, type PostFxPassDescriptor } from './skia-bridge.js';\n\n/**\n * Capture the frame's picture into an offscreen surface **on the UI thread**.\n *\n * The thread is the entire point, and getting it wrong is invisible to every\n * test in this repo. RN-Skia's own `usePictureAsTexture` does exactly this work\n * inside `runOnUI` (`external/reanimated/textures.ts`), and it must: a surface\n * built on the JS thread belongs to a different GL context than the on-screen\n * `<Canvas>`, so the `<Image>` samples nothing and the app renders a black\n * frame while the game loop runs happily. Building the surface here — same\n * thread, same context as the canvas that samples it — is what makes the\n * snapshot drawable without a `makeNonTextureImage()` GPU→CPU readback.\n *\n * Verified on device (Pixel 7 / Android 17): JS-thread capture → black canvas;\n * this path → renders. See external-review-2026-08.md §11.4b.\n *\n * The surface is cached across frames in a shared value rather than rebuilt per\n * frame (RN-Skia rebuilds it every call; that is NEW-2). `surfaceKey` packs the\n * pixel size so a viewport change reallocates exactly once.\n */\nconst captureSceneOnUI = (\n target: SharedValue<SkImage | null>,\n surfaceSV: SharedValue<SkSurface | null>,\n surfaceKey: SharedValue<number>,\n picture: SkPicture,\n w: number,\n h: number,\n): void => {\n 'worklet';\n const key = w * 65536 + h;\n if (surfaceSV.value === null || surfaceKey.value !== key) {\n surfaceSV.value = Skia.Surface.MakeOffscreen(w, h);\n surfaceKey.value = key;\n }\n const surface = surfaceSV.value;\n if (surface === null) return;\n surface.getCanvas().drawPicture(picture);\n surface.flush();\n target.value = surface.makeImageSnapshot();\n};\n\n/** Render hook invoked during the frame — receives the game context and\n * the active Skia canvas for direct draw calls. Hooks run between\n * `renderer.applyCamera()` and `renderer.end()`, so the camera transform\n * is already applied. */\nexport type RenderHook = (ctx: GameContextValue, canvas: unknown) => void;\n\n/** Render hook for post-processing passes. Receives the game context, the\n * active Skia canvas, and the `SkiaFrameRenderer` bridge so the hook can\n * call `bridge.setPostFxBinding(runtime, chain)` to register the runtime\n * and chain for the current frame.\n * `bridge` is `null` only on platforms where no Skia renderer was created\n * (future web fallback). */\nexport type PostFxRenderHook = (\n ctx: GameContextValue,\n canvas: unknown,\n bridge: import('./skia-bridge.js').SkiaFrameRenderer | null,\n) => void;\n\n/** Configuration passed to <GameView>. */\nexport interface GameConfig {\n /** Fixed timestep in seconds (default 1/60). */\n fixedDt?: number;\n /** Maximum dt cap in seconds (default 0.25). */\n maxDt?: number;\n /** Background clear color as 32-bit ARGB int (default 0xFF000000). */\n clearColor?: number;\n /** Asset loader function — injected into AssetManager at construction. */\n assetLoader?: AssetLoader;\n /** Called after camera transform and before the sprite render system.\n * Intended for tilemap / background layer rendering. */\n onRenderBackground?: RenderHook;\n /** Called after the sprite batch has been flushed, before `renderer.end()`.\n * Receives the bridge as 3rd arg so the hook can call\n * `bridge.setPostFxBinding(runtime, chain)` to register the postfx runtime\n * and chain for the current frame. */\n onRenderPostFx?: PostFxRenderHook;\n /**\n * Promote the underlying Skia surface from a TextureView (default) to a\n * SurfaceView on Android. With `opaque: true`, SurfaceView paints in a\n * separate compositing layer below the regular RN view tree, which lets\n * full-screen RN overlays (HUDs, menus) render on top without needing\n * elevation/zIndex tricks.\n *\n * Without this, RN-Skia's TextureView can clip overlapping full-screen\n * RN siblings on certain Android devices/Fabric configurations.\n *\n * Implies the canvas content is opaque — the clearColor's alpha must be\n * fully opaque (0xFF), which the default `0xff000000` already satisfies.\n * Defaults to `false` to preserve the current iOS-equivalent behavior.\n *\n * **Recommended on Android.** Measured on a Pixel 7 (Android 17, release\n * build, XR-1c): with the default TextureView path RN-Skia logs its\n * `updateTexImage: LegacySurfaceTexture is not attached!` /\n * `updateAndRelease() failed` pair **22 028 times per 60 s** — 90% of all\n * logcat output, saturating the 256 KiB ring buffer so unrelated diagnostics\n * are lost. With `opaque: true` the same build over three 60 s windows logs\n * the pair **zero** times and total log volume drops ~10x. RN-Skia labels the\n * pair ignorable and rendering is correct either way, so this is log noise\n * and TextureView overhead, not a correctness fix. Native memory is flat\n * across a 6-minute soak on both paths.\n */\n opaque?: boolean;\n}\n\n/** Props for the <GameView> component. */\nexport interface GameViewProps {\n /** Game configuration. */\n config?: GameConfig;\n /** Called once the game context is ready (loop not yet started). */\n onReady?: (ctx: GameContextValue) => void;\n /** Style applied to the outer View container. */\n style?: ViewStyle;\n /** Optional overlay children (e.g. VirtualJoystick, VirtualButton). */\n children?: React.ReactNode;\n /** Explicit safe-area insets. If omitted, resolved via `useContext(SafeAreaInsetsContext)`\n * from react-native-safe-area-context; falls back to `{ top: 0, right: 0, bottom: 0,\n * left: 0 }` when no `<SafeAreaProvider>` ancestor is mounted. */\n safeArea?: SafeArea;\n}\n\n/**\n * GameView — root component that sets up the Skia canvas, game loop,\n * and all core game systems. Provides GameContext to descendants.\n *\n * Overlay controls (VirtualJoystick, VirtualButton) should be placed\n * as children; they render on top of the Skia canvas.\n */\nexport function GameView({\n config,\n onReady,\n style,\n children,\n safeArea,\n}: GameViewProps): React.ReactElement {\n // useContext must run unconditionally (hook rules), even when `safeArea` makes its\n // value unused below — it never throws, unlike useSafeAreaInsets() without a provider.\n const contextInsets = useContext(SafeAreaInsetsContext);\n const resolvedSafeArea: SafeArea = safeArea ?? contextInsets ?? ZERO_INSETS;\n const canvasRef = useCanvasRef();\n const [passes, setPasses] = useState<readonly PostFxPassDescriptor[]>(EMPTY_PASSES);\n const [viewportSize, setViewportSize] = useState({ w: 0, h: 0 });\n const pd = PixelRatio.get();\n const isWeb = Platform.OS === 'web';\n // Both platforms write captured frames into a Reanimated shared value so\n // rn-skia's <Image> reads the latest frame on the UI thread without a React\n // re-render. createSceneCapture reuses one offscreen surface per viewport\n // size (fixing per-frame MakeOffscreen on native, NEW-2) and gates the\n // GPU→CPU makeNonTextureImage() copy to web only, where cross-context\n // sampling requires it (web: nonTextureImage true, native: false).\n const sceneImage = useSharedValue<SkImage | null>(null);\n const captureRef = useRef<SceneCapture<SkImage> | null>(null);\n // Native only: the offscreen surface lives on the UI thread, so it is held in\n // shared values rather than a ref — a ref would put it back on the JS thread\n // and reintroduce the black-frame regression captureSceneOnUI exists to fix.\n const uiSurface = useSharedValue<SkSurface | null>(null);\n const uiSurfaceKey = useSharedValue(0);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: intentional mount-only\n const ctx = useMemo<GameContextValue>(() => {\n const loop = new GameLoop({\n fixedDt: config?.fixedDt,\n maxDt: config?.maxDt,\n });\n const world = new World();\n const camera = new Camera2D();\n const input = new InputManager();\n const audio = new AudioManager();\n const noop: AssetLoader = () => Promise.resolve(null);\n const assets = new AssetManager(config?.assetLoader ?? noop);\n const scenes = new SceneManager();\n const renderer = new Renderer();\n const batch = new SpriteBatch();\n return { world, camera, input, audio, assets, scenes, loop, renderer, batch };\n }, []);\n\n // Warn once per <GameView> instance (not per page load) so each independently\n // mounted instance with a postfx binding gets its own one-time notice.\n const webPostFxWarnedRef = useRef(false);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: intentional mount-only\n useEffect(() => {\n const bridge = createSkiaFrameRenderer(Skia);\n ctx.renderer.setCanvas(bridge.canvas);\n\n const clearColor = config?.clearColor ?? 0xff000000;\n const onRenderBackground = config?.onRenderBackground;\n const onRenderPostFx = config?.onRenderPostFx;\n\n const spriteQuery = ctx.world.query(Position, Sprite);\n const renderSystem = createRenderSystem(ctx.world, spriteQuery, Position, Sprite, ctx.batch);\n\n // Last passes signature pushed to state; gates setPasses so an unchanged\n // (or empty) chain does not churn a fresh array + RuntimeShader tree every\n // frame. Seeded to the same EMPTY_PASSES the state holds, so an empty chain\n // never triggers a re-render from passes.\n let prevBuilt: readonly PostFxPassDescriptor[] = EMPTY_PASSES;\n\n const unsubscribeLate = ctx.loop.onLateUpdate.add((dt) => {\n ctx.camera.update(dt);\n ctx.input.update();\n });\n\n const unsubscribePre = ctx.loop.onPreRender.add(() => {\n const w = ctx.camera.viewportWidth;\n const h = ctx.camera.viewportHeight;\n bridge.beginFrame(w, h, ctx.loop.clock.elapsed, pd);\n ctx.renderer.begin(clearColor);\n ctx.renderer.applyCamera(\n ctx.camera.effectiveX,\n ctx.camera.effectiveY,\n ctx.camera.zoom,\n ctx.camera.rotation,\n w,\n h,\n );\n if (onRenderBackground) onRenderBackground(ctx, ctx.renderer.canvas);\n renderSystem();\n ctx.batch.flush(bridge.drawAtlas, ctx.renderer);\n if (onRenderPostFx) onRenderPostFx(ctx, ctx.renderer.canvas, bridge);\n ctx.renderer.end();\n const pic = bridge.endFrame();\n if (pic !== null) {\n if (isWeb) {\n // Web has one thread, so the JS-thread capture is same-context by\n // construction; this is the path WEB-1..WEB-7 verified in Chrome,\n // including the surface cache that keeps Chrome from evicting the\n // on-screen canvas (web-target-2026-08.md §12). Left untouched.\n if (captureRef.current === null) {\n captureRef.current = createSceneCapture(Skia, {\n nonTextureImage: true,\n retentionDepth: 3,\n });\n }\n const img = captureRef.current.capture(pic, w * pd, h * pd);\n if (img !== null) sceneImage.value = img;\n } else {\n // Native must build the surface on the UI thread — see captureSceneOnUI.\n // `scheduleOnUI` and not Reanimated's `runOnUI`: the latter is curried,\n // so `runOnUI(fn)` allocated a fresh wrapper on every frame in this\n // hook. Passing the args directly allocates nothing (ADR-0002).\n scheduleOnUI(\n captureSceneOnUI,\n sceneImage,\n uiSurface,\n uiSurfaceKey,\n pic as SkPicture,\n w * pd,\n h * pd,\n );\n }\n }\n if (!isWeb) {\n const built = bridge.buildPostFxPasses(null, null, w, h) as readonly PostFxPassDescriptor[];\n if (!samePasses(prevBuilt, built)) {\n prevBuilt = built.length === 0 ? EMPTY_PASSES : built;\n setPasses(prevBuilt);\n }\n } else if (bridge.hasPostFxBinding() && !webPostFxWarnedRef.current) {\n console.warn(\n 'postfx chain skipped: Skia.RuntimeShaderBuilder and' +\n ' ImageFilter.MakeRuntimeShaderWithChildren both throw' +\n ' \"Not implemented on React Native Web\".',\n );\n webPostFxWarnedRef.current = true;\n }\n canvasRef.current?.redraw();\n });\n\n onReady?.(ctx);\n ctx.loop.start();\n return () => {\n unsubscribeLate();\n unsubscribePre();\n captureRef.current?.dispose();\n captureRef.current = null;\n ctx.loop.stop();\n };\n }, []);\n\n const handleLayout = useCallback(\n (event: LayoutChangeEvent): void => {\n const { width, height } = event.nativeEvent.layout;\n ctx.camera.setViewport(width, height);\n setViewportSize({ w: width, h: height });\n },\n [ctx],\n );\n\n const onGrant = useCallback(\n (e: GestureResponderEvent): void => {\n const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;\n if (changedTouches.length === 0) {\n ctx.input.onPointerDown(Number(identifier), locationX, locationY);\n return;\n }\n for (let i = 0; i < changedTouches.length; i++) {\n const t = changedTouches[i];\n if (t === undefined) continue;\n ctx.input.onPointerDown(Number(t.identifier), t.locationX, t.locationY);\n }\n },\n [ctx],\n );\n const onMove = useCallback(\n (e: GestureResponderEvent): void => {\n const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;\n if (changedTouches.length === 0) {\n ctx.input.onPointerMove(Number(identifier), locationX, locationY);\n return;\n }\n for (let i = 0; i < changedTouches.length; i++) {\n const t = changedTouches[i];\n if (t === undefined) continue;\n ctx.input.onPointerMove(Number(t.identifier), t.locationX, t.locationY);\n }\n },\n [ctx],\n );\n const onRelease = useCallback(\n (e: GestureResponderEvent): void => {\n const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;\n if (changedTouches.length === 0) {\n ctx.input.onPointerUp(Number(identifier), locationX, locationY);\n return;\n }\n for (let i = 0; i < changedTouches.length; i++) {\n const t = changedTouches[i];\n if (t === undefined) continue;\n ctx.input.onPointerUp(Number(t.identifier), t.locationX, t.locationY);\n }\n },\n [ctx],\n );\n\n const containerStyle = useMemo(() => [styles.container, style], [style]);\n const passElements = useMemo(\n () => passes.map((p) => <RuntimeShader key={p.id} source={p.source} uniforms={p.uniforms} />),\n [passes],\n );\n\n return (\n <SafeAreaContext.Provider value={resolvedSafeArea}>\n <GameContext.Provider value={ctx}>\n <View\n style={containerStyle}\n onLayout={handleLayout}\n onStartShouldSetResponder={returnTrue}\n onResponderGrant={onGrant}\n onResponderMove={onMove}\n onResponderRelease={onRelease}\n onResponderTerminate={onRelease}\n >\n <Canvas\n ref={canvasRef as React.Ref<CanvasRef>}\n style={StyleSheet.absoluteFill}\n pointerEvents=\"none\"\n opaque={config?.opaque ?? false}\n >\n {viewportSize.w === 0 ? null : (\n <Image\n image={sceneImage}\n x={0}\n y={0}\n width={viewportSize.w}\n height={viewportSize.h}\n fit=\"cover\"\n >\n {passElements}\n </Image>\n )}\n </Canvas>\n {children}\n </View>\n </GameContext.Provider>\n </SafeAreaContext.Provider>\n );\n}\n\nfunction returnTrue(): boolean {\n return true;\n}\n\n/** Stable empty-chain reference — an empty `buildPostFxPasses` result collapses\n * to this so the `passes` state never changes for a postfx-free GameView. */\nconst EMPTY_PASSES: readonly PostFxPassDescriptor[] = [];\n\n/** Fallback insets when no `<SafeAreaProvider>` ancestor supplies a context value. */\nconst ZERO_INSETS: SafeArea = { top: 0, right: 0, bottom: 0, left: 0 };\n\n/**\n * Shallow structural equality of two pass lists. The signature is length +\n * per-pass `id` + shader ref + child-image refs + uniform values. Uniforms are\n * compared (not just `id`/`source`) because animating effects — the hit-flash\n * decay and timed triggers — keep a constant `id`/`source` while only their\n * uniform values change frame to frame; excluding them would freeze those\n * animations. Cost is trivial: postfx chains hold a handful of scalar/short-vec\n * uniforms.\n */\nfunction samePasses(\n a: readonly PostFxPassDescriptor[],\n b: readonly PostFxPassDescriptor[],\n): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n const pa = a[i];\n const pb = b[i];\n if (pa === undefined || pb === undefined) return false;\n if (pa.id !== pb.id || pa.source !== pb.source) return false;\n if (!sameChildren(pa.children, pb.children)) return false;\n if (!sameUniforms(pa.uniforms, pb.uniforms)) return false;\n }\n return true;\n}\n\nfunction sameChildren(a: readonly unknown[], b: readonly unknown[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\nfunction sameUniforms(\n a: PostFxPassDescriptor['uniforms'],\n b: PostFxPassDescriptor['uniforms'],\n): boolean {\n const aKeys = Object.keys(a);\n if (aKeys.length !== Object.keys(b).length) return false;\n for (const key of aKeys) {\n const va = a[key];\n const vb = b[key];\n if (va === undefined || vb === undefined) return false;\n if (typeof va === 'number') {\n if (va !== vb) return false;\n } else {\n if (typeof vb === 'number' || va.length !== vb.length) return false;\n for (let i = 0; i < va.length; i++) {\n if (va[i] !== vb[i]) return false;\n }\n }\n }\n return true;\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n});\n","import type { Query } from '@flare-engine/ecs';\nimport { useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport { GameContext, type GameContextValue } from './game-context.js';\n\n/**\n * useGame — returns the GameContextValue from the nearest <GameView>.\n * Throws if called outside a <GameView>.\n */\nexport function useGame(): GameContextValue {\n const ctx = useContext(GameContext);\n if (!ctx) {\n throw new Error('useGame must be used inside a <GameView>');\n }\n return ctx;\n}\n\n/**\n * useEntity — subscribes to an ECS Query and returns the current entity list.\n * Re-renders when entities are added to or removed from the query.\n *\n * @param query An active Query obtained from world.query(...)\n */\nexport function useEntity(query: Query): readonly number[] {\n const [entities, setEntities] = useState<readonly number[]>(() => Array.from(query));\n\n useEffect(() => {\n const refresh = () => setEntities(Array.from(query));\n\n const unsubAdd = query.onEntityAdded.add(refresh);\n const unsubRemove = query.onEntityRemoved.add(refresh);\n\n // Sync initial state (query may have changed between render and effect)\n refresh();\n\n return () => {\n unsubAdd();\n unsubRemove();\n };\n }, [query]);\n\n return entities;\n}\n\n/**\n * useGameLoop — registers a per-frame callback on the game loop's onUpdate signal.\n * The callback is called each frame with delta time in seconds.\n * Automatically unregisters on unmount.\n *\n * @param callback Function called each frame with dt in seconds.\n */\nexport function useGameLoop(callback: (dt: number) => void): void {\n const { loop } = useGame();\n const callbackRef = useRef(callback);\n callbackRef.current = callback;\n\n const stable = useCallback((dt: number) => {\n callbackRef.current(dt);\n }, []);\n\n useEffect(() => {\n const unsub = loop.onUpdate.add(stable);\n return () => {\n unsub();\n };\n }, [loop, stable]);\n}\n","import type React from 'react';\nimport type { ViewStyle } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\n/** Props for the <LoadingScreen> component. */\nexport interface LoadingScreenProps {\n /** Progress in [0, 1]. Values outside this range are clamped. */\n progress: number;\n /** Style applied to the outer container (covers parent by default). */\n style?: ViewStyle;\n /** Filled portion color. */\n barColor?: string;\n /** Track color. */\n trackColor?: string;\n /** Background color behind the track. */\n backgroundColor?: string;\n}\n\n/**\n * LoadingScreen — full-screen asset-load overlay.\n *\n * Renders before `<GameView>` mounts its Skia canvas (or alongside it\n * while `AssetManager.load()` resolves). Pure RN Views so it works\n * without a live Skia context. Consumers drive `progress` from the\n * AssetManager progress callback.\n */\nexport function LoadingScreen({\n progress,\n style,\n barColor = '#ffffff',\n trackColor = 'rgba(255,255,255,0.2)',\n backgroundColor = '#000000',\n}: LoadingScreenProps): React.ReactElement {\n const clamped = progress < 0 ? 0 : progress > 1 ? 1 : progress;\n const percent = `${Math.round(clamped * 100)}%` as `${number}%`;\n\n return (\n <View style={[styles.container, { backgroundColor }, style]}>\n <View style={[styles.track, { backgroundColor: trackColor }]}>\n <View style={[styles.bar, { width: percent, backgroundColor: barColor }]} />\n </View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 32,\n },\n track: {\n width: '80%',\n height: 6,\n borderRadius: 3,\n overflow: 'hidden',\n },\n bar: {\n height: '100%',\n },\n});\n","import type { Signal } from '@flare-engine/events';\nimport { easeOutCubic } from '@flare-engine/math';\nimport { useEffect, useRef, useState } from 'react';\n\nexport function useOverlayFade(visible: boolean, durationMs = 300): number {\n const target = visible ? 1 : 0;\n const [opacity, setOpacity] = useState<number>(target);\n const opacityRef = useRef<number>(opacity);\n const startRef = useRef<number | null>(null);\n const rafRef = useRef<number | null>(null);\n\n // Keep ref in sync with state (runs before effect)\n opacityRef.current = opacity;\n\n useEffect(() => {\n if (typeof requestAnimationFrame === 'undefined') {\n setOpacity(target);\n return;\n }\n const from = opacityRef.current;\n startRef.current = null;\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n\n const step = (now: number) => {\n if (startRef.current === null) startRef.current = now;\n const t = Math.min((now - startRef.current) / durationMs, 1);\n setOpacity(from + (target - from) * t);\n if (t < 1) {\n rafRef.current = requestAnimationFrame(step);\n }\n };\n rafRef.current = requestAnimationFrame(step);\n return () => {\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n };\n }, [target, durationMs]);\n\n return opacity;\n}\n\nexport function useCountUp(target: number, durationMs = 600): number {\n const [value, setValue] = useState<number>(target);\n const valueRef = useRef<number>(value);\n const startRef = useRef<number | null>(null);\n const rafRef = useRef<number | null>(null);\n\n // Keep ref in sync with state (runs before effect)\n valueRef.current = value;\n\n useEffect(() => {\n if (typeof requestAnimationFrame === 'undefined') {\n setValue(target);\n return;\n }\n const from = valueRef.current;\n startRef.current = null;\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n\n const step = (now: number) => {\n if (startRef.current === null) startRef.current = now;\n const t = Math.min((now - startRef.current) / durationMs, 1);\n setValue(from + (target - from) * easeOutCubic(t));\n if (t < 1) {\n rafRef.current = requestAnimationFrame(step);\n }\n };\n rafRef.current = requestAnimationFrame(step);\n return () => {\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n };\n }, [target, durationMs]);\n\n return value;\n}\n\nexport function useSignalState<T>(signal: Signal<T>, initial: T): T {\n const [state, setState] = useState<T>(initial);\n\n useEffect(() => {\n const disposer = signal.add(setState);\n return disposer;\n }, [signal]);\n\n return state;\n}\n","import type { SkiaAtlasModuleLike } from '@flare-engine/assets';\nimport { Skia } from '@shopify/react-native-skia';\n\n/**\n * The RN-Skia module adapted to the engine's structural atlas interface.\n * Centralises the one boundary assertion so template code stays cast-free.\n */\nexport const skiaAtlasModule: SkiaAtlasModuleLike = Skia as unknown as SkiaAtlasModuleLike;\n","import {\n createButtonState,\n pressButton,\n releaseButton,\n resetButtonFrame,\n type VirtualButtonState,\n} from '@flare-engine/input';\nimport type React from 'react';\nimport { useCallback, useRef } from 'react';\nimport type { ViewStyle } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\n/** Props for the <VirtualButton> component. */\nexport interface VirtualButtonProps {\n /** Called on each state change. */\n onStateChange?: (state: VirtualButtonState) => void;\n /** Style applied to the button. */\n style?: ViewStyle;\n /** Button label / overlay content. */\n children?: React.ReactNode;\n}\n\n/**\n * VirtualButton — an on-screen button overlay component.\n *\n * Uses raw `onTouchStart`/`onTouchEnd` so press and release fire regardless\n * of which ancestor holds the RN responder — enabling simultaneous use with\n * `<VirtualJoystick>` without responder conflicts.\n */\nexport function VirtualButton({\n onStateChange,\n style,\n children,\n}: VirtualButtonProps): React.ReactElement {\n const stateRef = useRef<VirtualButtonState>(createButtonState());\n\n const handlePress = useCallback(() => {\n resetButtonFrame(stateRef.current);\n pressButton(stateRef.current);\n onStateChange?.(stateRef.current);\n }, [onStateChange]);\n\n const handleRelease = useCallback(() => {\n resetButtonFrame(stateRef.current);\n releaseButton(stateRef.current);\n onStateChange?.(stateRef.current);\n }, [onStateChange]);\n\n return (\n <View\n style={[styles.button, style]}\n onTouchStart={handlePress}\n onTouchEnd={handleRelease}\n onTouchCancel={handleRelease}\n >\n {children}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n button: {\n width: 60,\n height: 60,\n borderRadius: 30,\n backgroundColor: 'rgba(255,255,255,0.3)',\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n","import {\n createJoystickState,\n releaseJoystick,\n updateJoystick,\n type VirtualJoystickConfig,\n type VirtualJoystickState,\n} from '@flare-engine/input';\nimport type React from 'react';\nimport { useCallback, useRef, useState } from 'react';\nimport type { GestureResponderEvent, ViewStyle } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\n/** Props for the <VirtualJoystick> component. */\nexport interface VirtualJoystickProps {\n /** Joystick configuration (dead zone, max radius). */\n config?: VirtualJoystickConfig;\n /** Called on each state change. */\n onStateChange?: (state: VirtualJoystickState) => void;\n /** Style applied to the outer container. */\n style?: ViewStyle;\n /** Custom node rendered in place of the default base circle View. */\n base?: React.ReactNode;\n /** Custom node rendered in place of the default knob View. */\n thumb?: React.ReactNode;\n}\n\n/**\n * VirtualJoystick — an on-screen joystick overlay component.\n *\n * Renders a base circle and a knob that follows the user's touch.\n * Claims the React Native touch responder so children of a parent that\n * also claims the responder (e.g. <GameView>) still receive move/end events.\n */\nexport function VirtualJoystick({\n config,\n onStateChange,\n style,\n base,\n thumb,\n}: VirtualJoystickProps): React.ReactElement {\n const stateRef = useRef<VirtualJoystickState>(createJoystickState());\n const sizeRef = useRef<{ w: number; h: number }>({ w: 0, h: 0 });\n const [knob, setKnob] = useState({ x: 0, y: 0 });\n\n const handleLayout = useCallback(\n (e: { nativeEvent: { layout: { width: number; height: number } } }) => {\n sizeRef.current = { w: e.nativeEvent.layout.width, h: e.nativeEvent.layout.height };\n },\n [],\n );\n\n const handleTouch = useCallback(\n (e: GestureResponderEvent) => {\n const { locationX, locationY } = e.nativeEvent;\n const { w, h } = sizeRef.current;\n updateJoystick(stateRef.current, w / 2, h / 2, locationX, locationY, config);\n onStateChange?.(stateRef.current);\n const { x, y } = stateRef.current.offset;\n setKnob((prev) => (prev.x === x && prev.y === y ? prev : { x, y }));\n },\n [config, onStateChange],\n );\n\n const handleRelease = useCallback(() => {\n releaseJoystick(stateRef.current);\n onStateChange?.(stateRef.current);\n setKnob((prev) => (prev.x === 0 && prev.y === 0 ? prev : { x: 0, y: 0 }));\n }, [onStateChange]);\n\n const maxRadius = config?.maxRadius ?? 50;\n\n return (\n <View\n style={[\n styles.center,\n ...(base ? [] : [styles.baseBg]),\n {\n width: maxRadius * 2,\n height: maxRadius * 2,\n borderRadius: maxRadius,\n },\n style,\n ]}\n onLayout={handleLayout}\n onStartShouldSetResponder={returnTrue}\n onMoveShouldSetResponder={returnTrue}\n onResponderGrant={handleTouch}\n onResponderMove={handleTouch}\n onResponderRelease={handleRelease}\n onResponderTerminate={handleRelease}\n onResponderTerminationRequest={returnFalse}\n >\n {base ? (\n <View style={StyleSheet.absoluteFill} pointerEvents=\"none\">\n {base}\n </View>\n ) : null}\n {thumb ? (\n <View\n style={{ transform: [{ translateX: knob.x }, { translateY: knob.y }] }}\n pointerEvents=\"none\"\n >\n {thumb}\n </View>\n ) : (\n <View\n style={[styles.knob, { transform: [{ translateX: knob.x }, { translateY: knob.y }] }]}\n />\n )}\n </View>\n );\n}\n\nfunction returnTrue(): boolean {\n return true;\n}\n\nfunction returnFalse(): boolean {\n return false;\n}\n\nconst styles = StyleSheet.create({\n center: {\n alignItems: 'center',\n justifyContent: 'center',\n },\n baseBg: {\n back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IACnB,QAAQ,YAAY;IACpB,cAAc;GAChB;GACA;EACF;EACA,UAAU;EACV,2BAA2B;EAC3B,0BAA0B;EAC1B,kBAAkB;EAClB,iBAAiB;EACjB,oBAAoB;EACpB,sBAAsB;EACtB,+BAA+B;YAlBjC,CAoBG,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACA,aAAAA,MAAD;GAAM,OAAOC,aAAAA,WAAW;GAAc,eAAc;aACjD;EACG,CAAA,IACJ,MACH,QACC,iBAAA,GAAA,kBAAA,IAAA,CAACD,aAAAA,MAAD;GACE,OAAO,EAAE,WAAW,CAAC,EAAE,YAAY,KAAK,EAAE,GAAG,EAAE,YAAY,KAAK,EAAE,CAAC,EAAE;GACrE,eAAc;aAEb;EACG,CAAA,IAEN,iBAAA,GAAA,kBAAA,IAAA,CAACA,aAAAA,MAAD,EACE,OAAO,CAAC,OAAO,MAAM,EAAE,WAAW,CAAC,EAAE,YAAY,KAAK,EAAE,GAAG,EAAE,YAAY,KAAK,EAAE,CAAC,EAAE,CAAC,EACrF,CAAA,CAEC;;AAEV;AAEA,SAAS,aAAsB;CAC7B,OAAO;AACT;AAEA,SAAS,cAAuB;CAC9B,OAAO;AACT;AAEA,MAAM,SAASC,aAAAA,WAAW,OAAO;CAC/B,QAAQ;EACN,YAAY;EACZ,gBAAgB;CAClB;CACA,QAAQ,EACN,iBAAiB,wBACnB;CACA,MAAM;EACJ,OAAO;EACP,QAAQ;EACR,cAAc;EACd,iBAAiB;CACnB;AACF,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -6,9 +6,11 @@ import { Position, World } from "@flare-engine/ecs";
|
|
|
6
6
|
import { InputManager, createButtonState, createJoystickState, pressButton, releaseButton, releaseJoystick, resetButtonFrame, updateJoystick } from "@flare-engine/input";
|
|
7
7
|
import { Camera2D, Renderer, Sprite, SpriteBatch, createFrameRenderer, createRenderSystem } from "@flare-engine/render";
|
|
8
8
|
import { SceneManager } from "@flare-engine/scene";
|
|
9
|
-
import { Canvas, Image, RuntimeShader, Skia, useCanvasRef
|
|
9
|
+
import { Canvas, Image, RuntimeShader, Skia, useCanvasRef } from "@shopify/react-native-skia";
|
|
10
10
|
import { PixelRatio, Platform, StyleSheet, View } from "react-native";
|
|
11
|
-
import {
|
|
11
|
+
import { useSharedValue } from "react-native-reanimated";
|
|
12
|
+
import { SafeAreaInsetsContext } from "react-native-safe-area-context";
|
|
13
|
+
import { scheduleOnUI } from "react-native-worklets";
|
|
12
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
15
|
import { easeOutCubic } from "@flare-engine/math";
|
|
14
16
|
//#region src/game-context.ts
|
|
@@ -102,8 +104,9 @@ function createSceneSurfaceCache(Skia) {
|
|
|
102
104
|
* released once the ring exceeds depth 3, ensuring the canvas's rAF always has
|
|
103
105
|
* a live image to paint from.
|
|
104
106
|
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
function createSceneCapture(Skia, opts) {
|
|
108
|
+
const useNonTexture = opts?.nonTextureImage ?? true;
|
|
109
|
+
const retentionDepth = opts?.retentionDepth ?? 3;
|
|
107
110
|
const surfaces = createSceneSurfaceCache(Skia);
|
|
108
111
|
const ring = [];
|
|
109
112
|
return {
|
|
@@ -114,10 +117,10 @@ function createSceneCapture(Skia) {
|
|
|
114
117
|
surface.flush();
|
|
115
118
|
const snapshot = surface.makeImageSnapshot();
|
|
116
119
|
const detachable = snapshot;
|
|
117
|
-
const detached = detachable.makeNonTextureImage ? detachable.makeNonTextureImage() : snapshot;
|
|
120
|
+
const detached = useNonTexture && detachable.makeNonTextureImage ? detachable.makeNonTextureImage() : snapshot;
|
|
118
121
|
if (detached !== snapshot) releaseSkiaObject(snapshot);
|
|
119
122
|
ring.push(detached);
|
|
120
|
-
if (ring.length >
|
|
123
|
+
if (ring.length > retentionDepth) releaseSkiaObject(ring.shift());
|
|
121
124
|
return detached;
|
|
122
125
|
},
|
|
123
126
|
dispose() {
|
|
@@ -127,54 +130,6 @@ function createSceneCapture(Skia) {
|
|
|
127
130
|
}
|
|
128
131
|
};
|
|
129
132
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Web scene texture (imperative form): expose a `capture` callback that
|
|
132
|
-
* `GameView`'s `onPreRender` frame callback invokes directly instead of pushing
|
|
133
|
-
* a picture through React state.
|
|
134
|
-
*
|
|
135
|
-
* The previous reactive form called `setImage` from a `useEffect` keyed on
|
|
136
|
-
* `[Skia, picture, width, height]`. `onPreRender` would call `setPicture`,
|
|
137
|
-
* React would re-render, the effect would re-run, `setImage` would re-render
|
|
138
|
-
* again. That is a setState-in-a-passive-effect cascade; React's
|
|
139
|
-
* NESTED_PASSIVE_UPDATE_LIMIT (50) trips and logs `Maximum update depth
|
|
140
|
-
* exceeded` on every web load. It also costs two React renders per frame and
|
|
141
|
-
* delays the captured image by two hops.
|
|
142
|
-
*
|
|
143
|
-
* `GameLoop` schedules via `requestAnimationFrame`, so calling `setImage`
|
|
144
|
-
* directly from `onPreRender` is an ordinary root update that never touches the
|
|
145
|
-
* passive-update counter. Both hooks still run on both platforms so hook order
|
|
146
|
-
* never varies, but this hook is now inert on native simply because nothing
|
|
147
|
-
* calls `capture` on that platform.
|
|
148
|
-
*
|
|
149
|
-
* `makeNonTextureImage()` is required regardless of reuse: the offscreen surface
|
|
150
|
-
* has its own WebGL context, and a texture-backed image cannot be sampled by the
|
|
151
|
-
* on-screen canvas's context. It also makes reuse safe — the snapshot is copied
|
|
152
|
-
* off the GPU so next frame's draw into the same surface cannot disturb the image
|
|
153
|
-
* React still holds.
|
|
154
|
-
*
|
|
155
|
-
* The surface is never cleared here: `Renderer.begin()` records
|
|
156
|
-
* `canvas.clear(clearColor)` into the picture itself (packages/render
|
|
157
|
-
* `renderer.ts:75`), so replaying the picture repaints the full surface.
|
|
158
|
-
*/
|
|
159
|
-
function useWebSceneTexture(Skia) {
|
|
160
|
-
const captureRef = useRef(null);
|
|
161
|
-
const [image, setImage] = useState(null);
|
|
162
|
-
useEffect(() => {
|
|
163
|
-
return () => {
|
|
164
|
-
captureRef.current?.dispose();
|
|
165
|
-
captureRef.current = null;
|
|
166
|
-
};
|
|
167
|
-
}, []);
|
|
168
|
-
return {
|
|
169
|
-
image,
|
|
170
|
-
capture: useCallback((picture, width, height) => {
|
|
171
|
-
if (picture === null || picture === void 0) return;
|
|
172
|
-
if (captureRef.current === null) captureRef.current = createSceneCapture(Skia);
|
|
173
|
-
const next = captureRef.current.capture(picture, width, height);
|
|
174
|
-
if (next !== null) setImage(next);
|
|
175
|
-
}, [Skia])
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
133
|
//#endregion
|
|
179
134
|
//#region src/skia-bridge.ts
|
|
180
135
|
/**
|
|
@@ -239,6 +194,38 @@ function unpackArgb(out, argb) {
|
|
|
239
194
|
//#endregion
|
|
240
195
|
//#region src/game-view.tsx
|
|
241
196
|
/**
|
|
197
|
+
* Capture the frame's picture into an offscreen surface **on the UI thread**.
|
|
198
|
+
*
|
|
199
|
+
* The thread is the entire point, and getting it wrong is invisible to every
|
|
200
|
+
* test in this repo. RN-Skia's own `usePictureAsTexture` does exactly this work
|
|
201
|
+
* inside `runOnUI` (`external/reanimated/textures.ts`), and it must: a surface
|
|
202
|
+
* built on the JS thread belongs to a different GL context than the on-screen
|
|
203
|
+
* `<Canvas>`, so the `<Image>` samples nothing and the app renders a black
|
|
204
|
+
* frame while the game loop runs happily. Building the surface here — same
|
|
205
|
+
* thread, same context as the canvas that samples it — is what makes the
|
|
206
|
+
* snapshot drawable without a `makeNonTextureImage()` GPU→CPU readback.
|
|
207
|
+
*
|
|
208
|
+
* Verified on device (Pixel 7 / Android 17): JS-thread capture → black canvas;
|
|
209
|
+
* this path → renders. See external-review-2026-08.md §11.4b.
|
|
210
|
+
*
|
|
211
|
+
* The surface is cached across frames in a shared value rather than rebuilt per
|
|
212
|
+
* frame (RN-Skia rebuilds it every call; that is NEW-2). `surfaceKey` packs the
|
|
213
|
+
* pixel size so a viewport change reallocates exactly once.
|
|
214
|
+
*/
|
|
215
|
+
const captureSceneOnUI = (target, surfaceSV, surfaceKey, picture, w, h) => {
|
|
216
|
+
"worklet";
|
|
217
|
+
const key = w * 65536 + h;
|
|
218
|
+
if (surfaceSV.value === null || surfaceKey.value !== key) {
|
|
219
|
+
surfaceSV.value = Skia.Surface.MakeOffscreen(w, h);
|
|
220
|
+
surfaceKey.value = key;
|
|
221
|
+
}
|
|
222
|
+
const surface = surfaceSV.value;
|
|
223
|
+
if (surface === null) return;
|
|
224
|
+
surface.getCanvas().drawPicture(picture);
|
|
225
|
+
surface.flush();
|
|
226
|
+
target.value = surface.makeImageSnapshot();
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
242
229
|
* GameView — root component that sets up the Skia canvas, game loop,
|
|
243
230
|
* and all core game systems. Provides GameContext to descendants.
|
|
244
231
|
*
|
|
@@ -246,28 +233,20 @@ function unpackArgb(out, argb) {
|
|
|
246
233
|
* as children; they render on top of the Skia canvas.
|
|
247
234
|
*/
|
|
248
235
|
function GameView({ config, onReady, style, children, safeArea }) {
|
|
249
|
-
const
|
|
250
|
-
const resolvedSafeArea = safeArea ??
|
|
236
|
+
const contextInsets = useContext(SafeAreaInsetsContext);
|
|
237
|
+
const resolvedSafeArea = safeArea ?? contextInsets ?? ZERO_INSETS;
|
|
251
238
|
const canvasRef = useCanvasRef();
|
|
252
|
-
const [picture, setPicture] = useState(null);
|
|
253
239
|
const [passes, setPasses] = useState(EMPTY_PASSES);
|
|
254
240
|
const [viewportSize, setViewportSize] = useState({
|
|
255
241
|
w: 0,
|
|
256
242
|
h: 0
|
|
257
243
|
});
|
|
258
244
|
const pd = PixelRatio.get();
|
|
259
|
-
const sceneSize = useMemo(() => ({
|
|
260
|
-
width: viewportSize.w * pd,
|
|
261
|
-
height: viewportSize.h * pd
|
|
262
|
-
}), [
|
|
263
|
-
viewportSize.w,
|
|
264
|
-
viewportSize.h,
|
|
265
|
-
pd
|
|
266
|
-
]);
|
|
267
245
|
const isWeb = Platform.OS === "web";
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
const
|
|
246
|
+
const sceneImage = useSharedValue(null);
|
|
247
|
+
const captureRef = useRef(null);
|
|
248
|
+
const uiSurface = useSharedValue(null);
|
|
249
|
+
const uiSurfaceKey = useSharedValue(0);
|
|
271
250
|
const ctx = useMemo(() => {
|
|
272
251
|
const loop = new GameLoop({
|
|
273
252
|
fixedDt: config?.fixedDt,
|
|
@@ -316,8 +295,14 @@ function GameView({ config, onReady, style, children, safeArea }) {
|
|
|
316
295
|
if (onRenderPostFx) onRenderPostFx(ctx, ctx.renderer.canvas, bridge);
|
|
317
296
|
ctx.renderer.end();
|
|
318
297
|
const pic = bridge.endFrame();
|
|
319
|
-
if (pic !== null) if (isWeb)
|
|
320
|
-
|
|
298
|
+
if (pic !== null) if (isWeb) {
|
|
299
|
+
if (captureRef.current === null) captureRef.current = createSceneCapture(Skia, {
|
|
300
|
+
nonTextureImage: true,
|
|
301
|
+
retentionDepth: 3
|
|
302
|
+
});
|
|
303
|
+
const img = captureRef.current.capture(pic, w * pd, h * pd);
|
|
304
|
+
if (img !== null) sceneImage.value = img;
|
|
305
|
+
} else scheduleOnUI(captureSceneOnUI, sceneImage, uiSurface, uiSurfaceKey, pic, w * pd, h * pd);
|
|
321
306
|
if (!isWeb) {
|
|
322
307
|
const built = bridge.buildPostFxPasses(null, null, w, h);
|
|
323
308
|
if (!samePasses(prevBuilt, built)) {
|
|
@@ -335,6 +320,8 @@ function GameView({ config, onReady, style, children, safeArea }) {
|
|
|
335
320
|
return () => {
|
|
336
321
|
unsubscribeLate();
|
|
337
322
|
unsubscribePre();
|
|
323
|
+
captureRef.current?.dispose();
|
|
324
|
+
captureRef.current = null;
|
|
338
325
|
ctx.loop.stop();
|
|
339
326
|
};
|
|
340
327
|
}, []);
|
|
@@ -404,8 +391,8 @@ function GameView({ config, onReady, style, children, safeArea }) {
|
|
|
404
391
|
style: StyleSheet.absoluteFill,
|
|
405
392
|
pointerEvents: "none",
|
|
406
393
|
opaque: config?.opaque ?? false,
|
|
407
|
-
children: viewportSize.w === 0
|
|
408
|
-
image:
|
|
394
|
+
children: viewportSize.w === 0 ? null : /* @__PURE__ */ jsx(Image, {
|
|
395
|
+
image: sceneImage,
|
|
409
396
|
x: 0,
|
|
410
397
|
y: 0,
|
|
411
398
|
width: viewportSize.w,
|
|
@@ -424,6 +411,13 @@ function returnTrue$1() {
|
|
|
424
411
|
/** Stable empty-chain reference — an empty `buildPostFxPasses` result collapses
|
|
425
412
|
* to this so the `passes` state never changes for a postfx-free GameView. */
|
|
426
413
|
const EMPTY_PASSES = [];
|
|
414
|
+
/** Fallback insets when no `<SafeAreaProvider>` ancestor supplies a context value. */
|
|
415
|
+
const ZERO_INSETS = {
|
|
416
|
+
top: 0,
|
|
417
|
+
right: 0,
|
|
418
|
+
bottom: 0,
|
|
419
|
+
left: 0
|
|
420
|
+
};
|
|
427
421
|
/**
|
|
428
422
|
* Shallow structural equality of two pass lists. The signature is length +
|
|
429
423
|
* per-pass `id` + shader ref + child-image refs + uniform values. Uniforms are
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["styles","returnTrue","styles","styles"],"sources":["../src/game-context.ts","../src/safe-area.ts","../src/scene-texture.ts","../src/skia-bridge.ts","../src/game-view.tsx","../src/hooks.ts","../src/loading-screen.tsx","../src/overlay-hooks.ts","../src/skia-atlas.ts","../src/virtual-button.tsx","../src/virtual-joystick.tsx"],"sourcesContent":["import type { AssetManager } from '@flare-engine/assets';\nimport type { AudioManager } from '@flare-engine/audio';\nimport type { GameLoop } from '@flare-engine/core';\nimport type { World } from '@flare-engine/ecs';\nimport type { InputManager } from '@flare-engine/input';\nimport type { Camera2D, Renderer, SpriteBatch } from '@flare-engine/render';\nimport type { SceneManager } from '@flare-engine/scene';\nimport { createContext } from 'react';\n\n/** The value exposed via GameContext. */\nexport interface GameContextValue {\n /** ECS world. */\n world: World;\n /** Primary 2D camera. */\n camera: Camera2D;\n /** Input manager (pointer, touches). */\n input: InputManager;\n /** Audio manager. */\n audio: AudioManager;\n /** Asset manager. */\n assets: AssetManager;\n /** Scene manager. */\n scenes: SceneManager;\n /** Game loop. */\n loop: GameLoop;\n /** Frame renderer (owns the draw phase). */\n renderer: Renderer;\n /** Sprite batch — queue `draw()` calls from systems or custom logic. */\n batch: SpriteBatch;\n}\n\n/**\n * React context that provides access to core game objects.\n * Null if accessed outside a <GameView>.\n */\nexport const GameContext = createContext<GameContextValue | null>(null);\n","import { createContext, useContext } from 'react';\n\nexport interface SafeArea {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport const SafeAreaContext = createContext<SafeArea | null>(null);\n\nexport function useSafeArea(): SafeArea {\n const value = useContext(SafeAreaContext);\n if (value === null) {\n throw new Error('useSafeArea must be used inside a <GameView>');\n }\n return value;\n}\n","import type { SkImageLike } from '@flare-engine/assets';\nimport { useCallback, useEffect, useRef, useState } from 'react';\n\n/**\n * Structural offscreen surface — the subset `GameView`'s scene capture needs.\n * Declared locally so this module does not depend on RN-Skia's concrete types.\n */\nexport interface SceneSurfaceLike<TImage = SkImageLike> {\n getCanvas(): SceneSurfaceCanvasLike;\n makeImageSnapshot(): TImage;\n flush(): void;\n}\n\n/** The canvas subset used when capturing a frame's picture. */\nexport interface SceneSurfaceCanvasLike {\n drawPicture(picture: unknown): void;\n}\n\n/** Structural Skia module — only the offscreen-surface factory is needed. */\nexport interface SceneSurfaceModuleLike<TImage = SkImageLike> {\n Surface: {\n MakeOffscreen(width: number, height: number): SceneSurfaceLike<TImage> | null;\n };\n}\n\n/** A size-keyed offscreen surface holder. */\nexport interface SceneSurfaceCache<TImage = SkImageLike> {\n /**\n * The surface for this viewport size, allocating only when the size actually\n * changed. Returns null for a zero-sized viewport, or when Skia refuses the\n * allocation.\n */\n acquire(width: number, height: number): SceneSurfaceLike<TImage> | null;\n /** Release the live surface. Safe to call repeatedly. */\n dispose(): void;\n}\n\n/**\n * `Symbol.dispose` is not in this project's ES2022 lib, so the well-known\n * symbol is looked up at runtime instead of written as a computed key.\n */\nconst DISPOSE = (Symbol as unknown as { dispose?: symbol }).dispose;\n\nfunction releaseSkiaObject(target: unknown): void {\n if (DISPOSE === undefined || target === null || target === undefined) return;\n const disposer = (target as Record<symbol, unknown>)[DISPOSE];\n if (typeof disposer === 'function') {\n (disposer as () => void).call(target);\n }\n}\n\n/**\n * Reuse one offscreen surface across frames instead of allocating per frame.\n *\n * On **web** this is a correctness requirement, not an optimisation. RN-Skia's\n * web `MakeOffscreen` builds a fresh `OffscreenCanvas` and a fresh WebGL\n * context on every call and releases neither; Chrome caps a page at 16 live\n * WebGL contexts and evicts the oldest, which is the on-screen `<Canvas>`.\n * A per-frame allocation therefore kills the visible canvas within ~16 frames\n * while the game loop keeps running — the app looks alive and paints nothing.\n * Measured and written up in docs/plans/web-target-2026-08.md §12.\n */\nexport function createSceneSurfaceCache<TImage>(\n Skia: SceneSurfaceModuleLike<TImage>,\n): SceneSurfaceCache<TImage> {\n let surface: SceneSurfaceLike<TImage> | null = null;\n let currentWidth = 0;\n let currentHeight = 0;\n\n const dispose = (): void => {\n if (surface === null) return;\n releaseSkiaObject(surface);\n surface = null;\n currentWidth = 0;\n currentHeight = 0;\n };\n\n return {\n acquire(width: number, height: number): SceneSurfaceLike<TImage> | null {\n if (width <= 0 || height <= 0) return null;\n if (surface !== null && currentWidth === width && currentHeight === height) {\n return surface;\n }\n dispose();\n const next = Skia.Surface.MakeOffscreen(width, height);\n if (next === null) return null;\n surface = next;\n currentWidth = width;\n currentHeight = height;\n return surface;\n },\n dispose,\n };\n}\n\n/** A snapshot that can be detached from its GL context (RN-Skia web SkImage). */\ninterface DetachableImage<TImage> {\n makeNonTextureImage?(): TImage;\n}\n\n/** Per-frame scene capture over a reused surface. */\nexport interface SceneCapture<TImage> {\n /**\n * Draw `picture` into the reused surface and return an image detached from\n * that surface's GL context. Returns null for a zero-sized viewport.\n */\n capture(picture: unknown, width: number, height: number): TImage | null;\n /** Release the surface and the frame image still held. */\n dispose(): void;\n}\n\n/**\n * Capture the scene into a reused offscreen surface, releasing Skia objects as\n * it goes.\n *\n * Two leaks have to be avoided here, and both were measured in a browser\n * (docs/plans/web-target-2026-08.md §12):\n *\n * 1. **Per-frame surfaces.** RN-Skia's web `MakeOffscreen` builds an\n * `OffscreenCanvas` + WebGL context per call and releases neither; Chrome\n * caps a page at 16 live contexts and evicts the on-screen canvas. Hence the\n * surface cache.\n * 2. **Per-frame images.** `makeNonTextureImage()` reads the whole viewport back\n * into the wasm heap. Leaving old CPU images unreleased exhausts that heap.\n * A single-slot release strategy is not enough: RN-Skia's web `<Canvas>`\n * paints on its own rAF, which fires *after* the capture, so the image handed\n * to React on frame N is still in use when frame N+1 runs. Releasing it\n * immediately causes `BindingError: Cannot pass deleted object as a pointer of\n * type Image const*` from `JsiSkImage.width` every frame and a blank canvas.\n * Measured at 2560×1215 / Chrome (WEB-3):\n * hold=1 (one slot — what shipped at WEB-2) → blank, BindingError every frame\n * hold=2 → blank\n * hold=3 → 1378 frames, zero errors\n * A FIFO ring of depth 3 is the measured minimum.\n *\n * The snapshot is released as soon as it has been copied. Frame images are\n * released once the ring exceeds depth 3, ensuring the canvas's rAF always has\n * a live image to paint from.\n */\n\nconst RETENTION_DEPTH = 3;\n\nexport function createSceneCapture<TImage>(\n Skia: SceneSurfaceModuleLike<TImage>,\n): SceneCapture<TImage> {\n const surfaces = createSceneSurfaceCache(Skia);\n const ring: TImage[] = [];\n\n return {\n capture(picture: unknown, width: number, height: number): TImage | null {\n const surface = surfaces.acquire(width, height);\n if (surface === null) return null;\n\n surface.getCanvas().drawPicture(picture);\n surface.flush();\n\n const snapshot = surface.makeImageSnapshot();\n const detachable = snapshot as DetachableImage<TImage>;\n const detached = detachable.makeNonTextureImage ? detachable.makeNonTextureImage() : snapshot;\n\n if (detached !== snapshot) releaseSkiaObject(snapshot);\n ring.push(detached);\n if (ring.length > RETENTION_DEPTH) {\n releaseSkiaObject(ring.shift()!);\n }\n return detached;\n },\n dispose(): void {\n for (const img of ring) {\n releaseSkiaObject(img);\n }\n ring.length = 0;\n surfaces.dispose();\n },\n };\n}\n\n/**\n * Returned by `useWebSceneTexture`. `image` is the latest captured frame (null\n * until the first capture). `capture` is the imperative callback `GameView`'s\n * frame callback invokes directly each frame.\n */\nexport interface WebSceneTexture<TImage> {\n image: TImage | null;\n capture(picture: unknown, width: number, height: number): void;\n}\n\n/**\n * Web scene texture (imperative form): expose a `capture` callback that\n * `GameView`'s `onPreRender` frame callback invokes directly instead of pushing\n * a picture through React state.\n *\n * The previous reactive form called `setImage` from a `useEffect` keyed on\n * `[Skia, picture, width, height]`. `onPreRender` would call `setPicture`,\n * React would re-render, the effect would re-run, `setImage` would re-render\n * again. That is a setState-in-a-passive-effect cascade; React's\n * NESTED_PASSIVE_UPDATE_LIMIT (50) trips and logs `Maximum update depth\n * exceeded` on every web load. It also costs two React renders per frame and\n * delays the captured image by two hops.\n *\n * `GameLoop` schedules via `requestAnimationFrame`, so calling `setImage`\n * directly from `onPreRender` is an ordinary root update that never touches the\n * passive-update counter. Both hooks still run on both platforms so hook order\n * never varies, but this hook is now inert on native simply because nothing\n * calls `capture` on that platform.\n *\n * `makeNonTextureImage()` is required regardless of reuse: the offscreen surface\n * has its own WebGL context, and a texture-backed image cannot be sampled by the\n * on-screen canvas's context. It also makes reuse safe — the snapshot is copied\n * off the GPU so next frame's draw into the same surface cannot disturb the image\n * React still holds.\n *\n * The surface is never cleared here: `Renderer.begin()` records\n * `canvas.clear(clearColor)` into the picture itself (packages/render\n * `renderer.ts:75`), so replaying the picture repaints the full surface.\n */\nexport function useWebSceneTexture<TImage>(\n Skia: SceneSurfaceModuleLike<TImage>,\n): WebSceneTexture<TImage> {\n const captureRef = useRef<SceneCapture<TImage> | null>(null);\n const [image, setImage] = useState<TImage | null>(null);\n\n useEffect(() => {\n return () => {\n captureRef.current?.dispose();\n captureRef.current = null;\n };\n }, []);\n\n const capture = useCallback(\n (picture: unknown, width: number, height: number): void => {\n if (picture === null || picture === undefined) return;\n if (captureRef.current === null) {\n captureRef.current = createSceneCapture(Skia);\n }\n const next = captureRef.current.capture(picture, width, height);\n if (next !== null) setImage(next);\n },\n [Skia],\n );\n\n return { image, capture };\n}\n","import type { SkImageLike } from '@flare-engine/assets';\nimport {\n createFrameRenderer,\n type FrameRenderer,\n type FrameRendererCompiledPass,\n type FrameRendererModule,\n type FrameRendererPostFxChain,\n type FrameRendererPostFxDescriptor,\n type FrameRendererPostFxRuntime,\n type SpriteDrawCommand,\n} from '@flare-engine/render';\nimport type { SkColor, SkImage, SkImageFilter, SkRuntimeEffect } from '@shopify/react-native-skia';\n\n/** Structural canvas — minimal subset needed for offscreen rendering. */\nexport interface SkOffscreenCanvasLike {\n drawPicture(picture: unknown): void;\n drawImageRect(image: unknown, src: unknown, dst: unknown, paint: unknown): void;\n drawRect(rect: unknown, paint: unknown): void;\n clear(color: unknown): void;\n}\n\n/** Structural canvas surface — minimal subset needed for offscreen capture. */\nexport interface SkSurfaceLike {\n getCanvas(): SkOffscreenCanvasLike;\n makeImageSnapshot(): SkImageLike;\n /** Force queued draws to execute. Required for GPU-backed surfaces before\n * makeImageSnapshot is called, otherwise the snapshot may capture\n * uninitialized texture content. See Skia's SkSurface.flush docs. */\n flush(): void;\n}\n\n/**\n * A single post-processing pass descriptor built by `buildPostFxPasses`.\n * GameView maps each descriptor to a `<RuntimeShader>` child of `<Image>`.\n */\nexport interface PostFxPassDescriptor {\n /** Stable id, used as React key. */\n readonly id: string;\n /** The compiled SkRuntimeEffect passed as `<RuntimeShader source={…}/>`. */\n readonly source: SkRuntimeEffect;\n /**\n * Uniform map keyed by SkSL uniform name. Vector uniforms are `number[]`\n * whose length equals `columns * rows`; scalar uniforms are `number`.\n * Built by zipping `shader.getUniformName(i)` → sliced Float32Array values.\n */\n readonly uniforms: Record<string, number | readonly number[]>;\n /**\n * Extra child shader slots beyond the implicit scene sampler. Empty for every\n * built-in PT effect; only color-grading-lut would populate it. Each entry\n * is an SkImage that GameView wraps in `<ImageShader>`.\n */\n readonly children: readonly SkImage[];\n}\n\n/**\n * Take a snapshot of `surface` and detach it from the GPU context so it can\n * be safely sampled from a different GrDirectContext (e.g. the on-screen\n * Canvas). RN-Skia's MakeOffscreen allocates a private Gr context per\n * surface; without this step Skia silently renders black when the texture is\n * read from any other context.\n *\n * Calls `makeNonTextureImage()` when available (RN-Skia ≥ 0.1 on device).\n * Falls back to the raw snapshot when the method is absent (CPU surfaces,\n * test mocks) — no behavioural change in those paths.\n */\nfunction detachSnapshot(surface: SkSurfaceLike): SkImageLike {\n const snap = surface.makeImageSnapshot();\n if (typeof snap.makeNonTextureImage === 'function') {\n return snap.makeNonTextureImage();\n }\n return snap;\n}\n\n/** A single axis-aligned rectangle shape to draw into an offscreen surface. */\nexport interface ShapeRect {\n readonly x: number;\n readonly y: number;\n readonly w: number;\n readonly h: number;\n /** ARGB packed integer: 0xAARRGGBB */\n readonly color: number;\n}\n\n/** Options for `renderShapesToImage`. */\nexport interface RenderShapesOpts {\n readonly width: number;\n readonly height: number;\n /** ARGB packed integer: 0xAARRGGBB */\n readonly clearColor: number;\n readonly shapes: readonly ShapeRect[];\n}\n\n/**\n * Narrow view of the Skia module — only the factories the bridge needs.\n * Declared as its own type so tests can pass a plain mock without pulling\n * in the full `@shopify/react-native-skia` surface.\n *\n * Extends `FrameRendererModule` from `@flare-engine/render` with the\n * native Surface and ImageFilter that are not needed in render-web.\n */\nexport type SkiaModuleLike = FrameRendererModule & {\n RuntimeEffect?: { Make(sksl: string): SkRuntimeEffect | null };\n Surface?: {\n Make(width: number, height: number): SkSurfaceLike | null;\n MakeOffscreen?(width: number, height: number): SkSurfaceLike | null;\n };\n /** Optional — present on device builds; absent in CPU/test mocks (drop-shadow falls back to the default paint). */\n ImageFilter?: {\n MakeDropShadow(\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null,\n ): SkImageFilter;\n };\n};\n\n/**\n * A single compiled postfx pass descriptor produced by the runtime.\n * Re-exported from render's FrameRendererCompiledPass for consumer compatibility.\n */\nexport type CompiledPassLike = FrameRendererCompiledPass;\n\n/**\n * Minimal structural view of a PostFxRuntime that the bridge needs.\n * Re-exported from render's FrameRendererPostFxRuntime for consumer compatibility.\n */\nexport type PostFxRuntimeLike = FrameRendererPostFxRuntime;\n\n/** Minimal structural view of an EffectChain the bridge needs. */\nexport type PostFxChainLike = FrameRendererPostFxChain;\n\n/**\n * Frame renderer that bridges a `SpriteBatch` to a Skia `<Picture>`.\n * The implementation lives in `@flare-engine/render` (`createFrameRenderer`);\n * this interface narrows the return type for native-Skia consumers.\n */\nexport type SkiaFrameRenderer = FrameRenderer;\n\n/**\n * Create a `SkiaFrameRenderer`.\n *\n * `Skia` is passed in (rather than imported) so unit tests can supply a\n * mock. Production code constructs this once inside `<GameView>` using the\n * real `Skia` import from `@shopify/react-native-skia`.\n *\n * Delegates to `createFrameRenderer` from `@flare-engine/render` — the\n * frame-renderer body is backend-neutral and shared with render-web.\n */\nexport function createSkiaFrameRenderer(Skia: SkiaModuleLike): SkiaFrameRenderer {\n return createFrameRenderer(Skia);\n}\n\n// Scratch buffer for ARGB → RGBA-float unpacking in renderShapesToImage.\n// Allocated once per call (not module-level) so concurrent callers are safe.\n// Hot paths inside createSkiaFrameRenderer use their own pre-allocated buffers.\n\n/**\n * Render a list of solid rectangles into a fresh offscreen surface and return\n * the resulting image snapshot. Returns `null` if `Surface` factory is absent or\n * fails. The surface is not cached — callers that need reuse should cache the\n * returned image themselves.\n */\nexport function renderShapesToImage(\n skia: SkiaModuleLike,\n opts: RenderShapesOpts,\n): SkImageLike | null {\n if (skia.Surface === undefined) return null;\n const surface = skia.Surface.Make(opts.width, opts.height);\n if (surface === null) return null;\n\n const scratch = new Float32Array(4);\n const canvas = surface.getCanvas();\n\n unpackArgb(scratch, opts.clearColor);\n canvas.clear(scratch);\n\n const paint = skia.Paint();\n for (const shape of opts.shapes) {\n unpackArgb(scratch, shape.color);\n if (paint.setColor) paint.setColor(scratch);\n const rect = skia.XYWHRect(shape.x, shape.y, shape.w, shape.h);\n canvas.drawRect(rect, paint);\n }\n\n return detachSnapshot(surface);\n}\n\n/** Unpack a 0xAARRGGBB integer into a Float32Array [r, g, b, a] in 0..1 range. */\nfunction unpackArgb(out: Float32Array, argb: number): void {\n out[0] = ((argb >>> 16) & 0xff) / 255;\n out[1] = ((argb >>> 8) & 0xff) / 255;\n out[2] = (argb & 0xff) / 255;\n out[3] = ((argb >>> 24) & 0xff) / 255;\n}\n\n// Re-export the PostFxPassDescriptor shape for GameView consumers.\n// The type is defined above in this file so it carries the concrete SkRuntimeEffect/SkImage\n// types that GameView needs — unlike the generic FrameRendererPostFxDescriptor from render.\n// Alias for clarity at call-sites.\nexport type { FrameRendererPostFxDescriptor, SpriteDrawCommand };\n","import type { AssetLoader } from '@flare-engine/assets';\nimport { AssetManager } from '@flare-engine/assets';\nimport { AudioManager } from '@flare-engine/audio';\nimport { GameLoop } from '@flare-engine/core';\nimport { Position, World } from '@flare-engine/ecs';\nimport { InputManager } from '@flare-engine/input';\nimport { Camera2D, createRenderSystem, Renderer, Sprite, SpriteBatch } from '@flare-engine/render';\nimport { SceneManager } from '@flare-engine/scene';\nimport type { CanvasRef, SkImage, SkPicture } from '@shopify/react-native-skia';\nimport {\n Canvas,\n Image,\n RuntimeShader,\n Skia,\n useCanvasRef,\n usePictureAsTexture,\n} from '@shopify/react-native-skia';\nimport type React from 'react';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { GestureResponderEvent, LayoutChangeEvent, ViewStyle } from 'react-native';\nimport { PixelRatio, Platform, StyleSheet, View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { GameContext, type GameContextValue } from './game-context.js';\nimport { type SafeArea, SafeAreaContext } from './safe-area.js';\nimport { useWebSceneTexture } from './scene-texture.js';\nimport { createSkiaFrameRenderer, type PostFxPassDescriptor } from './skia-bridge.js';\n\n/** Render hook invoked during the frame — receives the game context and\n * the active Skia canvas for direct draw calls. Hooks run between\n * `renderer.applyCamera()` and `renderer.end()`, so the camera transform\n * is already applied. */\nexport type RenderHook = (ctx: GameContextValue, canvas: unknown) => void;\n\n/** Render hook for post-processing passes. Receives the game context, the\n * active Skia canvas, and the `SkiaFrameRenderer` bridge so the hook can\n * call `bridge.setPostFxBinding(runtime, chain)` to register the runtime\n * and chain for the current frame.\n * `bridge` is `null` only on platforms where no Skia renderer was created\n * (future web fallback). */\nexport type PostFxRenderHook = (\n ctx: GameContextValue,\n canvas: unknown,\n bridge: import('./skia-bridge.js').SkiaFrameRenderer | null,\n) => void;\n\n/** Configuration passed to <GameView>. */\nexport interface GameConfig {\n /** Fixed timestep in seconds (default 1/60). */\n fixedDt?: number;\n /** Maximum dt cap in seconds (default 0.25). */\n maxDt?: number;\n /** Background clear color as 32-bit ARGB int (default 0xFF000000). */\n clearColor?: number;\n /** Asset loader function — injected into AssetManager at construction. */\n assetLoader?: AssetLoader;\n /** Called after camera transform and before the sprite render system.\n * Intended for tilemap / background layer rendering. */\n onRenderBackground?: RenderHook;\n /** Called after the sprite batch has been flushed, before `renderer.end()`.\n * Receives the bridge as 3rd arg so the hook can call\n * `bridge.setPostFxBinding(runtime, chain)` to register the postfx runtime\n * and chain for the current frame. */\n onRenderPostFx?: PostFxRenderHook;\n /**\n * Promote the underlying Skia surface from a TextureView (default) to a\n * SurfaceView on Android. With `opaque: true`, SurfaceView paints in a\n * separate compositing layer below the regular RN view tree, which lets\n * full-screen RN overlays (HUDs, menus) render on top without needing\n * elevation/zIndex tricks.\n *\n * Without this, RN-Skia's TextureView can clip overlapping full-screen\n * RN siblings on certain Android devices/Fabric configurations.\n *\n * Implies the canvas content is opaque — the clearColor's alpha must be\n * fully opaque (0xFF). Defaults to `false` to preserve the current\n * iOS-equivalent behavior.\n */\n opaque?: boolean;\n}\n\n/** Props for the <GameView> component. */\nexport interface GameViewProps {\n /** Game configuration. */\n config?: GameConfig;\n /** Called once the game context is ready (loop not yet started). */\n onReady?: (ctx: GameContextValue) => void;\n /** Style applied to the outer View container. */\n style?: ViewStyle;\n /** Optional overlay children (e.g. VirtualJoystick, VirtualButton). */\n children?: React.ReactNode;\n /** Explicit safe-area insets. If omitted, resolved from react-native-safe-area-context\n * via `useSafeAreaInsets()` (requires a `<SafeAreaProvider>` ancestor; falls back to\n * zero insets when no provider is mounted). */\n safeArea?: SafeArea;\n}\n\n/**\n * GameView — root component that sets up the Skia canvas, game loop,\n * and all core game systems. Provides GameContext to descendants.\n *\n * Overlay controls (VirtualJoystick, VirtualButton) should be placed\n * as children; they render on top of the Skia canvas.\n */\nexport function GameView({\n config,\n onReady,\n style,\n children,\n safeArea,\n}: GameViewProps): React.ReactElement {\n const insets = useSafeAreaInsets();\n const resolvedSafeArea: SafeArea = safeArea ?? insets;\n const canvasRef = useCanvasRef();\n const [picture, setPicture] = useState<SkPicture | null>(null);\n const [passes, setPasses] = useState<readonly PostFxPassDescriptor[]>(EMPTY_PASSES);\n const [viewportSize, setViewportSize] = useState({ w: 0, h: 0 });\n const pd = PixelRatio.get();\n const sceneSize = useMemo(\n () => ({ width: viewportSize.w * pd, height: viewportSize.h * pd }),\n [viewportSize.w, viewportSize.h, pd],\n );\n // Web and native capture the scene differently, but BOTH hooks run on both\n // platforms so hook order never varies.\n //\n // Native: usePictureAsTexture converts the SkPicture → texture each frame.\n // Web: useWebSceneTexture is now imperative — GameView's onPreRender frame\n // callback calls its capture(picture, width, height) directly instead of\n // pushing the picture through React state. The old reactive approach\n // (setState-in-a-passive-effect) tripped React's NESTED_PASSIVE_UPDATE_LIMIT\n // (50) and logged \"Maximum update depth exceeded\" on every web load. It also\n // cost two React renders per frame and added one hop of image latency. The\n // web hook is inert on native because nothing calls capture there.\n //\n // usePictureAsTexture calls MakeOffscreen per picture on web, allocating an\n // unreleased WebGL context every frame and evicting the on-screen canvas at\n // Chrome's 16-context cap; the web path reuses one surface instead.\n // See docs/plans/web-target-2026-08.md §12.\n const isWeb = Platform.OS === 'web';\n const nativeTexture = usePictureAsTexture(isWeb ? null : picture, sceneSize);\n const { image: webTexture, capture: captureWebScene } = useWebSceneTexture<SkImage>(Skia);\n const sceneTexture = isWeb ? webTexture : nativeTexture;\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: intentional mount-only\n const ctx = useMemo<GameContextValue>(() => {\n const loop = new GameLoop({\n fixedDt: config?.fixedDt,\n maxDt: config?.maxDt,\n });\n const world = new World();\n const camera = new Camera2D();\n const input = new InputManager();\n const audio = new AudioManager();\n const noop: AssetLoader = () => Promise.resolve(null);\n const assets = new AssetManager(config?.assetLoader ?? noop);\n const scenes = new SceneManager();\n const renderer = new Renderer();\n const batch = new SpriteBatch();\n return { world, camera, input, audio, assets, scenes, loop, renderer, batch };\n }, []);\n\n // Warn once per <GameView> instance (not per page load) so each independently\n // mounted instance with a postfx binding gets its own one-time notice.\n const webPostFxWarnedRef = useRef(false);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: intentional mount-only\n useEffect(() => {\n const bridge = createSkiaFrameRenderer(Skia);\n ctx.renderer.setCanvas(bridge.canvas);\n\n const clearColor = config?.clearColor ?? 0xff000000;\n const onRenderBackground = config?.onRenderBackground;\n const onRenderPostFx = config?.onRenderPostFx;\n\n const spriteQuery = ctx.world.query(Position, Sprite);\n const renderSystem = createRenderSystem(ctx.world, spriteQuery, Position, Sprite, ctx.batch);\n\n // Last passes signature pushed to state; gates setPasses so an unchanged\n // (or empty) chain does not churn a fresh array + RuntimeShader tree every\n // frame. Seeded to the same EMPTY_PASSES the state holds, so an empty chain\n // never triggers a re-render from passes.\n let prevBuilt: readonly PostFxPassDescriptor[] = EMPTY_PASSES;\n\n const unsubscribeLate = ctx.loop.onLateUpdate.add((dt) => {\n ctx.camera.update(dt);\n ctx.input.update();\n });\n\n const unsubscribePre = ctx.loop.onPreRender.add(() => {\n const w = ctx.camera.viewportWidth;\n const h = ctx.camera.viewportHeight;\n bridge.beginFrame(w, h, ctx.loop.clock.elapsed, pd);\n ctx.renderer.begin(clearColor);\n ctx.renderer.applyCamera(\n ctx.camera.effectiveX,\n ctx.camera.effectiveY,\n ctx.camera.zoom,\n ctx.camera.rotation,\n w,\n h,\n );\n if (onRenderBackground) onRenderBackground(ctx, ctx.renderer.canvas);\n renderSystem();\n ctx.batch.flush(bridge.drawAtlas, ctx.renderer);\n if (onRenderPostFx) onRenderPostFx(ctx, ctx.renderer.canvas, bridge);\n ctx.renderer.end();\n const pic = bridge.endFrame() as SkPicture | null;\n if (pic !== null) {\n if (isWeb) captureWebScene(pic, w * pd, h * pd);\n else setPicture(pic);\n }\n if (!isWeb) {\n const built = bridge.buildPostFxPasses(null, null, w, h) as readonly PostFxPassDescriptor[];\n if (!samePasses(prevBuilt, built)) {\n prevBuilt = built.length === 0 ? EMPTY_PASSES : built;\n setPasses(prevBuilt);\n }\n } else if (bridge.hasPostFxBinding() && !webPostFxWarnedRef.current) {\n console.warn(\n 'postfx chain skipped: Skia.RuntimeShaderBuilder and' +\n ' ImageFilter.MakeRuntimeShaderWithChildren both throw' +\n ' \"Not implemented on React Native Web\".',\n );\n webPostFxWarnedRef.current = true;\n }\n canvasRef.current?.redraw();\n });\n\n onReady?.(ctx);\n ctx.loop.start();\n return () => {\n unsubscribeLate();\n unsubscribePre();\n ctx.loop.stop();\n };\n }, []);\n\n const handleLayout = useCallback(\n (event: LayoutChangeEvent): void => {\n const { width, height } = event.nativeEvent.layout;\n ctx.camera.setViewport(width, height);\n setViewportSize({ w: width, h: height });\n },\n [ctx],\n );\n\n const onGrant = useCallback(\n (e: GestureResponderEvent): void => {\n const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;\n if (changedTouches.length === 0) {\n ctx.input.onPointerDown(Number(identifier), locationX, locationY);\n return;\n }\n for (let i = 0; i < changedTouches.length; i++) {\n const t = changedTouches[i];\n if (t === undefined) continue;\n ctx.input.onPointerDown(Number(t.identifier), t.locationX, t.locationY);\n }\n },\n [ctx],\n );\n const onMove = useCallback(\n (e: GestureResponderEvent): void => {\n const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;\n if (changedTouches.length === 0) {\n ctx.input.onPointerMove(Number(identifier), locationX, locationY);\n return;\n }\n for (let i = 0; i < changedTouches.length; i++) {\n const t = changedTouches[i];\n if (t === undefined) continue;\n ctx.input.onPointerMove(Number(t.identifier), t.locationX, t.locationY);\n }\n },\n [ctx],\n );\n const onRelease = useCallback(\n (e: GestureResponderEvent): void => {\n const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;\n if (changedTouches.length === 0) {\n ctx.input.onPointerUp(Number(identifier), locationX, locationY);\n return;\n }\n for (let i = 0; i < changedTouches.length; i++) {\n const t = changedTouches[i];\n if (t === undefined) continue;\n ctx.input.onPointerUp(Number(t.identifier), t.locationX, t.locationY);\n }\n },\n [ctx],\n );\n\n const containerStyle = useMemo(() => [styles.container, style], [style]);\n const passElements = useMemo(\n () => passes.map((p) => <RuntimeShader key={p.id} source={p.source} uniforms={p.uniforms} />),\n [passes],\n );\n\n return (\n <SafeAreaContext.Provider value={resolvedSafeArea}>\n <GameContext.Provider value={ctx}>\n <View\n style={containerStyle}\n onLayout={handleLayout}\n onStartShouldSetResponder={returnTrue}\n onResponderGrant={onGrant}\n onResponderMove={onMove}\n onResponderRelease={onRelease}\n onResponderTerminate={onRelease}\n >\n <Canvas\n ref={canvasRef as React.Ref<CanvasRef>}\n style={StyleSheet.absoluteFill}\n pointerEvents=\"none\"\n opaque={config?.opaque ?? false}\n >\n {viewportSize.w === 0 || sceneTexture == null ? null : (\n <Image\n image={sceneTexture}\n x={0}\n y={0}\n width={viewportSize.w}\n height={viewportSize.h}\n fit=\"cover\"\n >\n {passElements}\n </Image>\n )}\n </Canvas>\n {children}\n </View>\n </GameContext.Provider>\n </SafeAreaContext.Provider>\n );\n}\n\nfunction returnTrue(): boolean {\n return true;\n}\n\n/** Stable empty-chain reference — an empty `buildPostFxPasses` result collapses\n * to this so the `passes` state never changes for a postfx-free GameView. */\nconst EMPTY_PASSES: readonly PostFxPassDescriptor[] = [];\n\n/**\n * Shallow structural equality of two pass lists. The signature is length +\n * per-pass `id` + shader ref + child-image refs + uniform values. Uniforms are\n * compared (not just `id`/`source`) because animating effects — the hit-flash\n * decay and timed triggers — keep a constant `id`/`source` while only their\n * uniform values change frame to frame; excluding them would freeze those\n * animations. Cost is trivial: postfx chains hold a handful of scalar/short-vec\n * uniforms.\n */\nfunction samePasses(\n a: readonly PostFxPassDescriptor[],\n b: readonly PostFxPassDescriptor[],\n): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n const pa = a[i];\n const pb = b[i];\n if (pa === undefined || pb === undefined) return false;\n if (pa.id !== pb.id || pa.source !== pb.source) return false;\n if (!sameChildren(pa.children, pb.children)) return false;\n if (!sameUniforms(pa.uniforms, pb.uniforms)) return false;\n }\n return true;\n}\n\nfunction sameChildren(a: readonly unknown[], b: readonly unknown[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\nfunction sameUniforms(\n a: PostFxPassDescriptor['uniforms'],\n b: PostFxPassDescriptor['uniforms'],\n): boolean {\n const aKeys = Object.keys(a);\n if (aKeys.length !== Object.keys(b).length) return false;\n for (const key of aKeys) {\n const va = a[key];\n const vb = b[key];\n if (va === undefined || vb === undefined) return false;\n if (typeof va === 'number') {\n if (va !== vb) return false;\n } else {\n if (typeof vb === 'number' || va.length !== vb.length) return false;\n for (let i = 0; i < va.length; i++) {\n if (va[i] !== vb[i]) return false;\n }\n }\n }\n return true;\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n});\n","import type { Query } from '@flare-engine/ecs';\nimport { useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport { GameContext, type GameContextValue } from './game-context.js';\n\n/**\n * useGame — returns the GameContextValue from the nearest <GameView>.\n * Throws if called outside a <GameView>.\n */\nexport function useGame(): GameContextValue {\n const ctx = useContext(GameContext);\n if (!ctx) {\n throw new Error('useGame must be used inside a <GameView>');\n }\n return ctx;\n}\n\n/**\n * useEntity — subscribes to an ECS Query and returns the current entity list.\n * Re-renders when entities are added to or removed from the query.\n *\n * @param query An active Query obtained from world.query(...)\n */\nexport function useEntity(query: Query): readonly number[] {\n const [entities, setEntities] = useState<readonly number[]>(() => Array.from(query));\n\n useEffect(() => {\n const refresh = () => setEntities(Array.from(query));\n\n const unsubAdd = query.onEntityAdded.add(refresh);\n const unsubRemove = query.onEntityRemoved.add(refresh);\n\n // Sync initial state (query may have changed between render and effect)\n refresh();\n\n return () => {\n unsubAdd();\n unsubRemove();\n };\n }, [query]);\n\n return entities;\n}\n\n/**\n * useGameLoop — registers a per-frame callback on the game loop's onUpdate signal.\n * The callback is called each frame with delta time in seconds.\n * Automatically unregisters on unmount.\n *\n * @param callback Function called each frame with dt in seconds.\n */\nexport function useGameLoop(callback: (dt: number) => void): void {\n const { loop } = useGame();\n const callbackRef = useRef(callback);\n callbackRef.current = callback;\n\n const stable = useCallback((dt: number) => {\n callbackRef.current(dt);\n }, []);\n\n useEffect(() => {\n const unsub = loop.onUpdate.add(stable);\n return () => {\n unsub();\n };\n }, [loop, stable]);\n}\n","import type React from 'react';\nimport type { ViewStyle } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\n/** Props for the <LoadingScreen> component. */\nexport interface LoadingScreenProps {\n /** Progress in [0, 1]. Values outside this range are clamped. */\n progress: number;\n /** Style applied to the outer container (covers parent by default). */\n style?: ViewStyle;\n /** Filled portion color. */\n barColor?: string;\n /** Track color. */\n trackColor?: string;\n /** Background color behind the track. */\n backgroundColor?: string;\n}\n\n/**\n * LoadingScreen — full-screen asset-load overlay.\n *\n * Renders before `<GameView>` mounts its Skia canvas (or alongside it\n * while `AssetManager.load()` resolves). Pure RN Views so it works\n * without a live Skia context. Consumers drive `progress` from the\n * AssetManager progress callback.\n */\nexport function LoadingScreen({\n progress,\n style,\n barColor = '#ffffff',\n trackColor = 'rgba(255,255,255,0.2)',\n backgroundColor = '#000000',\n}: LoadingScreenProps): React.ReactElement {\n const clamped = progress < 0 ? 0 : progress > 1 ? 1 : progress;\n const percent = `${Math.round(clamped * 100)}%` as `${number}%`;\n\n return (\n <View style={[styles.container, { backgroundColor }, style]}>\n <View style={[styles.track, { backgroundColor: trackColor }]}>\n <View style={[styles.bar, { width: percent, backgroundColor: barColor }]} />\n </View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 32,\n },\n track: {\n width: '80%',\n height: 6,\n borderRadius: 3,\n overflow: 'hidden',\n },\n bar: {\n height: '100%',\n },\n});\n","import type { Signal } from '@flare-engine/events';\nimport { easeOutCubic } from '@flare-engine/math';\nimport { useEffect, useRef, useState } from 'react';\n\nexport function useOverlayFade(visible: boolean, durationMs = 300): number {\n const target = visible ? 1 : 0;\n const [opacity, setOpacity] = useState<number>(target);\n const opacityRef = useRef<number>(opacity);\n const startRef = useRef<number | null>(null);\n const rafRef = useRef<number | null>(null);\n\n // Keep ref in sync with state (runs before effect)\n opacityRef.current = opacity;\n\n useEffect(() => {\n if (typeof requestAnimationFrame === 'undefined') {\n setOpacity(target);\n return;\n }\n const from = opacityRef.current;\n startRef.current = null;\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n\n const step = (now: number) => {\n if (startRef.current === null) startRef.current = now;\n const t = Math.min((now - startRef.current) / durationMs, 1);\n setOpacity(from + (target - from) * t);\n if (t < 1) {\n rafRef.current = requestAnimationFrame(step);\n }\n };\n rafRef.current = requestAnimationFrame(step);\n return () => {\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n };\n }, [target, durationMs]);\n\n return opacity;\n}\n\nexport function useCountUp(target: number, durationMs = 600): number {\n const [value, setValue] = useState<number>(target);\n const valueRef = useRef<number>(value);\n const startRef = useRef<number | null>(null);\n const rafRef = useRef<number | null>(null);\n\n // Keep ref in sync with state (runs before effect)\n valueRef.current = value;\n\n useEffect(() => {\n if (typeof requestAnimationFrame === 'undefined') {\n setValue(target);\n return;\n }\n const from = valueRef.current;\n startRef.current = null;\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n\n const step = (now: number) => {\n if (startRef.current === null) startRef.current = now;\n const t = Math.min((now - startRef.current) / durationMs, 1);\n setValue(from + (target - from) * easeOutCubic(t));\n if (t < 1) {\n rafRef.current = requestAnimationFrame(step);\n }\n };\n rafRef.current = requestAnimationFrame(step);\n return () => {\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n };\n }, [target, durationMs]);\n\n return value;\n}\n\nexport function useSignalState<T>(signal: Signal<T>, initial: T): T {\n const [state, setState] = useState<T>(initial);\n\n useEffect(() => {\n const disposer = signal.add(setState);\n return disposer;\n }, [signal]);\n\n return state;\n}\n","import type { SkiaAtlasModuleLike } from '@flare-engine/assets';\nimport { Skia } from '@shopify/react-native-skia';\n\n/**\n * The RN-Skia module adapted to the engine's structural atlas interface.\n * Centralises the one boundary assertion so template code stays cast-free.\n */\nexport const skiaAtlasModule: SkiaAtlasModuleLike = Skia as unknown as SkiaAtlasModuleLike;\n","import {\n createButtonState,\n pressButton,\n releaseButton,\n resetButtonFrame,\n type VirtualButtonState,\n} from '@flare-engine/input';\nimport type React from 'react';\nimport { useCallback, useRef } from 'react';\nimport type { ViewStyle } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\n/** Props for the <VirtualButton> component. */\nexport interface VirtualButtonProps {\n /** Called on each state change. */\n onStateChange?: (state: VirtualButtonState) => void;\n /** Style applied to the button. */\n style?: ViewStyle;\n /** Button label / overlay content. */\n children?: React.ReactNode;\n}\n\n/**\n * VirtualButton — an on-screen button overlay component.\n *\n * Uses raw `onTouchStart`/`onTouchEnd` so press and release fire regardless\n * of which ancestor holds the RN responder — enabling simultaneous use with\n * `<VirtualJoystick>` without responder conflicts.\n */\nexport function VirtualButton({\n onStateChange,\n style,\n children,\n}: VirtualButtonProps): React.ReactElement {\n const stateRef = useRef<VirtualButtonState>(createButtonState());\n\n const handlePress = useCallback(() => {\n resetButtonFrame(stateRef.current);\n pressButton(stateRef.current);\n onStateChange?.(stateRef.current);\n }, [onStateChange]);\n\n const handleRelease = useCallback(() => {\n resetButtonFrame(stateRef.current);\n releaseButton(stateRef.current);\n onStateChange?.(stateRef.current);\n }, [onStateChange]);\n\n return (\n <View\n style={[styles.button, style]}\n onTouchStart={handlePress}\n onTouchEnd={handleRelease}\n onTouchCancel={handleRelease}\n >\n {children}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n button: {\n width: 60,\n height: 60,\n borderRadius: 30,\n backgroundColor: 'rgba(255,255,255,0.3)',\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n","import {\n createJoystickState,\n releaseJoystick,\n updateJoystick,\n type VirtualJoystickConfig,\n type VirtualJoystickState,\n} from '@flare-engine/input';\nimport type React from 'react';\nimport { useCallback, useRef, useState } from 'react';\nimport type { GestureResponderEvent, ViewStyle } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\n/** Props for the <VirtualJoystick> component. */\nexport interface VirtualJoystickProps {\n /** Joystick configuration (dead zone, max radius). */\n config?: VirtualJoystickConfig;\n /** Called on each state change. */\n onStateChange?: (state: VirtualJoystickState) => void;\n /** Style applied to the outer container. */\n style?: ViewStyle;\n /** Custom node rendered in place of the default base circle View. */\n base?: React.ReactNode;\n /** Custom node rendered in place of the default knob View. */\n thumb?: React.ReactNode;\n}\n\n/**\n * VirtualJoystick — an on-screen joystick overlay component.\n *\n * Renders a base circle and a knob that follows the user's touch.\n * Claims the React Native touch responder so children of a parent that\n * also claims the responder (e.g. <GameView>) still receive move/end events.\n */\nexport function VirtualJoystick({\n config,\n onStateChange,\n style,\n base,\n thumb,\n}: VirtualJoystickProps): React.ReactElement {\n const stateRef = useRef<VirtualJoystickState>(createJoystickState());\n const sizeRef = useRef<{ w: number; h: number }>({ w: 0, h: 0 });\n const [knob, setKnob] = useState({ x: 0, y: 0 });\n\n const handleLayout = useCallback(\n (e: { nativeEvent: { layout: { width: number; height: number } } }) => {\n sizeRef.current = { w: e.nativeEvent.layout.width, h: e.nativeEvent.layout.height };\n },\n [],\n );\n\n const handleTouch = useCallback(\n (e: GestureResponderEvent) => {\n const { locationX, locationY } = e.nativeEvent;\n const { w, h } = sizeRef.current;\n updateJoystick(stateRef.current, w / 2, h / 2, locationX, locationY, config);\n onStateChange?.(stateRef.current);\n const { x, y } = stateRef.current.offset;\n setKnob((prev) => (prev.x === x && prev.y === y ? prev : { x, y }));\n },\n [config, onStateChange],\n );\n\n const handleRelease = useCallback(() => {\n releaseJoystick(stateRef.current);\n onStateChange?.(stateRef.current);\n setKnob((prev) => (prev.x === 0 && prev.y === 0 ? prev : { x: 0, y: 0 }));\n }, [onStateChange]);\n\n const maxRadius = config?.maxRadius ?? 50;\n\n return (\n <View\n style={[\n styles.center,\n ...(base ? [] : [styles.baseBg]),\n {\n width: maxRadius * 2,\n height: maxRadius * 2,\n borderRadius: maxRadius,\n },\n style,\n ]}\n onLayout={handleLayout}\n onStartShouldSetResponder={returnTrue}\n onMoveShouldSetResponder={returnTrue}\n onResponderGrant={handleTouch}\n onResponderMove={handleTouch}\n onResponderRelease={handleRelease}\n onResponderTerminate={handleRelease}\n onResponderTerminationRequest={returnFalse}\n >\n {base ? (\n <View style={StyleSheet.absoluteFill} pointerEvents=\"none\">\n {base}\n </View>\n ) : null}\n {thumb ? (\n <View\n style={{ transform: [{ translateX: knob.x }, { translateY: knob.y }] }}\n pointerEvents=\"none\"\n >\n {thumb}\n </View>\n ) : (\n <View\n style={[styles.knob, { transform: [{ translateX: knob.x }, { translateY: knob.y }] }]}\n />\n )}\n </View>\n );\n}\n\nfunction returnTrue(): boolean {\n return true;\n}\n\nfunction returnFalse(): boolean {\n return false;\n}\n\nconst styles = StyleSheet.create({\n center: {\n alignItems: 'center',\n justifyContent: 'center',\n },\n baseBg: {\n backgroundColor: 'rgba(255,255,255,0.2)',\n },\n knob: {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SAAS,cAAuB;CAC9B,OAAO;AACT;AAEA,MAAM,SAAS,WAAW,OAAO;CAC/B,QAAQ;EACN,YAAY;EACZ,gBAAgB;CAClB;CACA,QAAQ,EACN,iBAAiB,wBACnB;CACA,MAAM;EACJ,OAAO;EACP,QAAQ;EACR,cAAc;EACd,iBAAiB;CACnB;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["styles","returnTrue","styles","styles"],"sources":["../src/game-context.ts","../src/safe-area.ts","../src/scene-texture.ts","../src/skia-bridge.ts","../src/game-view.tsx","../src/hooks.ts","../src/loading-screen.tsx","../src/overlay-hooks.ts","../src/skia-atlas.ts","../src/virtual-button.tsx","../src/virtual-joystick.tsx"],"sourcesContent":["import type { AssetManager } from '@flare-engine/assets';\nimport type { AudioManager } from '@flare-engine/audio';\nimport type { GameLoop } from '@flare-engine/core';\nimport type { World } from '@flare-engine/ecs';\nimport type { InputManager } from '@flare-engine/input';\nimport type { Camera2D, Renderer, SpriteBatch } from '@flare-engine/render';\nimport type { SceneManager } from '@flare-engine/scene';\nimport { createContext } from 'react';\n\n/** The value exposed via GameContext. */\nexport interface GameContextValue {\n /** ECS world. */\n world: World;\n /** Primary 2D camera. */\n camera: Camera2D;\n /** Input manager (pointer, touches). */\n input: InputManager;\n /** Audio manager. */\n audio: AudioManager;\n /** Asset manager. */\n assets: AssetManager;\n /** Scene manager. */\n scenes: SceneManager;\n /** Game loop. */\n loop: GameLoop;\n /** Frame renderer (owns the draw phase). */\n renderer: Renderer;\n /** Sprite batch — queue `draw()` calls from systems or custom logic. */\n batch: SpriteBatch;\n}\n\n/**\n * React context that provides access to core game objects.\n * Null if accessed outside a <GameView>.\n */\nexport const GameContext = createContext<GameContextValue | null>(null);\n","import { createContext, useContext } from 'react';\n\nexport interface SafeArea {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport const SafeAreaContext = createContext<SafeArea | null>(null);\n\nexport function useSafeArea(): SafeArea {\n const value = useContext(SafeAreaContext);\n if (value === null) {\n throw new Error('useSafeArea must be used inside a <GameView>');\n }\n return value;\n}\n","import type { SkImageLike } from '@flare-engine/assets';\n\n/**\n * Structural offscreen surface — the subset `GameView`'s scene capture needs.\n * Declared locally so this module does not depend on RN-Skia's concrete types.\n */\nexport interface SceneSurfaceLike<TImage = SkImageLike> {\n getCanvas(): SceneSurfaceCanvasLike;\n makeImageSnapshot(): TImage;\n flush(): void;\n}\n\n/** The canvas subset used when capturing a frame's picture. */\nexport interface SceneSurfaceCanvasLike {\n drawPicture(picture: unknown): void;\n}\n\n/** Structural Skia module — only the offscreen-surface factory is needed. */\nexport interface SceneSurfaceModuleLike<TImage = SkImageLike> {\n Surface: {\n MakeOffscreen(width: number, height: number): SceneSurfaceLike<TImage> | null;\n };\n}\n\n/** A size-keyed offscreen surface holder. */\nexport interface SceneSurfaceCache<TImage = SkImageLike> {\n /**\n * The surface for this viewport size, allocating only when the size actually\n * changed. Returns null for a zero-sized viewport, or when Skia refuses the\n * allocation.\n */\n acquire(width: number, height: number): SceneSurfaceLike<TImage> | null;\n /** Release the live surface. Safe to call repeatedly. */\n dispose(): void;\n}\n\n/**\n * `Symbol.dispose` is not in this project's ES2022 lib, so the well-known\n * symbol is looked up at runtime instead of written as a computed key.\n */\nconst DISPOSE = (Symbol as unknown as { dispose?: symbol }).dispose;\n\nfunction releaseSkiaObject(target: unknown): void {\n if (DISPOSE === undefined || target === null || target === undefined) return;\n const disposer = (target as Record<symbol, unknown>)[DISPOSE];\n if (typeof disposer === 'function') {\n (disposer as () => void).call(target);\n }\n}\n\n/**\n * Reuse one offscreen surface across frames instead of allocating per frame.\n *\n * On **web** this is a correctness requirement, not an optimisation. RN-Skia's\n * web `MakeOffscreen` builds a fresh `OffscreenCanvas` and a fresh WebGL\n * context on every call and releases neither; Chrome caps a page at 16 live\n * WebGL contexts and evicts the oldest, which is the on-screen `<Canvas>`.\n * A per-frame allocation therefore kills the visible canvas within ~16 frames\n * while the game loop keeps running — the app looks alive and paints nothing.\n * Measured and written up in docs/plans/web-target-2026-08.md §12.\n */\nexport function createSceneSurfaceCache<TImage>(\n Skia: SceneSurfaceModuleLike<TImage>,\n): SceneSurfaceCache<TImage> {\n let surface: SceneSurfaceLike<TImage> | null = null;\n let currentWidth = 0;\n let currentHeight = 0;\n\n const dispose = (): void => {\n if (surface === null) return;\n releaseSkiaObject(surface);\n surface = null;\n currentWidth = 0;\n currentHeight = 0;\n };\n\n return {\n acquire(width: number, height: number): SceneSurfaceLike<TImage> | null {\n if (width <= 0 || height <= 0) return null;\n if (surface !== null && currentWidth === width && currentHeight === height) {\n return surface;\n }\n dispose();\n const next = Skia.Surface.MakeOffscreen(width, height);\n if (next === null) return null;\n surface = next;\n currentWidth = width;\n currentHeight = height;\n return surface;\n },\n dispose,\n };\n}\n\n/** A snapshot that can be detached from its GL context (RN-Skia web SkImage). */\ninterface DetachableImage<TImage> {\n makeNonTextureImage?(): TImage;\n}\n\n/** Per-frame scene capture over a reused surface. */\nexport interface SceneCapture<TImage> {\n /**\n * Draw `picture` into the reused surface and return an image detached from\n * that surface's GL context. Returns null for a zero-sized viewport.\n */\n capture(picture: unknown, width: number, height: number): TImage | null;\n /** Release the surface and the frame image still held. */\n dispose(): void;\n}\n\n/**\n * Options for `createSceneCapture`.\n *\n * `nonTextureImage` defaults to `true` (web semantics: call\n * `makeNonTextureImage()` to copy the snapshot off the surface's GL context so\n * the on-screen canvas can sample it).\n *\n * **This factory is web-only since XR-1c.** An earlier revision said the\n * snapshot \"is a true copy on native\", so `false` was safe there. That is\n * wrong: the native snapshot is GPU-backed and belongs to whichever context\n * created the surface. What actually makes it sampleable is building the\n * surface on the **UI thread**, which `game-view.tsx` does through\n * `scheduleOnUI`, not through a call into this module. Passing `false` here on native\n * yields a black frame; passing `true` fixes it only by forcing a per-frame\n * GPU→CPU readback. Verified on a Pixel 7 — external-review-2026-08.md §11.4b.\n *\n * `retentionDepth` defaults to 3 — the web-measured minimum, and the only\n * platform this runs on.\n */\nexport interface SceneCaptureOptions {\n nonTextureImage?: boolean;\n retentionDepth?: number;\n}\n\n/**\n * Capture the scene into a reused offscreen surface, releasing Skia objects as\n * it goes.\n *\n * Two leaks have to be avoided here, and both were measured in a browser\n * (docs/plans/web-target-2026-08.md §12):\n *\n * 1. **Per-frame surfaces.** RN-Skia's web `MakeOffscreen` builds an\n * `OffscreenCanvas` + WebGL context per call and releases neither; Chrome\n * caps a page at 16 live contexts and evicts the on-screen canvas. Hence the\n * surface cache.\n * 2. **Per-frame images.** `makeNonTextureImage()` reads the whole viewport back\n * into the wasm heap. Leaving old CPU images unreleased exhausts that heap.\n * A single-slot release strategy is not enough: RN-Skia's web `<Canvas>`\n * paints on its own rAF, which fires *after* the capture, so the image handed\n * to React on frame N is still in use when frame N+1 runs. Releasing it\n * immediately causes `BindingError: Cannot pass deleted object as a pointer of\n * type Image const*` from `JsiSkImage.width` every frame and a blank canvas.\n * Measured at 2560×1215 / Chrome (WEB-3):\n * hold=1 (one slot — what shipped at WEB-2) → blank, BindingError every frame\n * hold=2 → blank\n * hold=3 → 1378 frames, zero errors\n * A FIFO ring of depth 3 is the measured minimum.\n *\n * The snapshot is released as soon as it has been copied. Frame images are\n * released once the ring exceeds depth 3, ensuring the canvas's rAF always has\n * a live image to paint from.\n */\n\nexport function createSceneCapture<TImage>(\n Skia: SceneSurfaceModuleLike<TImage>,\n opts?: SceneCaptureOptions,\n): SceneCapture<TImage> {\n const useNonTexture = opts?.nonTextureImage ?? true;\n const retentionDepth = opts?.retentionDepth ?? 3;\n const surfaces = createSceneSurfaceCache(Skia);\n const ring: TImage[] = [];\n\n return {\n capture(picture: unknown, width: number, height: number): TImage | null {\n const surface = surfaces.acquire(width, height);\n if (surface === null) return null;\n\n surface.getCanvas().drawPicture(picture);\n surface.flush();\n\n const snapshot = surface.makeImageSnapshot();\n const detachable = snapshot as DetachableImage<TImage>;\n const detached =\n useNonTexture && detachable.makeNonTextureImage\n ? detachable.makeNonTextureImage()\n : snapshot;\n\n if (detached !== snapshot) releaseSkiaObject(snapshot);\n ring.push(detached);\n if (ring.length > retentionDepth) {\n releaseSkiaObject(ring.shift()!);\n }\n return detached;\n },\n dispose(): void {\n for (const img of ring) {\n releaseSkiaObject(img);\n }\n ring.length = 0;\n surfaces.dispose();\n },\n };\n}\n","import type { SkImageLike } from '@flare-engine/assets';\nimport {\n createFrameRenderer,\n type FrameRenderer,\n type FrameRendererCompiledPass,\n type FrameRendererModule,\n type FrameRendererPostFxChain,\n type FrameRendererPostFxDescriptor,\n type FrameRendererPostFxRuntime,\n type SpriteDrawCommand,\n} from '@flare-engine/render';\nimport type { SkColor, SkImage, SkImageFilter, SkRuntimeEffect } from '@shopify/react-native-skia';\n\n/** Structural canvas — minimal subset needed for offscreen rendering. */\nexport interface SkOffscreenCanvasLike {\n drawPicture(picture: unknown): void;\n drawImageRect(image: unknown, src: unknown, dst: unknown, paint: unknown): void;\n drawRect(rect: unknown, paint: unknown): void;\n clear(color: unknown): void;\n}\n\n/** Structural canvas surface — minimal subset needed for offscreen capture. */\nexport interface SkSurfaceLike {\n getCanvas(): SkOffscreenCanvasLike;\n makeImageSnapshot(): SkImageLike;\n /** Force queued draws to execute. Required for GPU-backed surfaces before\n * makeImageSnapshot is called, otherwise the snapshot may capture\n * uninitialized texture content. See Skia's SkSurface.flush docs. */\n flush(): void;\n}\n\n/**\n * A single post-processing pass descriptor built by `buildPostFxPasses`.\n * GameView maps each descriptor to a `<RuntimeShader>` child of `<Image>`.\n */\nexport interface PostFxPassDescriptor {\n /** Stable id, used as React key. */\n readonly id: string;\n /** The compiled SkRuntimeEffect passed as `<RuntimeShader source={…}/>`. */\n readonly source: SkRuntimeEffect;\n /**\n * Uniform map keyed by SkSL uniform name. Vector uniforms are `number[]`\n * whose length equals `columns * rows`; scalar uniforms are `number`.\n * Built by zipping `shader.getUniformName(i)` → sliced Float32Array values.\n */\n readonly uniforms: Record<string, number | readonly number[]>;\n /**\n * Extra child shader slots beyond the implicit scene sampler. Empty for every\n * built-in effect; only color-grading-lut would populate it. Each entry\n * is an SkImage that GameView wraps in `<ImageShader>`.\n */\n readonly children: readonly SkImage[];\n}\n\n/**\n * Take a snapshot of `surface` and detach it from the GPU context so it can\n * be safely sampled from a different GrDirectContext (e.g. the on-screen\n * Canvas). RN-Skia's MakeOffscreen allocates a private Gr context per\n * surface; without this step Skia silently renders black when the texture is\n * read from any other context.\n *\n * Calls `makeNonTextureImage()` when available (RN-Skia ≥ 0.1 on device).\n * Falls back to the raw snapshot when the method is absent (CPU surfaces,\n * test mocks) — no behavioural change in those paths.\n */\nfunction detachSnapshot(surface: SkSurfaceLike): SkImageLike {\n const snap = surface.makeImageSnapshot();\n if (typeof snap.makeNonTextureImage === 'function') {\n return snap.makeNonTextureImage();\n }\n return snap;\n}\n\n/** A single axis-aligned rectangle shape to draw into an offscreen surface. */\nexport interface ShapeRect {\n readonly x: number;\n readonly y: number;\n readonly w: number;\n readonly h: number;\n /** ARGB packed integer: 0xAARRGGBB */\n readonly color: number;\n}\n\n/** Options for `renderShapesToImage`. */\nexport interface RenderShapesOpts {\n readonly width: number;\n readonly height: number;\n /** ARGB packed integer: 0xAARRGGBB */\n readonly clearColor: number;\n readonly shapes: readonly ShapeRect[];\n}\n\n/**\n * Narrow view of the Skia module — only the factories the bridge needs.\n * Declared as its own type so tests can pass a plain mock without pulling\n * in the full `@shopify/react-native-skia` surface.\n *\n * Extends `FrameRendererModule` from `@flare-engine/render` with the\n * native Surface and ImageFilter that are not needed in render-web.\n */\nexport type SkiaModuleLike = FrameRendererModule & {\n RuntimeEffect?: { Make(sksl: string): SkRuntimeEffect | null };\n Surface?: {\n Make(width: number, height: number): SkSurfaceLike | null;\n MakeOffscreen?(width: number, height: number): SkSurfaceLike | null;\n };\n /** Optional — present on device builds; absent in CPU/test mocks (drop-shadow falls back to the default paint). */\n ImageFilter?: {\n MakeDropShadow(\n dx: number,\n dy: number,\n sigmaX: number,\n sigmaY: number,\n color: SkColor,\n input: SkImageFilter | null,\n ): SkImageFilter;\n };\n};\n\n/**\n * A single compiled postfx pass descriptor produced by the runtime.\n * Re-exported from render's FrameRendererCompiledPass for consumer compatibility.\n */\nexport type CompiledPassLike = FrameRendererCompiledPass;\n\n/**\n * Minimal structural view of a PostFxRuntime that the bridge needs.\n * Re-exported from render's FrameRendererPostFxRuntime for consumer compatibility.\n */\nexport type PostFxRuntimeLike = FrameRendererPostFxRuntime;\n\n/** Minimal structural view of an EffectChain the bridge needs. */\nexport type PostFxChainLike = FrameRendererPostFxChain;\n\n/**\n * Frame renderer that bridges a `SpriteBatch` to a Skia `<Picture>`.\n * The implementation lives in `@flare-engine/render` (`createFrameRenderer`);\n * this interface narrows the return type for native-Skia consumers.\n */\nexport type SkiaFrameRenderer = FrameRenderer;\n\n/**\n * Create a `SkiaFrameRenderer`.\n *\n * `Skia` is passed in (rather than imported) so unit tests can supply a\n * mock. Production code constructs this once inside `<GameView>` using the\n * real `Skia` import from `@shopify/react-native-skia`.\n *\n * Delegates to `createFrameRenderer` from `@flare-engine/render` — the\n * frame-renderer body is backend-neutral and shared with render-web.\n */\nexport function createSkiaFrameRenderer(Skia: SkiaModuleLike): SkiaFrameRenderer {\n return createFrameRenderer(Skia);\n}\n\n// Scratch buffer for ARGB → RGBA-float unpacking in renderShapesToImage.\n// Allocated once per call (not module-level) so concurrent callers are safe.\n// Hot paths inside createSkiaFrameRenderer use their own pre-allocated buffers.\n\n/**\n * Render a list of solid rectangles into a fresh offscreen surface and return\n * the resulting image snapshot. Returns `null` if `Surface` factory is absent or\n * fails. The surface is not cached — callers that need reuse should cache the\n * returned image themselves.\n */\nexport function renderShapesToImage(\n skia: SkiaModuleLike,\n opts: RenderShapesOpts,\n): SkImageLike | null {\n if (skia.Surface === undefined) return null;\n const surface = skia.Surface.Make(opts.width, opts.height);\n if (surface === null) return null;\n\n const scratch = new Float32Array(4);\n const canvas = surface.getCanvas();\n\n unpackArgb(scratch, opts.clearColor);\n canvas.clear(scratch);\n\n const paint = skia.Paint();\n for (const shape of opts.shapes) {\n unpackArgb(scratch, shape.color);\n if (paint.setColor) paint.setColor(scratch);\n const rect = skia.XYWHRect(shape.x, shape.y, shape.w, shape.h);\n canvas.drawRect(rect, paint);\n }\n\n return detachSnapshot(surface);\n}\n\n/** Unpack a 0xAARRGGBB integer into a Float32Array [r, g, b, a] in 0..1 range. */\nfunction unpackArgb(out: Float32Array, argb: number): void {\n out[0] = ((argb >>> 16) & 0xff) / 255;\n out[1] = ((argb >>> 8) & 0xff) / 255;\n out[2] = (argb & 0xff) / 255;\n out[3] = ((argb >>> 24) & 0xff) / 255;\n}\n\n// Re-export the PostFxPassDescriptor shape for GameView consumers.\n// The type is defined above in this file so it carries the concrete SkRuntimeEffect/SkImage\n// types that GameView needs — unlike the generic FrameRendererPostFxDescriptor from render.\n// Alias for clarity at call-sites.\nexport type { FrameRendererPostFxDescriptor, SpriteDrawCommand };\n","import type { AssetLoader } from '@flare-engine/assets';\nimport { AssetManager } from '@flare-engine/assets';\nimport { AudioManager } from '@flare-engine/audio';\nimport { GameLoop } from '@flare-engine/core';\nimport { Position, World } from '@flare-engine/ecs';\nimport { InputManager } from '@flare-engine/input';\nimport { Camera2D, createRenderSystem, Renderer, Sprite, SpriteBatch } from '@flare-engine/render';\nimport { SceneManager } from '@flare-engine/scene';\nimport type { CanvasRef, SkImage, SkPicture, SkSurface } from '@shopify/react-native-skia';\nimport { Canvas, Image, RuntimeShader, Skia, useCanvasRef } from '@shopify/react-native-skia';\nimport type React from 'react';\nimport { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport type { GestureResponderEvent, LayoutChangeEvent, ViewStyle } from 'react-native';\nimport { PixelRatio, Platform, StyleSheet, View } from 'react-native';\nimport { type SharedValue, useSharedValue } from 'react-native-reanimated';\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport { scheduleOnUI } from 'react-native-worklets';\nimport { GameContext, type GameContextValue } from './game-context.js';\nimport { type SafeArea, SafeAreaContext } from './safe-area.js';\nimport { createSceneCapture, type SceneCapture } from './scene-texture.js';\nimport { createSkiaFrameRenderer, type PostFxPassDescriptor } from './skia-bridge.js';\n\n/**\n * Capture the frame's picture into an offscreen surface **on the UI thread**.\n *\n * The thread is the entire point, and getting it wrong is invisible to every\n * test in this repo. RN-Skia's own `usePictureAsTexture` does exactly this work\n * inside `runOnUI` (`external/reanimated/textures.ts`), and it must: a surface\n * built on the JS thread belongs to a different GL context than the on-screen\n * `<Canvas>`, so the `<Image>` samples nothing and the app renders a black\n * frame while the game loop runs happily. Building the surface here — same\n * thread, same context as the canvas that samples it — is what makes the\n * snapshot drawable without a `makeNonTextureImage()` GPU→CPU readback.\n *\n * Verified on device (Pixel 7 / Android 17): JS-thread capture → black canvas;\n * this path → renders. See external-review-2026-08.md §11.4b.\n *\n * The surface is cached across frames in a shared value rather than rebuilt per\n * frame (RN-Skia rebuilds it every call; that is NEW-2). `surfaceKey` packs the\n * pixel size so a viewport change reallocates exactly once.\n */\nconst captureSceneOnUI = (\n target: SharedValue<SkImage | null>,\n surfaceSV: SharedValue<SkSurface | null>,\n surfaceKey: SharedValue<number>,\n picture: SkPicture,\n w: number,\n h: number,\n): void => {\n 'worklet';\n const key = w * 65536 + h;\n if (surfaceSV.value === null || surfaceKey.value !== key) {\n surfaceSV.value = Skia.Surface.MakeOffscreen(w, h);\n surfaceKey.value = key;\n }\n const surface = surfaceSV.value;\n if (surface === null) return;\n surface.getCanvas().drawPicture(picture);\n surface.flush();\n target.value = surface.makeImageSnapshot();\n};\n\n/** Render hook invoked during the frame — receives the game context and\n * the active Skia canvas for direct draw calls. Hooks run between\n * `renderer.applyCamera()` and `renderer.end()`, so the camera transform\n * is already applied. */\nexport type RenderHook = (ctx: GameContextValue, canvas: unknown) => void;\n\n/** Render hook for post-processing passes. Receives the game context, the\n * active Skia canvas, and the `SkiaFrameRenderer` bridge so the hook can\n * call `bridge.setPostFxBinding(runtime, chain)` to register the runtime\n * and chain for the current frame.\n * `bridge` is `null` only on platforms where no Skia renderer was created\n * (future web fallback). */\nexport type PostFxRenderHook = (\n ctx: GameContextValue,\n canvas: unknown,\n bridge: import('./skia-bridge.js').SkiaFrameRenderer | null,\n) => void;\n\n/** Configuration passed to <GameView>. */\nexport interface GameConfig {\n /** Fixed timestep in seconds (default 1/60). */\n fixedDt?: number;\n /** Maximum dt cap in seconds (default 0.25). */\n maxDt?: number;\n /** Background clear color as 32-bit ARGB int (default 0xFF000000). */\n clearColor?: number;\n /** Asset loader function — injected into AssetManager at construction. */\n assetLoader?: AssetLoader;\n /** Called after camera transform and before the sprite render system.\n * Intended for tilemap / background layer rendering. */\n onRenderBackground?: RenderHook;\n /** Called after the sprite batch has been flushed, before `renderer.end()`.\n * Receives the bridge as 3rd arg so the hook can call\n * `bridge.setPostFxBinding(runtime, chain)` to register the postfx runtime\n * and chain for the current frame. */\n onRenderPostFx?: PostFxRenderHook;\n /**\n * Promote the underlying Skia surface from a TextureView (default) to a\n * SurfaceView on Android. With `opaque: true`, SurfaceView paints in a\n * separate compositing layer below the regular RN view tree, which lets\n * full-screen RN overlays (HUDs, menus) render on top without needing\n * elevation/zIndex tricks.\n *\n * Without this, RN-Skia's TextureView can clip overlapping full-screen\n * RN siblings on certain Android devices/Fabric configurations.\n *\n * Implies the canvas content is opaque — the clearColor's alpha must be\n * fully opaque (0xFF), which the default `0xff000000` already satisfies.\n * Defaults to `false` to preserve the current iOS-equivalent behavior.\n *\n * **Recommended on Android.** Measured on a Pixel 7 (Android 17, release\n * build, XR-1c): with the default TextureView path RN-Skia logs its\n * `updateTexImage: LegacySurfaceTexture is not attached!` /\n * `updateAndRelease() failed` pair **22 028 times per 60 s** — 90% of all\n * logcat output, saturating the 256 KiB ring buffer so unrelated diagnostics\n * are lost. With `opaque: true` the same build over three 60 s windows logs\n * the pair **zero** times and total log volume drops ~10x. RN-Skia labels the\n * pair ignorable and rendering is correct either way, so this is log noise\n * and TextureView overhead, not a correctness fix. Native memory is flat\n * across a 6-minute soak on both paths.\n */\n opaque?: boolean;\n}\n\n/** Props for the <GameView> component. */\nexport interface GameViewProps {\n /** Game configuration. */\n config?: GameConfig;\n /** Called once the game context is ready (loop not yet started). */\n onReady?: (ctx: GameContextValue) => void;\n /** Style applied to the outer View container. */\n style?: ViewStyle;\n /** Optional overlay children (e.g. VirtualJoystick, VirtualButton). */\n children?: React.ReactNode;\n /** Explicit safe-area insets. If omitted, resolved via `useContext(SafeAreaInsetsContext)`\n * from react-native-safe-area-context; falls back to `{ top: 0, right: 0, bottom: 0,\n * left: 0 }` when no `<SafeAreaProvider>` ancestor is mounted. */\n safeArea?: SafeArea;\n}\n\n/**\n * GameView — root component that sets up the Skia canvas, game loop,\n * and all core game systems. Provides GameContext to descendants.\n *\n * Overlay controls (VirtualJoystick, VirtualButton) should be placed\n * as children; they render on top of the Skia canvas.\n */\nexport function GameView({\n config,\n onReady,\n style,\n children,\n safeArea,\n}: GameViewProps): React.ReactElement {\n // useContext must run unconditionally (hook rules), even when `safeArea` makes its\n // value unused below — it never throws, unlike useSafeAreaInsets() without a provider.\n const contextInsets = useContext(SafeAreaInsetsContext);\n const resolvedSafeArea: SafeArea = safeArea ?? contextInsets ?? ZERO_INSETS;\n const canvasRef = useCanvasRef();\n const [passes, setPasses] = useState<readonly PostFxPassDescriptor[]>(EMPTY_PASSES);\n const [viewportSize, setViewportSize] = useState({ w: 0, h: 0 });\n const pd = PixelRatio.get();\n const isWeb = Platform.OS === 'web';\n // Both platforms write captured frames into a Reanimated shared value so\n // rn-skia's <Image> reads the latest frame on the UI thread without a React\n // re-render. createSceneCapture reuses one offscreen surface per viewport\n // size (fixing per-frame MakeOffscreen on native, NEW-2) and gates the\n // GPU→CPU makeNonTextureImage() copy to web only, where cross-context\n // sampling requires it (web: nonTextureImage true, native: false).\n const sceneImage = useSharedValue<SkImage | null>(null);\n const captureRef = useRef<SceneCapture<SkImage> | null>(null);\n // Native only: the offscreen surface lives on the UI thread, so it is held in\n // shared values rather than a ref — a ref would put it back on the JS thread\n // and reintroduce the black-frame regression captureSceneOnUI exists to fix.\n const uiSurface = useSharedValue<SkSurface | null>(null);\n const uiSurfaceKey = useSharedValue(0);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: intentional mount-only\n const ctx = useMemo<GameContextValue>(() => {\n const loop = new GameLoop({\n fixedDt: config?.fixedDt,\n maxDt: config?.maxDt,\n });\n const world = new World();\n const camera = new Camera2D();\n const input = new InputManager();\n const audio = new AudioManager();\n const noop: AssetLoader = () => Promise.resolve(null);\n const assets = new AssetManager(config?.assetLoader ?? noop);\n const scenes = new SceneManager();\n const renderer = new Renderer();\n const batch = new SpriteBatch();\n return { world, camera, input, audio, assets, scenes, loop, renderer, batch };\n }, []);\n\n // Warn once per <GameView> instance (not per page load) so each independently\n // mounted instance with a postfx binding gets its own one-time notice.\n const webPostFxWarnedRef = useRef(false);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: intentional mount-only\n useEffect(() => {\n const bridge = createSkiaFrameRenderer(Skia);\n ctx.renderer.setCanvas(bridge.canvas);\n\n const clearColor = config?.clearColor ?? 0xff000000;\n const onRenderBackground = config?.onRenderBackground;\n const onRenderPostFx = config?.onRenderPostFx;\n\n const spriteQuery = ctx.world.query(Position, Sprite);\n const renderSystem = createRenderSystem(ctx.world, spriteQuery, Position, Sprite, ctx.batch);\n\n // Last passes signature pushed to state; gates setPasses so an unchanged\n // (or empty) chain does not churn a fresh array + RuntimeShader tree every\n // frame. Seeded to the same EMPTY_PASSES the state holds, so an empty chain\n // never triggers a re-render from passes.\n let prevBuilt: readonly PostFxPassDescriptor[] = EMPTY_PASSES;\n\n const unsubscribeLate = ctx.loop.onLateUpdate.add((dt) => {\n ctx.camera.update(dt);\n ctx.input.update();\n });\n\n const unsubscribePre = ctx.loop.onPreRender.add(() => {\n const w = ctx.camera.viewportWidth;\n const h = ctx.camera.viewportHeight;\n bridge.beginFrame(w, h, ctx.loop.clock.elapsed, pd);\n ctx.renderer.begin(clearColor);\n ctx.renderer.applyCamera(\n ctx.camera.effectiveX,\n ctx.camera.effectiveY,\n ctx.camera.zoom,\n ctx.camera.rotation,\n w,\n h,\n );\n if (onRenderBackground) onRenderBackground(ctx, ctx.renderer.canvas);\n renderSystem();\n ctx.batch.flush(bridge.drawAtlas, ctx.renderer);\n if (onRenderPostFx) onRenderPostFx(ctx, ctx.renderer.canvas, bridge);\n ctx.renderer.end();\n const pic = bridge.endFrame();\n if (pic !== null) {\n if (isWeb) {\n // Web has one thread, so the JS-thread capture is same-context by\n // construction; this is the path WEB-1..WEB-7 verified in Chrome,\n // including the surface cache that keeps Chrome from evicting the\n // on-screen canvas (web-target-2026-08.md §12). Left untouched.\n if (captureRef.current === null) {\n captureRef.current = createSceneCapture(Skia, {\n nonTextureImage: true,\n retentionDepth: 3,\n });\n }\n const img = captureRef.current.capture(pic, w * pd, h * pd);\n if (img !== null) sceneImage.value = img;\n } else {\n // Native must build the surface on the UI thread — see captureSceneOnUI.\n // `scheduleOnUI` and not Reanimated's `runOnUI`: the latter is curried,\n // so `runOnUI(fn)` allocated a fresh wrapper on every frame in this\n // hook. Passing the args directly allocates nothing (ADR-0002).\n scheduleOnUI(\n captureSceneOnUI,\n sceneImage,\n uiSurface,\n uiSurfaceKey,\n pic as SkPicture,\n w * pd,\n h * pd,\n );\n }\n }\n if (!isWeb) {\n const built = bridge.buildPostFxPasses(null, null, w, h) as readonly PostFxPassDescriptor[];\n if (!samePasses(prevBuilt, built)) {\n prevBuilt = built.length === 0 ? EMPTY_PASSES : built;\n setPasses(prevBuilt);\n }\n } else if (bridge.hasPostFxBinding() && !webPostFxWarnedRef.current) {\n console.warn(\n 'postfx chain skipped: Skia.RuntimeShaderBuilder and' +\n ' ImageFilter.MakeRuntimeShaderWithChildren both throw' +\n ' \"Not implemented on React Native Web\".',\n );\n webPostFxWarnedRef.current = true;\n }\n canvasRef.current?.redraw();\n });\n\n onReady?.(ctx);\n ctx.loop.start();\n return () => {\n unsubscribeLate();\n unsubscribePre();\n captureRef.current?.dispose();\n captureRef.current = null;\n ctx.loop.stop();\n };\n }, []);\n\n const handleLayout = useCallback(\n (event: LayoutChangeEvent): void => {\n const { width, height } = event.nativeEvent.layout;\n ctx.camera.setViewport(width, height);\n setViewportSize({ w: width, h: height });\n },\n [ctx],\n );\n\n const onGrant = useCallback(\n (e: GestureResponderEvent): void => {\n const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;\n if (changedTouches.length === 0) {\n ctx.input.onPointerDown(Number(identifier), locationX, locationY);\n return;\n }\n for (let i = 0; i < changedTouches.length; i++) {\n const t = changedTouches[i];\n if (t === undefined) continue;\n ctx.input.onPointerDown(Number(t.identifier), t.locationX, t.locationY);\n }\n },\n [ctx],\n );\n const onMove = useCallback(\n (e: GestureResponderEvent): void => {\n const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;\n if (changedTouches.length === 0) {\n ctx.input.onPointerMove(Number(identifier), locationX, locationY);\n return;\n }\n for (let i = 0; i < changedTouches.length; i++) {\n const t = changedTouches[i];\n if (t === undefined) continue;\n ctx.input.onPointerMove(Number(t.identifier), t.locationX, t.locationY);\n }\n },\n [ctx],\n );\n const onRelease = useCallback(\n (e: GestureResponderEvent): void => {\n const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;\n if (changedTouches.length === 0) {\n ctx.input.onPointerUp(Number(identifier), locationX, locationY);\n return;\n }\n for (let i = 0; i < changedTouches.length; i++) {\n const t = changedTouches[i];\n if (t === undefined) continue;\n ctx.input.onPointerUp(Number(t.identifier), t.locationX, t.locationY);\n }\n },\n [ctx],\n );\n\n const containerStyle = useMemo(() => [styles.container, style], [style]);\n const passElements = useMemo(\n () => passes.map((p) => <RuntimeShader key={p.id} source={p.source} uniforms={p.uniforms} />),\n [passes],\n );\n\n return (\n <SafeAreaContext.Provider value={resolvedSafeArea}>\n <GameContext.Provider value={ctx}>\n <View\n style={containerStyle}\n onLayout={handleLayout}\n onStartShouldSetResponder={returnTrue}\n onResponderGrant={onGrant}\n onResponderMove={onMove}\n onResponderRelease={onRelease}\n onResponderTerminate={onRelease}\n >\n <Canvas\n ref={canvasRef as React.Ref<CanvasRef>}\n style={StyleSheet.absoluteFill}\n pointerEvents=\"none\"\n opaque={config?.opaque ?? false}\n >\n {viewportSize.w === 0 ? null : (\n <Image\n image={sceneImage}\n x={0}\n y={0}\n width={viewportSize.w}\n height={viewportSize.h}\n fit=\"cover\"\n >\n {passElements}\n </Image>\n )}\n </Canvas>\n {children}\n </View>\n </GameContext.Provider>\n </SafeAreaContext.Provider>\n );\n}\n\nfunction returnTrue(): boolean {\n return true;\n}\n\n/** Stable empty-chain reference — an empty `buildPostFxPasses` result collapses\n * to this so the `passes` state never changes for a postfx-free GameView. */\nconst EMPTY_PASSES: readonly PostFxPassDescriptor[] = [];\n\n/** Fallback insets when no `<SafeAreaProvider>` ancestor supplies a context value. */\nconst ZERO_INSETS: SafeArea = { top: 0, right: 0, bottom: 0, left: 0 };\n\n/**\n * Shallow structural equality of two pass lists. The signature is length +\n * per-pass `id` + shader ref + child-image refs + uniform values. Uniforms are\n * compared (not just `id`/`source`) because animating effects — the hit-flash\n * decay and timed triggers — keep a constant `id`/`source` while only their\n * uniform values change frame to frame; excluding them would freeze those\n * animations. Cost is trivial: postfx chains hold a handful of scalar/short-vec\n * uniforms.\n */\nfunction samePasses(\n a: readonly PostFxPassDescriptor[],\n b: readonly PostFxPassDescriptor[],\n): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n const pa = a[i];\n const pb = b[i];\n if (pa === undefined || pb === undefined) return false;\n if (pa.id !== pb.id || pa.source !== pb.source) return false;\n if (!sameChildren(pa.children, pb.children)) return false;\n if (!sameUniforms(pa.uniforms, pb.uniforms)) return false;\n }\n return true;\n}\n\nfunction sameChildren(a: readonly unknown[], b: readonly unknown[]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n}\n\nfunction sameUniforms(\n a: PostFxPassDescriptor['uniforms'],\n b: PostFxPassDescriptor['uniforms'],\n): boolean {\n const aKeys = Object.keys(a);\n if (aKeys.length !== Object.keys(b).length) return false;\n for (const key of aKeys) {\n const va = a[key];\n const vb = b[key];\n if (va === undefined || vb === undefined) return false;\n if (typeof va === 'number') {\n if (va !== vb) return false;\n } else {\n if (typeof vb === 'number' || va.length !== vb.length) return false;\n for (let i = 0; i < va.length; i++) {\n if (va[i] !== vb[i]) return false;\n }\n }\n }\n return true;\n}\n\nconst styles = StyleSheet.create({\n container: { flex: 1 },\n});\n","import type { Query } from '@flare-engine/ecs';\nimport { useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport { GameContext, type GameContextValue } from './game-context.js';\n\n/**\n * useGame — returns the GameContextValue from the nearest <GameView>.\n * Throws if called outside a <GameView>.\n */\nexport function useGame(): GameContextValue {\n const ctx = useContext(GameContext);\n if (!ctx) {\n throw new Error('useGame must be used inside a <GameView>');\n }\n return ctx;\n}\n\n/**\n * useEntity — subscribes to an ECS Query and returns the current entity list.\n * Re-renders when entities are added to or removed from the query.\n *\n * @param query An active Query obtained from world.query(...)\n */\nexport function useEntity(query: Query): readonly number[] {\n const [entities, setEntities] = useState<readonly number[]>(() => Array.from(query));\n\n useEffect(() => {\n const refresh = () => setEntities(Array.from(query));\n\n const unsubAdd = query.onEntityAdded.add(refresh);\n const unsubRemove = query.onEntityRemoved.add(refresh);\n\n // Sync initial state (query may have changed between render and effect)\n refresh();\n\n return () => {\n unsubAdd();\n unsubRemove();\n };\n }, [query]);\n\n return entities;\n}\n\n/**\n * useGameLoop — registers a per-frame callback on the game loop's onUpdate signal.\n * The callback is called each frame with delta time in seconds.\n * Automatically unregisters on unmount.\n *\n * @param callback Function called each frame with dt in seconds.\n */\nexport function useGameLoop(callback: (dt: number) => void): void {\n const { loop } = useGame();\n const callbackRef = useRef(callback);\n callbackRef.current = callback;\n\n const stable = useCallback((dt: number) => {\n callbackRef.current(dt);\n }, []);\n\n useEffect(() => {\n const unsub = loop.onUpdate.add(stable);\n return () => {\n unsub();\n };\n }, [loop, stable]);\n}\n","import type React from 'react';\nimport type { ViewStyle } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\n/** Props for the <LoadingScreen> component. */\nexport interface LoadingScreenProps {\n /** Progress in [0, 1]. Values outside this range are clamped. */\n progress: number;\n /** Style applied to the outer container (covers parent by default). */\n style?: ViewStyle;\n /** Filled portion color. */\n barColor?: string;\n /** Track color. */\n trackColor?: string;\n /** Background color behind the track. */\n backgroundColor?: string;\n}\n\n/**\n * LoadingScreen — full-screen asset-load overlay.\n *\n * Renders before `<GameView>` mounts its Skia canvas (or alongside it\n * while `AssetManager.load()` resolves). Pure RN Views so it works\n * without a live Skia context. Consumers drive `progress` from the\n * AssetManager progress callback.\n */\nexport function LoadingScreen({\n progress,\n style,\n barColor = '#ffffff',\n trackColor = 'rgba(255,255,255,0.2)',\n backgroundColor = '#000000',\n}: LoadingScreenProps): React.ReactElement {\n const clamped = progress < 0 ? 0 : progress > 1 ? 1 : progress;\n const percent = `${Math.round(clamped * 100)}%` as `${number}%`;\n\n return (\n <View style={[styles.container, { backgroundColor }, style]}>\n <View style={[styles.track, { backgroundColor: trackColor }]}>\n <View style={[styles.bar, { width: percent, backgroundColor: barColor }]} />\n </View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 32,\n },\n track: {\n width: '80%',\n height: 6,\n borderRadius: 3,\n overflow: 'hidden',\n },\n bar: {\n height: '100%',\n },\n});\n","import type { Signal } from '@flare-engine/events';\nimport { easeOutCubic } from '@flare-engine/math';\nimport { useEffect, useRef, useState } from 'react';\n\nexport function useOverlayFade(visible: boolean, durationMs = 300): number {\n const target = visible ? 1 : 0;\n const [opacity, setOpacity] = useState<number>(target);\n const opacityRef = useRef<number>(opacity);\n const startRef = useRef<number | null>(null);\n const rafRef = useRef<number | null>(null);\n\n // Keep ref in sync with state (runs before effect)\n opacityRef.current = opacity;\n\n useEffect(() => {\n if (typeof requestAnimationFrame === 'undefined') {\n setOpacity(target);\n return;\n }\n const from = opacityRef.current;\n startRef.current = null;\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n\n const step = (now: number) => {\n if (startRef.current === null) startRef.current = now;\n const t = Math.min((now - startRef.current) / durationMs, 1);\n setOpacity(from + (target - from) * t);\n if (t < 1) {\n rafRef.current = requestAnimationFrame(step);\n }\n };\n rafRef.current = requestAnimationFrame(step);\n return () => {\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n };\n }, [target, durationMs]);\n\n return opacity;\n}\n\nexport function useCountUp(target: number, durationMs = 600): number {\n const [value, setValue] = useState<number>(target);\n const valueRef = useRef<number>(value);\n const startRef = useRef<number | null>(null);\n const rafRef = useRef<number | null>(null);\n\n // Keep ref in sync with state (runs before effect)\n valueRef.current = value;\n\n useEffect(() => {\n if (typeof requestAnimationFrame === 'undefined') {\n setValue(target);\n return;\n }\n const from = valueRef.current;\n startRef.current = null;\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n\n const step = (now: number) => {\n if (startRef.current === null) startRef.current = now;\n const t = Math.min((now - startRef.current) / durationMs, 1);\n setValue(from + (target - from) * easeOutCubic(t));\n if (t < 1) {\n rafRef.current = requestAnimationFrame(step);\n }\n };\n rafRef.current = requestAnimationFrame(step);\n return () => {\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);\n };\n }, [target, durationMs]);\n\n return value;\n}\n\nexport function useSignalState<T>(signal: Signal<T>, initial: T): T {\n const [state, setState] = useState<T>(initial);\n\n useEffect(() => {\n const disposer = signal.add(setState);\n return disposer;\n }, [signal]);\n\n return state;\n}\n","import type { SkiaAtlasModuleLike } from '@flare-engine/assets';\nimport { Skia } from '@shopify/react-native-skia';\n\n/**\n * The RN-Skia module adapted to the engine's structural atlas interface.\n * Centralises the one boundary assertion so template code stays cast-free.\n */\nexport const skiaAtlasModule: SkiaAtlasModuleLike = Skia as unknown as SkiaAtlasModuleLike;\n","import {\n createButtonState,\n pressButton,\n releaseButton,\n resetButtonFrame,\n type VirtualButtonState,\n} from '@flare-engine/input';\nimport type React from 'react';\nimport { useCallback, useRef } from 'react';\nimport type { ViewStyle } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\n/** Props for the <VirtualButton> component. */\nexport interface VirtualButtonProps {\n /** Called on each state change. */\n onStateChange?: (state: VirtualButtonState) => void;\n /** Style applied to the button. */\n style?: ViewStyle;\n /** Button label / overlay content. */\n children?: React.ReactNode;\n}\n\n/**\n * VirtualButton — an on-screen button overlay component.\n *\n * Uses raw `onTouchStart`/`onTouchEnd` so press and release fire regardless\n * of which ancestor holds the RN responder — enabling simultaneous use with\n * `<VirtualJoystick>` without responder conflicts.\n */\nexport function VirtualButton({\n onStateChange,\n style,\n children,\n}: VirtualButtonProps): React.ReactElement {\n const stateRef = useRef<VirtualButtonState>(createButtonState());\n\n const handlePress = useCallback(() => {\n resetButtonFrame(stateRef.current);\n pressButton(stateRef.current);\n onStateChange?.(stateRef.current);\n }, [onStateChange]);\n\n const handleRelease = useCallback(() => {\n resetButtonFrame(stateRef.current);\n releaseButton(stateRef.current);\n onStateChange?.(stateRef.current);\n }, [onStateChange]);\n\n return (\n <View\n style={[styles.button, style]}\n onTouchStart={handlePress}\n onTouchEnd={handleRelease}\n onTouchCancel={handleRelease}\n >\n {children}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n button: {\n width: 60,\n height: 60,\n borderRadius: 30,\n backgroundColor: 'rgba(255,255,255,0.3)',\n alignItems: 'center',\n justifyContent: 'center',\n },\n});\n","import {\n createJoystickState,\n releaseJoystick,\n updateJoystick,\n type VirtualJoystickConfig,\n type VirtualJoystickState,\n} from '@flare-engine/input';\nimport type React from 'react';\nimport { useCallback, useRef, useState } from 'react';\nimport type { GestureResponderEvent, ViewStyle } from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\n/** Props for the <VirtualJoystick> component. */\nexport interface VirtualJoystickProps {\n /** Joystick configuration (dead zone, max radius). */\n config?: VirtualJoystickConfig;\n /** Called on each state change. */\n onStateChange?: (state: VirtualJoystickState) => void;\n /** Style applied to the outer container. */\n style?: ViewStyle;\n /** Custom node rendered in place of the default base circle View. */\n base?: React.ReactNode;\n /** Custom node rendered in place of the default knob View. */\n thumb?: React.ReactNode;\n}\n\n/**\n * VirtualJoystick — an on-screen joystick overlay component.\n *\n * Renders a base circle and a knob that follows the user's touch.\n * Claims the React Native touch responder so children of a parent that\n * also claims the responder (e.g. <GameView>) still receive move/end events.\n */\nexport function VirtualJoystick({\n config,\n onStateChange,\n style,\n base,\n thumb,\n}: VirtualJoystickProps): React.ReactElement {\n const stateRef = useRef<VirtualJoystickState>(createJoystickState());\n const sizeRef = useRef<{ w: number; h: number }>({ w: 0, h: 0 });\n const [knob, setKnob] = useState({ x: 0, y: 0 });\n\n const handleLayout = useCallback(\n (e: { nativeEvent: { layout: { width: number; height: number } } }) => {\n sizeRef.current = { w: e.nativeEvent.layout.width, h: e.nativeEvent.layout.height };\n },\n [],\n );\n\n const handleTouch = useCallback(\n (e: GestureResponderEvent) => {\n const { locationX, locationY } = e.nativeEvent;\n const { w, h } = sizeRef.current;\n updateJoystick(stateRef.current, w / 2, h / 2, locationX, locationY, config);\n onStateChange?.(stateRef.current);\n const { x, y } = stateRef.current.offset;\n setKnob((prev) => (prev.x === x && prev.y === y ? prev : { x, y }));\n },\n [config, onStateChange],\n );\n\n const handleRelease = useCallback(() => {\n releaseJoystick(stateRef.current);\n onStateChange?.(stateRef.current);\n setKnob((prev) => (prev.x === 0 && prev.y === 0 ? prev : { x: 0, y: 0 }));\n }, [onStateChange]);\n\n const maxRadius = config?.maxRadius ?? 50;\n\n return (\n <View\n style={[\n styles.center,\n ...(base ? [] : [styles.baseBg]),\n {\n width: maxRadius * 2,\n height: maxRadius * 2,\n borderRadius: maxRadius,\n },\n style,\n ]}\n onLayout={handleLayout}\n onStartShouldSetResponder={returnTrue}\n onMoveShouldSetResponder={returnTrue}\n onResponderGrant={handleTouch}\n onResponderMove={handleTouch}\n onResponderRelease={handleRelease}\n onResponderTerminate={handleRelease}\n onResponderTerminationRequest={returnFalse}\n >\n {base ? (\n <View style={StyleSheet.absoluteFill} pointerEvents=\"none\">\n {base}\n </View>\n ) : null}\n {thumb ? (\n <View\n style={{ transform: [{ translateX: knob.x }, { translateY: knob.y }] }}\n pointerEvents=\"none\"\n >\n {thumb}\n </View>\n ) : (\n <View\n style={[styles.knob, { transform: [{ translateX: knob.x }, { translateY: knob.y }] }]}\n />\n )}\n </View>\n );\n}\n\nfunction returnTrue(): boolean {\n return true;\n}\n\nfunction returnFalse(): boolean {\n return false;\n}\n\nconst styles = StyleSheet.create({\n center: {\n alignItems: 'center',\n justifyContent: 'center',\n },\n baseBg: {\n backgroundColor: 'rgba(255,255,255,0.2)',\n },\n knob: {\n width: 40,\n height: 40,\n borderRadius: 20,\n backgroundColor: 'rgba(255,255,255,0.6)',\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,cAAc,cAAuC,IAAI;;;AC1BtE,MAAa,kBAAkB,cAA+B,IAAI;AAElE,SAAgB,cAAwB;CACtC,MAAM,QAAQ,WAAW,eAAe;CACxC,IAAI,UAAU,MACZ,MAAM,IAAI,MAAM,8CAA8C;CAEhE,OAAO;AACT;;;;;;;ACuBA,MAAM,UAAW,OAA2C;AAE5D,SAAS,kBAAkB,QAAuB;CAChD,IAAI,YAAY,KAAA,KAAa,WAAW,QAAQ,WAAW,KAAA,GAAW;CACtE,MAAM,WAAY,OAAmC;CACrD,IAAI,OAAO,aAAa,YACtB,SAAyB,KAAK,MAAM;AAExC;;;;;;;;;;;;AAaA,SAAgB,wBACd,MAC2B;CAC3B,IAAI,UAA2C;CAC/C,IAAI,eAAe;CACnB,IAAI,gBAAgB;CAEpB,MAAM,gBAAsB;EAC1B,IAAI,YAAY,MAAM;EACtB,kBAAkB,OAAO;EACzB,UAAU;EACV,eAAe;EACf,gBAAgB;CAClB;CAEA,O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AY;IACpB,cAAc;GAChB;GACA;EACF;EACA,UAAU;EACV,2BAA2B;EAC3B,0BAA0B;EAC1B,kBAAkB;EAClB,iBAAiB;EACjB,oBAAoB;EACpB,sBAAsB;EACtB,+BAA+B;YAlBjC,CAoBG,OACC,oBAAC,MAAD;GAAM,OAAO,WAAW;GAAc,eAAc;aACjD;EACG,CAAA,IACJ,MACH,QACC,oBAAC,MAAD;GACE,OAAO,EAAE,WAAW,CAAC,EAAE,YAAY,KAAK,EAAE,GAAG,EAAE,YAAY,KAAK,EAAE,CAAC,EAAE;GACrE,eAAc;aAEb;EACG,CAAA,IAEN,oBAAC,MAAD,EACE,OAAO,CAAC,OAAO,MAAM,EAAE,WAAW,CAAC,EAAE,YAAY,KAAK,EAAE,GAAG,EAAE,YAAY,KAAK,EAAE,CAAC,EAAE,CAAC,EACrF,CAAA,CAEC;;AAEV;AAEA,SAAS,aAAsB;CAC7B,OAAO;AACT;AAEA,SAAS,cAAuB;CAC9B,OAAO;AACT;AAEA,MAAM,SAAS,WAAW,OAAO;CAC/B,QAAQ;EACN,YAAY;EACZ,gBAAgB;CAClB;CACA,QAAQ,EACN,iBAAiB,wBACnB;CACA,MAAM;EACJ,OAAO;EACP,QAAQ;EACR,cAAc;EACd,iBAAiB;CACnB;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flare-engine/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "GameView, hooks, VirtualJoystick, VirtualButton",
|
|
5
5
|
"keywords": ["flare-engine", "react", "react-native", "game-view", "hooks"],
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"files": ["dist", "README.md", "LICENSE", "NOTICE"],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsdown",
|
|
35
|
-
"test": "bun test",
|
|
35
|
+
"test": "bun ../../scripts/test-isolated.mjs",
|
|
36
36
|
"lint": "biome check src/",
|
|
37
37
|
"typecheck": "tsc --noEmit"
|
|
38
38
|
},
|
|
@@ -40,20 +40,22 @@
|
|
|
40
40
|
"@types/react": "^19.0.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@flare-engine/assets": "^0.
|
|
44
|
-
"@flare-engine/audio": "^0.
|
|
45
|
-
"@flare-engine/core": "^0.
|
|
46
|
-
"@flare-engine/ecs": "^0.
|
|
47
|
-
"@flare-engine/events": "^0.
|
|
48
|
-
"@flare-engine/input": "^0.
|
|
49
|
-
"@flare-engine/math": "^0.
|
|
50
|
-
"@flare-engine/render": "^0.
|
|
51
|
-
"@flare-engine/scene": "^0.
|
|
43
|
+
"@flare-engine/assets": "^0.4.1",
|
|
44
|
+
"@flare-engine/audio": "^0.4.1",
|
|
45
|
+
"@flare-engine/core": "^0.4.1",
|
|
46
|
+
"@flare-engine/ecs": "^0.4.1",
|
|
47
|
+
"@flare-engine/events": "^0.4.1",
|
|
48
|
+
"@flare-engine/input": "^0.4.1",
|
|
49
|
+
"@flare-engine/math": "^0.4.1",
|
|
50
|
+
"@flare-engine/render": "^0.4.1",
|
|
51
|
+
"@flare-engine/scene": "^0.4.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"react": ">=19.0.0",
|
|
55
55
|
"react-native": ">=0.79.0",
|
|
56
56
|
"@shopify/react-native-skia": ">=2.0.0",
|
|
57
|
+
"react-native-reanimated": ">=4.0.0",
|
|
58
|
+
"react-native-worklets": ">=0.7.0",
|
|
57
59
|
"react-native-safe-area-context": ">=4.0.0",
|
|
58
60
|
"react-native-web": ">=0.20.0",
|
|
59
61
|
"canvaskit-wasm": ">=0.40.0"
|