@tanstack/router-core 0.0.1-beta.16 → 0.0.1-beta.161

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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/build/cjs/fileRoute.js +29 -0
  3. package/build/cjs/fileRoute.js.map +1 -0
  4. package/build/cjs/history.js +226 -0
  5. package/build/cjs/history.js.map +1 -0
  6. package/build/cjs/index.js +78 -0
  7. package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
  8. package/build/cjs/{packages/router-core/src/path.js → path.js} +45 -56
  9. package/build/cjs/path.js.map +1 -0
  10. package/build/cjs/{packages/router-core/src/qss.js → qss.js} +10 -16
  11. package/build/cjs/qss.js.map +1 -0
  12. package/build/cjs/route.js +101 -0
  13. package/build/cjs/route.js.map +1 -0
  14. package/build/cjs/router.js +1134 -0
  15. package/build/cjs/router.js.map +1 -0
  16. package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +34 -19
  17. package/build/cjs/searchParams.js.map +1 -0
  18. package/build/cjs/{packages/router-core/src/utils.js → utils.js} +54 -64
  19. package/build/cjs/utils.js.map +1 -0
  20. package/build/esm/index.js +1439 -2091
  21. package/build/esm/index.js.map +1 -1
  22. package/build/stats-html.html +59 -49
  23. package/build/stats-react.json +203 -234
  24. package/build/types/index.d.ts +573 -431
  25. package/build/umd/index.development.js +1673 -2221
  26. package/build/umd/index.development.js.map +1 -1
  27. package/build/umd/index.production.js +13 -2
  28. package/build/umd/index.production.js.map +1 -1
  29. package/package.json +11 -7
  30. package/src/fileRoute.ts +162 -0
  31. package/src/history.ts +292 -0
  32. package/src/index.ts +3 -10
  33. package/src/link.ts +121 -118
  34. package/src/path.ts +37 -17
  35. package/src/qss.ts +1 -2
  36. package/src/route.ts +874 -218
  37. package/src/routeInfo.ts +47 -211
  38. package/src/router.ts +1511 -1024
  39. package/src/searchParams.ts +33 -9
  40. package/src/utils.ts +80 -49
  41. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
  42. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  43. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
  44. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
  45. package/build/cjs/node_modules/history/index.js +0 -815
  46. package/build/cjs/node_modules/history/index.js.map +0 -1
  47. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
  48. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
  49. package/build/cjs/packages/router-core/src/index.js +0 -58
  50. package/build/cjs/packages/router-core/src/path.js.map +0 -1
  51. package/build/cjs/packages/router-core/src/qss.js.map +0 -1
  52. package/build/cjs/packages/router-core/src/route.js +0 -147
  53. package/build/cjs/packages/router-core/src/route.js.map +0 -1
  54. package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
  55. package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
  56. package/build/cjs/packages/router-core/src/routeMatch.js +0 -231
  57. package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
  58. package/build/cjs/packages/router-core/src/router.js +0 -833
  59. package/build/cjs/packages/router-core/src/router.js.map +0 -1
  60. package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
  61. package/build/cjs/packages/router-core/src/utils.js.map +0 -1
  62. package/src/frameworks.ts +0 -11
  63. package/src/routeConfig.ts +0 -514
  64. package/src/routeMatch.ts +0 -319
@@ -1,5 +1,5 @@
1
1
  /**
2
- * router-core
2
+ * @tanstack/router-core/src/index.ts
3
3
  *
4
4
  * Copyright (c) TanStack
5
5
  *
@@ -8,120 +8,134 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { BrowserHistory, MemoryHistory, HashHistory, History } from 'history';
12
- export { createBrowserHistory, createHashHistory, createMemoryHistory } from 'history';
13
11
  export { default as invariant } from 'tiny-invariant';
12
+ export { default as warning } from 'tiny-warning';
13
+ import { Store } from '@tanstack/react-store';
14
14
 
15
- interface FrameworkGenerics {
16
- }
17
- declare type GetFrameworkGeneric<U> = U extends keyof FrameworkGenerics ? FrameworkGenerics[U] : any;
18
-
19
- interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> extends Route<TAllRouteInfo, TRouteInfo> {
20
- matchId: string;
21
- pathname: string;
22
- params: TRouteInfo['params'];
23
- parentMatch?: RouteMatch;
24
- childMatches: RouteMatch[];
25
- routeSearch: TRouteInfo['searchSchema'];
26
- search: TRouteInfo['fullSearchSchema'];
27
- status: 'idle' | 'loading' | 'success' | 'error';
28
- updatedAt?: number;
29
- error?: unknown;
30
- isInvalid: boolean;
31
- getIsInvalid: () => boolean;
32
- loaderData: TRouteInfo['loaderData'];
33
- routeLoaderData: TRouteInfo['routeLoaderData'];
34
- isFetching: boolean;
35
- invalidAt: number;
36
- __: {
37
- component?: GetFrameworkGeneric<'Component'>;
38
- errorComponent?: GetFrameworkGeneric<'Component'>;
39
- pendingComponent?: GetFrameworkGeneric<'Component'>;
40
- loadPromise?: Promise<void>;
41
- componentsPromise?: Promise<void>;
42
- dataPromise?: Promise<TRouteInfo['routeLoaderData']>;
43
- onExit?: void | ((matchContext: {
44
- params: TRouteInfo['allParams'];
45
- search: TRouteInfo['fullSearchSchema'];
46
- }) => void);
47
- abortController: AbortController;
48
- latestId: string;
49
- validate: () => void;
50
- notify: () => void;
51
- resolve: () => void;
52
- };
53
- cancel: () => void;
54
- load: (loaderOpts?: {
55
- preload: true;
56
- maxAge: number;
57
- gcMaxAge: number;
58
- } | {
59
- preload?: false;
60
- maxAge?: never;
61
- gcMaxAge?: never;
62
- }) => Promise<TRouteInfo['routeLoaderData']>;
63
- fetch: (opts?: {
64
- maxAge?: number;
65
- }) => Promise<TRouteInfo['routeLoaderData']>;
66
- invalidate: () => void;
67
- hasLoaders: () => boolean;
68
- }
69
- declare function createRouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo>(router: Router<any, any>, route: Route<TAllRouteInfo, TRouteInfo>, opts: {
70
- parentMatch?: RouteMatch<any, any>;
71
- matchId: string;
72
- params: TRouteInfo['allParams'];
15
+ interface RouterHistory {
16
+ location: RouterLocation;
17
+ listen: (cb: () => void) => () => void;
18
+ push: (path: string, state?: any) => void;
19
+ replace: (path: string, state?: any) => void;
20
+ go: (index: number) => void;
21
+ back: () => void;
22
+ forward: () => void;
23
+ createHref: (href: string) => string;
24
+ block: (blockerFn: BlockerFn) => () => void;
25
+ }
26
+ interface ParsedPath {
27
+ href: string;
73
28
  pathname: string;
74
- }): RouteMatch<TAllRouteInfo, TRouteInfo>;
29
+ search: string;
30
+ hash: string;
31
+ }
32
+ interface RouterLocation extends ParsedPath {
33
+ state: any;
34
+ }
35
+ type BlockerFn = (retry: () => void, cancel: () => void) => void;
36
+ declare function createBrowserHistory(opts?: {
37
+ getHref?: () => string;
38
+ createHref?: (path: string) => string;
39
+ }): RouterHistory;
40
+ declare function createHashHistory(): RouterHistory;
41
+ declare function createMemoryHistory(opts?: {
42
+ initialEntries: string[];
43
+ initialIndex?: number;
44
+ }): RouterHistory;
75
45
 
76
- declare type NoInfer<T> = [T][T extends any ? 0 : never];
77
- declare type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N;
78
- declare type IsAnyBoolean<T> = 1 extends 0 & T ? true : false;
79
- declare type IsKnown<T, Y, N> = unknown extends T ? N : Y;
80
- declare type PickAsRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
81
- declare type PickAsPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
82
- declare type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never;
83
- declare type PickExtra<T, K> = Expand<{
46
+ type NoInfer<T> = [T][T extends any ? 0 : never];
47
+ type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N;
48
+ type IsAnyBoolean<T> = 1 extends 0 & T ? true : false;
49
+ type IsKnown<T, Y, N> = unknown extends T ? N : Y;
50
+ type PickAsRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
51
+ type PickAsPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
52
+ type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never;
53
+ type PickExtra<T, K> = {
84
54
  [TKey in keyof K as string extends TKey ? never : TKey extends keyof T ? never : TKey]: K[TKey];
85
- }>;
86
- declare type PickRequired<T> = {
55
+ };
56
+ type PickRequired<T> = {
87
57
  [K in keyof T as undefined extends T[K] ? never : K]: T[K];
88
58
  };
89
- declare type Expand<T> = T extends object ? T extends infer O ? {
59
+ type Expand<T> = T extends object ? T extends infer O ? {
90
60
  [K in keyof O]: O[K];
91
61
  } : never : T;
92
- declare type Values<O> = O[ValueKeys<O>];
93
- declare type ValueKeys<O> = Extract<keyof O, PropertyKey>;
94
- declare type DeepAwaited<T> = T extends Promise<infer A> ? DeepAwaited<A> : T extends Record<infer A, Promise<infer B>> ? {
62
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => any ? I : never;
63
+ type Compute<T> = {
64
+ [K in keyof T]: T[K];
65
+ } | never;
66
+ type AllKeys<T> = T extends any ? keyof T : never;
67
+ type MergeUnion<T, Keys extends keyof T = keyof T> = Compute<{
68
+ [K in Keys]: T[Keys];
69
+ } & {
70
+ [K in AllKeys<T>]?: T extends any ? K extends keyof T ? T[K] : never : never;
71
+ }>;
72
+ type Values<O> = O[ValueKeys<O>];
73
+ type ValueKeys<O> = Extract<keyof O, PropertyKey>;
74
+ type DeepAwaited<T> = T extends Promise<infer A> ? DeepAwaited<A> : T extends Record<infer A, Promise<infer B>> ? {
95
75
  [K in A]: DeepAwaited<B>;
96
76
  } : T;
97
- declare type PathParamMask<TRoutePath extends string> = TRoutePath extends `${infer L}/:${infer C}/${infer R}` ? PathParamMask<`${L}/${string}/${R}`> : TRoutePath extends `${infer L}/:${infer C}` ? PathParamMask<`${L}/${string}`> : TRoutePath;
98
- declare type Timeout = ReturnType<typeof setTimeout>;
99
- declare type Updater<TPrevious, TResult = TPrevious> = TResult | ((prev?: TPrevious) => TResult);
100
- declare type PickExtract<T, U> = {
77
+ type PathParamMask<TRoutePath extends string> = TRoutePath extends `${infer L}/$${infer C}/${infer R}` ? PathParamMask<`${L}/${string}/${R}`> : TRoutePath extends `${infer L}/$${infer C}` ? PathParamMask<`${L}/${string}`> : TRoutePath;
78
+ type Timeout = ReturnType<typeof setTimeout>;
79
+ type Updater<TPrevious, TResult = TPrevious> = TResult | ((prev?: TPrevious) => TResult);
80
+ type PickExtract<T, U> = {
101
81
  [K in keyof T as T[K] extends U ? K : never]: T[K];
102
82
  };
103
- declare type PickExclude<T, U> = {
83
+ type PickExclude<T, U> = {
104
84
  [K in keyof T as T[K] extends U ? never : K]: T[K];
105
85
  };
86
+ declare function last<T>(arr: T[]): T | undefined;
87
+ declare function functionalUpdate<TResult>(updater: Updater<TResult>, previous: TResult): TResult;
88
+ declare function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K>;
106
89
  /**
107
90
  * This function returns `a` if `b` is deeply equal.
108
91
  * If not, it will replace any deeply equal children of `b` with those of `a`.
109
- * This can be used for structural sharing between JSON values for example.
92
+ * This can be used for structural sharing between immutable JSON values for example.
93
+ * Do not use this with signals
110
94
  */
