/** * Client-safe route map builder * * Provides a fluent API for building route maps with prefixes. * Can be imported in client code without pulling in server dependencies. * * @example * ```typescript * import { createRouteMap, registerRouteMap } from "rsc-router/browser"; * * const routeMap = createRouteMap() * .add(homeRoutes) * .add(blogRoutes, "blog") * .add(shopRoutes, "shop"); * * registerRouteMap(routeMap.routes); * * declare global { * namespace RSCRouter { * interface RegisteredRoutes extends typeof routeMap.routes {} * } * } * ``` */ import type { PrefixRoutePatterns } from "./reverse.js"; /** * Route map builder interface * * Accumulates route types through the builder chain for type-safe reverse. */ export interface RouteMapBuilder = {}> { /** * Add routes without prefix */ add>(routes: T): RouteMapBuilder; /** * Add routes with prefix (only URL patterns are prefixed, keys stay unchanged) * @param routes - Route definitions to add * @param prefix - URL prefix WITHOUT leading slash (e.g., "blog" not "/blog") */ add, P extends string>(routes: T, prefix: P): RouteMapBuilder>; /** * The accumulated route map (for typeof extraction in module augmentation) */ readonly routes: TRoutes; } /** * Create a new route map builder * * @returns A builder for accumulating routes with type-safe prefixes * * @example * ```typescript * const routeMap = createRouteMap() * .add(homeRoutes) * .add(blogRoutes, "blog"); * * // Types are accumulated through the chain * type AppRoutes = typeof routeMap.routes; * ``` */ export declare function createRouteMap(): RouteMapBuilder<{}>; declare let cachedPrecomputedEntries: Array<{ staticPrefix: string; routes: Record; }> | null; /** * Register the route map globally for reverse to use at runtime * * Call this after building your route map to make it available to reverse. * Routes are merged with any existing registered routes. * * @param map - The route map to register * * @example * ```typescript * const routeMap = createRouteMap() * .add(homeRoutes) * .add(blogRoutes, "blog"); * * registerRouteMap(routeMap.routes); * ``` */ export declare function registerRouteMap(map: Record): void; /** * Get the globally registered route map * * Used internally by reverse to resolve route names to URLs at runtime. * Returns the cached manifest if available (complete with lazy includes), * otherwise returns the runtime-accumulated route map. * * @returns The registered route map */ export declare function getGlobalRouteMap(): Record; /** * Set the cached manifest (for runtime cache integration) * * This sets the complete route manifest from a runtime cache. * The cached manifest includes all routes (including lazy includes) * and takes precedence over the incrementally-built globalRouteMap. * * @param manifest - The complete route manifest to cache */ export declare function setCachedManifest(manifest: Record): void; /** * Check if a cached manifest is loaded * * @returns true if a complete manifest is available */ export declare function hasCachedManifest(): boolean; /** * Clear the cached manifest (for testing) */ export declare function clearCachedManifest(): void; /** * Set pre-computed route entries from build-time data. * * Each entry corresponds to a leaf node in the prefix tree (no nested includes). * evaluateLazyEntry() checks these before running the handler, avoiding the * 5-50ms cost of handler evaluation for route matching on the first request. * * @param entries - Array of { staticPrefix, routes } from build-time prefix tree leaves */ export declare function setPrecomputedEntries(entries: Array<{ staticPrefix: string; routes: Record; }> | null): void; /** * Get pre-computed route entries (if available) */ export declare function getPrecomputedEntries(): typeof cachedPrecomputedEntries; declare let cachedRouteTrie: import("./build/route-trie.js").TrieNode | null; export declare function setRouteTrie(trie: typeof cachedRouteTrie): void; export declare function getRouteTrie(): typeof cachedRouteTrie; export declare function setRouterManifest(routerId: string, manifest: Record): void; export declare function getRouterManifest(routerId: string): Record | undefined; export declare function setRouterTrie(routerId: string, trie: import("./build/route-trie.js").TrieNode): void; export declare function getRouterTrie(routerId: string): import("./build/route-trie.js").TrieNode | undefined; export declare function setRouterPrecomputedEntries(routerId: string, entries: Array<{ staticPrefix: string; routes: Record; }>): void; export declare function getRouterPrecomputedEntries(routerId: string): Array<{ staticPrefix: string; routes: Record; }> | undefined; export declare function registerRouterManifestLoader(routerId: string, loader: () => Promise): void; export declare function ensureRouterManifest(routerId: string): Promise; export declare function setManifestReadyPromise(promise: Promise): void; export declare function waitForManifestReady(): Promise | null; import type { SearchSchema } from "./search-params.js"; export declare function registerSearchSchema(routeName: string, schema: SearchSchema): void; export declare function getSearchSchema(routeName: string): SearchSchema | undefined; export {}; //# sourceMappingURL=route-map-builder.d.ts.map