/** * High-performance replay buffer for outgoing WebSocket data frames. * * Stores encoded frames keyed by monotonic sequence number for replay * on reconnect. Bounded by byte size — oldest entries are evicted when full. * Optionally also bounded by age — entries older than `maxAgeMs` are evicted * at push time, which matches the reconnect window: frames that arrived before * the reconnect deadline can never be replayed anyway. * * When `binaryMaxBytes` is provided, binary frames are stored in a separate * lane with its own byte budget. A large binary cannot evict text frames, * and a binary gap does not block text replay. * * Oversized frames are stored as `null` gap markers. `getAfter` stops at the * first gap per lane so the peer only receives a continuous run. * * Requires non-decreasing seq values (use `nextSeq()` / `pushFrame()` for normal operation). */ export declare class ReplayBuffer { private readonly text; private readonly binary; private readonly maxAgeMs; private _seq; private cleanupTimer; private cleanupScheduledAt; /** Current sequence number. */ get seq(): number; constructor(maxBytes: number, maxAgeMs: number, binaryMaxBytes: number); /** Increment and return the next sequence number. */ nextSeq(): number; /** * Convenience wrapper: advance the internal seq and push the frame. * Equivalent to `push(buf.nextSeq(), frame)`. */ pushFrame(frame: Uint8Array, isBinary?: boolean): boolean; /** * Store an already-encoded frame. * Oversized frames are stored as a `null` gap marker so `getAfter` stops there. * @returns `true` if the frame was stored, `false` if it was too large. */ push(seq: number, frame: Uint8Array, isBinary?: boolean): boolean; /** Get all frames with seq > afterSeq, stopping at the first gap per lane. * When binary lane is active, merge-iterates both lanes by seq order. */ getAfter(afterSeq: number): Uint8Array[]; /** * Eagerly evict expired entries without pushing a new frame. * Call this periodically on idle channels to return memory promptly. */ evict(now?: number): void; get length(): number; get byteLength(): number; dispose(): void; /** Schedule cleanup for the oldest entry's expiry. Skips if a timer already * fires at or before that deadline — new entries are always newer than existing * ones (FIFO), so the oldest entry never moves earlier on push. */ private scheduleCleanup; }