@tanstack/react-router 1.97.25 → 1.98.0
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/Match.cjs +18 -6
- package/dist/cjs/Match.cjs.map +1 -1
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +2 -0
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/lazyRouteComponent.cjs +17 -13
- package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +10 -2
- package/dist/cjs/router.cjs +23 -11
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +2 -1
- package/dist/esm/Match.js +18 -6
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.d.ts +2 -0
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/lazyRouteComponent.js +17 -13
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/esm/route.d.ts +10 -2
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +2 -1
- package/dist/esm/router.js +23 -11
- package/dist/esm/router.js.map +1 -1
- package/package.json +3 -3
- package/src/Match.tsx +22 -6
- package/src/Matches.tsx +2 -0
- package/src/index.tsx +2 -0
- package/src/lazyRouteComponent.tsx +34 -31
- package/src/route.ts +38 -1
- package/src/router.ts +32 -11
package/dist/esm/router.js
CHANGED
|
@@ -327,7 +327,7 @@ class Router {
|
|
|
327
327
|
path: route.fullPath,
|
|
328
328
|
params: (matchedRoutesResult == null ? void 0 : matchedRoutesResult.routeParams) ?? {},
|
|
329
329
|
decodeCharMap: this.pathParamsDecodeCharMap
|
|
330
|
-
});
|
|
330
|
+
}).interpolatedPath;
|
|
331
331
|
const pathname2 = joinPaths([this.basepath, interpolatedPath]);
|
|
332
332
|
return pathname2 === fromPath;
|
|
333
333
|
})) == null ? void 0 : _d.id];
|
|
@@ -355,7 +355,7 @@ class Router {
|
|
|
355
355
|
leaveWildcards: false,
|
|
356
356
|
leaveParams: opts.leaveParams,
|
|
357
357
|
decodeCharMap: this.pathParamsDecodeCharMap
|
|
358
|
-
});
|
|
358
|
+
}).interpolatedPath;
|
|
359
359
|
let search = fromSearch;
|
|
360
360
|
if (opts._includeValidateSearch && ((_f = this.options.search) == null ? void 0 : _f.strict)) {
|
|
361
361
|
let validatedSearch = {};
|
|
@@ -814,7 +814,7 @@ class Router {
|
|
|
814
814
|
triggerOnReady();
|
|
815
815
|
}
|
|
816
816
|
const handleRedirectAndNotFound = (match, err) => {
|
|
817
|
-
var _a, _b, _c;
|
|
817
|
+
var _a, _b, _c, _d;
|
|
818
818
|
if (isResolvedRedirect(err)) {
|
|
819
819
|
if (!err.reloadDocument) {
|
|
820
820
|
throw err;
|
|
@@ -843,6 +843,10 @@ class Router {
|
|
|
843
843
|
this._handleNotFound(matches, err, {
|
|
844
844
|
updateMatch
|
|
845
845
|
});
|
|
846
|
+
(_d = this.serverSsr) == null ? void 0 : _d.onMatchSettled({
|
|
847
|
+
router: this,
|
|
848
|
+
match: this.getMatch(match.id)
|
|
849
|
+
});
|
|
846
850
|
throw err;
|
|
847
851
|
}
|
|
848
852
|
}
|
|
@@ -1312,7 +1316,9 @@ class Router {
|
|
|
1312
1316
|
_fromLocation: next
|
|
1313
1317
|
});
|
|
1314
1318
|
}
|
|
1315
|
-
|
|
1319
|
+
if (!isNotFound(err)) {
|
|
1320
|
+
console.error(err);
|
|
1321
|
+
}
|
|
1316
1322
|
return void 0;
|
|
1317
1323
|
}
|
|
1318
1324
|
};
|
|
@@ -1479,15 +1485,17 @@ class Router {
|
|
|
1479
1485
|
matchedRoutes.forEach((route, index) => {
|
|
1480
1486
|
var _a, _b, _c, _d;
|
|
1481
1487
|
const parentMatch = matches[index - 1];
|
|
1482
|
-
const [preMatchSearch, searchError] = (() => {
|
|
1488
|
+
const [preMatchSearch, strictMatchSearch, searchError] = (() => {
|
|
1483
1489
|
const parentSearch = (parentMatch == null ? void 0 : parentMatch.search) ?? next.search;
|
|
1490
|
+
const parentStrictSearch = (parentMatch == null ? void 0 : parentMatch._strictSearch) ?? {};
|
|
1484
1491
|
try {
|
|
1485
|
-
const
|
|
1492
|
+
const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? {};
|
|
1486
1493
|
return [
|
|
1487
1494
|
{
|
|
1488
1495
|
...parentSearch,
|
|
1489
|
-
...
|
|
1496
|
+
...strictSearch
|
|
1490
1497
|
},
|
|
1498
|
+
{ ...parentStrictSearch, ...strictSearch },
|
|
1491
1499
|
void 0
|
|
1492
1500
|
];
|
|
1493
1501
|
} catch (err) {
|
|
@@ -1500,14 +1508,14 @@ class Router {
|
|
|
1500
1508
|
if (opts == null ? void 0 : opts.throwOnError) {
|
|
1501
1509
|
throw searchParamError;
|
|
1502
1510
|
}
|
|
1503
|
-
return [parentSearch, searchParamError];
|
|
1511
|
+
return [parentSearch, {}, searchParamError];
|
|
1504
1512
|
}
|
|
1505
1513
|
})();
|
|
1506
1514
|
const loaderDeps = ((_b = (_a = route.options).loaderDeps) == null ? void 0 : _b.call(_a, {
|
|
1507
1515
|
search: preMatchSearch
|
|
1508
1516
|
})) ?? "";
|
|
1509
1517
|
const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : "";
|
|
1510
|
-
const interpolatedPath = interpolatePath({
|
|
1518
|
+
const { usedParams, interpolatedPath } = interpolatePath({
|
|
1511
1519
|
path: route.fullPath,
|
|
1512
1520
|
params: routeParams,
|
|
1513
1521
|
decodeCharMap: this.pathParamsDecodeCharMap
|
|
@@ -1517,7 +1525,7 @@ class Router {
|
|
|
1517
1525
|
params: routeParams,
|
|
1518
1526
|
leaveWildcards: true,
|
|
1519
1527
|
decodeCharMap: this.pathParamsDecodeCharMap
|
|
1520
|
-
}) + loaderDepsHash;
|
|
1528
|
+
}).interpolatedPath + loaderDepsHash;
|
|
1521
1529
|
const existingMatch = this.getMatch(matchId);
|
|
1522
1530
|
const previousMatch = this.state.matches.find(
|
|
1523
1531
|
(d) => d.routeId === route.id
|
|
@@ -1529,7 +1537,9 @@ class Router {
|
|
|
1529
1537
|
...existingMatch,
|
|
1530
1538
|
cause,
|
|
1531
1539
|
params: previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
|
|
1532
|
-
|
|
1540
|
+
_strictParams: usedParams,
|
|
1541
|
+
search: previousMatch ? replaceEqualDeep(previousMatch.search, preMatchSearch) : replaceEqualDeep(existingMatch.search, preMatchSearch),
|
|
1542
|
+
_strictSearch: strictMatchSearch
|
|
1533
1543
|
};
|
|
1534
1544
|
} else {
|
|
1535
1545
|
const status = route.options.loader || route.options.beforeLoad || route.lazyFn || routeNeedsPreload(route) ? "pending" : "success";
|
|
@@ -1538,9 +1548,11 @@ class Router {
|
|
|
1538
1548
|
index,
|
|
1539
1549
|
routeId: route.id,
|
|
1540
1550
|
params: previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
|
|
1551
|
+
_strictParams: usedParams,
|
|
1541
1552
|
pathname: joinPaths([this.basepath, interpolatedPath]),
|
|
1542
1553
|
updatedAt: Date.now(),
|
|
1543
1554
|
search: previousMatch ? replaceEqualDeep(previousMatch.search, preMatchSearch) : preMatchSearch,
|
|
1555
|
+
_strictSearch: strictMatchSearch,
|
|
1544
1556
|
searchError: void 0,
|
|
1545
1557
|
status,
|
|
1546
1558
|
isFetching: false,
|