@tanstack/router-core 0.0.1-beta.15 → 0.0.1-beta.151

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