declare const COMPILED_ROUTE_PATTERN: unique symbol; export type RoutePatternSegment = { readonly kind: "static"; readonly value: string; } | { readonly kind: "param"; readonly name: string; } | { readonly kind: "wildcard"; readonly name: string; } /** A segment that is part literal, part parameter: `:key.txt`, `feed.:format`, `v:major.:minor`. */ | { readonly kind: "mixed"; readonly parts: readonly MixedPart[]; }; /** One piece of a {@link RoutePatternSegment} of kind `mixed`, in left-to-right order. */ export type MixedPart = { readonly t: "lit"; readonly v: string; } | { readonly t: "param"; readonly name: string; }; /** * Compiled route grammar shared by runtime routers, browser navigation, mocks, and adapters. * * The result, its two arrays, and every segment are frozen because consumers share one instance. In * particular, a segment must not diverge from the lazily cached regex after first match. The measured * sub-microsecond cost per route is paid only at registration and preserves that runtime invariant. */ export interface CompiledRoutePattern { readonly [COMPILED_ROUTE_PATTERN]: true; readonly pattern: string; readonly segments: readonly RoutePatternSegment[]; readonly paramNames: readonly string[]; } export type RoutePatternMatch = { readonly matched: true; readonly params: Record; } | { readonly matched: false; readonly reason: "not-found" | "malformed"; }; /** The regex source matching one segment's worth of a mixed pattern, with a capture per parameter. */ export declare function mixedSegmentSource(parts: readonly MixedPart[]): string; /** Parse and validate Nifra's strict route grammar once. Trailing slashes remain significant. */ export declare function compileRoutePattern(pattern: string): CompiledRoutePattern; /** * Total ordering for mixed segment shapes, shared by the trie and regex-based routers. * * Code-unit comparison, never `localeCompare`: this exists so the server and the browser agree on which * of two equally-weighted patterns wins, and `localeCompare` answers by the RUNTIME's locale - a server * and a visitor in different locales would order the same pair differently, which is the divergence * being prevented. */ export declare function compareMixedPartsSpecificity(left: readonly MixedPart[], right: readonly MixedPart[]): number; /** Core precedence: static > mixed > param > wildcard at the first differing segment, independent of * registration order. */ export declare function compareRoutePatternSpecificity(left: CompiledRoutePattern, right: CompiledRoutePattern): number; /** * Sort compiled routes most-specific-first - a static segment beats a dynamic one, the order the router * resolves a path in. The single home for that precedence: the web router, the mock server, and the * editor plugin all order routes through this one comparator, so which file a path resolves to can never * diverge between runtime, client, and editor. Sorts in place and returns the same array. */ export declare function sortRoutesBySpecificity(routes: T[]): T[]; /** Decode router captures under one rule. Plain values take the zero-allocation path; malformed * escapes return `null`, allowing HTTP to emit 400 while client navigation declines the match. */ export declare function decodeRouteParams(raw: Record): Record | null; /** Match one compiled pattern and return decoded captures. The caller decides cross-pattern order. */ export declare function matchRoutePattern(compiled: CompiledRoutePattern, pathname: string): RoutePatternMatch; export {}; //# sourceMappingURL=pattern.d.ts.map