@hanzogui/static 7.0.0 → 7.3.1
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 +11 -11
- package/dist/constants.cjs +2 -2
- package/dist/exports.cjs +2 -2
- package/dist/extractor/bundle.cjs +6 -6
- package/dist/extractor/bundleConfig.cjs +45 -45
- package/dist/extractor/createExtractor.cjs +39 -39
- package/dist/extractor/createLogger.cjs +1 -1
- package/dist/extractor/extractHelpers.cjs +1 -1
- package/dist/extractor/extractMediaStyle.cjs +7 -7
- package/dist/extractor/extractToClassNames.cjs +9 -9
- package/dist/extractor/extractToNative.cjs +7 -7
- package/dist/extractor/{getHanzoguiConfigPathFromOptionsConfig.cjs → getGuiConfigPathFromOptionsConfig.cjs} +5 -5
- package/dist/extractor/getPrefixLogs.cjs +1 -1
- package/dist/extractor/getStaticBindingsForScope.cjs +2 -2
- package/dist/extractor/{loadHanzogui.cjs → loadGui.cjs} +65 -65
- package/dist/extractor/regenerateConfig.cjs +20 -20
- package/dist/extractor/{watchHanzoguiConfig.cjs → watchGuiConfig.cjs} +15 -15
- package/dist/getPragmaOptions.cjs +6 -6
- package/dist/helpers/{requireHanzoguiCore.cjs → requireGuiCore.cjs} +12 -12
- package/dist/registerRequire.cjs +20 -20
- package/dist/worker.cjs +3 -3
- package/package.json +29 -23
- package/src/check-dep-versions.ts +1 -1
- package/src/checkDeps.ts +27 -27
- package/src/constants.ts +2 -2
- package/src/exports.ts +2 -2
- package/src/extractor/bundle.ts +9 -9
- package/src/extractor/bundleConfig.ts +56 -56
- package/src/extractor/createEvaluator.ts +2 -2
- package/src/extractor/createExtractor.ts +55 -55
- package/src/extractor/createLogger.ts +3 -3
- package/src/extractor/extractHelpers.ts +12 -12
- package/src/extractor/extractMediaStyle.ts +13 -13
- package/src/extractor/extractToClassNames.ts +11 -11
- package/src/extractor/extractToNative.ts +13 -13
- package/src/extractor/{getHanzoguiConfigPathFromOptionsConfig.ts → getGuiConfigPathFromOptionsConfig.ts} +3 -3
- package/src/extractor/getPrefixLogs.ts +3 -3
- package/src/extractor/getStaticBindingsForScope.ts +2 -2
- package/src/extractor/{loadHanzogui.ts → loadGui.ts} +85 -85
- package/src/extractor/regenerateConfig.ts +23 -23
- package/src/extractor/{watchHanzoguiConfig.ts → watchGuiConfig.ts} +10 -10
- package/src/getPragmaOptions.ts +6 -6
- package/src/helpers/requireGuiCore.ts +28 -0
- package/src/registerRequire.ts +27 -27
- package/src/server.ts +2 -2
- package/src/types.ts +10 -10
- package/src/worker.ts +7 -7
- package/types/constants.d.ts.map +1 -1
- package/types/exports.d.ts +2 -2
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts +2 -2
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +12 -12
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/createEvaluator.d.ts +2 -2
- package/types/extractor/createEvaluator.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts +5 -5
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/createLogger.d.ts +2 -2
- package/types/extractor/createLogger.d.ts.map +1 -1
- package/types/extractor/extractHelpers.d.ts +8 -8
- package/types/extractor/extractHelpers.d.ts.map +1 -1
- package/types/extractor/extractMediaStyle.d.ts +4 -4
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts +2 -2
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/extractToNative.d.ts +3 -3
- package/types/extractor/extractToNative.d.ts.map +1 -1
- package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts +3 -0
- package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts.map +1 -0
- package/types/extractor/getPrefixLogs.d.ts +2 -2
- package/types/extractor/getPrefixLogs.d.ts.map +1 -1
- package/types/extractor/loadGui.d.ts +22 -0
- package/types/extractor/loadGui.d.ts.map +1 -0
- package/types/extractor/regenerateConfig.d.ts +4 -4
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/extractor/watchGuiConfig.d.ts +5 -0
- package/types/extractor/watchGuiConfig.d.ts.map +1 -0
- package/types/helpers/requireGuiCore.d.ts +3 -0
- package/types/helpers/requireGuiCore.d.ts.map +1 -0
- package/types/registerRequire.d.ts +3 -3
- package/types/registerRequire.d.ts.map +1 -1
- package/types/server.d.ts +2 -2
- package/types/server.d.ts.map +1 -1
- package/types/types.d.ts +10 -10
- package/types/types.d.ts.map +1 -1
- package/types/worker.d.ts +4 -4
- package/types/worker.d.ts.map +1 -1
- package/src/helpers/requireHanzoguiCore.ts +0 -28
- package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts +0 -3
- package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts.map +0 -1
- package/types/extractor/loadHanzogui.d.ts +0 -22
- package/types/extractor/loadHanzogui.d.ts.map +0 -1
- package/types/extractor/watchHanzoguiConfig.d.ts +0 -5
- package/types/extractor/watchHanzoguiConfig.d.ts.map +0 -1
- package/types/helpers/requireHanzoguiCore.d.ts +0 -3
- package/types/helpers/requireHanzoguiCore.d.ts.map +0 -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 "";
|
|
@@ -64,7 +64,7 @@ function checkDuplicateInstalls(root) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
if (duplicates.size === 0) return "";
|
|
67
|
-
const lines = ["Found duplicate
|
|
67
|
+
const lines = ["Found duplicate gui installations in node_modules:", "", "This causes multiple runtime instances, which breaks theme/config detection.", ""];
|
|
68
68
|
for (const [pkg, locations] of duplicates) {
|
|
69
69
|
lines.push(` ${pkg}:`);
|
|
70
70
|
for (const loc of locations) {
|
|
@@ -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 = /["'](@hanzogui\/[\w-]+|
|
|
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 = /^"?(@hanzogui\/[\w-]+|
|
|
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,11 +204,11 @@ 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) {
|
|
211
|
-
const configNames = ["
|
|
211
|
+
const configNames = ["gui.config.ts", "gui.config.tsx", "gui.config.js", "gui.config.mjs", "gui.config.cjs"];
|
|
212
212
|
const searchDirs = [root, (0, import_node_path.join)(root, "src"), (0, import_node_path.join)(root, "app"), (0, import_node_path.join)(root, "config")];
|
|
213
213
|
for (const dir of searchDirs) {
|
|
214
214
|
for (const name of configNames) {
|
|
@@ -217,7 +217,7 @@ function checkConfigExists(root) {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
const buildConfigNames = ["
|
|
220
|
+
const buildConfigNames = ["gui.build.ts", "gui.build.js", "gui.build.mjs", "gui.build.cjs"];
|
|
221
221
|
for (const name of buildConfigNames) {
|
|
222
222
|
const buildPath = (0, import_node_path.join)(root, name);
|
|
223
223
|
if ((0, import_node_fs.existsSync)(buildPath)) {
|
|
@@ -235,8 +235,8 @@ function checkConfigExists(root) {
|
|
|
235
235
|
if ((0, import_node_fs.existsSync)(pkgJsonPath)) {
|
|
236
236
|
try {
|
|
237
237
|
const pkg = JSON.parse((0, import_node_fs.readFileSync)(pkgJsonPath, "utf8"));
|
|
238
|
-
if (pkg.
|
|
239
|
-
const configPath = (0, import_node_path.join)(root, pkg.
|
|
238
|
+
if (pkg.gui?.config) {
|
|
239
|
+
const configPath = (0, import_node_path.join)(root, pkg.gui.config);
|
|
240
240
|
if ((0, import_node_fs.existsSync)(configPath)) return "";
|
|
241
241
|
}
|
|
242
242
|
} catch {}
|
|
@@ -247,7 +247,7 @@ function checkConfigExists(root) {
|
|
|
247
247
|
if (pkg.workspaces) return "";
|
|
248
248
|
} catch {}
|
|
249
249
|
}
|
|
250
|
-
return ["No
|
|
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 = [];
|
|
@@ -260,7 +260,7 @@ async function checkDeps(root) {
|
|
|
260
260
|
const configSummary = checkConfigExists(root);
|
|
261
261
|
if (configSummary) issues.push(configSummary);
|
|
262
262
|
if (issues.length === 0) {
|
|
263
|
-
console.info(`
|
|
263
|
+
console.info(`Gui dependencies look good \u2705`);
|
|
264
264
|
process.exit(0);
|
|
265
265
|
}
|
|
266
266
|
for (let i = 0; i < issues.length; i++) {
|
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");
|
package/dist/exports.cjs
CHANGED
|
@@ -38,8 +38,8 @@ __reExport(exports_exports, require("./extractor/extractToClassNames.cjs"), modu
|
|
|
38
38
|
__reExport(exports_exports, require("./extractor/concatClassName.cjs"), module.exports);
|
|
39
39
|
__reExport(exports_exports, require("./extractor/extractToNative.cjs"), module.exports);
|
|
40
40
|
__reExport(exports_exports, require("./extractor/extractHelpers.cjs"), module.exports);
|
|
41
|
-
__reExport(exports_exports, require("./extractor/
|
|
42
|
-
__reExport(exports_exports, require("./extractor/
|
|
41
|
+
__reExport(exports_exports, require("./extractor/loadGui.cjs"), module.exports);
|
|
42
|
+
__reExport(exports_exports, require("./extractor/watchGuiConfig.cjs"), module.exports);
|
|
43
43
|
__reExport(exports_exports, require("./extractor/createLogger.cjs"), module.exports);
|
|
44
44
|
__reExport(exports_exports, require("./registerRequire.cjs"), module.exports);
|
|
45
45
|
var import_detectModuleFormat = require("./extractor/detectModuleFormat.cjs");
|
|
@@ -35,7 +35,7 @@ var bundle_exports = {};
|
|
|
35
35
|
__export(bundle_exports, {
|
|
36
36
|
esbuildIgnoreFilesRegex: () => esbuildIgnoreFilesRegex,
|
|
37
37
|
esbuildLoaderConfig: () => esbuildLoaderConfig,
|
|
38
|
-
|
|
38
|
+
esbundleGuiConfig: () => esbundleGuiConfig
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(bundle_exports);
|
|
41
41
|
var import_node_fs = require("node:fs");
|
|
@@ -44,7 +44,7 @@ var FS = __toESM(require("fs-extra"));
|
|
|
44
44
|
var import_detectModuleFormat = require("./detectModuleFormat.cjs");
|
|
45
45
|
var import_esbuildAliasPlugin = require("./esbuildAliasPlugin.cjs");
|
|
46
46
|
var import_hasTopLevelAwait = require("./hasTopLevelAwait.cjs");
|
|
47
|
-
var
|
|
47
|
+
var import_loadGui = require("./loadGui.cjs");
|
|
48
48
|
var import_esbuildTsconfigPaths = require("./esbuildTsconfigPaths.cjs");
|
|
49
49
|
const esbuildLoaderConfig = {
|
|
50
50
|
".js": "jsx",
|
|
@@ -78,8 +78,8 @@ function getESBuildConfig({
|
|
|
78
78
|
resolvePlatformSpecificEntries,
|
|
79
79
|
...options
|
|
80
80
|
}, platform, aliases) {
|
|
81
|
-
if (process.env.DEBUG?.startsWith("
|
|
82
|
-
const resolvedEntryPoints = !resolvePlatformSpecificEntries ? entryPoints : entryPoints.map(
|
|
81
|
+
if (process.env.DEBUG?.startsWith("gui")) console.info(`Building`, entryPoints);
|
|
82
|
+
const resolvedEntryPoints = !resolvePlatformSpecificEntries ? entryPoints : entryPoints.map(import_loadGui.resolveWebOrNativeSpecificEntry);
|
|
83
83
|
const detectedFormat = options.format || detectEntryFormat(resolvedEntryPoints[0]);
|
|
84
84
|
return {
|
|
85
85
|
bundle: true,
|
|
@@ -131,7 +131,7 @@ function getESBuildConfig({
|
|
|
131
131
|
modified = true;
|
|
132
132
|
}
|
|
133
133
|
if ((0, import_hasTopLevelAwait.hasTopLevelAwait)(contents, args.path)) {
|
|
134
|
-
if (process.env.DEBUG?.startsWith("
|
|
134
|
+
if (process.env.DEBUG?.startsWith("gui")) console.info(`[gui] stubbing file with top-level await: ${args.path}`);
|
|
135
135
|
return {
|
|
136
136
|
contents: `// stubbed - contains top-level await
|
|
137
137
|
export default {}`,
|
|
@@ -212,7 +212,7 @@ function detectEntryFormat(entryPoint) {
|
|
|
212
212
|
return "cjs";
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
async function
|
|
215
|
+
async function esbundleGuiConfig(props, platform, aliases) {
|
|
216
216
|
const config = getESBuildConfig(props, platform, aliases);
|
|
217
217
|
const tmpFile = props.outfile + ".tmp." + process.pid;
|
|
218
218
|
const result = await import_esbuild.default.build({
|
|
@@ -43,7 +43,7 @@ __export(bundleConfig_exports, {
|
|
|
43
43
|
loadComponentsInner: () => loadComponentsInner,
|
|
44
44
|
loadComponentsInnerSync: () => loadComponentsInnerSync,
|
|
45
45
|
loadComponentsSync: () => loadComponentsSync,
|
|
46
|
-
|
|
46
|
+
writeGuiCSS: () => writeGuiCSS
|
|
47
47
|
});
|
|
48
48
|
module.exports = __toCommonJS(bundleConfig_exports);
|
|
49
49
|
var import_generator = __toESM(require("@babel/generator"));
|
|
@@ -60,15 +60,15 @@ var import_promises = require("node:fs/promises");
|
|
|
60
60
|
var import_registerRequire = require("../registerRequire.cjs");
|
|
61
61
|
var import_babelParse = require("./babelParse.cjs");
|
|
62
62
|
var import_bundle = require("./bundle.cjs");
|
|
63
|
-
var
|
|
63
|
+
var import_getGuiConfigPathFromOptionsConfig = require("./getGuiConfigPathFromOptionsConfig.cjs");
|
|
64
64
|
var import_hasTopLevelAwait = require("./hasTopLevelAwait.cjs");
|
|
65
|
-
var
|
|
65
|
+
var import_requireGuiCore = require("../helpers/requireGuiCore.cjs");
|
|
66
66
|
var import_detectModuleFormat = require("./detectModuleFormat.cjs");
|
|
67
67
|
const activeTempFiles = /* @__PURE__ */new Set();
|
|
68
68
|
function getDynamicEvalOutfile(name, format, contents) {
|
|
69
69
|
const ext = format === "esm" ? "mjs" : "cjs";
|
|
70
70
|
const hash = (0, import_node_crypto.createHash)("sha1").update(name).update("\0").update(format).update("\0").update(contents).digest("hex").slice(0, 10);
|
|
71
|
-
return (0, import_node_path.join)(process.cwd(), ".
|
|
71
|
+
return (0, import_node_path.join)(process.cwd(), ".gui", `dynamic-eval-${hash}-${(0, import_node_path.basename)(name)}.${ext}`);
|
|
72
72
|
}
|
|
73
73
|
function getEsbuildStdinLoader(filePath) {
|
|
74
74
|
if (filePath.endsWith(".tsx")) return "tsx";
|
|
@@ -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
|
|
@@ -199,24 +199,24 @@ async function getBundledConfig(props, rebuild = false) {
|
|
|
199
199
|
}
|
|
200
200
|
return currentBundle;
|
|
201
201
|
}
|
|
202
|
-
global.
|
|
202
|
+
global.guiLastLoaded ||= 0;
|
|
203
203
|
function updateLastLoaded(config) {
|
|
204
|
-
global.
|
|
205
|
-
global.
|
|
204
|
+
global.guiLastLoaded = Date.now();
|
|
205
|
+
global.guiLastBundledConfig = config;
|
|
206
206
|
}
|
|
207
207
|
let hasBundledOnce = false;
|
|
208
208
|
let hasLoggedBuild = false;
|
|
209
209
|
async function bundleConfig(props) {
|
|
210
|
-
if (global.
|
|
211
|
-
return global.
|
|
210
|
+
if (global.guiLastBundledConfig && Date.now() - global.guiLastLoaded < 3e3) {
|
|
211
|
+
return global.guiLastBundledConfig;
|
|
212
212
|
}
|
|
213
213
|
try {
|
|
214
214
|
isBundling = true;
|
|
215
|
-
const configEntry = props.config ? (0,
|
|
216
|
-
const tmpDir = (0, import_node_path.join)(process.cwd(), ".
|
|
215
|
+
const configEntry = props.config ? (0, import_getGuiConfigPathFromOptionsConfig.getGuiConfigPathFromOptionsConfig)(props.config) : "";
|
|
216
|
+
const tmpDir = (0, import_node_path.join)(process.cwd(), ".gui");
|
|
217
217
|
const configFormat = configEntry ? (0, import_detectModuleFormat.detectModuleFormat)(configEntry) : "cjs";
|
|
218
218
|
const configExt = configFormat === "esm" ? ".mjs" : ".cjs";
|
|
219
|
-
const configOutPath = (0, import_node_path.join)(tmpDir, `
|
|
219
|
+
const configOutPath = (0, import_node_path.join)(tmpDir, `gui.config${configExt}`);
|
|
220
220
|
const baseComponents = (props.components || []).filter(x => x !== "@hanzogui/core");
|
|
221
221
|
const componentFormats = baseComponents.map(mod => {
|
|
222
222
|
try {
|
|
@@ -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;
|
|
@@ -250,7 +250,7 @@ async function bundleConfig(props) {
|
|
|
250
250
|
await FS.ensureDir(tmpDir);
|
|
251
251
|
} catch {}
|
|
252
252
|
const start = Date.now();
|
|
253
|
-
await Promise.all([props.config ? (0, import_bundle.
|
|
253
|
+
await Promise.all([props.config ? (0, import_bundle.esbundleGuiConfig)({
|
|
254
254
|
entryPoints: [configEntry],
|
|
255
255
|
external,
|
|
256
256
|
outfile: configOutPath,
|
|
@@ -258,7 +258,7 @@ async function bundleConfig(props) {
|
|
|
258
258
|
format: configFormat,
|
|
259
259
|
...esbuildExtraOptions
|
|
260
260
|
}, props.platform || "web") : null, ...baseComponents.map((componentModule, i) => {
|
|
261
|
-
return (0, import_bundle.
|
|
261
|
+
return (0, import_bundle.esbundleGuiConfig)({
|
|
262
262
|
entryPoints: [componentModule],
|
|
263
263
|
resolvePlatformSpecificEntries: true,
|
|
264
264
|
external,
|
|
@@ -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,17 +306,17 @@ 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) {
|
|
313
313
|
const {
|
|
314
|
-
|
|
315
|
-
} = (0,
|
|
316
|
-
config =
|
|
314
|
+
createGui
|
|
315
|
+
} = (0, import_requireGuiCore.requireGuiCore)(props.platform || "web");
|
|
316
|
+
config = createGui(config);
|
|
317
317
|
}
|
|
318
318
|
if (props.outputCSS) {
|
|
319
|
-
await
|
|
319
|
+
await writeGuiCSS(props.outputCSS, config);
|
|
320
320
|
}
|
|
321
321
|
let components = await loadComponents({
|
|
322
322
|
...props,
|
|
@@ -328,25 +328,25 @@ 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 = {
|
|
340
340
|
components,
|
|
341
341
|
nameToPaths: {},
|
|
342
|
-
|
|
342
|
+
guiConfig: config
|
|
343
343
|
};
|
|
344
344
|
currentBundle = res;
|
|
345
345
|
updateLastLoaded(res);
|
|
346
346
|
return res;
|
|
347
347
|
} catch (err) {
|
|
348
|
-
console.error(`Error bundling
|
|
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 {
|
|
@@ -355,9 +355,9 @@ async function bundleConfig(props) {
|
|
|
355
355
|
waitForBundle.clear();
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
async function
|
|
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 {
|
|
@@ -488,9 +488,9 @@ async function loadComponentsInner(props, forceExports = false) {
|
|
|
488
488
|
forceExports: false
|
|
489
489
|
});
|
|
490
490
|
} catch (err2) {
|
|
491
|
-
if (process.env.
|
|
491
|
+
if (process.env.GUI_ENABLE_WARN_DYNAMIC_LOAD) {
|
|
492
492
|
console.info(`
|
|
493
|
-
|
|
493
|
+
Gui attempted but failed to dynamically optimize components in:
|
|
494
494
|
${name}
|
|
495
495
|
`);
|
|
496
496
|
console.info(err2);
|
|
@@ -513,7 +513,7 @@ isDynamic: `, isDynamic);
|
|
|
513
513
|
cacheComponents[key] = results;
|
|
514
514
|
return results;
|
|
515
515
|
} catch (err) {
|
|
516
|
-
console.info(`
|
|
516
|
+
console.info(`Gui error bundling components`, err.message, err.stack);
|
|
517
517
|
return null;
|
|
518
518
|
} finally {
|
|
519
519
|
unregister();
|
|
@@ -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 {
|
|
@@ -607,9 +607,9 @@ function loadComponentsInnerSync(props, forceExports = false) {
|
|
|
607
607
|
forceExports: false
|
|
608
608
|
});
|
|
609
609
|
} catch (err) {
|
|
610
|
-
if (process.env.
|
|
610
|
+
if (process.env.GUI_ENABLE_WARN_DYNAMIC_LOAD) {
|
|
611
611
|
console.info(`
|
|
612
|
-
|
|
612
|
+
Gui attempted but failed to dynamically optimize components in:
|
|
613
613
|
${name}
|
|
614
614
|
`);
|
|
615
615
|
console.info(err);
|
|
@@ -626,7 +626,7 @@ isDynamic: `, isDynamic);
|
|
|
626
626
|
cacheComponents[key] = info;
|
|
627
627
|
return info;
|
|
628
628
|
} catch (err) {
|
|
629
|
-
console.info(`
|
|
629
|
+
console.info(`Gui error bundling components`, err.message, err.stack);
|
|
630
630
|
return null;
|
|
631
631
|
} finally {
|
|
632
632
|
unregister();
|
|
@@ -651,7 +651,7 @@ function getComponentStaticConfigByName(name, exported) {
|
|
|
651
651
|
throw new Error(`Invalid export from package ${name}: ${typeof exported}`);
|
|
652
652
|
}
|
|
653
653
|
for (const key in exported) {
|
|
654
|
-
const found =
|
|
654
|
+
const found = getGuiComponent(key, exported[key]);
|
|
655
655
|
if (found) {
|
|
656
656
|
const {
|
|
657
657
|
Component,
|
|
@@ -663,14 +663,14 @@ function getComponentStaticConfigByName(name, exported) {
|
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
665
|
} catch (err) {
|
|
666
|
-
if (process.env.
|
|
667
|
-
console.error(`
|
|
666
|
+
if (process.env.GUI_ENABLE_WARN_DYNAMIC_LOAD) {
|
|
667
|
+
console.error(`Gui failed getting components from ${name} (Disable error by setting environment variable GUI_ENABLE_WARN_DYNAMIC_LOAD=1)`);
|
|
668
668
|
console.error(err);
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
671
|
return components;
|
|
672
672
|
}
|
|
673
|
-
function
|
|
673
|
+
function getGuiComponent(name, Component) {
|
|
674
674
|
if (name[0].toUpperCase() !== name[0]) {
|
|
675
675
|
return;
|
|
676
676
|
}
|