@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
- "version": "1.132.0-alpha.19",
3
+ "version": "1.132.0-alpha.20",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
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
- const strictParams = interpolatePathResult.usedParams
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
- let paramsError = parseErrors[index]
1301
+ const previousMatch = this.state.matches.find(
1302
+ (d) => d.routeId === route.id,
1303
+ )
1321
1304
 
1322
- const strictParseParams =
1323
- route.options.params?.parse ?? route.options.parseParams
1305
+ const strictParams =
1306
+ existingMatch?._strictParams ?? interpolatePathResult.usedParams
1324
1307
 
1325
- if (strictParseParams) {
1326
- try {
1327
- Object.assign(strictParams, strictParseParams(strictParams as any))
1328
- } catch (err: any) {
1329
- // any param errors should already have been dealt with above, if this
1330
- // somehow differs, let's report this in the same manner
1331
- if (!paramsError) {
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
- // Waste not, want not. If we already have a match for this route,
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: paramsError,
1378
+ paramsError,
1402
1379
  __routeContext: undefined,
1403
1380
  _nonReactive: {
1404
1381
  loadPromise: createControlledPromise(),