@tanstack/router-core 0.0.1-beta.9 → 1.97.24

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