import { ComponentType } from 'react'; /** * Catch-all route configuration */ export interface CatchAllRouteConfig { /** Base path before the catch-all segment */ readonly basePath: string; /** Parameter name for the catch-all segments */ readonly paramName: string; /** Whether the catch-all is optional (can match basePath alone) */ readonly optional: boolean; /** Component to render */ readonly component: ComponentType; /** Loading component */ readonly loading?: ComponentType; /** Error component */ readonly error?: ComponentType<{ error: Error; }>; /** Not found component (for failed lookups) */ readonly notFound?: ComponentType; /** Segment validator */ readonly validateSegment?: (segment: string) => boolean; /** Transform segments before passing to component */ readonly transformSegments?: (segments: string[]) => string[]; /** Maximum allowed segments */ readonly maxSegments?: number; /** Minimum required segments (for optional catch-all) */ readonly minSegments?: number; /** Allowed segment patterns (regex) */ readonly allowedPatterns?: readonly RegExp[]; /** Denied segment patterns (regex) */ readonly deniedPatterns?: readonly RegExp[]; /** Metadata for the route */ readonly meta?: CatchAllRouteMeta; /** Feature flag for this route */ readonly featureFlag?: string; } /** * Props passed to catch-all route component */ export interface CatchAllRouteProps { /** Array of captured path segments */ readonly segments: readonly string[]; /** Joined path from segments */ readonly joinedPath: string; /** Number of segments */ readonly depth: number; /** Whether this is the base path (empty segments) */ readonly isBase: boolean; /** Full matched path */ readonly fullPath: string; /** Original params object */ readonly params: Record; } /** * Catch-all route metadata */ export interface CatchAllRouteMeta { /** Route title template */ readonly title?: string; /** Route description */ readonly description?: string; /** Whether to index in sitemap */ readonly indexable?: boolean; /** Custom metadata */ readonly custom?: Record; } /** * Catch-all match result */ export interface CatchAllMatch { /** Whether the path matches */ readonly matches: boolean; /** Captured segments */ readonly segments: readonly string[]; /** Validation errors (if any) */ readonly errors: readonly CatchAllError[]; /** Match score for priority sorting */ readonly score: number; /** Computed props for component */ readonly props: CatchAllRouteProps | null; } /** * Catch-all validation error */ export interface CatchAllError { /** Error type */ readonly type: 'invalid-segment' | 'too-many-segments' | 'too-few-segments' | 'pattern-violation'; /** Error message */ readonly message: string; /** Problematic segment (if applicable) */ readonly segment?: string; /** Segment index (if applicable) */ readonly index?: number; } /** * Registered catch-all route */ export interface RegisteredCatchAllRoute { /** Unique route ID */ readonly id: string; /** Route configuration */ readonly config: CatchAllRouteConfig; /** Compiled pattern for matching */ readonly pattern: CatchAllPattern; /** Registration timestamp */ readonly registeredAt: number; } /** * Compiled catch-all pattern */ export interface CatchAllPattern { /** Base path regex */ readonly baseRegex: RegExp; /** Full path regex */ readonly fullRegex: RegExp; /** Static prefix length */ readonly staticPrefixLength: number; } /** * Manages a single catch-all route * * @example * ```typescript * const route = new CatchAllRoute({ * basePath: '/blog', * paramName: 'slug', * optional: true, * component: BlogPage, * }); * * if (route.matches('/blog/2024/01/hello-world')) { * const segments = route.parseSegments('/blog/2024/01/hello-world'); * // ['2024', '01', 'hello-world'] * } * ``` */ export declare class CatchAllRoute { private readonly config; private readonly pattern; constructor(config: CatchAllRouteConfig); /** * Check if a path matches this catch-all route * * @param path - URL path to check * @returns True if path matches */ matches(path: string): boolean; /** * Parse segments from a matched path * * @param path - URL path to parse * @returns Array of segments */ parseSegments(path: string): string[]; /** * Match a path and return full match result * * @param path - URL path to match * @returns Match result with segments and validation */ match(path: string): CatchAllMatch; /** * Get the route pattern string * * @returns Pattern string (e.g., '/docs/*' or '/docs/*?') */ getPatternString(): string; /** * Get the URL path for given segments * * @param segments - Segments to join * @returns Full URL path */ buildPath(segments: readonly string[]): string; /** * Get route configuration */ getConfig(): Readonly; /** * Get component for rendering */ getComponent(): ComponentType; /** * Compile the route pattern into regex */ private compilePattern; } /** * Manages multiple catch-all routes with priority ordering */ export declare class CatchAllRouteManager { private routes; private idCounter; /** * Register a catch-all route * * @param config - Route configuration * @returns Route ID */ register(config: CatchAllRouteConfig): string; /** * Unregister a catch-all route * * @param id - Route ID * @returns True if route was found and removed */ unregister(id: string): boolean; /** * Find the best matching catch-all route for a path * * @param path - URL path * @returns Best match or null */ findBestMatch(path: string): { route: RegisteredCatchAllRoute; match: CatchAllMatch; } | null; /** * Get all registered routes */ getAllRoutes(): readonly RegisteredCatchAllRoute[]; /** * Get a specific route * * @param id - Route ID */ getRoute(id: string): RegisteredCatchAllRoute | undefined; /** * Clear all routes */ clearAll(): void; } /** * Create a catch-all route configuration * * @param config - Route configuration * @returns CatchAllRoute instance */ export declare function createCatchAllRoute(config: CatchAllRouteConfig): CatchAllRoute; /** * Create a catch-all route for documentation sites * * @param options - Configuration options * @returns Configured CatchAllRoute */ export declare function createDocsCatchAll(options: { basePath?: string; component: ComponentType; notFound?: ComponentType; maxDepth?: number; }): CatchAllRoute; /** * Create a catch-all route for blog posts * * @param options - Configuration options * @returns Configured CatchAllRoute */ export declare function createBlogCatchAll(options: { basePath?: string; component: ComponentType; }): CatchAllRoute; /** * Get the default catch-all route manager */ export declare function getCatchAllManager(): CatchAllRouteManager; /** * Reset the default catch-all route manager */ export declare function resetCatchAllManager(): void; /** * Check if a path pattern is a catch-all * * @param pattern - Route pattern * @returns True if pattern is a catch-all */ export declare function isCatchAllPattern(pattern: string): boolean; /** * Extract base path from catch-all pattern * * @param pattern - Route pattern with catch-all * @returns Base path without catch-all */ export declare function extractBasePath(pattern: string): string; /** * Check if catch-all is optional * * @param pattern - Route pattern * @returns True if catch-all is optional */ export declare function isOptionalCatchAll(pattern: string): boolean; /** * Normalize path segments for comparison * * @param segments - Array of segments * @returns Normalized segments */ export declare function normalizeSegments(segments: readonly string[]): string[]; /** * Join segments into a path * * @param segments - Array of segments * @returns Joined path */ export declare function joinSegments(segments: readonly string[]): string; /** * Split a path into segments * * @param path - URL path * @returns Array of segments */ export declare function splitPath(path: string): string[]; /** * Type guard for CatchAllRouteProps */ export declare function isCatchAllRouteProps(value: unknown): value is CatchAllRouteProps; /** * Type guard for CatchAllMatch */ export declare function isCatchAllMatch(value: unknown): value is CatchAllMatch;