@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
|
@@ -841,6 +841,16 @@
|
|
|
841
841
|
return next.matchesById[id];
|
|
842
842
|
});
|
|
843
843
|
}
|
|
844
|
+
if (matchesByIdChanged || matchesChanged || pendingMatchesChanged) {
|
|
845
|
+
const hasPendingComponent = next.pendingMatches.some(d => {
|
|
846
|
+
const route = this.getRoute(d.routeId);
|
|
847
|
+
return !!route?.options.pendingComponent;
|
|
848
|
+
});
|
|
849
|
+
next.renderedMatchIds = hasPendingComponent ? next.pendingMatchIds : next.matchIds;
|
|
850
|
+
next.renderedMatches = next.renderedMatchIds.map(id => {
|
|
851
|
+
return next.matchesById[id];
|
|
852
|
+
});
|
|
853
|
+
}
|
|
844
854
|
next.isFetching = [...next.matches, ...next.pendingMatches].some(d => d.isFetching);
|
|
845
855
|
this.state = next;
|
|
846
856
|
},
|
|
@@ -1054,20 +1064,10 @@
|
|
|
1054
1064
|
return this.latestLoadPromise;
|
|
1055
1065
|
};
|
|
1056
1066
|
#mergeMatches = (prevMatchesById, nextMatches) => {
|
|
1057
|
-
|
|
1058
|
-
...prevMatchesById
|
|
1067
|
+
return {
|
|
1068
|
+
...prevMatchesById,
|
|
1069
|
+
...Object.fromEntries(nextMatches.map(match => [match.id, match]))
|
|
1059
1070
|
};
|
|
1060
|
-
let hadNew = false;
|
|
1061
|
-
nextMatches.forEach(match => {
|
|
1062
|
-
if (!nextMatchesById[match.id]) {
|
|
1063
|
-
hadNew = true;
|
|
1064
|
-
nextMatchesById[match.id] = match;
|
|
1065
|
-
}
|
|
1066
|
-
});
|
|
1067
|
-
if (!hadNew) {
|
|
1068
|
-
return prevMatchesById;
|
|
1069
|
-
}
|
|
1070
|
-
return nextMatchesById;
|
|
1071
1071
|
};
|
|
1072
1072
|
getRoute = id => {
|
|
1073
1073
|
const route = this.routesById[id];
|
|
@@ -1217,14 +1217,17 @@
|
|
|
1217
1217
|
};
|
|
1218
1218
|
try {
|
|
1219
1219
|
const validator = typeof route.options.validateSearch === 'object' ? route.options.validateSearch.parse : route.options.validateSearch;
|
|
1220
|
-
|
|
1221
|
-
|
|
1220
|
+
let routeSearch = validator?.(parentSearchInfo.search) ?? {};
|
|
1221
|
+
let search = {
|
|
1222
1222
|
...parentSearchInfo.search,
|
|
1223
1223
|
...routeSearch
|
|
1224
1224
|
};
|
|
1225
|
+
routeSearch = replaceEqualDeep(match.routeSearch, routeSearch);
|
|
1226
|
+
search = replaceEqualDeep(match.search, search);
|
|
1225
1227
|
return {
|
|
1226
|
-
routeSearch
|
|
1227
|
-
search
|
|
1228
|
+
routeSearch,
|
|
1229
|
+
search,
|
|
1230
|
+
searchDidChange: match.routeSearch !== routeSearch
|
|
1228
1231
|
};
|
|
1229
1232
|
} catch (err) {
|
|
1230
1233
|
match.searchError = new SearchParamError(err.message, {
|
|
@@ -1805,7 +1808,6 @@
|
|
|
1805
1808
|
};
|
|
1806
1809
|
#commitLocation = async location => {
|
|
1807
1810
|
const next = this.buildNext(location);
|
|
1808
|
-
const id = '' + Date.now() + Math.random();
|
|
1809
1811
|
if (this.navigateTimeout) clearTimeout(this.navigateTimeout);
|
|
1810
1812
|
let nextAction = 'replace';
|
|
1811
1813
|
if (!location.replace) {
|
|
@@ -1816,10 +1818,7 @@
|
|
|
1816
1818
|
nextAction = 'replace';
|
|
1817
1819
|
}
|
|
1818
1820
|
const href = `${next.pathname}${next.searchStr}${next.hash ? `#${next.hash}` : ''}`;
|
|
1819
|
-
this.history[nextAction === 'push' ? 'push' : 'replace'](href,
|
|
1820
|
-
id,
|
|
1821
|
-
...next.state
|
|
1822
|
-
});
|
|
1821
|
+
this.history[nextAction === 'push' ? 'push' : 'replace'](href, next.state);
|
|
1823
1822
|
this.resetNextScroll = location.resetScroll ?? true;
|
|
1824
1823
|
return this.latestLoadPromise;
|
|
1825
1824
|
};
|
|
@@ -1905,6 +1904,8 @@
|
|
|
1905
1904
|
pendingMatchIds: [],
|
|
1906
1905
|
matches: [],
|
|
1907
1906
|
pendingMatches: [],
|
|
1907
|
+
renderedMatchIds: [],
|
|
1908
|
+
renderedMatches: [],
|
|
1908
1909
|
lastUpdated: Date.now()
|
|
1909
1910
|
};
|
|
1910
1911
|
}
|