@vxrn/compiler 1.1.397

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.
Files changed (98) hide show
  1. package/LICENSE +45 -0
  2. package/dist/cjs/configure.cjs +34 -0
  3. package/dist/cjs/configure.js +29 -0
  4. package/dist/cjs/configure.js.map +6 -0
  5. package/dist/cjs/configure.native.js +35 -0
  6. package/dist/cjs/configure.native.js.map +6 -0
  7. package/dist/cjs/constants.cjs +65 -0
  8. package/dist/cjs/constants.js +34 -0
  9. package/dist/cjs/constants.js.map +6 -0
  10. package/dist/cjs/constants.native.js +65 -0
  11. package/dist/cjs/constants.native.js.map +6 -0
  12. package/dist/cjs/index.cjs +124 -0
  13. package/dist/cjs/index.js +113 -0
  14. package/dist/cjs/index.js.map +6 -0
  15. package/dist/cjs/index.native.js +123 -0
  16. package/dist/cjs/index.native.js.map +6 -0
  17. package/dist/cjs/refresh-runtime.cjs +295 -0
  18. package/dist/cjs/refresh-runtime.js +296 -0
  19. package/dist/cjs/refresh-runtime.js.map +6 -0
  20. package/dist/cjs/refresh-runtime.native.js +316 -0
  21. package/dist/cjs/refresh-runtime.native.js.map +6 -0
  22. package/dist/cjs/transformBabel.cjs +111 -0
  23. package/dist/cjs/transformBabel.js +116 -0
  24. package/dist/cjs/transformBabel.js.map +6 -0
  25. package/dist/cjs/transformBabel.native.js +152 -0
  26. package/dist/cjs/transformBabel.native.js.map +6 -0
  27. package/dist/cjs/transformSWC.cjs +261 -0
  28. package/dist/cjs/transformSWC.js +256 -0
  29. package/dist/cjs/transformSWC.js.map +6 -0
  30. package/dist/cjs/transformSWC.native.js +275 -0
  31. package/dist/cjs/transformSWC.native.js.map +6 -0
  32. package/dist/cjs/types.cjs +16 -0
  33. package/dist/cjs/types.js +14 -0
  34. package/dist/cjs/types.js.map +6 -0
  35. package/dist/cjs/types.native.js +15 -0
  36. package/dist/cjs/types.native.js.map +6 -0
  37. package/dist/esm/configure.js +13 -0
  38. package/dist/esm/configure.js.map +6 -0
  39. package/dist/esm/configure.mjs +10 -0
  40. package/dist/esm/configure.mjs.map +1 -0
  41. package/dist/esm/configure.native.js +13 -0
  42. package/dist/esm/configure.native.js.map +6 -0
  43. package/dist/esm/constants.js +18 -0
  44. package/dist/esm/constants.js.map +6 -0
  45. package/dist/esm/constants.mjs +38 -0
  46. package/dist/esm/constants.mjs.map +1 -0
  47. package/dist/esm/constants.native.js +41 -0
  48. package/dist/esm/constants.native.js.map +6 -0
  49. package/dist/esm/index.js +102 -0
  50. package/dist/esm/index.js.map +6 -0
  51. package/dist/esm/index.mjs +99 -0
  52. package/dist/esm/index.mjs.map +1 -0
  53. package/dist/esm/index.native.js +104 -0
  54. package/dist/esm/index.native.js.map +6 -0
  55. package/dist/esm/refresh-runtime.js +280 -0
  56. package/dist/esm/refresh-runtime.js.map +6 -0
  57. package/dist/esm/refresh-runtime.mjs +266 -0
  58. package/dist/esm/refresh-runtime.mjs.map +1 -0
  59. package/dist/esm/refresh-runtime.native.js +290 -0
  60. package/dist/esm/refresh-runtime.native.js.map +6 -0
  61. package/dist/esm/transformBabel.js +95 -0
  62. package/dist/esm/transformBabel.js.map +6 -0
  63. package/dist/esm/transformBabel.mjs +76 -0
  64. package/dist/esm/transformBabel.mjs.map +1 -0
  65. package/dist/esm/transformBabel.native.js +125 -0
  66. package/dist/esm/transformBabel.native.js.map +6 -0
  67. package/dist/esm/transformSWC.js +246 -0
  68. package/dist/esm/transformSWC.js.map +6 -0
  69. package/dist/esm/transformSWC.mjs +237 -0
  70. package/dist/esm/transformSWC.mjs.map +1 -0
  71. package/dist/esm/transformSWC.native.js +257 -0
  72. package/dist/esm/transformSWC.native.js.map +6 -0
  73. package/dist/esm/types.js +1 -0
  74. package/dist/esm/types.js.map +6 -0
  75. package/dist/esm/types.mjs +2 -0
  76. package/dist/esm/types.mjs.map +1 -0
  77. package/dist/esm/types.native.js +1 -0
  78. package/dist/esm/types.native.js.map +6 -0
  79. package/package.json +54 -0
  80. package/src/configure.ts +17 -0
  81. package/src/constants.ts +21 -0
  82. package/src/index.ts +166 -0
  83. package/src/refresh-runtime.js +619 -0
  84. package/src/transformBabel.ts +218 -0
  85. package/src/transformSWC.ts +381 -0
  86. package/src/types.ts +36 -0
  87. package/types/configure.d.ts +10 -0
  88. package/types/configure.d.ts.map +1 -0
  89. package/types/constants.d.ts +9 -0
  90. package/types/constants.d.ts.map +1 -0
  91. package/types/index.d.ts +12 -0
  92. package/types/index.d.ts.map +1 -0
  93. package/types/transformBabel.d.ts +12 -0
  94. package/types/transformBabel.d.ts.map +1 -0
  95. package/types/transformSWC.d.ts +7 -0
  96. package/types/transformSWC.d.ts.map +1 -0
  97. package/types/types.d.ts +29 -0
  98. package/types/types.d.ts.map +1 -0
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var index_exports = {};
17
+ __export(index_exports, {
18
+ createVXRNCompilerPlugin: () => createVXRNCompilerPlugin
19
+ });
20
+ module.exports = __toCommonJS(index_exports);
21
+ var import_utils = require("@vxrn/utils"), import_node_fs = require("node:fs"), import_promises = require("node:fs/promises"), import_node_path = require("node:path"), import_constants = require("./constants"), import_transformBabel = require("./transformBabel"), import_transformSWC = require("./transformSWC");
22
+ __reExport(index_exports, require("./configure"), module.exports);
23
+ __reExport(index_exports, require("./transformBabel"), module.exports);
24
+ __reExport(index_exports, require("./transformSWC"), module.exports);
25
+ const import_meta = {};
26
+ async function createVXRNCompilerPlugin(optionsIn) {
27
+ var reactVersion = await async function() {
28
+ var path = (0, import_utils.resolvePath)("react/package.json"), json = JSON.parse(await (0, import_promises.readFile)(path, "utf-8"));
29
+ return json.version;
30
+ }(), envNames = {
31
+ ios: !0,
32
+ android: !0,
33
+ client: !0,
34
+ ssr: !0
35
+ };
36
+ function getEnvName(name) {
37
+ if (!envNames[name]) throw new Error(`Invalid env: ${name}`);
38
+ return name;
39
+ }
40
+ return [
41
+ {
42
+ name: "one:compiler-resolve-refresh-runtime",
43
+ apply: "serve",
44
+ enforce: "pre",
45
+ // Run before Vite default resolve to avoid syscalls
46
+ resolveId: function(id) {
47
+ return id === import_constants.runtimePublicPath ? id : void 0;
48
+ },
49
+ load: function(id) {
50
+ return id === import_constants.runtimePublicPath ? (0, import_node_fs.readFileSync)((0, import_node_path.join)(import_meta.dirname, "refresh-runtime.js"), "utf-8") : void 0;
51
+ }
52
+ },
53
+ {
54
+ name: "one:compiler",
55
+ enforce: "pre",
56
+ config: function() {
57
+ var config = {
58
+ esbuild: !1,
59
+ optimizeDeps: {
60
+ noDiscovery: !0
61
+ }
62
+ };
63
+ return {
64
+ environments: {
65
+ ios: config,
66
+ android: config
67
+ }
68
+ };
69
+ },
70
+ transform: {
71
+ order: "pre",
72
+ async handler(codeIn, _id) {
73
+ var _optionsIn_transform, code = codeIn, shouldDebug = process.env.NODE_ENV === "development" && codeIn.startsWith("// debug");
74
+ shouldDebug && (console.info(`[one] ${_id} input:`), console.info(codeIn));
75
+ var extension = (0, import_node_path.extname)(_id);
76
+ if (import_constants.validParsers.has(extension)) {
77
+ var id = _id.split("?")[0], isPreProcess = id.startsWith("vxrn-swc-preprocess:");
78
+ if (isPreProcess && (id = id.replace("vxrn-swc-preprocess:", "")), !id.includes("virtual:")) {
79
+ var environment = getEnvName(this.environment.name), production = process.env.NODE_ENV === "production", transformProps = {
80
+ id,
81
+ code,
82
+ development: !production,
83
+ environment,
84
+ reactForRNVersion: reactVersion.split(".")[0]
85
+ }, userTransform = optionsIn == null || (_optionsIn_transform = optionsIn.transform) === null || _optionsIn_transform === void 0 ? void 0 : _optionsIn_transform.call(optionsIn, transformProps);
86
+ if (userTransform !== !1) {
87
+ if (!isPreProcess && userTransform !== "swc") {
88
+ var babelOptions = (0, import_transformBabel.getBabelOptions)({
89
+ ...transformProps,
90
+ userSetting: userTransform
91
+ });
92
+ if (babelOptions) {
93
+ var babelOut = await (0, import_transformBabel.transformBabel)(id, code, babelOptions);
94
+ babelOut && (import_constants.debug === null || import_constants.debug === void 0 || (0, import_constants.debug)(`[${id}] transformed with babel options: ${JSON.stringify(babelOptions)}`), code = babelOut);
95
+ }
96
+ }
97
+ var swcOptions = {
98
+ environment,
99
+ mode: "serve",
100
+ production,
101
+ ...optionsIn
102
+ }, out = await (0, import_transformSWC.transformSWC)(id, code, {
103
+ ...swcOptions,
104
+ es5: !0,
105
+ noHMR: isPreProcess
106
+ });
107
+ return shouldDebug && (console.info("swcOptions", swcOptions), console.info("final output:", out == null ? void 0 : out.code)), out;
108
+ }
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
114
+ ];
115
+ }
116
+ // Annotate the CommonJS export names for ESM import in node:
117
+ 0 && (module.exports = {
118
+ createVXRNCompilerPlugin,
119
+ ...require("./configure"),
120
+ ...require("./transformBabel"),
121
+ ...require("./transformSWC")
122
+ });
123
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Users/n8/one/packages/compiler/src/index.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;AAAA;;;;;AAKA,mBAA4B,wBAC5B,iBAA6B,oBAC7B,kBAAyB,6BACzB,mBAA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erPlugin", "optionsIn", "reactVersion", "path", "resolvePath", "json", "JSON", "parse", "readFile", "version", "envNames", "ios", "android", "client", "ssr", "getEnvName", "name", "Error", "apply", "enforce", "resolveId", "id", "runtimePublicPath", "undefined", "load", "readFileSync", "join", "dirname", "config", "esbuild", "optimizeDeps", "noDiscovery", "environments", "transform", "order", "handler", "codeIn", "_id", "code", "shouldDebug", "process", "env", "NODE_ENV", "startsWith", "console", "info", "extension", "extname", "validParsers", "has", "split", "isPreProcess", "replace", "includes", "environment", "production", "transformProps", "development", "reactForRNVersion", "userTransform", "babelOptions", "getBabelOptions", "userSetting", "babelOut", "transformBabel", "debug", "stringify", "swcOptions", "mode", "out", "transformSWC", "es5", "noHMR"]
6
+ }
@@ -0,0 +1,295 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var refresh_runtime_exports = {};
22
+ __export(refresh_runtime_exports, {
23
+ __hmr_import: () => __hmr_import,
24
+ createSignatureFunctionForTransform: () => createSignatureFunctionForTransform,
25
+ default: () => refresh_runtime_default,
26
+ getRefreshReg: () => getRefreshReg,
27
+ injectIntoGlobalHook: () => injectIntoGlobalHook,
28
+ registerExportsForReactRefresh: () => registerExportsForReactRefresh,
29
+ validateRefreshBoundaryAndEnqueueUpdate: () => validateRefreshBoundaryAndEnqueueUpdate
30
+ });
31
+ module.exports = __toCommonJS(refresh_runtime_exports);
32
+ /*! Copyright (c) Meta Platforms, Inc. and affiliates. **/
33
+ const REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
34
+ REACT_MEMO_TYPE = Symbol.for("react.memo");
35
+ let allFamiliesByID = /* @__PURE__ */new Map(),
36
+ allFamiliesByType = /* @__PURE__ */new WeakMap(),
37
+ allSignaturesByType = /* @__PURE__ */new WeakMap();
38
+ const updatedFamiliesByType = /* @__PURE__ */new WeakMap();
39
+ let pendingUpdates = [];
40
+ const helpersByRendererID = /* @__PURE__ */new Map(),
41
+ helpersByRoot = /* @__PURE__ */new Map(),
42
+ mountedRoots = /* @__PURE__ */new Set(),
43
+ failedRoots = /* @__PURE__ */new Set();
44
+ let rootElements = /* @__PURE__ */new WeakMap(),
45
+ isPerformingRefresh = !1;
46
+ function computeFullKey(signature) {
47
+ if (signature.fullKey !== null) return signature.fullKey;
48
+ let fullKey = signature.ownKey,
49
+ hooks2;
50
+ try {
51
+ hooks2 = signature.getCustomHooks();
52
+ } catch {
53
+ return signature.forceReset = !0, signature.fullKey = fullKey, fullKey;
54
+ }
55
+ for (let i = 0; i < hooks2.length; i++) {
56
+ const hook = hooks2[i];
57
+ if (typeof hook != "function") return signature.forceReset = !0, signature.fullKey = fullKey, fullKey;
58
+ const nestedHookSignature = allSignaturesByType.get(hook);
59
+ if (nestedHookSignature === void 0) continue;
60
+ const nestedHookKey = computeFullKey(nestedHookSignature);
61
+ nestedHookSignature.forceReset && (signature.forceReset = !0), fullKey += `
62
+ ---
63
+ ` + nestedHookKey;
64
+ }
65
+ return signature.fullKey = fullKey, fullKey;
66
+ }
67
+ function haveEqualSignatures(prevType, nextType) {
68
+ const prevSignature = allSignaturesByType.get(prevType),
69
+ nextSignature = allSignaturesByType.get(nextType);
70
+ return prevSignature === void 0 && nextSignature === void 0 ? !0 : !(prevSignature === void 0 || nextSignature === void 0 || computeFullKey(prevSignature) !== computeFullKey(nextSignature) || nextSignature.forceReset);
71
+ }
72
+ function isReactClass(type) {
73
+ return type.prototype && type.prototype.isReactComponent;
74
+ }
75
+ function canPreserveStateBetween(prevType, nextType) {
76
+ return isReactClass(prevType) || isReactClass(nextType) ? !1 : !!haveEqualSignatures(prevType, nextType);
77
+ }
78
+ function resolveFamily(type) {
79
+ return updatedFamiliesByType.get(type);
80
+ }
81
+ function getProperty(object, property) {
82
+ try {
83
+ return object[property];
84
+ } catch {
85
+ return;
86
+ }
87
+ }
88
+ function performReactRefresh() {
89
+ if (pendingUpdates.length === 0 || isPerformingRefresh) return null;
90
+ isPerformingRefresh = !0;
91
+ try {
92
+ const staleFamilies = /* @__PURE__ */new Set(),
93
+ updatedFamilies = /* @__PURE__ */new Set(),
94
+ updates = pendingUpdates;
95
+ pendingUpdates = [], updates.forEach(([family, nextType]) => {
96
+ const prevType = family.current;
97
+ updatedFamiliesByType.set(prevType, family), updatedFamiliesByType.set(nextType, family), family.current = nextType, canPreserveStateBetween(prevType, nextType) ? updatedFamilies.add(family) : staleFamilies.add(family);
98
+ });
99
+ const update = {
100
+ updatedFamilies,
101
+ // Families that will re-render preserving state
102
+ staleFamilies
103
+ // Families that will be remounted
104
+ };
105
+ helpersByRendererID.forEach(helpers => {
106
+ helpers.setRefreshHandler(resolveFamily);
107
+ });
108
+ let didError = !1,
109
+ firstError = null;
110
+ const failedRootsSnapshot = new Set(failedRoots),
111
+ mountedRootsSnapshot = new Set(mountedRoots),
112
+ helpersByRootSnapshot = new Map(helpersByRoot);
113
+ if (failedRootsSnapshot.forEach(root => {
114
+ const helpers = helpersByRootSnapshot.get(root);
115
+ if (helpers === void 0) throw new Error("Could not find helpers for a root. This is a bug in React Refresh.");
116
+ if (failedRoots.has(root), rootElements === null || !rootElements.has(root)) return;
117
+ const element = rootElements.get(root);
118
+ try {
119
+ helpers.scheduleRoot(root, element);
120
+ } catch (err) {
121
+ didError || (didError = !0, firstError = err);
122
+ }
123
+ }), mountedRootsSnapshot.forEach(root => {
124
+ const helpers = helpersByRootSnapshot.get(root);
125
+ if (helpers === void 0) throw new Error("Could not find helpers for a root. This is a bug in React Refresh.");
126
+ mountedRoots.has(root);
127
+ try {
128
+ helpers.scheduleRefresh(root, update);
129
+ } catch (err) {
130
+ didError || (didError = !0, firstError = err);
131
+ }
132
+ }), didError) throw firstError;
133
+ return update;
134
+ } finally {
135
+ isPerformingRefresh = !1;
136
+ }
137
+ }
138
+ function register(type, id) {
139
+ if (type === null || typeof type != "function" && typeof type != "object" || allFamiliesByType.has(type)) return;
140
+ let family = allFamiliesByID.get(id);
141
+ if (family === void 0 ? (family = {
142
+ current: type
143
+ }, allFamiliesByID.set(id, family)) : pendingUpdates.push([family, type]), allFamiliesByType.set(type, family), typeof type == "object" && type !== null) switch (getProperty(type, "$$typeof")) {
144
+ case REACT_FORWARD_REF_TYPE:
145
+ register(type.render, id + "$render");
146
+ break;
147
+ case REACT_MEMO_TYPE:
148
+ register(type.type, id + "$type");
149
+ break;
150
+ }
151
+ }
152
+ function setSignature(type, key, forceReset, getCustomHooks) {
153
+ if (allSignaturesByType.has(type) || allSignaturesByType.set(type, {
154
+ forceReset,
155
+ ownKey: key,
156
+ fullKey: null,
157
+ getCustomHooks: getCustomHooks || (() => [])
158
+ }), typeof type == "object" && type !== null) switch (getProperty(type, "$$typeof")) {
159
+ case REACT_FORWARD_REF_TYPE:
160
+ setSignature(type.render, key, forceReset, getCustomHooks);
161
+ break;
162
+ case REACT_MEMO_TYPE:
163
+ setSignature(type.type, key, forceReset, getCustomHooks);
164
+ break;
165
+ }
166
+ }
167
+ function collectCustomHooksForSignature(type) {
168
+ const signature = allSignaturesByType.get(type);
169
+ signature !== void 0 && computeFullKey(signature);
170
+ }
171
+ function injectIntoGlobalHook(globalObject) {
172
+ let hook = globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__;
173
+ if (hook === void 0) {
174
+ let nextID = 0;
175
+ globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook = {
176
+ renderers: /* @__PURE__ */new Map(),
177
+ supportsFiber: !0,
178
+ inject: injected => nextID++,
179
+ onScheduleFiberRoot: (id, root, children) => {},
180
+ onCommitFiberRoot: (id, root, maybePriorityLevel, didError) => {},
181
+ onCommitFiberUnmount() {}
182
+ };
183
+ }
184
+ if (hook.isDisabled) {
185
+ 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
+ return;
187
+ }
188
+ const oldInject = hook.inject;
189
+ hook.inject = function (injected) {
190
+ const id = oldInject.apply(this, arguments);
191
+ return typeof injected.scheduleRefresh == "function" && typeof injected.setRefreshHandler == "function" && helpersByRendererID.set(id, injected), id;
192
+ }, hook.renderers.forEach((injected, id) => {
193
+ typeof injected.scheduleRefresh == "function" && typeof injected.setRefreshHandler == "function" && helpersByRendererID.set(id, injected);
194
+ });
195
+ const oldOnCommitFiberRoot = hook.onCommitFiberRoot,
196
+ oldOnScheduleFiberRoot = hook.onScheduleFiberRoot || (() => {});
197
+ hook.onScheduleFiberRoot = function (id, root, children) {
198
+ return isPerformingRefresh || (failedRoots.delete(root), rootElements !== null && rootElements.set(root, children)), oldOnScheduleFiberRoot.apply(this, arguments);
199
+ }, hook.onCommitFiberRoot = function (id, root, maybePriorityLevel, didError) {
200
+ const helpers = helpersByRendererID.get(id);
201
+ if (helpers !== void 0) {
202
+ helpersByRoot.set(root, helpers);
203
+ const current = root.current,
204
+ alternate = current.alternate;
205
+ if (alternate !== null) {
206
+ const wasMounted = alternate.memoizedState != null && alternate.memoizedState.element != null && mountedRoots.has(root),
207
+ isMounted = current.memoizedState != null && current.memoizedState.element != null;
208
+ !wasMounted && isMounted ? (mountedRoots.add(root), failedRoots.delete(root)) : wasMounted && isMounted || (wasMounted && !isMounted ? (mountedRoots.delete(root), didError ? failedRoots.add(root) : helpersByRoot.delete(root)) : !wasMounted && !isMounted && didError && failedRoots.add(root));
209
+ } else mountedRoots.add(root);
210
+ }
211
+ return oldOnCommitFiberRoot.apply(this, arguments);
212
+ };
213
+ }
214
+ function createSignatureFunctionForTransform() {
215
+ let savedType,
216
+ hasCustomHooks,
217
+ didCollectHooks = !1;
218
+ return (type, key, forceReset, getCustomHooks) => {
219
+ if (typeof key == "string") return savedType || (savedType = type, hasCustomHooks = typeof getCustomHooks == "function"), type != null && (typeof type == "function" || typeof type == "object") && setSignature(type, key, forceReset, getCustomHooks), type;
220
+ !didCollectHooks && hasCustomHooks && (didCollectHooks = !0, collectCustomHooksForSignature(savedType));
221
+ };
222
+ }
223
+ function isLikelyComponentType(type) {
224
+ switch (typeof type) {
225
+ case "function":
226
+ {
227
+ if (type.prototype != null) {
228
+ if (type.prototype.isReactComponent) return !0;
229
+ const ownNames = Object.getOwnPropertyNames(type.prototype);
230
+ if (ownNames.length > 1 || ownNames[0] !== "constructor" || type.prototype.__proto__ !== Object.prototype) return !1;
231
+ }
232
+ const name = type.name || type.displayName;
233
+ return typeof name == "string" && /^[A-Z]/.test(name);
234
+ }
235
+ case "object":
236
+ {
237
+ if (type != null) switch (getProperty(type, "$$typeof")) {
238
+ case REACT_FORWARD_REF_TYPE:
239
+ case REACT_MEMO_TYPE:
240
+ return !0;
241
+ default:
242
+ return !1;
243
+ }
244
+ return !1;
245
+ }
246
+ default:
247
+ return !1;
248
+ }
249
+ }
250
+ function getRefreshReg(filename) {
251
+ return (type, id) => register(type, filename + " " + id);
252
+ }
253
+ function registerExportsForReactRefresh(filename, moduleExports) {
254
+ for (const key in moduleExports) {
255
+ if (key === "__esModule") continue;
256
+ const exportValue = moduleExports[key];
257
+ isLikelyComponentType(exportValue) && register(exportValue, filename + " export " + key);
258
+ }
259
+ }
260
+ function debounce(fn, delay) {
261
+ let handle;
262
+ return () => {
263
+ clearTimeout(handle), handle = setTimeout(fn, delay);
264
+ };
265
+ }
266
+ const hooks = [];
267
+ window.__registerBeforePerformReactRefresh = cb => {
268
+ hooks.push(cb);
269
+ };
270
+ const enqueueUpdate = debounce(async () => {
271
+ hooks.length && (await Promise.all(hooks.map(cb => cb()))), performReactRefresh();
272
+ }, 16);
273
+ function validateRefreshBoundaryAndEnqueueUpdate(id, prevExports, nextExports) {
274
+ const ignoredExports = window.__getReactRefreshIgnoredExports?.({
275
+ id
276
+ }) ?? [];
277
+ if (predicateOnExport(ignoredExports, prevExports, key => key in nextExports) !== !0) return "Could not Fast Refresh (export removed)";
278
+ if (predicateOnExport(ignoredExports, nextExports, key => key in prevExports) !== !0) return "Could not Fast Refresh (new export)";
279
+ let hasExports = !1;
280
+ const allExportsAreComponentsOrUnchanged = predicateOnExport(ignoredExports, nextExports, (key, value) => (hasExports = !0, isLikelyComponentType(value) ? !0 : prevExports[key] === nextExports[key]));
281
+ if (hasExports && allExportsAreComponentsOrUnchanged === !0) enqueueUpdate();else return `Could not Fast Refresh ("${allExportsAreComponentsOrUnchanged}" export is incompatible). Learn more at https://github.com/vitejs/vite-plugin-react-swc#consistent-components-exports`;
282
+ }
283
+ function predicateOnExport(ignoredExports, moduleExports, predicate) {
284
+ for (const key in moduleExports) {
285
+ if (key === "__esModule" || ignoredExports.includes(key)) continue;
286
+ const desc = Object.getOwnPropertyDescriptor(moduleExports, key);
287
+ if (desc && desc.get || !predicate(key, moduleExports[key])) return key;
288
+ }
289
+ return !0;
290
+ }
291
+ const __hmr_import = module2 => import(/* @vite-ignore */
292
+ module2);
293
+ var refresh_runtime_default = {
294
+ injectIntoGlobalHook
295
+ };