@hanzogui/static 7.3.1 → 8.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/check-dep-versions.cjs +1 -1
- package/dist/checkDeps.cjs +10 -10
- package/dist/constants.cjs +2 -2
- package/dist/exports.cjs +2 -0
- package/dist/extractor/bundle.cjs +14 -4
- package/dist/extractor/bundleConfig.cjs +40 -27
- package/dist/extractor/concatClassName.cjs +40 -11
- package/dist/extractor/createExtractor.cjs +137 -30
- package/dist/extractor/extractHelpers.cjs +1 -1
- package/dist/extractor/extractMediaStyle.cjs +5 -5
- package/dist/extractor/extractToClassNames.cjs +52 -4
- package/dist/extractor/extractToNative.cjs +16 -8
- package/dist/extractor/getPrefixLogs.cjs +1 -1
- package/dist/extractor/getStaticBindingsForScope.cjs +2 -2
- package/dist/extractor/loadGui.cjs +52 -46
- package/dist/extractor/regenerateConfig.cjs +17 -17
- package/dist/extractor/watchGuiConfig.cjs +9 -9
- package/dist/getPragmaOptions.cjs +4 -4
- package/dist/registerRequire.cjs +17 -16
- package/package.json +21 -28
- package/src/check-dep-versions.ts +1 -1
- package/src/checkDeps.ts +25 -25
- package/src/constants.ts +2 -2
- package/src/exports.ts +1 -0
- package/src/extractor/bundle.ts +35 -6
- package/src/extractor/bundleConfig.ts +48 -28
- package/src/extractor/concatClassName.ts +37 -20
- package/src/extractor/createExtractor.ts +256 -36
- package/src/extractor/extractHelpers.ts +2 -2
- package/src/extractor/extractMediaStyle.ts +5 -5
- package/src/extractor/extractToClassNames.ts +109 -7
- package/src/extractor/extractToNative.ts +27 -10
- package/src/extractor/getPrefixLogs.ts +1 -1
- package/src/extractor/getStaticBindingsForScope.ts +2 -2
- package/src/extractor/loadGui.ts +66 -51
- package/src/extractor/regenerateConfig.ts +17 -17
- package/src/extractor/watchGuiConfig.ts +14 -9
- package/src/getPragmaOptions.ts +4 -4
- package/src/registerRequire.ts +32 -19
- package/types/constants.d.ts.map +1 -1
- package/types/exports.d.ts +1 -0
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +1 -1
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/extractMediaStyle.d.ts +1 -1
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/extractToNative.d.ts.map +1 -1
- package/types/extractor/loadGui.d.ts +5 -5
- package/types/extractor/loadGui.d.ts.map +1 -1
- package/types/extractor/regenerateConfig.d.ts +3 -3
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/extractor/watchGuiConfig.d.ts +1 -1
- package/types/extractor/watchGuiConfig.d.ts.map +1 -1
- package/types/registerRequire.d.ts +1 -1
- package/types/registerRequire.d.ts.map +1 -1
- package/LICENSE +0 -42
|
@@ -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: ["hanzogui", "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", "hanzogui"];
|
|
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 hanzogui 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-]+|hanzogui)@([^"'\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-]+|hanzogui)@[^":\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 hanzogui 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 = ["hanzogui.config.ts", "hanzogui.config.tsx", "hanzogui.config.js", "hanzogui.config.mjs", "hanzogui.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 = ["hanzogui.build.ts", "hanzogui.build.js", "hanzogui.build.mjs", "hanzogui.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.hanzogui?.config) {
|
|
239
|
+
const configPath = (0, import_node_path.join)(root, pkg.hanzogui.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 hanzogui.config file found.", "", "Gui requires a config file (e.g. hanzogui.config.ts) that calls createGui().", `Without it, components will throw "Can't find Gui configuration" at runtime.`, "", "See: https://hanzogui.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: "hanzogui",
|
|
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("hanzogui");
|
package/dist/exports.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(exports_exports, {
|
|
|
26
26
|
clearFormatCache: () => import_detectModuleFormat.clearFormatCache,
|
|
27
27
|
createExtractor: () => import_createExtractor.createExtractor,
|
|
28
28
|
detectModuleFormat: () => import_detectModuleFormat.detectModuleFormat,
|
|
29
|
+
esbundleGuiConfig: () => import_bundle.esbundleGuiConfig,
|
|
29
30
|
literalToAst: () => import_literalToAst.literalToAst
|
|
30
31
|
});
|
|
31
32
|
module.exports = __toCommonJS(exports_exports);
|
|
@@ -43,4 +44,5 @@ __reExport(exports_exports, require("./extractor/watchGuiConfig.cjs"), module.ex
|
|
|
43
44
|
__reExport(exports_exports, require("./extractor/createLogger.cjs"), module.exports);
|
|
44
45
|
__reExport(exports_exports, require("./registerRequire.cjs"), module.exports);
|
|
45
46
|
var import_detectModuleFormat = require("./extractor/detectModuleFormat.cjs");
|
|
47
|
+
var import_bundle = require("./extractor/bundle.cjs");
|
|
46
48
|
__reExport(exports_exports, require("./getPragmaOptions.cjs"), module.exports);
|
|
@@ -76,15 +76,25 @@ const esbuildIgnoreFilesRegex = new RegExp(`.(${dataExtensions.join("|")})$`, "i
|
|
|
76
76
|
function getESBuildConfig({
|
|
77
77
|
entryPoints,
|
|
78
78
|
resolvePlatformSpecificEntries,
|
|
79
|
+
define: callerDefine,
|
|
79
80
|
...options
|
|
80
81
|
}, platform, aliases) {
|
|
81
|
-
if (process.env.DEBUG?.startsWith("
|
|
82
|
-
const resolvedEntryPoints = !resolvePlatformSpecificEntries ? entryPoints : entryPoints.map(import_loadGui.resolveWebOrNativeSpecificEntry);
|
|
82
|
+
if (process.env.DEBUG?.startsWith("hanzogui")) console.info(`Building`, entryPoints);
|
|
83
|
+
const resolvedEntryPoints = !resolvePlatformSpecificEntries ? entryPoints : entryPoints.map(entry => (0, import_loadGui.resolveWebOrNativeSpecificEntry)(entry, platform));
|
|
83
84
|
const detectedFormat = options.format || detectEntryFormat(resolvedEntryPoints[0]);
|
|
84
85
|
return {
|
|
85
86
|
bundle: true,
|
|
86
87
|
entryPoints: resolvedEntryPoints,
|
|
87
88
|
format: detectedFormat,
|
|
89
|
+
define: {
|
|
90
|
+
...(platform === "web" ? {
|
|
91
|
+
"process.env.GUI_TARGET": "\"web\"",
|
|
92
|
+
"process.env.EXPO_OS": "\"web\""
|
|
93
|
+
} : {
|
|
94
|
+
"process.env.GUI_TARGET": "\"native\""
|
|
95
|
+
}),
|
|
96
|
+
...callerDefine
|
|
97
|
+
},
|
|
88
98
|
...(detectedFormat === "esm" ? {
|
|
89
99
|
mainFields: ["module", "main"],
|
|
90
100
|
banner: {
|
|
@@ -96,7 +106,7 @@ function getESBuildConfig({
|
|
|
96
106
|
jsxFactory: "react",
|
|
97
107
|
allowOverwrite: true,
|
|
98
108
|
keepNames: true,
|
|
99
|
-
resolveExtensions: [...[".web.tsx", ".web.ts", ".web.jsx", ".web.js"], ".tsx", ".ts", ".jsx", ".js"],
|
|
109
|
+
resolveExtensions: [...(platform === "web" ? [".web.tsx", ".web.ts", ".web.jsx", ".web.js"] : [".native.tsx", ".native.ts", ".native.jsx", ".native.js"]), ".tsx", ".ts", ".jsx", ".js"],
|
|
100
110
|
platform: "node",
|
|
101
111
|
tsconfigRaw: {
|
|
102
112
|
compilerOptions: {
|
|
@@ -131,7 +141,7 @@ function getESBuildConfig({
|
|
|
131
141
|
modified = true;
|
|
132
142
|
}
|
|
133
143
|
if ((0, import_hasTopLevelAwait.hasTopLevelAwait)(contents, args.path)) {
|
|
134
|
-
if (process.env.DEBUG?.startsWith("
|
|
144
|
+
if (process.env.DEBUG?.startsWith("hanzogui")) console.info(`[hanzogui] stubbing file with top-level await: ${args.path}`);
|
|
135
145
|
return {
|
|
136
146
|
contents: `// stubbed - contains top-level await
|
|
137
147
|
export default {}`,
|
|
@@ -68,7 +68,7 @@ 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(), ".hanzogui", `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("hanzogui")) {
|
|
145
|
+
console.info(`[hanzogui] 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
|
|
@@ -177,6 +177,7 @@ const esbuildOptionsWithPlugins = {
|
|
|
177
177
|
plugins: [handleEsmFeaturesPlugin]
|
|
178
178
|
};
|
|
179
179
|
let currentBundle = null;
|
|
180
|
+
let currentBundleKey = "";
|
|
180
181
|
let isBundling = false;
|
|
181
182
|
let lastBundle = null;
|
|
182
183
|
const waitForBundle = /* @__PURE__ */new Set();
|
|
@@ -189,34 +190,45 @@ function hasBundledConfigChanged() {
|
|
|
189
190
|
}
|
|
190
191
|
let loadedConfig = null;
|
|
191
192
|
const getLoadedConfig = () => loadedConfig;
|
|
193
|
+
function getBundleKey(props) {
|
|
194
|
+
return JSON.stringify({
|
|
195
|
+
components: props.components,
|
|
196
|
+
config: props.config,
|
|
197
|
+
platform: props.platform
|
|
198
|
+
});
|
|
199
|
+
}
|
|
192
200
|
async function getBundledConfig(props, rebuild = false) {
|
|
201
|
+
const bundleKey = getBundleKey(props);
|
|
193
202
|
if (isBundling) {
|
|
194
203
|
await new Promise(res => {
|
|
195
204
|
waitForBundle.add(res);
|
|
196
205
|
});
|
|
197
|
-
}
|
|
206
|
+
}
|
|
207
|
+
if (!currentBundle || currentBundleKey !== bundleKey || rebuild) {
|
|
198
208
|
return await bundleConfig(props);
|
|
199
209
|
}
|
|
200
210
|
return currentBundle;
|
|
201
211
|
}
|
|
202
|
-
global.
|
|
203
|
-
function updateLastLoaded(config) {
|
|
204
|
-
global.
|
|
205
|
-
global.
|
|
212
|
+
global.hanzoguiLastLoaded ||= 0;
|
|
213
|
+
function updateLastLoaded(config, bundleKey) {
|
|
214
|
+
global.hanzoguiLastLoaded = Date.now();
|
|
215
|
+
global.hanzoguiLastBundledConfig = config;
|
|
216
|
+
global.hanzoguiLastBundledConfigKey = bundleKey;
|
|
206
217
|
}
|
|
207
218
|
let hasBundledOnce = false;
|
|
208
219
|
let hasLoggedBuild = false;
|
|
209
220
|
async function bundleConfig(props) {
|
|
210
|
-
|
|
211
|
-
|
|
221
|
+
const bundleKey = getBundleKey(props);
|
|
222
|
+
if (global.hanzoguiLastBundledConfig && global.hanzoguiLastBundledConfigKey === bundleKey && Date.now() - global.hanzoguiLastLoaded < 3e3) {
|
|
223
|
+
return global.hanzoguiLastBundledConfig;
|
|
212
224
|
}
|
|
213
225
|
try {
|
|
214
226
|
isBundling = true;
|
|
215
227
|
const configEntry = props.config ? (0, import_getGuiConfigPathFromOptionsConfig.getGuiConfigPathFromOptionsConfig)(props.config) : "";
|
|
216
|
-
const tmpDir = (0, import_node_path.join)(process.cwd(), ".
|
|
228
|
+
const tmpDir = (0, import_node_path.join)(process.cwd(), ".hanzogui");
|
|
217
229
|
const configFormat = configEntry ? (0, import_detectModuleFormat.detectModuleFormat)(configEntry) : "cjs";
|
|
218
230
|
const configExt = configFormat === "esm" ? ".mjs" : ".cjs";
|
|
219
|
-
const configOutPath = (0, import_node_path.join)(tmpDir, `
|
|
231
|
+
const configOutPath = (0, import_node_path.join)(tmpDir, `hanzogui.config${configExt}`);
|
|
220
232
|
const baseComponents = (props.components || []).filter(x => x !== "@hanzogui/core");
|
|
221
233
|
const componentFormats = baseComponents.map(mod => {
|
|
222
234
|
try {
|
|
@@ -231,7 +243,7 @@ async function bundleConfig(props) {
|
|
|
231
243
|
const ext = componentFormats[i] === "esm" ? ".mjs" : ".cjs";
|
|
232
244
|
return (0, import_node_path.join)(tmpDir, `${componentModule.split(import_node_path.sep).join("-").replace(/[^a-z0-9]+/gi, "")}-components.config${ext}`);
|
|
233
245
|
});
|
|
234
|
-
if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("
|
|
246
|
+
if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("hanzogui")) {
|
|
235
247
|
console.info(`Building config entry`, configEntry);
|
|
236
248
|
}
|
|
237
249
|
let shouldBuild = !props.disableInitialBuild;
|
|
@@ -271,8 +283,8 @@ async function bundleConfig(props) {
|
|
|
271
283
|
if (!hasLoggedBuild && !props["_skipBuildLog"]) {
|
|
272
284
|
hasLoggedBuild = true;
|
|
273
285
|
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, `
|
|
274
|
-
\u27A1 [
|
|
275
|
-
if (process.env.DEBUG?.startsWith("
|
|
286
|
+
\u27A1 [hanzogui] built config, components, prompt (${Date.now() - start}ms)`);
|
|
287
|
+
if (process.env.DEBUG?.startsWith("hanzogui")) {
|
|
276
288
|
(0, import_cli_color.colorLog)(import_cli_color.Color.Dim, `
|
|
277
289
|
Config .${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), configOutPath)}
|
|
278
290
|
Components ${componentOutPaths.map(p => `.${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), p)}`).join("\n ")}
|
|
@@ -306,7 +318,7 @@ async function bundleConfig(props) {
|
|
|
306
318
|
throw new Error(`No config: ${config}`);
|
|
307
319
|
}
|
|
308
320
|
if (config._isProxyWorm) {
|
|
309
|
-
throw new Error(`Got a proxied config - likely a module loading error. Set DEBUG=
|
|
321
|
+
throw new Error(`Got a proxied config - likely a module loading error. Set DEBUG=hanzogui for details.`);
|
|
310
322
|
}
|
|
311
323
|
loadedConfig = config;
|
|
312
324
|
if (!config.parsed) {
|
|
@@ -328,25 +340,26 @@ async function bundleConfig(props) {
|
|
|
328
340
|
for (const component of components) {
|
|
329
341
|
component.moduleName = baseComponents[componentOutPaths.indexOf(component.moduleName)] || component.moduleName;
|
|
330
342
|
if (!component.moduleName) {
|
|
331
|
-
if (process.env.DEBUG?.includes("
|
|
343
|
+
if (process.env.DEBUG?.includes("hanzogui") || process.env.IS_GUI_DEV) {
|
|
332
344
|
console.warn(`\u26A0\uFE0F no module name found: ${component.moduleName} ${JSON.stringify(baseComponents)} in ${JSON.stringify(componentOutPaths)}`);
|
|
333
345
|
}
|
|
334
346
|
}
|
|
335
347
|
}
|
|
336
|
-
if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("
|
|
348
|
+
if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("hanzogui")) {
|
|
337
349
|
console.info("Loaded components", components);
|
|
338
350
|
}
|
|
339
351
|
const res = {
|
|
340
352
|
components,
|
|
341
353
|
nameToPaths: {},
|
|
342
|
-
|
|
354
|
+
hanzoguiConfig: config
|
|
343
355
|
};
|
|
344
356
|
currentBundle = res;
|
|
345
|
-
|
|
357
|
+
currentBundleKey = bundleKey;
|
|
358
|
+
updateLastLoaded(res, bundleKey);
|
|
346
359
|
return res;
|
|
347
360
|
} catch (err) {
|
|
348
|
-
console.error(`Error bundling
|
|
349
|
-
if (process.env.DEBUG?.includes("
|
|
361
|
+
console.error(`Error bundling hanzogui config: ${err?.message} (run with DEBUG=hanzogui to see stack)`);
|
|
362
|
+
if (process.env.DEBUG?.includes("hanzogui")) {
|
|
350
363
|
console.error(err.stack);
|
|
351
364
|
}
|
|
352
365
|
} finally {
|
|
@@ -357,7 +370,7 @@ async function bundleConfig(props) {
|
|
|
357
370
|
}
|
|
358
371
|
async function writeGuiCSS(outputCSS, config) {
|
|
359
372
|
const flush = async () => {
|
|
360
|
-
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [
|
|
373
|
+
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [hanzogui] output css: ${outputCSS}`);
|
|
361
374
|
await FS.writeFile(outputCSS, css);
|
|
362
375
|
};
|
|
363
376
|
const css = config.getCSS();
|
|
@@ -447,7 +460,7 @@ async function loadComponentsInner(props, forceExports = false) {
|
|
|
447
460
|
loader: import_bundle.esbuildLoaderConfig
|
|
448
461
|
});
|
|
449
462
|
}
|
|
450
|
-
if (process.env.DEBUG === "
|
|
463
|
+
if (process.env.DEBUG === "hanzogui") {
|
|
451
464
|
console.info(`loadModule`, loadModule, format);
|
|
452
465
|
}
|
|
453
466
|
let moduleResult;
|
|
@@ -480,7 +493,7 @@ async function loadComponentsInner(props, forceExports = false) {
|
|
|
480
493
|
} catch (err) {
|
|
481
494
|
console.info("babel err", err, writtenContents);
|
|
482
495
|
writtenContents = fileContents;
|
|
483
|
-
if (process.env.DEBUG?.startsWith("
|
|
496
|
+
if (process.env.DEBUG?.startsWith("hanzogui")) {
|
|
484
497
|
console.info(`Error parsing babel likely`, err);
|
|
485
498
|
}
|
|
486
499
|
try {
|
|
@@ -568,7 +581,7 @@ function loadComponentsInnerSync(props, forceExports = false) {
|
|
|
568
581
|
loader: import_bundle.esbuildLoaderConfig
|
|
569
582
|
});
|
|
570
583
|
}
|
|
571
|
-
if (process.env.DEBUG === "
|
|
584
|
+
if (process.env.DEBUG === "hanzogui") {
|
|
572
585
|
console.info(`loadModule`, loadModule, require.resolve(loadModule));
|
|
573
586
|
}
|
|
574
587
|
const moduleResult = require(loadModule);
|
|
@@ -596,7 +609,7 @@ function loadComponentsInnerSync(props, forceExports = false) {
|
|
|
596
609
|
} catch (err) {
|
|
597
610
|
console.info("babel err", err, writtenContents);
|
|
598
611
|
writtenContents = fileContents;
|
|
599
|
-
if (process.env.DEBUG?.startsWith("
|
|
612
|
+
if (process.env.DEBUG?.startsWith("hanzogui")) {
|
|
600
613
|
console.info(`Error parsing babel likely`, err);
|
|
601
614
|
}
|
|
602
615
|
} finally {
|
|
@@ -53,13 +53,12 @@ function concatClassName(_cn) {
|
|
|
53
53
|
final = name + " " + final;
|
|
54
54
|
continue;
|
|
55
55
|
}
|
|
56
|
-
const nextChar = name[splitIndex + 1];
|
|
57
|
-
const isMediaQuery = nextChar === "_";
|
|
58
56
|
const styleKey = name.slice(1, name.indexOf("-"));
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
const {
|
|
58
|
+
mediaKey,
|
|
59
|
+
pseudoKey
|
|
60
|
+
} = getClassNameScope(name, splitIndex);
|
|
61
|
+
const uid = `${styleKey}${mediaKey ? `@${mediaKey}` : ""}${pseudoKey ? `:${pseudoKey}` : ""}`;
|
|
63
62
|
if (usedPrefixes.has(uid)) {
|
|
64
63
|
continue;
|
|
65
64
|
}
|
|
@@ -67,8 +66,8 @@ function concatClassName(_cn) {
|
|
|
67
66
|
const propName = styleKey;
|
|
68
67
|
if (propName && propObjects) {
|
|
69
68
|
if (propObjects.some(po => {
|
|
70
|
-
if (
|
|
71
|
-
const propKey = pseudoInvert[
|
|
69
|
+
if (pseudoKey) {
|
|
70
|
+
const propKey = pseudoInvert[pseudoKey];
|
|
72
71
|
return po && po[propKey] && propName in po[propKey] && po[propKey] !== null;
|
|
73
72
|
}
|
|
74
73
|
const res = po && propName in po && po[propName] !== null;
|
|
@@ -82,11 +81,41 @@ function concatClassName(_cn) {
|
|
|
82
81
|
}
|
|
83
82
|
return final.trim();
|
|
84
83
|
}
|
|
84
|
+
function getClassNameScope(name, splitIndex) {
|
|
85
|
+
let mediaKey = "";
|
|
86
|
+
let pseudoKey = "";
|
|
87
|
+
let valueStart = splitIndex + 1;
|
|
88
|
+
if (name[valueStart] === "_") {
|
|
89
|
+
const mediaEnd = name.indexOf("_", valueStart + 1);
|
|
90
|
+
if (mediaEnd > valueStart + 1) {
|
|
91
|
+
mediaKey = name.slice(valueStart + 1, mediaEnd);
|
|
92
|
+
valueStart = mediaEnd + 1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (name[valueStart] === "0") {
|
|
96
|
+
const pseudoStart = valueStart + 1;
|
|
97
|
+
for (const nextPseudoKey of pseudoKeys) {
|
|
98
|
+
if (name.startsWith(`${nextPseudoKey}-`, pseudoStart)) {
|
|
99
|
+
pseudoKey = nextPseudoKey;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
mediaKey,
|
|
106
|
+
pseudoKey
|
|
107
|
+
};
|
|
108
|
+
}
|
|
85
109
|
const pseudoInvert = {
|
|
86
110
|
hover: "hoverStyle",
|
|
111
|
+
active: "pressStyle",
|
|
87
112
|
focus: "focusStyle",
|
|
88
|
-
|
|
113
|
+
"focus-visible": "focusVisibleStyle",
|
|
114
|
+
"focus-within": "focusWithinStyle",
|
|
89
115
|
focusVisible: "focusVisibleStyle",
|
|
90
116
|
focusWithin: "focusWithinStyle",
|
|
91
|
-
disabled: "disabledStyle"
|
|
92
|
-
|
|
117
|
+
disabled: "disabledStyle",
|
|
118
|
+
enter: "enterStyle",
|
|
119
|
+
exit: "exitStyle"
|
|
120
|
+
};
|
|
121
|
+
const pseudoKeys = Object.keys(pseudoInvert).sort((a, b) => b.length - a.length);
|