@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.
@@ -4014,7 +4014,7 @@ var drawChart = (function (exports) {
4014
4014
  </script>
4015
4015
  <script>
4016
4016
  /*<!--*/
4017
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"b6e9-21","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"packages","children":[{"name":"router-core/build/esm/index.js","uid":"b6e9-23"},{"name":"react-router/src/index.tsx","uid":"b6e9-25"}]}]}],"isRoot":true},"nodeParts":{"b6e9-21":{"renderedLength":798,"gzipLength":366,"brotliLength":0,"mainUid":"b6e9-20"},"b6e9-23":{"renderedLength":68622,"gzipLength":14235,"brotliLength":0,"mainUid":"b6e9-22"},"b6e9-25":{"renderedLength":11932,"gzipLength":3067,"brotliLength":0,"mainUid":"b6e9-24"}},"nodeMetas":{"b6e9-20":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"b6e9-21"},"imported":[],"importedBy":[{"uid":"b6e9-24"}]},"b6e9-22":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"b6e9-23"},"imported":[],"importedBy":[{"uid":"b6e9-24"}]},"b6e9-24":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"b6e9-25"},"imported":[{"uid":"b6e9-20"},{"uid":"b6e9-26"},{"uid":"b6e9-27"},{"uid":"b6e9-22"}],"importedBy":[],"isEntry":true},"b6e9-26":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"b6e9-24"}],"isExternal":true},"b6e9-27":{"id":"use-sync-external-store/shim","moduleParts":{},"imported":[],"importedBy":[{"uid":"b6e9-24"}],"isExternal":true}},"env":{"rollup":"2.77.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4017
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"138f-25","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"packages","children":[{"name":"router-core/build/esm/index.js","uid":"138f-27"},{"name":"react-router/src/index.tsx","uid":"138f-29"}]}]}],"isRoot":true},"nodeParts":{"138f-25":{"renderedLength":798,"gzipLength":366,"brotliLength":0,"mainUid":"138f-24"},"138f-27":{"renderedLength":69909,"gzipLength":14557,"brotliLength":0,"mainUid":"138f-26"},"138f-29":{"renderedLength":11456,"gzipLength":2963,"brotliLength":0,"mainUid":"138f-28"}},"nodeMetas":{"138f-24":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"138f-25"},"imported":[],"importedBy":[{"uid":"138f-28"}]},"138f-26":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"138f-27"},"imported":[],"importedBy":[{"uid":"138f-28"}]},"138f-28":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"138f-29"},"imported":[{"uid":"138f-24"},{"uid":"138f-30"},{"uid":"138f-31"},{"uid":"138f-26"}],"importedBy":[],"isEntry":true},"138f-30":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"138f-28"}],"isExternal":true},"138f-31":{"id":"use-sync-external-store/shim","moduleParts":{},"imported":[],"importedBy":[{"uid":"138f-28"}],"isExternal":true}},"env":{"rollup":"2.77.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4018
4018
 
4019
4019
  const run = () => {
4020
4020
  const width = window.innerWidth;
@@ -7,7 +7,7 @@
7
7
  "name": "index.production.js",
8
8
  "children": [
9
9
  {
10
- "uid": "b6e9-29",
10
+ "uid": "138f-33",
11
11
  "name": "\u0000rollupPluginBabelHelpers.js"
12
12
  },
13
13
  {
@@ -15,11 +15,11 @@
15
15
  "children": [
16
16
  {
17
17
  "name": "router-core/build/esm/index.js",
18
- "uid": "b6e9-31"
18
+ "uid": "138f-35"
19
19
  },
20
20
  {
21
21
  "name": "react-router/src/index.tsx",
22
- "uid": "b6e9-33"
22
+ "uid": "138f-37"
23
23
  }
24
24
  ]
25
25
  }
@@ -29,90 +29,90 @@
29
29
  "isRoot": true
30
30
  },
31
31
  "nodeParts": {
32
- "b6e9-29": {
32
+ "138f-33": {
33
33
  "renderedLength": 798,
34
34
  "gzipLength": 366,
35
35
  "brotliLength": 0,
36
- "mainUid": "b6e9-28"
36
+ "mainUid": "138f-32"
37
37
  },
38
- "b6e9-31": {
39
- "renderedLength": 68622,
40
- "gzipLength": 14235,
38
+ "138f-35": {
39
+ "renderedLength": 69909,
40
+ "gzipLength": 14557,
41
41
  "brotliLength": 0,
42
- "mainUid": "b6e9-30"
42
+ "mainUid": "138f-34"
43
43
  },
44
- "b6e9-33": {
45
- "renderedLength": 11932,
46
- "gzipLength": 3067,
44
+ "138f-37": {
45
+ "renderedLength": 11456,
46
+ "gzipLength": 2963,
47
47
  "brotliLength": 0,
48
- "mainUid": "b6e9-32"
48
+ "mainUid": "138f-36"
49
49
  }
50
50
  },
51
51
  "nodeMetas": {
52
- "b6e9-28": {
52
+ "138f-32": {
53
53
  "id": "\u0000rollupPluginBabelHelpers.js",
54
54
  "moduleParts": {
55
- "index.production.js": "b6e9-29"
55
+ "index.production.js": "138f-33"
56
56
  },
57
57
  "imported": [],
58
58
  "importedBy": [
59
59
  {
60
- "uid": "b6e9-32"
60
+ "uid": "138f-36"
61
61
  }
62
62
  ]
63
63
  },
64
- "b6e9-30": {
64
+ "138f-34": {
65
65
  "id": "/packages/router-core/build/esm/index.js",
66
66
  "moduleParts": {
67
- "index.production.js": "b6e9-31"
67
+ "index.production.js": "138f-35"
68
68
  },
69
69
  "imported": [],
70
70
  "importedBy": [
71
71
  {
72
- "uid": "b6e9-32"
72
+ "uid": "138f-36"
73
73
  }
74
74
  ]
75
75
  },
76
- "b6e9-32": {
76
+ "138f-36": {
77
77
  "id": "/packages/react-router/src/index.tsx",
78
78
  "moduleParts": {
79
- "index.production.js": "b6e9-33"
79
+ "index.production.js": "138f-37"
80
80
  },
81
81
  "imported": [
82
82
  {
83
- "uid": "b6e9-28"
83
+ "uid": "138f-32"
84
84
  },
85
85
  {
86
- "uid": "b6e9-34"
86
+ "uid": "138f-38"
87
87
  },
88
88
  {
89
- "uid": "b6e9-35"
89
+ "uid": "138f-39"
90
90
  },
91
91
  {
92
- "uid": "b6e9-30"
92
+ "uid": "138f-34"
93
93
  }
94
94
  ],
95
95
  "importedBy": [],
96
96
  "isEntry": true
97
97
  },
98
- "b6e9-34": {
98
+ "138f-38": {
99
99
  "id": "react",
100
100
  "moduleParts": {},
101
101
  "imported": [],
102
102
  "importedBy": [
103
103
  {
104
- "uid": "b6e9-32"
104
+ "uid": "138f-36"
105
105
  }
106
106
  ],
107
107
  "isExternal": true
108
108
  },
109
- "b6e9-35": {
109
+ "138f-39": {
110
110
  "id": "use-sync-external-store/shim",
111
111
  "moduleParts": {},
112
112
  "imported": [],
113
113
  "importedBy": [
114
114
  {
115
- "uid": "b6e9-32"
115
+ "uid": "138f-36"
116
116
  }
117
117
  ],
118
118
  "isExternal": true
@@ -900,6 +900,15 @@
900
900
 
901
901
  return parsedPath;
902
902
  }
903
+ var prefix = 'Invariant failed';
904
+ function invariant(condition, message) {
905
+ if (condition) {
906
+ return;
907
+ }
908
+ var provided = typeof message === 'function' ? message() : message;
909
+ var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
910
+ throw new Error(value);
911
+ }
903
912
 
904
913
  // @ts-nocheck
905
914
  // We're inlining qss here for compression's sake, but we've included it as a hard dependency for the MIT license it requires.
@@ -954,7 +963,7 @@
954
963
  return out;
955
964
  }
956
965
 
957
- const createRouteConfig = function createRouteConfig(options, children, isRoot, parentId) {
966
+ const createRouteConfig = function createRouteConfig(options, children, isRoot, parentId, parentPath) {
958
967
  if (options === void 0) {
959
968
  options = {};
960
969
  }
@@ -965,8 +974,6 @@
965
974
 
966
975
  if (isRoot) {
967
976
  options.path = rootRouteId;
968
- } else {
969
- warning(!options.path, 'Routes must have a path property.');
970
977
  } // Strip the root from parentIds
971
978
 
972
979
 
@@ -974,13 +981,14 @@
974
981
  parentId = '';
975
982
  }
976
983
 
977
- let path = String(isRoot ? rootRouteId : options.path); // If the path is anything other than an index path, trim it up
984
+ let path = isRoot ? rootRouteId : options.path; // If the path is anything other than an index path, trim it up
978
985
 
979
- if (path !== '/') {
986
+ if (path && path !== '/') {
980
987
  path = trimPath(path);
981
988
  }
982
989
 
983
- let id = joinPaths([parentId, path]);
990
+ const routeId = path || options.id;
991
+ let id = joinPaths([parentId, routeId]);
984
992
 
985
993
  if (path === rootRouteId) {
986
994
  path = '/';
@@ -990,14 +998,15 @@
990
998
  id = joinPaths(['/', id]);
991
999
  }
992
1000
 
993
- const fullPath = id === rootRouteId ? '/' : trimPathRight(id);
1001
+ const fullPath = id === rootRouteId ? '/' : trimPathRight(joinPaths([parentPath, path]));
994
1002
  return {
995
1003
  id: id,
1004
+ routeId: routeId,
996
1005
  path: path,
997
1006
  fullPath: fullPath,
998
1007
  options: options,
999
1008
  children,
1000
- addChildren: cb => createRouteConfig(options, cb(childOptions => createRouteConfig(childOptions, undefined, false, id)), false, parentId)
1009
+ addChildren: cb => createRouteConfig(options, cb(childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath)), false, parentId, parentPath)
1001
1010
  };
1002
1011
  };
1003
1012
  const rootRouteId = '__root__';
@@ -1020,6 +1029,7 @@
1020
1029
  let router = {
1021
1030
  options: originalOptions,
1022
1031
  listeners: [],
1032
+ removeActionQueue: [],
1023
1033
  // Resolved after construction
1024
1034
  basepath: '',
1025
1035
  routeTree: undefined,
@@ -1143,12 +1153,14 @@
1143
1153
  strictParseParams: true
1144
1154
  });
1145
1155
  const toMatches = router.matchRoutes(pathname);
1146
- const prevParams = (_last = last(fromMatches)) == null ? void 0 : _last.params;
1156
+
1157
+ const prevParams = _extends$1({}, (_last = last(fromMatches)) == null ? void 0 : _last.params);
1158
+
1147
1159
  let nextParams = ((_dest$params = dest.params) != null ? _dest$params : true) === true ? prevParams : functionalUpdate(dest.params, prevParams);
1148
1160
 
1149
1161
  if (nextParams) {
1150
1162
  toMatches.map(d => d.options.stringifyParams).filter(Boolean).forEach(fn => {
1151
- Object.assign(nextParams, fn(nextParams));
1163
+ Object.assign({}, nextParams, fn(nextParams));
1152
1164
  });
1153
1165
  }
1154
1166
 
@@ -1251,22 +1263,33 @@
1251
1263
  router.startedLoadingAt = id;
1252
1264
 
1253
1265
  if (next) {
1266
+ // If the location.href has changed
1254
1267
  // Ingest the new location
1255
1268
  router.location = next;
1256
- } // Cancel any pending matches
1269
+ } // Clear out old actions
1270
+
1271
+
1272
+ router.removeActionQueue.forEach(_ref => {
1273
+ let {
1274
+ action,
1275
+ actionState
1276
+ } = _ref;
1277
+
1278
+ if (router.state.currentAction === actionState) {
1279
+ router.state.currentAction = undefined;
1280
+ }
1257
1281
 
1282
+ if (action.current === actionState) {
1283
+ action.current = undefined;
1284
+ }
1285
+ });
1286
+ router.removeActionQueue = []; // Cancel any pending matches
1258
1287
 
1259
1288
  router.cancelMatches(); // Match the routes
1260
1289
 
1261
1290
  const unloadedMatches = router.matchRoutes(location.pathname, {
1262
1291
  strictParseParams: true
1263
1292
  });
1264
- unloadedMatches.forEach((match, index) => {
1265
- const parent = unloadedMatches[index - 1];
1266
- const child = unloadedMatches[index + 1];
1267
- if (parent) match.__.setParentMatch(parent);
1268
- if (child) match.__.addChildMatch(child);
1269
- });
1270
1293
  router.state = _extends$1({}, router.state, {
1271
1294
  pending: {
1272
1295
  matches: unloadedMatches,
@@ -1373,59 +1396,81 @@
1373
1396
 
1374
1397
  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 : [])];
1375
1398
 
1376
- const recurse = async (routes, parentMatch) => {
1377
- var _parentMatch$params, _router$options$filte, _router$preloadCache$, _route$childRoutes2;
1399
+ const recurse = async routes => {
1400
+ var _parentMatch$params, _router$options$filte, _foundRoute$childRout;
1378
1401
 
1402
+ const parentMatch = last(matches);
1379
1403
  let params = (_parentMatch$params = parentMatch == null ? void 0 : parentMatch.params) != null ? _parentMatch$params : {};
1380
1404
  const filteredRoutes = (_router$options$filte = router.options.filterRoutes == null ? void 0 : router.options.filterRoutes(routes)) != null ? _router$options$filte : routes;
1381
- const route = filteredRoutes == null ? void 0 : filteredRoutes.find(route => {
1382
- var _route$childRoutes, _route$options$caseSe;
1383
-
1384
- const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes = route.childRoutes) != null && _route$childRoutes.length);
1385
- const matchParams = matchPathname(pathname, {
1386
- to: route.fullPath,
1387
- fuzzy,
1388
- caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
1389
- });
1405
+ let foundRoutes = [];
1390
1406
 
1391
- if (matchParams) {
1392
- let parsedParams;
1407
+ const findMatchInRoutes = (parentRoutes, routes) => {
1408
+ routes.some(route => {
1409
+ var _route$childRoutes, _route$childRoutes2, _route$options$caseSe;
1393
1410
 
1394
- try {
1395
- var _route$options$parseP;
1411
+ if (!route.routePath && (_route$childRoutes = route.childRoutes) != null && _route$childRoutes.length) {
1412
+ return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
1413
+ }
1396
1414
 
1397
- parsedParams = (_route$options$parseP = route.options.parseParams == null ? void 0 : route.options.parseParams(matchParams)) != null ? _route$options$parseP : matchParams;
1398
- } catch (err) {
1399
- if (opts != null && opts.strictParseParams) {
1400
- throw err;
1415
+ const fuzzy = !!(route.routePath !== '/' || (_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length);
1416
+ const matchParams = matchPathname(pathname, {
1417
+ to: route.fullPath,
1418
+ fuzzy,
1419
+ caseSensitive: (_route$options$caseSe = route.options.caseSensitive) != null ? _route$options$caseSe : router.options.caseSensitive
1420
+ });
1421
+
1422
+ if (matchParams) {
1423
+ let parsedParams;
1424
+
1425
+ try {
1426
+ var _route$options$parseP;
1427
+
1428
+ parsedParams = (_route$options$parseP = route.options.parseParams == null ? void 0 : route.options.parseParams(matchParams)) != null ? _route$options$parseP : matchParams;
1429
+ } catch (err) {
1430
+ if (opts != null && opts.strictParseParams) {
1431
+ throw err;
1432
+ }
1401
1433
  }
1434
+
1435
+ params = _extends$1({}, params, parsedParams);
1402
1436
  }
1403
1437
 
1404
- params = _extends$1({}, params, parsedParams);
1405
- }
1438
+ if (!!matchParams) {
1439
+ foundRoutes = [...parentRoutes, route];
1440
+ }
1406
1441
 
1407
- return !!matchParams;
1408
- });
1442
+ return !!foundRoutes.length;
1443
+ });
1444
+ return !!foundRoutes.length;
1445
+ };
1409
1446
 
1410
- if (!route) {
1447
+ findMatchInRoutes([], filteredRoutes);
1448
+
1449
+ if (!foundRoutes.length) {
1411
1450
  return;
1412
1451
  }
1413
1452
 
1414
- const interpolatedPath = interpolatePath(route.routePath, params);
1415
- const matchId = interpolatePath(route.routeId, params, true);
1416
- const match = existingMatches.find(d => d.matchId === matchId) || ((_router$preloadCache$ = router.preloadCache[matchId]) == null ? void 0 : _router$preloadCache$.match) || createRouteMatch(router, route, {
1417
- matchId,
1418
- params,
1419
- pathname: joinPaths([pathname, interpolatedPath])
1453
+ foundRoutes.forEach(foundRoute => {
1454
+ var _router$preloadCache$;
1455
+
1456
+ const interpolatedPath = interpolatePath(foundRoute.routePath, params);
1457
+ const matchId = interpolatePath(foundRoute.routeId, params, true);
1458
+ const match = existingMatches.find(d => d.matchId === matchId) || ((_router$preloadCache$ = router.preloadCache[matchId]) == null ? void 0 : _router$preloadCache$.match) || createRouteMatch(router, foundRoute, {
1459
+ matchId,
1460
+ params,
1461
+ pathname: joinPaths([pathname, interpolatedPath])
1462
+ });
1463
+ matches.push(match);
1420
1464
  });
1421
- matches.push(match);
1465
+ const foundRoute = last(foundRoutes);
1422
1466
 
1423
- if ((_route$childRoutes2 = route.childRoutes) != null && _route$childRoutes2.length) {
1424
- recurse(route.childRoutes, match);
1467
+ if ((_foundRoute$childRout = foundRoute.childRoutes) != null && _foundRoute$childRout.length) {
1468
+ recurse(foundRoute.childRoutes);
1425
1469
  }
1426
1470
  };
1427
1471
 
1428
1472
  recurse([router.routeTree]);
1473
+ cascadeLoaderData(matches);
1429
1474
  return matches;
1430
1475
  },
1431
1476
  loadMatches: async (resolvedMatches, loaderOpts) => {
@@ -1504,14 +1549,14 @@
1504
1549
  const next = router.buildNext(location);
1505
1550
  return router.commitLocation(next, location.replace);
1506
1551
  },
1507
- navigate: async _ref => {
1552
+ navigate: async _ref2 => {
1508
1553
  let {
1509
1554
  from,
1510
1555
  to = '.',
1511
1556
  search,
1512
1557
  hash,
1513
1558
  replace
1514
- } = _ref;
1559
+ } = _ref2;
1515
1560
  // If this link simply reloads the current route,
1516
1561
  // make sure it has a new key so it will trigger a data refresh
1517
1562
  // If this `to` is a valid external URL, return
@@ -1525,12 +1570,7 @@
1525
1570
  isExternal = true;
1526
1571
  } catch (e) {}
1527
1572
 
1528
- if (isExternal) {
1529
- {
1530
- throw new Error('Attempting to navigate to external url with router.navigate!');
1531
- }
1532
- }
1533
-
1573
+ invariant(!isExternal, 'Attempting to navigate to external url with router.navigate!');
1534
1574
  return router._navigate({
1535
1575
  from: fromString,
1536
1576
  to: toString,
@@ -1538,8 +1578,8 @@
1538
1578
  hash
1539
1579
  });
1540
1580
  },
1541
- buildLink: _ref2 => {
1542
- var _preload, _ref3, _ref4;
1581
+ buildLink: _ref3 => {
1582
+ var _preload, _ref4, _ref5;
1543
1583
 
1544
1584
  let {
1545
1585
  from,
@@ -1554,7 +1594,7 @@
1554
1594
  preloadMaxAge: userPreloadMaxAge,
1555
1595
  preloadDelay: userPreloadDelay,
1556
1596
  disabled
1557
- } = _ref2;
1597
+ } = _ref3;
1558
1598
 
1559
1599
  // If this link simply reloads the current route,
1560
1600
  // make sure it has a new key so it will trigger a data refresh
@@ -1578,8 +1618,8 @@
1578
1618
  };
1579
1619
  const next = router.buildNext(nextOpts);
1580
1620
  preload = (_preload = preload) != null ? _preload : router.options.defaultLinkPreload;
1581
- const preloadMaxAge = (_ref3 = userPreloadMaxAge != null ? userPreloadMaxAge : router.options.defaultLinkPreloadMaxAge) != null ? _ref3 : 2000;
1582
- const preloadDelay = (_ref4 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultLinkPreloadDelay) != null ? _ref4 : 50; // Compare path/hash for matches
1621
+ const preloadMaxAge = (_ref4 = userPreloadMaxAge != null ? userPreloadMaxAge : router.options.defaultLinkPreloadMaxAge) != null ? _ref4 : 2000;
1622
+ const preloadDelay = (_ref5 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultLinkPreloadDelay) != null ? _ref5 : 50; // Compare path/hash for matches
1583
1623
 
1584
1624
  const pathIsEqual = router.state.location.pathname === next.pathname;
1585
1625
  const currentPathSplit = router.state.location.pathname.split('/');
@@ -1653,11 +1693,11 @@
1653
1693
  },
1654
1694
  __experimental__createSnapshot: () => {
1655
1695
  return _extends$1({}, router.state, {
1656
- matches: router.state.matches.map(_ref5 => {
1696
+ matches: router.state.matches.map(_ref6 => {
1657
1697
  let {
1658
1698
  routeLoaderData: loaderData,
1659
1699
  matchId
1660
- } = _ref5;
1700
+ } = _ref6;
1661
1701
  return {
1662
1702
  matchId,
1663
1703
  loaderData
@@ -1685,13 +1725,14 @@
1685
1725
  // ]).replace(new RegExp(`^${rootRouteId}`), '')
1686
1726
  // ) as TRouteInfo['id']
1687
1727
  const {
1688
- id: routeId,
1728
+ id,
1729
+ routeId,
1689
1730
  path: routePath,
1690
1731
  fullPath
1691
1732
  } = routeConfig;
1692
1733
 
1693
- const action = router.state.actions[routeId] || (() => {
1694
- router.state.actions[routeId] = {
1734
+ const action = router.state.actions[id] || (() => {
1735
+ router.state.actions[id] = {
1695
1736
  pending: [],
1696
1737
  submit: async (submission, actionOpts) => {
1697
1738
  var _actionOpts$invalidat;
@@ -1706,10 +1747,12 @@
1706
1747
  status: 'pending',
1707
1748
  submission
1708
1749
  };
1750
+ action.current = actionState;
1709
1751
  action.latest = actionState;
1710
1752
  action.pending.push(actionState);
1711
1753
  router.state = _extends$1({}, router.state, {
1712
- action: actionState
1754
+ currentAction: actionState,
1755
+ latestAction: actionState
1713
1756
  });
1714
1757
  router.notify();
1715
1758
 
@@ -1733,20 +1776,20 @@
1733
1776
  actionState.status = 'error';
1734
1777
  } finally {
1735
1778
  action.pending = action.pending.filter(d => d !== actionState);
1736
-
1737
- if (actionState === router.state.action) {
1738
- router.state.action = undefined;
1739
- }
1740
-
1779
+ router.removeActionQueue.push({
1780
+ action,
1781
+ actionState
1782
+ });
1741
1783
  router.notify();
1742
1784
  }
1743
1785
  }
1744
1786
  };
1745
- return router.state.actions[routeId];
1787
+ return router.state.actions[id];
1746
1788
  })();
1747
1789
 
1748
1790
  let route = {
1749
- routeId,
1791
+ routeId: id,
1792
+ routeRouteId: routeId,
1750
1793
  routePath,
1751
1794
  fullPath,
1752
1795
  options,
@@ -1823,16 +1866,17 @@
1823
1866
  clearTimeout(routeMatch.__.pendingMinTimeout);
1824
1867
  delete routeMatch.__.pendingMinPromise;
1825
1868
  },
1826
- setParentMatch: parentMatch => {
1827
- routeMatch.parentMatch = parentMatch;
1828
- },
1829
- addChildMatch: childMatch => {
1830
- if (routeMatch.childMatches.find(d => d.matchId === childMatch.matchId)) {
1831
- return;
1832
- }
1833
-
1834
- routeMatch.childMatches.push(childMatch);
1835
- },
1869
+ // setParentMatch: (parentMatch?: RouteMatch) => {
1870
+ // routeMatch.parentMatch = parentMatch
1871
+ // },
1872
+ // addChildMatch: (childMatch: RouteMatch) => {
1873
+ // if (
1874
+ // routeMatch.childMatches.find((d) => d.matchId === childMatch.matchId)
1875
+ // ) {
1876
+ // return
1877
+ // }
1878
+ // routeMatch.childMatches.push(childMatch)
1879
+ // },
1836
1880
  validate: () => {
1837
1881
  var _routeMatch$parentMat, _routeMatch$parentMat2;
1838
1882
 
@@ -1936,7 +1980,6 @@
1936
1980
  }
1937
1981
 
1938
1982
  routeMatch.routeLoaderData = replaceEqualDeep(routeMatch.routeLoaderData, data);
1939
- cascadeLoaderData(routeMatch);
1940
1983
  routeMatch.error = undefined;
1941
1984
  routeMatch.status = 'success';
1942
1985
  routeMatch.updatedAt = Date.now();
@@ -1996,16 +2039,14 @@
1996
2039
  return routeMatch;
1997
2040
  }
1998
2041
 
1999
- function cascadeLoaderData(routeMatch) {
2000
- if (routeMatch.parentMatch) {
2001
- routeMatch.loaderData = replaceEqualDeep(routeMatch.loaderData, _extends$1({}, routeMatch.parentMatch.loaderData, routeMatch.routeLoaderData));
2002
- }
2042
+ function cascadeLoaderData(matches) {
2043
+ matches.forEach((match, index) => {
2044
+ const parent = matches[index - 1];
2003
2045
 
2004
- if (routeMatch.childMatches.length) {
2005
- routeMatch.childMatches.forEach(childMatch => {
2006
- cascadeLoaderData(childMatch);
2007
- });
2008
- }
2046
+ if (parent) {
2047
+ match.loaderData = replaceEqualDeep(match.loaderData, _extends$1({}, parent.loaderData, match.routeLoaderData));
2048
+ }
2049
+ });
2009
2050
  }
2010
2051
 
2011
2052
  function matchPathname(currentPathname, matchLocation) {
@@ -2483,34 +2524,21 @@
2483
2524
  useRoute: routeId => {
2484
2525
  const route = router.getRoute(routeId);
2485
2526
  useRouterSubscription(router);
2486
-
2487
- if (!route) {
2488
- throw new Error("Could not find a route for route \"" + routeId + "\"! Did you forget to add it to your route config?");
2489
- }
2490
-
2527
+ invariant(route, "Could not find a route for route \"" + routeId + "\"! Did you forget to add it to your route config?");
2491
2528
  return route;
2492
2529
  },
2493
2530
  useMatch: routeId => {
2494
- if (routeId === rootRouteId) {
2495
- throw new Error("\"" + rootRouteId + "\" cannot be used with useMatch! Did you mean to useRoute(\"" + rootRouteId + "\")?");
2496
- }
2531
+ invariant(routeId !== rootRouteId, "\"" + rootRouteId + "\" cannot be used with useMatch! Did you mean to useRoute(\"" + rootRouteId + "\")?");
2497
2532
 
2498
2533
  const runtimeMatch = _useMatch();
2499
2534
 
2500
2535
  const match = router.state.matches.find(d => d.routeId === routeId);
2501
-
2502
- if (!match) {
2503
- throw new Error("Could not find a match for route \"" + routeId + "\" being rendered in this component!");
2504
- }
2505
-
2506
- if (runtimeMatch.routeId !== (match == null ? void 0 : match.routeId)) {
2507
- 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?");
2508
- }
2509
-
2536
+ invariant(match, "Could not find a match for route \"" + routeId + "\" being rendered in this component!");
2537
+ 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?");
2510
2538
  useRouterSubscription(router);
2511
2539
 
2512
2540
  if (!match) {
2513
- throw new Error('Match not found!');
2541
+ invariant('Match not found!');
2514
2542
  }
2515
2543
 
2516
2544
  return match;
@@ -2721,6 +2749,7 @@
2721
2749
  exports.defaultParseSearch = defaultParseSearch;
2722
2750
  exports.defaultStringifySearch = defaultStringifySearch;
2723
2751
  exports.functionalUpdate = functionalUpdate;
2752
+ exports.invariant = invariant;
2724
2753
  exports.last = last;
2725
2754
  exports.matchByPath = matchByPath;
2726
2755
  exports.matchPathname = matchPathname;