type SlotResolver = () => Promise | unknown; type SlotErrorHandler = (error: unknown, slot: StreamingSlot) => void; export type StreamingSlotMetricType = 'prepared' | 'dropped' | 'resolved' | 'patched' | 'timeout' | 'size_exceeded' | 'error'; export type StreamingSlotMetric = { type: StreamingSlotMetricType; slotId: string; durationMs?: number; bytes?: number; reason?: string; error?: unknown; }; export type StreamingSlotMetricHandler = (metric: StreamingSlotMetric) => void; export type StreamingSlotPolicy = { timeoutMs?: number; fallbackHtml?: unknown; errorHtml?: unknown; maxSlotsPerResponse?: number; maxSlotHtmlSizeBytes?: number; onError?: SlotErrorHandler; onSlotMetric?: StreamingSlotMetricHandler; }; type StreamingSlotPolicyValue = { timeoutMs: number; fallbackHtml: string; errorHtml?: string; maxSlotsPerResponse: number; maxSlotHtmlSizeBytes: number; onError?: SlotErrorHandler; onSlotMetric?: StreamingSlotMetricHandler; }; export type StreamingSlot = { errorHtml?: unknown; fallbackHtml?: unknown; id: string; timeoutMs?: number; resolve: SlotResolver; }; export type StreamingSlotPatchPayload = string | { [key: string]: unknown; html: string; }; type DeferredStreamingSlot = Omit & { id?: string; }; export type AppendStreamingSlotsOptions = { injectRuntime?: boolean; nonce?: string; runtimePreludeScript?: string; policy?: StreamingSlotPolicy; onSlotMetric?: StreamingSlotMetricHandler; onError?: (error: unknown, slot: StreamingSlot) => void; runtimePlacement?: 'body' | 'head'; }; export type StreamOutOfOrderSlotsOptions = { footerHtml?: string; headerHtml?: string; nonce?: string; policy?: StreamingSlotPolicy; onSlotMetric?: StreamingSlotMetricHandler; onError?: (error: unknown, slot: StreamingSlot) => void; slots: DeferredStreamingSlot[]; }; export declare const createStreamingSlotId: () => string; export declare const getStreamingSlotsRuntimeScript: () => string; export declare const injectHtmlIntoBody: (html: string, injection: string) => string; export declare const injectHtmlIntoHead: (html: string, injection: string) => string; export declare const renderStreamingSlotPatchTag: (id: string, payload: StreamingSlotPatchPayload, nonce?: string) => string; export declare const renderStreamingSlotPlaceholder: (id: string, fallbackHtml?: string) => string; export declare const renderStreamingSlotsRuntimeTag: (nonce?: string, runtimePreludeScript?: string) => string; export declare const getStreamingSlotPolicy: () => StreamingSlotPolicyValue; export declare const setStreamingSlotPolicy: (policy?: StreamingSlotPolicy) => void; export declare const withStreamingSlotPolicy: (policy: StreamingSlotPolicy, callback: () => Promise | T) => Promise; export declare const appendStreamingSlotPatchesToStream: (stream: ReadableStream, slots?: DeferredStreamingSlot[], { injectRuntime, nonce, onError, onSlotMetric, policy, runtimePreludeScript, runtimePlacement }?: AppendStreamingSlotsOptions) => ReadableStream>; export declare const injectStreamingRuntimeIntoStream: (stream: ReadableStream, nonce?: string, runtimePlacement?: "body" | "head", runtimePreludeScript?: string) => ReadableStream>; export declare const streamOutOfOrderSlots: ({ footerHtml, headerHtml, nonce, policy, onSlotMetric, onError, slots }: StreamOutOfOrderSlotsOptions) => ReadableStream>; export {};