import type { urls } from "../../urls.js"; import { type EntryData, type InterceptEntry, type LoaderEntry } from "../../server/context.js"; import { type RouteMatchResult } from "../../router/pattern-matching.js"; import type { RouteEntry } from "../../types.js"; export type { EntryData, InterceptEntry, LoaderEntry }; export interface SegmentInfo { id: string; type: EntryData["type"]; pattern?: string; } export interface InterceptInfo { slotName: string; routeName: string; hasWhen: boolean; whenCount: number; hasLoader: boolean; hasMiddleware: boolean; } /** * Build a route tree from url patterns for inspection. * * Executes the urls() handler inside RSCRouterContext and extracts * the manifest, patterns, and route entries. Lazy includes are * eagerly evaluated so the full tree is available. * * @example * ```ts * const tree = buildRouteTree( * urls(({ path, layout }) => [ * layout(RootLayout, () => [ * path("/", HomePage, { name: "home" }), * path("/about", AboutPage, { name: "about" }), * ]), * ]) * ); * * // Inspect patterns * expect(tree.routes()).toEqual({ home: "/", about: "/about" }); * * // Inspect segment IDs * expect(tree.segmentId("home")).toBe("M0L0L0R0"); * * // Match a URL * const match = tree.match("/about"); * expect(match?.routeKey).toBe("about"); * ``` */ export declare function buildRouteTree(urlPatterns: ReturnType, options?: { mountIndex?: number; }): RouteTree; /** * Wrapper around the raw manifest/patterns/entries providing * convenient inspection methods for route tree, segment IDs, * middleware, intercepts, loaders, and parallel slots. */ export declare class RouteTree { readonly manifest: Map; readonly patterns: Map; readonly routeEntries: RouteEntry[]; constructor(manifest: Map, patterns: Map, routeEntries: RouteEntry[]); /** Route name -> URL pattern map as a plain object */ routes(): Record; /** Get all route names */ routeNames(): string[]; /** Get the segment ID (shortCode) for a named route */ segmentId(name: string): string | undefined; /** Get segment IDs for all named routes */ segmentIds(): Record; /** * Get the full segment path from root to a named route. * Returns an array of { id, type, pattern? } entries. */ segmentPath(name: string): SegmentInfo[]; /** Get the EntryData for a named route */ entry(name: string): EntryData | undefined; /** Get the EntryData for a route matching a URL pattern string */ entryByPattern(pattern: string): EntryData | undefined; /** Match a pathname and return the match result (routeKey, params) */ match(pathname: string): RouteMatchResult | null; /** Get middleware functions attached to a named route/layout */ middleware(name: string): Array; /** Check if a named route/layout has middleware */ hasMiddleware(name: string): boolean; /** * Collect all middleware in the chain from root to a named route. * Returns them in execution order (root first). */ middlewareChain(name: string): Array<{ segmentId: string; count: number; }>; /** Get intercept entries for a named route/layout */ intercepts(name: string): InterceptInfo[]; /** Get raw InterceptEntry objects for a named route/layout */ interceptEntries(name: string): InterceptEntry[]; /** Get loader entries for a named route/layout */ loaders(name: string): LoaderEntry[]; /** Check if a named route/layout has loaders */ hasLoaders(name: string): boolean; /** Get parallel slot entries (child EntryData with type="parallel") */ parallelSlots(name: string): EntryData[]; /** Get parallel slot names for a named route/layout */ parallelSlotNames(name: string): string[]; /** Check if a named route/layout has an error boundary */ hasErrorBoundary(name: string): boolean; /** Check if a named route/layout has a not-found boundary */ hasNotFoundBoundary(name: string): boolean; /** Check if a named route/layout has cache config */ hasCache(name: string): boolean; /** Check if a named route/layout has a loading component */ hasLoading(name: string): boolean; /** * Debug print the route tree. * Useful for exploring the structure in tests. */ debug(): string; } //# sourceMappingURL=route-tree.d.ts.map