import { ComponentType } from 'react'; /** * Interception level determines how far up the route tree to intercept * * - SameLevel (.) - Intercept from same route level * - OneUp (..) - Intercept from one level up * - TwoUp (...) - Intercept from two levels up * - Root (...) - Intercept from any level (root) */ export declare enum InterceptionLevel { /** Intercept from same route level */ SameLevel = ".", /** Intercept from one level up */ OneUp = "..", /** Intercept from two levels up */ TwoUp = "...", /** Intercept from root (any level) */ Root = "...." } /** * Intercepting route configuration */ export interface InterceptingRouteConfig { /** Route pattern to intercept */ readonly pattern: string; /** Interception level */ readonly level: InterceptionLevel; /** Component to render when intercepted */ readonly interceptWith: ComponentType; /** Fallback component for direct navigation */ readonly fallback: ComponentType; /** Origins from which interception is allowed */ readonly allowedOrigins?: readonly string[]; /** Origins from which interception is denied */ readonly deniedOrigins?: readonly string[]; /** Custom condition for interception */ readonly shouldIntercept?: (context: InterceptionContext) => boolean; /** Feature flag for this interception */ readonly featureFlag?: string; } /** * Props passed to intercepted route component */ export interface InterceptedRouteProps { /** Whether route is currently intercepted */ readonly isIntercepted: boolean; /** Original navigation context */ readonly interceptionContext: InterceptionContext; /** Close the interception (return to origin) */ readonly closeInterception: () => void; /** Navigate to the full page (break out of interception) */ readonly navigateToFull: () => void; } /** * Context for interception decision making */ export interface InterceptionContext { /** Current URL path */ readonly currentPath: string; /** Previous URL path (origin of navigation) */ readonly originPath: string; /** Target URL path */ readonly targetPath: string; /** Extracted route parameters */ readonly params: Record; /** Navigation trigger type */ readonly triggerType: NavigationTrigger; /** Navigation state data */ readonly state?: unknown; /** Whether this is a back/forward navigation */ readonly isPopState: boolean; } /** * Navigation trigger types */ export type NavigationTrigger = 'link' | 'programmatic' | 'popstate' | 'replace' | 'external'; /** * Interception resolution result */ export interface InterceptionResolution { /** Whether route should be intercepted */ readonly shouldIntercept: boolean; /** Component to render */ readonly component: ComponentType; /** Props for the component */ readonly props: InterceptedRouteProps | Record; /** Interception context if intercepted */ readonly context: InterceptionContext | null; /** Reason if not intercepted */ readonly skipReason?: string; } /** * Registered intercepting route */ export interface RegisteredInterceptor { /** Unique interceptor ID */ readonly id: string; /** Route pattern */ readonly pattern: string; /** Interception configuration */ readonly config: InterceptingRouteConfig; /** Registration timestamp */ readonly registeredAt: number; } /** * Interception manager state */ export interface InterceptionManagerState { /** Currently active interception */ readonly activeInterception: InterceptionContext | null; /** Navigation history for interception tracking */ readonly history: readonly InterceptionContext[]; /** Registered interceptors */ readonly interceptors: readonly RegisteredInterceptor[]; } /** * Manages route interception logic * * @example * ```typescript * const manager = new InterceptingRouteManager(); * * manager.register({ * pattern: '/photo/:id', * level: InterceptionLevel.SameLevel, * interceptWith: PhotoModal, * fallback: PhotoPage, * }); * * const resolution = manager.resolve({ * currentPath: '/gallery', * originPath: '/gallery', * targetPath: '/photo/123', * params: { id: '123' }, * triggerType: 'link', * isPopState: false, * }); * ``` */ export declare class InterceptingRouteManager { private interceptors; private activeInterception; private history; private idCounter; /** * Register an intercepting route * * @param config - Interception configuration * @returns Interceptor ID for later reference */ register(config: InterceptingRouteConfig): string; /** * Unregister an intercepting route * * @param id - Interceptor ID * @returns True if interceptor was found and removed */ unregister(id: string): boolean; /** * Resolve whether a navigation should be intercepted * * @param context - Interception context * @returns Resolution result */ resolve(context: InterceptionContext): InterceptionResolution; /** * Close the current interception */ closeInterception(): void; /** * Navigate to full page (break out of interception) */ navigateToFull(_path: string): void; /** * Get current interception state */ getState(): InterceptionManagerState; /** * Check if currently in an interception */ isIntercepted(): boolean; /** * Get active interception context */ getActiveInterception(): InterceptionContext | null; /** * Clear all interceptors */ clearAll(): void; /** * Get all registered interceptors */ getInterceptors(): readonly RegisteredInterceptor[]; /** * Check if a path matches a pattern * * Delegates to core path matching utility. */ private matchesPattern; /** * Determine if navigation should be intercepted */ private shouldIntercept; /** * Check if interception level condition is met * * Uses core path depth utility. */ private checkInterceptionLevel; } /** * Create an intercepting route configuration * * @param config - Interception configuration * @returns Validated configuration */ export declare function createInterceptingRoute(config: InterceptingRouteConfig): InterceptingRouteConfig; /** * Create an interception context from navigation event * * @param event - Navigation event details * @returns Interception context */ export declare function createInterceptionContext(event: { currentPath: string; originPath: string; targetPath: string; params?: Record; state?: unknown; isPopState?: boolean; triggerType?: NavigationTrigger; }): InterceptionContext; /** * Get the default interception manager */ export declare function getInterceptionManager(): InterceptingRouteManager; /** * Reset the default interception manager */ export declare function resetInterceptionManager(): void; /** * Parse interception level from string notation * * @param notation - Dot notation (e.g., '.', '..', '...') * @returns Interception level */ export declare function parseInterceptionLevel(notation: string): InterceptionLevel; /** * Get dot notation for interception level * * @param level - Interception level * @returns Dot notation string */ export declare function getInterceptionNotation(level: InterceptionLevel): string; /** * Check if a route pattern contains interception markers * * @param pattern - Route pattern * @returns True if pattern has interception markers */ export declare function hasInterceptionMarker(pattern: string): boolean; /** * Extract interception level from route pattern * * @param pattern - Route pattern with interception marker * @returns Level and cleaned pattern, or null if no marker */ export declare function extractInterceptionFromPattern(pattern: string): { level: InterceptionLevel; cleanPattern: string; } | null; /** * Build intercepted route path * * @param basePath - Base path * @param level - Interception level * @param targetSegment - Target segment * @returns Intercepted route path */ export declare function buildInterceptedPath(basePath: string, level: InterceptionLevel, targetSegment: string): string; /** * Type guard for InterceptionContext */ export declare function isInterceptionContext(value: unknown): value is InterceptionContext; /** * Type guard for InterceptionLevel */ export declare function isInterceptionLevel(value: unknown): value is InterceptionLevel;