@tanstack/react-router 0.0.1-beta.35 → 0.0.1-beta.36
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/index.js +8 -8
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +8 -8
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +50 -50
- package/build/umd/index.development.js +103 -93
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +10 -8
|
@@ -1252,7 +1252,6 @@
|
|
|
1252
1252
|
actionState.status = 'success';
|
|
1253
1253
|
return res;
|
|
1254
1254
|
} catch (err) {
|
|
1255
|
-
console.log('tanner');
|
|
1256
1255
|
console.error(err);
|
|
1257
1256
|
actionState.error = err;
|
|
1258
1257
|
actionState.status = 'error';
|
|
@@ -1406,7 +1405,7 @@
|
|
|
1406
1405
|
validate: () => {
|
|
1407
1406
|
var _routeMatch$parentMat, _routeMatch$parentMat2;
|
|
1408
1407
|
// Validate the search params and stabilize them
|
|
1409
|
-
const parentSearch = (_routeMatch$parentMat = (_routeMatch$parentMat2 = routeMatch.parentMatch) == null ? void 0 : _routeMatch$parentMat2.search) != null ? _routeMatch$parentMat : router.
|
|
1408
|
+
const parentSearch = (_routeMatch$parentMat = (_routeMatch$parentMat2 = routeMatch.parentMatch) == null ? void 0 : _routeMatch$parentMat2.search) != null ? _routeMatch$parentMat : router.state.currentLocation.search;
|
|
1410
1409
|
try {
|
|
1411
1410
|
var _validator;
|
|
1412
1411
|
const prevSearch = routeMatch.routeSearch;
|
|
@@ -1458,7 +1457,7 @@
|
|
|
1458
1457
|
// If this is a preload, add it to the preload cache
|
|
1459
1458
|
if (loaderOpts != null && loaderOpts.preload && minMaxAge > 0) {
|
|
1460
1459
|
// If the match is currently active, don't preload it
|
|
1461
|
-
if (router.state.
|
|
1460
|
+
if (router.state.currentMatches.find(d => d.matchId === routeMatch.matchId)) {
|
|
1462
1461
|
return;
|
|
1463
1462
|
}
|
|
1464
1463
|
router.matchCache[routeMatch.matchId] = {
|
|
@@ -1612,8 +1611,9 @@
|
|
|
1612
1611
|
function getInitialRouterState() {
|
|
1613
1612
|
return {
|
|
1614
1613
|
status: 'idle',
|
|
1615
|
-
|
|
1616
|
-
|
|
1614
|
+
latestLocation: null,
|
|
1615
|
+
currentLocation: null,
|
|
1616
|
+
currentMatches: [],
|
|
1617
1617
|
actions: {},
|
|
1618
1618
|
loaders: {},
|
|
1619
1619
|
lastUpdated: Date.now(),
|
|
@@ -1644,7 +1644,6 @@
|
|
|
1644
1644
|
basepath: '',
|
|
1645
1645
|
routeTree: undefined,
|
|
1646
1646
|
routesById: {},
|
|
1647
|
-
__location: undefined,
|
|
1648
1647
|
//
|
|
1649
1648
|
resolveNavigation: () => {},
|
|
1650
1649
|
matchCache: {},
|
|
@@ -1664,65 +1663,53 @@
|
|
|
1664
1663
|
return router.routesById[id];
|
|
1665
1664
|
},
|
|
1666
1665
|
notify: () => {
|
|
1667
|
-
const isFetching = router.state.status === 'loading' || router.state.
|
|
1668
|
-
const isPreloading = Object.values(router.matchCache).some(d => d.match.isFetching && !router.state.
|
|
1666
|
+
const isFetching = router.state.status === 'loading' || router.state.currentMatches.some(d => d.isFetching);
|
|
1667
|
+
const isPreloading = Object.values(router.matchCache).some(d => d.match.isFetching && !router.state.currentMatches.find(dd => dd.matchId === d.match.matchId));
|
|
1669
1668
|
if (router.state.isFetching !== isFetching || router.state.isPreloading !== isPreloading) {
|
|
1670
1669
|
router.state = _extends({}, router.state, {
|
|
1671
1670
|
isFetching,
|
|
1672
1671
|
isPreloading
|
|
1673
1672
|
});
|
|
1674
1673
|
}
|
|
1675
|
-
cascadeLoaderData(router.state.
|
|
1674
|
+
cascadeLoaderData(router.state.currentMatches);
|
|
1676
1675
|
router.listeners.forEach(listener => listener(router));
|
|
1677
1676
|
},
|
|
1678
1677
|
dehydrate: () => {
|
|
1679
1678
|
return {
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
matches: router.state.matches.map(match => pick(match, ['matchId', 'status', 'routeLoaderData', 'loaderData', 'isInvalid', 'invalidAt']))
|
|
1679
|
+
state: _extends({}, pick(router.state, ['latestLocation', 'currentLocation', 'status', 'lastUpdated']), {
|
|
1680
|
+
currentMatches: router.state.currentMatches.map(match => pick(match, ['matchId', 'status', 'routeLoaderData', 'loaderData', 'isInvalid', 'invalidAt']))
|
|
1683
1681
|
}),
|
|
1684
1682
|
context: router.options.context
|
|
1685
1683
|
};
|
|
1686
1684
|
},
|
|
1687
1685
|
hydrate: dehydratedState => {
|
|
1688
1686
|
// Update the location
|
|
1689
|
-
router.
|
|
1687
|
+
router.state.latestLocation = dehydratedState.state.latestLocation;
|
|
1688
|
+
router.state.currentLocation = dehydratedState.state.currentLocation;
|
|
1690
1689
|
|
|
1691
1690
|
// Update the context
|
|
1692
1691
|
router.options.context = dehydratedState.context;
|
|
1693
1692
|
|
|
1694
1693
|
// Match the routes
|
|
1695
|
-
const
|
|
1694
|
+
const currentMatches = router.matchRoutes(router.state.latestLocation.pathname, {
|
|
1696
1695
|
strictParseParams: true
|
|
1697
1696
|
});
|
|
1698
|
-
|
|
1699
|
-
const dehydratedMatch = dehydratedState.state.
|
|
1697
|
+
currentMatches.forEach((match, index) => {
|
|
1698
|
+
const dehydratedMatch = dehydratedState.state.currentMatches[index];
|
|
1700
1699
|
invariant(dehydratedMatch, 'Oh no! Dehydrated route matches did not match the active state of the router 😬');
|
|
1701
1700
|
Object.assign(match, dehydratedMatch);
|
|
1702
1701
|
});
|
|
1703
|
-
|
|
1702
|
+
currentMatches.forEach(match => match.__.validate());
|
|
1704
1703
|
router.state = _extends({}, router.state, dehydratedState, {
|
|
1705
|
-
|
|
1704
|
+
currentMatches
|
|
1706
1705
|
});
|
|
1707
1706
|
},
|
|
1708
1707
|
mount: () => {
|
|
1709
|
-
router.
|
|
1710
|
-
to: '.',
|
|
1711
|
-
search: true,
|
|
1712
|
-
hash: true
|
|
1713
|
-
});
|
|
1714
|
-
|
|
1715
|
-
// If the current location isn't updated, trigger a navigation
|
|
1716
|
-
// to the current location. Otherwise, load the current location.
|
|
1717
|
-
// if (next.href !== router.__location.href) {
|
|
1718
|
-
// router.__.commitLocation(next, true)
|
|
1719
|
-
// }
|
|
1720
|
-
|
|
1721
|
-
if (!router.state.matches.length) {
|
|
1708
|
+
if (!router.state.currentMatches.length) {
|
|
1722
1709
|
router.load();
|
|
1723
1710
|
}
|
|
1724
1711
|
const unsub = router.history.listen(event => {
|
|
1725
|
-
router.load(router.__.parseLocation(event.location, router.
|
|
1712
|
+
router.load(router.__.parseLocation(event.location, router.state.latestLocation));
|
|
1726
1713
|
});
|
|
1727
1714
|
|
|
1728
1715
|
// addEventListener does not exist in React Native, but window does
|
|
@@ -1747,12 +1734,12 @@
|
|
|
1747
1734
|
update: opts => {
|
|
1748
1735
|
var _trimPath;
|
|
1749
1736
|
const newHistory = (opts == null ? void 0 : opts.history) !== router.history;
|
|
1750
|
-
if (!router.
|
|
1737
|
+
if (!router.state.latestLocation || newHistory) {
|
|
1751
1738
|
if (opts != null && opts.history) {
|
|
1752
1739
|
router.history = opts.history;
|
|
1753
1740
|
}
|
|
1754
|
-
router.
|
|
1755
|
-
router.state.
|
|
1741
|
+
router.state.latestLocation = router.__.parseLocation(router.history.location);
|
|
1742
|
+
router.state.currentLocation = router.state.latestLocation;
|
|
1756
1743
|
}
|
|
1757
1744
|
Object.assign(router.options, opts);
|
|
1758
1745
|
const {
|
|
@@ -1767,8 +1754,8 @@
|
|
|
1767
1754
|
return router;
|
|
1768
1755
|
},
|
|
1769
1756
|
cancelMatches: () => {
|
|
1770
|
-
var _router$state$pending
|
|
1771
|
-
[...router.state.
|
|
1757
|
+
var _router$state$pending;
|
|
1758
|
+
[...router.state.currentMatches, ...((_router$state$pending = router.state.pendingMatches) != null ? _router$state$pending : [])].forEach(match => {
|
|
1772
1759
|
match.cancel();
|
|
1773
1760
|
});
|
|
1774
1761
|
},
|
|
@@ -1777,51 +1764,43 @@
|
|
|
1777
1764
|
router.startedLoadingAt = id;
|
|
1778
1765
|
if (next) {
|
|
1779
1766
|
// Ingest the new location
|
|
1780
|
-
router.
|
|
1767
|
+
router.state.latestLocation = next;
|
|
1781
1768
|
}
|
|
1782
1769
|
|
|
1783
1770
|
// Cancel any pending matches
|
|
1784
1771
|
router.cancelMatches();
|
|
1785
1772
|
|
|
1786
1773
|
// Match the routes
|
|
1787
|
-
const matches = router.matchRoutes(router.
|
|
1774
|
+
const matches = router.matchRoutes(router.state.latestLocation.pathname, {
|
|
1788
1775
|
strictParseParams: true
|
|
1789
1776
|
});
|
|
1790
1777
|
if (typeof document !== 'undefined') {
|
|
1791
1778
|
router.state = _extends({}, router.state, {
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
},
|
|
1796
|
-
status: 'loading'
|
|
1779
|
+
status: 'loading',
|
|
1780
|
+
pendingMatches: matches,
|
|
1781
|
+
pendingLocation: router.state.latestLocation
|
|
1797
1782
|
});
|
|
1798
1783
|
} else {
|
|
1799
1784
|
router.state = _extends({}, router.state, {
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1785
|
+
status: 'loading',
|
|
1786
|
+
currentMatches: matches,
|
|
1787
|
+
currentLocation: router.state.latestLocation
|
|
1803
1788
|
});
|
|
1804
1789
|
}
|
|
1790
|
+
router.notify();
|
|
1805
1791
|
|
|
1806
|
-
//
|
|
1792
|
+
// Load the matches
|
|
1807
1793
|
try {
|
|
1808
|
-
await
|
|
1809
|
-
router: router,
|
|
1810
|
-
match
|
|
1811
|
-
})));
|
|
1794
|
+
await router.loadMatches(matches);
|
|
1812
1795
|
} catch (err) {
|
|
1813
|
-
console.
|
|
1814
|
-
invariant(false,
|
|
1796
|
+
console.log(err);
|
|
1797
|
+
invariant(false, 'Matches failed to load due to error above ☝️. Navigation cancelled!');
|
|
1815
1798
|
}
|
|
1816
|
-
router.notify();
|
|
1817
|
-
|
|
1818
|
-
// Load the matches
|
|
1819
|
-
await router.loadMatches(matches);
|
|
1820
1799
|
if (router.startedLoadingAt !== id) {
|
|
1821
1800
|
// Ignore side-effects of match loading
|
|
1822
1801
|
return router.navigationPromise;
|
|
1823
1802
|
}
|
|
1824
|
-
const previousMatches = router.state.
|
|
1803
|
+
const previousMatches = router.state.currentMatches;
|
|
1825
1804
|
const exiting = [],
|
|
1826
1805
|
staying = [];
|
|
1827
1806
|
previousMatches.forEach(d => {
|
|
@@ -1880,10 +1859,11 @@
|
|
|
1880
1859
|
}
|
|
1881
1860
|
});
|
|
1882
1861
|
router.state = _extends({}, router.state, {
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1862
|
+
status: 'idle',
|
|
1863
|
+
currentLocation: router.state.latestLocation,
|
|
1864
|
+
currentMatches: matches,
|
|
1865
|
+
pendingLocation: undefined,
|
|
1866
|
+
pendingMatches: undefined
|
|
1887
1867
|
});
|
|
1888
1868
|
router.notify();
|
|
1889
1869
|
router.resolveNavigation();
|
|
@@ -1909,7 +1889,7 @@
|
|
|
1909
1889
|
},
|
|
1910
1890
|
loadRoute: async function loadRoute(navigateOpts) {
|
|
1911
1891
|
if (navigateOpts === void 0) {
|
|
1912
|
-
navigateOpts = router.
|
|
1892
|
+
navigateOpts = router.state.latestLocation;
|
|
1913
1893
|
}
|
|
1914
1894
|
const next = router.buildNext(navigateOpts);
|
|
1915
1895
|
const matches = router.matchRoutes(next.pathname, {
|
|
@@ -1921,7 +1901,7 @@
|
|
|
1921
1901
|
preloadRoute: async function preloadRoute(navigateOpts, loaderOpts) {
|
|
1922
1902
|
var _ref3, _ref4, _loaderOpts$maxAge, _ref5, _ref6, _loaderOpts$gcMaxAge;
|
|
1923
1903
|
if (navigateOpts === void 0) {
|
|
1924
|
-
navigateOpts = router.
|
|
1904
|
+
navigateOpts = router.state.latestLocation;
|
|
1925
1905
|
}
|
|
1926
1906
|
const next = router.buildNext(navigateOpts);
|
|
1927
1907
|
const matches = router.matchRoutes(next.pathname, {
|
|
@@ -1935,13 +1915,13 @@
|
|
|
1935
1915
|
return matches;
|
|
1936
1916
|
},
|
|
1937
1917
|
matchRoutes: (pathname, opts) => {
|
|
1938
|
-
var _router$state$
|
|
1918
|
+
var _router$state$pending2;
|
|
1939
1919
|
router.cleanMatchCache();
|
|
1940
1920
|
const matches = [];
|
|
1941
1921
|
if (!router.routeTree) {
|
|
1942
1922
|
return matches;
|
|
1943
1923
|
}
|
|
1944
|
-
const existingMatches = [...router.state.
|
|
1924
|
+
const existingMatches = [...router.state.currentMatches, ...((_router$state$pending2 = router.state.pendingMatches) != null ? _router$state$pending2 : [])];
|
|
1945
1925
|
const recurse = async routes => {
|
|
1946
1926
|
var _parentMatch$params, _router$options$filte, _foundRoute$childRout;
|
|
1947
1927
|
const parentMatch = last(matches);
|
|
@@ -1960,7 +1940,15 @@
|
|
|
1960
1940
|
fuzzy,
|
|
1961
1941
|
caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
|
|
1962
1942
|
});
|
|
1963
|
-
|
|
1943
|
+
|
|
1944
|
+
// console.log(
|
|
1945
|
+
// router.basepath,
|
|
1946
|
+
// route.fullPath,
|
|
1947
|
+
// fuzzy,
|
|
1948
|
+
// pathname,
|
|
1949
|
+
// matchParams,
|
|
1950
|
+
// )
|
|
1951
|
+
|
|
1964
1952
|
if (matchParams) {
|
|
1965
1953
|
let parsedParams;
|
|
1966
1954
|
try {
|
|
@@ -2006,10 +1994,27 @@
|
|
|
2006
1994
|
return matches;
|
|
2007
1995
|
},
|
|
2008
1996
|
loadMatches: async (resolvedMatches, loaderOpts) => {
|
|
2009
|
-
|
|
2010
|
-
var _search$__data;
|
|
1997
|
+
resolvedMatches.forEach(async match => {
|
|
2011
1998
|
// Validate the match (loads search params etc)
|
|
2012
1999
|
match.__.validate();
|
|
2000
|
+
});
|
|
2001
|
+
|
|
2002
|
+
// Check each match middleware to see if the route can be accessed
|
|
2003
|
+
await Promise.all(resolvedMatches.map(async match => {
|
|
2004
|
+
try {
|
|
2005
|
+
await (match.options.beforeLoad == null ? void 0 : match.options.beforeLoad({
|
|
2006
|
+
router: router,
|
|
2007
|
+
match
|
|
2008
|
+
}));
|
|
2009
|
+
} catch (err) {
|
|
2010
|
+
if (!(loaderOpts != null && loaderOpts.preload)) {
|
|
2011
|
+
match.options.onLoadError == null ? void 0 : match.options.onLoadError(err);
|
|
2012
|
+
}
|
|
2013
|
+
throw err;
|
|
2014
|
+
}
|
|
2015
|
+
}));
|
|
2016
|
+
const matchPromises = resolvedMatches.map(async match => {
|
|
2017
|
+
var _search$__data;
|
|
2013
2018
|
const search = match.search;
|
|
2014
2019
|
if ((_search$__data = search.__data) != null && _search$__data.matchId && search.__data.matchId !== match.matchId) {
|
|
2015
2020
|
return;
|
|
@@ -2064,10 +2069,10 @@
|
|
|
2064
2069
|
}
|
|
2065
2070
|
},
|
|
2066
2071
|
invalidateRoute: opts => {
|
|
2067
|
-
var _router$state$
|
|
2072
|
+
var _router$state$pending3;
|
|
2068
2073
|
const next = router.buildNext(opts);
|
|
2069
2074
|
const unloadedMatchIds = router.matchRoutes(next.pathname).map(d => d.matchId);
|
|
2070
|
-
[...router.state.
|
|
2075
|
+
[...router.state.currentMatches, ...((_router$state$pending3 = router.state.pendingMatches) != null ? _router$state$pending3 : [])].forEach(match => {
|
|
2071
2076
|
if (unloadedMatchIds.includes(match.matchId)) {
|
|
2072
2077
|
match.invalidate();
|
|
2073
2078
|
}
|
|
@@ -2090,15 +2095,14 @@
|
|
|
2090
2095
|
});
|
|
2091
2096
|
const next = router.buildNext(location);
|
|
2092
2097
|
if (opts != null && opts.pending) {
|
|
2093
|
-
|
|
2094
|
-
if (!((_router$state$pending7 = router.state.pending) != null && _router$state$pending7.location)) {
|
|
2098
|
+
if (!router.state.pendingLocation) {
|
|
2095
2099
|
return false;
|
|
2096
2100
|
}
|
|
2097
|
-
return !!matchPathname(router.basepath, router.state.
|
|
2101
|
+
return !!matchPathname(router.basepath, router.state.pendingLocation.pathname, _extends({}, opts, {
|
|
2098
2102
|
to: next.pathname
|
|
2099
2103
|
}));
|
|
2100
2104
|
}
|
|
2101
|
-
return !!matchPathname(router.basepath, router.state.
|
|
2105
|
+
return !!matchPathname(router.basepath, router.state.currentLocation.pathname, _extends({}, opts, {
|
|
2102
2106
|
to: next.pathname
|
|
2103
2107
|
}));
|
|
2104
2108
|
},
|
|
@@ -2176,11 +2180,11 @@
|
|
|
2176
2180
|
const preloadDelay = (_ref9 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultPreloadDelay) != null ? _ref9 : 0;
|
|
2177
2181
|
|
|
2178
2182
|
// Compare path/hash for matches
|
|
2179
|
-
const pathIsEqual = router.state.
|
|
2180
|
-
const currentPathSplit = router.state.
|
|
2183
|
+
const pathIsEqual = router.state.currentLocation.pathname === next.pathname;
|
|
2184
|
+
const currentPathSplit = router.state.currentLocation.pathname.split('/');
|
|
2181
2185
|
const nextPathSplit = next.pathname.split('/');
|
|
2182
2186
|
const pathIsFuzzyEqual = nextPathSplit.every((d, i) => d === currentPathSplit[i]);
|
|
2183
|
-
const hashIsEqual = router.state.
|
|
2187
|
+
const hashIsEqual = router.state.currentLocation.hash === next.hash;
|
|
2184
2188
|
// Combine the matches based on user options
|
|
2185
2189
|
const pathTest = activeOptions != null && activeOptions.exact ? pathIsEqual : pathIsFuzzyEqual;
|
|
2186
2190
|
const hashTest = activeOptions != null && activeOptions.includeHash ? hashIsEqual : true;
|
|
@@ -2207,6 +2211,9 @@
|
|
|
2207
2211
|
router.preloadRoute(nextOpts, {
|
|
2208
2212
|
maxAge: userPreloadMaxAge,
|
|
2209
2213
|
gcMaxAge: userPreloadGcMaxAge
|
|
2214
|
+
}).catch(err => {
|
|
2215
|
+
console.log(err);
|
|
2216
|
+
console.warn('Error preloading route! ☝️');
|
|
2210
2217
|
});
|
|
2211
2218
|
}
|
|
2212
2219
|
};
|
|
@@ -2221,6 +2228,9 @@
|
|
|
2221
2228
|
router.preloadRoute(nextOpts, {
|
|
2222
2229
|
maxAge: userPreloadMaxAge,
|
|
2223
2230
|
gcMaxAge: userPreloadGcMaxAge
|
|
2231
|
+
}).catch(err => {
|
|
2232
|
+
console.log(err);
|
|
2233
|
+
console.warn('Error preloading route! ☝️');
|
|
2224
2234
|
});
|
|
2225
2235
|
}, preloadDelay);
|
|
2226
2236
|
}
|
|
@@ -2303,9 +2313,9 @@
|
|
|
2303
2313
|
if (dest === void 0) {
|
|
2304
2314
|
dest = {};
|
|
2305
2315
|
}
|
|
2306
|
-
const fromPathname = dest.fromCurrent ? router.
|
|
2316
|
+
const fromPathname = dest.fromCurrent ? router.state.latestLocation.pathname : (_dest$from = dest.from) != null ? _dest$from : router.state.latestLocation.pathname;
|
|
2307
2317
|
let pathname = resolvePath((_router$basepath = router.basepath) != null ? _router$basepath : '/', fromPathname, "" + ((_dest$to = dest.to) != null ? _dest$to : '.'));
|
|
2308
|
-
const fromMatches = router.matchRoutes(router.
|
|
2318
|
+
const fromMatches = router.matchRoutes(router.state.latestLocation.pathname, {
|
|
2309
2319
|
strictParseParams: true
|
|
2310
2320
|
});
|
|
2311
2321
|
const toMatches = router.matchRoutes(pathname);
|
|
@@ -2319,7 +2329,7 @@
|
|
|
2319
2329
|
pathname = interpolatePath(pathname, nextParams != null ? nextParams : {});
|
|
2320
2330
|
|
|
2321
2331
|
// Pre filters first
|
|
2322
|
-
const preFilteredSearch = (_dest$__preSearchFilt = dest.__preSearchFilters) != null && _dest$__preSearchFilt.length ? dest.__preSearchFilters.reduce((prev, next) => next(prev), router.
|
|
2332
|
+
const preFilteredSearch = (_dest$__preSearchFilt = dest.__preSearchFilters) != null && _dest$__preSearchFilt.length ? dest.__preSearchFilters.reduce((prev, next) => next(prev), router.state.latestLocation.search) : router.state.latestLocation.search;
|
|
2323
2333
|
|
|
2324
2334
|
// Then the link/navigate function
|
|
2325
2335
|
const destSearch = dest.search === true ? preFilteredSearch // Preserve resolvedFrom true
|
|
@@ -2329,15 +2339,15 @@
|
|
|
2329
2339
|
|
|
2330
2340
|
// Then post filters
|
|
2331
2341
|
const postFilteredSearch = (_dest$__postSearchFil = dest.__postSearchFilters) != null && _dest$__postSearchFil.length ? dest.__postSearchFilters.reduce((prev, next) => next(prev), destSearch) : destSearch;
|
|
2332
|
-
const search = replaceEqualDeep(router.
|
|
2342
|
+
const search = replaceEqualDeep(router.state.latestLocation.search, postFilteredSearch);
|
|
2333
2343
|
const searchStr = router.options.stringifySearch(search);
|
|
2334
|
-
let hash = dest.hash === true ? router.
|
|
2344
|
+
let hash = dest.hash === true ? router.state.latestLocation.hash : functionalUpdate(dest.hash, router.state.latestLocation.hash);
|
|
2335
2345
|
hash = hash ? "#" + hash : '';
|
|
2336
2346
|
return {
|
|
2337
2347
|
pathname,
|
|
2338
2348
|
search,
|
|
2339
2349
|
searchStr,
|
|
2340
|
-
state: router.
|
|
2350
|
+
state: router.state.latestLocation.state,
|
|
2341
2351
|
hash,
|
|
2342
2352
|
href: "" + pathname + searchStr + hash,
|
|
2343
2353
|
key: dest.key
|
|
@@ -2566,7 +2576,7 @@
|
|
|
2566
2576
|
useRouterSubscription(router);
|
|
2567
2577
|
invariant(routeId !== rootRouteId, "\"" + rootRouteId + "\" cannot be used with useMatch! Did you mean to useRoute(\"" + rootRouteId + "\")?");
|
|
2568
2578
|
const nearestMatch = useNearestMatch();
|
|
2569
|
-
const match = router.state.
|
|
2579
|
+
const match = router.state.currentMatches.find(d => d.routeId === routeId);
|
|
2570
2580
|
if ((_opts$strict = opts == null ? void 0 : opts.strict) != null ? _opts$strict : true) {
|
|
2571
2581
|
invariant(match, "Could not find an active match for \"" + routeId + "\"!");
|
|
2572
2582
|
invariant(nearestMatch.routeId == (match == null ? void 0 : match.routeId), "useMatch(\"" + (match == null ? void 0 : match.routeId) + "\") is being called in a component that is meant to render the '" + nearestMatch.routeId + "' route. Did you mean to 'useMatch(\"" + (match == null ? void 0 : match.routeId) + "\", { strict: false })' or 'useRoute(\"" + (match == null ? void 0 : match.routeId) + "\")' instead?");
|
|
@@ -2611,7 +2621,7 @@
|
|
|
2611
2621
|
router: router
|
|
2612
2622
|
}
|
|
2613
2623
|
}, /*#__PURE__*/React__namespace.createElement(MatchesProvider, {
|
|
2614
|
-
value: [undefined, ...router.state.
|
|
2624
|
+
value: [undefined, ...router.state.currentMatches]
|
|
2615
2625
|
}, /*#__PURE__*/React__namespace.createElement(Outlet, null))));
|
|
2616
2626
|
}
|
|
2617
2627
|
function useRouter() {
|
|
@@ -2637,7 +2647,7 @@
|
|
|
2637
2647
|
return router.useRoute(routeId);
|
|
2638
2648
|
}
|
|
2639
2649
|
function useSearch(_routeId) {
|
|
2640
|
-
return useRouter().state.
|
|
2650
|
+
return useRouter().state.currentLocation.search;
|
|
2641
2651
|
}
|
|
2642
2652
|
function linkProps(props) {
|
|
2643
2653
|
const router = useRouter();
|
|
@@ -2711,10 +2721,10 @@
|
|
|
2711
2721
|
const errorComponent = (_props$errorComponent = props.errorComponent) != null ? _props$errorComponent : DefaultErrorBoundary;
|
|
2712
2722
|
React__namespace.useEffect(() => {
|
|
2713
2723
|
if (activeErrorState) {
|
|
2714
|
-
let prevKey = router.state.
|
|
2724
|
+
let prevKey = router.state.currentLocation.key;
|
|
2715
2725
|
return router.subscribe(() => {
|
|
2716
|
-
if (router.state.
|
|
2717
|
-
prevKey = router.state.
|
|
2726
|
+
if (router.state.currentLocation.key !== prevKey) {
|
|
2727
|
+
prevKey = router.state.currentLocation.key;
|
|
2718
2728
|
setActiveErrorState({});
|
|
2719
2729
|
}
|
|
2720
2730
|
});
|
|
@@ -2768,11 +2778,11 @@
|
|
|
2768
2778
|
unblock();
|
|
2769
2779
|
transition.retry();
|
|
2770
2780
|
} else {
|
|
2771
|
-
router.state.
|
|
2781
|
+
router.state.currentLocation.pathname = window.location.pathname;
|
|
2772
2782
|
}
|
|
2773
2783
|
});
|
|
2774
2784
|
return unblock;
|
|
2775
|
-
}, [when,
|
|
2785
|
+
}, [when, message]);
|
|
2776
2786
|
}
|
|
2777
2787
|
function Prompt(_ref7) {
|
|
2778
2788
|
let {
|