@tanstack/router-core 1.131.37 → 1.131.38
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 +17 -33
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +17 -33
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +28 -51
package/src/router.ts
CHANGED
|
@@ -1111,33 +1111,6 @@ export class RouterCore<
|
|
|
1111
1111
|
return rootRouteId
|
|
1112
1112
|
})()
|
|
1113
1113
|
|
|
1114
|
-
const parseErrors = matchedRoutes.map((route) => {
|
|
1115
|
-
let parsedParamsError
|
|
1116
|
-
|
|
1117
|
-
const parseParams =
|
|
1118
|
-
route.options.params?.parse ?? route.options.parseParams
|
|
1119
|
-
|
|
1120
|
-
if (parseParams) {
|
|
1121
|
-
try {
|
|
1122
|
-
const parsedParams = parseParams(routeParams)
|
|
1123
|
-
// Add the parsed params to the accumulated params bag
|
|
1124
|
-
Object.assign(routeParams, parsedParams)
|
|
1125
|
-
} catch (err: any) {
|
|
1126
|
-
parsedParamsError = new PathParamError(err.message, {
|
|
1127
|
-
cause: err,
|
|
1128
|
-
})
|
|
1129
|
-
|
|
1130
|
-
if (opts?.throwOnError) {
|
|
1131
|
-
throw parsedParamsError
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
return parsedParamsError
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
return
|
|
1139
|
-
})
|
|
1140
|
-
|
|
1141
1114
|
const matches: Array<AnyRouteMatch> = []
|
|
1142
1115
|
|
|
1143
1116
|
const getParentContext = (parentMatch?: AnyRouteMatch) => {
|
|
@@ -1224,20 +1197,36 @@ export class RouterCore<
|
|
|
1224
1197
|
parseCache: this.parsePathnameCache,
|
|
1225
1198
|
})
|
|
1226
1199
|
|
|
1227
|
-
|
|
1200
|
+
// Waste not, want not. If we already have a match for this route,
|
|
1201
|
+
// reuse it. This is important for layout routes, which might stick
|
|
1202
|
+
// around between navigation actions that only change leaf routes.
|
|
1203
|
+
|
|
1204
|
+
// Existing matches are matches that are already loaded along with
|
|
1205
|
+
// pending matches that are still loading
|
|
1206
|
+
const matchId = interpolatePathResult.interpolatedPath + loaderDepsHash
|
|
1207
|
+
|
|
1208
|
+
const existingMatch = this.getMatch(matchId)
|
|
1228
1209
|
|
|
1229
|
-
|
|
1210
|
+
const previousMatch = this.state.matches.find(
|
|
1211
|
+
(d) => d.routeId === route.id,
|
|
1212
|
+
)
|
|
1230
1213
|
|
|
1231
|
-
const
|
|
1232
|
-
|
|
1214
|
+
const strictParams =
|
|
1215
|
+
existingMatch?._strictParams ?? interpolatePathResult.usedParams
|
|
1233
1216
|
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1217
|
+
let paramsError: PathParamError | undefined = undefined
|
|
1218
|
+
|
|
1219
|
+
if (!existingMatch) {
|
|
1220
|
+
const strictParseParams =
|
|
1221
|
+
route.options.params?.parse ?? route.options.parseParams
|
|
1222
|
+
|
|
1223
|
+
if (strictParseParams) {
|
|
1224
|
+
try {
|
|
1225
|
+
Object.assign(
|
|
1226
|
+
strictParams,
|
|
1227
|
+
strictParseParams(strictParams as Record<string, string>),
|
|
1228
|
+
)
|
|
1229
|
+
} catch (err: any) {
|
|
1241
1230
|
paramsError = new PathParamError(err.message, {
|
|
1242
1231
|
cause: err,
|
|
1243
1232
|
})
|
|
@@ -1249,19 +1238,7 @@ export class RouterCore<
|
|
|
1249
1238
|
}
|
|
1250
1239
|
}
|
|
1251
1240
|
|
|
1252
|
-
|
|
1253
|
-
// reuse it. This is important for layout routes, which might stick
|
|
1254
|
-
// around between navigation actions that only change leaf routes.
|
|
1255
|
-
|
|
1256
|
-
// Existing matches are matches that are already loaded along with
|
|
1257
|
-
// pending matches that are still loading
|
|
1258
|
-
const matchId = interpolatePathResult.interpolatedPath + loaderDepsHash
|
|
1259
|
-
|
|
1260
|
-
const existingMatch = this.getMatch(matchId)
|
|
1261
|
-
|
|
1262
|
-
const previousMatch = this.state.matches.find(
|
|
1263
|
-
(d) => d.routeId === route.id,
|
|
1264
|
-
)
|
|
1241
|
+
Object.assign(routeParams, strictParams)
|
|
1265
1242
|
|
|
1266
1243
|
const cause = previousMatch ? 'stay' : 'enter'
|
|
1267
1244
|
|