@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
|
@@ -56,8 +56,8 @@ var import_getGuiConfigPathFromOptionsConfig = require("./getGuiConfigPathFromOp
|
|
|
56
56
|
var import_regenerateConfig = require("./regenerateConfig.cjs");
|
|
57
57
|
const getFilledOptions = propsIn => ({
|
|
58
58
|
platform: "web",
|
|
59
|
-
config: "
|
|
60
|
-
components: ["
|
|
59
|
+
config: "hanzogui.config.ts",
|
|
60
|
+
components: ["hanzogui"],
|
|
61
61
|
...propsIn
|
|
62
62
|
});
|
|
63
63
|
let isLoadingPromise;
|
|
@@ -73,17 +73,17 @@ async function loadGui(propsIn) {
|
|
|
73
73
|
const props = getFilledOptions(propsIn);
|
|
74
74
|
const bundleInfo = await (0, import_bundleConfig.getBundledConfig)(props);
|
|
75
75
|
if (!bundleInfo) {
|
|
76
|
-
console.warn(`No bundled config generated, maybe an error in bundling. Set DEBUG=
|
|
76
|
+
console.warn(`No bundled config generated, maybe an error in bundling. Set DEBUG=hanzogui and re-run to get logs.`);
|
|
77
77
|
resolvePromise(null);
|
|
78
78
|
return null;
|
|
79
79
|
}
|
|
80
80
|
await generateThemesAndLog(props);
|
|
81
|
-
const maybeGuiConfig = bundleInfo.
|
|
81
|
+
const maybeGuiConfig = bundleInfo.hanzoguiConfig;
|
|
82
82
|
if (maybeGuiConfig && !maybeGuiConfig.parsed) {
|
|
83
83
|
const {
|
|
84
84
|
createGui
|
|
85
85
|
} = (0, import_requireGuiCore.requireGuiCore)(props.platform || "web");
|
|
86
|
-
bundleInfo.
|
|
86
|
+
bundleInfo.hanzoguiConfig = createGui(bundleInfo.hanzoguiConfig);
|
|
87
87
|
}
|
|
88
88
|
if (!(0, import_bundleConfig.hasBundledConfigChanged)()) {
|
|
89
89
|
resolvePromise(bundleInfo);
|
|
@@ -107,7 +107,7 @@ const generateThemesAndLog = async (options, force = false) => {
|
|
|
107
107
|
waiting = true;
|
|
108
108
|
await new Promise(res => setTimeout(res, 30));
|
|
109
109
|
if (await (0, import_regenerateConfig.generateGuiThemes)(options, force)) {
|
|
110
|
-
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [
|
|
110
|
+
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [hanzogui] generated themes: ${(0, import_node_path.relative)(process.cwd(), options.themeBuilder.output)}`);
|
|
111
111
|
if (options.outputCSS) {
|
|
112
112
|
const loadedConfig = (0, import_bundleConfig.getLoadedConfig)();
|
|
113
113
|
if (loadedConfig) await (0, import_bundleConfig.writeGuiCSS)(options.outputCSS, loadedConfig);
|
|
@@ -120,8 +120,8 @@ const generateThemesAndLog = async (options, force = false) => {
|
|
|
120
120
|
const last = {};
|
|
121
121
|
const lastVersion = {};
|
|
122
122
|
let esbuildWasmInitialized = false;
|
|
123
|
-
async function loadGuiBuildConfigAsync(
|
|
124
|
-
const buildFilePath =
|
|
123
|
+
async function loadGuiBuildConfigAsync(hanzoguiOptions) {
|
|
124
|
+
const buildFilePath = hanzoguiOptions?.buildFile ?? "./hanzogui.build.ts";
|
|
125
125
|
const absolutePath = buildFilePath[0] === "." ? (0, import_node_path.join)(process.cwd(), buildFilePath) : buildFilePath;
|
|
126
126
|
if (fsExtra.existsSync(absolutePath)) try {
|
|
127
127
|
const source = await fsExtra.readFile(absolutePath, "utf-8");
|
|
@@ -141,41 +141,46 @@ async function loadGuiBuildConfigAsync(guiOptions) {
|
|
|
141
141
|
new Function("module", "exports", "require", "process", result.code)(module2, module2.exports, require, process);
|
|
142
142
|
const out = module2.exports.default || module2.exports;
|
|
143
143
|
if (!out || typeof out !== "object") throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
144
|
-
|
|
145
|
-
...
|
|
144
|
+
hanzoguiOptions = {
|
|
145
|
+
...hanzoguiOptions,
|
|
146
146
|
...out
|
|
147
147
|
};
|
|
148
148
|
} catch (err) {
|
|
149
|
-
console.error(`[
|
|
149
|
+
console.error(`[hanzogui] Error loading ${buildFilePath}:`, err);
|
|
150
150
|
throw err;
|
|
151
|
+
} finally {
|
|
152
|
+
try {
|
|
153
|
+
esbuildWasm.stop();
|
|
154
|
+
esbuildWasmInitialized = false;
|
|
155
|
+
} catch {}
|
|
151
156
|
}
|
|
152
|
-
if (!
|
|
157
|
+
if (!hanzoguiOptions) throw new Error(`No hanzogui build options found either via input props or at hanzogui.build.ts`);
|
|
153
158
|
return {
|
|
154
|
-
config: "
|
|
155
|
-
components: ["
|
|
156
|
-
...
|
|
159
|
+
config: "hanzogui.config.ts",
|
|
160
|
+
components: ["hanzogui", "@hanzogui/core"],
|
|
161
|
+
...hanzoguiOptions
|
|
157
162
|
};
|
|
158
163
|
}
|
|
159
|
-
function loadGuiBuildConfigSync(
|
|
160
|
-
const buildFilePath =
|
|
164
|
+
function loadGuiBuildConfigSync(hanzoguiOptions) {
|
|
165
|
+
const buildFilePath = hanzoguiOptions?.buildFile ?? "./hanzogui.build.ts";
|
|
161
166
|
if (fsExtra.existsSync(buildFilePath)) {
|
|
162
167
|
const registered = (0, import_registerRequire.registerRequire)("web");
|
|
163
168
|
try {
|
|
164
169
|
const out = (buildFilePath[0] === "." ? require((0, import_node_path.join)(process.cwd(), buildFilePath)) : require(buildFilePath)).default;
|
|
165
170
|
if (!out) throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
166
|
-
|
|
167
|
-
...
|
|
171
|
+
hanzoguiOptions = {
|
|
172
|
+
...hanzoguiOptions,
|
|
168
173
|
...out
|
|
169
174
|
};
|
|
170
175
|
} finally {
|
|
171
176
|
registered.unregister();
|
|
172
177
|
}
|
|
173
178
|
}
|
|
174
|
-
if (!
|
|
179
|
+
if (!hanzoguiOptions) throw new Error(`No hanzogui build options found either via input props or at hanzogui.build.ts`);
|
|
175
180
|
return {
|
|
176
|
-
config: "
|
|
177
|
-
components: ["
|
|
178
|
-
...
|
|
181
|
+
config: "hanzogui.config.ts",
|
|
182
|
+
components: ["hanzogui", "@hanzogui/core"],
|
|
183
|
+
...hanzoguiOptions
|
|
179
184
|
};
|
|
180
185
|
}
|
|
181
186
|
function loadGuiSync({
|
|
@@ -200,40 +205,40 @@ function loadGuiSync({
|
|
|
200
205
|
const devValueOG = globalThis["__DEV__"];
|
|
201
206
|
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
202
207
|
try {
|
|
203
|
-
let
|
|
208
|
+
let hanzoguiConfig = null;
|
|
204
209
|
if (propsIn.config) {
|
|
205
210
|
const configPath = (0, import_getGuiConfigPathFromOptionsConfig.getGuiConfigPathFromOptionsConfig)(propsIn.config);
|
|
206
211
|
const exp = require(configPath);
|
|
207
212
|
if (!exp || exp._isProxyWorm) throw new Error(`Got a empty / proxied config!`);
|
|
208
|
-
|
|
209
|
-
if (!
|
|
213
|
+
hanzoguiConfig = exp["default"] || exp["config"] || exp;
|
|
214
|
+
if (!hanzoguiConfig || !hanzoguiConfig.parsed) {
|
|
210
215
|
const confPath = require.resolve(configPath);
|
|
211
216
|
throw new Error(`Can't find valid config in ${confPath}:
|
|
212
217
|
|
|
213
218
|
Be sure you "export default" or "export const config" the config.`);
|
|
214
219
|
}
|
|
215
|
-
if (
|
|
220
|
+
if (hanzoguiConfig) {
|
|
216
221
|
const {
|
|
217
222
|
createGui
|
|
218
223
|
} = (0, import_requireGuiCore.requireGuiCore)(props.platform || "web");
|
|
219
|
-
createGui(
|
|
224
|
+
createGui(hanzoguiConfig);
|
|
220
225
|
}
|
|
221
226
|
}
|
|
222
227
|
const components = (0, import_bundleConfig.loadComponentsSync)(props, forceExports);
|
|
223
228
|
if (!components) throw new Error(`No components loaded`);
|
|
224
|
-
if (process.env.DEBUG === "
|
|
229
|
+
if (process.env.DEBUG === "hanzogui") console.info(`components`, components);
|
|
225
230
|
process.env.IS_STATIC = void 0;
|
|
226
231
|
globalThis["__DEV__"] = devValueOG;
|
|
227
232
|
const info = {
|
|
228
233
|
components,
|
|
229
|
-
|
|
234
|
+
hanzoguiConfig,
|
|
230
235
|
nameToPaths: (0, import_registerRequire.getNameToPaths)()
|
|
231
236
|
};
|
|
232
|
-
if (
|
|
237
|
+
if (hanzoguiConfig) {
|
|
233
238
|
const {
|
|
234
239
|
outputCSS
|
|
235
240
|
} = props;
|
|
236
|
-
if (outputCSS) (0, import_bundleConfig.writeGuiCSS)(outputCSS,
|
|
241
|
+
if (outputCSS) (0, import_bundleConfig.writeGuiCSS)(outputCSS, hanzoguiConfig);
|
|
237
242
|
(0, import_regenerateConfig.regenerateConfigSync)(props, info);
|
|
238
243
|
}
|
|
239
244
|
last[key] = {
|
|
@@ -244,17 +249,17 @@ function loadGuiSync({
|
|
|
244
249
|
} catch (err) {
|
|
245
250
|
if (err instanceof Error) {
|
|
246
251
|
if (!import_constants.SHOULD_DEBUG && !forceExports) {
|
|
247
|
-
console.warn(`Error loading
|
|
252
|
+
console.warn(`Error loading hanzogui.config.ts (set DEBUG=hanzogui to see full stack), running hanzogui without custom config`);
|
|
248
253
|
console.info(`
|
|
249
254
|
|
|
250
255
|
${err.message}
|
|
251
256
|
|
|
252
257
|
`);
|
|
253
258
|
} else if (import_constants.SHOULD_DEBUG) console.error(err);
|
|
254
|
-
} else console.error(`Error loading
|
|
259
|
+
} else console.error(`Error loading hanzogui.config.ts`, err);
|
|
255
260
|
return {
|
|
256
261
|
components: [],
|
|
257
|
-
|
|
262
|
+
hanzoguiConfig: null,
|
|
258
263
|
nameToPaths: {}
|
|
259
264
|
};
|
|
260
265
|
}
|
|
@@ -265,11 +270,11 @@ function loadGuiSync({
|
|
|
265
270
|
async function getOptions({
|
|
266
271
|
root = process.cwd(),
|
|
267
272
|
tsconfigPath = "tsconfig.json",
|
|
268
|
-
|
|
273
|
+
hanzoguiOptions,
|
|
269
274
|
host,
|
|
270
275
|
debug
|
|
271
276
|
} = {}) {
|
|
272
|
-
const dotDir = (0, import_node_path.join)(root, ".
|
|
277
|
+
const dotDir = (0, import_node_path.join)(root, ".hanzogui");
|
|
273
278
|
let pkgJson = {};
|
|
274
279
|
try {
|
|
275
280
|
pkgJson = await fsExtra.readJSON((0, import_node_path.join)(root, "package.json"));
|
|
@@ -281,39 +286,40 @@ async function getOptions({
|
|
|
281
286
|
pkgJson,
|
|
282
287
|
debug,
|
|
283
288
|
tsconfigPath,
|
|
284
|
-
|
|
289
|
+
hanzoguiOptions: {
|
|
285
290
|
platform: "web",
|
|
286
|
-
components: ["
|
|
287
|
-
...
|
|
288
|
-
config:
|
|
291
|
+
components: ["hanzogui"],
|
|
292
|
+
...hanzoguiOptions,
|
|
293
|
+
config: hanzoguiOptions?.config ?? (await getDefaultGuiConfigPath(root, hanzoguiOptions?.config))
|
|
289
294
|
},
|
|
290
295
|
paths: {
|
|
291
296
|
root,
|
|
292
297
|
dotDir,
|
|
293
|
-
conf: (0, import_node_path.join)(dotDir, "
|
|
298
|
+
conf: (0, import_node_path.join)(dotDir, "hanzogui.config.json"),
|
|
294
299
|
types: (0, import_node_path.join)(dotDir, "types.json")
|
|
295
300
|
}
|
|
296
301
|
};
|
|
297
302
|
}
|
|
298
|
-
function resolveWebOrNativeSpecificEntry(entry) {
|
|
303
|
+
function resolveWebOrNativeSpecificEntry(entry, platform) {
|
|
299
304
|
const workspaceRoot = (0, import_node_path.resolve)();
|
|
300
305
|
const resolved = require.resolve(entry, {
|
|
301
306
|
paths: [workspaceRoot]
|
|
302
307
|
});
|
|
303
308
|
const ext = (0, import_node_path.extname)(resolved);
|
|
304
309
|
const fileName = (0, import_node_path.basename)(resolved).replace(ext, "");
|
|
305
|
-
const
|
|
310
|
+
const specificExt = (platform || "web") === "web" ? "web" : "native";
|
|
311
|
+
const specificFile = (0, import_node_path.join)((0, import_node_path.dirname)(resolved), fileName + "." + specificExt + ext);
|
|
306
312
|
if (fsExtra.existsSync(specificFile)) return specificFile;
|
|
307
313
|
return entry;
|
|
308
314
|
}
|
|
309
|
-
const defaultPaths = ["
|
|
315
|
+
const defaultPaths = ["hanzogui.config.ts", (0, import_node_path.join)("src", "hanzogui.config.ts")];
|
|
310
316
|
let hasWarnedOnce = false;
|
|
311
317
|
async function getDefaultGuiConfigPath(root, configPath) {
|
|
312
318
|
const searchPaths = [...new Set([configPath, ...defaultPaths].filter(Boolean).map(p => (0, import_node_path.join)(root, p)))];
|
|
313
319
|
for (const path of searchPaths) if (await fsExtra.pathExists(path)) return path;
|
|
314
320
|
if (!hasWarnedOnce) {
|
|
315
321
|
hasWarnedOnce = true;
|
|
316
|
-
console.warn(`Warning: couldn't find
|
|
322
|
+
console.warn(`Warning: couldn't find hanzogui.config.ts in the following paths given configuration "${configPath}":
|
|
317
323
|
${searchPaths.join(`
|
|
318
324
|
`)}
|
|
319
325
|
`);
|
|
@@ -43,43 +43,43 @@ var import_generate_themes = require("@hanzogui/generate-themes");
|
|
|
43
43
|
var FS = __toESM(require("fs-extra"));
|
|
44
44
|
var import_requireGuiCore = require("../helpers/requireGuiCore.cjs");
|
|
45
45
|
var import_bundleConfig = require("./bundleConfig.cjs");
|
|
46
|
-
const
|
|
47
|
-
const confFile = (0, import_node_path.join)(
|
|
48
|
-
async function regenerateConfig(
|
|
46
|
+
const hanzoguiDir = (0, import_node_path.join)(process.cwd(), ".hanzogui");
|
|
47
|
+
const confFile = (0, import_node_path.join)(hanzoguiDir, "hanzogui.config.json");
|
|
48
|
+
async function regenerateConfig(hanzoguiOptions, configIn, rebuild = false) {
|
|
49
49
|
try {
|
|
50
|
-
const config = configIn ?? (await (0, import_bundleConfig.getBundledConfig)(
|
|
50
|
+
const config = configIn ?? (await (0, import_bundleConfig.getBundledConfig)(hanzoguiOptions, rebuild));
|
|
51
51
|
if (!config) return;
|
|
52
|
-
const out = transformConfig(config,
|
|
52
|
+
const out = transformConfig(config, hanzoguiOptions.platform || "web");
|
|
53
53
|
await FS.ensureDir((0, import_node_path.dirname)(confFile));
|
|
54
54
|
await FS.writeJSON(confFile, out, {
|
|
55
55
|
spaces: 2
|
|
56
56
|
});
|
|
57
57
|
} catch (err) {
|
|
58
|
-
if (process.env.DEBUG?.includes("
|
|
58
|
+
if (process.env.DEBUG?.includes("hanzogui") || process.env.IS_GUI_DEV) {
|
|
59
59
|
console.warn("regenerateConfig error", err);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
function regenerateConfigSync(
|
|
63
|
+
function regenerateConfigSync(_hanzoguiOptions, config) {
|
|
64
64
|
try {
|
|
65
65
|
FS.ensureDirSync((0, import_node_path.dirname)(confFile));
|
|
66
|
-
FS.writeJSONSync(confFile, transformConfig(config,
|
|
66
|
+
FS.writeJSONSync(confFile, transformConfig(config, _hanzoguiOptions.platform || "web"), {
|
|
67
67
|
spaces: 2
|
|
68
68
|
});
|
|
69
69
|
} catch (err) {
|
|
70
|
-
if (process.env.DEBUG?.includes("
|
|
70
|
+
if (process.env.DEBUG?.includes("hanzogui") || process.env.IS_GUI_DEV) {
|
|
71
71
|
console.warn("regenerateConfig error", err);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
async function generateGuiThemes(
|
|
76
|
-
if (!
|
|
75
|
+
async function generateGuiThemes(hanzoguiOptions, force = false) {
|
|
76
|
+
if (!hanzoguiOptions.themeBuilder) {
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
const {
|
|
80
80
|
input,
|
|
81
81
|
output
|
|
82
|
-
} =
|
|
82
|
+
} = hanzoguiOptions.themeBuilder;
|
|
83
83
|
const inPath = resolveRelativePath(input);
|
|
84
84
|
const outPath = resolveRelativePath(output);
|
|
85
85
|
const generatedOutput = await (0, import_generate_themes.generateThemes)(inPath);
|
|
@@ -93,7 +93,7 @@ async function generateGuiThemes(guiOptions, force = false) {
|
|
|
93
93
|
return true;
|
|
94
94
|
})());
|
|
95
95
|
if (hasChanged) {
|
|
96
|
-
await (0, import_generate_themes.writeGeneratedThemes)(
|
|
96
|
+
await (0, import_generate_themes.writeGeneratedThemes)(hanzoguiDir, outPath, generatedOutput);
|
|
97
97
|
}
|
|
98
98
|
return hasChanged;
|
|
99
99
|
}
|
|
@@ -119,12 +119,12 @@ function transformConfig(config, platform) {
|
|
|
119
119
|
const {
|
|
120
120
|
components,
|
|
121
121
|
nameToPaths,
|
|
122
|
-
|
|
122
|
+
hanzoguiConfig
|
|
123
123
|
} = next;
|
|
124
124
|
const {
|
|
125
125
|
themes,
|
|
126
126
|
tokens
|
|
127
|
-
} =
|
|
127
|
+
} = hanzoguiConfig;
|
|
128
128
|
for (const key in themes) {
|
|
129
129
|
const theme = themes[key];
|
|
130
130
|
theme.id = key;
|
|
@@ -165,11 +165,11 @@ function transformConfig(config, platform) {
|
|
|
165
165
|
shorthands: _shorthands,
|
|
166
166
|
userShorthands,
|
|
167
167
|
...cleanedConfig
|
|
168
|
-
} = next.
|
|
168
|
+
} = next.hanzoguiConfig;
|
|
169
169
|
return {
|
|
170
170
|
components,
|
|
171
171
|
nameToPaths,
|
|
172
|
-
|
|
172
|
+
hanzoguiConfig: {
|
|
173
173
|
...cleanedConfig,
|
|
174
174
|
// Output userShorthands as shorthands (excludes built-ins)
|
|
175
175
|
shorthands: userShorthands
|
|
@@ -28,8 +28,8 @@ module.exports = __toCommonJS(watchGuiConfig_exports);
|
|
|
28
28
|
var import_loadGui = require("./loadGui.cjs");
|
|
29
29
|
var import_regenerateConfig = require("./regenerateConfig.cjs");
|
|
30
30
|
let isWatching = false;
|
|
31
|
-
async function watchGuiConfig(
|
|
32
|
-
if (process.env.NODE_ENV === "production") {
|
|
31
|
+
async function watchGuiConfig(hanzoguiOptions) {
|
|
32
|
+
if (process.env.NODE_ENV === "production" || hanzoguiOptions.disable) {
|
|
33
33
|
return {
|
|
34
34
|
dispose() {}
|
|
35
35
|
};
|
|
@@ -39,17 +39,17 @@ async function watchGuiConfig(guiOptions) {
|
|
|
39
39
|
}
|
|
40
40
|
isWatching = true;
|
|
41
41
|
const options = await (0, import_loadGui.getOptions)({
|
|
42
|
-
|
|
42
|
+
hanzoguiOptions
|
|
43
43
|
});
|
|
44
|
-
if (!options.
|
|
44
|
+
if (!options.hanzoguiOptions.config) {
|
|
45
45
|
isWatching = false;
|
|
46
46
|
throw new Error(`No config`);
|
|
47
47
|
}
|
|
48
|
-
const disposeConfigWatcher = await (0, import_loadGui.esbuildWatchFiles)(options.
|
|
49
|
-
await (0, import_loadGui.generateThemesAndLog)(options.
|
|
50
|
-
await (0, import_regenerateConfig.regenerateConfig)(options.
|
|
48
|
+
const disposeConfigWatcher = await (0, import_loadGui.esbuildWatchFiles)(options.hanzoguiOptions.config, async () => {
|
|
49
|
+
await (0, import_loadGui.generateThemesAndLog)(options.hanzoguiOptions);
|
|
50
|
+
await (0, import_regenerateConfig.regenerateConfig)(options.hanzoguiOptions, null, true);
|
|
51
51
|
});
|
|
52
|
-
const themeBuilderInput = options.
|
|
52
|
+
const themeBuilderInput = options.hanzoguiOptions.themeBuilder?.input;
|
|
53
53
|
let disposeThemesWatcher;
|
|
54
54
|
if (themeBuilderInput) {
|
|
55
55
|
let inputPath = themeBuilderInput;
|
|
@@ -57,7 +57,7 @@ async function watchGuiConfig(guiOptions) {
|
|
|
57
57
|
inputPath = require.resolve(themeBuilderInput);
|
|
58
58
|
} catch {}
|
|
59
59
|
disposeThemesWatcher = await (0, import_loadGui.esbuildWatchFiles)(inputPath, async () => {
|
|
60
|
-
await (0, import_loadGui.generateThemesAndLog)(options.
|
|
60
|
+
await (0, import_loadGui.generateThemesAndLog)(options.hanzoguiOptions);
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
return {
|
|
@@ -38,14 +38,14 @@ function getPragmaOptions({
|
|
|
38
38
|
if (trimmed && !trimmed.startsWith("//") && !trimmed.startsWith("/*")) {
|
|
39
39
|
break;
|
|
40
40
|
}
|
|
41
|
-
pragma = trimmed.match(/(\/\/|\/\*)\s?!?\s?(
|
|
41
|
+
pragma = trimmed.match(/(\/\/|\/\*)\s?!?\s?(hanzogui-ignore|debug|debug-verbose)(\n|\s|$).*/)?.[2].trim() || "";
|
|
42
42
|
if (pragma) {
|
|
43
43
|
pragma = pragma.replace("!", "").trim();
|
|
44
44
|
break;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
switch (pragma) {
|
|
48
|
-
case "
|
|
48
|
+
case "hanzogui-ignore":
|
|
49
49
|
shouldDisable = true;
|
|
50
50
|
break;
|
|
51
51
|
case "debug":
|
|
@@ -60,10 +60,10 @@ function getPragmaOptions({
|
|
|
60
60
|
shouldPrintDebug = "verbose";
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
if (process.env.DEBUG?.includes("
|
|
63
|
+
if (process.env.DEBUG?.includes("hanzogui")) {
|
|
64
64
|
shouldPrintDebug ||= true;
|
|
65
65
|
}
|
|
66
|
-
if (process.env.DEBUG?.includes("
|
|
66
|
+
if (process.env.DEBUG?.includes("hanzogui-verbose")) {
|
|
67
67
|
shouldPrintDebug = "verbose";
|
|
68
68
|
}
|
|
69
69
|
return {
|
package/dist/registerRequire.cjs
CHANGED
|
@@ -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
|
}
|
|
@@ -94,7 +94,7 @@ function registerRequire(platform, {
|
|
|
94
94
|
hookIgnoreNodeModules: false,
|
|
95
95
|
// don't transform @hanzogui packages - they have pre-built dist files
|
|
96
96
|
hookMatcher: filename => {
|
|
97
|
-
if (filename.includes("@hanzogui") || /\/
|
|
97
|
+
if (filename.includes("@hanzogui") || /\/hanzogui\/code\/(core|ui|packages)\//.test(filename)) {
|
|
98
98
|
return false;
|
|
99
99
|
}
|
|
100
100
|
return true;
|
|
@@ -111,14 +111,14 @@ 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
124
|
return (0, import_requireGuiCore.requireGuiCore)(platform, path2 => {
|
|
@@ -137,7 +137,7 @@ function registerRequire(platform, {
|
|
|
137
137
|
if (path === "react-native/package.json") {
|
|
138
138
|
return og.apply(this, ["react-native-web/package.json"]);
|
|
139
139
|
}
|
|
140
|
-
if (path === "@hanzogui/react-native-web-lite" || path === "react-native" || path.startsWith("react-native/")) {
|
|
140
|
+
if (path === "@hanzogui/react-native-web-lite" || path === "react-native" || path.startsWith("react-native/") || path === "react-native-web" || path.startsWith("react-native-web/")) {
|
|
141
141
|
try {
|
|
142
142
|
return og.apply("react-native");
|
|
143
143
|
} catch {
|
|
@@ -145,11 +145,12 @@ 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 isFromGuiPkg = callerFile.includes("@hanzogui") || callerFile.includes("node_modules/
|
|
151
|
-
const isFromStaticLoader = !callerFile || callerFile === "." || callerFile === "[eval]" || callerFile.endsWith("/[eval]") || callerFile.includes("/
|
|
152
|
-
|
|
150
|
+
const isFromGuiPkg = callerFile.includes("@hanzogui") || callerFile.includes("node_modules/hanzogui/") || /\/hanzogui\/code\/(core|ui|packages)\//.test(callerFile);
|
|
151
|
+
const isFromStaticLoader = !callerFile || callerFile === "." || callerFile === "[eval]" || callerFile.endsWith("/[eval]") || callerFile.includes("/pkgs/compiler/static/") || callerFile.includes("/.hanzogui/");
|
|
152
|
+
const isRelativeFromWhitelisted = path.startsWith(".") && Object.keys(whitelisted).some(pkg => callerFile.includes(`/node_modules/${pkg}/`));
|
|
153
|
+
if (path === "hanzogui" || path.startsWith("@hanzogui/") || isRelativeFromWhitelisted || isFromGuiPkg || isFromStaticLoader) {
|
|
153
154
|
return og.apply(this, [path]);
|
|
154
155
|
}
|
|
155
156
|
return proxyWorm;
|
|
@@ -159,7 +160,7 @@ function registerRequire(platform, {
|
|
|
159
160
|
const out = og.apply(this, arguments);
|
|
160
161
|
return out;
|
|
161
162
|
} catch (err) {
|
|
162
|
-
if (!process.env.GUI_ENABLE_WARN_DYNAMIC_LOAD && path.includes("
|
|
163
|
+
if (!process.env.GUI_ENABLE_WARN_DYNAMIC_LOAD && path.includes("hanzogui-dynamic-eval")) {
|
|
163
164
|
return;
|
|
164
165
|
}
|
|
165
166
|
if (allowedIgnores[path] || IGNORES === "true") {} else if (!process.env.GUI_SHOW_FULL_BUNDLE_ERRORS && !process.env.DEBUG) {
|
|
@@ -167,16 +168,16 @@ function registerRequire(platform, {
|
|
|
167
168
|
hasWarnedForModules.add(path);
|
|
168
169
|
}
|
|
169
170
|
} else {
|
|
170
|
-
console.warn(` [
|
|
171
|
+
console.warn(` [hanzogui] skipped "${path}" (set GUI_IGNORE_BUNDLE_ERRORS="${path}" to silence)`);
|
|
171
172
|
}
|
|
172
173
|
return proxyWorm;
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
return {
|
|
176
|
-
|
|
177
|
+
hanzoguiRequire,
|
|
177
178
|
unregister: () => {
|
|
178
179
|
if (hasWarnedForModules.size) {
|
|
179
|
-
console.info(` [
|
|
180
|
+
console.info(` [hanzogui] skipped loading ${hasWarnedForModules.size} module, see: https://hanzogui.dev/docs/intro/errors#warning-001`);
|
|
180
181
|
hasWarnedForModules.clear();
|
|
181
182
|
}
|
|
182
183
|
unregister();
|
|
@@ -193,7 +194,7 @@ const knownIgnorableModules = {
|
|
|
193
194
|
solito: true,
|
|
194
195
|
"expo-linear-gradient": true,
|
|
195
196
|
"@expo/vector-icons": true,
|
|
196
|
-
"
|
|
197
|
+
"hanzogui/linear-gradient": true,
|
|
197
198
|
// animation libraries not needed for static extraction
|
|
198
199
|
"@emotion/is-prop-valid": true,
|
|
199
200
|
"framer-motion": true,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzogui/static",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "MIT",
|
|
6
6
|
"source": "src/index.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"src",
|
|
@@ -35,10 +35,10 @@
|
|
|
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": "8.0.0",
|
|
54
|
+
"@hanzogui/config-default": "8.0.0",
|
|
55
|
+
"@hanzogui/core": "8.0.0",
|
|
56
|
+
"@hanzogui/fake-react-native": "8.0.0",
|
|
57
|
+
"@hanzogui/generate-themes": "8.0.0",
|
|
58
|
+
"@hanzogui/helpers": "8.0.0",
|
|
59
|
+
"@hanzogui/helpers-node": "8.0.0",
|
|
60
|
+
"@hanzogui/proxy-worm": "8.0.0",
|
|
61
|
+
"@hanzogui/react-native-web-internals": "8.0.0",
|
|
62
|
+
"@hanzogui/react-native-web-lite": "8.0.0",
|
|
63
|
+
"@hanzogui/shorthands": "8.0.0",
|
|
64
|
+
"@hanzogui/types": "8.0.0",
|
|
65
|
+
"@hanzogui/web": "8.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": "8.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",
|
|
@@ -92,16 +92,9 @@
|
|
|
92
92
|
"typescript": "~5.9.2"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"react": ">=19"
|
|
96
|
-
"react-native": "*"
|
|
95
|
+
"react": ">=19"
|
|
97
96
|
},
|
|
98
97
|
"tests": {
|
|
99
98
|
"parallel": true
|
|
100
|
-
},
|
|
101
|
-
"author": "Hanzo AI <dev@hanzo.ai>",
|
|
102
|
-
"peerDependenciesMeta": {
|
|
103
|
-
"react-native": {
|
|
104
|
-
"optional": true
|
|
105
|
-
}
|
|
106
99
|
}
|
|
107
100
|
}
|
|
@@ -575,7 +575,7 @@ function check(path: string): {
|
|
|
575
575
|
dependencies: Dependencies
|
|
576
576
|
} {
|
|
577
577
|
const options: Options = {
|
|
578
|
-
includeDepPattern: ['
|
|
578
|
+
includeDepPattern: ['hanzogui', 'react-native-web-lite', 'react-native-web-internals'],
|
|
579
579
|
}
|
|
580
580
|
|
|
581
581
|
if (
|