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

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