@tanstack/react-router 0.0.1-alpha.3 → 0.0.1-alpha.5
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/react-router/src/index.js +6 -18
- package/build/cjs/react-router/src/index.js.map +1 -1
- package/build/cjs/router-core/build/esm/index.js +143 -98
- package/build/cjs/router-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +148 -117
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +29 -29
- package/build/umd/index.development.js +143 -114
- 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/index.tsx +30 -33
package/build/esm/index.js
CHANGED
|
@@ -880,6 +880,20 @@ function parsePath(path) {
|
|
|
880
880
|
return parsedPath;
|
|
881
881
|
}
|
|
882
882
|
|
|
883
|
+
var isProduction = process.env.NODE_ENV === 'production';
|
|
884
|
+
var prefix = 'Invariant failed';
|
|
885
|
+
function invariant(condition, message) {
|
|
886
|
+
if (condition) {
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
if (isProduction) {
|
|
890
|
+
throw new Error(prefix);
|
|
891
|
+
}
|
|
892
|
+
var provided = typeof message === 'function' ? message() : message;
|
|
893
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
894
|
+
throw new Error(value);
|
|
895
|
+
}
|
|
896
|
+
|
|
883
897
|
// @ts-nocheck
|
|
884
898
|
// We're inlining qss here for compression's sake, but we've included it as a hard dependency for the MIT license it requires.
|
|
885
899
|
function encode(obj, pfx) {
|
|
@@ -933,7 +947,7 @@ function decode(str) {
|
|
|
933
947
|
return out;
|
|
934
948
|
}
|
|
935
949
|
|
|
936
|
-
const createRouteConfig = function createRouteConfig(options, children, isRoot, parentId) {
|
|
950
|
+
const createRouteConfig = function createRouteConfig(options, children, isRoot, parentId, parentPath) {
|
|
937
951
|
if (options === void 0) {
|
|
938
952
|
options = {};
|
|
939
953
|
}
|
|
@@ -944,8 +958,6 @@ const createRouteConfig = function createRouteConfig(options, children, isRoot,
|
|
|
944
958
|
|
|
945
959
|
if (isRoot) {
|
|
946
960
|
options.path = rootRouteId;
|
|
947
|
-
} else {
|
|
948
|
-
warning(!options.path, 'Routes must have a path property.');
|
|
949
961
|
} // Strip the root from parentIds
|
|
950
962
|
|
|
951
963
|
|
|
@@ -953,13 +965,14 @@ const createRouteConfig = function createRouteConfig(options, children, isRoot,
|
|
|
953
965
|
parentId = '';
|
|
954
966
|
}
|
|
955
967
|
|
|
956
|
-
let path =
|
|
968
|
+
let path = isRoot ? rootRouteId : options.path; // If the path is anything other than an index path, trim it up
|
|
957
969
|
|
|
958
|
-
if (path !== '/') {
|
|
970
|
+
if (path && path !== '/') {
|
|
959
971
|
path = trimPath(path);
|
|
960
972
|
}
|
|
961
973
|
|
|
962
|
-
|
|
974
|
+
const routeId = path || options.id;
|
|
975
|
+
let id = joinPaths([parentId, routeId]);
|
|
963
976
|
|
|
964
977
|
if (path === rootRouteId) {
|
|
965
978
|
path = '/';
|
|
@@ -969,14 +982,15 @@ const createRouteConfig = function createRouteConfig(options, children, isRoot,
|
|
|
969
982
|
id = joinPaths(['/', id]);
|
|
970
983
|
}
|
|
971
984
|
|
|
972
|
-
const fullPath = id === rootRouteId ? '/' : trimPathRight(
|
|
985
|
+
const fullPath = id === rootRouteId ? '/' : trimPathRight(joinPaths([parentPath, path]));
|
|
973
986
|
return {
|
|
974
987
|
id: id,
|
|
988
|
+
routeId: routeId,
|
|
975
989
|
path: path,
|
|
976
990
|
fullPath: fullPath,
|
|
977
991
|
options: options,
|
|
978
992
|
children,
|
|
979
|
-
addChildren: cb => createRouteConfig(options, cb(childOptions => createRouteConfig(childOptions, undefined, false, id)), false, parentId)
|
|
993
|
+
addChildren: cb => createRouteConfig(options, cb(childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath)), false, parentId, parentPath)
|
|
980
994
|
};
|
|
981
995
|
};
|
|
982
996
|
const rootRouteId = '__root__';
|
|
@@ -999,6 +1013,7 @@ function createRouter(userOptions) {
|
|
|
999
1013
|
let router = {
|
|
1000
1014
|
options: originalOptions,
|
|
1001
1015
|
listeners: [],
|
|
1016
|
+
removeActionQueue: [],
|
|
1002
1017
|
// Resolved after construction
|
|
1003
1018
|
basepath: '',
|
|
1004
1019
|
routeTree: undefined,
|
|
@@ -1122,12 +1137,14 @@ function createRouter(userOptions) {
|
|
|
1122
1137
|
strictParseParams: true
|
|
1123
1138
|
});
|
|
1124
1139
|
const toMatches = router.matchRoutes(pathname);
|
|
1125
|
-
|
|
1140
|
+
|
|
1141
|
+
const prevParams = _extends$1({}, (_last = last(fromMatches)) == null ? void 0 : _last.params);
|
|
1142
|
+
|
|
1126
1143
|
let nextParams = ((_dest$params = dest.params) != null ? _dest$params : true) === true ? prevParams : functionalUpdate(dest.params, prevParams);
|
|
1127
1144
|
|
|
1128
1145
|
if (nextParams) {
|
|
1129
1146
|
toMatches.map(d => d.options.stringifyParams).filter(Boolean).forEach(fn => {
|
|
1130
|
-
Object.assign(nextParams, fn(nextParams));
|
|
1147
|
+
Object.assign({}, nextParams, fn(nextParams));
|
|
1131
1148
|
});
|
|
1132
1149
|
}
|
|
1133
1150
|
|
|
@@ -1230,22 +1247,33 @@ function createRouter(userOptions) {
|
|
|
1230
1247
|
router.startedLoadingAt = id;
|
|
1231
1248
|
|
|
1232
1249
|
if (next) {
|
|
1250
|
+
// If the location.href has changed
|
|
1233
1251
|
// Ingest the new location
|
|
1234
1252
|
router.location = next;
|
|
1235
|
-
} //
|
|
1253
|
+
} // Clear out old actions
|
|
1236
1254
|
|
|
1237
1255
|
|
|
1256
|
+
router.removeActionQueue.forEach(_ref => {
|
|
1257
|
+
let {
|
|
1258
|
+
action,
|
|
1259
|
+
actionState
|
|
1260
|
+
} = _ref;
|
|
1261
|
+
|
|
1262
|
+
if (router.state.currentAction === actionState) {
|
|
1263
|
+
router.state.currentAction = undefined;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
if (action.current === actionState) {
|
|
1267
|
+
action.current = undefined;
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
router.removeActionQueue = []; // Cancel any pending matches
|
|
1271
|
+
|
|
1238
1272
|
router.cancelMatches(); // Match the routes
|
|
1239
1273
|
|
|
1240
1274
|
const unloadedMatches = router.matchRoutes(location.pathname, {
|
|
1241
1275
|
strictParseParams: true
|
|
1242
1276
|
});
|
|
1243
|
-
unloadedMatches.forEach((match, index) => {
|
|
1244
|
-
const parent = unloadedMatches[index - 1];
|
|
1245
|
-
const child = unloadedMatches[index + 1];
|
|
1246
|
-
if (parent) match.__.setParentMatch(parent);
|
|
1247
|
-
if (child) match.__.addChildMatch(child);
|
|
1248
|
-
});
|
|
1249
1277
|
router.state = _extends$1({}, router.state, {
|
|
1250
1278
|
pending: {
|
|
1251
1279
|
matches: unloadedMatches,
|
|
@@ -1352,59 +1380,81 @@ function createRouter(userOptions) {
|
|
|
1352
1380
|
|
|
1353
1381
|
const existingMatches = [...router.state.matches, ...((_router$state$pending3 = (_router$state$pending4 = router.state.pending) == null ? void 0 : _router$state$pending4.matches) != null ? _router$state$pending3 : [])];
|
|
1354
1382
|
|
|
1355
|
-
const recurse = async
|
|
1356
|
-
var _parentMatch$params, _router$options$filte,
|
|
1383
|
+
const recurse = async routes => {
|
|
1384
|
+
var _parentMatch$params, _router$options$filte, _foundRoute$childRout;
|
|
1357
1385
|
|
|
1386
|
+
const parentMatch = last(matches);
|
|
1358
1387
|
let params = (_parentMatch$params = parentMatch == null ? void 0 : parentMatch.params) != null ? _parentMatch$params : {};
|
|
1359
1388
|
const filteredRoutes = (_router$options$filte = router.options.filterRoutes == null ? void 0 : router.options.filterRoutes(routes)) != null ? _router$options$filte : routes;
|
|
1360
|
-
|
|
1361
|
-
var _route$childRoutes, _route$options$caseSe;
|
|
1362
|
-
|
|
1363
|
-
const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes = route.childRoutes) != null && _route$childRoutes.length);
|
|
1364
|
-
const matchParams = matchPathname(pathname, {
|
|
1365
|
-
to: route.fullPath,
|
|
1366
|
-
fuzzy,
|
|
1367
|
-
caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
|
|
1368
|
-
});
|
|
1389
|
+
let foundRoutes = [];
|
|
1369
1390
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1391
|
+
const findMatchInRoutes = (parentRoutes, routes) => {
|
|
1392
|
+
routes.some(route => {
|
|
1393
|
+
var _route$childRoutes, _route$childRoutes2, _route$options$caseSe;
|
|
1372
1394
|
|
|
1373
|
-
|
|
1374
|
-
|
|
1395
|
+
if (!route.routePath && (_route$childRoutes = route.childRoutes) != null && _route$childRoutes.length) {
|
|
1396
|
+
return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
|
|
1397
|
+
}
|
|
1375
1398
|
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1399
|
+
const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length);
|
|
1400
|
+
const matchParams = matchPathname(pathname, {
|
|
1401
|
+
to: route.fullPath,
|
|
1402
|
+
fuzzy,
|
|
1403
|
+
caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
|
|
1404
|
+
});
|
|
1405
|
+
|
|
1406
|
+
if (matchParams) {
|
|
1407
|
+
let parsedParams;
|
|
1408
|
+
|
|
1409
|
+
try {
|
|
1410
|
+
var _route$options$parseP;
|
|
1411
|
+
|
|
1412
|
+
parsedParams = (_route$options$parseP = route.options.parseParams == null ? void 0 : route.options.parseParams(matchParams)) != null ? _route$options$parseP : matchParams;
|
|
1413
|
+
} catch (err) {
|
|
1414
|
+
if (opts != null && opts.strictParseParams) {
|
|
1415
|
+
throw err;
|
|
1416
|
+
}
|
|
1380
1417
|
}
|
|
1418
|
+
|
|
1419
|
+
params = _extends$1({}, params, parsedParams);
|
|
1381
1420
|
}
|
|
1382
1421
|
|
|
1383
|
-
|
|
1384
|
-
|
|
1422
|
+
if (!!matchParams) {
|
|
1423
|
+
foundRoutes = [...parentRoutes, route];
|
|
1424
|
+
}
|
|
1385
1425
|
|
|
1386
|
-
|
|
1387
|
-
|
|
1426
|
+
return !!foundRoutes.length;
|
|
1427
|
+
});
|
|
1428
|
+
return !!foundRoutes.length;
|
|
1429
|
+
};
|
|
1388
1430
|
|
|
1389
|
-
|
|
1431
|
+
findMatchInRoutes([], filteredRoutes);
|
|
1432
|
+
|
|
1433
|
+
if (!foundRoutes.length) {
|
|
1390
1434
|
return;
|
|
1391
1435
|
}
|
|
1392
1436
|
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
params,
|
|
1398
|
-
|
|
1437
|
+
foundRoutes.forEach(foundRoute => {
|
|
1438
|
+
var _router$preloadCache$;
|
|
1439
|
+
|
|
1440
|
+
const interpolatedPath = interpolatePath(foundRoute.routePath, params);
|
|
1441
|
+
const matchId = interpolatePath(foundRoute.routeId, params, true);
|
|
1442
|
+
const match = existingMatches.find(d => d.matchId === matchId) || ((_router$preloadCache$ = router.preloadCache[matchId]) == null ? void 0 : _router$preloadCache$.match) || createRouteMatch(router, foundRoute, {
|
|
1443
|
+
matchId,
|
|
1444
|
+
params,
|
|
1445
|
+
pathname: joinPaths([pathname, interpolatedPath])
|
|
1446
|
+
});
|
|
1447
|
+
matches.push(match);
|
|
1399
1448
|
});
|
|
1400
|
-
|
|
1449
|
+
const foundRoute = last(foundRoutes);
|
|
1401
1450
|
|
|
1402
|
-
if ((
|
|
1403
|
-
recurse(
|
|
1451
|
+
if ((_foundRoute$childRout = foundRoute.childRoutes) != null && _foundRoute$childRout.length) {
|
|
1452
|
+
recurse(foundRoute.childRoutes);
|
|
1404
1453
|
}
|
|
1405
1454
|
};
|
|
1406
1455
|
|
|
1407
1456
|
recurse([router.routeTree]);
|
|
1457
|
+
cascadeLoaderData(matches);
|
|
1408
1458
|
return matches;
|
|
1409
1459
|
},
|
|
1410
1460
|
loadMatches: async (resolvedMatches, loaderOpts) => {
|
|
@@ -1483,14 +1533,14 @@ function createRouter(userOptions) {
|
|
|
1483
1533
|
const next = router.buildNext(location);
|
|
1484
1534
|
return router.commitLocation(next, location.replace);
|
|
1485
1535
|
},
|
|
1486
|
-
navigate: async
|
|
1536
|
+
navigate: async _ref2 => {
|
|
1487
1537
|
let {
|
|
1488
1538
|
from,
|
|
1489
1539
|
to = '.',
|
|
1490
1540
|
search,
|
|
1491
1541
|
hash,
|
|
1492
1542
|
replace
|
|
1493
|
-
} =
|
|
1543
|
+
} = _ref2;
|
|
1494
1544
|
// If this link simply reloads the current route,
|
|
1495
1545
|
// make sure it has a new key so it will trigger a data refresh
|
|
1496
1546
|
// If this `to` is a valid external URL, return
|
|
@@ -1504,14 +1554,7 @@ function createRouter(userOptions) {
|
|
|
1504
1554
|
isExternal = true;
|
|
1505
1555
|
} catch (e) {}
|
|
1506
1556
|
|
|
1507
|
-
|
|
1508
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1509
|
-
throw new Error('Attempting to navigate to external url with router.navigate!');
|
|
1510
|
-
}
|
|
1511
|
-
|
|
1512
|
-
return;
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1557
|
+
invariant(!isExternal, 'Attempting to navigate to external url with router.navigate!');
|
|
1515
1558
|
return router._navigate({
|
|
1516
1559
|
from: fromString,
|
|
1517
1560
|
to: toString,
|
|
@@ -1519,8 +1562,8 @@ function createRouter(userOptions) {
|
|
|
1519
1562
|
hash
|
|
1520
1563
|
});
|
|
1521
1564
|
},
|
|
1522
|
-
buildLink:
|
|
1523
|
-
var _preload,
|
|
1565
|
+
buildLink: _ref3 => {
|
|
1566
|
+
var _preload, _ref4, _ref5;
|
|
1524
1567
|
|
|
1525
1568
|
let {
|
|
1526
1569
|
from,
|
|
@@ -1535,7 +1578,7 @@ function createRouter(userOptions) {
|
|
|
1535
1578
|
preloadMaxAge: userPreloadMaxAge,
|
|
1536
1579
|
preloadDelay: userPreloadDelay,
|
|
1537
1580
|
disabled
|
|
1538
|
-
} =
|
|
1581
|
+
} = _ref3;
|
|
1539
1582
|
|
|
1540
1583
|
// If this link simply reloads the current route,
|
|
1541
1584
|
// make sure it has a new key so it will trigger a data refresh
|
|
@@ -1559,8 +1602,8 @@ function createRouter(userOptions) {
|
|
|
1559
1602
|
};
|
|
1560
1603
|
const next = router.buildNext(nextOpts);
|
|
1561
1604
|
preload = (_preload = preload) != null ? _preload : router.options.defaultLinkPreload;
|
|
1562
|
-
const preloadMaxAge = (
|
|
1563
|
-
const preloadDelay = (
|
|
1605
|
+
const preloadMaxAge = (_ref4 = userPreloadMaxAge != null ? userPreloadMaxAge : router.options.defaultLinkPreloadMaxAge) != null ? _ref4 : 2000;
|
|
1606
|
+
const preloadDelay = (_ref5 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultLinkPreloadDelay) != null ? _ref5 : 50; // Compare path/hash for matches
|
|
1564
1607
|
|
|
1565
1608
|
const pathIsEqual = router.state.location.pathname === next.pathname;
|
|
1566
1609
|
const currentPathSplit = router.state.location.pathname.split('/');
|
|
@@ -1634,11 +1677,11 @@ function createRouter(userOptions) {
|
|
|
1634
1677
|
},
|
|
1635
1678
|
__experimental__createSnapshot: () => {
|
|
1636
1679
|
return _extends$1({}, router.state, {
|
|
1637
|
-
matches: router.state.matches.map(
|
|
1680
|
+
matches: router.state.matches.map(_ref6 => {
|
|
1638
1681
|
let {
|
|
1639
1682
|
routeLoaderData: loaderData,
|
|
1640
1683
|
matchId
|
|
1641
|
-
} =
|
|
1684
|
+
} = _ref6;
|
|
1642
1685
|
return {
|
|
1643
1686
|
matchId,
|
|
1644
1687
|
loaderData
|
|
@@ -1666,13 +1709,14 @@ function createRoute(routeConfig, options, parent, router) {
|
|
|
1666
1709
|
// ]).replace(new RegExp(`^${rootRouteId}`), '')
|
|
1667
1710
|
// ) as TRouteInfo['id']
|
|
1668
1711
|
const {
|
|
1669
|
-
id
|
|
1712
|
+
id,
|
|
1713
|
+
routeId,
|
|
1670
1714
|
path: routePath,
|
|
1671
1715
|
fullPath
|
|
1672
1716
|
} = routeConfig;
|
|
1673
1717
|
|
|
1674
|
-
const action = router.state.actions[
|
|
1675
|
-
router.state.actions[
|
|
1718
|
+
const action = router.state.actions[id] || (() => {
|
|
1719
|
+
router.state.actions[id] = {
|
|
1676
1720
|
pending: [],
|
|
1677
1721
|
submit: async (submission, actionOpts) => {
|
|
1678
1722
|
var _actionOpts$invalidat;
|
|
@@ -1687,10 +1731,12 @@ function createRoute(routeConfig, options, parent, router) {
|
|
|
1687
1731
|
status: 'pending',
|
|
1688
1732
|
submission
|
|
1689
1733
|
};
|
|
1734
|
+
action.current = actionState;
|
|
1690
1735
|
action.latest = actionState;
|
|
1691
1736
|
action.pending.push(actionState);
|
|
1692
1737
|
router.state = _extends$1({}, router.state, {
|
|
1693
|
-
|
|
1738
|
+
currentAction: actionState,
|
|
1739
|
+
latestAction: actionState
|
|
1694
1740
|
});
|
|
1695
1741
|
router.notify();
|
|
1696
1742
|
|
|
@@ -1714,20 +1760,20 @@ function createRoute(routeConfig, options, parent, router) {
|
|
|
1714
1760
|
actionState.status = 'error';
|
|
1715
1761
|
} finally {
|
|
1716
1762
|
action.pending = action.pending.filter(d => d !== actionState);
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1763
|
+
router.removeActionQueue.push({
|
|
1764
|
+
action,
|
|
1765
|
+
actionState
|
|
1766
|
+
});
|
|
1722
1767
|
router.notify();
|
|
1723
1768
|
}
|
|
1724
1769
|
}
|
|
1725
1770
|
};
|
|
1726
|
-
return router.state.actions[
|
|
1771
|
+
return router.state.actions[id];
|
|
1727
1772
|
})();
|
|
1728
1773
|
|
|
1729
1774
|
let route = {
|
|
1730
|
-
routeId,
|
|
1775
|
+
routeId: id,
|
|
1776
|
+
routeRouteId: routeId,
|
|
1731
1777
|
routePath,
|
|
1732
1778
|
fullPath,
|
|
1733
1779
|
options,
|
|
@@ -1804,16 +1850,17 @@ function createRouteMatch(router, route, opts) {
|
|
|
1804
1850
|
clearTimeout(routeMatch.__.pendingMinTimeout);
|
|
1805
1851
|
delete routeMatch.__.pendingMinPromise;
|
|
1806
1852
|
},
|
|
1807
|
-
setParentMatch: parentMatch => {
|
|
1808
|
-
|
|
1809
|
-
},
|
|
1810
|
-
addChildMatch: childMatch => {
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1853
|
+
// setParentMatch: (parentMatch?: RouteMatch) => {
|
|
1854
|
+
// routeMatch.parentMatch = parentMatch
|
|
1855
|
+
// },
|
|
1856
|
+
// addChildMatch: (childMatch: RouteMatch) => {
|
|
1857
|
+
// if (
|
|
1858
|
+
// routeMatch.childMatches.find((d) => d.matchId === childMatch.matchId)
|
|
1859
|
+
// ) {
|
|
1860
|
+
// return
|
|
1861
|
+
// }
|
|
1862
|
+
// routeMatch.childMatches.push(childMatch)
|
|
1863
|
+
// },
|
|
1817
1864
|
validate: () => {
|
|
1818
1865
|
var _routeMatch$parentMat, _routeMatch$parentMat2;
|
|
1819
1866
|
|
|
@@ -1917,7 +1964,6 @@ function createRouteMatch(router, route, opts) {
|
|
|
1917
1964
|
}
|
|
1918
1965
|
|
|
1919
1966
|
routeMatch.routeLoaderData = replaceEqualDeep(routeMatch.routeLoaderData, data);
|
|
1920
|
-
cascadeLoaderData(routeMatch);
|
|
1921
1967
|
routeMatch.error = undefined;
|
|
1922
1968
|
routeMatch.status = 'success';
|
|
1923
1969
|
routeMatch.updatedAt = Date.now();
|
|
@@ -1977,16 +2023,14 @@ function createRouteMatch(router, route, opts) {
|
|
|
1977
2023
|
return routeMatch;
|
|
1978
2024
|
}
|
|
1979
2025
|
|
|
1980
|
-
function cascadeLoaderData(
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
}
|
|
2026
|
+
function cascadeLoaderData(matches) {
|
|
2027
|
+
matches.forEach((match, index) => {
|
|
2028
|
+
const parent = matches[index - 1];
|
|
1984
2029
|
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
}
|
|
2030
|
+
if (parent) {
|
|
2031
|
+
match.loaderData = replaceEqualDeep(match.loaderData, _extends$1({}, parent.loaderData, match.routeLoaderData));
|
|
2032
|
+
}
|
|
2033
|
+
});
|
|
1990
2034
|
}
|
|
1991
2035
|
|
|
1992
2036
|
function matchPathname(currentPathname, matchLocation) {
|
|
@@ -2464,34 +2508,21 @@ function createReactRouter(opts) {
|
|
|
2464
2508
|
useRoute: routeId => {
|
|
2465
2509
|
const route = router.getRoute(routeId);
|
|
2466
2510
|
useRouterSubscription(router);
|
|
2467
|
-
|
|
2468
|
-
if (!route) {
|
|
2469
|
-
throw new Error("Could not find a route for route \"" + routeId + "\"! Did you forget to add it to your route config?");
|
|
2470
|
-
}
|
|
2471
|
-
|
|
2511
|
+
invariant(route, "Could not find a route for route \"" + routeId + "\"! Did you forget to add it to your route config?");
|
|
2472
2512
|
return route;
|
|
2473
2513
|
},
|
|
2474
2514
|
useMatch: routeId => {
|
|
2475
|
-
|
|
2476
|
-
throw new Error("\"" + rootRouteId + "\" cannot be used with useMatch! Did you mean to useRoute(\"" + rootRouteId + "\")?");
|
|
2477
|
-
}
|
|
2515
|
+
invariant(routeId !== rootRouteId, "\"" + rootRouteId + "\" cannot be used with useMatch! Did you mean to useRoute(\"" + rootRouteId + "\")?");
|
|
2478
2516
|
|
|
2479
2517
|
const runtimeMatch = _useMatch();
|
|
2480
2518
|
|
|
2481
2519
|
const match = router.state.matches.find(d => d.routeId === routeId);
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
throw new Error("Could not find a match for route \"" + routeId + "\" being rendered in this component!");
|
|
2485
|
-
}
|
|
2486
|
-
|
|
2487
|
-
if (runtimeMatch.routeId !== (match == null ? void 0 : match.routeId)) {
|
|
2488
|
-
throw new Error("useMatch('" + (match == null ? void 0 : match.routeId) + "') is being called in a component that is meant to render the '" + runtimeMatch.routeId + "' route. Did you mean to 'useRoute(" + (match == null ? void 0 : match.routeId) + ")' instead?");
|
|
2489
|
-
}
|
|
2490
|
-
|
|
2520
|
+
invariant(match, "Could not find a match for route \"" + routeId + "\" being rendered in this component!");
|
|
2521
|
+
invariant(runtimeMatch.routeId == (match == null ? void 0 : match.routeId), "useMatch('" + (match == null ? void 0 : match.routeId) + "') is being called in a component that is meant to render the '" + runtimeMatch.routeId + "' route. Did you mean to 'useRoute(" + (match == null ? void 0 : match.routeId) + ")' instead?");
|
|
2491
2522
|
useRouterSubscription(router);
|
|
2492
2523
|
|
|
2493
2524
|
if (!match) {
|
|
2494
|
-
|
|
2525
|
+
invariant('Match not found!');
|
|
2495
2526
|
}
|
|
2496
2527
|
|
|
2497
2528
|
return match;
|
|
@@ -2687,5 +2718,5 @@ function DefaultCatchBoundary(_ref6) {
|
|
|
2687
2718
|
}, "If you are the owner of this website, it's highly recommended that you configure your own custom Catch/Error boundaries for the router. You can optionally configure a boundary for each route."));
|
|
2688
2719
|
}
|
|
2689
2720
|
|
|
2690
|
-
export { DefaultCatchBoundary, MatchesProvider, Outlet, RouterProvider, createBrowserHistory, createHashHistory, createMemoryHistory, createReactRouter, createRoute, createRouteConfig, createRouteMatch, createRouter, defaultParseSearch, defaultStringifySearch, functionalUpdate, last, matchByPath, matchPathname, parsePathname, parseSearchWith, replaceEqualDeep, _resolvePath as resolvePath, rootRouteId, stringifySearchWith, _useMatch as useMatch, useMatches, useParentMatches, useRouter, warning };
|
|
2721
|
+
export { DefaultCatchBoundary, MatchesProvider, Outlet, RouterProvider, createBrowserHistory, createHashHistory, createMemoryHistory, createReactRouter, createRoute, createRouteConfig, createRouteMatch, createRouter, defaultParseSearch, defaultStringifySearch, functionalUpdate, invariant, last, matchByPath, matchPathname, parsePathname, parseSearchWith, replaceEqualDeep, _resolvePath as resolvePath, rootRouteId, stringifySearchWith, _useMatch as useMatch, useMatches, useParentMatches, useRouter, warning };
|
|
2691
2722
|
//# sourceMappingURL=index.js.map
|