@tanstack/react-router 0.0.1-beta.70 → 0.0.1-beta.71
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/cjs/index.js +5 -4
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +5 -4
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +57 -57
- package/build/umd/index.development.js +42 -30
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +3 -3
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +12 -15
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": "48bd-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": "
|
|
18
|
+
"uid": "48bd-111"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
|
|
22
|
-
"uid": "
|
|
22
|
+
"uid": "48bd-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": "
|
|
31
|
+
"uid": "48bd-115"
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"name": "router/build/esm/index.js",
|
|
35
|
-
"uid": "
|
|
35
|
+
"uid": "48bd-117"
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"name": "react-store/build/esm/index.js",
|
|
39
|
-
"uid": "
|
|
39
|
+
"uid": "48bd-119"
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"name": "react-router/src/index.tsx",
|
|
43
|
-
"uid": "
|
|
43
|
+
"uid": "48bd-121"
|
|
44
44
|
}
|
|
45
45
|
]
|
|
46
46
|
}
|
|
@@ -50,176 +50,176 @@
|
|
|
50
50
|
"isRoot": true
|
|
51
51
|
},
|
|
52
52
|
"nodeParts": {
|
|
53
|
-
"
|
|
53
|
+
"48bd-109": {
|
|
54
54
|
"renderedLength": 429,
|
|
55
55
|
"gzipLength": 238,
|
|
56
56
|
"brotliLength": 0,
|
|
57
|
-
"mainUid": "
|
|
57
|
+
"mainUid": "48bd-108"
|
|
58
58
|
},
|
|
59
|
-
"
|
|
59
|
+
"48bd-111": {
|
|
60
60
|
"renderedLength": 181,
|
|
61
61
|
"gzipLength": 129,
|
|
62
62
|
"brotliLength": 0,
|
|
63
|
-
"mainUid": "
|
|
63
|
+
"mainUid": "48bd-110"
|
|
64
64
|
},
|
|
65
|
-
"
|
|
65
|
+
"48bd-113": {
|
|
66
66
|
"renderedLength": 44,
|
|
67
67
|
"gzipLength": 62,
|
|
68
68
|
"brotliLength": 0,
|
|
69
|
-
"mainUid": "
|
|
69
|
+
"mainUid": "48bd-112"
|
|
70
70
|
},
|
|
71
|
-
"
|
|
71
|
+
"48bd-115": {
|
|
72
72
|
"renderedLength": 1288,
|
|
73
73
|
"gzipLength": 497,
|
|
74
74
|
"brotliLength": 0,
|
|
75
|
-
"mainUid": "
|
|
75
|
+
"mainUid": "48bd-114"
|
|
76
76
|
},
|
|
77
|
-
"
|
|
78
|
-
"renderedLength":
|
|
79
|
-
"gzipLength":
|
|
77
|
+
"48bd-117": {
|
|
78
|
+
"renderedLength": 46374,
|
|
79
|
+
"gzipLength": 11002,
|
|
80
80
|
"brotliLength": 0,
|
|
81
|
-
"mainUid": "
|
|
81
|
+
"mainUid": "48bd-116"
|
|
82
82
|
},
|
|
83
|
-
"
|
|
83
|
+
"48bd-119": {
|
|
84
84
|
"renderedLength": 1571,
|
|
85
85
|
"gzipLength": 594,
|
|
86
86
|
"brotliLength": 0,
|
|
87
|
-
"mainUid": "
|
|
87
|
+
"mainUid": "48bd-118"
|
|
88
88
|
},
|
|
89
|
-
"
|
|
90
|
-
"renderedLength":
|
|
91
|
-
"gzipLength":
|
|
89
|
+
"48bd-121": {
|
|
90
|
+
"renderedLength": 12514,
|
|
91
|
+
"gzipLength": 3242,
|
|
92
92
|
"brotliLength": 0,
|
|
93
|
-
"mainUid": "
|
|
93
|
+
"mainUid": "48bd-120"
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"nodeMetas": {
|
|
97
|
-
"
|
|
97
|
+
"48bd-108": {
|
|
98
98
|
"id": "\u0000rollupPluginBabelHelpers.js",
|
|
99
99
|
"moduleParts": {
|
|
100
|
-
"index.production.js": "
|
|
100
|
+
"index.production.js": "48bd-109"
|
|
101
101
|
},
|
|
102
102
|
"imported": [],
|
|
103
103
|
"importedBy": [
|
|
104
104
|
{
|
|
105
|
-
"uid": "
|
|
105
|
+
"uid": "48bd-120"
|
|
106
106
|
}
|
|
107
107
|
]
|
|
108
108
|
},
|
|
109
|
-
"
|
|
109
|
+
"48bd-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": "
|
|
112
|
+
"index.production.js": "48bd-111"
|
|
113
113
|
},
|
|
114
114
|
"imported": [],
|
|
115
115
|
"importedBy": [
|
|
116
116
|
{
|
|
117
|
-
"uid": "
|
|
117
|
+
"uid": "48bd-116"
|
|
118
118
|
}
|
|
119
119
|
]
|
|
120
120
|
},
|
|
121
|
-
"
|
|
121
|
+
"48bd-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": "
|
|
124
|
+
"index.production.js": "48bd-113"
|
|
125
125
|
},
|
|
126
126
|
"imported": [],
|
|
127
127
|
"importedBy": [
|
|
128
128
|
{
|
|
129
|
-
"uid": "
|
|
129
|
+
"uid": "48bd-116"
|
|
130
130
|
}
|
|
131
131
|
]
|
|
132
132
|
},
|
|
133
|
-
"
|
|
133
|
+
"48bd-114": {
|
|
134
134
|
"id": "/packages/store/build/esm/index.js",
|
|
135
135
|
"moduleParts": {
|
|
136
|
-
"index.production.js": "
|
|
136
|
+
"index.production.js": "48bd-115"
|
|
137
137
|
},
|
|
138
138
|
"imported": [],
|
|
139
139
|
"importedBy": [
|
|
140
140
|
{
|
|
141
|
-
"uid": "
|
|
141
|
+
"uid": "48bd-116"
|
|
142
142
|
}
|
|
143
143
|
]
|
|
144
144
|
},
|
|
145
|
-
"
|
|
145
|
+
"48bd-116": {
|
|
146
146
|
"id": "/packages/router/build/esm/index.js",
|
|
147
147
|
"moduleParts": {
|
|
148
|
-
"index.production.js": "
|
|
148
|
+
"index.production.js": "48bd-117"
|
|
149
149
|
},
|
|
150
150
|
"imported": [
|
|
151
151
|
{
|
|
152
|
-
"uid": "
|
|
152
|
+
"uid": "48bd-110"
|
|
153
153
|
},
|
|
154
154
|
{
|
|
155
|
-
"uid": "
|
|
155
|
+
"uid": "48bd-112"
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
|
-
"uid": "
|
|
158
|
+
"uid": "48bd-114"
|
|
159
159
|
}
|
|
160
160
|
],
|
|
161
161
|
"importedBy": [
|
|
162
162
|
{
|
|
163
|
-
"uid": "
|
|
163
|
+
"uid": "48bd-120"
|
|
164
164
|
}
|
|
165
165
|
]
|
|
166
166
|
},
|
|
167
|
-
"
|
|
167
|
+
"48bd-118": {
|
|
168
168
|
"id": "/packages/react-store/build/esm/index.js",
|
|
169
169
|
"moduleParts": {
|
|
170
|
-
"index.production.js": "
|
|
170
|
+
"index.production.js": "48bd-119"
|
|
171
171
|
},
|
|
172
172
|
"imported": [
|
|
173
173
|
{
|
|
174
|
-
"uid": "
|
|
174
|
+
"uid": "48bd-123"
|
|
175
175
|
}
|
|
176
176
|
],
|
|
177
177
|
"importedBy": [
|
|
178
178
|
{
|
|
179
|
-
"uid": "
|
|
179
|
+
"uid": "48bd-120"
|
|
180
180
|
}
|
|
181
181
|
]
|
|
182
182
|
},
|
|
183
|
-
"
|
|
183
|
+
"48bd-120": {
|
|
184
184
|
"id": "/packages/react-router/src/index.tsx",
|
|
185
185
|
"moduleParts": {
|
|
186
|
-
"index.production.js": "
|
|
186
|
+
"index.production.js": "48bd-121"
|
|
187
187
|
},
|
|
188
188
|
"imported": [
|
|
189
189
|
{
|
|
190
|
-
"uid": "
|
|
190
|
+
"uid": "48bd-108"
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
|
-
"uid": "
|
|
193
|
+
"uid": "48bd-122"
|
|
194
194
|
},
|
|
195
195
|
{
|
|
196
|
-
"uid": "
|
|
196
|
+
"uid": "48bd-116"
|
|
197
197
|
},
|
|
198
198
|
{
|
|
199
|
-
"uid": "
|
|
199
|
+
"uid": "48bd-118"
|
|
200
200
|
}
|
|
201
201
|
],
|
|
202
202
|
"importedBy": [],
|
|
203
203
|
"isEntry": true
|
|
204
204
|
},
|
|
205
|
-
"
|
|
205
|
+
"48bd-122": {
|
|
206
206
|
"id": "react",
|
|
207
207
|
"moduleParts": {},
|
|
208
208
|
"imported": [],
|
|
209
209
|
"importedBy": [
|
|
210
210
|
{
|
|
211
|
-
"uid": "
|
|
211
|
+
"uid": "48bd-120"
|
|
212
212
|
}
|
|
213
213
|
],
|
|
214
214
|
"isExternal": true
|
|
215
215
|
},
|
|
216
|
-
"
|
|
216
|
+
"48bd-123": {
|
|
217
217
|
"id": "use-sync-external-store/shim/with-selector",
|
|
218
218
|
"moduleParts": {},
|
|
219
219
|
"imported": [],
|
|
220
220
|
"importedBy": [
|
|
221
221
|
{
|
|
222
|
-
"uid": "
|
|
222
|
+
"uid": "48bd-118"
|
|
223
223
|
}
|
|
224
224
|
],
|
|
225
225
|
"isExternal": true
|
|
@@ -435,7 +435,7 @@
|
|
|
435
435
|
// Remove empty segments and '.' segments
|
|
436
436
|
const split = pathname.split('/').filter(Boolean);
|
|
437
437
|
segments.push(...split.map(part => {
|
|
438
|
-
if (part === '$') {
|
|
438
|
+
if (part === '$' || part === '*') {
|
|
439
439
|
return {
|
|
440
440
|
type: 'wildcard',
|
|
441
441
|
value: part
|
|
@@ -464,7 +464,7 @@
|
|
|
464
464
|
function interpolatePath(path, params, leaveWildcard) {
|
|
465
465
|
const interpolatedPathSegments = parsePathname(path);
|
|
466
466
|
return joinPaths(interpolatedPathSegments.map(segment => {
|
|
467
|
-
if (segment.value
|
|
467
|
+
if (['$', '*'].includes(segment.value) && !leaveWildcard) {
|
|
468
468
|
return '';
|
|
469
469
|
}
|
|
470
470
|
if (segment.type === 'param') {
|
|
@@ -503,7 +503,7 @@
|
|
|
503
503
|
if (routeSegment) {
|
|
504
504
|
if (routeSegment.type === 'wildcard') {
|
|
505
505
|
if (baseSegment?.value) {
|
|
506
|
-
params['
|
|
506
|
+
params['*'] = joinPaths(baseSegments.slice(i).map(d => d.value));
|
|
507
507
|
return true;
|
|
508
508
|
}
|
|
509
509
|
return false;
|
|
@@ -802,25 +802,6 @@
|
|
|
802
802
|
if (!this.state.currentMatches.length) {
|
|
803
803
|
this.safeLoad();
|
|
804
804
|
}
|
|
805
|
-
const visibilityChangeEvent = 'visibilitychange';
|
|
806
|
-
const focusEvent = 'focus';
|
|
807
|
-
|
|
808
|
-
// addEventListener does not exist in React Native, but window does
|
|
809
|
-
// In the future, we might need to invert control here for more adapters
|
|
810
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
811
|
-
if (window.addEventListener) {
|
|
812
|
-
// Listen to visibilitychange and focus
|
|
813
|
-
window.addEventListener(visibilityChangeEvent, this.#onFocus, false);
|
|
814
|
-
window.addEventListener(focusEvent, this.#onFocus, false);
|
|
815
|
-
}
|
|
816
|
-
return () => {
|
|
817
|
-
if (window.removeEventListener) {
|
|
818
|
-
// Be sure to unsubscribe if a new handler is set
|
|
819
|
-
|
|
820
|
-
window.removeEventListener(visibilityChangeEvent, this.#onFocus);
|
|
821
|
-
window.removeEventListener(focusEvent, this.#onFocus);
|
|
822
|
-
}
|
|
823
|
-
};
|
|
824
805
|
}
|
|
825
806
|
return () => {};
|
|
826
807
|
};
|
|
@@ -1313,7 +1294,40 @@
|
|
|
1313
1294
|
}
|
|
1314
1295
|
this.routesById[route.id] = route;
|
|
1315
1296
|
const children = route.children;
|
|
1316
|
-
if (children?.length)
|
|
1297
|
+
if (children?.length) {
|
|
1298
|
+
recurseRoutes(children);
|
|
1299
|
+
route.children = children.map((d, i) => {
|
|
1300
|
+
const parsed = parsePathname(trimPathLeft(cleanPath(d.path ?? '/')));
|
|
1301
|
+
while (parsed.length > 1 && parsed[0]?.value === '/') {
|
|
1302
|
+
parsed.shift();
|
|
1303
|
+
}
|
|
1304
|
+
let score = 0;
|
|
1305
|
+
parsed.forEach((d, i) => {
|
|
1306
|
+
let modifier = 1;
|
|
1307
|
+
while (i--) {
|
|
1308
|
+
modifier *= 0.001;
|
|
1309
|
+
}
|
|
1310
|
+
if (d.type === 'pathname' && d.value !== '/') {
|
|
1311
|
+
score += 1 * modifier;
|
|
1312
|
+
} else if (d.type === 'param') {
|
|
1313
|
+
score += 2 * modifier;
|
|
1314
|
+
} else if (d.type === 'wildcard') {
|
|
1315
|
+
score += 3 * modifier;
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1318
|
+
return {
|
|
1319
|
+
child: d,
|
|
1320
|
+
parsed,
|
|
1321
|
+
index: i,
|
|
1322
|
+
score
|
|
1323
|
+
};
|
|
1324
|
+
}).sort((a, b) => {
|
|
1325
|
+
if (a.score !== b.score) {
|
|
1326
|
+
return a.score - b.score;
|
|
1327
|
+
}
|
|
1328
|
+
return a.index - b.index;
|
|
1329
|
+
}).map(d => d.child);
|
|
1330
|
+
}
|
|
1317
1331
|
});
|
|
1318
1332
|
};
|
|
1319
1333
|
recurseRoutes([routeTree]);
|
|
@@ -1337,9 +1351,6 @@
|
|
|
1337
1351
|
key: state?.key || '__init__'
|
|
1338
1352
|
};
|
|
1339
1353
|
};
|
|
1340
|
-
#onFocus = () => {
|
|
1341
|
-
this.safeLoad();
|
|
1342
|
-
};
|
|
1343
1354
|
#buildLocation = (dest = {}) => {
|
|
1344
1355
|
dest.fromCurrent = dest.fromCurrent ?? dest.to === '';
|
|
1345
1356
|
const fromPathname = dest.fromCurrent ? this.state.latestLocation.pathname : dest.from ?? this.state.latestLocation.pathname;
|
|
@@ -1870,7 +1881,7 @@
|
|
|
1870
1881
|
}
|
|
1871
1882
|
function useRouterContext() {
|
|
1872
1883
|
const value = React__namespace.useContext(routerContext);
|
|
1873
|
-
warning(
|
|
1884
|
+
warning(value, 'useRouter must be used inside a <Router> component!');
|
|
1874
1885
|
useStore(value.router.store);
|
|
1875
1886
|
return value.router;
|
|
1876
1887
|
}
|
|
@@ -2062,15 +2073,16 @@
|
|
|
2062
2073
|
style: {
|
|
2063
2074
|
height: '.5rem'
|
|
2064
2075
|
}
|
|
2065
|
-
}), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("pre",
|
|
2076
|
+
}), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("pre", {
|
|
2066
2077
|
style: {
|
|
2067
2078
|
fontSize: '.7em',
|
|
2068
2079
|
border: '1px solid red',
|
|
2069
2080
|
borderRadius: '.25rem',
|
|
2070
2081
|
padding: '.5rem',
|
|
2071
|
-
color: 'red'
|
|
2082
|
+
color: 'red',
|
|
2083
|
+
overflow: 'auto'
|
|
2072
2084
|
}
|
|
2073
|
-
}, error.message) : null)));
|
|
2085
|
+
}, error.message ? /*#__PURE__*/React__namespace.createElement("code", null, error.message) : null)));
|
|
2074
2086
|
}
|
|
2075
2087
|
|
|
2076
2088
|
// TODO: While we migrate away from the history package, these need to be disabled
|