111
- declare function replaceEqualDeep(prev: any, next: any): any;
112
- declare function last<T>(arr: T[]): T | undefined;
113
- declare function warning(cond: any, message: string): cond is true;
114
- declare function functionalUpdate<TResult>(updater: Updater<TResult>, previous: TResult): TResult;
115
- declare function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K>;
95
+ declare function replaceEqualDeep<T>(prev: any, _next: T): T;
96
+ declare function isPlainObject(o: any): boolean;
97
+ declare function partialDeepEqual(a: any, b: any): boolean;
98
+
99
+ type ParseRoute<TRouteTree extends AnyRoute> = TRouteTree | ParseRouteChildren<TRouteTree>;
100
+ 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[] ? {
101
+ [TId in TChildren[number]['id'] as string]: ParseRoute<TChildren[number]>;
102
+ }[string] : never : never;
103
+ type RoutesById<TRouteTree extends AnyRoute> = {
104
+ [K in ParseRoute<TRouteTree>['id'] as K['id']]: K;
105
+ };
106
+ type RouteById<TRouteTree extends AnyRoute, TId> = Extract<ParseRoute<TRouteTree>, {
107
+ id: TId;
108
+ }>;
109
+ type RouteIds<TRouteTree extends AnyRoute> = AnyRoute extends TRouteTree ? string : ParseRoute<TRouteTree>['id'];
110
+ type RoutesByPath<TRouteTree extends AnyRoute> = {
111
+ [K in ParseRoute<TRouteTree>['fullPath'] as K['fullPath']]: K;
112
+ };
113
+ type RouteByPath<TRouteTree extends AnyRoute, TPath> = Extract<ParseRoute<TRouteTree>, {
114
+ fullPath: TPath;
115
+ }>;
116
+ type RoutePaths<TRouteTree extends AnyRoute> = ParseRoute<TRouteTree>['fullPath'] | '/';
117
+ type FullSearchSchema<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['__types']['fullSearchSchema']> & {};
118
+ type AllParams<TRouteTree extends AnyRoute> = MergeUnion<ParseRoute<TRouteTree>['__types']['allParams']>;
116
119
 
120
+ declare global {
121
+ interface Window {
122
+ __TSR_DEHYDRATED__?: HydrationCtx;
123
+ }
124
+ }
125
+ interface Register {
126
+ }
127
+ type AnyRouter = Router<any, any>;
128
+ type RegisteredRouter = Register extends {
129
+ router: infer TRouter extends AnyRouter;
130
+ } ? TRouter : AnyRouter;
117
131
  interface LocationState {
118
132
  }
