@tanstack/router-core 1.158.4 → 1.159.6
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/dist/cjs/router.cjs +10 -7
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +10 -7
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +14 -10
package/dist/cjs/router.cjs
CHANGED
|
@@ -109,14 +109,14 @@ class RouterCore {
|
|
|
109
109
|
if (this.options.routeTree !== this.routeTree) {
|
|
110
110
|
this.routeTree = this.options.routeTree;
|
|
111
111
|
let processRouteTreeResult;
|
|
112
|
-
if ((isServer.isServer ?? this.isServer) && globalThis.__TSR_CACHE__ && globalThis.__TSR_CACHE__.routeTree === this.routeTree) {
|
|
112
|
+
if ((isServer.isServer ?? this.isServer) && process.env.NODE_ENV !== "development" && globalThis.__TSR_CACHE__ && globalThis.__TSR_CACHE__.routeTree === this.routeTree) {
|
|
113
113
|
const cached = globalThis.__TSR_CACHE__;
|
|
114
114
|
this.resolvePathCache = cached.resolvePathCache;
|
|
115
115
|
processRouteTreeResult = cached.processRouteTreeResult;
|
|
116
116
|
} else {
|
|
117
117
|
this.resolvePathCache = lruCache.createLRUCache(1e3);
|
|
118
118
|
processRouteTreeResult = this.buildRouteTree();
|
|
119
|
-
if ((isServer.isServer ?? this.isServer) && globalThis.__TSR_CACHE__ === void 0) {
|
|
119
|
+
if ((isServer.isServer ?? this.isServer) && process.env.NODE_ENV !== "development" && globalThis.__TSR_CACHE__ === void 0) {
|
|
120
120
|
globalThis.__TSR_CACHE__ = {
|
|
121
121
|
routeTree: this.routeTree,
|
|
122
122
|
processRouteTreeResult,
|
|
@@ -1129,6 +1129,9 @@ class RouterCore {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
const globalNotFoundRouteId = isGlobalNotFound ? findGlobalNotFoundRouteId(this.options.notFoundMode, matchedRoutes) : void 0;
|
|
1131
1131
|
const matches = new Array(matchedRoutes.length);
|
|
1132
|
+
const previousMatchesByRouteId = new Map(
|
|
1133
|
+
this.state.matches.map((match) => [match.routeId, match])
|
|
1134
|
+
);
|
|
1132
1135
|
for (let index = 0; index < matchedRoutes.length; index++) {
|
|
1133
1136
|
const route = matchedRoutes[index];
|
|
1134
1137
|
const parentMatch = matches[index - 1];
|
|
@@ -1178,9 +1181,7 @@ class RouterCore {
|
|
|
1178
1181
|
loaderDepsHash
|
|
1179
1182
|
);
|
|
1180
1183
|
const existingMatch = this.getMatch(matchId);
|
|
1181
|
-
const previousMatch =
|
|
1182
|
-
(d) => d.routeId === route.id
|
|
1183
|
-
);
|
|
1184
|
+
const previousMatch = previousMatchesByRouteId.get(route.id);
|
|
1184
1185
|
const strictParams = existingMatch?._strictParams ?? usedParams;
|
|
1185
1186
|
let paramsError = void 0;
|
|
1186
1187
|
if (!existingMatch) {
|
|
@@ -1206,7 +1207,7 @@ class RouterCore {
|
|
|
1206
1207
|
match = {
|
|
1207
1208
|
...existingMatch,
|
|
1208
1209
|
cause,
|
|
1209
|
-
params: previousMatch
|
|
1210
|
+
params: previousMatch?.params ?? routeParams,
|
|
1210
1211
|
_strictParams: strictParams,
|
|
1211
1212
|
search: previousMatch ? utils.replaceEqualDeep(previousMatch.search, preMatchSearch) : utils.replaceEqualDeep(existingMatch.search, preMatchSearch),
|
|
1212
1213
|
_strictSearch: strictMatchSearch
|
|
@@ -1218,7 +1219,7 @@ class RouterCore {
|
|
|
1218
1219
|
ssr: isServer.isServer ?? this.isServer ? void 0 : route.options.ssr,
|
|
1219
1220
|
index,
|
|
1220
1221
|
routeId: route.id,
|
|
1221
|
-
params: previousMatch
|
|
1222
|
+
params: previousMatch?.params ?? routeParams,
|
|
1222
1223
|
_strictParams: strictParams,
|
|
1223
1224
|
pathname: interpolatedPath,
|
|
1224
1225
|
updatedAt: Date.now(),
|
|
@@ -1265,6 +1266,8 @@ class RouterCore {
|
|
|
1265
1266
|
const match = matches[index];
|
|
1266
1267
|
const route = this.looseRoutesById[match.routeId];
|
|
1267
1268
|
const existingMatch = this.getMatch(match.id);
|
|
1269
|
+
const previousMatch = previousMatchesByRouteId.get(match.routeId);
|
|
1270
|
+
match.params = previousMatch ? utils.replaceEqualDeep(previousMatch.params, routeParams) : routeParams;
|
|
1268
1271
|
if (!existingMatch) {
|
|
1269
1272
|
const parentMatch = matches[index - 1];
|
|
1270
1273
|
const parentContext = this.getParentContext(parentMatch);
|