@tanstack/react-router 0.0.1-beta.156 → 0.0.1-beta.158

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":"f64d-151","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"packages","children":[{"name":"store/build/esm/index.js","uid":"f64d-153"},{"name":"react-store/build/esm/index.js","uid":"f64d-155"},{"name":"router-core/build/esm/index.js","uid":"f64d-161"},{"name":"react-router/src/index.tsx","uid":"f64d-163"}]},{"name":"node_modules/.pnpm","children":[{"name":"tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","uid":"f64d-157"},{"name":"tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","uid":"f64d-159"}]}]}],"isRoot":true},"nodeParts":{"f64d-151":{"renderedLength":429,"gzipLength":238,"brotliLength":0,"mainUid":"f64d-150"},"f64d-153":{"renderedLength":1843,"gzipLength":644,"brotliLength":0,"mainUid":"f64d-152"},"f64d-155":{"renderedLength":1006,"gzipLength":479,"brotliLength":0,"mainUid":"f64d-154"},"f64d-157":{"renderedLength":181,"gzipLength":129,"brotliLength":0,"mainUid":"f64d-156"},"f64d-159":{"renderedLength":44,"gzipLength":62,"brotliLength":0,"mainUid":"f64d-158"},"f64d-161":{"renderedLength":56115,"gzipLength":13303,"brotliLength":0,"mainUid":"f64d-160"},"f64d-163":{"renderedLength":17095,"gzipLength":3814,"brotliLength":0,"mainUid":"f64d-162"}},"nodeMetas":{"f64d-150":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"f64d-151"},"imported":[],"importedBy":[{"uid":"f64d-162"}]},"f64d-152":{"id":"/packages/store/build/esm/index.js","moduleParts":{"index.production.js":"f64d-153"},"imported":[],"importedBy":[{"uid":"f64d-154"}]},"f64d-154":{"id":"/packages/react-store/build/esm/index.js","moduleParts":{"index.production.js":"f64d-155"},"imported":[{"uid":"f64d-165"},{"uid":"f64d-152"}],"importedBy":[{"uid":"f64d-162"},{"uid":"f64d-160"}]},"f64d-156":{"id":"/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","moduleParts":{"index.production.js":"f64d-157"},"imported":[],"importedBy":[{"uid":"f64d-162"},{"uid":"f64d-160"}]},"f64d-158":{"id":"/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","moduleParts":{"index.production.js":"f64d-159"},"imported":[],"importedBy":[{"uid":"f64d-162"},{"uid":"f64d-160"}]},"f64d-160":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"f64d-161"},"imported":[{"uid":"f64d-156"},{"uid":"f64d-158"},{"uid":"f64d-154"}],"importedBy":[{"uid":"f64d-162"}]},"f64d-162":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"f64d-163"},"imported":[{"uid":"f64d-150"},{"uid":"f64d-164"},{"uid":"f64d-154"},{"uid":"f64d-156"},{"uid":"f64d-158"},{"uid":"f64d-160"}],"importedBy":[],"isEntry":true},"f64d-164":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"f64d-162"}],"isExternal":true},"f64d-165":{"id":"use-sync-external-store/shim/with-selector","moduleParts":{},"imported":[],"importedBy":[{"uid":"f64d-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":"b487-151","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"packages","children":[{"name":"store/build/esm/index.js","uid":"b487-153"},{"name":"react-store/build/esm/index.js","uid":"b487-155"},{"name":"router-core/build/esm/index.js","uid":"b487-161"},{"name":"react-router/src/index.tsx","uid":"b487-163"}]},{"name":"node_modules/.pnpm","children":[{"name":"tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","uid":"b487-157"},{"name":"tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","uid":"b487-159"}]}]}],"isRoot":true},"nodeParts":{"b487-151":{"renderedLength":429,"gzipLength":238,"brotliLength":0,"mainUid":"b487-150"},"b487-153":{"renderedLength":1843,"gzipLength":644,"brotliLength":0,"mainUid":"b487-152"},"b487-155":{"renderedLength":1006,"gzipLength":479,"brotliLength":0,"mainUid":"b487-154"},"b487-157":{"renderedLength":181,"gzipLength":129,"brotliLength":0,"mainUid":"b487-156"},"b487-159":{"renderedLength":44,"gzipLength":62,"brotliLength":0,"mainUid":"b487-158"},"b487-161":{"renderedLength":56305,"gzipLength":13276,"brotliLength":0,"mainUid":"b487-160"},"b487-163":{"renderedLength":17095,"gzipLength":3814,"brotliLength":0,"mainUid":"b487-162"}},"nodeMetas":{"b487-150":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"b487-151"},"imported":[],"importedBy":[{"uid":"b487-162"}]},"b487-152":{"id":"/packages/store/build/esm/index.js","moduleParts":{"index.production.js":"b487-153"},"imported":[],"importedBy":[{"uid":"b487-154"}]},"b487-154":{"id":"/packages/react-store/build/esm/index.js","moduleParts":{"index.production.js":"b487-155"},"imported":[{"uid":"b487-165"},{"uid":"b487-152"}],"importedBy":[{"uid":"b487-162"},{"uid":"b487-160"}]},"b487-156":{"id":"/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","moduleParts":{"index.production.js":"b487-157"},"imported":[],"importedBy":[{"uid":"b487-162"},{"uid":"b487-160"}]},"b487-158":{"id":"/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","moduleParts":{"index.production.js":"b487-159"},"imported":[],"importedBy":[{"uid":"b487-162"},{"uid":"b487-160"}]},"b487-160":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"b487-161"},"imported":[{"uid":"b487-156"},{"uid":"b487-158"},{"uid":"b487-154"}],"importedBy":[{"uid":"b487-162"}]},"b487-162":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"b487-163"},"imported":[{"uid":"b487-150"},{"uid":"b487-164"},{"uid":"b487-154"},{"uid":"b487-156"},{"uid":"b487-158"},{"uid":"b487-160"}],"importedBy":[],"isEntry":true},"b487-164":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"b487-162"}],"isExternal":true},"b487-165":{"id":"use-sync-external-store/shim/with-selector","moduleParts":{},"imported":[],"importedBy":[{"uid":"b487-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": "f64d-167",
10
+ "uid": "b487-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": "f64d-169"
18
+ "uid": "b487-169"
19
19
  },
20
20
  {
21
21
  "name": "react-store/build/esm/index.js",
22
- "uid": "f64d-171"
22
+ "uid": "b487-171"
23
23
  },
24
24
  {
25
25
  "name": "router-core/build/esm/index.js",
26
- "uid": "f64d-177"
26
+ "uid": "b487-177"
27
27
  },
28
28
  {
29
29
  "name": "react-router/src/index.tsx",
30
- "uid": "f64d-179"
30
+ "uid": "b487-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": "f64d-173"
39
+ "uid": "b487-173"
40
40
  },
41
41
  {
42
42
  "name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
43
- "uid": "f64d-175"
43
+ "uid": "b487-175"
44
44
  }
45
45
  ]
46
46
  }
