interface SSEOptions { readonly withCredentials?: boolean; readonly eventSource?: SSEConstructor; readonly onOpen?: (event: Event) => void; readonly onMessage?: (event: MessageEvent) => void; readonly onError?: (event: Event) => void; } interface SSEClient { readonly source: EventSource; close(): void; } type SSEConstructor = new (url: string, options?: EventSourceInit) => EventSource; declare function createSSE(url: string, options?: SSEOptions): SSEClient; interface WebSocketOptions { readonly protocols?: string | readonly string[]; readonly webSocket?: WebSocketConstructor; readonly autoReconnect?: boolean; readonly reconnectDelay?: number; } interface WebSocketClient { readonly socket: WebSocket | null; readonly state: WebSocketState; connect(): void; send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void; close(code?: number, reason?: string): void; on(event: K, listener: WebSocketEventListener): () => void; } type WebSocketState = 'idle' | 'connecting' | 'open' | 'closed'; type WebSocketEventName = 'open' | 'message' | 'error' | 'close'; type WebSocketEventListener = K extends 'message' ? (event: MessageEvent) => void : K extends 'close' ? (event: CloseEvent) => void : (event: Event) => void; type WebSocketConstructor = new (url: string, protocols?: string | string[]) => WebSocket; declare function createWebSocket(url: string, options?: WebSocketOptions): WebSocketClient; export { type SSEClient, type SSEConstructor, type SSEOptions, type WebSocketClient, type WebSocketConstructor, type WebSocketEventListener, type WebSocketEventName, type WebSocketOptions, type WebSocketState, createSSE, createWebSocket };