@flare-engine/devtools 0.2.0 → 0.3.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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/dev-mode.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 { isDevMode } from './dev-mode.js';\nexport {\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","declare const __DEV__: boolean | undefined;\n\nexport function isDevMode(): boolean {\n return typeof __DEV__ !== 'undefined' && Boolean(__DEV__);\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\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;AAAA;;;ACEO,SAAS,YAAqB;AACnC,SAAO,OAAO,YAAY,eAAe,QAAQ,OAAO;AAC1D;;;AC0BO,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,SAAS,EAAG,QAAO;AACzD,YAAM,SAAS,KAAK,MAAM,SAAS;AACnC,UAAI,UAAU,MAAO,QAAO;AAC5B,YAAM,OAAO,OAAO,IAAI,SAAS,WAAW,KAAK;AACjD,aAAO,MAAM,GAAG,KAAK;AAAA,IACvB;AAAA,IACA,QAAc;AACZ,eAAS,IAAI,GAAG,IAAI,UAAU,IAAK,OAAM,CAAC,IAAI;AAC9C,aAAO;AACP,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K,OAAO,EAAE,OAAO,OAAO,GAAI,iBAAM;AAAA;AAAA,EACzC;AAEJ;","names":["import_react","import_react","import_jsx_runtime","import_react_native","import_jsx_runtime"]}
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 pause(): void;\n step(): void;\n resume(): 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 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"],"mappings":";;;;;AA6BA,MAAa,mBAAA,GAAA,MAAA,cAAA,CAA6D,IAAI;;;AC3B9E,SAAgB,YAAqB;CACnC,OAAO,OAAO,YAAY,eAAe,QAAQ,OAAO;AAC1D;;;;ACAA,SAAgB,cAAoC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