@tanstack/router-core 0.0.1-beta.187 → 0.0.1-beta.189
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/history.js.map +1 -1
- package/build/cjs/route.js.map +1 -1
- package/build/cjs/router.js +16 -39
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +16 -39
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +124 -124
- package/build/types/history.d.ts +2 -2
- package/build/types/link.d.ts +1 -2
- package/build/types/router.d.ts +6 -9
- package/build/umd/index.development.js +16 -39
- 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/history.ts +5 -5
- package/src/link.ts +2 -10
- package/src/route.ts +4 -13
- package/src/router.ts +25 -50
package/build/types/router.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { Store } from '@tanstack/store';
|
|
3
2
|
import { LinkInfo, LinkOptions, NavigateOptions, ToOptions, ResolveRelativePath } from './link';
|
|
4
3
|
import { Route, AnySearchSchema, AnyRoute, AnyContext, AnyPathParams, RegisteredRouteComponent, RegisteredErrorRouteComponent, RegisteredPendingRouteComponent, RouteMask } from './route';
|
|
5
4
|
import { RoutesById, RoutesByPath, ParseRoute, FullSearchSchema, RouteById, RoutePaths, RouteIds } from './routeInfo';
|
|
6
5
|
import { NoInfer, PickAsRequired, Timeout, Updater, NonNullableUpdater } from './utils';
|
|
7
|
-
import {
|
|
6
|
+
import { HistoryState, RouterHistory } from './history';
|
|
8
7
|
declare global {
|
|
9
8
|
interface Window {
|
|
10
9
|
__TSR_DEHYDRATED__?: HydrationCtx;
|
|
@@ -12,6 +11,8 @@ declare global {
|
|
|
12
11
|
}
|
|
13
12
|
export interface Register {
|
|
14
13
|
}
|
|
14
|
+
export interface LocationState {
|
|
15
|
+
}
|
|
15
16
|
export type AnyRouter = Router<any, any>;
|
|
16
17
|
export type RegisteredRouter = Register extends {
|
|
17
18
|
router: infer TRouter extends AnyRouter;
|
|
@@ -21,7 +22,7 @@ export interface ParsedLocation<TSearchObj extends AnySearchSchema = {}> {
|
|
|
21
22
|
pathname: string;
|
|
22
23
|
search: TSearchObj;
|
|
23
24
|
searchStr: string;
|
|
24
|
-
state:
|
|
25
|
+
state: HistoryState;
|
|
25
26
|
hash: string;
|
|
26
27
|
maskedLocation?: ParsedLocation<TSearchObj>;
|
|
27
28
|
unmaskOnReload?: boolean;
|
|
@@ -89,10 +90,6 @@ export interface RouterOptions<TRouteTree extends AnyRoute, TDehydrated extends
|
|
|
89
90
|
router: AnyRouter;
|
|
90
91
|
}) => void;
|
|
91
92
|
context?: TRouteTree['types']['routerContext'];
|
|
92
|
-
Wrap?: React.ComponentType<{
|
|
93
|
-
children: React.ReactNode;
|
|
94
|
-
dehydratedState?: TDehydrated;
|
|
95
|
-
}>;
|
|
96
93
|
dehydrate?: () => TDehydrated;
|
|
97
94
|
hydrate?: (dehydrated: TDehydrated) => void;
|
|
98
95
|
routeMasks?: RouteMask<TRouteTree>[];
|
|
@@ -225,9 +222,9 @@ export declare class Router<TRouteTree extends AnyRoute = AnyRoute, TDehydrated
|
|
|
225
222
|
maxAge?: number;
|
|
226
223
|
}) => Promise<void>;
|
|
227
224
|
resolvePath: (from: string, path: string) => string;
|
|
228
|
-
navigate: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "", TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = "">({ from, to,
|
|
225
|
+
navigate: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "", TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = "">({ from, to, ...rest }: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>) => Promise<void>;
|
|
229
226
|
matchRoute: <TRouteTree_1 extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree_1> = "/", TTo extends string = "", TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<TRouteTree_1, TFrom, TTo, "/", "">, opts?: MatchRouteOptions) => false | RouteById<TRouteTree_1, TResolved>["types"]["allParams"];
|
|
230
|
-
buildLink: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">(
|
|
227
|
+
buildLink: <TFrom extends RoutePaths<TRouteTree> = "/", TTo extends string = "">(dest: LinkOptions<TRouteTree, TFrom, TTo, TFrom, "">) => LinkInfo;
|
|
231
228
|
dehydrate: () => DehydratedRouter;
|
|
232
229
|
hydrate: (__do_not_use_server_ctx?: HydrationCtx) => Promise<void>;
|
|
233
230
|
injectedHtml: (string | (() => Promise<string> | string))[];
|
|
@@ -1440,11 +1440,7 @@
|
|
|
1440
1440
|
navigate = async ({
|
|
1441
1441
|
from,
|
|
1442
1442
|
to = '',
|
|
1443
|
-
|
|
1444
|
-
hash,
|
|
1445
|
-
replace,
|
|
1446
|
-
params,
|
|
1447
|
-
resetScroll
|
|
1443
|
+
...rest
|
|
1448
1444
|
}) => {
|
|
1449
1445
|
// If this link simply reloads the current route,
|
|
1450
1446
|
// make sure it has a new key so it will trigger a data refresh
|
|
@@ -1460,13 +1456,9 @@
|
|
|
1460
1456
|
} catch (e) {}
|
|
1461
1457
|
invariant(!isExternal, 'Attempting to navigate to external url with this.navigate!');
|
|
1462
1458
|
return this.#buildAndCommitLocation({
|
|
1459
|
+
...rest,
|
|
1463
1460
|
from: fromString,
|
|
1464
|
-
to: toString
|
|
1465
|
-
search,
|
|
1466
|
-
hash,
|
|
1467
|
-
params,
|
|
1468
|
-
replace,
|
|
1469
|
-
resetScroll
|
|
1461
|
+
to: toString
|
|
1470
1462
|
});
|
|
1471
1463
|
};
|
|
1472
1464
|
matchRoute = (location, opts) => {
|
|
@@ -1494,28 +1486,23 @@
|
|
|
1494
1486
|
}
|
|
1495
1487
|
return match;
|
|
1496
1488
|
};
|
|
1497
|
-
buildLink =
|
|
1498
|
-
from,
|
|
1499
|
-
to = '.',
|
|
1500
|
-
search,
|
|
1501
|
-
params,
|
|
1502
|
-
hash,
|
|
1503
|
-
target,
|
|
1504
|
-
replace,
|
|
1505
|
-
activeOptions,
|
|
1506
|
-
preload,
|
|
1507
|
-
preloadDelay: userPreloadDelay,
|
|
1508
|
-
disabled,
|
|
1509
|
-
state,
|
|
1510
|
-
mask,
|
|
1511
|
-
resetScroll
|
|
1512
|
-
}) => {
|
|
1489
|
+
buildLink = dest => {
|
|
1513
1490
|
// If this link simply reloads the current route,
|
|
1514
1491
|
// make sure it has a new key so it will trigger a data refresh
|
|
1515
1492
|
|
|
1516
1493
|
// If this `to` is a valid external URL, return
|
|
1517
1494
|
// null for LinkUtils
|
|
1518
1495
|
|
|
1496
|
+
const {
|
|
1497
|
+
to,
|
|
1498
|
+
preload: userPreload,
|
|
1499
|
+
preloadDelay: userPreloadDelay,
|
|
1500
|
+
activeOptions,
|
|
1501
|
+
disabled,
|
|
1502
|
+
target,
|
|
1503
|
+
replace,
|
|
1504
|
+
resetScroll
|
|
1505
|
+
} = dest;
|
|
1519
1506
|
try {
|
|
1520
1507
|
new URL(`${to}`);
|
|
1521
1508
|
return {
|
|
@@ -1523,19 +1510,9 @@
|
|
|
1523
1510
|
href: to
|
|
1524
1511
|
};
|
|
1525
1512
|
} catch (e) {}
|
|
1526
|
-
const nextOpts =
|
|
1527
|
-
from,
|
|
1528
|
-
to,
|
|
1529
|
-
search,
|
|
1530
|
-
params,
|
|
1531
|
-
hash,
|
|
1532
|
-
replace,
|
|
1533
|
-
state,
|
|
1534
|
-
mask,
|
|
1535
|
-
resetScroll
|
|
1536
|
-
};
|
|
1513
|
+
const nextOpts = dest;
|
|
1537
1514
|
const next = this.buildLocation(nextOpts);
|
|
1538
|
-
preload =
|
|
1515
|
+
const preload = userPreload ?? this.options.defaultPreload;
|
|
1539
1516
|
const preloadDelay = userPreloadDelay ?? this.options.defaultPreloadDelay ?? 0;
|
|
1540
1517
|
|
|
1541
1518
|
// Compare path/hash for matches
|