@tanstack/router-core 1.131.36 → 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 +29 -27
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +29 -27
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +42 -39
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) => {
|
|
@@ -1210,20 +1183,19 @@ export class RouterCore<
|
|
|
1210
1183
|
|
|
1211
1184
|
const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : ''
|
|
1212
1185
|
|
|
1213
|
-
const {
|
|
1186
|
+
const { interpolatedPath } = interpolatePath({
|
|
1214
1187
|
path: route.fullPath,
|
|
1215
1188
|
params: routeParams,
|
|
1216
1189
|
decodeCharMap: this.pathParamsDecodeCharMap,
|
|
1217
1190
|
})
|
|
1218
1191
|
|
|
1219
|
-
const
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
}).interpolatedPath + loaderDepsHash
|
|
1192
|
+
const interpolatePathResult = interpolatePath({
|
|
1193
|
+
path: route.id,
|
|
1194
|
+
params: routeParams,
|
|
1195
|
+
leaveWildcards: true,
|
|
1196
|
+
decodeCharMap: this.pathParamsDecodeCharMap,
|
|
1197
|
+
parseCache: this.parsePathnameCache,
|
|
1198
|
+
})
|
|
1227
1199
|
|
|
1228
1200
|
// Waste not, want not. If we already have a match for this route,
|
|
1229
1201
|
// reuse it. This is important for layout routes, which might stick
|
|
@@ -1231,12 +1203,43 @@ export class RouterCore<
|
|
|
1231
1203
|
|
|
1232
1204
|
// Existing matches are matches that are already loaded along with
|
|
1233
1205
|
// pending matches that are still loading
|
|
1206
|
+
const matchId = interpolatePathResult.interpolatedPath + loaderDepsHash
|
|
1207
|
+
|
|
1234
1208
|
const existingMatch = this.getMatch(matchId)
|
|
1235
1209
|
|
|
1236
1210
|
const previousMatch = this.state.matches.find(
|
|
1237
1211
|
(d) => d.routeId === route.id,
|
|
1238
1212
|
)
|
|
1239
1213
|
|
|
1214
|
+
const strictParams =
|
|
1215
|
+
existingMatch?._strictParams ?? interpolatePathResult.usedParams
|
|
1216
|
+
|
|
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) {
|
|
1230
|
+
paramsError = new PathParamError(err.message, {
|
|
1231
|
+
cause: err,
|
|
1232
|
+
})
|
|
1233
|
+
|
|
1234
|
+
if (opts?.throwOnError) {
|
|
1235
|
+
throw paramsError
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
Object.assign(routeParams, strictParams)
|
|
1242
|
+
|
|
1240
1243
|
const cause = previousMatch ? 'stay' : 'enter'
|
|
1241
1244
|
|
|
1242
1245
|
let match: AnyRouteMatch
|
|
@@ -1248,7 +1251,7 @@ export class RouterCore<
|
|
|
1248
1251
|
params: previousMatch
|
|
1249
1252
|
? replaceEqualDeep(previousMatch.params, routeParams)
|
|
1250
1253
|
: routeParams,
|
|
1251
|
-
_strictParams:
|
|
1254
|
+
_strictParams: strictParams,
|
|
1252
1255
|
search: previousMatch
|
|
1253
1256
|
? replaceEqualDeep(previousMatch.search, preMatchSearch)
|
|
1254
1257
|
: replaceEqualDeep(existingMatch.search, preMatchSearch),
|
|
@@ -1270,7 +1273,7 @@ export class RouterCore<
|
|
|
1270
1273
|
params: previousMatch
|
|
1271
1274
|
? replaceEqualDeep(previousMatch.params, routeParams)
|
|
1272
1275
|
: routeParams,
|
|
1273
|
-
_strictParams:
|
|
1276
|
+
_strictParams: strictParams,
|
|
1274
1277
|
pathname: joinPaths([this.basepath, interpolatedPath]),
|
|
1275
1278
|
updatedAt: Date.now(),
|
|
1276
1279
|
search: previousMatch
|
|
@@ -1281,7 +1284,7 @@ export class RouterCore<
|
|
|
1281
1284
|
status,
|
|
1282
1285
|
isFetching: false,
|
|
1283
1286
|
error: undefined,
|
|
1284
|
-
paramsError
|
|
1287
|
+
paramsError,
|
|
1285
1288
|
__routeContext: undefined,
|
|
1286
1289
|
_nonReactive: {
|
|
1287
1290
|
loadPromise: createControlledPromise(),
|