@flare-engine/react 0.3.0 → 0.3.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/dist/index.d.mts CHANGED
@@ -303,8 +303,9 @@ interface VirtualButtonProps {
303
303
  /**
304
304
  * VirtualButton — an on-screen button overlay component.
305
305
  *
306
- * Claims the React Native touch responder so press/release fire reliably
307
- * even when an ancestor (e.g. <GameView>) also claims the responder.
306
+ * Uses raw `onTouchStart`/`onTouchEnd` so press and release fire regardless
307
+ * of which ancestor holds the RN responder — enabling simultaneous use with
308
+ * `<VirtualJoystick>` without responder conflicts.
308
309
  */
309
310
  declare function VirtualButton({ onStateChange, style, children }: VirtualButtonProps): React.ReactElement;
310
311
  //#endregion
@@ -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;;;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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;;;;;;;KCoBnB,cAAc,KAAK,kBAAkB;;;;;;;KAQrC,oBACV,KAAK,kBACL,iBACA,QAFK;;UAMU;;EAEf;;EAEA;;EAEA;;EAEA,cAAc;;;EAGd,qBAAqB;;;;;EAKrB,iBAAiB;;;;;;;;;;;;;;;EAejB;;;UAIe;;EAEf,SAAS;;EAET,WAAW,KAAK;;EAEhB,QAAQ;;EAER,WAAW,MAAM;;;;EAIjB,WAAW;;;;;;;;;iBAUG,WACd,QACA,SACA,OACA,UACA,YACC,gBAAgB,MAAM;;;;;;;iBCrGT,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
@@ -303,8 +303,9 @@ interface VirtualButtonProps {
303
303
  /**
304
304
  * VirtualButton — an on-screen button overlay component.
305
305
  *
306
- * Claims the React Native touch responder so press/release fire reliably
307
- * even when an ancestor (e.g. <GameView>) also claims the responder.
306
+ * Uses raw `onTouchStart`/`onTouchEnd` so press and release fire regardless
307
+ * of which ancestor holds the RN responder — enabling simultaneous use with
308
+ * `<VirtualJoystick>` without responder conflicts.
308
309
  */
309
310
  declare function VirtualButton({ onStateChange, style, children }: VirtualButtonProps): React.ReactElement;
310
311
  //#endregion
@@ -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/over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A,YACC,gBAAgB,MAAM;;;;;;;iBCrGT,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;;;;;;;;iBASH,gBACd,eACA,OACA,YACC,qBAAqB,MAAM;;;;UCnBb;;EAEf,SAAS;;EAET,iBAAiB,OAAO;;EAExB,QAAQ;;EAER,OAAO,MAAM;;EAEb,QAAQ,MAAM;;;;;;;;;iBAUA,kBACd,QACA,eACA,OACA,MACA,SACC,uBAAuB,MAAM"}
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;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BAAiB,OAAO;;EAExB,QAAQ;;EAER,OAAO,MAAM;;EAEb,QAAQ,MAAM;;;;;;;;;iBAUA,kBACd,QACA,eACA,OACA,MACA,SACC,uBAAuB,MAAM"}
package/dist/index.js CHANGED
@@ -348,13 +348,40 @@ function GameView({ config, onReady, style, children, safeArea }) {
348
348
  });
349
349
  }, [ctx]);
350
350
  const onGrant = (0, react.useCallback)((e) => {
351
- ctx.input.onPointerDown(0, e.nativeEvent.locationX, e.nativeEvent.locationY);
351
+ const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;
352
+ if (changedTouches.length === 0) {
353
+ ctx.input.onPointerDown(Number(identifier), locationX, locationY);
354
+ return;
355
+ }
356
+ for (let i = 0; i < changedTouches.length; i++) {
357
+ const t = changedTouches[i];
358
+ if (t === void 0) continue;
359
+ ctx.input.onPointerDown(Number(t.identifier), t.locationX, t.locationY);
360
+ }
352
361
  }, [ctx]);
