import type { RouteIntentData } from '../isomorphic-utils/router-protocol.js'; export type HandlerInterceptor = (next: () => Promise) => Promise; export type ServerFunctionContext = { origin: readonly [rscPath: string, rscParams: unknown] | undefined; refreshRequested: boolean; legacyTarget?: readonly [rscPath: string, rscParams: unknown]; }; type RouterStore = { req: Request; rscPath?: string; rscParams?: unknown; serverFunction?: ServerFunctionContext | undefined; nonce?: string; intent?: ReturnType; }; declare const createRouteIntent: (signal: AbortSignal) => { promise: PromiseLike; readonly value: RouteIntentData | undefined; record(intent: RouteIntentData): void; }; export declare function getRouteIntent(): { promise: PromiseLike; readonly value: RouteIntentData | undefined; record(intent: RouteIntentData): void; }; export declare function runWithRouterStore(store: RouterStore, fn: () => T): T; /** * Access the request being handled. Available while the router handles a * request or builds a page: in a render, a server function, an API route * handler, a handler interceptor, or `unstable_defineRouter`'s `resolve`. * Throws if called outside that scope, such as at module scope. * * `url` is the URL the request was sent to, which is Waku's RSC URL after a * client navigation, so read the route with `unstable_parseRouterRequest`. A * server function called from the client gets a request that identifies no * route, so pass it any route data it needs as arguments. Inside an API route * handler, the handler's own `req` has its pathname relative to the base path * and shares this request's body, so read the body from it. A static render * runs at build time against a synthetic request, so read request data only in * dynamic renders. * * @example * import { getRequest } from 'waku/router/server'; * * const Country = () => { * const country = getRequest().headers.get('cf-ipcountry') ?? 'unknown'; * return

{country}

; * }; */ export declare function getRequest(): Request; export declare function setRscPath(rscPath: string): void; export declare function setRscParams(rscParams: unknown): void; export declare function getRscPath(): string | undefined; export declare function getRscParams(): unknown; export declare function setServerFunctionContext(context: ServerFunctionContext | undefined): void; export declare function getServerFunctionContext(): ServerFunctionContext; /** * Set the nonce applied to framework inline scripts for the current request. * Call this from a handler interceptor (e.g. bridging a Hono middleware's * generated nonce) before rendering. */ export declare function setNonce(nonce: string): void; export declare function getNonce(): string | undefined; export {};