@tanstack/router-core 0.0.1-beta.174 → 0.0.1-beta.176

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.
@@ -0,0 +1,92 @@
1
+ import { Trim } from './fileRoute';
2
+ import { AnyRoute } from './route';
3
+ import { AllParams, FullSearchSchema, RouteByPath, RouteIds, RoutePaths } from './routeInfo';
4
+ import { ParsedLocation, LocationState } from './router';
5
+ import { NoInfer, PickRequired, UnionToIntersection, Updater } from './utils';
6
+ export type LinkInfo = {
7
+ type: 'external';
8
+ href: string;
9
+ } | {
10
+ type: 'internal';
11
+ next: ParsedLocation;
12
+ handleFocus: (e: any) => void;
13
+ handleClick: (e: any) => void;
14
+ handleEnter: (e: any) => void;
15
+ handleLeave: (e: any) => void;
16
+ handleTouchStart: (e: any) => void;
17
+ isActive: boolean;
18
+ disabled?: boolean;
19
+ };
20
+ export type CleanPath<T extends string> = T extends `${infer L}//${infer R}` ? CleanPath<`${CleanPath<L>}/${CleanPath<R>}`> : T extends `${infer L}//` ? `${CleanPath<L>}/` : T extends `//${infer L}` ? `/${CleanPath<L>}` : T;
21
+ export type Split<S, TIncludeTrailingSlash = true> = S extends unknown ? string extends S ? string[] : S extends string ? CleanPath<S> extends '' ? [] : TIncludeTrailingSlash extends true ? CleanPath<S> extends `${infer T}/` ? [...Split<T>, '/'] : CleanPath<S> extends `/${infer U}` ? Split<U> : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : [S] : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : S extends string ? [S] : never : never : never;
22
+ export type ParsePathParams<T extends string> = keyof {
23
+ [K in Trim<Split<T>[number], '_'> as K extends `$${infer L}` ? L : never]: K;
24
+ };
25
+ export type Join<T, Delimiter extends string = '/'> = T extends [] ? '' : T extends [infer L extends string] ? L : T extends [infer L extends string, ...infer Tail extends [...string[]]] ? CleanPath<`${L}${Delimiter}${Join<Tail>}`> : never;
26
+ export type Last<T extends any[]> = T extends [...infer _, infer L] ? L : never;
27
+ export type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends string, TTo extends string, SplitPaths extends string[] = Split<AllPaths, false>> = TTo extends `..${infer _}` ? SplitPaths extends [
28
+ ...Split<ResolveRelativePath<TFrom, TTo>, false>,
29
+ ...infer TToRest
30
+ ] ? `${CleanPath<Join<[
31
+ ...Split<TTo, false>,
32
+ ...(TToRest | (Split<ResolveRelativePath<TFrom, TTo>, false>['length'] extends 1 ? never : ['../']))
33
+ ]>>}` : never : TTo extends `./${infer RestTTo}` ? SplitPaths extends [
34
+ ...Split<TFrom, false>,
35
+ ...Split<RestTTo, false>,
36
+ ...infer RestPath
37
+ ] ? `${TTo}${Join<RestPath>}` : never : (TFrom extends `/` ? never : SplitPaths extends [...Split<TFrom, false>, ...infer RestPath] ? Join<RestPath> extends {
38
+ length: 0;
39
+ } ? never : './' : never) | (TFrom extends `/` ? never : '../') | AllPaths;
40
+ export type NavigateOptions<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = ToOptions<TRouteTree, TFrom, TTo> & {
41
+ replace?: boolean;
42
+ resetScroll?: boolean;
43
+ };
44
+ export type ToOptions<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = '', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
45
+ to?: ToPathOption<TRouteTree, TFrom, TTo>;
46
+ hash?: Updater<string>;
47
+ state?: LocationState;
48
+ from?: TFrom;
49
+ } & CheckPath<TRouteTree, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TRouteTree, TFrom, TResolvedTo> & PathParamOptions<TRouteTree, TFrom, TResolvedTo>;
50
+ export type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & RouteByPath<TRouteTree, TFrom> extends never ? {} : RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']>, TToSchema = Partial<RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']> & Omit<RouteByPath<TRouteTree, TTo>['types']['fullSearchSchema'], keyof PickRequired<RouteByPath<TRouteTree, TFrom>['types']['fullSearchSchema']>>, TFromFullSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & TFromSchema>, TToFullSchema = UnionToIntersection<FullSearchSchema<TRouteTree> & TToSchema>> = keyof PickRequired<TToSchema> extends never ? {
51
+ search?: true | SearchReducer<TFromFullSchema, TToFullSchema>;
52
+ } : {
53
+ search: SearchReducer<TFromFullSchema, TToFullSchema>;
54
+ };
55
+ type SearchReducer<TFrom, TTo> = {
56
+ [TKey in keyof TTo]: TTo[TKey];
57
+ } | ((current: TFrom) => TTo);
58
+ export type PathParamOptions<TRouteTree extends AnyRoute, TFrom, TTo, TFromSchema = UnionToIntersection<RouteByPath<TRouteTree, TFrom> extends never ? {} : RouteByPath<TRouteTree, TFrom>['types']['allParams']>, TToSchema = Partial<RouteByPath<TRouteTree, TFrom>['types']['allParams']> & Omit<RouteByPath<TRouteTree, TTo>['types']['allParams'], keyof PickRequired<RouteByPath<TRouteTree, TFrom>['types']['allParams']>>, TFromFullParams = UnionToIntersection<AllParams<TRouteTree> & TFromSchema>, TToFullParams = UnionToIntersection<AllParams<TRouteTree> & TToSchema>> = keyof PickRequired<TToSchema> extends never ? {
59
+ params?: ParamsReducer<TFromFullParams, TToFullParams>;
60
+ } : {
61
+ params: ParamsReducer<TFromFullParams, TToFullParams>;
62
+ };
63
+ type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
64
+ export type ToPathOption<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = TTo | RelativeToPathAutoComplete<RoutePaths<TRouteTree>, NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
65
+ export type ToIdOption<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = TTo | RelativeToPathAutoComplete<RouteIds<TRouteTree>, NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
66
+ export interface ActiveOptions {
67
+ exact?: boolean;
68
+ includeHash?: boolean;
69
+ includeSearch?: boolean;
70
+ }
71
+ export type LinkOptions<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = NavigateOptions<TRouteTree, TFrom, TTo> & {
72
+ target?: HTMLAnchorElement['target'];
73
+ activeOptions?: ActiveOptions;
74
+ preload?: false | 'intent';
75
+ preloadDelay?: number;
76
+ disabled?: boolean;
77
+ };
78
+ export type CheckRelativePath<TRouteTree extends AnyRoute, TFrom, TTo> = TTo extends string ? TFrom extends string ? ResolveRelativePath<TFrom, TTo> extends RoutePaths<TRouteTree> ? {} : {
79
+ Error: `${TFrom} + ${TTo} resolves to ${ResolveRelativePath<TFrom, TTo>}, which is not a valid route path.`;
80
+ 'Valid Route Paths': RoutePaths<TRouteTree>;
81
+ } : {} : {};
82
+ export type CheckPath<TRouteTree extends AnyRoute, TPath, TPass> = Exclude<TPath, RoutePaths<TRouteTree>> extends never ? TPass : CheckPathError<TRouteTree, Exclude<TPath, RoutePaths<TRouteTree>>>;
83
+ export type CheckPathError<TRouteTree extends AnyRoute, TInvalids> = {
84
+ to: RoutePaths<TRouteTree>;
85
+ };
86
+ export type CheckId<TRouteTree extends AnyRoute, TPath, TPass> = Exclude<TPath, RouteIds<TRouteTree>> extends never ? TPass : CheckIdError<TRouteTree, Exclude<TPath, RouteIds<TRouteTree>>>;
87
+ export type CheckIdError<TRouteTree extends AnyRoute, TInvalids> = {
88
+ Error: `${TInvalids extends string ? TInvalids : never} is not a valid route ID.`;
89
+ 'Valid Route IDs': RouteIds<TRouteTree>;
90
+ };
91
+ export type ResolveRelativePath<TFrom, TTo = '.'> = TFrom extends string ? TTo extends string ? TTo extends '.' ? TFrom : TTo extends `./` ? Join<[TFrom, '/']> : TTo extends `./${infer TRest}` ? ResolveRelativePath<TFrom, TRest> : TTo extends `/${infer TRest}` ? TTo : Split<TTo> extends ['..', ...infer ToRest] ? Split<TFrom> extends [...infer FromRest, infer FromTail] ? ToRest extends ['/'] ? Join<[...FromRest, '/']> : ResolveRelativePath<Join<FromRest>, Join<ToRest>> : never : Split<TTo> extends ['.', ...infer ToRest] ? ToRest extends ['/'] ? Join<[TFrom, '/']> : ResolveRelativePath<TFrom, Join<ToRest>> : CleanPath<Join<['/', ...Split<TFrom>, ...Split<TTo>]>> : never : never;
92
+ export {};
@@ -0,0 +1,16 @@
1
+ import { AnyPathParams } from './route';
2
+ import { MatchLocation } from './router';
3
+ export interface Segment {
4
+ type: 'pathname' | 'param' | 'wildcard';
5
+ value: string;
6
+ }
7
+ export declare function joinPaths(paths: (string | undefined)[]): string;
8
+ export declare function cleanPath(path: string): string;
9
+ export declare function trimPathLeft(path: string): string;
10
+ export declare function trimPathRight(path: string): string;
11
+ export declare function trimPath(path: string): string;
12
+ export declare function resolvePath(basepath: string, base: string, to: string): string;
13
+ export declare function parsePathname(pathname?: string): Segment[];
14
+ export declare function interpolatePath(path: string | undefined, params: any, leaveWildcards?: boolean): string;
15
+ export declare function matchPathname(basepath: string, currentPathname: string, matchLocation: Pick<MatchLocation, 'to' | 'fuzzy' | 'caseSensitive'>): AnyPathParams | undefined;
16
+ export declare function matchByPath(basepath: string, from: string, matchLocation: Pick<MatchLocation, 'to' | 'caseSensitive' | 'fuzzy'>): Record<string, string> | undefined;
@@ -0,0 +1,2 @@
1
+ export declare function encode(obj: any, pfx?: string): string;
2
+ export declare function decode(str: any): {};
@@ -0,0 +1,234 @@
1
+ import { ParsePathParams } from './link';
2
+ import { AnyRouter, RouteMatch, AnyRouteMatch } from './router';
3
+ import { IsAny, NoInfer, PickRequired, UnionToIntersection } from './utils';
4
+ export declare const rootRouteId: "__root__";
5
+ export type RootRouteId = typeof rootRouteId;
6
+ export type AnyPathParams = {};
7
+ export type AnySearchSchema = {};
8
+ export type AnyContext = {};
9
+ export interface RouteMeta {
10
+ }
11
+ export interface RouteContext {
12
+ }
13
+ export interface RegisterRouteComponent<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
14
+ }
15
+ export interface RegisterErrorRouteComponent<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
16
+ }
17
+ export interface RegisterPendingRouteComponent<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
18
+ }
19
+ export interface RegisterRouteProps<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
20
+ }
21
+ export interface RegisterErrorRouteProps<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
22
+ }
23
+ export interface RegisterPendingRouteProps<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
24
+ }
25
+ export type RegisteredRouteComponent<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = RegisterRouteComponent<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TAllContext> extends {
26
+ RouteComponent: infer T;
27
+ } ? T : () => unknown;
28
+ export type RegisteredErrorRouteComponent<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = RegisterErrorRouteComponent<TFullSearchSchema, TAllParams, TRouteContext, TAllContext> extends {
29
+ ErrorRouteComponent: infer T;
30
+ } ? T : () => unknown;
31
+ export type RegisteredPendingRouteComponent<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = RegisterPendingRouteComponent<TFullSearchSchema, TAllParams, TRouteContext, TAllContext> extends {
32
+ PendingRouteComponent: infer T;
33
+ } ? T : () => unknown;
34
+ export type RegisteredRouteProps<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = RegisterRouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TAllContext> extends {
35
+ RouteProps: infer T;
36
+ } ? T : {};
37
+ export type RegisteredErrorRouteProps<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = RegisterRouteProps<TFullSearchSchema, TAllParams, TRouteContext, TAllContext> extends {
38
+ ErrorRouteProps: infer T;
39
+ } ? T : {};
40
+ export type RegisteredPendingRouteProps<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = RegisterRouteProps<TFullSearchSchema, TAllParams, TRouteContext, TAllContext> extends {
41
+ PendingRouteProps: infer T;
42
+ } ? T : {};
43
+ export type PreloadableObj = {
44
+ preload?: () => Promise<void>;
45
+ };
46
+ export type RoutePathOptions<TCustomId, TPath> = {
47
+ path: TPath;
48
+ } | {
49
+ id: TCustomId;
50
+ };
51
+ export type RoutePathOptionsIntersection<TCustomId, TPath> = UnionToIntersection<RoutePathOptions<TCustomId, TPath>>;
52
+ export type MetaOptions = keyof PickRequired<RouteMeta> extends never ? {
53
+ meta?: RouteMeta;
54
+ } : {
55
+ meta: RouteMeta;
56
+ };
57
+ export type AnyRouteProps = RegisteredRouteProps<any, any, any, any, any>;
58
+ export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TLoader = unknown, TParentSearchSchema extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParams extends AnyPathParams = AnyPathParams, TAllParams extends AnyPathParams = TParams, TParentContext extends AnyContext = AnyContext, TAllParentContext extends AnyContext = AnyContext, TRouteContext extends RouteContext = RouteContext, TAllContext extends AnyContext = AnyContext> = BaseRouteOptions<TParentRoute, TCustomId, TPath, TLoader, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TAllContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TAllContext>;
59
+ export type ParamsFallback<TPath extends string, TParams> = unknown extends TParams ? Record<ParsePathParams<TPath>, string> : TParams;
60
+ export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TLoader = unknown, TParentSearchSchema extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParams extends AnyPathParams = {}, TAllParams = ParamsFallback<TPath, TParams>, TParentContext extends AnyContext = AnyContext, TAllParentContext extends AnyContext = AnyContext, TRouteContext extends RouteContext = RouteContext, TAllContext extends AnyContext = AnyContext> = RoutePathOptions<TCustomId, TPath> & {
61
+ layoutLimit?: string;
62
+ getParentRoute: () => TParentRoute;
63
+ validateSearch?: SearchSchemaValidator<TSearchSchema>;
64
+ loader?: LoaderFn<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TAllContext>;
65
+ } & ([TLoader] extends [never] ? {
66
+ loader: 'Loaders must return a type other than never. If you are throwing a redirect() and not returning anything, return a redirect() instead.';
67
+ } : {}) & ({
68
+ parseParams?: (rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>) => TParams extends Record<ParsePathParams<TPath>, any> ? TParams : 'parseParams must return an object';
69
+ stringifyParams?: (params: NoInfer<ParamsFallback<TPath, TParams>>) => Record<ParsePathParams<TPath>, string>;
70
+ } | {
71
+ stringifyParams?: never;
72
+ parseParams?: never;
73
+ }) & (keyof PickRequired<RouteContext> extends never ? {
74
+ getContext?: GetContextFn<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext>;
75
+ } : {
76
+ getContext: GetContextFn<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext>;
77
+ });
78
+ type GetContextFn<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext> = (opts: {
79
+ params: TAllParams;
80
+ search: TFullSearchSchema;
81
+ } & (TParentRoute extends undefined ? {
82
+ context?: TAllParentContext;
83
+ parentContext?: TParentContext;
84
+ } : {
85
+ context: TAllParentContext;
86
+ parentContext: TParentContext;
87
+ })) => TRouteContext;
88
+ export type UpdatableRouteOptions<TLoader, TSearchSchema extends AnySearchSchema, TFullSearchSchema extends AnySearchSchema, TAllParams extends AnyPathParams, TRouteContext extends AnyContext, TAllContext extends AnyContext> = MetaOptions & {
89
+ key?: null | false | GetKeyFn<TFullSearchSchema, TAllParams>;
90
+ caseSensitive?: boolean;
91
+ wrapInSuspense?: boolean;
92
+ component?: RegisteredRouteComponent<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TAllContext>;
93
+ errorComponent?: RegisteredErrorRouteComponent<TFullSearchSchema, TAllParams, TRouteContext, TAllContext>;
94
+ pendingComponent?: RegisteredPendingRouteComponent<TFullSearchSchema, TAllParams, TRouteContext, TAllContext>;
95
+ preSearchFilters?: SearchFilter<TFullSearchSchema>[];
96
+ postSearchFilters?: SearchFilter<TFullSearchSchema>[];
97
+ preloadMaxAge?: number;
98
+ maxAge?: number;
99
+ gcMaxAge?: number;
100
+ beforeLoad?: (opts: LoaderContext<TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TAllContext>) => Promise<void> | void;
101
+ onError?: (err: any) => void;
102
+ onEnter?: (match: AnyRouteMatch) => void;
103
+ onTransition?: (match: AnyRouteMatch) => void;
104
+ onLeave?: (match: AnyRouteMatch) => void;
105
+ };
106
+ export type ParseParamsOption<TPath extends string, TParams> = ParseParamsFn<TPath, TParams>;
107
+ export type ParseParamsFn<TPath extends string, TParams> = (rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>) => TParams extends Record<ParsePathParams<TPath>, any> ? TParams : 'parseParams must return an object';
108
+ export type ParseParamsObj<TPath extends string, TParams> = {
109
+ parse?: ParseParamsFn<TPath, TParams>;
110
+ };
111
+ export type SearchSchemaValidator<TReturn> = SearchSchemaValidatorObj<TReturn> | SearchSchemaValidatorFn<TReturn>;
112
+ export type SearchSchemaValidatorObj<TReturn> = {
113
+ parse?: SearchSchemaValidatorFn<TReturn>;
114
+ };
115
+ export type SearchSchemaValidatorFn<TReturn> = (searchObj: Record<string, unknown>) => TReturn;
116
+ export type DefinedPathParamWarning = 'Path params cannot be redefined by child routes!';
117
+ export type ParentParams<TParentParams> = AnyPathParams extends TParentParams ? {} : {
118
+ [Key in keyof TParentParams]?: DefinedPathParamWarning;
119
+ };
120
+ export type LoaderFn<TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TAllParams = {}, TContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = (match: LoaderContext<TSearchSchema, TFullSearchSchema, TAllParams, TContext, TAllContext> & {
121
+ parentMatchPromise?: Promise<void>;
122
+ }) => Promise<TLoader> | TLoader;
123
+ export type GetKeyFn<TFullSearchSchema extends AnySearchSchema = {}, TAllParams = {}> = (loaderContext: {
124
+ params: TAllParams;
125
+ search: TFullSearchSchema;
126
+ }) => any;
127
+ export interface LoaderContext<TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TAllParams = {}, TContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
128
+ params: TAllParams;
129
+ routeSearch: TSearchSchema;
130
+ search: TFullSearchSchema;
131
+ abortController: AbortController;
132
+ preload: boolean;
133
+ routeContext: TContext;
134
+ context: TAllContext;
135
+ }
136
+ export type UnloaderFn<TPath extends string> = (routeMatch: RouteMatch<any, Route>) => void;
137
+ export type SearchFilter<T, U = T> = (prev: T) => U;
138
+ export type ResolveId<TParentRoute, TCustomId extends string, TPath extends string> = TParentRoute extends {
139
+ id: infer TParentId extends string;
140
+ } ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId> : RootRouteId;
141
+ export type InferFullSearchSchema<TRoute> = TRoute extends {
142
+ isRoot: true;
143
+ types: {
144
+ searchSchema: infer TSearchSchema;
145
+ };
146
+ } ? TSearchSchema : TRoute extends {
147
+ types: {
148
+ fullSearchSchema: infer TFullSearchSchema;
149
+ };
150
+ } ? TFullSearchSchema : {};
151
+ export type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = InferFullSearchSchema<TParentRoute> & TSearchSchema;
152
+ export interface AnyRoute extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
153
+ }
154
+ export type MergeParamsFromParent<T, U> = IsAny<T, U, T & U>;
155
+ export type UseLoaderResult<T> = T;
156
+ export type StreamedPromise<T> = {
157
+ promise: Promise<T>;
158
+ status: 'resolved' | 'pending';
159
+ data: T;
160
+ resolve: (value: T) => void;
161
+ };
162
+ export type RouteConstraints = {
163
+ TParentRoute: AnyRoute;
164
+ TPath: string;
165
+ TFullPath: string;
166
+ TCustomId: string;
167
+ TId: string;
168
+ TSearchSchema: AnySearchSchema;
169
+ TFullSearchSchema: AnySearchSchema;
170
+ TParams: Record<string, any>;
171
+ TAllParams: Record<string, any>;
172
+ TParentContext: AnyContext;
173
+ TAllParentContext: AnyContext;
174
+ TRouteContext: RouteContext;
175
+ TAllContext: AnyContext;
176
+ TRouterContext: AnyContext;
177
+ TChildren: unknown;
178
+ TRouteTree: AnyRoute;
179
+ };
180
+ export declare class Route<TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute, TPath extends RouteConstraints['TPath'] = '/', TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, TPath>, TCustomId extends RouteConstraints['TCustomId'] = string, TId extends RouteConstraints['TId'] = ResolveId<TParentRoute, TCustomId, TPath>, TLoader = unknown, TSearchSchema extends RouteConstraints['TSearchSchema'] = {}, TFullSearchSchema extends RouteConstraints['TFullSearchSchema'] = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends RouteConstraints['TParams'] = Record<ParsePathParams<TPath>, string>, TAllParams extends RouteConstraints['TAllParams'] = MergeParamsFromParent<TParentRoute['types']['allParams'], TParams>, TParentContext extends RouteConstraints['TParentContext'] = TParentRoute['types']['routeContext'], TAllParentContext extends RouteConstraints['TAllParentContext'] = TParentRoute['types']['context'], TRouteContext extends RouteConstraints['TRouteContext'] = RouteContext, TAllContext extends RouteConstraints['TAllContext'] = MergeParamsFromParent<TParentRoute['types']['context'], TRouteContext>, TRouterContext extends RouteConstraints['TRouterContext'] = AnyContext, TChildren extends RouteConstraints['TChildren'] = unknown, TRouteTree extends RouteConstraints['TRouteTree'] = AnyRoute> {
181
+ types: {
182
+ parentRoute: TParentRoute;
183
+ path: TPath;
184
+ to: TrimPathRight<TFullPath>;
185
+ fullPath: TFullPath;
186
+ customId: TCustomId;
187
+ id: TId;
188
+ loader: TLoader;
189
+ searchSchema: TSearchSchema;
190
+ fullSearchSchema: TFullSearchSchema;
191
+ params: TParams;
192
+ allParams: TAllParams;
193
+ parentContext: TParentContext;
194
+ allParentContext: TAllParentContext;
195
+ routeContext: TRouteContext;
196
+ context: TAllContext;
197
+ children: TChildren;
198
+ routeTree: TRouteTree;
199
+ routerContext: TRouterContext;
200
+ };
201
+ isRoot: TParentRoute extends Route<any> ? true : false;
202
+ options: RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TAllContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TAllContext>;
203
+ parentRoute: TParentRoute;
204
+ id: TId;
205
+ path: TPath;
206
+ fullPath: TFullPath;
207
+ to: TrimPathRight<TFullPath>;
208
+ children?: TChildren;
209
+ originalIndex?: number;
210
+ router?: AnyRouter;
211
+ rank: number;
212
+ constructor(options: RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TAllContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TAllContext>);
213
+ init: (opts: {
214
+ originalIndex: number;
215
+ router: AnyRouter;
216
+ }) => void;
217
+ addChildren: <TNewChildren extends AnyRoute[]>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TLoader, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TAllContext, TRouterContext, TNewChildren, TRouteTree>;
218
+ update: (options: UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TAllContext>) => this;
219
+ static __onInit: (route: any) => void;
220
+ }
221
+ export type AnyRootRoute = RootRoute<any, any, any, any>;
222
+ export declare class RouterContext<TRouterContext extends {}> {
223
+ constructor();
224
+ createRootRoute: <TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TRouteContext extends RouteContext = RouteContext>(options?: Omit<RouteOptions<AnyRoute, "__root__", "", TLoader, TSearchSchema, TSearchSchema, TSearchSchema, {}, {}, TRouterContext, TRouterContext, TRouteContext, IsAny<TRouterContext, TRouteContext, TRouterContext & TRouteContext>>, "caseSensitive" | "id" | "path" | "getParentRoute" | "stringifyParams" | "parseParams"> | undefined) => RootRoute<TLoader, TSearchSchema, TRouteContext, TRouterContext>;
225
+ }
226
+ export declare class RootRoute<TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TRouteContext extends RouteContext = RouteContext, TRouterContext extends {} = {}> extends Route<any, '/', '/', string, RootRouteId, TLoader, TSearchSchema, TSearchSchema, {}, {}, TRouterContext, TRouterContext, TRouteContext, MergeParamsFromParent<TRouterContext, TRouteContext>, TRouterContext, any, any> {
227
+ constructor(options?: Omit<RouteOptions<AnyRoute, RootRouteId, '', TLoader, TSearchSchema, TSearchSchema, TSearchSchema, {}, {}, TRouterContext, TRouterContext, TRouteContext, MergeParamsFromParent<TRouterContext, TRouteContext>>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams'>);
228
+ }
229
+ export type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TPrefixed;
230
+ type RoutePrefix<TPrefix extends string, TPath extends string> = string extends TPath ? RootRouteId : TPath extends string ? TPrefix extends RootRouteId ? TPath extends '/' ? '/' : `/${TrimPath<TPath>}` : `${TPrefix}/${TPath}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TPath>}`>}` : never;
231
+ export type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
232
+ export type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
233
+ export type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
234
+ export {};
@@ -0,0 +1,22 @@
1
+ import { AnyRoute, Route } from './route';
2
+ import { MergeUnion } from './utils';
3
+ export type ParseRoute<TRouteTree extends AnyRoute> = TRouteTree | ParseRouteChildren<TRouteTree>;
4
+ export type ParseRouteChildren<TRouteTree extends AnyRoute> = TRouteTree extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, infer TChildren, any> ? unknown extends TChildren ? never : TChildren extends AnyRoute[] ? {
5
+ [TId in TChildren[number]['id'] as string]: ParseRoute<TChildren[number]>;
6
+ }[string] : never : never;
7
+ export type RoutesById<TRouteTree extends AnyRoute> = {
8
+ [K in ParseRoute<TRouteTree> as K['id']]: K;
9
+ };
10
+ export type RouteById<TRouteTree extends AnyRoute, TId> = Extract<ParseRoute<TRouteTree>, {
11
+ id: TId;
12
+ }>;
13
+ export type RouteIds<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['id'];
14
+ export type RoutesByPath<TRouteTree extends AnyRoute> = {
15
+ [K in ParseRoute<TRouteTree> as K['fullPath']]: K;
16
+ };
17
+ export type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<ParseRoute<TRouteTree>, {
18
+ fullPath: TPath;
19
+ }>;
20
+ export type RoutePaths<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['fullPath'] | '/';
21
+ export type FullSearchSchema<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['fullSearchSchema']> & {};
22
+ export type AllParams<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['types']['allParams']>;
@@ -0,0 +1,251 @@
1
+ /// <reference types="react" />
2
+ import { Store } from '@tanstack/store';
3
+ import { LinkInfo, LinkOptions, NavigateOptions, ToOptions, ResolveRelativePath } from './link';
4
+ import { Route, AnySearchSchema, AnyRoute, AnyContext, AnyPathParams, RegisteredRouteComponent, RegisteredErrorRouteComponent, RegisteredPendingRouteComponent } from './route';
5
+ import { RoutesById, RoutesByPath, ParseRoute, FullSearchSchema, RouteById, RoutePaths, RouteIds } from './routeInfo';
6
+ import { NoInfer, PickAsRequired, Timeout, Updater } from './utils';
7
+ import { RouterHistory } from './history';
8
+ declare global {
9
+ interface Window {
10
+ __TSR_DEHYDRATED__?: HydrationCtx;
11
+ }
12
+ }
13
+ export interface Register {
14
+ }
15
+ export type AnyRouter = Router<any, any>;
16
+ export type RegisteredRouter = Register extends {
17
+ router: infer TRouter extends AnyRouter;
18
+ } ? TRouter : AnyRouter;
19
+ export interface LocationState {
20
+ }
21
+ export interface ParsedLocation<TSearchObj extends AnySearchSchema = {}> {
22
+ href: string;
23
+ pathname: string;
24
+ search: TSearchObj;
25
+ searchStr: string;
26
+ state: LocationState;
27
+ hash: string;
28
+ key?: string;
29
+ }
30
+ export interface FromLocation {
31
+ pathname: string;
32
+ search?: unknown;
33
+ key?: string;
34
+ hash?: string;
35
+ }
36
+ export type SearchSerializer = (searchObj: Record<string, any>) => string;
37
+ export type SearchParser = (searchStr: string) => Record<string, any>;
38
+ export type HydrationCtx = {
39
+ router: DehydratedRouter;
40
+ payload: Record<string, any>;
41
+ };
42
+ export interface RouteMatch<TRouteTree extends AnyRoute = AnyRoute, TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id']> {
43
+ id: string;
44
+ key?: string;
45
+ routeId: TRouteId;
46
+ pathname: string;
47
+ params: RouteById<TRouteTree, TRouteId>['types']['allParams'];
48
+ status: 'pending' | 'success' | 'error';
49
+ isFetching: boolean;
50
+ invalid: boolean;
51
+ error: unknown;
52
+ paramsError: unknown;
53
+ searchError: unknown;
54
+ updatedAt: number;
55
+ maxAge: number;
56
+ preloadMaxAge: number;
57
+ loaderData: RouteById<TRouteTree, TRouteId>['types']['loader'];
58
+ loadPromise?: Promise<void>;
59
+ __resolveLoadPromise?: () => void;
60
+ routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext'];
61
+ context: RouteById<TRouteTree, TRouteId>['types']['context'];
62
+ routeSearch: RouteById<TRouteTree, TRouteId>['types']['searchSchema'];
63
+ search: FullSearchSchema<TRouteTree> & RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'];
64
+ fetchedAt: number;
65
+ abortController: AbortController;
66
+ }
67
+ export type AnyRouteMatch = RouteMatch<any>;
68
+ export type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends TRouteTree['types']['routerContext'] ? {
69
+ context?: TRouteTree['types']['routerContext'];
70
+ } : {
71
+ context: TRouteTree['types']['routerContext'];
72
+ };
73
+ export interface RouterOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<string, any>> {
74
+ history?: RouterHistory;
75
+ stringifySearch?: SearchSerializer;
76
+ parseSearch?: SearchParser;
77
+ defaultPreload?: false | 'intent';
78
+ defaultPreloadDelay?: number;
79
+ refetchOnWindowFocus?: boolean;
80
+ defaultComponent?: RegisteredRouteComponent<unknown, AnySearchSchema, AnyPathParams, AnyContext, AnyContext>;
81
+ defaultErrorComponent?: RegisteredErrorRouteComponent<AnySearchSchema, AnyPathParams, AnyContext, AnyContext>;
82
+ defaultPendingComponent?: RegisteredPendingRouteComponent<AnySearchSchema, AnyPathParams, AnyContext, AnyContext>;
83
+ defaultMaxAge?: number;
84
+ defaultGcMaxAge?: number;
85
+ defaultPreloadMaxAge?: number;
86
+ caseSensitive?: boolean;
87
+ routeTree?: TRouteTree;
88
+ basepath?: string;
89
+ createRoute?: (opts: {
90
+ route: AnyRoute;
91
+ router: AnyRouter;
92
+ }) => void;
93
+ context?: TRouteTree['types']['routerContext'];
94
+ Wrap?: React.ComponentType<{
95
+ children: React.ReactNode;
96
+ dehydratedState?: TDehydrated;
97
+ }>;
98
+ dehydrate?: () => TDehydrated;
99
+ hydrate?: (dehydrated: TDehydrated) => void;
100
+ }
101
+ export interface RouterState<TRouteTree extends AnyRoute = AnyRoute> {
102
+ status: 'idle' | 'pending';
103
+ isFetching: boolean;
104
+ matchesById: Record<string, RouteMatch<TRouteTree>>;
105
+ matchIds: string[];
106
+ pendingMatchIds: string[];
107
+ matches: RouteMatch<TRouteTree>[];
108
+ pendingMatches: RouteMatch<TRouteTree>[];
109
+ location: ParsedLocation<FullSearchSchema<TRouteTree>>;
110
+ resolvedLocation: ParsedLocation<FullSearchSchema<TRouteTree>>;
111
+ lastUpdated: number;
112
+ }
113
+ export type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void;
114
+ export interface BuildNextOptions {
115
+ to?: string | number | null;
116
+ params?: true | Updater<unknown>;
117
+ search?: true | Updater<unknown>;
118
+ hash?: true | Updater<string>;
119
+ state?: LocationState;
120
+ key?: string;
121
+ from?: string;
122
+ fromCurrent?: boolean;
123
+ __matches?: AnyRouteMatch[];
124
+ }
125
+ export interface MatchLocation {
126
+ to?: string | number | null;
127
+ fuzzy?: boolean;
128
+ caseSensitive?: boolean;
129
+ from?: string;
130
+ fromCurrent?: boolean;
131
+ }
132
+ export interface MatchRouteOptions {
133
+ pending?: boolean;
134
+ caseSensitive?: boolean;
135
+ includeSearch?: boolean;
136
+ fuzzy?: boolean;
137
+ }
138
+ export interface DehydratedRouterState {
139
+ dehydratedMatches: DehydratedRouteMatch[];
140
+ }
141
+ export type DehydratedRouteMatch = Pick<RouteMatch, 'fetchedAt' | 'invalid' | 'maxAge' | 'preloadMaxAge' | 'id' | 'loaderData' | 'status' | 'updatedAt'>;
142
+ export interface DehydratedRouter {
143
+ state: DehydratedRouterState;
144
+ }
145
+ export type RouterConstructorOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & RouterContextOptions<TRouteTree>;
146
+ export declare const componentTypes: readonly ["component", "errorComponent", "pendingComponent"];
147
+ export type RouterEvents = {
148
+ onBeforeLoad: {
149
+ type: 'onBeforeLoad';
150
+ from: ParsedLocation;
151
+ to: ParsedLocation;
152
+ pathChanged: boolean;
153
+ };
154
+ onLoad: {
155
+ type: 'onLoad';
156
+ from: ParsedLocation;
157
+ to: ParsedLocation;
158
+ pathChanged: boolean;
159
+ };
160
+ };
161
+ export type RouterEvent = RouterEvents[keyof RouterEvents];
162
+ export type RouterListener<TRouterEvent extends RouterEvent> = {
163
+ eventType: TRouterEvent['type'];
164
+ fn: ListenerFn<TRouterEvent>;
165
+ };
166
+ export declare class Router<TRouteTree extends AnyRoute = AnyRoute, TDehydrated extends Record<string, any> = Record<string, any>> {
167
+ #private;
168
+ types: {
169
+ RootRoute: TRouteTree;
170
+ };
171
+ options: PickAsRequired<RouterOptions<TRouteTree, TDehydrated>, 'stringifySearch' | 'parseSearch' | 'context'>;
172
+ history: RouterHistory;
173
+ basepath: string;
174
+ routeTree: TRouteTree;
175
+ routesById: RoutesById<TRouteTree>;
176
+ routesByPath: RoutesByPath<TRouteTree>;
177
+ flatRoutes: ParseRoute<TRouteTree>[];
178
+ navigateTimeout: undefined | Timeout;
179
+ nextAction: undefined | 'push' | 'replace';
180
+ navigationPromise: undefined | Promise<void>;
181
+ __store: Store<RouterState<TRouteTree>>;
182
+ state: RouterState<TRouteTree>;
183
+ dehydratedData?: TDehydrated;
184
+ resetNextScroll: boolean;
185
+ constructor(options: RouterConstructorOptions<TRouteTree, TDehydrated>);
186
+ subscribers: Set<RouterListener<RouterEvent>>;
187
+ subscribe: <TType extends keyof RouterEvents>(eventType: TType, fn: ListenerFn<RouterEvents[TType]>) => () => void;
188
+ reset: () => void;
189
+ mount: () => () => void;
190
+ update: (opts?: RouterOptions<any, any>) => this;
191
+ buildNext: (opts: BuildNextOptions) => ParsedLocation;
192
+ cancelMatches: () => void;
193
+ cancelMatch: (id: string) => void;
194
+ safeLoad: (opts?: {
195
+ next?: ParsedLocation;
196
+ }) => Promise<void>;
197
+ latestLoadPromise: Promise<void>;
198
+ load: (opts?: {
199
+ next?: ParsedLocation;
200
+ throwOnError?: boolean;
201
+ __dehydratedMatches?: DehydratedRouteMatch[];
202
+ }) => Promise<void>;
203
+ getRoute: (id: string) => Route;
204
+ preloadRoute: (navigateOpts?: BuildNextOptions & {
205
+ maxAge?: number;
206
+ }) => Promise<RouteMatch<TRouteTree, ParseRoute<TRouteTree>["id"]>[]>;
207
+ cleanMatches: () => void;
208
+ matchRoutes: (pathname: string, locationSearch: AnySearchSchema, opts?: {
209
+ throwOnError?: boolean;
210
+ debug?: boolean;
211
+ }) => RouteMatch<TRouteTree>[];
212
+ loadMatches: (resolvedMatches: AnyRouteMatch[], opts?: {
213
+ preload?: boolean;
214
+ maxAge?: number;
215
+ }) => Promise<void>;
216
+ reload: () => Promise<void>;
217
+ resolvePath: (from: string, path: string) => string;
218
+ navigate: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">({ from, to, search, hash, replace, params, resetScroll, }: NavigateOptions<TRouteTree, TFrom, TTo>) => Promise<void>;
219
+ matchRoute: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<TRouteTree, TFrom, TTo, ResolveRelativePath<TFrom, NoInfer<TTo>>>, opts?: MatchRouteOptions) => false | RouteById<TRouteTree, TResolved>["types"]["allParams"];
220
+ buildLink: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">({ from, to, search, params, hash, target, replace, activeOptions, preload, preloadDelay: userPreloadDelay, disabled, state, resetScroll, }: LinkOptions<TRouteTree, TFrom, TTo>) => LinkInfo;
221
+ dehydrate: () => DehydratedRouter;
222
+ hydrate: (__do_not_use_server_ctx?: HydrationCtx) => Promise<void>;
223
+ injectedHtml: (string | (() => Promise<string> | string))[];
224
+ injectHtml: (html: string | (() => Promise<string> | string)) => Promise<void>;
225
+ dehydrateData: <T>(key: any, getData: T | (() => T | Promise<T>)) => () => T | undefined;
226
+ hydrateData: <T = unknown>(key: any) => T | undefined;
227
+ getRouteMatch: (id: string) => undefined | RouteMatch<TRouteTree>;
228
+ setRouteMatch: (id: string, updater: (prev: RouteMatch<TRouteTree>) => RouteMatch<TRouteTree>) => void;
229
+ setRouteMatchData: (id: string, updater: (prev: any) => any, opts?: {
230
+ updatedAt?: number;
231
+ maxAge?: number;
232
+ }) => void;
233
+ invalidate: (opts?: {
234
+ matchId?: string;
235
+ reload?: boolean;
236
+ }) => Promise<void>;
237
+ }
238
+ export type AnyRedirect = Redirect<any, any, any>;
239
+ export type Redirect<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = NavigateOptions<TRouteTree, TFrom, TTo> & {
240
+ code?: number;
241
+ };
242
+ export declare function redirect<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''>(opts: Redirect<TRouteTree, TFrom, TTo>): Redirect<TRouteTree, TFrom, TTo>;
243
+ export declare function isRedirect(obj: any): obj is AnyRedirect;
244
+ export declare class SearchParamError extends Error {
245
+ }
246
+ export declare class PathParamError extends Error {
247
+ }
248
+ export declare function lazyFn<T extends Record<string, (...args: any[]) => any>, TKey extends keyof T = 'default'>(fn: () => Promise<T>, key?: TKey): (...args: Parameters<T[TKey]>) => Promise<ReturnType<T[TKey]>>;
249
+ export declare function isMatchInvalid(match: AnyRouteMatch, opts?: {
250
+ preload?: boolean;
251
+ }): boolean;
@@ -0,0 +1,6 @@
1
+ import { AnyRouter, ParsedLocation } from './router';
2
+ export type ScrollRestorationOptions = {
3
+ getKey?: (location: ParsedLocation) => string;
4
+ };
5
+ export declare function watchScrollPositions(router: AnyRouter, opts?: ScrollRestorationOptions): () => void;
6
+ export declare function restoreScrollPositions(router: AnyRouter, opts?: ScrollRestorationOptions): void;
@@ -0,0 +1,5 @@
1
+ import { AnySearchSchema } from './route';
2
+ export declare const defaultParseSearch: (searchStr: string) => AnySearchSchema;
3
+ export declare const defaultStringifySearch: (search: Record<string, any>) => string;
4
+ export declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => AnySearchSchema;
5
+ export declare function stringifySearchWith(stringify: (search: any) => string, parser?: (str: string) => any): (search: Record<string, any>) => string;