export { ServerChannelBuffer }; /** Callback pair for buffered entries — resolve on flush, reject on eviction. */ type EntryCallback = { resolve: (...args: any[]) => void; reject: (err: Error) => void; }; /** * Hard-capped ring buffer for channel messages sent before the client connects. * * Buffers text, publish, binary, and ack-request messages sent before the client connects. * After every push, oldest entries are evicted (FIFO) until the byte * total is within the cap. Delivery callbacks on evicted entries are rejected * immediately so channel memory stays hard-capped. * * Binary messages (tags 1 and 4) are stored in a separate lane with its own * byte budget. An oversized binary only clears the binary lane — text messages * are never affected. * * A single message larger than its lane's maxBytes causes that lane to be * cleared and the message dropped — sequential delivery is paramount; * a gap in the middle is never acceptable, so the lane resets to a * clean slate instead. * * Sequential delivery is guaranteed: flush() sends all buffered messages * in insertion order by merge-iterating both lanes. There are no gaps or null markers. */ declare class ServerChannelBuffer { #private; constructor(maxBytes: number, binaryMaxBytes: number); get byteLength(): number; get size(): number; pushText(data: string, resolve: () => void, reject: (err: Error) => void): void; pushTextAck(data: string, resolve: (value: TAck) => void, reject: (err: Error) => void): void; pushPublish(data: string): void; pushBinary(data: Uint8Array, resolve: () => void, reject: (err: Error) => void): void; pushBinaryAck(data: Uint8Array, resolve: (value: unknown) => void, reject: (err: Error) => void): void; pushPublishBinary(data: Uint8Array): void; /** * Flush all buffered messages to the client connection in insertion order, then clear. * Merge-iterates text and binary lanes by insertion order so the caller * sees the same sequence as if both lanes were a single interleaved buffer. */ flush(handlers: { sendText: (data: string) => void; sendPublish: (data: string) => void; sendBinary: (data: Uint8Array) => void; sendTextAck: (data: string, cb: EntryCallback) => void; sendBinaryAck: (data: Uint8Array, cb: EntryCallback) => void; sendPublishBinary: (data: Uint8Array) => void; }): void; clear(err?: Error): void; }