@flare-engine/devtools 0.1.0
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/LICENSE +21 -0
- package/README.md +35 -0
- package/dist/index.d.mts +161 -0
- package/dist/index.d.ts +161 -0
- package/dist/index.js +379 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +344 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Grzegorz Otto
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @flare-engine/devtools
|
|
2
|
+
|
|
3
|
+
In-game devtools — entity inspector, time scrub, pause / step. `<DevtoolsPanel>` is a web-only floating panel; `<DevtoolsHUD>` is a native-only compact overlay. Tree-shaken in production via `__DEV__` guards. The snapshot ring buffer pre-allocates frames at construction and reuses them in place — no per-frame allocation.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
bun add @flare-engine/devtools
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer deps: `react`, `react-native`.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { DevtoolsProvider, DevtoolsPanel, DevtoolsHUD, useEntityInspector } from '@flare-engine/devtools';
|
|
17
|
+
|
|
18
|
+
if (__DEV__) {
|
|
19
|
+
<DevtoolsProvider world={world} loop={loop} config={{ ringSize: 120 }}>
|
|
20
|
+
<DevtoolsPanel />
|
|
21
|
+
<DevtoolsHUD />
|
|
22
|
+
</DevtoolsProvider>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function CustomInspector() {
|
|
26
|
+
const { selected, components } = useEntityInspector();
|
|
27
|
+
// ...
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
See [API spec](../../docs/design/api-specs.md#flare-enginedevtools--8kb-gzip-tree-shaken-in-prod) and [skill reference](../../.github/skills/flare-devtools/SKILL.md).
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { GameLoop } from '@flare-engine/core';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { World } from '@flare-engine/ecs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Source callback used by `createSnapshotRingBuffer` to produce a snapshot
|
|
8
|
+
* each capture tick. The ring buffer never introspects the snapshot — it is
|
|
9
|
+
* an opaque `T` to this package. A future `World.serialize()` can be passed
|
|
10
|
+
* in directly by consumers.
|
|
11
|
+
*/
|
|
12
|
+
type SnapshotSource<T> = () => T;
|
|
13
|
+
/**
|
|
14
|
+
* Pre-allocated snapshot ring buffer. Slots are allocated once at
|
|
15
|
+
* construction and the `write` cursor walks in place — zero per-frame
|
|
16
|
+
* allocation. `rewind(framesAgo)` returns the snapshot that was `framesAgo`
|
|
17
|
+
* captures back (0 = latest), or `null` if the requested offset exceeds the
|
|
18
|
+
* number of snapshots currently held.
|
|
19
|
+
*/
|
|
20
|
+
interface SnapshotRingBuffer<T> {
|
|
21
|
+
/** Maximum number of snapshots retained. */
|
|
22
|
+
readonly size: number;
|
|
23
|
+
/** Number of snapshots currently held (0…size). */
|
|
24
|
+
readonly length: number;
|
|
25
|
+
/** Most recent snapshot, or `null` if `length === 0`. */
|
|
26
|
+
readonly latest: T | null;
|
|
27
|
+
/** Capture a new snapshot. Overwrites the oldest slot once full. */
|
|
28
|
+
capture(): void;
|
|
29
|
+
/** Return the snapshot from `framesAgo` captures back, or `null`. */
|
|
30
|
+
rewind(framesAgo: number): T | null;
|
|
31
|
+
/** Drop all retained snapshots. */
|
|
32
|
+
reset(): void;
|
|
33
|
+
}
|
|
34
|
+
declare function createSnapshotRingBuffer<T>(size: number, source: SnapshotSource<T>): SnapshotRingBuffer<T>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Restore callback invoked by `TimeScrubber.rewind()` to apply a historical
|
|
38
|
+
* snapshot back to world state. Consumers implement deserialize semantics
|
|
39
|
+
* here — the scrubber itself never touches ECS state.
|
|
40
|
+
*/
|
|
41
|
+
type RestoreCallback<T> = (snapshot: T) => void;
|
|
42
|
+
interface TimeScrubberOptions<T> {
|
|
43
|
+
loop: GameLoop;
|
|
44
|
+
buffer: SnapshotRingBuffer<T>;
|
|
45
|
+
/** Optional restore callback. If omitted, `rewind()` is a no-op beyond pausing the loop. */
|
|
46
|
+
restore?: RestoreCallback<T>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* TimeScrubber — imperative controller binding a `GameLoop` to a snapshot
|
|
50
|
+
* ring buffer. Exposes pause / step / resume plus `rewind(framesAgo)` which
|
|
51
|
+
* pauses the loop and hands the historical snapshot to the restore callback.
|
|
52
|
+
*/
|
|
53
|
+
declare class TimeScrubber<T> {
|
|
54
|
+
private readonly loop;
|
|
55
|
+
private readonly buffer;
|
|
56
|
+
private readonly restore;
|
|
57
|
+
private _stepRequested;
|
|
58
|
+
private _scrubFrames;
|
|
59
|
+
constructor(options: TimeScrubberOptions<T>);
|
|
60
|
+
/** Whether the loop is currently paused. */
|
|
61
|
+
get paused(): boolean;
|
|
62
|
+
/** Whether the scrubber is currently displaying a historical snapshot. */
|
|
63
|
+
get scrubbing(): boolean;
|
|
64
|
+
/** Current scrub offset (0 = latest, N = N frames back). */
|
|
65
|
+
get scrubOffset(): number;
|
|
66
|
+
/** Pause the loop (timescale → 0). */
|
|
67
|
+
pause(): void;
|
|
68
|
+
/** Resume the loop at normal speed and clear any scrub state. */
|
|
69
|
+
resume(): void;
|
|
70
|
+
/** Request a single-frame step. Caller polls `consumeStep()` each frame. */
|
|
71
|
+
step(): void;
|
|
72
|
+
/** Ring-buffer depth available for rewind. */
|
|
73
|
+
get available(): number;
|
|
74
|
+
/**
|
|
75
|
+
* Pause the loop and restore the snapshot from `framesAgo` captures back.
|
|
76
|
+
* Clamps to available history. Returns the snapshot applied, or `null`
|
|
77
|
+
* when the buffer is empty.
|
|
78
|
+
*/
|
|
79
|
+
rewind(framesAgo: number): T | null;
|
|
80
|
+
/**
|
|
81
|
+
* Returns true once per `step()` call, then resets. Frame-driver code is
|
|
82
|
+
* expected to advance the simulation by one fixed tick when this is true.
|
|
83
|
+
*/
|
|
84
|
+
consumeStep(): boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Devtools configuration. */
|
|
88
|
+
interface DevtoolsConfig {
|
|
89
|
+
/** Ring-buffer depth in frames. Default 120 (~2 s @ 60 fps). */
|
|
90
|
+
ringSize?: number;
|
|
91
|
+
/** Capture every Nth `onUpdate`. Default 1 (every frame). */
|
|
92
|
+
captureInterval?: number;
|
|
93
|
+
/** Enable the native HUD surface. Default true. */
|
|
94
|
+
enabledOnNative?: boolean;
|
|
95
|
+
}
|
|
96
|
+
/** Value exposed via `DevtoolsContext`. */
|
|
97
|
+
interface DevtoolsContextValue {
|
|
98
|
+
world: World;
|
|
99
|
+
loop: GameLoop;
|
|
100
|
+
buffer: SnapshotRingBuffer<unknown>;
|
|
101
|
+
scrubber: TimeScrubber<unknown>;
|
|
102
|
+
selectedEntity: number | null;
|
|
103
|
+
select(entity: number | null): void;
|
|
104
|
+
pause(): void;
|
|
105
|
+
step(): void;
|
|
106
|
+
resume(): void;
|
|
107
|
+
}
|
|
108
|
+
declare const DevtoolsContext: react.Context<DevtoolsContextValue | null>;
|
|
109
|
+
|
|
110
|
+
interface DevtoolsProviderProps<T = unknown> {
|
|
111
|
+
world: World;
|
|
112
|
+
loop: GameLoop;
|
|
113
|
+
/** Snapshot producer. Called on every capture tick. Must be cheap. */
|
|
114
|
+
snapshot: SnapshotSource<T>;
|
|
115
|
+
/** Optional restore callback for `TimeScrubber.rewind()`. */
|
|
116
|
+
restore?: RestoreCallback<T>;
|
|
117
|
+
config?: DevtoolsConfig;
|
|
118
|
+
children?: ReactNode;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* DevtoolsProvider — mounts a devtools session for a given `World` + `GameLoop`.
|
|
122
|
+
* Subscribes to `loop.onUpdate` and captures snapshots into a pre-allocated
|
|
123
|
+
* ring buffer; exposes scrubber controls via `DevtoolsContext`.
|
|
124
|
+
*/
|
|
125
|
+
declare function DevtoolsProvider<T>({ world, loop, snapshot, restore, config, children, }: DevtoolsProviderProps<T>): ReactNode;
|
|
126
|
+
|
|
127
|
+
/** Returns the active devtools context, or throws if no provider is mounted. */
|
|
128
|
+
declare function useDevtools(): DevtoolsContextValue;
|
|
129
|
+
interface EntityInspectorView {
|
|
130
|
+
selected: number | null;
|
|
131
|
+
select(entity: number | null): void;
|
|
132
|
+
/** Entity IDs present in the world at the moment the hook was read. */
|
|
133
|
+
entities: readonly number[];
|
|
134
|
+
}
|
|
135
|
+
/** Entity-inspector hook. Never mutates the world — read-only snapshot. */
|
|
136
|
+
declare function useEntityInspector(): EntityInspectorView;
|
|
137
|
+
interface TimeScrubView {
|
|
138
|
+
paused: boolean;
|
|
139
|
+
scrubbing: boolean;
|
|
140
|
+
available: number;
|
|
141
|
+
pause(): void;
|
|
142
|
+
resume(): void;
|
|
143
|
+
step(): void;
|
|
144
|
+
rewind(framesAgo: number): void;
|
|
145
|
+
}
|
|
146
|
+
/** Time-scrub hook — exposes the scrubber's imperative controls. */
|
|
147
|
+
declare function useTimeScrub(): TimeScrubView;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* DevtoolsPanel — full web-side panel. Renders the entity tree, scrub
|
|
151
|
+
* controls, and buffer depth. No-op on native (renders `null`).
|
|
152
|
+
*/
|
|
153
|
+
declare function DevtoolsPanel(): ReactNode;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* DevtoolsHUD — compact native overlay. Shows buffer depth + pause/step/resume
|
|
157
|
+
* buttons. No-op on web (renders `null`).
|
|
158
|
+
*/
|
|
159
|
+
declare function DevtoolsHUD(): ReactNode;
|
|
160
|
+
|
|
161
|
+
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, useDevtools, useEntityInspector, useTimeScrub };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { GameLoop } from '@flare-engine/core';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { World } from '@flare-engine/ecs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Source callback used by `createSnapshotRingBuffer` to produce a snapshot
|
|
8
|
+
* each capture tick. The ring buffer never introspects the snapshot — it is
|
|
9
|
+
* an opaque `T` to this package. A future `World.serialize()` can be passed
|
|
10
|
+
* in directly by consumers.
|
|
11
|
+
*/
|
|
12
|
+
type SnapshotSource<T> = () => T;
|
|
13
|
+
/**
|
|
14
|
+
* Pre-allocated snapshot ring buffer. Slots are allocated once at
|
|
15
|
+
* construction and the `write` cursor walks in place — zero per-frame
|
|
16
|
+
* allocation. `rewind(framesAgo)` returns the snapshot that was `framesAgo`
|
|
17
|
+
* captures back (0 = latest), or `null` if the requested offset exceeds the
|
|
18
|
+
* number of snapshots currently held.
|
|
19
|
+
*/
|
|
20
|
+
interface SnapshotRingBuffer<T> {
|
|
21
|
+
/** Maximum number of snapshots retained. */
|
|
22
|
+
readonly size: number;
|
|
23
|
+
/** Number of snapshots currently held (0…size). */
|
|
24
|
+
readonly length: number;
|
|
25
|
+
/** Most recent snapshot, or `null` if `length === 0`. */
|
|
26
|
+
readonly latest: T | null;
|
|
27
|
+
/** Capture a new snapshot. Overwrites the oldest slot once full. */
|
|
28
|
+
capture(): void;
|
|
29
|
+
/** Return the snapshot from `framesAgo` captures back, or `null`. */
|
|
30
|
+
rewind(framesAgo: number): T | null;
|
|
31
|
+
/** Drop all retained snapshots. */
|
|
32
|
+
reset(): void;
|
|
33
|
+
}
|
|
34
|
+
declare function createSnapshotRingBuffer<T>(size: number, source: SnapshotSource<T>): SnapshotRingBuffer<T>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Restore callback invoked by `TimeScrubber.rewind()` to apply a historical
|
|
38
|
+
* snapshot back to world state. Consumers implement deserialize semantics
|
|
39
|
+
* here — the scrubber itself never touches ECS state.
|
|
40
|
+
*/
|
|
41
|
+
type RestoreCallback<T> = (snapshot: T) => void;
|
|
42
|
+
interface TimeScrubberOptions<T> {
|
|
43
|
+
loop: GameLoop;
|
|
44
|
+
buffer: SnapshotRingBuffer<T>;
|
|
45
|
+
/** Optional restore callback. If omitted, `rewind()` is a no-op beyond pausing the loop. */
|
|
46
|
+
restore?: RestoreCallback<T>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* TimeScrubber — imperative controller binding a `GameLoop` to a snapshot
|
|
50
|
+
* ring buffer. Exposes pause / step / resume plus `rewind(framesAgo)` which
|
|
51
|
+
* pauses the loop and hands the historical snapshot to the restore callback.
|
|
52
|
+
*/
|
|
53
|
+
declare class TimeScrubber<T> {
|
|
54
|
+
private readonly loop;
|
|
55
|
+
private readonly buffer;
|
|
56
|
+
private readonly restore;
|
|
57
|
+
private _stepRequested;
|
|
58
|
+
private _scrubFrames;
|
|
59
|
+
constructor(options: TimeScrubberOptions<T>);
|
|
60
|
+
/** Whether the loop is currently paused. */
|
|
61
|
+
get paused(): boolean;
|
|
62
|
+
/** Whether the scrubber is currently displaying a historical snapshot. */
|
|
63
|
+
get scrubbing(): boolean;
|
|
64
|
+
/** Current scrub offset (0 = latest, N = N frames back). */
|
|
65
|
+
get scrubOffset(): number;
|
|
66
|
+
/** Pause the loop (timescale → 0). */
|
|
67
|
+
pause(): void;
|
|
68
|
+
/** Resume the loop at normal speed and clear any scrub state. */
|
|
69
|
+
resume(): void;
|
|
70
|
+
/** Request a single-frame step. Caller polls `consumeStep()` each frame. */
|
|
71
|
+
step(): void;
|
|
72
|
+
/** Ring-buffer depth available for rewind. */
|
|
73
|
+
get available(): number;
|
|
74
|
+
/**
|
|
75
|
+
* Pause the loop and restore the snapshot from `framesAgo` captures back.
|
|
76
|
+
* Clamps to available history. Returns the snapshot applied, or `null`
|
|
77
|
+
* when the buffer is empty.
|
|
78
|
+
*/
|
|
79
|
+
rewind(framesAgo: number): T | null;
|
|
80
|
+
/**
|
|
81
|
+
* Returns true once per `step()` call, then resets. Frame-driver code is
|
|
82
|
+
* expected to advance the simulation by one fixed tick when this is true.
|
|
83
|
+
*/
|
|
84
|
+
consumeStep(): boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Devtools configuration. */
|
|
88
|
+
interface DevtoolsConfig {
|
|
89
|
+
/** Ring-buffer depth in frames. Default 120 (~2 s @ 60 fps). */
|
|
90
|
+
ringSize?: number;
|
|
91
|
+
/** Capture every Nth `onUpdate`. Default 1 (every frame). */
|
|
92
|
+
captureInterval?: number;
|
|
93
|
+
/** Enable the native HUD surface. Default true. */
|
|
94
|
+
enabledOnNative?: boolean;
|
|
95
|
+
}
|
|
96
|
+
/** Value exposed via `DevtoolsContext`. */
|
|
97
|
+
interface DevtoolsContextValue {
|
|
98
|
+
world: World;
|
|
99
|
+
loop: GameLoop;
|
|
100
|
+
buffer: SnapshotRingBuffer<unknown>;
|
|
101
|
+
scrubber: TimeScrubber<unknown>;
|
|
102
|
+
selectedEntity: number | null;
|
|
103
|
+
select(entity: number | null): void;
|
|
104
|
+
pause(): void;
|
|
105
|
+
step(): void;
|
|
106
|
+
resume(): void;
|
|
107
|
+
}
|
|
108
|
+
declare const DevtoolsContext: react.Context<DevtoolsContextValue | null>;
|
|
109
|
+
|
|
110
|
+
interface DevtoolsProviderProps<T = unknown> {
|
|
111
|
+
world: World;
|
|
112
|
+
loop: GameLoop;
|
|
113
|
+
/** Snapshot producer. Called on every capture tick. Must be cheap. */
|
|
114
|
+
snapshot: SnapshotSource<T>;
|
|
115
|
+
/** Optional restore callback for `TimeScrubber.rewind()`. */
|
|
116
|
+
restore?: RestoreCallback<T>;
|
|
117
|
+
config?: DevtoolsConfig;
|
|
118
|
+
children?: ReactNode;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* DevtoolsProvider — mounts a devtools session for a given `World` + `GameLoop`.
|
|
122
|
+
* Subscribes to `loop.onUpdate` and captures snapshots into a pre-allocated
|
|
123
|
+
* ring buffer; exposes scrubber controls via `DevtoolsContext`.
|
|
124
|
+
*/
|
|
125
|
+
declare function DevtoolsProvider<T>({ world, loop, snapshot, restore, config, children, }: DevtoolsProviderProps<T>): ReactNode;
|
|
126
|
+
|
|
127
|
+
/** Returns the active devtools context, or throws if no provider is mounted. */
|
|
128
|
+
declare function useDevtools(): DevtoolsContextValue;
|
|
129
|
+
interface EntityInspectorView {
|
|
130
|
+
selected: number | null;
|
|
131
|
+
select(entity: number | null): void;
|
|
132
|
+
/** Entity IDs present in the world at the moment the hook was read. */
|
|
133
|
+
entities: readonly number[];
|
|
134
|
+
}
|
|
135
|
+
/** Entity-inspector hook. Never mutates the world — read-only snapshot. */
|
|
136
|
+
declare function useEntityInspector(): EntityInspectorView;
|
|
137
|
+
interface TimeScrubView {
|
|
138
|
+
paused: boolean;
|
|
139
|
+
scrubbing: boolean;
|
|
140
|
+
available: number;
|
|
141
|
+
pause(): void;
|
|
142
|
+
resume(): void;
|
|
143
|
+
step(): void;
|
|
144
|
+
rewind(framesAgo: number): void;
|
|
145
|
+
}
|
|
146
|
+
/** Time-scrub hook — exposes the scrubber's imperative controls. */
|
|
147
|
+
declare function useTimeScrub(): TimeScrubView;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* DevtoolsPanel — full web-side panel. Renders the entity tree, scrub
|
|
151
|
+
* controls, and buffer depth. No-op on native (renders `null`).
|
|
152
|
+
*/
|
|
153
|
+
declare function DevtoolsPanel(): ReactNode;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* DevtoolsHUD — compact native overlay. Shows buffer depth + pause/step/resume
|
|
157
|
+
* buttons. No-op on web (renders `null`).
|
|
158
|
+
*/
|
|
159
|
+
declare function DevtoolsHUD(): ReactNode;
|
|
160
|
+
|
|
161
|
+
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, useDevtools, useEntityInspector, useTimeScrub };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
DevtoolsContext: () => DevtoolsContext,
|
|
24
|
+
DevtoolsHUD: () => DevtoolsHUD,
|
|
25
|
+
DevtoolsPanel: () => DevtoolsPanel,
|
|
26
|
+
DevtoolsProvider: () => DevtoolsProvider,
|
|
27
|
+
TimeScrubber: () => TimeScrubber,
|
|
28
|
+
createSnapshotRingBuffer: () => createSnapshotRingBuffer,
|
|
29
|
+
useDevtools: () => useDevtools,
|
|
30
|
+
useEntityInspector: () => useEntityInspector,
|
|
31
|
+
useTimeScrub: () => useTimeScrub
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
|
|
35
|
+
// src/ring-buffer.ts
|
|
36
|
+
function createSnapshotRingBuffer(size, source) {
|
|
37
|
+
if (size <= 0 || !Number.isFinite(size)) {
|
|
38
|
+
throw new Error(`SnapshotRingBuffer size must be a positive finite number, got ${size}`);
|
|
39
|
+
}
|
|
40
|
+
const capacity = Math.floor(size);
|
|
41
|
+
const slots = new Array(capacity).fill(null);
|
|
42
|
+
let head = 0;
|
|
43
|
+
let count = 0;
|
|
44
|
+
return {
|
|
45
|
+
size: capacity,
|
|
46
|
+
get length() {
|
|
47
|
+
return count;
|
|
48
|
+
},
|
|
49
|
+
get latest() {
|
|
50
|
+
if (count === 0) return null;
|
|
51
|
+
const idx = (head - 1 + capacity) % capacity;
|
|
52
|
+
return slots[idx] ?? null;
|
|
53
|
+
},
|
|
54
|
+
capture() {
|
|
55
|
+
slots[head] = source();
|
|
56
|
+
head = (head + 1) % capacity;
|
|
57
|
+
if (count < capacity) count++;
|
|
58
|
+
},
|
|
59
|
+
rewind(framesAgo) {
|
|
60
|
+
if (framesAgo < 0 || !Number.isFinite(framesAgo)) return null;
|
|
61
|
+
const offset = Math.floor(framesAgo);
|
|
62
|
+
if (offset >= count) return null;
|
|
63
|
+
const idx = (head - 1 - offset + capacity * 2) % capacity;
|
|
64
|
+
return slots[idx] ?? null;
|
|
65
|
+
},
|
|
66
|
+
reset() {
|
|
67
|
+
for (let i = 0; i < capacity; i++) slots[i] = null;
|
|
68
|
+
head = 0;
|
|
69
|
+
count = 0;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/time-scrubber.ts
|
|
75
|
+
var TimeScrubber = class {
|
|
76
|
+
loop;
|
|
77
|
+
buffer;
|
|
78
|
+
restore;
|
|
79
|
+
_stepRequested = false;
|
|
80
|
+
_scrubFrames = 0;
|
|
81
|
+
constructor(options) {
|
|
82
|
+
this.loop = options.loop;
|
|
83
|
+
this.buffer = options.buffer;
|
|
84
|
+
this.restore = options.restore;
|
|
85
|
+
}
|
|
86
|
+
/** Whether the loop is currently paused. */
|
|
87
|
+
get paused() {
|
|
88
|
+
return this.loop.clock.timescale === 0;
|
|
89
|
+
}
|
|
90
|
+
/** Whether the scrubber is currently displaying a historical snapshot. */
|
|
91
|
+
get scrubbing() {
|
|
92
|
+
return this._scrubFrames > 0;
|
|
93
|
+
}
|
|
94
|
+
/** Current scrub offset (0 = latest, N = N frames back). */
|
|
95
|
+
get scrubOffset() {
|
|
96
|
+
return this._scrubFrames;
|
|
97
|
+
}
|
|
98
|
+
/** Pause the loop (timescale → 0). */
|
|
99
|
+
pause() {
|
|
100
|
+
this.loop.clock.timescale = 0;
|
|
101
|
+
}
|
|
102
|
+
/** Resume the loop at normal speed and clear any scrub state. */
|
|
103
|
+
resume() {
|
|
104
|
+
this.loop.clock.timescale = 1;
|
|
105
|
+
this._scrubFrames = 0;
|
|
106
|
+
this._stepRequested = false;
|
|
107
|
+
}
|
|
108
|
+
/** Request a single-frame step. Caller polls `consumeStep()` each frame. */
|
|
109
|
+
step() {
|
|
110
|
+
this._stepRequested = true;
|
|
111
|
+
}
|
|
112
|
+
/** Ring-buffer depth available for rewind. */
|
|
113
|
+
get available() {
|
|
114
|
+
return this.buffer.length;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Pause the loop and restore the snapshot from `framesAgo` captures back.
|
|
118
|
+
* Clamps to available history. Returns the snapshot applied, or `null`
|
|
119
|
+
* when the buffer is empty.
|
|
120
|
+
*/
|
|
121
|
+
rewind(framesAgo) {
|
|
122
|
+
if (framesAgo < 0 || !Number.isFinite(framesAgo)) return null;
|
|
123
|
+
const max = this.buffer.length - 1;
|
|
124
|
+
if (max < 0) return null;
|
|
125
|
+
const offset = Math.min(Math.floor(framesAgo), max);
|
|
126
|
+
const snap = this.buffer.rewind(offset);
|
|
127
|
+
if (snap === null) return null;
|
|
128
|
+
this.pause();
|
|
129
|
+
this._scrubFrames = offset;
|
|
130
|
+
if (this.restore) this.restore(snap);
|
|
131
|
+
return snap;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Returns true once per `step()` call, then resets. Frame-driver code is
|
|
135
|
+
* expected to advance the simulation by one fixed tick when this is true.
|
|
136
|
+
*/
|
|
137
|
+
consumeStep() {
|
|
138
|
+
if (!this._stepRequested) return false;
|
|
139
|
+
this._stepRequested = false;
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// src/context.ts
|
|
145
|
+
var import_react = require("react");
|
|
146
|
+
var DevtoolsContext = (0, import_react.createContext)(null);
|
|
147
|
+
|
|
148
|
+
// src/provider.tsx
|
|
149
|
+
var import_react2 = require("react");
|
|
150
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
151
|
+
var DEFAULT_CONFIG = {
|
|
152
|
+
ringSize: 120,
|
|
153
|
+
captureInterval: 1,
|
|
154
|
+
enabledOnNative: true
|
|
155
|
+
};
|
|
156
|
+
function DevtoolsProvider({
|
|
157
|
+
world,
|
|
158
|
+
loop,
|
|
159
|
+
snapshot,
|
|
160
|
+
restore,
|
|
161
|
+
config,
|
|
162
|
+
children
|
|
163
|
+
}) {
|
|
164
|
+
const ringSize = config?.ringSize ?? DEFAULT_CONFIG.ringSize;
|
|
165
|
+
const captureInterval = config?.captureInterval ?? DEFAULT_CONFIG.captureInterval;
|
|
166
|
+
const [selectedEntity, select] = (0, import_react2.useState)(null);
|
|
167
|
+
const snapshotRef = (0, import_react2.useRef)(snapshot);
|
|
168
|
+
snapshotRef.current = snapshot;
|
|
169
|
+
const restoreRef = (0, import_react2.useRef)(restore);
|
|
170
|
+
restoreRef.current = restore;
|
|
171
|
+
const { buffer, scrubber } = (0, import_react2.useMemo)(() => {
|
|
172
|
+
const buf = createSnapshotRingBuffer(ringSize, () => snapshotRef.current());
|
|
173
|
+
const scrub = new TimeScrubber({
|
|
174
|
+
loop,
|
|
175
|
+
buffer: buf,
|
|
176
|
+
restore: (s) => restoreRef.current?.(s)
|
|
177
|
+
});
|
|
178
|
+
return { buffer: buf, scrubber: scrub };
|
|
179
|
+
}, [loop, ringSize]);
|
|
180
|
+
(0, import_react2.useEffect)(() => {
|
|
181
|
+
let ticks = 0;
|
|
182
|
+
const unsub = loop.onUpdate.add(() => {
|
|
183
|
+
ticks++;
|
|
184
|
+
if (ticks % captureInterval === 0) buffer.capture();
|
|
185
|
+
});
|
|
186
|
+
return () => {
|
|
187
|
+
unsub();
|
|
188
|
+
};
|
|
189
|
+
}, [loop, buffer, captureInterval]);
|
|
190
|
+
const value = {
|
|
191
|
+
world,
|
|
192
|
+
loop,
|
|
193
|
+
buffer,
|
|
194
|
+
scrubber,
|
|
195
|
+
selectedEntity,
|
|
196
|
+
select,
|
|
197
|
+
pause: () => scrubber.pause(),
|
|
198
|
+
step: () => scrubber.step(),
|
|
199
|
+
resume: () => scrubber.resume()
|
|
200
|
+
};
|
|
201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DevtoolsContext.Provider, { value, children });
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// src/hooks.ts
|
|
205
|
+
var import_react3 = require("react");
|
|
206
|
+
function useDevtools() {
|
|
207
|
+
const ctx = (0, import_react3.useContext)(DevtoolsContext);
|
|
208
|
+
if (!ctx) {
|
|
209
|
+
throw new Error("useDevtools must be used inside a <DevtoolsProvider>");
|
|
210
|
+
}
|
|
211
|
+
return ctx;
|
|
212
|
+
}
|
|
213
|
+
function useEntityInspector() {
|
|
214
|
+
const { world, selectedEntity, select } = useDevtools();
|
|
215
|
+
const entities = [];
|
|
216
|
+
const max = world.nextId ?? 0;
|
|
217
|
+
for (let id = 1; id < max; id++) {
|
|
218
|
+
if (world.exists(id)) entities.push(id);
|
|
219
|
+
}
|
|
220
|
+
return { selected: selectedEntity, select, entities };
|
|
221
|
+
}
|
|
222
|
+
function useTimeScrub() {
|
|
223
|
+
const { scrubber } = useDevtools();
|
|
224
|
+
return {
|
|
225
|
+
paused: scrubber.paused,
|
|
226
|
+
scrubbing: scrubber.scrubbing,
|
|
227
|
+
available: scrubber.available,
|
|
228
|
+
pause: () => scrubber.pause(),
|
|
229
|
+
resume: () => scrubber.resume(),
|
|
230
|
+
step: () => scrubber.step(),
|
|
231
|
+
rewind: (framesAgo) => {
|
|
232
|
+
scrubber.rewind(framesAgo);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// src/panel.tsx
|
|
238
|
+
var import_react_native = require("react-native");
|
|
239
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
240
|
+
function DevtoolsPanel() {
|
|
241
|
+
if (import_react_native.Platform.OS !== "web") return null;
|
|
242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PanelBody, {});
|
|
243
|
+
}
|
|
244
|
+
function PanelBody() {
|
|
245
|
+
const { buffer } = useDevtools();
|
|
246
|
+
const { entities, selected, select } = useEntityInspector();
|
|
247
|
+
const scrub = useTimeScrub();
|
|
248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
249
|
+
import_react_native.View,
|
|
250
|
+
{
|
|
251
|
+
style: {
|
|
252
|
+
position: "absolute",
|
|
253
|
+
top: 8,
|
|
254
|
+
right: 8,
|
|
255
|
+
padding: 8,
|
|
256
|
+
backgroundColor: "rgba(0,0,0,0.75)",
|
|
257
|
+
borderRadius: 4,
|
|
258
|
+
minWidth: 200
|
|
259
|
+
},
|
|
260
|
+
children: [
|
|
261
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native.Text, { style: { color: "#fff", fontWeight: "bold" }, children: "Devtools" }),
|
|
262
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native.Text, { style: { color: "#ccc" }, children: [
|
|
263
|
+
"buffer ",
|
|
264
|
+
buffer.length,
|
|
265
|
+
"/",
|
|
266
|
+
buffer.size
|
|
267
|
+
] }),
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native.Text, { style: { color: "#ccc" }, children: [
|
|
269
|
+
scrub.paused ? "paused" : "running",
|
|
270
|
+
scrub.scrubbing ? " (scrub)" : ""
|
|
271
|
+
] }),
|
|
272
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native.View, { style: { flexDirection: "row", marginTop: 4 }, children: [
|
|
273
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DevButton, { label: "Pause", onPress: scrub.pause }),
|
|
274
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DevButton, { label: "Step", onPress: scrub.step }),
|
|
275
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DevButton, { label: "Resume", onPress: scrub.resume })
|
|
276
|
+
] }),
|
|
277
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native.View, { style: { marginTop: 8 }, children: [
|
|
278
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native.Text, { style: { color: "#fff" }, children: [
|
|
279
|
+
"entities (",
|
|
280
|
+
entities.length,
|
|
281
|
+
")"
|
|
282
|
+
] }),
|
|
283
|
+
entities.slice(0, 20).map((id) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native.Pressable, { onPress: () => select(id), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native.Text, { style: { color: id === selected ? "#ff0" : "#fff" }, children: [
|
|
284
|
+
"#",
|
|
285
|
+
id
|
|
286
|
+
] }) }, id))
|
|
287
|
+
] })
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
function DevButton({
|
|
293
|
+
label,
|
|
294
|
+
onPress
|
|
295
|
+
}) {
|
|
296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
297
|
+
import_react_native.Pressable,
|
|
298
|
+
{
|
|
299
|
+
onPress,
|
|
300
|
+
style: {
|
|
301
|
+
paddingHorizontal: 6,
|
|
302
|
+
paddingVertical: 2,
|
|
303
|
+
marginRight: 4,
|
|
304
|
+
backgroundColor: "#444",
|
|
305
|
+
borderRadius: 2
|
|
306
|
+
},
|
|
307
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native.Text, { style: { color: "#fff" }, children: label })
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// src/hud.tsx
|
|
313
|
+
var import_react_native2 = require("react-native");
|
|
314
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
315
|
+
function DevtoolsHUD() {
|
|
316
|
+
if (import_react_native2.Platform.OS === "web") return null;
|
|
317
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HUDBody, {});
|
|
318
|
+
}
|
|
319
|
+
function HUDBody() {
|
|
320
|
+
const { buffer } = useDevtools();
|
|
321
|
+
const scrub = useTimeScrub();
|
|
322
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
323
|
+
import_react_native2.View,
|
|
324
|
+
{
|
|
325
|
+
style: {
|
|
326
|
+
position: "absolute",
|
|
327
|
+
bottom: 16,
|
|
328
|
+
right: 16,
|
|
329
|
+
flexDirection: "row",
|
|
330
|
+
alignItems: "center",
|
|
331
|
+
padding: 6,
|
|
332
|
+
backgroundColor: "rgba(0,0,0,0.75)",
|
|
333
|
+
borderRadius: 4
|
|
334
|
+
},
|
|
335
|
+
children: [
|
|
336
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native2.Text, { style: { color: "#fff", marginRight: 8 }, children: [
|
|
337
|
+
buffer.length,
|
|
338
|
+
"/",
|
|
339
|
+
buffer.size
|
|
340
|
+
] }),
|
|
341
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HudButton, { label: "||", onPress: scrub.pause }),
|
|
342
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HudButton, { label: ">|", onPress: scrub.step }),
|
|
343
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HudButton, { label: ">", onPress: scrub.resume })
|
|
344
|
+
]
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
function HudButton({
|
|
349
|
+
label,
|
|
350
|
+
onPress
|
|
351
|
+
}) {
|
|
352
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
353
|
+
import_react_native2.Pressable,
|
|
354
|
+
{
|
|
355
|
+
onPress,
|
|
356
|
+
style: {
|
|
357
|
+
paddingHorizontal: 6,
|
|
358
|
+
paddingVertical: 2,
|
|
359
|
+
marginLeft: 4,
|
|
360
|
+
backgroundColor: "#444",
|
|
361
|
+
borderRadius: 2
|
|
362
|
+
},
|
|
363
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.Text, { style: { color: "#fff" }, children: label })
|
|
364
|
+
}
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
368
|
+
0 && (module.exports = {
|
|
369
|
+
DevtoolsContext,
|
|
370
|
+
DevtoolsHUD,
|
|
371
|
+
DevtoolsPanel,
|
|
372
|
+
DevtoolsProvider,
|
|
373
|
+
TimeScrubber,
|
|
374
|
+
createSnapshotRingBuffer,
|
|
375
|
+
useDevtools,
|
|
376
|
+
useEntityInspector,
|
|
377
|
+
useTimeScrub
|
|
378
|
+
});
|
|
379
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/ring-buffer.ts","../src/time-scrubber.ts","../src/context.ts","../src/provider.tsx","../src/hooks.ts","../src/panel.tsx","../src/hud.tsx"],"sourcesContent":["export {\n createSnapshotRingBuffer,\n type SnapshotRingBuffer,\n type SnapshotSource,\n} from './ring-buffer.js';\nexport {\n TimeScrubber,\n type RestoreCallback,\n type TimeScrubberOptions,\n} from './time-scrubber.js';\nexport {\n DevtoolsContext,\n type DevtoolsConfig,\n type DevtoolsContextValue,\n} from './context.js';\nexport { DevtoolsProvider, type DevtoolsProviderProps } from './provider.js';\nexport { useDevtools, useEntityInspector, useTimeScrub } from './hooks.js';\nexport type { EntityInspectorView, TimeScrubView } from './hooks.js';\nexport { DevtoolsPanel } from './panel.js';\nexport { DevtoolsHUD } from './hud.js';\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\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). */\n pause(): void {\n this.loop.clock.timescale = 0;\n }\n\n /** Resume the loop at normal speed and clear any scrub state. */\n resume(): void {\n this.loop.clock.timescale = 1;\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 { 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 pause(): void;\n step(): void;\n resume(): void;\n}\n\nexport const DevtoolsContext = createContext<DevtoolsContextValue | null>(null);\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 { type SnapshotSource, createSnapshotRingBuffer } 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 pause: () => scrubber.pause(),\n step: () => scrubber.step(),\n resume: () => scrubber.resume(),\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","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` does not expose an iterator; fall back to scanning the id range.\n // This is the 0.1.0 partial scope — a cheaper iterator may land in 0.2.0.\n const max = (world as unknown as { nextId?: number }).nextId ?? 0;\n for (let id = 1; id < max; id++) {\n if (world.exists(id)) entities.push(id);\n }\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, 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({\n label,\n onPress,\n}: {\n label: string;\n onPress: () => void;\n}): 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","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({\n label,\n onPress,\n}: {\n label: string;\n onPress: () => void;\n}): 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC8BO,SAAS,yBACd,MACA,QACuB;AACvB,MAAI,QAAQ,KAAK,CAAC,OAAO,SAAS,IAAI,GAAG;AACvC,UAAM,IAAI,MAAM,iEAAiE,IAAI,EAAE;AAAA,EACzF;AACA,QAAM,WAAW,KAAK,MAAM,IAAI;AAChC,QAAM,QAAsB,IAAI,MAAM,QAAQ,EAAE,KAAK,IAAI;AACzD,MAAI,OAAO;AACX,MAAI,QAAQ;AAEZ,SAAO;AAAA,IACL,MAAM;AAAA,IACN,IAAI,SAAiB;AACnB,aAAO;AAAA,IACT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AChB;AAAA,MAEA;AAAA,sDAAC,6BAAK,OAAO,EAAE,OAAO,QAAQ,aAAa,EAAE,GAC1C;AAAA,iBAAO;AAAA,UAAO;AAAA,UAAE,OAAO;AAAA,WAC1B;AAAA,QACA,6CAAC,aAAU,OAAM,MAAK,SAAS,MAAM,OAAO;AAAA,QAC5C,6CAAC,aAAU,OAAM,MAAK,SAAS,MAAM,MAAM;AAAA,QAC3C,6CAAC,aAAU,OAAM,KAAI,SAAS,MAAM,QAAQ;AAAA;AAAA;AAAA,EAC9C;AAEJ;AAEA,SAAS,UAAU;AAAA,EACjB;AAAA,EACA;AACF,GAGc;AACZ,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA,QACL,mBAAmB;AAAA,QACnB,iBAAiB;AAAA,QACjB,YAAY;AAAA,QACZ,iBAAiB;AAAA,QACjB,cAAc;AAAA,MAChB;AAAA,MAEA,uDAAC,6BAAK,OAAO,EAAE,OAAO,OAAO,GAAI,iBAAM;AAAA;AAAA,EACzC;AAEJ;","names":["import_react","import_react","import_jsx_runtime","import_react_native","import_jsx_runtime"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
// src/ring-buffer.ts
|
|
2
|
+
function createSnapshotRingBuffer(size, source) {
|
|
3
|
+
if (size <= 0 || !Number.isFinite(size)) {
|
|
4
|
+
throw new Error(`SnapshotRingBuffer size must be a positive finite number, got ${size}`);
|
|
5
|
+
}
|
|
6
|
+
const capacity = Math.floor(size);
|
|
7
|
+
const slots = new Array(capacity).fill(null);
|
|
8
|
+
let head = 0;
|
|
9
|
+
let count = 0;
|
|
10
|
+
return {
|
|
11
|
+
size: capacity,
|
|
12
|
+
get length() {
|
|
13
|
+
return count;
|
|
14
|
+
},
|
|
15
|
+
get latest() {
|
|
16
|
+
if (count === 0) return null;
|
|
17
|
+
const idx = (head - 1 + capacity) % capacity;
|
|
18
|
+
return slots[idx] ?? null;
|
|
19
|
+
},
|
|
20
|
+
capture() {
|
|
21
|
+
slots[head] = source();
|
|
22
|
+
head = (head + 1) % capacity;
|
|
23
|
+
if (count < capacity) count++;
|
|
24
|
+
},
|
|
25
|
+
rewind(framesAgo) {
|
|
26
|
+
if (framesAgo < 0 || !Number.isFinite(framesAgo)) return null;
|
|
27
|
+
const offset = Math.floor(framesAgo);
|
|
28
|
+
if (offset >= count) return null;
|
|
29
|
+
const idx = (head - 1 - offset + capacity * 2) % capacity;
|
|
30
|
+
return slots[idx] ?? null;
|
|
31
|
+
},
|
|
32
|
+
reset() {
|
|
33
|
+
for (let i = 0; i < capacity; i++) slots[i] = null;
|
|
34
|
+
head = 0;
|
|
35
|
+
count = 0;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/time-scrubber.ts
|
|
41
|
+
var TimeScrubber = class {
|
|
42
|
+
loop;
|
|
43
|
+
buffer;
|
|
44
|
+
restore;
|
|
45
|
+
_stepRequested = false;
|
|
46
|
+
_scrubFrames = 0;
|
|
47
|
+
constructor(options) {
|
|
48
|
+
this.loop = options.loop;
|
|
49
|
+
this.buffer = options.buffer;
|
|
50
|
+
this.restore = options.restore;
|
|
51
|
+
}
|
|
52
|
+
/** Whether the loop is currently paused. */
|
|
53
|
+
get paused() {
|
|
54
|
+
return this.loop.clock.timescale === 0;
|
|
55
|
+
}
|
|
56
|
+
/** Whether the scrubber is currently displaying a historical snapshot. */
|
|
57
|
+
get scrubbing() {
|
|
58
|
+
return this._scrubFrames > 0;
|
|
59
|
+
}
|
|
60
|
+
/** Current scrub offset (0 = latest, N = N frames back). */
|
|
61
|
+
get scrubOffset() {
|
|
62
|
+
return this._scrubFrames;
|
|
63
|
+
}
|
|
64
|
+
/** Pause the loop (timescale → 0). */
|
|
65
|
+
pause() {
|
|
66
|
+
this.loop.clock.timescale = 0;
|
|
67
|
+
}
|
|
68
|
+
/** Resume the loop at normal speed and clear any scrub state. */
|
|
69
|
+
resume() {
|
|
70
|
+
this.loop.clock.timescale = 1;
|
|
71
|
+
this._scrubFrames = 0;
|
|
72
|
+
this._stepRequested = false;
|
|
73
|
+
}
|
|
74
|
+
/** Request a single-frame step. Caller polls `consumeStep()` each frame. */
|
|
75
|
+
step() {
|
|
76
|
+
this._stepRequested = true;
|
|
77
|
+
}
|
|
78
|
+
/** Ring-buffer depth available for rewind. */
|
|
79
|
+
get available() {
|
|
80
|
+
return this.buffer.length;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Pause the loop and restore the snapshot from `framesAgo` captures back.
|
|
84
|
+
* Clamps to available history. Returns the snapshot applied, or `null`
|
|
85
|
+
* when the buffer is empty.
|
|
86
|
+
*/
|
|
87
|
+
rewind(framesAgo) {
|
|
88
|
+
if (framesAgo < 0 || !Number.isFinite(framesAgo)) return null;
|
|
89
|
+
const max = this.buffer.length - 1;
|
|
90
|
+
if (max < 0) return null;
|
|
91
|
+
const offset = Math.min(Math.floor(framesAgo), max);
|
|
92
|
+
const snap = this.buffer.rewind(offset);
|
|
93
|
+
if (snap === null) return null;
|
|
94
|
+
this.pause();
|
|
95
|
+
this._scrubFrames = offset;
|
|
96
|
+
if (this.restore) this.restore(snap);
|
|
97
|
+
return snap;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns true once per `step()` call, then resets. Frame-driver code is
|
|
101
|
+
* expected to advance the simulation by one fixed tick when this is true.
|
|
102
|
+
*/
|
|
103
|
+
consumeStep() {
|
|
104
|
+
if (!this._stepRequested) return false;
|
|
105
|
+
this._stepRequested = false;
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// src/context.ts
|
|
111
|
+
import { createContext } from "react";
|
|
112
|
+
var DevtoolsContext = createContext(null);
|
|
113
|
+
|
|
114
|
+
// src/provider.tsx
|
|
115
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
116
|
+
import { jsx } from "react/jsx-runtime";
|
|
117
|
+
var DEFAULT_CONFIG = {
|
|
118
|
+
ringSize: 120,
|
|
119
|
+
captureInterval: 1,
|
|
120
|
+
enabledOnNative: true
|
|
121
|
+
};
|
|
122
|
+
function DevtoolsProvider({
|
|
123
|
+
world,
|
|
124
|
+
loop,
|
|
125
|
+
snapshot,
|
|
126
|
+
restore,
|
|
127
|
+
config,
|
|
128
|
+
children
|
|
129
|
+
}) {
|
|
130
|
+
const ringSize = config?.ringSize ?? DEFAULT_CONFIG.ringSize;
|
|
131
|
+
const captureInterval = config?.captureInterval ?? DEFAULT_CONFIG.captureInterval;
|
|
132
|
+
const [selectedEntity, select] = useState(null);
|
|
133
|
+
const snapshotRef = useRef(snapshot);
|
|
134
|
+
snapshotRef.current = snapshot;
|
|
135
|
+
const restoreRef = useRef(restore);
|
|
136
|
+
restoreRef.current = restore;
|
|
137
|
+
const { buffer, scrubber } = useMemo(() => {
|
|
138
|
+
const buf = createSnapshotRingBuffer(ringSize, () => snapshotRef.current());
|
|
139
|
+
const scrub = new TimeScrubber({
|
|
140
|
+
loop,
|
|
141
|
+
buffer: buf,
|
|
142
|
+
restore: (s) => restoreRef.current?.(s)
|
|
143
|
+
});
|
|
144
|
+
return { buffer: buf, scrubber: scrub };
|
|
145
|
+
}, [loop, ringSize]);
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
let ticks = 0;
|
|
148
|
+
const unsub = loop.onUpdate.add(() => {
|
|
149
|
+
ticks++;
|
|
150
|
+
if (ticks % captureInterval === 0) buffer.capture();
|
|
151
|
+
});
|
|
152
|
+
return () => {
|
|
153
|
+
unsub();
|
|
154
|
+
};
|
|
155
|
+
}, [loop, buffer, captureInterval]);
|
|
156
|
+
const value = {
|
|
157
|
+
world,
|
|
158
|
+
loop,
|
|
159
|
+
buffer,
|
|
160
|
+
scrubber,
|
|
161
|
+
selectedEntity,
|
|
162
|
+
select,
|
|
163
|
+
pause: () => scrubber.pause(),
|
|
164
|
+
step: () => scrubber.step(),
|
|
165
|
+
resume: () => scrubber.resume()
|
|
166
|
+
};
|
|
167
|
+
return /* @__PURE__ */ jsx(DevtoolsContext.Provider, { value, children });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// src/hooks.ts
|
|
171
|
+
import { useContext } from "react";
|
|
172
|
+
function useDevtools() {
|
|
173
|
+
const ctx = useContext(DevtoolsContext);
|
|
174
|
+
if (!ctx) {
|
|
175
|
+
throw new Error("useDevtools must be used inside a <DevtoolsProvider>");
|
|
176
|
+
}
|
|
177
|
+
return ctx;
|
|
178
|
+
}
|
|
179
|
+
function useEntityInspector() {
|
|
180
|
+
const { world, selectedEntity, select } = useDevtools();
|
|
181
|
+
const entities = [];
|
|
182
|
+
const max = world.nextId ?? 0;
|
|
183
|
+
for (let id = 1; id < max; id++) {
|
|
184
|
+
if (world.exists(id)) entities.push(id);
|
|
185
|
+
}
|
|
186
|
+
return { selected: selectedEntity, select, entities };
|
|
187
|
+
}
|
|
188
|
+
function useTimeScrub() {
|
|
189
|
+
const { scrubber } = useDevtools();
|
|
190
|
+
return {
|
|
191
|
+
paused: scrubber.paused,
|
|
192
|
+
scrubbing: scrubber.scrubbing,
|
|
193
|
+
available: scrubber.available,
|
|
194
|
+
pause: () => scrubber.pause(),
|
|
195
|
+
resume: () => scrubber.resume(),
|
|
196
|
+
step: () => scrubber.step(),
|
|
197
|
+
rewind: (framesAgo) => {
|
|
198
|
+
scrubber.rewind(framesAgo);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// src/panel.tsx
|
|
204
|
+
import { Platform, Pressable, Text, View } from "react-native";
|
|
205
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
206
|
+
function DevtoolsPanel() {
|
|
207
|
+
if (Platform.OS !== "web") return null;
|
|
208
|
+
return /* @__PURE__ */ jsx2(PanelBody, {});
|
|
209
|
+
}
|
|
210
|
+
function PanelBody() {
|
|
211
|
+
const { buffer } = useDevtools();
|
|
212
|
+
const { entities, selected, select } = useEntityInspector();
|
|
213
|
+
const scrub = useTimeScrub();
|
|
214
|
+
return /* @__PURE__ */ jsxs(
|
|
215
|
+
View,
|
|
216
|
+
{
|
|
217
|
+
style: {
|
|
218
|
+
position: "absolute",
|
|
219
|
+
top: 8,
|
|
220
|
+
right: 8,
|
|
221
|
+
padding: 8,
|
|
222
|
+
backgroundColor: "rgba(0,0,0,0.75)",
|
|
223
|
+
borderRadius: 4,
|
|
224
|
+
minWidth: 200
|
|
225
|
+
},
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ jsx2(Text, { style: { color: "#fff", fontWeight: "bold" }, children: "Devtools" }),
|
|
228
|
+
/* @__PURE__ */ jsxs(Text, { style: { color: "#ccc" }, children: [
|
|
229
|
+
"buffer ",
|
|
230
|
+
buffer.length,
|
|
231
|
+
"/",
|
|
232
|
+
buffer.size
|
|
233
|
+
] }),
|
|
234
|
+
/* @__PURE__ */ jsxs(Text, { style: { color: "#ccc" }, children: [
|
|
235
|
+
scrub.paused ? "paused" : "running",
|
|
236
|
+
scrub.scrubbing ? " (scrub)" : ""
|
|
237
|
+
] }),
|
|
238
|
+
/* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", marginTop: 4 }, children: [
|
|
239
|
+
/* @__PURE__ */ jsx2(DevButton, { label: "Pause", onPress: scrub.pause }),
|
|
240
|
+
/* @__PURE__ */ jsx2(DevButton, { label: "Step", onPress: scrub.step }),
|
|
241
|
+
/* @__PURE__ */ jsx2(DevButton, { label: "Resume", onPress: scrub.resume })
|
|
242
|
+
] }),
|
|
243
|
+
/* @__PURE__ */ jsxs(View, { style: { marginTop: 8 }, children: [
|
|
244
|
+
/* @__PURE__ */ jsxs(Text, { style: { color: "#fff" }, children: [
|
|
245
|
+
"entities (",
|
|
246
|
+
entities.length,
|
|
247
|
+
")"
|
|
248
|
+
] }),
|
|
249
|
+
entities.slice(0, 20).map((id) => /* @__PURE__ */ jsx2(Pressable, { onPress: () => select(id), children: /* @__PURE__ */ jsxs(Text, { style: { color: id === selected ? "#ff0" : "#fff" }, children: [
|
|
250
|
+
"#",
|
|
251
|
+
id
|
|
252
|
+
] }) }, id))
|
|
253
|
+
] })
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
function DevButton({
|
|
259
|
+
label,
|
|
260
|
+
onPress
|
|
261
|
+
}) {
|
|
262
|
+
return /* @__PURE__ */ jsx2(
|
|
263
|
+
Pressable,
|
|
264
|
+
{
|
|
265
|
+
onPress,
|
|
266
|
+
style: {
|
|
267
|
+
paddingHorizontal: 6,
|
|
268
|
+
paddingVertical: 2,
|
|
269
|
+
marginRight: 4,
|
|
270
|
+
backgroundColor: "#444",
|
|
271
|
+
borderRadius: 2
|
|
272
|
+
},
|
|
273
|
+
children: /* @__PURE__ */ jsx2(Text, { style: { color: "#fff" }, children: label })
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// src/hud.tsx
|
|
279
|
+
import { Platform as Platform2, Pressable as Pressable2, Text as Text2, View as View2 } from "react-native";
|
|
280
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
281
|
+
function DevtoolsHUD() {
|
|
282
|
+
if (Platform2.OS === "web") return null;
|
|
283
|
+
return /* @__PURE__ */ jsx3(HUDBody, {});
|
|
284
|
+
}
|
|
285
|
+
function HUDBody() {
|
|
286
|
+
const { buffer } = useDevtools();
|
|
287
|
+
const scrub = useTimeScrub();
|
|
288
|
+
return /* @__PURE__ */ jsxs2(
|
|
289
|
+
View2,
|
|
290
|
+
{
|
|
291
|
+
style: {
|
|
292
|
+
position: "absolute",
|
|
293
|
+
bottom: 16,
|
|
294
|
+
right: 16,
|
|
295
|
+
flexDirection: "row",
|
|
296
|
+
alignItems: "center",
|
|
297
|
+
padding: 6,
|
|
298
|
+
backgroundColor: "rgba(0,0,0,0.75)",
|
|
299
|
+
borderRadius: 4
|
|
300
|
+
},
|
|
301
|
+
children: [
|
|
302
|
+
/* @__PURE__ */ jsxs2(Text2, { style: { color: "#fff", marginRight: 8 }, children: [
|
|
303
|
+
buffer.length,
|
|
304
|
+
"/",
|
|
305
|
+
buffer.size
|
|
306
|
+
] }),
|
|
307
|
+
/* @__PURE__ */ jsx3(HudButton, { label: "||", onPress: scrub.pause }),
|
|
308
|
+
/* @__PURE__ */ jsx3(HudButton, { label: ">|", onPress: scrub.step }),
|
|
309
|
+
/* @__PURE__ */ jsx3(HudButton, { label: ">", onPress: scrub.resume })
|
|
310
|
+
]
|
|
311
|
+
}
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
function HudButton({
|
|
315
|
+
label,
|
|
316
|
+
onPress
|
|
317
|
+
}) {
|
|
318
|
+
return /* @__PURE__ */ jsx3(
|
|
319
|
+
Pressable2,
|
|
320
|
+
{
|
|
321
|
+
onPress,
|
|
322
|
+
style: {
|
|
323
|
+
paddingHorizontal: 6,
|
|
324
|
+
paddingVertical: 2,
|
|
325
|
+
marginLeft: 4,
|
|
326
|
+
backgroundColor: "#444",
|
|
327
|
+
borderRadius: 2
|
|
328
|
+
},
|
|
329
|
+
children: /* @__PURE__ */ jsx3(Text2, { style: { color: "#fff" }, children: label })
|
|
330
|
+
}
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
export {
|
|
334
|
+
DevtoolsContext,
|
|
335
|
+
DevtoolsHUD,
|
|
336
|
+
DevtoolsPanel,
|
|
337
|
+
DevtoolsProvider,
|
|
338
|
+
TimeScrubber,
|
|
339
|
+
createSnapshotRingBuffer,
|
|
340
|
+
useDevtools,
|
|
341
|
+
useEntityInspector,
|
|
342
|
+
useTimeScrub
|
|
343
|
+
};
|
|
344
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ring-buffer.ts","../src/time-scrubber.ts","../src/context.ts","../src/provider.tsx","../src/hooks.ts","../src/panel.tsx","../src/hud.tsx"],"sourcesContent":["/**\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\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). */\n pause(): void {\n this.loop.clock.timescale = 0;\n }\n\n /** Resume the loop at normal speed and clear any scrub state. */\n resume(): void {\n this.loop.clock.timescale = 1;\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 { 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 pause(): void;\n step(): void;\n resume(): void;\n}\n\nexport const DevtoolsContext = createContext<DevtoolsContextValue | null>(null);\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 { type SnapshotSource, createSnapshotRingBuffer } 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 pause: () => scrubber.pause(),\n step: () => scrubber.step(),\n resume: () => scrubber.resume(),\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","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` does not expose an iterator; fall back to scanning the id range.\n // This is the 0.1.0 partial scope — a cheaper iterator may land in 0.2.0.\n const max = (world as unknown as { nextId?: number }).nextId ?? 0;\n for (let id = 1; id < max; id++) {\n if (world.exists(id)) entities.push(id);\n }\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, 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({\n label,\n onPress,\n}: {\n label: string;\n onPress: () => void;\n}): 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","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({\n label,\n onPress,\n}: {\n label: string;\n onPress: () => void;\n}): 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"],"mappings":";AA8BO,SAAS,yBACd,MACA,QACuB;AACvB,MAAI,QAAQ,KAAK,CAAC,OAAO,SAAS,IAAI,GAAG;AACvC,UAAM,IAAI,MAAM,iEAAiE,IAAI,EAAE;AAAA,EACzF;AACA,QAAM,WAAW,KAAK,MAAM,IAAI;AAChC,QAAM,QAAsB,IAAI,MAAM,QAAQ,EAAE,KAAK,IAAI;AACzD,MAAI,OAAO;AACX,MAAI,QAAQ;AAEZ,SAAO;AAAA,IACL,MAAM;AAAA,IACN,IAAI,SAAiB;AACnB,aAAO;AAAA,IACT;AAAA,IACA,IAAI,SAAmB;AACrB,UAAI,UAAU,EAAG,QAAO;AACxB,YAAM,OAAO,OAAO,IAAI,YAAY;AACpC,aAAO,MAAM,GAAG,KAAK;AAAA,IACvB;AAAA,IACA,UAAgB;AACd,YAAM,IAAI,IAAI,OAAO;AACrB,cAAQ,OAAO,KAAK;AACpB,UAAI,QAAQ,SAAU;AAAA,IACxB;AAAA,IACA,OAAO,WAA6B;AAClC,UAAI,YAAY,KAAK,CAAC,OAAO,SAAS,SAA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AC1B;AAAA,QACA,gBAAAJ,KAAC,aAAU,OAAM,MAAK,SAAS,MAAM,OAAO;AAAA,QAC5C,gBAAAA,KAAC,aAAU,OAAM,MAAK,SAAS,MAAM,MAAM;AAAA,QAC3C,gBAAAA,KAAC,aAAU,OAAM,KAAI,SAAS,MAAM,QAAQ;AAAA;AAAA;AAAA,EAC9C;AAEJ;AAEA,SAAS,UAAU;AAAA,EACjB;AAAA,EACA;AACF,GAGc;AACZ,SACE,gBAAAA;AAAA,IAACK;AAAA,IAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA,QACL,mBAAmB;AAAA,QACnB,iBAAiB;AAAA,QACjB,YAAY;AAAA,QACZ,iBAAiB;AAAA,QACjB,cAAc;AAAA,MAChB;AAAA,MAEA,0BAAAL,KAACI,OAAA,EAAK,OAAO,EAAE,OAAO,OAAO,GAAI,iBAAM;AAAA;AAAA,EACzC;AAEJ;","names":["jsx","Platform","Pressable","Text","View","jsx","jsxs","Platform","View","Text","Pressable"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flare-engine/devtools",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Devtools partial — entity inspector, time scrub, pause/step",
|
|
5
|
+
"keywords": ["flare-engine", "devtools", "inspector", "debug"],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Grzegorz Otto",
|
|
8
|
+
"homepage": "https://github.com/grzott/flare-engine#readme",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/grzott/flare-engine/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/grzott/flare-engine.git",
|
|
15
|
+
"directory": "packages/devtools"
|
|
16
|
+
},
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"module": "dist/index.mjs",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.mjs",
|
|
24
|
+
"require": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsup",
|
|
30
|
+
"test": "bun test",
|
|
31
|
+
"lint": "biome check src/",
|
|
32
|
+
"typecheck": "tsc --noEmit"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/react": "^18.0.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@flare-engine/core": "^0.1.0",
|
|
39
|
+
"@flare-engine/ecs": "^0.1.0",
|
|
40
|
+
"@flare-engine/events": "^0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": ">=18.0.0",
|
|
44
|
+
"react-native": ">=0.73.0"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "restricted",
|
|
48
|
+
"registry": "https://registry.npmjs.org/"
|
|
49
|
+
},
|
|
50
|
+
"sideEffects": false
|
|
51
|
+
}
|