import type { Unstable_RscEnhancer } from 'waku/minimal/client'; import type { RouteProps } from '../isomorphic-utils/route-path.js'; import { useRouterCache } from './caches.js'; type ServerFunctionRoutingCallbacks = { getSettledRoute: () => RouteProps; getPendingRoute: () => Pick | undefined; applyRouteResponse: (elements: Readonly>) => void | Promise; }; /** * Holds one Root's server function routing policy and its committed * navigation callbacks. */ export type ServerFunctionRouting = { enhancer: Unstable_RscEnhancer; /** * Cleanup disconnects only this connection. Prefer * `useServerFunctionRouting_UNSTABLE`. */ connect: (connection: ServerFunctionRoutingCallbacks & { cache: ReturnType; }) => () => void; }; /** * Creates server function routing for one custom router. Install `enhancer` * last in that router's Root `rscEnhancers`, then connect navigation * callbacks with `useServerFunctionRouting_UNSTABLE` beneath the Root. Create * the controller and Root's stable enhancer array before rendering React. RSC * requests pass through. Server function calls before connection fail; start * mount-time calls in `useEffect`, not descendant layout effects. */ export declare function createServerFunctionRouting(): ServerFunctionRouting; /** * Connects a declaratively installed server-function-routing controller to this Root. * Each server function call reports `getSettledRoute()` as its origin. Origin * rerenders are dropped, retaining the return value, if the settled route changes * or any navigation request is pending. * `getPendingRoute` returns the uncommitted destination or `undefined`. * `applyRouteResponse` handles every accepted route-bearing response, including * same-route updates. It owns applying the elements and their intents; Minimal * does not merge that response again. The controller waits for the callback. * A rejected callback rejects the call. Callback updates take effect on commit * without replacing the enhancer. A response arriving without a connected * binding retains its return value and discards its elements. */ export declare function useServerFunctionRouting(serverFunctionRouting: ServerFunctionRouting, { getSettledRoute, getPendingRoute, applyRouteResponse, }: ServerFunctionRoutingCallbacks): void; export {};