@tanstack/react-router 0.0.1-beta.50 → 0.0.1-beta.51

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.
@@ -7,7 +7,7 @@
7
7
  "name": "index.production.js",
8
8
  "children": [
9
9
  {
10
- "uid": "4de6-81",
10
+ "uid": "8d97-81",
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": "4de6-83"
18
+ "uid": "8d97-83"
19
19
  },
20
20
  {
21
21
  "name": "immer@9.0.16/node_modules/immer/dist/immer.esm.mjs",
22
- "uid": "4de6-85"
22
+ "uid": "8d97-85"
23
23
  }
24
24
  ]
25
25
  },
@@ -28,17 +28,17 @@
28
28
  "children": [
29
29
  {
30
30
  "name": "router-core/build/esm/index.js",
31
- "uid": "4de6-87"
31
+ "uid": "8d97-87"
32
32
  },
33
33
  {
34
34
  "name": "react-router/src",
35
35
  "children": [
36
36
  {
37
- "uid": "4de6-89",
37
+ "uid": "8d97-89",
38
38
  "name": "useStore.ts"
39
39
  },
40
40
  {
41
- "uid": "4de6-91",
41
+ "uid": "8d97-91",
42
42
  "name": "index.tsx"
43
43
  }
44
44
  ]
@@ -51,155 +51,155 @@
51
51
  "isRoot": true
52
52
  },
53
53
  "nodeParts": {
54
- "4de6-81": {
54
+ "8d97-81": {
55
55
  "renderedLength": 429,
56
56
  "gzipLength": 238,
57
57
  "brotliLength": 0,
58
- "mainUid": "4de6-80"
58
+ "mainUid": "8d97-80"
59
59
  },
60
- "4de6-83": {
60
+ "8d97-83": {
61
61
  "renderedLength": 181,
62
62
  "gzipLength": 129,
63
63
  "brotliLength": 0,
64
- "mainUid": "4de6-82"
64
+ "mainUid": "8d97-82"
65
65
  },
66
- "4de6-85": {
66
+ "8d97-85": {
67
67
  "renderedLength": 8203,
68
68
  "gzipLength": 3238,
69
69
  "brotliLength": 0,
70
- "mainUid": "4de6-84"
70
+ "mainUid": "8d97-84"
71
71
  },
72
- "4de6-87": {
73
- "renderedLength": 56576,
74
- "gzipLength": 13412,
72
+ "8d97-87": {
73
+ "renderedLength": 56666,
74
+ "gzipLength": 13446,
75
75
  "brotliLength": 0,
76
- "mainUid": "4de6-86"
76
+ "mainUid": "8d97-86"
77
77
  },
78
- "4de6-89": {
78
+ "8d97-89": {
79
79
  "renderedLength": 1347,
80
80
  "gzipLength": 484,
81
81
  "brotliLength": 0,
82
- "mainUid": "4de6-88"
82
+ "mainUid": "8d97-88"
83
83
  },
84
- "4de6-91": {
85
- "renderedLength": 12620,
86
- "gzipLength": 3340,
84
+ "8d97-91": {
85
+ "renderedLength": 12608,
86
+ "gzipLength": 3327,
87
87
  "brotliLength": 0,
88
- "mainUid": "4de6-90"
88
+ "mainUid": "8d97-90"
89
89
  }
90
90
  },
91
91
  "nodeMetas": {
92
- "4de6-80": {
92
+ "8d97-80": {
93
93
  "id": "\u0000rollupPluginBabelHelpers.js",
94
94
  "moduleParts": {
95
- "index.production.js": "4de6-81"
95
+ "index.production.js": "8d97-81"
96
96
  },
97
97
  "imported": [],
98
98
  "importedBy": [
99
99
  {
100
- "uid": "4de6-90"
100
+ "uid": "8d97-90"
101
101
  }
102
102
  ]
103
103
  },
104
- "4de6-82": {
104
+ "8d97-82": {
105
105
  "id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
106
106
  "moduleParts": {
107
- "index.production.js": "4de6-83"
107
+ "index.production.js": "8d97-83"
108
108
  },
109
109
  "imported": [],
110
110
  "importedBy": [
111
111
  {
112
- "uid": "4de6-86"
112
+ "uid": "8d97-86"
113
113
  }
114
114
  ]
115
115
  },
116
- "4de6-84": {
116
+ "8d97-84": {
117
117
  "id": "/node_modules/.pnpm/immer@9.0.16/node_modules/immer/dist/immer.esm.mjs",
118
118
  "moduleParts": {
119
- "index.production.js": "4de6-85"
119
+ "index.production.js": "8d97-85"
120
120
  },
121
121
  "imported": [],
122
122
  "importedBy": [
123
123
  {
124
- "uid": "4de6-86"
124
+ "uid": "8d97-86"
125
125
  }
126
126
  ]
127
127
  },
128
- "4de6-86": {
128
+ "8d97-86": {
129
129
  "id": "/packages/router-core/build/esm/index.js",
130
130
  "moduleParts": {
131
- "index.production.js": "4de6-87"
131
+ "index.production.js": "8d97-87"
132
132
  },
133
133
  "imported": [
134
134
  {
135
- "uid": "4de6-82"
135
+ "uid": "8d97-82"
136
136
  },
137
137
  {
138
- "uid": "4de6-84"
138
+ "uid": "8d97-84"
139
139
  }
140
140
  ],
141
141
  "importedBy": [
142
142
  {
143
- "uid": "4de6-90"
143
+ "uid": "8d97-90"
144
144
  }
145
145
  ]
146
146
  },
147
- "4de6-88": {
147
+ "8d97-88": {
148
148
  "id": "/packages/react-router/src/useStore.ts",
149
149
  "moduleParts": {
150
- "index.production.js": "4de6-89"
150
+ "index.production.js": "8d97-89"
151
151
  },
152
152
  "imported": [
153
153
  {
154
- "uid": "4de6-93"
154
+ "uid": "8d97-93"
155
155
  }
156
156
  ],
157
157
  "importedBy": [
158
158
  {
159
- "uid": "4de6-90"
159
+ "uid": "8d97-90"
160
160
  }
161
161
  ]
162
162
  },
163
- "4de6-90": {
163
+ "8d97-90": {
164
164
  "id": "/packages/react-router/src/index.tsx",
165
165
  "moduleParts": {
166
- "index.production.js": "4de6-91"
166
+ "index.production.js": "8d97-91"
167
167
  },
168
168
  "imported": [
169
169
  {
170
- "uid": "4de6-80"
170
+ "uid": "8d97-80"
171
171
  },
172
172
  {
173
- "uid": "4de6-92"
173
+ "uid": "8d97-92"
174
174
  },
175
175
  {
176
- "uid": "4de6-86"
176
+ "uid": "8d97-86"
177
177
  },
178
178
  {
179
- "uid": "4de6-88"
179
+ "uid": "8d97-88"
180
180
  }
181
181
  ],
182
182
  "importedBy": [],
183
183
  "isEntry": true
184
184
  },
185
- "4de6-92": {
185
+ "8d97-92": {
186
186
  "id": "react",
187
187
  "moduleParts": {},
188
188
  "imported": [],
189
189
  "importedBy": [
190
190
  {
191
- "uid": "4de6-90"
191
+ "uid": "8d97-90"
192
192
  }
193
193
  ],
194
194
  "isExternal": true
195
195
  },
196
- "4de6-93": {
196
+ "8d97-93": {
197
197
  "id": "use-sync-external-store/shim/with-selector",
198
198
  "moduleParts": {},
199
199
  "imported": [],
200
200
  "importedBy": [
201
201
  {
202
- "uid": "4de6-88"
202
+ "uid": "8d97-88"
203
203
  }
204
204
  ],
205
205
  "isExternal": true
@@ -724,7 +724,7 @@
724
724
  Object.assign(this, {
725
725
  route,
726
726
  router,
727
- matchId: opts.matchId,
727
+ id: opts.id,
728
728
  pathname: opts.pathname,
729
729
  params: opts.params,
730
730
  store: createStore({
@@ -1018,13 +1018,12 @@
1018
1018
  parseSearch: options?.parseSearch ?? defaultParseSearch,
1019
1019
  fetchServerDataFn: options?.fetchServerDataFn ?? defaultFetchServerDataFn
1020
1020
  };
1021
- this.history = this.options?.history ?? createBrowserHistory();
1022
1021
  this.store = createStore(getInitialRouterState());
1023
1022
  this.basepath = '';
1024
1023
  this.update(options);
1025
1024
 
1026
1025
  // Allow frameworks to hook into the router creation
1027
- this.options.createRouter?.(this);
1026
+ this.options.Router?.(this);
1028
1027
  }
1029
1028
  reset = () => {
1030
1029
  this.store.setState(s => Object.assign(s, getInitialRouterState()));
@@ -1063,13 +1062,14 @@
1063
1062
  return () => {};
1064
1063
  };
1065
1064
  update = opts => {
1066
- if (!this.store.state.latestLocation) {
1065
+ Object.assign(this.options, opts);
1066
+ if (!this.history || this.options.history && this.options.history !== this.history) {
1067
+ this.history = this.options?.history ?? isServer ? createMemoryHistory() : createBrowserHistory();
1067
1068
  this.store.setState(s => {
1068
1069
  s.latestLocation = this.#parseLocation();
1069
1070
  s.currentLocation = s.latestLocation;
1070
1071
  });
1071
1072
  }
1072
- Object.assign(this.options, opts);
1073
1073
  const {
1074
1074
  basepath,
1075
1075
  routeConfig
@@ -1294,7 +1294,7 @@
1294
1294
  const interpolatedPath = interpolatePath(foundRoute.path, params);
1295
1295
  const matchId = interpolatePath(foundRoute.id, params, true);
1296
1296
  const match = existingMatches.find(d => d.id === matchId) || this.store.state.matchCache[matchId]?.match || new RouteMatch(this, foundRoute, {
1297
- matchId,
1297
+ id: matchId,
1298
1298
  params,
1299
1299
  pathname: joinPaths([this.basepath, interpolatedPath])
1300
1300
  });
@@ -1366,10 +1366,11 @@
1366
1366
 
1367
1367
  // TODO: batch requests when possible
1368
1368
 
1369
- return this.options.fetchServerDataFn({
1369
+ const res = await this.options.fetchServerDataFn({
1370
1370
  router: this,
1371
1371
  routeMatch
1372
1372
  });
1373
+ return res;
1373
1374
  }
1374
1375
  };
1375
1376
  invalidateRoute = async opts => {
@@ -1560,7 +1561,7 @@
1560
1561
  state: {
1561
1562
  ...pick(this.store.state, ['latestLocation', 'currentLocation', 'status', 'lastUpdated']),
1562
1563
  currentMatches: this.store.state.currentMatches.map(match => ({
1563
- matchId: match.id,
1564
+ id: match.id,
1564
1565
  state: {
1565
1566
  ...pick(match.store.state, ['status', 'routeLoaderData', 'invalidAt', 'invalid'])
1566
1567
  }
@@ -1580,7 +1581,7 @@
1580
1581
  });
1581
1582
  currentMatches.forEach((match, index) => {
1582
1583
  const dehydratedMatch = dehydratedRouter.state.currentMatches[index];
1583
- invariant(dehydratedMatch && dehydratedMatch.matchId === match.id, 'Oh no! There was a hydration mismatch when attempting to rethis.store the state of the router! 😬');
1584
+ invariant(dehydratedMatch && dehydratedMatch.id === match.id, 'Oh no! There was a hydration mismatch when attempting to rethis.store the state of the router! 😬');
1584
1585
  Object.assign(match, dehydratedMatch);
1585
1586
  });
1586
1587
  currentMatches.forEach(match => match.__validate());
@@ -1727,7 +1728,9 @@
1727
1728
  id,
1728
1729
  ...next.state
1729
1730
  });
1730
- this.load(this.#parseLocation(this.store.state.latestLocation));
1731
+
1732
+ // this.load(this.#parseLocation(this.store.state.latestLocation))
1733
+
1731
1734
  return this.navigationPromise = new Promise(resolve => {
1732
1735
  const previousNavigationResolve = this.resolveNavigation;
1733
1736
  this.resolveNavigation = () => {
@@ -1769,7 +1772,7 @@
1769
1772
  });
1770
1773
  }
1771
1774
 
1772
- // createRouterAction is a constrained identify function that takes options: key, action, onSuccess, onError, onSettled, etc
1775
+ // RouterAction is a constrained identify function that takes options: key, action, onSuccess, onError, onSettled, etc
1773
1776
  function createAction(options) {
1774
1777
  const store = createStore({
1775
1778
  submissions: []
@@ -2026,7 +2029,7 @@
2026
2029
  ...rest
2027
2030
  }) {
2028
2031
  router.update(rest);
2029
- const [,, currentMatches] = useStore(router.store, s => [s.status, s.pendingMatches, s.currentMatches], true);
2032
+ const currentMatches = useStore(router.store, s => s.currentMatches, undefined);
2030
2033
  React__namespace.useEffect(router.mount, [router]);
2031
2034
  return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
2032
2035
  value: {
@@ -2193,11 +2196,11 @@
2193
2196
 
2194
2197
  // React.useEffect(() => {
2195
2198
  // if (activeErrorState) {
2196
- // let prevKey = router.store.currentLocation.key
2199
+ // let prevKey = router.store.state.currentLocation.key
2197
2200
  // return createRoot((dispose) => {
2198
2201
  // createEffect(() => {
2199
- // if (router.store.currentLocation.key !== prevKey) {
2200
- // prevKey = router.store.currentLocation.key
2202
+ // if (router.store.state.currentLocation.key !== prevKey) {
2203
+ // prevKey = router.store.state.currentLocation.key
2201
2204
  // setActiveErrorState({} as any)
2202
2205
  // }
2203
2206
  // })