@hanzogui/static 3.0.6 → 4.4.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/check-dep-versions.cjs +201 -96
- package/dist/checkDeps.cjs +163 -92
- package/dist/constants.cjs +32 -30
- package/dist/exports.cjs +15 -13
- package/dist/extractor/accessSafe.cjs +25 -23
- package/dist/extractor/babelParse.cjs +30 -28
- package/dist/extractor/buildClassName.cjs +59 -35
- package/dist/extractor/bundle.cjs +163 -105
- package/dist/extractor/bundleConfig.cjs +467 -264
- package/dist/extractor/concatClassName.cjs +41 -29
- package/dist/extractor/createEvaluator.cjs +54 -41
- package/dist/extractor/createExtractor.cjs +1338 -661
- package/dist/extractor/createLogger.cjs +30 -25
- package/dist/extractor/detectModuleFormat.cjs +22 -16
- package/dist/extractor/ensureImportingConcat.cjs +31 -25
- package/dist/extractor/errors.cjs +12 -10
- package/dist/extractor/esbuildAliasPlugin.cjs +28 -16
- package/dist/extractor/esbuildTsconfigPaths.cjs +58 -36
- package/dist/extractor/evaluateAstNode.cjs +104 -59
- package/dist/extractor/extractHelpers.cjs +130 -67
- package/dist/extractor/extractMediaStyle.cjs +110 -69
- package/dist/extractor/extractToClassNames.cjs +336 -230
- package/dist/extractor/extractToNative.cjs +244 -149
- package/dist/extractor/findTopmostFunction.cjs +22 -13
- package/dist/extractor/generatedUid.cjs +39 -28
- package/dist/extractor/getGuiConfigPathFromOptionsConfig.cjs +20 -14
- package/dist/extractor/getPrefixLogs.cjs +12 -10
- package/dist/extractor/getPropValueFromAttributes.cjs +52 -34
- package/dist/extractor/getSourceModule.cjs +73 -37
- package/dist/extractor/getStaticBindingsForScope.cjs +131 -68
- package/dist/extractor/hasTopLevelAwait.cjs +62 -0
- package/dist/extractor/hoistClassNames.cjs +46 -32
- package/dist/extractor/literalToAst.cjs +67 -42
- package/dist/extractor/loadFile.cjs +9 -3
- package/dist/extractor/loadGui.cjs +198 -109
- package/dist/extractor/logLines.cjs +27 -19
- package/dist/extractor/normalizeTernaries.cjs +66 -44
- package/dist/extractor/propsToFontFamilyCache.cjs +15 -11
- package/dist/extractor/regenerateConfig.cjs +109 -81
- package/dist/extractor/removeUnusedHooks.cjs +73 -41
- package/dist/extractor/timer.cjs +23 -14
- package/dist/extractor/validHTMLAttributes.cjs +61 -59
- package/dist/extractor/watchGuiConfig.cjs +35 -23
- package/dist/getPragmaOptions.cjs +34 -19
- package/dist/helpers/memoize.cjs +24 -16
- package/dist/helpers/requireGuiCore.cjs +22 -15
- package/dist/index.cjs +26 -24
- package/dist/registerRequire.cjs +170 -77
- package/dist/server.cjs +35 -28
- package/dist/types.cjs +7 -5
- package/dist/worker.cjs +62 -40
- package/package.json +15 -15
- package/src/checkDeps.ts +1 -1
- package/src/extractor/babelParse.ts +1 -0
- package/src/extractor/bundle.ts +6 -6
- package/src/extractor/bundleConfig.ts +10 -10
- package/src/extractor/createExtractor.ts +28 -13
- package/src/extractor/createLogger.ts +1 -3
- package/src/extractor/extractToNative.ts +35 -9
- package/src/extractor/hasTopLevelAwait.ts +28 -0
- package/src/extractor/loadGui.ts +4 -4
- package/src/extractor/regenerateConfig.ts +2 -2
- package/src/getPragmaOptions.ts +2 -2
- package/src/helpers/requireGuiCore.ts +6 -6
- package/src/registerRequire.ts +52 -5
- package/src/worker.ts +1 -1
- package/types/extractor/babelParse.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/createLogger.d.ts.map +1 -1
- package/types/extractor/extractToNative.d.ts.map +1 -1
- package/types/extractor/hasTopLevelAwait.d.ts +2 -0
- package/types/extractor/hasTopLevelAwait.d.ts.map +1 -0
- package/types/registerRequire.d.ts.map +1 -1
- package/types/worker.d.ts +1 -1
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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);
|
|
32
34
|
var loadGui_exports = {};
|
|
33
35
|
__export(loadGui_exports, {
|
|
34
36
|
esbuildWatchFiles: () => esbuildWatchFiles,
|
|
@@ -41,17 +43,17 @@ __export(loadGui_exports, {
|
|
|
41
43
|
resolveWebOrNativeSpecificEntry: () => resolveWebOrNativeSpecificEntry
|
|
42
44
|
});
|
|
43
45
|
module.exports = __toCommonJS(loadGui_exports);
|
|
44
|
-
var import_node_path = require("node:path")
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
var import_node_path = require("node:path");
|
|
47
|
+
var import_cli_color = require("@hanzogui/cli-color");
|
|
48
|
+
var import_esbuild = __toESM(require("esbuild"));
|
|
49
|
+
var esbuildWasm = __toESM(require("esbuild-wasm"));
|
|
50
|
+
var fsExtra = __toESM(require("fs-extra"));
|
|
51
|
+
var import_constants = require("../constants.cjs");
|
|
52
|
+
var import_requireGuiCore = require("../helpers/requireGuiCore.cjs");
|
|
53
|
+
var import_registerRequire = require("../registerRequire.cjs");
|
|
54
|
+
var import_bundleConfig = require("./bundleConfig.cjs");
|
|
55
|
+
var import_getGuiConfigPathFromOptionsConfig = require("./getGuiConfigPathFromOptionsConfig.cjs");
|
|
56
|
+
var import_regenerateConfig = require("./regenerateConfig.cjs");
|
|
55
57
|
const getFilledOptions = propsIn => ({
|
|
56
58
|
// defaults
|
|
57
59
|
platform: "web",
|
|
@@ -62,14 +64,20 @@ const getFilledOptions = propsIn => ({
|
|
|
62
64
|
let isLoadingPromise;
|
|
63
65
|
async function loadGui(propsIn) {
|
|
64
66
|
if (isLoadingPromise) return await isLoadingPromise;
|
|
65
|
-
let resolvePromise
|
|
67
|
+
let resolvePromise;
|
|
68
|
+
let rejectPromise;
|
|
66
69
|
isLoadingPromise = new Promise((res, rej) => {
|
|
67
|
-
resolvePromise = res
|
|
70
|
+
resolvePromise = res;
|
|
71
|
+
rejectPromise = rej;
|
|
68
72
|
});
|
|
69
73
|
try {
|
|
70
|
-
const props = getFilledOptions(propsIn)
|
|
71
|
-
|
|
72
|
-
if (!bundleInfo)
|
|
74
|
+
const props = getFilledOptions(propsIn);
|
|
75
|
+
const bundleInfo = await (0, import_bundleConfig.getBundledConfig)(props);
|
|
76
|
+
if (!bundleInfo) {
|
|
77
|
+
console.warn(`No bundled config generated, maybe an error in bundling. Set DEBUG=hanzo-gui and re-run to get logs.`);
|
|
78
|
+
resolvePromise(null);
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
73
81
|
await generateThemesAndLog(props);
|
|
74
82
|
const maybeGuiConfig = bundleInfo.guiConfig;
|
|
75
83
|
if (maybeGuiConfig && !maybeGuiConfig.parsed) {
|
|
@@ -78,53 +86,82 @@ async function loadGui(propsIn) {
|
|
|
78
86
|
} = (0, import_requireGuiCore.requireGuiCore)(props.platform || "web");
|
|
79
87
|
bundleInfo.guiConfig = createGui(bundleInfo.guiConfig);
|
|
80
88
|
}
|
|
81
|
-
|
|
89
|
+
if (!(0, import_bundleConfig.hasBundledConfigChanged)()) {
|
|
90
|
+
resolvePromise(bundleInfo);
|
|
91
|
+
return bundleInfo;
|
|
92
|
+
}
|
|
93
|
+
await (0, import_regenerateConfig.regenerateConfig)(props, bundleInfo);
|
|
94
|
+
resolvePromise(bundleInfo);
|
|
95
|
+
return bundleInfo;
|
|
82
96
|
} catch (err) {
|
|
83
|
-
|
|
97
|
+
rejectPromise();
|
|
98
|
+
throw err;
|
|
84
99
|
} finally {
|
|
85
100
|
isLoadingPromise = null;
|
|
86
101
|
}
|
|
87
102
|
}
|
|
88
|
-
let waiting =
|
|
89
|
-
const generateThemesAndLog = async (options, force =
|
|
90
|
-
|
|
91
|
-
|
|
103
|
+
let waiting = false;
|
|
104
|
+
const generateThemesAndLog = async (options, force = false) => {
|
|
105
|
+
if (waiting) return;
|
|
106
|
+
if (!options.themeBuilder) return;
|
|
107
|
+
try {
|
|
108
|
+
waiting = true;
|
|
109
|
+
await new Promise(res => setTimeout(res, 30));
|
|
110
|
+
const didGenerate = await (0, import_regenerateConfig.generateGuiThemes)(options, force);
|
|
111
|
+
if (didGenerate) {
|
|
112
|
+
const whitespaceBefore = ` `;
|
|
113
|
+
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, `${whitespaceBefore}\u27A1 [hanzo-gui] generated themes: ${(0, import_node_path.relative)(process.cwd(), options.themeBuilder.output)}`);
|
|
114
|
+
if (options.outputCSS) {
|
|
92
115
|
const loadedConfig = (0, import_bundleConfig.getLoadedConfig)();
|
|
93
|
-
|
|
116
|
+
if (loadedConfig) {
|
|
117
|
+
await (0, import_bundleConfig.writeGuiCSS)(options.outputCSS, loadedConfig);
|
|
118
|
+
}
|
|
94
119
|
}
|
|
95
|
-
} finally {
|
|
96
|
-
waiting = !1;
|
|
97
120
|
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
121
|
+
} finally {
|
|
122
|
+
waiting = false;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const last = {};
|
|
126
|
+
const lastVersion = {};
|
|
127
|
+
let esbuildWasmInitialized = false;
|
|
102
128
|
async function loadGuiBuildConfigAsync(guiOptions) {
|
|
103
|
-
const buildFilePath = guiOptions?.buildFile ?? "./gui.build.ts"
|
|
104
|
-
|
|
105
|
-
if (fsExtra.existsSync(absolutePath))
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
129
|
+
const buildFilePath = guiOptions?.buildFile ?? "./gui.build.ts";
|
|
130
|
+
const absolutePath = buildFilePath[0] === "." ? (0, import_node_path.join)(process.cwd(), buildFilePath) : buildFilePath;
|
|
131
|
+
if (fsExtra.existsSync(absolutePath)) {
|
|
132
|
+
try {
|
|
133
|
+
const source = await fsExtra.readFile(absolutePath, "utf-8");
|
|
134
|
+
if (!esbuildWasmInitialized) {
|
|
135
|
+
await esbuildWasm.initialize({});
|
|
136
|
+
esbuildWasmInitialized = true;
|
|
137
|
+
}
|
|
138
|
+
const result = await esbuildWasm.transform(source, {
|
|
109
139
|
loader: "ts",
|
|
110
140
|
format: "cjs",
|
|
111
141
|
target: "node18",
|
|
112
142
|
sourcefile: absolutePath
|
|
113
|
-
})
|
|
114
|
-
module2 = {
|
|
143
|
+
});
|
|
144
|
+
const module2 = {
|
|
115
145
|
exports: {}
|
|
116
146
|
};
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
147
|
+
const fn = new Function("module", "exports", "require", "process", result.code);
|
|
148
|
+
fn(module2, module2.exports, require, process);
|
|
149
|
+
const out = module2.exports.default || module2.exports;
|
|
150
|
+
if (!out || typeof out !== "object") {
|
|
151
|
+
throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
152
|
+
}
|
|
153
|
+
guiOptions = {
|
|
154
|
+
...guiOptions,
|
|
155
|
+
...out
|
|
156
|
+
};
|
|
157
|
+
} catch (err) {
|
|
158
|
+
console.error(`[hanzo-gui] Error loading ${buildFilePath}:`, err);
|
|
159
|
+
throw err;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (!guiOptions) {
|
|
163
|
+
throw new Error(`No hanzo-gui build options found either via input props or at gui.build.ts`);
|
|
126
164
|
}
|
|
127
|
-
if (!guiOptions) throw new Error("No hanzo-gui build options found either via input props or at gui.build.ts");
|
|
128
165
|
return {
|
|
129
166
|
config: "gui.config.ts",
|
|
130
167
|
components: ["@hanzo/gui", "@hanzogui/core"],
|
|
@@ -137,7 +174,9 @@ function loadGuiBuildConfigSync(guiOptions) {
|
|
|
137
174
|
const registered = (0, import_registerRequire.registerRequire)("web");
|
|
138
175
|
try {
|
|
139
176
|
const out = (buildFilePath[0] === "." ? require((0, import_node_path.join)(process.cwd(), buildFilePath)) : require(buildFilePath)).default;
|
|
140
|
-
if (!out)
|
|
177
|
+
if (!out) {
|
|
178
|
+
throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
179
|
+
}
|
|
141
180
|
guiOptions = {
|
|
142
181
|
...guiOptions,
|
|
143
182
|
...out
|
|
@@ -146,7 +185,9 @@ function loadGuiBuildConfigSync(guiOptions) {
|
|
|
146
185
|
registered.unregister();
|
|
147
186
|
}
|
|
148
187
|
}
|
|
149
|
-
if (!guiOptions)
|
|
188
|
+
if (!guiOptions) {
|
|
189
|
+
throw new Error(`No hanzo-gui build options found either via input props or at gui.build.ts`);
|
|
190
|
+
}
|
|
150
191
|
return {
|
|
151
192
|
config: "gui.config.ts",
|
|
152
193
|
components: ["@hanzo/gui", "@hanzogui/core"],
|
|
@@ -159,25 +200,33 @@ function loadGuiSync({
|
|
|
159
200
|
...propsIn
|
|
160
201
|
}) {
|
|
161
202
|
const key = JSON.stringify(propsIn);
|
|
162
|
-
if (last[key] && !(0, import_bundleConfig.hasBundledConfigChanged)()
|
|
203
|
+
if (last[key] && !(0, import_bundleConfig.hasBundledConfigChanged)()) {
|
|
204
|
+
if (!lastVersion[key] || lastVersion[key] === cacheKey) {
|
|
205
|
+
return last[key];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
163
208
|
lastVersion[key] = cacheKey || "";
|
|
164
209
|
const props = getFilledOptions(propsIn);
|
|
165
|
-
process.env.IS_STATIC = "is_static"
|
|
210
|
+
process.env.IS_STATIC = "is_static";
|
|
211
|
+
process.env.GUI_IS_SERVER = "true";
|
|
166
212
|
const {
|
|
167
213
|
unregister
|
|
168
214
|
} = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
169
215
|
proxyWormImports: !!forceExports
|
|
170
216
|
});
|
|
171
217
|
try {
|
|
172
|
-
const devValueOG = globalThis
|
|
173
|
-
globalThis
|
|
218
|
+
const devValueOG = globalThis["__DEV__"];
|
|
219
|
+
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
174
220
|
try {
|
|
175
221
|
let guiConfig = null;
|
|
176
222
|
if (propsIn.config) {
|
|
177
|
-
const configPath = (0, import_getGuiConfigPathFromOptionsConfig.getGuiConfigPathFromOptionsConfig)(propsIn.config)
|
|
178
|
-
|
|
179
|
-
if (!exp || exp._isProxyWorm)
|
|
180
|
-
|
|
223
|
+
const configPath = (0, import_getGuiConfigPathFromOptionsConfig.getGuiConfigPathFromOptionsConfig)(propsIn.config);
|
|
224
|
+
const exp = require(configPath);
|
|
225
|
+
if (!exp || exp._isProxyWorm) {
|
|
226
|
+
throw new Error(`Got a empty / proxied config!`);
|
|
227
|
+
}
|
|
228
|
+
guiConfig = exp["default"] || exp["config"] || exp;
|
|
229
|
+
if (!guiConfig || !guiConfig.parsed) {
|
|
181
230
|
const confPath = require.resolve(configPath);
|
|
182
231
|
throw new Error(`Can't find valid config in ${confPath}:
|
|
183
232
|
|
|
@@ -191,8 +240,14 @@ function loadGuiSync({
|
|
|
191
240
|
}
|
|
192
241
|
}
|
|
193
242
|
const components = (0, import_bundleConfig.loadComponentsSync)(props, forceExports);
|
|
194
|
-
if (!components)
|
|
195
|
-
|
|
243
|
+
if (!components) {
|
|
244
|
+
throw new Error(`No components loaded`);
|
|
245
|
+
}
|
|
246
|
+
if (process.env.DEBUG === "@hanzo/gui") {
|
|
247
|
+
console.info(`components`, components);
|
|
248
|
+
}
|
|
249
|
+
process.env.IS_STATIC = void 0;
|
|
250
|
+
globalThis["__DEV__"] = devValueOG;
|
|
196
251
|
const info = {
|
|
197
252
|
components,
|
|
198
253
|
guiConfig,
|
|
@@ -202,18 +257,34 @@ function loadGuiSync({
|
|
|
202
257
|
const {
|
|
203
258
|
outputCSS
|
|
204
259
|
} = props;
|
|
205
|
-
|
|
260
|
+
if (outputCSS) {
|
|
261
|
+
(0, import_bundleConfig.writeGuiCSS)(outputCSS, guiConfig);
|
|
262
|
+
}
|
|
263
|
+
(0, import_regenerateConfig.regenerateConfigSync)(props, info);
|
|
206
264
|
}
|
|
207
|
-
|
|
265
|
+
last[key] = {
|
|
208
266
|
...info,
|
|
209
|
-
cached:
|
|
210
|
-
}
|
|
267
|
+
cached: true
|
|
268
|
+
};
|
|
269
|
+
return info;
|
|
211
270
|
} catch (err) {
|
|
212
|
-
|
|
271
|
+
if (err instanceof Error) {
|
|
272
|
+
if (!import_constants.SHOULD_DEBUG && !forceExports) {
|
|
273
|
+
console.warn(`Error loading gui.config.ts (set DEBUG=hanzo-gui to see full stack), running hanzo-gui without custom config`);
|
|
274
|
+
console.info(`
|
|
213
275
|
|
|
214
276
|
${err.message}
|
|
215
277
|
|
|
216
|
-
`)
|
|
278
|
+
`);
|
|
279
|
+
} else {
|
|
280
|
+
if (import_constants.SHOULD_DEBUG) {
|
|
281
|
+
console.error(err);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
console.error(`Error loading gui.config.ts`, err);
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
217
288
|
components: [],
|
|
218
289
|
guiConfig: null,
|
|
219
290
|
nameToPaths: {}
|
|
@@ -234,7 +305,7 @@ async function getOptions({
|
|
|
234
305
|
let pkgJson = {};
|
|
235
306
|
try {
|
|
236
307
|
pkgJson = await fsExtra.readJSON((0, import_node_path.join)(root, "package.json"));
|
|
237
|
-
} catch {}
|
|
308
|
+
} catch (err) {}
|
|
238
309
|
return {
|
|
239
310
|
mode: process.env.NODE_ENV === "production" ? "production" : "development",
|
|
240
311
|
root,
|
|
@@ -257,33 +328,44 @@ async function getOptions({
|
|
|
257
328
|
};
|
|
258
329
|
}
|
|
259
330
|
function resolveWebOrNativeSpecificEntry(entry) {
|
|
260
|
-
const workspaceRoot = (0, import_node_path.resolve)()
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
331
|
+
const workspaceRoot = (0, import_node_path.resolve)();
|
|
332
|
+
const resolved = require.resolve(entry, {
|
|
333
|
+
paths: [workspaceRoot]
|
|
334
|
+
});
|
|
335
|
+
const ext = (0, import_node_path.extname)(resolved);
|
|
336
|
+
const fileName = (0, import_node_path.basename)(resolved).replace(ext, "");
|
|
337
|
+
const specificExt = true ? "web" : "native";
|
|
338
|
+
const specificFile = (0, import_node_path.join)((0, import_node_path.dirname)(resolved), fileName + "." + specificExt + ext);
|
|
339
|
+
if (fsExtra.existsSync(specificFile)) {
|
|
340
|
+
return specificFile;
|
|
341
|
+
}
|
|
342
|
+
return entry;
|
|
268
343
|
}
|
|
269
344
|
const defaultPaths = ["gui.config.ts", (0, import_node_path.join)("src", "gui.config.ts")];
|
|
270
|
-
let hasWarnedOnce =
|
|
345
|
+
let hasWarnedOnce = false;
|
|
271
346
|
async function getDefaultGuiConfigPath(root, configPath) {
|
|
272
347
|
const searchPaths = [...new Set([configPath, ...defaultPaths].filter(Boolean).map(p => (0, import_node_path.join)(root, p)))];
|
|
273
|
-
for (const path of searchPaths)
|
|
274
|
-
|
|
348
|
+
for (const path of searchPaths) {
|
|
349
|
+
if (await fsExtra.pathExists(path)) {
|
|
350
|
+
return path;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (!hasWarnedOnce) {
|
|
354
|
+
hasWarnedOnce = true;
|
|
355
|
+
console.warn(`Warning: couldn't find gui.config.ts in the following paths given configuration "${configPath}":
|
|
275
356
|
${searchPaths.join(`
|
|
276
357
|
`)}
|
|
277
|
-
`)
|
|
358
|
+
`);
|
|
359
|
+
}
|
|
278
360
|
}
|
|
279
361
|
async function esbuildWatchFiles(entry, onChanged) {
|
|
280
|
-
let hasRunOnce =
|
|
362
|
+
let hasRunOnce = false;
|
|
281
363
|
const context = await import_esbuild.default.context({
|
|
282
|
-
bundle:
|
|
364
|
+
bundle: true,
|
|
283
365
|
entryPoints: [entry],
|
|
284
366
|
resolveExtensions: [".ts", ".tsx", ".js", ".mjs"],
|
|
285
367
|
logLevel: "silent",
|
|
286
|
-
write:
|
|
368
|
+
write: false,
|
|
287
369
|
alias: {
|
|
288
370
|
"@react-native/normalize-color": "@hanzogui/proxy-worm",
|
|
289
371
|
"react-native-web": "@hanzogui/react-native-web-lite",
|
|
@@ -300,23 +382,30 @@ async function esbuildWatchFiles(entry, onChanged) {
|
|
|
300
382
|
// },
|
|
301
383
|
// },
|
|
302
384
|
{
|
|
303
|
-
name:
|
|
385
|
+
name: `on-rebuild`,
|
|
304
386
|
setup({
|
|
305
387
|
onEnd,
|
|
306
388
|
onResolve
|
|
307
389
|
}) {
|
|
390
|
+
let filter = /^[^./]|^\.[^./]|^\.\.[^/]/;
|
|
308
391
|
onResolve({
|
|
309
|
-
filter
|
|
392
|
+
filter
|
|
310
393
|
}, args => ({
|
|
311
394
|
path: args.path,
|
|
312
|
-
external:
|
|
313
|
-
}))
|
|
314
|
-
|
|
395
|
+
external: true
|
|
396
|
+
}));
|
|
397
|
+
onEnd(() => {
|
|
398
|
+
if (!hasRunOnce) {
|
|
399
|
+
hasRunOnce = true;
|
|
400
|
+
} else {
|
|
401
|
+
onChanged();
|
|
402
|
+
}
|
|
315
403
|
});
|
|
316
404
|
}
|
|
317
405
|
}]
|
|
318
406
|
});
|
|
319
|
-
|
|
407
|
+
void context.watch();
|
|
408
|
+
return () => {
|
|
320
409
|
context.dispose();
|
|
321
410
|
};
|
|
322
411
|
}
|
|
@@ -3,33 +3,41 @@ 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 logLines_exports = {};
|
|
22
24
|
__export(logLines_exports, {
|
|
23
25
|
logLines: () => logLines
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(logLines_exports);
|
|
26
|
-
const prefix = " "
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const prefix = " ";
|
|
29
|
+
const logLines = (str, singleLine = false) => {
|
|
30
|
+
if (singleLine) {
|
|
31
|
+
return prefix + str.split(" ").join(`
|
|
29
32
|
${prefix}`);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
}
|
|
34
|
+
const lines = [""];
|
|
35
|
+
const items = str.split(" ");
|
|
36
|
+
for (const item of items) {
|
|
37
|
+
if (item.length + lines[lines.length - 1].length > 85) {
|
|
38
|
+
lines.push("");
|
|
39
|
+
}
|
|
40
|
+
lines[lines.length - 1] += item + " ";
|
|
41
|
+
}
|
|
42
|
+
return lines.map((line, i) => prefix + (i == 0 ? "" : " ") + line.trim()).join("\n");
|
|
43
|
+
};
|
|
@@ -2,45 +2,50 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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);
|
|
32
34
|
var normalizeTernaries_exports = {};
|
|
33
35
|
__export(normalizeTernaries_exports, {
|
|
34
36
|
normalizeTernaries: () => normalizeTernaries
|
|
35
37
|
});
|
|
36
38
|
module.exports = __toCommonJS(normalizeTernaries_exports);
|
|
37
|
-
var import_generator = __toESM(require("@babel/generator"))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
var import_generator = __toESM(require("@babel/generator"));
|
|
40
|
+
var t = __toESM(require("@babel/types"));
|
|
41
|
+
var import_web = require("@hanzogui/web");
|
|
42
|
+
var import_invariant = __toESM(require("invariant"));
|
|
43
|
+
var import_propsToFontFamilyCache = require("./propsToFontFamilyCache.cjs");
|
|
42
44
|
function normalizeTernaries(ternaries) {
|
|
43
|
-
|
|
45
|
+
(0, import_invariant.default)(Array.isArray(ternaries), "extractStaticTernaries expects param 1 to be an array of ternaries");
|
|
46
|
+
if (ternaries.length === 0) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
44
49
|
const ternariesByKey = {};
|
|
45
50
|
for (let idx = -1, len = ternaries.length; ++idx < len;) {
|
|
46
51
|
const {
|
|
@@ -51,23 +56,40 @@ function normalizeTernaries(ternaries) {
|
|
|
51
56
|
...rest
|
|
52
57
|
} = ternaries[idx];
|
|
53
58
|
let ternaryTest = test;
|
|
54
|
-
t.isExpressionStatement(test)
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
if (t.isExpressionStatement(test)) {
|
|
60
|
+
ternaryTest = test.expression;
|
|
61
|
+
}
|
|
62
|
+
let shouldSwap = false;
|
|
63
|
+
if (t.isUnaryExpression(test) && test.operator === "!") {
|
|
64
|
+
ternaryTest = test.argument;
|
|
65
|
+
shouldSwap = true;
|
|
66
|
+
} else if (t.isBinaryExpression(test)) {
|
|
67
|
+
if (test.operator === "!==" || test.operator === "!=") {
|
|
68
|
+
ternaryTest = t.binaryExpression(test.operator.replace("!", "="), test.left, test.right);
|
|
69
|
+
shouldSwap = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
57
72
|
const key = (0, import_generator.default)(ternaryTest).code;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
if (!ternariesByKey[key]) {
|
|
74
|
+
ternariesByKey[key] = {
|
|
75
|
+
...rest,
|
|
76
|
+
alternate: {},
|
|
77
|
+
consequent: {},
|
|
78
|
+
test: ternaryTest,
|
|
79
|
+
remove
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const altStyle = (shouldSwap ? consequent : alternate) ?? {};
|
|
83
|
+
const consStyle = (shouldSwap ? alternate : consequent) ?? {};
|
|
84
|
+
const nextAlt = ternariesByKey[key].alternate;
|
|
85
|
+
ternariesByKey[key].alternate = (0, import_web.mergeProps)(altStyle, nextAlt);
|
|
86
|
+
(0, import_propsToFontFamilyCache.forwardFontFamilyName)(altStyle, ternariesByKey[key].alternate);
|
|
69
87
|
const nextCons = ternariesByKey[key].consequent;
|
|
70
|
-
ternariesByKey[key].consequent = (0, import_web.mergeProps)(consStyle, nextCons)
|
|
88
|
+
ternariesByKey[key].consequent = (0, import_web.mergeProps)(consStyle, nextCons);
|
|
89
|
+
(0, import_propsToFontFamilyCache.forwardFontFamilyName)(consStyle, ternariesByKey[key].consequent);
|
|
71
90
|
}
|
|
72
|
-
|
|
91
|
+
const ternaryExpression = Object.keys(ternariesByKey).map(key => {
|
|
92
|
+
return ternariesByKey[key];
|
|
93
|
+
});
|
|
94
|
+
return ternaryExpression;
|
|
73
95
|
}
|