@hanzogui/vite-plugin 2.0.0-rc.41-hanzoai.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nate Wienert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,28 @@
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: 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, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
22
+ }), mod);
23
+ var extensions_exports = {};
24
+ __export(extensions_exports, {
25
+ extensions: () => extensions
26
+ });
27
+ module.exports = __toCommonJS(extensions_exports);
28
+ const extensions = [".ios.js", ".native.js", ".native.ts", ".native.tsx", ".js", ".jsx", ".json", ".ts", ".tsx", ".mjs"];
@@ -0,0 +1,20 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
8
+ get: () => from[key],
9
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
10
+ });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
+ value: true
17
+ }), mod);
18
+ var index_exports = {};
19
+ module.exports = __toCommonJS(index_exports);
20
+ __reExport(index_exports, require("./plugin.cjs"), module.exports);
@@ -0,0 +1,101 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
34
+ var loadHanzogui_exports = {};
35
+ __export(loadHanzogui_exports, {
36
+ cleanup: () => cleanup,
37
+ ensureFullConfigLoaded: () => ensureFullConfigLoaded,
38
+ getHanzoguiOptions: () => getHanzoguiOptions,
39
+ getLoadPromise: () => getLoadPromise,
40
+ loadHanzoguiBuildConfig: () => loadHanzoguiBuildConfig
41
+ });
42
+ module.exports = __toCommonJS(loadHanzogui_exports);
43
+ var StaticWorker = __toESM(require("@hanzogui/static-worker"), 1);
44
+ const LOAD_STATE_KEY = "__hanzogui_load_state__";
45
+ function getLoadState() {
46
+ if (!globalThis[LOAD_STATE_KEY]) {
47
+ ;
48
+ globalThis[LOAD_STATE_KEY] = {
49
+ loadPromise: null,
50
+ loadedOptions: null,
51
+ fullConfigLoaded: false,
52
+ fullConfigLoadPromise: null
53
+ };
54
+ }
55
+ return globalThis[LOAD_STATE_KEY];
56
+ }
57
+ function getHanzoguiOptions() {
58
+ return getLoadState().loadedOptions;
59
+ }
60
+ function getLoadPromise() {
61
+ return getLoadState().loadPromise;
62
+ }
63
+ async function loadHanzoguiBuildConfig(optionsIn) {
64
+ const state = getLoadState();
65
+ if (state.loadedOptions) return state.loadedOptions;
66
+ if (state.loadPromise) return state.loadPromise;
67
+ state.loadPromise = (async () => {
68
+ const options = await StaticWorker.loadHanzoguiBuildConfig({
69
+ ...optionsIn,
70
+ platform: "web"
71
+ });
72
+ state.loadedOptions = options;
73
+ return options;
74
+ })();
75
+ return state.loadPromise;
76
+ }
77
+ async function ensureFullConfigLoaded() {
78
+ const state = getLoadState();
79
+ if (state.fullConfigLoaded) return;
80
+ if (state.fullConfigLoadPromise) return state.fullConfigLoadPromise;
81
+ state.fullConfigLoadPromise = (async () => {
82
+ const options = await loadHanzoguiBuildConfig();
83
+ if (!options.disableWatchHanzoguiConfig && !options.disable) {
84
+ await StaticWorker.loadHanzogui({
85
+ components: ["hanzogui"],
86
+ platform: "web",
87
+ ...options
88
+ });
89
+ }
90
+ state.fullConfigLoaded = true;
91
+ })();
92
+ return state.fullConfigLoadPromise;
93
+ }
94
+ async function cleanup() {
95
+ await StaticWorker.destroyPool();
96
+ const state = getLoadState();
97
+ state.loadPromise = null;
98
+ state.loadedOptions = null;
99
+ state.fullConfigLoaded = false;
100
+ state.fullConfigLoadPromise = null;
101
+ }
@@ -0,0 +1,423 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
34
+ var plugin_exports = {};
35
+ __export(plugin_exports, {
36
+ hanzoguiAliases: () => hanzoguiAliases,
37
+ hanzoguiPlugin: () => hanzoguiPlugin
38
+ });
39
+ module.exports = __toCommonJS(plugin_exports);
40
+ var Static = __toESM(require("@hanzogui/static-worker"), 1);
41
+ var import_static_worker = require("@hanzogui/static-worker");
42
+ var import_node_crypto = require("node:crypto");
43
+ var import_node_path = __toESM(require("node:path"), 1);
44
+ var import_node_url = require("node:url");
45
+ var import_vite = require("vite");
46
+ var import_loadHanzogui = require("./loadHanzogui.cjs");
47
+ const import_meta = {};
48
+ const resolve = name => (0, import_node_url.fileURLToPath)(import_meta.resolve(name));
49
+ const CACHE_KEY = "__hanzogui_vite_cache__";
50
+ const CACHE_SIZE_KEY = "__hanzogui_vite_cache_size__";
51
+ const PENDING_KEY = "__hanzogui_vite_pending__";
52
+ function getSharedCache() {
53
+ if (!globalThis[CACHE_KEY]) {
54
+ ;
55
+ globalThis[CACHE_KEY] = {};
56
+ }
57
+ return globalThis[CACHE_KEY];
58
+ }
59
+ function getSharedCacheSize() {
60
+ return globalThis[CACHE_SIZE_KEY] || 0;
61
+ }
62
+ function setSharedCacheSize(size) {
63
+ ;
64
+ globalThis[CACHE_SIZE_KEY] = size;
65
+ }
66
+ function clearSharedCache() {
67
+ ;
68
+ globalThis[CACHE_KEY] = {};
69
+ globalThis[CACHE_SIZE_KEY] = 0;
70
+ }
71
+ function getPendingExtractions() {
72
+ if (!globalThis[PENDING_KEY]) {
73
+ ;
74
+ globalThis[PENDING_KEY] = /* @__PURE__ */new Map();
75
+ }
76
+ return globalThis[PENDING_KEY];
77
+ }
78
+ function hanzoguiAliases(options = {}) {
79
+ const aliases = [];
80
+ if (options.svg) {
81
+ aliases.push({
82
+ find: "react-native-svg",
83
+ replacement: resolve("@hanzogui/react-native-svg")
84
+ });
85
+ }
86
+ if (options.rnwLite) {
87
+ const rnwl = resolve(options.rnwLite === "without-animated" ? "@hanzogui/react-native-web-lite/without-animated" : "@hanzogui/react-native-web-lite");
88
+ const rnwlBase = import_node_path.default.dirname(resolve("@hanzogui/react-native-web-lite/package.json"));
89
+ aliases.push({
90
+ // map deep RNW paths like dist/exports/StyleSheet/preprocess to rnw-lite's flat structure
91
+ // extracts the final path segment (e.g. "preprocess" or "createReactDOMStyle")
92
+ find: /^react-native(?:-web)?\/dist\/(?:exports|modules)\/.*\/([^/]+)$/,
93
+ replacement: `${rnwlBase}/dist/esm/$1.mjs`
94
+ }, {
95
+ find: /^react-native$/,
96
+ replacement: rnwl
97
+ }, {
98
+ find: /^react-native\/(Libraries\/Utilities\/codegenNativeComponent|Libraries\/Utilities\/codegenNativeCommand)$/,
99
+ replacement: `${rnwlBase}/$1`
100
+ }, {
101
+ find: "react-native/package.json",
102
+ replacement: resolve("@hanzogui/react-native-web-lite/package.json")
103
+ }, {
104
+ find: /^react-native-web$/,
105
+ replacement: rnwl
106
+ });
107
+ }
108
+ return aliases;
109
+ }
110
+ function hanzoguiPlugin({
111
+ disableResolveConfig,
112
+ ...hanzoguiOptionsIn
113
+ } = {}) {
114
+ let shouldExtract = !hanzoguiOptionsIn.disableExtraction;
115
+ let watcher;
116
+ const enableNativeEnv = !!globalThis.__vxrnEnableNativeEnv;
117
+ const extensions = [`.web.mjs`, `.web.js`, `.web.jsx`, `.web.ts`, `.web.tsx`, ".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
118
+ (0, import_loadHanzogui.loadHanzoguiBuildConfig)(hanzoguiOptionsIn);
119
+ const ensureLoaded = async () => {
120
+ const promise = (0, import_loadHanzogui.getLoadPromise)();
121
+ if (promise) await promise;
122
+ const options = (0, import_loadHanzogui.getHanzoguiOptions)();
123
+ if (options) {
124
+ shouldExtract = !options.disableExtraction;
125
+ }
126
+ return options;
127
+ };
128
+ const getHash = input => (0, import_node_crypto.createHash)("sha1").update(input).digest("base64");
129
+ const memoryCache = getSharedCache();
130
+ const cssMap = /* @__PURE__ */new Map();
131
+ let config;
132
+ let server;
133
+ const virtualExt = `.hanzogui.css`;
134
+ const getAbsoluteVirtualFileId = filePath => {
135
+ if (filePath.startsWith(config.root)) {
136
+ return filePath;
137
+ }
138
+ return (0, import_vite.normalizePath)(import_node_path.default.join(config.root, filePath));
139
+ };
140
+ function isNotClient(environment) {
141
+ return environment?.name && environment.name !== "client";
142
+ }
143
+ function isNative(environment) {
144
+ return environment?.name && (environment.name === "ios" || environment.name === "android");
145
+ }
146
+ function invalidateModule(absoluteId) {
147
+ if (!server) return;
148
+ const {
149
+ moduleGraph
150
+ } = server;
151
+ const modules = moduleGraph.getModulesByFile(absoluteId);
152
+ if (modules) {
153
+ for (const module2 of modules) {
154
+ moduleGraph.invalidateModule(module2);
155
+ module2.lastHMRTimestamp = module2.lastInvalidationTimestamp || Date.now();
156
+ }
157
+ }
158
+ }
159
+ const basePlugin = {
160
+ name: "hanzogui",
161
+ enforce: "pre",
162
+ configureServer(_server) {
163
+ server = _server;
164
+ },
165
+ async buildEnd() {
166
+ await watcher?.then(res => {
167
+ res?.dispose();
168
+ });
169
+ },
170
+ async config(_, env) {
171
+ const options = await ensureLoaded();
172
+ if (!options) {
173
+ throw new Error(`No hanzogui options loaded`);
174
+ }
175
+ if (!options.disableWatchHanzoguiConfig) {
176
+ watcher = Static.watchHanzoguiConfig({
177
+ components: ["hanzogui"],
178
+ config: "./src/hanzogui.config.ts",
179
+ ...options
180
+ }).catch(err => {
181
+ console.error(` [Hanzogui] Error watching config: ${err}`);
182
+ });
183
+ }
184
+ return {
185
+ envPrefix: ["TAMAGUI_"],
186
+ environments: {
187
+ client: {
188
+ define: {
189
+ "process.env.TAMAGUI_IS_CLIENT": JSON.stringify(true),
190
+ "process.env.TAMAGUI_ENVIRONMENT": '"client"'
191
+ }
192
+ }
193
+ },
194
+ define: {
195
+ // reanimated support
196
+ _frameTimestamp: void 0,
197
+ _WORKLET: false,
198
+ __DEV__: `${env.mode === "development"}`,
199
+ "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || env.mode),
200
+ "process.env.ENABLE_RSC": JSON.stringify(process.env.ENABLE_RSC || ""),
201
+ "process.env.ENABLE_STEPS": JSON.stringify(process.env.ENABLE_STEPS || ""),
202
+ "process.env.IS_STATIC": JSON.stringify(false),
203
+ ...(env.mode === "production" && {
204
+ "process.env.TAMAGUI_OPTIMIZE_THEMES": JSON.stringify(true)
205
+ })
206
+ },
207
+ resolve: disableResolveConfig || enableNativeEnv ? {} : {
208
+ extensions,
209
+ alias: {
210
+ ...(options.platform !== "native" && {
211
+ "react-native/Libraries/Renderer/shims/ReactFabric": resolve("@hanzogui/proxy-worm"),
212
+ "react-native/Libraries/Utilities/codegenNativeComponent": resolve("@hanzogui/proxy-worm"),
213
+ "react-native-svg": resolve("@hanzogui/react-native-svg"),
214
+ ...(!options?.useReactNativeWebLite && {
215
+ "react-native": resolve("react-native-web")
216
+ })
217
+ })
218
+ }
219
+ }
220
+ };
221
+ }
222
+ };
223
+ const rnwLitePlugin = {
224
+ name: "hanzogui-rnw-lite",
225
+ config() {
226
+ if (enableNativeEnv) {
227
+ return {};
228
+ }
229
+ const options = (0, import_loadHanzogui.getHanzoguiOptions)();
230
+ if (!options?.useReactNativeWebLite) {
231
+ return {};
232
+ }
233
+ return {
234
+ resolve: {
235
+ alias: hanzoguiAliases({
236
+ rnwLite: options.useReactNativeWebLite
237
+ })
238
+ },
239
+ optimizeDeps: {
240
+ // upstream react-native-web must not be pre-bundled when aliased to lite
241
+ exclude: ["react-native-web"]
242
+ }
243
+ };
244
+ }
245
+ };
246
+ const extractPlugin = {
247
+ name: "hanzogui-extract",
248
+ enforce: "pre",
249
+ async config(userConf) {
250
+ const options = await ensureLoaded();
251
+ userConf.optimizeDeps ||= {};
252
+ userConf.optimizeDeps.include ||= [];
253
+ userConf.optimizeDeps.include.push("inline-style-prefixer");
254
+ if (!shouldExtract) return;
255
+ userConf.optimizeDeps.include.push("@hanzogui/core/inject-styles");
256
+ },
257
+ async configResolved(resolvedConfig) {
258
+ config = resolvedConfig;
259
+ },
260
+ async resolveId(source) {
261
+ if (!shouldExtract) return;
262
+ if (isNative(this.environment)) {
263
+ return;
264
+ }
265
+ if (isNotClient(this.environment)) {
266
+ return;
267
+ }
268
+ const [validId, query] = source.split("?");
269
+ if (!validId.endsWith(virtualExt)) {
270
+ return;
271
+ }
272
+ const absoluteId = source.startsWith(config.root) ? source : getAbsoluteVirtualFileId(validId);
273
+ if (cssMap.has(absoluteId)) {
274
+ return absoluteId + (query ? `?${query}` : "");
275
+ }
276
+ },
277
+ async load(id) {
278
+ if (!shouldExtract) return;
279
+ const options = (0, import_loadHanzogui.getHanzoguiOptions)();
280
+ if (options?.disable) {
281
+ return;
282
+ }
283
+ if (isNative(this.environment)) {
284
+ return;
285
+ }
286
+ if (isNotClient(this.environment)) {
287
+ return;
288
+ }
289
+ const [validId] = id.split("?");
290
+ return cssMap.get(validId);
291
+ },
292
+ transform: {
293
+ order: "pre",
294
+ async handler(code, id) {
295
+ const options = await ensureLoaded();
296
+ await (0, import_loadHanzogui.ensureFullConfigLoaded)();
297
+ if (options?.disable) {
298
+ return;
299
+ }
300
+ if (isNative(this.environment)) {
301
+ return;
302
+ }
303
+ const [validId] = id.split("?");
304
+ if (!validId.endsWith(".tsx")) {
305
+ return;
306
+ }
307
+ const {
308
+ shouldDisable,
309
+ shouldPrintDebug
310
+ } = await (0, import_static_worker.getPragmaOptions)({
311
+ source: code,
312
+ path: validId
313
+ });
314
+ if (shouldPrintDebug) {
315
+ console.trace(`Current file: ${id} in environment: ${this.environment?.name}, shouldDisable: ${shouldDisable}`);
316
+ console.info(`
317
+
318
+ Original source:
319
+ ${code}
320
+
321
+ `);
322
+ }
323
+ if (shouldDisable) {
324
+ return;
325
+ }
326
+ const isSSR = isNotClient(this.environment);
327
+ const cacheKey = getHash(`${code}${id}`);
328
+ const pending = getPendingExtractions();
329
+ const formatResult = entry => {
330
+ const finalCode = !isSSR && entry.cssImport ? `${entry.js}
331
+ ${entry.cssImport}` : entry.js;
332
+ return {
333
+ code: finalCode,
334
+ map: entry.map
335
+ };
336
+ };
337
+ const cached = memoryCache[cacheKey];
338
+ if (cached) {
339
+ if (process.env.DEBUG_TAMAGUI_CACHE) {
340
+ console.info(`[hanzogui-cache] HIT ${this.environment?.name || "unknown"} ${id.split("/").pop()} key=${cacheKey.slice(0, 8)}`);
341
+ }
342
+ return formatResult(cached);
343
+ }
344
+ const pendingExtraction = pending.get(cacheKey);
345
+ if (pendingExtraction) {
346
+ if (process.env.DEBUG_TAMAGUI_CACHE) {
347
+ console.info(`[hanzogui-cache] WAIT ${this.environment?.name || "unknown"} ${id.split("/").pop()} key=${cacheKey.slice(0, 8)}`);
348
+ }
349
+ const result = await pendingExtraction;
350
+ if (result) {
351
+ return formatResult(result);
352
+ }
353
+ return;
354
+ }
355
+ if (process.env.DEBUG_TAMAGUI_CACHE) {
356
+ console.info(`[hanzogui-cache] EXTRACT ${this.environment?.name || "unknown"} ${id.split("/").pop()} key=${cacheKey.slice(0, 8)}`);
357
+ }
358
+ const extractionPromise = (async () => {
359
+ let extracted;
360
+ try {
361
+ extracted = await Static.extractToClassNames({
362
+ source: code,
363
+ sourcePath: validId,
364
+ options,
365
+ shouldPrintDebug
366
+ });
367
+ } catch (err) {
368
+ if (process.env.DEBUG_TAMAGUI_CACHE) {
369
+ console.info(`[hanzogui-cache] ERROR extracting ${id.split("/").pop()}:`, err);
370
+ }
371
+ console.error(err instanceof Error ? err.message : String(err));
372
+ return null;
373
+ }
374
+ if (!extracted) {
375
+ if (process.env.DEBUG_TAMAGUI_CACHE) {
376
+ console.info(`[hanzogui-cache] no extraction result for ${id.split("/").pop()}`);
377
+ }
378
+ return null;
379
+ }
380
+ const rootRelativeId = `${validId}${virtualExt}`;
381
+ const absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
382
+ let cssImport = null;
383
+ if (extracted.styles) {
384
+ this.addWatchFile(rootRelativeId);
385
+ if (server && cssMap.has(absoluteId)) {
386
+ invalidateModule(rootRelativeId);
387
+ }
388
+ cssImport = `import "${rootRelativeId}";`;
389
+ cssMap.set(absoluteId, extracted.styles);
390
+ }
391
+ const jsCode = extracted.js.toString();
392
+ const cacheEntry = {
393
+ js: jsCode,
394
+ map: extracted.map,
395
+ cssImport
396
+ };
397
+ const newSize = getSharedCacheSize() + jsCode.length;
398
+ if (newSize > 67108864) {
399
+ clearSharedCache();
400
+ } else {
401
+ setSharedCacheSize(newSize);
402
+ }
403
+ memoryCache[cacheKey] = cacheEntry;
404
+ if (process.env.DEBUG_TAMAGUI_CACHE) {
405
+ console.info(`[hanzogui-cache] WRITE key=${cacheKey.slice(0, 8)} cacheSize=${Object.keys(memoryCache).length}`);
406
+ }
407
+ return cacheEntry;
408
+ })();
409
+ pending.set(cacheKey, extractionPromise);
410
+ try {
411
+ const result = await extractionPromise;
412
+ if (result) {
413
+ return formatResult(result);
414
+ }
415
+ return;
416
+ } finally {
417
+ pending.delete(cacheKey);
418
+ }
419
+ }
420
+ }
421
+ };
422
+ return [basePlugin, rnwLitePlugin, extractPlugin];
423
+ }
@@ -0,0 +1,3 @@
1
+ const extensions = [".ios.js", ".native.js", ".native.ts", ".native.tsx", ".js", ".jsx", ".json", ".ts", ".tsx", ".mjs"];
2
+ export { extensions };
3
+ //# sourceMappingURL=extensions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["extensions"],"sources":["../../src/extensions.ts"],"sourcesContent":[null],"mappings":"AAAO,MAAMA,UAAA,GAAa,CACxB,WACA,cACA,cACA,eACA,OACA,QACA,SACA,OACA,QACA,OACF","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./plugin.mjs";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./plugin.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -0,0 +1,61 @@
1
+ import * as StaticWorker from "@hanzogui/static-worker";
2
+ const LOAD_STATE_KEY = "__hanzogui_load_state__";
3
+ function getLoadState() {
4
+ if (!globalThis[LOAD_STATE_KEY]) {
5
+ ;
6
+ globalThis[LOAD_STATE_KEY] = {
7
+ loadPromise: null,
8
+ loadedOptions: null,
9
+ fullConfigLoaded: false,
10
+ fullConfigLoadPromise: null
11
+ };
12
+ }
13
+ return globalThis[LOAD_STATE_KEY];
14
+ }
15
+ function getHanzoguiOptions() {
16
+ return getLoadState().loadedOptions;
17
+ }
18
+ function getLoadPromise() {
19
+ return getLoadState().loadPromise;
20
+ }
21
+ async function loadHanzoguiBuildConfig(optionsIn) {
22
+ const state = getLoadState();
23
+ if (state.loadedOptions) return state.loadedOptions;
24
+ if (state.loadPromise) return state.loadPromise;
25
+ state.loadPromise = (async () => {
26
+ const options = await StaticWorker.loadHanzoguiBuildConfig({
27
+ ...optionsIn,
28
+ platform: "web"
29
+ });
30
+ state.loadedOptions = options;
31
+ return options;
32
+ })();
33
+ return state.loadPromise;
34
+ }
35
+ async function ensureFullConfigLoaded() {
36
+ const state = getLoadState();
37
+ if (state.fullConfigLoaded) return;
38
+ if (state.fullConfigLoadPromise) return state.fullConfigLoadPromise;
39
+ state.fullConfigLoadPromise = (async () => {
40
+ const options = await loadHanzoguiBuildConfig();
41
+ if (!options.disableWatchHanzoguiConfig && !options.disable) {
42
+ await StaticWorker.loadHanzogui({
43
+ components: ["hanzogui"],
44
+ platform: "web",
45
+ ...options
46
+ });
47
+ }
48
+ state.fullConfigLoaded = true;
49
+ })();
50
+ return state.fullConfigLoadPromise;
51
+ }
52
+ async function cleanup() {
53
+ await StaticWorker.destroyPool();
54
+ const state = getLoadState();
55
+ state.loadPromise = null;
56
+ state.loadedOptions = null;
57
+ state.fullConfigLoaded = false;
58
+ state.fullConfigLoadPromise = null;
59
+ }
60
+ export { cleanup, ensureFullConfigLoaded, getHanzoguiOptions, getLoadPromise, loadHanzoguiBuildConfig };
61
+ //# sourceMappingURL=loadHanzogui.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["StaticWorker","LOAD_STATE_KEY","getLoadState","globalThis","loadPromise","loadedOptions","fullConfigLoaded","fullConfigLoadPromise","getHanzoguiOptions","getLoadPromise","loadHanzoguiBuildConfig","optionsIn","state","options","platform","ensureFullConfigLoaded","disableWatchHanzoguiConfig","disable","loadHanzogui","components","cleanup","destroyPool"],"sources":["../../src/loadHanzogui.ts"],"sourcesContent":[null],"mappings":"AAAA,YAAYA,YAAA,MAAkB;AAI9B,MAAMC,cAAA,GAAiB;AASvB,SAASC,aAAA,EAA0B;EACjC,IAAI,CAAEC,UAAA,CAAmBF,cAAc,GAAG;IACxC;IAAEE,UAAA,CAAmBF,cAAc,IAAI;MACrCG,WAAA,EAAa;MACbC,aAAA,EAAe;MACfC,gBAAA,EAAkB;MAClBC,qBAAA,EAAuB;IACzB;EACF;EACA,OAAQJ,UAAA,CAAmBF,cAAc;AAC3C;AAEO,SAASO,mBAAA,EAA6C;EAC3D,OAAON,YAAA,CAAa,EAAEG,aAAA;AACxB;AAEO,SAASI,eAAA,EAAkD;EAChE,OAAOP,YAAA,CAAa,EAAEE,WAAA;AACxB;AAMA,eAAsBM,wBACpBC,SAAA,EAC0B;EAC1B,MAAMC,KAAA,GAAQV,YAAA,CAAa;EAC3B,IAAIU,KAAA,CAAMP,aAAA,EAAe,OAAOO,KAAA,CAAMP,aAAA;EACtC,IAAIO,KAAA,CAAMR,WAAA,EAAa,OAAOQ,KAAA,CAAMR,WAAA;EAEpCQ,KAAA,CAAMR,WAAA,IAAe,YAAY;IAC/B,MAAMS,OAAA,GAAU,MAAMb,YAAA,CAAaU,uBAAA,CAAwB;MACzD,GAAGC,SAAA;MACHG,QAAA,EAAU;IACZ,CAAC;IAEDF,KAAA,CAAMP,aAAA,GAAgBQ,OAAA;IACtB,OAAOA,OAAA;EACT,GAAG;EAEH,OAAOD,KAAA,CAAMR,WAAA;AACf;AAMA,eAAsBW,uBAAA,EAAwC;EAC5D,MAAMH,KAAA,GAAQV,YAAA,CAAa;EAE3B,IAAIU,KAAA,CAAMN,gBAAA,EAAkB;EAC5B,IAAIM,KAAA,CAAML,qBAAA,EAAuB,OAAOK,KAAA,CAAML,qBAAA;EAI9CK,KAAA,CAAML,qBAAA,IAAyB,YAAY;IACzC,MAAMM,OAAA,GAAU,MAAMH,uBAAA,CAAwB;IAG9C,IAAI,CAACG,OAAA,CAAQG,0BAAA,IAA8B,CAACH,OAAA,CAAQI,OAAA,EAAS;MAC3D,MAAMjB,YAAA,CAAakB,YAAA,CAAa;QAC9BC,UAAA,EAAY,CAAC,UAAU;QACvBL,QAAA,EAAU;QACV,GAAGD;MACL,CAAC;IACH;IACAD,KAAA,CAAMN,gBAAA,GAAmB;EAC3B,GAAG;EAEH,OAAOM,KAAA,CAAML,qBAAA;AACf;AAEA,eAAsBa,QAAA,EAAU;EAC9B,MAAMpB,YAAA,CAAaqB,WAAA,CAAY;EAC/B,MAAMT,KAAA,GAAQV,YAAA,CAAa;EAC3BU,KAAA,CAAMR,WAAA,GAAc;EACpBQ,KAAA,CAAMP,aAAA,GAAgB;EACtBO,KAAA,CAAMN,gBAAA,GAAmB;EACzBM,KAAA,CAAML,qBAAA,GAAwB;AAChC","ignoreList":[]}