119
- interface Location<TSearchObj extends AnySearchSchema = {}, TState extends LocationState = LocationState> {
133
+ interface ParsedLocation<TSearchObj extends AnySearchSchema = {}> {
120
134
  href: string;
121
135
  pathname: string;
122
136
  search: TSearchObj;
123
137
  searchStr: string;
124
- state: TState;
138
+ state: LocationState;
125
139
  hash: string;
126
140
  key?: string;
127
141
  }
@@ -131,107 +145,95 @@ interface FromLocation {
131
145
  key?: string;
132
146
  hash?: string;
133
147
  }
134
- declare type SearchSerializer = (searchObj: Record<string, any>) => string;
135
- declare type SearchParser = (searchStr: string) => Record<string, any>;
136
- declare type FilterRoutesFn = <TRoute extends Route<any, RouteInfo>>(routeConfigs: TRoute[]) => TRoute[];
137
- interface RouterOptions<TRouteConfig extends AnyRouteConfig> {
138
- history?: BrowserHistory | MemoryHistory | HashHistory;
148
+ type SearchSerializer = (searchObj: Record<string, any>) => string;
149
+ type SearchParser = (searchStr: string) => Record<string, any>;
150
+ type HydrationCtx = {
151
+ router: DehydratedRouter;
152
+ payload: Record<string, any>;
153
+ };
154
+ interface RouteMatch<TRouteTree extends AnyRoute = AnyRoute, TRoute extends AnyRoute = AnyRoute> {
155
+ id: string;
156
+ key?: string;
157
+ routeId: string;
158
+ pathname: string;
159
+ params: TRoute['__types']['allParams'];
160
+ status: 'pending' | 'success' | 'error';
161
+ isFetching: boolean;
162
+ invalid: boolean;
163
+ error: unknown;
164
+ paramsError: unknown;
165
+ searchError: unknown;
166
+ updatedAt: number;
167
+ invalidAt: number;
168
+ preloadInvalidAt: number;
169
+ loaderData: TRoute['__types']['loader'];
170
+ loadPromise?: Promise<void>;
171
+ __resolveLoadPromise?: () => void;
172
+ routeContext: TRoute['__types']['routeContext'];
173
+ context: TRoute['__types']['context'];
174
+ routeSearch: TRoute['__types']['searchSchema'];
175
+ search: FullSearchSchema<TRouteTree> & TRoute['__types']['fullSearchSchema'];
176
+ fetchedAt: number;
177
+ abortController: AbortController;
178
+ }
179
+ type AnyRouteMatch = RouteMatch<AnyRoute, AnyRoute>;
180
+ type RouterContextOptions<TRouteTree extends AnyRoute> = AnyContext extends TRouteTree['__types']['routerContext'] ? {
181
+ context?: TRouteTree['__types']['routerContext'];
182
+ } : {
183
+ context: TRouteTree['__types']['routerContext'];
184
+ };
185
+ interface RouterOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<string, any>> {
186
+ history?: RouterHistory;
139
187
  stringifySearch?: SearchSerializer;
140
188
  parseSearch?: SearchParser;
141
- filterRoutes?: FilterRoutesFn;
142
189
  defaultPreload?: false | 'intent';
143
- defaultPreloadMaxAge?: number;
144
- defaultPreloadGcMaxAge?: number;
145
190
  defaultPreloadDelay?: number;
146
- useErrorBoundary?: boolean;
147
- defaultComponent?: GetFrameworkGeneric<'Component'>;
148
- defaultErrorComponent?: GetFrameworkGeneric<'Component'>;
149
- defaultPendingComponent?: GetFrameworkGeneric<'Component'>;
150
- defaultLoaderMaxAge?: number;
151
- defaultLoaderGcMaxAge?: number;
191
+ defaultComponent?: RegisteredRouteComponent<RouteProps<unknown, AnySearchSchema, AnyPathParams, AnyContext, AnyContext>>;
192
+ defaultErrorComponent?: RegisteredRouteErrorComponent<RouteProps<unknown, AnySearchSchema, AnyPathParams, AnyContext, AnyContext>>;
193
+ defaultPendingComponent?: RegisteredRouteComponent<RouteProps<unknown, AnySearchSchema, AnyPathParams, AnyContext, AnyContext>>;
194
+ defaultMaxAge?: number;
195
+ defaultGcMaxAge?: number;
196
+ defaultPreloadMaxAge?: number;
152
197
  caseSensitive?: boolean;
153
- routeConfig?: TRouteConfig;
198
+ routeTree?: TRouteTree;
154
199
  basepath?: string;
155
- createRouter?: (router: Router<any, any>) => void;
156
200
  createRoute?: (opts: {
157
201
  route: AnyRoute;
158
- router: Router<any, any>;
202
+ router: AnyRouter;
159
203
  }) => void;
160
- loadComponent?: (component: GetFrameworkGeneric<'Component'>) => Promise<GetFrameworkGeneric<'Component'>>;
161
- }
162
- interface Action<TPayload = unknown, TResponse = unknown> {
163
- submit: (submission?: TPayload, actionOpts?: {
164
- invalidate?: boolean;
165
- multi?: boolean;
166
- }) => Promise<TResponse>;
167
- current?: ActionState<TPayload, TResponse>;
168
- latest?: ActionState<TPayload, TResponse>;
169
- submissions: ActionState<TPayload, TResponse>[];
170
- }
171
- interface ActionState<TPayload = unknown, TResponse = unknown> {
172
- submittedAt: number;
173
- status: 'idle' | 'pending' | 'success' | 'error';
174
- submission: TPayload;
175
- isMulti: boolean;
176
- data?: TResponse;
177
- error?: unknown;
178
- }
179
- interface Loader<TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}, TRouteLoaderData = AnyLoaderData> {
180
- fetch: keyof PickRequired<TFullSearchSchema> extends never ? keyof TAllParams extends never ? (loaderContext: {
181
- signal?: AbortSignal;
182
- }) => Promise<TRouteLoaderData> : (loaderContext: {
183
- params: TAllParams;
184
- search?: TFullSearchSchema;
185
- signal?: AbortSignal;
186
- }) => Promise<TRouteLoaderData> : keyof TAllParams extends never ? (loaderContext: {
187
- search: TFullSearchSchema;
188
- params: TAllParams;
189
- signal?: AbortSignal;
190
- }) => Promise<TRouteLoaderData> : (loaderContext: {
191
- search: TFullSearchSchema;
192
- signal?: AbortSignal;
193
- }) => Promise<TRouteLoaderData>;
194
- current?: LoaderState<TFullSearchSchema, TAllParams>;
195
- latest?: LoaderState<TFullSearchSchema, TAllParams>;
196
- pending: LoaderState<TFullSearchSchema, TAllParams>[];
197
- }
198
- interface LoaderState<TFullSearchSchema = unknown, TAllParams = unknown> {
199
- loadedAt: number;
200
- loaderContext: LoaderContext<TFullSearchSchema, TAllParams>;
201
- }
202
- interface RouterState {
203
- status: 'idle' | 'loading';
204
- location: Location;
205
- matches: RouteMatch[];
206
- lastUpdated: number;
207
- actions: Record<string, Action>;
208
- loaders: Record<string, Loader>;
209
- pending?: PendingState;
204
+ onRouteChange?: () => void;
205
+ context?: TRouteTree['__types']['routerContext'];
206
+ Wrap?: React.ComponentType<{
207
+ children: React.ReactNode;
208
+ dehydratedState?: TDehydrated;
209
+ }>;
210
+ dehydrate?: () => TDehydrated;
211
+ hydrate?: (dehydrated: TDehydrated) => void;
212
+ }
213
+ interface RouterState<TRouteTree extends AnyRoute = AnyRoute> {
214
+ status: 'idle' | 'pending';
210
215
  isFetching: boolean;
211
- isPreloading: boolean;
212
- }
213
- interface PendingState {
214
- location: Location;
215
- matches: RouteMatch[];
216
+ matchesById: Record<string, RouteMatch<TRouteTree, AnyRoute>>;
217
+ matchIds: string[];
218
+ pendingMatchIds: string[];
219
+ matches: RouteMatch<TRouteTree, AnyRoute>[];
220
+ pendingMatches: RouteMatch<TRouteTree, AnyRoute>[];
221
+ location: ParsedLocation<FullSearchSchema<TRouteTree>>;
222
+ resolvedLocation: ParsedLocation<FullSearchSchema<TRouteTree>>;
223
+ lastUpdated: number;
216
224
  }
217
- declare type Listener = (router: Router<any, any>) => void;
218
- declare type ListenerFn = () => void;
225
+ type ListenerFn = () => void;
219
226
  interface BuildNextOptions {
220
227
  to?: string | number | null;
221
- params?: true | Updater<Record<string, any>>;
228
+ params?: true | Updater<unknown>;
222
229
  search?: true | Updater<unknown>;
223
230
  hash?: true | Updater<string>;
224
231
  state?: LocationState;
225
232
  key?: string;
226
233
  from?: string;
227
234
  fromCurrent?: boolean;
228
- __preSearchFilters?: SearchFilter<any>[];
229
- __postSearchFilters?: SearchFilter<any>[];
235
+ __matches?: AnyRouteMatch[];
230
236
  }
231
- declare type MatchCacheEntry = {
232
- gc: number;
233
- match: RouteMatch;
234
- };
235
237
  interface MatchLocation {
236
238
  to?: string | number | null;
237
239
  fuzzy?: boolean;
@@ -240,206 +242,207 @@ interface MatchLocation {
240
242
  fromCurrent?: boolean;
241
243
  }
242
244
  interface MatchRouteOptions {
243
- pending: boolean;
245
+ pending?: boolean;
244
246
  caseSensitive?: boolean;
247
+ includeSearch?: boolean;
248
+ fuzzy?: boolean;
245
249
  }
246
250
  interface DehydratedRouterState extends Pick<RouterState, 'status' | 'location' | 'lastUpdated'> {
247
- matches: DehydratedRouteMatch[];
248
251
  }
249
- interface DehydratedRouteMatch extends Pick<RouteMatch<any, any>, 'matchId' | 'status' | 'routeLoaderData' | 'loaderData' | 'isInvalid' | 'invalidAt'> {
252
+ interface DehydratedRouter {
253
+ state: DehydratedRouterState;
250
254
  }
251
- interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>> {
252
- history: BrowserHistory | MemoryHistory | HashHistory;
253
- options: PickAsRequired<RouterOptions<TRouteConfig>, 'stringifySearch' | 'parseSearch'>;
255
+ type RouterConstructorOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & RouterContextOptions<TRouteTree>;
256
+ declare const componentTypes: readonly ["component", "errorComponent", "pendingComponent"];
257
+ declare class Router<TRouteTree extends AnyRoute = AnyRoute, TDehydrated extends Record<string, any> = Record<string, any>> {
258
+ #private;
259
+ types: {
260
+ RootRoute: TRouteTree;
261
+ };
262
+ options: PickAsRequired<RouterOptions<TRouteTree, TDehydrated>, 'stringifySearch' | 'parseSearch' | 'context'>;
263
+ history: RouterHistory;
254
264
  basepath: string;
255
- allRouteInfo: TAllRouteInfo;
256
- listeners: Listener[];
257
- location: Location;
258
- navigateTimeout?: Timeout;
259
- nextAction?: 'push' | 'replace';
260
- state: RouterState;
261
- routeTree: Route<TAllRouteInfo, RouteInfo>;
262
- routesById: RoutesById<TAllRouteInfo>;
263
- navigationPromise: Promise<void>;
264
- startedLoadingAt: number;
265
- resolveNavigation: () => void;
266
- subscribe: (listener: Listener) => () => void;
265
+ routeTree: TRouteTree;
266
+ routesById: RoutesById<TRouteTree>;
267
+ routesByPath: RoutesByPath<TRouteTree>;
268
+ flatRoutes: ParseRoute<TRouteTree>[];
269
+ navigateTimeout: undefined | Timeout;
270
+ nextAction: undefined | 'push' | 'replace';
271
+ navigationPromise: undefined | Promise<void>;
272
+ __store: Store<RouterState<TRouteTree>>;
273
+ state: RouterState<TRouteTree>;
274
+ dehydratedData?: TDehydrated;
275
+ constructor(options: RouterConstructorOptions<TRouteTree, TDehydrated>);
267
276
  reset: () => void;
268
- notify: () => void;
269
- mount: () => () => void;
270
- onFocus: () => void;
271
- update: <TRouteConfig extends RouteConfig = RouteConfig>(opts?: RouterOptions<TRouteConfig>) => Router<TRouteConfig>;
272
- buildNext: (opts: BuildNextOptions) => Location;
277
+ mount: () => void;
278
+ update: (opts?: RouterOptions<any, any>) => this;
279
+ buildNext: (opts: BuildNextOptions) => ParsedLocation;
273
280
  cancelMatches: () => void;
274
- load: (next?: Location) => Promise<void>;
275
- matchCache: Record<string, MatchCacheEntry>;
276
- cleanMatchCache: () => void;
277
- getRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(id: TId) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
278
- loadRoute: (navigateOpts: BuildNextOptions) => Promise<RouteMatch[]>;
279
- preloadRoute: (navigateOpts: BuildNextOptions, loaderOpts: {
281
+ cancelMatch: (id: string) => void;
282
+ safeLoad: (opts?: {
283
+ next?: ParsedLocation;
284
+ }) => Promise<void>;
285
+ latestLoadPromise: Promise<void>;
286
+ load: (opts?: {
287
+ next?: ParsedLocation;
288
+ throwOnError?: boolean;
289
+ }) => Promise<void>;
290
+ getRoute: (id: string) => Route;
291
+ preloadRoute: (navigateOpts?: BuildNextOptions & {
292
+ maxAge?: number;
293
+ }) => Promise<RouteMatch<TRouteTree, ParseRoute<TRouteTree>>[]>;
294
+ cleanMatches: () => void;
295
+ matchRoutes: (pathname: string, locationSearch: AnySearchSchema, opts?: {
296
+ throwOnError?: boolean;
297
+ debug?: boolean;
298
+ }) => RouteMatch<TRouteTree, ParseRoute<TRouteTree>>[];
299
+ loadMatches: (resolvedMatches: AnyRouteMatch[], opts?: {
300
+ preload?: boolean;
280
301
  maxAge?: number;
281
- gcMaxAge?: number;
282
- }) => Promise<RouteMatch[]>;
283
- matchRoutes: (pathname: string, opts?: {
284
- strictParseParams?: boolean;
285
- }) => RouteMatch[];
286
- loadMatches: (resolvedMatches: RouteMatch[], loaderOpts?: {
287
- preload: true;
288
- maxAge: number;
289
- gcMaxAge: number;
290
- } | {
291
- preload?: false;
292
- maxAge?: never;
293
- gcMaxAge?: never;
294
302
  }) => Promise<void>;
295
- invalidateRoute: (opts: MatchLocation) => void;
296
303
  reload: () => Promise<void>;
297
304
  resolvePath: (from: string, path: string) => string;
298
- navigate: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo>) => Promise<void>;
299
- matchRoute: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(matchLocation: ToOptions<TAllRouteInfo, TFrom, TTo>, opts?: MatchRouteOptions) => boolean;
300
- buildLink: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: LinkOptions<TAllRouteInfo, TFrom, TTo>) => LinkInfo;
301
- dehydrateState: () => DehydratedRouterState;
302
- hydrateState: (state: DehydratedRouterState) => void;
303
- __: {
304
- buildRouteTree: (routeConfig: RouteConfig) => Route<TAllRouteInfo, AnyRouteInfo>;
305
- parseLocation: (location: History['location'], previousLocation?: Location) => Location;
306
- buildLocation: (dest: BuildNextOptions) => Location;
307
- commitLocation: (next: Location, replace?: boolean) => Promise<void>;
308
- navigate: (location: BuildNextOptions & {
309
- replace?: boolean;
310
- }) => Promise<void>;
311
- };
312
- }
313
- declare function createRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>>(userOptions?: RouterOptions<TRouteConfig>): Router<TRouteConfig, TAllRouteInfo>;
314
-
315
- interface AnyRoute extends Route<any, any> {
316
- }
317
- interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> {
318
- routeId: TRouteInfo['id'];
319
- routeRouteId: TRouteInfo['routeId'];
320
- routePath: TRouteInfo['path'];
321
- fullPath: TRouteInfo['fullPath'];
322
- parentRoute?: AnyRoute;
323
- childRoutes?: AnyRoute[];
324
- options: RouteOptions;
325
- router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>;
326
- buildLink: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>) => LinkInfo;
327
- matchRoute: <TTo extends string = '.', TResolved extends string = ResolveRelativePath<TRouteInfo['id'], TTo>>(matchLocation: CheckRelativePath<TAllRouteInfo, TRouteInfo['fullPath'], NoInfer<TTo>> & Omit<ToOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>, opts?: MatchRouteOptions) => RouteInfoByPath<TAllRouteInfo, TResolved>['allParams'];
328
- navigate: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['id'], TTo>, 'from'>) => Promise<void>;
329
- action: unknown extends TRouteInfo['actionResponse'] ? Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']> | undefined : Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>;
330
- loader: unknown extends TRouteInfo['routeLoaderData'] ? Action<LoaderContext<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams']>, TRouteInfo['routeLoaderData']> | undefined : Loader<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams'], TRouteInfo['routeLoaderData']>;
331
- }
332
- declare function createRoute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo>(routeConfig: RouteConfig, options: TRouteInfo['options'], parent: undefined | Route<TAllRouteInfo, any>, router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>): Route<TAllRouteInfo, TRouteInfo>;
333
-
334
- interface AnyAllRouteInfo {
335
- routeConfig: AnyRouteConfig;
336
- routeInfo: AnyRouteInfo;
337
- routeInfoById: Record<string, AnyRouteInfo>;
338
- routeInfoByFullPath: Record<string, AnyRouteInfo>;
339
- routeIds: any;
340
- routePaths: any;
341
- }
342
- interface DefaultAllRouteInfo {
343
- routeConfig: RouteConfig;
344
- routeInfo: RouteInfo;
345
- routeInfoById: Record<string, RouteInfo>;
346
- routeInfoByFullPath: Record<string, RouteInfo>;
347
- routeIds: string;
348
- routePaths: string;
349
- }
350
- interface AllRouteInfo<TRouteConfig extends AnyRouteConfig = RouteConfig> extends RoutesInfoInner<TRouteConfig, ParseRouteConfig<TRouteConfig>> {
351
- }
352
- declare type ParseRouteConfig<TRouteConfig = AnyRouteConfig> = TRouteConfig extends AnyRouteConfig ? RouteConfigRoute<TRouteConfig> | ParseRouteChildren<TRouteConfig> : never;
353
- declare type ParseRouteChildren<TRouteConfig> = TRouteConfig extends AnyRouteConfigWithChildren<infer TChildren> ? unknown extends TChildren ? never : TChildren extends AnyRouteConfig[] ? Values<{
354
- [TId in TChildren[number]['id']]: ParseRouteChild<TChildren[number], TId>;
355
- }> : never : never;
356
- declare type ParseRouteChild<TRouteConfig, TId> = TRouteConfig & {
357
- id: TId;
358
- } extends AnyRouteConfig ? ParseRouteConfig<TRouteConfig> : never;
359
- declare type RouteConfigRoute<TRouteConfig> = TRouteConfig extends RouteConfig<infer TId, infer TRouteId, infer TPath, infer TFullPath, infer TParentLoaderData, infer TRouteLoaderData, infer TLoaderData, infer TActionPayload, infer TActionResponse, infer TParentSearchSchema, infer TSearchSchema, infer TFullSearchSchema, infer TParentParams, infer TParams, infer TAllParams, any> ? string extends TRouteId ? never : RouteInfo<TId, TRouteId, TPath, TFullPath, TParentLoaderData, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams> : never;
360
- interface RoutesInfoInner<TRouteConfig extends AnyRouteConfig, TRouteInfo extends RouteInfo<string, string, any, any, any, any, any, any, any, any, any, any, any, any, any> = RouteInfo, TRouteInfoById = {
361
- [TInfo in TRouteInfo as TInfo['id']]: TInfo;
362
- }, TRouteInfoByFullPath = {
363
- [TInfo in TRouteInfo as TInfo['fullPath'] extends RootRouteId ? never : string extends TInfo['fullPath'] ? never : TInfo['fullPath']]: TInfo;
364
- }> {
365
- routeConfig: TRouteConfig;
366
- routeInfo: TRouteInfo;
367
- routeInfoById: TRouteInfoById;
368
- routeInfoByFullPath: TRouteInfoByFullPath;
369
- routeIds: keyof TRouteInfoById;
370
- routePaths: keyof TRouteInfoByFullPath;
371
- }
372
- interface AnyRouteInfo extends RouteInfo<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
373
- }
374
- interface RouteInfo<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = {}, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams = {}> {
375
- id: TId;
376
- routeId: TRouteId;
377
- path: TPath;
378
- fullPath: TFullPath;
379
- parentRouteLoaderData: TParentRouteLoaderData;
380
- routeLoaderData: TRouteLoaderData;
381
- loaderData: TLoaderData;
382
- actionPayload: TActionPayload;
383
- actionResponse: TActionResponse;
384
- searchSchema: TSearchSchema;
385
- fullSearchSchema: TFullSearchSchema;
386
- parentParams: TParentParams;
387
- params: TParams;
388
- allParams: TAllParams;
389
- options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
390
- }
391
- declare type RoutesById<TAllRouteInfo extends AnyAllRouteInfo> = {
392
- [K in keyof TAllRouteInfo['routeInfoById']]: Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][K]>;
305
+ navigate: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">({ from, to, search, hash, replace, params, }: NavigateOptions<TRouteTree, TFrom, TTo>) => Promise<void>;
306
+ 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"];
307
+ buildLink: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">({ from, to, search, params, hash, target, replace, activeOptions, preload, preloadDelay: userPreloadDelay, disabled, state, }: LinkOptions<TRouteTree, TFrom, TTo>) => LinkInfo;
308
+ dehydrate: () => DehydratedRouter;
309
+ hydrate: (__do_not_use_server_ctx?: HydrationCtx) => Promise<void>;
310
+ injectedHtml: (string | (() => Promise<string> | string))[];
311
+ injectHtml: (html: string | (() => Promise<string> | string)) => Promise<void>;
312
+ dehydrateData: <T>(key: any, getData: T | (() => T | Promise<T>)) => () => T | undefined;
313
+ hydrateData: <T = unknown>(key: any) => T | undefined;
314
+ getRouteMatch: (id: string) => undefined | RouteMatch<TRouteTree, AnyRoute>;
315
+ setRouteMatch: (id: string, updater: (prev: RouteMatch<TRouteTree, AnyRoute>) => RouteMatch<TRouteTree, AnyRoute>) => void;
316
+ setRouteMatchData: (id: string, updater: (prev: any) => any, opts?: {
317
+ updatedAt?: number;
318
+ maxAge?: number;
319
+ }) => void;
320
+ invalidate: (opts?: {
321
+ matchId?: string;
322
+ reload?: boolean;
323
+ }) => Promise<void>;
324
+ getIsInvalid: (opts?: {
325
+ matchId: string;
326
+ preload?: boolean;
327
+ }) => boolean;
328
+ }
329
+ type AnyRedirect = Redirect<any, any, any>;
330
+ type Redirect<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = NavigateOptions<TRouteTree, TFrom, TTo> & {
331
+ code?: number;
393
332
  };
