@flare-engine/react 0.4.6 → 0.4.7
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 +17 -37
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +17 -37
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
package/dist/index.d.mts
CHANGED
|
@@ -9,7 +9,6 @@ import { SceneManager } from "@flare-engine/scene";
|
|
|
9
9
|
import { SkColor, SkImage, SkImageFilter, SkRuntimeEffect } from "@shopify/react-native-skia";
|
|
10
10
|
import { ViewStyle } from "react-native";
|
|
11
11
|
import { Signal } from "@flare-engine/events";
|
|
12
|
-
//#region src/game-context.d.ts
|
|
13
12
|
/** The value exposed via GameContext. */
|
|
14
13
|
interface GameContextValue {
|
|
15
14
|
/** ECS world. */
|
|
@@ -35,9 +34,7 @@ interface GameContextValue {
|
|
|
35
34
|
* React context that provides access to core game objects.
|
|
36
35
|
* Null if accessed outside a <GameView>.
|
|
37
36
|
*/
|
|
38
|
-
declare const GameContext: import("react").Context<GameContextValue | null>;
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/skia-bridge.d.ts
|
|
37
|
+
export declare const GameContext: import("react").Context<GameContextValue | null>;
|
|
41
38
|
/** Structural canvas — minimal subset needed for offscreen rendering. */
|
|
42
39
|
interface SkOffscreenCanvasLike {
|
|
43
40
|
drawPicture(picture: unknown): void;
|
|
@@ -142,26 +139,22 @@ type SkiaFrameRenderer = FrameRenderer;
|
|
|
142
139
|
* Delegates to `createFrameRenderer` from `@flare-engine/render` — the
|
|
143
140
|
* frame-renderer body is backend-neutral and shared with render-web.
|
|
144
141
|
*/
|
|
145
|
-
declare function createSkiaFrameRenderer(Skia: SkiaModuleLike): SkiaFrameRenderer;
|
|
142
|
+
export declare function createSkiaFrameRenderer(Skia: SkiaModuleLike): SkiaFrameRenderer;
|
|
146
143
|
/**
|
|
147
144
|
* Render a list of solid rectangles into a fresh offscreen surface and return
|
|
148
145
|
* the resulting image snapshot. Returns `null` if `Surface` factory is absent or
|
|
149
146
|
* fails. The surface is not cached — callers that need reuse should cache the
|
|
150
147
|
* returned image themselves.
|
|
151
148
|
*/
|
|
152
|
-
declare function renderShapesToImage(skia: SkiaModuleLike, opts: RenderShapesOpts): SkImageLike | null;
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region src/safe-area.d.ts
|
|
149
|
+
export declare function renderShapesToImage(skia: SkiaModuleLike, opts: RenderShapesOpts): SkImageLike | null;
|
|
155
150
|
interface SafeArea {
|
|
156
151
|
top: number;
|
|
157
152
|
right: number;
|
|
158
153
|
bottom: number;
|
|
159
154
|
left: number;
|
|
160
155
|
}
|
|
161
|
-
declare const SafeAreaContext: import("react").Context<SafeArea | null>;
|
|
162
|
-
declare function useSafeArea(): SafeArea;
|
|
163
|
-
//#endregion
|
|
164
|
-
//#region src/game-view.d.ts
|
|
156
|
+
export declare const SafeAreaContext: import("react").Context<SafeArea | null>;
|
|
157
|
+
export declare function useSafeArea(): SafeArea;
|
|
165
158
|
/** Render hook invoked during the frame — receives the game context and
|
|
166
159
|
* the active Skia canvas for direct draw calls. Hooks run between
|
|
167
160
|
* `renderer.applyCamera()` and `renderer.end()`, so the camera transform
|
|
@@ -241,21 +234,19 @@ interface GameViewProps {
|
|
|
241
234
|
* Overlay controls (VirtualJoystick, VirtualButton) should be placed
|
|
242
235
|
* as children; they render on top of the Skia canvas.
|
|
243
236
|
*/
|
|
244
|
-
declare function GameView({ config, onReady, style, children, safeArea }: GameViewProps): React.ReactElement;
|
|
245
|
-
//#endregion
|
|
246
|
-
//#region src/hooks.d.ts
|
|
237
|
+
export declare function GameView({ config, onReady, style, children, safeArea }: GameViewProps): React.ReactElement;
|
|
247
238
|
/**
|
|
248
239
|
* useGame — returns the GameContextValue from the nearest <GameView>.
|
|
249
240
|
* Throws if called outside a <GameView>.
|
|
250
241
|
*/
|
|
251
|
-
declare function useGame(): GameContextValue;
|
|
242
|
+
export declare function useGame(): GameContextValue;
|
|
252
243
|
/**
|
|
253
244
|
* useEntity — subscribes to an ECS Query and returns the current entity list.
|
|
254
245
|
* Re-renders when entities are added to or removed from the query.
|
|
255
246
|
*
|
|
256
247
|
* @param query An active Query obtained from world.query(...)
|
|
257
248
|
*/
|
|
258
|
-
declare function useEntity(query: Query): readonly number[];
|
|
249
|
+
export declare function useEntity(query: Query): readonly number[];
|
|
259
250
|
/**
|
|
260
251
|
* useGameLoop — registers a per-frame callback on the game loop's onUpdate signal.
|
|
261
252
|
* The callback is called each frame with delta time in seconds.
|
|
@@ -263,9 +254,7 @@ declare function useEntity(query: Query): readonly number[];
|
|
|
263
254
|
*
|
|
264
255
|
* @param callback Function called each frame with dt in seconds.
|
|
265
256
|
*/
|
|
266
|
-
declare function useGameLoop(callback: (dt: number) => void): void;
|
|
267
|
-
//#endregion
|
|
268
|
-
//#region src/loading-screen.d.ts
|
|
257
|
+
export declare function useGameLoop(callback: (dt: number) => void): void;
|
|
269
258
|
/** Props for the <LoadingScreen> component. */
|
|
270
259
|
interface LoadingScreenProps {
|
|
271
260
|
/** Progress in [0, 1]. Values outside this range are clamped. */
|
|
@@ -287,21 +276,15 @@ interface LoadingScreenProps {
|
|
|
287
276
|
* without a live Skia context. Consumers drive `progress` from the
|
|
288
277
|
* AssetManager progress callback.
|
|
289
278
|
*/
|
|
290
|
-
declare function LoadingScreen({ progress, style, barColor, trackColor, backgroundColor }: LoadingScreenProps): React.ReactElement;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
declare function
|
|
294
|
-
declare function useCountUp(target: number, durationMs?: number): number;
|
|
295
|
-
declare function useSignalState<T>(signal: Signal<T>, initial: T): T;
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region src/skia-atlas.d.ts
|
|
279
|
+
export declare function LoadingScreen({ progress, style, barColor, trackColor, backgroundColor }: LoadingScreenProps): React.ReactElement;
|
|
280
|
+
export declare function useOverlayFade(visible: boolean, durationMs?: number): number;
|
|
281
|
+
export declare function useCountUp(target: number, durationMs?: number): number;
|
|
282
|
+
export declare function useSignalState<T>(signal: Signal<T>, initial: T): T;
|
|
298
283
|
/**
|
|
299
284
|
* The RN-Skia module adapted to the engine's structural atlas interface.
|
|
300
285
|
* Centralises the one boundary assertion so template code stays cast-free.
|
|
301
286
|
*/
|
|
302
|
-
declare const skiaAtlasModule: SkiaAtlasModuleLike;
|
|
303
|
-
//#endregion
|
|
304
|
-
//#region src/virtual-button.d.ts
|
|
287
|
+
export declare const skiaAtlasModule: SkiaAtlasModuleLike;
|
|
305
288
|
/** Props for the <VirtualButton> component. */
|
|
306
289
|
interface VirtualButtonProps {
|
|
307
290
|
/** Called on each state change. */
|
|
@@ -318,9 +301,7 @@ interface VirtualButtonProps {
|
|
|
318
301
|
* of which ancestor holds the RN responder — enabling simultaneous use with
|
|
319
302
|
* `<VirtualJoystick>` without responder conflicts.
|
|
320
303
|
*/
|
|
321
|
-
declare function VirtualButton({ onStateChange, style, children }: VirtualButtonProps): React.ReactElement;
|
|
322
|
-
//#endregion
|
|
323
|
-
//#region src/virtual-joystick.d.ts
|
|
304
|
+
export declare function VirtualButton({ onStateChange, style, children }: VirtualButtonProps): React.ReactElement;
|
|
324
305
|
/** Props for the <VirtualJoystick> component. */
|
|
325
306
|
interface VirtualJoystickProps {
|
|
326
307
|
/** Joystick configuration (dead zone, max radius). */
|
|
@@ -341,7 +322,6 @@ interface VirtualJoystickProps {
|
|
|
341
322
|
* Claims the React Native touch responder so children of a parent that
|
|
342
323
|
* also claims the responder (e.g. <GameView>) still receive move/end events.
|
|
343
324
|
*/
|
|
344
|
-
declare function VirtualJoystick({ config, onStateChange, style, base, thumb }: VirtualJoystickProps): React.ReactElement;
|
|
345
|
-
|
|
346
|
-
export { type CompiledPassLike, type GameConfig, GameContext, type GameContextValue, GameView, type GameViewProps, LoadingScreen, type LoadingScreenProps, type PostFxChainLike, type PostFxPassDescriptor, type PostFxRenderHook, type PostFxRuntimeLike, type RenderHook, type RenderShapesOpts, type SafeArea, SafeAreaContext, type ShapeRect, type SkOffscreenCanvasLike, type SkiaFrameRenderer, type SkiaModuleLike, VirtualButton, type VirtualButtonProps, VirtualJoystick, type VirtualJoystickProps, createSkiaFrameRenderer, renderShapesToImage, skiaAtlasModule, useCountUp, useEntity, useGame, useGameLoop, useOverlayFade, useSafeArea, useSignalState };
|
|
325
|
+
export declare function VirtualJoystick({ config, onStateChange, style, base, thumb }: VirtualJoystickProps): React.ReactElement;
|
|
326
|
+
export type { CompiledPassLike, GameConfig, GameContextValue, GameViewProps, LoadingScreenProps, PostFxChainLike, PostFxPassDescriptor, PostFxRenderHook, PostFxRuntimeLike, RenderHook, RenderShapesOpts, SafeArea, ShapeRect, SkOffscreenCanvasLike, SkiaFrameRenderer, SkiaModuleLike, VirtualButtonProps, VirtualJoystickProps };
|
|
347
327
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/game-context.ts","../src/skia-bridge.ts","../src/safe-area.ts","../src/game-view.tsx","../src/hooks.ts","../src/loading-screen.tsx","../src/overlay-hooks.ts","../src/skia-atlas.ts","../src/virtual-button.tsx","../src/virtual-joystick.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["_$__skia_bridge_js0.SkiaFrameRenderer"],"sources":["../src/game-context.ts","../src/skia-bridge.ts","../src/safe-area.ts","../src/game-view.tsx","../src/hooks.ts","../src/loading-screen.tsx","../src/overlay-hooks.ts","../src/skia-atlas.ts","../src/virtual-button.tsx","../src/virtual-joystick.tsx"],"mappings":";;;;;;;;;;;;UAUiB;;EAEf,OAAO;;EAEP,QAAQ;;EAER,OAAO;;EAEP,OAAO;;EAEP,QAAQ;;EAER,QAAQ;;EAER,MAAM;;EAEN,UAAU;;EAEV,OAAO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,qBAAqB,MAAM;wBC5Bd,eAAe,kBAAkB;wBAoCjC,WAAW,gBAAgB;wBAmC3B,eAAe,GAAG,QAAQ,OAAO,IAAI,SAAS,IAAI;;;;;qBCpErD,iBAAiB;;UCMb;;EAEf,iBAAiB,OAAO;;EAExB,QAAQ;;EAER,WAAW,MAAM;;;;;;;;;wBAUH,gBACd,eACA,OACA,YACC,qBAAqB,MAAM;;UCpBb;;EAEf,SAAS;;EAET,iBAAiB,OAAO;;EAExB,QAAQ;;EAER,OAAO,MAAM;;EAEb,QAAQ,MAAM;;;;;;;;;wBAmBA,kBACd,QACA,eACA,OACA,MACA,SACC,uBAAuB,MAAM"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ import { SkColor, SkImage, SkImageFilter, SkRuntimeEffect } from "@shopify/react
|
|
|
9
9
|
import React from "react";
|
|
10
10
|
import { ViewStyle } from "react-native";
|
|
11
11
|
import { Signal } from "@flare-engine/events";
|
|
12
|
-
//#region src/game-context.d.ts
|
|
13
12
|
/** The value exposed via GameContext. */
|
|
14
13
|
interface GameContextValue {
|
|
15
14
|
/** ECS world. */
|
|
@@ -35,9 +34,7 @@ interface GameContextValue {
|
|
|
35
34
|
* React context that provides access to core game objects.
|
|
36
35
|
* Null if accessed outside a <GameView>.
|
|
37
36
|
*/
|
|
38
|
-
declare const GameContext: import("react").Context<GameContextValue | null>;
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/skia-bridge.d.ts
|
|
37
|
+
export declare const GameContext: import("react").Context<GameContextValue | null>;
|
|
41
38
|
/** Structural canvas — minimal subset needed for offscreen rendering. */
|
|
42
39
|
interface SkOffscreenCanvasLike {
|
|
43
40
|
drawPicture(picture: unknown): void;
|
|
@@ -142,26 +139,22 @@ type SkiaFrameRenderer = FrameRenderer;
|
|
|
142
139
|
* Delegates to `createFrameRenderer` from `@flare-engine/render` — the
|
|
143
140
|
* frame-renderer body is backend-neutral and shared with render-web.
|
|
144
141
|
*/
|
|
145
|
-
declare function createSkiaFrameRenderer(Skia: SkiaModuleLike): SkiaFrameRenderer;
|
|
142
|
+
export declare function createSkiaFrameRenderer(Skia: SkiaModuleLike): SkiaFrameRenderer;
|
|
146
143
|
/**
|
|
147
144
|
* Render a list of solid rectangles into a fresh offscreen surface and return
|
|
148
145
|
* the resulting image snapshot. Returns `null` if `Surface` factory is absent or
|
|
149
146
|
* fails. The surface is not cached — callers that need reuse should cache the
|
|
150
147
|
* returned image themselves.
|
|
151
148
|
*/
|
|
152
|
-
declare function renderShapesToImage(skia: SkiaModuleLike, opts: RenderShapesOpts): SkImageLike | null;
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region src/safe-area.d.ts
|
|
149
|
+
export declare function renderShapesToImage(skia: SkiaModuleLike, opts: RenderShapesOpts): SkImageLike | null;
|
|
155
150
|
interface SafeArea {
|
|
156
151
|
top: number;
|
|
157
152
|
right: number;
|
|
158
153
|
bottom: number;
|
|
159
154
|
left: number;
|
|
160
155
|
}
|
|
161
|
-
declare const SafeAreaContext: import("react").Context<SafeArea | null>;
|
|
162
|
-
declare function useSafeArea(): SafeArea;
|
|
163
|
-
//#endregion
|
|
164
|
-
//#region src/game-view.d.ts
|
|
156
|
+
export declare const SafeAreaContext: import("react").Context<SafeArea | null>;
|
|
157
|
+
export declare function useSafeArea(): SafeArea;
|
|
165
158
|
/** Render hook invoked during the frame — receives the game context and
|
|
166
159
|
* the active Skia canvas for direct draw calls. Hooks run between
|
|
167
160
|
* `renderer.applyCamera()` and `renderer.end()`, so the camera transform
|
|
@@ -241,21 +234,19 @@ interface GameViewProps {
|
|
|
241
234
|
* Overlay controls (VirtualJoystick, VirtualButton) should be placed
|
|
242
235
|
* as children; they render on top of the Skia canvas.
|
|
243
236
|
*/
|
|
244
|
-
declare function GameView({ config, onReady, style, children, safeArea }: GameViewProps): React.ReactElement;
|
|
245
|
-
//#endregion
|
|
246
|
-
//#region src/hooks.d.ts
|
|
237
|
+
export declare function GameView({ config, onReady, style, children, safeArea }: GameViewProps): React.ReactElement;
|
|
247
238
|
/**
|
|
248
239
|
* useGame — returns the GameContextValue from the nearest <GameView>.
|
|
249
240
|
* Throws if called outside a <GameView>.
|
|
250
241
|
*/
|
|
251
|
-
declare function useGame(): GameContextValue;
|
|
242
|
+
export declare function useGame(): GameContextValue;
|
|
252
243
|
/**
|
|
253
244
|
* useEntity — subscribes to an ECS Query and returns the current entity list.
|
|
254
245
|
* Re-renders when entities are added to or removed from the query.
|
|
255
246
|
*
|
|
256
247
|
* @param query An active Query obtained from world.query(...)
|
|
257
248
|
*/
|
|
258
|
-
declare function useEntity(query: Query): readonly number[];
|
|
249
|
+
export declare function useEntity(query: Query): readonly number[];
|
|
259
250
|
/**
|
|
260
251
|
* useGameLoop — registers a per-frame callback on the game loop's onUpdate signal.
|
|
261
252
|
* The callback is called each frame with delta time in seconds.
|
|
@@ -263,9 +254,7 @@ declare function useEntity(query: Query): readonly number[];
|
|
|
263
254
|
*
|
|
264
255
|
* @param callback Function called each frame with dt in seconds.
|
|
265
256
|
*/
|
|
266
|
-
declare function useGameLoop(callback: (dt: number) => void): void;
|
|
267
|
-
//#endregion
|
|
268
|
-
//#region src/loading-screen.d.ts
|
|
257
|
+
export declare function useGameLoop(callback: (dt: number) => void): void;
|
|
269
258
|
/** Props for the <LoadingScreen> component. */
|
|
270
259
|
interface LoadingScreenProps {
|
|
271
260
|
/** Progress in [0, 1]. Values outside this range are clamped. */
|
|
@@ -287,21 +276,15 @@ interface LoadingScreenProps {
|
|
|
287
276
|
* without a live Skia context. Consumers drive `progress` from the
|
|
288
277
|
* AssetManager progress callback.
|
|
289
278
|
*/
|
|
290
|
-
declare function LoadingScreen({ progress, style, barColor, trackColor, backgroundColor }: LoadingScreenProps): React.ReactElement;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
declare function
|
|
294
|
-
declare function useCountUp(target: number, durationMs?: number): number;
|
|
295
|
-
declare function useSignalState<T>(signal: Signal<T>, initial: T): T;
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region src/skia-atlas.d.ts
|
|
279
|
+
export declare function LoadingScreen({ progress, style, barColor, trackColor, backgroundColor }: LoadingScreenProps): React.ReactElement;
|
|
280
|
+
export declare function useOverlayFade(visible: boolean, durationMs?: number): number;
|
|
281
|
+
export declare function useCountUp(target: number, durationMs?: number): number;
|
|
282
|
+
export declare function useSignalState<T>(signal: Signal<T>, initial: T): T;
|
|
298
283
|
/**
|
|
299
284
|
* The RN-Skia module adapted to the engine's structural atlas interface.
|
|
300
285
|
* Centralises the one boundary assertion so template code stays cast-free.
|
|
301
286
|
*/
|
|
302
|
-
declare const skiaAtlasModule: SkiaAtlasModuleLike;
|
|
303
|
-
//#endregion
|
|
304
|
-
//#region src/virtual-button.d.ts
|
|
287
|
+
export declare const skiaAtlasModule: SkiaAtlasModuleLike;
|
|
305
288
|
/** Props for the <VirtualButton> component. */
|
|
306
289
|
interface VirtualButtonProps {
|
|
307
290
|
/** Called on each state change. */
|
|
@@ -318,9 +301,7 @@ interface VirtualButtonProps {
|
|
|
318
301
|
* of which ancestor holds the RN responder — enabling simultaneous use with
|
|
319
302
|
* `<VirtualJoystick>` without responder conflicts.
|
|
320
303
|
*/
|
|
321
|
-
declare function VirtualButton({ onStateChange, style, children }: VirtualButtonProps): React.ReactElement;
|
|
322
|
-
//#endregion
|
|
323
|
-
//#region src/virtual-joystick.d.ts
|
|
304
|
+
export declare function VirtualButton({ onStateChange, style, children }: VirtualButtonProps): React.ReactElement;
|
|
324
305
|
/** Props for the <VirtualJoystick> component. */
|
|
325
306
|
interface VirtualJoystickProps {
|
|
326
307
|
/** Joystick configuration (dead zone, max radius). */
|
|
@@ -341,7 +322,6 @@ interface VirtualJoystickProps {
|
|
|
341
322
|
* Claims the React Native touch responder so children of a parent that
|
|
342
323
|
* also claims the responder (e.g. <GameView>) still receive move/end events.
|
|
343
324
|
*/
|
|
344
|
-
declare function VirtualJoystick({ config, onStateChange, style, base, thumb }: VirtualJoystickProps): React.ReactElement;
|
|
345
|
-
|
|
346
|
-
export { type CompiledPassLike, type GameConfig, GameContext, type GameContextValue, GameView, type GameViewProps, LoadingScreen, type LoadingScreenProps, type PostFxChainLike, type PostFxPassDescriptor, type PostFxRenderHook, type PostFxRuntimeLike, type RenderHook, type RenderShapesOpts, type SafeArea, SafeAreaContext, type ShapeRect, type SkOffscreenCanvasLike, type SkiaFrameRenderer, type SkiaModuleLike, VirtualButton, type VirtualButtonProps, VirtualJoystick, type VirtualJoystickProps, createSkiaFrameRenderer, renderShapesToImage, skiaAtlasModule, useCountUp, useEntity, useGame, useGameLoop, useOverlayFade, useSafeArea, useSignalState };
|
|
325
|
+
export declare function VirtualJoystick({ config, onStateChange, style, base, thumb }: VirtualJoystickProps): React.ReactElement;
|
|
326
|
+
export type { CompiledPassLike, GameConfig, GameContextValue, GameViewProps, LoadingScreenProps, PostFxChainLike, PostFxPassDescriptor, PostFxRenderHook, PostFxRuntimeLike, RenderHook, RenderShapesOpts, SafeArea, ShapeRect, SkOffscreenCanvasLike, SkiaFrameRenderer, SkiaModuleLike, VirtualButtonProps, VirtualJoystickProps };
|
|
347
327
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/game-context.ts","../src/skia-bridge.ts","../src/safe-area.ts","../src/game-view.tsx","../src/hooks.ts","../src/loading-screen.tsx","../src/overlay-hooks.ts","../src/skia-atlas.ts","../src/virtual-button.tsx","../src/virtual-joystick.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["_$__skia_bridge_js0.SkiaFrameRenderer"],"sources":["../src/game-context.ts","../src/skia-bridge.ts","../src/safe-area.ts","../src/game-view.tsx","../src/hooks.ts","../src/loading-screen.tsx","../src/overlay-hooks.ts","../src/skia-atlas.ts","../src/virtual-button.tsx","../src/virtual-joystick.tsx"],"mappings":";;;;;;;;;;;;UAUiB;;EAEf,OAAO;;EAEP,QAAQ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;;EAEf;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;;;;;;;;;;wBAWc,gBACd,UACA,OACA,UACA,YACA,mBACC,qBAAqB,MAAM;wBC5Bd,eAAe,kBAAkB;wBAoCjC,WAAW,gBAAgB;wBAmC3B,eAAe,GAAG,QAAQ,OAAO,IAAI,SAAS,IAAI;;;;;qBCpErD,iBAAiB;;UCMb;;EAEf,iBAAiB,OAAO;;EAExB,QAAQ;;EAER,WAAW,MAAM;;;;;;;;;wBAUH,gBACd,eACA,OACA,YACC,qBAAqB,MAAM;;UCpBb;;EAEf,SAAS;;EAET,iBAAiB,OAAO;;EAExB,QAAQ;;EAER,OAAO,MAAM;;EAEb,QAAQ,MAAM;;;;;;;;;wBAmBA,kBACd,QACA,eACA,OACA,MACA,SACC,uBAAuB,MAAM"}
|
package/dist/index.js
CHANGED
|
@@ -14,22 +14,20 @@ let react_native_safe_area_context = require("react-native-safe-area-context");
|
|
|
14
14
|
let react_native_worklets = require("react-native-worklets");
|
|
15
15
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
16
16
|
let _flare_engine_math = require("@flare-engine/math");
|
|
17
|
-
|
|
17
|
+
// src/game-context.ts
|
|
18
18
|
/**
|
|
19
19
|
* React context that provides access to core game objects.
|
|
20
20
|
* Null if accessed outside a <GameView>.
|
|
21
21
|
*/
|
|
22
22
|
const GameContext = (0, react.createContext)(null);
|
|
23
|
-
|
|
24
|
-
//#region src/safe-area.ts
|
|
23
|
+
// src/safe-area.ts
|
|
25
24
|
const SafeAreaContext = (0, react.createContext)(null);
|
|
26
25
|
function useSafeArea() {
|
|
27
26
|
const value = (0, react.useContext)(SafeAreaContext);
|
|
28
27
|
if (value === null) throw new Error("useSafeArea must be used inside a <GameView>");
|
|
29
28
|
return value;
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
//#region src/scene-texture.ts
|
|
30
|
+
// src/scene-texture.ts
|
|
33
31
|
/**
|
|
34
32
|
* `Symbol.dispose` is not in this project's ES2022 lib, so the well-known
|
|
35
33
|
* symbol is looked up at runtime instead of written as a computed key.
|
|
@@ -131,8 +129,7 @@ function createSceneCapture(Skia, opts) {
|
|
|
131
129
|
}
|
|
132
130
|
};
|
|
133
131
|
}
|
|
134
|
-
|
|
135
|
-
//#region src/skia-bridge.ts
|
|
132
|
+
// src/skia-bridge.ts
|
|
136
133
|
/**
|
|
137
134
|
* Take a snapshot of `surface` and detach it from the GPU context so it can
|
|
138
135
|
* be safely sampled from a different GrDirectContext (e.g. the on-screen
|
|
@@ -192,8 +189,7 @@ function unpackArgb(out, argb) {
|
|
|
192
189
|
out[2] = (argb & 255) / 255;
|
|
193
190
|
out[3] = (argb >>> 24 & 255) / 255;
|
|
194
191
|
}
|
|
195
|
-
|
|
196
|
-
//#region src/game-view.tsx
|
|
192
|
+
// src/game-view.tsx
|
|
197
193
|
/**
|
|
198
194
|
* Capture the frame's picture into an offscreen surface **on the UI thread**.
|
|
199
195
|
*
|
|
@@ -296,14 +292,16 @@ function GameView({ config, onReady, style, children, safeArea }) {
|
|
|
296
292
|
if (onRenderPostFx) onRenderPostFx(ctx, ctx.renderer.canvas, bridge);
|
|
297
293
|
ctx.renderer.end();
|
|
298
294
|
const pic = bridge.endFrame();
|
|
299
|
-
if (pic !== null)
|
|
300
|
-
if (
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
295
|
+
if (pic !== null) {
|
|
296
|
+
if (isWeb) {
|
|
297
|
+
if (captureRef.current === null) captureRef.current = createSceneCapture(_shopify_react_native_skia.Skia, {
|
|
298
|
+
nonTextureImage: true,
|
|
299
|
+
retentionDepth: 3
|
|
300
|
+
});
|
|
301
|
+
const img = captureRef.current.capture(pic, w * pd, h * pd);
|
|
302
|
+
if (img !== null) sceneImage.value = img;
|
|
303
|
+
} else (0, react_native_worklets.scheduleOnUI)(captureSceneOnUI, sceneImage, uiSurface, uiSurfaceKey, pic, w * pd, h * pd);
|
|
304
|
+
}
|
|
307
305
|
if (!isWeb) {
|
|
308
306
|
const built = bridge.buildPostFxPasses(null, null, w, h);
|
|
309
307
|
if (!samePasses(prevBuilt, built)) {
|
|
@@ -462,8 +460,7 @@ function sameUniforms(a, b) {
|
|
|
462
460
|
return true;
|
|
463
461
|
}
|
|
464
462
|
const styles$3 = react_native.StyleSheet.create({ container: { flex: 1 } });
|
|
465
|
-
|
|
466
|
-
//#region src/hooks.ts
|
|
463
|
+
// src/hooks.ts
|
|
467
464
|
/**
|
|
468
465
|
* useGame — returns the GameContextValue from the nearest <GameView>.
|
|
469
466
|
* Throws if called outside a <GameView>.
|
|
@@ -514,8 +511,7 @@ function useGameLoop(callback) {
|
|
|
514
511
|
};
|
|
515
512
|
}, [loop, stable]);
|
|
516
513
|
}
|
|
517
|
-
|
|
518
|
-
//#region src/loading-screen.tsx
|
|
514
|
+
// src/loading-screen.tsx
|
|
519
515
|
/**
|
|
520
516
|
* LoadingScreen — full-screen asset-load overlay.
|
|
521
517
|
*
|
|
@@ -560,8 +556,7 @@ const styles$2 = react_native.StyleSheet.create({
|
|
|
560
556
|
},
|
|
561
557
|
bar: { height: "100%" }
|
|
562
558
|
});
|
|
563
|
-
|
|
564
|
-
//#region src/overlay-hooks.ts
|
|
559
|
+
// src/overlay-hooks.ts
|
|
565
560
|
function useOverlayFade(visible, durationMs = 300) {
|
|
566
561
|
const target = visible ? 1 : 0;
|
|
567
562
|
const [opacity, setOpacity] = (0, react.useState)(target);
|
|
@@ -624,15 +619,13 @@ function useSignalState(signal, initial) {
|
|
|
624
619
|
}, [signal]);
|
|
625
620
|
return state;
|
|
626
621
|
}
|
|
627
|
-
|
|
628
|
-
//#region src/skia-atlas.ts
|
|
622
|
+
// src/skia-atlas.ts
|
|
629
623
|
/**
|
|
630
624
|
* The RN-Skia module adapted to the engine's structural atlas interface.
|
|
631
625
|
* Centralises the one boundary assertion so template code stays cast-free.
|
|
632
626
|
*/
|
|
633
627
|
const skiaAtlasModule = _shopify_react_native_skia.Skia;
|
|
634
|
-
|
|
635
|
-
//#region src/virtual-button.tsx
|
|
628
|
+
// src/virtual-button.tsx
|
|
636
629
|
/**
|
|
637
630
|
* VirtualButton — an on-screen button overlay component.
|
|
638
631
|
*
|
|
@@ -668,8 +661,7 @@ const styles$1 = react_native.StyleSheet.create({ button: {
|
|
|
668
661
|
alignItems: "center",
|
|
669
662
|
justifyContent: "center"
|
|
670
663
|
} });
|
|
671
|
-
|
|
672
|
-
//#region src/virtual-joystick.tsx
|
|
664
|
+
// src/virtual-joystick.tsx
|
|
673
665
|
/**
|
|
674
666
|
* VirtualJoystick — an on-screen joystick overlay component.
|
|
675
667
|
*
|
|
@@ -793,7 +785,6 @@ const styles = react_native.StyleSheet.create({
|
|
|
793
785
|
pointerEvents: "none"
|
|
794
786
|
}
|
|
795
787
|
});
|
|
796
|
-
//#endregion
|
|
797
788
|
exports.GameContext = GameContext;
|
|
798
789
|
exports.GameView = GameView;
|
|
799
790
|
exports.LoadingScreen = LoadingScreen;
|