@hanzogui/vite-plugin 4.4.0 → 7.0.0
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/index.cjs +13 -20
- package/dist/esm/index.mjs +7 -2
- package/dist/types/index.d.ts +10 -0
- package/package.json +12 -45
- package/LICENSE +0 -21
- package/dist/cjs/extensions.cjs +0 -28
- package/dist/cjs/loadGui.cjs +0 -101
- package/dist/cjs/plugin.cjs +0 -423
- package/dist/esm/extensions.mjs +0 -3
- package/dist/esm/extensions.mjs.map +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/loadGui.mjs +0 -61
- package/dist/esm/loadGui.mjs.map +0 -1
- package/dist/esm/plugin.mjs +0 -385
- package/dist/esm/plugin.mjs.map +0 -1
- package/src/extensions.ts +0 -12
- package/src/index.ts +0 -1
- package/src/loadGui.ts +0 -94
- package/src/plugin.ts +0 -550
- package/types/extensions.d.ts +0 -2
- package/types/extensions.d.ts.map +0 -1
- package/types/index.d.ts +0 -2
- package/types/index.d.ts.map +0 -1
- package/types/loadGui.d.ts +0 -15
- package/types/loadGui.d.ts.map +0 -1
- package/types/plugin.d.ts +0 -22
- package/types/plugin.d.ts.map +0 -1
package/dist/cjs/plugin.cjs
DELETED
|
@@ -1,423 +0,0 @@
|
|
|
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
|
-
guiAliases: () => guiAliases,
|
|
37
|
-
guiPlugin: () => guiPlugin
|
|
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_loadGui = require("./loadGui.cjs");
|
|
47
|
-
const import_meta = {};
|
|
48
|
-
const resolve = name => (0, import_node_url.fileURLToPath)(import_meta.resolve(name));
|
|
49
|
-
const CACHE_KEY = "__gui_vite_cache__";
|
|
50
|
-
const CACHE_SIZE_KEY = "__gui_vite_cache_size__";
|
|
51
|
-
const PENDING_KEY = "__gui_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 guiAliases(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 guiPlugin({
|
|
111
|
-
disableResolveConfig,
|
|
112
|
-
...guiOptionsIn
|
|
113
|
-
} = {}) {
|
|
114
|
-
let shouldExtract = !guiOptionsIn.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_loadGui.loadGuiBuildConfig)(guiOptionsIn);
|
|
119
|
-
const ensureLoaded = async () => {
|
|
120
|
-
const promise = (0, import_loadGui.getLoadPromise)();
|
|
121
|
-
if (promise) await promise;
|
|
122
|
-
const options = (0, import_loadGui.getGuiOptions)();
|
|
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 = `.gui.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: "hanzo-gui",
|
|
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 hanzo-gui options loaded`);
|
|
174
|
-
}
|
|
175
|
-
if (!options.disableWatchGuiConfig) {
|
|
176
|
-
watcher = Static.watchGuiConfig({
|
|
177
|
-
components: ["@hanzo/gui"],
|
|
178
|
-
config: "./src/gui.config.ts",
|
|
179
|
-
...options
|
|
180
|
-
}).catch(err => {
|
|
181
|
-
console.error(` [GUI] Error watching config: ${err}`);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
return {
|
|
185
|
-
envPrefix: ["GUI_"],
|
|
186
|
-
environments: {
|
|
187
|
-
client: {
|
|
188
|
-
define: {
|
|
189
|
-
"process.env.GUI_IS_CLIENT": JSON.stringify(true),
|
|
190
|
-
"process.env.GUI_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.GUI_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: "gui-rnw-lite",
|
|
225
|
-
config() {
|
|
226
|
-
if (enableNativeEnv) {
|
|
227
|
-
return {};
|
|
228
|
-
}
|
|
229
|
-
const options = (0, import_loadGui.getGuiOptions)();
|
|
230
|
-
if (!options?.useReactNativeWebLite) {
|
|
231
|
-
return {};
|
|
232
|
-
}
|
|
233
|
-
return {
|
|
234
|
-
resolve: {
|
|
235
|
-
alias: guiAliases({
|
|
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: "gui-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_loadGui.getGuiOptions)();
|
|
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_loadGui.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_GUI_CACHE) {
|
|
340
|
-
console.info(`[gui-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_GUI_CACHE) {
|
|
347
|
-
console.info(`[gui-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_GUI_CACHE) {
|
|
356
|
-
console.info(`[gui-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_GUI_CACHE) {
|
|
369
|
-
console.info(`[gui-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_GUI_CACHE) {
|
|
376
|
-
console.info(`[gui-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_GUI_CACHE) {
|
|
405
|
-
console.info(`[gui-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
|
-
}
|
package/dist/esm/extensions.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
package/dist/esm/index.js
DELETED
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
package/dist/esm/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
package/dist/esm/loadGui.mjs
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import * as StaticWorker from "@hanzogui/static-worker";
|
|
2
|
-
const LOAD_STATE_KEY = "__gui_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 getGuiOptions() {
|
|
16
|
-
return getLoadState().loadedOptions;
|
|
17
|
-
}
|
|
18
|
-
function getLoadPromise() {
|
|
19
|
-
return getLoadState().loadPromise;
|
|
20
|
-
}
|
|
21
|
-
async function loadGuiBuildConfig(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.loadGuiBuildConfig({
|
|
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 loadGuiBuildConfig();
|
|
41
|
-
if (!options.disableWatchGuiConfig && !options.disable) {
|
|
42
|
-
await StaticWorker.loadGui({
|
|
43
|
-
components: ["@hanzo/gui"],
|
|
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, getGuiOptions, getLoadPromise, loadGuiBuildConfig };
|
|
61
|
-
//# sourceMappingURL=loadGui.mjs.map
|
package/dist/esm/loadGui.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["StaticWorker","LOAD_STATE_KEY","getLoadState","globalThis","loadPromise","loadedOptions","fullConfigLoaded","fullConfigLoadPromise","getGuiOptions","getLoadPromise","loadGuiBuildConfig","optionsIn","state","options","platform","ensureFullConfigLoaded","disableWatchGuiConfig","disable","loadGui","components","cleanup","destroyPool"],"sources":["../../src/loadGui.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,cAAA,EAAmC;EACjD,OAAON,YAAA,CAAa,EAAEG,aAAA;AACxB;AAEO,SAASI,eAAA,EAA6C;EAC3D,OAAOP,YAAA,CAAa,EAAEE,WAAA;AACxB;AAMA,eAAsBM,mBACpBC,SAAA,EACqB;EACrB,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,kBAAA,CAAmB;MACpD,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,kBAAA,CAAmB;IAGzC,IAAI,CAACG,OAAA,CAAQG,qBAAA,IAAyB,CAACH,OAAA,CAAQI,OAAA,EAAS;MACtD,MAAMjB,YAAA,CAAakB,OAAA,CAAQ;QACzBC,UAAA,EAAY,CAAC,YAAY;QACzBL,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":[]}
|