@tanstack/router-core 0.0.1-beta.19 → 0.0.1-beta.190

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 (82) hide show
  1. package/LICENSE +21 -0
  2. package/build/cjs/defer.js +39 -0
  3. package/build/cjs/defer.js.map +1 -0
  4. package/build/cjs/fileRoute.js +29 -0
  5. package/build/cjs/fileRoute.js.map +1 -0
  6. package/build/cjs/history.js +228 -0
  7. package/build/cjs/history.js.map +1 -0
  8. package/build/cjs/index.js +86 -0
  9. package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
  10. package/build/cjs/{packages/router-core/src/path.js → path.js} +45 -56
  11. package/build/cjs/path.js.map +1 -0
  12. package/build/cjs/{packages/router-core/src/qss.js → qss.js} +10 -16
  13. package/build/cjs/qss.js.map +1 -0
  14. package/build/cjs/route.js +114 -0
  15. package/build/cjs/route.js.map +1 -0
  16. package/build/cjs/router.js +1267 -0
  17. package/build/cjs/router.js.map +1 -0
  18. package/build/cjs/scroll-restoration.js +139 -0
  19. package/build/cjs/scroll-restoration.js.map +1 -0
  20. package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +32 -19
  21. package/build/cjs/searchParams.js.map +1 -0
  22. package/build/cjs/{packages/router-core/src/utils.js → utils.js} +69 -64
  23. package/build/cjs/utils.js.map +1 -0
  24. package/build/esm/index.js +1746 -2121
  25. package/build/esm/index.js.map +1 -1
  26. package/build/stats-html.html +59 -49
  27. package/build/stats-react.json +197 -211
  28. package/build/types/defer.d.ts +19 -0
  29. package/build/types/fileRoute.d.ts +35 -0
  30. package/build/types/history.d.ts +36 -0
  31. package/build/types/index.d.ts +13 -609
  32. package/build/types/link.d.ts +96 -0
  33. package/build/types/path.d.ts +16 -0
  34. package/build/types/qss.d.ts +2 -0
  35. package/build/types/route.d.ts +251 -0
  36. package/build/types/routeInfo.d.ts +22 -0
  37. package/build/types/router.d.ts +260 -0
  38. package/build/types/scroll-restoration.d.ts +6 -0
  39. package/build/types/searchParams.d.ts +5 -0
  40. package/build/types/utils.d.ts +44 -0
  41. package/build/umd/index.development.js +1978 -2243
  42. package/build/umd/index.development.js.map +1 -1
  43. package/build/umd/index.production.js +13 -2
  44. package/build/umd/index.production.js.map +1 -1
  45. package/package.json +11 -7
  46. package/src/defer.ts +55 -0
  47. package/src/fileRoute.ts +161 -0
  48. package/src/history.ts +300 -0
  49. package/src/index.ts +5 -10
  50. package/src/link.ts +136 -125
  51. package/src/path.ts +37 -17
  52. package/src/qss.ts +1 -2
  53. package/src/route.ts +948 -218
  54. package/src/routeInfo.ts +45 -211
  55. package/src/router.ts +1778 -1075
  56. package/src/scroll-restoration.ts +179 -0
  57. package/src/searchParams.ts +31 -9
  58. package/src/utils.ts +84 -49
  59. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
  60. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  61. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
  62. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
  63. package/build/cjs/node_modules/history/index.js +0 -815
  64. package/build/cjs/node_modules/history/index.js.map +0 -1
  65. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
  66. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
  67. package/build/cjs/packages/router-core/src/index.js +0 -58
  68. package/build/cjs/packages/router-core/src/path.js.map +0 -1
  69. package/build/cjs/packages/router-core/src/qss.js.map +0 -1
  70. package/build/cjs/packages/router-core/src/route.js +0 -147
  71. package/build/cjs/packages/router-core/src/route.js.map +0 -1
  72. package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
  73. package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
  74. package/build/cjs/packages/router-core/src/routeMatch.js +0 -220
  75. package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
  76. package/build/cjs/packages/router-core/src/router.js +0 -870
  77. package/build/cjs/packages/router-core/src/router.js.map +0 -1
  78. package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
  79. package/build/cjs/packages/router-core/src/utils.js.map +0 -1
  80. package/src/frameworks.ts +0 -11
  81. package/src/routeConfig.ts +0 -511
  82. package/src/routeMatch.ts +0 -312
