/** * Bounded transition history log for the state inspector. * * Maintains a ring-buffer of the most recent N state transitions. * When the buffer is full, oldest entries are evicted (FIFO). * All operations are O(1) amortised. * * State inspector transition log. */ import type { TransitionEntry } from './types.js'; /** * BoundedTransitionLog, a fixed-capacity log of state transitions. * * Each call to `append()` stores a new entry. When capacity is exceeded, the * oldest entry is evicted; `totalAppended - size` exposes the eviction count. */ export declare class BoundedTransitionLog { private readonly _maxSize; /** Circular buffer storage. */ private readonly _entries; /** Index at which the next write will occur. */ private _head; /** Total number of entries ever appended (not capped at _maxSize). */ private _totalAppended; /** Monotonic entry ID counter. */ private _nextId; /** * @param maxSize - Maximum number of entries to retain. Must be >= 1. * @default DEFAULT_MAX_TRANSITIONS */ constructor(maxSize?: number); /** Maximum number of entries this log can retain. */ get maxSize(): number; /** Total entries ever appended (monotonically increasing). */ get totalAppended(): number; /** Number of entries currently retained (capped at maxSize). */ get size(): number; /** * Append a new transition to the log. * Evicts the oldest entry if the buffer is full. * * @param entry - The transition entry to record (without an `id`). * The `id` field is assigned by the log. * @returns The stored TransitionEntry with its assigned `id`. */ append(entry: Omit): TransitionEntry; /** * Return all retained entries in chronological order (oldest → newest). * * Performance note: allocates a new array per call. At the default * maxSize of 1000 this is acceptable for devtools use. Direct ring-buffer * iteration without allocation is a follow-up optimisation if needed. * * @returns Ordered array of TransitionEntry. */ getAll(): TransitionEntry[]; /** * Return entries filtered by domain name. * * @param domain - Domain to filter by. * @returns Ordered entries for the given domain. */ getByDomain(domain: string): TransitionEntry[]; /** * Return entries recorded at or after a given epoch ms timestamp. * * @param sinceMs - Inclusive lower bound (epoch ms). * @returns Ordered entries at or after the timestamp. */ getSince(sinceMs: number): TransitionEntry[]; /** * Return the N most recent entries. * * @param n - Number of entries to return. * @returns Slice of at most N entries, most recent last. */ getLast(n: number): TransitionEntry[]; /** * Clear all retained entries and reset counters. * The capacity remains unchanged. */ clear(): void; } //# sourceMappingURL=transition-log.d.ts.map