@flare-engine/devtools 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 +11 -27
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +11 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { GameLoop } from "@flare-engine/core";
|
|
3
3
|
import { World } from "@flare-engine/ecs";
|
|
4
|
-
//#region src/ring-buffer.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Source callback used by `createSnapshotRingBuffer` to produce a snapshot
|
|
7
6
|
* each capture tick. The ring buffer never introspects the snapshot — it is
|
|
@@ -30,9 +29,7 @@ interface SnapshotRingBuffer<T> {
|
|
|
30
29
|
/** Drop all retained snapshots. */
|
|
31
30
|
reset(): void;
|
|
32
31
|
}
|
|
33
|
-
declare function createSnapshotRingBuffer<T>(size: number, source: SnapshotSource<T>): SnapshotRingBuffer<T>;
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/time-scrubber.d.ts
|
|
32
|
+
export declare function createSnapshotRingBuffer<T>(size: number, source: SnapshotSource<T>): SnapshotRingBuffer<T>;
|
|
36
33
|
/**
|
|
37
34
|
* Restore callback invoked by `TimeScrubber.rewind()` to apply a historical
|
|
38
35
|
* snapshot back to world state. Consumers implement deserialize semantics
|
|
@@ -50,7 +47,7 @@ interface TimeScrubberOptions<T> {
|
|
|
50
47
|
* ring buffer. Exposes pause / step / resume plus `rewind(framesAgo)` which
|
|
51
48
|
* pauses the loop and hands the historical snapshot to the restore callback.
|
|
52
49
|
*/
|
|
53
|
-
declare class TimeScrubber<T> {
|
|
50
|
+
export declare class TimeScrubber<T> {
|
|
54
51
|
private readonly loop;
|
|
55
52
|
private readonly buffer;
|
|
56
53
|
private readonly restore;
|
|
@@ -89,8 +86,6 @@ declare class TimeScrubber<T> {
|
|
|
89
86
|
*/
|
|
90
87
|
consumeStep(): boolean;
|
|
91
88
|
}
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/context.d.ts
|
|
94
89
|
/** Devtools configuration. */
|
|
95
90
|
interface DevtoolsConfig {
|
|
96
91
|
/** Ring-buffer depth in frames. Default 120 (~2 s @ 60 fps). */
|
|
@@ -109,14 +104,10 @@ interface DevtoolsContextValue {
|
|
|
109
104
|
selectedEntity: number | null;
|
|
110
105
|
select(entity: number | null): void;
|
|
111
106
|
}
|
|
112
|
-
declare const DevtoolsContext: import("react").Context<DevtoolsContextValue | null>;
|
|
113
|
-
|
|
114
|
-
//#region src/dev-mode.d.ts
|
|
115
|
-
declare function isDevMode(): boolean;
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/hooks.d.ts
|
|
107
|
+
export declare const DevtoolsContext: import("react").Context<DevtoolsContextValue | null>;
|
|
108
|
+
export declare function isDevMode(): boolean;
|
|
118
109
|
/** Returns the active devtools context, or throws if no provider is mounted. */
|
|
119
|
-
declare function useDevtools(): DevtoolsContextValue;
|
|
110
|
+
export declare function useDevtools(): DevtoolsContextValue;
|
|
120
111
|
interface EntityInspectorView {
|
|
121
112
|
selected: number | null;
|
|
122
113
|
select(entity: number | null): void;
|
|
@@ -124,7 +115,7 @@ interface EntityInspectorView {
|
|
|
124
115
|
entities: readonly number[];
|
|
125
116
|
}
|
|
126
117
|
/** Entity-inspector hook. Never mutates the world — read-only snapshot. */
|
|
127
|
-
declare function useEntityInspector(): EntityInspectorView;
|
|
118
|
+
export declare function useEntityInspector(): EntityInspectorView;
|
|
128
119
|
interface TimeScrubView {
|
|
129
120
|
paused: boolean;
|
|
130
121
|
scrubbing: boolean;
|
|
@@ -135,23 +126,17 @@ interface TimeScrubView {
|
|
|
135
126
|
rewind(framesAgo: number): void;
|
|
136
127
|
}
|
|
137
128
|
/** Time-scrub hook — exposes the scrubber's imperative controls. */
|
|
138
|
-
declare function useTimeScrub(): TimeScrubView;
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/hud.d.ts
|
|
129
|
+
export declare function useTimeScrub(): TimeScrubView;
|
|
141
130
|
/**
|
|
142
131
|
* DevtoolsHUD — compact native overlay. Shows buffer depth + pause/step/resume
|
|
143
132
|
* buttons. No-op on web (renders `null`).
|
|
144
133
|
*/
|
|
145
|
-
declare function DevtoolsHUD(): ReactNode;
|
|
146
|
-
//#endregion
|
|
147
|
-
//#region src/panel.d.ts
|
|
134
|
+
export declare function DevtoolsHUD(): ReactNode;
|
|
148
135
|
/**
|
|
149
136
|
* DevtoolsPanel — full web-side panel. Renders the entity tree, scrub
|
|
150
137
|
* controls, and buffer depth. No-op on native (renders `null`).
|
|
151
138
|
*/
|
|
152
|
-
declare function DevtoolsPanel(): ReactNode;
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region src/provider.d.ts
|
|
139
|
+
export declare function DevtoolsPanel(): ReactNode;
|
|
155
140
|
interface DevtoolsProviderProps<T = unknown> {
|
|
156
141
|
world: World;
|
|
157
142
|
loop: GameLoop;
|
|
@@ -167,7 +152,6 @@ interface DevtoolsProviderProps<T = unknown> {
|
|
|
167
152
|
* Subscribes to `loop.onUpdate` and captures snapshots into a pre-allocated
|
|
168
153
|
* ring buffer; exposes scrubber controls via `DevtoolsContext`.
|
|
169
154
|
*/
|
|
170
|
-
declare function DevtoolsProvider<T>({ world, loop, snapshot, restore, config, children }: DevtoolsProviderProps<T>): ReactNode;
|
|
171
|
-
|
|
172
|
-
export { type DevtoolsConfig, DevtoolsContext, type DevtoolsContextValue, DevtoolsHUD, DevtoolsPanel, DevtoolsProvider, type DevtoolsProviderProps, type EntityInspectorView, type RestoreCallback, type SnapshotRingBuffer, type SnapshotSource, type TimeScrubView, TimeScrubber, type TimeScrubberOptions, createSnapshotRingBuffer, isDevMode, useDevtools, useEntityInspector, useTimeScrub };
|
|
155
|
+
export declare function DevtoolsProvider<T>({ world, loop, snapshot, restore, config, children }: DevtoolsProviderProps<T>): ReactNode;
|
|
156
|
+
export type { DevtoolsConfig, DevtoolsContextValue, DevtoolsProviderProps, EntityInspectorView, RestoreCallback, SnapshotRingBuffer, SnapshotSource, TimeScrubView, TimeScrubberOptions };
|
|
173
157
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/ring-buffer.ts","../src/time-scrubber.ts","../src/context.ts","../src/dev-mode.ts","../src/hooks.ts","../src/hud.tsx","../src/panel.tsx","../src/provider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/ring-buffer.ts","../src/time-scrubber.ts","../src/context.ts","../src/dev-mode.ts","../src/hooks.ts","../src/hud.tsx","../src/panel.tsx","../src/provider.tsx"],"mappings":";;;;;;;;;KAMY,eAAe,WAAW;;;;;;;;UASrB,mBAAmB;;WAEzB;;WAEA;;WAEA,QAAQ;;EAEjB;;EAEA,OAAO,oBAAoB;;EAE3B;;wBAGc,yBAAyB,GACvC,cACA,QAAQ,eAAe,KACtB,mBAAmB;;;;;;KCzBV,gBAAgB,MAAM,UAAU;UAE3B,oBAAoB;EACnC,MAAM;EACN,QAAQ,mBAAmB;;EAE3B,UAAU,gBAAgB;;;;;;;qBAQf,aAAa;mBACP;mBACA;mBACA;UACT;UACA;;UAEA;EAEI,YAAA,SAAS,oBAAoB;;MAOrC;;MAKA;;MAKA;;;;EAOJ;;;;EAUA;;EAOA;;MAKI;;;;;;EASJ,OAAO,oBAAoB;;;;;EAiB3B;;;UChGe;;EAEf;;EAEA;;EAEA;;;UAIe;EACf,OAAO;EACP,MAAM;EACN,QAAQ;EACR,UAAU;EACV;EACA,OAAO;;qBAGI,iCAAe,QAAA;wBCxBZ;;wBCEA,eAAe;UAQd;EACf;EACA,OAAO;;EAEP;;;wBAIc,sBAAsB;UAOrB;EACf;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;;;wBAIO,gBAAgB;;;;;wBC9BhB,eAAe;;;;;wBCAf,iBAAiB;UCDhB,sBAAsB;EACrC,OAAO;EACP,MAAM;;EAEN,UAAU,eAAe;;EAEzB,UAAU,gBAAgB;EAC1B,SAAS;EACT,WAAW;;;;;;;wBAcG,iBAAiB,KAC/B,OACA,MACA,UACA,SACA,QACA,YACC,sBAAsB,KAAK"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GameLoop } from "@flare-engine/core";
|
|
2
2
|
import { World } from "@flare-engine/ecs";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
|
-
//#region src/ring-buffer.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Source callback used by `createSnapshotRingBuffer` to produce a snapshot
|
|
7
6
|
* each capture tick. The ring buffer never introspects the snapshot — it is
|
|
@@ -30,9 +29,7 @@ interface SnapshotRingBuffer<T> {
|
|
|
30
29
|
/** Drop all retained snapshots. */
|
|
31
30
|
reset(): void;
|
|
32
31
|
}
|
|
33
|
-
declare function createSnapshotRingBuffer<T>(size: number, source: SnapshotSource<T>): SnapshotRingBuffer<T>;
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/time-scrubber.d.ts
|
|
32
|
+
export declare function createSnapshotRingBuffer<T>(size: number, source: SnapshotSource<T>): SnapshotRingBuffer<T>;
|
|
36
33
|
/**
|
|
37
34
|
* Restore callback invoked by `TimeScrubber.rewind()` to apply a historical
|
|
38
35
|
* snapshot back to world state. Consumers implement deserialize semantics
|
|
@@ -50,7 +47,7 @@ interface TimeScrubberOptions<T> {
|
|
|
50
47
|
* ring buffer. Exposes pause / step / resume plus `rewind(framesAgo)` which
|
|
51
48
|
* pauses the loop and hands the historical snapshot to the restore callback.
|
|
52
49
|
*/
|
|
53
|
-
declare class TimeScrubber<T> {
|
|
50
|
+
export declare class TimeScrubber<T> {
|
|
54
51
|
private readonly loop;
|
|
55
52
|
private readonly buffer;
|
|
56
53
|
private readonly restore;
|
|
@@ -89,8 +86,6 @@ declare class TimeScrubber<T> {
|
|
|
89
86
|
*/
|
|
90
87
|
consumeStep(): boolean;
|
|
91
88
|
}
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/context.d.ts
|
|
94
89
|
/** Devtools configuration. */
|
|
95
90
|
interface DevtoolsConfig {
|
|
96
91
|
/** Ring-buffer depth in frames. Default 120 (~2 s @ 60 fps). */
|
|
@@ -109,14 +104,10 @@ interface DevtoolsContextValue {
|
|
|
109
104
|
selectedEntity: number | null;
|
|
110
105
|
select(entity: number | null): void;
|
|
111
106
|
}
|
|
112
|
-
declare const DevtoolsContext: import("react").Context<DevtoolsContextValue | null>;
|
|
113
|
-
|
|
114
|
-
//#region src/dev-mode.d.ts
|
|
115
|
-
declare function isDevMode(): boolean;
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/hooks.d.ts
|
|
107
|
+
export declare const DevtoolsContext: import("react").Context<DevtoolsContextValue | null>;
|
|
108
|
+
export declare function isDevMode(): boolean;
|
|
118
109
|
/** Returns the active devtools context, or throws if no provider is mounted. */
|
|
119
|
-
declare function useDevtools(): DevtoolsContextValue;
|
|
110
|
+
export declare function useDevtools(): DevtoolsContextValue;
|
|
120
111
|
interface EntityInspectorView {
|
|
121
112
|
selected: number | null;
|
|
122
113
|
select(entity: number | null): void;
|
|
@@ -124,7 +115,7 @@ interface EntityInspectorView {
|
|
|
124
115
|
entities: readonly number[];
|
|
125
116
|
}
|
|
126
117
|
/** Entity-inspector hook. Never mutates the world — read-only snapshot. */
|
|
127
|
-
declare function useEntityInspector(): EntityInspectorView;
|
|
118
|
+
export declare function useEntityInspector(): EntityInspectorView;
|
|
128
119
|
interface TimeScrubView {
|
|
129
120
|
paused: boolean;
|
|
130
121
|
scrubbing: boolean;
|
|
@@ -135,23 +126,17 @@ interface TimeScrubView {
|
|
|
135
126
|
rewind(framesAgo: number): void;
|
|
136
127
|
}
|
|
137
128
|
/** Time-scrub hook — exposes the scrubber's imperative controls. */
|
|
138
|
-
declare function useTimeScrub(): TimeScrubView;
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/hud.d.ts
|
|
129
|
+
export declare function useTimeScrub(): TimeScrubView;
|
|
141
130
|
/**
|
|
142
131
|
* DevtoolsHUD — compact native overlay. Shows buffer depth + pause/step/resume
|
|
143
132
|
* buttons. No-op on web (renders `null`).
|
|
144
133
|
*/
|
|
145
|
-
declare function DevtoolsHUD(): ReactNode;
|
|
146
|
-
//#endregion
|
|
147
|
-
//#region src/panel.d.ts
|
|
134
|
+
export declare function DevtoolsHUD(): ReactNode;
|
|
148
135
|
/**
|
|
149
136
|
* DevtoolsPanel — full web-side panel. Renders the entity tree, scrub
|
|
150
137
|
* controls, and buffer depth. No-op on native (renders `null`).
|
|
151
138
|
*/
|
|
152
|
-
declare function DevtoolsPanel(): ReactNode;
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region src/provider.d.ts
|
|
139
|
+
export declare function DevtoolsPanel(): ReactNode;
|
|
155
140
|
interface DevtoolsProviderProps<T = unknown> {
|
|
156
141
|
world: World;
|
|
157
142
|
loop: GameLoop;
|
|
@@ -167,7 +152,6 @@ interface DevtoolsProviderProps<T = unknown> {
|
|
|
167
152
|
* Subscribes to `loop.onUpdate` and captures snapshots into a pre-allocated
|
|
168
153
|
* ring buffer; exposes scrubber controls via `DevtoolsContext`.
|
|
169
154
|
*/
|
|
170
|
-
declare function DevtoolsProvider<T>({ world, loop, snapshot, restore, config, children }: DevtoolsProviderProps<T>): ReactNode;
|
|
171
|
-
|
|
172
|
-
export { type DevtoolsConfig, DevtoolsContext, type DevtoolsContextValue, DevtoolsHUD, DevtoolsPanel, DevtoolsProvider, type DevtoolsProviderProps, type EntityInspectorView, type RestoreCallback, type SnapshotRingBuffer, type SnapshotSource, type TimeScrubView, TimeScrubber, type TimeScrubberOptions, createSnapshotRingBuffer, isDevMode, useDevtools, useEntityInspector, useTimeScrub };
|
|
155
|
+
export declare function DevtoolsProvider<T>({ world, loop, snapshot, restore, config, children }: DevtoolsProviderProps<T>): ReactNode;
|
|
156
|
+
export type { DevtoolsConfig, DevtoolsContextValue, DevtoolsProviderProps, EntityInspectorView, RestoreCallback, SnapshotRingBuffer, SnapshotSource, TimeScrubView, TimeScrubberOptions };
|
|
173
157
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/ring-buffer.ts","../src/time-scrubber.ts","../src/context.ts","../src/dev-mode.ts","../src/hooks.ts","../src/hud.tsx","../src/panel.tsx","../src/provider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/ring-buffer.ts","../src/time-scrubber.ts","../src/context.ts","../src/dev-mode.ts","../src/hooks.ts","../src/hud.tsx","../src/panel.tsx","../src/provider.tsx"],"mappings":";;;;;;;;;KAMY,eAAe,WAAW;;;;;;;;UASrB,mBAAmB;;WAEzB;;WAEA;;WAEA,QAAQ;;EAEjB;;EAEA,OAAO,oBAAoB;;EAE3B;;wBAGc,yBAAyB,GACvC,cACA,QAAQ,eAAe,KACtB,mBAAmB;;;;;;KCzBV,gBAAgB,MAAM,UAAU;UAE3B,oBAAoB;EACnC,MAAM;EACN,QAAQ,mBAAmB;;EAE3B,UAAU,gBAAgB;;;;;;;qBAQf,aAAa;mBACP;mBACA;mBACA;UACT;UACA;;UAEA;EAEI,YAAA,SAAS,oBAAoB;;MAOrC;;MAKA;;MAKA;;;;EAOJ;;;;EAUA;;EAOA;;MAKI;;;;;;EASJ,OAAO,oBAAoB;;;;;EAiB3B;;;UChGe;;EAEf;;EAEA;;EAEA;;;UAIe;EACf,OAAO;EACP,MAAM;EACN,QAAQ;EACR,UAAU;EACV;EACA,OAAO;;qBAGI,iCAAe,QAAA;wBCxBZ;;wBCEA,eAAe;UAQd;EACf;EACA,OAAO;;EAEP;;;wBAIc,sBAAsB;UAOrB;EACf;EACA;EACA;EACA;EACA;EACA;EACA,OAAO;;;wBAIO,gBAAgB;;;;;wBC9BhB,eAAe;;;;;wBCAf,iBAAiB;UCDhB,sBAAsB;EACrC,OAAO;EACP,MAAM;;EAEN,UAAU,eAAe;;EAEzB,UAAU,gBAAgB;EAC1B,SAAS;EACT,WAAW;;;;;;;wBAcG,iBAAiB,KAC/B,OACA,MACA,UACA,SACA,QACA,YACC,sBAAsB,KAAK"}
|
package/dist/index.js
CHANGED
|
@@ -2,15 +2,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
let react = require("react");
|
|
3
3
|
let react_native = require("react-native");
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
-
|
|
5
|
+
// src/context.ts
|
|
6
6
|
const DevtoolsContext = (0, react.createContext)(null);
|
|
7
|
-
|
|
8
|
-
//#region src/dev-mode.ts
|
|
7
|
+
// src/dev-mode.ts
|
|
9
8
|
function isDevMode() {
|
|
10
9
|
return typeof __DEV__ !== "undefined" && Boolean(__DEV__);
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
//#region src/hooks.ts
|
|
11
|
+
// src/hooks.ts
|
|
14
12
|
/** Returns the active devtools context, or throws if no provider is mounted. */
|
|
15
13
|
function useDevtools() {
|
|
16
14
|
const ctx = (0, react.useContext)(DevtoolsContext);
|
|
@@ -43,8 +41,7 @@ function useTimeScrub() {
|
|
|
43
41
|
}
|
|
44
42
|
};
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
//#region src/hud.tsx
|
|
44
|
+
// src/hud.tsx
|
|
48
45
|
/**
|
|
49
46
|
* DevtoolsHUD — compact native overlay. Shows buffer depth + pause/step/resume
|
|
50
47
|
* buttons. No-op on web (renders `null`).
|
|
@@ -110,8 +107,7 @@ function HudButton({ label, onPress }) {
|
|
|
110
107
|
})
|
|
111
108
|
});
|
|
112
109
|
}
|
|
113
|
-
|
|
114
|
-
//#region src/panel.tsx
|
|
110
|
+
// src/panel.tsx
|
|
115
111
|
/**
|
|
116
112
|
* DevtoolsPanel — full web-side panel. Renders the entity tree, scrub
|
|
117
113
|
* controls, and buffer depth. No-op on native (renders `null`).
|
|
@@ -211,8 +207,7 @@ function DevButton({ label, onPress }) {
|
|
|
211
207
|
})
|
|
212
208
|
});
|
|
213
209
|
}
|
|
214
|
-
|
|
215
|
-
//#region src/ring-buffer.ts
|
|
210
|
+
// src/ring-buffer.ts
|
|
216
211
|
function createSnapshotRingBuffer(size, source) {
|
|
217
212
|
if (size <= 0 || !Number.isFinite(size)) throw new Error(`SnapshotRingBuffer size must be a positive finite number, got ${size}`);
|
|
218
213
|
const capacity = Math.floor(size);
|
|
@@ -248,8 +243,7 @@ function createSnapshotRingBuffer(size, source) {
|
|
|
248
243
|
}
|
|
249
244
|
};
|
|
250
245
|
}
|
|
251
|
-
|
|
252
|
-
//#region src/time-scrubber.ts
|
|
246
|
+
// src/time-scrubber.ts
|
|
253
247
|
/**
|
|
254
248
|
* TimeScrubber — imperative controller binding a `GameLoop` to a snapshot
|
|
255
249
|
* ring buffer. Exposes pause / step / resume plus `rewind(framesAgo)` which
|
|
@@ -330,8 +324,7 @@ var TimeScrubber = class {
|
|
|
330
324
|
return true;
|
|
331
325
|
}
|
|
332
326
|
};
|
|
333
|
-
|
|
334
|
-
//#region src/provider.tsx
|
|
327
|
+
// src/provider.tsx
|
|
335
328
|
const DEFAULT_CONFIG = {
|
|
336
329
|
ringSize: 120,
|
|
337
330
|
captureInterval: 1,
|
|
@@ -388,7 +381,6 @@ function DevtoolsProvider({ world, loop, snapshot, restore, config, children })
|
|
|
388
381
|
children
|
|
389
382
|
});
|
|
390
383
|
}
|
|
391
|
-
//#endregion
|
|
392
384
|
exports.DevtoolsContext = DevtoolsContext;
|
|
393
385
|
exports.DevtoolsHUD = DevtoolsHUD;
|
|
394
386
|
exports.DevtoolsPanel = DevtoolsPanel;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Platform","View","Text","Pressable","Platform","View","Text","Pressable"],"sources":["../src/context.ts","../src/dev-mode.ts","../src/hooks.ts","../src/hud.tsx","../src/panel.tsx","../src/ring-buffer.ts","../src/time-scrubber.ts","../src/provider.tsx"],"sourcesContent":["import type { GameLoop } from '@flare-engine/core';\nimport type { World } from '@flare-engine/ecs';\nimport { createContext } from 'react';\nimport type { SnapshotRingBuffer } from './ring-buffer.js';\nimport type { TimeScrubber } from './time-scrubber.js';\n\n/** Devtools configuration. */\nexport interface DevtoolsConfig {\n /** Ring-buffer depth in frames. Default 120 (~2 s @ 60 fps). */\n ringSize?: number;\n /** Capture every Nth `onUpdate`. Default 1 (every frame). */\n captureInterval?: number;\n /** Enable the native HUD surface. Default true. */\n enabledOnNative?: boolean;\n}\n\n/** Value exposed via `DevtoolsContext`. */\nexport interface DevtoolsContextValue {\n world: World;\n loop: GameLoop;\n buffer: SnapshotRingBuffer<unknown>;\n scrubber: TimeScrubber<unknown>;\n selectedEntity: number | null;\n select(entity: number | null): void;\n}\n\nexport const DevtoolsContext = createContext<DevtoolsContextValue | null>(null);\n","declare const __DEV__: boolean | undefined;\n\nexport function isDevMode(): boolean {\n return typeof __DEV__ !== 'undefined' && Boolean(__DEV__);\n}\n","import { useContext } from 'react';\nimport { DevtoolsContext, type DevtoolsContextValue } from './context.js';\n\n/** Returns the active devtools context, or throws if no provider is mounted. */\nexport function useDevtools(): DevtoolsContextValue {\n const ctx = useContext(DevtoolsContext);\n if (!ctx) {\n throw new Error('useDevtools must be used inside a <DevtoolsProvider>');\n }\n return ctx;\n}\n\nexport interface EntityInspectorView {\n selected: number | null;\n select(entity: number | null): void;\n /** Entity IDs present in the world at the moment the hook was read. */\n entities: readonly number[];\n}\n\n/** Entity-inspector hook. Never mutates the world — read-only snapshot. */\nexport function useEntityInspector(): EntityInspectorView {\n const { world, selectedEntity, select } = useDevtools();\n const entities: number[] = [];\n world.forEachEntity((id) => entities.push(id));\n return { selected: selectedEntity, select, entities };\n}\n\nexport interface TimeScrubView {\n paused: boolean;\n scrubbing: boolean;\n available: number;\n pause(): void;\n resume(): void;\n step(): void;\n rewind(framesAgo: number): void;\n}\n\n/** Time-scrub hook — exposes the scrubber's imperative controls. */\nexport function useTimeScrub(): TimeScrubView {\n const { scrubber } = useDevtools();\n return {\n paused: scrubber.paused,\n scrubbing: scrubber.scrubbing,\n available: scrubber.available,\n pause: () => scrubber.pause(),\n resume: () => scrubber.resume(),\n step: () => scrubber.step(),\n rewind: (framesAgo: number) => {\n scrubber.rewind(framesAgo);\n },\n };\n}\n","import type { ReactNode } from 'react';\nimport { Platform, Pressable, Text, View } from 'react-native';\nimport { useDevtools, useTimeScrub } from './hooks.js';\n\n/**\n * DevtoolsHUD — compact native overlay. Shows buffer depth + pause/step/resume\n * buttons. No-op on web (renders `null`).\n */\nexport function DevtoolsHUD(): ReactNode {\n if (Platform.OS === 'web') return null;\n return <HUDBody />;\n}\n\nfunction HUDBody(): ReactNode {\n const { buffer } = useDevtools();\n const scrub = useTimeScrub();\n\n return (\n <View\n style={{\n position: 'absolute',\n bottom: 16,\n right: 16,\n flexDirection: 'row',\n alignItems: 'center',\n padding: 6,\n backgroundColor: 'rgba(0,0,0,0.75)',\n borderRadius: 4,\n }}\n >\n <Text style={{ color: '#fff', marginRight: 8 }}>\n {buffer.length}/{buffer.size}\n </Text>\n <HudButton label=\"||\" onPress={scrub.pause} />\n <HudButton label=\">|\" onPress={scrub.step} />\n <HudButton label=\">\" onPress={scrub.resume} />\n </View>\n );\n}\n\nfunction HudButton({ label, onPress }: { label: string; onPress: () => void }): ReactNode {\n return (\n <Pressable\n onPress={onPress}\n style={{\n paddingHorizontal: 6,\n paddingVertical: 2,\n marginLeft: 4,\n backgroundColor: '#444',\n borderRadius: 2,\n }}\n >\n <Text style={{ color: '#fff' }}>{label}</Text>\n </Pressable>\n );\n}\n","import type { ReactNode } from 'react';\nimport { Platform, Pressable, Text, View } from 'react-native';\nimport { useDevtools, useEntityInspector, useTimeScrub } from './hooks.js';\n\n/**\n * DevtoolsPanel — full web-side panel. Renders the entity tree, scrub\n * controls, and buffer depth. No-op on native (renders `null`).\n */\nexport function DevtoolsPanel(): ReactNode {\n if (Platform.OS !== 'web') return null;\n return <PanelBody />;\n}\n\nfunction PanelBody(): ReactNode {\n const { buffer } = useDevtools();\n const { entities, selected, select } = useEntityInspector();\n const scrub = useTimeScrub();\n\n return (\n <View\n style={{\n position: 'absolute',\n top: 8,\n right: 8,\n padding: 8,\n backgroundColor: 'rgba(0,0,0,0.75)',\n borderRadius: 4,\n minWidth: 200,\n }}\n >\n <Text style={{ color: '#fff', fontWeight: 'bold' }}>Devtools</Text>\n <Text style={{ color: '#ccc' }}>\n buffer {buffer.length}/{buffer.size}\n </Text>\n <Text style={{ color: '#ccc' }}>\n {scrub.paused ? 'paused' : 'running'}\n {scrub.scrubbing ? ' (scrub)' : ''}\n </Text>\n <View style={{ flexDirection: 'row', marginTop: 4 }}>\n <DevButton label=\"Pause\" onPress={scrub.pause} />\n <DevButton label=\"Step\" onPress={scrub.step} />\n <DevButton label=\"Resume\" onPress={scrub.resume} />\n </View>\n <View style={{ marginTop: 8 }}>\n <Text style={{ color: '#fff' }}>entities ({entities.length})</Text>\n {entities.slice(0, 20).map((id) => (\n <Pressable key={id} onPress={() => select(id)}>\n <Text style={{ color: id === selected ? '#ff0' : '#fff' }}>#{id}</Text>\n </Pressable>\n ))}\n </View>\n </View>\n );\n}\n\nfunction DevButton({ label, onPress }: { label: string; onPress: () => void }): ReactNode {\n return (\n <Pressable\n onPress={onPress}\n style={{\n paddingHorizontal: 6,\n paddingVertical: 2,\n marginRight: 4,\n backgroundColor: '#444',\n borderRadius: 2,\n }}\n >\n <Text style={{ color: '#fff' }}>{label}</Text>\n </Pressable>\n );\n}\n","/**\n * Source callback used by `createSnapshotRingBuffer` to produce a snapshot\n * each capture tick. The ring buffer never introspects the snapshot — it is\n * an opaque `T` to this package. A future `World.serialize()` can be passed\n * in directly by consumers.\n */\nexport type SnapshotSource<T> = () => T;\n\n/**\n * Pre-allocated snapshot ring buffer. Slots are allocated once at\n * construction and the `write` cursor walks in place — zero per-frame\n * allocation. `rewind(framesAgo)` returns the snapshot that was `framesAgo`\n * captures back (0 = latest), or `null` if the requested offset exceeds the\n * number of snapshots currently held.\n */\nexport interface SnapshotRingBuffer<T> {\n /** Maximum number of snapshots retained. */\n readonly size: number;\n /** Number of snapshots currently held (0…size). */\n readonly length: number;\n /** Most recent snapshot, or `null` if `length === 0`. */\n readonly latest: T | null;\n /** Capture a new snapshot. Overwrites the oldest slot once full. */\n capture(): void;\n /** Return the snapshot from `framesAgo` captures back, or `null`. */\n rewind(framesAgo: number): T | null;\n /** Drop all retained snapshots. */\n reset(): void;\n}\n\nexport function createSnapshotRingBuffer<T>(\n size: number,\n source: SnapshotSource<T>,\n): SnapshotRingBuffer<T> {\n if (size <= 0 || !Number.isFinite(size)) {\n throw new Error(`SnapshotRingBuffer size must be a positive finite number, got ${size}`);\n }\n const capacity = Math.floor(size);\n const slots: (T | null)[] = new Array(capacity).fill(null);\n let head = 0; // next write index\n let count = 0;\n\n return {\n size: capacity,\n get length(): number {\n return count;\n },\n get latest(): T | null {\n if (count === 0) return null;\n const idx = (head - 1 + capacity) % capacity;\n return slots[idx] ?? null;\n },\n capture(): void {\n slots[head] = source();\n head = (head + 1) % capacity;\n if (count < capacity) count++;\n },\n rewind(framesAgo: number): T | null {\n if (framesAgo < 0 || !Number.isFinite(framesAgo)) return null;\n const offset = Math.floor(framesAgo);\n if (offset >= count) return null;\n const idx = (head - 1 - offset + capacity * 2) % capacity;\n return slots[idx] ?? null;\n },\n reset(): void {\n for (let i = 0; i < capacity; i++) slots[i] = null;\n head = 0;\n count = 0;\n },\n };\n}\n","import type { GameLoop } from '@flare-engine/core';\nimport type { SnapshotRingBuffer } from './ring-buffer.js';\n\n/**\n * Restore callback invoked by `TimeScrubber.rewind()` to apply a historical\n * snapshot back to world state. Consumers implement deserialize semantics\n * here — the scrubber itself never touches ECS state.\n */\nexport type RestoreCallback<T> = (snapshot: T) => void;\n\nexport interface TimeScrubberOptions<T> {\n loop: GameLoop;\n buffer: SnapshotRingBuffer<T>;\n /** Optional restore callback. If omitted, `rewind()` is a no-op beyond pausing the loop. */\n restore?: RestoreCallback<T>;\n}\n\n/**\n * TimeScrubber — imperative controller binding a `GameLoop` to a snapshot\n * ring buffer. Exposes pause / step / resume plus `rewind(framesAgo)` which\n * pauses the loop and hands the historical snapshot to the restore callback.\n */\nexport class TimeScrubber<T> {\n private readonly loop: GameLoop;\n private readonly buffer: SnapshotRingBuffer<T>;\n private readonly restore: RestoreCallback<T> | undefined;\n private _stepRequested = false;\n private _scrubFrames = 0;\n /** Timescale captured at `pause()`, restored by `resume()`. Defaults to 1. */\n private _savedTimescale = 1;\n\n constructor(options: TimeScrubberOptions<T>) {\n this.loop = options.loop;\n this.buffer = options.buffer;\n this.restore = options.restore;\n }\n\n /** Whether the loop is currently paused. */\n get paused(): boolean {\n return this.loop.clock.timescale === 0;\n }\n\n /** Whether the scrubber is currently displaying a historical snapshot. */\n get scrubbing(): boolean {\n return this._scrubFrames > 0;\n }\n\n /** Current scrub offset (0 = latest, N = N frames back). */\n get scrubOffset(): number {\n return this._scrubFrames;\n }\n\n /** Pause the loop (timescale → 0), remembering the running speed.\n * The `!== 0` guard means a double pause (e.g. `rewind()` calls `pause()`\n * while already paused) keeps the first saved value instead of storing 0. */\n pause(): void {\n if (this.loop.clock.timescale !== 0) {\n this._savedTimescale = this.loop.clock.timescale;\n }\n this.loop.clock.timescale = 0;\n }\n\n /** Resume the loop at its pre-pause speed and clear any scrub state.\n * Restores the timescale captured at `pause()` (defaults to 1 if never\n * paused), so resuming an active slow-mo returns to that rate, not 1×. */\n resume(): void {\n this.loop.clock.timescale = this._savedTimescale;\n this._scrubFrames = 0;\n this._stepRequested = false;\n }\n\n /** Request a single-frame step. Caller polls `consumeStep()` each frame. */\n step(): void {\n this._stepRequested = true;\n }\n\n /** Ring-buffer depth available for rewind. */\n get available(): number {\n return this.buffer.length;\n }\n\n /**\n * Pause the loop and restore the snapshot from `framesAgo` captures back.\n * Clamps to available history. Returns the snapshot applied, or `null`\n * when the buffer is empty.\n */\n rewind(framesAgo: number): T | null {\n if (framesAgo < 0 || !Number.isFinite(framesAgo)) return null;\n const max = this.buffer.length - 1;\n if (max < 0) return null;\n const offset = Math.min(Math.floor(framesAgo), max);\n const snap = this.buffer.rewind(offset);\n if (snap === null) return null;\n this.pause();\n this._scrubFrames = offset;\n if (this.restore) this.restore(snap);\n return snap;\n }\n\n /**\n * Returns true once per `step()` call, then resets. Frame-driver code is\n * expected to advance the simulation by one fixed tick when this is true.\n */\n consumeStep(): boolean {\n if (!this._stepRequested) return false;\n this._stepRequested = false;\n return true;\n }\n}\n","import type { GameLoop } from '@flare-engine/core';\nimport type { World } from '@flare-engine/ecs';\nimport { type ReactNode, useEffect, useMemo, useRef, useState } from 'react';\nimport { type DevtoolsConfig, DevtoolsContext, type DevtoolsContextValue } from './context.js';\nimport { createSnapshotRingBuffer, type SnapshotSource } from './ring-buffer.js';\nimport { type RestoreCallback, TimeScrubber } from './time-scrubber.js';\n\nexport interface DevtoolsProviderProps<T = unknown> {\n world: World;\n loop: GameLoop;\n /** Snapshot producer. Called on every capture tick. Must be cheap. */\n snapshot: SnapshotSource<T>;\n /** Optional restore callback for `TimeScrubber.rewind()`. */\n restore?: RestoreCallback<T>;\n config?: DevtoolsConfig;\n children?: ReactNode;\n}\n\nconst DEFAULT_CONFIG: Required<DevtoolsConfig> = {\n ringSize: 120,\n captureInterval: 1,\n enabledOnNative: true,\n};\n\n/**\n * DevtoolsProvider — mounts a devtools session for a given `World` + `GameLoop`.\n * Subscribes to `loop.onUpdate` and captures snapshots into a pre-allocated\n * ring buffer; exposes scrubber controls via `DevtoolsContext`.\n */\nexport function DevtoolsProvider<T>({\n world,\n loop,\n snapshot,\n restore,\n config,\n children,\n}: DevtoolsProviderProps<T>): ReactNode {\n const ringSize = config?.ringSize ?? DEFAULT_CONFIG.ringSize;\n const captureInterval = config?.captureInterval ?? DEFAULT_CONFIG.captureInterval;\n const [selectedEntity, select] = useState<number | null>(null);\n\n // Capture snapshot + restore in refs so the buffer/scrubber identity is\n // stable across renders — the live callbacks are read each tick.\n const snapshotRef = useRef(snapshot);\n snapshotRef.current = snapshot;\n const restoreRef = useRef(restore);\n restoreRef.current = restore;\n\n const { buffer, scrubber } = useMemo(() => {\n const buf = createSnapshotRingBuffer<T>(ringSize, () => snapshotRef.current());\n const scrub = new TimeScrubber<T>({\n loop,\n buffer: buf,\n restore: (s: T) => restoreRef.current?.(s),\n });\n return { buffer: buf, scrubber: scrub };\n }, [loop, ringSize]);\n\n useEffect(() => {\n let ticks = 0;\n const unsub = loop.onUpdate.add(() => {\n ticks++;\n if (ticks % captureInterval === 0) buffer.capture();\n });\n return () => {\n unsub();\n };\n }, [loop, buffer, captureInterval]);\n\n const value: DevtoolsContextValue = {\n world,\n loop,\n buffer: buffer as SnapshotRingBufferUnknown,\n scrubber: scrubber as TimeScrubberUnknown,\n selectedEntity,\n select,\n };\n\n return <DevtoolsContext.Provider value={value}>{children}</DevtoolsContext.Provider>;\n}\n\n// Narrow aliases so the context value type stays concrete without exposing the\n// provider's generic parameter in every downstream import.\ntype SnapshotRingBufferUnknown = DevtoolsContextValue['buffer'];\ntype TimeScrubberUnknown = DevtoolsContextValue['scrubber'];\n"],"mappings":";;;;;AA0BA,MAAa,mBAAA,GAAA,MAAA,cAAA,CAA6D,IAAI;;;ACxB9E,SAAgB,YAAqB;CACnC,OAAO,OAAO,YAAY,eAAe,QAAQ,OAAO;AAC1D;;;;ACAA,SAAgB,cAAoC;CAClD,MAAM,OAAA,GAAA,MAAA,WAAA,CAAiB,eAAe;CACtC,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,sDAAsD;CAExE,OAAO;AACT;;AAUA,SAAgB,qBAA0C;CACxD,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C,CACoC;EAAE;CACxC,GAAG,CAAC,MAAM,QAAQ,CAAC;CAEnB,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,QAAQ;EACZ,MAAM,QAAQ,KAAK,SAAS,UAAU;GACpC;GACA,IAAI,QAAQ,oBAAoB,GAAG,OAAO,QAAQ;EACpD,CAAC;EACD,aAAa;GACX,MAAM;EACR;CACF,GAAG;EAAC;EAAM;EAAQ;CAAe,CAAC;CAElC,MAAM,QAA8B;EAClC;EACA;EACQ;EACE;EACV;EACA;CACF;CAEA,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAgB,UAAjB;EAAiC;EAAQ;CAAmC,CAAA;AACrF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["createContext","useContext","Platform","View","Text","Pressable","Platform","View","Text","Pressable","useState","useRef","useMemo"],"sources":["../src/context.ts","../src/dev-mode.ts","../src/hooks.ts","../src/hud.tsx","../src/panel.tsx","../src/ring-buffer.ts","../src/time-scrubber.ts","../src/provider.tsx"],"sourcesContent":["import type { GameLoop } from '@flare-engine/core';\nimport type { World } from '@flare-engine/ecs';\nimport { createContext } from 'react';\nimport type { SnapshotRingBuffer } from './ring-buffer.js';\nimport type { TimeScrubber } from './time-scrubber.js';\n\n/** Devtools configuration. */\nexport interface DevtoolsConfig {\n /** Ring-buffer depth in frames. Default 120 (~2 s @ 60 fps). */\n ringSize?: number;\n /** Capture every Nth `onUpdate`. Default 1 (every frame). */\n captureInterval?: number;\n /** Enable the native HUD surface. Default true. */\n enabledOnNative?: boolean;\n}\n\n/** Value exposed via `DevtoolsContext`. */\nexport interface DevtoolsContextValue {\n world: World;\n loop: GameLoop;\n buffer: SnapshotRingBuffer<unknown>;\n scrubber: TimeScrubber<unknown>;\n selectedEntity: number | null;\n select(entity: number | null): void;\n}\n\nexport const DevtoolsContext = createContext<DevtoolsContextValue | null>(null);\n","declare const __DEV__: boolean | undefined;\n\nexport function isDevMode(): boolean {\n return typeof __DEV__ !== 'undefined' && Boolean(__DEV__);\n}\n","import { useContext } from 'react';\nimport { DevtoolsContext, type DevtoolsContextValue } from './context.js';\n\n/** Returns the active devtools context, or throws if no provider is mounted. */\nexport function useDevtools(): DevtoolsContextValue {\n const ctx = useContext(DevtoolsContext);\n if (!ctx) {\n throw new Error('useDevtools must be used inside a <DevtoolsProvider>');\n }\n return ctx;\n}\n\nexport interface EntityInspectorView {\n selected: number | null;\n select(entity: number | null): void;\n /** Entity IDs present in the world at the moment the hook was read. */\n entities: readonly number[];\n}\n\n/** Entity-inspector hook. Never mutates the world — read-only snapshot. */\nexport function useEntityInspector(): EntityInspectorView {\n const { world, selectedEntity, select } = useDevtools();\n const entities: number[] = [];\n world.forEachEntity((id) => entities.push(id));\n return { selected: selectedEntity, select, entities };\n}\n\nexport interface TimeScrubView {\n paused: boolean;\n scrubbing: boolean;\n available: number;\n pause(): void;\n resume(): void;\n step(): void;\n rewind(framesAgo: number): void;\n}\n\n/** Time-scrub hook — exposes the scrubber's imperative controls. */\nexport function useTimeScrub(): TimeScrubView {\n const { scrubber } = useDevtools();\n return {\n paused: scrubber.paused,\n scrubbing: scrubber.scrubbing,\n available: scrubber.available,\n pause: () => scrubber.pause(),\n resume: () => scrubber.resume(),\n step: () => scrubber.step(),\n rewind: (framesAgo: number) => {\n scrubber.rewind(framesAgo);\n },\n };\n}\n","import type { ReactNode } from 'react';\nimport { Platform, Pressable, Text, View } from 'react-native';\nimport { useDevtools, useTimeScrub } from './hooks.js';\n\n/**\n * DevtoolsHUD — compact native overlay. Shows buffer depth + pause/step/resume\n * buttons. No-op on web (renders `null`).\n */\nexport function DevtoolsHUD(): ReactNode {\n if (Platform.OS === 'web') return null;\n return <HUDBody />;\n}\n\nfunction HUDBody(): ReactNode {\n const { buffer } = useDevtools();\n const scrub = useTimeScrub();\n\n return (\n <View\n style={{\n position: 'absolute',\n bottom: 16,\n right: 16,\n flexDirection: 'row',\n alignItems: 'center',\n padding: 6,\n backgroundColor: 'rgba(0,0,0,0.75)',\n borderRadius: 4,\n }}\n >\n <Text style={{ color: '#fff', marginRight: 8 }}>\n {buffer.length}/{buffer.size}\n </Text>\n <HudButton label=\"||\" onPress={scrub.pause} />\n <HudButton label=\">|\" onPress={scrub.step} />\n <HudButton label=\">\" onPress={scrub.resume} />\n </View>\n );\n}\n\nfunction HudButton({ label, onPress }: { label: string; onPress: () => void }): ReactNode {\n return (\n <Pressable\n onPress={onPress}\n style={{\n paddingHorizontal: 6,\n paddingVertical: 2,\n marginLeft: 4,\n backgroundColor: '#444',\n borderRadius: 2,\n }}\n >\n <Text style={{ color: '#fff' }}>{label}</Text>\n </Pressable>\n );\n}\n","import type { ReactNode } from 'react';\nimport { Platform, Pressable, Text, View } from 'react-native';\nimport { useDevtools, useEntityInspector, useTimeScrub } from './hooks.js';\n\n/**\n * DevtoolsPanel — full web-side panel. Renders the entity tree, scrub\n * controls, and buffer depth. No-op on native (renders `null`).\n */\nexport function DevtoolsPanel(): ReactNode {\n if (Platform.OS !== 'web') return null;\n return <PanelBody />;\n}\n\nfunction PanelBody(): ReactNode {\n const { buffer } = useDevtools();\n const { entities, selected, select } = useEntityInspector();\n const scrub = useTimeScrub();\n\n return (\n <View\n style={{\n position: 'absolute',\n top: 8,\n right: 8,\n padding: 8,\n backgroundColor: 'rgba(0,0,0,0.75)',\n borderRadius: 4,\n minWidth: 200,\n }}\n >\n <Text style={{ color: '#fff', fontWeight: 'bold' }}>Devtools</Text>\n <Text style={{ color: '#ccc' }}>\n buffer {buffer.length}/{buffer.size}\n </Text>\n <Text style={{ color: '#ccc' }}>\n {scrub.paused ? 'paused' : 'running'}\n {scrub.scrubbing ? ' (scrub)' : ''}\n </Text>\n <View style={{ flexDirection: 'row', marginTop: 4 }}>\n <DevButton label=\"Pause\" onPress={scrub.pause} />\n <DevButton label=\"Step\" onPress={scrub.step} />\n <DevButton label=\"Resume\" onPress={scrub.resume} />\n </View>\n <View style={{ marginTop: 8 }}>\n <Text style={{ color: '#fff' }}>entities ({entities.length})</Text>\n {entities.slice(0, 20).map((id) => (\n <Pressable key={id} onPress={() => select(id)}>\n <Text style={{ color: id === selected ? '#ff0' : '#fff' }}>#{id}</Text>\n </Pressable>\n ))}\n </View>\n </View>\n );\n}\n\nfunction DevButton({ label, onPress }: { label: string; onPress: () => void }): ReactNode {\n return (\n <Pressable\n onPress={onPress}\n style={{\n paddingHorizontal: 6,\n paddingVertical: 2,\n marginRight: 4,\n backgroundColor: '#444',\n borderRadius: 2,\n }}\n >\n <Text style={{ color: '#fff' }}>{label}</Text>\n </Pressable>\n );\n}\n","/**\n * Source callback used by `createSnapshotRingBuffer` to produce a snapshot\n * each capture tick. The ring buffer never introspects the snapshot — it is\n * an opaque `T` to this package. A future `World.serialize()` can be passed\n * in directly by consumers.\n */\nexport type SnapshotSource<T> = () => T;\n\n/**\n * Pre-allocated snapshot ring buffer. Slots are allocated once at\n * construction and the `write` cursor walks in place — zero per-frame\n * allocation. `rewind(framesAgo)` returns the snapshot that was `framesAgo`\n * captures back (0 = latest), or `null` if the requested offset exceeds the\n * number of snapshots currently held.\n */\nexport interface SnapshotRingBuffer<T> {\n /** Maximum number of snapshots retained. */\n readonly size: number;\n /** Number of snapshots currently held (0…size). */\n readonly length: number;\n /** Most recent snapshot, or `null` if `length === 0`. */\n readonly latest: T | null;\n /** Capture a new snapshot. Overwrites the oldest slot once full. */\n capture(): void;\n /** Return the snapshot from `framesAgo` captures back, or `null`. */\n rewind(framesAgo: number): T | null;\n /** Drop all retained snapshots. */\n reset(): void;\n}\n\nexport function createSnapshotRingBuffer<T>(\n size: number,\n source: SnapshotSource<T>,\n): SnapshotRingBuffer<T> {\n if (size <= 0 || !Number.isFinite(size)) {\n throw new Error(`SnapshotRingBuffer size must be a positive finite number, got ${size}`);\n }\n const capacity = Math.floor(size);\n const slots: (T | null)[] = new Array(capacity).fill(null);\n let head = 0; // next write index\n let count = 0;\n\n return {\n size: capacity,\n get length(): number {\n return count;\n },\n get latest(): T | null {\n if (count === 0) return null;\n const idx = (head - 1 + capacity) % capacity;\n return slots[idx] ?? null;\n },\n capture(): void {\n slots[head] = source();\n head = (head + 1) % capacity;\n if (count < capacity) count++;\n },\n rewind(framesAgo: number): T | null {\n if (framesAgo < 0 || !Number.isFinite(framesAgo)) return null;\n const offset = Math.floor(framesAgo);\n if (offset >= count) return null;\n const idx = (head - 1 - offset + capacity * 2) % capacity;\n return slots[idx] ?? null;\n },\n reset(): void {\n for (let i = 0; i < capacity; i++) slots[i] = null;\n head = 0;\n count = 0;\n },\n };\n}\n","import type { GameLoop } from '@flare-engine/core';\nimport type { SnapshotRingBuffer } from './ring-buffer.js';\n\n/**\n * Restore callback invoked by `TimeScrubber.rewind()` to apply a historical\n * snapshot back to world state. Consumers implement deserialize semantics\n * here — the scrubber itself never touches ECS state.\n */\nexport type RestoreCallback<T> = (snapshot: T) => void;\n\nexport interface TimeScrubberOptions<T> {\n loop: GameLoop;\n buffer: SnapshotRingBuffer<T>;\n /** Optional restore callback. If omitted, `rewind()` is a no-op beyond pausing the loop. */\n restore?: RestoreCallback<T>;\n}\n\n/**\n * TimeScrubber — imperative controller binding a `GameLoop` to a snapshot\n * ring buffer. Exposes pause / step / resume plus `rewind(framesAgo)` which\n * pauses the loop and hands the historical snapshot to the restore callback.\n */\nexport class TimeScrubber<T> {\n private readonly loop: GameLoop;\n private readonly buffer: SnapshotRingBuffer<T>;\n private readonly restore: RestoreCallback<T> | undefined;\n private _stepRequested = false;\n private _scrubFrames = 0;\n /** Timescale captured at `pause()`, restored by `resume()`. Defaults to 1. */\n private _savedTimescale = 1;\n\n constructor(options: TimeScrubberOptions<T>) {\n this.loop = options.loop;\n this.buffer = options.buffer;\n this.restore = options.restore;\n }\n\n /** Whether the loop is currently paused. */\n get paused(): boolean {\n return this.loop.clock.timescale === 0;\n }\n\n /** Whether the scrubber is currently displaying a historical snapshot. */\n get scrubbing(): boolean {\n return this._scrubFrames > 0;\n }\n\n /** Current scrub offset (0 = latest, N = N frames back). */\n get scrubOffset(): number {\n return this._scrubFrames;\n }\n\n /** Pause the loop (timescale → 0), remembering the running speed.\n * The `!== 0` guard means a double pause (e.g. `rewind()` calls `pause()`\n * while already paused) keeps the first saved value instead of storing 0. */\n pause(): void {\n if (this.loop.clock.timescale !== 0) {\n this._savedTimescale = this.loop.clock.timescale;\n }\n this.loop.clock.timescale = 0;\n }\n\n /** Resume the loop at its pre-pause speed and clear any scrub state.\n * Restores the timescale captured at `pause()` (defaults to 1 if never\n * paused), so resuming an active slow-mo returns to that rate, not 1×. */\n resume(): void {\n this.loop.clock.timescale = this._savedTimescale;\n this._scrubFrames = 0;\n this._stepRequested = false;\n }\n\n /** Request a single-frame step. Caller polls `consumeStep()` each frame. */\n step(): void {\n this._stepRequested = true;\n }\n\n /** Ring-buffer depth available for rewind. */\n get available(): number {\n return this.buffer.length;\n }\n\n /**\n * Pause the loop and restore the snapshot from `framesAgo` captures back.\n * Clamps to available history. Returns the snapshot applied, or `null`\n * when the buffer is empty.\n */\n rewind(framesAgo: number): T | null {\n if (framesAgo < 0 || !Number.isFinite(framesAgo)) return null;\n const max = this.buffer.length - 1;\n if (max < 0) return null;\n const offset = Math.min(Math.floor(framesAgo), max);\n const snap = this.buffer.rewind(offset);\n if (snap === null) return null;\n this.pause();\n this._scrubFrames = offset;\n if (this.restore) this.restore(snap);\n return snap;\n }\n\n /**\n * Returns true once per `step()` call, then resets. Frame-driver code is\n * expected to advance the simulation by one fixed tick when this is true.\n */\n consumeStep(): boolean {\n if (!this._stepRequested) return false;\n this._stepRequested = false;\n return true;\n }\n}\n","import type { GameLoop } from '@flare-engine/core';\nimport type { World } from '@flare-engine/ecs';\nimport { type ReactNode, useEffect, useMemo, useRef, useState } from 'react';\nimport { type DevtoolsConfig, DevtoolsContext, type DevtoolsContextValue } from './context.js';\nimport { createSnapshotRingBuffer, type SnapshotSource } from './ring-buffer.js';\nimport { type RestoreCallback, TimeScrubber } from './time-scrubber.js';\n\nexport interface DevtoolsProviderProps<T = unknown> {\n world: World;\n loop: GameLoop;\n /** Snapshot producer. Called on every capture tick. Must be cheap. */\n snapshot: SnapshotSource<T>;\n /** Optional restore callback for `TimeScrubber.rewind()`. */\n restore?: RestoreCallback<T>;\n config?: DevtoolsConfig;\n children?: ReactNode;\n}\n\nconst DEFAULT_CONFIG: Required<DevtoolsConfig> = {\n ringSize: 120,\n captureInterval: 1,\n enabledOnNative: true,\n};\n\n/**\n * DevtoolsProvider — mounts a devtools session for a given `World` + `GameLoop`.\n * Subscribes to `loop.onUpdate` and captures snapshots into a pre-allocated\n * ring buffer; exposes scrubber controls via `DevtoolsContext`.\n */\nexport function DevtoolsProvider<T>({\n world,\n loop,\n snapshot,\n restore,\n config,\n children,\n}: DevtoolsProviderProps<T>): ReactNode {\n const ringSize = config?.ringSize ?? DEFAULT_CONFIG.ringSize;\n const captureInterval = config?.captureInterval ?? DEFAULT_CONFIG.captureInterval;\n const [selectedEntity, select] = useState<number | null>(null);\n\n // Capture snapshot + restore in refs so the buffer/scrubber identity is\n // stable across renders — the live callbacks are read each tick.\n const snapshotRef = useRef(snapshot);\n snapshotRef.current = snapshot;\n const restoreRef = useRef(restore);\n restoreRef.current = restore;\n\n const { buffer, scrubber } = useMemo(() => {\n const buf = createSnapshotRingBuffer<T>(ringSize, () => snapshotRef.current());\n const scrub = new TimeScrubber<T>({\n loop,\n buffer: buf,\n restore: (s: T) => restoreRef.current?.(s),\n });\n return { buffer: buf, scrubber: scrub };\n }, [loop, ringSize]);\n\n useEffect(() => {\n let ticks = 0;\n const unsub = loop.onUpdate.add(() => {\n ticks++;\n if (ticks % captureInterval === 0) buffer.capture();\n });\n return () => {\n unsub();\n };\n }, [loop, buffer, captureInterval]);\n\n const value: DevtoolsContextValue = {\n world,\n loop,\n buffer: buffer as SnapshotRingBufferUnknown,\n scrubber: scrubber as TimeScrubberUnknown,\n selectedEntity,\n select,\n };\n\n return <DevtoolsContext.Provider value={value}>{children}</DevtoolsContext.Provider>;\n}\n\n// Narrow aliases so the context value type stays concrete without exposing the\n// provider's generic parameter in every downstream import.\ntype SnapshotRingBufferUnknown = DevtoolsContextValue['buffer'];\ntype TimeScrubberUnknown = DevtoolsContextValue['scrubber'];\n"],"mappings":";;;;;AA0BA,MAAa,mBAAA,GAAkBA,MAAAA,cAAAA,CAA2C,IAAI;;ACxB9E,SAAgB,YAAqB;CACnC,OAAO,OAAO,YAAY,eAAe,QAAQ,OAAO;AAC1D;;;ACAA,SAAgB,cAAoC;CAClD,MAAM,OAAA,GAAMC,MAAAA,WAAAA,CAAW,eAAe;CACtC,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,sDAAsD;CAExE,OAAO;AACT;;AAUA,SAAgB,qBAA0C;CACxD,MAAM,EAAE,OAAO,gBAAgB,WAAW,YAAY;CACtD,MAAM,WAAqB,CAAC;CAC5B,MAAM,eAAe,OAAO,SAAS,KAAK,EAAE,CAAC;CAC7C,OAAO;EAAE,UAAU;EAAgB;EAAQ;CAAS;AACtD;;AAaA,SAAgB,eAA8B;CAC5C,MAAM,EAAE,aAAa,YAAY;CACjC,OAAO;EACL,QAAQ,SAAS;EACjB,WAAW,SAAS;EACpB,WAAW,SAAS;EACpB,aAAa,SAAS,MAAM;EAC5B,cAAc,SAAS,OAAO;EAC9B,YAAY,SAAS,KAAK;EAC1B,SAAS,cAAsB;GAC7B,SAAS,OAAO,SAAS;EAC3B;CACF;AACF;;;;;;AC3CA,SAAgB,cAAyB;CACvC,IAAIC,aAAAA,SAAS,OAAO,OAAO,OAAO;CAClC,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD,CAAU,CAAA;AACnB;AAEA,SAAS,UAAqB;CAC5B,MAAM,EAAE,WAAW,YAAY;CAC/B,MAAM,QAAQ,aAAa;CAE3B,OACE,iBAAA,GAAA,kBAAA,KAAA,CAACC,aAAAA,MAAD;EACE,OAAO;GACL,UAAU;GACV,QAAQ;GACR,OAAO;GACP,eAAe;GACf,YAAY;GACZ,SAAS;GACT,iBAAiB;GACjB,cAAc;EAChB;EAVF,UAAA;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ACA,YACsC;CACtC,MAAM,WAAW,QAAQ,YAAY,eAAe;CACpD,MAAM,kBAAkB,QAAQ,mBAAmB,eAAe;CAClE,MAAM,CAAC,gBAAgB,WAAA,GAAUE,MAAAA,SAAAA,CAAwB,IAAI;CAI7D,MAAM,eAAA,GAAcC,MAAAA,OAAAA,CAAO,QAAQ;CACnC,YAAY,UAAU;CACtB,MAAM,cAAA,GAAaA,MAAAA,OAAAA,CAAO,OAAO;CACjC,WAAW,UAAU;CAErB,MAAM,EAAE,QAAQ,cAAA,GAAaC,MAAAA,QAAAA,OAAc;EACzC,MAAM,MAAM,yBAA4B,gBAAgB,YAAY,QAAQ,CAAC;EAM7E,OAAO;GAAE,QAAQ;GAAK,UAAU,IALd,aAAgB;IAChC;IACA,QAAQ;IACR,UAAU,MAAS,WAAW,UAAU,CAAC;GAC3C,CACoC;EAAE;CACxC,GAAG,CAAC,MAAM,QAAQ,CAAC;CAEnB,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,QAAQ;EACZ,MAAM,QAAQ,KAAK,SAAS,UAAU;GACpC;GACA,IAAI,QAAQ,oBAAoB,GAAG,OAAO,QAAQ;EACpD,CAAC;EACD,aAAa;GACX,MAAM;EACR;CACF,GAAG;EAAC;EAAM;EAAQ;CAAe,CAAC;CAElC,MAAM,QAA8B;EAClC;EACA;EACQ;EACE;EACV;EACA;CACF;CAEA,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAgB,UAAjB;EAAiC;EAAQ;CAAmC,CAAA;AACrF"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { Platform, Pressable, Text, View } from "react-native";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/context.ts
|
|
5
5
|
const DevtoolsContext = createContext(null);
|
|
6
|
-
|
|
7
|
-
//#region src/dev-mode.ts
|
|
6
|
+
// src/dev-mode.ts
|
|
8
7
|
function isDevMode() {
|
|
9
8
|
return typeof __DEV__ !== "undefined" && Boolean(__DEV__);
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
//#region src/hooks.ts
|
|
10
|
+
// src/hooks.ts
|
|
13
11
|
/** Returns the active devtools context, or throws if no provider is mounted. */
|
|
14
12
|
function useDevtools() {
|
|
15
13
|
const ctx = useContext(DevtoolsContext);
|
|
@@ -42,8 +40,7 @@ function useTimeScrub() {
|
|
|
42
40
|
}
|
|
43
41
|
};
|
|
44
42
|
}
|
|
45
|
-
|
|
46
|
-
//#region src/hud.tsx
|
|
43
|
+
// src/hud.tsx
|
|
47
44
|
/**
|
|
48
45
|
* DevtoolsHUD — compact native overlay. Shows buffer depth + pause/step/resume
|
|
49
46
|
* buttons. No-op on web (renders `null`).
|
|
@@ -109,8 +106,7 @@ function HudButton({ label, onPress }) {
|
|
|
109
106
|
})
|
|
110
107
|
});
|
|
111
108
|
}
|
|
112
|
-
|
|
113
|
-
//#region src/panel.tsx
|
|
109
|
+
// src/panel.tsx
|
|
114
110
|
/**
|
|
115
111
|
* DevtoolsPanel — full web-side panel. Renders the entity tree, scrub
|
|
116
112
|
* controls, and buffer depth. No-op on native (renders `null`).
|
|
@@ -210,8 +206,7 @@ function DevButton({ label, onPress }) {
|
|
|
210
206
|
})
|
|
211
207
|
});
|
|
212
208
|
}
|
|
213
|
-
|
|
214
|
-
//#region src/ring-buffer.ts
|
|
209
|
+
// src/ring-buffer.ts
|
|
215
210
|
function createSnapshotRingBuffer(size, source) {
|
|
216
211
|
if (size <= 0 || !Number.isFinite(size)) throw new Error(`SnapshotRingBuffer size must be a positive finite number, got ${size}`);
|
|
217
212
|
const capacity = Math.floor(size);
|
|
@@ -247,8 +242,7 @@ function createSnapshotRingBuffer(size, source) {
|
|
|
247
242
|
}
|
|
248
243
|
};
|
|
249
244
|
}
|
|
250
|
-
|
|
251
|
-
//#region src/time-scrubber.ts
|
|
245
|
+
// src/time-scrubber.ts
|
|
252
246
|
/**
|
|
253
247
|
* TimeScrubber — imperative controller binding a `GameLoop` to a snapshot
|
|
254
248
|
* ring buffer. Exposes pause / step / resume plus `rewind(framesAgo)` which
|
|
@@ -329,8 +323,7 @@ var TimeScrubber = class {
|
|
|
329
323
|
return true;
|
|
330
324
|
}
|
|
331
325
|
};
|
|
332
|
-
|
|
333
|
-
//#region src/provider.tsx
|
|
326
|
+
// src/provider.tsx
|
|
334
327
|
const DEFAULT_CONFIG = {
|
|
335
328
|
ringSize: 120,
|
|
336
329
|
captureInterval: 1,
|
|
@@ -387,7 +380,6 @@ function DevtoolsProvider({ world, loop, snapshot, restore, config, children })
|
|
|
387
380
|
children
|
|
388
381
|
});
|
|
389
382
|
}
|
|
390
|
-
//#endregion
|
|
391
383
|
export { DevtoolsContext, DevtoolsHUD, DevtoolsPanel, DevtoolsProvider, TimeScrubber, createSnapshotRingBuffer, isDevMode, useDevtools, useEntityInspector, useTimeScrub };
|
|
392
384
|
|
|
393
385
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/context.ts","../src/dev-mode.ts","../src/hooks.ts","../src/hud.tsx","../src/panel.tsx","../src/ring-buffer.ts","../src/time-scrubber.ts","../src/provider.tsx"],"sourcesContent":["import type { GameLoop } from '@flare-engine/core';\nimport type { World } from '@flare-engine/ecs';\nimport { createContext } from 'react';\nimport type { SnapshotRingBuffer } from './ring-buffer.js';\nimport type { TimeScrubber } from './time-scrubber.js';\n\n/** Devtools configuration. */\nexport interface DevtoolsConfig {\n /** Ring-buffer depth in frames. Default 120 (~2 s @ 60 fps). */\n ringSize?: number;\n /** Capture every Nth `onUpdate`. Default 1 (every frame). */\n captureInterval?: number;\n /** Enable the native HUD surface. Default true. */\n enabledOnNative?: boolean;\n}\n\n/** Value exposed via `DevtoolsContext`. */\nexport interface DevtoolsContextValue {\n world: World;\n loop: GameLoop;\n buffer: SnapshotRingBuffer<unknown>;\n scrubber: TimeScrubber<unknown>;\n selectedEntity: number | null;\n select(entity: number | null): void;\n}\n\nexport const DevtoolsContext = createContext<DevtoolsContextValue | null>(null);\n","declare const __DEV__: boolean | undefined;\n\nexport function isDevMode(): boolean {\n return typeof __DEV__ !== 'undefined' && Boolean(__DEV__);\n}\n","import { useContext } from 'react';\nimport { DevtoolsContext, type DevtoolsContextValue } from './context.js';\n\n/** Returns the active devtools context, or throws if no provider is mounted. */\nexport function useDevtools(): DevtoolsContextValue {\n const ctx = useContext(DevtoolsContext);\n if (!ctx) {\n throw new Error('useDevtools must be used inside a <DevtoolsProvider>');\n }\n return ctx;\n}\n\nexport interface EntityInspectorView {\n selected: number | null;\n select(entity: number | null): void;\n /** Entity IDs present in the world at the moment the hook was read. */\n entities: readonly number[];\n}\n\n/** Entity-inspector hook. Never mutates the world — read-only snapshot. */\nexport function useEntityInspector(): EntityInspectorView {\n const { world, selectedEntity, select } = useDevtools();\n const entities: number[] = [];\n world.forEachEntity((id) => entities.push(id));\n return { selected: selectedEntity, select, entities };\n}\n\nexport interface TimeScrubView {\n paused: boolean;\n scrubbing: boolean;\n available: number;\n pause(): void;\n resume(): void;\n step(): void;\n rewind(framesAgo: number): void;\n}\n\n/** Time-scrub hook — exposes the scrubber's imperative controls. */\nexport function useTimeScrub(): TimeScrubView {\n const { scrubber } = useDevtools();\n return {\n paused: scrubber.paused,\n scrubbing: scrubber.scrubbing,\n available: scrubber.available,\n pause: () => scrubber.pause(),\n resume: () => scrubber.resume(),\n step: () => scrubber.step(),\n rewind: (framesAgo: number) => {\n scrubber.rewind(framesAgo);\n },\n };\n}\n","import type { ReactNode } from 'react';\nimport { Platform, Pressable, Text, View } from 'react-native';\nimport { useDevtools, useTimeScrub } from './hooks.js';\n\n/**\n * DevtoolsHUD — compact native overlay. Shows buffer depth + pause/step/resume\n * buttons. No-op on web (renders `null`).\n */\nexport function DevtoolsHUD(): ReactNode {\n if (Platform.OS === 'web') return null;\n return <HUDBody />;\n}\n\nfunction HUDBody(): ReactNode {\n const { buffer } = useDevtools();\n const scrub = useTimeScrub();\n\n return (\n <View\n style={{\n position: 'absolute',\n bottom: 16,\n right: 16,\n flexDirection: 'row',\n alignItems: 'center',\n padding: 6,\n backgroundColor: 'rgba(0,0,0,0.75)',\n borderRadius: 4,\n }}\n >\n <Text style={{ color: '#fff', marginRight: 8 }}>\n {buffer.length}/{buffer.size}\n </Text>\n <HudButton label=\"||\" onPress={scrub.pause} />\n <HudButton label=\">|\" onPress={scrub.step} />\n <HudButton label=\">\" onPress={scrub.resume} />\n </View>\n );\n}\n\nfunction HudButton({ label, onPress }: { label: string; onPress: () => void }): ReactNode {\n return (\n <Pressable\n onPress={onPress}\n style={{\n paddingHorizontal: 6,\n paddingVertical: 2,\n marginLeft: 4,\n backgroundColor: '#444',\n borderRadius: 2,\n }}\n >\n <Text style={{ color: '#fff' }}>{label}</Text>\n </Pressable>\n );\n}\n","import type { ReactNode } from 'react';\nimport { Platform, Pressable, Text, View } from 'react-native';\nimport { useDevtools, useEntityInspector, useTimeScrub } from './hooks.js';\n\n/**\n * DevtoolsPanel — full web-side panel. Renders the entity tree, scrub\n * controls, and buffer depth. No-op on native (renders `null`).\n */\nexport function DevtoolsPanel(): ReactNode {\n if (Platform.OS !== 'web') return null;\n return <PanelBody />;\n}\n\nfunction PanelBody(): ReactNode {\n const { buffer } = useDevtools();\n const { entities, selected, select } = useEntityInspector();\n const scrub = useTimeScrub();\n\n return (\n <View\n style={{\n position: 'absolute',\n top: 8,\n right: 8,\n padding: 8,\n backgroundColor: 'rgba(0,0,0,0.75)',\n borderRadius: 4,\n minWidth: 200,\n }}\n >\n <Text style={{ color: '#fff', fontWeight: 'bold' }}>Devtools</Text>\n <Text style={{ color: '#ccc' }}>\n buffer {buffer.length}/{buffer.size}\n </Text>\n <Text style={{ color: '#ccc' }}>\n {scrub.paused ? 'paused' : 'running'}\n {scrub.scrubbing ? ' (scrub)' : ''}\n </Text>\n <View style={{ flexDirection: 'row', marginTop: 4 }}>\n <DevButton label=\"Pause\" onPress={scrub.pause} />\n <DevButton label=\"Step\" onPress={scrub.step} />\n <DevButton label=\"Resume\" onPress={scrub.resume} />\n </View>\n <View style={{ marginTop: 8 }}>\n <Text style={{ color: '#fff' }}>entities ({entities.length})</Text>\n {entities.slice(0, 20).map((id) => (\n <Pressable key={id} onPress={() => select(id)}>\n <Text style={{ color: id === selected ? '#ff0' : '#fff' }}>#{id}</Text>\n </Pressable>\n ))}\n </View>\n </View>\n );\n}\n\nfunction DevButton({ label, onPress }: { label: string; onPress: () => void }): ReactNode {\n return (\n <Pressable\n onPress={onPress}\n style={{\n paddingHorizontal: 6,\n paddingVertical: 2,\n marginRight: 4,\n backgroundColor: '#444',\n borderRadius: 2,\n }}\n >\n <Text style={{ color: '#fff' }}>{label}</Text>\n </Pressable>\n );\n}\n","/**\n * Source callback used by `createSnapshotRingBuffer` to produce a snapshot\n * each capture tick. The ring buffer never introspects the snapshot — it is\n * an opaque `T` to this package. A future `World.serialize()` can be passed\n * in directly by consumers.\n */\nexport type SnapshotSource<T> = () => T;\n\n/**\n * Pre-allocated snapshot ring buffer. Slots are allocated once at\n * construction and the `write` cursor walks in place — zero per-frame\n * allocation. `rewind(framesAgo)` returns the snapshot that was `framesAgo`\n * captures back (0 = latest), or `null` if the requested offset exceeds the\n * number of snapshots currently held.\n */\nexport interface SnapshotRingBuffer<T> {\n /** Maximum number of snapshots retained. */\n readonly size: number;\n /** Number of snapshots currently held (0…size). */\n readonly length: number;\n /** Most recent snapshot, or `null` if `length === 0`. */\n readonly latest: T | null;\n /** Capture a new snapshot. Overwrites the oldest slot once full. */\n capture(): void;\n /** Return the snapshot from `framesAgo` captures back, or `null`. */\n rewind(framesAgo: number): T | null;\n /** Drop all retained snapshots. */\n reset(): void;\n}\n\nexport function createSnapshotRingBuffer<T>(\n size: number,\n source: SnapshotSource<T>,\n): SnapshotRingBuffer<T> {\n if (size <= 0 || !Number.isFinite(size)) {\n throw new Error(`SnapshotRingBuffer size must be a positive finite number, got ${size}`);\n }\n const capacity = Math.floor(size);\n const slots: (T | null)[] = new Array(capacity).fill(null);\n let head = 0; // next write index\n let count = 0;\n\n return {\n size: capacity,\n get length(): number {\n return count;\n },\n get latest(): T | null {\n if (count === 0) return null;\n const idx = (head - 1 + capacity) % capacity;\n return slots[idx] ?? null;\n },\n capture(): void {\n slots[head] = source();\n head = (head + 1) % capacity;\n if (count < capacity) count++;\n },\n rewind(framesAgo: number): T | null {\n if (framesAgo < 0 || !Number.isFinite(framesAgo)) return null;\n const offset = Math.floor(framesAgo);\n if (offset >= count) return null;\n const idx = (head - 1 - offset + capacity * 2) % capacity;\n return slots[idx] ?? null;\n },\n reset(): void {\n for (let i = 0; i < capacity; i++) slots[i] = null;\n head = 0;\n count = 0;\n },\n };\n}\n","import type { GameLoop } from '@flare-engine/core';\nimport type { SnapshotRingBuffer } from './ring-buffer.js';\n\n/**\n * Restore callback invoked by `TimeScrubber.rewind()` to apply a historical\n * snapshot back to world state. Consumers implement deserialize semantics\n * here — the scrubber itself never touches ECS state.\n */\nexport type RestoreCallback<T> = (snapshot: T) => void;\n\nexport interface TimeScrubberOptions<T> {\n loop: GameLoop;\n buffer: SnapshotRingBuffer<T>;\n /** Optional restore callback. If omitted, `rewind()` is a no-op beyond pausing the loop. */\n restore?: RestoreCallback<T>;\n}\n\n/**\n * TimeScrubber — imperative controller binding a `GameLoop` to a snapshot\n * ring buffer. Exposes pause / step / resume plus `rewind(framesAgo)` which\n * pauses the loop and hands the historical snapshot to the restore callback.\n */\nexport class TimeScrubber<T> {\n private readonly loop: GameLoop;\n private readonly buffer: SnapshotRingBuffer<T>;\n private readonly restore: RestoreCallback<T> | undefined;\n private _stepRequested = false;\n private _scrubFrames = 0;\n /** Timescale captured at `pause()`, restored by `resume()`. Defaults to 1. */\n private _savedTimescale = 1;\n\n constructor(options: TimeScrubberOptions<T>) {\n this.loop = options.loop;\n this.buffer = options.buffer;\n this.restore = options.restore;\n }\n\n /** Whether the loop is currently paused. */\n get paused(): boolean {\n return this.loop.clock.timescale === 0;\n }\n\n /** Whether the scrubber is currently displaying a historical snapshot. */\n get scrubbing(): boolean {\n return this._scrubFrames > 0;\n }\n\n /** Current scrub offset (0 = latest, N = N frames back). */\n get scrubOffset(): number {\n return this._scrubFrames;\n }\n\n /** Pause the loop (timescale → 0), remembering the running speed.\n * The `!== 0` guard means a double pause (e.g. `rewind()` calls `pause()`\n * while already paused) keeps the first saved value instead of storing 0. */\n pause(): void {\n if (this.loop.clock.timescale !== 0) {\n this._savedTimescale = this.loop.clock.timescale;\n }\n this.loop.clock.timescale = 0;\n }\n\n /** Resume the loop at its pre-pause speed and clear any scrub state.\n * Restores the timescale captured at `pause()` (defaults to 1 if never\n * paused), so resuming an active slow-mo returns to that rate, not 1×. */\n resume(): void {\n this.loop.clock.timescale = this._savedTimescale;\n this._scrubFrames = 0;\n this._stepRequested = false;\n }\n\n /** Request a single-frame step. Caller polls `consumeStep()` each frame. */\n step(): void {\n this._stepRequested = true;\n }\n\n /** Ring-buffer depth available for rewind. */\n get available(): number {\n return this.buffer.length;\n }\n\n /**\n * Pause the loop and restore the snapshot from `framesAgo` captures back.\n * Clamps to available history. Returns the snapshot applied, or `null`\n * when the buffer is empty.\n */\n rewind(framesAgo: number): T | null {\n if (framesAgo < 0 || !Number.isFinite(framesAgo)) return null;\n const max = this.buffer.length - 1;\n if (max < 0) return null;\n const offset = Math.min(Math.floor(framesAgo), max);\n const snap = this.buffer.rewind(offset);\n if (snap === null) return null;\n this.pause();\n this._scrubFrames = offset;\n if (this.restore) this.restore(snap);\n return snap;\n }\n\n /**\n * Returns true once per `step()` call, then resets. Frame-driver code is\n * expected to advance the simulation by one fixed tick when this is true.\n */\n consumeStep(): boolean {\n if (!this._stepRequested) return false;\n this._stepRequested = false;\n return true;\n }\n}\n","import type { GameLoop } from '@flare-engine/core';\nimport type { World } from '@flare-engine/ecs';\nimport { type ReactNode, useEffect, useMemo, useRef, useState } from 'react';\nimport { type DevtoolsConfig, DevtoolsContext, type DevtoolsContextValue } from './context.js';\nimport { createSnapshotRingBuffer, type SnapshotSource } from './ring-buffer.js';\nimport { type RestoreCallback, TimeScrubber } from './time-scrubber.js';\n\nexport interface DevtoolsProviderProps<T = unknown> {\n world: World;\n loop: GameLoop;\n /** Snapshot producer. Called on every capture tick. Must be cheap. */\n snapshot: SnapshotSource<T>;\n /** Optional restore callback for `TimeScrubber.rewind()`. */\n restore?: RestoreCallback<T>;\n config?: DevtoolsConfig;\n children?: ReactNode;\n}\n\nconst DEFAULT_CONFIG: Required<DevtoolsConfig> = {\n ringSize: 120,\n captureInterval: 1,\n enabledOnNative: true,\n};\n\n/**\n * DevtoolsProvider — mounts a devtools session for a given `World` + `GameLoop`.\n * Subscribes to `loop.onUpdate` and captures snapshots into a pre-allocated\n * ring buffer; exposes scrubber controls via `DevtoolsContext`.\n */\nexport function DevtoolsProvider<T>({\n world,\n loop,\n snapshot,\n restore,\n config,\n children,\n}: DevtoolsProviderProps<T>): ReactNode {\n const ringSize = config?.ringSize ?? DEFAULT_CONFIG.ringSize;\n const captureInterval = config?.captureInterval ?? DEFAULT_CONFIG.captureInterval;\n const [selectedEntity, select] = useState<number | null>(null);\n\n // Capture snapshot + restore in refs so the buffer/scrubber identity is\n // stable across renders — the live callbacks are read each tick.\n const snapshotRef = useRef(snapshot);\n snapshotRef.current = snapshot;\n const restoreRef = useRef(restore);\n restoreRef.current = restore;\n\n const { buffer, scrubber } = useMemo(() => {\n const buf = createSnapshotRingBuffer<T>(ringSize, () => snapshotRef.current());\n const scrub = new TimeScrubber<T>({\n loop,\n buffer: buf,\n restore: (s: T) => restoreRef.current?.(s),\n });\n return { buffer: buf, scrubber: scrub };\n }, [loop, ringSize]);\n\n useEffect(() => {\n let ticks = 0;\n const unsub = loop.onUpdate.add(() => {\n ticks++;\n if (ticks % captureInterval === 0) buffer.capture();\n });\n return () => {\n unsub();\n };\n }, [loop, buffer, captureInterval]);\n\n const value: DevtoolsContextValue = {\n world,\n loop,\n buffer: buffer as SnapshotRingBufferUnknown,\n scrubber: scrubber as TimeScrubberUnknown,\n selectedEntity,\n select,\n };\n\n return <DevtoolsContext.Provider value={value}>{children}</DevtoolsContext.Provider>;\n}\n\n// Narrow aliases so the context value type stays concrete without exposing the\n// provider's generic parameter in every downstream import.\ntype SnapshotRingBufferUnknown = DevtoolsContextValue['buffer'];\ntype TimeScrubberUnknown = DevtoolsContextValue['scrubber'];\n"],"mappings":";;;;AA0BA,MAAa,kBAAkB,cAA2C,IAAI;;;ACxB9E,SAAgB,YAAqB;CACnC,OAAO,OAAO,YAAY,eAAe,QAAQ,OAAO;AAC1D;;;;ACAA,SAAgB,cAAoC;CAClD,MAAM,MAAM,WAAW,eAAe;CACtC,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,sDAAsD;CAExE,OAAO;AACT;;AAUA,SAAgB,qBAA0C;CACxD,MAAM,EAAE,OAAO,gBAAgB,WAAW,YAAY;CACtD,MAAM,WAAqB,CAAC;CAC5B,MAAM,eAAe,OAAO,SAAS,KAAK,EAAE,CAAC;CAC7C,OAAO;EAAE,UAAU;EAAgB;EAAQ;CAAS;AACtD;;AAaA,SAAgB,eAA8B;CAC5C,MAAM,EAAE,aAAa,YAAY;CACjC,OAAO;EACL,QAAQ,SAAS;EACjB,WAAW,SAAS;EACpB,WAAW,SAAS;EACpB,aAAa,SAAS,MAAM;EAC5B,cAAc,SAAS,OAAO;EAC9B,YAAY,SAAS,KAAK;EAC1B,SAAS,cAAsB;GAC7B,SAAS,OAAO,SAAS;EAC3B;CACF;AACF;;;;;;;AC3CA,SAAgB,cAAyB;CACvC,IAAI,SAAS,OAAO,OAAO,OAAO;CAClC,OAAO,oBAAC,SAAD,CAAU,CAAA;AACnB;AAEA,SAAS,UAAqB;CAC5B,MAAM,EAAE,WAAW,YAAY;CAC/B,MAAM,QAAQ,aAAa;CAE3B,OACE,qBAAC,MAAD;EACE,OAAO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aAAa;GACX,MAAM;EACR;CACF,GAAG;EAAC;EAAM;EAAQ;CAAe,CAAC;CAElC,MAAM,QAA8B;EAClC;EACA;EACQ;EACE;EACV;EACA;CACF;CAEA,OAAO,oBAAC,gBAAgB,UAAjB;EAAiC;EAAQ;CAAmC,CAAA;AACrF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/context.ts","../src/dev-mode.ts","../src/hooks.ts","../src/hud.tsx","../src/panel.tsx","../src/ring-buffer.ts","../src/time-scrubber.ts","../src/provider.tsx"],"sourcesContent":["import type { GameLoop } from '@flare-engine/core';\nimport type { World } from '@flare-engine/ecs';\nimport { createContext } from 'react';\nimport type { SnapshotRingBuffer } from './ring-buffer.js';\nimport type { TimeScrubber } from './time-scrubber.js';\n\n/** Devtools configuration. */\nexport interface DevtoolsConfig {\n /** Ring-buffer depth in frames. Default 120 (~2 s @ 60 fps). */\n ringSize?: number;\n /** Capture every Nth `onUpdate`. Default 1 (every frame). */\n captureInterval?: number;\n /** Enable the native HUD surface. Default true. */\n enabledOnNative?: boolean;\n}\n\n/** Value exposed via `DevtoolsContext`. */\nexport interface DevtoolsContextValue {\n world: World;\n loop: GameLoop;\n buffer: SnapshotRingBuffer<unknown>;\n scrubber: TimeScrubber<unknown>;\n selectedEntity: number | null;\n select(entity: number | null): void;\n}\n\nexport const DevtoolsContext = createContext<DevtoolsContextValue | null>(null);\n","declare const __DEV__: boolean | undefined;\n\nexport function isDevMode(): boolean {\n return typeof __DEV__ !== 'undefined' && Boolean(__DEV__);\n}\n","import { useContext } from 'react';\nimport { DevtoolsContext, type DevtoolsContextValue } from './context.js';\n\n/** Returns the active devtools context, or throws if no provider is mounted. */\nexport function useDevtools(): DevtoolsContextValue {\n const ctx = useContext(DevtoolsContext);\n if (!ctx) {\n throw new Error('useDevtools must be used inside a <DevtoolsProvider>');\n }\n return ctx;\n}\n\nexport interface EntityInspectorView {\n selected: number | null;\n select(entity: number | null): void;\n /** Entity IDs present in the world at the moment the hook was read. */\n entities: readonly number[];\n}\n\n/** Entity-inspector hook. Never mutates the world — read-only snapshot. */\nexport function useEntityInspector(): EntityInspectorView {\n const { world, selectedEntity, select } = useDevtools();\n const entities: number[] = [];\n world.forEachEntity((id) => entities.push(id));\n return { selected: selectedEntity, select, entities };\n}\n\nexport interface TimeScrubView {\n paused: boolean;\n scrubbing: boolean;\n available: number;\n pause(): void;\n resume(): void;\n step(): void;\n rewind(framesAgo: number): void;\n}\n\n/** Time-scrub hook — exposes the scrubber's imperative controls. */\nexport function useTimeScrub(): TimeScrubView {\n const { scrubber } = useDevtools();\n return {\n paused: scrubber.paused,\n scrubbing: scrubber.scrubbing,\n available: scrubber.available,\n pause: () => scrubber.pause(),\n resume: () => scrubber.resume(),\n step: () => scrubber.step(),\n rewind: (framesAgo: number) => {\n scrubber.rewind(framesAgo);\n },\n };\n}\n","import type { ReactNode } from 'react';\nimport { Platform, Pressable, Text, View } from 'react-native';\nimport { useDevtools, useTimeScrub } from './hooks.js';\n\n/**\n * DevtoolsHUD — compact native overlay. Shows buffer depth + pause/step/resume\n * buttons. No-op on web (renders `null`).\n */\nexport function DevtoolsHUD(): ReactNode {\n if (Platform.OS === 'web') return null;\n return <HUDBody />;\n}\n\nfunction HUDBody(): ReactNode {\n const { buffer } = useDevtools();\n const scrub = useTimeScrub();\n\n return (\n <View\n style={{\n position: 'absolute',\n bottom: 16,\n right: 16,\n flexDirection: 'row',\n alignItems: 'center',\n padding: 6,\n backgroundColor: 'rgba(0,0,0,0.75)',\n borderRadius: 4,\n }}\n >\n <Text style={{ color: '#fff', marginRight: 8 }}>\n {buffer.length}/{buffer.size}\n </Text>\n <HudButton label=\"||\" onPress={scrub.pause} />\n <HudButton label=\">|\" onPress={scrub.step} />\n <HudButton label=\">\" onPress={scrub.resume} />\n </View>\n );\n}\n\nfunction HudButton({ label, onPress }: { label: string; onPress: () => void }): ReactNode {\n return (\n <Pressable\n onPress={onPress}\n style={{\n paddingHorizontal: 6,\n paddingVertical: 2,\n marginLeft: 4,\n backgroundColor: '#444',\n borderRadius: 2,\n }}\n >\n <Text style={{ color: '#fff' }}>{label}</Text>\n </Pressable>\n );\n}\n","import type { ReactNode } from 'react';\nimport { Platform, Pressable, Text, View } from 'react-native';\nimport { useDevtools, useEntityInspector, useTimeScrub } from './hooks.js';\n\n/**\n * DevtoolsPanel — full web-side panel. Renders the entity tree, scrub\n * controls, and buffer depth. No-op on native (renders `null`).\n */\nexport function DevtoolsPanel(): ReactNode {\n if (Platform.OS !== 'web') return null;\n return <PanelBody />;\n}\n\nfunction PanelBody(): ReactNode {\n const { buffer } = useDevtools();\n const { entities, selected, select } = useEntityInspector();\n const scrub = useTimeScrub();\n\n return (\n <View\n style={{\n position: 'absolute',\n top: 8,\n right: 8,\n padding: 8,\n backgroundColor: 'rgba(0,0,0,0.75)',\n borderRadius: 4,\n minWidth: 200,\n }}\n >\n <Text style={{ color: '#fff', fontWeight: 'bold' }}>Devtools</Text>\n <Text style={{ color: '#ccc' }}>\n buffer {buffer.length}/{buffer.size}\n </Text>\n <Text style={{ color: '#ccc' }}>\n {scrub.paused ? 'paused' : 'running'}\n {scrub.scrubbing ? ' (scrub)' : ''}\n </Text>\n <View style={{ flexDirection: 'row', marginTop: 4 }}>\n <DevButton label=\"Pause\" onPress={scrub.pause} />\n <DevButton label=\"Step\" onPress={scrub.step} />\n <DevButton label=\"Resume\" onPress={scrub.resume} />\n </View>\n <View style={{ marginTop: 8 }}>\n <Text style={{ color: '#fff' }}>entities ({entities.length})</Text>\n {entities.slice(0, 20).map((id) => (\n <Pressable key={id} onPress={() => select(id)}>\n <Text style={{ color: id === selected ? '#ff0' : '#fff' }}>#{id}</Text>\n </Pressable>\n ))}\n </View>\n </View>\n );\n}\n\nfunction DevButton({ label, onPress }: { label: string; onPress: () => void }): ReactNode {\n return (\n <Pressable\n onPress={onPress}\n style={{\n paddingHorizontal: 6,\n paddingVertical: 2,\n marginRight: 4,\n backgroundColor: '#444',\n borderRadius: 2,\n }}\n >\n <Text style={{ color: '#fff' }}>{label}</Text>\n </Pressable>\n );\n}\n","/**\n * Source callback used by `createSnapshotRingBuffer` to produce a snapshot\n * each capture tick. The ring buffer never introspects the snapshot — it is\n * an opaque `T` to this package. A future `World.serialize()` can be passed\n * in directly by consumers.\n */\nexport type SnapshotSource<T> = () => T;\n\n/**\n * Pre-allocated snapshot ring buffer. Slots are allocated once at\n * construction and the `write` cursor walks in place — zero per-frame\n * allocation. `rewind(framesAgo)` returns the snapshot that was `framesAgo`\n * captures back (0 = latest), or `null` if the requested offset exceeds the\n * number of snapshots currently held.\n */\nexport interface SnapshotRingBuffer<T> {\n /** Maximum number of snapshots retained. */\n readonly size: number;\n /** Number of snapshots currently held (0…size). */\n readonly length: number;\n /** Most recent snapshot, or `null` if `length === 0`. */\n readonly latest: T | null;\n /** Capture a new snapshot. Overwrites the oldest slot once full. */\n capture(): void;\n /** Return the snapshot from `framesAgo` captures back, or `null`. */\n rewind(framesAgo: number): T | null;\n /** Drop all retained snapshots. */\n reset(): void;\n}\n\nexport function createSnapshotRingBuffer<T>(\n size: number,\n source: SnapshotSource<T>,\n): SnapshotRingBuffer<T> {\n if (size <= 0 || !Number.isFinite(size)) {\n throw new Error(`SnapshotRingBuffer size must be a positive finite number, got ${size}`);\n }\n const capacity = Math.floor(size);\n const slots: (T | null)[] = new Array(capacity).fill(null);\n let head = 0; // next write index\n let count = 0;\n\n return {\n size: capacity,\n get length(): number {\n return count;\n },\n get latest(): T | null {\n if (count === 0) return null;\n const idx = (head - 1 + capacity) % capacity;\n return slots[idx] ?? null;\n },\n capture(): void {\n slots[head] = source();\n head = (head + 1) % capacity;\n if (count < capacity) count++;\n },\n rewind(framesAgo: number): T | null {\n if (framesAgo < 0 || !Number.isFinite(framesAgo)) return null;\n const offset = Math.floor(framesAgo);\n if (offset >= count) return null;\n const idx = (head - 1 - offset + capacity * 2) % capacity;\n return slots[idx] ?? null;\n },\n reset(): void {\n for (let i = 0; i < capacity; i++) slots[i] = null;\n head = 0;\n count = 0;\n },\n };\n}\n","import type { GameLoop } from '@flare-engine/core';\nimport type { SnapshotRingBuffer } from './ring-buffer.js';\n\n/**\n * Restore callback invoked by `TimeScrubber.rewind()` to apply a historical\n * snapshot back to world state. Consumers implement deserialize semantics\n * here — the scrubber itself never touches ECS state.\n */\nexport type RestoreCallback<T> = (snapshot: T) => void;\n\nexport interface TimeScrubberOptions<T> {\n loop: GameLoop;\n buffer: SnapshotRingBuffer<T>;\n /** Optional restore callback. If omitted, `rewind()` is a no-op beyond pausing the loop. */\n restore?: RestoreCallback<T>;\n}\n\n/**\n * TimeScrubber — imperative controller binding a `GameLoop` to a snapshot\n * ring buffer. Exposes pause / step / resume plus `rewind(framesAgo)` which\n * pauses the loop and hands the historical snapshot to the restore callback.\n */\nexport class TimeScrubber<T> {\n private readonly loop: GameLoop;\n private readonly buffer: SnapshotRingBuffer<T>;\n private readonly restore: RestoreCallback<T> | undefined;\n private _stepRequested = false;\n private _scrubFrames = 0;\n /** Timescale captured at `pause()`, restored by `resume()`. Defaults to 1. */\n private _savedTimescale = 1;\n\n constructor(options: TimeScrubberOptions<T>) {\n this.loop = options.loop;\n this.buffer = options.buffer;\n this.restore = options.restore;\n }\n\n /** Whether the loop is currently paused. */\n get paused(): boolean {\n return this.loop.clock.timescale === 0;\n }\n\n /** Whether the scrubber is currently displaying a historical snapshot. */\n get scrubbing(): boolean {\n return this._scrubFrames > 0;\n }\n\n /** Current scrub offset (0 = latest, N = N frames back). */\n get scrubOffset(): number {\n return this._scrubFrames;\n }\n\n /** Pause the loop (timescale → 0), remembering the running speed.\n * The `!== 0` guard means a double pause (e.g. `rewind()` calls `pause()`\n * while already paused) keeps the first saved value instead of storing 0. */\n pause(): void {\n if (this.loop.clock.timescale !== 0) {\n this._savedTimescale = this.loop.clock.timescale;\n }\n this.loop.clock.timescale = 0;\n }\n\n /** Resume the loop at its pre-pause speed and clear any scrub state.\n * Restores the timescale captured at `pause()` (defaults to 1 if never\n * paused), so resuming an active slow-mo returns to that rate, not 1×. */\n resume(): void {\n this.loop.clock.timescale = this._savedTimescale;\n this._scrubFrames = 0;\n this._stepRequested = false;\n }\n\n /** Request a single-frame step. Caller polls `consumeStep()` each frame. */\n step(): void {\n this._stepRequested = true;\n }\n\n /** Ring-buffer depth available for rewind. */\n get available(): number {\n return this.buffer.length;\n }\n\n /**\n * Pause the loop and restore the snapshot from `framesAgo` captures back.\n * Clamps to available history. Returns the snapshot applied, or `null`\n * when the buffer is empty.\n */\n rewind(framesAgo: number): T | null {\n if (framesAgo < 0 || !Number.isFinite(framesAgo)) return null;\n const max = this.buffer.length - 1;\n if (max < 0) return null;\n const offset = Math.min(Math.floor(framesAgo), max);\n const snap = this.buffer.rewind(offset);\n if (snap === null) return null;\n this.pause();\n this._scrubFrames = offset;\n if (this.restore) this.restore(snap);\n return snap;\n }\n\n /**\n * Returns true once per `step()` call, then resets. Frame-driver code is\n * expected to advance the simulation by one fixed tick when this is true.\n */\n consumeStep(): boolean {\n if (!this._stepRequested) return false;\n this._stepRequested = false;\n return true;\n }\n}\n","import type { GameLoop } from '@flare-engine/core';\nimport type { World } from '@flare-engine/ecs';\nimport { type ReactNode, useEffect, useMemo, useRef, useState } from 'react';\nimport { type DevtoolsConfig, DevtoolsContext, type DevtoolsContextValue } from './context.js';\nimport { createSnapshotRingBuffer, type SnapshotSource } from './ring-buffer.js';\nimport { type RestoreCallback, TimeScrubber } from './time-scrubber.js';\n\nexport interface DevtoolsProviderProps<T = unknown> {\n world: World;\n loop: GameLoop;\n /** Snapshot producer. Called on every capture tick. Must be cheap. */\n snapshot: SnapshotSource<T>;\n /** Optional restore callback for `TimeScrubber.rewind()`. */\n restore?: RestoreCallback<T>;\n config?: DevtoolsConfig;\n children?: ReactNode;\n}\n\nconst DEFAULT_CONFIG: Required<DevtoolsConfig> = {\n ringSize: 120,\n captureInterval: 1,\n enabledOnNative: true,\n};\n\n/**\n * DevtoolsProvider — mounts a devtools session for a given `World` + `GameLoop`.\n * Subscribes to `loop.onUpdate` and captures snapshots into a pre-allocated\n * ring buffer; exposes scrubber controls via `DevtoolsContext`.\n */\nexport function DevtoolsProvider<T>({\n world,\n loop,\n snapshot,\n restore,\n config,\n children,\n}: DevtoolsProviderProps<T>): ReactNode {\n const ringSize = config?.ringSize ?? DEFAULT_CONFIG.ringSize;\n const captureInterval = config?.captureInterval ?? DEFAULT_CONFIG.captureInterval;\n const [selectedEntity, select] = useState<number | null>(null);\n\n // Capture snapshot + restore in refs so the buffer/scrubber identity is\n // stable across renders — the live callbacks are read each tick.\n const snapshotRef = useRef(snapshot);\n snapshotRef.current = snapshot;\n const restoreRef = useRef(restore);\n restoreRef.current = restore;\n\n const { buffer, scrubber } = useMemo(() => {\n const buf = createSnapshotRingBuffer<T>(ringSize, () => snapshotRef.current());\n const scrub = new TimeScrubber<T>({\n loop,\n buffer: buf,\n restore: (s: T) => restoreRef.current?.(s),\n });\n return { buffer: buf, scrubber: scrub };\n }, [loop, ringSize]);\n\n useEffect(() => {\n let ticks = 0;\n const unsub = loop.onUpdate.add(() => {\n ticks++;\n if (ticks % captureInterval === 0) buffer.capture();\n });\n return () => {\n unsub();\n };\n }, [loop, buffer, captureInterval]);\n\n const value: DevtoolsContextValue = {\n world,\n loop,\n buffer: buffer as SnapshotRingBufferUnknown,\n scrubber: scrubber as TimeScrubberUnknown,\n selectedEntity,\n select,\n };\n\n return <DevtoolsContext.Provider value={value}>{children}</DevtoolsContext.Provider>;\n}\n\n// Narrow aliases so the context value type stays concrete without exposing the\n// provider's generic parameter in every downstream import.\ntype SnapshotRingBufferUnknown = DevtoolsContextValue['buffer'];\ntype TimeScrubberUnknown = DevtoolsContextValue['scrubber'];\n"],"mappings":";;;;AA0BA,MAAa,kBAAkB,cAA2C,IAAI;;ACxB9E,SAAgB,YAAqB;CACnC,OAAO,OAAO,YAAY,eAAe,QAAQ,OAAO;AAC1D;;;ACAA,SAAgB,cAAoC;CAClD,MAAM,MAAM,WAAW,eAAe;CACtC,IAAI,CAAC,KAC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KAAK,gBAAgB,OAAO;EACjC,KAAK,iBAAiB;EACtB,OAAO;CACT;AACF;;AC1FA,MAAM,iBAA2C;CAC/C,UAAU;CACV,iBAAiB;CACjB,iBAAiB;AACnB;;;;;;AAOA,SAAgB,iBAAoB,EAClC,OACA,MACA,UACA,SACA,QACA,YACsC;CACtC,MAAM,WAAW,QAAQ,YAAY,eAAe;CACpD,MAAM,kBAAkB,QAAQ,mBAAmB,eAAe;CAClE,MAAM,CAAC,gBAAgB,UAAU,SAAwB,IAAI;CAI7D,MAAM,cAAc,OAAO,QAAQ;CACnC,YAAY,UAAU;CACtB,MAAM,aAAa,OAAO,OAAO;CACjC,WAAW,UAAU;CAErB,MAAM,EAAE,QAAQ,aAAa,cAAc;EACzC,MAAM,MAAM,yBAA4B,gBAAgB,YAAY,QAAQ,CAAC;EAM7E,OAAO;GAAE,QAAQ;GAAK,UAAU,IALd,aAAgB;IAChC;IACA,QAAQ;IACR,UAAU,MAAS,WAAW,UAAU,CAAC;GAC3C,CACoC;EAAE;CACxC,GAAG,CAAC,MAAM,QAAQ,CAAC;CAEnB,gBAAgB;EACd,IAAI,QAAQ;EACZ,MAAM,QAAQ,KAAK,SAAS,UAAU;GACpC;GACA,IAAI,QAAQ,oBAAoB,GAAG,OAAO,QAAQ;EACpD,CAAC;EACD,aAAa;GACX,MAAM;EACR;CACF,GAAG;EAAC;EAAM;EAAQ;CAAe,CAAC;CAElC,MAAM,QAA8B;EAClC;EACA;EACQ;EACE;EACV;EACA;CACF;CAEA,OAAO,oBAAC,gBAAgB,UAAjB;EAAiC;EAAQ;CAAmC,CAAA;AACrF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flare-engine/devtools",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "Devtools partial — entity inspector, time scrub, pause/step",
|
|
5
5
|
"keywords": ["flare-engine", "devtools", "inspector", "debug"],
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"typecheck": "tsc --noEmit"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/react": "^19.
|
|
40
|
+
"@types/react": "^19.3.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@flare-engine/core": "^0.4.
|
|
44
|
-
"@flare-engine/ecs": "^0.4.
|
|
43
|
+
"@flare-engine/core": "^0.4.7",
|
|
44
|
+
"@flare-engine/ecs": "^0.4.7"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=19.0.0",
|