@tanstack/router-core 0.0.1-beta.182 → 0.0.1-beta.183
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/router.js +23 -22
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +23 -22
- 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/router.d.ts +2 -0
- package/build/umd/index.development.js +23 -22
- 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 +1 -1
- package/src/router.ts +30 -25
package/build/esm/index.js
CHANGED
|
@@ -746,6 +746,16 @@ class Router {
|
|
|
746
746
|
return next.matchesById[id];
|
|
747
747
|
});
|
|
748
748
|
}
|
|
749
|
+
if (matchesByIdChanged || matchesChanged || pendingMatchesChanged) {
|
|
750
|
+
const hasPendingComponent = next.pendingMatches.some(d => {
|
|
751
|
+
const route = this.getRoute(d.routeId);
|
|
752
|
+
return !!route?.options.pendingComponent;
|
|
753
|
+
});
|
|
754
|
+
next.renderedMatchIds = hasPendingComponent ? next.pendingMatchIds : next.matchIds;
|
|
755
|
+
next.renderedMatches = next.renderedMatchIds.map(id => {
|
|
756
|
+
return next.matchesById[id];
|
|
757
|
+
});
|
|
758
|
+
}
|
|
749
759
|
next.isFetching = [...next.matches, ...next.pendingMatches].some(d => d.isFetching);
|
|
750
760
|
this.state = next;
|
|
751
761
|
},
|
|
@@ -959,20 +969,10 @@ class Router {
|
|
|
959
969
|
return this.latestLoadPromise;
|
|
960
970
|
};
|
|
961
971
|
#mergeMatches = (prevMatchesById, nextMatches) => {
|
|
962
|
-
|
|
963
|
-
...prevMatchesById
|
|
972
|
+
return {
|
|
973
|
+
...prevMatchesById,
|
|
974
|
+
...Object.fromEntries(nextMatches.map(match => [match.id, match]))
|
|
964
975
|
};
|
|
965
|
-
let hadNew = false;
|
|
966
|
-
nextMatches.forEach(match => {
|
|
967
|
-
if (!nextMatchesById[match.id]) {
|
|
968
|
-
hadNew = true;
|
|
969
|
-
nextMatchesById[match.id] = match;
|
|
970
|
-
}
|
|
971
|
-
});
|
|
972
|
-
if (!hadNew) {
|
|
973
|
-
return prevMatchesById;
|
|
974
|
-
}
|
|
975
|
-
return nextMatchesById;
|
|
976
976
|
};
|
|
977
977
|
getRoute = id => {
|
|
978
978
|
const route = this.routesById[id];
|
|
@@ -1122,14 +1122,17 @@ class Router {
|
|
|
1122
1122
|
};
|
|
1123
1123
|
try {
|
|
1124
1124
|
const validator = typeof route.options.validateSearch === 'object' ? route.options.validateSearch.parse : route.options.validateSearch;
|
|
1125
|
-
|
|
1126
|
-
|
|
1125
|
+
let routeSearch = validator?.(parentSearchInfo.search) ?? {};
|
|
1126
|
+
let search = {
|
|
1127
1127
|
...parentSearchInfo.search,
|
|
1128
1128
|
...routeSearch
|
|
1129
1129
|
};
|
|
1130
|
+
routeSearch = replaceEqualDeep(match.routeSearch, routeSearch);
|
|
1131
|
+
search = replaceEqualDeep(match.search, search);
|
|
1130
1132
|
return {
|
|
1131
|
-
routeSearch
|
|
1132
|
-
search
|
|
1133
|
+
routeSearch,
|
|
1134
|
+
search,
|
|
1135
|
+
searchDidChange: match.routeSearch !== routeSearch
|
|
1133
1136
|
};
|
|
1134
1137
|
} catch (err) {
|
|
1135
1138
|
match.searchError = new SearchParamError(err.message, {
|
|
@@ -1710,7 +1713,6 @@ class Router {
|
|
|
1710
1713
|
};
|
|
1711
1714
|
#commitLocation = async location => {
|
|
1712
1715
|
const next = this.buildNext(location);
|
|
1713
|
-
const id = '' + Date.now() + Math.random();
|
|
1714
1716
|
if (this.navigateTimeout) clearTimeout(this.navigateTimeout);
|
|
1715
1717
|
let nextAction = 'replace';
|
|
1716
1718
|
if (!location.replace) {
|
|
@@ -1721,10 +1723,7 @@ class Router {
|
|
|
1721
1723
|
nextAction = 'replace';
|
|
1722
1724
|
}
|
|
1723
1725
|
const href = `${next.pathname}${next.searchStr}${next.hash ? `#${next.hash}` : ''}`;
|
|
1724
|
-
this.history[nextAction === 'push' ? 'push' : 'replace'](href,
|
|
1725
|
-
id,
|
|
1726
|
-
...next.state
|
|
1727
|
-
});
|
|
1726
|
+
this.history[nextAction === 'push' ? 'push' : 'replace'](href, next.state);
|
|
1728
1727
|
this.resetNextScroll = location.resetScroll ?? true;
|
|
1729
1728
|
return this.latestLoadPromise;
|
|
1730
1729
|
};
|
|
@@ -1810,6 +1809,8 @@ function getInitialRouterState() {
|
|
|
1810
1809
|
pendingMatchIds: [],
|
|
1811
1810
|
matches: [],
|
|
1812
1811
|
pendingMatches: [],
|
|
1812
|
+
renderedMatchIds: [],
|
|
1813
|
+
renderedMatches: [],
|
|
1813
1814
|
lastUpdated: Date.now()
|
|
1814
1815
|
};
|
|
1815
1816
|
}
|