@tanstack/router-core 0.0.1-beta.157 → 0.0.1-beta.158

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.157",
4
+ "version": "0.0.1-beta.158",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -43,7 +43,7 @@
43
43
  "tiny-invariant": "^1.3.1",
44
44
  "tiny-warning": "^1.0.3",
45
45
  "@gisatcz/cross-package-react-context": "^0.2.0",
46
- "@tanstack/react-store": "0.0.1-beta.157"
46
+ "@tanstack/react-store": "0.0.1-beta.158"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "rollup --config rollup.config.js",
package/src/router.ts CHANGED
@@ -641,43 +641,38 @@ export class Router<
641
641
  if (routeCursor) matchedRoutes.unshift(routeCursor)
642
642
  }
643
643
 
644
- // Alright, by now we should have all of our
645
- // matching routes and their param pairs, let's
646
- // Turn them into actual `Match` objects and
647
- // accumulate the params into a single params bag
648
- let allParams = {}
649
-
650
644
  // Existing matches are matches that are already loaded along with
651
645
  // pending matches that are still loading
652
646
 
653
- const matches = matchedRoutes.map((route) => {
654
- let parsedParams
647
+ const parseErrors = matchedRoutes.map((route) => {
655
648
  let parsedParamsError
656
649
 
657
- try {
658
- parsedParams =
659
- (route.options.parseParams as any)?.(routeParams!) ?? routeParams
660
- // (typeof route.options.parseParams === 'object' &&
661
- // route.options.parseParams.parse
662
- // ? route.options.parseParams.parse(routeParams)
663
- // : (route.options.parseParams as any)?.(routeParams!)) ?? routeParams
664
- } catch (err: any) {
665
- parsedParamsError = new PathParamError(err.message, {
666
- cause: err,
667
- })
650
+ if (route.options.parseParams) {
651
+ try {
652
+ const parsedParams = route.options.parseParams(routeParams)
653
+ // Add the parsed params to the accumulated params bag
654
+ Object.assign(routeParams, parsedParams)
655
+ } catch (err: any) {
656
+ parsedParamsError = new PathParamError(err.message, {
657
+ cause: err,
658
+ })
668
659
 
669
- if (opts?.throwOnError) {
670
- throw parsedParamsError
660
+ if (opts?.throwOnError) {
661
+ throw parsedParamsError
662
+ }
663
+
664
+ return parsedParamsError
671
665
  }
672
666
  }
673
667
 
674
- // Add the parsed params to the accumulated params bag
675
- Object.assign(allParams, parsedParams)
668
+ return
669
+ })
676
670
 
677
- const interpolatedPath = interpolatePath(route.path, allParams)
671
+ const matches = matchedRoutes.map((route, index) => {
672
+ const interpolatedPath = interpolatePath(route.path, routeParams)
678
673
  const key = route.options.key
679
674
  ? route.options.key({
680
- params: allParams,
675
+ params: routeParams,
681
676
  search: locationSearch,
682
677
  }) ?? ''
683
678
  : ''
@@ -685,7 +680,7 @@ export class Router<
685
680
  const stringifiedKey = key ? JSON.stringify(key) : ''
686
681
 
687
682
  const matchId =
688
- interpolatePath(route.id, allParams, true) + stringifiedKey
683
+ interpolatePath(route.id, routeParams, true) + stringifiedKey
689
684
 
690
685
  // Waste not, want not. If we already have a match for this route,
691
686
  // reuse it. This is important for layout routes, which might stick
@@ -706,7 +701,7 @@ export class Router<
706
701
  id: matchId,
707
702
  key: stringifiedKey,
708
703
  routeId: route.id,
709
- params: allParams,
704
+ params: routeParams,
710
705
  pathname: joinPaths([this.basepath, interpolatedPath]),
711
706
  updatedAt: Date.now(),
712
707
  invalidAt: Infinity,
@@ -717,7 +712,7 @@ export class Router<
717
712
  isFetching: false,
718
713
  invalid: false,
719
714
  error: undefined,
720
- paramsError: parsedParamsError,
715
+ paramsError: parseErrors[index],
721
716
  searchError: undefined,
722
717
  loaderData: undefined,
723
718
  loadPromise: Promise.resolve(),
@@ -1129,7 +1124,7 @@ export class Router<
1129
1124
  preload,
1130
1125
  preloadDelay: userPreloadDelay,
1131
1126
  disabled,
1132
- state
1127
+ state,
1133
1128
  }: LinkOptions<TRouteTree, TFrom, TTo>): LinkInfo => {
1134
1129
  // If this link simply reloads the current route,
1135
1130
  // make sure it has a new key so it will trigger a data refresh
@@ -1152,7 +1147,7 @@ export class Router<
1152
1147
  params,
1153
1148
  hash,
1154
1149
  replace,
1155
- state
1150
+ state,
1156
1151
  }
1157
1152
 
1158
1153
  const next = this.buildNext(nextOpts)