@flare-engine/react 0.4.6 → 0.4.8

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/dist/index.d.mts CHANGED
@@ -9,7 +9,6 @@ import { SceneManager } from "@flare-engine/scene";
9
9
  import { SkColor, SkImage, SkImageFilter, SkRuntimeEffect } from "@shopify/react-native-skia";
10
10
  import { ViewStyle } from "react-native";
11
11
  import { Signal } from "@flare-engine/events";
12
- //#region src/game-context.d.ts
13
12
  /** The value exposed via GameContext. */
14
13
  interface GameContextValue {
15
14
  /** ECS world. */
@@ -35,9 +34,7 @@ interface GameContextValue {
35
34
  * React context that provides access to core game objects.
36
35
  * Null if accessed outside a <GameView>.
37
36
  */
38
- declare const GameContext: import("react").Context<GameContextValue | null>;
39
- //#endregion
40
- //#region src/skia-bridge.d.ts
37
+ export declare const GameContext: import("react").Context<GameContextValue | null>;
41
38
  /** Structural canvas — minimal subset needed for offscreen rendering. */
42
39
  interface SkOffscreenCanvasLike {
43
40
  drawPicture(picture: unknown): void;
@@ -56,7 +53,8 @@ interface SkSurfaceLike {
56
53
  }
57
54
  /**
58
55
  * A single post-processing pass descriptor built by `buildPostFxPasses`.
59
- * GameView maps each descriptor to a `<RuntimeShader>` child of `<Image>`.
56
+ * GameView maps each descriptor to a `<RuntimeShader>` image filter, or to a
57
+ * nested `<Shader>` when a pass carries `children` (see that field).
60
58
  */
61
59
  interface PostFxPassDescriptor {
62
60
  /** Stable id, used as React key. */
@@ -70,9 +68,13 @@ interface PostFxPassDescriptor {
70
68
  */
71
69
  readonly uniforms: Record<string, number | readonly number[]>;
72
70
  /**
73
- * Extra child shader slots beyond the implicit scene sampler. Empty for every
74
- * built-in effect; only color-grading-lut would populate it. Each entry
75
- * is an SkImage that GameView wraps in `<ImageShader>`.
71
+ * Extra sampler children beyond the implicit scene sampler, in SkSL
72
+ * declaration order with `src` excluded. Empty for every built-in effect
73
+ * except color-grading-lut (its LUT image). RN-Skia's `<RuntimeShader>`
74
+ * image filter cannot bind them — it calls `MakeRuntimeShader(rtb, null,
75
+ * null)`, source only — so GameView renders a pass with children, and every
76
+ * pass before it, as a nested `<Shader>` chain whose children are bound
77
+ * positionally: `src` first, then one `<ImageShader>` per entry here.
76
78
  */
77
79
  readonly children: readonly SkImage[];
78
80
  }
@@ -142,26 +144,22 @@ type SkiaFrameRenderer = FrameRenderer;
142
144
  * Delegates to `createFrameRenderer` from `@flare-engine/render` — the
143
145
  * frame-renderer body is backend-neutral and shared with render-web.
144
146
  */
145
- declare function createSkiaFrameRenderer(Skia: SkiaModuleLike): SkiaFrameRenderer;
147
+ export declare function createSkiaFrameRenderer(Skia: SkiaModuleLike): SkiaFrameRenderer;
146
148
  /**
147
149
  * Render a list of solid rectangles into a fresh offscreen surface and return
148
150
  * the resulting image snapshot. Returns `null` if `Surface` factory is absent or
149
151
  * fails. The surface is not cached — callers that need reuse should cache the
150
152
  * returned image themselves.
151
153
  */
152
- declare function renderShapesToImage(skia: SkiaModuleLike, opts: RenderShapesOpts): SkImageLike | null;
153
- //#endregion
154
- //#region src/safe-area.d.ts
154
+ export declare function renderShapesToImage(skia: SkiaModuleLike, opts: RenderShapesOpts): SkImageLike | null;
155
155
  interface SafeArea {
156
156
  top: number;
157
157
  right: number;
158
158
  bottom: number;
159
159
  left: number;
160
160
  }
161
- declare const SafeAreaContext: import("react").Context<SafeArea | null>;
162
- declare function useSafeArea(): SafeArea;
163
- //#endregion
164
- //#region src/game-view.d.ts
161
+ export declare const SafeAreaContext: import("react").Context<SafeArea | null>;
162
+ export declare function useSafeArea(): SafeArea;
165
163
  /** Render hook invoked during the frame — receives the game context and
166
164
  * the active Skia canvas for direct draw calls. Hooks run between
167
165
  * `renderer.applyCamera()` and `renderer.end()`, so the camera transform
@@ -241,21 +239,19 @@ interface GameViewProps {
241
239
  * Overlay controls (VirtualJoystick, VirtualButton) should be placed
242
240
  * as children; they render on top of the Skia canvas.
243
241
  */
244
- declare function GameView({ config, onReady, style, children, safeArea }: GameViewProps): React.ReactElement;
245
- //#endregion
246
- //#region src/hooks.d.ts
242
+ export declare function GameView({ config, onReady, style, children, safeArea }: GameViewProps): React.ReactElement;
247
243
  /**
248
244
  * useGame — returns the GameContextValue from the nearest <GameView>.
249
245
  * Throws if called outside a <GameView>.
250
246
  */
251
- declare function useGame(): GameContextValue;
247
+ export declare function useGame(): GameContextValue;
252
248
  /**
253
249
  * useEntity — subscribes to an ECS Query and returns the current entity list.
254
250
  * Re-renders when entities are added to or removed from the query.
255
251
  *
256
252
  * @param query An active Query obtained from world.query(...)
257
253
  */
258
- declare function useEntity(query: Query): readonly number[];
254
+ export declare function useEntity(query: Query): readonly number[];
259
255
  /**
260
256
  * useGameLoop — registers a per-frame callback on the game loop's onUpdate signal.
261
257
  * The callback is called each frame with delta time in seconds.
@@ -263,9 +259,7 @@ declare function useEntity(query: Query): readonly number[];
263
259
  *
264
260
  * @param callback Function called each frame with dt in seconds.
265
261
  */
266
- declare function useGameLoop(callback: (dt: number) => void): void;
267
- //#endregion
268
- //#region src/loading-screen.d.ts
262
+ export declare function useGameLoop(callback: (dt: number) => void): void;
269
263
  /** Props for the <LoadingScreen> component. */
270
264
  interface LoadingScreenProps {
271
265
  /** Progress in [0, 1]. Values outside this range are clamped. */
@@ -287,21 +281,15 @@ interface LoadingScreenProps {
287
281
  * without a live Skia context. Consumers drive `progress` from the
288
282
  * AssetManager progress callback.
289
283
  */
290
- declare function LoadingScreen({ progress, style, barColor, trackColor, backgroundColor }: LoadingScreenProps): React.ReactElement;
291
- //#endregion
292
- //#region src/overlay-hooks.d.ts
293
- declare function useOverlayFade(visible: boolean, durationMs?: number): number;
294
- declare function useCountUp(target: number, durationMs?: number): number;
295
- declare function useSignalState<T>(signal: Signal<T>, initial: T): T;
296
- //#endregion
297
- //#region src/skia-atlas.d.ts
284
+ export declare function LoadingScreen({ progress, style, barColor, trackColor, backgroundColor }: LoadingScreenProps): React.ReactElement;
285
+ export declare function useOverlayFade(visible: boolean, durationMs?: number): number;
286
+ export declare function useCountUp(target: number, durationMs?: number): number;
287
+ export declare function useSignalState<T>(signal: Signal<T>, initial: T): T;
298
288
  /**
299
289
  * The RN-Skia module adapted to the engine's structural atlas interface.
300
290
  * Centralises the one boundary assertion so template code stays cast-free.
301
291
  */
302
- declare const skiaAtlasModule: SkiaAtlasModuleLike;
303
- //#endregion
304
- //#region src/virtual-button.d.ts
292
+ export declare const skiaAtlasModule: SkiaAtlasModuleLike;
305
293
  /** Props for the <VirtualButton> component. */
306
294
  interface VirtualButtonProps {
307
295
  /** Called on each state change. */
@@ -318,9 +306,7 @@ interface VirtualButtonProps {
318
306
  * of which ancestor holds the RN responder — enabling simultaneous use with
319
307
  * `<VirtualJoystick>` without responder conflicts.
320
308
  */
321
- declare function VirtualButton({ onStateChange, style, children }: VirtualButtonProps): React.ReactElement;
322
- //#endregion
323
- //#region src/virtual-joystick.d.ts
309
+ export declare function VirtualButton({ onStateChange, style, children }: VirtualButtonProps): React.ReactElement;
324
310
  /** Props for the <VirtualJoystick> component. */
325
311
  interface VirtualJoystickProps {
326
312
  /** Joystick configuration (dead zone, max radius). */
@@ -341,7 +327,6 @@ interface VirtualJoystickProps {
341
327
  * Claims the React Native touch responder so children of a parent that
342
328
  * also claims the responder (e.g. <GameView>) still receive move/end events.
343
329
  */
344
- declare function VirtualJoystick({ config, onStateChange, style, base, thumb }: VirtualJoystickProps): React.ReactElement;
345
- //#endregion
346
- export { type CompiledPassLike, type GameConfig, GameContext, type GameContextValue, GameView, type GameViewProps, LoadingScreen, type LoadingScreenProps, type PostFxChainLike, type PostFxPassDescriptor, type PostFxRenderHook, type PostFxRuntimeLike, type RenderHook, type RenderShapesOpts, type SafeArea, SafeAreaContext, type ShapeRect, type SkOffscreenCanvasLike, type SkiaFrameRenderer, type SkiaModuleLike, VirtualButton, type VirtualButtonProps, VirtualJoystick, type VirtualJoystickProps, createSkiaFrameRenderer, renderShapesToImage, skiaAtlasModule, useCountUp, useEntity, useGame, useGameLoop, useOverlayFade, useSafeArea, useSignalState };
330
+ export declare function VirtualJoystick({ config, onStateChange, style, base, thumb }: VirtualJoystickProps): React.ReactElement;
331
+ export type { CompiledPassLike, GameConfig, GameContextValue, GameViewProps, LoadingScreenProps, PostFxChainLike, PostFxPassDescriptor, PostFxRenderHook, PostFxRuntimeLike, RenderHook, RenderShapesOpts, SafeArea, ShapeRect, SkOffscreenCanvasLike, SkiaFrameRenderer, SkiaModuleLike, VirtualButtonProps, VirtualJoystickProps };
347
332
  //# sourceMappingURL=index.d.mts.map
@@ -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;;;;;;;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;;;;;;;;;iBAmBA,kBACd,QACA,eACA,OACA,MACA,SACC,uBAAuB,MAAM"}
1
+ {"version":3,"file":"index.d.mts","names":["_$__skia_bridge_js0.SkiaFrameRenderer"],"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;;;;;;qBAOI,6BAAW,QAAA;;UCrBP;EACf,YAAY;EACZ,cAAc,gBAAgB,cAAc,cAAc;EAC1D,SAAS,eAAe;EACxB,MAAM;;;UAIS;EACf,aAAa;EACb,qBAAqB;;;;EAIrB;;;;;;;UAQe;;WAEN;;WAEA,QAAQ;;;;;;WAMR,UAAU;;;;;;;;;;WAUV,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;;;;;;;;;;;wBAYhB,wBAAwB,MAAM,iBAAiB;;;;;;;wBAc/C,oBACd,MAAM,gBACN,MAAM,mBACL;UC3Kc;EACf;EACA;EACA;EACA;;qBAGW,iCAAe,QAAA;wBAEZ,eAAe;;;;;KCkEnB,cAAc,KAAK,kBAAkB;;;;;;;KAQrC,oBACV,KAAK,kBACL,iBACA,QAFKA;;UAMU;;EAEf;;EAEA;;EAEA;;EAEA,cAAc;;;EAGd,qBAAqB;;;;;EAKrB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BjB;;;UAIe;;EAEf,SAAS;;EAET,WAAW,KAAK;;EAEhB,QAAQ;;EAER,WAAW,MAAM;;;;EAIjB,WAAW;;;;;;;;;wBAUG,WACd,QACA,SACA,OACA,UACA,YACC,gBAAgB,MAAM;;;;;wBC9JT,WAAW;;;;;;;wBAcX,UAAU,OAAO;;;;;;;;wBA4BjB,YAAY,WAAW;;UC7CtB;;EAEf;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;;;;;;;;;;wBAWc,gBACd,UACA,OACA,UACA,YACA,mBACC,qBAAqB,MAAM;wBC5Bd,eAAe,kBAAkB;wBAoCjC,WAAW,gBAAgB;wBAmC3B,eAAe,GAAG,QAAQ,OAAO,IAAI,SAAS,IAAI;;;;;qBCpErD,iBAAiB;;UCMb;;EAEf,iBAAiB,OAAO;;EAExB,QAAQ;;EAER,WAAW,MAAM;;;;;;;;;wBAUH,gBACd,eACA,OACA,YACC,qBAAqB,MAAM;;UCpBb;;EAEf,SAAS;;EAET,iBAAiB,OAAO;;EAExB,QAAQ;;EAER,OAAO,MAAM;;EAEb,QAAQ,MAAM;;;;;;;;;wBAmBA,kBACd,QACA,eACA,OACA,MACA,SACC,uBAAuB,MAAM"}
package/dist/index.d.ts CHANGED
@@ -9,7 +9,6 @@ import { SkColor, SkImage, SkImageFilter, SkRuntimeEffect } from "@shopify/react
9
9
  import React from "react";
10
10
  import { ViewStyle } from "react-native";
11
11
  import { Signal } from "@flare-engine/events";
12
- //#region src/game-context.d.ts
13
12
  /** The value exposed via GameContext. */
14
13
  interface GameContextValue {
15
14
  /** ECS world. */
@@ -35,9 +34,7 @@ interface GameContextValue {
35
34
  * React context that provides access to core game objects.
36
35
  * Null if accessed outside a <GameView>.
37
36
  */
38
- declare const GameContext: import("react").Context<GameContextValue | null>;
39
- //#endregion
40
- //#region src/skia-bridge.d.ts
37
+ export declare const GameContext: import("react").Context<GameContextValue | null>;
41
38
  /** Structural canvas — minimal subset needed for offscreen rendering. */
42
39
  interface SkOffscreenCanvasLike {
43
40
  drawPicture(picture: unknown): void;
@@ -56,7 +53,8 @@ interface SkSurfaceLike {
56
53
  }
57
54
  /**
58
55
  * A single post-processing pass descriptor built by `buildPostFxPasses`.
59
- * GameView maps each descriptor to a `<RuntimeShader>` child of `<Image>`.
56
+ * GameView maps each descriptor to a `<RuntimeShader>` image filter, or to a
57
+ * nested `<Shader>` when a pass carries `children` (see that field).
60
58
  */
61
59
  interface PostFxPassDescriptor {
62
60
  /** Stable id, used as React key. */
@@ -70,9 +68,13 @@ interface PostFxPassDescriptor {
70
68
  */
71
69
  readonly uniforms: Record<string, number | readonly number[]>;
72
70
  /**
73
- * Extra child shader slots beyond the implicit scene sampler. Empty for every
74
- * built-in effect; only color-grading-lut would populate it. Each entry
75
- * is an SkImage that GameView wraps in `<ImageShader>`.
71
+ * Extra sampler children beyond the implicit scene sampler, in SkSL
72
+ * declaration order with `src` excluded. Empty for every built-in effect
73
+ * except color-grading-lut (its LUT image). RN-Skia's `<RuntimeShader>`
74
+ * image filter cannot bind them — it calls `MakeRuntimeShader(rtb, null,
75
+ * null)`, source only — so GameView renders a pass with children, and every
76
+ * pass before it, as a nested `<Shader>` chain whose children are bound
77
+ * positionally: `src` first, then one `<ImageShader>` per entry here.
76
78
  */
77
79
  readonly children: readonly SkImage[];
78
80
  }
@@ -142,26 +144,22 @@ type SkiaFrameRenderer = FrameRenderer;
142
144
  * Delegates to `createFrameRenderer` from `@flare-engine/render` — the
143
145
  * frame-renderer body is backend-neutral and shared with render-web.
144
146
  */
145
- declare function createSkiaFrameRenderer(Skia: SkiaModuleLike): SkiaFrameRenderer;
147
+ export declare function createSkiaFrameRenderer(Skia: SkiaModuleLike): SkiaFrameRenderer;
146
148
  /**
147
149
  * Render a list of solid rectangles into a fresh offscreen surface and return
148
150
  * the resulting image snapshot. Returns `null` if `Surface` factory is absent or
149
151
  * fails. The surface is not cached — callers that need reuse should cache the
150
152
  * returned image themselves.
151
153
  */
152
- declare function renderShapesToImage(skia: SkiaModuleLike, opts: RenderShapesOpts): SkImageLike | null;
153
- //#endregion
154
- //#region src/safe-area.d.ts
154
+ export declare function renderShapesToImage(skia: SkiaModuleLike, opts: RenderShapesOpts): SkImageLike | null;
155
155
  interface SafeArea {
156
156
  top: number;
157
157
  right: number;
158
158
  bottom: number;
159
159
  left: number;
160
160
  }
161
- declare const SafeAreaContext: import("react").Context<SafeArea | null>;
162
- declare function useSafeArea(): SafeArea;
163
- //#endregion
164
- //#region src/game-view.d.ts
161
+ export declare const SafeAreaContext: import("react").Context<SafeArea | null>;
162
+ export declare function useSafeArea(): SafeArea;
165
163
  /** Render hook invoked during the frame — receives the game context and
166
164
  * the active Skia canvas for direct draw calls. Hooks run between
167
165
  * `renderer.applyCamera()` and `renderer.end()`, so the camera transform
@@ -241,21 +239,19 @@ interface GameViewProps {
241
239
  * Overlay controls (VirtualJoystick, VirtualButton) should be placed
242
240
  * as children; they render on top of the Skia canvas.
243
241
  */
244
- declare function GameView({ config, onReady, style, children, safeArea }: GameViewProps): React.ReactElement;
245
- //#endregion
246
- //#region src/hooks.d.ts
242
+ export declare function GameView({ config, onReady, style, children, safeArea }: GameViewProps): React.ReactElement;
247
243
  /**
248
244
  * useGame — returns the GameContextValue from the nearest <GameView>.
249
245
  * Throws if called outside a <GameView>.
250
246
  */
251
- declare function useGame(): GameContextValue;
247
+ export declare function useGame(): GameContextValue;
252
248
  /**
253
249
  * useEntity — subscribes to an ECS Query and returns the current entity list.
254
250
  * Re-renders when entities are added to or removed from the query.
255
251
  *
256
252
  * @param query An active Query obtained from world.query(...)
257
253
  */
258
- declare function useEntity(query: Query): readonly number[];
254
+ export declare function useEntity(query: Query): readonly number[];
259
255
  /**
260
256
  * useGameLoop — registers a per-frame callback on the game loop's onUpdate signal.
261
257
  * The callback is called each frame with delta time in seconds.
@@ -263,9 +259,7 @@ declare function useEntity(query: Query): readonly number[];
263
259
  *
264
260
  * @param callback Function called each frame with dt in seconds.
265
261
  */
266
- declare function useGameLoop(callback: (dt: number) => void): void;
267
- //#endregion
268
- //#region src/loading-screen.d.ts
262
+ export declare function useGameLoop(callback: (dt: number) => void): void;
269
263
  /** Props for the <LoadingScreen> component. */
270
264
  interface LoadingScreenProps {
271
265
  /** Progress in [0, 1]. Values outside this range are clamped. */
@@ -287,21 +281,15 @@ interface LoadingScreenProps {
287
281
  * without a live Skia context. Consumers drive `progress` from the
288
282
  * AssetManager progress callback.
289
283
  */
290
- declare function LoadingScreen({ progress, style, barColor, trackColor, backgroundColor }: LoadingScreenProps): React.ReactElement;
291
- //#endregion
292
- //#region src/overlay-hooks.d.ts
293
- declare function useOverlayFade(visible: boolean, durationMs?: number): number;
294
- declare function useCountUp(target: number, durationMs?: number): number;
295
- declare function useSignalState<T>(signal: Signal<T>, initial: T): T;
296
- //#endregion
297
- //#region src/skia-atlas.d.ts
284
+ export declare function LoadingScreen({ progress, style, barColor, trackColor, backgroundColor }: LoadingScreenProps): React.ReactElement;
285
+ export declare function useOverlayFade(visible: boolean, durationMs?: number): number;
286
+ export declare function useCountUp(target: number, durationMs?: number): number;
287
+ export declare function useSignalState<T>(signal: Signal<T>, initial: T): T;
298
288
  /**
299
289
  * The RN-Skia module adapted to the engine's structural atlas interface.
300
290
  * Centralises the one boundary assertion so template code stays cast-free.
301
291
  */
302
- declare const skiaAtlasModule: SkiaAtlasModuleLike;
303
- //#endregion
304
- //#region src/virtual-button.d.ts
292
+ export declare const skiaAtlasModule: SkiaAtlasModuleLike;
305
293
  /** Props for the <VirtualButton> component. */
306
294
  interface VirtualButtonProps {
307
295
  /** Called on each state change. */
@@ -318,9 +306,7 @@ interface VirtualButtonProps {
318
306
  * of which ancestor holds the RN responder — enabling simultaneous use with
319
307
  * `<VirtualJoystick>` without responder conflicts.
320
308
  */
321
- declare function VirtualButton({ onStateChange, style, children }: VirtualButtonProps): React.ReactElement;
322
- //#endregion
323
- //#region src/virtual-joystick.d.ts
309
+ export declare function VirtualButton({ onStateChange, style, children }: VirtualButtonProps): React.ReactElement;
324
310
  /** Props for the <VirtualJoystick> component. */
325
311
  interface VirtualJoystickProps {
326
312
  /** Joystick configuration (dead zone, max radius). */
@@ -341,7 +327,6 @@ interface VirtualJoystickProps {
341
327
  * Claims the React Native touch responder so children of a parent that
342
328
  * also claims the responder (e.g. <GameView>) still receive move/end events.
343
329
  */
344
- declare function VirtualJoystick({ config, onStateChange, style, base, thumb }: VirtualJoystickProps): React.ReactElement;
345
- //#endregion
346
- export { type CompiledPassLike, type GameConfig, GameContext, type GameContextValue, GameView, type GameViewProps, LoadingScreen, type LoadingScreenProps, type PostFxChainLike, type PostFxPassDescriptor, type PostFxRenderHook, type PostFxRuntimeLike, type RenderHook, type RenderShapesOpts, type SafeArea, SafeAreaContext, type ShapeRect, type SkOffscreenCanvasLike, type SkiaFrameRenderer, type SkiaModuleLike, VirtualButton, type VirtualButtonProps, VirtualJoystick, type VirtualJoystickProps, createSkiaFrameRenderer, renderShapesToImage, skiaAtlasModule, useCountUp, useEntity, useGame, useGameLoop, useOverlayFade, useSafeArea, useSignalState };
330
+ export declare function VirtualJoystick({ config, onStateChange, style, base, thumb }: VirtualJoystickProps): React.ReactElement;
331
+ export type { CompiledPassLike, GameConfig, GameContextValue, GameViewProps, LoadingScreenProps, PostFxChainLike, PostFxPassDescriptor, PostFxRenderHook, PostFxRuntimeLike, RenderHook, RenderShapesOpts, SafeArea, ShapeRect, SkOffscreenCanvasLike, SkiaFrameRenderer, SkiaModuleLike, VirtualButtonProps, VirtualJoystickProps };
347
332
  //# sourceMappingURL=index.d.ts.map
@@ -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;;;;U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Bd,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;;;;;;;;;iBAmBA,kBACd,QACA,eACA,OACA,MACA,SACC,uBAAuB,MAAM"}
1
+ {"version":3,"file":"index.d.ts","names":["_$__skia_bridge_js0.SkiaFrameRenderer"],"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;;;;;;qBAOI,6BAAW,QAAA;;UCrBP;EACf,YAAY;EACZ,cAAc,gBAAgB,cAAc,cAAc;EAC1D,SAAS,eAAe;EACxB,MAAM;;;UAIS;EACf,aAAa;EACb,qBAAqB;;;;EAIrB;;;;;;;UAQe;;WAEN;;WAEA,QAAQ;;;;;;WAMR,UAAU;;;;;;;;;;WAUV,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,OAA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native-safe-area-context");
14
14
  let react_native_worklets = require("react-native-worklets");
15
15
  let react_jsx_runtime = require("react/jsx-runtime");
16
16
  let _flare_engine_math = require("@flare-engine/math");
17
- //#region src/game-context.ts
17
+ // src/game-context.ts
18
18
  /**
19
19
  * React context that provides access to core game objects.
20
20
  * Null if accessed outside a <GameView>.
21
21
  */
22
22
  const GameContext = (0, react.createContext)(null);
23
- //#endregion
24
- //#region src/safe-area.ts
23
+ // src/safe-area.ts
25
24
  const SafeAreaContext = (0, react.createContext)(null);
26
25
  function useSafeArea() {
27
26
  const value = (0, react.useContext)(SafeAreaContext);
28
27
  if (value === null) throw new Error("useSafeArea must be used inside a <GameView>");
29
28
  return value;
30
29
  }
31
- //#endregion
32
- //#region src/scene-texture.ts
30
+ // src/scene-texture.ts
33
31
  /**
34
32
  * `Symbol.dispose` is not in this project's ES2022 lib, so the well-known
35
33
  * symbol is looked up at runtime instead of written as a computed key.
@@ -131,8 +129,7 @@ function createSceneCapture(Skia, opts) {
131
129
  }
132
130
  };
133
131
  }
134
- //#endregion
135
- //#region src/skia-bridge.ts
132
+ // src/skia-bridge.ts
136
133
  /**
137
134
  * Take a snapshot of `surface` and detach it from the GPU context so it can
138
135
  * be safely sampled from a different GrDirectContext (e.g. the on-screen
@@ -192,8 +189,7 @@ function unpackArgb(out, argb) {
192
189
  out[2] = (argb & 255) / 255;
193
190
  out[3] = (argb >>> 24 & 255) / 255;
194
191
  }
195
- //#endregion
196
- //#region src/game-view.tsx
192
+ // src/game-view.tsx
197
193
  /**
198
194
  * Capture the frame's picture into an offscreen surface **on the UI thread**.
199
195
  *
@@ -296,14 +292,16 @@ function GameView({ config, onReady, style, children, safeArea }) {
296
292
  if (onRenderPostFx) onRenderPostFx(ctx, ctx.renderer.canvas, bridge);
297
293
  ctx.renderer.end();
298
294
  const pic = bridge.endFrame();
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);
295
+ if (pic !== null) {
296
+ if (isWeb) {
297
+ if (captureRef.current === null) captureRef.current = createSceneCapture(_shopify_react_native_skia.Skia, {
298
+ nonTextureImage: true,
299
+ retentionDepth: 3
300
+ });
301
+ const img = captureRef.current.capture(pic, w * pd, h * pd);
302
+ if (img !== null) sceneImage.value = img;
303
+ } else (0, react_native_worklets.scheduleOnUI)(captureSceneOnUI, sceneImage, uiSurface, uiSurfaceKey, pic, w * pd, h * pd);
304
+ }
307
305
  if (!isWeb) {
308
306
  const built = bridge.buildPostFxPasses(null, null, w, h);
309
307
  if (!samePasses(prevBuilt, built)) {
@@ -371,10 +369,73 @@ function GameView({ config, onReady, style, children, safeArea }) {
371
369
  }
372
370
  }, [ctx]);
373
371
  const containerStyle = (0, react.useMemo)(() => [styles$3.container, style], [style]);
374
- const passElements = (0, react.useMemo)(() => passes.map((p) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_shopify_react_native_skia.RuntimeShader, {
375
- source: p.source,
376
- uniforms: p.uniforms
377
- }, p.id)), [passes]);
372
+ const canvasContent = (0, react.useMemo)(() => {
373
+ if (viewportSize.w === 0) return null;
374
+ const w = viewportSize.w;
375
+ const h = viewportSize.h;
376
+ const last = lastPassWithChildren(passes);
377
+ if (last < 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_shopify_react_native_skia.Image, {
378
+ image: sceneImage,
379
+ x: 0,
380
+ y: 0,
381
+ width: w,
382
+ height: h,
383
+ fit: "cover",
384
+ children: passes.map((p) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_shopify_react_native_skia.RuntimeShader, {
385
+ source: p.source,
386
+ uniforms: p.uniforms
387
+ }, p.id))
388
+ });
389
+ let shader = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_shopify_react_native_skia.ImageShader, {
390
+ image: sceneImage,
391
+ fit: "cover",
392
+ rect: {
393
+ x: 0,
394
+ y: 0,
395
+ width: w,
396
+ height: h
397
+ },
398
+ tx: "clamp",
399
+ ty: "clamp",
400
+ sampling: LINEAR_SAMPLING
401
+ });
402
+ for (let i = 0; i <= last; i++) {
403
+ const p = passes[i];
404
+ if (p === void 0) continue;
405
+ const samplers = [];
406
+ for (let c = 0; c < p.children.length; c++) samplers.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_shopify_react_native_skia.ImageShader, {
407
+ image: p.children[c] ?? null,
408
+ tx: "clamp",
409
+ ty: "clamp",
410
+ sampling: LINEAR_SAMPLING
411
+ }, c));
412
+ shader = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_shopify_react_native_skia.Shader, {
413
+ source: p.source,
414
+ uniforms: p.uniforms,
415
+ children: [shader, samplers]
416
+ });
417
+ }
418
+ const filters = [];
419
+ for (let i = last + 1; i < passes.length; i++) {
420
+ const p = passes[i];
421
+ if (p === void 0) continue;
422
+ filters.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_shopify_react_native_skia.RuntimeShader, {
423
+ source: p.source,
424
+ uniforms: p.uniforms
425
+ }, p.id));
426
+ }
427
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_shopify_react_native_skia.Rect, {
428
+ x: 0,
429
+ y: 0,
430
+ width: w,
431
+ height: h,
432
+ children: [shader, filters]
433
+ });
434
+ }, [
435
+ passes,
436
+ viewportSize,
437
+ sceneImage
438
+ ]);
378
439
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SafeAreaContext.Provider, {
379
440
  value: resolvedSafeArea,
380
441
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(GameContext.Provider, {
@@ -392,15 +453,7 @@ function GameView({ config, onReady, style, children, safeArea }) {
392
453
  style: react_native.StyleSheet.absoluteFill,
393
454
  pointerEvents: "none",
394
455
  opaque: config?.opaque ?? false,
395
- children: viewportSize.w === 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_shopify_react_native_skia.Image, {
396
- image: sceneImage,
397
- x: 0,
398
- y: 0,
399
- width: viewportSize.w,
400
- height: viewportSize.h,
401
- fit: "cover",
402
- children: passElements
403
- })
456
+ children: canvasContent
404
457
  }), children]
405
458
  })
406
459
  })
@@ -412,6 +465,20 @@ function returnTrue$1() {
412
465
  /** Stable empty-chain reference — an empty `buildPostFxPasses` result collapses
413
466
  * to this so the `passes` state never changes for a postfx-free GameView. */
414
467
  const EMPTY_PASSES = [];
468
+ /** Linear, mipmap-free sampling for every ImageShader in the pass chain — the
469
+ * options render-web hands makeShaderOptions, so both backends sample alike. */
470
+ const LINEAR_SAMPLING = {
471
+ filter: _shopify_react_native_skia.FilterMode.Linear,
472
+ mipmap: _shopify_react_native_skia.MipmapMode.None
473
+ };
474
+ /** Index of the last pass carrying extra sampler children, or -1 when none does. */
475
+ function lastPassWithChildren(passes) {
476
+ for (let i = passes.length - 1; i >= 0; i--) {
477
+ const p = passes[i];
478
+ if (p !== void 0 && p.children.length > 0) return i;
479
+ }
480
+ return -1;
481
+ }
415
482
  /** Fallback insets when no `<SafeAreaProvider>` ancestor supplies a context value. */
416
483
  const ZERO_INSETS = {
417
484
  top: 0,
@@ -462,8 +529,7 @@ function sameUniforms(a, b) {
462
529
  return true;
463
530
  }
464
531
  const styles$3 = react_native.StyleSheet.create({ container: { flex: 1 } });
465
- //#endregion
466
- //#region src/hooks.ts
532
+ // src/hooks.ts
467
533
  /**
468
534
  * useGame — returns the GameContextValue from the nearest <GameView>.
469
535
  * Throws if called outside a <GameView>.
@@ -514,8 +580,7 @@ function useGameLoop(callback) {
514
580
  };
515
581
  }, [loop, stable]);
516
582
  }
517
- //#endregion
518
- //#region src/loading-screen.tsx
583
+ // src/loading-screen.tsx
519
584
  /**
520
585
  * LoadingScreen — full-screen asset-load overlay.
521
586
  *
@@ -560,8 +625,7 @@ const styles$2 = react_native.StyleSheet.create({
560
625
  },
561
626
  bar: { height: "100%" }
562
627
  });
563
- //#endregion
564
- //#region src/overlay-hooks.ts
628
+ // src/overlay-hooks.ts
565
629
  function useOverlayFade(visible, durationMs = 300) {
566
630
  const target = visible ? 1 : 0;
567
631
  const [opacity, setOpacity] = (0, react.useState)(target);
@@ -624,15 +688,13 @@ function useSignalState(signal, initial) {
624
688
  }, [signal]);
625
689
  return state;
626
690
  }
627
- //#endregion
628
- //#region src/skia-atlas.ts
691
+ // src/skia-atlas.ts
629
692
  /**
630
693
  * The RN-Skia module adapted to the engine's structural atlas interface.
631
694
  * Centralises the one boundary assertion so template code stays cast-free.
632
695
  */
633
696
  const skiaAtlasModule = _shopify_react_native_skia.Skia;
634
- //#endregion
635
- //#region src/virtual-button.tsx
697
+ // src/virtual-button.tsx
636
698
  /**
637
699
  * VirtualButton — an on-screen button overlay component.
638
700
  *
@@ -668,8 +730,7 @@ const styles$1 = react_native.StyleSheet.create({ button: {
668
730
  alignItems: "center",
669
731
  justifyContent: "center"
670
732
  } });
671
- //#endregion
672
- //#region src/virtual-joystick.tsx
733
+ // src/virtual-joystick.tsx
673
734
  /**
674
735
  * VirtualJoystick — an on-screen joystick overlay component.
675
736
  *
@@ -793,7 +854,6 @@ const styles = react_native.StyleSheet.create({
793
854
  pointerEvents: "none"
794
855
  }
795
856
  });
796
- //#endregion
797
857
  exports.GameContext = GameContext;
798
858
  exports.GameView = GameView;
799
859
  exports.LoadingScreen = LoadingScreen;