@hanzogui/static 4.3.1 → 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/babelParse.cjs +1 -1
- package/dist/extractor/bundle.cjs +23 -39
- package/dist/extractor/bundleConfig.cjs +51 -48
- 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/hasTopLevelAwait.cjs +62 -0
- 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 +58 -20
- 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/babelParse.ts +1 -0
- package/src/extractor/bundle.ts +16 -18
- package/src/extractor/bundleConfig.ts +62 -62
- 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/hasTopLevelAwait.ts +28 -0
- 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 +79 -34
- 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/babelParse.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/hasTopLevelAwait.d.ts +2 -0
- package/types/extractor/hasTopLevelAwait.d.ts.map +1 -0
- 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");
|
|
@@ -43,6 +43,39 @@ const compiled = {};
|
|
|
43
43
|
function setRequireResult(name, result) {
|
|
44
44
|
compiled[name] = result;
|
|
45
45
|
}
|
|
46
|
+
function getStaticExtractionStub(path) {
|
|
47
|
+
switch (path) {
|
|
48
|
+
case "expo-constants":
|
|
49
|
+
return {
|
|
50
|
+
__esModule: true,
|
|
51
|
+
default: {
|
|
52
|
+
executionEnvironment: null
|
|
53
|
+
},
|
|
54
|
+
ExecutionEnvironment: {
|
|
55
|
+
Bare: "bare",
|
|
56
|
+
Standalone: "standalone",
|
|
57
|
+
StoreClient: "storeClient"
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
case "expo-updates":
|
|
61
|
+
return {
|
|
62
|
+
__esModule: true,
|
|
63
|
+
default: {
|
|
64
|
+
isEnabled: false,
|
|
65
|
+
isUsingEmbeddedAssets: true
|
|
66
|
+
},
|
|
67
|
+
checkForUpdateAsync: async () => ({
|
|
68
|
+
isAvailable: false
|
|
69
|
+
}),
|
|
70
|
+
fetchUpdateAsync: async () => ({
|
|
71
|
+
isNew: false
|
|
72
|
+
}),
|
|
73
|
+
reloadAsync: async () => {}
|
|
74
|
+
};
|
|
75
|
+
default:
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
46
79
|
function registerRequire(platform, {
|
|
47
80
|
proxyWormImports
|
|
48
81
|
} = {
|
|
@@ -50,7 +83,7 @@ function registerRequire(platform, {
|
|
|
50
83
|
}) {
|
|
51
84
|
if (isRegistered) {
|
|
52
85
|
return {
|
|
53
|
-
|
|
86
|
+
hanzoguiRequire: require,
|
|
54
87
|
unregister: () => {}
|
|
55
88
|
};
|
|
56
89
|
}
|
|
@@ -59,9 +92,9 @@ function registerRequire(platform, {
|
|
|
59
92
|
unregister
|
|
60
93
|
} = (0, import_node.register)({
|
|
61
94
|
hookIgnoreNodeModules: false,
|
|
62
|
-
// don't transform @
|
|
95
|
+
// don't transform @hanzogui packages - they have pre-built dist files
|
|
63
96
|
hookMatcher: filename => {
|
|
64
|
-
if (filename.includes("@
|
|
97
|
+
if (filename.includes("@hanzogui") || /\/hanzogui\/code\/(core|ui|packages)\//.test(filename)) {
|
|
65
98
|
return false;
|
|
66
99
|
}
|
|
67
100
|
return true;
|
|
@@ -78,13 +111,17 @@ function registerRequire(platform, {
|
|
|
78
111
|
og = Module.prototype.require;
|
|
79
112
|
}
|
|
80
113
|
isRegistered = true;
|
|
81
|
-
Module.prototype.require =
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
|
|
114
|
+
Module.prototype.require = hanzoguiRequire;
|
|
115
|
+
function hanzoguiRequire(path) {
|
|
116
|
+
const staticExtractionStub = getStaticExtractionStub(path);
|
|
117
|
+
if (staticExtractionStub) {
|
|
118
|
+
return staticExtractionStub;
|
|
119
|
+
}
|
|
120
|
+
if (path === "hanzogui" && platform === "native") {
|
|
121
|
+
return og.apply(this, ["hanzogui/native"]);
|
|
85
122
|
}
|
|
86
123
|
if (path === "@hanzogui/core") {
|
|
87
|
-
return (0,
|
|
124
|
+
return (0, import_requireHanzoguiCore.requireHanzoguiCore)(platform, path2 => {
|
|
88
125
|
return og.apply(this, [path2]);
|
|
89
126
|
});
|
|
90
127
|
}
|
|
@@ -108,10 +145,11 @@ function registerRequire(platform, {
|
|
|
108
145
|
}
|
|
109
146
|
}
|
|
110
147
|
if (!whitelisted[path]) {
|
|
111
|
-
if (proxyWormImports && !path.includes(".
|
|
148
|
+
if (proxyWormImports && !path.includes(".hanzogui-dynamic-eval")) {
|
|
112
149
|
const callerFile = this?.filename || this?.id || "";
|
|
113
|
-
const
|
|
114
|
-
|
|
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) {
|
|
115
153
|
return og.apply(this, [path]);
|
|
116
154
|
}
|
|
117
155
|
return proxyWorm;
|
|
@@ -121,24 +159,24 @@ function registerRequire(platform, {
|
|
|
121
159
|
const out = og.apply(this, arguments);
|
|
122
160
|
return out;
|
|
123
161
|
} catch (err) {
|
|
124
|
-
if (!process.env.
|
|
162
|
+
if (!process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD && path.includes("hanzogui-dynamic-eval")) {
|
|
125
163
|
return;
|
|
126
164
|
}
|
|
127
|
-
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) {
|
|
128
166
|
if (hasWarnedForModules.has(path)) {} else {
|
|
129
167
|
hasWarnedForModules.add(path);
|
|
130
168
|
}
|
|
131
169
|
} else {
|
|
132
|
-
console.warn(` [
|
|
170
|
+
console.warn(` [hanzogui] skipped "${path}" (set TAMAGUI_IGNORE_BUNDLE_ERRORS="${path}" to silence)`);
|
|
133
171
|
}
|
|
134
172
|
return proxyWorm;
|
|
135
173
|
}
|
|
136
174
|
}
|
|
137
175
|
return {
|
|
138
|
-
|
|
176
|
+
hanzoguiRequire,
|
|
139
177
|
unregister: () => {
|
|
140
178
|
if (hasWarnedForModules.size) {
|
|
141
|
-
console.info(` [
|
|
179
|
+
console.info(` [hanzogui] skipped loading ${hasWarnedForModules.size} module, see: https://hanzogui.dev/docs/intro/errors#warning-001`);
|
|
142
180
|
hasWarnedForModules.clear();
|
|
143
181
|
}
|
|
144
182
|
unregister();
|
|
@@ -147,15 +185,15 @@ function registerRequire(platform, {
|
|
|
147
185
|
}
|
|
148
186
|
};
|
|
149
187
|
}
|
|
150
|
-
const IGNORES = process.env.
|
|
151
|
-
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(",");
|
|
152
190
|
const knownIgnorableModules = {
|
|
153
191
|
"@gorhom/bottom-sheet": true,
|
|
154
192
|
"expo-modules": true,
|
|
155
193
|
solito: true,
|
|
156
194
|
"expo-linear-gradient": true,
|
|
157
195
|
"@expo/vector-icons": true,
|
|
158
|
-
"
|
|
196
|
+
"hanzogui/linear-gradient": true,
|
|
159
197
|
// animation libraries not needed for static extraction
|
|
160
198
|
"@emotion/is-prop-valid": true,
|
|
161
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,10 +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
|
-
import {
|
|
7
|
+
import { hasTopLevelAwait } from './hasTopLevelAwait'
|
|
8
|
+
import { resolveWebOrNativeSpecificEntry } from './loadHanzogui'
|
|
8
9
|
import { TsconfigPathsPlugin } from './esbuildTsconfigPaths'
|
|
9
10
|
|
|
10
11
|
export const esbuildLoaderConfig = {
|
|
@@ -53,10 +54,10 @@ type Props = Omit<Partial<esbuild.BuildOptions>, 'entryPoints'> & {
|
|
|
53
54
|
|
|
54
55
|
function getESBuildConfig(
|
|
55
56
|
{ entryPoints, resolvePlatformSpecificEntries, ...options }: Props,
|
|
56
|
-
platform:
|
|
57
|
+
platform: HanzoguiPlatform,
|
|
57
58
|
aliases?: Record<string, string>
|
|
58
59
|
) {
|
|
59
|
-
if (process.env.DEBUG?.startsWith('
|
|
60
|
+
if (process.env.DEBUG?.startsWith('hanzogui')) {
|
|
60
61
|
console.info(`Building`, entryPoints)
|
|
61
62
|
}
|
|
62
63
|
|
|
@@ -86,7 +87,7 @@ function getESBuildConfig(
|
|
|
86
87
|
allowOverwrite: true,
|
|
87
88
|
keepNames: true,
|
|
88
89
|
resolveExtensions: [
|
|
89
|
-
...(process.env.
|
|
90
|
+
...(process.env.TAMAGUI_TARGET === 'web'
|
|
90
91
|
? ['.web.tsx', '.web.ts', '.web.jsx', '.web.js']
|
|
91
92
|
: ['.native.tsx', '.native.ts', '.native.jsx', '.native.js']),
|
|
92
93
|
'.tsx',
|
|
@@ -120,7 +121,7 @@ function getESBuildConfig(
|
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
// skip most node_modules
|
|
123
|
-
if (args.path.includes('node_modules') && !args.path.includes('@
|
|
124
|
+
if (args.path.includes('node_modules') && !args.path.includes('@hanzogui')) {
|
|
124
125
|
return null
|
|
125
126
|
}
|
|
126
127
|
|
|
@@ -146,17 +147,14 @@ function getESBuildConfig(
|
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
// stub files with top-level await - they're typically runtime-only
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
) {
|
|
153
|
-
if (process.env.DEBUG?.startsWith('@hanzo/gui')) {
|
|
154
|
-
console.info(
|
|
155
|
-
`[hanzo-gui] stubbing file with top-level await: ${args.path}`
|
|
156
|
-
)
|
|
150
|
+
if (hasTopLevelAwait(contents, args.path)) {
|
|
151
|
+
if (process.env.DEBUG?.startsWith('hanzogui')) {
|
|
152
|
+
console.info(`[hanzogui] stubbing file with top-level await: ${args.path}`)
|
|
157
153
|
}
|
|
158
154
|
return {
|
|
159
|
-
|
|
155
|
+
// Keep this as an ESM-shaped stub so esbuild doesn't inline a
|
|
156
|
+
// top-level `module.exports = {}` into the parent bundle.
|
|
157
|
+
contents: `// stubbed - contains top-level await\nexport default {}`,
|
|
160
158
|
loader: 'js',
|
|
161
159
|
}
|
|
162
160
|
}
|
|
@@ -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)
|