@tanstack/router-core 1.114.22 → 1.114.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +25 -0
- package/dist/cjs/index.cjs +4 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -1
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +69 -0
- package/dist/cjs/redirect.cjs.map +1 -1
- package/dist/cjs/redirect.d.cts +15 -0
- package/dist/cjs/route.cjs +108 -0
- package/dist/cjs/route.cjs.map +1 -0
- package/dist/cjs/route.d.cts +54 -0
- package/dist/esm/Matches.d.ts +25 -0
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/link.d.ts +69 -0
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/redirect.d.ts +15 -0
- package/dist/esm/redirect.js.map +1 -1
- package/dist/esm/route.d.ts +54 -0
- package/dist/esm/route.js +108 -0
- package/dist/esm/route.js.map +1 -0
- package/package.json +1 -1
- package/src/Matches.ts +25 -0
- package/src/index.ts +3 -2
- package/src/link.ts +69 -6
- package/src/redirect.ts +15 -0
- package/src/route.ts +368 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.js","sources":["../../src/route.ts"],"sourcesContent":["import { joinPaths, trimPathLeft } from './path'\nimport { notFound } from './not-found'\nimport { rootRouteId } from './root'\nimport type { LazyRoute } from './fileRoute'\nimport type { NotFoundError } from './not-found'\nimport type { NavigateOptions, ParsePathParams } from './link'\nimport type { ParsedLocation } from './location'\nimport type {\n AnyRouteMatch,\n MakeRouteMatchFromRoute,\n MakeRouteMatchUnion,\n RouteMatch,\n} from './Matches'\nimport type { RootRouteId } from './root'\nimport type { ParseRoute, RouteById, RoutePaths } from './routeInfo'\nimport type { AnyRouter, RegisteredRouter } from './router'\nimport type { BuildLocationFn, NavigateFn } from './RouterProvider'\nimport type {\n Assign,\n Constrain,\n Expand,\n IntersectAssign,\n NoInfer,\n} from './utils'\nimport type {\n AnySchema,\n AnyStandardSchemaValidator,\n AnyValidator,\n AnyValidatorAdapter,\n AnyValidatorObj,\n DefaultValidator,\n ResolveSearchValidatorInput,\n ResolveValidatorOutput,\n StandardSchemaValidator,\n ValidatorAdapter,\n ValidatorFn,\n ValidatorObj,\n} from './validators'\n\nexport type AnyPathParams = {}\n\nexport type SearchSchemaInput = {\n __TSearchSchemaInput__: 'TSearchSchemaInput'\n}\n\nexport type AnyContext = {}\n\nexport interface RouteContext {}\n\nexport type PreloadableObj = { preload?: () => Promise<void> }\n\nexport type RoutePathOptions<TCustomId, TPath> =\n | {\n path: TPath\n }\n | {\n id: TCustomId\n }\n\nexport interface StaticDataRouteOption {}\n\nexport type RoutePathOptionsIntersection<TCustomId, TPath> = {\n path: TPath\n id: TCustomId\n}\n\nexport type SearchFilter<TInput, TResult = TInput> = (prev: TInput) => TResult\n\nexport type SearchMiddlewareContext<TSearchSchema> = {\n search: TSearchSchema\n next: (newSearch: TSearchSchema) => TSearchSchema\n}\n\nexport type SearchMiddleware<TSearchSchema> = (\n ctx: SearchMiddlewareContext<TSearchSchema>,\n) => TSearchSchema\n\nexport type ResolveId<\n TParentRoute,\n TCustomId extends string,\n TPath extends string,\n> = TParentRoute extends { id: infer TParentId extends string }\n ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>\n : RootRouteId\n\nexport type InferFullSearchSchema<TRoute> = TRoute extends {\n types: {\n fullSearchSchema: infer TFullSearchSchema\n }\n}\n ? TFullSearchSchema\n : {}\n\nexport type InferFullSearchSchemaInput<TRoute> = TRoute extends {\n types: {\n fullSearchSchemaInput: infer TFullSearchSchemaInput\n }\n}\n ? TFullSearchSchemaInput\n : {}\n\nexport type InferAllParams<TRoute> = TRoute extends {\n types: {\n allParams: infer TAllParams\n }\n}\n ? TAllParams\n : {}\n\nexport type InferAllContext<TRoute> = unknown extends TRoute\n ? TRoute\n : TRoute extends {\n types: {\n allContext: infer TAllContext\n }\n }\n ? TAllContext\n : {}\n\nexport type ResolveSearchSchemaFnInput<TSearchValidator> =\n TSearchValidator extends (input: infer TSearchSchemaInput) => any\n ? TSearchSchemaInput extends SearchSchemaInput\n ? Omit<TSearchSchemaInput, keyof SearchSchemaInput>\n : ResolveSearchSchemaFn<TSearchValidator>\n : AnySchema\n\nexport type ResolveSearchSchemaInput<TSearchValidator> =\n TSearchValidator extends AnyStandardSchemaValidator\n ? NonNullable<TSearchValidator['~standard']['types']>['input']\n : TSearchValidator extends AnyValidatorAdapter\n ? TSearchValidator['types']['input']\n : TSearchValidator extends AnyValidatorObj\n ? ResolveSearchSchemaFnInput<TSearchValidator['parse']>\n : ResolveSearchSchemaFnInput<TSearchValidator>\n\nexport type ResolveSearchSchemaFn<TSearchValidator> = TSearchValidator extends (\n ...args: any\n) => infer TSearchSchema\n ? TSearchSchema\n : AnySchema\n\nexport type ResolveSearchSchema<TSearchValidator> =\n unknown extends TSearchValidator\n ? TSearchValidator\n : TSearchValidator extends AnyStandardSchemaValidator\n ? NonNullable<TSearchValidator['~standard']['types']>['output']\n : TSearchValidator extends AnyValidatorAdapter\n ? TSearchValidator['types']['output']\n : TSearchValidator extends AnyValidatorObj\n ? ResolveSearchSchemaFn<TSearchValidator['parse']>\n : ResolveSearchSchemaFn<TSearchValidator>\n\nexport type ParseSplatParams<TPath extends string> = TPath &\n `${string}$` extends never\n ? TPath & `${string}$/${string}` extends never\n ? never\n : '_splat'\n : '_splat'\n\nexport interface SplatParams {\n _splat?: string\n}\n\nexport type ResolveParams<TPath extends string> =\n ParseSplatParams<TPath> extends never\n ? Record<ParsePathParams<TPath>, string>\n : Record<ParsePathParams<TPath>, string> & SplatParams\n\nexport type ParseParamsFn<in out TPath extends string, in out TParams> = (\n rawParams: ResolveParams<TPath>,\n) => TParams extends Record<ParsePathParams<TPath>, any>\n ? TParams\n : Record<ParsePathParams<TPath>, any>\n\nexport type StringifyParamsFn<in out TPath extends string, in out TParams> = (\n params: TParams,\n) => ResolveParams<TPath>\n\nexport type ParamsOptions<in out TPath extends string, in out TParams> = {\n params?: {\n parse?: ParseParamsFn<TPath, TParams>\n stringify?: StringifyParamsFn<TPath, TParams>\n }\n\n /** \n @deprecated Use params.parse instead\n */\n parseParams?: ParseParamsFn<TPath, TParams>\n\n /** \n @deprecated Use params.stringify instead\n */\n stringifyParams?: StringifyParamsFn<TPath, TParams>\n}\n\ninterface RequiredStaticDataRouteOption {\n staticData: StaticDataRouteOption\n}\n\ninterface OptionalStaticDataRouteOption {\n staticData?: StaticDataRouteOption\n}\n\nexport type UpdatableStaticRouteOption = {} extends StaticDataRouteOption\n ? OptionalStaticDataRouteOption\n : RequiredStaticDataRouteOption\n\nexport type MetaDescriptor =\n | { charSet: 'utf-8' }\n | { title: string }\n | { name: string; content: string }\n | { property: string; content: string }\n | { httpEquiv: string; content: string }\n | { 'script:ld+json': LdJsonObject }\n | { tagName: 'meta' | 'link'; [name: string]: string }\n | Record<string, unknown>\n\ntype LdJsonObject = { [Key in string]: LdJsonValue } & {\n [Key in string]?: LdJsonValue | undefined\n}\ntype LdJsonArray = Array<LdJsonValue> | ReadonlyArray<LdJsonValue>\ntype LdJsonPrimitive = string | number | boolean | null\ntype LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray\n\nexport type RouteLinkEntry = {}\n\nexport type SearchValidator<TInput, TOutput> =\n | ValidatorObj<TInput, TOutput>\n | ValidatorFn<TInput, TOutput>\n | ValidatorAdapter<TInput, TOutput>\n | StandardSchemaValidator<TInput, TOutput>\n | undefined\n\nexport type AnySearchValidator = SearchValidator<any, any>\n\nexport type DefaultSearchValidator = SearchValidator<\n Record<string, unknown>,\n AnySchema\n>\n\nexport type RoutePrefix<\n TPrefix extends string,\n TPath extends string,\n> = string extends TPath\n ? RootRouteId\n : TPath extends string\n ? TPrefix extends RootRouteId\n ? TPath extends '/'\n ? '/'\n : `/${TrimPath<TPath>}`\n : `${TPrefix}/${TPath}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}`\n : never\n\nexport type TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\nexport type TrimPathLeft<T extends string> =\n T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\n\nexport type TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport type LooseReturnType<T> = T extends (\n ...args: Array<any>\n) => infer TReturn\n ? TReturn\n : never\n\nexport type LooseAsyncReturnType<T> = T extends (\n ...args: Array<any>\n) => infer TReturn\n ? TReturn extends Promise<infer TReturn>\n ? TReturn\n : TReturn\n : never\n\nexport type ContextReturnType<TContextFn> = unknown extends TContextFn\n ? TContextFn\n : LooseReturnType<TContextFn> extends never\n ? AnyContext\n : LooseReturnType<TContextFn>\n\nexport type ContextAsyncReturnType<TContextFn> = unknown extends TContextFn\n ? TContextFn\n : LooseAsyncReturnType<TContextFn> extends never\n ? AnyContext\n : LooseAsyncReturnType<TContextFn>\n\nexport type ResolveRouteContext<TRouteContextFn, TBeforeLoadFn> = Assign<\n ContextReturnType<TRouteContextFn>,\n ContextAsyncReturnType<TBeforeLoadFn>\n>\n\nexport type ResolveLoaderData<TLoaderFn> = unknown extends TLoaderFn\n ? TLoaderFn\n : LooseAsyncReturnType<TLoaderFn> extends never\n ? undefined\n : LooseAsyncReturnType<TLoaderFn>\n\nexport type ResolveFullSearchSchema<\n TParentRoute extends AnyRoute,\n TSearchValidator,\n> = unknown extends TParentRoute\n ? ResolveValidatorOutput<TSearchValidator>\n : IntersectAssign<\n InferFullSearchSchema<TParentRoute>,\n ResolveValidatorOutput<TSearchValidator>\n >\n\nexport type ResolveFullSearchSchemaInput<\n TParentRoute extends AnyRoute,\n TSearchValidator,\n> = IntersectAssign<\n InferFullSearchSchemaInput<TParentRoute>,\n ResolveSearchValidatorInput<TSearchValidator>\n>\n\nexport type ResolveAllParamsFromParent<\n TParentRoute extends AnyRoute,\n TParams,\n> = Assign<InferAllParams<TParentRoute>, TParams>\n\nexport type RouteContextParameter<\n TParentRoute extends AnyRoute,\n TRouterContext,\n> = unknown extends TParentRoute\n ? TRouterContext\n : Assign<TRouterContext, InferAllContext<TParentRoute>>\n\nexport type BeforeLoadContextParameter<\n TParentRoute extends AnyRoute,\n TRouterContext,\n TRouteContextFn,\n> = Assign<\n RouteContextParameter<TParentRoute, TRouterContext>,\n ContextReturnType<TRouteContextFn>\n>\n\nexport type ResolveAllContext<\n TParentRoute extends AnyRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n> = Assign<\n BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>,\n ContextAsyncReturnType<TBeforeLoadFn>\n>\nexport interface FullSearchSchemaOption<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n> {\n search: Expand<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n}\n\nexport interface RemountDepsOptions<\n in out TRouteId,\n in out TFullSearchSchema,\n in out TAllParams,\n in out TLoaderDeps,\n> {\n routeId: TRouteId\n search: TFullSearchSchema\n params: TAllParams\n loaderDeps: TLoaderDeps\n}\n\nexport type MakeRemountDepsOptionsUnion<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n> =\n ParseRoute<TRouteTree> extends infer TRoute extends AnyRoute\n ? TRoute extends any\n ? RemountDepsOptions<\n TRoute['id'],\n TRoute['types']['fullSearchSchema'],\n TRoute['types']['allParams'],\n TRoute['types']['loaderDeps']\n >\n : never\n : never\n\nexport interface RouteTypes<\n in out TParentRoute extends AnyRoute,\n in out TPath extends string,\n in out TFullPath extends string,\n in out TCustomId extends string,\n in out TId extends string,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps,\n in out TLoaderFn,\n in out TChildren,\n in out TFileRouteTypes,\n> {\n parentRoute: TParentRoute\n path: TPath\n to: TrimPathRight<TFullPath>\n fullPath: TFullPath\n customId: TCustomId\n id: TId\n searchSchema: ResolveValidatorOutput<TSearchValidator>\n searchSchemaInput: ResolveSearchValidatorInput<TSearchValidator>\n searchValidator: TSearchValidator\n fullSearchSchema: ResolveFullSearchSchema<TParentRoute, TSearchValidator>\n fullSearchSchemaInput: ResolveFullSearchSchemaInput<\n TParentRoute,\n TSearchValidator\n >\n params: TParams\n allParams: ResolveAllParamsFromParent<TParentRoute, TParams>\n routerContext: TRouterContext\n routeContext: ResolveRouteContext<TRouteContextFn, TBeforeLoadFn>\n routeContextFn: TRouteContextFn\n beforeLoadFn: TBeforeLoadFn\n allContext: ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n children: TChildren\n loaderData: ResolveLoaderData<TLoaderFn>\n loaderDeps: TLoaderDeps\n fileRouteTypes: TFileRouteTypes\n}\n\nexport type ResolveFullPath<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>,\n> = TPrefixed extends RootRouteId ? '/' : TPrefixed\n\nexport interface RouteExtensions<TId, TFullPath> {}\n\nexport type RouteLazyFn<TRoute extends AnyRoute> = (\n lazyFn: () => Promise<LazyRoute>,\n) => TRoute\n\nexport type RouteAddChildrenFn<\n in out TParentRoute extends AnyRoute,\n in out TPath extends string,\n in out TFullPath extends string,\n in out TCustomId extends string,\n in out TId extends string,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps extends Record<string, any>,\n in out TLoaderFn,\n in out TFileRouteTypes,\n> = <const TNewChildren>(\n children: Constrain<\n TNewChildren,\n ReadonlyArray<AnyRoute> | Record<string, AnyRoute>\n >,\n) => Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n>\n\nexport type RouteAddFileChildrenFn<\n in out TParentRoute extends AnyRoute,\n in out TPath extends string,\n in out TFullPath extends string,\n in out TCustomId extends string,\n in out TId extends string,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps extends Record<string, any>,\n in out TLoaderFn,\n in out TFileRouteTypes,\n> = <const TNewChildren>(\n children: TNewChildren,\n) => Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TNewChildren,\n TFileRouteTypes\n>\n\nexport type RouteAddFileTypesFn<\n TParentRoute extends AnyRoute,\n TPath extends string,\n TFullPath extends string,\n TCustomId extends string,\n TId extends string,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps extends Record<string, any>,\n TLoaderFn,\n TChildren,\n> = <TNewFileRouteTypes>() => Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TNewFileRouteTypes\n>\n\nexport interface Route<\n in out TParentRoute extends AnyRoute,\n in out TPath extends string,\n in out TFullPath extends string,\n in out TCustomId extends string,\n in out TId extends string,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps extends Record<string, any>,\n in out TLoaderFn,\n in out TChildren,\n in out TFileRouteTypes,\n> extends RouteExtensions<TId, TFullPath> {\n fullPath: TFullPath\n path: TPath\n id: TId\n parentRoute: TParentRoute\n children?: TChildren\n types: RouteTypes<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n isRoot: TParentRoute extends AnyRoute ? true : false\n _componentsPromise?: Promise<Array<void>>\n lazyFn?: () => Promise<LazyRoute>\n _lazyPromise?: Promise<void>\n rank: number\n to: TrimPathRight<TFullPath>\n init: (opts: { originalIndex: number; defaultSsr?: boolean }) => void\n update: (\n options: UpdatableRouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => this\n lazy: RouteLazyFn<this>\n addChildren: RouteAddChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n >\n _addFileChildren: RouteAddFileChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n >\n _addFileTypes: RouteAddFileTypesFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n >\n}\n\nexport type AnyRoute = Route<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n>\n\nexport type AnyRouteWithContext<TContext> = AnyRoute & {\n types: { allContext: TContext }\n}\n\nexport type RouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TId extends string = string,\n TCustomId extends string = string,\n TFullPath extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = AnyPathParams,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n> = BaseRouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n> &\n UpdatableRouteOptions<\n NoInfer<TParentRoute>,\n NoInfer<TCustomId>,\n NoInfer<TFullPath>,\n NoInfer<TParams>,\n NoInfer<TSearchValidator>,\n NoInfer<TLoaderFn>,\n NoInfer<TLoaderDeps>,\n NoInfer<TRouterContext>,\n NoInfer<TRouteContextFn>,\n NoInfer<TBeforeLoadFn>\n >\n\nexport type RouteContextFn<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n> = (\n ctx: RouteContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext\n >,\n) => any\n\nexport type BeforeLoadFn<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n> = (\n ctx: BeforeLoadContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn\n >,\n) => any\n\nexport type FileBaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TId extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TRemountDepsFn = AnyContext,\n> = ParamsOptions<TPath, TParams> & {\n validateSearch?: Constrain<TSearchValidator, AnyValidator, DefaultValidator>\n\n shouldReload?:\n | boolean\n | ((\n match: LoaderFnContext<\n TParentRoute,\n TId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => any)\n\n context?: Constrain<\n TRouteContextFn,\n (\n ctx: RouteContextOptions<\n TParentRoute,\n TParams,\n TRouterContext,\n TLoaderDeps\n >,\n ) => any\n >\n\n // This async function is called before a route is loaded.\n // If an error is thrown here, the route's loader will not be called.\n // If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onError` function.\n // If thrown during a preload event, the error will be logged to the console.\n beforeLoad?: Constrain<\n TBeforeLoadFn,\n (\n ctx: BeforeLoadContextOptions<\n TParentRoute,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn\n >,\n ) => any\n >\n\n loaderDeps?: (\n opts: FullSearchSchemaOption<TParentRoute, TSearchValidator>,\n ) => TLoaderDeps\n\n remountDeps?: Constrain<\n TRemountDepsFn,\n (\n opt: RemountDepsOptions<\n TId,\n FullSearchSchemaOption<TParentRoute, TSearchValidator>,\n Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>,\n TLoaderDeps\n >,\n ) => any\n >\n\n loader?: Constrain<\n TLoaderFn,\n (\n ctx: LoaderFnContext<\n TParentRoute,\n TId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) => any\n >\n}\n\nexport type BaseRouteOptions<\n TParentRoute extends AnyRoute = AnyRoute,\n TId extends string = string,\n TCustomId extends string = string,\n TPath extends string = string,\n TSearchValidator = undefined,\n TParams = {},\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n> = RoutePathOptions<TCustomId, TPath> &\n FileBaseRouteOptions<\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > & {\n getParentRoute: () => TParentRoute\n }\n\nexport interface ContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TParams,\n> {\n abortController: AbortController\n preload: boolean\n params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>\n location: ParsedLocation\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: NavigateFn\n buildLocation: BuildLocationFn\n cause: 'preload' | 'enter' | 'stay'\n matches: Array<MakeRouteMatchUnion>\n}\n\nexport interface RouteContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TParams,\n in out TRouterContext,\n in out TLoaderDeps,\n> extends ContextOptions<TParentRoute, TParams> {\n deps: TLoaderDeps\n context: Expand<RouteContextParameter<TParentRoute, TRouterContext>>\n}\n\nexport interface BeforeLoadContextOptions<\n in out TParentRoute extends AnyRoute,\n in out TSearchValidator,\n in out TParams,\n in out TRouterContext,\n in out TRouteContextFn,\n> extends ContextOptions<TParentRoute, TParams>,\n FullSearchSchemaOption<TParentRoute, TSearchValidator> {\n context: Expand<\n BeforeLoadContextParameter<TParentRoute, TRouterContext, TRouteContextFn>\n >\n}\n\ntype AssetFnContextOptions<\n in out TRouteId,\n in out TFullPath,\n in out TParentRoute extends AnyRoute,\n in out TParams,\n in out TSearchValidator,\n in out TLoaderFn,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n in out TLoaderDeps,\n> = {\n matches: Array<\n RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >\n >\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >\n params: ResolveAllParamsFromParent<TParentRoute, TParams>\n loaderData: ResolveLoaderData<TLoaderFn>\n}\n\nexport interface DefaultUpdatableRouteOptionsExtensions {\n component?: unknown\n errorComponent?: unknown\n notFoundComponent?: unknown\n pendingComponent?: unknown\n}\n\nexport interface UpdatableRouteOptionsExtensions\n extends DefaultUpdatableRouteOptionsExtensions {}\n\nexport interface UpdatableRouteOptions<\n in out TParentRoute extends AnyRoute,\n in out TRouteId,\n in out TFullPath,\n in out TParams,\n in out TSearchValidator,\n in out TLoaderFn,\n in out TLoaderDeps,\n in out TRouterContext,\n in out TRouteContextFn,\n in out TBeforeLoadFn,\n> extends UpdatableStaticRouteOption,\n UpdatableRouteOptionsExtensions {\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n // If true, this route will be forcefully wrapped in a suspense boundary\n wrapInSuspense?: boolean\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n\n pendingMs?: number\n pendingMinMs?: number\n staleTime?: number\n gcTime?: number\n preload?: boolean\n preloadStaleTime?: number\n preloadGcTime?: number\n search?: {\n middlewares?: Array<\n SearchMiddleware<\n ResolveFullSearchSchemaInput<TParentRoute, TSearchValidator>\n >\n >\n }\n /** \n @deprecated Use search.middlewares instead\n */\n preSearchFilters?: Array<\n SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n >\n /** \n @deprecated Use search.middlewares instead\n */\n postSearchFilters?: Array<\n SearchFilter<ResolveFullSearchSchema<TParentRoute, TSearchValidator>>\n >\n onCatch?: (error: Error) => void\n onError?: (err: any) => void\n // These functions are called as route matches are loaded, stick around and leave the active\n // matches\n onEnter?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n onStay?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n onLeave?: (\n match: RouteMatch<\n TRouteId,\n TFullPath,\n ResolveAllParamsFromParent<TParentRoute, TParams>,\n ResolveFullSearchSchema<TParentRoute, TSearchValidator>,\n ResolveLoaderData<TLoaderFn>,\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n TLoaderDeps\n >,\n ) => void\n headers?: (ctx: {\n loaderData: ResolveLoaderData<TLoaderFn>\n }) => Record<string, string>\n head?: (\n ctx: AssetFnContextOptions<\n TRouteId,\n TFullPath,\n TParentRoute,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps\n >,\n ) => {\n links?: AnyRouteMatch['links']\n scripts?: AnyRouteMatch['headScripts']\n meta?: AnyRouteMatch['meta']\n }\n scripts?: (\n ctx: AssetFnContextOptions<\n TRouteId,\n TFullPath,\n TParentRoute,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps\n >,\n ) => AnyRouteMatch['scripts']\n ssr?: boolean\n codeSplitGroupings?: Array<\n Array<\n | 'loader'\n | 'component'\n | 'pendingComponent'\n | 'notFoundComponent'\n | 'errorComponent'\n >\n >\n}\n\nexport type RouteLoaderFn<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TId extends string = string,\n in out TParams = {},\n in out TLoaderDeps = {},\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n> = (\n match: LoaderFnContext<\n TParentRoute,\n TId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n) => any\n\nexport interface LoaderFnContext<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TId extends string = string,\n in out TParams = {},\n in out TLoaderDeps = {},\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n> {\n abortController: AbortController\n preload: boolean\n params: Expand<ResolveAllParamsFromParent<TParentRoute, TParams>>\n deps: TLoaderDeps\n context: Expand<\n ResolveAllContext<\n TParentRoute,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\n location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps\n /**\n * @deprecated Use `throw redirect({ to: '/somewhere' })` instead\n **/\n navigate: (opts: NavigateOptions<AnyRouter>) => Promise<void> | void\n // root route does not have a parent match\n parentMatchPromise: TId extends RootRouteId\n ? never\n : Promise<MakeRouteMatchFromRoute<TParentRoute>>\n cause: 'preload' | 'enter' | 'stay'\n route: AnyRoute\n}\n\nexport type RootRouteOptions<\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n> = Omit<\n RouteOptions<\n any, // TParentRoute\n RootRouteId, // TId\n RootRouteId, // TCustomId\n '', // TFullPath\n '', // TPath\n TSearchValidator,\n {}, // TParams\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n | 'path'\n | 'id'\n | 'getParentRoute'\n | 'caseSensitive'\n | 'parseParams'\n | 'stringifyParams'\n | 'params'\n>\n\nexport type RouteConstraints = {\n TParentRoute: AnyRoute\n TPath: string\n TFullPath: string\n TCustomId: string\n TId: string\n TSearchSchema: AnySchema\n TFullSearchSchema: AnySchema\n TParams: Record<string, any>\n TAllParams: Record<string, any>\n TParentContext: AnyContext\n TRouteContext: RouteContext\n TAllContext: AnyContext\n TRouterContext: AnyContext\n TChildren: unknown\n TRouteTree: AnyRoute\n}\n\nexport type RouteTypesById<TRouter extends AnyRouter, TId> = RouteById<\n TRouter['routeTree'],\n TId\n>['types']\n\nexport type RouteMask<TRouteTree extends AnyRoute> = {\n routeTree: TRouteTree\n from: RoutePaths<TRouteTree>\n to?: any\n params?: any\n search?: any\n hash?: any\n state?: any\n unmaskOnReload?: boolean\n}\n\n/**\n * @deprecated Use `ErrorComponentProps` instead.\n */\nexport type ErrorRouteProps = {\n error: unknown\n info?: { componentStack: string }\n reset: () => void\n}\n\nexport type ErrorComponentProps = {\n error: Error\n info?: { componentStack: string }\n reset: () => void\n}\nexport type NotFoundRouteProps = {\n // TODO: Make sure this is `| null | undefined` (this is for global not-founds)\n data: unknown\n}\n\nexport class BaseRoute<\n in out TParentRoute extends AnyRoute = AnyRoute,\n in out TPath extends string = '/',\n in out TFullPath extends string = ResolveFullPath<TParentRoute, TPath>,\n in out TCustomId extends string = string,\n in out TId extends string = ResolveId<TParentRoute, TCustomId, TPath>,\n in out TSearchValidator = undefined,\n in out TParams = ResolveParams<TPath>,\n in out TRouterContext = AnyContext,\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> implements\n Route<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n{\n isRoot: TParentRoute extends AnyRoute ? true : false\n options: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n\n // The following properties are set up in this.init()\n parentRoute!: TParentRoute\n private _id!: TId\n private _path!: TPath\n private _fullPath!: TFullPath\n private _to!: TrimPathRight<TFullPath>\n private _ssr!: boolean\n\n public get to() {\n return this._to\n }\n\n public get id() {\n return this._id\n }\n\n public get path() {\n return this._path\n }\n\n public get fullPath() {\n return this._fullPath\n }\n\n public get ssr() {\n return this._ssr\n }\n\n // Optional\n children?: TChildren\n originalIndex?: number\n rank!: number\n lazyFn?: () => Promise<LazyRoute>\n _lazyPromise?: Promise<void>\n _componentsPromise?: Promise<Array<void>>\n\n constructor(\n options?: RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ) {\n this.options = (options as any) || {}\n this.isRoot = !options?.getParentRoute as any\n\n if ((options as any)?.id && (options as any)?.path) {\n throw new Error(`Route cannot have both an 'id' and a 'path' option.`)\n }\n }\n\n types!: RouteTypes<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n\n init = (opts: { originalIndex: number; defaultSsr?: boolean }): void => {\n this.originalIndex = opts.originalIndex\n\n const options = this.options as\n | (RouteOptions<\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n > &\n RoutePathOptionsIntersection<TCustomId, TPath>)\n | undefined\n\n const isRoot = !options?.path && !options?.id\n\n this.parentRoute = this.options.getParentRoute?.()\n\n if (isRoot) {\n this._path = rootRouteId as TPath\n } else if (!this.parentRoute) {\n throw new Error(\n `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,\n )\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options?.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPathLeft(path)\n }\n\n const customId = options?.id || path\n\n // Strip the parentId prefix from the first level of children\n let id = isRoot\n ? rootRouteId\n : joinPaths([\n this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,\n customId,\n ])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])\n\n this._path = path as TPath\n this._id = id as TId\n this._fullPath = fullPath as TFullPath\n this._to = fullPath as TrimPathRight<TFullPath>\n this._ssr = options?.ssr ?? opts.defaultSsr ?? true\n }\n\n addChildren: RouteAddChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n > = (children) => {\n return this._addFileChildren(children) as any\n }\n\n _addFileChildren: RouteAddFileChildrenFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TFileRouteTypes\n > = (children) => {\n if (Array.isArray(children)) {\n this.children = children as TChildren\n }\n\n if (typeof children === 'object' && children !== null) {\n this.children = Object.values(children) as TChildren\n }\n\n return this as any\n }\n\n _addFileTypes: RouteAddFileTypesFn<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren\n > = () => {\n return this as any\n }\n\n updateLoader = <TNewLoaderFn>(options: {\n loader: Constrain<\n TNewLoaderFn,\n RouteLoaderFn<\n TParentRoute,\n TCustomId,\n TParams,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >\n >\n }) => {\n Object.assign(this.options, options)\n return this as unknown as BaseRoute<\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TNewLoaderFn,\n TChildren,\n TFileRouteTypes\n >\n }\n\n update = (\n options: UpdatableRouteOptions<\n TParentRoute,\n TCustomId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): this => {\n Object.assign(this.options, options)\n return this\n }\n\n lazy: RouteLazyFn<this> = (lazyFn) => {\n this.lazyFn = lazyFn\n return this\n }\n}\n\nexport class BaseRouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> {\n id: TId\n\n constructor({ id }: { id: TId }) {\n this.id = id as any\n }\n\n notFound = (opts?: NotFoundError) => {\n return notFound({ routeId: this.id as string, ...opts })\n }\n}\n\nexport class BaseRootRoute<\n in out TSearchValidator = undefined,\n in out TRouterContext = {},\n in out TRouteContextFn = AnyContext,\n in out TBeforeLoadFn = AnyContext,\n in out TLoaderDeps extends Record<string, any> = {},\n in out TLoaderFn = undefined,\n in out TChildren = unknown,\n in out TFileRouteTypes = unknown,\n> extends BaseRoute<\n any, // TParentRoute\n '/', // TPath\n '/', // TFullPath\n string, // TCustomId\n RootRouteId, // TId\n TSearchValidator, // TSearchValidator\n {}, // TParams\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren, // TChildren\n TFileRouteTypes\n> {\n constructor(\n options?: RootRouteOptions<\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn\n >,\n ) {\n super(options as any)\n }\n}\n\n//\n"],"names":["options"],"mappings":";;;AAwuCO,MAAM,UAgCb;AAAA,EAqDE,YACE,SAcA;AA0BF,SAAA,OAAO,CAAC,SAAgE;;AACtE,WAAK,gBAAgB,KAAK;AAE1B,YAAMA,WAAU,KAAK;AAkBrB,YAAM,SAAS,EAACA,YAAA,gBAAAA,SAAS,SAAQ,EAACA,YAAA,gBAAAA,SAAS;AAEtC,WAAA,eAAc,gBAAK,SAAQ,mBAAb;AAEnB,UAAI,QAAQ;AACV,aAAK,QAAQ;AAAA,MAAA,WACJ,CAAC,KAAK,aAAa;AAC5B,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MAAA;AAGE,UAAA,OAA2B,SAAS,cAAcA,YAAA,gBAAAA,SAAS;AAG3D,UAAA,QAAQ,SAAS,KAAK;AACxB,eAAO,aAAa,IAAI;AAAA,MAAA;AAGpB,YAAA,YAAWA,YAAA,gBAAAA,SAAS,OAAM;AAG5B,UAAA,KAAK,SACL,cACA,UAAU;AAAA,QACR,KAAK,YAAY,OAAO,cAAc,KAAK,KAAK,YAAY;AAAA,QAC5D;AAAA,MAAA,CACD;AAEL,UAAI,SAAS,aAAa;AACjB,eAAA;AAAA,MAAA;AAGT,UAAI,OAAO,aAAa;AACtB,aAAK,UAAU,CAAC,KAAK,EAAE,CAAC;AAAA,MAAA;AAGpB,YAAA,WACJ,OAAO,cAAc,MAAM,UAAU,CAAC,KAAK,YAAY,UAAU,IAAI,CAAC;AAExE,WAAK,QAAQ;AACb,WAAK,MAAM;AACX,WAAK,YAAY;AACjB,WAAK,MAAM;AACX,WAAK,QAAOA,YAAA,gBAAAA,SAAS,QAAO,KAAK,cAAc;AAAA,IACjD;AAEA,SAAA,cAcI,CAAC,aAAa;AACT,aAAA,KAAK,iBAAiB,QAAQ;AAAA,IACvC;AAEA,SAAA,mBAcI,CAAC,aAAa;AACZ,UAAA,MAAM,QAAQ,QAAQ,GAAG;AAC3B,aAAK,WAAW;AAAA,MAAA;AAGlB,UAAI,OAAO,aAAa,YAAY,aAAa,MAAM;AAChD,aAAA,WAAW,OAAO,OAAO,QAAQ;AAAA,MAAA;AAGjC,aAAA;AAAA,IACT;AAEA,SAAA,gBAcI,MAAM;AACD,aAAA;AAAA,IACT;AAEA,SAAA,eAAe,CAAeA,aAaxB;AACG,aAAA,OAAO,KAAK,SAASA,QAAO;AAC5B,aAAA;AAAA,IAgBT;AAEA,SAAA,SAAS,CACPA,aAYS;AACF,aAAA,OAAO,KAAK,SAASA,QAAO;AAC5B,aAAA;AAAA,IACT;AAEA,SAAA,OAA0B,CAAC,WAAW;AACpC,WAAK,SAAS;AACP,aAAA;AAAA,IACT;AAjNO,SAAA,UAAW,WAAmB,CAAC;AAC/B,SAAA,SAAS,EAAC,mCAAS;AAEnB,SAAA,mCAAiB,QAAO,mCAAiB,OAAM;AAC5C,YAAA,IAAI,MAAM,qDAAqD;AAAA,IAAA;AAAA,EACvE;AAAA,EAjDF,IAAW,KAAK;AACd,WAAO,KAAK;AAAA,EAAA;AAAA,EAGd,IAAW,KAAK;AACd,WAAO,KAAK;AAAA,EAAA;AAAA,EAGd,IAAW,OAAO;AAChB,WAAO,KAAK;AAAA,EAAA;AAAA,EAGd,IAAW,WAAW;AACpB,WAAO,KAAK;AAAA,EAAA;AAAA,EAGd,IAAW,MAAM;AACf,WAAO,KAAK;AAAA,EAAA;AA6OhB;AAEO,MAAM,aAAgE;AAAA,EAG3E,YAAY,EAAE,MAAmB;AAIjC,SAAA,WAAW,CAAC,SAAyB;AACnC,aAAO,SAAS,EAAE,SAAS,KAAK,IAAc,GAAG,MAAM;AAAA,IACzD;AALE,SAAK,KAAK;AAAA,EAAA;AAMd;AAEO,MAAM,sBASH,UAeR;AAAA,EACA,YACE,SAQA;AACA,UAAM,OAAc;AAAA,EAAA;AAExB;"}
|
package/package.json
CHANGED
package/src/Matches.ts
CHANGED
|
@@ -206,9 +206,34 @@ export type MakeRouteMatchUnion<
|
|
|
206
206
|
>
|
|
207
207
|
: never
|
|
208
208
|
|
|
209
|
+
/**
|
|
210
|
+
* The `MatchRouteOptions` type is used to describe the options that can be used when matching a route.
|
|
211
|
+
*
|
|
212
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#matchrouteoptions-type)
|
|
213
|
+
*/
|
|
209
214
|
export interface MatchRouteOptions {
|
|
215
|
+
/**
|
|
216
|
+
* If `true`, will match against pending location instead of the current location.
|
|
217
|
+
*
|
|
218
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#pending-property)
|
|
219
|
+
*/
|
|
210
220
|
pending?: boolean
|
|
221
|
+
/**
|
|
222
|
+
* If `true`, will match against the current location with case sensitivity.
|
|
223
|
+
*
|
|
224
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#casesensitive-property)
|
|
225
|
+
*/
|
|
211
226
|
caseSensitive?: boolean
|
|
227
|
+
/**
|
|
228
|
+
* If `true`, will match against the current location's search params using a deep inclusive check. e.g. `{ a: 1 }` will match for a current location of `{ a: 1, b: 2 }`.
|
|
229
|
+
*
|
|
230
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#includesearch-property)
|
|
231
|
+
*/
|
|
212
232
|
includeSearch?: boolean
|
|
233
|
+
/**
|
|
234
|
+
* If `true`, will match against the current location using a fuzzy match. e.g. `/posts` will match for a current location of `/posts/123`.
|
|
235
|
+
*
|
|
236
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/MatchRouteOptionsType#fuzzy-property)
|
|
237
|
+
*/
|
|
213
238
|
fuzzy?: boolean
|
|
214
239
|
}
|
package/src/index.ts
CHANGED
|
@@ -115,6 +115,7 @@ export { encode, decode } from './qss'
|
|
|
115
115
|
export { rootRouteId } from './root'
|
|
116
116
|
export type { RootRouteId } from './root'
|
|
117
117
|
|
|
118
|
+
export { BaseRoute, BaseRouteApi, BaseRootRoute } from './route'
|
|
118
119
|
export type {
|
|
119
120
|
AnyPathParams,
|
|
120
121
|
SearchSchemaInput,
|
|
@@ -182,10 +183,10 @@ export type {
|
|
|
182
183
|
RouteLoaderFn,
|
|
183
184
|
LoaderFnContext,
|
|
184
185
|
RouteContextFn,
|
|
185
|
-
RouteContextOptions,
|
|
186
186
|
BeforeLoadFn,
|
|
187
|
-
BeforeLoadContextOptions,
|
|
188
187
|
ContextOptions,
|
|
188
|
+
RouteContextOptions,
|
|
189
|
+
BeforeLoadContextOptions,
|
|
189
190
|
RootRouteOptions,
|
|
190
191
|
UpdatableRouteOptionsExtensions,
|
|
191
192
|
RouteConstraints,
|
package/src/link.ts
CHANGED
|
@@ -216,21 +216,64 @@ export type NavigateOptions<
|
|
|
216
216
|
TMaskTo extends string = '.',
|
|
217
217
|
> = ToOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & NavigateOptionProps
|
|
218
218
|
|
|
219
|
+
/**
|
|
220
|
+
* The NavigateOptions type is used to describe the options that can be used when describing a navigation action in TanStack Router.
|
|
221
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType)
|
|
222
|
+
*/
|
|
219
223
|
export interface NavigateOptionProps {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
224
|
+
/**
|
|
225
|
+
* If set to `true`, the router will scroll the element with an id matching the hash into view with default `ScrollIntoViewOptions`.
|
|
226
|
+
* If set to `false`, the router will not scroll the element with an id matching the hash into view.
|
|
227
|
+
* If set to `ScrollIntoViewOptions`, the router will scroll the element with an id matching the hash into view with the provided options.
|
|
228
|
+
* @default true
|
|
229
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#hashscrollintoview)
|
|
230
|
+
* @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)
|
|
231
|
+
*/
|
|
223
232
|
hashScrollIntoView?: boolean | ScrollIntoViewOptions
|
|
224
|
-
|
|
233
|
+
/**
|
|
234
|
+
* `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.
|
|
235
|
+
* @default false
|
|
236
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#replace)
|
|
237
|
+
*/
|
|
225
238
|
replace?: boolean
|
|
239
|
+
/**
|
|
240
|
+
* Defaults to `true` so that the scroll position will be reset to 0,0 after the location is committed to the browser history.
|
|
241
|
+
* If `false`, the scroll position will not be reset to 0,0 after the location is committed to history.
|
|
242
|
+
* @default true
|
|
243
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#resetscroll)
|
|
244
|
+
*/
|
|
226
245
|
resetScroll?: boolean
|
|
227
246
|
/** @deprecated All navigations now use startTransition under the hood */
|
|
228
247
|
startTransition?: boolean
|
|
229
|
-
|
|
230
|
-
|
|
248
|
+
/**
|
|
249
|
+
* If set to `true`, the router will wrap the resulting navigation in a `document.startViewTransition()` call.
|
|
250
|
+
* If `ViewTransitionOptions`, route navigations will be called using `document.startViewTransition({update, types})`
|
|
251
|
+
* where `types` will be the strings array passed with `ViewTransitionOptions["types"]`.
|
|
252
|
+
* If the browser does not support viewTransition types, the navigation will fall back to normal `document.startTransition()`, same as if `true` was passed.
|
|
253
|
+
*
|
|
254
|
+
* If the browser does not support this api, this option will be ignored.
|
|
255
|
+
* @default false
|
|
256
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#viewtransition)
|
|
257
|
+
* @see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition)
|
|
258
|
+
* @see [Google](https://developer.chrome.com/docs/web-platform/view-transitions/same-document#view-transition-types)
|
|
259
|
+
*/
|
|
231
260
|
viewTransition?: boolean | ViewTransitionOptions
|
|
261
|
+
/**
|
|
262
|
+
* If `true`, navigation will ignore any blockers that might prevent it.
|
|
263
|
+
* @default false
|
|
264
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#ignoreblocker)
|
|
265
|
+
*/
|
|
232
266
|
ignoreBlocker?: boolean
|
|
267
|
+
/**
|
|
268
|
+
* If `true`, navigation to a route inside of router will trigger a full page load instead of the traditional SPA navigation.
|
|
269
|
+
* @default false
|
|
270
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#reloaddocument)
|
|
271
|
+
*/
|
|
233
272
|
reloadDocument?: boolean
|
|
273
|
+
/**
|
|
274
|
+
* This can be used instead of `to` to navigate to a fully built href, e.g. pointing to an external target.
|
|
275
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType#href)
|
|
276
|
+
*/
|
|
234
277
|
href?: string
|
|
235
278
|
}
|
|
236
279
|
|
|
@@ -495,10 +538,30 @@ export type FromPathOption<TRouter extends AnyRouter, TFrom> = ConstrainLiteral<
|
|
|
495
538
|
RoutePaths<TRouter['routeTree']>
|
|
496
539
|
>
|
|
497
540
|
|
|
541
|
+
/**
|
|
542
|
+
* @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/navigation#active-options)
|
|
543
|
+
*/
|
|
498
544
|
export interface ActiveOptions {
|
|
545
|
+
/**
|
|
546
|
+
* If true, the link will be active if the current route matches the `to` route path exactly (no children routes)
|
|
547
|
+
* @default false
|
|
548
|
+
*/
|
|
499
549
|
exact?: boolean
|
|
550
|
+
/**
|
|
551
|
+
* If true, the link will only be active if the current URL hash matches the `hash` prop
|
|
552
|
+
* @default false
|
|
553
|
+
*/
|
|
500
554
|
includeHash?: boolean
|
|
555
|
+
/**
|
|
556
|
+
* If true, the link will only be active if the current URL search params inclusively match the `search` prop
|
|
557
|
+
* @default true
|
|
558
|
+
*/
|
|
501
559
|
includeSearch?: boolean
|
|
560
|
+
/**
|
|
561
|
+
* This modifies the `includeSearch` behavior.
|
|
562
|
+
* If true, properties in `search` that are explicitly `undefined` must NOT be present in the current URL search params for the link to be active.
|
|
563
|
+
* @default false
|
|
564
|
+
*/
|
|
502
565
|
explicitUndefined?: boolean
|
|
503
566
|
}
|
|
504
567
|
|
package/src/redirect.ts
CHANGED
|
@@ -5,6 +5,9 @@ import type { PickAsRequired } from './utils'
|
|
|
5
5
|
|
|
6
6
|
export type AnyRedirect = Redirect<any, any, any, any, any>
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RedirectType)
|
|
10
|
+
*/
|
|
8
11
|
export type Redirect<
|
|
9
12
|
TRouter extends AnyRouter = RegisteredRouter,
|
|
10
13
|
TFrom extends RoutePaths<TRouter['routeTree']> | string = '/',
|
|
@@ -17,8 +20,20 @@ export type Redirect<
|
|
|
17
20
|
* @deprecated Use `statusCode` instead
|
|
18
21
|
**/
|
|
19
22
|
code?: number
|
|
23
|
+
/**
|
|
24
|
+
* The HTTP status code to use when redirecting.
|
|
25
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RedirectType#statuscode-property)
|
|
26
|
+
*/
|
|
20
27
|
statusCode?: number
|
|
28
|
+
/**
|
|
29
|
+
* If provided, will throw the redirect object instead of returning it. This can be useful in places where `throwing` in a function might cause it to have a return type of `never`. In that case, you can use `redirect({ throw: true })` to throw the redirect object instead of returning it.
|
|
30
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RedirectType#throw-property)
|
|
31
|
+
*/
|
|
21
32
|
throw?: any
|
|
33
|
+
/**
|
|
34
|
+
* The HTTP headers to use when redirecting.
|
|
35
|
+
* @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RedirectType#headers-property)
|
|
36
|
+
*/
|
|
22
37
|
headers?: HeadersInit
|
|
23
38
|
} & NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>
|
|
24
39
|
|
package/src/route.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { joinPaths, trimPathLeft } from './path'
|
|
2
|
+
import { notFound } from './not-found'
|
|
3
|
+
import { rootRouteId } from './root'
|
|
1
4
|
import type { LazyRoute } from './fileRoute'
|
|
5
|
+
import type { NotFoundError } from './not-found'
|
|
2
6
|
import type { NavigateOptions, ParsePathParams } from './link'
|
|
3
7
|
import type { ParsedLocation } from './location'
|
|
4
8
|
import type {
|
|
@@ -1250,4 +1254,368 @@ export type NotFoundRouteProps = {
|
|
|
1250
1254
|
data: unknown
|
|
1251
1255
|
}
|
|
1252
1256
|
|
|
1257
|
+
export class BaseRoute<
|
|
1258
|
+
in out TParentRoute extends AnyRoute = AnyRoute,
|
|
1259
|
+
in out TPath extends string = '/',
|
|
1260
|
+
in out TFullPath extends string = ResolveFullPath<TParentRoute, TPath>,
|
|
1261
|
+
in out TCustomId extends string = string,
|
|
1262
|
+
in out TId extends string = ResolveId<TParentRoute, TCustomId, TPath>,
|
|
1263
|
+
in out TSearchValidator = undefined,
|
|
1264
|
+
in out TParams = ResolveParams<TPath>,
|
|
1265
|
+
in out TRouterContext = AnyContext,
|
|
1266
|
+
in out TRouteContextFn = AnyContext,
|
|
1267
|
+
in out TBeforeLoadFn = AnyContext,
|
|
1268
|
+
in out TLoaderDeps extends Record<string, any> = {},
|
|
1269
|
+
in out TLoaderFn = undefined,
|
|
1270
|
+
in out TChildren = unknown,
|
|
1271
|
+
in out TFileRouteTypes = unknown,
|
|
1272
|
+
> implements
|
|
1273
|
+
Route<
|
|
1274
|
+
TParentRoute,
|
|
1275
|
+
TPath,
|
|
1276
|
+
TFullPath,
|
|
1277
|
+
TCustomId,
|
|
1278
|
+
TId,
|
|
1279
|
+
TSearchValidator,
|
|
1280
|
+
TParams,
|
|
1281
|
+
TRouterContext,
|
|
1282
|
+
TRouteContextFn,
|
|
1283
|
+
TBeforeLoadFn,
|
|
1284
|
+
TLoaderDeps,
|
|
1285
|
+
TLoaderFn,
|
|
1286
|
+
TChildren,
|
|
1287
|
+
TFileRouteTypes
|
|
1288
|
+
>
|
|
1289
|
+
{
|
|
1290
|
+
isRoot: TParentRoute extends AnyRoute ? true : false
|
|
1291
|
+
options: RouteOptions<
|
|
1292
|
+
TParentRoute,
|
|
1293
|
+
TId,
|
|
1294
|
+
TCustomId,
|
|
1295
|
+
TFullPath,
|
|
1296
|
+
TPath,
|
|
1297
|
+
TSearchValidator,
|
|
1298
|
+
TParams,
|
|
1299
|
+
TLoaderDeps,
|
|
1300
|
+
TLoaderFn,
|
|
1301
|
+
TRouterContext,
|
|
1302
|
+
TRouteContextFn,
|
|
1303
|
+
TBeforeLoadFn
|
|
1304
|
+
>
|
|
1305
|
+
|
|
1306
|
+
// The following properties are set up in this.init()
|
|
1307
|
+
parentRoute!: TParentRoute
|
|
1308
|
+
private _id!: TId
|
|
1309
|
+
private _path!: TPath
|
|
1310
|
+
private _fullPath!: TFullPath
|
|
1311
|
+
private _to!: TrimPathRight<TFullPath>
|
|
1312
|
+
private _ssr!: boolean
|
|
1313
|
+
|
|
1314
|
+
public get to() {
|
|
1315
|
+
return this._to
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
public get id() {
|
|
1319
|
+
return this._id
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
public get path() {
|
|
1323
|
+
return this._path
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
public get fullPath() {
|
|
1327
|
+
return this._fullPath
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
public get ssr() {
|
|
1331
|
+
return this._ssr
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
// Optional
|
|
1335
|
+
children?: TChildren
|
|
1336
|
+
originalIndex?: number
|
|
1337
|
+
rank!: number
|
|
1338
|
+
lazyFn?: () => Promise<LazyRoute>
|
|
1339
|
+
_lazyPromise?: Promise<void>
|
|
1340
|
+
_componentsPromise?: Promise<Array<void>>
|
|
1341
|
+
|
|
1342
|
+
constructor(
|
|
1343
|
+
options?: RouteOptions<
|
|
1344
|
+
TParentRoute,
|
|
1345
|
+
TId,
|
|
1346
|
+
TCustomId,
|
|
1347
|
+
TFullPath,
|
|
1348
|
+
TPath,
|
|
1349
|
+
TSearchValidator,
|
|
1350
|
+
TParams,
|
|
1351
|
+
TLoaderDeps,
|
|
1352
|
+
TLoaderFn,
|
|
1353
|
+
TRouterContext,
|
|
1354
|
+
TRouteContextFn,
|
|
1355
|
+
TBeforeLoadFn
|
|
1356
|
+
>,
|
|
1357
|
+
) {
|
|
1358
|
+
this.options = (options as any) || {}
|
|
1359
|
+
this.isRoot = !options?.getParentRoute as any
|
|
1360
|
+
|
|
1361
|
+
if ((options as any)?.id && (options as any)?.path) {
|
|
1362
|
+
throw new Error(`Route cannot have both an 'id' and a 'path' option.`)
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
types!: RouteTypes<
|
|
1367
|
+
TParentRoute,
|
|
1368
|
+
TPath,
|
|
1369
|
+
TFullPath,
|
|
1370
|
+
TCustomId,
|
|
1371
|
+
TId,
|
|
1372
|
+
TSearchValidator,
|
|
1373
|
+
TParams,
|
|
1374
|
+
TRouterContext,
|
|
1375
|
+
TRouteContextFn,
|
|
1376
|
+
TBeforeLoadFn,
|
|
1377
|
+
TLoaderDeps,
|
|
1378
|
+
TLoaderFn,
|
|
1379
|
+
TChildren,
|
|
1380
|
+
TFileRouteTypes
|
|
1381
|
+
>
|
|
1382
|
+
|
|
1383
|
+
init = (opts: { originalIndex: number; defaultSsr?: boolean }): void => {
|
|
1384
|
+
this.originalIndex = opts.originalIndex
|
|
1385
|
+
|
|
1386
|
+
const options = this.options as
|
|
1387
|
+
| (RouteOptions<
|
|
1388
|
+
TParentRoute,
|
|
1389
|
+
TId,
|
|
1390
|
+
TCustomId,
|
|
1391
|
+
TFullPath,
|
|
1392
|
+
TPath,
|
|
1393
|
+
TSearchValidator,
|
|
1394
|
+
TParams,
|
|
1395
|
+
TLoaderDeps,
|
|
1396
|
+
TLoaderFn,
|
|
1397
|
+
TRouterContext,
|
|
1398
|
+
TRouteContextFn,
|
|
1399
|
+
TBeforeLoadFn
|
|
1400
|
+
> &
|
|
1401
|
+
RoutePathOptionsIntersection<TCustomId, TPath>)
|
|
1402
|
+
| undefined
|
|
1403
|
+
|
|
1404
|
+
const isRoot = !options?.path && !options?.id
|
|
1405
|
+
|
|
1406
|
+
this.parentRoute = this.options.getParentRoute?.()
|
|
1407
|
+
|
|
1408
|
+
if (isRoot) {
|
|
1409
|
+
this._path = rootRouteId as TPath
|
|
1410
|
+
} else if (!this.parentRoute) {
|
|
1411
|
+
throw new Error(
|
|
1412
|
+
`Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,
|
|
1413
|
+
)
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
let path: undefined | string = isRoot ? rootRouteId : options?.path
|
|
1417
|
+
|
|
1418
|
+
// If the path is anything other than an index path, trim it up
|
|
1419
|
+
if (path && path !== '/') {
|
|
1420
|
+
path = trimPathLeft(path)
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
const customId = options?.id || path
|
|
1424
|
+
|
|
1425
|
+
// Strip the parentId prefix from the first level of children
|
|
1426
|
+
let id = isRoot
|
|
1427
|
+
? rootRouteId
|
|
1428
|
+
: joinPaths([
|
|
1429
|
+
this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id,
|
|
1430
|
+
customId,
|
|
1431
|
+
])
|
|
1432
|
+
|
|
1433
|
+
if (path === rootRouteId) {
|
|
1434
|
+
path = '/'
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
if (id !== rootRouteId) {
|
|
1438
|
+
id = joinPaths(['/', id])
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
const fullPath =
|
|
1442
|
+
id === rootRouteId ? '/' : joinPaths([this.parentRoute.fullPath, path])
|
|
1443
|
+
|
|
1444
|
+
this._path = path as TPath
|
|
1445
|
+
this._id = id as TId
|
|
1446
|
+
this._fullPath = fullPath as TFullPath
|
|
1447
|
+
this._to = fullPath as TrimPathRight<TFullPath>
|
|
1448
|
+
this._ssr = options?.ssr ?? opts.defaultSsr ?? true
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
addChildren: RouteAddChildrenFn<
|
|
1452
|
+
TParentRoute,
|
|
1453
|
+
TPath,
|
|
1454
|
+
TFullPath,
|
|
1455
|
+
TCustomId,
|
|
1456
|
+
TId,
|
|
1457
|
+
TSearchValidator,
|
|
1458
|
+
TParams,
|
|
1459
|
+
TRouterContext,
|
|
1460
|
+
TRouteContextFn,
|
|
1461
|
+
TBeforeLoadFn,
|
|
1462
|
+
TLoaderDeps,
|
|
1463
|
+
TLoaderFn,
|
|
1464
|
+
TFileRouteTypes
|
|
1465
|
+
> = (children) => {
|
|
1466
|
+
return this._addFileChildren(children) as any
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
_addFileChildren: RouteAddFileChildrenFn<
|
|
1470
|
+
TParentRoute,
|
|
1471
|
+
TPath,
|
|
1472
|
+
TFullPath,
|
|
1473
|
+
TCustomId,
|
|
1474
|
+
TId,
|
|
1475
|
+
TSearchValidator,
|
|
1476
|
+
TParams,
|
|
1477
|
+
TRouterContext,
|
|
1478
|
+
TRouteContextFn,
|
|
1479
|
+
TBeforeLoadFn,
|
|
1480
|
+
TLoaderDeps,
|
|
1481
|
+
TLoaderFn,
|
|
1482
|
+
TFileRouteTypes
|
|
1483
|
+
> = (children) => {
|
|
1484
|
+
if (Array.isArray(children)) {
|
|
1485
|
+
this.children = children as TChildren
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
if (typeof children === 'object' && children !== null) {
|
|
1489
|
+
this.children = Object.values(children) as TChildren
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
return this as any
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
_addFileTypes: RouteAddFileTypesFn<
|
|
1496
|
+
TParentRoute,
|
|
1497
|
+
TPath,
|
|
1498
|
+
TFullPath,
|
|
1499
|
+
TCustomId,
|
|
1500
|
+
TId,
|
|
1501
|
+
TSearchValidator,
|
|
1502
|
+
TParams,
|
|
1503
|
+
TRouterContext,
|
|
1504
|
+
TRouteContextFn,
|
|
1505
|
+
TBeforeLoadFn,
|
|
1506
|
+
TLoaderDeps,
|
|
1507
|
+
TLoaderFn,
|
|
1508
|
+
TChildren
|
|
1509
|
+
> = () => {
|
|
1510
|
+
return this as any
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
updateLoader = <TNewLoaderFn>(options: {
|
|
1514
|
+
loader: Constrain<
|
|
1515
|
+
TNewLoaderFn,
|
|
1516
|
+
RouteLoaderFn<
|
|
1517
|
+
TParentRoute,
|
|
1518
|
+
TCustomId,
|
|
1519
|
+
TParams,
|
|
1520
|
+
TLoaderDeps,
|
|
1521
|
+
TRouterContext,
|
|
1522
|
+
TRouteContextFn,
|
|
1523
|
+
TBeforeLoadFn
|
|
1524
|
+
>
|
|
1525
|
+
>
|
|
1526
|
+
}) => {
|
|
1527
|
+
Object.assign(this.options, options)
|
|
1528
|
+
return this as unknown as BaseRoute<
|
|
1529
|
+
TParentRoute,
|
|
1530
|
+
TPath,
|
|
1531
|
+
TFullPath,
|
|
1532
|
+
TCustomId,
|
|
1533
|
+
TId,
|
|
1534
|
+
TSearchValidator,
|
|
1535
|
+
TParams,
|
|
1536
|
+
TRouterContext,
|
|
1537
|
+
TRouteContextFn,
|
|
1538
|
+
TBeforeLoadFn,
|
|
1539
|
+
TLoaderDeps,
|
|
1540
|
+
TNewLoaderFn,
|
|
1541
|
+
TChildren,
|
|
1542
|
+
TFileRouteTypes
|
|
1543
|
+
>
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
update = (
|
|
1547
|
+
options: UpdatableRouteOptions<
|
|
1548
|
+
TParentRoute,
|
|
1549
|
+
TCustomId,
|
|
1550
|
+
TFullPath,
|
|
1551
|
+
TParams,
|
|
1552
|
+
TSearchValidator,
|
|
1553
|
+
TLoaderFn,
|
|
1554
|
+
TLoaderDeps,
|
|
1555
|
+
TRouterContext,
|
|
1556
|
+
TRouteContextFn,
|
|
1557
|
+
TBeforeLoadFn
|
|
1558
|
+
>,
|
|
1559
|
+
): this => {
|
|
1560
|
+
Object.assign(this.options, options)
|
|
1561
|
+
return this
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
lazy: RouteLazyFn<this> = (lazyFn) => {
|
|
1565
|
+
this.lazyFn = lazyFn
|
|
1566
|
+
return this
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
export class BaseRouteApi<TId, TRouter extends AnyRouter = RegisteredRouter> {
|
|
1571
|
+
id: TId
|
|
1572
|
+
|
|
1573
|
+
constructor({ id }: { id: TId }) {
|
|
1574
|
+
this.id = id as any
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
notFound = (opts?: NotFoundError) => {
|
|
1578
|
+
return notFound({ routeId: this.id as string, ...opts })
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
export class BaseRootRoute<
|
|
1583
|
+
in out TSearchValidator = undefined,
|
|
1584
|
+
in out TRouterContext = {},
|
|
1585
|
+
in out TRouteContextFn = AnyContext,
|
|
1586
|
+
in out TBeforeLoadFn = AnyContext,
|
|
1587
|
+
in out TLoaderDeps extends Record<string, any> = {},
|
|
1588
|
+
in out TLoaderFn = undefined,
|
|
1589
|
+
in out TChildren = unknown,
|
|
1590
|
+
in out TFileRouteTypes = unknown,
|
|
1591
|
+
> extends BaseRoute<
|
|
1592
|
+
any, // TParentRoute
|
|
1593
|
+
'/', // TPath
|
|
1594
|
+
'/', // TFullPath
|
|
1595
|
+
string, // TCustomId
|
|
1596
|
+
RootRouteId, // TId
|
|
1597
|
+
TSearchValidator, // TSearchValidator
|
|
1598
|
+
{}, // TParams
|
|
1599
|
+
TRouterContext,
|
|
1600
|
+
TRouteContextFn,
|
|
1601
|
+
TBeforeLoadFn,
|
|
1602
|
+
TLoaderDeps,
|
|
1603
|
+
TLoaderFn,
|
|
1604
|
+
TChildren, // TChildren
|
|
1605
|
+
TFileRouteTypes
|
|
1606
|
+
> {
|
|
1607
|
+
constructor(
|
|
1608
|
+
options?: RootRouteOptions<
|
|
1609
|
+
TSearchValidator,
|
|
1610
|
+
TRouterContext,
|
|
1611
|
+
TRouteContextFn,
|
|
1612
|
+
TBeforeLoadFn,
|
|
1613
|
+
TLoaderDeps,
|
|
1614
|
+
TLoaderFn
|
|
1615
|
+
>,
|
|
1616
|
+
) {
|
|
1617
|
+
super(options as any)
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1253
1621
|
//
|