import React from "react";
import type { ErrorPhase } from "../types.js";
/**
 * Options for injectRSCPayload
 */
export interface InjectRSCPayloadOptions {
    /**
     * Nonce for Content Security Policy (CSP)
     */
    nonce?: string;
}
/**
 * Options for renderToReadableStream from react-dom/server
 */
interface RenderToReadableStreamOptions {
    bootstrapScriptContent?: string;
    nonce?: string;
    formState?: unknown;
}
/**
 * Options for the renderHTML function
 */
export interface SSRRenderOptions {
    /**
     * Form state for useActionState progressive enhancement.
     * This is the result of decodeFormState() and should be passed to
     * react-dom's renderToReadableStream to enable useActionState to
     * receive the action result during SSR.
     */
    formState?: unknown;
    /**
     * Nonce for Content Security Policy (CSP)
     */
    nonce?: string;
}
/**
 * SSR dependencies from external packages
 */
export interface SSRDependencies<TEnv = unknown> {
    /**
     * createFromReadableStream from @vitejs/plugin-rsc/ssr
     */
    createFromReadableStream: <T>(stream: ReadableStream<Uint8Array>) => Promise<T>;
    /**
     * renderToReadableStream from react-dom/server.edge
     */
    renderToReadableStream: (element: React.ReactNode, options?: RenderToReadableStreamOptions) => Promise<ReadableStream<Uint8Array>>;
    /**
     * injectRSCPayload from rsc-html-stream/server
     */
    injectRSCPayload: (rscStream: ReadableStream<Uint8Array>, options?: InjectRSCPayloadOptions) => TransformStream<Uint8Array, Uint8Array>;
    /**
     * Function to load bootstrap script content
     * Typically: () => import.meta.viteRsc.loadBootstrapScriptContent("index")
     */
    loadBootstrapScriptContent: () => Promise<string>;
    /**
     * Optional callback invoked when an error occurs during SSR rendering.
     *
     * This callback is for notification/logging purposes.
     *
     * @example
     * ```typescript
     * export const renderHTML = createSSRHandler({
     *   // ... other deps
     *   onError: (error, context) => {
     *     console.error('[SSR] Rendering error:', error);
     *     Sentry.captureException(error);
     *   },
     * });
     * ```
     */
    onError?: (error: Error, context: {
        phase: ErrorPhase;
    }) => void;
}
/**
 * Create an SSR handler that converts RSC streams to HTML.
 *
 * @example
 * ```tsx
 * import { createSSRHandler } from "rsc-router/ssr";
 * import { createFromReadableStream } from "@vitejs/plugin-rsc/ssr";
 * import { renderToReadableStream } from "react-dom/server.edge";
 * import { injectRSCPayload } from "rsc-html-stream/server";
 *
 * export const renderHTML = createSSRHandler({
 *   createFromReadableStream,
 *   renderToReadableStream,
 *   injectRSCPayload,
 *   loadBootstrapScriptContent: () =>
 *     import.meta.viteRsc.loadBootstrapScriptContent("index"),
 * });
 * ```
 */
export declare function createSSRHandler<TEnv = unknown>(deps: SSRDependencies<TEnv>): (rscStream: ReadableStream<Uint8Array>, options?: SSRRenderOptions) => Promise<ReadableStream<Uint8Array>>;
export {};
//# sourceMappingURL=index.d.ts.map