@tanstack/router-core 1.171.10 → 1.171.12
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/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +7 -0
- package/dist/cjs/router.cjs +19 -11
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/searchMiddleware.cjs +24 -20
- package/dist/cjs/searchMiddleware.cjs.map +1 -1
- package/dist/cjs/utils.cjs +1 -1
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +1 -0
- package/dist/esm/route.d.ts +7 -0
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.js +19 -11
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/searchMiddleware.js +25 -21
- package/dist/esm/searchMiddleware.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -0
- package/dist/esm/utils.js +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/route.ts +8 -0
- package/src/router.ts +23 -22
- package/src/searchMiddleware.ts +70 -39
- package/src/utils.ts +1 -1
package/dist/esm/router.js
CHANGED
|
@@ -1120,11 +1120,13 @@ function buildMiddlewareChain(destRoutes) {
|
|
|
1120
1120
|
}
|
|
1121
1121
|
const routeValidateSearch = routeOptions.validateSearch;
|
|
1122
1122
|
if (routeValidateSearch) {
|
|
1123
|
-
const validate = ({ search, next }
|
|
1123
|
+
const validate = ({ search, next, meta }) => {
|
|
1124
1124
|
const result = next(search);
|
|
1125
1125
|
if (includeValidateSearch) try {
|
|
1126
1126
|
const validated = validateSearch(routeValidateSearch, result);
|
|
1127
|
-
if (
|
|
1127
|
+
if (meta && validated) {
|
|
1128
|
+
for (const key in validated) if (!(key in result)) (meta.defaulted ||= /* @__PURE__ */ new Map()).set(key, validated[key]);
|
|
1129
|
+
}
|
|
1128
1130
|
return {
|
|
1129
1131
|
...result,
|
|
1130
1132
|
...validated
|
|
@@ -1135,23 +1137,29 @@ function buildMiddlewareChain(destRoutes) {
|
|
|
1135
1137
|
middlewares.push(validate);
|
|
1136
1138
|
}
|
|
1137
1139
|
}
|
|
1138
|
-
const applyNext = (index, currentSearch,
|
|
1140
|
+
const applyNext = (index, currentSearch, meta) => {
|
|
1139
1141
|
if (index >= middlewares.length) {
|
|
1140
1142
|
if (!dest.search) return {};
|
|
1141
1143
|
if (dest.search === true) return currentSearch;
|
|
1142
|
-
|
|
1144
|
+
const result = functionalUpdate(dest.search, currentSearch);
|
|
1145
|
+
if (meta) meta.explicit = result;
|
|
1146
|
+
return result;
|
|
1143
1147
|
}
|
|
1144
|
-
const next = (newSearch,
|
|
1145
|
-
if (
|
|
1146
|
-
const
|
|
1147
|
-
return
|
|
1148
|
+
const next = (newSearch, collectMeta) => {
|
|
1149
|
+
if (collectMeta) {
|
|
1150
|
+
const nextMeta = meta || {};
|
|
1151
|
+
return {
|
|
1152
|
+
search: applyNext(index + 1, newSearch, nextMeta),
|
|
1153
|
+
meta: nextMeta
|
|
1154
|
+
};
|
|
1148
1155
|
}
|
|
1149
|
-
return applyNext(index + 1, newSearch,
|
|
1156
|
+
return applyNext(index + 1, newSearch, meta);
|
|
1150
1157
|
};
|
|
1151
1158
|
return middlewares[index]({
|
|
1152
1159
|
search: currentSearch,
|
|
1153
|
-
next
|
|
1154
|
-
|
|
1160
|
+
next,
|
|
1161
|
+
meta
|
|
1162
|
+
});
|
|
1155
1163
|
};
|
|
1156
1164
|
return function middleware(search, nextDest, _includeValidateSearch) {
|
|
1157
1165
|
dest = nextDest;
|