@tanstack/router-core 0.0.1-alpha.4 → 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":"c4e0-1","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"node_modules","children":[{"name":"@babel/runtime/helpers/esm/extends.js","uid":"c4e0-3"},{"name":"history/index.js","uid":"c4e0-5"},{"name":"tiny-invariant/dist/esm/tiny-invariant.js","uid":"c4e0-7"}]},{"name":"packages/router-core/src","children":[{"uid":"c4e0-9","name":"qss.ts"},{"uid":"c4e0-11","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"c4e0-1":{"renderedLength":437,"gzipLength":243,"brotliLength":0,"mainUid":"c4e0-0"},"c4e0-3":{"renderedLength":431,"gzipLength":240,"brotliLength":0,"mainUid":"c4e0-2"},"c4e0-5":{"renderedLength":20618,"gzipLength":3797,"brotliLength":0,"mainUid":"c4e0-4"},"c4e0-7":{"renderedLength":181,"gzipLength":129,"brotliLength":0,"mainUid":"c4e0-6"},"c4e0-9":{"renderedLength":1241,"gzipLength":523,"brotliLength":0,"mainUid":"c4e0-8"},"c4e0-11":{"renderedLength":46465,"gzipLength":10249,"brotliLength":0,"mainUid":"c4e0-10"}},"nodeMetas":{"c4e0-0":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"c4e0-1"},"imported":[],"importedBy":[{"uid":"c4e0-10"}]},"c4e0-2":{"id":"/node_modules/@babel/runtime/helpers/esm/extends.js","moduleParts":{"index.production.js":"c4e0-3"},"imported":[],"importedBy":[{"uid":"c4e0-4"}]},"c4e0-4":{"id":"/node_modules/history/index.js","moduleParts":{"index.production.js":"c4e0-5"},"imported":[{"uid":"c4e0-2"}],"importedBy":[{"uid":"c4e0-10"}]},"c4e0-6":{"id":"/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","moduleParts":{"index.production.js":"c4e0-7"},"imported":[],"importedBy":[{"uid":"c4e0-10"}]},"c4e0-8":{"id":"/packages/router-core/src/qss.ts","moduleParts":{"index.production.js":"c4e0-9"},"imported":[],"importedBy":[{"uid":"c4e0-10"}]},"c4e0-10":{"id":"/packages/router-core/src/index.ts","moduleParts":{"index.production.js":"c4e0-11"},"imported":[{"uid":"c4e0-0"},{"uid":"c4e0-4"},{"uid":"c4e0-6"},{"uid":"c4e0-8"}],"importedBy":[],"isEntry":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-1","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"node_modules","children":[{"name":"@babel/runtime/helpers/esm/extends.js","uid":"138f-3"},{"name":"history/index.js","uid":"138f-5"},{"name":"tiny-invariant/dist/esm/tiny-invariant.js","uid":"138f-7"}]},{"name":"packages/router-core/src","children":[{"uid":"138f-9","name":"qss.ts"},{"uid":"138f-11","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"138f-1":{"renderedLength":437,"gzipLength":243,"brotliLength":0,"mainUid":"138f-0"},"138f-3":{"renderedLength":431,"gzipLength":240,"brotliLength":0,"mainUid":"138f-2"},"138f-5":{"renderedLength":20618,"gzipLength":3797,"brotliLength":0,"mainUid":"138f-4"},"138f-7":{"renderedLength":181,"gzipLength":129,"brotliLength":0,"mainUid":"138f-6"},"138f-9":{"renderedLength":1241,"gzipLength":523,"brotliLength":0,"mainUid":"138f-8"},"138f-11":{"renderedLength":46765,"gzipLength":10333,"brotliLength":0,"mainUid":"138f-10"}},"nodeMetas":{"138f-0":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"138f-1"},"imported":[],"importedBy":[{"uid":"138f-10"}]},"138f-2":{"id":"/node_modules/@babel/runtime/helpers/esm/extends.js","moduleParts":{"index.production.js":"138f-3"},"imported":[],"importedBy":[{"uid":"138f-4"}]},"138f-4":{"id":"/node_modules/history/index.js","moduleParts":{"index.production.js":"138f-5"},"imported":[{"uid":"138f-2"}],"importedBy":[{"uid":"138f-10"}]},"138f-6":{"id":"/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","moduleParts":{"index.production.js":"138f-7"},"imported":[],"importedBy":[{"uid":"138f-10"}]},"138f-8":{"id":"/packages/router-core/src/qss.ts","moduleParts":{"index.production.js":"138f-9"},"imported":[],"importedBy":[{"uid":"138f-10"}]},"138f-10":{"id":"/packages/router-core/src/index.ts","moduleParts":{"index.production.js":"138f-11"},"imported":[{"uid":"138f-0"},{"uid":"138f-4"},{"uid":"138f-6"},{"uid":"138f-8"}],"importedBy":[],"isEntry":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": "c4e0-13",
10
+ "uid": "138f-13",
11
11
  "name": "\u0000rollupPluginBabelHelpers.js"
12
12
  },
13
13
  {
@@ -15,15 +15,15 @@
15
15
  "children": [
16
16
  {
17
17
  "name": "@babel/runtime/helpers/esm/extends.js",
18
- "uid": "c4e0-15"
18
+ "uid": "138f-15"
19
19
  },
20
20
  {
21
21
  "name": "history/index.js",
22
- "uid": "c4e0-17"
22
+ "uid": "138f-17"
23
23
  },
24
24
  {
25
25
  "name": "tiny-invariant/dist/esm/tiny-invariant.js",
26
- "uid": "c4e0-19"
26
+ "uid": "138f-19"
27
27
  }
28
28
  ]
29
29
  },
@@ -31,11 +31,11 @@
31
31
  "name": "packages/router-core/src",
32
32
  "children": [
33
33
  {
34
- "uid": "c4e0-21",
34
+ "uid": "138f-21",
35
35
  "name": "qss.ts"
36
36
  },
37
37
  {
38
- "uid": "c4e0-23",
38
+ "uid": "138f-23",
39
39
  "name": "index.ts"
40
40
  }
41
41
  ]
@@ -46,125 +46,125 @@
46
46
  "isRoot": true
47
47
  },
