@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
package/dist/registerRequire.cjs
CHANGED
|
@@ -29,7 +29,7 @@ __export(registerRequire_exports, {
|
|
|
29
29
|
module.exports = __toCommonJS(registerRequire_exports);
|
|
30
30
|
var import_node = require("esbuild-register/dist/node");
|
|
31
31
|
var import_bundle = require("./extractor/bundle.cjs");
|
|
32
|
-
var
|
|
32
|
+
var import_requireHanzoguiCore = require("./helpers/requireHanzoguiCore.cjs");
|
|
33
33
|
const nameToPaths = {};
|
|
34
34
|
const getNameToPaths = () => nameToPaths;
|
|
35
35
|
const Module = require("node:module");
|
|
@@ -83,7 +83,7 @@ function registerRequire(platform, {
|
|
|
83
83
|
}) {
|
|
84
84
|
if (isRegistered) {
|
|
85
85
|
return {
|
|
86
|
-
|
|
86
|
+
hanzoguiRequire: require,
|
|
87
87
|
unregister: () => {}
|
|
88
88
|
};
|
|
89
89
|
}
|
|
@@ -92,9 +92,9 @@ function registerRequire(platform, {
|
|
|
92
92
|
unregister
|
|
93
93
|
} = (0, import_node.register)({
|
|
94
94
|
hookIgnoreNodeModules: false,
|
|
95
|
-
// don't transform @
|
|
95
|
+
// don't transform @hanzogui packages - they have pre-built dist files
|
|
96
96
|
hookMatcher: filename => {
|
|
97
|
-
if (filename.includes("@
|
|
97
|
+
if (filename.includes("@hanzogui") || /\/hanzogui\/code\/(core|ui|packages)\//.test(filename)) {
|
|
98
98
|
return false;
|
|
99
99
|
}
|
|
100
100
|
return true;
|
|
@@ -111,17 +111,17 @@ function registerRequire(platform, {
|
|
|
111
111
|
og = Module.prototype.require;
|
|
112
112
|
}
|
|
113
113
|
isRegistered = true;
|
|
114
|
-
Module.prototype.require =
|
|
115
|
-
function
|
|
114
|
+
Module.prototype.require = hanzoguiRequire;
|
|
115
|
+
function hanzoguiRequire(path) {
|
|
116
116
|
const staticExtractionStub = getStaticExtractionStub(path);
|
|
117
117
|
if (staticExtractionStub) {
|
|
118
118
|
return staticExtractionStub;
|
|
119
119
|
}
|
|
120
|
-
if (path === "
|
|
121
|
-
return og.apply(this, ["
|
|
120
|
+
if (path === "hanzogui" && platform === "native") {
|
|
121
|
+
return og.apply(this, ["hanzogui/native"]);
|
|
122
122
|
}
|
|
123
123
|
if (path === "@hanzogui/core") {
|
|
124
|
-
return (0,
|
|
124
|
+
return (0, import_requireHanzoguiCore.requireHanzoguiCore)(platform, path2 => {
|
|
125
125
|
return og.apply(this, [path2]);
|
|
126
126
|
});
|
|
127
127
|
}
|
|
@@ -145,11 +145,11 @@ function registerRequire(platform, {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
if (!whitelisted[path]) {
|
|
148
|
-
if (proxyWormImports && !path.includes(".
|
|
148
|
+
if (proxyWormImports && !path.includes(".hanzogui-dynamic-eval")) {
|
|
149
149
|
const callerFile = this?.filename || this?.id || "";
|
|
150
|
-
const
|
|
151
|
-
const isFromStaticLoader = !callerFile || callerFile === "." || callerFile === "[eval]" || callerFile.endsWith("/[eval]") || callerFile.includes("/code/compiler/static/") || callerFile.includes("/.
|
|
152
|
-
if (path === "
|
|
150
|
+
const isFromHanzoguiPkg = callerFile.includes("@hanzogui") || callerFile.includes("node_modules/hanzogui/");
|
|
151
|
+
const isFromStaticLoader = !callerFile || callerFile === "." || callerFile === "[eval]" || callerFile.endsWith("/[eval]") || callerFile.includes("/code/compiler/static/") || callerFile.includes("/.hanzogui/");
|
|
152
|
+
if (path === "hanzogui" || path.startsWith("@hanzogui/") || isFromHanzoguiPkg || isFromStaticLoader) {
|
|
153
153
|
return og.apply(this, [path]);
|
|
154
154
|
}
|
|
155
155
|
return proxyWorm;
|
|
@@ -159,24 +159,24 @@ function registerRequire(platform, {
|
|
|
159
159
|
const out = og.apply(this, arguments);
|
|
160
160
|
return out;
|
|
161
161
|
} catch (err) {
|
|
162
|
-
if (!process.env.
|
|
162
|
+
if (!process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD && path.includes("hanzogui-dynamic-eval")) {
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
|
-
if (allowedIgnores[path] || IGNORES === "true") {} else if (!process.env.
|
|
165
|
+
if (allowedIgnores[path] || IGNORES === "true") {} else if (!process.env.TAMAGUI_SHOW_FULL_BUNDLE_ERRORS && !process.env.DEBUG) {
|
|
166
166
|
if (hasWarnedForModules.has(path)) {} else {
|
|
167
167
|
hasWarnedForModules.add(path);
|
|
168
168
|
}
|
|
169
169
|
} else {
|
|
170
|
-
console.warn(` [
|
|
170
|
+
console.warn(` [hanzogui] skipped "${path}" (set TAMAGUI_IGNORE_BUNDLE_ERRORS="${path}" to silence)`);
|
|
171
171
|
}
|
|
172
172
|
return proxyWorm;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
return {
|
|
176
|
-
|
|
176
|
+
hanzoguiRequire,
|
|
177
177
|
unregister: () => {
|
|
178
178
|
if (hasWarnedForModules.size) {
|
|
179
|
-
console.info(` [
|
|
179
|
+
console.info(` [hanzogui] skipped loading ${hasWarnedForModules.size} module, see: https://hanzogui.dev/docs/intro/errors#warning-001`);
|
|
180
180
|
hasWarnedForModules.clear();
|
|
181
181
|
}
|
|
182
182
|
unregister();
|
|
@@ -185,15 +185,15 @@ function registerRequire(platform, {
|
|
|
185
185
|
}
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
|
-
const IGNORES = process.env.
|
|
189
|
-
const extraIgnores = IGNORES === "true" ? [] :
|
|
188
|
+
const IGNORES = process.env.TAMAGUI_IGNORE_BUNDLE_ERRORS;
|
|
189
|
+
const extraIgnores = IGNORES === "true" ? [] : process.env.TAMAGUI_IGNORE_BUNDLE_ERRORS?.split(",");
|
|
190
190
|
const knownIgnorableModules = {
|
|
191
191
|
"@gorhom/bottom-sheet": true,
|
|
192
192
|
"expo-modules": true,
|
|
193
193
|
solito: true,
|
|
194
194
|
"expo-linear-gradient": true,
|
|
195
195
|
"@expo/vector-icons": true,
|
|
196
|
-
"
|
|
196
|
+
"hanzogui/linear-gradient": true,
|
|
197
197
|
// animation libraries not needed for static extraction
|
|
198
198
|
"@emotion/is-prop-valid": true,
|
|
199
199
|
"framer-motion": true,
|
package/dist/worker.cjs
CHANGED
|
@@ -52,13 +52,13 @@ async function runTask(task) {
|
|
|
52
52
|
try {
|
|
53
53
|
if (task.type === "extractToClassNames") {
|
|
54
54
|
const isFullyDisabled = task.options.disableExtraction && task.options.disableDebugAttr;
|
|
55
|
-
if (!isFullyDisabled && !task.options["
|
|
55
|
+
if (!isFullyDisabled && !task.options["_disableLoadHanzogui"]) {
|
|
56
56
|
const cacheKey = JSON.stringify({
|
|
57
57
|
config: task.options.config,
|
|
58
58
|
components: task.options.components
|
|
59
59
|
});
|
|
60
60
|
if (!configCache.has(cacheKey)) {
|
|
61
|
-
configCache.set(cacheKey, getWebExtractor().
|
|
61
|
+
configCache.set(cacheKey, getWebExtractor().loadHanzogui(task.options));
|
|
62
62
|
}
|
|
63
63
|
await configCache.get(cacheKey);
|
|
64
64
|
}
|
|
@@ -80,7 +80,7 @@ async function runTask(task) {
|
|
|
80
80
|
components: task.options.components
|
|
81
81
|
});
|
|
82
82
|
if (!configCache.has(cacheKey)) {
|
|
83
|
-
configCache.set(cacheKey, getNativeExtractor().
|
|
83
|
+
configCache.set(cacheKey, getNativeExtractor().loadHanzogui(task.options));
|
|
84
84
|
}
|
|
85
85
|
await configCache.get(cacheKey);
|
|
86
86
|
const result = (0, import_extractToNative.extractToNative)(task.sourceFileName, task.sourceCode, task.options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzogui/static",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
"types": "./types/checkDeps.d.ts",
|
|
27
27
|
"default": "./dist/checkDeps.cjs"
|
|
28
28
|
},
|
|
29
|
-
"./
|
|
30
|
-
"types": "./types/extractor/
|
|
31
|
-
"default": "./dist/extractor/
|
|
29
|
+
"./loadHanzogui": {
|
|
30
|
+
"types": "./types/extractor/loadHanzogui.d.ts",
|
|
31
|
+
"default": "./dist/extractor/loadHanzogui.cjs"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
|
-
"build": "
|
|
39
|
-
"watch": "
|
|
40
|
-
"clean": "
|
|
41
|
-
"clean:build": "
|
|
38
|
+
"build": "hanzogui-build --skip-native",
|
|
39
|
+
"watch": "hanzogui-build --skip-native --watch",
|
|
40
|
+
"clean": "hanzogui-build clean",
|
|
41
|
+
"clean:build": "hanzogui-build clean:build"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/core": "^7.25.2",
|
|
@@ -50,19 +50,19 @@
|
|
|
50
50
|
"@babel/template": "^7.25.0",
|
|
51
51
|
"@babel/traverse": "^7.25.4",
|
|
52
52
|
"@babel/types": "^7.25.4",
|
|
53
|
-
"@hanzogui/cli-color": "
|
|
54
|
-
"@hanzogui/config-default": "
|
|
55
|
-
"@hanzogui/core": "
|
|
56
|
-
"@hanzogui/fake-react-native": "
|
|
57
|
-
"@hanzogui/generate-themes": "
|
|
58
|
-
"@hanzogui/helpers": "
|
|
59
|
-
"@hanzogui/helpers-node": "
|
|
60
|
-
"@hanzogui/proxy-worm": "
|
|
61
|
-
"@hanzogui/react-native-web-internals": "
|
|
62
|
-
"@hanzogui/react-native-web-lite": "
|
|
63
|
-
"@hanzogui/shorthands": "
|
|
64
|
-
"@hanzogui/types": "
|
|
65
|
-
"@hanzogui/web": "
|
|
53
|
+
"@hanzogui/cli-color": "7.0.0",
|
|
54
|
+
"@hanzogui/config-default": "7.0.0",
|
|
55
|
+
"@hanzogui/core": "7.0.0",
|
|
56
|
+
"@hanzogui/fake-react-native": "7.0.0",
|
|
57
|
+
"@hanzogui/generate-themes": "7.0.0",
|
|
58
|
+
"@hanzogui/helpers": "7.0.0",
|
|
59
|
+
"@hanzogui/helpers-node": "7.0.0",
|
|
60
|
+
"@hanzogui/proxy-worm": "7.0.0",
|
|
61
|
+
"@hanzogui/react-native-web-internals": "7.0.0",
|
|
62
|
+
"@hanzogui/react-native-web-lite": "7.0.0",
|
|
63
|
+
"@hanzogui/shorthands": "7.0.0",
|
|
64
|
+
"@hanzogui/types": "7.0.0",
|
|
65
|
+
"@hanzogui/web": "7.0.0",
|
|
66
66
|
"babel-literal-to-ast": "^2.1.0",
|
|
67
67
|
"browserslist": "^4.28.1",
|
|
68
68
|
"check-dependency-version-consistency": "^4.1.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@babel/plugin-syntax-typescript": "^7.25.4",
|
|
82
|
-
"@hanzogui/build": "
|
|
82
|
+
"@hanzogui/build": "7.0.0",
|
|
83
83
|
"@types/babel__core": "^7.20.5",
|
|
84
84
|
"@types/find-root": "^1.1.2",
|
|
85
85
|
"@types/node": "^22.1.0",
|
|
@@ -575,11 +575,7 @@ function check(path: string): {
|
|
|
575
575
|
dependencies: Dependencies
|
|
576
576
|
} {
|
|
577
577
|
const options: Options = {
|
|
578
|
-
includeDepPattern: [
|
|
579
|
-
'@hanzo/gui',
|
|
580
|
-
'react-native-web-lite',
|
|
581
|
-
'react-native-web-internals',
|
|
582
|
-
],
|
|
578
|
+
includeDepPattern: ['hanzogui', 'react-native-web-lite', 'react-native-web-internals'],
|
|
583
579
|
}
|
|
584
580
|
|
|
585
581
|
if (
|
package/src/checkDeps.ts
CHANGED
|
@@ -22,10 +22,10 @@ export type Options = {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// critical packages that must not be duplicated at runtime
|
|
25
|
-
const CRITICAL_PACKAGES = ['@hanzogui/web', '@hanzogui/core', '
|
|
25
|
+
const CRITICAL_PACKAGES = ['@hanzogui/web', '@hanzogui/core', 'hanzogui']
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* Walks node_modules to find duplicate physical copies of critical
|
|
28
|
+
* Walks node_modules to find duplicate physical copies of critical hanzogui packages.
|
|
29
29
|
* Detects nested node_modules that would cause multiple runtime instances.
|
|
30
30
|
*/
|
|
31
31
|
function checkDuplicateInstalls(root: string): string {
|
|
@@ -60,7 +60,7 @@ function checkDuplicateInstalls(root: string): string {
|
|
|
60
60
|
if (duplicates.size === 0) return ''
|
|
61
61
|
|
|
62
62
|
const lines: string[] = [
|
|
63
|
-
'Found duplicate
|
|
63
|
+
'Found duplicate hanzogui installations in node_modules:',
|
|
64
64
|
'',
|
|
65
65
|
'This causes multiple runtime instances, which breaks theme/config detection.',
|
|
66
66
|
'',
|
|
@@ -92,7 +92,7 @@ function checkDuplicateInstalls(root: string): string {
|
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* Recursively find all instances of a package in node_modules.
|
|
95
|
-
* Handles both scoped (@hanzogui/web) and unscoped (
|
|
95
|
+
* Handles both scoped (@hanzogui/web) and unscoped (hanzogui) packages.
|
|
96
96
|
*/
|
|
97
97
|
function findAllInstances(
|
|
98
98
|
nodeModulesDir: string,
|
|
@@ -139,7 +139,7 @@ function findAllInstances(
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
/**
|
|
142
|
-
* Checks lockfile for multiple resolved versions of
|
|
142
|
+
* Checks lockfile for multiple resolved versions of hanzogui packages.
|
|
143
143
|
* Supports bun.lock, yarn.lock, and package-lock.json.
|
|
144
144
|
*/
|
|
145
145
|
function checkLockfileDuplicates(root: string): string {
|
|
@@ -160,9 +160,9 @@ function checkBunLockDuplicates(lockPath: string): string {
|
|
|
160
160
|
const duplicates = new Map<string, Set<string>>()
|
|
161
161
|
const criticalSet = new Set(CRITICAL_PACKAGES)
|
|
162
162
|
|
|
163
|
-
// match patterns like "@hanzogui/web@version" or "
|
|
163
|
+
// match patterns like "@hanzogui/web@version" or "hanzogui@version" in resolved entries
|
|
164
164
|
// bun.lock format: "package@version": ["resolved-url", ...]
|
|
165
|
-
const packagePattern = /["'](@
|
|
165
|
+
const packagePattern = /["'](@hanzogui\/[\w-]+|hanzogui)@([^"'\s,]+)["']/g
|
|
166
166
|
let match: RegExpExecArray | null
|
|
167
167
|
while ((match = packagePattern.exec(content)) !== null) {
|
|
168
168
|
const name = match[1]
|
|
@@ -189,7 +189,7 @@ function checkYarnLockDuplicates(lockPath: string): string {
|
|
|
189
189
|
// yarn.lock format:
|
|
190
190
|
// "@hanzogui/web@^1.0.0":
|
|
191
191
|
// version "1.0.1"
|
|
192
|
-
const entryPattern = /^"?(@
|
|
192
|
+
const entryPattern = /^"?(@hanzogui\/[\w-]+|hanzogui)@[^":\n]+[":]?\s*$/gm
|
|
193
193
|
const versionPattern = /^\s+version\s+"([^"]+)"/gm
|
|
194
194
|
|
|
195
195
|
let entryMatch: RegExpExecArray | null
|
|
@@ -260,23 +260,21 @@ function formatLockfileDuplicates(
|
|
|
260
260
|
lines.push(
|
|
261
261
|
'Multiple versions cause duplicate runtime instances, breaking config/theme detection.'
|
|
262
262
|
)
|
|
263
|
-
lines.push(
|
|
264
|
-
'Fix: ensure all hanzo-gui packages use the same version range, then dedupe.'
|
|
265
|
-
)
|
|
263
|
+
lines.push('Fix: ensure all hanzogui packages use the same version range, then dedupe.')
|
|
266
264
|
|
|
267
265
|
return lines.join('\n')
|
|
268
266
|
}
|
|
269
267
|
|
|
270
268
|
/**
|
|
271
|
-
* Checks that a
|
|
269
|
+
* Checks that a hanzogui config file exists in common locations.
|
|
272
270
|
*/
|
|
273
271
|
function checkConfigExists(root: string): string {
|
|
274
272
|
const configNames = [
|
|
275
|
-
'
|
|
276
|
-
'
|
|
277
|
-
'
|
|
278
|
-
'
|
|
279
|
-
'
|
|
273
|
+
'hanzogui.config.ts',
|
|
274
|
+
'hanzogui.config.tsx',
|
|
275
|
+
'hanzogui.config.js',
|
|
276
|
+
'hanzogui.config.mjs',
|
|
277
|
+
'hanzogui.config.cjs',
|
|
280
278
|
]
|
|
281
279
|
|
|
282
280
|
const searchDirs = [root, join(root, 'src'), join(root, 'app'), join(root, 'config')]
|
|
@@ -289,12 +287,12 @@ function checkConfigExists(root: string): string {
|
|
|
289
287
|
}
|
|
290
288
|
}
|
|
291
289
|
|
|
292
|
-
// check if
|
|
290
|
+
// check if hanzogui.build.ts references a config path
|
|
293
291
|
const buildConfigNames = [
|
|
294
|
-
'
|
|
295
|
-
'
|
|
296
|
-
'
|
|
297
|
-
'
|
|
292
|
+
'hanzogui.build.ts',
|
|
293
|
+
'hanzogui.build.js',
|
|
294
|
+
'hanzogui.build.mjs',
|
|
295
|
+
'hanzogui.build.cjs',
|
|
298
296
|
]
|
|
299
297
|
for (const name of buildConfigNames) {
|
|
300
298
|
const buildPath = join(root, name)
|
|
@@ -310,13 +308,13 @@ function checkConfigExists(root: string): string {
|
|
|
310
308
|
}
|
|
311
309
|
}
|
|
312
310
|
|
|
313
|
-
// also check if there's a
|
|
311
|
+
// also check if there's a hanzogui config referenced in package.json
|
|
314
312
|
const pkgJsonPath = join(root, 'package.json')
|
|
315
313
|
if (existsSync(pkgJsonPath)) {
|
|
316
314
|
try {
|
|
317
315
|
const pkg = JSON.parse(readFileSync(pkgJsonPath, 'utf8'))
|
|
318
|
-
if (pkg.
|
|
319
|
-
const configPath = join(root, pkg.
|
|
316
|
+
if (pkg.hanzogui?.config) {
|
|
317
|
+
const configPath = join(root, pkg.hanzogui.config)
|
|
320
318
|
if (existsSync(configPath)) return ''
|
|
321
319
|
}
|
|
322
320
|
} catch {}
|
|
@@ -331,12 +329,12 @@ function checkConfigExists(root: string): string {
|
|
|
331
329
|
}
|
|
332
330
|
|
|
333
331
|
return [
|
|
334
|
-
'No
|
|
332
|
+
'No hanzogui.config file found.',
|
|
335
333
|
'',
|
|
336
|
-
'
|
|
337
|
-
'Without it, components will throw "Can\'t find
|
|
334
|
+
'Hanzogui requires a config file (e.g. hanzogui.config.ts) that calls createHanzogui().',
|
|
335
|
+
'Without it, components will throw "Can\'t find Hanzogui configuration" at runtime.',
|
|
338
336
|
'',
|
|
339
|
-
'See: https://
|
|
337
|
+
'See: https://hanzogui.dev/docs/core/configuration',
|
|
340
338
|
].join('\n')
|
|
341
339
|
}
|
|
342
340
|
|
|
@@ -360,7 +358,7 @@ export async function checkDeps(root: string) {
|
|
|
360
358
|
if (configSummary) issues.push(configSummary)
|
|
361
359
|
|
|
362
360
|
if (issues.length === 0) {
|
|
363
|
-
console.info(`
|
|
361
|
+
console.info(`Hanzogui dependencies look good ✅`)
|
|
364
362
|
process.exit(0)
|
|
365
363
|
}
|
|
366
364
|
|
package/src/constants.ts
CHANGED
|
@@ -6,9 +6,9 @@ export const CSS_FILE_NAME = '__snack.css'
|
|
|
6
6
|
export const MEDIA_SEP = '_'
|
|
7
7
|
|
|
8
8
|
// ensure cache dir
|
|
9
|
-
export const cacheDir = findCacheDir({ name: '
|
|
9
|
+
export const cacheDir = findCacheDir({ name: 'hanzogui', create: true })
|
|
10
10
|
|
|
11
11
|
export const FAILED_EVAL = Symbol('failed_style_eval')
|
|
12
12
|
|
|
13
13
|
export const SHOULD_DEBUG =
|
|
14
|
-
process.env.DEBUG === '*' || process.env.DEBUG?.startsWith('
|
|
14
|
+
process.env.DEBUG === '*' || process.env.DEBUG?.startsWith('hanzogui')
|
package/src/exports.ts
CHANGED
|
@@ -7,8 +7,8 @@ export * from './extractor/extractToClassNames'
|
|
|
7
7
|
export * from './extractor/concatClassName'
|
|
8
8
|
export * from './extractor/extractToNative'
|
|
9
9
|
export * from './extractor/extractHelpers'
|
|
10
|
-
export * from './extractor/
|
|
11
|
-
export * from './extractor/
|
|
10
|
+
export * from './extractor/loadHanzogui'
|
|
11
|
+
export * from './extractor/watchHanzoguiConfig'
|
|
12
12
|
export * from './extractor/createLogger'
|
|
13
13
|
export * from './registerRequire'
|
|
14
14
|
export { detectModuleFormat, clearFormatCache } from './extractor/detectModuleFormat'
|
package/src/extractor/bundle.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs'
|
|
2
2
|
import esbuild from 'esbuild'
|
|
3
3
|
import * as FS from 'fs-extra'
|
|
4
|
-
import type {
|
|
4
|
+
import type { HanzoguiPlatform } from '../types'
|
|
5
5
|
import { detectModuleFormat } from './detectModuleFormat'
|
|
6
6
|
import { esbuildAliasPlugin } from './esbuildAliasPlugin'
|
|
7
7
|
import { hasTopLevelAwait } from './hasTopLevelAwait'
|
|
8
|
-
import { resolveWebOrNativeSpecificEntry } from './
|
|
8
|
+
import { resolveWebOrNativeSpecificEntry } from './loadHanzogui'
|
|
9
9
|
import { TsconfigPathsPlugin } from './esbuildTsconfigPaths'
|
|
10
10
|
|
|
11
11
|
export const esbuildLoaderConfig = {
|
|
@@ -54,10 +54,10 @@ type Props = Omit<Partial<esbuild.BuildOptions>, 'entryPoints'> & {
|
|
|
54
54
|
|
|
55
55
|
function getESBuildConfig(
|
|
56
56
|
{ entryPoints, resolvePlatformSpecificEntries, ...options }: Props,
|
|
57
|
-
platform:
|
|
57
|
+
platform: HanzoguiPlatform,
|
|
58
58
|
aliases?: Record<string, string>
|
|
59
59
|
) {
|
|
60
|
-
if (process.env.DEBUG?.startsWith('
|
|
60
|
+
if (process.env.DEBUG?.startsWith('hanzogui')) {
|
|
61
61
|
console.info(`Building`, entryPoints)
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -87,7 +87,7 @@ function getESBuildConfig(
|
|
|
87
87
|
allowOverwrite: true,
|
|
88
88
|
keepNames: true,
|
|
89
89
|
resolveExtensions: [
|
|
90
|
-
...(process.env.
|
|
90
|
+
...(process.env.TAMAGUI_TARGET === 'web'
|
|
91
91
|
? ['.web.tsx', '.web.ts', '.web.jsx', '.web.js']
|
|
92
92
|
: ['.native.tsx', '.native.ts', '.native.jsx', '.native.js']),
|
|
93
93
|
'.tsx',
|
|
@@ -121,7 +121,7 @@ function getESBuildConfig(
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
// skip most node_modules
|
|
124
|
-
if (args.path.includes('node_modules') && !args.path.includes('@
|
|
124
|
+
if (args.path.includes('node_modules') && !args.path.includes('@hanzogui')) {
|
|
125
125
|
return null
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -148,10 +148,8 @@ function getESBuildConfig(
|
|
|
148
148
|
|
|
149
149
|
// stub files with top-level await - they're typically runtime-only
|
|
150
150
|
if (hasTopLevelAwait(contents, args.path)) {
|
|
151
|
-
if (process.env.DEBUG?.startsWith('
|
|
152
|
-
console.info(
|
|
153
|
-
`[hanzo-gui] stubbing file with top-level await: ${args.path}`
|
|
154
|
-
)
|
|
151
|
+
if (process.env.DEBUG?.startsWith('hanzogui')) {
|
|
152
|
+
console.info(`[hanzogui] stubbing file with top-level await: ${args.path}`)
|
|
155
153
|
}
|
|
156
154
|
return {
|
|
157
155
|
// Keep this as an ESM-shaped stub so esbuild doesn't inline a
|
|
@@ -187,7 +185,7 @@ function getESBuildConfig(
|
|
|
187
185
|
// only externalize @hanzogui/core and @hanzogui/web - these are provided at runtime
|
|
188
186
|
// other @hanzogui/* packages (like @hanzogui/config/v3) must be bundled in to avoid
|
|
189
187
|
// ESM race conditions when multiple threads require() them concurrently
|
|
190
|
-
build.onResolve({ filter: /^@
|
|
188
|
+
build.onResolve({ filter: /^@hanzogui\/(core|web)$/ }, (args) => {
|
|
191
189
|
if (args.kind === 'entry-point') {
|
|
192
190
|
return null
|
|
193
191
|
}
|
|
@@ -257,9 +255,9 @@ function detectEntryFormat(entryPoint: string): esbuild.BuildOptions['format'] {
|
|
|
257
255
|
}
|
|
258
256
|
}
|
|
259
257
|
|
|
260
|
-
export async function
|
|
258
|
+
export async function esbundleHanzoguiConfig(
|
|
261
259
|
props: Props,
|
|
262
|
-
platform:
|
|
260
|
+
platform: HanzoguiPlatform,
|
|
263
261
|
aliases?: Record<string, string>
|
|
264
262
|
) {
|
|
265
263
|
const config = getESBuildConfig(props, platform, aliases)
|