import { Store } from '@tanstack/store'; import { GetFrameworkGeneric } from './frameworks'; import { LinkInfo, LinkOptions, NavigateOptions, ToOptions, ValidFromPath, ResolveRelativePath } from './link'; import { AnyRoute, Route } from './route'; import { AnyPathParams, AnyRouteConfig, AnySearchSchema, LoaderContext, RouteConfig, SearchFilter } from './routeConfig'; import { AllRouteInfo, AnyAllRouteInfo, RouteInfo, RoutesById } from './routeInfo'; import { RouteMatch, RouteMatchStore } from './routeMatch'; import { NoInfer, PickAsRequired, Timeout, Updater } from './utils'; import { RouterHistory } from './history'; export interface RegisterRouter { } export type AnyRouter = Router; export type RegisteredRouter = RegisterRouter extends { router: Router; } ? Router : Router; export type RegisteredAllRouteInfo = RegisterRouter extends { router: Router; } ? TAllRouteInfo : AnyAllRouteInfo; export interface LocationState { } export interface ParsedLocation { href: string; pathname: string; search: TSearchObj; searchStr: string; state: TState; hash: string; key?: string; } export interface FromLocation { pathname: string; search?: unknown; key?: string; hash?: string; } export type SearchSerializer = (searchObj: Record) => string; export type SearchParser = (searchStr: string) => Record; export type FilterRoutesFn = >(routeConfigs: TRoute[]) => TRoute[]; export interface RouterOptions { history?: RouterHistory; stringifySearch?: SearchSerializer; parseSearch?: SearchParser; filterRoutes?: FilterRoutesFn; defaultPreload?: false | 'intent'; defaultPreloadDelay?: number; defaultComponent?: GetFrameworkGeneric<'Component'>; defaultErrorComponent?: GetFrameworkGeneric<'ErrorComponent'>; defaultPendingComponent?: GetFrameworkGeneric<'Component'>; defaultLoaderMaxAge?: number; defaultLoaderGcMaxAge?: number; caseSensitive?: boolean; routeConfig?: TRouteConfig; basepath?: string; Router?: (router: AnyRouter) => void; createRoute?: (opts: { route: AnyRoute; router: AnyRouter; }) => void; context?: TRouterContext; loadComponent?: (component: GetFrameworkGeneric<'Component'>) => Promise>; onRouteChange?: () => void; fetchServerDataFn?: FetchServerDataFn; } type FetchServerDataFn = (ctx: { router: AnyRouter; routeMatch: RouteMatch; }) => Promise; export interface LoaderState { loadedAt: number; loaderContext: LoaderContext; } export interface RouterStore { status: 'idle' | 'pending'; latestLocation: ParsedLocation; currentMatches: RouteMatch[]; currentLocation: ParsedLocation; pendingMatches?: RouteMatch[]; pendingLocation?: ParsedLocation; lastUpdated: number; } export type ListenerFn = () => void; export interface BuildNextOptions { to?: string | number | null; params?: true | Updater; search?: true | Updater; hash?: true | Updater; state?: LocationState; key?: string; from?: string; fromCurrent?: boolean; __preSearchFilters?: SearchFilter[]; __postSearchFilters?: SearchFilter[]; } export type MatchCacheEntry = { gc: number; match: RouteMatch; }; export interface MatchLocation { to?: string | number | null; fuzzy?: boolean; caseSensitive?: boolean; from?: string; fromCurrent?: boolean; } export interface MatchRouteOptions { pending?: boolean; caseSensitive?: boolean; fuzzy?: boolean; } export interface DehydratedRouterState extends Pick { currentMatches: DehydratedRouteMatch[]; } export interface DehydratedRouter { state: DehydratedRouterState; context: TRouterContext; } export type MatchCache = Record; interface DehydratedRouteMatch { id: string; state: Pick, 'status'>; } export interface RouterContext { } export declare const defaultFetchServerDataFn: FetchServerDataFn; export declare class Router, TRouterContext = unknown> { #private; types: { RouteConfig: TRouteConfig; AllRouteInfo: TAllRouteInfo; }; options: PickAsRequired, 'stringifySearch' | 'parseSearch' | 'context'>; history: RouterHistory; basepath: string; routeTree: Route; routesById: RoutesById; navigateTimeout: undefined | Timeout; nextAction: undefined | 'push' | 'replace'; navigationPromise: undefined | Promise; store: Store>; startedLoadingAt: number; resolveNavigation: () => void; constructor(options?: RouterOptions); reset: () => void; mount: () => () => void; update: = RouteConfig, TAllRouteInfo_1 extends AnyAllRouteInfo = AllRouteInfo, TRouterContext_1 = unknown>(opts?: RouterOptions | undefined) => Router; buildNext: (opts: BuildNextOptions) => ParsedLocation<{}, LocationState>; cancelMatches: () => void; load: (next?: ParsedLocation) => Promise; getRoute: (id: TId) => Route; loadRoute: (navigateOpts?: BuildNextOptions) => Promise; preloadRoute: (navigateOpts?: BuildNextOptions) => Promise>[]>; matchRoutes: (pathname: string, opts?: { strictParseParams?: boolean; }) => RouteMatch>[]; loadMatches: (resolvedMatches: RouteMatch[], loaderOpts?: { preload?: boolean; }) => Promise; reload: () => void; resolvePath: (from: string, path: string) => string; navigate: = "/", TTo extends string = ".">({ from, to, search, hash, replace, params, }: NavigateOptions) => Promise; matchRoute: = "/", TTo extends string = ".">(location: ToOptions>>, opts?: MatchRouteOptions) => false | TAllRouteInfo["routeInfoById"][ResolveRelativePath>]["allParams"]; buildLink: = "/", TTo extends string = ".">({ from, to, search, params, hash, target, replace, activeOptions, preload, preloadMaxAge: userPreloadMaxAge, preloadGcMaxAge: userPreloadGcMaxAge, preloadDelay: userPreloadDelay, disabled, }: LinkOptions) => LinkInfo; dehydrate: () => DehydratedRouter; hydrate: (dehydratedRouter: DehydratedRouter) => void; } export {};