import { ComponentType, LazyExoticComponent } from 'react'; import { DiscoveredRoute, NavigationResult, RouteAccessConfig, RouteAnalyticsEvent, RouteMetadata, RouteParams, RoutePrefetchConfig, TypedNavigationOptions } from './types'; /** * Registered route entry with all metadata */ export interface RegisteredRoute { /** Unique route ID */ readonly id: string; /** URL path pattern */ readonly path: TPath; /** Display name for UI */ readonly displayName: string; /** Source file path */ readonly sourceFile: string; /** Route metadata */ readonly meta: RouteMetadata; /** Access control */ readonly access: RouteAccessConfig; /** Prefetch configuration */ readonly prefetch: RoutePrefetchConfig; /** Parameter names */ readonly paramNames: readonly string[]; /** Lazy component */ readonly component?: LazyExoticComponent>; /** Preload function */ readonly preload?: () => Promise; /** Data loader keys for prefetching */ readonly dataLoaderKeys?: readonly unknown[][]; } /** * Registry listener for route changes */ export type RegistryListener = (event: RegistryEvent) => void; /** * Registry event types */ export type RegistryEvent = { type: 'route_registered'; route: RegisteredRoute; } | { type: 'route_unregistered'; routeId: string; } | { type: 'prefetch_started'; routeId: string; } | { type: 'prefetch_completed'; routeId: string; } | { type: 'navigation'; path: string; params?: Record; }; /** * Unified route registry for the application */ declare class RouteRegistry { private state; /** * Register a route in the registry */ register(route: Omit, 'id' | 'prefetch'> & { id?: string; prefetch?: RoutePrefetchConfig; }): RegisteredRoute; /** * Register multiple routes from discovered routes */ registerFromDiscovery(routes: DiscoveredRoute[], componentMap: Map>>, preloadMap?: Map Promise>): RegisteredRoute[]; /** * Unregister a route */ unregister(routeId: string): boolean; /** * Clear all registered routes */ clear(): void; /** * Get a route by ID */ getById(routeId: string): RegisteredRoute | undefined; /** * Get a route by path */ getByPath(path: string): RegisteredRoute | undefined; /** * Get all registered routes */ getAll(): RegisteredRoute[]; /** * Get routes matching a filter */ filter(predicate: (route: RegisteredRoute) => boolean): RegisteredRoute[]; /** * Find routes by feature */ getByFeature(feature: string): RegisteredRoute[]; /** * Get public routes */ getPublicRoutes(): RegisteredRoute[]; /** * Get protected routes */ getProtectedRoutes(): RegisteredRoute[]; /** * Build a path with type-safe parameters * * Delegates to the canonical `buildRoutePath` from `./route-builder` * to ensure consistent path building across the application. */ buildPath(path: TPath, params?: RouteParams, query?: Record): string; /** * Match a path against registered routes */ matchPath(pathname: string): { route: RegisteredRoute | null; params: Record; }; /** * Queue a route for prefetching */ queuePrefetch(routeId: string): void; /** * Execute prefetch for a route */ prefetch(routeId: string): Promise; /** * Prefetch by path */ prefetchByPath(path: string): Promise; /** * Process prefetch queue */ processQueue(maxConcurrent?: number): Promise; /** * Get prefetch status for a route */ isPrefetched(routeId: string): boolean; /** * Clear prefetch cache */ clearPrefetchCache(): void; /** * Track a navigation event */ trackNavigation(path: string, params?: Record, metadata?: Record): void; /** * Get navigation analytics */ getAnalytics(): readonly RouteAnalyticsEvent[]; /** * Get navigation history */ getNavigationHistory(limit?: number): readonly RouteAnalyticsEvent[]; /** * Get most visited routes */ getMostVisited(limit?: number): Array<{ path: string; count: number; }>; /** * Subscribe to registry events */ subscribe(listener: RegistryListener): () => void; /** * Emit an event to all listeners */ private emit; /** * Generate a route ID from path */ private generateId; /** * Generate display name from route */ private generateDisplayName; /** * Infer prefetch priority from route */ private inferPriority; /** * Capitalize a string */ private capitalize; /** * Extract params from pathname * * Delegates to core path utilities. */ private extractParams; /** * Chunk array for batch processing */ private chunkArray; } /** * Global route registry instance */ export declare const routeRegistry: RouteRegistry; /** * Hook for accessing the route registry */ export declare function useRouteRegistry(): RouteRegistry; /** * Hook for type-safe navigation with prefetching */ export declare function useTypedNavigate(): { navigateTo: (path: TPath, params?: RouteParams, options?: TypedNavigationOptions & { query?: Record; }) => NavigationResult; prefetchRoute: (path: string) => void; currentPath: string; isActive: (path: string) => boolean; isActivePrefix: (prefix: string) => boolean; }; /** * Hook for prefetching routes on hover/focus */ export declare function usePrefetchHandlers(path: string): { onMouseEnter: () => void; onMouseLeave: () => void; onFocus: () => void; }; /** * Hook for getting route metadata */ export declare function useRouteMetadata(path: string): RouteMetadata | undefined; /** * Hook for getting navigation analytics */ export declare function useNavigationAnalytics(): { history: readonly RouteAnalyticsEvent[]; mostVisited: Array<{ path: string; count: number; }>; allEvents: readonly RouteAnalyticsEvent[]; }; export { RouteRegistry };