export type EventOverflowPolicy = "close" | "drop_oldest" | "drop_newest"; export declare const EVENT_MULTIPLEXER_SINGLE_CONSUMER_CODE = "ERR_PRISM_EVENT_MULTIPLEXER_SINGLE_CONSUMER"; /** Thrown when a second consumer subscribes while one is active (single-consumer contract). */ export declare class EventMultiplexerError extends Error { readonly code = "ERR_PRISM_EVENT_MULTIPLEXER_SINGLE_CONSUMER"; constructor(message?: string); } export interface EventOverflowInfo { readonly droppedEvents: number; readonly maxQueuedEvents: number; readonly policy: EventOverflowPolicy; } export interface EventMultiplexerOptions { readonly maxQueuedEvents?: number; readonly overflow?: EventOverflowPolicy; readonly overflowEvent?: (info: EventOverflowInfo) => T; readonly compare?: (a: T, b: T) => number; readonly signal?: AbortSignal; } export interface EventMultiplexer { publish(event: T): void; observe(source: AsyncIterable, map: (event: S) => T): () => void; /** * Single-consumer subscription. A second concurrent subscriber is rejected with * `EventMultiplexerError` (ERR_PRISM_EVENT_MULTIPLEXER_SINGLE_CONSUMER); the slot * frees when the active consumer's iterator completes or is `return()`ed at a * yield, or when the multiplexer closes. A consumer parked awaiting an event is * released by the next `publish`/`close` — `return()` while parked waits for it. */ subscribe(): AsyncIterable; close(): void; readonly droppedEvents: number; readonly closed: boolean; } /** Bounded single-consumer fan-in for arbitrary async event sources. */ export declare function createEventMultiplexer(options?: EventMultiplexerOptions): EventMultiplexer;