/** * Build-time manifest generation for @rangojs/router * * Extracts the prefix tree and route manifest from UrlPatterns at build time. * This enables: * - Pre-computed prefix tree for fast short-circuit checks * - Complete route manifest for href() without runtime evaluation * - Support for nested includes */ import type { UrlPatterns } from "../urls.js"; /** * Node in the prefix tree */ export interface PrefixTreeNode { /** The static prefix for this node */ staticPrefix: string; /** The full URL prefix (including parent prefixes) */ fullPrefix: string; /** Name prefix for routes in this include */ namePrefix?: string; /** Child nodes (nested includes) */ children: Record; /** Route names defined directly in this include (not in children) */ routes: string[]; } /** * Generated manifest containing prefix tree and route mappings */ export interface GeneratedManifest { /** Nested prefix tree for short-circuit optimization */ prefixTree: Record; /** Complete route name → pattern mapping for href() */ routeManifest: Record; /** Route name → trailing slash mode for trie redirect handling */ routeTrailingSlash?: Record; /** Route names using Prerender (for dev-mode Node.js delegation) */ prerenderRoutes?: string[]; /** Route names with passthrough: true (handler kept in bundle for live fallback) */ passthroughRoutes?: string[]; /** Route name → response type for non-RSC routes */ responseTypeRoutes?: Record; /** Route name -> search schema descriptor for typed URL helpers */ routeSearchSchemas?: Record>; /** Generation timestamp */ generatedAt: string; } /** * Generate manifest from UrlPatterns * * This runs all patterns (including lazy ones) at build time to extract: * - The complete prefix tree for short-circuit optimization * - The complete route manifest for href() * * @example * ```typescript * import { generateManifest } from "@rangojs/router/build"; * import { urlpatterns } from "./urls"; * * const manifest = generateManifest(urlpatterns); * // Write to file for runtime use * fs.writeFileSync( * "src/generated/route-manifest.json", * JSON.stringify(manifest, null, 2) * ); * ``` */ export declare function generateManifest(urlpatterns: UrlPatterns, mountIndex?: number): GeneratedManifest & { _routeAncestry: Record; _prerenderDefs?: Record; }; /** * Generate TypeScript code for the manifest * * @example * ```typescript * const code = generateManifestCode(urlpatterns); * fs.writeFileSync("src/generated/route-manifest.ts", code); * ``` */ export declare function generateManifestCode(urlpatterns: UrlPatterns): string; //# sourceMappingURL=generate-manifest.d.ts.map