@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
package/build/esm/index.js
CHANGED
|
@@ -966,42 +966,36 @@ class Router {
|
|
|
966
966
|
if (routeCursor) matchedRoutes.unshift(routeCursor);
|
|
967
967
|
}
|
|
968
968
|
|
|
969
|
-
// Alright, by now we should have all of our
|
|
970
|
-
// matching routes and their param pairs, let's
|
|
971
|
-
// Turn them into actual `Match` objects and
|
|
972
|
-
// accumulate the params into a single params bag
|
|
973
|
-
let allParams = {};
|
|
974
|
-
|
|
975
969
|
// Existing matches are matches that are already loaded along with
|
|
976
970
|
// pending matches that are still loading
|
|
977
971
|
|
|
978
|
-
const
|
|
979
|
-
let parsedParams;
|
|
972
|
+
const parseErrors = matchedRoutes.map(route => {
|
|
980
973
|
let parsedParamsError;
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
974
|
+
if (route.options.parseParams) {
|
|
975
|
+
try {
|
|
976
|
+
const parsedParams = route.options.parseParams(routeParams);
|
|
977
|
+
// Add the parsed params to the accumulated params bag
|
|
978
|
+
Object.assign(routeParams, parsedParams);
|
|
979
|
+
} catch (err) {
|
|
980
|
+
parsedParamsError = new PathParamError(err.message, {
|
|
981
|
+
cause: err
|
|
982
|
+
});
|
|
983
|
+
if (opts?.throwOnError) {
|
|
984
|
+
throw parsedParamsError;
|
|
985
|
+
}
|
|
986
|
+
return parsedParamsError;
|
|
993
987
|
}
|
|
994
988
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
const interpolatedPath = interpolatePath(route.path,
|
|
989
|
+
return;
|
|
990
|
+
});
|
|
991
|
+
const matches = matchedRoutes.map((route, index) => {
|
|
992
|
+
const interpolatedPath = interpolatePath(route.path, routeParams);
|
|
999
993
|
const key = route.options.key ? route.options.key({
|
|
1000
|
-
params:
|
|
994
|
+
params: routeParams,
|
|
1001
995
|
search: locationSearch
|
|
1002
996
|
}) ?? '' : '';
|
|
1003
997
|
const stringifiedKey = key ? JSON.stringify(key) : '';
|
|
1004
|
-
const matchId = interpolatePath(route.id,
|
|
998
|
+
const matchId = interpolatePath(route.id, routeParams, true) + stringifiedKey;
|
|
1005
999
|
|
|
1006
1000
|
// Waste not, want not. If we already have a match for this route,
|
|
1007
1001
|
// reuse it. This is important for layout routes, which might stick
|
|
@@ -1019,7 +1013,7 @@ class Router {
|
|
|
1019
1013
|
id: matchId,
|
|
1020
1014
|
key: stringifiedKey,
|
|
1021
1015
|
routeId: route.id,
|
|
1022
|
-
params:
|
|
1016
|
+
params: routeParams,
|
|
1023
1017
|
pathname: joinPaths([this.basepath, interpolatedPath]),
|
|
1024
1018
|
updatedAt: Date.now(),
|
|
1025
1019
|
invalidAt: Infinity,
|
|
@@ -1030,7 +1024,7 @@ class Router {
|
|
|
1030
1024
|
isFetching: false,
|
|
1031
1025
|
invalid: false,
|
|
1032
1026
|
error: undefined,
|
|
1033
|
-
paramsError:
|
|
1027
|
+
paramsError: parseErrors[index],
|
|
1034
1028
|
searchError: undefined,
|
|
1035
1029
|
loaderData: undefined,
|
|
1036
1030
|
loadPromise: Promise.resolve(),
|