import { ComponentType, ReactNode } from 'react'; /** * Parallel route slot configuration */ export interface ParallelRouteSlot { /** Slot identifier (e.g., '@modal', '@sidebar') */ readonly name: string; /** Path pattern for this slot (can include params) */ readonly path: string; /** Component to render in this slot */ readonly component: ComponentType; /** Loading component for this slot */ readonly loading?: ComponentType; /** Error component for this slot */ readonly error?: ComponentType<{ error: Error; reset: () => void; }>; /** Default component when slot is inactive */ readonly default?: ComponentType; /** Whether this slot is optional */ readonly optional?: boolean; /** Custom slot metadata */ readonly meta?: Record; /** Feature flag for this slot */ readonly featureFlag?: string; } /** * Parallel routes configuration */ export interface ParallelRoutesConfig { /** Named slots for parallel rendering */ readonly slots: Record>; /** Default slot to use if none specified */ readonly defaultSlot?: string; /** Layout component that wraps all slots */ readonly layout?: ComponentType<{ children: ReactNode; slots: Record; }>; /** Enable slot-level code splitting */ readonly codeSplit?: boolean; /** Feature flag for parallel routes */ readonly featureFlag?: string; } /** * Slot render state */ export interface SlotRenderState { /** Whether slot is loading */ readonly isLoading: boolean; /** Whether slot has error */ readonly hasError: boolean; /** Error if any */ readonly error: Error | null; /** Whether slot is active */ readonly isActive: boolean; /** Current render content */ readonly content: ReactNode | null; } /** * Parallel routes render context */ export interface ParallelRoutesContext { /** All slot states */ readonly slots: ReadonlyMap; /** Active slot names */ readonly activeSlots: readonly string[]; /** Refresh a specific slot */ readonly refreshSlot: (slotName: string) => Promise; /** Set slot active/inactive */ readonly setSlotActive: (slotName: string, active: boolean) => void; /** Get slot render content */ readonly getSlotContent: (slotName: string) => ReactNode | null; } /** * Slot match result */ export interface SlotMatch { /** Matched slot */ readonly slot: ParallelRouteSlot; /** Extracted parameters */ readonly params: Record; /** Full matched path */ readonly path: string; /** Match score (for sorting) */ readonly score: number; } /** * Parallel route resolution result */ export interface ParallelRouteResolution { /** Matched slots */ readonly matches: ReadonlyMap; /** Unmatched slot names */ readonly unmatched: readonly string[]; /** Resolution timestamp */ readonly timestamp: number; } /** * Slot name prefix for parallel routes */ export declare const SLOT_PREFIX = "@"; /** * Default slot name */ export declare const DEFAULT_SLOT_NAME = "children"; /** * Manages parallel route slot rendering * * @example * ```typescript * const parallel = new ParallelRoutes({ * slots: { * main: { path: '/', component: MainPage }, * sidebar: { path: '@sidebar', component: Sidebar }, * }, * }); * * const matches = parallel.resolveSlots('/dashboard'); * ``` */ export declare class ParallelRoutes { private readonly config; private readonly slots; private readonly slotStates; constructor(config: ParallelRoutesConfig); /** * Get all slot configurations */ getSlots(): ReadonlyMap; /** * Get a specific slot configuration */ getSlot(name: string): ParallelRouteSlot | undefined; /** * Get slot state */ getSlotState(name: string): SlotRenderState | undefined; /** * Resolve which slots match a given path * * @param path - Current URL path * @returns Resolution result with matched slots */ resolveSlots(path: string): ParallelRouteResolution; /** * Update slot state */ updateSlotState(name: string, update: Partial): void; /** * Create render context for use in components */ createContext(): ParallelRoutesContext; /** * Get slot names that should render for a given path */ getActiveSlotsForPath(path: string): string[]; /** * Check if a slot is configured */ hasSlot(name: string): boolean; /** * Get the default slot */ getDefaultSlot(): ParallelRouteSlot | undefined; /** * Get layout component */ getLayout(): ComponentType<{ children: ReactNode; slots: Record; }> | undefined; /** * Match a single slot against a path */ private matchSlot; /** * Extract parameters from a path given a pattern * * Delegates to core path utilities. */ private extractParams; /** * Calculate match score for sorting * * Delegates to core pattern specificity calculation. */ private calculateMatchScore; } /** * Create a new ParallelRoutes instance * * @param config - Parallel routes configuration * @returns Configured ParallelRoutes instance */ export declare function createParallelRoutes(config: ParallelRoutesConfig): ParallelRoutes; /** * Create a single slot configuration * * @param name - Slot name * @param config - Slot configuration * @returns Complete slot configuration */ export declare function createSlot(name: string, config: Omit, 'name'>): ParallelRouteSlot; /** * Check if a path segment is a slot reference * * @param segment - Path segment to check * @returns True if segment is a slot reference */ export declare function isSlotSegment(segment: string): boolean; /** * Extract slot name from a segment * * @param segment - Slot segment (e.g., '@modal') * @returns Slot name (e.g., 'modal') */ export declare function extractSlotName(segment: string): string; /** * Create a slot path from a slot name * * @param name - Slot name * @returns Slot path (e.g., '@modal') */ export declare function createSlotPath(name: string): string; /** * Merge slot states for composite rendering * * @param states - Array of slot states * @returns Merged loading/error state */ export declare function mergeSlotStates(states: readonly SlotRenderState[]): { isAnyLoading: boolean; isAllLoading: boolean; hasAnyError: boolean; errors: readonly Error[]; isAllActive: boolean; }; /** * Sort slots by priority for rendering order * * @param slots - Slots to sort * @param priority - Priority map (slot name -> priority number, higher = first) * @returns Sorted slots */ export declare function sortSlotsByPriority(slots: readonly ParallelRouteSlot[], priority?: Record): readonly ParallelRouteSlot[]; /** * Type guard for ParallelRouteSlot */ export declare function isParallelRouteSlot(value: unknown): value is ParallelRouteSlot; /** * Type guard for SlotMatch */ export declare function isSlotMatch(value: unknown): value is SlotMatch;