@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/build/cjs/router.js +22 -28
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +22 -28
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +116 -116
- package/build/types/index.d.ts +1 -1
- package/build/umd/index.development.js +22 -28
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/router.ts +25 -30
|
@@ -1061,42 +1061,36 @@
|
|
|
1061
1061
|
if (routeCursor) matchedRoutes.unshift(routeCursor);
|
|
1062
1062
|
}
|
|
1063
1063
|
|
|
1064
|
-
// Alright, by now we should have all of our
|
|
1065
|
-
// matching routes and their param pairs, let's
|
|
1066
|
-
// Turn them into actual `Match` objects and
|
|
1067
|
-
// accumulate the params into a single params bag
|
|
1068
|
-
let allParams = {};
|
|
1069
|
-
|
|
1070
1064
|
// Existing matches are matches that are already loaded along with
|
|
1071
1065
|
// pending matches that are still loading
|
|
1072
1066
|
|
|
1073
|
-
const
|
|
1074
|
-
let parsedParams;
|
|
1067
|
+
const parseErrors = matchedRoutes.map(route => {
|
|
1075
1068
|
let parsedParamsError;
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1069
|
+
if (route.options.parseParams) {
|
|
1070
|
+
try {
|
|
1071
|
+
const parsedParams = route.options.parseParams(routeParams);
|
|
1072
|
+
// Add the parsed params to the accumulated params bag
|
|
1073
|
+
Object.assign(routeParams, parsedParams);
|
|
1074
|
+
} catch (err) {
|
|
1075
|
+
parsedParamsError = new PathParamError(err.message, {
|
|
1076
|
+
cause: err
|
|
1077
|
+
});
|
|
1078
|
+
if (opts?.throwOnError) {
|
|
1079
|
+
throw parsedParamsError;
|
|
1080
|
+
}
|
|
1081
|
+
return parsedParamsError;
|
|
1088
1082
|
}
|
|
1089
1083
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
const interpolatedPath = interpolatePath(route.path,
|
|
1084
|
+
return;
|
|
1085
|
+
});
|
|
1086
|
+
const matches = matchedRoutes.map((route, index) => {
|
|
1087
|
+
const interpolatedPath = interpolatePath(route.path, routeParams);
|
|
1094
1088
|
const key = route.options.key ? route.options.key({
|
|
1095
|
-
params:
|
|
1089
|
+
params: routeParams,
|
|
1096
1090
|
search: locationSearch
|
|
1097
1091
|
}) ?? '' : '';
|
|
1098
1092
|
const stringifiedKey = key ? JSON.stringify(key) : '';
|
|
1099
|
-
const matchId = interpolatePath(route.id,
|
|
1093
|
+
const matchId = interpolatePath(route.id, routeParams, true) + stringifiedKey;
|
|
1100
1094
|
|
|
1101
1095
|
// Waste not, want not. If we already have a match for this route,
|
|
1102
1096
|
// reuse it. This is important for layout routes, which might stick
|
|
@@ -1114,7 +1108,7 @@
|
|
|
1114
1108
|
id: matchId,
|
|
1115
1109
|
key: stringifiedKey,
|
|
1116
1110
|
routeId: route.id,
|
|
1117
|
-
params:
|
|
1111
|
+
params: routeParams,
|
|
1118
1112
|
pathname: joinPaths([this.basepath, interpolatedPath]),
|
|
1119
1113
|
updatedAt: Date.now(),
|
|
1120
1114
|
invalidAt: Infinity,
|
|
@@ -1125,7 +1119,7 @@
|
|
|
1125
1119
|
isFetching: false,
|
|
1126
1120
|
invalid: false,
|
|
1127
1121
|
error: undefined,
|
|
1128
|
-
paramsError:
|
|
1122
|
+
paramsError: parseErrors[index],
|
|
1129
1123
|
searchError: undefined,
|
|
1130
1124
|
loaderData: undefined,
|
|
1131
1125
|
loadPromise: Promise.resolve(),
|