@hanzogui/static 4.4.0 → 7.3.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/LICENSE +40 -19
- package/dist/check-dep-versions.cjs +1 -1
- package/dist/checkDeps.cjs +5 -5
- package/dist/constants.cjs +2 -2
- package/dist/extractor/bundle.cjs +16 -35
- package/dist/extractor/bundleConfig.cjs +16 -16
- package/dist/extractor/createExtractor.cjs +7 -7
- package/dist/extractor/extractHelpers.cjs +1 -1
- package/dist/extractor/extractToNative.cjs +3 -3
- package/dist/extractor/getPrefixLogs.cjs +1 -1
- package/dist/extractor/getStaticBindingsForScope.cjs +2 -2
- package/dist/extractor/loadGui.cjs +49 -93
- package/dist/extractor/regenerateConfig.cjs +2 -2
- package/dist/getPragmaOptions.cjs +1 -1
- package/dist/registerRequire.cjs +11 -11
- package/package.json +22 -21
- package/src/check-dep-versions.ts +1 -5
- package/src/checkDeps.ts +9 -11
- package/src/constants.ts +2 -2
- package/src/extractor/bundle.ts +5 -7
- package/src/extractor/bundleConfig.ts +16 -16
- package/src/extractor/createExtractor.ts +21 -14
- package/src/extractor/createLogger.ts +3 -1
- package/src/extractor/esbuildTsconfigPaths.ts +1 -1
- package/src/extractor/extractHelpers.ts +5 -2
- package/src/extractor/extractMediaStyle.ts +7 -1
- package/src/extractor/extractToNative.ts +3 -3
- package/src/extractor/getPrefixLogs.ts +1 -1
- package/src/extractor/getStaticBindingsForScope.ts +2 -2
- package/src/extractor/loadGui.ts +16 -13
- package/src/extractor/regenerateConfig.ts +17 -7
- package/src/getPragmaOptions.ts +1 -1
- package/src/registerRequire.ts +18 -20
- package/src/types.ts +4 -1
- package/src/worker.ts +1 -1
- package/types/check-dep-versions.d.ts.map +1 -1
- package/types/checkDeps.d.ts.map +1 -1
- package/types/constants.d.ts.map +1 -1
- package/types/extractor/bundle.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/extractHelpers.d.ts.map +1 -1
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- package/types/extractor/loadGui.d.ts.map +1 -1
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/registerRequire.d.ts.map +1 -1
- package/types/types.d.ts.map +1 -1
- package/types/worker.d.ts +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-present, Hanzo AI, Inc.
|
|
4
|
+
|
|
5
|
+
Portions of this software are derived from upstream code originally licensed under
|
|
6
|
+
the MIT License, with the following copyright notices retained per its terms:
|
|
2
7
|
|
|
3
8
|
Copyright (c) 2020 Nate Wienert
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
Copyright (c) 2015-present, Nicolas Gallagher.
|
|
10
|
+
Copyright (c) 2015-present, Facebook, Inc.
|
|
11
|
+
Copyright (c) 2021 Radix
|
|
12
|
+
Copyright (c) 2017 Carmelo Pullara
|
|
13
|
+
Copyright (c) 2018 Framer B.V.
|
|
14
|
+
Copyright (c) 2022 WorkOS
|
|
15
|
+
|
|
16
|
+
All rights reserved.
|
|
17
|
+
|
|
18
|
+
Redistribution and use in source and binary forms, with or without
|
|
19
|
+
modification, are permitted provided that the following conditions are met:
|
|
20
|
+
|
|
21
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
22
|
+
list of conditions and the following disclaimer.
|
|
23
|
+
|
|
24
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
25
|
+
this list of conditions and the following disclaimer in the documentation
|
|
26
|
+
and/or other materials provided with the distribution.
|
|
27
|
+
|
|
28
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
29
|
+
may be used to endorse or promote products derived from this software
|
|
30
|
+
without specific prior written permission.
|
|
31
|
+
|
|
32
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
33
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
34
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
35
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
36
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
37
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
38
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
39
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
40
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
41
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
42
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -275,7 +275,7 @@ const DEFAULT_DEP_TYPES = ["dependencies" /* dependencies */, "devDependencies"
|
|
|
275
275
|
];
|
|
276
276
|
function check(path) {
|
|
277
277
|
const options = {
|
|
278
|
-
includeDepPattern: ["
|
|
278
|
+
includeDepPattern: ["gui", "react-native-web-lite", "react-native-web-internals"]
|
|
279
279
|
};
|
|
280
280
|
if (options && options.depType && options.depType.some(dt => !Object.keys(DEPENDENCY_TYPE).includes(dt))) {
|
|
281
281
|
throw new Error(`Invalid depType provided. Choices are: ${Object.keys(DEPENDENCY_TYPE).join(", ")}.`);
|
package/dist/checkDeps.cjs
CHANGED
|
@@ -37,7 +37,7 @@ var DEPENDENCY_TYPE = /* @__PURE__ */(DEPENDENCY_TYPE2 => {
|
|
|
37
37
|
DEPENDENCY_TYPE2["resolutions"] = "resolutions";
|
|
38
38
|
return DEPENDENCY_TYPE2;
|
|
39
39
|
})(DEPENDENCY_TYPE || {});
|
|
40
|
-
const CRITICAL_PACKAGES = ["@hanzogui/web", "@hanzogui/core", "
|
|
40
|
+
const CRITICAL_PACKAGES = ["@hanzogui/web", "@hanzogui/core", "gui"];
|
|
41
41
|
function checkDuplicateInstalls(root) {
|
|
42
42
|
const nodeModules = (0, import_node_path.join)(root, "node_modules");
|
|
43
43
|
if (!(0, import_node_fs.existsSync)(nodeModules)) return "";
|
|
@@ -130,7 +130,7 @@ function checkBunLockDuplicates(lockPath) {
|
|
|
130
130
|
const content = (0, import_node_fs.readFileSync)(lockPath, "utf8");
|
|
131
131
|
const duplicates = /* @__PURE__ */new Map();
|
|
132
132
|
const criticalSet = new Set(CRITICAL_PACKAGES);
|
|
133
|
-
const packagePattern = /["'](@
|
|
133
|
+
const packagePattern = /["'](@hanzogui\/[\w-]+|gui)@([^"'\s,]+)["']/g;
|
|
134
134
|
let match;
|
|
135
135
|
while ((match = packagePattern.exec(content)) !== null) {
|
|
136
136
|
const name = match[1];
|
|
@@ -150,7 +150,7 @@ function checkYarnLockDuplicates(lockPath) {
|
|
|
150
150
|
const content = (0, import_node_fs.readFileSync)(lockPath, "utf8");
|
|
151
151
|
const duplicates = /* @__PURE__ */new Map();
|
|
152
152
|
const criticalSet = new Set(CRITICAL_PACKAGES);
|
|
153
|
-
const entryPattern = /^"?(@
|
|
153
|
+
const entryPattern = /^"?(@hanzogui\/[\w-]+|gui)@[^":\n]+[":]?\s*$/gm;
|
|
154
154
|
const versionPattern = /^\s+version\s+"([^"]+)"/gm;
|
|
155
155
|
let entryMatch;
|
|
156
156
|
while ((entryMatch = entryPattern.exec(content)) !== null) {
|
|
@@ -204,7 +204,7 @@ function formatLockfileDuplicates(duplicates, lockfileName) {
|
|
|
204
204
|
}
|
|
205
205
|
lines.push("");
|
|
206
206
|
lines.push("Multiple versions cause duplicate runtime instances, breaking config/theme detection.");
|
|
207
|
-
lines.push("Fix: ensure all
|
|
207
|
+
lines.push("Fix: ensure all gui packages use the same version range, then dedupe.");
|
|
208
208
|
return lines.join("\n");
|
|
209
209
|
}
|
|
210
210
|
function checkConfigExists(root) {
|
|
@@ -247,7 +247,7 @@ function checkConfigExists(root) {
|
|
|
247
247
|
if (pkg.workspaces) return "";
|
|
248
248
|
} catch {}
|
|
249
249
|
}
|
|
250
|
-
return ["No gui.config file found.", "", "Gui requires a config file (e.g. gui.config.ts) that calls createGui().", `Without it, components will throw "Can't find
|
|
250
|
+
return ["No gui.config file found.", "", "Gui requires a config file (e.g. gui.config.ts) that calls createGui().", `Without it, components will throw "Can't find Gui configuration" at runtime.`, "", "See: https://gui.dev/docs/core/configuration"].join("\n");
|
|
251
251
|
}
|
|
252
252
|
async function checkDeps(root) {
|
|
253
253
|
const issues = [];
|
package/dist/constants.cjs
CHANGED
|
@@ -44,8 +44,8 @@ var import_find_cache_dir = __toESM(require("find-cache-dir"));
|
|
|
44
44
|
const CSS_FILE_NAME = "__snack.css";
|
|
45
45
|
const MEDIA_SEP = "_";
|
|
46
46
|
const cacheDir = (0, import_find_cache_dir.default)({
|
|
47
|
-
name: "
|
|
47
|
+
name: "gui",
|
|
48
48
|
create: true
|
|
49
49
|
});
|
|
50
50
|
const FAILED_EVAL = /* @__PURE__ */Symbol("failed_style_eval");
|
|
51
|
-
const SHOULD_DEBUG = process.env.DEBUG === "*" || process.env.DEBUG?.startsWith("
|
|
51
|
+
const SHOULD_DEBUG = process.env.DEBUG === "*" || process.env.DEBUG?.startsWith("gui");
|
|
@@ -78,20 +78,17 @@ function getESBuildConfig({
|
|
|
78
78
|
resolvePlatformSpecificEntries,
|
|
79
79
|
...options
|
|
80
80
|
}, platform, aliases) {
|
|
81
|
-
if (process.env.DEBUG?.startsWith("
|
|
82
|
-
console.info(`Building`, entryPoints);
|
|
83
|
-
}
|
|
81
|
+
if (process.env.DEBUG?.startsWith("gui")) console.info(`Building`, entryPoints);
|
|
84
82
|
const resolvedEntryPoints = !resolvePlatformSpecificEntries ? entryPoints : entryPoints.map(import_loadGui.resolveWebOrNativeSpecificEntry);
|
|
85
83
|
const detectedFormat = options.format || detectEntryFormat(resolvedEntryPoints[0]);
|
|
86
|
-
|
|
84
|
+
return {
|
|
87
85
|
bundle: true,
|
|
88
86
|
entryPoints: resolvedEntryPoints,
|
|
89
87
|
format: detectedFormat,
|
|
90
|
-
// for ESM: prefer "module" field for resolution, add require() shim for bundled CJS deps
|
|
91
88
|
...(detectedFormat === "esm" ? {
|
|
92
89
|
mainFields: ["module", "main"],
|
|
93
90
|
banner: {
|
|
94
|
-
js:
|
|
91
|
+
js: "import { createRequire as __cr } from \"module\"; const require = __cr(import.meta.url);"
|
|
95
92
|
}
|
|
96
93
|
} : {}),
|
|
97
94
|
target: "node24",
|
|
@@ -99,7 +96,7 @@ function getESBuildConfig({
|
|
|
99
96
|
jsxFactory: "react",
|
|
100
97
|
allowOverwrite: true,
|
|
101
98
|
keepNames: true,
|
|
102
|
-
resolveExtensions: [...
|
|
99
|
+
resolveExtensions: [...[".web.tsx", ".web.ts", ".web.jsx", ".web.js"], ".tsx", ".ts", ".jsx", ".js"],
|
|
103
100
|
platform: "node",
|
|
104
101
|
tsconfigRaw: {
|
|
105
102
|
compilerOptions: {
|
|
@@ -117,12 +114,8 @@ function getESBuildConfig({
|
|
|
117
114
|
build.onLoad({
|
|
118
115
|
filter: /\.(ts|tsx|js|jsx|mjs)$/
|
|
119
116
|
}, args => {
|
|
120
|
-
if (!isCjs)
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
if (args.path.includes("node_modules") && !args.path.includes("@gui")) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
117
|
+
if (!isCjs) return null;
|
|
118
|
+
if (args.path.includes("node_modules") && !args.path.includes("@hanzogui")) return null;
|
|
126
119
|
let contents = (0, import_node_fs.readFileSync)(args.path, "utf8");
|
|
127
120
|
let modified = false;
|
|
128
121
|
if (contents.includes("import.meta.env")) {
|
|
@@ -130,7 +123,7 @@ function getESBuildConfig({
|
|
|
130
123
|
modified = true;
|
|
131
124
|
}
|
|
132
125
|
if (contents.includes("import.meta.url")) {
|
|
133
|
-
contents = contents.replace(/import\.meta\.url/g,
|
|
126
|
+
contents = contents.replace(/import\.meta\.url/g, "\"\"");
|
|
134
127
|
modified = true;
|
|
135
128
|
}
|
|
136
129
|
if (contents.includes("import.meta.main")) {
|
|
@@ -138,23 +131,17 @@ function getESBuildConfig({
|
|
|
138
131
|
modified = true;
|
|
139
132
|
}
|
|
140
133
|
if ((0, import_hasTopLevelAwait.hasTopLevelAwait)(contents, args.path)) {
|
|
141
|
-
if (process.env.DEBUG?.startsWith("
|
|
142
|
-
console.info(`[hanzo-gui] stubbing file with top-level await: ${args.path}`);
|
|
143
|
-
}
|
|
134
|
+
if (process.env.DEBUG?.startsWith("gui")) console.info(`[gui] stubbing file with top-level await: ${args.path}`);
|
|
144
135
|
return {
|
|
145
|
-
// Keep this as an ESM-shaped stub so esbuild doesn't inline a
|
|
146
|
-
// top-level `module.exports = {}` into the parent bundle.
|
|
147
136
|
contents: `// stubbed - contains top-level await
|
|
148
137
|
export default {}`,
|
|
149
138
|
loader: "js"
|
|
150
139
|
};
|
|
151
140
|
}
|
|
152
|
-
if (modified) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
};
|
|
157
|
-
}
|
|
141
|
+
if (modified) return {
|
|
142
|
+
contents,
|
|
143
|
+
loader: args.path.endsWith(".tsx") ? "tsx" : args.path.endsWith(".ts") ? "ts" : args.path.endsWith(".jsx") ? "jsx" : "js"
|
|
144
|
+
};
|
|
158
145
|
return null;
|
|
159
146
|
});
|
|
160
147
|
}
|
|
@@ -163,11 +150,9 @@ export default {}`,
|
|
|
163
150
|
setup(build) {
|
|
164
151
|
const proxyWormPath = require.resolve("@hanzogui/proxy-worm");
|
|
165
152
|
build.onResolve({
|
|
166
|
-
filter: /^@
|
|
153
|
+
filter: /^@hanzogui\/(core|web)$/
|
|
167
154
|
}, args => {
|
|
168
|
-
if (args.kind === "entry-point")
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
155
|
+
if (args.kind === "entry-point") return null;
|
|
171
156
|
return {
|
|
172
157
|
path: platform === "native" ? "@hanzogui/core/native" : args.path,
|
|
173
158
|
external: true
|
|
@@ -217,16 +202,12 @@ export default {}`,
|
|
|
217
202
|
})],
|
|
218
203
|
...options
|
|
219
204
|
};
|
|
220
|
-
return res;
|
|
221
205
|
}
|
|
222
206
|
function detectEntryFormat(entryPoint) {
|
|
223
|
-
if (entryPoint.startsWith("/") || entryPoint.startsWith("."))
|
|
224
|
-
return (0, import_detectModuleFormat.detectModuleFormat)(entryPoint);
|
|
225
|
-
}
|
|
207
|
+
if (entryPoint.startsWith("/") || entryPoint.startsWith(".")) return (0, import_detectModuleFormat.detectModuleFormat)(entryPoint);
|
|
226
208
|
try {
|
|
227
209
|
const pkgJsonPath = require.resolve(entryPoint + "/package.json");
|
|
228
|
-
|
|
229
|
-
return pkg.type === "module" ? "esm" : "cjs";
|
|
210
|
+
return JSON.parse((0, import_node_fs.readFileSync)(pkgJsonPath, "utf-8")).type === "module" ? "esm" : "cjs";
|
|
230
211
|
} catch {
|
|
231
212
|
return "cjs";
|
|
232
213
|
}
|
|
@@ -123,7 +123,7 @@ const handleEsmFeaturesPlugin = {
|
|
|
123
123
|
if (!isCjs) {
|
|
124
124
|
return null;
|
|
125
125
|
}
|
|
126
|
-
if (args.path.includes("node_modules") && !args.path.includes("@
|
|
126
|
+
if (args.path.includes("node_modules") && !args.path.includes("@hanzogui")) {
|
|
127
127
|
return null;
|
|
128
128
|
}
|
|
129
129
|
let contents = (0, import_node_fs.readFileSync)(args.path, "utf8");
|
|
@@ -141,8 +141,8 @@ const handleEsmFeaturesPlugin = {
|
|
|
141
141
|
modified = true;
|
|
142
142
|
}
|
|
143
143
|
if ((0, import_hasTopLevelAwait.hasTopLevelAwait)(contents, args.path)) {
|
|
144
|
-
if (process.env.DEBUG?.startsWith("
|
|
145
|
-
console.info(`[
|
|
144
|
+
if (process.env.DEBUG?.startsWith("gui")) {
|
|
145
|
+
console.info(`[gui] stubbing file with top-level await: ${args.path}`);
|
|
146
146
|
}
|
|
147
147
|
return {
|
|
148
148
|
// Keep this as an ESM-shaped stub so esbuild doesn't inline a top-level
|
|
@@ -231,7 +231,7 @@ async function bundleConfig(props) {
|
|
|
231
231
|
const ext = componentFormats[i] === "esm" ? ".mjs" : ".cjs";
|
|
232
232
|
return (0, import_node_path.join)(tmpDir, `${componentModule.split(import_node_path.sep).join("-").replace(/[^a-z0-9]+/gi, "")}-components.config${ext}`);
|
|
233
233
|
});
|
|
234
|
-
if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("
|
|
234
|
+
if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("gui")) {
|
|
235
235
|
console.info(`Building config entry`, configEntry);
|
|
236
236
|
}
|
|
237
237
|
let shouldBuild = !props.disableInitialBuild;
|
|
@@ -271,8 +271,8 @@ async function bundleConfig(props) {
|
|
|
271
271
|
if (!hasLoggedBuild && !props["_skipBuildLog"]) {
|
|
272
272
|
hasLoggedBuild = true;
|
|
273
273
|
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, `
|
|
274
|
-
\u27A1 [
|
|
275
|
-
if (process.env.DEBUG?.startsWith("
|
|
274
|
+
\u27A1 [gui] built config, components, prompt (${Date.now() - start}ms)`);
|
|
275
|
+
if (process.env.DEBUG?.startsWith("gui")) {
|
|
276
276
|
(0, import_cli_color.colorLog)(import_cli_color.Color.Dim, `
|
|
277
277
|
Config .${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), configOutPath)}
|
|
278
278
|
Components ${componentOutPaths.map(p => `.${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), p)}`).join("\n ")}
|
|
@@ -306,7 +306,7 @@ async function bundleConfig(props) {
|
|
|
306
306
|
throw new Error(`No config: ${config}`);
|
|
307
307
|
}
|
|
308
308
|
if (config._isProxyWorm) {
|
|
309
|
-
throw new Error(`Got a proxied config - likely a module loading error. Set DEBUG=
|
|
309
|
+
throw new Error(`Got a proxied config - likely a module loading error. Set DEBUG=gui for details.`);
|
|
310
310
|
}
|
|
311
311
|
loadedConfig = config;
|
|
312
312
|
if (!config.parsed) {
|
|
@@ -328,12 +328,12 @@ async function bundleConfig(props) {
|
|
|
328
328
|
for (const component of components) {
|
|
329
329
|
component.moduleName = baseComponents[componentOutPaths.indexOf(component.moduleName)] || component.moduleName;
|
|
330
330
|
if (!component.moduleName) {
|
|
331
|
-
if (process.env.DEBUG?.includes("
|
|
331
|
+
if (process.env.DEBUG?.includes("gui") || process.env.IS_GUI_DEV) {
|
|
332
332
|
console.warn(`\u26A0\uFE0F no module name found: ${component.moduleName} ${JSON.stringify(baseComponents)} in ${JSON.stringify(componentOutPaths)}`);
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("
|
|
336
|
+
if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("gui")) {
|
|
337
337
|
console.info("Loaded components", components);
|
|
338
338
|
}
|
|
339
339
|
const res = {
|
|
@@ -345,8 +345,8 @@ async function bundleConfig(props) {
|
|
|
345
345
|
updateLastLoaded(res);
|
|
346
346
|
return res;
|
|
347
347
|
} catch (err) {
|
|
348
|
-
console.error(`Error bundling gui config: ${err?.message} (run with DEBUG=
|
|
349
|
-
if (process.env.DEBUG?.includes("
|
|
348
|
+
console.error(`Error bundling gui config: ${err?.message} (run with DEBUG=gui to see stack)`);
|
|
349
|
+
if (process.env.DEBUG?.includes("gui")) {
|
|
350
350
|
console.error(err.stack);
|
|
351
351
|
}
|
|
352
352
|
} finally {
|
|
@@ -357,7 +357,7 @@ async function bundleConfig(props) {
|
|
|
357
357
|
}
|
|
358
358
|
async function writeGuiCSS(outputCSS, config) {
|
|
359
359
|
const flush = async () => {
|
|
360
|
-
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [
|
|
360
|
+
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [gui] output css: ${outputCSS}`);
|
|
361
361
|
await FS.writeFile(outputCSS, css);
|
|
362
362
|
};
|
|
363
363
|
const css = config.getCSS();
|
|
@@ -447,7 +447,7 @@ async function loadComponentsInner(props, forceExports = false) {
|
|
|
447
447
|
loader: import_bundle.esbuildLoaderConfig
|
|
448
448
|
});
|
|
449
449
|
}
|
|
450
|
-
if (process.env.DEBUG === "
|
|
450
|
+
if (process.env.DEBUG === "gui") {
|
|
451
451
|
console.info(`loadModule`, loadModule, format);
|
|
452
452
|
}
|
|
453
453
|
let moduleResult;
|
|
@@ -480,7 +480,7 @@ async function loadComponentsInner(props, forceExports = false) {
|
|
|
480
480
|
} catch (err) {
|
|
481
481
|
console.info("babel err", err, writtenContents);
|
|
482
482
|
writtenContents = fileContents;
|
|
483
|
-
if (process.env.DEBUG?.startsWith("
|
|
483
|
+
if (process.env.DEBUG?.startsWith("gui")) {
|
|
484
484
|
console.info(`Error parsing babel likely`, err);
|
|
485
485
|
}
|
|
486
486
|
try {
|
|
@@ -568,7 +568,7 @@ function loadComponentsInnerSync(props, forceExports = false) {
|
|
|
568
568
|
loader: import_bundle.esbuildLoaderConfig
|
|
569
569
|
});
|
|
570
570
|
}
|
|
571
|
-
if (process.env.DEBUG === "
|
|
571
|
+
if (process.env.DEBUG === "gui") {
|
|
572
572
|
console.info(`loadModule`, loadModule, require.resolve(loadModule));
|
|
573
573
|
}
|
|
574
574
|
const moduleResult = require(loadModule);
|
|
@@ -596,7 +596,7 @@ function loadComponentsInnerSync(props, forceExports = false) {
|
|
|
596
596
|
} catch (err) {
|
|
597
597
|
console.info("babel err", err, writtenContents);
|
|
598
598
|
writtenContents = fileContents;
|
|
599
|
-
if (process.env.DEBUG?.startsWith("
|
|
599
|
+
if (process.env.DEBUG?.startsWith("gui")) {
|
|
600
600
|
console.info(`Error parsing babel likely`, err);
|
|
601
601
|
}
|
|
602
602
|
} finally {
|
|
@@ -306,7 +306,7 @@ function createExtractor({
|
|
|
306
306
|
if (shouldPrintDebug) {
|
|
307
307
|
logger.info(["loaded components:", propsWithFileInfo.allLoadedComponents.map(comp => Object.keys(comp.nameToInfo).join(", ")).join(", ")].join(" "));
|
|
308
308
|
}
|
|
309
|
-
if (process.env.DEBUG?.startsWith("
|
|
309
|
+
if (process.env.DEBUG?.startsWith("gui")) {
|
|
310
310
|
logger.info(["loaded:", propsWithFileInfo.allLoadedComponents.map(x => x.moduleName)].join("\n"));
|
|
311
311
|
}
|
|
312
312
|
}
|
|
@@ -315,7 +315,7 @@ function createExtractor({
|
|
|
315
315
|
if (!guiConfig?.themes) {
|
|
316
316
|
console.error(`\u26D4\uFE0F Error: Missing "themes" in your gui.config file:
|
|
317
317
|
|
|
318
|
-
You may not need the compiler! Remember you can run
|
|
318
|
+
You may not need the compiler! Remember you can run Gui with no configuration at all.
|
|
319
319
|
|
|
320
320
|
You may have not "export default" your config (you can also "export const config").
|
|
321
321
|
|
|
@@ -348,8 +348,8 @@ function createExtractor({
|
|
|
348
348
|
const body = fileOrPath.type === "Program" ? fileOrPath.get("body") : fileOrPath.program.body;
|
|
349
349
|
if (!isFullyDisabled(options)) {
|
|
350
350
|
if (Object.keys(components || []).length === 0) {
|
|
351
|
-
console.warn(`Warning:
|
|
352
|
-
if (process.env.DEBUG === "
|
|
351
|
+
console.warn(`Warning: Gui didn't find any valid components (DEBUG=gui for more)`);
|
|
352
|
+
if (process.env.DEBUG === "gui") {
|
|
353
353
|
console.info(`components`, Object.keys(components || []), components);
|
|
354
354
|
}
|
|
355
355
|
}
|
|
@@ -493,12 +493,12 @@ function createExtractor({
|
|
|
493
493
|
if (!out2.cached) {
|
|
494
494
|
const foundNames = out2.components?.map(x => Object.keys(x.nameToInfo).join(", ")).join(", ").trim();
|
|
495
495
|
if (foundNames) {
|
|
496
|
-
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` |
|
|
496
|
+
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` | Gui found dynamic components: ${foundNames}`);
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
499
|
} catch (err) {
|
|
500
500
|
if (shouldPrintDebug) {
|
|
501
|
-
logger.info(`skip optimize styled(${variableName}), unable to pre-process (DEBUG=
|
|
501
|
+
logger.info(`skip optimize styled(${variableName}), unable to pre-process (DEBUG=gui for more)`);
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
504
|
}
|
|
@@ -676,7 +676,7 @@ function createExtractor({
|
|
|
676
676
|
if (!component || !component.staticConfig) {
|
|
677
677
|
if (shouldPrintDebug) {
|
|
678
678
|
logger.info(`
|
|
679
|
-
- No
|
|
679
|
+
- No Gui conf for: ${node.name.name}
|
|
680
680
|
`);
|
|
681
681
|
}
|
|
682
682
|
return;
|
|
@@ -171,7 +171,7 @@ const isValidImport = (props, moduleName, componentName) => {
|
|
|
171
171
|
return Boolean(getValidImport(props, moduleName, componentName));
|
|
172
172
|
};
|
|
173
173
|
const getValidComponentPackages = (0, import_memoize.memoize)(props => {
|
|
174
|
-
return [... /* @__PURE__ */new Set(["@hanzogui/core", "
|
|
174
|
+
return [... /* @__PURE__ */new Set(["@hanzogui/core", "gui", ...(props.components || [])])];
|
|
175
175
|
});
|
|
176
176
|
const getValidComponentsPaths = (0, import_memoize.memoize)(props => {
|
|
177
177
|
return getValidComponentPackages(props).flatMap(pkg => {
|
|
@@ -88,7 +88,7 @@ function getBabelPlugin() {
|
|
|
88
88
|
}
|
|
89
89
|
function getBabelParseDefinition(options) {
|
|
90
90
|
return {
|
|
91
|
-
name: "
|
|
91
|
+
name: "gui",
|
|
92
92
|
visitor: {
|
|
93
93
|
Program: {
|
|
94
94
|
enter(root) {
|
|
@@ -306,7 +306,7 @@ function getBabelParseDefinition(options) {
|
|
|
306
306
|
if (message.includes("Unexpected return value from visitor method")) {
|
|
307
307
|
message = "Unexpected return value from visitor method";
|
|
308
308
|
}
|
|
309
|
-
console.warn("Error in
|
|
309
|
+
console.warn("Error in Gui parse, skipping", message, err.stack);
|
|
310
310
|
return;
|
|
311
311
|
}
|
|
312
312
|
}
|
|
@@ -336,7 +336,7 @@ function getBabelParseDefinition(options) {
|
|
|
336
336
|
}
|
|
337
337
|
function assertValidTag(node) {
|
|
338
338
|
if (node.attributes.find(x => x.type === "JSXAttribute" && x.name.name === "style")) {
|
|
339
|
-
if (process.env.DEBUG?.startsWith("
|
|
339
|
+
if (process.env.DEBUG?.startsWith("gui")) {
|
|
340
340
|
console.warn("\u26A0\uFE0F Cannot pass style attribute to extracted style");
|
|
341
341
|
}
|
|
342
342
|
}
|
|
@@ -27,5 +27,5 @@ __export(getPrefixLogs_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(getPrefixLogs_exports);
|
|
28
28
|
var import_cli_color = require("@hanzogui/cli-color");
|
|
29
29
|
function getPrefixLogs(options) {
|
|
30
|
-
return options?.prefixLogs ?? ` \u{1F425} [
|
|
30
|
+
return options?.prefixLogs ?? ` \u{1F425} [gui] ${(0, import_cli_color.colorString)(import_cli_color.Color.FgYellow, options?.platform || "web")}`;
|
|
31
31
|
}
|
|
@@ -141,8 +141,8 @@ async function getStaticBindingsForScope(scope, whitelist = [], sourcePath, bind
|
|
|
141
141
|
}
|
|
142
142
|
} catch (err) {
|
|
143
143
|
if (shouldPrintDebug) {
|
|
144
|
-
console.warn(` | Skipping partial evaluation of constant file: ${moduleName} (DEBUG=
|
|
145
|
-
} else if (process.env.DEBUG?.startsWith("
|
|
144
|
+
console.warn(` | Skipping partial evaluation of constant file: ${moduleName} (DEBUG=gui for more)`);
|
|
145
|
+
} else if (process.env.DEBUG?.startsWith("gui")) {
|
|
146
146
|
console.info(`Error in partial evaluation`, err.message, err.stack);
|
|
147
147
|
}
|
|
148
148
|
}
|