@tanstack/react-router 0.0.1-beta.75 → 0.0.1-beta.77

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":"37ac-93","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"node_modules/.pnpm","children":[{"name":"tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","uid":"37ac-95"},{"name":"tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","uid":"37ac-97"}]},{"name":"packages","children":[{"name":"store/build/esm/index.js","uid":"37ac-99"},{"name":"router/build/esm/index.js","uid":"37ac-101"},{"name":"react-store/build/esm/index.js","uid":"37ac-103"},{"name":"react-router/src/index.tsx","uid":"37ac-105"}]}]}],"isRoot":true},"nodeParts":{"37ac-93":{"renderedLength":429,"gzipLength":238,"brotliLength":0,"mainUid":"37ac-92"},"37ac-95":{"renderedLength":181,"gzipLength":129,"brotliLength":0,"mainUid":"37ac-94"},"37ac-97":{"renderedLength":44,"gzipLength":62,"brotliLength":0,"mainUid":"37ac-96"},"37ac-99":{"renderedLength":1288,"gzipLength":497,"brotliLength":0,"mainUid":"37ac-98"},"37ac-101":{"renderedLength":46913,"gzipLength":11093,"brotliLength":0,"mainUid":"37ac-100"},"37ac-103":{"renderedLength":1571,"gzipLength":594,"brotliLength":0,"mainUid":"37ac-102"},"37ac-105":{"renderedLength":12591,"gzipLength":3262,"brotliLength":0,"mainUid":"37ac-104"}},"nodeMetas":{"37ac-92":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"37ac-93"},"imported":[],"importedBy":[{"uid":"37ac-104"}]},"37ac-94":{"id":"/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","moduleParts":{"index.production.js":"37ac-95"},"imported":[],"importedBy":[{"uid":"37ac-100"}]},"37ac-96":{"id":"/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","moduleParts":{"index.production.js":"37ac-97"},"imported":[],"importedBy":[{"uid":"37ac-100"}]},"37ac-98":{"id":"/packages/store/build/esm/index.js","moduleParts":{"index.production.js":"37ac-99"},"imported":[],"importedBy":[{"uid":"37ac-100"}]},"37ac-100":{"id":"/packages/router/build/esm/index.js","moduleParts":{"index.production.js":"37ac-101"},"imported":[{"uid":"37ac-94"},{"uid":"37ac-96"},{"uid":"37ac-98"}],"importedBy":[{"uid":"37ac-104"}]},"37ac-102":{"id":"/packages/react-store/build/esm/index.js","moduleParts":{"index.production.js":"37ac-103"},"imported":[{"uid":"37ac-107"}],"importedBy":[{"uid":"37ac-104"}]},"37ac-104":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"37ac-105"},"imported":[{"uid":"37ac-92"},{"uid":"37ac-106"},{"uid":"37ac-100"},{"uid":"37ac-102"}],"importedBy":[],"isEntry":true},"37ac-106":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"37ac-104"}],"isExternal":true},"37ac-107":{"id":"use-sync-external-store/shim/with-selector","moduleParts":{},"imported":[],"importedBy":[{"uid":"37ac-102"}],"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":"5d99-93","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"node_modules/.pnpm","children":[{"name":"tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","uid":"5d99-95"},{"name":"tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","uid":"5d99-97"}]},{"name":"packages","children":[{"name":"store/build/esm/index.js","uid":"5d99-99"},{"name":"router/build/esm/index.js","uid":"5d99-101"},{"name":"react-store/build/esm/index.js","uid":"5d99-103"},{"name":"react-router/src/index.tsx","uid":"5d99-105"}]}]}],"isRoot":true},"nodeParts":{"5d99-93":{"renderedLength":429,"gzipLength":238,"brotliLength":0,"mainUid":"5d99-92"},"5d99-95":{"renderedLength":181,"gzipLength":129,"brotliLength":0,"mainUid":"5d99-94"},"5d99-97":{"renderedLength":44,"gzipLength":62,"brotliLength":0,"mainUid":"5d99-96"},"5d99-99":{"renderedLength":1288,"gzipLength":497,"brotliLength":0,"mainUid":"5d99-98"},"5d99-101":{"renderedLength":48257,"gzipLength":11461,"brotliLength":0,"mainUid":"5d99-100"},"5d99-103":{"renderedLength":1571,"gzipLength":594,"brotliLength":0,"mainUid":"5d99-102"},"5d99-105":{"renderedLength":12591,"gzipLength":3262,"brotliLength":0,"mainUid":"5d99-104"}},"nodeMetas":{"5d99-92":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"5d99-93"},"imported":[],"importedBy":[{"uid":"5d99-104"}]},"5d99-94":{"id":"/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","moduleParts":{"index.production.js":"5d99-95"},"imported":[],"importedBy":[{"uid":"5d99-100"}]},"5d99-96":{"id":"/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","moduleParts":{"index.production.js":"5d99-97"},"imported":[],"importedBy":[{"uid":"5d99-100"}]},"5d99-98":{"id":"/packages/store/build/esm/index.js","moduleParts":{"index.production.js":"5d99-99"},"imported":[],"importedBy":[{"uid":"5d99-100"}]},"5d99-100":{"id":"/packages/router/build/esm/index.js","moduleParts":{"index.production.js":"5d99-101"},"imported":[{"uid":"5d99-94"},{"uid":"5d99-96"},{"uid":"5d99-98"}],"importedBy":[{"uid":"5d99-104"}]},"5d99-102":{"id":"/packages/react-store/build/esm/index.js","moduleParts":{"index.production.js":"5d99-103"},"imported":[{"uid":"5d99-107"}],"importedBy":[{"uid":"5d99-104"}]},"5d99-104":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"5d99-105"},"imported":[{"uid":"5d99-92"},{"uid":"5d99-106"},{"uid":"5d99-100"},{"uid":"5d99-102"}],"importedBy":[],"isEntry":true},"5d99-106":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"5d99-104"}],"isExternal":true},"5d99-107":{"id":"use-sync-external-store/shim/with-selector","moduleParts":{},"imported":[],"importedBy":[{"uid":"5d99-102"}],"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": "37ac-109",
10
+ "uid": "5d99-109",
11
11
  "name": "\u0000rollupPluginBabelHelpers.js"
12
12
  },