394
- declare type RouteInfoById<TAllRouteInfo extends AnyAllRouteInfo, TId> = TId extends keyof TAllRouteInfo['routeInfoById'] ? IsAny<TAllRouteInfo['routeInfoById'][TId]['id'], RouteInfo, TAllRouteInfo['routeInfoById'][TId]> : never;
395
- declare type RouteInfoByPath<TAllRouteInfo extends AnyAllRouteInfo, TPath> = TPath extends keyof TAllRouteInfo['routeInfoByFullPath'] ? IsAny<TAllRouteInfo['routeInfoByFullPath'][TPath]['id'], RouteInfo, TAllRouteInfo['routeInfoByFullPath'][TPath]> : never;
333
+ declare function redirect<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''>(opts: Redirect<TRouteTree, TFrom, TTo>): Redirect<TRouteTree, TFrom, TTo>;
334
+ declare function isRedirect(obj: any): obj is AnyRedirect;
335
+ declare class SearchParamError extends Error {
336
+ }
337
+ declare class PathParamError extends Error {
338
+ }
339
+ 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]>>;
396
340
 
397
341
  declare const rootRouteId: "__root__";
398
- declare type RootRouteId = typeof rootRouteId;
399
- declare type AnyLoaderData = {};
400
- declare type AnyPathParams = {};
401
- declare type AnySearchSchema = {};
342
+ type RootRouteId = typeof rootRouteId;
343
+ type AnyPathParams = {};
344
+ type AnySearchSchema = {};
345
+ type AnyContext = {};
402
346
  interface RouteMeta {
403
347
  }
