@tanstack/react-router 0.0.1-beta.182 → 0.0.1-beta.183

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.
@@ -11,19 +11,19 @@
11
11
  "children": [
12
12
  {
13
13
  "name": "@tanstack+store@0.0.1/node_modules/@tanstack/store/build/esm/index.js",
14
- "uid": "ff99-159"
14
+ "uid": "d5e5-159"
15
15
  },
16
16
  {
17
17
  "name": "@tanstack+react-store@0.0.1/node_modules/@tanstack/react-store/build/esm/index.js",
18
- "uid": "ff99-161"
18
+ "uid": "d5e5-161"
19
19
  },
20
20
  {
21
21
  "name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
22
- "uid": "ff99-163"
22
+ "uid": "d5e5-163"
23
23
  },
24
24
  {
25
25
  "name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
26
- "uid": "ff99-165"
26
+ "uid": "d5e5-165"
27
27
  }
28
28
  ]
29
29
  },
@@ -32,25 +32,25 @@
32
32
  "children": [
33
33
  {
34
34
  "name": "router-core/build/esm/index.js",
35
- "uid": "ff99-167"
35
+ "uid": "d5e5-167"
36
36
  },
37
37
  {
38
38
  "name": "react-router/src",
39
39
  "children": [
40
40
  {
41
- "uid": "ff99-171",
41
+ "uid": "d5e5-171",
42
42
  "name": "react.tsx"
43
43
  },
44
44
  {
45
- "uid": "ff99-173",
45
+ "uid": "d5e5-173",
46
46
  "name": "scroll-restoration.tsx"
47
47
  },
48
48
  {
49
- "uid": "ff99-175",
49
+ "uid": "d5e5-175",
50
50
  "name": "awaited.tsx"
51
51
  },
52
52
  {
53
- "uid": "ff99-177",
53
+ "uid": "d5e5-177",
54
54
  "name": "index.tsx"
55
55
  }
56
56
  ]
@@ -58,7 +58,7 @@
58
58
  ]
59
59
  },
60
60
  {
61
- "uid": "ff99-169",
61
+ "uid": "d5e5-169",
62
62
  "name": "\u0000rollupPluginBabelHelpers.js"
63
63
  }
64
64
  ]
@@ -67,302 +67,302 @@
67
67
  "isRoot": true
68
68
  },