13
13
  {
@@ -15,11 +15,11 @@
15
15
  "children": [
16
16
  {
17
17
  "name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
18
- "uid": "37ac-111"
18
+ "uid": "5d99-111"
19
19
  },
20
20
  {
21
21
  "name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
22
- "uid": "37ac-113"
22
+ "uid": "5d99-113"
23
23
  }
24
24
  ]
25
25
  },
@@ -28,19 +28,19 @@
28
28
  "children": [
29
29
  {
30
30
  "name": "store/build/esm/index.js",
31
- "uid": "37ac-115"
31
+ "uid": "5d99-115"
32
32
  },
33
33
  {
34
34
  "name": "router/build/esm/index.js",
35
- "uid": "37ac-117"
35
+ "uid": "5d99-117"
36
36
  },
37
37
  {
38
38
  "name": "react-store/build/esm/index.js",
39
- "uid": "37ac-119"
39
+ "uid": "5d99-119"
40
40
  },
41
41
  {
42
42
  "name": "react-router/src/index.tsx",
43
- "uid": "37ac-121"
43
+ "uid": "5d99-121"
44
44
  }
45
45
  ]
46
46
  }
@@ -50,176 +50,176 @@
50
50
  "isRoot": true
51
51
  },
52
52
  "nodeParts": {
53
- "37ac-109": {
53
+ "5d99-109": {
54
54
  "renderedLength": 429,
55
55
  "gzipLength": 238,
56
56
  "brotliLength": 0,
57
- "mainUid": "37ac-108"
57
+ "mainUid": "5d99-108"
58
58
  },
59
- "37ac-111": {
59
+ "5d99-111": {
60
60
  "renderedLength": 181,
61
61
  "gzipLength": 129,
62
62
  "brotliLength": 0,
63
- "mainUid": "37ac-110"
63
+ "mainUid": "5d99-110"
64
64
  },
65
- "37ac-113": {
65
+ "5d99-113": {
66
66
  "renderedLength": 44,
67
67
  "gzipLength": 62,
68
68
  "brotliLength": 0,
69
- "mainUid": "37ac-112"
69
+ "mainUid": "5d99-112"
70
70
  },
71
- "37ac-115": {
71
+ "5d99-115": {
72
72
  "renderedLength": 1288,
73
73
  "gzipLength": 497,
74
74
  "brotliLength": 0,
75
- "mainUid": "37ac-114"
75
+ "mainUid": "5d99-114"
76
76
  },
77
- "37ac-117": {
78
- "renderedLength": 46913,
79
- "gzipLength": 11093,
77
+ "5d99-117": {
78
+ "renderedLength": 48257,
79
+ "gzipLength": 11461,
80
80
  "brotliLength": 0,
81
- "mainUid": "37ac-116"
81
+ "mainUid": "5d99-116"
82
82
  },
83
- "37ac-119": {
83
+ "5d99-119": {
84
84
  "renderedLength": 1571,
85
85
  "gzipLength": 594,
86
86
  "brotliLength": 0,
87
- "mainUid": "37ac-118"
87
+ "mainUid": "5d99-118"
88
88
  },
89
- "37ac-121": {
89
+ "5d99-121": {
90
90
  "renderedLength": 12591,
91
91
  "gzipLength": 3262,
92
92
  "brotliLength": 0,
93
- "mainUid": "37ac-120"
93
+ "mainUid": "5d99-120"
94
94
  }
95
95
  },
96
96
  "nodeMetas": {
97
- "37ac-108": {
97
+ "5d99-108": {
98
98
  "id": "\u0000rollupPluginBabelHelpers.js",
99
99
  "moduleParts": {
100
- "index.production.js": "37ac-109"
100
+ "index.production.js": "5d99-109"
101
101
  },
102
102
  "imported": [],
103
103
  "importedBy": [
104
104
  {
105
- "uid": "37ac-120"
105
+ "uid": "5d99-120"
106
106
  }
107
107
  ]
108
108
  },
109
- "37ac-110": {
109
+ "5d99-110": {
110
110
  "id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
111
111
  "moduleParts": {
112
- "index.production.js": "37ac-111"
112
+ "index.production.js": "5d99-111"
113
113
  },
114
114
  "imported": [],
115
115
  "importedBy": [
116
116
  {
117
- "uid": "37ac-116"
117
+ "uid": "5d99-116"
118
118
  }
119
119
  ]
120
120
  },
121
- "37ac-112": {
121
+ "5d99-112": {
122
122
  "id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
123
123
  "moduleParts": {
124
- "index.production.js": "37ac-113"
124
+ "index.production.js": "5d99-113"
125
125
  },
126
126
  "imported": [],
127
127
  "importedBy": [
128
128
  {
129
- "uid": "37ac-116"
129
+ "uid": "5d99-116"
130
130
  }
131
131
  ]
132
132
  },
133
- "37ac-114": {
133
+ "5d99-114": {
134
134
  "id": "/packages/store/build/esm/index.js",
135
135
  "moduleParts": {
136
- "index.production.js": "37ac-115"
136
+ "index.production.js": "5d99-115"
137
137
  },
138
138
  "imported": [],
139
139
  "importedBy": [
140
140
  {
141
- "uid": "37ac-116"
141
+ "uid": "5d99-116"
142
142
  }
143
143
  ]
144
144
  },
145
- "37ac-116": {
145
+ "5d99-116": {
146
146
  "id": "/packages/router/build/esm/index.js",
147
147
  "moduleParts": {
148
- "index.production.js": "37ac-117"
148
+ "index.production.js": "5d99-117"
149
149
  },
150
150
  "imported": [
151
151
  {
152
- "uid": "37ac-110"
152
+ "uid": "5d99-110"
153
153
  },
154
154
  {
155
- "uid": "37ac-112"
155
+ "uid": "5d99-112"
156
156
  },
157
157
  {
158
- "uid": "37ac-114"
158
+ "uid": "5d99-114"
159
159
  }
160
160
  ],
161
161
  "importedBy": [
162
162
  {
163
- "uid": "37ac-120"
163
+ "uid": "5d99-120"
164
164
  }
165
165
  ]
166
166
  },
167
- "37ac-118": {
167
+ "5d99-118": {
168
168
  "id": "/packages/react-store/build/esm/index.js",
169
169
  "moduleParts": {
170
- "index.production.js": "37ac-119"
170
+ "index.production.js": "5d99-119"
171
171
  },
172
172
  "imported": [
173
173
  {
174
- "uid": "37ac-123"
174
+ "uid": "5d99-123"
175
175
  }
176
176
  ],
177
177
  "importedBy": [
178
178
  {
179
- "uid": "37ac-120"
179
+ "uid": "5d99-120"
180
180
  }
181
181
  ]
182
182
  },
183
- "37ac-120": {
183
+ "5d99-120": {
184
184
  "id": "/packages/react-router/src/index.tsx",
185
185
  "moduleParts": {
186
- "index.production.js": "37ac-121"
186
+ "index.production.js": "5d99-121"
187
187
  },
188
188
  "imported": [
189
189
  {
190
- "uid": "37ac-108"
190
+ "uid": "5d99-108"
191
191
  },
192
192
  {
193
- "uid": "37ac-122"
193
+ "uid": "5d99-122"
194
194
  },
195
195
  {
196
- "uid": "37ac-116"
196
+ "uid": "5d99-116"
197
197
  },
198
198
  {
199
- "uid": "37ac-118"
199
+ "uid": "5d99-118"
200
200
  }
201
201
  ],
202
202
  "importedBy": [],
203
203
  "isEntry": true
204
204
  },
205
- "37ac-122": {
205
+ "5d99-122": {
206
206
  "id": "react",
207
207
  "moduleParts": {},
208
208
  "imported": [],
209
209
  "importedBy": [
210
210
  {
211
- "uid": "37ac-120"
211
+ "uid": "5d99-120"
212
212
  }
213
213
  ],
214
214
  "isExternal": true
215
215
  },
216
- "37ac-123": {
216
+ "5d99-123": {
217
217
  "id": "use-sync-external-store/shim/with-selector",
218
218
  "moduleParts": {},
219
219
  "imported": [],
220
220
  "importedBy": [
221
221
  {
222
- "uid": "37ac-118"
222
+ "uid": "5d99-118"
223
223
  }
224
224
  ],
225
225
  "isExternal": true
@@ -612,11 +612,11 @@
612
612
  this.router = opts.router;
613
613
  const allOptions = this.options;
614
614
  const isRoot = !allOptions?.path && !allOptions?.id;
615
- const parent = this.options?.getParentRoute?.();
615
+ this.parentRoute = this.options?.getParentRoute?.();
616
616
  if (isRoot) {
617
617
  this.path = rootRouteId;
618
618
  } else {
619
- invariant(parent, `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`);
619
+ invariant(this.parentRoute, `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`);
620
620
  }
621
621
  let path = isRoot ? rootRouteId : allOptions.path;
622
622
 
@@ -627,14 +627,14 @@
627
627
  const customId = allOptions?.id || path;
628
628
 
629
629
  // Strip the parentId prefix from the first level of children
630
- let id = isRoot ? rootRouteId : joinPaths([parent.id === rootRouteId ? '' : parent.id, customId]);
630
+ let id = isRoot ? rootRouteId : joinPaths([this.parentRoute.id === rootRouteId ? '' : this.parentRoute.id, customId]);
631
631
  if (path === rootRouteId) {
632
632
  path = '/';
633
633
  }
634
634
  if (id !== rootRouteId) {
635
635
  id = joinPaths(['/', id]);
636
636
  }
637
- const fullPath = id === rootRouteId ? '/' : trimPathRight(joinPaths([parent.fullPath, path]));
637
+ const fullPath = id === rootRouteId ? '/' : trimPathRight(joinPaths([this.parentRoute.fullPath, path]));
638
638
  this.path = path;
639
639
  this.id = id;
640
640
  // this.customId = customId as TCustomId
@@ -644,10 +644,34 @@
644
644
  this.children = children;
645
645
  return this;
646
646
  };
647
- generate = options => {
648
- invariant(false, `route.generate() is used by TanStack Router's file-based routing code generation and should not actually be called during runtime. `);
649
- };
647
+
648
+ // generate = (
649
+ // options: Omit<
650
+ // RouteOptions<
651
+ // TParentRoute,
652
+ // TCustomId,
653
+ // TPath,
654
+ // InferFullSearchSchema<TParentRoute>,
655
+ // TSearchSchema,
656
+ // TFullSearchSchema,
657
+ // TParentRoute['__types']['allParams'],
658
+ // TParams,
659
+ // TAllParams,
660
+ // TParentContext,
661
+ // TAllParentContext,
662
+ // TRouteContext,
663
+ // TContext
664
+ // >,
665
+ // 'path'
666
+ // >,
667
+ // ) => {
668
+ // invariant(
669
+ // false,
670
+ // `route.generate() is used by TanStack Router's file-based routing code generation and should not actually be called during runtime. `,
671
+ // )
672
+ // }
650
673
  }
674
+
651
675
  class RootRoute extends Route {
652
676
  constructor(options) {
653
677
  super(options);
@@ -1291,19 +1315,14 @@
1291
1315
  });
1292
1316
  };
1293
1317
  #buildRouteTree = routeTree => {
1294
- const recurseRoutes = routes => {
1318
+ const recurseRoutes = (routes, parentRoute) => {
1295
1319
  routes.forEach((route, i) => {
1296
1320
  route.init({
1297
1321
  originalIndex: i,
1298
1322
  router: this
1299
1323
  });
1300
1324
  const existingRoute = this.routesById[route.id];
1301
- if (existingRoute) {
1302
- {
1303
- console.warn(`Duplicate routes found with id: ${String(route.id)}`, this.routesById, route);
1304
- }
1305
- throw new Error();
1306
- }
1325
+ invariant(!existingRoute, `Duplicate routes found with id: ${String(route.id)}`);
1307
1326
  this.routesById[route.id] = route;
1308
1327
  const children = route.children;
1309
1328
  if (children?.length) {
@@ -1343,6 +1362,19 @@
1343
1362
  });
1344
1363
  };
1345
1364
  recurseRoutes([routeTree]);
1365
+ const recurceCheckRoutes = (routes, parentRoute) => {
1366
+ routes.forEach(route => {
1367
+ if (route.isRoot) {
1368
+ invariant(!parentRoute, 'Root routes can only be used as the root of a route tree.');
1369
+ } else {
1370
+ invariant(parentRoute ? route.parentRoute === parentRoute : true, `Expected a route with path "${route.path}" to be passed to its parent route "${route.parentRoute?.id}" in an addChildren() call, but was instead passed as a child of the "${parentRoute?.id}" route.`);
1371
+ }
1372
+ if (route.children) {
1373
+ recurceCheckRoutes(route.children, route);
1374
+ }
1375
+ });
1376
+ };
1377
+ recurceCheckRoutes([routeTree], undefined);
1346
1378
  return routeTree;
1347
1379
  };
1348
1380
  #parseLocation = previousLocation => {
@@ -1464,7 +1496,6 @@
1464
1496
  const componentTypes = ['component', 'errorComponent', 'pendingComponent'];
1465
1497
  class RouteMatch {
1466
1498
  abortController = new AbortController();
1467
- onLoaderDataListeners = new Set();
1468
1499
  constructor(router, route, opts) {
1469
1500
  Object.assign(this, {
1470
1501
  route,