353
362
  const onMove = (0, react.useCallback)((e) => {
354
- ctx.input.onPointerMove(0, e.nativeEvent.locationX, e.nativeEvent.locationY);
363
+ const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;
364
+ if (changedTouches.length === 0) {
365
+ ctx.input.onPointerMove(Number(identifier), locationX, locationY);
366
+ return;
367
+ }
368
+ for (let i = 0; i < changedTouches.length; i++) {
369
+ const t = changedTouches[i];
370
+ if (t === void 0) continue;
371
+ ctx.input.onPointerMove(Number(t.identifier), t.locationX, t.locationY);
372
+ }
355
373
  }, [ctx]);
356
374
  const onRelease = (0, react.useCallback)((e) => {
357
- ctx.input.onPointerUp(0, e.nativeEvent.locationX, e.nativeEvent.locationY);
375
+ const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;
376
+ if (changedTouches.length === 0) {
377
+ ctx.input.onPointerUp(Number(identifier), locationX, locationY);
378
+ return;
379
+ }
380
+ for (let i = 0; i < changedTouches.length; i++) {
381
+ const t = changedTouches[i];
382
+ if (t === void 0) continue;
383
+ ctx.input.onPointerUp(Number(t.identifier), t.locationX, t.locationY);
384
+ }
358
385
  }, [ctx]);
359
386
  const containerStyle = (0, react.useMemo)(() => [styles$3.container, style], [style]);
360
387
  const passElements = (0, react.useMemo)(() => passes.map((p) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_shopify_react_native_skia.RuntimeShader, {
@@ -368,7 +395,7 @@ function GameView({ config, onReady, style, children, safeArea }) {
368
395
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_native.View, {
369
396
  style: containerStyle,
370
397
  onLayout: handleLayout,
371
- onStartShouldSetResponder: returnTrue$2,
398
+ onStartShouldSetResponder: returnTrue$1,
372
399
  onResponderGrant: onGrant,
373
400
  onResponderMove: onMove,
374
401
  onResponderRelease: onRelease,
@@ -392,7 +419,7 @@ function GameView({ config, onReady, style, children, safeArea }) {
392
419
  })
393
420
  });
394
421
  }
395
- function returnTrue$2() {
422
+ function returnTrue$1() {
396
423
  return true;
397
424
  }
398
425
  /** Stable empty-chain reference — an empty `buildPostFxPasses` result collapses
@@ -615,8 +642,9 @@ const skiaAtlasModule = _shopify_react_native_skia.Skia;
615
642
  /**
616
643
  * VirtualButton — an on-screen button overlay component.
617
644
  *
618
- * Claims the React Native touch responder so press/release fire reliably
619
- * even when an ancestor (e.g. <GameView>) also claims the responder.
645
+ * Uses raw `onTouchStart`/`onTouchEnd` so press and release fire regardless
646
+ * of which ancestor holds the RN responder — enabling simultaneous use with
647
+ * `<VirtualJoystick>` without responder conflicts.
620
648
  */
621
649
  function VirtualButton({ onStateChange, style, children }) {
622
650
  const stateRef = (0, react.useRef)((0, _flare_engine_input.createButtonState)());
@@ -632,16 +660,12 @@ function VirtualButton({ onStateChange, style, children }) {
632
660
  }, [onStateChange]);
633
661
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
634
662
  style: [styles$1.button, style],
635
- onStartShouldSetResponder: returnTrue$1,
636
- onResponderGrant: handlePress,
637
- onResponderRelease: handleRelease,
638
- onResponderTerminate: handleRelease,
663
+ onTouchStart: handlePress,
664
+ onTouchEnd: handleRelease,
665
+ onTouchCancel: handleRelease,
639
666
  children
640
667
  });
641
668
  }
