/** * Timeline buffer for state inspector time-travel. * * Maintains a bounded circular buffer of timeline events. Each event records * a full domain snapshot so an operator can step backward/forward through * state history without re-running mutations. * * Step controls: * - `stepBack()` / `stepForward()`, move the cursor one position. * - `seekTo(index)`, jump to an absolute index. * - `seekToTime(epochMs)`, seek to the nearest event at or before a timestamp. * - `exitTimeTravel()`, return the cursor to the live tail. * * The "live" position is represented as cursor === size (one past the last * stored event). When live, `getCurrentSnapshot()` returns undefined, signalling * that callers should use the inspector's live snapshot instead. */ import type { TimelineEvent, TimeTravelCursor } from './types.js'; /** * TimelineBuffer, fixed-capacity ring buffer of TimelineEvent snapshots. * * Indices are stable within a session (they increment monotonically via * the `seq` field on each event). The cursor is an offset into the live * ring: 0 = oldest retained, size-1 = newest, size = live. */ export declare class TimelineBuffer { private readonly _maxSize; private readonly _ring; private _head; private _totalAppended; private _cursor; private _nextSeq; /** * @param maxSize, Maximum events to retain. Must be >= 2. * @default DEFAULT_TIMELINE_BUFFER_SIZE */ constructor(maxSize?: number); /** Maximum events retained. */ get maxSize(): number; /** Current number of events retained (capped at maxSize). */ get size(): number; /** Total events ever appended (monotonically increasing). */ get totalAppended(): number; /** * Whether the cursor is at the live position (past the newest event). * When live, `getCurrentSnapshot()` returns undefined. */ get isLive(): boolean; /** Current cursor state for display. */ get cursorState(): TimeTravelCursor; /** * Append a new timeline event. * * If the cursor is live it advances with the tail (stays live). * If the cursor is pinned (time-travel mode), it stays pinned. * * @param event, Event without `seq` (assigned here). * @returns The stored TimelineEvent with its assigned `seq`. */ append(event: Omit): TimelineEvent; /** * Return all retained events in chronological order. * * @returns Events oldest → newest. */ getAll(): TimelineEvent[]; /** * Return the event at a logical index (0 = oldest, size-1 = newest). * * @returns TimelineEvent or undefined when out of range. */ getAt(index: number): TimelineEvent | undefined; /** * Return the event at the current cursor position, or undefined when live. */ getCurrentEvent(): TimelineEvent | undefined; /** * Step the cursor one event backward (toward oldest). * If already at index 0, the cursor stays at 0. * * @returns true if the cursor moved. */ stepBack(): boolean; /** * Step the cursor one event forward (toward live). * When the cursor reaches the live position (past the newest event), * `isLive` becomes true. * * @returns true if the cursor moved. */ stepForward(): boolean; /** * Seek the cursor to an absolute logical index. * Clamps to [0, size] where size === live. * * @param index, Target index (size = live). */ seekTo(index: number): void; /** * Seek to the nearest event at or before a given epoch ms timestamp. * If no events exist before the timestamp, seeks to index 0. * If all events are before or equal, seeks to the newest. * * @param epochMs, Target timestamp. */ seekToTime(epochMs: number): void; /** * Return the cursor to the live tail (exit time-travel mode). */ exitTimeTravel(): void; /** * Clear all retained events and reset to live position. */ clear(): void; } //# sourceMappingURL=timeline.d.ts.map