@tanstack/react-router 0.0.1-beta.13 → 0.0.1-beta.15
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/react-router/src/index.js +2 -7
- package/build/cjs/react-router/src/index.js.map +1 -1
- package/build/cjs/router-core/build/esm/index.js +22 -7
- package/build/cjs/router-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +24 -14
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +32 -32
- package/build/umd/index.development.js +24 -14
- 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/index.tsx +2 -4
package/build/esm/index.js
CHANGED
|
@@ -1570,7 +1570,10 @@ function createRouteMatch(router, route, opts) {
|
|
|
1570
1570
|
var _ref, _ref2, _opts$maxAge;
|
|
1571
1571
|
|
|
1572
1572
|
if (routeMatch.options.loader) {
|
|
1573
|
+
var _routeMatch$parentMat3;
|
|
1574
|
+
|
|
1573
1575
|
const data = await routeMatch.options.loader({
|
|
1576
|
+
parentLoaderPromise: (_routeMatch$parentMat3 = routeMatch.parentMatch) == null ? void 0 : _routeMatch$parentMat3.__.dataPromise,
|
|
1574
1577
|
params: routeMatch.params,
|
|
1575
1578
|
search: routeMatch.routeSearch,
|
|
1576
1579
|
signal: routeMatch.__.abortController.signal
|
|
@@ -1587,6 +1590,7 @@ function createRouteMatch(router, route, opts) {
|
|
|
1587
1590
|
routeMatch.status = 'success';
|
|
1588
1591
|
routeMatch.updatedAt = Date.now();
|
|
1589
1592
|
routeMatch.invalidAt = routeMatch.updatedAt + ((_ref = (_ref2 = (_opts$maxAge = opts == null ? void 0 : opts.maxAge) != null ? _opts$maxAge : routeMatch.options.loaderMaxAge) != null ? _ref2 : router.options.defaultLoaderMaxAge) != null ? _ref : 0);
|
|
1593
|
+
return routeMatch.routeLoaderData;
|
|
1590
1594
|
} catch (err) {
|
|
1591
1595
|
if (id !== routeMatch.__.latestId) {
|
|
1592
1596
|
return routeMatch.__.loadPromise;
|
|
@@ -1599,11 +1603,12 @@ function createRouteMatch(router, route, opts) {
|
|
|
1599
1603
|
routeMatch.error = err;
|
|
1600
1604
|
routeMatch.status = 'error';
|
|
1601
1605
|
routeMatch.updatedAt = Date.now();
|
|
1606
|
+
throw err;
|
|
1602
1607
|
}
|
|
1603
1608
|
});
|
|
1604
1609
|
|
|
1605
1610
|
try {
|
|
1606
|
-
await Promise.all([routeMatch.__.componentsPromise, routeMatch.__.dataPromise]);
|
|
1611
|
+
await Promise.all([routeMatch.__.componentsPromise, routeMatch.__.dataPromise.catch(() => {})]);
|
|
1607
1612
|
|
|
1608
1613
|
if (id !== routeMatch.__.latestId) {
|
|
1609
1614
|
return routeMatch.__.loadPromise;
|
|
@@ -1747,10 +1752,16 @@ function createRouter(userOptions) {
|
|
|
1747
1752
|
return router.routesById[id];
|
|
1748
1753
|
},
|
|
1749
1754
|
notify: () => {
|
|
1750
|
-
router.state
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1755
|
+
const isFetching = router.state.status === 'loading' || router.state.matches.some(d => d.isFetching);
|
|
1756
|
+
const isPreloading = Object.values(router.matchCache).some(d => d.match.isFetching && !router.state.matches.find(dd => dd.matchId === d.match.matchId));
|
|
1757
|
+
|
|
1758
|
+
if (router.state.isFetching !== isFetching || router.state.isPreloading !== isPreloading) {
|
|
1759
|
+
router.state = _extends({}, router.state, {
|
|
1760
|
+
isFetching,
|
|
1761
|
+
isPreloading
|
|
1762
|
+
});
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1754
1765
|
cascadeLoaderData(router.state.matches);
|
|
1755
1766
|
router.listeners.forEach(listener => listener(router));
|
|
1756
1767
|
},
|
|
@@ -1769,7 +1780,7 @@ function createRouter(userOptions) {
|
|
|
1769
1780
|
invariant(dehydratedMatch, 'Oh no! Dehydrated route matches did not match the active state of the router 😬');
|
|
1770
1781
|
Object.assign(match, dehydratedMatch);
|
|
1771
1782
|
});
|
|
1772
|
-
|
|
1783
|
+
matches.forEach(match => match.__.validate());
|
|
1773
1784
|
router.state = _extends({}, router.state, dehydratedState, {
|
|
1774
1785
|
matches
|
|
1775
1786
|
});
|
|
@@ -1785,8 +1796,11 @@ function createRouter(userOptions) {
|
|
|
1785
1796
|
|
|
1786
1797
|
if (next.href !== router.location.href) {
|
|
1787
1798
|
router.__.commitLocation(next, true);
|
|
1788
|
-
}
|
|
1799
|
+
}
|
|
1789
1800
|
|
|
1801
|
+
if (!router.state.matches.length) {
|
|
1802
|
+
router.load();
|
|
1803
|
+
}
|
|
1790
1804
|
|
|
1791
1805
|
const unsub = router.history.listen(event => {
|
|
1792
1806
|
router.load(router.__.parseLocation(event.location, router.location));
|
|
@@ -2076,6 +2090,7 @@ function createRouter(userOptions) {
|
|
|
2076
2090
|
const interpolatedPath = interpolatePath(foundRoute.routePath, params);
|
|
2077
2091
|
const matchId = interpolatePath(foundRoute.routeId, params, true);
|
|
2078
2092
|
const match = existingMatches.find(d => d.matchId === matchId) || ((_router$matchCache$ma = router.matchCache[matchId]) == null ? void 0 : _router$matchCache$ma.match) || createRouteMatch(router, foundRoute, {
|
|
2093
|
+
parentMatch,
|
|
2079
2094
|
matchId,
|
|
2080
2095
|
params,
|
|
2081
2096
|
pathname: joinPaths([pathname, interpolatedPath])
|
|
@@ -2487,9 +2502,6 @@ const _excluded = ["type", "children", "target", "activeProps", "inactiveProps",
|
|
|
2487
2502
|
//
|
|
2488
2503
|
const matchesContext = /*#__PURE__*/React.createContext(null);
|
|
2489
2504
|
const routerContext = /*#__PURE__*/React.createContext(null); // Detect if we're in the DOM
|
|
2490
|
-
|
|
2491
|
-
const isDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
2492
|
-
const useLayoutEffect = isDOM ? React.useLayoutEffect : React.useEffect;
|
|
2493
2505
|
function MatchesProvider(props) {
|
|
2494
2506
|
return /*#__PURE__*/React.createElement(matchesContext.Provider, props);
|
|
2495
2507
|
}
|
|
@@ -2671,10 +2683,8 @@ function RouterProvider(_ref2) {
|
|
|
2671
2683
|
|
|
2672
2684
|
router.update(rest);
|
|
2673
2685
|
useRouterSubscription(router);
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
router.load();
|
|
2677
|
-
return unsub;
|
|
2686
|
+
React.useEffect(() => {
|
|
2687
|
+
return router.mount();
|
|
2678
2688
|
}, [router]);
|
|
2679
2689
|
return /*#__PURE__*/React.createElement(routerContext.Provider, {
|
|
2680
2690
|
value: {
|