69
69
  "nodeParts": {
70
- "ff99-159": {
70
+ "d5e5-159": {
71
71
  "renderedLength": 1843,
72
72
  "gzipLength": 644,
73
73
  "brotliLength": 0,
74
- "mainUid": "ff99-158"
74
+ "mainUid": "d5e5-158"
75
75
  },
76
- "ff99-161": {
76
+ "d5e5-161": {
77
77
  "renderedLength": 1006,
78
78
  "gzipLength": 479,
79
79
  "brotliLength": 0,
80
- "mainUid": "ff99-160"
80
+ "mainUid": "d5e5-160"
81
81
  },
82
- "ff99-163": {
82
+ "d5e5-163": {
83
83
  "renderedLength": 181,
84
84
  "gzipLength": 129,
85
85
  "brotliLength": 0,
86
- "mainUid": "ff99-162"
86
+ "mainUid": "d5e5-162"
87
87
  },
88
- "ff99-165": {
88
+ "d5e5-165": {
89
89
  "renderedLength": 44,
90
90
  "gzipLength": 62,
91
91
  "brotliLength": 0,
92
- "mainUid": "ff99-164"
92
+ "mainUid": "d5e5-164"
93
93
  },
94
- "ff99-167": {
95
- "renderedLength": 64170,
96
- "gzipLength": 15197,
94
+ "d5e5-167": {
95
+ "renderedLength": 64537,
96
+ "gzipLength": 15249,
97
97
  "brotliLength": 0,
98
- "mainUid": "ff99-166"
98
+ "mainUid": "d5e5-166"
99
99
  },
100
- "ff99-169": {
100
+ "d5e5-169": {
101
101
  "renderedLength": 429,
102
102
  "gzipLength": 238,
103
103
  "brotliLength": 0,
104
- "mainUid": "ff99-168"
104
+ "mainUid": "d5e5-168"
105
105
  },
106
- "ff99-171": {
107
- "renderedLength": 17448,
108
- "gzipLength": 3863,
106
+ "d5e5-171": {
107
+ "renderedLength": 17084,
108
+ "gzipLength": 3790,
109
109
  "brotliLength": 0,
110
- "mainUid": "ff99-170"
110
+ "mainUid": "d5e5-170"
111
111
  },
112
- "ff99-173": {
112
+ "d5e5-173": {
113
113
  "renderedLength": 466,
114
114
  "gzipLength": 228,
115
115
  "brotliLength": 0,
116
- "mainUid": "ff99-172"
116
+ "mainUid": "d5e5-172"
117
117
  },
118
- "ff99-175": {
118
+ "d5e5-175": {
119
119
  "renderedLength": 641,
120
120
  "gzipLength": 305,
121
121
  "brotliLength": 0,
122
- "mainUid": "ff99-174"
122
+ "mainUid": "d5e5-174"
123
123
  },
124
- "ff99-177": {
124
+ "d5e5-177": {
125
125
  "renderedLength": 0,
126
126
  "gzipLength": 0,
127
127
  "brotliLength": 0,
128
- "mainUid": "ff99-176"
128
+ "mainUid": "d5e5-176"
129
129
  }
130
130
  },
131
131
  "nodeMetas": {
132
- "ff99-158": {
132
+ "d5e5-158": {
133
133
  "id": "/node_modules/.pnpm/@tanstack+store@0.0.1/node_modules/@tanstack/store/build/esm/index.js",
134
134
  "moduleParts": {
135
- "index.production.js": "ff99-159"
135
+ "index.production.js": "d5e5-159"
136
136
  },
137
137
  "imported": [],
138
138
  "importedBy": [
139
139
  {
140
- "uid": "ff99-160"
140
+ "uid": "d5e5-160"
141
141
  },
142
142
  {
143
- "uid": "ff99-166"
143
+ "uid": "d5e5-166"
144
144
  }
145
145
  ]
146
146
  },
147
- "ff99-160": {
147
+ "d5e5-160": {
148
148
  "id": "/node_modules/.pnpm/@tanstack+react-store@0.0.1/node_modules/@tanstack/react-store/build/esm/index.js",
149
149
  "moduleParts": {
150
- "index.production.js": "ff99-161"
150
+ "index.production.js": "d5e5-161"
151
151
  },
152
152
  "imported": [
153
153
  {
154
- "uid": "ff99-178"
154
+ "uid": "d5e5-178"
155
155
  },
156
156
  {
157
- "uid": "ff99-158"
157
+ "uid": "d5e5-158"
158
158
  }
159
159
  ],
160
160
  "importedBy": [
161
161
  {
162
- "uid": "ff99-176"
162
+ "uid": "d5e5-176"
163
163
  },
164
164
  {
165
- "uid": "ff99-170"
165
+ "uid": "d5e5-170"
166
166
  }
167
167
  ]
168
168
  },
169
- "ff99-162": {
169
+ "d5e5-162": {
170
170
  "id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
171
171
  "moduleParts": {
172
- "index.production.js": "ff99-163"
172
+ "index.production.js": "d5e5-163"
173
173
  },
174
174
  "imported": [],
175
175
  "importedBy": [
176
176
  {
177
- "uid": "ff99-166"
177
+ "uid": "d5e5-166"
178
178
  },
179
179
  {
180
- "uid": "ff99-170"
180
+ "uid": "d5e5-170"
181
181
  }
182
182
  ]
183
183
  },
184
- "ff99-164": {
184
+ "d5e5-164": {
185
185
  "id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
186
186
  "moduleParts": {
187
- "index.production.js": "ff99-165"
187
+ "index.production.js": "d5e5-165"
188
188
  },
189
189
  "imported": [],
190
190
  "importedBy": [
191
191
  {
192
- "uid": "ff99-166"
192
+ "uid": "d5e5-166"
193
193
  },
194
194
  {
195
- "uid": "ff99-170"
195
+ "uid": "d5e5-170"
196
196
  }
197
197
  ]
198
198
  },
199
- "ff99-166": {
199
+ "d5e5-166": {
200
200
  "id": "/packages/router-core/build/esm/index.js",
201
201
  "moduleParts": {
202
- "index.production.js": "ff99-167"
202
+ "index.production.js": "d5e5-167"
203
203
  },
204
204
  "imported": [
205
205
  {
206
- "uid": "ff99-162"
206
+ "uid": "d5e5-162"
207
207
  },
208
208
  {
209
- "uid": "ff99-164"
209
+ "uid": "d5e5-164"
210
210
  },
211
211
  {
212
- "uid": "ff99-158"
212
+ "uid": "d5e5-158"
213
213
  }
214
214
  ],
215
215
  "importedBy": [
216
216
  {
217
- "uid": "ff99-176"
217
+ "uid": "d5e5-176"
218
218
  },
219
219
  {
220
- "uid": "ff99-170"
220
+ "uid": "d5e5-170"
221
221
  },
222
222
  {
223
- "uid": "ff99-172"
223
+ "uid": "d5e5-172"
224
224
  },
225
225
  {
226
- "uid": "ff99-174"
226
+ "uid": "d5e5-174"
227
227
  }
228
228
  ]
229
229
  },
230
- "ff99-168": {
230
+ "d5e5-168": {
231
231
  "id": "\u0000rollupPluginBabelHelpers.js",
232
232
  "moduleParts": {
233
- "index.production.js": "ff99-169"
233
+ "index.production.js": "d5e5-169"
234
234
  },
235
235
  "imported": [],
236
236
  "importedBy": [
237
237
  {
238
- "uid": "ff99-170"
238
+ "uid": "d5e5-170"
239
239
  }
240
240
  ]
241
241
  },
242
- "ff99-170": {
242
+ "d5e5-170": {
243
243
  "id": "/packages/react-router/src/react.tsx",
244
244
  "moduleParts": {
245
- "index.production.js": "ff99-171"
245
+ "index.production.js": "d5e5-171"
246
246
  },
247
247
  "imported": [
248
248
  {
249
- "uid": "ff99-168"
249
+ "uid": "d5e5-168"
250
250
  },
251
251
  {
252
- "uid": "ff99-179"
252
+ "uid": "d5e5-179"
253
253
  },
254
254
  {
255
- "uid": "ff99-160"
255
+ "uid": "d5e5-160"
256
256
  },
257
257
  {
258
- "uid": "ff99-162"
258
+ "uid": "d5e5-162"
259
259
  },
260
260
  {
261
- "uid": "ff99-164"
261
+ "uid": "d5e5-164"
262
262
  },
263
263
  {
264
- "uid": "ff99-166"
264
+ "uid": "d5e5-166"
265
265
  }
266
266
  ],
267
267
  "importedBy": [
268
268
  {
269
- "uid": "ff99-176"
269
+ "uid": "d5e5-176"
270
270
  },
271
271
  {
272
- "uid": "ff99-172"
272
+ "uid": "d5e5-172"
273
273
  },
274
274
  {
275
- "uid": "ff99-174"
275
+ "uid": "d5e5-174"
276
276
  }
277
277
  ]
278
278
  },
279
- "ff99-172": {
279
+ "d5e5-172": {
280
280
  "id": "/packages/react-router/src/scroll-restoration.tsx",
281
281
  "moduleParts": {
282
- "index.production.js": "ff99-173"
282
+ "index.production.js": "d5e5-173"
283
283
  },
284
284
  "imported": [
285
285
  {
286
- "uid": "ff99-179"
286
+ "uid": "d5e5-179"
287
287
  },
288
288
  {
289
- "uid": "ff99-166"
289
+ "uid": "d5e5-166"
290
290
  },
291
291
  {
292
- "uid": "ff99-170"
292
+ "uid": "d5e5-170"
293
293
  }
294
294
  ],
295
295
  "importedBy": [
296
296
  {
297
- "uid": "ff99-176"
297
+ "uid": "d5e5-176"
298
298
  }
299
299
  ]
300
300
  },
301
- "ff99-174": {
301
+ "d5e5-174": {
302
302
  "id": "/packages/react-router/src/awaited.tsx",
303
303
  "moduleParts": {
304
- "index.production.js": "ff99-175"
304
+ "index.production.js": "d5e5-175"
305
305
  },
306
306
  "imported": [
307
307
  {
308
- "uid": "ff99-166"
308
+ "uid": "d5e5-166"
309
309
  },
310
310
  {
311
- "uid": "ff99-170"
311
+ "uid": "d5e5-170"
312
312
  }
313
313
  ],
314
314
  "importedBy": [
315
315
  {
316
- "uid": "ff99-176"
316
+ "uid": "d5e5-176"
317
317
  }
318
318
  ]
319
319
  },
320
- "ff99-176": {
320
+ "d5e5-176": {
321
321
  "id": "/packages/react-router/src/index.tsx",
322
322
  "moduleParts": {
323
- "index.production.js": "ff99-177"
323
+ "index.production.js": "d5e5-177"
324
324
  },
325
325
  "imported": [
326
326
  {
327
- "uid": "ff99-160"
327
+ "uid": "d5e5-160"
328
328
  },
329
329
  {
330
- "uid": "ff99-166"
330
+ "uid": "d5e5-166"
331
331
  },
332
332
  {
333
- "uid": "ff99-170"
333
+ "uid": "d5e5-170"
334
334
  },
335
335
  {
336
- "uid": "ff99-172"
336
+ "uid": "d5e5-172"
337
337
  },
338
338
  {
339
- "uid": "ff99-174"
339
+ "uid": "d5e5-174"
340
340
  }
341
341
  ],
342
342
  "importedBy": [],
343
343
  "isEntry": true
344
344
  },
345
- "ff99-178": {
345
+ "d5e5-178": {
346
346
  "id": "use-sync-external-store/shim/with-selector",
347
347
  "moduleParts": {},
348
348
  "imported": [],
349
349
  "importedBy": [
350
350
  {
351
- "uid": "ff99-160"
351
+ "uid": "d5e5-160"
352
352
  }
353
353
  ],
354
354
  "isExternal": true
355
355
  },
356
- "ff99-179": {
356
+ "d5e5-179": {
357
357
  "id": "react",
358
358
  "moduleParts": {},
359
359
  "imported": [],
360
360
  "importedBy": [
361
361
  {
362
- "uid": "ff99-170"
362
+ "uid": "d5e5-170"
363
363
  },
364
364
  {
365
- "uid": "ff99-172"
365
+ "uid": "d5e5-172"
366
366
  }
367
367
  ],
368
368
  "isExternal": true
@@ -906,6 +906,16 @@
906
906
  return next.matchesById[id];
907
907
  });
908
908
  }
909
+ if (matchesByIdChanged || matchesChanged || pendingMatchesChanged) {
910
+ const hasPendingComponent = next.pendingMatches.some(d => {
911
+ const route = this.getRoute(d.routeId);
912
+ return !!route?.options.pendingComponent;
913
+ });
914
+ next.renderedMatchIds = hasPendingComponent ? next.pendingMatchIds : next.matchIds;
915
+ next.renderedMatches = next.renderedMatchIds.map(id => {
916
+ return next.matchesById[id];
917
+ });
918
+ }
909
919
  next.isFetching = [...next.matches, ...next.pendingMatches].some(d => d.isFetching);
910
920
  this.state = next;
911
921
  },
@@ -1119,20 +1129,10 @@
1119
1129
  return this.latestLoadPromise;
1120
1130
  };
1121
1131
  #mergeMatches = (prevMatchesById, nextMatches) => {
1122
- const nextMatchesById = {
1123
- ...prevMatchesById
1132
+ return {
1133
+ ...prevMatchesById,
1134
+ ...Object.fromEntries(nextMatches.map(match => [match.id, match]))
1124
1135
  };
1125
- let hadNew = false;
1126
- nextMatches.forEach(match => {
1127
- if (!nextMatchesById[match.id]) {
1128
- hadNew = true;
1129
- nextMatchesById[match.id] = match;
1130
- }
1131
- });
1132
- if (!hadNew) {
1133
- return prevMatchesById;
1134
- }
1135
- return nextMatchesById;
1136
1136
  };
1137
1137
  getRoute = id => {
1138
1138
  const route = this.routesById[id];
@@ -1282,14 +1282,17 @@
1282
1282
  };
1283
1283
  try {
1284
1284
  const validator = typeof route.options.validateSearch === 'object' ? route.options.validateSearch.parse : route.options.validateSearch;
1285
- const routeSearch = validator?.(parentSearchInfo.search) ?? {};
1286
- const search = {
1285
+ let routeSearch = validator?.(parentSearchInfo.search) ?? {};
1286
+ let search = {
1287
1287
  ...parentSearchInfo.search,
1288
1288
  ...routeSearch
1289
1289
  };
1290
+ routeSearch = replaceEqualDeep(match.routeSearch, routeSearch);
1291
+ search = replaceEqualDeep(match.search, search);
1290
1292
  return {
1291
- routeSearch: replaceEqualDeep(match.routeSearch, routeSearch),
1292
- search: replaceEqualDeep(match.search, search)
1293
+ routeSearch,
1294
+ search,
1295
+ searchDidChange: match.routeSearch !== routeSearch
1293
1296
  };
1294
1297
  } catch (err) {
1295
1298
  match.searchError = new SearchParamError(err.message, {
@@ -1870,7 +1873,6 @@
1870
1873
  };
1871
1874
  #commitLocation = async location => {
1872
1875
  const next = this.buildNext(location);
1873
- const id = '' + Date.now() + Math.random();
1874
1876
  if (this.navigateTimeout) clearTimeout(this.navigateTimeout);
1875
1877
  let nextAction = 'replace';
1876
1878
  if (!location.replace) {
@@ -1881,10 +1883,7 @@
1881
1883
  nextAction = 'replace';
1882
1884
  }
1883
1885
  const href = `${next.pathname}${next.searchStr}${next.hash ? `#${next.hash}` : ''}`;
1884
- this.history[nextAction === 'push' ? 'push' : 'replace'](href, {
1885
- id,
1886
- ...next.state
1887
- });
1886
+ this.history[nextAction === 'push' ? 'push' : 'replace'](href, next.state);
1888
1887
  this.resetNextScroll = location.resetScroll ?? true;
1889
1888
  return this.latestLoadPromise;
1890
1889
  };
@@ -1970,6 +1969,8 @@
1970
1969
  pendingMatchIds: [],
1971
1970
  matches: [],
1972
1971
  pendingMatches: [],
1972
+ renderedMatchIds: [],
1973
+ renderedMatches: [],
1973
1974
  lastUpdated: Date.now()
1974
1975
  };
1975
1976
  }
@@ -2372,14 +2373,7 @@
2372
2373
  const router = useRouter();
2373
2374
  const matchIds = useRouterState({
2374
2375
  select: state => {
2375
- const hasPendingComponent = state.pendingMatches.some(d => {
2376
- const route = router.getRoute(d.routeId);
2377
- return !!route?.options.pendingComponent;
2378
- });
2379
- if (hasPendingComponent) {
2380
- return state.pendingMatchIds;
2381
- }
2382
- return state.matchIds;
2376
+ return state.renderedMatchIds;
2383
2377
  }
2384
2378
  });
2385
2379
  return /*#__PURE__*/React__namespace.createElement(matchIdsContext.Provider, {
@@ -2401,7 +2395,7 @@
2401
2395
  const matchIds = React__namespace.useContext(matchIdsContext);
2402
2396
  return useRouterState({
2403
2397
  select: state => {
2404
- const matches = state.matches.slice(state.matches.findIndex(d => d.id === matchIds[0]));
2398
+ const matches = state.renderedMatches.slice(state.renderedMatches.findIndex(d => d.id === matchIds[0]));
2405
2399
  return opts?.select ? opts.select(matches) : matches;
2406
2400
  }
2407
2401
  });
@@ -2412,8 +2406,7 @@
2412
2406
  const nearestMatchRouteId = router.getRouteMatch(nearestMatchId)?.routeId;
2413
2407
  const matchRouteId = useRouterState({
2414
2408
  select: state => {
2415
- const matches = state.status === 'pending' ? state.pendingMatches : state.matches;
2416
- const match = opts?.from ? matches.find(d => d.routeId === opts?.from) : matches.find(d => d.id === nearestMatchId);
2409
+ const match = opts?.from ? state.renderedMatches.find(d => d.routeId === opts?.from) : state.renderedMatches.find(d => d.id === nearestMatchId);
2417
2410
  return match.routeId;
2418
2411
  }
2419
2412
  });
@@ -2422,8 +2415,7 @@
2422
2415
  }
2423
2416
  const matchSelection = useRouterState({
2424
2417
  select: state => {
2425
- const matches = state.status === 'pending' ? state.pendingMatches : state.matches;
2426
- const match = opts?.from ? matches.find(d => d.routeId === opts?.from) : matches.find(d => d.id === nearestMatchId);
2418
+ const match = opts?.from ? state.renderedMatches.find(d => d.routeId === opts?.from) : state.renderedMatches.find(d => d.id === nearestMatchId);
2427
2419
  invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
2428
2420
  return opts?.select ? opts.select(match) : match;
2429
2421
  }
@@ -2459,7 +2451,7 @@
2459
2451
  function useParams(opts) {
2460
2452
  return useRouterState({
2461
2453
  select: state => {
2462
- const params = last(state.matches)?.params;
2454
+ const params = last(state.renderedMatches)?.params;
2463
2455
  return opts?.select ? opts.select(params) : params;
2464
2456
  }
2465
2457
  });