type SlotResolver = () => Promise<string> | string;
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?: string;
    errorHtml?: string;
    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?: string;
    fallbackHtml?: string;
    id: string;
    timeoutMs?: number;
    resolve: SlotResolver;
};
type DeferredStreamingSlot = Omit<StreamingSlot, 'id'> & {
    id?: string;
};
export type AppendStreamingSlotsOptions = {
    injectRuntime?: boolean;
    nonce?: string;
    policy?: StreamingSlotPolicy;
    onSlotMetric?: StreamingSlotMetricHandler;
    onError?: (error: unknown, slot: StreamingSlot) => void;
};
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 renderStreamingSlotsRuntimeTag: (nonce?: string) => string;
export declare const renderStreamingSlotPlaceholder: (id: string, fallbackHtml?: string) => string;
export declare const renderStreamingSlotPatchTag: (id: string, html: string, nonce?: string) => string;
export declare const injectHtmlIntoHead: (html: string, injection: string) => string;
export declare const getStreamingSlotPolicy: () => StreamingSlotPolicyValue;
export declare const setStreamingSlotPolicy: (policy?: StreamingSlotPolicy) => void;
export declare const withStreamingSlotPolicy: <T>(policy: StreamingSlotPolicy, callback: () => Promise<T> | T) => Promise<T>;
export declare const streamOutOfOrderSlots: ({ footerHtml, headerHtml, nonce, policy, onSlotMetric, onError, slots }: StreamOutOfOrderSlotsOptions) => ReadableStream<Uint8Array<ArrayBufferLike>>;
export declare const injectStreamingRuntimeIntoStream: (stream: ReadableStream<string | Uint8Array>, nonce?: string) => ReadableStream<Uint8Array<ArrayBufferLike>>;
export declare const appendStreamingSlotPatchesToStream: (stream: ReadableStream<string | Uint8Array>, slots?: DeferredStreamingSlot[], { injectRuntime, nonce, onError, onSlotMetric, policy }?: AppendStreamingSlotsOptions) => ReadableStream<string | Uint8Array<ArrayBufferLike>>;
export {};
