import { LazyRoute } from './fileRoute.js'; import { NotFoundError } from './not-found.js'; import { NavigateOptions, ParsePathParams } from './link.js'; import { ParsedLocation } from './location.js'; import { AnyRouteMatch, MakeRouteMatchFromRoute, MakeRouteMatchUnion, RouteMatch } from './Matches.js'; import { RootRouteId } from './root.js'; import { ParseRoute, RouteById, RoutePaths } from './routeInfo.js'; import { AnyRouter, RegisteredRouter } from './router.js'; import { BuildLocationFn, NavigateFn } from './RouterProvider.js'; import { Assign, Constrain, Expand, IntersectAssign, NoInfer } from './utils.js'; import { AnySchema, AnyStandardSchemaValidator, AnyValidator, AnyValidatorAdapter, AnyValidatorObj, DefaultValidator, ResolveSearchValidatorInput, ResolveValidatorOutput, StandardSchemaValidator, ValidatorAdapter, ValidatorFn, ValidatorObj } from './validators.js'; export type AnyPathParams = {}; export type SearchSchemaInput = { __TSearchSchemaInput__: 'TSearchSchemaInput'; }; export type AnyContext = {}; export interface RouteContext { } export type PreloadableObj = { preload?: () => Promise; }; export type RoutePathOptions = { path: TPath; } | { id: TCustomId; }; export interface StaticDataRouteOption { } export type RoutePathOptionsIntersection = { path: TPath; id: TCustomId; }; export type SearchFilter = (prev: TInput) => TResult; export type SearchMiddlewareContext = { search: TSearchSchema; next: (newSearch: TSearchSchema) => TSearchSchema; }; export type SearchMiddleware = (ctx: SearchMiddlewareContext) => TSearchSchema; export type ResolveId = TParentRoute extends { id: infer TParentId extends string; } ? RoutePrefix : RootRouteId; export type InferFullSearchSchema = TRoute extends { types: { fullSearchSchema: infer TFullSearchSchema; }; } ? TFullSearchSchema : {}; export type InferFullSearchSchemaInput = TRoute extends { types: { fullSearchSchemaInput: infer TFullSearchSchemaInput; }; } ? TFullSearchSchemaInput : {}; export type InferAllParams = TRoute extends { types: { allParams: infer TAllParams; }; } ? TAllParams : {}; export type InferAllContext = unknown extends TRoute ? TRoute : TRoute extends { types: { allContext: infer TAllContext; }; } ? TAllContext : {}; export type ResolveSearchSchemaFnInput = TSearchValidator extends (input: infer TSearchSchemaInput) => any ? TSearchSchemaInput extends SearchSchemaInput ? Omit : ResolveSearchSchemaFn : AnySchema; export type ResolveSearchSchemaInput = TSearchValidator extends AnyStandardSchemaValidator ? NonNullable['input'] : TSearchValidator extends AnyValidatorAdapter ? TSearchValidator['types']['input'] : TSearchValidator extends AnyValidatorObj ? ResolveSearchSchemaFnInput : ResolveSearchSchemaFnInput; export type ResolveSearchSchemaFn = TSearchValidator extends (...args: any) => infer TSearchSchema ? TSearchSchema : AnySchema; export type ResolveSearchSchema = unknown extends TSearchValidator ? TSearchValidator : TSearchValidator extends AnyStandardSchemaValidator ? NonNullable['output'] : TSearchValidator extends AnyValidatorAdapter ? TSearchValidator['types']['output'] : TSearchValidator extends AnyValidatorObj ? ResolveSearchSchemaFn : ResolveSearchSchemaFn; export type ParseSplatParams = TPath & `${string}$` extends never ? TPath & `${string}$/${string}` extends never ? never : '_splat' : '_splat'; export interface SplatParams { _splat?: string; } export type ResolveParams = ParseSplatParams extends never ? Record, string> : Record, string> & SplatParams; export type ParseParamsFn = (rawParams: ResolveParams) => TParams extends Record, any> ? TParams : Record, any>; export type StringifyParamsFn = (params: TParams) => ResolveParams; export type ParamsOptions = { params?: { parse?: ParseParamsFn; stringify?: StringifyParamsFn; }; /** @deprecated Use params.parse instead */ parseParams?: ParseParamsFn; /** @deprecated Use params.stringify instead */ stringifyParams?: StringifyParamsFn; }; interface RequiredStaticDataRouteOption { staticData: StaticDataRouteOption; } interface OptionalStaticDataRouteOption { staticData?: StaticDataRouteOption; } export type UpdatableStaticRouteOption = {} extends StaticDataRouteOption ? OptionalStaticDataRouteOption : RequiredStaticDataRouteOption; export type MetaDescriptor = { charSet: 'utf-8'; } | { title: string; } | { name: string; content: string; } | { property: string; content: string; } | { httpEquiv: string; content: string; } | { 'script:ld+json': LdJsonObject; } | { tagName: 'meta' | 'link'; [name: string]: string; } | Record; type LdJsonObject = { [Key in string]: LdJsonValue; } & { [Key in string]?: LdJsonValue | undefined; }; type LdJsonArray = Array | ReadonlyArray; type LdJsonPrimitive = string | number | boolean | null; type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray; export type RouteLinkEntry = {}; export type SearchValidator = ValidatorObj | ValidatorFn | ValidatorAdapter | StandardSchemaValidator | undefined; export type AnySearchValidator = SearchValidator; export type DefaultSearchValidator = SearchValidator, AnySchema>; export type RoutePrefix = string extends TPath ? RootRouteId : TPath extends string ? TPrefix extends RootRouteId ? TPath extends '/' ? '/' : `/${TrimPath}` : `${TPrefix}/${TPath}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight}/${TrimPath}`>}` : never; export type TrimPath = '' extends T ? '' : TrimPathRight>; export type TrimPathLeft = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft : T extends `/${infer U}` ? TrimPathLeft : T; export type TrimPathRight = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight : T; export type LooseReturnType = T extends (...args: Array) => infer TReturn ? TReturn : never; export type LooseAsyncReturnType = T extends (...args: Array) => infer TReturn ? TReturn extends Promise ? TReturn : TReturn : never; export type ContextReturnType = unknown extends TContextFn ? TContextFn : LooseReturnType extends never ? AnyContext : LooseReturnType; export type ContextAsyncReturnType = unknown extends TContextFn ? TContextFn : LooseAsyncReturnType extends never ? AnyContext : LooseAsyncReturnType; export type ResolveRouteContext = Assign, ContextAsyncReturnType>; export type ResolveLoaderData = unknown extends TLoaderFn ? TLoaderFn : LooseAsyncReturnType extends never ? undefined : LooseAsyncReturnType; export type ResolveFullSearchSchema = unknown extends TParentRoute ? ResolveValidatorOutput : IntersectAssign, ResolveValidatorOutput>; export type ResolveFullSearchSchemaInput = IntersectAssign, ResolveSearchValidatorInput>; export type ResolveAllParamsFromParent = Assign, TParams>; export type RouteContextParameter = unknown extends TParentRoute ? TRouterContext : Assign>; export type BeforeLoadContextParameter = Assign, ContextReturnType>; export type ResolveAllContext = Assign, ContextAsyncReturnType>; export interface FullSearchSchemaOption { search: Expand>; } export interface RemountDepsOptions { routeId: TRouteId; search: TFullSearchSchema; params: TAllParams; loaderDeps: TLoaderDeps; } export type MakeRemountDepsOptionsUnion = ParseRoute extends infer TRoute extends AnyRoute ? TRoute extends any ? RemountDepsOptions : never : never; export interface RouteTypes { parentRoute: TParentRoute; path: TPath; to: TrimPathRight; fullPath: TFullPath; customId: TCustomId; id: TId; searchSchema: ResolveValidatorOutput; searchSchemaInput: ResolveSearchValidatorInput; searchValidator: TSearchValidator; fullSearchSchema: ResolveFullSearchSchema; fullSearchSchemaInput: ResolveFullSearchSchemaInput; params: TParams; allParams: ResolveAllParamsFromParent; routerContext: TRouterContext; routeContext: ResolveRouteContext; routeContextFn: TRouteContextFn; beforeLoadFn: TBeforeLoadFn; allContext: ResolveAllContext; children: TChildren; loaderData: ResolveLoaderData; loaderDeps: TLoaderDeps; fileRouteTypes: TFileRouteTypes; } export type ResolveFullPath> = TPrefixed extends RootRouteId ? '/' : TPrefixed; export interface RouteExtensions { } export type RouteLazyFn = (lazyFn: () => Promise) => TRoute; export type RouteAddChildrenFn, in out TLoaderFn, in out TFileRouteTypes> = (children: Constrain | Record>) => Route; export type RouteAddFileChildrenFn, in out TLoaderFn, in out TFileRouteTypes> = (children: TNewChildren) => Route; export type RouteAddFileTypesFn, TLoaderFn, TChildren> = () => Route; export interface Route, in out TLoaderFn, in out TChildren, in out TFileRouteTypes> extends RouteExtensions { fullPath: TFullPath; path: TPath; id: TId; parentRoute: TParentRoute; children?: TChildren; types: RouteTypes; options: RouteOptions; isRoot: TParentRoute extends AnyRoute ? true : false; _componentsPromise?: Promise>; lazyFn?: () => Promise; _lazyPromise?: Promise; rank: number; to: TrimPathRight; init: (opts: { originalIndex: number; defaultSsr?: boolean; }) => void; update: (options: UpdatableRouteOptions) => this; lazy: RouteLazyFn; addChildren: RouteAddChildrenFn; _addFileChildren: RouteAddFileChildrenFn; _addFileTypes: RouteAddFileTypesFn; } export type AnyRoute = Route; export type AnyRouteWithContext = AnyRoute & { types: { allContext: TContext; }; }; export type RouteOptions = {}, TLoaderFn = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext> = BaseRouteOptions & UpdatableRouteOptions, NoInfer, NoInfer, NoInfer, NoInfer, NoInfer, NoInfer, NoInfer, NoInfer, NoInfer>; export type RouteContextFn = (ctx: RouteContextOptions) => any; export type BeforeLoadFn = (ctx: BeforeLoadContextOptions) => any; export type FileBaseRouteOptions = {}, TLoaderFn = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TRemountDepsFn = AnyContext> = ParamsOptions & { validateSearch?: Constrain; shouldReload?: boolean | ((match: LoaderFnContext) => any); context?: Constrain) => any>; beforeLoad?: Constrain) => any>; loaderDeps?: (opts: FullSearchSchemaOption) => TLoaderDeps; remountDeps?: Constrain, Expand>, TLoaderDeps>) => any>; loader?: Constrain) => any>; }; export type BaseRouteOptions = {}, TLoaderFn = undefined, TRouterContext = {}, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext> = RoutePathOptions & FileBaseRouteOptions & { getParentRoute: () => TParentRoute; }; export interface ContextOptions { abortController: AbortController; preload: boolean; params: Expand>; location: ParsedLocation; /** * @deprecated Use `throw redirect({ to: '/somewhere' })` instead **/ navigate: NavigateFn; buildLocation: BuildLocationFn; cause: 'preload' | 'enter' | 'stay'; matches: Array; } export interface RouteContextOptions extends ContextOptions { deps: TLoaderDeps; context: Expand>; } export interface BeforeLoadContextOptions extends ContextOptions, FullSearchSchemaOption { context: Expand>; } type AssetFnContextOptions = { matches: Array, ResolveFullSearchSchema, ResolveLoaderData, ResolveAllContext, TLoaderDeps>>; match: RouteMatch, ResolveFullSearchSchema, ResolveLoaderData, ResolveAllContext, TLoaderDeps>; params: ResolveAllParamsFromParent; loaderData: ResolveLoaderData; }; export interface DefaultUpdatableRouteOptionsExtensions { component?: unknown; errorComponent?: unknown; notFoundComponent?: unknown; pendingComponent?: unknown; } export interface UpdatableRouteOptionsExtensions extends DefaultUpdatableRouteOptionsExtensions { } export interface UpdatableRouteOptions extends UpdatableStaticRouteOption, UpdatableRouteOptionsExtensions { caseSensitive?: boolean; wrapInSuspense?: boolean; pendingMs?: number; pendingMinMs?: number; staleTime?: number; gcTime?: number; preload?: boolean; preloadStaleTime?: number; preloadGcTime?: number; search?: { middlewares?: Array>>; }; /** @deprecated Use search.middlewares instead */ preSearchFilters?: Array>>; /** @deprecated Use search.middlewares instead */ postSearchFilters?: Array>>; onCatch?: (error: Error) => void; onError?: (err: any) => void; onEnter?: (match: RouteMatch, ResolveFullSearchSchema, ResolveLoaderData, ResolveAllContext, TLoaderDeps>) => void; onStay?: (match: RouteMatch, ResolveFullSearchSchema, ResolveLoaderData, ResolveAllContext, TLoaderDeps>) => void; onLeave?: (match: RouteMatch, ResolveFullSearchSchema, ResolveLoaderData, ResolveAllContext, TLoaderDeps>) => void; headers?: (ctx: { loaderData: ResolveLoaderData; }) => Record; head?: (ctx: AssetFnContextOptions) => { links?: AnyRouteMatch['links']; scripts?: AnyRouteMatch['headScripts']; meta?: AnyRouteMatch['meta']; }; scripts?: (ctx: AssetFnContextOptions) => AnyRouteMatch['scripts']; ssr?: boolean; codeSplitGroupings?: Array>; } export type RouteLoaderFn = (match: LoaderFnContext) => any; export interface LoaderFnContext { abortController: AbortController; preload: boolean; params: Expand>; deps: TLoaderDeps; context: Expand>; location: ParsedLocation; /** * @deprecated Use `throw redirect({ to: '/somewhere' })` instead **/ navigate: (opts: NavigateOptions) => Promise | void; parentMatchPromise: TId extends RootRouteId ? never : Promise>; cause: 'preload' | 'enter' | 'stay'; route: AnyRoute; } export type RootRouteOptions = {}, TLoaderFn = undefined> = Omit, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams' | 'params'>; export type RouteConstraints = { TParentRoute: AnyRoute; TPath: string; TFullPath: string; TCustomId: string; TId: string; TSearchSchema: AnySchema; TFullSearchSchema: AnySchema; TParams: Record; TAllParams: Record; TParentContext: AnyContext; TRouteContext: RouteContext; TAllContext: AnyContext; TRouterContext: AnyContext; TChildren: unknown; TRouteTree: AnyRoute; }; export type RouteTypesById = RouteById['types']; export type RouteMask = { routeTree: TRouteTree; from: RoutePaths; to?: any; params?: any; search?: any; hash?: any; state?: any; unmaskOnReload?: boolean; }; /** * @deprecated Use `ErrorComponentProps` instead. */ export type ErrorRouteProps = { error: unknown; info?: { componentStack: string; }; reset: () => void; }; export type ErrorComponentProps = { error: Error; info?: { componentStack: string; }; reset: () => void; }; export type NotFoundRouteProps = { data: unknown; }; export declare class BaseRoute, in out TCustomId extends string = string, in out TId extends string = ResolveId, in out TSearchValidator = undefined, in out TParams = ResolveParams, in out TRouterContext = AnyContext, in out TRouteContextFn = AnyContext, in out TBeforeLoadFn = AnyContext, in out TLoaderDeps extends Record = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown> implements Route { isRoot: TParentRoute extends AnyRoute ? true : false; options: RouteOptions; parentRoute: TParentRoute; private _id; private _path; private _fullPath; private _to; private _ssr; get to(): TrimPathRight; get id(): TId; get path(): TPath; get fullPath(): TFullPath; get ssr(): boolean; children?: TChildren; originalIndex?: number; rank: number; lazyFn?: () => Promise; _lazyPromise?: Promise; _componentsPromise?: Promise>; constructor(options?: RouteOptions); types: RouteTypes; init: (opts: { originalIndex: number; defaultSsr?: boolean; }) => void; addChildren: RouteAddChildrenFn; _addFileChildren: RouteAddFileChildrenFn; _addFileTypes: RouteAddFileTypesFn; updateLoader: (options: { loader: Constrain>; }) => BaseRoute; update: (options: UpdatableRouteOptions) => this; lazy: RouteLazyFn; } export declare class BaseRouteApi { id: TId; constructor({ id }: { id: TId; }); notFound: (opts?: NotFoundError) => NotFoundError; } export declare class BaseRootRoute = {}, in out TLoaderFn = undefined, in out TChildren = unknown, in out TFileRouteTypes = unknown> extends BaseRoute { constructor(options?: RootRouteOptions); } export {};