@tanstack/react-router 0.0.1-beta.51 → 0.0.1-beta.52
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.
package/build/stats-html.html
CHANGED
|
@@ -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":"
|
|
4027
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"7dac-67","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"node_modules/.pnpm","children":[{"name":"tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","uid":"7dac-69"},{"name":"immer@9.0.16/node_modules/immer/dist/immer.esm.mjs","uid":"7dac-71"}]},{"name":"packages","children":[{"name":"router-core/build/esm/index.js","uid":"7dac-73"},{"name":"react-router/src","children":[{"uid":"7dac-75","name":"useStore.ts"},{"uid":"7dac-77","name":"index.tsx"}]}]}]}],"isRoot":true},"nodeParts":{"7dac-67":{"renderedLength":429,"gzipLength":238,"brotliLength":0,"mainUid":"7dac-66"},"7dac-69":{"renderedLength":181,"gzipLength":129,"brotliLength":0,"mainUid":"7dac-68"},"7dac-71":{"renderedLength":8203,"gzipLength":3238,"brotliLength":0,"mainUid":"7dac-70"},"7dac-73":{"renderedLength":56528,"gzipLength":13417,"brotliLength":0,"mainUid":"7dac-72"},"7dac-75":{"renderedLength":1347,"gzipLength":484,"brotliLength":0,"mainUid":"7dac-74"},"7dac-77":{"renderedLength":12608,"gzipLength":3327,"brotliLength":0,"mainUid":"7dac-76"}},"nodeMetas":{"7dac-66":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"7dac-67"},"imported":[],"importedBy":[{"uid":"7dac-76"}]},"7dac-68":{"id":"/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","moduleParts":{"index.production.js":"7dac-69"},"imported":[],"importedBy":[{"uid":"7dac-72"}]},"7dac-70":{"id":"/node_modules/.pnpm/immer@9.0.16/node_modules/immer/dist/immer.esm.mjs","moduleParts":{"index.production.js":"7dac-71"},"imported":[],"importedBy":[{"uid":"7dac-72"}]},"7dac-72":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"7dac-73"},"imported":[{"uid":"7dac-68"},{"uid":"7dac-70"}],"importedBy":[{"uid":"7dac-76"}]},"7dac-74":{"id":"/packages/react-router/src/useStore.ts","moduleParts":{"index.production.js":"7dac-75"},"imported":[{"uid":"7dac-79"}],"importedBy":[{"uid":"7dac-76"}]},"7dac-76":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"7dac-77"},"imported":[{"uid":"7dac-66"},{"uid":"7dac-78"},{"uid":"7dac-72"},{"uid":"7dac-74"}],"importedBy":[],"isEntry":true},"7dac-78":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"7dac-76"}],"isExternal":true},"7dac-79":{"id":"use-sync-external-store/shim/with-selector","moduleParts":{},"imported":[],"importedBy":[{"uid":"7dac-74"}],"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;
|
package/build/stats-react.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"name": "index.production.js",
|
|
8
8
|
"children": [
|
|
9
9
|
{
|
|
10
|
-
"uid": "
|
|
10
|
+
"uid": "7dac-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": "
|
|
18
|
+
"uid": "7dac-83"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"name": "immer@9.0.16/node_modules/immer/dist/immer.esm.mjs",
|
|
22
|
-
"uid": "
|
|
22
|
+
"uid": "7dac-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": "
|
|
31
|
+
"uid": "7dac-87"
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"name": "react-router/src",
|
|
35
35
|
"children": [
|
|
36
36
|
{
|
|
37
|
-
"uid": "
|
|
37
|
+
"uid": "7dac-89",
|
|
38
38
|
"name": "useStore.ts"
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
"uid": "
|
|
41
|
+
"uid": "7dac-91",
|
|
42
42
|
"name": "index.tsx"
|
|
43
43
|
}
|
|
44
44
|
]
|
|
@@ -51,155 +51,155 @@
|
|
|
51
51
|
"isRoot": true
|
|
52
52
|
},
|
|
53
53
|
"nodeParts": {
|
|
54
|
-
"
|
|
54
|
+
"7dac-81": {
|
|
55
55
|
"renderedLength": 429,
|
|
56
56
|
"gzipLength": 238,
|
|
57
57
|
"brotliLength": 0,
|
|
58
|
-
"mainUid": "
|
|
58
|
+
"mainUid": "7dac-80"
|
|
59
59
|
},
|
|
60
|
-
"
|
|
60
|
+
"7dac-83": {
|
|
61
61
|
"renderedLength": 181,
|
|
62
62
|
"gzipLength": 129,
|
|
63
63
|
"brotliLength": 0,
|
|
64
|
-
"mainUid": "
|
|
64
|
+
"mainUid": "7dac-82"
|
|
65
65
|
},
|
|
66
|
-
"
|
|
66
|
+
"7dac-85": {
|
|
67
67
|
"renderedLength": 8203,
|
|
68
68
|
"gzipLength": 3238,
|
|
69
69
|
"brotliLength": 0,
|
|
70
|
-
"mainUid": "
|
|
70
|
+
"mainUid": "7dac-84"
|
|
71
71
|
},
|
|
72
|
-
"
|
|
73
|
-
"renderedLength":
|
|
74
|
-
"gzipLength":
|
|
72
|
+
"7dac-87": {
|
|
73
|
+
"renderedLength": 56528,
|
|
74
|
+
"gzipLength": 13417,
|
|
75
75
|
"brotliLength": 0,
|
|
76
|
-
"mainUid": "
|
|
76
|
+
"mainUid": "7dac-86"
|
|
77
77
|
},
|
|
78
|
-
"
|
|
78
|
+
"7dac-89": {
|
|
79
79
|
"renderedLength": 1347,
|
|
80
80
|
"gzipLength": 484,
|
|
81
81
|
"brotliLength": 0,
|
|
82
|
-
"mainUid": "
|
|
82
|
+
"mainUid": "7dac-88"
|
|
83
83
|
},
|
|
84
|
-
"
|
|
84
|
+
"7dac-91": {
|
|
85
85
|
"renderedLength": 12608,
|
|
86
86
|
"gzipLength": 3327,
|
|
87
87
|
"brotliLength": 0,
|
|
88
|
-
"mainUid": "
|
|
88
|
+
"mainUid": "7dac-90"
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
"nodeMetas": {
|
|
92
|
-
"
|
|
92
|
+
"7dac-80": {
|
|
93
93
|
"id": "\u0000rollupPluginBabelHelpers.js",
|
|
94
94
|
"moduleParts": {
|
|
95
|
-
"index.production.js": "
|
|
95
|
+
"index.production.js": "7dac-81"
|
|
96
96
|
},
|
|
97
97
|
"imported": [],
|
|
98
98
|
"importedBy": [
|
|
99
99
|
{
|
|
100
|
-
"uid": "
|
|
100
|
+
"uid": "7dac-90"
|
|
101
101
|
}
|
|
102
102
|
]
|
|
103
103
|
},
|
|
104
|
-
"
|
|
104
|
+
"7dac-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": "
|
|
107
|
+
"index.production.js": "7dac-83"
|
|
108
108
|
},
|
|
109
109
|
"imported": [],
|
|
110
110
|
"importedBy": [
|
|
111
111
|
{
|
|
112
|
-
"uid": "
|
|
112
|
+
"uid": "7dac-86"
|
|
113
113
|
}
|
|
114
114
|
]
|
|
115
115
|
},
|
|
116
|
-
"
|
|
116
|
+
"7dac-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": "
|
|
119
|
+
"index.production.js": "7dac-85"
|
|
120
120
|
},
|
|
121
121
|
"imported": [],
|
|
122
122
|
"importedBy": [
|
|
123
123
|
{
|
|
124
|
-
"uid": "
|
|
124
|
+
"uid": "7dac-86"
|
|
125
125
|
}
|
|
126
126
|
]
|
|
127
127
|
},
|
|
128
|
-
"
|
|
128
|
+
"7dac-86": {
|
|
129
129
|
"id": "/packages/router-core/build/esm/index.js",
|
|
130
130
|
"moduleParts": {
|
|
131
|
-
"index.production.js": "
|
|
131
|
+
"index.production.js": "7dac-87"
|
|
132
132
|
},
|
|
133
133
|
"imported": [
|
|
134
134
|
{
|
|
135
|
-
"uid": "
|
|
135
|
+
"uid": "7dac-82"
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
|
-
"uid": "
|
|
138
|
+
"uid": "7dac-84"
|
|
139
139
|
}
|
|
140
140
|
],
|
|
141
141
|
"importedBy": [
|
|
142
142
|
{
|
|
143
|
-
"uid": "
|
|
143
|
+
"uid": "7dac-90"
|
|
144
144
|
}
|
|
145
145
|
]
|
|
146
146
|
},
|
|
147
|
-
"
|
|
147
|
+
"7dac-88": {
|
|
148
148
|
"id": "/packages/react-router/src/useStore.ts",
|
|
149
149
|
"moduleParts": {
|
|
150
|
-
"index.production.js": "
|
|
150
|
+
"index.production.js": "7dac-89"
|
|
151
151
|
},
|
|
152
152
|
"imported": [
|
|
153
153
|
{
|
|
154
|
-
"uid": "
|
|
154
|
+
"uid": "7dac-93"
|
|
155
155
|
}
|
|
156
156
|
],
|
|
157
157
|
"importedBy": [
|
|
158
158
|
{
|
|
159
|
-
"uid": "
|
|
159
|
+
"uid": "7dac-90"
|
|
160
160
|
}
|
|
161
161
|
]
|
|
162
162
|
},
|
|
163
|
-
"
|
|
163
|
+
"7dac-90": {
|
|
164
164
|
"id": "/packages/react-router/src/index.tsx",
|
|
165
165
|
"moduleParts": {
|
|
166
|
-
"index.production.js": "
|
|
166
|
+
"index.production.js": "7dac-91"
|
|
167
167
|
},
|
|
168
168
|
"imported": [
|
|
169
169
|
{
|
|
170
|
-
"uid": "
|
|
170
|
+
"uid": "7dac-80"
|
|
171
171
|
},
|
|
172
172
|
{
|
|
173
|
-
"uid": "
|
|
173
|
+
"uid": "7dac-92"
|
|
174
174
|
},
|
|
175
175
|
{
|
|
176
|
-
"uid": "
|
|
176
|
+
"uid": "7dac-86"
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
|
-
"uid": "
|
|
179
|
+
"uid": "7dac-88"
|
|
180
180
|
}
|
|
181
181
|
],
|
|
182
182
|
"importedBy": [],
|
|
183
183
|
"isEntry": true
|
|
184
184
|
},
|
|
185
|
-
"
|
|
185
|
+
"7dac-92": {
|
|
186
186
|
"id": "react",
|
|
187
187
|
"moduleParts": {},
|
|
188
188
|
"imported": [],
|
|
189
189
|
"importedBy": [
|
|
190
190
|
{
|
|
191
|
-
"uid": "
|
|
191
|
+
"uid": "7dac-90"
|
|
192
192
|
}
|
|
193
193
|
],
|
|
194
194
|
"isExternal": true
|
|
195
195
|
},
|
|
196
|
-
"
|
|
196
|
+
"7dac-93": {
|
|
197
197
|
"id": "use-sync-external-store/shim/with-selector",
|
|
198
198
|
"moduleParts": {},
|
|
199
199
|
"imported": [],
|
|
200
200
|
"importedBy": [
|
|
201
201
|
{
|
|
202
|
-
"uid": "
|
|
202
|
+
"uid": "7dac-88"
|
|
203
203
|
}
|
|
204
204
|
],
|
|
205
205
|
"isExternal": true
|
|
@@ -167,13 +167,8 @@
|
|
|
167
167
|
const getLocation = () => parseLocation(entries[index], currentState);
|
|
168
168
|
return createHistory({
|
|
169
169
|
getLocation,
|
|
170
|
-
listener:
|
|
171
|
-
|
|
172
|
-
// We might need to handle the hashchange event in the future
|
|
173
|
-
// window.addEventListener(hashChangeEvent, onUpdate)
|
|
174
|
-
return () => {
|
|
175
|
-
window.removeEventListener(popStateEvent, onUpdate);
|
|
176
|
-
};
|
|
170
|
+
listener: () => {
|
|
171
|
+
return () => {};
|
|
177
172
|
},
|
|
178
173
|
pushState: (path, state) => {
|
|
179
174
|
currentState = {
|
|
@@ -742,7 +737,7 @@
|
|
|
742
737
|
this.store.setState(s => s.status = 'success');
|
|
743
738
|
}
|
|
744
739
|
}
|
|
745
|
-
|
|
740
|
+
setLoaderData = loaderData => {
|
|
746
741
|
batch(() => {
|
|
747
742
|
this.store.setState(s => {
|
|
748
743
|
s.routeLoaderData = loaderData;
|
|
@@ -817,7 +812,7 @@
|
|
|
817
812
|
if (this.route.options.loader) {
|
|
818
813
|
const data = await this.router.loadMatchData(this);
|
|
819
814
|
if (latestPromise = checkLatest()) return latestPromise;
|
|
820
|
-
this
|
|
815
|
+
this.setLoaderData(data);
|
|
821
816
|
}
|
|
822
817
|
this.store.setState(s => {
|
|
823
818
|
s.error = undefined;
|
|
@@ -1002,8 +997,7 @@
|
|
|
1002
997
|
throw new Error('Failed to fetch match data');
|
|
1003
998
|
};
|
|
1004
999
|
class Router {
|
|
1005
|
-
|
|
1006
|
-
|
|
1000
|
+
#unsubHistory;
|
|
1007
1001
|
startedLoadingAt = Date.now();
|
|
1008
1002
|
resolveNavigation = () => {};
|
|
1009
1003
|
constructor(options) {
|
|
@@ -1035,9 +1029,6 @@
|
|
|
1035
1029
|
if (!this.store.state.currentMatches.length) {
|
|
1036
1030
|
this.load();
|
|
1037
1031
|
}
|
|
1038
|
-
const unsubHistory = this.history.listen(() => {
|
|
1039
|
-
this.load(this.#parseLocation(this.store.state.latestLocation));
|
|
1040
|
-
});
|
|
1041
1032
|
const visibilityChangeEvent = 'visibilitychange';
|
|
1042
1033
|
const focusEvent = 'focus';
|
|
1043
1034
|
|
|
@@ -1050,7 +1041,6 @@
|
|
|
1050
1041
|
window.addEventListener(focusEvent, this.#onFocus, false);
|
|
1051
1042
|
}
|
|
1052
1043
|
return () => {
|
|
1053
|
-
unsubHistory();
|
|
1054
1044
|
if (window.removeEventListener) {
|
|
1055
1045
|
// Be sure to unsubscribe if a new handler is set
|
|
1056
1046
|
|
|
@@ -1064,11 +1054,17 @@
|
|
|
1064
1054
|
update = opts => {
|
|
1065
1055
|
Object.assign(this.options, opts);
|
|
1066
1056
|
if (!this.history || this.options.history && this.options.history !== this.history) {
|
|
1067
|
-
|
|
1057
|
+
if (this.#unsubHistory) {
|
|
1058
|
+
this.#unsubHistory();
|
|
1059
|
+
}
|
|
1060
|
+
this.history = this.options.history ?? (isServer ? createMemoryHistory() : createBrowserHistory());
|
|
1068
1061
|
this.store.setState(s => {
|
|
1069
1062
|
s.latestLocation = this.#parseLocation();
|
|
1070
1063
|
s.currentLocation = s.latestLocation;
|
|
1071
1064
|
});
|
|
1065
|
+
this.#unsubHistory = this.history.listen(() => {
|
|
1066
|
+
this.load(this.#parseLocation(this.store.state.latestLocation));
|
|
1067
|
+
});
|
|
1072
1068
|
}
|
|
1073
1069
|
const {
|
|
1074
1070
|
basepath,
|
|
@@ -1582,7 +1578,10 @@
|
|
|
1582
1578
|
currentMatches.forEach((match, index) => {
|
|
1583
1579
|
const dehydratedMatch = dehydratedRouter.state.currentMatches[index];
|
|
1584
1580
|
invariant(dehydratedMatch && dehydratedMatch.id === match.id, 'Oh no! There was a hydration mismatch when attempting to rethis.store the state of the router! 😬');
|
|
1585
|
-
|
|
1581
|
+
match.store.setState(s => {
|
|
1582
|
+
Object.assign(s, dehydratedMatch.state);
|
|
1583
|
+
});
|
|
1584
|
+
match.setLoaderData(dehydratedMatch.state.routeLoaderData);
|
|
1586
1585
|
});
|
|
1587
1586
|
currentMatches.forEach(match => match.__validate());
|
|
1588
1587
|
Object.assign(s, {
|