@tanstack/router-core 0.0.1-beta.14 → 0.0.1-beta.145

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