642
- function returnTrue$1() {
643
- return true;
644
- }
645
669
  const styles$1 = react_native.StyleSheet.create({ button: {
646
670
  width: 60,
647
671
  height: 60,
@@ -713,6 +737,7 @@ function VirtualJoystick({ config, onStateChange, style, base, thumb }) {
713
737
  onResponderMove: handleTouch,
714
738
  onResponderRelease: handleRelease,
715
739
  onResponderTerminate: handleRelease,
740
+ onResponderTerminationRequest: returnFalse,
716
741
  children: [base ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
717
742
  style: react_native.StyleSheet.absoluteFill,
718
743
  pointerEvents: "none",
@@ -727,6 +752,9 @@ function VirtualJoystick({ config, onStateChange, style, base, thumb }) {
727
752
  function returnTrue() {
728
753
  return true;
729
754
  }
755
+ function returnFalse() {
756
+ return false;
757
+ }
730
758
  const styles = react_native.StyleSheet.create({
731
759
  center: {
732
760
  alignItems: "center",
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","returnTrue","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 ctx.input.onPointerDown(0, e.nativeEvent.locationX, e.nativeEvent.locationY);\n },\n [ctx],\n );\n const onMove = useCallback(\n (e: GestureResponderEvent): void => {\n ctx.input.onPointerMove(0, e.nativeEvent.locationX, e.nativeEvent.locationY);\n },\n [ctx],\n );\n const onRelease = useCallback(\n (e: GestureResponderEvent): void => {\n ctx.input.onPointerUp(0, e.nativeEvent.locationX, e.nativeEvent.locationY);\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 * Claims the React Native touch responder so press/release fire reliably\n * even when an ancestor (e.g. <GameView>) also claims the responder.\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 onStartShouldSetResponder={returnTrue}\n onResponderGrant={handlePress}\n onResponderRelease={handleRelease}\n onResponderTerminate={handleRelease}\n >\n {children}\n </View>\n );\n}\n\nfunction returnTrue(): boolean {\n return true;\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 >\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\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,eAAA,GAAA,MAAA,cAAA,CAAqD,IAAI;;;AC1BtE,MAAa,mBAAA,GAAA,MAAA,cAAA,CAAiD,IAAI;AAElE,SAAgB,cAAwB;CACtC,MAAM,SAAA,GAAA,MAAA,WAAA,CAAmB,eAAe;CACxC,IAAI,UAAU,MACZ,MAAM,IAAI,MAAM,8CAA8C;CAEhE,OAAO;AACT;;;;;;;ACwBA,MAAM,UAAW,OAA2C;AAE5D,S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YAAY;IACnB,QAAQ,YAAY;IACpB,cAAc;GAChB;GACA;EACF;EACA,UAAU;EACV,2BAA2B;EAC3B,0BAA0B;EAC1B,kBAAkB;EAClB,iBAAiB;EACjB,oBAAoB;EACpB,sBAAsB;YAjBxB,CAmBG,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,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":["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,\n backgroundColor: 'rgba(255,255,255,0.6)',\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,MAAa,eAAA,GAAA,MAAA,cAAA,CAAqD,IAAI;;;AC1BtE,MAAa,mBAAA,GAAA,MAAA,cAAA,CAAiD,IAAI;AAElE,SAAgB,cAAwB;CACtC,MAAM,SAAA,GAAA,MAAA,WAAA,CAAmB,eAAe;CACxC,IAAI,UAAU,MACZ,MAAM,IAAI,MAAM,8CAA8C;CAEhE,OAAO;AACT;;;;;;;ACwBA,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,OAAO;EACL,QAAQ,OAAe,QAAiD;GACtE,IAAI,SAAS,KAAK,UAAU,GAAG,OAAO;GACtC,IAAI,YAAY,QAAQ,iBAAiB,SAAS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({ config, onReady, style, children, safeArea }) {
347
347
  });
348
348
  }, [ctx]);
349
349
  const onGrant = useCallback((e) => {
350
- ctx.input.onPointerDown(0, e.nativeEvent.locationX, e.nativeEvent.locationY);
350
+ const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;
351
+ if (changedTouches.length === 0) {
352
+ ctx.input.onPointerDown(Number(identifier), locationX, locationY);
353
+ return;
354
+ }
355
+ for (let i = 0; i < changedTouches.length; i++) {
356
+ const t = changedTouches[i];
357
+ if (t === void 0) continue;
358
+ ctx.input.onPointerDown(Number(t.identifier), t.locationX, t.locationY);
359
+ }
351
360
  }, [ctx]);
352
361
  const onMove = useCallback((e) => {
353
- ctx.input.onPointerMove(0, e.nativeEvent.locationX, e.nativeEvent.locationY);
362
+ const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;
363
+ if (changedTouches.length === 0) {
364
+ ctx.input.onPointerMove(Number(identifier), locationX, locationY);
365
+ return;
366
+ }
367
+ for (let i = 0; i < changedTouches.length; i++) {
368
+ const t = changedTouches[i];
369
+ if (t === void 0) continue;
370
+ ctx.input.onPointerMove(Number(t.identifier), t.locationX, t.locationY);
371
+ }
354
372
  }, [ctx]);
355
373
  const onRelease = useCallback((e) => {
356
- ctx.input.onPointerUp(0, e.nativeEvent.locationX, e.nativeEvent.locationY);
374
+ const { changedTouches, identifier, locationX, locationY } = e.nativeEvent;
375
+ if (changedTouches.length === 0) {
376
+ ctx.input.onPointerUp(Number(identifier), locationX, locationY);
377
+ return;
378
+ }
379
+ for (let i = 0; i < changedTouches.length; i++) {
380
+ const t = changedTouches[i];
381
+ if (t === void 0) continue;
382
+ ctx.input.onPointerUp(Number(t.identifier), t.locationX, t.locationY);
383
+ }
357
384
  }, [ctx]);
358
385
  const containerStyle = useMemo(() => [styles$3.container, style], [style]);
359
386
  const passElements = useMemo(() => passes.map((p) => /* @__PURE__ */ jsx(RuntimeShader, {
@@ -367,7 +394,7 @@ function GameView({ config, onReady, style, children, safeArea }) {
367
394
  children: /* @__PURE__ */ jsxs(View, {
368
395
  style: containerStyle,
369
396
  onLayout: handleLayout,
370
- onStartShouldSetResponder: returnTrue$2,
397
+ onStartShouldSetResponder: returnTrue$1,
371
398
  onResponderGrant: onGrant,
372
399
  onResponderMove: onMove,
373
400
  onResponderRelease: onRelease,
@@ -391,7 +418,7 @@ function GameView({ config, onReady, style, children, safeArea }) {
391
418
  })
392
419
  });
393
420
  }
394
- function returnTrue$2() {
421
+ function returnTrue$1() {
395
422
  return true;
396
423
  }
397
424
  /** Stable empty-chain reference — an empty `buildPostFxPasses` result collapses
@@ -614,8 +641,9 @@ const skiaAtlasModule = Skia;
614
641
  /**
615
642
  * VirtualButton — an on-screen button overlay component.
616
643
  *
617
- * Claims the React Native touch responder so press/release fire reliably
618
- * even when an ancestor (e.g. <GameView>) also claims the responder.
644
+ * Uses raw `onTouchStart`/`onTouchEnd` so press and release fire regardless
645
+ * of which ancestor holds the RN responder — enabling simultaneous use with
646
+ * `<VirtualJoystick>` without responder conflicts.
619
647
  */
620
648
  function VirtualButton({ onStateChange, style, children }) {
621
649
  const stateRef = useRef(createButtonState());
@@ -631,16 +659,12 @@ function VirtualButton({ onStateChange, style, children }) {
631
659
  }, [onStateChange]);
632
660
  return /* @__PURE__ */ jsx(View, {
633
661
  style: [styles$1.button, style],
634
- onStartShouldSetResponder: returnTrue$1,
635
- onResponderGrant: handlePress,
636
- onResponderRelease: handleRelease,
637
- onResponderTerminate: handleRelease,
662
+ onTouchStart: handlePress,
663
+ onTouchEnd: handleRelease,
664
+ onTouchCancel: handleRelease,
638
665
  children
639
666
  });
640
667
  }
641
- function returnTrue$1() {
642
- return true;
643
- }
644
668
  const styles$1 = StyleSheet.create({ button: {
645
669
  width: 60,
646
670
  height: 60,
@@ -712,6 +736,7 @@ function VirtualJoystick({ config, onStateChange, style, base, thumb }) {
712
736
  onResponderMove: handleTouch,
713
737
  onResponderRelease: handleRelease,
714
738
  onResponderTerminate: handleRelease,
739
+ onResponderTerminationRequest: returnFalse,
715
740
  children: [base ? /* @__PURE__ */ jsx(View, {
716
741
  style: StyleSheet.absoluteFill,
717
742
  pointerEvents: "none",
@@ -726,6 +751,9 @@ function VirtualJoystick({ config, onStateChange, style, base, thumb }) {
726
751
  function returnTrue() {
727
752
  return true;
728
753
  }
754
+ function returnFalse() {
755
+ return false;
756
+ }
729
757
  const styles = StyleSheet.create({
730
758
  center: {
731
759
  alignItems: "center",
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["styles","returnTrue","styles","styles","returnTrue"],"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 ctx.input.onPointerDown(0, e.nativeEvent.locationX, e.nativeEvent.locationY);\n },\n [ctx],\n );\n const onMove = useCallback(\n (e: GestureResponderEvent): void => {\n ctx.input.onPointerMove(0, e.nativeEvent.locationX, e.nativeEvent.locationY);\n },\n [ctx],\n );\n const onRelease = useCallback(\n (e: GestureResponderEvent): void => {\n ctx.input.onPointerUp(0, e.nativeEvent.locationX, e.nativeEvent.locationY);\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 * Claims the React Native touch responder so press/release fire reliably\n * even when an ancestor (e.g. <GameView>) also claims the responder.\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 onStartShouldSetResponder={returnTrue}\n onResponderGrant={handlePress}\n onResponderRelease={handleRelease}\n onResponderTerminate={handleRelease}\n >\n {children}\n </View>\n );\n}\n\nfunction returnTrue(): boolean {\n return true;\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 >\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\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;;;;;;;ACwBA,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,OAAO;EACL,QAAQ,OAAe,QAAiD;GACtE,IAAI,SAAS,KAAK,UAAU,GAAG,OAAO;GACtC,IAAI,YAAY,QAAQ,iBAAiB,SAAS,kBAAkB,QAClE,OAAO;GAET,QAAQ;GACR,MAAM,OAAO,KAAK,QAAQ,cAAc,OAAO,MAAM;GACrD,IA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AG;GAAG,GAAG;EAAE,CAAE;CAC1E,GAAG,CAAC,aAAa,CAAC;CAElB,MAAM,YAAY,QAAQ,aAAa;CAEvC,OACE,qBAAC,MAAD;EACE,OAAO;GACL,OAAO;GACP,GAAI,OAAO,CAAC,IAAI,CAAC,OAAO,MAAM;GAC9B;IACE,OAAO,YAAY;IACnB,QAAQ,YAAY;IACpB,cAAc;GAChB;GACA;EACF;EACA,UAAU;EACV,2BAA2B;EAC3B,0BAA0B;EAC1B,kBAAkB;EAClB,iBAAiB;EACjB,oBAAoB;EACpB,sBAAsB;YAjBxB,CAmBG,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,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';\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,\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;;;;;;;ACwBA,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,OAAO;EACL,QAAQ,OAAe,QAAiD;GACtE,IAAI,SAAS,KAAK,UAAU,GAAG,OAAO;GACtC,IAAI,YAAY,QAAQ,iBAAiB,SAAS,kBAAkB,QAClE,OAAO;GAET,QAAQ;GACR,MAAM,OAAO,KAAK,QAAQ,cAAc,OAAO,MAAM;GACrD,IAAI,SAAS,MAAM,OAAO;GAC1B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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.0",
3
+ "version": "0.3.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",
@@ -40,15 +40,15 @@
40
40
  "@types/react": "^19.0.0"
41
41
  },
42
42
  "dependencies": {
43
- "@flare-engine/assets": "^0.3.0",
44
- "@flare-engine/audio": "^0.3.0",
45
- "@flare-engine/core": "^0.3.0",
46
- "@flare-engine/ecs": "^0.3.0",
47
- "@flare-engine/events": "^0.3.0",
48
- "@flare-engine/input": "^0.3.0",
49
- "@flare-engine/math": "^0.3.0",
50
- "@flare-engine/render": "^0.3.0",
51
- "@flare-engine/scene": "^0.3.0"
43
+ "@flare-engine/assets": "^0.3.1",
44
+ "@flare-engine/audio": "^0.3.1",
45
+ "@flare-engine/core": "^0.3.1",
46
+ "@flare-engine/ecs": "^0.3.1",
47
+ "@flare-engine/events": "^0.3.1",
48
+ "@flare-engine/input": "^0.3.1",
49
+ "@flare-engine/math": "^0.3.1",
50
+ "@flare-engine/render": "^0.3.1",
51
+ "@flare-engine/scene": "^0.3.1"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "react": ">=19.0.0",