import React from "react"; import type { RscPayload, RscBrowserDependencies, NavigationStore, NavigationBridge } from "./types.js"; import type { EventController } from "./event-controller.js"; import type { ResolvedThemeConfig, Theme } from "../theme/types.js"; /** * Options for initializing the browser app */ export interface InitBrowserAppOptions { /** * RSC stream containing the initial payload (from rsc-html-stream/client) */ rscStream: ReadableStream; /** * RSC browser dependencies from @vitejs/plugin-rsc/browser */ deps: RscBrowserDependencies; /** * Optional store configuration */ storeOptions?: { /** * Maximum number of history entries to cache * @default 10 */ cacheSize?: number; }; /** * Enable global link interception for SPA navigation. * When enabled, clicks on same-origin anchor elements are intercepted * and handled via client-side navigation instead of full page loads. * * Links rendered with the Link component handle their own navigation * regardless of this setting. * * Set to false to disable global interception and rely solely on * Link components for SPA navigation. * * @default true */ linkInterception?: boolean; /** * Theme configuration from router. * When provided, enables theme support via useTheme hook. * Pass router.themeConfig here to enable theme features. * * @example * ```tsx * import { router } from "./router.js"; * * await initBrowserApp({ * rscStream, * deps: rscBrowser, * themeConfig: router.themeConfig, * initialTheme: document.documentElement.className.includes("dark") ? "dark" : "light", * }); * ``` */ themeConfig?: ResolvedThemeConfig | null; /** * Initial theme from server (typically read from cookie). * Only used when themeConfig is provided. */ initialTheme?: Theme; } /** * Result from initializing the browser app */ export interface BrowserAppContext { store: NavigationStore; eventController: EventController; bridge: NavigationBridge; initialPayload: RscPayload; initialTree: React.ReactNode | Promise; /** Theme configuration (null if theme not enabled) */ themeConfig?: ResolvedThemeConfig | null; /** Initial theme from server */ initialTheme?: Theme; /** Whether connection warmup is enabled */ warmupEnabled?: boolean; } /** * Initialize the browser app. Must be called before rendering RSCRouter. * * This function: * - Loads the initial RSC payload from the stream * - Creates the navigation store and event controller * - Sets up action and navigation bridges * - Configures HMR support */ export declare function initBrowserApp(options: InitBrowserAppOptions): Promise; /** * Get the browser app context. Throws if initBrowserApp hasn't been called. */ export declare function getBrowserAppContext(): BrowserAppContext; /** * Reset the browser app context (for testing) */ export declare function resetBrowserAppContext(): void; /** * Props for the RSCRouter component */ export interface RSCRouterProps { } /** * RSCRouter component - renders the RSC router with all internal wiring. * * Must be called after initBrowserApp() has completed. * * @example * ```tsx * import { initBrowserApp, RSCRouter } from "rsc-router/browser"; * import { rscStream } from "rsc-html-stream/client"; * import * as rscBrowser from "@vitejs/plugin-rsc/browser"; * * async function main() { * await initBrowserApp({ rscStream, deps: rscBrowser }); * * hydrateRoot( * document, * * * * ); * } * main(); * ``` */ export declare function RSCRouter(_props: RSCRouterProps): React.ReactElement; //# sourceMappingURL=rsc-router.d.ts.map