import type { Component, ComponentInstance } from './component.js'; import type { QueryClient } from './query.js'; import type { RouteDescriptor } from './route.js'; export interface SSRContext { url?: string | null; location?: { pathname: string; search: string; hash: string; state: unknown; }; pending?: Set>; resourceCache?: Map; routeState?: unknown; queryState?: unknown; head?: Map; [key: string]: unknown; } export interface HeadEntry { key: string; tag: string; props: Record; } export declare function renderToString( Component: Component, props?: Record, options?: { url?: string } ): string; /** * Await Suspense-tracked promises (`lazy`, `createResource`), then return HTML * with resolved content (not the fallback). */ export declare function renderToStringAsync( Component: Component, props?: Record, options?: { url?: string; maxPasses?: number } ): Promise; export declare function wrapHtmlDocument( body: string, options?: DocumentOptions ): string; export interface DocumentOptions { title?: string | false; /** Escaped text inserted into head. Use unsafeHead only for trusted markup. */ head?: string; unsafeHead?: string; managedHead?: string; scripts?: Array>; state?: unknown; stateId?: string; context?: SSRContext; nonce?: string; } export declare function serializeDocumentState(value: unknown): string; export declare function renderDocument( body: string, options?: DocumentOptions ): string; export declare function hydrate( Component: Component, container: Element, props?: Record ): ComponentInstance; export declare function runWithSSR( fn: () => T | Promise, context?: SSRContext ): T | Promise; export declare function getSSRContext(): SSRContext | null; export declare function createSSRContext(context?: SSRContext): SSRContext; export declare function setSSRContextStorage(storage: { getStore(): SSRContext | undefined; run(context: SSRContext, fn: () => T): T; }): void; export declare function isServer(): boolean; export declare function escapeHtml(value: unknown): string; export declare function serializeVnode( vdom: unknown, renderComponent: (type: Component, props: Record) => unknown ): string; export interface HeadProps { children?: unknown; key?: string; [key: string]: unknown; } export declare function Head(props: HeadProps): unknown; export declare function Title(props: HeadProps): null; export declare function Meta(props: HeadProps): null; export declare function HeadLink(props: HeadProps): null; export declare function Canonical(props: HeadProps): null; export declare function JsonLd(props: HeadProps & { value?: unknown }): null; export declare function OpenGraph(props: Record): unknown; export declare function applyRouteHeadEntries( metadata: Record[] ): void; export declare function registerHeadEntry( tag: string, props?: HeadProps ): string; export declare function renderHead(context?: SSRContext | null): string; export type GrainletReadableStream = ReadableStream & { shellReady: Promise; allReady: Promise; }; export interface StreamRenderOptions { context?: SSRContext; document?: DocumentOptions; nonce?: string; onAllReady?: () => void; onError?: (error: unknown) => void; onShellReady?: () => void; queryState?: unknown; request?: Request; routeState?: unknown; signal?: AbortSignal; state?: unknown | (() => unknown); stateId?: string; url?: string; } export declare function renderToReadableStream( Component: Component, props?: Record, options?: StreamRenderOptions ): GrainletReadableStream; export interface RequestHandlerOptions { App: Component>; routes?: RouteDescriptor[]; basename?: string; createQueryClient?: (args: { request: Request; platformContext: unknown; }) => QueryClient; document?: DocumentOptions; errorDocument?: (error: unknown) => string; nonce?: (args: { request: Request; platformContext: unknown }) => string; onError?: (error: unknown, request: Request) => void; props?: Record; streaming?: boolean; } export declare function createRequestHandler( options: RequestHandlerOptions ): (request: Request, platformContext?: unknown) => Promise; export declare function createNodeHandler( options: RequestHandlerOptions ): ( request: { method?: string; url?: string; headers: Record; socket?: { encrypted?: boolean }; once(event: string, listener: () => void): void; [Symbol.asyncIterator](): AsyncIterator; }, response: { statusCode: number; destroyed?: boolean; setHeader(name: string, value: string): void; write(chunk: Uint8Array): boolean; end(): void; destroy(error?: unknown): void; once(event: string, listener: () => void): void; }, platformContext?: unknown ) => Promise; export interface PrerenderResult { body: string; headers: Record; status: number; } export interface PrerenderOptions extends RequestHandlerOptions { origin?: string; paths?: string[] | (() => string[] | Promise); } export declare function prerenderPaths( options: PrerenderOptions ): Promise>; export declare function writePrerendered( options: PrerenderOptions & { outDir: string } ): Promise<{ manifest: Record; manifestPath: string; }>;