404
- declare type SearchSchemaValidator<TReturn, TParentSchema> = SearchSchemaValidatorObj<TReturn, TParentSchema> | SearchSchemaValidatorFn<TReturn, TParentSchema>;
405
- declare type SearchSchemaValidatorObj<TReturn, TParentSchema> = {
406
- parse?: SearchSchemaValidatorFn<TReturn, TParentSchema>;
348
+ interface RouteContext {
349
+ }
350
+ interface RegisterRouteComponent<TProps> {
351
+ }
352
+ interface RegisterRouteErrorComponent<TProps> {
353
+ }
354
+ type RegisteredRouteComponent<TProps> = RegisterRouteComponent<TProps> extends {
355
+ RouteComponent: infer T;
356
+ } ? T : (props: TProps) => unknown;
357
+ type RegisteredRouteErrorComponent<TProps> = RegisterRouteErrorComponent<TProps> extends {
358
+ RouteErrorComponent: infer T;
359
+ } ? T : (props: TProps) => unknown;
360
+ type PreloadableObj = {
361
+ preload?: () => Promise<void>;
407
362
  };
408
- declare type SearchSchemaValidatorFn<TReturn, TParentSchema> = (searchObj: Record<string, unknown>) => {} extends TParentSchema ? TReturn : keyof TReturn extends keyof TParentSchema ? {
409
- error: 'Top level search params cannot be redefined by child routes!';
410
- keys: keyof TReturn & keyof TParentSchema;
411
- } : TReturn;
412
- declare type DefinedPathParamWarning = 'Path params cannot be redefined by child routes!';
413
- declare type ParentParams<TParentParams> = AnyPathParams extends TParentParams ? {} : {
414
- [Key in keyof TParentParams]?: DefinedPathParamWarning;
363
+ type RoutePathOptions<TCustomId, TPath> = {
364
+ path: TPath;
365
+ } | {
366
+ id: TCustomId;
415
367
  };
416
- declare type LoaderFn<TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> = (loaderContext: LoaderContext<TParentRouteLoaderData, TFullSearchSchema, TAllParams>) => Promise<TRouteLoaderData>;
417
- interface LoaderContext<TParentRouteLoaderData extends AnyLoaderData = {}, TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> {
368
+ type RoutePathOptionsIntersection<TCustomId, TPath> = UnionToIntersection<RoutePathOptions<TCustomId, TPath>>;
369
+ type MetaOptions = keyof PickRequired<RouteMeta> extends never ? {
370
+ meta?: RouteMeta;
371
+ } : {
372
+ meta: RouteMeta;
373
+ };
374
+ type AnyRouteProps = RouteProps<any, any, any, any, any>;
375
+ type ComponentPropsFromRoute<TRoute> = TRoute extends Route<infer TParentRoute, infer TPath, infer TFullPath, infer TCustomId, infer TId, infer TLoader, infer TSearchSchema, infer TFullSearchSchema, infer TParams, infer TAllParams, infer TParentContext, infer TAllParentContext, infer TRouteContext, infer TContext, infer TRouterContext, infer TChildren, infer TRouteTree> ? RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext> : never;
376
+ type ComponentFromRoute<TRoute> = RegisteredRouteComponent<ComponentPropsFromRoute<TRoute>>;
377
+ type RouteLoaderFromRoute<TRoute extends AnyRoute> = LoaderFn<TRoute['__types']['loader'], TRoute['__types']['searchSchema'], TRoute['__types']['fullSearchSchema'], TRoute['__types']['allParams'], TRoute['__types']['routeContext'], TRoute['__types']['context']>;
378
+ type RouteProps<TLoader extends any = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TContext extends AnyContext = AnyContext> = {
379
+ useMatch: () => RouteMatch<any, any>;
380
+ useLoader: () => UseLoaderResult<TLoader>;
381
+ useSearch: <TStrict extends boolean = true, TSearch = TFullSearchSchema, TSelected = TSearch>(opts?: {
382
+ strict?: TStrict;
383
+ select?: (search: TSearch) => TSelected;
384
+ }) => TStrict extends true ? TSelected : TSelected | undefined;
385
+ useParams: <TDefaultSelected = TAllParams, TSelected = TDefaultSelected>(opts?: {
386
+ select?: (params: TDefaultSelected) => TSelected;
387
+ }) => TSelected;
388
+ useContext: <TDefaultSelected = TContext, TSelected = TDefaultSelected>(opts?: {
389
+ select?: (context: TDefaultSelected) => TSelected;
390
+ }) => TSelected;
391
+ useRouteContext: <TDefaultSelected = TRouteContext, TSelected = TDefaultSelected>(opts?: {
392
+ select?: (context: TDefaultSelected) => TSelected;
393
+ }) => TSelected;
394
+ };
395
+ 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>;
396
+ type ParamsFallback<TPath extends string, TParams> = unknown extends TParams ? Record<ParsePathParams<TPath>, string> : TParams;
397
+ 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> & {
398
+ layoutLimit?: string;
399
+ getParentRoute: () => TParentRoute;
400
+ validateSearch?: SearchSchemaValidator<TSearchSchema>;
401
+ loader?: LoaderFn<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TAllContext>;
402
+ } & ([TLoader] extends [never] ? {
403
+ loader: 'Loaders must return a type other than never. If you are throwing a redirect() and not returning anything, return a redirect() instead.';
404
+ } : {}) & ({
405
+ parseParams?: (rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>) => TParams extends Record<ParsePathParams<TPath>, any> ? TParams : 'parseParams must return an object';
406
+ stringifyParams?: (params: NoInfer<ParamsFallback<TPath, TParams>>) => Record<ParsePathParams<TPath>, string>;
407
+ } | {
408
+ stringifyParams?: never;
409
+ parseParams?: never;
410
+ }) & (keyof PickRequired<RouteContext> extends never ? {
411
+ getContext?: GetContextFn<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext>;
412
+ } : {
413
+ getContext: GetContextFn<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext>;
414
+ });
415
+ type GetContextFn<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext> = (opts: {
418
416
  params: TAllParams;
419
417
  search: TFullSearchSchema;
420
- signal?: AbortSignal;
421
- parentLoaderPromise?: Promise<TParentRouteLoaderData>;
422
- }
423
- declare type ActionFn<TActionPayload = unknown, TActionResponse = unknown> = (submission: TActionPayload) => TActionResponse | Promise<TActionResponse>;
424
- declare type UnloaderFn<TPath extends string> = (routeMatch: RouteMatch<any, RouteInfo<string, TPath>>) => void;
425
- declare type RouteOptions<TRouteId extends string = string, TPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = {}, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams = {}> = ({
426
- path: TPath;
427
- } | {
428
- id: TRouteId;
429
- }) & {
418
+ } & (TParentRoute extends undefined ? {
419
+ context?: TAllParentContext;
420
+ parentContext?: TParentContext;
421
+ } : {
422
+ context: TAllParentContext;
423
+ parentContext: TParentContext;
424
+ })) => TRouteContext;
425
+ type UpdatableRouteOptions<TLoader, TSearchSchema extends AnySearchSchema, TFullSearchSchema extends AnySearchSchema, TAllParams extends AnyPathParams, TRouteContext extends AnyContext, TContext extends AnyContext> = MetaOptions & {
426
+ key?: null | false | GetKeyFn<TFullSearchSchema, TAllParams>;
430
427
  caseSensitive?: boolean;
431
- validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>;
428
+ wrapInSuspense?: boolean;
429
+ component?: RegisteredRouteComponent<RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>>;
430
+ errorComponent?: RegisteredRouteErrorComponent<{
431
+ error: unknown;
432
+ } & Partial<RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>>>;
433
+ pendingComponent?: RegisteredRouteComponent<RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>>;
432
434
  preSearchFilters?: SearchFilter<TFullSearchSchema>[];
433
435
  postSearchFilters?: SearchFilter<TFullSearchSchema>[];
434
- component?: GetFrameworkGeneric<'Component'>;
435
- errorComponent?: GetFrameworkGeneric<'Component'>;
436
- pendingComponent?: GetFrameworkGeneric<'Component'>;
437
- loader?: LoaderFn<TParentRouteLoaderData, TRouteLoaderData, TFullSearchSchema, TAllParams>;
438
- loaderMaxAge?: number;
439
- loaderGcMaxAge?: number;
440
- action?: ActionFn<TActionPayload, TActionResponse>;
441
- useErrorBoundary?: boolean;
442
- onMatch?: (matchContext: {
436
+ preloadMaxAge?: number;
437
+ maxAge?: number;
438
+ gcMaxAge?: number;
439
+ beforeLoad?: (opts: LoaderContext<TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TContext>) => Promise<void> | void;
440
+ onBeforeLoadError?: (err: any) => void;
441
+ onValidateSearchError?: (err: any) => void;
442
+ onParseParamsError?: (err: any) => void;
443
+ onLoadError?: (err: any) => void;
444
+ onError?: (err: any) => void;
445
+ onLoaded?: (matchContext: {
443
446
  params: TAllParams;
444
447
  search: TFullSearchSchema;
445
448
  }) => void | undefined | ((match: {
@@ -450,65 +453,209 @@ declare type RouteOptions<TRouteId extends string = string, TPath extends string
450
453
  params: TAllParams;
451
454
  search: TFullSearchSchema;
452
455
  }) => void;
453
- meta?: RouteMeta;
454
- } & ({
455
- parseParams?: never;
456
- stringifyParams?: never;
457
- } | {
458
- parseParams: (rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>) => TParams;
459
- stringifyParams: (params: TParams) => Record<ParsePathParams<TPath>, string>;
460
- }) & (PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never ? {} : 'Cannot redefined path params in child routes!');
461
- declare type SearchFilter<T, U = T> = (prev: T) => U;
462
- interface RouteConfig<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData, TRouteLoaderData extends AnyLoaderData = AnyLoaderData, TLoaderData extends AnyLoaderData = AnyLoaderData, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams = {}, TKnownChildren = unknown> {
456
+ };
457
+ type ParseParamsOption<TPath extends string, TParams> = ParseParamsFn<TPath, TParams>;
458
+ 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';
459
+ type ParseParamsObj<TPath extends string, TParams> = {
460
+ parse?: ParseParamsFn<TPath, TParams>;
461
+ };
462
+ type SearchSchemaValidator<TReturn> = SearchSchemaValidatorObj<TReturn> | SearchSchemaValidatorFn<TReturn>;
463
+ type SearchSchemaValidatorObj<TReturn> = {
464
+ parse?: SearchSchemaValidatorFn<TReturn>;
465
+ };
466
+ type SearchSchemaValidatorFn<TReturn> = (searchObj: Record<string, unknown>) => TReturn;
467
+ type DefinedPathParamWarning = 'Path params cannot be redefined by child routes!';
468
+ type ParentParams<TParentParams> = AnyPathParams extends TParentParams ? {} : {
469
+ [Key in keyof TParentParams]?: DefinedPathParamWarning;
470
+ };
471
+ 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> & {
472
+ parentMatchPromise?: Promise<void>;
473
+ }) => Promise<TLoader> | TLoader;
474
+ type GetKeyFn<TFullSearchSchema extends AnySearchSchema = {}, TAllParams = {}> = (loaderContext: {
475
+ params: TAllParams;
476
+ search: TFullSearchSchema;
477
+ }) => any;
478
+ interface LoaderContext<TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TAllParams = {}, TContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> {
479
+ params: TAllParams;
480
+ routeSearch: TSearchSchema;
481
+ search: TFullSearchSchema;
482
+ abortController: AbortController;
483
+ preload: boolean;
484
+ routeContext: TContext;
485
+ context: TAllContext;
486
+ }
487
+ type UnloaderFn<TPath extends string> = (routeMatch: RouteMatch<any, Route>) => void;
488
+ type SearchFilter<T, U = T> = (prev: T) => U;
489
+ type ResolveId<TParentRoute, TCustomId extends string, TPath extends string> = TParentRoute extends {
490
+ id: infer TParentId extends string;
491
+ } ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId> : RootRouteId;
492
+ type InferFullSearchSchema<TRoute> = TRoute extends {
493
+ isRoot: true;
494
+ __types: {
495
+ searchSchema: infer TSearchSchema;
496
+ };
497
+ } ? TSearchSchema : TRoute extends {
498
+ __types: {
499
+ fullSearchSchema: infer TFullSearchSchema;
500
+ };
501
+ } ? TFullSearchSchema : {};
502
+ type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = InferFullSearchSchema<TParentRoute> & TSearchSchema;
503
+ interface AnyRoute extends Route<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
504
+ }
505
+ type MergeParamsFromParent<T, U> = IsAny<T, U, T & U>;
506
+ type UseLoaderResult<T> = T extends Record<PropertyKey, infer U> ? {
507
+ [K in keyof T]: UseLoaderResultPromise<T[K]>;
508
+ } : UseLoaderResultPromise<T>;
509
+ type UseLoaderResultPromise<T> = T extends Promise<infer U> ? StreamedPromise<U> : T;
510
+ type StreamedPromise<T> = {
511
+ promise: Promise<T>;
512
+ status: 'resolved' | 'pending';
513
+ data: T;
514
+ resolve: (value: T) => void;
515
+ };
516
+ type RouteConstraints = {
517
+ TParentRoute: AnyRoute;
518
+ TPath: string;
519
+ TFullPath: string;
520
+ TCustomId: string;
521
+ TId: string;
522
+ TSearchSchema: AnySearchSchema;
523
+ TFullSearchSchema: AnySearchSchema;
524
+ TParams: Record<string, any>;
525
+ TAllParams: Record<string, any>;
526
+ TParentContext: AnyContext;
527
+ TAllParentContext: AnyContext;
528
+ TRouteContext: RouteContext;
529
+ TAllContext: AnyContext;
530
+ TRouterContext: AnyContext;
531
+ TChildren: unknown;
532
+ TRouteTree: AnyRoute;
533
+ };
534
+ 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> {
535
+ __types: {
536
+ parentRoute: TParentRoute;
537
+ path: TPath;
538
+ to: TrimPathRight<TFullPath>;
539
+ fullPath: TFullPath;
540
+ customId: TCustomId;
541
+ id: TId;
542
+ loader: TLoader;
543
+ searchSchema: TSearchSchema;
544
+ fullSearchSchema: TFullSearchSchema;
545
+ params: TParams;
546
+ allParams: TAllParams;
547
+ parentContext: TParentContext;
548
+ allParentContext: TAllParentContext;
549
+ routeContext: TRouteContext;
550
+ context: TAllContext;
551
+ children: TChildren;
552
+ routeTree: TRouteTree;
553
+ routerContext: TRouterContext;
554
+ };
555
+ isRoot: TParentRoute extends Route<any> ? true : false;
556
+ options: RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TAllContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TAllContext>;
557
+ parentRoute: TParentRoute;
463
558
  id: TId;
464
- routeId: TRouteId;
465
- path: NoInfer<TPath>;
559
+ path: TPath;
466
560
  fullPath: TFullPath;
467
- options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
468
- children?: TKnownChildren;
469
- addChildren: IsAny<TId, any, <TNewChildren extends any>(children: TNewChildren extends AnyRouteConfig[] ? TNewChildren : {
470
- error: 'Invalid route detected';
471
- route: TNewChildren;
472
- }) => RouteConfig<TId, TRouteId, TPath, TFullPath, TParentRouteLoaderData, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
473
- createChildren: IsAny<TId, any, <TNewChildren extends any>(cb: (createChildRoute: CreateRouteConfigFn<false, TId, TFullPath, TRouteLoaderData, TLoaderData, TFullSearchSchema, TAllParams>) => TNewChildren extends AnyRouteConfig[] ? TNewChildren : {
474
- error: 'Invalid route detected';
475
- route: TNewChildren;
476
- }) => RouteConfig<TId, TRouteId, TPath, TFullPath, TParentRouteLoaderData, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
477
- createRoute: CreateRouteConfigFn<false, TId, TFullPath, TRouteLoaderData, TLoaderData, TFullSearchSchema, TAllParams>;
478
- }
479
- declare type CreateRouteConfigFn<TIsRoot extends boolean = false, TParentId extends string = string, TParentPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TParentSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}> = <TRouteId extends string, TPath extends string, TRouteLoaderData extends AnyLoaderData, TActionPayload, TActionResponse, TSearchSchema extends AnySearchSchema = AnySearchSchema, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams> = AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams>, TKnownChildren extends RouteConfig[] = RouteConfig[], TResolvedId extends string = string extends TRouteId ? string extends TPath ? string : TPath : TRouteId>(options?: TIsRoot extends true ? Omit<RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, Expand<TParentLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'> & {
480
- path?: never;
481
- } : RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, Expand<TParentLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, children?: TKnownChildren, isRoot?: boolean, parentId?: string, parentPath?: string) => RouteConfig<RoutePrefix<TParentId, TResolvedId>, TResolvedId, TPath, string extends TPath ? '' : RoutePath<RoutePrefix<TParentPath, TPath>>, TParentRouteLoaderData, TRouteLoaderData, Expand<TParentLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>, TKnownChildren>;
482
- declare type RoutePath<T extends string> = T extends RootRouteId ? '/' : TrimPathRight<`${T}`>;
483
- declare type RoutePrefix<TPrefix extends string, TId extends string> = string extends TId ? RootRouteId : TId extends string ? `${TPrefix}/${TId}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TId>}`>}` : never;
484
- interface AnyRouteConfig extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
485
- }
486
- interface AnyRouteConfigWithChildren<TChildren> extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, TChildren> {
487
- }
488
- declare type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
489
- declare type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
490
- declare type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
491
- declare const createRouteConfig: CreateRouteConfigFn<true>;
561
+ to: TrimPathRight<TFullPath>;
562
+ children?: TChildren;
563
+ originalIndex?: number;
564
+ router?: AnyRouter;
565
+ rank: number;
566
+ constructor(options: RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TAllContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TAllContext>);
567
+ init: (opts: {
568
+ originalIndex: number;
569
+ router: AnyRouter;
570
+ }) => void;
571
+ addChildren: <TNewChildren extends AnyRoute[]>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TLoader, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TAllContext, TRouterContext, TNewChildren, TRouteTree>;
572
+ update: (options: UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TAllContext>) => this;
573
+ static __onInit: (route: typeof this$1) => void;
574
+ }
575
+ type AnyRootRoute = RootRoute<any, any, any, any>;
576
+ declare class RouterContext<TRouterContext extends {}> {
577
+ constructor();
578
+ 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>;
579
+ }
580
+ 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> {
581
+ constructor(options?: Omit<RouteOptions<AnyRoute, RootRouteId, '', TLoader, TSearchSchema, TSearchSchema, TSearchSchema, {}, {}, TRouterContext, TRouterContext, TRouteContext, MergeParamsFromParent<TRouterContext, TRouteContext>>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams'>);
582
+ }
583
+ type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TPrefixed;
584
+ 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;
585
+ type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
586
+ type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
587
+ type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
588
+
589
+ interface FileRoutesByPath {
590
+ }
591
+ type Replace<S extends string, From extends string, To extends string> = S extends `${infer Start}${From}${infer Rest}` ? `${Start}${To}${Replace<Rest, From, To>}` : S;
592
+ type TrimLeft<T extends string, S extends string> = T extends `${S}${infer U}` ? U : T;
593
+ type TrimRight<T extends string, S extends string> = T extends `${infer U}${S}` ? U : T;
594
+ type Trim<T extends string, S extends string> = TrimLeft<TrimRight<T, S>, S>;
595
+ type RemoveUnderScores<T extends string> = Replace<Replace<TrimRight<TrimLeft<T, '/_'>, '_'>, '_/', '/'>, '/_', '/'>;
596
+ type ResolveFilePath<TParentRoute extends AnyRoute, TFilePath extends string> = TParentRoute['id'] extends RootRouteId ? TrimPathLeft<TFilePath> : Replace<TrimPathLeft<TFilePath>, TrimPathLeft<TParentRoute['__types']['customId']>, ''>;
597
+ type FileRoutePath<TParentRoute extends AnyRoute, TFilePath extends string> = ResolveFilePath<TParentRoute, TFilePath> extends `_${infer _}` ? string : ResolveFilePath<TParentRoute, TFilePath>;
598
+ declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'], TId extends RouteConstraints['TId'] = TFilePath, TPath extends RouteConstraints['TPath'] = FileRoutePath<TParentRoute, TFilePath>, TFullPath extends RouteConstraints['TFullPath'] = ResolveFullPath<TParentRoute, RemoveUnderScores<TPath>>> {
599
+ path: TFilePath;
600
+ constructor(path: TFilePath);
601
+ createRoute: <TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<string, any> = (TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never) extends never ? AnyPathParams : Record<TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> extends infer T ? T extends TrimLeft<TrimRight<Split<TPath, true>[number], "_">, "_"> ? T extends `$${infer L}` ? L : never : never : never, string>, TAllParams extends Record<string, any> = IsAny<TParentRoute["__types"]["allParams"], TParams, TParentRoute["__types"]["allParams"] & TParams>, TParentContext extends AnyContext = TParentRoute["__types"]["routeContext"], TAllParentContext extends string = TParentRoute["__types"]["context"], TRouteContext extends RouteContext = RouteContext, TContext extends AnyContext = IsAny<TParentRoute["__types"]["context"], TRouteContext, TParentRoute["__types"]["context"] & TRouteContext>, TRouterContext extends AnyContext = AnyContext, TChildren extends unknown = unknown, TRouteTree extends AnyRoute = AnyRoute>(options: Omit<RouteOptions<TParentRoute, string, string, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext>, "id" | "path" | "getParentRoute"> & {
602
+ meta?: RouteMeta | undefined;
603
+ } & {
604
+ key?: false | GetKeyFn<TFullSearchSchema, TAllParams> | null | undefined;
605
+ caseSensitive?: boolean | undefined;
606
+ wrapInSuspense?: boolean | undefined;
607
+ component?: ((props: RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>) => unknown) | undefined;
608
+ errorComponent?: ((props: {
609
+ error: unknown;
610
+ } & Partial<RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>>) => unknown) | undefined;
611
+ pendingComponent?: ((props: RouteProps<TLoader, TFullSearchSchema, TAllParams, TRouteContext, TContext>) => unknown) | undefined;
612
+ preSearchFilters?: SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
613
+ postSearchFilters?: SearchFilter<TFullSearchSchema, TFullSearchSchema>[] | undefined;
614
+ preloadMaxAge?: number | undefined;
615
+ maxAge?: number | undefined;
616
+ gcMaxAge?: number | undefined;
617
+ beforeLoad?: ((opts: LoaderContext<TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TContext>) => void | Promise<void>) | undefined;
618
+ onBeforeLoadError?: ((err: any) => void) | undefined;
619
+ onValidateSearchError?: ((err: any) => void) | undefined;
620
+ onParseParamsError?: ((err: any) => void) | undefined;
621
+ onLoadError?: ((err: any) => void) | undefined;
622
+ onError?: ((err: any) => void) | undefined;
623
+ onLoaded?: ((matchContext: {
624
+ params: TAllParams;
625
+ search: TFullSearchSchema;
626
+ }) => void | ((match: {
627
+ params: TAllParams;
628
+ search: TFullSearchSchema;
629
+ }) => void) | undefined) | undefined;
630
+ onTransition?: ((match: {
631
+ params: TAllParams;
632
+ search: TFullSearchSchema;
633
+ }) => void) | undefined;
634
+ }) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TLoader, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext, TRouterContext, TChildren, TRouteTree>;
635
+ }
492
636
 
493
- declare type LinkInfo = {
637
+ type LinkInfo = {
494
638
  type: 'external';
495
639
  href: string;
496
640
  } | {
497
641
  type: 'internal';
498
- next: Location;
642
+ next: ParsedLocation;
499
643
  handleFocus: (e: any) => void;
500
644
  handleClick: (e: any) => void;
501
645
  handleEnter: (e: any) => void;
502
646
  handleLeave: (e: any) => void;
647
+ handleTouchStart: (e: any) => void;
503
648
  isActive: boolean;
504
649
  disabled?: boolean;
505
650
  };
506
- declare type StartsWith<A, B> = A extends `${B extends string ? B : never}${infer _}` ? true : false;
507
- declare 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;
508
- declare 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;
509
- declare type ParsePathParams<T extends string> = Split<T>[number] extends infer U ? U extends `:${infer V}` ? V : never : never;
510
- declare type Join<T> = T extends [] ? '' : T extends [infer L extends string] ? L : T extends [infer L extends string, ...infer Tail extends [...string[]]] ? CleanPath<`${L}/${Join<Tail>}`> : never;
511
- declare type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends string, TTo extends string, SplitPaths extends string[] = Split<AllPaths, false>> = TTo extends `..${infer _}` ? SplitPaths extends [
651
+ 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;
652
+ 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;
653
+ type ParsePathParams<T extends string> = keyof {
654
+ [K in Trim<Split<T>[number], '_'> as K extends `$${infer L}` ? L : never]: K;
655
+ };
656
+ 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;
657
+ type Last<T extends any[]> = T extends [...infer _, infer L] ? L : never;
658
+ type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends string, TTo extends string, SplitPaths extends string[] = Split<AllPaths, false>> = TTo extends `..${infer _}` ? SplitPaths extends [
512
659
  ...Split<ResolveRelativePath<TFrom, TTo>, false>,
513
660
  ...infer TToRest
514
661
  ] ? `${CleanPath<Join<[
@@ -518,65 +665,60 @@ declare type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends s
518
665
  ...Split<TFrom, false>,
519
666
  ...Split<RestTTo, false>,
520
667
  ...infer RestPath
521
- ] ? `${TTo}${Join<RestPath>}` : never : './' | '../' | AllPaths;
522
- declare type NavigateOptionsAbsolute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = ToOptions<TAllRouteInfo, TFrom, TTo> & {
668
+ ] ? `${TTo}${Join<RestPath>}` : never : (TFrom extends `/` ? never : SplitPaths extends [...Split<TFrom, false>, ...infer RestPath] ? Join<RestPath> extends {
669
+ length: 0;
670
+ } ? never : './' : never) | (TFrom extends `/` ? never : '../') | AllPaths;
671
+ type NavigateOptions<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = ToOptions<TRouteTree, TFrom, TTo> & {
523
672
  replace?: boolean;
524
673
  };
525
- declare type ToOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
526
- to?: ToPathOption<TAllRouteInfo, TFrom, TTo>;
674
+ type ToOptions<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = '', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
675
+ to?: ToPathOption<TRouteTree, TFrom, TTo>;
527
676
  hash?: Updater<string>;
528
677
  state?: LocationState;
529
678
  from?: TFrom;
530
- } & CheckPath<TAllRouteInfo, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TAllRouteInfo, TFrom, TResolvedTo> & PathParamOptions<TAllRouteInfo, TFrom, TResolvedTo>;
531
- declare type SearchParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromSchema = RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema'], TToSchema = RouteInfoByPath<TAllRouteInfo, TTo>['fullSearchSchema']> = StartsWith<TFrom, TTo> extends true ? {
532
- search?: SearchReducer<TFromSchema, TToSchema>;
533
- } : keyof PickRequired<TToSchema> extends never ? {
534
- search?: SearchReducer<TFromSchema, TToSchema>;
679
+ } & CheckPath<TRouteTree, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TRouteTree, TFrom, TResolvedTo> & PathParamOptions<TRouteTree, TFrom, TResolvedTo>;
680
+ 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 ? {
681
+ search?: true | SearchReducer<TFromFullSchema, TToFullSchema>;
535
682
  } : {
536
- search: SearchReducer<TFromSchema, TToSchema>;
683
+ search: SearchReducer<TFromFullSchema, TToFullSchema>;
537
684
  };
