@tanstack/react-router 0.0.1-alpha.9 → 0.0.1-beta.10

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.
@@ -944,6 +944,12 @@ function functionalUpdate(updater, previous) {
944
944
 
945
945
  return updater;
946
946
  }
947
+ function pick(parent, keys) {
948
+ return keys.reduce((obj, key) => {
949
+ obj[key] = parent[key];
950
+ return obj;
951
+ }, {});
952
+ }
947
953
 
948
954
  function joinPaths(paths) {
949
955
  return cleanPath(paths.filter(Boolean).join('/'));
@@ -1170,6 +1176,7 @@ function toValue(mix) {
1170
1176
  var str = decodeURIComponent(mix);
1171
1177
  if (str === 'false') return false;
1172
1178
  if (str === 'true') return true;
1179
+ if (str.charAt(0) === '0') return str;
1173
1180
  return +str * 0 === 0 ? +str : str;
1174
1181
  }
1175
1182
 
@@ -1220,7 +1227,7 @@ function createRoute(routeConfig, options, parent, router) {
1220
1227
 
1221
1228
  const action = router.state.actions[id] || (() => {
1222
1229
  router.state.actions[id] = {
1223
- pending: [],
1230
+ submissions: [],
1224
1231
  submit: async (submission, actionOpts) => {
1225
1232
  var _actionOpts$invalidat;
1226
1233
 
@@ -1229,18 +1236,20 @@ function createRoute(routeConfig, options, parent, router) {
1229
1236
  }
1230
1237
 
1231
1238
  const invalidate = (_actionOpts$invalidat = actionOpts == null ? void 0 : actionOpts.invalidate) != null ? _actionOpts$invalidat : true;
1239
+
1240
+ if (!(actionOpts != null && actionOpts.multi)) {
1241
+ action.submissions = action.submissions.filter(d => d.isMulti);
1242
+ }
1243
+
1232
1244
  const actionState = {
1233
1245
  submittedAt: Date.now(),
1234
1246
  status: 'pending',
1235
- submission
1247
+ submission,
1248
+ isMulti: !!(actionOpts != null && actionOpts.multi)
1236
1249
  };
1237
1250
  action.current = actionState;
1238
1251
  action.latest = actionState;
1239
- action.pending.push(actionState);
1240
- router.state = _extends({}, router.state, {
1241
- currentAction: actionState,
1242
- latestAction: actionState
1243
- });
1252
+ action.submissions.push(actionState);
1244
1253
  router.notify();
1245
1254
 
1246
1255
  try {
@@ -1262,11 +1271,6 @@ function createRoute(routeConfig, options, parent, router) {
1262
1271
  actionState.error = err;
1263
1272
  actionState.status = 'error';
1264
1273
  } finally {
1265
- action.pending = action.pending.filter(d => d !== actionState);
1266
- router.removeActionQueue.push({
1267
- action,
1268
- actionState
1269
- });
1270
1274
  router.notify();
1271
1275
  }
1272
1276
  }
@@ -1274,6 +1278,40 @@ function createRoute(routeConfig, options, parent, router) {
1274
1278
  return router.state.actions[id];
1275
1279
  })();
1276
1280
 
1281
+ const loader = router.state.loaders[id] || (() => {
1282
+ router.state.loaders[id] = {
1283
+ pending: [],
1284
+ fetch: async loaderContext => {
1285
+ if (!route) {
1286
+ return;
1287
+ }
1288
+
1289
+ const loaderState = {
1290
+ loadedAt: Date.now(),
1291
+ loaderContext
1292
+ };
1293
+ loader.current = loaderState;
1294
+ loader.latest = loaderState;
1295
+ loader.pending.push(loaderState); // router.state = {
1296
+ // ...router.state,
1297
+ // currentAction: loaderState,
1298
+ // latestAction: loaderState,
1299
+ // }
1300
+
1301
+ router.notify();
1302
+
1303
+ try {
1304
+ return await (route.options.loader == null ? void 0 : route.options.loader(loaderContext));
1305
+ } finally {
1306
+ loader.pending = loader.pending.filter(d => d !== loaderState); // router.removeActionQueue.push({ loader, loaderState })
1307
+
1308
+ router.notify();
1309
+ }
1310
+ }
1311
+ };
1312
+ return router.state.loaders[id];
1313
+ })();
1314
+
1277
1315
  let route = {
1278
1316
  routeId: id,
1279
1317
  routeRouteId: routeId,
@@ -1284,6 +1322,7 @@ function createRoute(routeConfig, options, parent, router) {
1284
1322
  childRoutes: undefined,
1285
1323
  parentRoute: parent,
1286
1324
  action,
1325
+ loader: loader,
1287
1326
  buildLink: options => {
1288
1327
  return router.buildLink(_extends({}, options, {
1289
1328
  from: fullPath
@@ -1306,15 +1345,6 @@ function createRoute(routeConfig, options, parent, router) {
1306
1345
  });
1307
1346
  return route;
1308
1347
  }
1309
- function cascadeLoaderData(matches) {
1310
- matches.forEach((match, index) => {
1311
- const parent = matches[index - 1];
1312
-
1313
- if (parent) {
1314
- match.loaderData = replaceEqualDeep(match.loaderData, _extends({}, parent.loaderData, match.routeLoaderData));
1315
- }
1316
- });
1317
- }
1318
1348
 
1319
1349
  const rootRouteId = '__root__';
1320
1350
  const createRouteConfig = function createRouteConfig(options, children, isRoot, parentId, parentPath) {
@@ -1380,6 +1410,7 @@ function createRouteMatch(router, route, opts) {
1380
1410
  isFetching: false,
1381
1411
  isInvalid: false,
1382
1412
  invalidAt: Infinity,
1413
+ // pendingActions: [],
1383
1414
  getIsInvalid: () => {
1384
1415
  const now = Date.now();
1385
1416
  return routeMatch.isInvalid || routeMatch.invalidAt < now;
@@ -1419,17 +1450,6 @@ function createRouteMatch(router, route, opts) {
1419
1450
  clearTimeout(routeMatch.__.pendingMinTimeout);
1420
1451
  delete routeMatch.__.pendingMinPromise;
1421
1452
  },
1422
- // setParentMatch: (parentMatch?: RouteMatch) => {
1423
- // routeMatch.parentMatch = parentMatch
1424
- // },
1425
- // addChildMatch: (childMatch: RouteMatch) => {
1426
- // if (
1427
- // routeMatch.childMatches.find((d) => d.matchId === childMatch.matchId)
1428
- // ) {
1429
- // return
1430
- // }
1431
- // routeMatch.childMatches.push(childMatch)
1432
- // },
1433
1453
  validate: () => {
1434
1454
  var _routeMatch$parentMat, _routeMatch$parentMat2;
1435
1455
 
@@ -1437,9 +1457,11 @@ function createRouteMatch(router, route, opts) {
1437
1457
  const parentSearch = (_routeMatch$parentMat = (_routeMatch$parentMat2 = routeMatch.parentMatch) == null ? void 0 : _routeMatch$parentMat2.search) != null ? _routeMatch$parentMat : router.location.search;
1438
1458
 
1439
1459
  try {
1460
+ var _validator;
1461
+
1440
1462
  const prevSearch = routeMatch.routeSearch;
1441
1463
  const validator = typeof routeMatch.options.validateSearch === 'object' ? routeMatch.options.validateSearch.parse : routeMatch.options.validateSearch;
1442
- let nextSearch = replaceEqualDeep(prevSearch, validator == null ? void 0 : validator(parentSearch)); // Invalidate route matches when search param stability changes
1464
+ let nextSearch = replaceEqualDeep(prevSearch, (_validator = validator == null ? void 0 : validator(parentSearch)) != null ? _validator : {}); // Invalidate route matches when search param stability changes
1443
1465
 
1444
1466
  if (prevSearch !== nextSearch) {
1445
1467
  routeMatch.isInvalid = true;
@@ -1447,6 +1469,13 @@ function createRouteMatch(router, route, opts) {
1447
1469
 
1448
1470
  routeMatch.routeSearch = nextSearch;
1449
1471
  routeMatch.search = replaceEqualDeep(parentSearch, _extends({}, parentSearch, nextSearch));
1472
+ elementTypes.map(async type => {
1473
+ const routeElement = routeMatch.options[type];
1474
+
1475
+ if (typeof routeMatch.__[type] !== 'function') {
1476
+ routeMatch.__[type] = routeElement;
1477
+ }
1478
+ });
1450
1479
  } catch (err) {
1451
1480
  console.error(err);
1452
1481
  const error = new Error('Invalid search params found', {
@@ -1471,9 +1500,33 @@ function createRouteMatch(router, route, opts) {
1471
1500
  routeMatch.isInvalid = true;
1472
1501
  },
1473
1502
  hasLoaders: () => {
1474
- return !!(route.options.loader || route.options.import || elementTypes.some(d => typeof route.options[d] === 'function'));
1503
+ return !!(route.options.loader || elementTypes.some(d => typeof route.options[d] === 'function'));
1504
+ },
1505
+ load: async loaderOpts => {
1506
+ const now = Date.now();
1507
+ const minMaxAge = loaderOpts != null && loaderOpts.preload ? Math.max(loaderOpts == null ? void 0 : loaderOpts.maxAge, loaderOpts == null ? void 0 : loaderOpts.gcMaxAge) : 0; // If this is a preload, add it to the preload cache
1508
+
1509
+ if (loaderOpts != null && loaderOpts.preload && minMaxAge > 0) {
1510
+ // If the match is currently active, don't preload it
1511
+ if (router.state.matches.find(d => d.matchId === routeMatch.matchId)) {
1512
+ return;
1513
+ }
1514
+
1515
+ router.matchCache[routeMatch.matchId] = {
1516
+ gc: now + loaderOpts.gcMaxAge,
1517
+ match: routeMatch
1518
+ };
1519
+ } // If the match is invalid, errored or idle, trigger it to load
1520
+
1521
+
1522
+ if (routeMatch.status === 'success' && routeMatch.getIsInvalid() || routeMatch.status === 'error' || routeMatch.status === 'idle') {
1523
+ const maxAge = loaderOpts != null && loaderOpts.preload ? loaderOpts == null ? void 0 : loaderOpts.maxAge : undefined;
1524
+ await routeMatch.fetch({
1525
+ maxAge
1526
+ });
1527
+ }
1475
1528
  },
1476
- load: async opts => {
1529
+ fetch: async opts => {
1477
1530
  const id = '' + Date.now() + Math.random();
1478
1531
  routeMatch.__.latestId = id; // If the match was in an error state, set it
1479
1532
  // to a loading state again. Otherwise, keep it
@@ -1491,37 +1544,16 @@ function createRouteMatch(router, route, opts) {
1491
1544
  routeMatch.isFetching = true;
1492
1545
  routeMatch.__.resolve = resolve;
1493
1546
 
1494
- const loaderPromise = (async () => {
1495
- const importer = routeMatch.options.import; // First, run any importers
1496
-
1497
- if (importer) {
1498
- routeMatch.__.importPromise = importer({
1499
- params: routeMatch.params // search: routeMatch.search,
1500
-
1501
- }).then(imported => {
1502
- routeMatch.__ = _extends({}, routeMatch.__, imported);
1503
- });
1504
- } // Wait for the importer to finish before
1505
- // attempting to load elements and data
1506
-
1507
-
1508
- await routeMatch.__.importPromise; // Next, load the elements and data in parallel
1509
-
1547
+ routeMatch.__.loaderDataPromise = (async () => {
1548
+ // Load the elements and data in parallel
1510
1549
  routeMatch.__.elementsPromise = (async () => {
1511
1550
  // then run all element and data loaders in parallel
1512
1551
  // For each element type, potentially load it asynchronously
1513
1552
  await Promise.all(elementTypes.map(async type => {
1514
1553
  const routeElement = routeMatch.options[type];
1515
1554
 
1516
- if (routeMatch.__[type]) {
1517
- return;
1518
- }
1519
-
1520
- if (typeof routeElement === 'function') {
1521
- const res = await routeElement(routeMatch);
1522
- routeMatch.__[type] = res;
1523
- } else {
1524
- routeMatch.__[type] = routeMatch.options[type];
1555
+ if (typeof routeMatch.__[type] === 'function') {
1556
+ routeMatch.__[type] = await router.options.createElement(routeElement);
1525
1557
  }
1526
1558
  }));
1527
1559
  })();
@@ -1538,7 +1570,7 @@ function createRouteMatch(router, route, opts) {
1538
1570
  });
1539
1571
 
1540
1572
  if (id !== routeMatch.__.latestId) {
1541
- return routeMatch.__.loaderPromise;
1573
+ return routeMatch.__.loadPromise;
1542
1574
  }
1543
1575
 
1544
1576
  routeMatch.routeLoaderData = replaceEqualDeep(routeMatch.routeLoaderData, data);
@@ -1550,7 +1582,7 @@ function createRouteMatch(router, route, opts) {
1550
1582
  routeMatch.invalidAt = routeMatch.updatedAt + ((_ref = (_ref2 = (_opts$maxAge = opts == null ? void 0 : opts.maxAge) != null ? _opts$maxAge : routeMatch.options.loaderMaxAge) != null ? _ref2 : router.options.defaultLoaderMaxAge) != null ? _ref : 0);
1551
1583
  } catch (err) {
1552
1584
  if (id !== routeMatch.__.latestId) {
1553
- return routeMatch.__.loaderPromise;
1585
+ return routeMatch.__.loadPromise;
1554
1586
  }
1555
1587
 
1556
1588
  if (process.env.NODE_ENV !== 'production') {
@@ -1567,7 +1599,7 @@ function createRouteMatch(router, route, opts) {
1567
1599
  await Promise.all([routeMatch.__.elementsPromise, routeMatch.__.dataPromise]);
1568
1600
 
1569
1601
  if (id !== routeMatch.__.latestId) {
1570
- return routeMatch.__.loaderPromise;
1602
+ return routeMatch.__.loadPromise;
1571
1603
  }
1572
1604
 
1573
1605
  if (routeMatch.__.pendingMinPromise) {
@@ -1576,7 +1608,7 @@ function createRouteMatch(router, route, opts) {
1576
1608
  }
1577
1609
  } finally {
1578
1610
  if (id !== routeMatch.__.latestId) {
1579
- return routeMatch.__.loaderPromise;
1611
+ return routeMatch.__.loadPromise;
1580
1612
  }
1581
1613
 
1582
1614
  routeMatch.__.cancelPending();
@@ -1588,16 +1620,16 @@ function createRouteMatch(router, route, opts) {
1588
1620
  }
1589
1621
  })();
1590
1622
 
1591
- routeMatch.__.loaderPromise = loaderPromise;
1592
- await loaderPromise;
1623
+ await routeMatch.__.loaderDataPromise;
1593
1624
 
1594
1625
  if (id !== routeMatch.__.latestId) {
1595
- return routeMatch.__.loaderPromise;
1626
+ return routeMatch.__.loadPromise;
1596
1627
  }
1597
1628
 
1598
- delete routeMatch.__.loaderPromise;
1629
+ delete routeMatch.__.loaderDataPromise;
1599
1630
  });
1600
- return await routeMatch.__.loadPromise;
1631
+ await routeMatch.__.loadPromise;
1632
+ delete routeMatch.__.loadPromise;
1601
1633
  }
1602
1634
  });
1603
1635
 
@@ -1658,9 +1690,22 @@ function stringifySearchWith(stringify) {
1658
1690
 
1659
1691
  var _window$document;
1660
1692
  // Detect if we're in the DOM
1661
- const isServer = Boolean(typeof window === 'undefined' || !((_window$document = window.document) != null && _window$document.createElement)); // This is the default history object if none is defined
1693
+ const isServer = typeof window === 'undefined' || !((_window$document = window.document) != null && _window$document.createElement); // This is the default history object if none is defined
1694
+
1695
+ const createDefaultHistory = () => isServer ? createMemoryHistory() : createBrowserHistory();
1662
1696
 
1663
- const createDefaultHistory = () => !isServer ? createBrowserHistory() : createMemoryHistory();
1697
+ function getInitialRouterState() {
1698
+ return {
1699
+ status: 'idle',
1700
+ location: null,
1701
+ matches: [],
1702
+ actions: {},
1703
+ loaders: {},
1704
+ lastUpdated: Date.now(),
1705
+ isFetching: false,
1706
+ isPreloading: false
1707
+ };
1708
+ }
1664
1709
 
1665
1710
  function createRouter(userOptions) {
1666
1711
  var _userOptions$stringif, _userOptions$parseSea;
@@ -1678,9 +1723,9 @@ function createRouter(userOptions) {
1678
1723
  });
1679
1724
 
1680
1725
  let router = {
1726
+ history,
1681
1727
  options: originalOptions,
1682
1728
  listeners: [],
1683
- removeActionQueue: [],
1684
1729
  // Resolved after construction
1685
1730
  basepath: '',
1686
1731
  routeTree: undefined,
@@ -1691,15 +1736,10 @@ function createRouter(userOptions) {
1691
1736
  navigationPromise: Promise.resolve(),
1692
1737
  resolveNavigation: () => {},
1693
1738
  matchCache: {},
1694
- state: {
1695
- status: 'idle',
1696
- location: null,
1697
- matches: [],
1698
- actions: {},
1699
- loaderData: {},
1700
- lastUpdated: Date.now(),
1701
- isFetching: false,
1702
- isPreloading: false
1739
+ state: getInitialRouterState(),
1740
+ reset: () => {
1741
+ router.state = getInitialRouterState();
1742
+ router.notify();
1703
1743
  },
1704
1744
  startedLoadingAt: Date.now(),
1705
1745
  subscribe: listener => {
@@ -1717,24 +1757,44 @@ function createRouter(userOptions) {
1717
1757
  isPreloading: Object.values(router.matchCache).some(d => d.match.isFetching && !router.state.matches.find(dd => dd.matchId === d.match.matchId))
1718
1758
  });
1719
1759
  cascadeLoaderData(router.state.matches);
1720
- router.listeners.forEach(listener => listener());
1760
+ router.listeners.forEach(listener => listener(router));
1761
+ },
1762
+ dehydrateState: () => {
1763
+ return _extends({}, pick(router.state, ['status', 'location', 'lastUpdated']), {
1764
+ matches: router.state.matches.map(match => pick(match, ['matchId', 'status', 'routeLoaderData', 'loaderData', 'isInvalid', 'invalidAt']))
1765
+ });
1766
+ },
1767
+ hydrateState: dehydratedState => {
1768
+ // Match the routes
1769
+ const matches = router.matchRoutes(router.location.pathname, {
1770
+ strictParseParams: true
1771
+ });
1772
+ matches.forEach((match, index) => {
1773
+ const dehydratedMatch = dehydratedState.matches[index];
1774
+ invariant(dehydratedMatch, 'Oh no! Dehydrated route matches did not match the active state of the router 😬');
1775
+ Object.assign(match, dehydratedMatch);
1776
+ });
1777
+ router.loadMatches(matches);
1778
+ router.state = _extends({}, router.state, dehydratedState, {
1779
+ matches
1780
+ });
1721
1781
  },
1722
1782
  mount: () => {
1723
- const next = router.buildLocation({
1783
+ const next = router.__.buildLocation({
1724
1784
  to: '.',
1725
1785
  search: true,
1726
1786
  hash: true
1727
1787
  }); // If the current location isn't updated, trigger a navigation
1728
1788
  // to the current location. Otherwise, load the current location.
1729
1789
 
1790
+
1730
1791
  if (next.href !== router.location.href) {
1731
- router.commitLocation(next, true);
1732
- } else {
1733
- router.loadLocation();
1734
- }
1792
+ router.__.commitLocation(next, true);
1793
+ } // router.load()
1735
1794
 
1736
- const unsub = history.listen(event => {
1737
- router.loadLocation(router.parseLocation(event.location, router.location));
1795
+
1796
+ const unsub = router.history.listen(event => {
1797
+ router.load(router.__.parseLocation(event.location, router.location));
1738
1798
  }); // addEventListener does not exist in React Native, but window does
1739
1799
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1740
1800
 
@@ -1745,16 +1805,30 @@ function createRouter(userOptions) {
1745
1805
  }
1746
1806
 
1747
1807
  return () => {
1748
- unsub(); // Be sure to unsubscribe if a new handler is set
1808
+ unsub();
1749
1809
 
1750
- window.removeEventListener('visibilitychange', router.onFocus);
1751
- window.removeEventListener('focus', router.onFocus);
1810
+ if (!isServer && window.removeEventListener) {
1811
+ // Be sure to unsubscribe if a new handler is set
1812
+ window.removeEventListener('visibilitychange', router.onFocus);
1813
+ window.removeEventListener('focus', router.onFocus);
1814
+ }
1752
1815
  };
1753
1816
  },
1754
1817
  onFocus: () => {
1755
- router.loadLocation();
1818
+ router.load();
1756
1819
  },
1757
1820
  update: opts => {
1821
+ const newHistory = (opts == null ? void 0 : opts.history) !== router.history;
1822
+
1823
+ if (!router.location || newHistory) {
1824
+ if (opts != null && opts.history) {
1825
+ router.history = opts.history;
1826
+ }
1827
+
1828
+ router.location = router.__.parseLocation(router.history.location);
1829
+ router.state.location = router.location;
1830
+ }
1831
+
1758
1832
  Object.assign(router.options, opts);
1759
1833
  const {
1760
1834
  basepath,
@@ -1764,204 +1838,30 @@ function createRouter(userOptions) {
1764
1838
 
1765
1839
  if (routeConfig) {
1766
1840
  router.routesById = {};
1767
- router.routeTree = router.buildRouteTree(routeConfig);
1841
+ router.routeTree = router.__.buildRouteTree(routeConfig);
1768
1842
  }
1769
1843
 
1770
1844
  return router;
1771
1845
  },
1772
- buildRouteTree: rootRouteConfig => {
1773
- const recurseRoutes = (routeConfigs, parent) => {
1774
- return routeConfigs.map(routeConfig => {
1775
- const routeOptions = routeConfig.options;
1776
- const route = createRoute(routeConfig, routeOptions, parent, router); // {
1777
- // pendingMs: routeOptions.pendingMs ?? router.defaultPendingMs,
1778
- // pendingMinMs: routeOptions.pendingMinMs ?? router.defaultPendingMinMs,
1779
- // }
1780
-
1781
- const existingRoute = router.routesById[route.routeId];
1782
-
1783
- if (existingRoute) {
1784
- if (process.env.NODE_ENV !== 'production') {
1785
- console.warn("Duplicate routes found with id: " + String(route.routeId), router.routesById, route);
1786
- }
1787
-
1788
- throw new Error();
1789
- }
1790
- router.routesById[route.routeId] = route;
1791
- const children = routeConfig.children;
1792
- route.childRoutes = children != null && children.length ? recurseRoutes(children, route) : undefined;
1793
- return route;
1794
- });
1795
- };
1796
-
1797
- const routes = recurseRoutes([rootRouteConfig]);
1798
- return routes[0];
1799
- },
1800
- parseLocation: (location, previousLocation) => {
1801
- var _location$hash$split$;
1802
-
1803
- const parsedSearch = router.options.parseSearch(location.search);
1804
- return {
1805
- pathname: location.pathname,
1806
- searchStr: location.search,
1807
- search: replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.search, parsedSearch),
1808
- hash: (_location$hash$split$ = location.hash.split('#').reverse()[0]) != null ? _location$hash$split$ : '',
1809
- href: "" + location.pathname + location.search + location.hash,
1810
- state: location.state,
1811
- key: location.key
1812
- };
1813
- },
1814
- buildLocation: function buildLocation(dest) {
1815
- var _dest$from, _router$basepath, _dest$to, _last, _dest$params, _dest$__preSearchFilt, _functionalUpdate, _dest$__preSearchFilt2, _dest$__postSearchFil;
1816
-
1817
- if (dest === void 0) {
1818
- dest = {};
1819
- }
1820
-
1821
- // const resolvedFrom: Location = {
1822
- // ...router.location,
1823
- const fromPathname = dest.fromCurrent ? router.location.pathname : (_dest$from = dest.from) != null ? _dest$from : router.location.pathname;
1824
-
1825
- let pathname = resolvePath((_router$basepath = router.basepath) != null ? _router$basepath : '/', fromPathname, "" + ((_dest$to = dest.to) != null ? _dest$to : '.'));
1826
-
1827
- const fromMatches = router.matchRoutes(router.location.pathname, {
1828
- strictParseParams: true
1829
- });
1830
- const toMatches = router.matchRoutes(pathname);
1831
-
1832
- const prevParams = _extends({}, (_last = last(fromMatches)) == null ? void 0 : _last.params);
1833
-
1834
- let nextParams = ((_dest$params = dest.params) != null ? _dest$params : true) === true ? prevParams : functionalUpdate(dest.params, prevParams);
1835
-
1836
- if (nextParams) {
1837
- toMatches.map(d => d.options.stringifyParams).filter(Boolean).forEach(fn => {
1838
- Object.assign({}, nextParams, fn(nextParams));
1839
- });
1840
- }
1841
-
1842
- pathname = interpolatePath(pathname, nextParams != null ? nextParams : {}); // Pre filters first
1843
-
1844
- const preFilteredSearch = (_dest$__preSearchFilt = dest.__preSearchFilters) != null && _dest$__preSearchFilt.length ? dest.__preSearchFilters.reduce((prev, next) => next(prev), router.location.search) : router.location.search; // Then the link/navigate function
1845
-
1846
- const destSearch = dest.search === true ? preFilteredSearch // Preserve resolvedFrom true
1847
- : dest.search ? (_functionalUpdate = functionalUpdate(dest.search, preFilteredSearch)) != null ? _functionalUpdate : {} // Updater
1848
- : (_dest$__preSearchFilt2 = dest.__preSearchFilters) != null && _dest$__preSearchFilt2.length ? preFilteredSearch // Preserve resolvedFrom filters
1849
- : {}; // Then post filters
1850
-
1851
- const postFilteredSearch = (_dest$__postSearchFil = dest.__postSearchFilters) != null && _dest$__postSearchFil.length ? dest.__postSearchFilters.reduce((prev, next) => next(prev), destSearch) : destSearch;
1852
- const search = replaceEqualDeep(router.location.search, postFilteredSearch);
1853
- const searchStr = router.options.stringifySearch(search);
1854
- let hash = dest.hash === true ? router.location.hash : functionalUpdate(dest.hash, router.location.hash);
1855
- hash = hash ? "#" + hash : '';
1856
- return {
1857
- pathname,
1858
- search,
1859
- searchStr,
1860
- state: router.location.state,
1861
- hash,
1862
- href: "" + pathname + searchStr + hash,
1863
- key: dest.key
1864
- };
1865
- },
1866
- commitLocation: (next, replace) => {
1867
- const id = '' + Date.now() + Math.random();
1868
- if (router.navigateTimeout) clearTimeout(router.navigateTimeout);
1869
- let nextAction = 'replace';
1870
-
1871
- if (!replace) {
1872
- nextAction = 'push';
1873
- }
1874
-
1875
- const isSameUrl = router.parseLocation(history.location).href === next.href;
1876
-
1877
- if (isSameUrl && !next.key) {
1878
- nextAction = 'replace';
1879
- }
1880
-
1881
- if (nextAction === 'replace') {
1882
- history.replace({
1883
- pathname: next.pathname,
1884
- hash: next.hash,
1885
- search: next.searchStr
1886
- }, {
1887
- id
1888
- });
1889
- } else {
1890
- history.push({
1891
- pathname: next.pathname,
1892
- hash: next.hash,
1893
- search: next.searchStr
1894
- }, {
1895
- id
1896
- });
1897
- }
1898
-
1899
- router.navigationPromise = new Promise(resolve => {
1900
- const previousNavigationResolve = router.resolveNavigation;
1901
-
1902
- router.resolveNavigation = () => {
1903
- previousNavigationResolve();
1904
- resolve();
1905
- };
1906
- });
1907
- return router.navigationPromise;
1908
- },
1909
- buildNext: opts => {
1910
- const next = router.buildLocation(opts);
1911
- const matches = router.matchRoutes(next.pathname);
1912
-
1913
- const __preSearchFilters = matches.map(match => {
1914
- var _match$options$preSea;
1915
-
1916
- return (_match$options$preSea = match.options.preSearchFilters) != null ? _match$options$preSea : [];
1917
- }).flat().filter(Boolean);
1918
-
1919
- const __postSearchFilters = matches.map(match => {
1920
- var _match$options$postSe;
1921
-
1922
- return (_match$options$postSe = match.options.postSearchFilters) != null ? _match$options$postSe : [];
1923
- }).flat().filter(Boolean);
1924
-
1925
- return router.buildLocation(_extends({}, opts, {
1926
- __preSearchFilters,
1927
- __postSearchFilters
1928
- }));
1929
- },
1930
1846
  cancelMatches: () => {
1931
1847
  var _router$state$pending, _router$state$pending2;
1932
1848
  [...router.state.matches, ...((_router$state$pending = (_router$state$pending2 = router.state.pending) == null ? void 0 : _router$state$pending2.matches) != null ? _router$state$pending : [])].forEach(match => {
1933
1849
  match.cancel();
1934
1850
  });
1935
1851
  },
1936
- loadLocation: async next => {
1852
+ load: async next => {
1937
1853
  const id = Math.random();
1938
1854
  router.startedLoadingAt = id;
1939
1855
 
1940
1856
  if (next) {
1941
1857
  // Ingest the new location
1942
1858
  router.location = next;
1943
- } // Clear out old actions
1944
-
1945
-
1946
- router.removeActionQueue.forEach(_ref => {
1947
- let {
1948
- action,
1949
- actionState
1950
- } = _ref;
1951
-
1952
- if (router.state.currentAction === actionState) {
1953
- router.state.currentAction = undefined;
1954
- }
1859
+ } // Cancel any pending matches
1955
1860
 
1956
- if (action.current === actionState) {
1957
- action.current = undefined;
1958
- }
1959
- });
1960
- router.removeActionQueue = []; // Cancel any pending matches
1961
1861
 
1962
1862
  router.cancelMatches(); // Match the routes
1963
1863
 
1964
- const matches = router.matchRoutes(location.pathname, {
1864
+ const matches = router.matchRoutes(router.location.pathname, {
1965
1865
  strictParseParams: true
1966
1866
  });
1967
1867
  router.state = _extends({}, router.state, {
@@ -1994,19 +1894,24 @@ function createRouter(userOptions) {
1994
1894
  });
1995
1895
  const now = Date.now();
1996
1896
  exiting.forEach(d => {
1997
- var _ref2, _d$options$loaderGcMa, _ref3, _d$options$loaderMaxA;
1897
+ var _ref, _d$options$loaderGcMa, _ref2, _d$options$loaderMaxA;
1998
1898
 
1999
1899
  d.__.onExit == null ? void 0 : d.__.onExit({
2000
1900
  params: d.params,
2001
1901
  search: d.routeSearch
2002
- }); // Clear idle error states when match leaves
1902
+ }); // // Clear actions
1903
+ // if (d.action) {
1904
+ // d.action.current = undefined
1905
+ // d.action.submissions = []
1906
+ // }
1907
+ // Clear idle error states when match leaves
2003
1908
 
2004
1909
  if (d.status === 'error' && !d.isFetching) {
2005
1910
  d.status = 'idle';
2006
1911
  d.error = undefined;
2007
1912
  }
2008
1913
 
2009
- const gc = Math.max((_ref2 = (_d$options$loaderGcMa = d.options.loaderGcMaxAge) != null ? _d$options$loaderGcMa : router.options.defaultLoaderGcMaxAge) != null ? _ref2 : 0, (_ref3 = (_d$options$loaderMaxA = d.options.loaderMaxAge) != null ? _d$options$loaderMaxA : router.options.defaultLoaderMaxAge) != null ? _ref3 : 0);
1914
+ const gc = Math.max((_ref = (_d$options$loaderGcMa = d.options.loaderGcMaxAge) != null ? _d$options$loaderGcMa : router.options.defaultLoaderGcMaxAge) != null ? _ref : 0, (_ref2 = (_d$options$loaderMaxA = d.options.loaderMaxAge) != null ? _d$options$loaderMaxA : router.options.defaultLoaderMaxAge) != null ? _ref2 : 0);
2010
1915
 
2011
1916
  if (gc > 0) {
2012
1917
  router.matchCache[d.matchId] = {
@@ -2029,18 +1934,21 @@ function createRouter(userOptions) {
2029
1934
  params: d.params,
2030
1935
  search: d.search
2031
1936
  });
2032
- });
2033
-
2034
- if (matches.some(d => d.status === 'loading')) {
2035
- router.notify();
2036
- await Promise.all(matches.map(d => d.__.loaderPromise || Promise.resolve()));
2037
- }
1937
+ delete router.matchCache[d.matchId];
1938
+ }); // router.notify()
2038
1939
 
2039
1940
  if (router.startedLoadingAt !== id) {
2040
1941
  // Ignore side-effects of match loading
2041
1942
  return;
2042
1943
  }
2043
1944
 
1945
+ matches.forEach(match => {
1946
+ // Clear actions
1947
+ if (match.action) {
1948
+ match.action.current = undefined;
1949
+ match.action.submissions = [];
1950
+ }
1951
+ });
2044
1952
  router.state = _extends({}, router.state, {
2045
1953
  location: router.location,
2046
1954
  matches,
@@ -2081,7 +1989,7 @@ function createRouter(userOptions) {
2081
1989
  return matches;
2082
1990
  },
2083
1991
  preloadRoute: async function preloadRoute(navigateOpts, loaderOpts) {
2084
- var _ref4, _ref5, _loaderOpts$maxAge, _ref6, _ref7, _loaderOpts$gcMaxAge;
1992
+ var _ref3, _ref4, _loaderOpts$maxAge, _ref5, _ref6, _loaderOpts$gcMaxAge;
2085
1993
 
2086
1994
  if (navigateOpts === void 0) {
2087
1995
  navigateOpts = router.location;
@@ -2093,8 +2001,8 @@ function createRouter(userOptions) {
2093
2001
  });
2094
2002
  await router.loadMatches(matches, {
2095
2003
  preload: true,
2096
- maxAge: (_ref4 = (_ref5 = (_loaderOpts$maxAge = loaderOpts.maxAge) != null ? _loaderOpts$maxAge : router.options.defaultPreloadMaxAge) != null ? _ref5 : router.options.defaultLoaderMaxAge) != null ? _ref4 : 0,
2097
- gcMaxAge: (_ref6 = (_ref7 = (_loaderOpts$gcMaxAge = loaderOpts.gcMaxAge) != null ? _loaderOpts$gcMaxAge : router.options.defaultPreloadGcMaxAge) != null ? _ref7 : router.options.defaultLoaderGcMaxAge) != null ? _ref6 : 0
2004
+ maxAge: (_ref3 = (_ref4 = (_loaderOpts$maxAge = loaderOpts.maxAge) != null ? _loaderOpts$maxAge : router.options.defaultPreloadMaxAge) != null ? _ref4 : router.options.defaultLoaderMaxAge) != null ? _ref3 : 0,
2005
+ gcMaxAge: (_ref5 = (_ref6 = (_loaderOpts$gcMaxAge = loaderOpts.gcMaxAge) != null ? _loaderOpts$gcMaxAge : router.options.defaultPreloadGcMaxAge) != null ? _ref6 : router.options.defaultLoaderGcMaxAge) != null ? _ref5 : 0
2098
2006
  });
2099
2007
  return matches;
2100
2008
  },
@@ -2188,38 +2096,20 @@ function createRouter(userOptions) {
2188
2096
  return matches;
2189
2097
  },
2190
2098
  loadMatches: async (resolvedMatches, loaderOpts) => {
2191
- const now = Date.now();
2192
- const minMaxAge = loaderOpts != null && loaderOpts.preload ? Math.max(loaderOpts == null ? void 0 : loaderOpts.maxAge, loaderOpts == null ? void 0 : loaderOpts.gcMaxAge) : 0;
2193
2099
  const matchPromises = resolvedMatches.map(async match => {
2194
2100
  // Validate the match (loads search params etc)
2195
- match.__.validate(); // If this is a preload, add it to the preload cache
2196
-
2197
-
2198
- if (loaderOpts != null && loaderOpts.preload && minMaxAge > 0) {
2199
- // If the match is currently active, don't preload it
2200
- if (router.state.matches.find(d => d.matchId === match.matchId)) {
2201
- return;
2202
- }
2203
-
2204
- router.matchCache[match.matchId] = {
2205
- gc: now + loaderOpts.gcMaxAge,
2206
- match
2207
- };
2208
- } // If the match is invalid, errored or idle, trigger it to load
2209
-
2101
+ match.__.validate();
2210
2102
 
2211
- if (match.status === 'success' && match.getIsInvalid() || match.status === 'error' || match.status === 'idle') {
2212
- const maxAge = loaderOpts != null && loaderOpts.preload ? loaderOpts == null ? void 0 : loaderOpts.maxAge : undefined;
2213
- match.load({
2214
- maxAge
2215
- });
2216
- }
2103
+ match.load(loaderOpts);
2217
2104
 
2218
2105
  if (match.status === 'loading') {
2219
2106
  // If requested, start the pending timers
2220
- if (loaderOpts != null && loaderOpts.withPending) match.__.startPending(); // Wait for the first sign of activity from the match
2221
- // This might be completion, error, or a pending state
2107
+ if (loaderOpts != null && loaderOpts.withPending) match.__.startPending();
2108
+ }
2222
2109
 
2110
+ if (match.__.loadPromise) {
2111
+ // Wait for the first sign of activity from the match
2112
+ // This might be completion, error, or a pending state
2223
2113
  await match.__.loadPromise;
2224
2114
  }
2225
2115
  });
@@ -2237,7 +2127,7 @@ function createRouter(userOptions) {
2237
2127
  }
2238
2128
  });
2239
2129
  },
2240
- reload: () => router._navigate({
2130
+ reload: () => router.__.navigate({
2241
2131
  fromCurrent: true,
2242
2132
  replace: true,
2243
2133
  search: true
@@ -2270,11 +2160,7 @@ function createRouter(userOptions) {
2270
2160
  to: next.pathname
2271
2161
  }));
2272
2162
  },
2273
- _navigate: location => {
2274
- const next = router.buildNext(location);
2275
- return router.commitLocation(next, location.replace);
2276
- },
2277
- navigate: async _ref8 => {
2163
+ navigate: async _ref7 => {
2278
2164
  let {
2279
2165
  from,
2280
2166
  to = '.',
@@ -2282,7 +2168,7 @@ function createRouter(userOptions) {
2282
2168
  hash,
2283
2169
  replace,
2284
2170
  params
2285
- } = _ref8;
2171
+ } = _ref7;
2286
2172
  // If this link simply reloads the current route,
2287
2173
  // make sure it has a new key so it will trigger a data refresh
2288
2174
  // If this `to` is a valid external URL, return
@@ -2297,7 +2183,7 @@ function createRouter(userOptions) {
2297
2183
  } catch (e) {}
2298
2184
 
2299
2185
  invariant(!isExternal, 'Attempting to navigate to external url with router.navigate!');
2300
- return router._navigate({
2186
+ return router.__.navigate({
2301
2187
  from: fromString,
2302
2188
  to: toString,
2303
2189
  search,
@@ -2306,8 +2192,8 @@ function createRouter(userOptions) {
2306
2192
  params
2307
2193
  });
2308
2194
  },
2309
- buildLink: _ref9 => {
2310
- var _preload, _ref10;
2195
+ buildLink: _ref8 => {
2196
+ var _preload, _ref9;
2311
2197
 
2312
2198
  let {
2313
2199
  from,
@@ -2323,7 +2209,7 @@ function createRouter(userOptions) {
2323
2209
  preloadGcMaxAge: userPreloadGcMaxAge,
2324
2210
  preloadDelay: userPreloadDelay,
2325
2211
  disabled
2326
- } = _ref9;
2212
+ } = _ref8;
2327
2213
 
2328
2214
  // If this link simply reloads the current route,
2329
2215
  // make sure it has a new key so it will trigger a data refresh
@@ -2347,7 +2233,7 @@ function createRouter(userOptions) {
2347
2233
  };
2348
2234
  const next = router.buildNext(nextOpts);
2349
2235
  preload = (_preload = preload) != null ? _preload : router.options.defaultPreload;
2350
- const preloadDelay = (_ref10 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultPreloadDelay) != null ? _ref10 : 0; // Compare path/hash for matches
2236
+ const preloadDelay = (_ref9 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultPreloadDelay) != null ? _ref9 : 0; // Compare path/hash for matches
2351
2237
 
2352
2238
  const pathIsEqual = router.state.location.pathname === next.pathname;
2353
2239
  const currentPathSplit = router.state.location.pathname.split('/');
@@ -2369,7 +2255,7 @@ function createRouter(userOptions) {
2369
2255
  } // All is well? Navigate!)
2370
2256
 
2371
2257
 
2372
- router._navigate(nextOpts);
2258
+ router.__.navigate(nextOpts);
2373
2259
  }
2374
2260
  }; // The click handler
2375
2261
 
@@ -2420,10 +2306,169 @@ function createRouter(userOptions) {
2420
2306
  isActive,
2421
2307
  disabled
2422
2308
  };
2309
+ },
2310
+ buildNext: opts => {
2311
+ const next = router.__.buildLocation(opts);
2312
+
2313
+ const matches = router.matchRoutes(next.pathname);
2314
+
2315
+ const __preSearchFilters = matches.map(match => {
2316
+ var _match$options$preSea;
2317
+
2318
+ return (_match$options$preSea = match.options.preSearchFilters) != null ? _match$options$preSea : [];
2319
+ }).flat().filter(Boolean);
2320
+
2321
+ const __postSearchFilters = matches.map(match => {
2322
+ var _match$options$postSe;
2323
+
2324
+ return (_match$options$postSe = match.options.postSearchFilters) != null ? _match$options$postSe : [];
2325
+ }).flat().filter(Boolean);
2326
+
2327
+ return router.__.buildLocation(_extends({}, opts, {
2328
+ __preSearchFilters,
2329
+ __postSearchFilters
2330
+ }));
2331
+ },
2332
+ __: {
2333
+ buildRouteTree: rootRouteConfig => {
2334
+ const recurseRoutes = (routeConfigs, parent) => {
2335
+ return routeConfigs.map(routeConfig => {
2336
+ const routeOptions = routeConfig.options;
2337
+ const route = createRoute(routeConfig, routeOptions, parent, router);
2338
+ const existingRoute = router.routesById[route.routeId];
2339
+
2340
+ if (existingRoute) {
2341
+ if (process.env.NODE_ENV !== 'production') {
2342
+ console.warn("Duplicate routes found with id: " + String(route.routeId), router.routesById, route);
2343
+ }
2344
+
2345
+ throw new Error();
2346
+ }
2347
+ router.routesById[route.routeId] = route;
2348
+ const children = routeConfig.children;
2349
+ route.childRoutes = children != null && children.length ? recurseRoutes(children, route) : undefined;
2350
+ return route;
2351
+ });
2352
+ };
2353
+
2354
+ const routes = recurseRoutes([rootRouteConfig]);
2355
+ return routes[0];
2356
+ },
2357
+ parseLocation: (location, previousLocation) => {
2358
+ var _location$hash$split$;
2359
+
2360
+ const parsedSearch = router.options.parseSearch(location.search);
2361
+ return {
2362
+ pathname: location.pathname,
2363
+ searchStr: location.search,
2364
+ search: replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.search, parsedSearch),
2365
+ hash: (_location$hash$split$ = location.hash.split('#').reverse()[0]) != null ? _location$hash$split$ : '',
2366
+ href: "" + location.pathname + location.search + location.hash,
2367
+ state: location.state,
2368
+ key: location.key
2369
+ };
2370
+ },
2371
+ navigate: location => {
2372
+ const next = router.buildNext(location);
2373
+ return router.__.commitLocation(next, location.replace);
2374
+ },
2375
+ buildLocation: function buildLocation(dest) {
2376
+ var _dest$from, _router$basepath, _dest$to, _last, _dest$params, _dest$__preSearchFilt, _functionalUpdate, _dest$__preSearchFilt2, _dest$__postSearchFil;
2377
+
2378
+ if (dest === void 0) {
2379
+ dest = {};
2380
+ }
2381
+
2382
+ // const resolvedFrom: Location = {
2383
+ // ...router.location,
2384
+ const fromPathname = dest.fromCurrent ? router.location.pathname : (_dest$from = dest.from) != null ? _dest$from : router.location.pathname;
2385
+
2386
+ let pathname = resolvePath((_router$basepath = router.basepath) != null ? _router$basepath : '/', fromPathname, "" + ((_dest$to = dest.to) != null ? _dest$to : '.'));
2387
+
2388
+ const fromMatches = router.matchRoutes(router.location.pathname, {
2389
+ strictParseParams: true
2390
+ });
2391
+ const toMatches = router.matchRoutes(pathname);
2392
+
2393
+ const prevParams = _extends({}, (_last = last(fromMatches)) == null ? void 0 : _last.params);
2394
+
2395
+ let nextParams = ((_dest$params = dest.params) != null ? _dest$params : true) === true ? prevParams : functionalUpdate(dest.params, prevParams);
2396
+
2397
+ if (nextParams) {
2398
+ toMatches.map(d => d.options.stringifyParams).filter(Boolean).forEach(fn => {
2399
+ Object.assign({}, nextParams, fn(nextParams));
2400
+ });
2401
+ }
2402
+
2403
+ pathname = interpolatePath(pathname, nextParams != null ? nextParams : {}); // Pre filters first
2404
+
2405
+ const preFilteredSearch = (_dest$__preSearchFilt = dest.__preSearchFilters) != null && _dest$__preSearchFilt.length ? dest.__preSearchFilters.reduce((prev, next) => next(prev), router.location.search) : router.location.search; // Then the link/navigate function
2406
+
2407
+ const destSearch = dest.search === true ? preFilteredSearch // Preserve resolvedFrom true
2408
+ : dest.search ? (_functionalUpdate = functionalUpdate(dest.search, preFilteredSearch)) != null ? _functionalUpdate : {} // Updater
2409
+ : (_dest$__preSearchFilt2 = dest.__preSearchFilters) != null && _dest$__preSearchFilt2.length ? preFilteredSearch // Preserve resolvedFrom filters
2410
+ : {}; // Then post filters
2411
+
2412
+ const postFilteredSearch = (_dest$__postSearchFil = dest.__postSearchFilters) != null && _dest$__postSearchFil.length ? dest.__postSearchFilters.reduce((prev, next) => next(prev), destSearch) : destSearch;
2413
+ const search = replaceEqualDeep(router.location.search, postFilteredSearch);
2414
+ const searchStr = router.options.stringifySearch(search);
2415
+ let hash = dest.hash === true ? router.location.hash : functionalUpdate(dest.hash, router.location.hash);
2416
+ hash = hash ? "#" + hash : '';
2417
+ return {
2418
+ pathname,
2419
+ search,
2420
+ searchStr,
2421
+ state: router.location.state,
2422
+ hash,
2423
+ href: "" + pathname + searchStr + hash,
2424
+ key: dest.key
2425
+ };
2426
+ },
2427
+ commitLocation: (next, replace) => {
2428
+ const id = '' + Date.now() + Math.random();
2429
+ if (router.navigateTimeout) clearTimeout(router.navigateTimeout);
2430
+ let nextAction = 'replace';
2431
+
2432
+ if (!replace) {
2433
+ nextAction = 'push';
2434
+ }
2435
+
2436
+ const isSameUrl = router.__.parseLocation(history.location).href === next.href;
2437
+
2438
+ if (isSameUrl && !next.key) {
2439
+ nextAction = 'replace';
2440
+ }
2441
+
2442
+ if (nextAction === 'replace') {
2443
+ history.replace({
2444
+ pathname: next.pathname,
2445
+ hash: next.hash,
2446
+ search: next.searchStr
2447
+ }, {
2448
+ id
2449
+ });
2450
+ } else {
2451
+ history.push({
2452
+ pathname: next.pathname,
2453
+ hash: next.hash,
2454
+ search: next.searchStr
2455
+ }, {
2456
+ id
2457
+ });
2458
+ }
2459
+
2460
+ router.navigationPromise = new Promise(resolve => {
2461
+ const previousNavigationResolve = router.resolveNavigation;
2462
+
2463
+ router.resolveNavigation = () => {
2464
+ previousNavigationResolve();
2465
+ resolve();
2466
+ };
2467
+ });
2468
+ return router.navigationPromise;
2469
+ }
2423
2470
  }
2424
2471
  };
2425
- router.location = router.parseLocation(history.location);
2426
- router.state.location = router.location;
2427
2472
  router.update(userOptions); // Allow frameworks to hook into the router creation
2428
2473
 
2429
2474
  router.options.createRouter == null ? void 0 : router.options.createRouter(router);
@@ -2434,7 +2479,16 @@ function isCtrlEvent(e) {
2434
2479
  return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
2435
2480
  }
2436
2481
 
2437
- exports.cascadeLoaderData = cascadeLoaderData;
2482
+ function cascadeLoaderData(matches) {
2483
+ matches.forEach((match, index) => {
2484
+ const parent = matches[index - 1];
2485
+
2486
+ if (parent) {
2487
+ match.loaderData = replaceEqualDeep(match.loaderData, _extends({}, parent.loaderData, match.routeLoaderData));
2488
+ }
2489
+ });
2490
+ }
2491
+
2438
2492
  exports.cleanPath = cleanPath;
2439
2493
  exports.createBrowserHistory = createBrowserHistory;
2440
2494
  exports.createHashHistory = createHashHistory;
@@ -2456,6 +2510,7 @@ exports.matchByPath = matchByPath;
2456
2510
  exports.matchPathname = matchPathname;
2457
2511
  exports.parsePathname = parsePathname;
2458
2512
  exports.parseSearchWith = parseSearchWith;
2513
+ exports.pick = pick;
2459
2514
  exports.replaceEqualDeep = replaceEqualDeep;
2460
2515
  exports.resolvePath = resolvePath;
2461
2516
  exports.rootRouteId = rootRouteId;