@hanzogui/static 4.4.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +20 -39
- package/dist/extractor/bundleConfig.cjs +46 -46
- 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/{getGuiConfigPathFromOptionsConfig.cjs → getHanzoguiConfigPathFromOptionsConfig.cjs} +5 -5
- package/dist/extractor/getPrefixLogs.cjs +1 -1
- package/dist/extractor/getStaticBindingsForScope.cjs +2 -2
- package/dist/extractor/{loadGui.cjs → loadHanzogui.cjs} +97 -141
- package/dist/extractor/regenerateConfig.cjs +20 -20
- package/dist/extractor/{watchGuiConfig.cjs → watchHanzoguiConfig.cjs} +15 -15
- package/dist/getPragmaOptions.cjs +6 -6
- package/dist/helpers/{requireGuiCore.cjs → requireHanzoguiCore.cjs} +12 -12
- package/dist/registerRequire.cjs +21 -21
- package/dist/worker.cjs +3 -3
- package/package.json +22 -22
- package/src/check-dep-versions.ts +1 -5
- package/src/checkDeps.ts +28 -30
- package/src/constants.ts +2 -2
- package/src/exports.ts +2 -2
- package/src/extractor/bundle.ts +11 -13
- package/src/extractor/bundleConfig.ts +57 -57
- package/src/extractor/createEvaluator.ts +2 -2
- package/src/extractor/createExtractor.ts +62 -55
- package/src/extractor/createLogger.ts +5 -3
- package/src/extractor/esbuildTsconfigPaths.ts +1 -1
- package/src/extractor/extractHelpers.ts +15 -12
- package/src/extractor/extractMediaStyle.ts +19 -13
- package/src/extractor/extractToClassNames.ts +11 -11
- package/src/extractor/extractToNative.ts +13 -13
- package/src/extractor/{getGuiConfigPathFromOptionsConfig.ts → getHanzoguiConfigPathFromOptionsConfig.ts} +3 -3
- package/src/extractor/getPrefixLogs.ts +3 -3
- package/src/extractor/getStaticBindingsForScope.ts +2 -2
- package/src/extractor/{loadGui.ts → loadHanzogui.ts} +86 -83
- package/src/extractor/regenerateConfig.ts +34 -24
- package/src/extractor/{watchGuiConfig.ts → watchHanzoguiConfig.ts} +10 -10
- package/src/getPragmaOptions.ts +6 -6
- package/src/helpers/requireHanzoguiCore.ts +28 -0
- package/src/registerRequire.ts +34 -36
- package/src/server.ts +2 -2
- package/src/types.ts +13 -10
- package/src/worker.ts +7 -7
- 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/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/getHanzoguiConfigPathFromOptionsConfig.d.ts +3 -0
- package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.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/loadHanzogui.d.ts +22 -0
- package/types/extractor/loadHanzogui.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/watchHanzoguiConfig.d.ts +5 -0
- package/types/extractor/watchHanzoguiConfig.d.ts.map +1 -0
- package/types/helpers/requireHanzoguiCore.d.ts +3 -0
- package/types/helpers/requireHanzoguiCore.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/requireGuiCore.ts +0 -28
- package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts +0 -3
- package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts.map +0 -1
- package/types/extractor/loadGui.d.ts +0 -22
- package/types/extractor/loadGui.d.ts.map +0 -1
- package/types/extractor/watchGuiConfig.d.ts +0 -5
- package/types/extractor/watchGuiConfig.d.ts.map +0 -1
- package/types/helpers/requireGuiCore.d.ts +0 -3
- package/types/helpers/requireGuiCore.d.ts.map +0 -1
|
@@ -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 = /["'](@
|
|
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 = /^"?(@
|
|
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.", "", "Hanzogui requires a config file (e.g. hanzogui.config.ts) that calls createHanzogui().", `Without it, components will throw "Can't find Hanzogui configuration" at runtime.`, "", "See: https://hanzogui.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(`Hanzogui 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: "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
|
@@ -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/loadHanzogui.cjs"), module.exports);
|
|
42
|
+
__reExport(exports_exports, require("./extractor/watchHanzoguiConfig.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
|
+
esbundleHanzoguiConfig: () => esbundleHanzoguiConfig
|
|
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_loadHanzogui = require("./loadHanzogui.cjs");
|
|
48
48
|
var import_esbuildTsconfigPaths = require("./esbuildTsconfigPaths.cjs");
|
|
49
49
|
const esbuildLoaderConfig = {
|
|
50
50
|
".js": "jsx",
|
|
@@ -78,20 +78,17 @@ function getESBuildConfig({
|
|
|
78
78
|
resolvePlatformSpecificEntries,
|
|
79
79
|
...options
|
|
80
80
|
}, platform, aliases) {
|
|
81
|
-
if (process.env.DEBUG?.startsWith("
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
const resolvedEntryPoints = !resolvePlatformSpecificEntries ? entryPoints : entryPoints.map(import_loadGui.resolveWebOrNativeSpecificEntry);
|
|
81
|
+
if (process.env.DEBUG?.startsWith("hanzogui")) console.info(`Building`, entryPoints);
|
|
82
|
+
const resolvedEntryPoints = !resolvePlatformSpecificEntries ? entryPoints : entryPoints.map(import_loadHanzogui.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("hanzogui")) console.info(`[hanzogui] 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,21 +202,17 @@ 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
|
}
|
|
233
214
|
}
|
|
234
|
-
async function
|
|
215
|
+
async function esbundleHanzoguiConfig(props, platform, aliases) {
|
|
235
216
|
const config = getESBuildConfig(props, platform, aliases);
|
|
236
217
|
const tmpFile = props.outfile + ".tmp." + process.pid;
|
|
237
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
|
+
writeHanzoguiCSS: () => writeHanzoguiCSS
|
|
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_getHanzoguiConfigPathFromOptionsConfig = require("./getHanzoguiConfigPathFromOptionsConfig.cjs");
|
|
64
64
|
var import_hasTopLevelAwait = require("./hasTopLevelAwait.cjs");
|
|
65
|
-
var
|
|
65
|
+
var import_requireHanzoguiCore = require("../helpers/requireHanzoguiCore.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(), ".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";
|
|
@@ -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("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
|
|
@@ -199,24 +199,24 @@ async function getBundledConfig(props, rebuild = false) {
|
|
|
199
199
|
}
|
|
200
200
|
return currentBundle;
|
|
201
201
|
}
|
|
202
|
-
global.
|
|
202
|
+
global.hanzoguiLastLoaded ||= 0;
|
|
203
203
|
function updateLastLoaded(config) {
|
|
204
|
-
global.
|
|
205
|
-
global.
|
|
204
|
+
global.hanzoguiLastLoaded = Date.now();
|
|
205
|
+
global.hanzoguiLastBundledConfig = 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.hanzoguiLastBundledConfig && Date.now() - global.hanzoguiLastLoaded < 3e3) {
|
|
211
|
+
return global.hanzoguiLastBundledConfig;
|
|
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_getHanzoguiConfigPathFromOptionsConfig.getHanzoguiConfigPathFromOptionsConfig)(props.config) : "";
|
|
216
|
+
const tmpDir = (0, import_node_path.join)(process.cwd(), ".hanzogui");
|
|
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, `hanzogui.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("hanzogui")) {
|
|
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.esbundleHanzoguiConfig)({
|
|
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.esbundleHanzoguiConfig)({
|
|
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 [hanzogui] built config, components, prompt (${Date.now() - start}ms)`);
|
|
275
|
+
if (process.env.DEBUG?.startsWith("hanzogui")) {
|
|
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=hanzogui for details.`);
|
|
310
310
|
}
|
|
311
311
|
loadedConfig = config;
|
|
312
312
|
if (!config.parsed) {
|
|
313
313
|
const {
|
|
314
|
-
|
|
315
|
-
} = (0,
|
|
316
|
-
config =
|
|
314
|
+
createHanzogui
|
|
315
|
+
} = (0, import_requireHanzoguiCore.requireHanzoguiCore)(props.platform || "web");
|
|
316
|
+
config = createHanzogui(config);
|
|
317
317
|
}
|
|
318
318
|
if (props.outputCSS) {
|
|
319
|
-
await
|
|
319
|
+
await writeHanzoguiCSS(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("hanzogui") || process.env.IS_TAMAGUI_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("hanzogui")) {
|
|
337
337
|
console.info("Loaded components", components);
|
|
338
338
|
}
|
|
339
339
|
const res = {
|
|
340
340
|
components,
|
|
341
341
|
nameToPaths: {},
|
|
342
|
-
|
|
342
|
+
hanzoguiConfig: 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 hanzogui config: ${err?.message} (run with DEBUG=hanzogui to see stack)`);
|
|
349
|
+
if (process.env.DEBUG?.includes("hanzogui")) {
|
|
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 writeHanzoguiCSS(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 [hanzogui] 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 === "hanzogui") {
|
|
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("hanzogui")) {
|
|
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.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
|
|
492
492
|
console.info(`
|
|
493
|
-
|
|
493
|
+
Hanzogui 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(`Hanzogui 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 === "hanzogui") {
|
|
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("hanzogui")) {
|
|
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.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
|
|
611
611
|
console.info(`
|
|
612
|
-
|
|
612
|
+
Hanzogui 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(`Hanzogui 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 = getHanzoguiComponent(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.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
|
|
667
|
+
console.error(`Hanzogui failed getting components from ${name} (Disable error by setting environment variable TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD=1)`);
|
|
668
668
|
console.error(err);
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
671
|
return components;
|
|
672
672
|
}
|
|
673
|
-
function
|
|
673
|
+
function getHanzoguiComponent(name, Component) {
|
|
674
674
|
if (name[0].toUpperCase() !== name[0]) {
|
|
675
675
|
return;
|
|
676
676
|
}
|