import { t as HeadersRecord } from "./http-well-known-BK9MGKQf.js"; import { i as RetryOptions, t as EventEmitter } from "./emitter-yGbfYzOM.js"; //#region src/core/sse-client.d.ts /** * Configuration for {@link SSEClient}. * * @example * const sse = new SSEClient({ * url: 'https://api.example.com/events', * withCredentials: true, * reconnect: { maxRetries: 5, initialDelayMs: 1000 }, * }); * sse.on('message', (e) => console.log(e.data)); */ interface SSEConfig { /** The SSE endpoint URL. */ url: string; /** * Whether to send cookies and auth headers with the EventSource request * (equivalent to `withCredentials` on `XMLHttpRequest`). * @default false */ withCredentials?: boolean; /** * Automatic reconnect behaviour when the stream closes unexpectedly. * Pass `true` for defaults (5 retries, exponential back-off) or a * `RetryOptions` object to customise. * @default false */ reconnect?: boolean | RetryOptions; /** * Additional request headers. * * **Note:** The native browser `EventSource` API does not support custom * headers. This field is forwarded only when a fetch-based SSE polyfill * is in use. Common header names are suggested by IntelliSense. * * @example * headers: { Authorization: 'Bearer ' } */ headers?: HeadersRecord; } type SSEEvents = { open: [Event]; error: [Event]; message: [MessageEvent]; reconnect: [number]; 'reconnect:fail': [Error]; [key: string]: unknown[]; }; declare class SSEClient extends EventEmitter { private config; private eventSource; private reconnectAttempts; private isExplicitlyClosed; constructor(config: SSEConfig); connect(): void; close(): void; /** * Add a listener for a specific event type */ addEventListener(type: string, listener: (event: MessageEvent) => void): void; /** * Remove a listener for a specific event type */ removeEventListener(type: string, listener: (event: MessageEvent) => void): void; private setupListeners; private handleReconnect; private handleConnectionError; } //#endregion export { SSEConfig as n, SSEEvents as r, SSEClient as t }; //# sourceMappingURL=sse-client-DAMKkFYS.d.ts.map