48
48
  "nodeParts": {
49
- "c4e0-13": {
49
+ "138f-13": {
50
50
  "renderedLength": 437,
51
51
  "gzipLength": 243,
52
52
  "brotliLength": 0,
53
- "mainUid": "c4e0-12"
53
+ "mainUid": "138f-12"
54
54
  },
55
- "c4e0-15": {
55
+ "138f-15": {
56
56
  "renderedLength": 431,
57
57
  "gzipLength": 240,
58
58
  "brotliLength": 0,
59
- "mainUid": "c4e0-14"
59
+ "mainUid": "138f-14"
60
60
  },
61
- "c4e0-17": {
61
+ "138f-17": {
62
62
  "renderedLength": 20618,
63
63
  "gzipLength": 3797,
64
64
  "brotliLength": 0,
65
- "mainUid": "c4e0-16"
65
+ "mainUid": "138f-16"
66
66
  },
67
- "c4e0-19": {
67
+ "138f-19": {
68
68
  "renderedLength": 181,
69
69
  "gzipLength": 129,
70
70
  "brotliLength": 0,
71
- "mainUid": "c4e0-18"
71
+ "mainUid": "138f-18"
72
72
  },
73
- "c4e0-21": {
73
+ "138f-21": {
74
74
  "renderedLength": 1241,
75
75
  "gzipLength": 523,
76
76
  "brotliLength": 0,
77
- "mainUid": "c4e0-20"
77
+ "mainUid": "138f-20"
78
78
  },
79
- "c4e0-23": {
80
- "renderedLength": 46465,
81
- "gzipLength": 10249,
79
+ "138f-23": {
80
+ "renderedLength": 46765,
81
+ "gzipLength": 10333,
82
82
  "brotliLength": 0,
83
- "mainUid": "c4e0-22"
83
+ "mainUid": "138f-22"
84
84
  }
85
85
  },
86
86
  "nodeMetas": {
87
- "c4e0-12": {
87
+ "138f-12": {
88
88
  "id": "\u0000rollupPluginBabelHelpers.js",
89
89
  "moduleParts": {
90
- "index.production.js": "c4e0-13"
90
+ "index.production.js": "138f-13"
91
91
  },
92
92
  "imported": [],
93
93
  "importedBy": [
94
94
  {
95
- "uid": "c4e0-22"
95
+ "uid": "138f-22"
96
96
  }
97
97
  ]
98
98
  },
99
- "c4e0-14": {
99
+ "138f-14": {
100
100
  "id": "/node_modules/@babel/runtime/helpers/esm/extends.js",
101
101
  "moduleParts": {
102
- "index.production.js": "c4e0-15"
102
+ "index.production.js": "138f-15"
103
103
  },
104
104
  "imported": [],
105
105
  "importedBy": [
106
106
  {
107
- "uid": "c4e0-16"
107
+ "uid": "138f-16"
108
108
  }
109
109
  ]
110
110
  },
111
- "c4e0-16": {
111
+ "138f-16": {
112
112
  "id": "/node_modules/history/index.js",
113
113
  "moduleParts": {
114
- "index.production.js": "c4e0-17"
114
+ "index.production.js": "138f-17"
115
115
  },
116
116
  "imported": [
117
117
  {
118
- "uid": "c4e0-14"
118
+ "uid": "138f-14"
119
119
  }
120
120
  ],
121
121
  "importedBy": [
122
122
  {
123
- "uid": "c4e0-22"
123
+ "uid": "138f-22"
124
124
  }
125
125
  ]
126
126
  },
127
- "c4e0-18": {
127
+ "138f-18": {
128
128
  "id": "/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
129
129
  "moduleParts": {
130
- "index.production.js": "c4e0-19"
130
+ "index.production.js": "138f-19"
131
131
  },
132
132
  "imported": [],
133
133
  "importedBy": [
134
134
  {
135
- "uid": "c4e0-22"
135
+ "uid": "138f-22"
136
136
  }
137
137
  ]
138
138
  },
139
- "c4e0-20": {
139
+ "138f-20": {
140
140
  "id": "/packages/router-core/src/qss.ts",
141
141
  "moduleParts": {
142
- "index.production.js": "c4e0-21"
142
+ "index.production.js": "138f-21"
143
143
  },
144
144
  "imported": [],
145
145
  "importedBy": [
146
146
  {
147
- "uid": "c4e0-22"
147
+ "uid": "138f-22"
148
148
  }
149
149
  ]
150
150
  },
151
- "c4e0-22": {
151
+ "138f-22": {
152
152
  "id": "/packages/router-core/src/index.ts",
153
153
  "moduleParts": {
154
- "index.production.js": "c4e0-23"
154
+ "index.production.js": "138f-23"
155
155
  },
156
156
  "imported": [
157
157
  {
158
- "uid": "c4e0-12"
158
+ "uid": "138f-12"
159
159
  },
160
160
  {
161
- "uid": "c4e0-16"
161
+ "uid": "138f-16"
162
162
  },
163
163
  {
164
- "uid": "c4e0-18"
164
+ "uid": "138f-18"
165
165
  },
166
166
  {
167
- "uid": "c4e0-20"
167
+ "uid": "138f-20"
168
168
  }
169
169
  ],
170
170
  "importedBy": [],
@@ -231,7 +231,8 @@ interface RouterState {
231
231
  matches: RouteMatch[];
232
232
  lastUpdated: number;
233
233
  loaderData: unknown;
234
- action?: ActionState;
234
+ currentAction?: ActionState;
235
+ latestAction?: ActionState;
235
236
  actions: Record<string, Action>;
236
237
  pending?: PendingState;
237
238
  }
@@ -318,7 +319,8 @@ interface RouterOptions<TRouteConfig extends AnyRouteConfig> {
318
319
  }
319
320
  interface Action<TPayload = unknown, TResponse = unknown> {
320
321
  submit: (submission?: TPayload) => Promise<TResponse>;
321
- latest?: ActionState;
322
+ current?: ActionState<TPayload, TResponse>;
323
+ latest?: ActionState<TPayload, TResponse>;
322
324
  pending: ActionState<TPayload, TResponse>[];
323
325
  }
324
326
  interface ActionState<TPayload = unknown, TResponse = unknown> {
@@ -344,6 +346,10 @@ interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInf
344
346
  routeTree: Route<TAllRouteInfo, RouteInfo>;
345
347
  routesById: RoutesById<TAllRouteInfo>;
346
348
  navigationPromise: Promise<void>;
349
+ removeActionQueue: {
350
+ action: Action;
351
+ actionState: ActionState;
352
+ }[];
347
353
  startedLoadingAt: number;
348
354
  destroy: () => void;
349
355
  resolveNavigation: () => void;
@@ -495,8 +501,6 @@ interface RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo
495
501
  }) => void);
496
502
  abortController: AbortController;
497
503
  latestId: string;
498
- setParentMatch: (parentMatch: RouteMatch) => void;
499
- addChildMatch: (childMatch: RouteMatch) => void;
500
504
  validate: () => void;
501
505
  startPending: () => void;
502
506
  cancelPending: () => void;
@@ -968,6 +968,7 @@
968
968
  let router = {
969
969
  options: originalOptions,
970
970
  listeners: [],
971
+ removeActionQueue: [],
971
972
  // Resolved after construction
972
973
  basepath: '',
973
974
  routeTree: undefined,
@@ -1091,12 +1092,14 @@
1091
1092
  strictParseParams: true
1092
1093
  });
1093
1094
  const toMatches = router.matchRoutes(pathname);
1094
- const prevParams = (_last = last(fromMatches)) == null ? void 0 : _last.params;
1095
+
1096
+ const prevParams = _extends$1({}, (_last = last(fromMatches)) == null ? void 0 : _last.params);
1097
+
1095
1098
  let nextParams = ((_dest$params = dest.params) != null ? _dest$params : true) === true ? prevParams : functionalUpdate(dest.params, prevParams);
1096
1099
 
1097
1100
  if (nextParams) {
1098
1101
  toMatches.map(d => d.options.stringifyParams).filter(Boolean).forEach(fn => {
1099
- Object.assign(nextParams, fn(nextParams));
1102
+ Object.assign({}, nextParams, fn(nextParams));
1100
1103
  });
1101
1104
  }
1102
1105
 
@@ -1199,22 +1202,33 @@
1199
1202
  router.startedLoadingAt = id;
1200
1203
 
1201
1204
  if (next) {
1205
+ // If the location.href has changed
1202
1206
  // Ingest the new location
1203
1207
  router.location = next;
1204
- } // Cancel any pending matches
1208
+ } // Clear out old actions
1205
1209
 
1206
1210
 
1211
+ router.removeActionQueue.forEach(_ref => {
1212
+ let {
1213
+ action,
1214
+ actionState
1215
+ } = _ref;
1216
+
1217
+ if (router.state.currentAction === actionState) {
1218
+ router.state.currentAction = undefined;
1219
+ }
1220
+
1221
+ if (action.current === actionState) {
1222
+ action.current = undefined;
1223
+ }
1224
+ });
1225
+ router.removeActionQueue = []; // Cancel any pending matches
1226
+
1207
1227
  router.cancelMatches(); // Match the routes
1208
1228
 
1209
1229
  const unloadedMatches = router.matchRoutes(location.pathname, {
1210
1230
  strictParseParams: true
1211
1231
  });
1212
- unloadedMatches.forEach((match, index) => {
1213
- const parent = unloadedMatches[index - 1];
1214
- const child = unloadedMatches[index + 1];
1215
- if (parent) match.__.setParentMatch(parent);
1216
- if (child) match.__.addChildMatch(child);
1217
- });
1218
1232
  router.state = _extends$1({}, router.state, {
1219
1233
  pending: {
1220
1234
  matches: unloadedMatches,
@@ -1395,6 +1409,7 @@
1395
1409
  };
1396
1410
 
1397
1411
  recurse([router.routeTree]);
1412
+ cascadeLoaderData(matches);
1398
1413
  return matches;
1399
1414
  },
1400
1415
  loadMatches: async (resolvedMatches, loaderOpts) => {
@@ -1473,14 +1488,14 @@
1473
1488
  const next = router.buildNext(location);
1474
1489
  return router.commitLocation(next, location.replace);
1475
1490
  },
1476
- navigate: async _ref => {
1491
+ navigate: async _ref2 => {
1477
1492
  let {
1478
1493
  from,
1479
1494
  to = '.',
1480
1495
  search,
1481
1496
  hash,
1482
1497
  replace
1483
- } = _ref;
1498
+ } = _ref2;
1484
1499
  // If this link simply reloads the current route,
1485
1500
  // make sure it has a new key so it will trigger a data refresh
1486
1501
  // If this `to` is a valid external URL, return
@@ -1502,8 +1517,8 @@
1502
1517
  hash
1503
1518
  });
1504
1519
  },
1505
- buildLink: _ref2 => {
1506
- var _preload, _ref3, _ref4;
1520
+ buildLink: _ref3 => {
1521
+ var _preload, _ref4, _ref5;
1507
1522
 
1508
1523
  let {
1509
1524
  from,
@@ -1518,7 +1533,7 @@
1518
1533
  preloadMaxAge: userPreloadMaxAge,
1519
1534
  preloadDelay: userPreloadDelay,
1520
1535
  disabled
1521
- } = _ref2;
1536
+ } = _ref3;
1522
1537
 
1523
1538
  // If this link simply reloads the current route,
1524
1539
  // make sure it has a new key so it will trigger a data refresh
@@ -1542,8 +1557,8 @@
1542
1557
  };
1543
1558
  const next = router.buildNext(nextOpts);
1544
1559
  preload = (_preload = preload) != null ? _preload : router.options.defaultLinkPreload;
1545
- const preloadMaxAge = (_ref3 = userPreloadMaxAge != null ? userPreloadMaxAge : router.options.defaultLinkPreloadMaxAge) != null ? _ref3 : 2000;
1546
- const preloadDelay = (_ref4 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultLinkPreloadDelay) != null ? _ref4 : 50; // Compare path/hash for matches
1560
+ const preloadMaxAge = (_ref4 = userPreloadMaxAge != null ? userPreloadMaxAge : router.options.defaultLinkPreloadMaxAge) != null ? _ref4 : 2000;
1561
+ const preloadDelay = (_ref5 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultLinkPreloadDelay) != null ? _ref5 : 50; // Compare path/hash for matches
1547
1562
 
1548
1563
  const pathIsEqual = router.state.location.pathname === next.pathname;
1549
1564
  const currentPathSplit = router.state.location.pathname.split('/');
@@ -1617,11 +1632,11 @@
1617
1632
  },
1618
1633
  __experimental__createSnapshot: () => {
1619
1634
  return _extends$1({}, router.state, {
1620
- matches: router.state.matches.map(_ref5 => {
1635
+ matches: router.state.matches.map(_ref6 => {
1621
1636
  let {
1622
1637
  routeLoaderData: loaderData,
1623
1638
  matchId
1624
- } = _ref5;
1639
+ } = _ref6;
1625
1640
  return {
1626
1641
  matchId,
1627
1642
  loaderData
@@ -1671,10 +1686,12 @@
1671
1686
  status: 'pending',
1672
1687
  submission
1673
1688
  };
1689
+ action.current = actionState;
1674
1690
  action.latest = actionState;
1675
1691
  action.pending.push(actionState);
1676
1692
  router.state = _extends$1({}, router.state, {
1677
- action: actionState
1693
+ currentAction: actionState,
1694
+ latestAction: actionState
1678
1695
  });
1679
1696
  router.notify();
1680
1697
 
@@ -1698,11 +1715,10 @@
1698
1715
  actionState.status = 'error';
1699
1716
  } finally {
1700
1717
  action.pending = action.pending.filter(d => d !== actionState);
1701
-
1702
- if (actionState === router.state.action) {
1703
- router.state.action = undefined;
1704
- }
1705
-
1718
+ router.removeActionQueue.push({
1719
+ action,
1720
+ actionState
1721
+ });
1706
1722
  router.notify();
1707
1723
  }
1708
1724
  }
@@ -1789,16 +1805,17 @@
1789
1805
  clearTimeout(routeMatch.__.pendingMinTimeout);
1790
1806
  delete routeMatch.__.pendingMinPromise;
1791
1807
  },
1792
- setParentMatch: parentMatch => {
1793
- routeMatch.parentMatch = parentMatch;
1794
- },
1795
- addChildMatch: childMatch => {
1796
- if (routeMatch.childMatches.find(d => d.matchId === childMatch.matchId)) {
1797
- return;
1798
- }
1799
-
1800
- routeMatch.childMatches.push(childMatch);
1801
- },
1808
+ // setParentMatch: (parentMatch?: RouteMatch) => {
1809
+ // routeMatch.parentMatch = parentMatch
1810
+ // },
1811
+ // addChildMatch: (childMatch: RouteMatch) => {
1812
+ // if (
1813
+ // routeMatch.childMatches.find((d) => d.matchId === childMatch.matchId)
1814
+ // ) {
1815
+ // return
1816
+ // }
1817
+ // routeMatch.childMatches.push(childMatch)
1818
+ // },
1802
1819
  validate: () => {
1803
1820
  var _routeMatch$parentMat, _routeMatch$parentMat2;
1804
1821
 
@@ -1902,7 +1919,6 @@
1902
1919
  }
1903
1920
 
1904
1921
  routeMatch.routeLoaderData = replaceEqualDeep(routeMatch.routeLoaderData, data);
1905
- cascadeLoaderData(routeMatch);
1906
1922
  routeMatch.error = undefined;
1907
1923
  routeMatch.status = 'success';
1908
1924
  routeMatch.updatedAt = Date.now();
@@ -1962,16 +1978,14 @@
1962
1978
  return routeMatch;
1963
1979
  }
1964
1980
 
1965
- function cascadeLoaderData(routeMatch) {
1966
- if (routeMatch.parentMatch) {
1967
- routeMatch.loaderData = replaceEqualDeep(routeMatch.loaderData, _extends$1({}, routeMatch.parentMatch.loaderData, routeMatch.routeLoaderData));
1968
- }
1981
+ function cascadeLoaderData(matches) {
1982
+ matches.forEach((match, index) => {
1983
+ const parent = matches[index - 1];
1969
1984
 
1970
- if (routeMatch.childMatches.length) {
1971
- routeMatch.childMatches.forEach(childMatch => {
1972
- cascadeLoaderData(childMatch);
1973
- });
1974
- }
1985
+ if (parent) {
1986
+ match.loaderData = replaceEqualDeep(match.loaderData, _extends$1({}, parent.loaderData, match.routeLoaderData));
1987
+ }
1988
+ });
1975
1989
  }
1976
1990
 
1977
1991
  function matchPathname(currentPathname, matchLocation) {