@tanstack/react-router 0.0.1-beta.160 → 0.0.1-beta.161

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.
@@ -4024,7 +4024,7 @@ var drawChart = (function (exports) {
4024
4024
  </script>
4025
4025
  <script>
4026
4026
  /*<!--*/
4027
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"284f-151","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"packages","children":[{"name":"store/build/esm/index.js","uid":"284f-153"},{"name":"react-store/build/esm/index.js","uid":"284f-155"},{"name":"router-core/build/esm/index.js","uid":"284f-161"},{"name":"react-router/src/index.tsx","uid":"284f-163"}]},{"name":"node_modules/.pnpm","children":[{"name":"tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","uid":"284f-157"},{"name":"tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","uid":"284f-159"}]}]}],"isRoot":true},"nodeParts":{"284f-151":{"renderedLength":429,"gzipLength":238,"brotliLength":0,"mainUid":"284f-150"},"284f-153":{"renderedLength":1843,"gzipLength":644,"brotliLength":0,"mainUid":"284f-152"},"284f-155":{"renderedLength":1006,"gzipLength":479,"brotliLength":0,"mainUid":"284f-154"},"284f-157":{"renderedLength":181,"gzipLength":129,"brotliLength":0,"mainUid":"284f-156"},"284f-159":{"renderedLength":44,"gzipLength":62,"brotliLength":0,"mainUid":"284f-158"},"284f-161":{"renderedLength":56742,"gzipLength":13356,"brotliLength":0,"mainUid":"284f-160"},"284f-163":{"renderedLength":17095,"gzipLength":3814,"brotliLength":0,"mainUid":"284f-162"}},"nodeMetas":{"284f-150":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"284f-151"},"imported":[],"importedBy":[{"uid":"284f-162"}]},"284f-152":{"id":"/packages/store/build/esm/index.js","moduleParts":{"index.production.js":"284f-153"},"imported":[],"importedBy":[{"uid":"284f-154"}]},"284f-154":{"id":"/packages/react-store/build/esm/index.js","moduleParts":{"index.production.js":"284f-155"},"imported":[{"uid":"284f-165"},{"uid":"284f-152"}],"importedBy":[{"uid":"284f-162"},{"uid":"284f-160"}]},"284f-156":{"id":"/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","moduleParts":{"index.production.js":"284f-157"},"imported":[],"importedBy":[{"uid":"284f-162"},{"uid":"284f-160"}]},"284f-158":{"id":"/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","moduleParts":{"index.production.js":"284f-159"},"imported":[],"importedBy":[{"uid":"284f-162"},{"uid":"284f-160"}]},"284f-160":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"284f-161"},"imported":[{"uid":"284f-156"},{"uid":"284f-158"},{"uid":"284f-154"}],"importedBy":[{"uid":"284f-162"}]},"284f-162":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"284f-163"},"imported":[{"uid":"284f-150"},{"uid":"284f-164"},{"uid":"284f-154"},{"uid":"284f-156"},{"uid":"284f-158"},{"uid":"284f-160"}],"importedBy":[],"isEntry":true},"284f-164":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"284f-162"}],"isExternal":true},"284f-165":{"id":"use-sync-external-store/shim/with-selector","moduleParts":{},"imported":[],"importedBy":[{"uid":"284f-154"}],"isExternal":true}},"env":{"rollup":"2.79.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4027
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"4c32-151","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"packages","children":[{"name":"store/build/esm/index.js","uid":"4c32-153"},{"name":"react-store/build/esm/index.js","uid":"4c32-155"},{"name":"router-core/build/esm/index.js","uid":"4c32-161"},{"name":"react-router/src/index.tsx","uid":"4c32-163"}]},{"name":"node_modules/.pnpm","children":[{"name":"tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","uid":"4c32-157"},{"name":"tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","uid":"4c32-159"}]}]}],"isRoot":true},"nodeParts":{"4c32-151":{"renderedLength":429,"gzipLength":238,"brotliLength":0,"mainUid":"4c32-150"},"4c32-153":{"renderedLength":1843,"gzipLength":644,"brotliLength":0,"mainUid":"4c32-152"},"4c32-155":{"renderedLength":1006,"gzipLength":479,"brotliLength":0,"mainUid":"4c32-154"},"4c32-157":{"renderedLength":181,"gzipLength":129,"brotliLength":0,"mainUid":"4c32-156"},"4c32-159":{"renderedLength":44,"gzipLength":62,"brotliLength":0,"mainUid":"4c32-158"},"4c32-161":{"renderedLength":56934,"gzipLength":13356,"brotliLength":0,"mainUid":"4c32-160"},"4c32-163":{"renderedLength":17058,"gzipLength":3802,"brotliLength":0,"mainUid":"4c32-162"}},"nodeMetas":{"4c32-150":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"4c32-151"},"imported":[],"importedBy":[{"uid":"4c32-162"}]},"4c32-152":{"id":"/packages/store/build/esm/index.js","moduleParts":{"index.production.js":"4c32-153"},"imported":[],"importedBy":[{"uid":"4c32-154"}]},"4c32-154":{"id":"/packages/react-store/build/esm/index.js","moduleParts":{"index.production.js":"4c32-155"},"imported":[{"uid":"4c32-165"},{"uid":"4c32-152"}],"importedBy":[{"uid":"4c32-162"},{"uid":"4c32-160"}]},"4c32-156":{"id":"/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","moduleParts":{"index.production.js":"4c32-157"},"imported":[],"importedBy":[{"uid":"4c32-162"},{"uid":"4c32-160"}]},"4c32-158":{"id":"/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","moduleParts":{"index.production.js":"4c32-159"},"imported":[],"importedBy":[{"uid":"4c32-162"},{"uid":"4c32-160"}]},"4c32-160":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"4c32-161"},"imported":[{"uid":"4c32-156"},{"uid":"4c32-158"},{"uid":"4c32-154"}],"importedBy":[{"uid":"4c32-162"}]},"4c32-162":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"4c32-163"},"imported":[{"uid":"4c32-150"},{"uid":"4c32-164"},{"uid":"4c32-154"},{"uid":"4c32-156"},{"uid":"4c32-158"},{"uid":"4c32-160"}],"importedBy":[],"isEntry":true},"4c32-164":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"4c32-162"}],"isExternal":true},"4c32-165":{"id":"use-sync-external-store/shim/with-selector","moduleParts":{},"imported":[],"importedBy":[{"uid":"4c32-154"}],"isExternal":true}},"env":{"rollup":"2.79.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
4028
4028
 
4029
4029
  const run = () => {
4030
4030
  const width = window.innerWidth;
@@ -7,7 +7,7 @@
7
7
  "name": "index.production.js",
8
8
  "children": [
9
9
  {
10
- "uid": "284f-167",
10
+ "uid": "4c32-167",
11
11
  "name": "\u0000rollupPluginBabelHelpers.js"
12
12
  },
13
13
  {
@@ -15,19 +15,19 @@
15
15
  "children": [
16
16
  {
17
17
  "name": "store/build/esm/index.js",
18
- "uid": "284f-169"
18
+ "uid": "4c32-169"
19
19
  },
20
20
  {
21
21
  "name": "react-store/build/esm/index.js",
22
- "uid": "284f-171"
22
+ "uid": "4c32-171"
23
23
  },
24
24
  {
25
25
  "name": "router-core/build/esm/index.js",
26
- "uid": "284f-177"
26
+ "uid": "4c32-177"
27
27
  },
28
28
  {
29
29
  "name": "react-router/src/index.tsx",
30
- "uid": "284f-179"
30
+ "uid": "4c32-179"
31
31
  }
32
32
  ]
33
33
  },
@@ -36,11 +36,11 @@
36
36
  "children": [
37
37
  {
38
38
  "name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
39
- "uid": "284f-173"
39
+ "uid": "4c32-173"
40
40
  },
41
41
  {
42
42
  "name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
43
- "uid": "284f-175"
43
+ "uid": "4c32-175"
44
44
  }
45
45
  ]
46
46
  }
@@ -50,194 +50,194 @@
50
50
  "isRoot": true
51
51
  },
52
52
  "nodeParts": {
53
- "284f-167": {
53
+ "4c32-167": {
54
54
  "renderedLength": 429,
55
55
  "gzipLength": 238,
56
56
  "brotliLength": 0,
57
- "mainUid": "284f-166"
57
+ "mainUid": "4c32-166"
58
58
  },
59
- "284f-169": {
59
+ "4c32-169": {
60
60
  "renderedLength": 1843,
61
61
  "gzipLength": 644,
62
62
  "brotliLength": 0,
63
- "mainUid": "284f-168"
63
+ "mainUid": "4c32-168"
64
64
  },
65
- "284f-171": {
65
+ "4c32-171": {
66
66
  "renderedLength": 1006,
67
67
  "gzipLength": 479,
68
68
  "brotliLength": 0,
69
- "mainUid": "284f-170"
69
+ "mainUid": "4c32-170"
70
70
  },
71
- "284f-173": {
71
+ "4c32-173": {
72
72
  "renderedLength": 181,
73
73
  "gzipLength": 129,
74
74
  "brotliLength": 0,
75
- "mainUid": "284f-172"
75
+ "mainUid": "4c32-172"
76
76
  },
77
- "284f-175": {
77
+ "4c32-175": {
78
78
  "renderedLength": 44,
79
79
  "gzipLength": 62,
80
80
  "brotliLength": 0,
81
- "mainUid": "284f-174"
81
+ "mainUid": "4c32-174"
82
82
  },
83
- "284f-177": {
84
- "renderedLength": 56742,
83
+ "4c32-177": {
84
+ "renderedLength": 56934,
85
85
  "gzipLength": 13356,
86
86
  "brotliLength": 0,
87
- "mainUid": "284f-176"
87
+ "mainUid": "4c32-176"
88
88
  },
89
- "284f-179": {
90
- "renderedLength": 17095,
91
- "gzipLength": 3814,
89
+ "4c32-179": {
90
+ "renderedLength": 17058,
91
+ "gzipLength": 3802,
92
92
  "brotliLength": 0,
93
- "mainUid": "284f-178"
93
+ "mainUid": "4c32-178"
94
94
  }
95
95
  },
96
96
  "nodeMetas": {
97
- "284f-166": {
97
+ "4c32-166": {
98
98
  "id": "\u0000rollupPluginBabelHelpers.js",
99
99
  "moduleParts": {
100
- "index.production.js": "284f-167"
100
+ "index.production.js": "4c32-167"
101
101
  },
102
102
  "imported": [],
103
103
  "importedBy": [
104
104
  {
105
- "uid": "284f-178"
105
+ "uid": "4c32-178"
106
106
  }
107
107
  ]
108
108
  },
109
- "284f-168": {
109
+ "4c32-168": {
110
110
  "id": "/packages/store/build/esm/index.js",
111
111
  "moduleParts": {
112
- "index.production.js": "284f-169"
112
+ "index.production.js": "4c32-169"
113
113
  },
114
114
  "imported": [],
115
115
  "importedBy": [
116
116
  {
117
- "uid": "284f-170"
117
+ "uid": "4c32-170"
118
118
  }
119
119
  ]
120
120
  },
121
- "284f-170": {
121
+ "4c32-170": {
122
122
  "id": "/packages/react-store/build/esm/index.js",
123
123
  "moduleParts": {
124
- "index.production.js": "284f-171"
124
+ "index.production.js": "4c32-171"
125
125
  },
126
126
  "imported": [
127
127
  {
128
- "uid": "284f-181"
128
+ "uid": "4c32-181"
129
129
  },
130
130
  {
131
- "uid": "284f-168"
131
+ "uid": "4c32-168"
132
132
  }
133
133
  ],
134
134
  "importedBy": [
135
135
  {
136
- "uid": "284f-178"
136
+ "uid": "4c32-178"
137
137
  },
138
138
  {
139
- "uid": "284f-176"
139
+ "uid": "4c32-176"
140
140
  }
141
141
  ]
142
142
  },
143
- "284f-172": {
143
+ "4c32-172": {
144
144
  "id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
145
145
  "moduleParts": {
146
- "index.production.js": "284f-173"
146
+ "index.production.js": "4c32-173"
147
147
  },
148
148
  "imported": [],
149
149
  "importedBy": [
150
150
  {
151
- "uid": "284f-178"
151
+ "uid": "4c32-178"
152
152
  },
153
153
  {
154
- "uid": "284f-176"
154
+ "uid": "4c32-176"
155
155
  }
156
156
  ]
157
157
  },
158
- "284f-174": {
158
+ "4c32-174": {
159
159
  "id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
160
160
  "moduleParts": {
161
- "index.production.js": "284f-175"
161
+ "index.production.js": "4c32-175"
162
162
  },
163
163
  "imported": [],
164
164
  "importedBy": [
165
165
  {
166
- "uid": "284f-178"
166
+ "uid": "4c32-178"
167
167
  },
168
168
  {
169
- "uid": "284f-176"
169
+ "uid": "4c32-176"
170
170
  }
171
171
  ]
172
172
  },
173
- "284f-176": {
173
+ "4c32-176": {
174
174
  "id": "/packages/router-core/build/esm/index.js",
175
175
  "moduleParts": {
176
- "index.production.js": "284f-177"
176
+ "index.production.js": "4c32-177"
177
177
  },
178
178
  "imported": [
179
179
  {
180
- "uid": "284f-172"
180
+ "uid": "4c32-172"
181
181
  },
182
182
  {
183
- "uid": "284f-174"
183
+ "uid": "4c32-174"
184
184
  },
185
185
  {
186
- "uid": "284f-170"
186
+ "uid": "4c32-170"
187
187
  }
188
188
  ],
189
189
  "importedBy": [
190
190
  {
191
- "uid": "284f-178"
191
+ "uid": "4c32-178"
192
192
  }
193
193
  ]
194
194
  },
195
- "284f-178": {
195
+ "4c32-178": {
196
196
  "id": "/packages/react-router/src/index.tsx",
197
197
  "moduleParts": {
198
- "index.production.js": "284f-179"
198
+ "index.production.js": "4c32-179"
199
199
  },
200
200
  "imported": [
201
201
  {
202
- "uid": "284f-166"
202
+ "uid": "4c32-166"
203
203
  },
204
204
  {
205
- "uid": "284f-180"
205
+ "uid": "4c32-180"
206
206
  },
207
207
  {
208
- "uid": "284f-170"
208
+ "uid": "4c32-170"
209
209
  },
210
210
  {
211
- "uid": "284f-172"
211
+ "uid": "4c32-172"
212
212
  },
213
213
  {
214
- "uid": "284f-174"
214
+ "uid": "4c32-174"
215
215
  },
216
216
  {
217
- "uid": "284f-176"
217
+ "uid": "4c32-176"
218
218
  }
219
219
  ],
220
220
  "importedBy": [],
221
221
  "isEntry": true
222
222
  },
223
- "284f-180": {
223
+ "4c32-180": {
224
224
  "id": "react",
225
225
  "moduleParts": {},
226
226
  "imported": [],
227
227
  "importedBy": [
228
228
  {
229
- "uid": "284f-178"
229
+ "uid": "4c32-178"
230
230
  }
231
231
  ],
232
232
  "isExternal": true
233
233
  },
234
- "284f-181": {
234
+ "4c32-181": {
235
235
  "id": "use-sync-external-store/shim/with-selector",
236
236
  "moduleParts": {},
237
237
  "imported": [],
238
238
  "importedBy": [
239
239
  {
240
- "uid": "284f-170"
240
+ "uid": "4c32-170"
241
241
  }
242
242
  ],
243
243
  "isExternal": true
@@ -891,7 +891,6 @@
891
891
  onUpdate: () => {
892
892
  const prev = this.state;
893
893
  const next = this.__store.state;
894
- console.log(Object.values(next.matchesById).find(d => d.status === 'error'));
895
894
  const matchesByIdChanged = prev.matchesById !== next.matchesById;
896
895
  let matchesChanged;
897
896
  let pendingMatchesChanged;
@@ -1318,7 +1317,6 @@
1318
1317
  throw errorHandlerErr;
1319
1318
  }
1320
1319
  }
1321
- console.log('set error');
1322
1320
  this.setRouteMatch(match.id, s => ({
1323
1321
  ...s,
1324
1322
  error: err,
@@ -1371,17 +1369,17 @@
1371
1369
  const latest = this.getRouteMatch(match.id);
1372
1370
  return latest && latest.fetchedAt !== fetchedAt ? latest.loadPromise : undefined;
1373
1371
  };
1372
+ const handleIfRedirect = err => {
1373
+ if (isRedirect(err)) {
1374
+ if (!opts?.preload) {
1375
+ this.navigate(err);
1376
+ }
1377
+ return true;
1378
+ }
1379
+ return false;
1380
+ };
1374
1381
  const load = async () => {
1375
1382
  let latestPromise;
1376
- const handleError = err => {
1377
- if (isRedirect(err)) {
1378
- if (!opts?.preload) {
1379
- this.navigate(err);
1380
- }
1381
- return true;
1382
- }
1383
- return false;
1384
- };
1385
1383
  try {
1386
1384
  const componentsPromise = Promise.all(componentTypes.map(async type => {
1387
1385
  const component = route.options[type];
@@ -1398,39 +1396,48 @@
1398
1396
  if (latestPromise = checkLatest()) return await latestPromise;
1399
1397
  this.setRouteMatchData(match.id, () => loader, opts);
1400
1398
  } catch (loaderError) {
1399
+ let latestError = loaderError;
1401
1400
  if (latestPromise = checkLatest()) return await latestPromise;
1402
- handleError(loaderError);
1403
- let error = loaderError;
1404
- try {
1405
- if (route.options.onLoadError) {
1406
- route.options.onLoadError?.(loaderError);
1407
- } else {
1408
- route.options.onError?.(loaderError);
1401
+ if (handleIfRedirect(loaderError)) return;
1402
+ if (route.options.onLoadError) {
1403
+ try {
1404
+ route.options.onLoadError(loaderError);
1405
+ } catch (onLoadError) {
1406
+ latestError = onLoadError;
1407
+ if (handleIfRedirect(onLoadError)) return;
1408
+ }
1409
+ }
1410
+ if ((!route.options.onLoadError || latestError !== loaderError) && route.options.onError) {
1411
+ try {
1412
+ route.options.onError(latestError);
1413
+ } catch (onErrorError) {
1414
+ if (handleIfRedirect(onErrorError)) return;
1409
1415
  }
1410
- } catch (errorHandlerErr) {
1411
- error = errorHandlerErr;
1412
- handleError(error);
1413
1416
  }
1414
- console.log('set error');
1415
1417
  this.setRouteMatch(match.id, s => ({
1416
1418
  ...s,
1417
- error: error,
1419
+ error: loaderError,
1418
1420
  status: 'error',
1419
1421
  isFetching: false,
1420
1422
  updatedAt: Date.now()
1421
1423
  }));
1422
- console.log(this.getRouteMatch(match.id)?.status);
1423
1424
  }
1424
1425
  };
1425
- const loadPromise = load();
1426
- this.setRouteMatch(match.id, s => ({
1427
- ...s,
1428
- status: s.status !== 'success' ? 'pending' : s.status,
1429
- isFetching: true,
1430
- loadPromise,
1431
- fetchedAt,
1432
- invalid: false
1433
- }));
1426
+ let loadPromise;
1427
+ this.__store.batch(() => {
1428
+ this.setRouteMatch(match.id, s => ({
1429
+ ...s,
1430
+ // status: s.status !== 'success' ? 'pending' : s.status,
1431
+ isFetching: true,
1432
+ fetchedAt,
1433
+ invalid: false
1434
+ }));
1435
+ loadPromise = load();
1436
+ this.setRouteMatch(match.id, s => ({
1437
+ ...s,
1438
+ loadPromise
1439
+ }));
1440
+ });
1434
1441
  await loadPromise;
1435
1442
  })());
1436
1443
  });
@@ -1866,7 +1873,6 @@
1866
1873
  const updatedAt = opts?.updatedAt ?? Date.now();
1867
1874
  const preloadInvalidAt = updatedAt + (opts?.maxAge ?? route.options.preloadMaxAge ?? this.options.defaultPreloadMaxAge ?? 5000);
1868
1875
  const invalidAt = updatedAt + (opts?.maxAge ?? route.options.maxAge ?? this.options.defaultMaxAge ?? Infinity);
1869
- console.log('set success');
1870
1876
  this.setRouteMatch(id, s => ({
1871
1877
  ...s,
1872
1878
  error: undefined,
@@ -2176,7 +2182,6 @@
2176
2182
  return !!route?.options.pendingComponent;
2177
2183
  });
2178
2184
  if (hasPendingComponent) {
2179
- console.log('hasPending');
2180
2185
  return state.pendingMatchIds;
2181
2186
  }
2182
2187
  return state.matchIds;