import type { PreviewSession } from './index.js';
import { encodeSseEvent } from '../realtime/sse.js';
export { encodeSseEvent };
/**
 * Default keepalive interval. 25 s sits safely under the most aggressive
 * proxy/idle timeouts we've encountered in production (Cloudflare 30 s,
 * Vercel Serverless 30 s, most reverse-proxies 60 s).
 */
export declare const PREVIEW_SSE_HEARTBEAT_MS = 25000;
/**
 * Maximum stream lifetime in ms. After this, the server closes the stream
 * cleanly so EventSource will reconnect — important because some platforms
 * (Vercel Fluid Compute, Cloudflare Workers) cap any single response at a
 * few minutes regardless of activity.
 */
export declare const PREVIEW_SSE_MAX_LIFETIME_MS: number;
export interface PreviewStreamOptions {
    /** Override for tests so we don't have to wait 25 seconds. */
    heartbeatMs?: number;
    /** Override for tests so we don't tie up the suite for 4 minutes. */
    maxLifetimeMs?: number;
}
/**
 * Build a `ReadableStream` of Server-Sent Events for the given preview
 * session. The stream:
 *
 *   1. Emits an `event: ready` frame with the session's collection/id.
 *      Lets the client confirm the server-side subscription is wired up
 *      before it starts treating the absence of events as "stale".
 *   2. Forwards every `notifyPreviewUpdate(collection, id, payload)` to
 *      the client as `event: update` with `payload` as JSON data.
 *   3. Sends `: heartbeat\n\n` keepalive comments on
 *      `PREVIEW_SSE_HEARTBEAT_MS` intervals.
 *   4. Cleanly closes after `PREVIEW_SSE_MAX_LIFETIME_MS` and lets the
 *      browser reconnect, sidestepping platform idle/max-duration caps.
 *
 * The returned stream MUST be wrapped in a `Response` with the SSE
 * headers — `createPreviewStreamResponse` does this for typical callers.
 */
export declare function createPreviewStream(session: Pick<PreviewSession, 'collection' | 'documentId'>, opts?: PreviewStreamOptions): ReadableStream<Uint8Array>;
/**
 * Standard SSE response headers. Exposed for callers (and tests) that want
 * to wrap the stream themselves.
 */
export declare const PREVIEW_SSE_HEADERS: Record<string, string>;
export declare function createPreviewStreamResponse(session: Pick<PreviewSession, 'collection' | 'documentId'>, opts?: PreviewStreamOptions): Response;
//# sourceMappingURL=sse-stream.d.ts.map