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