@@ -1,610 +1,14 @@
1
- /**
2
- * router-core
3
- *
4
- * Copyright (c) TanStack
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- import { BrowserHistory, MemoryHistory, HashHistory, History } from 'history';
12
- export { createBrowserHistory, createHashHistory, createMemoryHistory } from 'history';
13
1
  export { default as invariant } from 'tiny-invariant';
14
-
15
- interface FrameworkGenerics {
16
- }
17
- 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'];
73
- pathname: string;
74
- }): RouteMatch<TAllRouteInfo, TRouteInfo>;
75
-
76
- type NoInfer<T> = [T][T extends any ? 0 : never];
77
- type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N;
78
- type IsAnyBoolean<T> = 1 extends 0 & T ? true : false;
79
- type IsKnown<T, Y, N> = unknown extends T ? N : Y;
80
- type PickAsRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
81
- type PickAsPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
82
- type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never;
83
- type PickExtra<T, K> = Expand<{
84
- [TKey in keyof K as string extends TKey ? never : TKey extends keyof T ? never : TKey]: K[TKey];
85
- }>;
86
- type PickRequired<T> = {
87
- [K in keyof T as undefined extends T[K] ? never : K]: T[K];
88
- };
89
- type Expand<T> = T extends object ? T extends infer O ? {
90
- [K in keyof O]: O[K];
91
- } : never : T;
92
- type Values<O> = O[ValueKeys<O>];
93
- type ValueKeys<O> = Extract<keyof O, PropertyKey>;
94
- type DeepAwaited<T> = T extends Promise<infer A> ? DeepAwaited<A> : T extends Record<infer A, Promise<infer B>> ? {
95
- [K in A]: DeepAwaited<B>;
96
- } : T;
97
- 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
- type Timeout = ReturnType<typeof setTimeout>;
99
- type Updater<TPrevious, TResult = TPrevious> = TResult | ((prev?: TPrevious) => TResult);
100
- type PickExtract<T, U> = {
101
- [K in keyof T as T[K] extends U ? K : never]: T[K];
102
- };
103
- type PickExclude<T, U> = {
104
- [K in keyof T as T[K] extends U ? never : K]: T[K];
105
- };
106
- /**
107
- * This function returns `a` if `b` is deeply equal.
108
- * 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.
110
- */
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>;
116
-
117
- interface LocationState {
118
- }
119
- interface Location<TSearchObj extends AnySearchSchema = {}, TState extends LocationState = LocationState> {
120
- href: string;
121
- pathname: string;
122
- search: TSearchObj;
123
- searchStr: string;
124
- state: TState;
125
- hash: string;
126
- key?: string;
127
- }
128
- interface FromLocation {
129
- pathname: string;
130
- search?: unknown;
131
- key?: string;
132
- hash?: string;
133
- }
134
- type SearchSerializer = (searchObj: Record<string, any>) => string;
135
- type SearchParser = (searchStr: string) => Record<string, any>;
136
- type FilterRoutesFn = <TRoute extends Route<any, RouteInfo>>(routeConfigs: TRoute[]) => TRoute[];
137
- interface RouterOptions<TRouteConfig extends AnyRouteConfig> {
138
- history?: BrowserHistory | MemoryHistory | HashHistory;
139
- stringifySearch?: SearchSerializer;
140
- parseSearch?: SearchParser;
141
- filterRoutes?: FilterRoutesFn;
142
- defaultPreload?: false | 'intent';
143
- defaultPreloadMaxAge?: number;
144
- defaultPreloadGcMaxAge?: number;
145
- defaultPreloadDelay?: number;
146
- defaultComponent?: GetFrameworkGeneric<'Component'>;
147
- defaultErrorComponent?: GetFrameworkGeneric<'Component'>;
148
- defaultPendingComponent?: GetFrameworkGeneric<'Component'>;
149
- defaultLoaderMaxAge?: number;
150
- defaultLoaderGcMaxAge?: number;
151
- caseSensitive?: boolean;
152
- routeConfig?: TRouteConfig;
153
- basepath?: string;
154
- useServerData?: boolean;
155
- createRouter?: (router: Router<any, any>) => void;
156
- createRoute?: (opts: {
157
- route: AnyRoute;
158
- router: Router<any, any>;
159
- }) => 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 extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> {
199
- loadedAt: number;
200
- loaderContext: LoaderContext<AnyLoaderData, 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;
210
- isFetching: boolean;
211
- isPreloading: boolean;
212
- }
213
- interface PendingState {
214
- location: Location;
215
- matches: RouteMatch[];
216
- }
217
- type Listener = (router: Router<any, any>) => void;
218
- type ListenerFn = () => void;
219
- interface BuildNextOptions {
220
- to?: string | number | null;
221
- params?: true | Updater<Record<string, any>>;
222
- search?: true | Updater<unknown>;
223
- hash?: true | Updater<string>;
224
- state?: LocationState;
225
- key?: string;
226
- from?: string;
227
- fromCurrent?: boolean;
228
- __preSearchFilters?: SearchFilter<any>[];
229
- __postSearchFilters?: SearchFilter<any>[];
230
- }
231
- type MatchCacheEntry = {
232
- gc: number;
233
- match: RouteMatch;
234
- };
235
- interface MatchLocation {
236
- to?: string | number | null;
237
- fuzzy?: boolean;
238
- caseSensitive?: boolean;
239
- from?: string;
240
- fromCurrent?: boolean;
241
- }
242
- interface MatchRouteOptions {
243
- pending: boolean;
244
- caseSensitive?: boolean;
245
- }
246
- interface DehydratedRouterState extends Pick<RouterState, 'status' | 'location' | 'lastUpdated'> {
247
- matches: DehydratedRouteMatch[];
248
- }
249
- interface DehydratedRouteMatch extends Pick<RouteMatch<any, any>, 'matchId' | 'status' | 'routeLoaderData' | 'loaderData' | 'isInvalid' | 'invalidAt'> {
250
- }
251
- interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>> {
252
- types: {
253
- RouteConfig: TRouteConfig;
254
- AllRouteInfo: TAllRouteInfo;
255
- };
256
- history: BrowserHistory | MemoryHistory | HashHistory;
257
- options: PickAsRequired<RouterOptions<TRouteConfig>, 'stringifySearch' | 'parseSearch'>;
258
- basepath: string;
259
- listeners: Listener[];
260
- location: Location;
261
- navigateTimeout?: Timeout;
262
- nextAction?: 'push' | 'replace';
263
- state: RouterState;
264
- routeTree: Route<TAllRouteInfo, RouteInfo>;
265
- routesById: RoutesById<TAllRouteInfo>;
266
- navigationPromise: Promise<void>;
267
- startedLoadingAt: number;
268
- resolveNavigation: () => void;
269
- subscribe: (listener: Listener) => () => void;
270
- reset: () => void;
271
- notify: () => void;
272
- mount: () => () => void;
273
- onFocus: () => void;
274
- update: <TRouteConfig extends RouteConfig = RouteConfig>(opts?: RouterOptions<TRouteConfig>) => Router<TRouteConfig>;
275
- buildNext: (opts: BuildNextOptions) => Location;
276
- cancelMatches: () => void;
277
- load: (next?: Location) => Promise<void>;
278
- matchCache: Record<string, MatchCacheEntry>;
279
- cleanMatchCache: () => void;
280
- getRoute: <TId extends keyof TAllRouteInfo['routeInfoById']>(id: TId) => Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]>;
281
- loadRoute: (navigateOpts: BuildNextOptions) => Promise<RouteMatch[]>;
282
- preloadRoute: (navigateOpts: BuildNextOptions, loaderOpts: {
283
- maxAge?: number;
284
- gcMaxAge?: number;
285
- }) => Promise<RouteMatch[]>;
286
- matchRoutes: (pathname: string, opts?: {
287
- strictParseParams?: boolean;
288
- }) => RouteMatch[];
289
- loadMatches: (resolvedMatches: RouteMatch[], loaderOpts?: {
290
- preload: true;
291
- maxAge: number;
292
- gcMaxAge: number;
293
- } | {
294
- preload?: false;
295
- maxAge?: never;
296
- gcMaxAge?: never;
297
- }) => Promise<void>;
298
- loadMatchData: (routeMatch: RouteMatch<any, any>) => Promise<Record<string, unknown>>;
299
- invalidateRoute: (opts: MatchLocation) => void;
300
- reload: () => Promise<void>;
301
- resolvePath: (from: string, path: string) => string;
302
- navigate: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo>) => Promise<void>;
303
- matchRoute: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(matchLocation: ToOptions<TAllRouteInfo, TFrom, TTo>, opts?: MatchRouteOptions) => boolean;
304
- buildLink: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: LinkOptions<TAllRouteInfo, TFrom, TTo>) => LinkInfo;
305
- dehydrateState: () => DehydratedRouterState;
306
- hydrateState: (state: DehydratedRouterState) => void;
307
- __: {
308
- buildRouteTree: (routeConfig: RouteConfig) => Route<TAllRouteInfo, AnyRouteInfo>;
309
- parseLocation: (location: History['location'], previousLocation?: Location) => Location;
310
- buildLocation: (dest: BuildNextOptions) => Location;
311
- commitLocation: (next: Location, replace?: boolean) => Promise<void>;
312
- navigate: (location: BuildNextOptions & {
313
- replace?: boolean;
314
- }) => Promise<void>;
315
- };
316
- }
317
- declare function createRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>>(userOptions?: RouterOptions<TRouteConfig>): Router<TRouteConfig, TAllRouteInfo>;
318
-
319
- interface AnyRoute extends Route<any, any> {
320
- }
321
- interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> {
322
- routeId: TRouteInfo['id'];
323
- routeRouteId: TRouteInfo['routeId'];
324
- routePath: TRouteInfo['path'];
325
- fullPath: TRouteInfo['fullPath'];
326
- parentRoute?: AnyRoute;
327
- childRoutes?: AnyRoute[];
328
- options: RouteOptions;
329
- router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>;
330
- buildLink: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>) => LinkInfo;
331
- 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'];
332
- navigate: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['id'], TTo>, 'from'>) => Promise<void>;
333
- action: unknown extends TRouteInfo['actionResponse'] ? Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']> | undefined : Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>;
334
- loader: unknown extends TRouteInfo['routeLoaderData'] ? Action<LoaderContext<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams']>, TRouteInfo['routeLoaderData']> | undefined : Loader<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams'], TRouteInfo['routeLoaderData']>;
335
- }
336
- 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>;
337
-
338
- interface AnyAllRouteInfo {
339
- routeConfig: AnyRouteConfig;
340
- routeInfo: AnyRouteInfo;
341
- routeInfoById: Record<string, AnyRouteInfo>;
342
- routeInfoByFullPath: Record<string, AnyRouteInfo>;
343
- routeIds: any;
344
- routePaths: any;
345
- }
346
- interface DefaultAllRouteInfo {
347
- routeConfig: RouteConfig;
348
- routeInfo: RouteInfo;
349
- routeInfoById: Record<string, RouteInfo>;
350
- routeInfoByFullPath: Record<string, RouteInfo>;
351
- routeIds: string;
352
- routePaths: string;
353
- }
354
- interface AllRouteInfo<TRouteConfig extends AnyRouteConfig = RouteConfig> extends RoutesInfoInner<TRouteConfig, ParseRouteConfig<TRouteConfig>> {
355
- }
356
- type ParseRouteConfig<TRouteConfig = AnyRouteConfig> = TRouteConfig extends AnyRouteConfig ? RouteConfigRoute<TRouteConfig> | ParseRouteChildren<TRouteConfig> : never;
357
- type ParseRouteChildren<TRouteConfig> = TRouteConfig extends AnyRouteConfigWithChildren<infer TChildren> ? unknown extends TChildren ? never : TChildren extends AnyRouteConfig[] ? Values<{
358
- [TId in TChildren[number]['id']]: ParseRouteChild<TChildren[number], TId>;
359
- }> : never : never;
360
- type ParseRouteChild<TRouteConfig, TId> = TRouteConfig & {
361
- id: TId;
362
- } extends AnyRouteConfig ? ParseRouteConfig<TRouteConfig> : never;
363
- 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;
364
- 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 = {
365
- '/': TRouteInfo;
366
- } & {
367
- [TInfo in TRouteInfo as TInfo['id']]: TInfo;
368
- }, TRouteInfoByFullPath = {
369
- '/': TRouteInfo;
370
- } & {
371
- [TInfo in TRouteInfo as TInfo['fullPath'] extends RootRouteId ? never : string extends TInfo['fullPath'] ? never : TInfo['fullPath']]: TInfo;
372
- }> {
373
- routeConfig: TRouteConfig;
374
- routeInfo: TRouteInfo;
375
- routeInfoById: TRouteInfoById;
376
- routeInfoByFullPath: TRouteInfoByFullPath;
377
- routeIds: keyof TRouteInfoById;
378
- routePaths: keyof TRouteInfoByFullPath;
379
- }
380
- interface AnyRouteInfo extends RouteInfo<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
381
- }
382
- 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 = {}> {
383
- id: TId;
384
- routeId: TRouteId;
385
- path: TPath;
386
- fullPath: TFullPath;
387
- parentRouteLoaderData: TParentRouteLoaderData;
388
- routeLoaderData: TRouteLoaderData;
389
- loaderData: TLoaderData;
390
- actionPayload: TActionPayload;
391
- actionResponse: TActionResponse;
392
- searchSchema: TSearchSchema;
393
- fullSearchSchema: TFullSearchSchema;
394
- parentParams: TParentParams;
395
- params: TParams;
396
- allParams: TAllParams;
397
- options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
398
- }
399
- type RoutesById<TAllRouteInfo extends AnyAllRouteInfo> = {
400
- [K in keyof TAllRouteInfo['routeInfoById']]: Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][K]>;
401
- };
402
- type RouteInfoById<TAllRouteInfo extends AnyAllRouteInfo, TId> = TId extends keyof TAllRouteInfo['routeInfoById'] ? IsAny<TAllRouteInfo['routeInfoById'][TId]['id'], RouteInfo, TAllRouteInfo['routeInfoById'][TId]> : never;
403
- type RouteInfoByPath<TAllRouteInfo extends AnyAllRouteInfo, TPath> = TPath extends keyof TAllRouteInfo['routeInfoByFullPath'] ? IsAny<TAllRouteInfo['routeInfoByFullPath'][TPath]['id'], RouteInfo, TAllRouteInfo['routeInfoByFullPath'][TPath]> : never;
404
-
405
- declare const rootRouteId: "__root__";
406
- type RootRouteId = typeof rootRouteId;
407
- type AnyLoaderData = {};
408
- type AnyPathParams = {};
409
- type AnySearchSchema = {};
410
- interface RouteMeta {
411
- }
412
- type SearchSchemaValidator<TReturn, TParentSchema> = SearchSchemaValidatorObj<TReturn, TParentSchema> | SearchSchemaValidatorFn<TReturn, TParentSchema>;
413
- type SearchSchemaValidatorObj<TReturn, TParentSchema> = {
414
- parse?: SearchSchemaValidatorFn<TReturn, TParentSchema>;
415
- };
416
- type SearchSchemaValidatorFn<TReturn, TParentSchema> = (searchObj: Record<string, unknown>) => {} extends TParentSchema ? TReturn : keyof TReturn extends keyof TParentSchema ? {
417
- error: 'Top level search params cannot be redefined by child routes!';
418
- keys: keyof TReturn & keyof TParentSchema;
419
- } : TReturn;
420
- type DefinedPathParamWarning = 'Path params cannot be redefined by child routes!';
421
- type ParentParams<TParentParams> = AnyPathParams extends TParentParams ? {} : {
422
- [Key in keyof TParentParams]?: DefinedPathParamWarning;
423
- };
424
- type LoaderFn<TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> = (loaderContext: LoaderContext<TParentRouteLoaderData, TFullSearchSchema, TAllParams>) => Promise<TRouteLoaderData>;
425
- interface LoaderContext<TParentRouteLoaderData extends AnyLoaderData = {}, TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> {
426
- params: TAllParams;
427
- search: TFullSearchSchema;
428
- signal?: AbortSignal;
429
- }
430
- type ActionFn<TActionPayload = unknown, TActionResponse = unknown> = (submission: TActionPayload) => TActionResponse | Promise<TActionResponse>;
431
- type UnloaderFn<TPath extends string> = (routeMatch: RouteMatch<any, RouteInfo<string, TPath>>) => void;
432
- 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 = {}> = ({
433
- path: TPath;
434
- } | {
435
- id: TRouteId;
436
- }) & {
437
- caseSensitive?: boolean;
438
- validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>;
439
- preSearchFilters?: SearchFilter<TFullSearchSchema>[];
440
- postSearchFilters?: SearchFilter<TFullSearchSchema>[];
441
- component?: GetFrameworkGeneric<'Component'>;
442
- errorComponent?: GetFrameworkGeneric<'Component'>;
443
- pendingComponent?: GetFrameworkGeneric<'Component'>;
444
- loader?: LoaderFn<TParentRouteLoaderData, TRouteLoaderData, TFullSearchSchema, TAllParams>;
445
- loaderMaxAge?: number;
446
- loaderGcMaxAge?: number;
447
- action?: ActionFn<TActionPayload, TActionResponse>;
448
- onMatch?: (matchContext: {
449
- params: TAllParams;
450
- search: TFullSearchSchema;
451
- }) => void | undefined | ((match: {
452
- params: TAllParams;
453
- search: TFullSearchSchema;
454
- }) => void);
455
- onTransition?: (match: {
456
- params: TAllParams;
457
- search: TFullSearchSchema;
458
- }) => void;
459
- meta?: RouteMeta;
460
- } & ({
461
- parseParams?: never;
462
- stringifyParams?: never;
463
- } | {
464
- parseParams: (rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>) => TParams;
465
- stringifyParams: (params: TParams) => Record<ParsePathParams<TPath>, string>;
466
- }) & (PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never ? {} : 'Cannot redefined path params in child routes!');
467
- type SearchFilter<T, U = T> = (prev: T) => U;
468
- 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> {
469
- id: TId;
470
- routeId: TRouteId;
471
- path: NoInfer<TPath>;
472
- fullPath: TFullPath;
473
- options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
474
- children?: TKnownChildren;
475
- addChildren: IsAny<TId, any, <TNewChildren extends any>(children: TNewChildren extends AnyRouteConfig[] ? TNewChildren : {
476
- error: 'Invalid route detected';
477
- route: TNewChildren;
478
- }) => RouteConfig<TId, TRouteId, TPath, TFullPath, TParentRouteLoaderData, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
479
- createChildren: IsAny<TId, any, <TNewChildren extends any>(cb: (createChildRoute: CreateRouteConfigFn<false, TId, TFullPath, TRouteLoaderData, TLoaderData, TFullSearchSchema, TAllParams>) => TNewChildren extends AnyRouteConfig[] ? TNewChildren : {
480
- error: 'Invalid route detected';
481
- route: TNewChildren;
482
- }) => RouteConfig<TId, TRouteId, TPath, TFullPath, TParentRouteLoaderData, TRouteLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
483
- createRoute: CreateRouteConfigFn<false, TId, TFullPath, TRouteLoaderData, TLoaderData, TFullSearchSchema, TAllParams>;
484
- }
485
- 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'> & {
486
- path?: never;
487
- } : 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>;
488
- type RoutePath<T extends string> = T extends RootRouteId ? '/' : TrimPathRight<`${T}`>;
489
- type RoutePrefix<TPrefix extends string, TId extends string> = string extends TId ? RootRouteId : TId extends string ? `${TPrefix}/${TId}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TId>}`>}` : never;
490
- interface AnyRouteConfig extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
491
- }
492
- interface AnyRouteConfigWithChildren<TChildren> extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, TChildren> {
493
- }
494
- type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
495
- type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
496
- type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
497
- declare const createRouteConfig: CreateRouteConfigFn<true>;
498
-
499
- type LinkInfo = {
500
- type: 'external';
501
- href: string;
502
- } | {
503
- type: 'internal';
504
- next: Location;
505
- handleFocus: (e: any) => void;
506
- handleClick: (e: any) => void;
507
- handleEnter: (e: any) => void;
508
- handleLeave: (e: any) => void;
509
- isActive: boolean;
510
- disabled?: boolean;
511
- };
512
- type StartsWith<A, B> = A extends `${B extends string ? B : never}${infer _}` ? true : false;
513
- 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;
514
- 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;
515
- type ParsePathParams<T extends string> = Split<T>[number] extends infer U ? U extends `:${infer V}` ? V : never : never;
516
- 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;
517
- type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends string, TTo extends string, SplitPaths extends string[] = Split<AllPaths, false>> = TTo extends `..${infer _}` ? SplitPaths extends [
518
- ...Split<ResolveRelativePath<TFrom, TTo>, false>,
519
- ...infer TToRest
520
- ] ? `${CleanPath<Join<[
521
- ...Split<TTo, false>,
522
- ...(TToRest | (Split<ResolveRelativePath<TFrom, TTo>, false>['length'] extends 1 ? never : ['../']))
523
- ]>>}` : never : TTo extends `./${infer RestTTo}` ? SplitPaths extends [
524
- ...Split<TFrom, false>,
525
- ...Split<RestTTo, false>,
526
- ...infer RestPath
527
- ] ? `${TTo}${Join<RestPath>}` : never : './' | '../' | AllPaths;
528
- type NavigateOptionsAbsolute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = ToOptions<TAllRouteInfo, TFrom, TTo> & {
529
- replace?: boolean;
530
- };
531
- type ToOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
532
- to?: ToPathOption<TAllRouteInfo, TFrom, TTo>;
533
- hash?: Updater<string>;
534
- state?: LocationState;
535
- from?: TFrom;
536
- } & CheckPath<TAllRouteInfo, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TAllRouteInfo, TFrom, TResolvedTo> & PathParamOptions<TAllRouteInfo, TFrom, TResolvedTo>;
537
- type SearchParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromSchema = RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema'], TToSchema = RouteInfoByPath<TAllRouteInfo, TTo>['fullSearchSchema']> = StartsWith<TFrom, TTo> extends true ? {
538
- search?: SearchReducer<TFromSchema, TToSchema>;
539
- } : keyof PickRequired<TToSchema> extends never ? {
540
- search?: SearchReducer<TFromSchema, TToSchema>;
541
- } : {
542
- search: SearchReducer<TFromSchema, TToSchema>;
543
- };
544
- type SearchReducer<TFrom, TTo> = {
545
- [TKey in keyof TTo]: TTo[TKey];
546
- } | ((current: TFrom) => TTo);
547
- type PathParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromParams = RouteInfoByPath<TAllRouteInfo, TFrom>['allParams'], TToParams = RouteInfoByPath<TAllRouteInfo, TTo>['allParams']> = StartsWith<TFrom, TTo> extends true ? {
548
- params?: ParamsReducer<TFromParams, TToParams>;
549
- } : AnyPathParams extends TToParams ? {
550
- params?: ParamsReducer<TFromParams, Record<string, never>>;
551
- } : {
552
- params: ParamsReducer<TFromParams, TToParams>;
553
- };
554
- type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
555
- 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>;
556
- 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>;
557
- interface ActiveOptions {
558
- exact?: boolean;
559
- includeHash?: boolean;
560
- }
561
- type LinkOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'> = NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo> & {
562
- target?: HTMLAnchorElement['target'];
563
- activeOptions?: ActiveOptions;
564
- preload?: false | 'intent';
565
- preloadMaxAge?: number;
566
- preloadGcMaxAge?: number;
567
- preloadDelay?: number;
568
- disabled?: boolean;
569
- };
570
- type CheckRelativePath<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo> = TTo extends string ? TFrom extends string ? ResolveRelativePath<TFrom, TTo> extends TAllRouteInfo['routePaths'] ? {} : {
571
- Error: `${TFrom} + ${TTo} resolves to ${ResolveRelativePath<TFrom, TTo>}, which is not a valid route path.`;
572
- 'Valid Route Paths': TAllRouteInfo['routePaths'];
573
- } : {} : {};
574
- type CheckPath<TAllRouteInfo extends AnyAllRouteInfo, TPath, TPass> = Exclude<TPath, TAllRouteInfo['routePaths']> extends never ? TPass : CheckPathError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routePaths']>>;
575
- type CheckPathError<TAllRouteInfo extends AnyAllRouteInfo, TInvalids> = Expand<{
576
- Error: `${TInvalids extends string ? TInvalids : never} is not a valid route path.`;
577
- 'Valid Route Paths': TAllRouteInfo['routePaths'];
578
- }>;
579
- type CheckId<TAllRouteInfo extends AnyAllRouteInfo, TPath, TPass> = Exclude<TPath, TAllRouteInfo['routeIds']> extends never ? TPass : CheckIdError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routeIds']>>;
580
- type CheckIdError<TAllRouteInfo extends AnyAllRouteInfo, TInvalids> = Expand<{
581
- Error: `${TInvalids extends string ? TInvalids : never} is not a valid route ID.`;
582
- 'Valid Route IDs': TAllRouteInfo['routeIds'];
583
- }>;
584
- 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;
585
- type ValidFromPath<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo> = undefined | (string extends TAllRouteInfo['routePaths'] ? string : TAllRouteInfo['routePaths']);
586
-
587
- interface Segment {
588
- type: 'pathname' | 'param' | 'wildcard';
589
- value: string;
590
- }
591
- declare function joinPaths(paths: (string | undefined)[]): string;
592
- declare function cleanPath(path: string): string;
593
- declare function trimPathLeft(path: string): string;
594
- declare function trimPathRight(path: string): string;
595
- declare function trimPath(path: string): string;
596
- declare function resolvePath(basepath: string, base: string, to: string): string;
597
- declare function parsePathname(pathname?: string): Segment[];
598
- declare function interpolatePath(path: string | undefined, params: any, leaveWildcard?: boolean): string;
599
- declare function matchPathname(currentPathname: string, matchLocation: Pick<MatchLocation, 'to' | 'fuzzy' | 'caseSensitive'>): AnyPathParams | undefined;
600
- declare function matchByPath(from: string, matchLocation: Pick<MatchLocation, 'to' | 'caseSensitive' | 'fuzzy'>): Record<string, string> | undefined;
601
-
602
- declare function encode(obj: any, pfx?: string): string;
603
- declare function decode(str: any): {};
604
-
605
- declare const defaultParseSearch: (searchStr: string) => AnySearchSchema;
606
- declare const defaultStringifySearch: (search: Record<string, any>) => string;
607
- declare function parseSearchWith(parser: (str: string) => any): (searchStr: string) => AnySearchSchema;
608
- declare function stringifySearchWith(stringify: (search: any) => string): (search: Record<string, any>) => string;
609
-
610
- 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 };
2
+ export { default as warning } from 'tiny-warning';
3
+ export * from './history';
4
+ export * from './link';
5
+ export * from './path';
6
+ export * from './qss';
7
+ export * from './route';
8
+ export * from './fileRoute';
9
+ export * from './routeInfo';
10
+ export * from './router';
11
+ export * from './searchParams';
12
+ export * from './utils';
13
+ export * from './scroll-restoration';
14
+ export * from './defer';