@tanstack/router-core 0.0.1-beta.30 → 0.0.1-beta.31
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/route.js.map +1 -1
- package/build/cjs/routeMatch.js +1 -1
- package/build/cjs/routeMatch.js.map +1 -1
- package/build/cjs/router.js +22 -24
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +23 -25
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +132 -132
- package/build/types/index.d.ts +158 -160
- package/build/umd/index.development.js +23 -25
- 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 +1 -1
- package/src/link.ts +62 -30
- package/src/route.ts +1 -1
- package/src/routeInfo.ts +4 -1
- package/src/routeMatch.ts +6 -4
- package/src/router.ts +28 -30
package/build/types/index.d.ts
CHANGED
|
@@ -16,63 +16,6 @@ interface FrameworkGenerics {
|
|
|
16
16
|
}
|
|
17
17
|
type GetFrameworkGeneric<U> = U extends keyof FrameworkGenerics ? FrameworkGenerics[U] : any;
|
|
18
18
|
|
|
19
|
-
interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> extends Route<TAllRouteInfo, TRouteInfo> {
|
|
20
|
-
matchId: string;
|
|
21
|
-
pathname: string;
|
|
22
|
-
params: TRouteInfo['allParams'];
|
|
23
|
-
parentMatch?: RouteMatch;
|
|
24
|
-
childMatches: RouteMatch[];
|
|
25
|
-
routeSearch: TRouteInfo['searchSchema'];
|
|
26
|
-
search: TRouteInfo['fullSearchSchema'];
|
|
27
|
-
status: 'idle' | 'loading' | 'success' | 'error';
|
|
28
|
-
updatedAt?: number;
|
|
29
|
-
error?: unknown;
|
|
30
|
-
isInvalid: boolean;
|
|
31
|
-
getIsInvalid: () => boolean;
|
|
32
|
-
loaderData: TRouteInfo['loaderData'];
|
|
33
|
-
routeLoaderData: TRouteInfo['routeLoaderData'];
|
|
34
|
-
isFetching: boolean;
|
|
35
|
-
invalidAt: number;
|
|
36
|
-
__: {
|
|
37
|
-
component?: GetFrameworkGeneric<'Component'>;
|
|
38
|
-
errorComponent?: GetFrameworkGeneric<'ErrorComponent'>;
|
|
39
|
-
pendingComponent?: GetFrameworkGeneric<'Component'>;
|
|
40
|
-
loadPromise?: Promise<void>;
|
|
41
|
-
componentsPromise?: Promise<void>;
|
|
42
|
-
dataPromise?: Promise<TRouteInfo['routeLoaderData']>;
|
|
43
|
-
onExit?: void | ((matchContext: {
|
|
44
|
-
params: TRouteInfo['allParams'];
|
|
45
|
-
search: TRouteInfo['fullSearchSchema'];
|
|
46
|
-
}) => void);
|
|
47
|
-
abortController: AbortController;
|
|
48
|
-
latestId: string;
|
|
49
|
-
validate: () => void;
|
|
50
|
-
notify: () => void;
|
|
51
|
-
resolve: () => void;
|
|
52
|
-
};
|
|
53
|
-
cancel: () => void;
|
|
54
|
-
load: (loaderOpts?: {
|
|
55
|
-
preload: true;
|
|
56
|
-
maxAge: number;
|
|
57
|
-
gcMaxAge: number;
|
|
58
|
-
} | {
|
|
59
|
-
preload?: false;
|
|
60
|
-
maxAge?: never;
|
|
61
|
-
gcMaxAge?: never;
|
|
62
|
-
}) => Promise<TRouteInfo['routeLoaderData']>;
|
|
63
|
-
fetch: (opts?: {
|
|
64
|
-
maxAge?: number;
|
|
65
|
-
}) => Promise<TRouteInfo['routeLoaderData']>;
|
|
66
|
-
invalidate: () => void;
|
|
67
|
-
hasLoaders: () => boolean;
|
|
68
|
-
}
|
|
69
|
-
declare function createRouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo>(router: Router<any, any, any>, route: Route<TAllRouteInfo, TRouteInfo>, opts: {
|
|
70
|
-
parentMatch?: RouteMatch<any, any>;
|
|
71
|
-
matchId: string;
|
|
72
|
-
params: TRouteInfo['allParams'];
|
|
73
|
-
pathname: string;
|
|
74
|
-
}): RouteMatch<TAllRouteInfo, TRouteInfo>;
|
|
75
|
-
|
|
76
19
|
type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
77
20
|
type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N;
|
|
78
21
|
type IsAnyBoolean<T> = 1 extends 0 & T ? true : false;
|
|
@@ -228,7 +171,7 @@ type Listener = (router: Router<any, any, any>) => void;
|
|
|
228
171
|
type ListenerFn = () => void;
|
|
229
172
|
interface BuildNextOptions {
|
|
230
173
|
to?: string | number | null;
|
|
231
|
-
params?: true | Updater<
|
|
174
|
+
params?: true | Updater<unknown>;
|
|
232
175
|
search?: true | Updater<unknown>;
|
|
233
176
|
hash?: true | Updater<string>;
|
|
234
177
|
state?: LocationState;
|
|
@@ -257,7 +200,7 @@ interface DehydratedRouterState extends Pick<RouterState, 'status' | 'location'
|
|
|
257
200
|
matches: DehydratedRouteMatch[];
|
|
258
201
|
}
|
|
259
202
|
interface DehydratedRouter<TRouterContext = unknown> {
|
|
260
|
-
location: Router['
|
|
203
|
+
location: Router['__location'];
|
|
261
204
|
state: DehydratedRouterState;
|
|
262
205
|
context: TRouterContext;
|
|
263
206
|
}
|
|
@@ -274,7 +217,7 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
|
|
|
274
217
|
options: PickAsRequired<RouterOptions<TRouteConfig, TRouterContext>, 'stringifySearch' | 'parseSearch' | 'context'>;
|
|
275
218
|
basepath: string;
|
|
276
219
|
listeners: Listener[];
|
|
277
|
-
|
|
220
|
+
__location: Location<TAllRouteInfo['fullSearchSchema']>;
|
|
278
221
|
navigateTimeout?: Timeout;
|
|
279
222
|
nextAction?: 'push' | 'replace';
|
|
280
223
|
state: RouterState<TAllRouteInfo['fullSearchSchema']>;
|
|
@@ -333,96 +276,62 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
|
|
|
333
276
|
}
|
|
334
277
|
declare function createRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown>(userOptions?: RouterOptions<TRouteConfig, TRouterContext>): Router<TRouteConfig, TAllRouteInfo, TRouterContext>;
|
|
335
278
|
|
|
336
|
-
interface
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
'/': TRouteInfo;
|
|
386
|
-
} & {
|
|
387
|
-
[TInfo in TRouteInfo as TInfo['id']]: TInfo;
|
|
388
|
-
}, TRouteInfoByFullPath = {
|
|
389
|
-
'/': TRouteInfo;
|
|
390
|
-
} & {
|
|
391
|
-
[TInfo in TRouteInfo as TInfo['fullPath'] extends RootRouteId ? never : string extends TInfo['fullPath'] ? never : TInfo['fullPath']]: TInfo;
|
|
392
|
-
}> {
|
|
393
|
-
routeConfig: TRouteConfig;
|
|
394
|
-
routeInfo: TRouteInfo;
|
|
395
|
-
routeInfoById: TRouteInfoById;
|
|
396
|
-
routeInfoByFullPath: TRouteInfoByFullPath;
|
|
397
|
-
routeIds: keyof TRouteInfoById;
|
|
398
|
-
routePaths: keyof TRouteInfoByFullPath;
|
|
399
|
-
fullSearchSchema: Partial<UnionToIntersection<TRouteInfo['fullSearchSchema']>>;
|
|
400
|
-
}
|
|
401
|
-
interface AnyRouteInfo extends RouteInfo<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
|
|
402
|
-
}
|
|
403
|
-
interface RouteInfo<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = {}, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends AnyPathParams = {}, TAllParams extends AnyPathParams = {}> {
|
|
404
|
-
id: TId;
|
|
405
|
-
routeId: TRouteId;
|
|
406
|
-
path: TPath;
|
|
407
|
-
fullPath: TFullPath;
|
|
408
|
-
parentRouteLoaderData: TParentRouteLoaderData;
|
|
409
|
-
routeLoaderData: TRouteLoaderData;
|
|
410
|
-
parentLoaderData: TParentLoaderData;
|
|
411
|
-
loaderData: TLoaderData;
|
|
412
|
-
actionPayload: TActionPayload;
|
|
413
|
-
actionResponse: TActionResponse;
|
|
414
|
-
searchSchema: TSearchSchema;
|
|
415
|
-
fullSearchSchema: TFullSearchSchema;
|
|
416
|
-
parentParams: TParentParams;
|
|
417
|
-
params: TParams;
|
|
418
|
-
allParams: TAllParams;
|
|
419
|
-
options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
|
|
279
|
+
interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> extends Route<TAllRouteInfo, TRouteInfo> {
|
|
280
|
+
matchId: string;
|
|
281
|
+
pathname: string;
|
|
282
|
+
params: TRouteInfo['allParams'];
|
|
283
|
+
parentMatch?: RouteMatch;
|
|
284
|
+
childMatches: RouteMatch[];
|
|
285
|
+
routeSearch: TRouteInfo['searchSchema'];
|
|
286
|
+
search: Expand<TAllRouteInfo['fullSearchSchema'] & TRouteInfo['fullSearchSchema']>;
|
|
287
|
+
status: 'idle' | 'loading' | 'success' | 'error';
|
|
288
|
+
updatedAt?: number;
|
|
289
|
+
error?: unknown;
|
|
290
|
+
isInvalid: boolean;
|
|
291
|
+
getIsInvalid: () => boolean;
|
|
292
|
+
loaderData: TRouteInfo['loaderData'];
|
|
293
|
+
routeLoaderData: TRouteInfo['routeLoaderData'];
|
|
294
|
+
isFetching: boolean;
|
|
295
|
+
invalidAt: number;
|
|
296
|
+
__: {
|
|
297
|
+
component?: GetFrameworkGeneric<'Component'>;
|
|
298
|
+
errorComponent?: GetFrameworkGeneric<'ErrorComponent'>;
|
|
299
|
+
pendingComponent?: GetFrameworkGeneric<'Component'>;
|
|
300
|
+
loadPromise?: Promise<void>;
|
|
301
|
+
componentsPromise?: Promise<void>;
|
|
302
|
+
dataPromise?: Promise<TRouteInfo['routeLoaderData']>;
|
|
303
|
+
onExit?: void | ((matchContext: {
|
|
304
|
+
params: TRouteInfo['allParams'];
|
|
305
|
+
search: TRouteInfo['fullSearchSchema'];
|
|
306
|
+
}) => void);
|
|
307
|
+
abortController: AbortController;
|
|
308
|
+
latestId: string;
|
|
309
|
+
validate: () => void;
|
|
310
|
+
notify: () => void;
|
|
311
|
+
resolve: () => void;
|
|
312
|
+
};
|
|
313
|
+
cancel: () => void;
|
|
314
|
+
load: (loaderOpts?: {
|
|
315
|
+
preload: true;
|
|
316
|
+
maxAge: number;
|
|
317
|
+
gcMaxAge: number;
|
|
318
|
+
} | {
|
|
319
|
+
preload?: false;
|
|
320
|
+
maxAge?: never;
|
|
321
|
+
gcMaxAge?: never;
|
|
322
|
+
}) => Promise<TRouteInfo['routeLoaderData']>;
|
|
323
|
+
fetch: (opts?: {
|
|
324
|
+
maxAge?: number;
|
|
325
|
+
}) => Promise<TRouteInfo['routeLoaderData']>;
|
|
326
|
+
invalidate: () => void;
|
|
327
|
+
hasLoaders: () => boolean;
|
|
420
328
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
329
|
+
declare function createRouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo>(router: Router<any, any, any>, route: Route<TAllRouteInfo, TRouteInfo>, opts: {
|
|
330
|
+
parentMatch?: RouteMatch<any, any>;
|
|
331
|
+
matchId: string;
|
|
332
|
+
params: TRouteInfo['allParams'];
|
|
333
|
+
pathname: string;
|
|
334
|
+
}): RouteMatch<TAllRouteInfo, TRouteInfo>;
|
|
426
335
|
|
|
427
336
|
declare const rootRouteId: "__root__";
|
|
428
337
|
type RootRouteId = typeof rootRouteId;
|
|
@@ -520,6 +429,100 @@ type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? Tr
|
|
|
520
429
|
type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
|
|
521
430
|
declare const createRouteConfig: CreateRouteConfigFn<true>;
|
|
522
431
|
|
|
432
|
+
interface AnyRoute extends Route<any, any, any> {
|
|
433
|
+
}
|
|
434
|
+
interface Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo, TRouterContext = unknown> {
|
|
435
|
+
routeInfo: TRouteInfo;
|
|
436
|
+
routeId: TRouteInfo['id'];
|
|
437
|
+
routeRouteId: TRouteInfo['routeId'];
|
|
438
|
+
routePath: TRouteInfo['path'];
|
|
439
|
+
fullPath: TRouteInfo['fullPath'];
|
|
440
|
+
parentRoute?: AnyRoute;
|
|
441
|
+
childRoutes?: AnyRoute[];
|
|
442
|
+
options: RouteOptions;
|
|
443
|
+
router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>;
|
|
444
|
+
buildLink: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>) => LinkInfo;
|
|
445
|
+
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'];
|
|
446
|
+
navigate: <TTo extends string = '.'>(options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>) => Promise<void>;
|
|
447
|
+
action: unknown extends TRouteInfo['actionResponse'] ? Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']> | undefined : Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>;
|
|
448
|
+
loader: unknown extends TRouteInfo['routeLoaderData'] ? Action<LoaderContext<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams']>, TRouteInfo['routeLoaderData']> | undefined : Loader<TRouteInfo['fullSearchSchema'], TRouteInfo['allParams'], TRouteInfo['routeLoaderData']>;
|
|
449
|
+
}
|
|
450
|
+
declare function createRoute<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo, TRouterContext = unknown>(routeConfig: RouteConfig, options: TRouteInfo['options'], parent: undefined | Route<TAllRouteInfo, any>, router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>): Route<TAllRouteInfo, TRouteInfo, TRouterContext>;
|
|
451
|
+
|
|
452
|
+
interface AnyAllRouteInfo {
|
|
453
|
+
routeConfig: AnyRouteConfig;
|
|
454
|
+
routeInfo: AnyRouteInfo;
|
|
455
|
+
routeInfoById: Record<string, AnyRouteInfo>;
|
|
456
|
+
routeInfoByFullPath: Record<string, AnyRouteInfo>;
|
|
457
|
+
routeIds: any;
|
|
458
|
+
routePaths: any;
|
|
459
|
+
fullSearchSchema: Record<string, any>;
|
|
460
|
+
allParams: Record<string, any>;
|
|
461
|
+
}
|
|
462
|
+
interface DefaultAllRouteInfo {
|
|
463
|
+
routeConfig: RouteConfig;
|
|
464
|
+
routeInfo: RouteInfo;
|
|
465
|
+
routeInfoById: Record<string, RouteInfo>;
|
|
466
|
+
routeInfoByFullPath: Record<string, RouteInfo>;
|
|
467
|
+
routeIds: string;
|
|
468
|
+
routePaths: string;
|
|
469
|
+
fullSearchSchema: AnySearchSchema;
|
|
470
|
+
allParams: AnyPathParams;
|
|
471
|
+
}
|
|
472
|
+
interface AllRouteInfo<TRouteConfig extends AnyRouteConfig = RouteConfig> extends RoutesInfoInner<TRouteConfig, ParseRouteConfig<TRouteConfig>> {
|
|
473
|
+
}
|
|
474
|
+
type ParseRouteConfig<TRouteConfig = AnyRouteConfig> = TRouteConfig extends AnyRouteConfig ? RouteConfigRoute<TRouteConfig> | ParseRouteChildren<TRouteConfig> : never;
|
|
475
|
+
type ParseRouteChildren<TRouteConfig> = TRouteConfig extends AnyRouteConfigWithChildren<infer TChildren> ? unknown extends TChildren ? never : TChildren extends AnyRouteConfig[] ? Values<{
|
|
476
|
+
[TId in TChildren[number]['id']]: ParseRouteChild<TChildren[number], TId>;
|
|
477
|
+
}> : never : never;
|
|
478
|
+
type ParseRouteChild<TRouteConfig, TId> = TRouteConfig & {
|
|
479
|
+
id: TId;
|
|
480
|
+
} extends AnyRouteConfig ? ParseRouteConfig<TRouteConfig> : never;
|
|
481
|
+
type RouteConfigRoute<TRouteConfig> = TRouteConfig extends RouteConfig<infer TId, infer TRouteId, infer TPath, infer TFullPath, infer TParentRouteLoaderData, infer TRouteLoaderData, infer TParentLoaderData, 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, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams> : never;
|
|
482
|
+
interface RoutesInfoInner<TRouteConfig extends AnyRouteConfig, TRouteInfo extends RouteInfo<string, string, any, any, any, any, any, any, any, any, any, any, any, any, any, any> = RouteInfo, TRouteInfoById = {
|
|
483
|
+
'/': TRouteInfo;
|
|
484
|
+
} & {
|
|
485
|
+
[TInfo in TRouteInfo as TInfo['id']]: TInfo;
|
|
486
|
+
}, TRouteInfoByFullPath = {
|
|
487
|
+
'/': TRouteInfo;
|
|
488
|
+
} & {
|
|
489
|
+
[TInfo in TRouteInfo as TInfo['fullPath'] extends RootRouteId ? never : string extends TInfo['fullPath'] ? never : TInfo['fullPath']]: TInfo;
|
|
490
|
+
}> {
|
|
491
|
+
routeConfig: TRouteConfig;
|
|
492
|
+
routeInfo: TRouteInfo;
|
|
493
|
+
routeInfoById: TRouteInfoById;
|
|
494
|
+
routeInfoByFullPath: TRouteInfoByFullPath;
|
|
495
|
+
routeIds: keyof TRouteInfoById;
|
|
496
|
+
routePaths: keyof TRouteInfoByFullPath;
|
|
497
|
+
fullSearchSchema: Partial<UnionToIntersection<TRouteInfo['fullSearchSchema']>>;
|
|
498
|
+
allParams: Partial<UnionToIntersection<TRouteInfo['allParams']>>;
|
|
499
|
+
}
|
|
500
|
+
interface AnyRouteInfo extends RouteInfo<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any> {
|
|
501
|
+
}
|
|
502
|
+
interface RouteInfo<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = '/', TParentRouteLoaderData extends AnyLoaderData = {}, TRouteLoaderData extends AnyLoaderData = {}, TParentLoaderData extends AnyLoaderData = {}, TLoaderData extends AnyLoaderData = {}, TActionPayload = unknown, TActionResponse = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends AnyPathParams = {}, TAllParams extends AnyPathParams = {}> {
|
|
503
|
+
id: TId;
|
|
504
|
+
routeId: TRouteId;
|
|
505
|
+
path: TPath;
|
|
506
|
+
fullPath: TFullPath;
|
|
507
|
+
parentRouteLoaderData: TParentRouteLoaderData;
|
|
508
|
+
routeLoaderData: TRouteLoaderData;
|
|
509
|
+
parentLoaderData: TParentLoaderData;
|
|
510
|
+
loaderData: TLoaderData;
|
|
511
|
+
actionPayload: TActionPayload;
|
|
512
|
+
actionResponse: TActionResponse;
|
|
513
|
+
searchSchema: TSearchSchema;
|
|
514
|
+
fullSearchSchema: TFullSearchSchema;
|
|
515
|
+
parentParams: TParentParams;
|
|
516
|
+
params: TParams;
|
|
517
|
+
allParams: TAllParams;
|
|
518
|
+
options: RouteOptions<TRouteId, TPath, TParentRouteLoaderData, TRouteLoaderData, TParentLoaderData, TLoaderData, TActionPayload, TActionResponse, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
|
|
519
|
+
}
|
|
520
|
+
type RoutesById<TAllRouteInfo extends AnyAllRouteInfo> = {
|
|
521
|
+
[K in keyof TAllRouteInfo['routeInfoById']]: Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][K]>;
|
|
522
|
+
};
|
|
523
|
+
type RouteInfoById<TAllRouteInfo extends AnyAllRouteInfo, TId> = TId extends keyof TAllRouteInfo['routeInfoById'] ? IsAny<TAllRouteInfo['routeInfoById'][TId]['id'], RouteInfo, TAllRouteInfo['routeInfoById'][TId]> : never;
|
|
524
|
+
type RouteInfoByPath<TAllRouteInfo extends AnyAllRouteInfo, TPath> = TPath extends keyof TAllRouteInfo['routeInfoByFullPath'] ? IsAny<TAllRouteInfo['routeInfoByFullPath'][TPath]['id'], RouteInfo, TAllRouteInfo['routeInfoByFullPath'][TPath]> : never;
|
|
525
|
+
|
|
523
526
|
type LinkInfo = {
|
|
524
527
|
type: 'external';
|
|
525
528
|
href: string;
|
|
@@ -533,7 +536,6 @@ type LinkInfo = {
|
|
|
533
536
|
isActive: boolean;
|
|
534
537
|
disabled?: boolean;
|
|
535
538
|
};
|
|
536
|
-
type StartsWith<A, B> = A extends `${B extends string ? B : never}${infer _}` ? true : false;
|
|
537
539
|
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;
|
|
538
540
|
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;
|
|
539
541
|
type ParsePathParams<T extends string> = Split<T>[number] extends infer U ? U extends `$${infer V}` ? V : never : never;
|
|
@@ -558,22 +560,18 @@ type ToOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFro
|
|
|
558
560
|
state?: LocationState;
|
|
559
561
|
from?: TFrom;
|
|
560
562
|
} & CheckPath<TAllRouteInfo, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TAllRouteInfo, TFrom, TResolvedTo> & PathParamOptions<TAllRouteInfo, TFrom, TResolvedTo>;
|
|
561
|
-
type SearchParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromSchema = RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']
|
|
562
|
-
search?: SearchReducer<
|
|
563
|
-
} : keyof PickRequired<TToSchema> extends never ? {
|
|
564
|
-
search?: SearchReducer<TFromSchema, TToSchema>;
|
|
563
|
+
type SearchParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromSchema = Expand<UnionToIntersection<TAllRouteInfo['fullSearchSchema'] & RouteInfoByPath<TAllRouteInfo, TFrom> extends never ? {} : RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']>>, TToSchema = Partial<RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']> & Omit<RouteInfoByPath<TAllRouteInfo, TTo>['fullSearchSchema'], keyof PickRequired<RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']>>, TFromFullSchema = Expand<UnionToIntersection<TAllRouteInfo['fullSearchSchema'] & TFromSchema>>, TToFullSchema = Expand<UnionToIntersection<TAllRouteInfo['fullSearchSchema'] & TToSchema>>> = keyof PickRequired<TToSchema> extends never ? {
|
|
564
|
+
search?: true | SearchReducer<TFromFullSchema, TToFullSchema>;
|
|
565
565
|
} : {
|
|
566
|
-
search: SearchReducer<
|
|
566
|
+
search: SearchReducer<TFromFullSchema, TToFullSchema>;
|
|
567
567
|
};
|
|
568
568
|
type SearchReducer<TFrom, TTo> = {
|
|
569
569
|
[TKey in keyof TTo]: TTo[TKey];
|
|
570
570
|
} | ((current: TFrom) => TTo);
|
|
571
|
-
type PathParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo,
|
|
572
|
-
params?: ParamsReducer<
|
|
573
|
-
} : AnyPathParams extends TToParams ? {
|
|
574
|
-
params?: ParamsReducer<TFromParams, Record<string, never>>;
|
|
571
|
+
type PathParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromSchema = Expand<UnionToIntersection<RouteInfoByPath<TAllRouteInfo, TFrom> extends never ? {} : RouteInfoByPath<TAllRouteInfo, TFrom>['allParams']>>, TToSchema = Partial<RouteInfoByPath<TAllRouteInfo, TFrom>['allParams']> & Omit<RouteInfoByPath<TAllRouteInfo, TTo>['allParams'], keyof PickRequired<RouteInfoByPath<TAllRouteInfo, TFrom>['allParams']>>, TFromFullParams = Expand<UnionToIntersection<TAllRouteInfo['allParams'] & TFromSchema>>, TToFullParams = Expand<UnionToIntersection<TAllRouteInfo['allParams'] & TToSchema>>> = keyof PickRequired<TToSchema> extends never ? {
|
|
572
|
+
params?: ParamsReducer<TFromFullParams, TToFullParams>;
|
|
575
573
|
} : {
|
|
576
|
-
params: ParamsReducer<
|
|
574
|
+
params: ParamsReducer<TFromFullParams, TToFullParams>;
|
|
577
575
|
};
|
|
578
576
|
type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
|
|
579
577
|
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>;
|
|
@@ -1343,7 +1343,7 @@
|
|
|
1343
1343
|
validate: () => {
|
|
1344
1344
|
var _routeMatch$parentMat, _routeMatch$parentMat2;
|
|
1345
1345
|
// Validate the search params and stabilize them
|
|
1346
|
-
const parentSearch = (_routeMatch$parentMat = (_routeMatch$parentMat2 = routeMatch.parentMatch) == null ? void 0 : _routeMatch$parentMat2.search) != null ? _routeMatch$parentMat : router.
|
|
1346
|
+
const parentSearch = (_routeMatch$parentMat = (_routeMatch$parentMat2 = routeMatch.parentMatch) == null ? void 0 : _routeMatch$parentMat2.search) != null ? _routeMatch$parentMat : router.__location.search;
|
|
1347
1347
|
try {
|
|
1348
1348
|
var _validator;
|
|
1349
1349
|
const prevSearch = routeMatch.routeSearch;
|
|
@@ -1581,7 +1581,7 @@
|
|
|
1581
1581
|
basepath: '',
|
|
1582
1582
|
routeTree: undefined,
|
|
1583
1583
|
routesById: {},
|
|
1584
|
-
|
|
1584
|
+
__location: undefined,
|
|
1585
1585
|
//
|
|
1586
1586
|
resolveNavigation: () => {},
|
|
1587
1587
|
matchCache: {},
|
|
@@ -1614,7 +1614,7 @@
|
|
|
1614
1614
|
},
|
|
1615
1615
|
dehydrate: () => {
|
|
1616
1616
|
return {
|
|
1617
|
-
location: router.
|
|
1617
|
+
location: router.__location,
|
|
1618
1618
|
state: _extends({}, pick(router.state, ['status', 'location', 'lastUpdated', 'location']), {
|
|
1619
1619
|
matches: router.state.matches.map(match => pick(match, ['matchId', 'status', 'routeLoaderData', 'loaderData', 'isInvalid', 'invalidAt']))
|
|
1620
1620
|
}),
|
|
@@ -1623,13 +1623,13 @@
|
|
|
1623
1623
|
},
|
|
1624
1624
|
hydrate: dehydratedState => {
|
|
1625
1625
|
// Update the location
|
|
1626
|
-
router.
|
|
1626
|
+
router.__location = dehydratedState.location;
|
|
1627
1627
|
|
|
1628
1628
|
// Update the context
|
|
1629
1629
|
router.options.context = dehydratedState.context;
|
|
1630
1630
|
|
|
1631
1631
|
// Match the routes
|
|
1632
|
-
const matches = router.matchRoutes(router.
|
|
1632
|
+
const matches = router.matchRoutes(router.__location.pathname, {
|
|
1633
1633
|
strictParseParams: true
|
|
1634
1634
|
});
|
|
1635
1635
|
matches.forEach((match, index) => {
|
|
@@ -1651,14 +1651,14 @@
|
|
|
1651
1651
|
|
|
1652
1652
|
// If the current location isn't updated, trigger a navigation
|
|
1653
1653
|
// to the current location. Otherwise, load the current location.
|
|
1654
|
-
if (next.href !== router.
|
|
1654
|
+
if (next.href !== router.__location.href) {
|
|
1655
1655
|
router.__.commitLocation(next, true);
|
|
1656
1656
|
}
|
|
1657
1657
|
if (!router.state.matches.length) {
|
|
1658
1658
|
router.load();
|
|
1659
1659
|
}
|
|
1660
1660
|
const unsub = router.history.listen(event => {
|
|
1661
|
-
router.load(router.__.parseLocation(event.location, router.
|
|
1661
|
+
router.load(router.__.parseLocation(event.location, router.__location));
|
|
1662
1662
|
});
|
|
1663
1663
|
|
|
1664
1664
|
// addEventListener does not exist in React Native, but window does
|
|
@@ -1682,12 +1682,12 @@
|
|
|
1682
1682
|
},
|
|
1683
1683
|
update: opts => {
|
|
1684
1684
|
const newHistory = (opts == null ? void 0 : opts.history) !== router.history;
|
|
1685
|
-
if (!router.
|
|
1685
|
+
if (!router.__location || newHistory) {
|
|
1686
1686
|
if (opts != null && opts.history) {
|
|
1687
1687
|
router.history = opts.history;
|
|
1688
1688
|
}
|
|
1689
|
-
router.
|
|
1690
|
-
router.state.location = router.
|
|
1689
|
+
router.__location = router.__.parseLocation(router.history.location);
|
|
1690
|
+
router.state.location = router.__location;
|
|
1691
1691
|
}
|
|
1692
1692
|
Object.assign(router.options, opts);
|
|
1693
1693
|
const {
|
|
@@ -1712,28 +1712,28 @@
|
|
|
1712
1712
|
router.startedLoadingAt = id;
|
|
1713
1713
|
if (next) {
|
|
1714
1714
|
// Ingest the new location
|
|
1715
|
-
router.
|
|
1715
|
+
router.__location = next;
|
|
1716
1716
|
}
|
|
1717
1717
|
|
|
1718
1718
|
// Cancel any pending matches
|
|
1719
1719
|
router.cancelMatches();
|
|
1720
1720
|
|
|
1721
1721
|
// Match the routes
|
|
1722
|
-
const matches = router.matchRoutes(router.
|
|
1722
|
+
const matches = router.matchRoutes(router.__location.pathname, {
|
|
1723
1723
|
strictParseParams: true
|
|
1724
1724
|
});
|
|
1725
1725
|
if (typeof document !== 'undefined') {
|
|
1726
1726
|
router.state = _extends({}, router.state, {
|
|
1727
1727
|
pending: {
|
|
1728
1728
|
matches: matches,
|
|
1729
|
-
location: router.
|
|
1729
|
+
location: router.__location
|
|
1730
1730
|
},
|
|
1731
1731
|
status: 'loading'
|
|
1732
1732
|
});
|
|
1733
1733
|
} else {
|
|
1734
1734
|
router.state = _extends({}, router.state, {
|
|
1735
1735
|
matches: matches,
|
|
1736
|
-
location: router.
|
|
1736
|
+
location: router.__location,
|
|
1737
1737
|
status: 'loading'
|
|
1738
1738
|
});
|
|
1739
1739
|
}
|
|
@@ -1817,7 +1817,7 @@
|
|
|
1817
1817
|
}
|
|
1818
1818
|
});
|
|
1819
1819
|
router.state = _extends({}, router.state, {
|
|
1820
|
-
location: router.
|
|
1820
|
+
location: router.__location,
|
|
1821
1821
|
matches,
|
|
1822
1822
|
pending: undefined,
|
|
1823
1823
|
status: 'idle'
|
|
@@ -1846,7 +1846,7 @@
|
|
|
1846
1846
|
},
|
|
1847
1847
|
loadRoute: async function loadRoute(navigateOpts) {
|
|
1848
1848
|
if (navigateOpts === void 0) {
|
|
1849
|
-
navigateOpts = router.
|
|
1849
|
+
navigateOpts = router.__location;
|
|
1850
1850
|
}
|
|
1851
1851
|
const next = router.buildNext(navigateOpts);
|
|
1852
1852
|
const matches = router.matchRoutes(next.pathname, {
|
|
@@ -1858,7 +1858,7 @@
|
|
|
1858
1858
|
preloadRoute: async function preloadRoute(navigateOpts, loaderOpts) {
|
|
1859
1859
|
var _ref3, _ref4, _loaderOpts$maxAge, _ref5, _ref6, _loaderOpts$gcMaxAge;
|
|
1860
1860
|
if (navigateOpts === void 0) {
|
|
1861
|
-
navigateOpts = router.
|
|
1861
|
+
navigateOpts = router.__location;
|
|
1862
1862
|
}
|
|
1863
1863
|
const next = router.buildNext(navigateOpts);
|
|
1864
1864
|
const matches = router.matchRoutes(next.pathname, {
|
|
@@ -2238,11 +2238,9 @@
|
|
|
2238
2238
|
if (dest === void 0) {
|
|
2239
2239
|
dest = {};
|
|
2240
2240
|
}
|
|
2241
|
-
|
|
2242
|
-
// ...router.location,
|
|
2243
|
-
const fromPathname = dest.fromCurrent ? router.location.pathname : (_dest$from = dest.from) != null ? _dest$from : router.location.pathname;
|
|
2241
|
+
const fromPathname = dest.fromCurrent ? router.__location.pathname : (_dest$from = dest.from) != null ? _dest$from : router.__location.pathname;
|
|
2244
2242
|
let pathname = resolvePath((_router$basepath = router.basepath) != null ? _router$basepath : '/', fromPathname, "" + ((_dest$to = dest.to) != null ? _dest$to : '.'));
|
|
2245
|
-
const fromMatches = router.matchRoutes(router.
|
|
2243
|
+
const fromMatches = router.matchRoutes(router.__location.pathname, {
|
|
2246
2244
|
strictParseParams: true
|
|
2247
2245
|
});
|
|
2248
2246
|
const toMatches = router.matchRoutes(pathname);
|
|
@@ -2256,7 +2254,7 @@
|
|
|
2256
2254
|
pathname = interpolatePath(pathname, nextParams != null ? nextParams : {});
|
|
2257
2255
|
|
|
2258
2256
|
// Pre filters first
|
|
2259
|
-
const preFilteredSearch = (_dest$__preSearchFilt = dest.__preSearchFilters) != null && _dest$__preSearchFilt.length ? dest.__preSearchFilters.reduce((prev, next) => next(prev), router.
|
|
2257
|
+
const preFilteredSearch = (_dest$__preSearchFilt = dest.__preSearchFilters) != null && _dest$__preSearchFilt.length ? dest.__preSearchFilters.reduce((prev, next) => next(prev), router.__location.search) : router.__location.search;
|
|
2260
2258
|
|
|
2261
2259
|
// Then the link/navigate function
|
|
2262
2260
|
const destSearch = dest.search === true ? preFilteredSearch // Preserve resolvedFrom true
|
|
@@ -2266,15 +2264,15 @@
|
|
|
2266
2264
|
|
|
2267
2265
|
// Then post filters
|
|
2268
2266
|
const postFilteredSearch = (_dest$__postSearchFil = dest.__postSearchFilters) != null && _dest$__postSearchFil.length ? dest.__postSearchFilters.reduce((prev, next) => next(prev), destSearch) : destSearch;
|
|
2269
|
-
const search = replaceEqualDeep(router.
|
|
2267
|
+
const search = replaceEqualDeep(router.__location.search, postFilteredSearch);
|
|
2270
2268
|
const searchStr = router.options.stringifySearch(search);
|
|
2271
|
-
let hash = dest.hash === true ? router.
|
|
2269
|
+
let hash = dest.hash === true ? router.__location.hash : functionalUpdate(dest.hash, router.__location.hash);
|
|
2272
2270
|
hash = hash ? "#" + hash : '';
|
|
2273
2271
|
return {
|
|
2274
2272
|
pathname,
|
|
2275
2273
|
search,
|
|
2276
2274
|
searchStr,
|
|
2277
|
-
state: router.
|
|
2275
|
+
state: router.__location.state,
|
|
2278
2276
|
hash,
|
|
2279
2277
|
href: "" + pathname + searchStr + hash,
|
|
2280
2278
|
key: dest.key
|