@vxrn/compiler 1.14.4 → 1.14.5
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/dist/cjs/cache.cjs +65 -44
- package/dist/cjs/configure.cjs +16 -14
- package/dist/cjs/constants.cjs +55 -53
- package/dist/cjs/index.cjs +217 -136
- package/dist/cjs/refresh-runtime.cjs +284 -125
- package/dist/cjs/transformBabel.cjs +180 -95
- package/dist/cjs/transformSWC.cjs +188 -131
- package/dist/cjs/types.cjs +7 -5
- package/dist/esm/cache.mjs +49 -30
- package/dist/esm/cache.mjs.map +1 -1
- package/dist/esm/configure.mjs +4 -4
- package/dist/esm/constants.mjs +43 -43
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/index.js +182 -103
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +182 -103
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/refresh-runtime.mjs +272 -115
- package/dist/esm/refresh-runtime.mjs.map +1 -1
- package/dist/esm/transformBabel.mjs +151 -68
- package/dist/esm/transformBabel.mjs.map +1 -1
- package/dist/esm/transformSWC.mjs +171 -116
- package/dist/esm/transformSWC.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var refresh_runtime_exports = {};
|
|
22
24
|
__export(refresh_runtime_exports, {
|
|
@@ -30,50 +32,80 @@ __export(refresh_runtime_exports, {
|
|
|
30
32
|
});
|
|
31
33
|
module.exports = __toCommonJS(refresh_runtime_exports);
|
|
32
34
|
/*! Copyright (c) Meta Platforms, Inc. and affiliates. **/
|
|
33
|
-
const REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref")
|
|
34
|
-
|
|
35
|
-
let allFamiliesByID = /* @__PURE__ */new Map()
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
|
|
36
|
+
const REACT_MEMO_TYPE = Symbol.for("react.memo");
|
|
37
|
+
let allFamiliesByID = /* @__PURE__ */new Map();
|
|
38
|
+
let allFamiliesByType = /* @__PURE__ */new WeakMap();
|
|
39
|
+
let allSignaturesByType = /* @__PURE__ */new WeakMap();
|
|
38
40
|
const updatedFamiliesByType = /* @__PURE__ */new WeakMap();
|
|
39
41
|
let pendingUpdates = [];
|
|
40
|
-
const helpersByRendererID = /* @__PURE__ */new Map()
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
let rootElements = /* @__PURE__ */new WeakMap()
|
|
45
|
-
|
|
42
|
+
const helpersByRendererID = /* @__PURE__ */new Map();
|
|
43
|
+
const helpersByRoot = /* @__PURE__ */new Map();
|
|
44
|
+
const mountedRoots = /* @__PURE__ */new Set();
|
|
45
|
+
const failedRoots = /* @__PURE__ */new Set();
|
|
46
|
+
let rootElements = /* @__PURE__ */new WeakMap();
|
|
47
|
+
let isPerformingRefresh = false;
|
|
46
48
|
function computeFullKey(signature) {
|
|
47
|
-
if (signature.fullKey !== null)
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
if (signature.fullKey !== null) {
|
|
50
|
+
return signature.fullKey;
|
|
51
|
+
}
|
|
52
|
+
let fullKey = signature.ownKey;
|
|
53
|
+
let hooks2;
|
|
50
54
|
try {
|
|
51
55
|
hooks2 = signature.getCustomHooks();
|
|
52
|
-
} catch {
|
|
53
|
-
|
|
56
|
+
} catch (err) {
|
|
57
|
+
signature.forceReset = true;
|
|
58
|
+
signature.fullKey = fullKey;
|
|
59
|
+
return fullKey;
|
|
54
60
|
}
|
|
55
61
|
for (let i = 0; i < hooks2.length; i++) {
|
|
56
62
|
const hook = hooks2[i];
|
|
57
|
-
if (typeof hook
|
|
63
|
+
if (typeof hook !== "function") {
|
|
64
|
+
signature.forceReset = true;
|
|
65
|
+
signature.fullKey = fullKey;
|
|
66
|
+
return fullKey;
|
|
67
|
+
}
|
|
58
68
|
const nestedHookSignature = allSignaturesByType.get(hook);
|
|
59
|
-
if (nestedHookSignature === void 0)
|
|
69
|
+
if (nestedHookSignature === void 0) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
60
72
|
const nestedHookKey = computeFullKey(nestedHookSignature);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
if (nestedHookSignature.forceReset) {
|
|
74
|
+
signature.forceReset = true;
|
|
75
|
+
}
|
|
76
|
+
fullKey += "\n---\n" + nestedHookKey;
|
|
64
77
|
}
|
|
65
|
-
|
|
78
|
+
signature.fullKey = fullKey;
|
|
79
|
+
return fullKey;
|
|
66
80
|
}
|
|
67
81
|
function haveEqualSignatures(prevType, nextType) {
|
|
68
|
-
const prevSignature = allSignaturesByType.get(prevType)
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
const prevSignature = allSignaturesByType.get(prevType);
|
|
83
|
+
const nextSignature = allSignaturesByType.get(nextType);
|
|
84
|
+
if (prevSignature === void 0 && nextSignature === void 0) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
if (prevSignature === void 0 || nextSignature === void 0) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (computeFullKey(prevSignature) !== computeFullKey(nextSignature)) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (nextSignature.forceReset) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
71
97
|
}
|
|
72
98
|
function isReactClass(type) {
|
|
73
99
|
return type.prototype && type.prototype.isReactComponent;
|
|
74
100
|
}
|
|
75
101
|
function canPreserveStateBetween(prevType, nextType) {
|
|
76
|
-
|
|
102
|
+
if (isReactClass(prevType) || isReactClass(nextType)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (haveEqualSignatures(prevType, nextType)) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
77
109
|
}
|
|
78
110
|
function resolveFamily(type) {
|
|
79
111
|
return updatedFamiliesByType.get(type);
|
|
@@ -81,20 +113,33 @@ function resolveFamily(type) {
|
|
|
81
113
|
function getProperty(object, property) {
|
|
82
114
|
try {
|
|
83
115
|
return object[property];
|
|
84
|
-
} catch {
|
|
85
|
-
return;
|
|
116
|
+
} catch (err) {
|
|
117
|
+
return void 0;
|
|
86
118
|
}
|
|
87
119
|
}
|
|
88
120
|
function performReactRefresh() {
|
|
89
|
-
if (pendingUpdates.length === 0
|
|
90
|
-
|
|
121
|
+
if (pendingUpdates.length === 0) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
if (isPerformingRefresh) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
isPerformingRefresh = true;
|
|
91
128
|
try {
|
|
92
|
-
const staleFamilies = /* @__PURE__ */new Set()
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
pendingUpdates = []
|
|
129
|
+
const staleFamilies = /* @__PURE__ */new Set();
|
|
130
|
+
const updatedFamilies = /* @__PURE__ */new Set();
|
|
131
|
+
const updates = pendingUpdates;
|
|
132
|
+
pendingUpdates = [];
|
|
133
|
+
updates.forEach(([family, nextType]) => {
|
|
96
134
|
const prevType = family.current;
|
|
97
|
-
updatedFamiliesByType.set(prevType, family)
|
|
135
|
+
updatedFamiliesByType.set(prevType, family);
|
|
136
|
+
updatedFamiliesByType.set(nextType, family);
|
|
137
|
+
family.current = nextType;
|
|
138
|
+
if (canPreserveStateBetween(prevType, nextType)) {
|
|
139
|
+
updatedFamilies.add(family);
|
|
140
|
+
} else {
|
|
141
|
+
staleFamilies.add(family);
|
|
142
|
+
}
|
|
98
143
|
});
|
|
99
144
|
const update = {
|
|
100
145
|
updatedFamilies,
|
|
@@ -105,68 +150,112 @@ function performReactRefresh() {
|
|
|
105
150
|
helpersByRendererID.forEach(helpers => {
|
|
106
151
|
helpers.setRefreshHandler(resolveFamily);
|
|
107
152
|
});
|
|
108
|
-
let didError =
|
|
109
|
-
|
|
110
|
-
const failedRootsSnapshot = new Set(failedRoots)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
153
|
+
let didError = false;
|
|
154
|
+
let firstError = null;
|
|
155
|
+
const failedRootsSnapshot = new Set(failedRoots);
|
|
156
|
+
const mountedRootsSnapshot = new Set(mountedRoots);
|
|
157
|
+
const helpersByRootSnapshot = new Map(helpersByRoot);
|
|
158
|
+
failedRootsSnapshot.forEach(root => {
|
|
114
159
|
const helpers = helpersByRootSnapshot.get(root);
|
|
115
|
-
if (helpers === void 0)
|
|
116
|
-
|
|
160
|
+
if (helpers === void 0) {
|
|
161
|
+
throw new Error("Could not find helpers for a root. This is a bug in React Refresh.");
|
|
162
|
+
}
|
|
163
|
+
if (!failedRoots.has(root)) {}
|
|
164
|
+
if (rootElements === null) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (!rootElements.has(root)) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
117
170
|
const element = rootElements.get(root);
|
|
118
171
|
try {
|
|
119
172
|
helpers.scheduleRoot(root, element);
|
|
120
173
|
} catch (err) {
|
|
121
|
-
|
|
174
|
+
if (!didError) {
|
|
175
|
+
didError = true;
|
|
176
|
+
firstError = err;
|
|
177
|
+
}
|
|
122
178
|
}
|
|
123
|
-
})
|
|
179
|
+
});
|
|
180
|
+
mountedRootsSnapshot.forEach(root => {
|
|
124
181
|
const helpers = helpersByRootSnapshot.get(root);
|
|
125
|
-
if (helpers === void 0)
|
|
126
|
-
|
|
182
|
+
if (helpers === void 0) {
|
|
183
|
+
throw new Error("Could not find helpers for a root. This is a bug in React Refresh.");
|
|
184
|
+
}
|
|
185
|
+
if (!mountedRoots.has(root)) {}
|
|
127
186
|
try {
|
|
128
187
|
helpers.scheduleRefresh(root, update);
|
|
129
188
|
} catch (err) {
|
|
130
|
-
|
|
189
|
+
if (!didError) {
|
|
190
|
+
didError = true;
|
|
191
|
+
firstError = err;
|
|
192
|
+
}
|
|
131
193
|
}
|
|
132
|
-
})
|
|
194
|
+
});
|
|
195
|
+
if (didError) {
|
|
196
|
+
throw firstError;
|
|
197
|
+
}
|
|
133
198
|
return update;
|
|
134
199
|
} finally {
|
|
135
|
-
isPerformingRefresh =
|
|
200
|
+
isPerformingRefresh = false;
|
|
136
201
|
}
|
|
137
202
|
}
|
|
138
203
|
function register(type, id) {
|
|
139
|
-
if (type === null
|
|
204
|
+
if (type === null) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (typeof type !== "function" && typeof type !== "object") {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (allFamiliesByType.has(type)) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
140
213
|
let family = allFamiliesByID.get(id);
|
|
141
|
-
if (family === void 0
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
214
|
+
if (family === void 0) {
|
|
215
|
+
family = {
|
|
216
|
+
current: type
|
|
217
|
+
};
|
|
218
|
+
allFamiliesByID.set(id, family);
|
|
219
|
+
} else {
|
|
220
|
+
pendingUpdates.push([family, type]);
|
|
221
|
+
}
|
|
222
|
+
allFamiliesByType.set(type, family);
|
|
223
|
+
if (typeof type === "object" && type !== null) {
|
|
224
|
+
switch (getProperty(type, "$$typeof")) {
|
|
225
|
+
case REACT_FORWARD_REF_TYPE:
|
|
226
|
+
register(type.render, id + "$render");
|
|
227
|
+
break;
|
|
228
|
+
case REACT_MEMO_TYPE:
|
|
229
|
+
register(type.type, id + "$type");
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
150
232
|
}
|
|
151
233
|
}
|
|
152
234
|
function setSignature(type, key, forceReset, getCustomHooks) {
|
|
153
|
-
if (allSignaturesByType.has(type)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
235
|
+
if (!allSignaturesByType.has(type)) {
|
|
236
|
+
allSignaturesByType.set(type, {
|
|
237
|
+
forceReset,
|
|
238
|
+
ownKey: key,
|
|
239
|
+
fullKey: null,
|
|
240
|
+
getCustomHooks: getCustomHooks || (() => [])
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
if (typeof type === "object" && type !== null) {
|
|
244
|
+
switch (getProperty(type, "$$typeof")) {
|
|
245
|
+
case REACT_FORWARD_REF_TYPE:
|
|
246
|
+
setSignature(type.render, key, forceReset, getCustomHooks);
|
|
247
|
+
break;
|
|
248
|
+
case REACT_MEMO_TYPE:
|
|
249
|
+
setSignature(type.type, key, forceReset, getCustomHooks);
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
165
252
|
}
|
|
166
253
|
}
|
|
167
254
|
function collectCustomHooksForSignature(type) {
|
|
168
255
|
const signature = allSignaturesByType.get(type);
|
|
169
|
-
signature !== void 0
|
|
256
|
+
if (signature !== void 0) {
|
|
257
|
+
computeFullKey(signature);
|
|
258
|
+
}
|
|
170
259
|
}
|
|
171
260
|
function injectIntoGlobalHook(globalObject) {
|
|
172
261
|
let hook = globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
@@ -174,7 +263,7 @@ function injectIntoGlobalHook(globalObject) {
|
|
|
174
263
|
let nextID = 0;
|
|
175
264
|
globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook = {
|
|
176
265
|
renderers: /* @__PURE__ */new Map(),
|
|
177
|
-
supportsFiber:
|
|
266
|
+
supportsFiber: true,
|
|
178
267
|
inject: injected => nextID++,
|
|
179
268
|
onScheduleFiberRoot: (id, root, children) => {},
|
|
180
269
|
onCommitFiberRoot: (id, root, maybePriorityLevel, didError) => {},
|
|
@@ -182,42 +271,83 @@ function injectIntoGlobalHook(globalObject) {
|
|
|
182
271
|
};
|
|
183
272
|
}
|
|
184
273
|
if (hook.isDisabled) {
|
|
185
|
-
console
|
|
274
|
+
console["warn"]("Something has shimmed the React DevTools global hook (__REACT_DEVTOOLS_GLOBAL_HOOK__). Fast Refresh is not compatible with this shim and will be disabled.");
|
|
186
275
|
return;
|
|
187
276
|
}
|
|
188
277
|
const oldInject = hook.inject;
|
|
189
278
|
hook.inject = function (injected) {
|
|
190
279
|
const id = oldInject.apply(this, arguments);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
280
|
+
if (typeof injected.scheduleRefresh === "function" && typeof injected.setRefreshHandler === "function") {
|
|
281
|
+
helpersByRendererID.set(id, injected);
|
|
282
|
+
}
|
|
283
|
+
return id;
|
|
284
|
+
};
|
|
285
|
+
hook.renderers.forEach((injected, id) => {
|
|
286
|
+
if (typeof injected.scheduleRefresh === "function" && typeof injected.setRefreshHandler === "function") {
|
|
287
|
+
helpersByRendererID.set(id, injected);
|
|
288
|
+
}
|
|
194
289
|
});
|
|
195
|
-
const oldOnCommitFiberRoot = hook.onCommitFiberRoot
|
|
196
|
-
|
|
290
|
+
const oldOnCommitFiberRoot = hook.onCommitFiberRoot;
|
|
291
|
+
const oldOnScheduleFiberRoot = hook.onScheduleFiberRoot || (() => {});
|
|
197
292
|
hook.onScheduleFiberRoot = function (id, root, children) {
|
|
198
|
-
|
|
199
|
-
|
|
293
|
+
if (!isPerformingRefresh) {
|
|
294
|
+
failedRoots.delete(root);
|
|
295
|
+
if (rootElements !== null) {
|
|
296
|
+
rootElements.set(root, children);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return oldOnScheduleFiberRoot.apply(this, arguments);
|
|
300
|
+
};
|
|
301
|
+
hook.onCommitFiberRoot = function (id, root, maybePriorityLevel, didError) {
|
|
200
302
|
const helpers = helpersByRendererID.get(id);
|
|
201
303
|
if (helpers !== void 0) {
|
|
202
304
|
helpersByRoot.set(root, helpers);
|
|
203
|
-
const current = root.current
|
|
204
|
-
|
|
305
|
+
const current = root.current;
|
|
306
|
+
const alternate = current.alternate;
|
|
205
307
|
if (alternate !== null) {
|
|
206
|
-
const wasMounted = alternate.memoizedState != null && alternate.memoizedState.element != null && mountedRoots.has(root)
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
308
|
+
const wasMounted = alternate.memoizedState != null && alternate.memoizedState.element != null && mountedRoots.has(root);
|
|
309
|
+
const isMounted = current.memoizedState != null && current.memoizedState.element != null;
|
|
310
|
+
if (!wasMounted && isMounted) {
|
|
311
|
+
mountedRoots.add(root);
|
|
312
|
+
failedRoots.delete(root);
|
|
313
|
+
} else if (wasMounted && isMounted) {} else if (wasMounted && !isMounted) {
|
|
314
|
+
mountedRoots.delete(root);
|
|
315
|
+
if (didError) {
|
|
316
|
+
failedRoots.add(root);
|
|
317
|
+
} else {
|
|
318
|
+
helpersByRoot.delete(root);
|
|
319
|
+
}
|
|
320
|
+
} else if (!wasMounted && !isMounted) {
|
|
321
|
+
if (didError) {
|
|
322
|
+
failedRoots.add(root);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
} else {
|
|
326
|
+
mountedRoots.add(root);
|
|
327
|
+
}
|
|
210
328
|
}
|
|
211
329
|
return oldOnCommitFiberRoot.apply(this, arguments);
|
|
212
330
|
};
|
|
213
331
|
}
|
|
214
332
|
function createSignatureFunctionForTransform() {
|
|
215
|
-
let savedType
|
|
216
|
-
|
|
217
|
-
|
|
333
|
+
let savedType;
|
|
334
|
+
let hasCustomHooks;
|
|
335
|
+
let didCollectHooks = false;
|
|
218
336
|
return (type, key, forceReset, getCustomHooks) => {
|
|
219
|
-
if (typeof key
|
|
220
|
-
|
|
337
|
+
if (typeof key === "string") {
|
|
338
|
+
if (!savedType) {
|
|
339
|
+
savedType = type;
|
|
340
|
+
hasCustomHooks = typeof getCustomHooks === "function";
|
|
341
|
+
}
|
|
342
|
+
if (type != null && (typeof type === "function" || typeof type === "object")) {
|
|
343
|
+
setSignature(type, key, forceReset, getCustomHooks);
|
|
344
|
+
}
|
|
345
|
+
return type;
|
|
346
|
+
}
|
|
347
|
+
if (!didCollectHooks && hasCustomHooks) {
|
|
348
|
+
didCollectHooks = true;
|
|
349
|
+
collectCustomHooksForSignature(savedType);
|
|
350
|
+
}
|
|
221
351
|
};
|
|
222
352
|
}
|
|
223
353
|
function isLikelyComponentType(type) {
|
|
@@ -225,26 +355,37 @@ function isLikelyComponentType(type) {
|
|
|
225
355
|
case "function":
|
|
226
356
|
{
|
|
227
357
|
if (type.prototype != null) {
|
|
228
|
-
if (type.prototype.isReactComponent)
|
|
358
|
+
if (type.prototype.isReactComponent) {
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
229
361
|
const ownNames = Object.getOwnPropertyNames(type.prototype);
|
|
230
|
-
if (ownNames.length > 1 || ownNames[0] !== "constructor"
|
|
362
|
+
if (ownNames.length > 1 || ownNames[0] !== "constructor") {
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
if (type.prototype.__proto__ !== Object.prototype) {
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
231
368
|
}
|
|
232
369
|
const name = type.name || type.displayName;
|
|
233
|
-
return typeof name
|
|
370
|
+
return typeof name === "string" && /^[A-Z]/.test(name);
|
|
234
371
|
}
|
|
235
372
|
case "object":
|
|
236
373
|
{
|
|
237
|
-
if (type != null)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
374
|
+
if (type != null) {
|
|
375
|
+
switch (getProperty(type, "$$typeof")) {
|
|
376
|
+
case REACT_FORWARD_REF_TYPE:
|
|
377
|
+
case REACT_MEMO_TYPE:
|
|
378
|
+
return true;
|
|
379
|
+
default:
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
243
382
|
}
|
|
244
|
-
return
|
|
383
|
+
return false;
|
|
245
384
|
}
|
|
246
385
|
default:
|
|
247
|
-
|
|
386
|
+
{
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
248
389
|
}
|
|
249
390
|
}
|
|
250
391
|
function getRefreshReg(filename) {
|
|
@@ -254,13 +395,16 @@ function registerExportsForReactRefresh(filename, moduleExports) {
|
|
|
254
395
|
for (const key in moduleExports) {
|
|
255
396
|
if (key === "__esModule") continue;
|
|
256
397
|
const exportValue = moduleExports[key];
|
|
257
|
-
isLikelyComponentType(exportValue)
|
|
398
|
+
if (isLikelyComponentType(exportValue)) {
|
|
399
|
+
register(exportValue, filename + " export " + key);
|
|
400
|
+
}
|
|
258
401
|
}
|
|
259
402
|
}
|
|
260
403
|
function debounce(fn, delay) {
|
|
261
404
|
let handle;
|
|
262
405
|
return () => {
|
|
263
|
-
clearTimeout(handle)
|
|
406
|
+
clearTimeout(handle);
|
|
407
|
+
handle = setTimeout(fn, delay);
|
|
264
408
|
};
|
|
265
409
|
}
|
|
266
410
|
const hooks = [];
|
|
@@ -268,23 +412,38 @@ window.__registerBeforePerformReactRefresh = cb => {
|
|
|
268
412
|
hooks.push(cb);
|
|
269
413
|
};
|
|
270
414
|
const enqueueUpdate = debounce(async () => {
|
|
271
|
-
hooks.length
|
|
415
|
+
if (hooks.length) await Promise.all(hooks.map(cb => cb()));
|
|
416
|
+
performReactRefresh();
|
|
272
417
|
}, 16);
|
|
273
418
|
function validateRefreshBoundaryAndEnqueueUpdate(id, prevExports, nextExports) {
|
|
274
419
|
const ignoredExports = ["sitemap", "loader", "generateStaticParams"];
|
|
275
|
-
if (predicateOnExport(ignoredExports, prevExports, key => key in nextExports) !==
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
420
|
+
if (predicateOnExport(ignoredExports, prevExports, key => key in nextExports) !== true) {
|
|
421
|
+
return "Could not Fast Refresh (export removed)";
|
|
422
|
+
}
|
|
423
|
+
if (predicateOnExport(ignoredExports, nextExports, key => key in prevExports) !== true) {
|
|
424
|
+
return "Could not Fast Refresh (new export)";
|
|
425
|
+
}
|
|
426
|
+
let hasExports = false;
|
|
427
|
+
const allExportsAreComponentsOrUnchanged = predicateOnExport(ignoredExports, nextExports, (key, value) => {
|
|
428
|
+
hasExports = true;
|
|
429
|
+
if (isLikelyComponentType(value)) return true;
|
|
430
|
+
return prevExports[key] === nextExports[key];
|
|
431
|
+
});
|
|
432
|
+
if (hasExports && allExportsAreComponentsOrUnchanged === true) {
|
|
433
|
+
enqueueUpdate();
|
|
434
|
+
} else {
|
|
435
|
+
return `Could not Fast Refresh ("${allExportsAreComponentsOrUnchanged}" export is incompatible). Learn more at https://github.com/vitejs/vite-plugin-react-swc#consistent-components-exports`;
|
|
436
|
+
}
|
|
280
437
|
}
|
|
281
438
|
function predicateOnExport(ignoredExports, moduleExports, predicate) {
|
|
282
439
|
for (const key in moduleExports) {
|
|
283
|
-
if (key === "__esModule"
|
|
440
|
+
if (key === "__esModule") continue;
|
|
441
|
+
if (ignoredExports.includes(key)) continue;
|
|
284
442
|
const desc = Object.getOwnPropertyDescriptor(moduleExports, key);
|
|
285
|
-
if (desc && desc.get
|
|
443
|
+
if (desc && desc.get) return key;
|
|
444
|
+
if (!predicate(key, moduleExports[key])) return key;
|
|
286
445
|
}
|
|
287
|
-
return
|
|
446
|
+
return true;
|
|
288
447
|
}
|
|
289
448
|
const __hmr_import = module2 => import(/* @vite-ignore */
|
|
290
449
|
module2);
|