@@ -50,194 +50,194 @@
50
50
  "isRoot": true
51
51
  },
52
52
  "nodeParts": {
53
- "f64d-167": {
53
+ "b487-167": {
54
54
  "renderedLength": 429,
55
55
  "gzipLength": 238,
56
56
  "brotliLength": 0,
57
- "mainUid": "f64d-166"
57
+ "mainUid": "b487-166"
58
58
  },
59
- "f64d-169": {
59
+ "b487-169": {
60
60
  "renderedLength": 1843,
61
61
  "gzipLength": 644,
62
62
  "brotliLength": 0,
63
- "mainUid": "f64d-168"
63
+ "mainUid": "b487-168"
64
64
  },
65
- "f64d-171": {
65
+ "b487-171": {
66
66
  "renderedLength": 1006,
67
67
  "gzipLength": 479,
68
68
  "brotliLength": 0,
69
- "mainUid": "f64d-170"
69
+ "mainUid": "b487-170"
70
70
  },
71
- "f64d-173": {
71
+ "b487-173": {
72
72
  "renderedLength": 181,
73
73
  "gzipLength": 129,
74
74
  "brotliLength": 0,
75
- "mainUid": "f64d-172"
75
+ "mainUid": "b487-172"
76
76
  },
77
- "f64d-175": {
77
+ "b487-175": {
78
78
  "renderedLength": 44,
79
79
  "gzipLength": 62,
80
80
  "brotliLength": 0,
81
- "mainUid": "f64d-174"
81
+ "mainUid": "b487-174"
82
82
  },
83
- "f64d-177": {
84
- "renderedLength": 56115,
85
- "gzipLength": 13303,
83
+ "b487-177": {
84
+ "renderedLength": 56305,
85
+ "gzipLength": 13276,
86
86
  "brotliLength": 0,
87
- "mainUid": "f64d-176"
87
+ "mainUid": "b487-176"
88
88
  },
89
- "f64d-179": {
89
+ "b487-179": {
90
90
  "renderedLength": 17095,
91
91
  "gzipLength": 3814,
92
92
  "brotliLength": 0,
93
- "mainUid": "f64d-178"
93
+ "mainUid": "b487-178"
94
94
  }
95
95
  },
96
96
  "nodeMetas": {
97
- "f64d-166": {
97
+ "b487-166": {
98
98
  "id": "\u0000rollupPluginBabelHelpers.js",
99
99
  "moduleParts": {
100
- "index.production.js": "f64d-167"
100
+ "index.production.js": "b487-167"
101
101
  },
102
102
  "imported": [],
103
103
  "importedBy": [
104
104
  {
105
- "uid": "f64d-178"
105
+ "uid": "b487-178"
106
106
  }
107
107
  ]
108
108
  },
109
- "f64d-168": {
109
+ "b487-168": {
110
110
  "id": "/packages/store/build/esm/index.js",
111
111
  "moduleParts": {
112
- "index.production.js": "f64d-169"
112
+ "index.production.js": "b487-169"
113
113
  },
114
114
  "imported": [],
115
115
  "importedBy": [
116
116
  {
117
- "uid": "f64d-170"
117
+ "uid": "b487-170"
118
118
  }
119
119
  ]
120
120
  },
121
- "f64d-170": {
121
+ "b487-170": {
122
122
  "id": "/packages/react-store/build/esm/index.js",
123
123
  "moduleParts": {
124
- "index.production.js": "f64d-171"
124
+ "index.production.js": "b487-171"
125
125
  },
126
126
  "imported": [
127
127
  {
128
- "uid": "f64d-181"
128
+ "uid": "b487-181"
129
129
  },
130
130
  {
131
- "uid": "f64d-168"
131
+ "uid": "b487-168"
132
132
  }
133
133
  ],
134
134
  "importedBy": [
135
135
  {
136
- "uid": "f64d-178"
136
+ "uid": "b487-178"
137
137
  },
138
138
  {
139
- "uid": "f64d-176"
139
+ "uid": "b487-176"
140
140
  }
141
141
  ]
142
142
  },
143
- "f64d-172": {
143
+ "b487-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": "f64d-173"
146
+ "index.production.js": "b487-173"
147
147
  },
148
148
  "imported": [],
149
149
  "importedBy": [
150
150
  {
151
- "uid": "f64d-178"
151
+ "uid": "b487-178"
152
152
  },
153
153
  {
154
- "uid": "f64d-176"
154
+ "uid": "b487-176"
155
155
  }
156
156
  ]
157
157
  },
158
- "f64d-174": {
158
+ "b487-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": "f64d-175"
161
+ "index.production.js": "b487-175"
162
162
  },
163
163
  "imported": [],
164
164
  "importedBy": [
165
165
  {
166
- "uid": "f64d-178"
166
+ "uid": "b487-178"
167
167
  },
168
168
  {
169
- "uid": "f64d-176"
169
+ "uid": "b487-176"
170
170
  }
171
171
  ]
172
172
  },
173
- "f64d-176": {
173
+ "b487-176": {
174
174
  "id": "/packages/router-core/build/esm/index.js",
175
175
  "moduleParts": {
176
- "index.production.js": "f64d-177"
176
+ "index.production.js": "b487-177"
177
177
  },
178
178
  "imported": [
179
179
  {
180
- "uid": "f64d-172"
180
+ "uid": "b487-172"
181
181
  },
182
182
  {
183
- "uid": "f64d-174"
183
+ "uid": "b487-174"
184
184
  },
185
185
  {
186
- "uid": "f64d-170"
186
+ "uid": "b487-170"
187
187
  }
188
188
  ],
189
189
  "importedBy": [
190
190
  {
191
- "uid": "f64d-178"
191
+ "uid": "b487-178"
192
192
  }
193
193
  ]
194
194
  },
195
- "f64d-178": {
195
+ "b487-178": {
196
196
  "id": "/packages/react-router/src/index.tsx",
197
197
  "moduleParts": {
198
- "index.production.js": "f64d-179"
198
+ "index.production.js": "b487-179"
199
199
  },
200
200
  "imported": [
201
201
  {
202
- "uid": "f64d-166"
202
+ "uid": "b487-166"
203
203
  },
204
204
  {
205
- "uid": "f64d-180"
205
+ "uid": "b487-180"
206
206
  },
207
207
  {
208
- "uid": "f64d-170"
208
+ "uid": "b487-170"
209
209
  },
210
210
  {
211
- "uid": "f64d-172"
211
+ "uid": "b487-172"
212
212
  },
213
213
  {
214
- "uid": "f64d-174"
214
+ "uid": "b487-174"
215
215
  },
216
216
  {
217
- "uid": "f64d-176"
217
+ "uid": "b487-176"
218
218
  }
219
219
  ],
220
220
  "importedBy": [],
221
221
  "isEntry": true
222
222
  },
223
- "f64d-180": {
223
+ "b487-180": {
224
224
  "id": "react",
225
225
  "moduleParts": {},
226
226
  "imported": [],
227
227
  "importedBy": [
228
228
  {
229
- "uid": "f64d-178"
229
+ "uid": "b487-178"
230
230
  }
231
231
  ],
232
232
  "isExternal": true
233
233
  },
234
- "f64d-181": {
234
+ "b487-181": {
235
235
  "id": "use-sync-external-store/shim/with-selector",
236
236
  "moduleParts": {},
237
237
  "imported": [],
238
238
  "importedBy": [
239
239
  {
240
- "uid": "f64d-170"
240
+ "uid": "b487-170"
241
241
  }
242
242
  ],
243
243
  "isExternal": true
@@ -811,7 +811,7 @@
811
811
  }
812
812
 
813
813
  const defaultParseSearch = parseSearchWith(JSON.parse);
814
- const defaultStringifySearch = stringifySearchWith(JSON.stringify);
814
+ const defaultStringifySearch = stringifySearchWith(JSON.stringify, JSON.parse);
815
815
  function parseSearchWith(parser) {
816
816
  return searchStr => {
817
817
  if (searchStr.substring(0, 1) === '?') {
@@ -833,7 +833,26 @@
833
833
  return query;
834
834
  };
835
835
  }
836
- function stringifySearchWith(stringify) {
836
+ function stringifySearchWith(stringify, parser) {
837
+ function stringifyValue(val) {
838
+ if (typeof val === 'object' && val !== null) {
839
+ try {
840
+ return stringify(val);
841
+ } catch (err) {
842
+ // silent
843
+ }
844
+ } else if (typeof val === 'string' && typeof parser === 'function') {
845
+ try {
846
+ // Check if it's a valid parseable string.
847
+ // If it is, then stringify it again.
848
+ parser(val);
849
+ return stringify(val);
850
+ } catch (err) {
851
+ // silent
852
+ }
853
+ }
854
+ return val;
855
+ }
837
856
  return search => {
838
857
  search = {
839
858
  ...search
@@ -843,12 +862,10 @@
843
862
  const val = search[key];
844
863
  if (typeof val === 'undefined' || val === undefined) {
845
864
  delete search[key];
846
- } else if (val && typeof val === 'object' && val !== null) {
847
- try {
848
- search[key] = stringify(val);
849
- } catch (err) {
850
- // silent
851
- }
865
+ } else if (Array.isArray(val)) {
866
+ search[key] = val.map(stringifyValue);
867
+ } else {
868
+ search[key] = stringifyValue(val);
852
869
  }
853
870
  });
854
871
  }
@@ -1124,42 +1141,36 @@
1124
1141
  if (routeCursor) matchedRoutes.unshift(routeCursor);
1125
1142
  }
1126
1143
 
1127
- // Alright, by now we should have all of our
1128
- // matching routes and their param pairs, let's
1129
- // Turn them into actual `Match` objects and
1130
- // accumulate the params into a single params bag
1131
- let allParams = {};
1132
-
1133
1144
  // Existing matches are matches that are already loaded along with
1134
1145
  // pending matches that are still loading
1135
1146
 
1136
- const matches = matchedRoutes.map(route => {
1137
- let parsedParams;
1147
+ const parseErrors = matchedRoutes.map(route => {
1138
1148
  let parsedParamsError;
1139
- try {
1140
- parsedParams = route.options.parseParams?.(routeParams) ?? routeParams;
1141
- // (typeof route.options.parseParams === 'object' &&
1142
- // route.options.parseParams.parse
1143
- // ? route.options.parseParams.parse(routeParams)
1144
- // : (route.options.parseParams as any)?.(routeParams!)) ?? routeParams
1145
- } catch (err) {
1146
- parsedParamsError = new PathParamError(err.message, {
1147
- cause: err
1148
- });
1149
- if (opts?.throwOnError) {
1150
- throw parsedParamsError;
1149
+ if (route.options.parseParams) {
1150
+ try {
1151
+ const parsedParams = route.options.parseParams(routeParams);
1152
+ // Add the parsed params to the accumulated params bag
1153
+ Object.assign(routeParams, parsedParams);
1154
+ } catch (err) {
1155
+ parsedParamsError = new PathParamError(err.message, {
1156
+ cause: err
1157
+ });
1158
+ if (opts?.throwOnError) {
1159
+ throw parsedParamsError;
1160
+ }
1161
+ return parsedParamsError;
1151
1162
  }
1152
1163
  }
1153
-
1154
- // Add the parsed params to the accumulated params bag
1155
- Object.assign(allParams, parsedParams);
1156
- const interpolatedPath = interpolatePath(route.path, allParams);
1164
+ return;
1165
+ });
1166
+ const matches = matchedRoutes.map((route, index) => {
1167
+ const interpolatedPath = interpolatePath(route.path, routeParams);
1157
1168
  const key = route.options.key ? route.options.key({
1158
- params: allParams,
1169
+ params: routeParams,
1159
1170
  search: locationSearch
1160
1171
  }) ?? '' : '';
1161
1172
  const stringifiedKey = key ? JSON.stringify(key) : '';
1162
- const matchId = interpolatePath(route.id, allParams, true) + stringifiedKey;
1173
+ const matchId = interpolatePath(route.id, routeParams, true) + stringifiedKey;
1163
1174
 
1164
1175
  // Waste not, want not. If we already have a match for this route,
1165
1176
  // reuse it. This is important for layout routes, which might stick
@@ -1177,7 +1188,7 @@
1177
1188
  id: matchId,
1178
1189
  key: stringifiedKey,
1179
1190
  routeId: route.id,
1180
- params: allParams,
1191
+ params: routeParams,
1181
1192
  pathname: joinPaths([this.basepath, interpolatedPath]),
1182
1193
  updatedAt: Date.now(),
1183
1194
  invalidAt: Infinity,
@@ -1188,7 +1199,7 @@
1188
1199
  isFetching: false,
1189
1200
  invalid: false,
1190
1201
  error: undefined,
1191
- paramsError: parsedParamsError,
1202
+ paramsError: parseErrors[index],
1192
1203
  searchError: undefined,
1193
1204
  loaderData: undefined,
1194
1205
  loadPromise: Promise.resolve(),