@tanstack/router-core 1.132.0-alpha.19 → 1.132.0-alpha.20
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 -32
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/router.js +17 -32
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +29 -52
package/package.json
CHANGED
package/src/router.ts
CHANGED
|
@@ -1202,33 +1202,6 @@ export class RouterCore<
|
|
|
1202
1202
|
return rootRouteId
|
|
1203
1203
|
})()
|
|
1204
1204
|
|
|
1205
|
-
const parseErrors = matchedRoutes.map((route) => {
|
|
1206
|
-
let parsedParamsError
|
|
1207
|
-
|
|
1208
|
-
const parseParams =
|
|
1209
|
-
route.options.params?.parse ?? route.options.parseParams
|
|
1210
|
-
|
|
1211
|
-
if (parseParams) {
|
|
1212
|
-
try {
|
|
1213
|
-
const parsedParams = parseParams(routeParams)
|
|
1214
|
-
// Add the parsed params to the accumulated params bag
|
|
1215
|
-
Object.assign(routeParams, parsedParams)
|
|
1216
|
-
} catch (err: any) {
|
|
1217
|
-
parsedParamsError = new PathParamError(err.message, {
|
|
1218
|
-
cause: err,
|
|
1219
|
-
})
|
|
1220
|
-
|
|
1221
|
-
if (opts?.throwOnError) {
|
|
1222
|
-
throw parsedParamsError
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
return parsedParamsError
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
|
|
1229
|
-
return
|
|
1230
|
-
})
|
|
1231
|
-
|
|
1232
1205
|
const matches: Array<AnyRouteMatch> = []
|
|
1233
1206
|
|
|
1234
1207
|
const getParentContext = (parentMatch?: AnyRouteMatch) => {
|
|
@@ -1315,20 +1288,36 @@ export class RouterCore<
|
|
|
1315
1288
|
parseCache: this.parsePathnameCache,
|
|
1316
1289
|
})
|
|
1317
1290
|
|
|
1318
|
-
|
|
1291
|
+
// Waste not, want not. If we already have a match for this route,
|
|
1292
|
+
// reuse it. This is important for layout routes, which might stick
|
|
1293
|
+
// around between navigation actions that only change leaf routes.
|
|
1294
|
+
|
|
1295
|
+
// Existing matches are matches that are already loaded along with
|
|
1296
|
+
// pending matches that are still loading
|
|
1297
|
+
const matchId = interpolatePathResult.interpolatedPath + loaderDepsHash
|
|
1298
|
+
|
|
1299
|
+
const existingMatch = this.getMatch(matchId)
|
|
1319
1300
|
|
|
1320
|
-
|
|
1301
|
+
const previousMatch = this.state.matches.find(
|
|
1302
|
+
(d) => d.routeId === route.id,
|
|
1303
|
+
)
|
|
1321
1304
|
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1305
|
+
const strictParams =
|
|
1306
|
+
existingMatch?._strictParams ?? interpolatePathResult.usedParams
|
|
1324
1307
|
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1308
|
+
let paramsError: PathParamError | undefined = undefined
|
|
1309
|
+
|
|
1310
|
+
if (!existingMatch) {
|
|
1311
|
+
const strictParseParams =
|
|
1312
|
+
route.options.params?.parse ?? route.options.parseParams
|
|
1313
|
+
|
|
1314
|
+
if (strictParseParams) {
|
|
1315
|
+
try {
|
|
1316
|
+
Object.assign(
|
|
1317
|
+
strictParams,
|
|
1318
|
+
strictParseParams(strictParams as Record<string, string>),
|
|
1319
|
+
)
|
|
1320
|
+
} catch (err: any) {
|
|
1332
1321
|
paramsError = new PathParamError(err.message, {
|
|
1333
1322
|
cause: err,
|
|
1334
1323
|
})
|
|
@@ -1340,19 +1329,7 @@ export class RouterCore<
|
|
|
1340
1329
|
}
|
|
1341
1330
|
}
|
|
1342
1331
|
|
|
1343
|
-
|
|
1344
|
-
// reuse it. This is important for layout routes, which might stick
|
|
1345
|
-
// around between navigation actions that only change leaf routes.
|
|
1346
|
-
|
|
1347
|
-
// Existing matches are matches that are already loaded along with
|
|
1348
|
-
// pending matches that are still loading
|
|
1349
|
-
const matchId = interpolatePathResult.interpolatedPath + loaderDepsHash
|
|
1350
|
-
|
|
1351
|
-
const existingMatch = this.getMatch(matchId)
|
|
1352
|
-
|
|
1353
|
-
const previousMatch = this.state.matches.find(
|
|
1354
|
-
(d) => d.routeId === route.id,
|
|
1355
|
-
)
|
|
1332
|
+
Object.assign(routeParams, strictParams)
|
|
1356
1333
|
|
|
1357
1334
|
const cause = previousMatch ? 'stay' : 'enter'
|
|
1358
1335
|
|
|
@@ -1398,7 +1375,7 @@ export class RouterCore<
|
|
|
1398
1375
|
status,
|
|
1399
1376
|
isFetching: false,
|
|
1400
1377
|
error: undefined,
|
|
1401
|
-
paramsError
|
|
1378
|
+
paramsError,
|
|
1402
1379
|
__routeContext: undefined,
|
|
1403
1380
|
_nonReactive: {
|
|
1404
1381
|
loadPromise: createControlledPromise(),
|