538
- declare type SearchReducer<TFrom, TTo> = {
685
+ type SearchReducer<TFrom, TTo> = {
539
686
  [TKey in keyof TTo]: TTo[TKey];
540
687
  } | ((current: TFrom) => TTo);
541
- declare type PathParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromParams = RouteInfoByPath<TAllRouteInfo, TFrom>['allParams'], TToParams = RouteInfoByPath<TAllRouteInfo, TTo>['allParams']> = StartsWith<TFrom, TTo> extends true ? {
542
- params?: ParamsReducer<TFromParams, TToParams>;
543
- } : AnyPathParams extends TToParams ? {
544
- params?: ParamsReducer<TFromParams, Record<string, never>>;
688
+ 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 ? {
689
+ params?: ParamsReducer<TFromFullParams, TToFullParams>;
545
690
  } : {
546
- params: ParamsReducer<TFromParams, TToParams>;
691
+ params: ParamsReducer<TFromFullParams, TToFullParams>;
547
692
  };
548
- declare type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
549
- declare type ToPathOption<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = TTo | RelativeToPathAutoComplete<TAllRouteInfo['routePaths'], NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
550
- declare type ToIdOption<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = TTo | RelativeToPathAutoComplete<TAllRouteInfo['routeIds'], NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
693
+ type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
694
+ 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>;
695
+ 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>;
551
696
  interface ActiveOptions {
552
697
  exact?: boolean;
553
698
  includeHash?: boolean;
699
+ includeSearch?: boolean;
554
700
  }
555
- declare type LinkOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo> & {
701
+ type LinkOptions<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> = '/', TTo extends string = ''> = NavigateOptions<TRouteTree, TFrom, TTo> & {
556
702
  target?: HTMLAnchorElement['target'];
557
703
  activeOptions?: ActiveOptions;
558
704
  preload?: false | 'intent';
559
- preloadMaxAge?: number;
560
- preloadGcMaxAge?: number;
561
705
  preloadDelay?: number;
562
706
  disabled?: boolean;
563
707
  };
564
- declare type CheckRelativePath<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo> = TTo extends string ? TFrom extends string ? ResolveRelativePath<TFrom, TTo> extends TAllRouteInfo['routePaths'] ? {} : {
708
+ type CheckRelativePath<TRouteTree extends AnyRoute, TFrom, TTo> = TTo extends string ? TFrom extends string ? ResolveRelativePath<TFrom, TTo> extends RoutePaths<TRouteTree> ? {} : {
565
709
  Error: `${TFrom} + ${TTo} resolves to ${ResolveRelativePath<TFrom, TTo>}, which is not a valid route path.`;
566
- 'Valid Route Paths': TAllRouteInfo['routePaths'];
710
+ 'Valid Route Paths': RoutePaths<TRouteTree>;
567
711
  } : {} : {};
568
- declare type CheckPath<TAllRouteInfo extends AnyAllRouteInfo, TPath, TPass> = Exclude<TPath, TAllRouteInfo['routePaths']> extends never ? TPass : CheckPathError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routePaths']>>;
569
- declare type CheckPathError<TAllRouteInfo extends AnyAllRouteInfo, TInvalids> = Expand<{
570
- Error: `${TInvalids extends string ? TInvalids : never} is not a valid route path.`;
571
- 'Valid Route Paths': TAllRouteInfo['routePaths'];
572
- }>;
573
- declare type CheckId<TAllRouteInfo extends AnyAllRouteInfo, TPath, TPass> = Exclude<TPath, TAllRouteInfo['routeIds']> extends never ? TPass : CheckIdError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routeIds']>>;
574
- declare type CheckIdError<TAllRouteInfo extends AnyAllRouteInfo, TInvalids> = Expand<{
712
+ type CheckPath<TRouteTree extends AnyRoute, TPath, TPass> = Exclude<TPath, RoutePaths<TRouteTree>> extends never ? TPass : CheckPathError<TRouteTree, Exclude<TPath, RoutePaths<TRouteTree>>>;
713
+ type CheckPathError<TRouteTree extends AnyRoute, TInvalids> = {
714
+ to: RoutePaths<TRouteTree>;
715
+ };
716
+ type CheckId<TRouteTree extends AnyRoute, TPath, TPass> = Exclude<TPath, RouteIds<TRouteTree>> extends never ? TPass : CheckIdError<TRouteTree, Exclude<TPath, RouteIds<TRouteTree>>>;
717
+ type CheckIdError<TRouteTree extends AnyRoute, TInvalids> = {
575
718
  Error: `${TInvalids extends string ? TInvalids : never} is not a valid route ID.`;
576
- 'Valid Route IDs': TAllRouteInfo['routeIds'];
577
- }>;
578
- declare 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;
579
- declare type ValidFromPath<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo> = undefined | (string extends TAllRouteInfo['routePaths'] ? string : TAllRouteInfo['routePaths']);
719
+ 'Valid Route IDs': RouteIds<TRouteTree>;
720
+ };
721
+ 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;
580
722
 
581
723
  interface Segment {
582
724
  type: 'pathname' | 'param' | 'wildcard';
@@ -589,9 +731,9 @@ declare function trimPathRight(path: string): string;
589
731
  declare function trimPath(path: string): string;
590
732
  declare function resolvePath(basepath: string, base: string, to: string): string;
591
733
  declare function parsePathname(pathname?: string): Segment[];
592
- declare function interpolatePath(path: string | undefined, params: any, leaveWildcard?: boolean): string;
593
- declare function matchPathname(currentPathname: string, matchLocation: Pick<MatchLocation, 'to' | 'fuzzy' | 'caseSensitive'>): AnyPathParams | undefined;
594
- declare function matchByPath(from: string, matchLocation: Pick<MatchLocation, 'to' | 'caseSensitive' | 'fuzzy'>): Record<string, string> | undefined;
734
+ declare function interpolatePath(path: string | undefined, params: any, leaveWildcards?: boolean): string;
735
+ declare function matchPathname(basepath: string, currentPathname: string, matchLocation: Pick<MatchLocation, 'to' | 'fuzzy' | 'caseSensitive'>): AnyPathParams | undefined;
736
+ declare function matchByPath(basepath: string, from: string, matchLocation: Pick<MatchLocation, 'to' | 'caseSensitive' | 'fuzzy'>): Record<string, string> | undefined;
595
737
 
596
738
  declare function encode(obj: any, pfx?: string): string;
597
739
  declare function decode(str: any): {};
@@ -599,6 +741,6 @@ declare function decode(str: any): {};
599
741
  declare const defaultParseSearch: (searchStr: string) => AnySearchSchema;
600
742
  declare const defaultStringifySearch: (search: Record<string, any>) => string;
601
743
  declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => AnySearchSchema;
602
- declare function stringifySearchWith(stringify: (search: any) => string): (search: Record<string, any>) => string;
744
+ declare function stringifySearchWith(stringify: (search: any) => string, parser?: (str: string) => any): (search: Record<string, any>) => string;
603
745
 
604
- export { Action, ActionFn, ActionState, AllRouteInfo, AnyAllRouteInfo, AnyLoaderData, AnyPathParams, AnyRoute, AnyRouteConfig, AnyRouteConfigWithChildren, AnyRouteInfo, AnySearchSchema, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, DeepAwaited, DefaultAllRouteInfo, DefinedPathParamWarning, Expand, FilterRoutesFn, FrameworkGenerics, FromLocation, GetFrameworkGeneric, IsAny, IsAnyBoolean, IsKnown, LinkInfo, LinkOptions, ListenerFn, Loader, LoaderContext, LoaderFn, LoaderState, Location, LocationState, MatchCacheEntry, MatchLocation, MatchRouteOptions, NavigateOptionsAbsolute, NoInfer, ParentParams, ParsePathParams, ParseRouteConfig, PathParamMask, PendingState, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, RelativeToPathAutoComplete, ResolveRelativePath, RootRouteId, Route, RouteConfig, RouteConfigRoute, RouteInfo, RouteInfoById, RouteInfoByPath, RouteMatch, RouteMeta, RouteOptions, Router, RouterOptions, RouterState, RoutesById, RoutesInfoInner, SearchFilter, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, Timeout, ToIdOption, ToOptions, ToPathOption, UnloaderFn, Updater, ValidFromPath, ValueKeys, Values, cleanPath, createRoute, createRouteConfig, createRouteMatch, createRouter, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, pick, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, warning };
746
+ export { ActiveOptions, AllParams, AnyContext, AnyPathParams, AnyRedirect, AnyRootRoute, AnyRoute, AnyRouteMatch, AnyRouteProps, AnyRouter, AnySearchSchema, BaseRouteOptions, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, CleanPath, ComponentFromRoute, ComponentPropsFromRoute, DeepAwaited, DefinedPathParamWarning, DehydratedRouter, DehydratedRouterState, Expand, FileRoute, FileRoutePath, FileRoutesByPath, FromLocation, FullSearchSchema, GetKeyFn, HydrationCtx, InferFullSearchSchema, IsAny, IsAnyBoolean, IsKnown, Join, Last, LinkInfo, LinkOptions, ListenerFn, LoaderContext, LoaderFn, LocationState, MatchLocation, MatchRouteOptions, MergeParamsFromParent, MergeUnion, MetaOptions, NavigateOptions, NoInfer, ParamsFallback, ParentParams, ParseParamsFn, ParseParamsObj, ParseParamsOption, ParsePathParams, ParseRoute, ParseRouteChildren, ParsedLocation, ParsedPath, PathParamError, PathParamMask, PathParamOptions, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, PreloadableObj, Redirect, Register, RegisterRouteComponent, RegisterRouteErrorComponent, RegisteredRouteComponent, RegisteredRouteErrorComponent, RegisteredRouter, RelativeToPathAutoComplete, RemoveUnderScores, ResolveFilePath, ResolveFullPath, ResolveFullSearchSchema, ResolveId, ResolveRelativePath, RootRoute, RootRouteId, Route, RouteById, RouteByPath, RouteConstraints, RouteContext, RouteIds, RouteLoaderFromRoute, RouteMatch, RouteMeta, RouteOptions, RoutePathOptions, RoutePathOptionsIntersection, RoutePaths, RouteProps, Router, RouterConstructorOptions, RouterContext, RouterContextOptions, RouterHistory, RouterLocation, RouterOptions, RouterState, RoutesById, RoutesByPath, SearchFilter, SearchParamError, SearchParamOptions, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, StreamedPromise, Timeout, ToIdOption, ToOptions, ToPathOption, Trim, TrimLeft, TrimPath, TrimPathLeft, TrimPathRight, TrimRight, UnionToIntersection, UnloaderFn, UpdatableRouteOptions, Updater, UseLoaderResult, UseLoaderResultPromise, ValueKeys, Values, cleanPath, componentTypes, createBrowserHistory, createHashHistory, createMemoryHistory, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, isPlainObject, isRedirect, joinPaths, last, lazyFn, matchByPath, matchPathname, parsePathname, parseSearchWith, partialDeepEqual, pick, redirect, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight };