@tanstack/router-core 0.0.1-beta.3 → 0.0.1-beta.30

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 (56) hide show
  1. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -2
  2. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
  3. package/build/cjs/{packages/router-core/src/index.js → index.js} +23 -7
  4. package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
  5. package/build/cjs/{packages/router-core/src/path.js → path.js} +7 -34
  6. package/build/cjs/path.js.map +1 -0
  7. package/build/cjs/{packages/router-core/src/qss.js → qss.js} +9 -13
  8. package/build/cjs/qss.js.map +1 -0
  9. package/build/cjs/{packages/router-core/src/route.js → route.js} +15 -37
  10. package/build/cjs/route.js.map +1 -0
  11. package/build/cjs/{packages/router-core/src/routeConfig.js → routeConfig.js} +13 -12
  12. package/build/cjs/routeConfig.js.map +1 -0
  13. package/build/cjs/routeMatch.js +200 -0
  14. package/build/cjs/routeMatch.js.map +1 -0
  15. package/build/cjs/{packages/router-core/src/router.js → router.js} +246 -208
  16. package/build/cjs/router.js.map +1 -0
  17. package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +7 -10
  18. package/build/cjs/searchParams.js.map +1 -0
  19. package/build/cjs/{packages/router-core/src/utils.js → utils.js} +17 -30
  20. package/build/cjs/utils.js.map +1 -0
  21. package/build/esm/index.js +382 -1307
  22. package/build/esm/index.js.map +1 -1
  23. package/build/stats-html.html +59 -49
  24. package/build/stats-react.json +161 -168
  25. package/build/types/index.d.ts +228 -206
  26. package/build/umd/index.development.js +373 -481
  27. package/build/umd/index.development.js.map +1 -1
  28. package/build/umd/index.production.js +1 -1
  29. package/build/umd/index.production.js.map +1 -1
  30. package/package.json +3 -2
  31. package/src/frameworks.ts +2 -2
  32. package/src/index.ts +0 -1
  33. package/src/link.ts +8 -5
  34. package/src/path.ts +2 -6
  35. package/src/qss.ts +1 -0
  36. package/src/route.ts +24 -32
  37. package/src/routeConfig.ts +100 -77
  38. package/src/routeInfo.ts +22 -7
  39. package/src/routeMatch.ts +95 -157
  40. package/src/router.ts +346 -122
  41. package/src/utils.ts +14 -7
  42. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
  43. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
  44. package/build/cjs/node_modules/history/index.js +0 -815
  45. package/build/cjs/node_modules/history/index.js.map +0 -1
  46. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
  47. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
  48. package/build/cjs/packages/router-core/src/path.js.map +0 -1
  49. package/build/cjs/packages/router-core/src/qss.js.map +0 -1
  50. package/build/cjs/packages/router-core/src/route.js.map +0 -1
  51. package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
  52. package/build/cjs/packages/router-core/src/routeMatch.js +0 -266
  53. package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
  54. package/build/cjs/packages/router-core/src/router.js.map +0 -1
  55. package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
  56. package/build/cjs/packages/router-core/src/utils.js.map +0 -1
@@ -14,36 +14,94 @@ export { default as invariant } from 'tiny-invariant';
14
14
 
15
15
  interface FrameworkGenerics {
16
16
  }
17
- declare type GetFrameworkGeneric<U> = U extends keyof FrameworkGenerics ? FrameworkGenerics[U] : any;
17
+ type GetFrameworkGeneric<U> = U extends keyof FrameworkGenerics ? FrameworkGenerics[U] : any;
18
18
 
19
- declare type NoInfer<T> = [T][T extends any ? 0 : never];
20
- declare type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N;
21
- declare type IsAnyBoolean<T> = 1 extends 0 & T ? true : false;
22
- declare type IsKnown<T, Y, N> = unknown extends T ? N : Y;
23
- declare type PickAsRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
24
- declare type PickAsPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
25
- declare type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never;
26
- declare type PickExtra<T, K> = Expand<{
19
+ interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> extends Route<TAllRouteInfo, TRouteInfo> {
20
+ matchId: string;
21
+ pathname: string;
22
+ params: TRouteInfo['allParams'];
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<'ErrorComponent'>;
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, any>, route: Route<TAllRouteInfo, TRouteInfo>, opts: {
70
+ parentMatch?: RouteMatch<any, any>;
71
+ matchId: string;
72
+ params: TRouteInfo['allParams'];
73
+ pathname: string;
74
+ }): RouteMatch<TAllRouteInfo, TRouteInfo>;
75
+
76
+ type NoInfer<T> = [T][T extends any ? 0 : never];
77
+ type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N;
78
+ type IsAnyBoolean<T> = 1 extends 0 & T ? true : false;
79
+ type IsKnown<T, Y, N> = unknown extends T ? N : Y;
80
+ type PickAsRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
81
+ type PickAsPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
82
+ type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never;
83
+ type PickExtra<T, K> = Expand<{
27
84
  [TKey in keyof K as string extends TKey ? never : TKey extends keyof T ? never : TKey]: K[TKey];
28
85
  }>;
29
- declare type PickRequired<T> = {
86
+ type PickRequired<T> = {
30
87
  [K in keyof T as undefined extends T[K] ? never : K]: T[K];
31
88
  };
32
- declare type Expand<T> = T extends object ? T extends infer O ? {
89
+ type Expand<T> = T extends object ? T extends infer O ? {
33
90
  [K in keyof O]: O[K];
34
91
  } : never : T;
35
- declare type Values<O> = O[ValueKeys<O>];
36
- declare type ValueKeys<O> = Extract<keyof O, PropertyKey>;
37
- declare type DeepAwaited<T> = T extends Promise<infer A> ? DeepAwaited<A> : T extends Record<infer A, Promise<infer B>> ? {
92
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => any ? I : never;
93
+ type Values<O> = O[ValueKeys<O>];
94
+ type ValueKeys<O> = Extract<keyof O, PropertyKey>;
95
+ type DeepAwaited<T> = T extends Promise<infer A> ? DeepAwaited<A> : T extends Record<infer A, Promise<infer B>> ? {
38
96
  [K in A]: DeepAwaited<B>;
39
97
  } : T;
40
- 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;
41
- declare type Timeout = ReturnType<typeof setTimeout>;
42
- declare type Updater<TPrevious, TResult = TPrevious> = TResult | ((prev?: TPrevious) => TResult);
43
- declare type PickExtract<T, U> = {
98
+ 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;
99
+ type Timeout = ReturnType<typeof setTimeout>;
100
+ type Updater<TPrevious, TResult = TPrevious> = TResult | ((prev?: TPrevious) => TResult);
101
+ type PickExtract<T, U> = {
44
102
  [K in keyof T as T[K] extends U ? K : never]: T[K];
45
103
  };
46
- declare type PickExclude<T, U> = {
104
+ type PickExclude<T, U> = {
47
105
  [K in keyof T as T[K] extends U ? never : K]: T[K];
48
106
  };
49
107
  /**
@@ -55,7 +113,16 @@ declare function replaceEqualDeep(prev: any, next: any): any;
55
113
  declare function last<T>(arr: T[]): T | undefined;
56
114
  declare function warning(cond: any, message: string): cond is true;
57
115
  declare function functionalUpdate<TResult>(updater: Updater<TResult>, previous: TResult): TResult;
116
+ declare function pick<T, K extends keyof T>(parent: T, keys: K[]): Pick<T, K>;
58
117
 
118
+ interface RegisterRouter {
119
+ }
120
+ type RegisteredRouter = RegisterRouter extends {
121
+ router: Router<infer TRouteConfig, infer TAllRouteInfo, infer TRouterContext>;
122
+ } ? Router<TRouteConfig, TAllRouteInfo, TRouterContext> : Router;
123
+ type RegisteredAllRouteInfo = RegisterRouter extends {
124
+ router: Router<infer TRouteConfig, infer TAllRouteInfo, infer TRouterContext>;
125
+ } ? TAllRouteInfo : AnyAllRouteInfo;
59
126
  interface LocationState {
60
127
  }
61
128
  interface Location<TSearchObj extends AnySearchSchema = {}, TState extends LocationState = LocationState> {
@@ -73,10 +140,10 @@ interface FromLocation {
73
140
  key?: string;
74
141
  hash?: string;
75
142
  }
76
- declare type SearchSerializer = (searchObj: Record<string, any>) => string;
77
- declare type SearchParser = (searchStr: string) => Record<string, any>;
78
- declare type FilterRoutesFn = <TRoute extends Route<any, RouteInfo>>(routeConfigs: TRoute[]) => TRoute[];
79
- interface RouterOptions<TRouteConfig extends AnyRouteConfig> {
143
+ type SearchSerializer = (searchObj: Record<string, any>) => string;
144
+ type SearchParser = (searchStr: string) => Record<string, any>;
145
+ type FilterRoutesFn = <TRoute extends Route<any, RouteInfo>>(routeConfigs: TRoute[]) => TRoute[];
146
+ interface RouterOptions<TRouteConfig extends AnyRouteConfig, TRouterContext> {
80
147
  history?: BrowserHistory | MemoryHistory | HashHistory;
81
148
  stringifySearch?: SearchSerializer;
82
149
  parseSearch?: SearchParser;
@@ -85,35 +152,37 @@ interface RouterOptions<TRouteConfig extends AnyRouteConfig> {
85
152
  defaultPreloadMaxAge?: number;
86
153
  defaultPreloadGcMaxAge?: number;
87
154
  defaultPreloadDelay?: number;
88
- useErrorBoundary?: boolean;
89
- defaultElement?: GetFrameworkGeneric<'Element'>;
90
- defaultErrorElement?: GetFrameworkGeneric<'Element'>;
91
- defaultCatchElement?: GetFrameworkGeneric<'Element'>;
92
- defaultPendingElement?: GetFrameworkGeneric<'Element'>;
93
- defaultPendingMs?: number;
94
- defaultPendingMinMs?: number;
155
+ defaultComponent?: GetFrameworkGeneric<'Component'>;
156
+ defaultErrorComponent?: GetFrameworkGeneric<'ErrorComponent'>;
157
+ defaultPendingComponent?: GetFrameworkGeneric<'Component'>;
95
158
  defaultLoaderMaxAge?: number;
96
159
  defaultLoaderGcMaxAge?: number;
97
160
  caseSensitive?: boolean;
98
161
  routeConfig?: TRouteConfig;
99
162
  basepath?: string;
100
- createRouter?: (router: Router<any, any>) => void;
163
+ useServerData?: boolean;
164
+ createRouter?: (router: Router<any, any, any>) => void;
101
165
  createRoute?: (opts: {
102
166
  route: AnyRoute;
103
- router: Router<any, any>;
167
+ router: Router<any, any, any>;
104
168
  }) => void;
105
- createElement?: (element: GetFrameworkGeneric<'SyncOrAsyncElement'>) => Promise<GetFrameworkGeneric<'Element'>>;
169
+ context?: TRouterContext;
170
+ loadComponent?: (component: GetFrameworkGeneric<'Component'>) => Promise<GetFrameworkGeneric<'Component'>>;
106
171
  }
107
172
  interface Action<TPayload = unknown, TResponse = unknown> {
108
- submit: (submission?: TPayload) => Promise<TResponse>;
173
+ submit: (submission?: TPayload, actionOpts?: {
174
+ invalidate?: boolean;
175
+ multi?: boolean;
176
+ }) => Promise<TResponse>;
109
177
  current?: ActionState<TPayload, TResponse>;
110
178
  latest?: ActionState<TPayload, TResponse>;
111
- pending: ActionState<TPayload, TResponse>[];
179
+ submissions: ActionState<TPayload, TResponse>[];
112
180
  }
113
181
  interface ActionState<TPayload = unknown, TResponse = unknown> {
114
182
  submittedAt: number;
115
183
  status: 'idle' | 'pending' | 'success' | 'error';
116
184
  submission: TPayload;
185
+ isMulti: boolean;
117
186
  data?: TResponse;
118
187
  error?: unknown;
119
188
  }
@@ -136,18 +205,15 @@ interface Loader<TFullSearchSchema extends AnySearchSchema = {}, TAllParams exte
136
205
  latest?: LoaderState<TFullSearchSchema, TAllParams>;
137
206
  pending: LoaderState<TFullSearchSchema, TAllParams>[];
138
207
  }
139
- interface LoaderState<TFullSearchSchema = unknown, TAllParams = unknown> {
208
+ interface LoaderState<TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> {
140
209
  loadedAt: number;
141
210
  loaderContext: LoaderContext<TFullSearchSchema, TAllParams>;
142
211
  }
143
- interface RouterState {
212
+ interface RouterState<TSearchObj extends AnySearchSchema = {}, TState extends LocationState = LocationState> {
144
213
  status: 'idle' | 'loading';
145
- location: Location;
214
+ location: Location<TSearchObj, TState>;
146
215
  matches: RouteMatch[];
147
216
  lastUpdated: number;
148
- loaderData: unknown;
149
- currentAction?: ActionState;
150
- latestAction?: ActionState;
151
217
  actions: Record<string, Action>;
152
218
  loaders: Record<string, Loader>;
153
219
  pending?: PendingState;
@@ -158,20 +224,21 @@ interface PendingState {
158
224
  location: Location;
159
225
  matches: RouteMatch[];
160
226
  }
161
- declare type Listener = (router: Router<any, any>) => void;
162
- declare type ListenerFn = () => void;
227
+ type Listener = (router: Router<any, any, any>) => void;
228
+ type ListenerFn = () => void;
163
229
  interface BuildNextOptions {
164
230
  to?: string | number | null;
165
231
  params?: true | Updater<Record<string, any>>;
166
232
  search?: true | Updater<unknown>;
167
233
  hash?: true | Updater<string>;
234
+ state?: LocationState;
168
235
  key?: string;
169
236
  from?: string;
170
237
  fromCurrent?: boolean;
171
238
  __preSearchFilters?: SearchFilter<any>[];
172
239
  __postSearchFilters?: SearchFilter<any>[];
173
240
  }
174
- declare type MatchCacheEntry = {
241
+ type MatchCacheEntry = {
175
242
  gc: number;
176
243
  match: RouteMatch;
177
244
  };
@@ -186,33 +253,45 @@ interface MatchRouteOptions {
186
253
  pending: boolean;
187
254
  caseSensitive?: boolean;
188
255
  }
189
- interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>> {
256
+ interface DehydratedRouterState extends Pick<RouterState, 'status' | 'location' | 'lastUpdated' | 'location'> {
257
+ matches: DehydratedRouteMatch[];
258
+ }
259
+ interface DehydratedRouter<TRouterContext = unknown> {
260
+ location: Router['location'];
261
+ state: DehydratedRouterState;
262
+ context: TRouterContext;
263
+ }
264
+ interface DehydratedRouteMatch extends Pick<RouteMatch<any, any>, 'matchId' | 'status' | 'routeLoaderData' | 'loaderData' | 'isInvalid' | 'invalidAt'> {
265
+ }
266
+ interface RouterContext {
267
+ }
268
+ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown> {
269
+ types: {
270
+ RouteConfig: TRouteConfig;
271
+ AllRouteInfo: TAllRouteInfo;
272
+ };
190
273
  history: BrowserHistory | MemoryHistory | HashHistory;
191
- options: PickAsRequired<RouterOptions<TRouteConfig>, 'stringifySearch' | 'parseSearch'>;
274
+ options: PickAsRequired<RouterOptions<TRouteConfig, TRouterContext>, 'stringifySearch' | 'parseSearch' | 'context'>;
192
275
  basepath: string;
193
- allRouteInfo: TAllRouteInfo;
194
276
  listeners: Listener[];
195
- location: Location;
277
+ location: Location<TAllRouteInfo['fullSearchSchema']>;
196
278
  navigateTimeout?: Timeout;
197
279
  nextAction?: 'push' | 'replace';
198
- state: RouterState;
280
+ state: RouterState<TAllRouteInfo['fullSearchSchema']>;
199
281
  routeTree: Route<TAllRouteInfo, RouteInfo>;
200
282
  routesById: RoutesById<TAllRouteInfo>;
201
- navigationPromise: Promise<void>;
202
- removeActionQueue: {
203
- action: Action;
204
- actionState: ActionState;
205
- }[];
283
+ navigationPromise?: Promise<void>;
206
284
  startedLoadingAt: number;
207
285
  resolveNavigation: () => void;
208
286
  subscribe: (listener: Listener) => () => void;
287
+ reset: () => void;
209
288
  notify: () => void;
210
289
  mount: () => () => void;
211
290
  onFocus: () => void;
212
- update: <TRouteConfig extends RouteConfig = RouteConfig>(opts?: RouterOptions<TRouteConfig>) => Router<TRouteConfig>;
291
+ update: <TRouteConfig extends RouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown>(opts?: RouterOptions<TRouteConfig, TRouterContext>) => Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
213
292
  buildNext: (opts: BuildNextOptions) => Location;
214
293
  cancelMatches: () => void;
215
- loadLocation: (next?: Location) => Promise<void>;
294
+ load: (next?: Location) => Promise<void>;
216
295
  matchCache: Record<string, MatchCacheEntry>;
217
296
  cleanMatchCache: () => void;
218
297
  getRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(id: TId) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
@@ -225,8 +304,6 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
225
304
  strictParseParams?: boolean;
226
305
  }) => RouteMatch[];
227
306
  loadMatches: (resolvedMatches: RouteMatch[], loaderOpts?: {
228
- withPending?: boolean;
229
- } & ({
230
307
  preload: true;
231
308
  maxAge: number;
232
309
  gcMaxAge: number;
@@ -234,13 +311,16 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
234
311
  preload?: false;
235
312
  maxAge?: never;
236
313
  gcMaxAge?: never;
237
- })) => Promise<void>;
314
+ }) => Promise<void>;
315
+ loadMatchData: (routeMatch: RouteMatch<any, any>) => Promise<Record<string, unknown>>;
238
316
  invalidateRoute: (opts: MatchLocation) => void;
239
317
  reload: () => Promise<void>;
240
318
  resolvePath: (from: string, path: string) => string;
241
319
  navigate: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo>) => Promise<void>;
242
320
  matchRoute: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(matchLocation: ToOptions<TAllRouteInfo, TFrom, TTo>, opts?: MatchRouteOptions) => boolean;
243
321
  buildLink: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: LinkOptions<TAllRouteInfo, TFrom, TTo>) => LinkInfo;
322
+ dehydrate: () => DehydratedRouter<TRouterContext>;
323
+ hydrate: (dehydratedRouter: DehydratedRouter<TRouterContext>) => void;
244
324
  __: {
245
325
  buildRouteTree: (routeConfig: RouteConfig) => Route<TAllRouteInfo, AnyRouteInfo>;
246
326
  parseLocation: (location: History['location'], previousLocation?: Location) => Location;
@@ -251,77 +331,12 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
251
331
  }) => Promise<void>;
252
332
  };
253
333
  }
254
- declare function createRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>>(userOptions?: RouterOptions<TRouteConfig>): Router<TRouteConfig, TAllRouteInfo>;
255
-
256
- interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> extends Route<TAllRouteInfo, TRouteInfo> {
257
- matchId: string;
258
- pathname: string;
259
- params: TRouteInfo['params'];
260
- parentMatch?: RouteMatch;
261
- childMatches: RouteMatch[];
262
- routeSearch: TRouteInfo['searchSchema'];
263
- search: TRouteInfo['fullSearchSchema'];
264
- status: 'idle' | 'loading' | 'success' | 'error';
265
- updatedAt?: number;
266
- error?: unknown;
267
- isInvalid: boolean;
268
- getIsInvalid: () => boolean;
269
- loaderData: TRouteInfo['loaderData'];
270
- routeLoaderData: TRouteInfo['routeLoaderData'];
271
- isFetching: boolean;
272
- isPending: boolean;
273
- invalidAt: number;
274
- __: {
275
- element?: GetFrameworkGeneric<'Element'>;
276
- errorElement?: GetFrameworkGeneric<'Element'>;
277
- catchElement?: GetFrameworkGeneric<'Element'>;
278
- pendingElement?: GetFrameworkGeneric<'Element'>;
279
- loadPromise?: Promise<void>;
280
- loaderPromise?: Promise<void>;
281
- elementsPromise?: Promise<void>;
282
- dataPromise?: Promise<void>;
283
- pendingTimeout?: Timeout;
284
- pendingMinTimeout?: Timeout;
285
- pendingMinPromise?: Promise<void>;
286
- onExit?: void | ((matchContext: {
287
- params: TRouteInfo['allParams'];
288
- search: TRouteInfo['fullSearchSchema'];
289
- }) => void);
290
- abortController: AbortController;
291
- latestId: string;
292
- validate: () => void;
293
- startPending: () => void;
294
- cancelPending: () => void;
295
- notify: () => void;
296
- resolve: () => void;
297
- };
298
- cancel: () => void;
299
- load: (loaderOpts?: {
300
- withPending?: boolean;
301
- } & ({
302
- preload: true;
303
- maxAge: number;
304
- gcMaxAge: number;
305
- } | {
306
- preload?: false;
307
- maxAge?: never;
308
- gcMaxAge?: never;
309
- })) => Promise<TRouteInfo['routeLoaderData']>;
310
- fetch: (opts?: {
311
- maxAge?: number;
312
- }) => Promise<TRouteInfo['routeLoaderData']>;
313
- invalidate: () => void;
314
- hasLoaders: () => boolean;
315
- }
316
- declare function createRouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo>(router: Router<any, any>, route: Route<TAllRouteInfo, TRouteInfo>, opts: {
317
- matchId: string;
318
- params: TRouteInfo['allParams'];
319
- pathname: string;
320
- }): RouteMatch<TAllRouteInfo, TRouteInfo>;
334
+ declare function createRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown>(userOptions?: RouterOptions<TRouteConfig, TRouterContext>): Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
321
335
 
322
- interface AnyRoute extends Route<any, any> {
336
+ interface AnyRoute extends Route<any, any, any> {
323
337
  }
324
- interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> {
338
+ interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo, TRouterContext = unknown> {
339
+ routeInfo: TRouteInfo;
325
340
  routeId: TRouteInfo['id'];
326
341
  routeRouteId: TRouteInfo['routeId'];
327
342
  routePath: TRouteInfo['path'];
@@ -329,15 +344,14 @@ interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRo
329
344
  parentRoute?: AnyRoute;
330
345
  childRoutes?: AnyRoute[];
331
346
  options: RouteOptions;
332
- router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>;
347
+ router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>;
333
348
  buildLink: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>) => LinkInfo;
334
349
  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'];
335
- navigate: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['id'], TTo>, 'from'>) => Promise<void>;
350
+ navigate: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>) => Promise<void>;
336
351
  action: unknown extends TRouteInfo['actionResponse'] ? Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']> | undefined : Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>;
337
352
  loader: unknown extends TRouteInfo['routeLoaderData'] ? Action<LoaderContext<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams']>, TRouteInfo['routeLoaderData']> | undefined : Loader<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams'], TRouteInfo['routeLoaderData']>;
338
353
  }
339
- 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>;
340
- declare function cascadeLoaderData(matches: RouteMatch<any, any>[]): void;
354
+ declare function createRoute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo, TRouterContext = unknown>(routeConfig: RouteConfig, options: TRouteInfo['options'], parent: undefined | Route<TAllRouteInfo, any>, router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>): Route<TAllRouteInfo, TRouteInfo, TRouterContext>;
341
355
 
342
356
  interface AnyAllRouteInfo {
343
357
  routeConfig: AnyRouteConfig;
@@ -346,6 +360,7 @@ interface AnyAllRouteInfo {
346
360
  routeInfoByFullPath: Record<string, AnyRouteInfo>;
347
361
  routeIds: any;
348
362
  routePaths: any;
363
+ fullSearchSchema: Record<string, any>;
349
364
  }
350
365
  interface DefaultAllRouteInfo {
351
366
  routeConfig: RouteConfig;
@@ -354,20 +369,25 @@ interface DefaultAllRouteInfo {
354
369
  routeInfoByFullPath: Record<string, RouteInfo>;
355
370
  routeIds: string;
356
371
  routePaths: string;
372
+ fullSearchSchema: AnySearchSchema;
357
373
  }
358
374
  interface AllRouteInfo<TRouteConfig extends AnyRouteConfig = RouteConfig> extends RoutesInfoInner<TRouteConfig, ParseRouteConfig<TRouteConfig>> {
359
375
  }
360
- declare type ParseRouteConfig<TRouteConfig = AnyRouteConfig> = TRouteConfig extends AnyRouteConfig ? RouteConfigRoute<TRouteConfig> | ParseRouteChildren<TRouteConfig> : never;
361
- declare type ParseRouteChildren<TRouteConfig> = TRouteConfig extends AnyRouteConfigWithChildren<infer TChildren> ? unknown extends TChildren ? never : TChildren extends AnyRouteConfig[] ? Values<{
376
+ type ParseRouteConfig<TRouteConfig = AnyRouteConfig> = TRouteConfig extends AnyRouteConfig ? RouteConfigRoute<TRouteConfig> | ParseRouteChildren<TRouteConfig> : never;
377
+ type ParseRouteChildren<TRouteConfig> = TRouteConfig extends AnyRouteConfigWithChildren<infer TChildren> ? unknown extends TChildren ? never : TChildren extends AnyRouteConfig[] ? Values<{
362
378
  [TId in TChildren[number]['id']]: ParseRouteChild<TChildren[number], TId>;
363
379
  }> : never : never;
364
- declare type ParseRouteChild<TRouteConfig, TId> = TRouteConfig & {
380
+ type ParseRouteChild<TRouteConfig, TId> = TRouteConfig & {
365
381
  id: TId;
366
382
  } extends AnyRouteConfig ? ParseRouteConfig<TRouteConfig> : never;
367
- declare type RouteConfigRoute<TRouteConfig> = TRouteConfig extends RouteConfig<infer TId, infer TRouteId, infer TPath, infer TFullPath, 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, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams> : never;
368
- interface RoutesInfoInner<TRouteConfig extends AnyRouteConfig, TRouteInfo extends RouteInfo<string, string, any, any, any, any, any, any, any, any, any, any, any, any> = RouteInfo, TRouteInfoById = {
383
+ type RouteConfigRoute<TRouteConfig> = TRouteConfig extends RouteConfig<infer TId, infer TRouteId, infer TPath, infer TFullPath, infer TParentRouteLoaderData, infer TRouteLoaderData, infer TParentLoaderData, 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, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams> : never;
384
+ interface RoutesInfoInner<TRouteConfig extends AnyRouteConfig, TRouteInfo extends RouteInfo<string, string, any, any, any, any, any, any, any, any, any, any, any, any, any, any> = RouteInfo, TRouteInfoById = {
385
+ '/': TRouteInfo;
386
+ } & {
369
387
  [TInfo in TRouteInfo as TInfo['id']]: TInfo;
370
388
  }, TRouteInfoByFullPath = {
389
+ '/': TRouteInfo;
390
+ } & {
371
391
  [TInfo in TRouteInfo as TInfo['fullPath'] extends RootRouteId ? never : string extends TInfo['fullPath'] ? never : TInfo['fullPath']]: TInfo;
372
392
  }> {
373
393
  routeConfig: TRouteConfig;
@@ -376,15 +396,18 @@ interface RoutesInfoInner<TRouteConfig extends AnyRouteConfig, TRouteInfo extend
376
396
  routeInfoByFullPath: TRouteInfoByFullPath;
377
397
  routeIds: keyof TRouteInfoById;
378
398
  routePaths: keyof TRouteInfoByFullPath;
399
+ fullSearchSchema: Partial<UnionToIntersection<TRouteInfo['fullSearchSchema']>>;
379
400
  }
380
- interface AnyRouteInfo extends RouteInfo<any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
401
+ interface AnyRouteInfo extends RouteInfo<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
381
402
  }
382
- interface RouteInfo<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = string, 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 = {}> {
403
+ interface RouteInfo<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = {}, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends AnyPathParams = {}, TAllParams extends AnyPathParams = {}> {
383
404
  id: TId;
384
405
  routeId: TRouteId;
385
406
  path: TPath;
386
407
  fullPath: TFullPath;
408
+ parentRouteLoaderData: TParentRouteLoaderData;
387
409
  routeLoaderData: TRouteLoaderData;
410
+ parentLoaderData: TParentLoaderData;
388
411
  loaderData: TLoaderData;
389
412
  actionPayload: TActionPayload;
390
413
  actionResponse: TActionResponse;
@@ -393,42 +416,42 @@ interface RouteInfo<TId extends string = string, TRouteId extends string = strin
393
416
  parentParams: TParentParams;
394
417
  params: TParams;
395
418
  allParams: TAllParams;
396
- options: RouteOptions<TRouteId, TPath, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
419
+ options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
397
420
  }
398
- declare type RoutesById<TAllRouteInfo extends AnyAllRouteInfo> = {
421
+ type RoutesById<TAllRouteInfo extends AnyAllRouteInfo> = {
399
422
  [K in keyof TAllRouteInfo['routeInfoById']]: Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][K]>;
400
423
  };
401
- declare type RouteInfoById<TAllRouteInfo extends AnyAllRouteInfo, TId> = TId extends keyof TAllRouteInfo['routeInfoById'] ? IsAny<TAllRouteInfo['routeInfoById'][TId]['id'], RouteInfo, TAllRouteInfo['routeInfoById'][TId]> : never;
402
- declare type RouteInfoByPath<TAllRouteInfo extends AnyAllRouteInfo, TPath> = TPath extends keyof TAllRouteInfo['routeInfoByFullPath'] ? IsAny<TAllRouteInfo['routeInfoByFullPath'][TPath]['id'], RouteInfo, TAllRouteInfo['routeInfoByFullPath'][TPath]> : never;
424
+ type RouteInfoById<TAllRouteInfo extends AnyAllRouteInfo, TId> = TId extends keyof TAllRouteInfo['routeInfoById'] ? IsAny<TAllRouteInfo['routeInfoById'][TId]['id'], RouteInfo, TAllRouteInfo['routeInfoById'][TId]> : never;
425
+ type RouteInfoByPath<TAllRouteInfo extends AnyAllRouteInfo, TPath> = TPath extends keyof TAllRouteInfo['routeInfoByFullPath'] ? IsAny<TAllRouteInfo['routeInfoByFullPath'][TPath]['id'], RouteInfo, TAllRouteInfo['routeInfoByFullPath'][TPath]> : never;
403
426
 
404
427
  declare const rootRouteId: "__root__";
405
- declare type RootRouteId = typeof rootRouteId;
406
- declare type AnyLoaderData = {};
407
- declare type AnyPathParams = {};
408
- declare type AnySearchSchema = {};
428
+ type RootRouteId = typeof rootRouteId;
429
+ type AnyLoaderData = {};
430
+ type AnyPathParams = {};
431
+ type AnySearchSchema = {};
409
432
  interface RouteMeta {
410
433
  }
411
- declare type SearchSchemaValidator<TReturn, TParentSchema> = SearchSchemaValidatorObj<TReturn, TParentSchema> | SearchSchemaValidatorFn<TReturn, TParentSchema>;
412
- declare type SearchSchemaValidatorObj<TReturn, TParentSchema> = {
434
+ type SearchSchemaValidator<TReturn, TParentSchema> = SearchSchemaValidatorObj<TReturn, TParentSchema> | SearchSchemaValidatorFn<TReturn, TParentSchema>;
435
+ type SearchSchemaValidatorObj<TReturn, TParentSchema> = {
413
436
  parse?: SearchSchemaValidatorFn<TReturn, TParentSchema>;
414
437
  };
415
- declare type SearchSchemaValidatorFn<TReturn, TParentSchema> = (searchObj: Record<string, unknown>) => {} extends TParentSchema ? TReturn : keyof TReturn extends keyof TParentSchema ? {
438
+ type SearchSchemaValidatorFn<TReturn, TParentSchema> = (searchObj: Record<string, unknown>) => {} extends TParentSchema ? TReturn : keyof TReturn extends keyof TParentSchema ? {
416
439
  error: 'Top level search params cannot be redefined by child routes!';
417
440
  keys: keyof TReturn & keyof TParentSchema;
418
441
  } : TReturn;
419
- declare type DefinedPathParamWarning = 'Path params cannot be redefined by child routes!';
420
- declare type ParentParams<TParentParams> = AnyPathParams extends TParentParams ? {} : {
442
+ type DefinedPathParamWarning = 'Path params cannot be redefined by child routes!';
443
+ type ParentParams<TParentParams> = AnyPathParams extends TParentParams ? {} : {
421
444
  [Key in keyof TParentParams]?: DefinedPathParamWarning;
422
445
  };
423
- declare type LoaderFn<TRouteLoaderData extends AnyLoaderData, TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> = (loaderContext: LoaderContext<TFullSearchSchema, TAllParams>) => Promise<TRouteLoaderData>;
446
+ type LoaderFn<TRouteLoaderData extends AnyLoaderData = {}, TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> = (loaderContext: LoaderContext<TFullSearchSchema, TAllParams>) => TRouteLoaderData | Promise<TRouteLoaderData>;
424
447
  interface LoaderContext<TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> {
425
448
  params: TAllParams;
426
449
  search: TFullSearchSchema;
427
450
  signal?: AbortSignal;
428
451
  }
429
- declare type ActionFn<TActionPayload = unknown, TActionResponse = unknown> = (submission: TActionPayload) => TActionResponse | Promise<TActionResponse>;
430
- declare type UnloaderFn<TPath extends string> = (routeMatch: RouteMatch<any, RouteInfo<string, TPath>>) => void;
431
- declare type RouteOptions<TRouteId extends string = string, TPath extends string = string, 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 = {}> = ({
452
+ type ActionFn<TActionPayload = unknown, TActionResponse = unknown> = (submission: TActionPayload) => TActionResponse | Promise<TActionResponse>;
453
+ type UnloaderFn<TPath extends string> = (routeMatch: RouteMatch<any, RouteInfo<string, TPath>>) => void;
454
+ type RouteOptions<TRouteId extends string = string, TPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData 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 = {}> = ({
432
455
  path: TPath;
433
456
  } | {
434
457
  id: TRouteId;
@@ -437,18 +460,18 @@ declare type RouteOptions<TRouteId extends string = string, TPath extends string
437
460
  validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>;
438
461
  preSearchFilters?: SearchFilter<TFullSearchSchema>[];
439
462
  postSearchFilters?: SearchFilter<TFullSearchSchema>[];
440
- pendingMs?: number;
441
- pendingMinMs?: number;
442
- element?: GetFrameworkGeneric<'SyncOrAsyncElement'>;
443
- errorElement?: GetFrameworkGeneric<'SyncOrAsyncElement'>;
444
- catchElement?: GetFrameworkGeneric<'SyncOrAsyncElement'>;
445
- pendingElement?: GetFrameworkGeneric<'SyncOrAsyncElement'>;
463
+ component?: GetFrameworkGeneric<'Component'>;
464
+ errorComponent?: GetFrameworkGeneric<'ErrorComponent'>;
465
+ pendingComponent?: GetFrameworkGeneric<'Component'>;
446
466
  loader?: LoaderFn<TRouteLoaderData, TFullSearchSchema, TAllParams>;
447
467
  loaderMaxAge?: number;
448
468
  loaderGcMaxAge?: number;
449
469
  action?: ActionFn<TActionPayload, TActionResponse>;
450
- useErrorBoundary?: boolean;
451
- onMatch?: (matchContext: {
470
+ beforeLoad?: (opts: {
471
+ router: Router<any, any, unknown>;
472
+ match: RouteMatch;
473
+ }) => Promise<void> | void;
474
+ onLoaded?: (matchContext: {
452
475
  params: TAllParams;
453
476
  search: TFullSearchSchema;
454
477
  }) => void | undefined | ((match: {
@@ -467,39 +490,37 @@ declare type RouteOptions<TRouteId extends string = string, TPath extends string
467
490
  parseParams: (rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>) => TParams;
468
491
  stringifyParams: (params: TParams) => Record<ParsePathParams<TPath>, string>;
469
492
  }) & (PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never ? {} : 'Cannot redefined path params in child routes!');
470
- declare type SearchFilter<T, U = T> = (prev: T) => U;
471
- interface RouteConfig<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = string, 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> {
493
+ type SearchFilter<T, U = T> = (prev: T) => U;
494
+ 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, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = AnyLoaderData, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends AnyPathParams = {}, TAllParams extends AnyPathParams = {}, TKnownChildren = unknown> {
472
495
  id: TId;
473
496
  routeId: TRouteId;
474
497
  path: NoInfer<TPath>;
475
498
  fullPath: TFullPath;
476
- options: RouteOptions<TRouteId, TPath, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
499
+ options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
477
500
  children?: TKnownChildren;
478
501
  addChildren: IsAny<TId, any, <TNewChildren extends any>(children: TNewChildren extends AnyRouteConfig[] ? TNewChildren : {
479
502
  error: 'Invalid route detected';
480
503
  route: TNewChildren;
481
- }) => RouteConfig<TId, TRouteId, TPath, TFullPath, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
482
- createChildren: IsAny<TId, any, <TNewChildren extends any>(cb: (createChildRoute: CreateRouteConfigFn<false, TId, TFullPath, TLoaderData, TFullSearchSchema, TAllParams>) => TNewChildren extends AnyRouteConfig[] ? TNewChildren : {
483
- error: 'Invalid route detected';
484
- route: TNewChildren;
485
- }) => RouteConfig<TId, TRouteId, TPath, TFullPath, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
486
- createRoute: CreateRouteConfigFn<false, TId, TFullPath, TLoaderData, TFullSearchSchema, TAllParams>;
504
+ }) => RouteConfig<TId, TRouteId, TPath, TFullPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
505
+ createRoute: CreateRouteConfigFn<false, TId, TFullPath, TRouteLoaderData, TLoaderData, TFullSearchSchema, TAllParams>;
506
+ generate: GenerateFn<TRouteId, TPath, TParentRouteLoaderData, TParentLoaderData, TParentSearchSchema, TParentParams>;
487
507
  }
488
- declare type CreateRouteConfigFn<TIsRoot extends boolean = false, TParentId extends string = string, TParentPath extends string = string, TParentAllLoaderData 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, TRouteLoaderData, Expand<TParentAllLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'> & {
508
+ type GenerateFn<TRouteId extends string = string, TPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData, TParentLoaderData extends AnyLoaderData = {}, TParentSearchSchema extends {} = {}, TParentParams extends AnyPathParams = {}> = <TRouteLoaderData extends AnyLoaderData = AnyLoaderData, TActionPayload = unknown, TActionResponse = unknown, TSearchSchema extends 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>>(options: Omit<RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'>) => void;
509
+ 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, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'> & {
489
510
  path?: never;
490
- } : RouteOptions<TRouteId, TPath, TRouteLoaderData, Expand<TParentAllLoaderData & 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>>, TRouteLoaderData, Expand<TParentAllLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>, TKnownChildren>;
491
- declare type RoutePath<T extends string> = T extends RootRouteId ? '/' : TrimPathRight<`${T}`>;
492
- 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;
493
- interface AnyRouteConfig extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
511
+ } : RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, Expand<TParentLoaderData & 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, TParentLoaderData, Expand<TParentLoaderData & NoInfer<TRouteLoaderData>>, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>, TKnownChildren>;
512
+ type RoutePath<T extends string> = T extends RootRouteId ? '/' : TrimPathRight<`${T}`>;
513
+ type RoutePrefix<TPrefix extends string, TId extends string> = string extends TId ? RootRouteId : TId extends string ? `${TPrefix}/${TId}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TId>}`>}` : never;
514
+ interface AnyRouteConfig extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
494
515
  }
495
- interface AnyRouteConfigWithChildren<TChildren> extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, TChildren> {
516
+ interface AnyRouteConfigWithChildren<TChildren> extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, TChildren> {
496
517
  }
497
- declare type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
498
- declare type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
499
- declare type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
518
+ type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
519
+ type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
520
+ type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
500
521
  declare const createRouteConfig: CreateRouteConfigFn<true>;
501
522
 
502
- declare type LinkInfo = {
523
+ type LinkInfo = {
503
524
  type: 'external';
504
525
  href: string;
505
526
  } | {
@@ -512,12 +533,12 @@ declare type LinkInfo = {
512
533
  isActive: boolean;
513
534
  disabled?: boolean;
514
535
  };
515
- declare type StartsWith<A, B> = A extends `${B extends string ? B : never}${infer _}` ? true : false;
516
- 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;
517
- 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;
518
- declare type ParsePathParams<T extends string> = Split<T>[number] extends infer U ? U extends `:${infer V}` ? V : never : never;
519
- 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;
520
- declare type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends string, TTo extends string, SplitPaths extends string[] = Split<AllPaths, false>> = TTo extends `..${infer _}` ? SplitPaths extends [
536
+ type StartsWith<A, B> = A extends `${B extends string ? B : never}${infer _}` ? true : false;
537
+ 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;
538
+ 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;
539
+ type ParsePathParams<T extends string> = Split<T>[number] extends infer U ? U extends `$${infer V}` ? V : never : never;
540
+ 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;
541
+ type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends string, TTo extends string, SplitPaths extends string[] = Split<AllPaths, false>> = TTo extends `..${infer _}` ? SplitPaths extends [
521
542
  ...Split<ResolveRelativePath<TFrom, TTo>, false>,
522
543
  ...infer TToRest
523
544
  ] ? `${CleanPath<Join<[
@@ -528,39 +549,40 @@ declare type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends s
528
549
  ...Split<RestTTo, false>,
529
550
  ...infer RestPath
530
551
  ] ? `${TTo}${Join<RestPath>}` : never : './' | '../' | AllPaths;
531
- declare type NavigateOptionsAbsolute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = ToOptions<TAllRouteInfo, TFrom, TTo> & {
552
+ type NavigateOptionsAbsolute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = ToOptions<TAllRouteInfo, TFrom, TTo> & {
532
553
  replace?: boolean;
533
554
  };
534
- declare type ToOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
555
+ type ToOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
535
556
  to?: ToPathOption<TAllRouteInfo, TFrom, TTo>;
536
557
  hash?: Updater<string>;
558
+ state?: LocationState;
537
559
  from?: TFrom;
538
560
  } & CheckPath<TAllRouteInfo, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TAllRouteInfo, TFrom, TResolvedTo> & PathParamOptions<TAllRouteInfo, TFrom, TResolvedTo>;
539
- declare type SearchParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromSchema = RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema'], TToSchema = RouteInfoByPath<TAllRouteInfo, TTo>['fullSearchSchema']> = StartsWith<TFrom, TTo> extends true ? {
561
+ type SearchParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromSchema = RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema'], TToSchema = RouteInfoByPath<TAllRouteInfo, TTo>['fullSearchSchema']> = StartsWith<TFrom, TTo> extends true ? {
540
562
  search?: SearchReducer<TFromSchema, TToSchema>;
541
563
  } : keyof PickRequired<TToSchema> extends never ? {
542
564
  search?: SearchReducer<TFromSchema, TToSchema>;
543
565
  } : {
544
566
  search: SearchReducer<TFromSchema, TToSchema>;
545
567
  };
546
- declare type SearchReducer<TFrom, TTo> = {
568
+ type SearchReducer<TFrom, TTo> = {
547
569
  [TKey in keyof TTo]: TTo[TKey];
548
570
  } | ((current: TFrom) => TTo);
549
- declare type PathParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromParams = RouteInfoByPath<TAllRouteInfo, TFrom>['allParams'], TToParams = RouteInfoByPath<TAllRouteInfo, TTo>['allParams']> = StartsWith<TFrom, TTo> extends true ? {
571
+ type PathParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromParams = RouteInfoByPath<TAllRouteInfo, TFrom>['allParams'], TToParams = RouteInfoByPath<TAllRouteInfo, TTo>['allParams']> = StartsWith<TFrom, TTo> extends true ? {
550
572
  params?: ParamsReducer<TFromParams, TToParams>;
551
573
  } : AnyPathParams extends TToParams ? {
552
574
  params?: ParamsReducer<TFromParams, Record<string, never>>;
553
575
  } : {
554
576
  params: ParamsReducer<TFromParams, TToParams>;
555
577
  };
556
- declare type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
557
- 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>;
558
- 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>;
578
+ type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
579
+ 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>;
580
+ 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>;
559
581
  interface ActiveOptions {
560
582
  exact?: boolean;
561
583
  includeHash?: boolean;
562
584
  }
563
- declare type LinkOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo> & {
585
+ type LinkOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo> & {
564
586
  target?: HTMLAnchorElement['target'];
565
587
  activeOptions?: ActiveOptions;
566
588
  preload?: false | 'intent';
@@ -569,22 +591,22 @@ declare type LinkOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRoute
569
591
  preloadDelay?: number;
570
592
  disabled?: boolean;
571
593
  };
572
- declare type CheckRelativePath<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo> = TTo extends string ? TFrom extends string ? ResolveRelativePath<TFrom, TTo> extends TAllRouteInfo['routePaths'] ? {} : {
594
+ type CheckRelativePath<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo> = TTo extends string ? TFrom extends string ? ResolveRelativePath<TFrom, TTo> extends TAllRouteInfo['routePaths'] ? {} : {
573
595
  Error: `${TFrom} + ${TTo} resolves to ${ResolveRelativePath<TFrom, TTo>}, which is not a valid route path.`;
574
596
  'Valid Route Paths': TAllRouteInfo['routePaths'];
575
597
  } : {} : {};
576
- declare type CheckPath<TAllRouteInfo extends AnyAllRouteInfo, TPath, TPass> = Exclude<TPath, TAllRouteInfo['routePaths']> extends never ? TPass : CheckPathError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routePaths']>>;
577
- declare type CheckPathError<TAllRouteInfo extends AnyAllRouteInfo, TInvalids> = Expand<{
598
+ type CheckPath<TAllRouteInfo extends AnyAllRouteInfo, TPath, TPass> = Exclude<TPath, TAllRouteInfo['routePaths']> extends never ? TPass : CheckPathError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routePaths']>>;
599
+ type CheckPathError<TAllRouteInfo extends AnyAllRouteInfo, TInvalids> = Expand<{
578
600
  Error: `${TInvalids extends string ? TInvalids : never} is not a valid route path.`;
579
601
  'Valid Route Paths': TAllRouteInfo['routePaths'];
580
602
  }>;
581
- declare type CheckId<TAllRouteInfo extends AnyAllRouteInfo, TPath, TPass> = Exclude<TPath, TAllRouteInfo['routeIds']> extends never ? TPass : CheckIdError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routeIds']>>;
582
- declare type CheckIdError<TAllRouteInfo extends AnyAllRouteInfo, TInvalids> = Expand<{
603
+ type CheckId<TAllRouteInfo extends AnyAllRouteInfo, TPath, TPass> = Exclude<TPath, TAllRouteInfo['routeIds']> extends never ? TPass : CheckIdError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routeIds']>>;
604
+ type CheckIdError<TAllRouteInfo extends AnyAllRouteInfo, TInvalids> = Expand<{
583
605
  Error: `${TInvalids extends string ? TInvalids : never} is not a valid route ID.`;
584
606
  'Valid Route IDs': TAllRouteInfo['routeIds'];
585
607
  }>;
586
- 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;
587
- declare type ValidFromPath<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo> = undefined | (string extends TAllRouteInfo['routePaths'] ? string : TAllRouteInfo['routePaths']);
608
+ 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;
609
+ type ValidFromPath<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo> = undefined | (string extends TAllRouteInfo['routePaths'] ? string : TAllRouteInfo['routePaths']);
588
610
 
589
611
  interface Segment {
590
612
  type: 'pathname' | 'param' | 'wildcard';
@@ -609,4 +631,4 @@ declare const defaultStringifySearch: (search: Record<string, any>) => string;
609
631
  declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => AnySearchSchema;
610
632
  declare function stringifySearchWith(stringify: (search: any) => string): (search: Record<string, any>) => string;
611
633
 
612
- 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, cascadeLoaderData, cleanPath, createRoute, createRouteConfig, createRouteMatch, createRouter, decode, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, warning };
634
+ export { Action, ActionFn, ActionState, AllRouteInfo, AnyAllRouteInfo, AnyLoaderData, AnyPathParams, AnyRoute, AnyRouteConfig, AnyRouteConfigWithChildren, AnyRouteInfo, AnySearchSchema, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, DeepAwaited, DefaultAllRouteInfo, DefinedPathParamWarning, DehydratedRouter, DehydratedRouterState, 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, RegisterRouter, RegisteredAllRouteInfo, RegisteredRouter, RelativeToPathAutoComplete, ResolveRelativePath, RootRouteId, Route, RouteConfig, RouteConfigRoute, RouteInfo, RouteInfoById, RouteInfoByPath, RouteMatch, RouteMeta, RouteOptions, Router, RouterContext, RouterOptions, RouterState, RoutesById, RoutesInfoInner, SearchFilter, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, Timeout, ToIdOption, ToOptions, ToPathOption, UnionToIntersection, 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 };