@tanstack/router-core 0.0.1-beta.4 → 0.0.1-beta.41

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