@hanzogui/static 7.0.0 → 7.3.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/LICENSE +40 -19
- 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 +6 -6
- package/dist/extractor/bundleConfig.cjs +45 -45
- 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/{getHanzoguiConfigPathFromOptionsConfig.cjs → getGuiConfigPathFromOptionsConfig.cjs} +5 -5
- package/dist/extractor/getPrefixLogs.cjs +1 -1
- package/dist/extractor/getStaticBindingsForScope.cjs +2 -2
- package/dist/extractor/{loadHanzogui.cjs → loadGui.cjs} +65 -65
- package/dist/extractor/regenerateConfig.cjs +20 -20
- package/dist/extractor/{watchHanzoguiConfig.cjs → watchGuiConfig.cjs} +15 -15
- package/dist/getPragmaOptions.cjs +6 -6
- package/dist/helpers/{requireHanzoguiCore.cjs → requireGuiCore.cjs} +12 -12
- package/dist/registerRequire.cjs +20 -20
- package/dist/worker.cjs +3 -3
- package/package.json +25 -24
- package/src/check-dep-versions.ts +1 -1
- package/src/checkDeps.ts +27 -27
- package/src/constants.ts +2 -2
- package/src/exports.ts +2 -2
- package/src/extractor/bundle.ts +9 -9
- package/src/extractor/bundleConfig.ts +56 -56
- package/src/extractor/createEvaluator.ts +2 -2
- package/src/extractor/createExtractor.ts +55 -55
- package/src/extractor/createLogger.ts +3 -3
- package/src/extractor/extractHelpers.ts +12 -12
- package/src/extractor/extractMediaStyle.ts +13 -13
- package/src/extractor/extractToClassNames.ts +11 -11
- package/src/extractor/extractToNative.ts +13 -13
- package/src/extractor/{getHanzoguiConfigPathFromOptionsConfig.ts → getGuiConfigPathFromOptionsConfig.ts} +3 -3
- package/src/extractor/getPrefixLogs.ts +3 -3
- package/src/extractor/getStaticBindingsForScope.ts +2 -2
- package/src/extractor/{loadHanzogui.ts → loadGui.ts} +85 -85
- package/src/extractor/regenerateConfig.ts +23 -23
- package/src/extractor/{watchHanzoguiConfig.ts → watchGuiConfig.ts} +10 -10
- package/src/getPragmaOptions.ts +6 -6
- package/src/helpers/requireGuiCore.ts +28 -0
- package/src/registerRequire.ts +27 -27
- package/src/server.ts +2 -2
- package/src/types.ts +10 -10
- package/src/worker.ts +7 -7
- 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/getGuiConfigPathFromOptionsConfig.d.ts +3 -0
- package/types/extractor/getGuiConfigPathFromOptionsConfig.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/loadGui.d.ts +22 -0
- package/types/extractor/loadGui.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/watchGuiConfig.d.ts +5 -0
- package/types/extractor/watchGuiConfig.d.ts.map +1 -0
- package/types/helpers/requireGuiCore.d.ts +3 -0
- package/types/helpers/requireGuiCore.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/requireHanzoguiCore.ts +0 -28
- package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts +0 -3
- package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts.map +0 -1
- package/types/extractor/loadHanzogui.d.ts +0 -22
- package/types/extractor/loadHanzogui.d.ts.map +0 -1
- package/types/extractor/watchHanzoguiConfig.d.ts +0 -5
- package/types/extractor/watchHanzoguiConfig.d.ts.map +0 -1
- package/types/helpers/requireHanzoguiCore.d.ts +0 -3
- package/types/helpers/requireHanzoguiCore.d.ts.map +0 -1
|
@@ -31,37 +31,37 @@ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
|
31
31
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
32
|
value: true
|
|
33
33
|
}), mod);
|
|
34
|
-
var
|
|
35
|
-
__export(
|
|
34
|
+
var loadGui_exports = {};
|
|
35
|
+
__export(loadGui_exports, {
|
|
36
36
|
esbuildWatchFiles: () => esbuildWatchFiles,
|
|
37
37
|
generateThemesAndLog: () => generateThemesAndLog,
|
|
38
38
|
getOptions: () => getOptions,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
loadGui: () => loadGui,
|
|
40
|
+
loadGuiBuildConfigAsync: () => loadGuiBuildConfigAsync,
|
|
41
|
+
loadGuiBuildConfigSync: () => loadGuiBuildConfigSync,
|
|
42
|
+
loadGuiSync: () => loadGuiSync,
|
|
43
43
|
resolveWebOrNativeSpecificEntry: () => resolveWebOrNativeSpecificEntry
|
|
44
44
|
});
|
|
45
|
-
module.exports = __toCommonJS(
|
|
45
|
+
module.exports = __toCommonJS(loadGui_exports);
|
|
46
46
|
var import_node_path = require("node:path");
|
|
47
47
|
var import_cli_color = require("@hanzogui/cli-color");
|
|
48
48
|
var import_esbuild = __toESM(require("esbuild"));
|
|
49
49
|
var esbuildWasm = __toESM(require("esbuild-wasm"));
|
|
50
50
|
var fsExtra = __toESM(require("fs-extra"));
|
|
51
51
|
var import_constants = require("../constants.cjs");
|
|
52
|
-
var
|
|
52
|
+
var import_requireGuiCore = require("../helpers/requireGuiCore.cjs");
|
|
53
53
|
var import_registerRequire = require("../registerRequire.cjs");
|
|
54
54
|
var import_bundleConfig = require("./bundleConfig.cjs");
|
|
55
|
-
var
|
|
55
|
+
var import_getGuiConfigPathFromOptionsConfig = require("./getGuiConfigPathFromOptionsConfig.cjs");
|
|
56
56
|
var import_regenerateConfig = require("./regenerateConfig.cjs");
|
|
57
57
|
const getFilledOptions = propsIn => ({
|
|
58
58
|
platform: "web",
|
|
59
|
-
config: "
|
|
60
|
-
components: ["
|
|
59
|
+
config: "gui.config.ts",
|
|
60
|
+
components: ["gui"],
|
|
61
61
|
...propsIn
|
|
62
62
|
});
|
|
63
63
|
let isLoadingPromise;
|
|
64
|
-
async function
|
|
64
|
+
async function loadGui(propsIn) {
|
|
65
65
|
if (isLoadingPromise) return await isLoadingPromise;
|
|
66
66
|
let resolvePromise;
|
|
67
67
|
let rejectPromise;
|
|
@@ -73,17 +73,17 @@ async function loadHanzogui(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=gui and re-run to get logs.`);
|
|
77
77
|
resolvePromise(null);
|
|
78
78
|
return null;
|
|
79
79
|
}
|
|
80
80
|
await generateThemesAndLog(props);
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
81
|
+
const maybeGuiConfig = bundleInfo.guiConfig;
|
|
82
|
+
if (maybeGuiConfig && !maybeGuiConfig.parsed) {
|
|
83
83
|
const {
|
|
84
|
-
|
|
85
|
-
} = (0,
|
|
86
|
-
bundleInfo.
|
|
84
|
+
createGui
|
|
85
|
+
} = (0, import_requireGuiCore.requireGuiCore)(props.platform || "web");
|
|
86
|
+
bundleInfo.guiConfig = createGui(bundleInfo.guiConfig);
|
|
87
87
|
}
|
|
88
88
|
if (!(0, import_bundleConfig.hasBundledConfigChanged)()) {
|
|
89
89
|
resolvePromise(bundleInfo);
|
|
@@ -106,11 +106,11 @@ const generateThemesAndLog = async (options, force = false) => {
|
|
|
106
106
|
try {
|
|
107
107
|
waiting = true;
|
|
108
108
|
await new Promise(res => setTimeout(res, 30));
|
|
109
|
-
if (await (0, import_regenerateConfig.
|
|
110
|
-
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [
|
|
109
|
+
if (await (0, import_regenerateConfig.generateGuiThemes)(options, force)) {
|
|
110
|
+
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [gui] 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
|
-
if (loadedConfig) await (0, import_bundleConfig.
|
|
113
|
+
if (loadedConfig) await (0, import_bundleConfig.writeGuiCSS)(options.outputCSS, loadedConfig);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
} finally {
|
|
@@ -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
|
|
124
|
-
const buildFilePath =
|
|
123
|
+
async function loadGuiBuildConfigAsync(guiOptions) {
|
|
124
|
+
const buildFilePath = guiOptions?.buildFile ?? "./gui.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,44 +141,44 @@ async function loadHanzoguiBuildConfigAsync(hanzoguiOptions) {
|
|
|
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
|
+
guiOptions = {
|
|
145
|
+
...guiOptions,
|
|
146
146
|
...out
|
|
147
147
|
};
|
|
148
148
|
} catch (err) {
|
|
149
|
-
console.error(`[
|
|
149
|
+
console.error(`[gui] Error loading ${buildFilePath}:`, err);
|
|
150
150
|
throw err;
|
|
151
151
|
}
|
|
152
|
-
if (!
|
|
152
|
+
if (!guiOptions) throw new Error(`No gui build options found either via input props or at gui.build.ts`);
|
|
153
153
|
return {
|
|
154
|
-
config: "
|
|
155
|
-
components: ["
|
|
156
|
-
...
|
|
154
|
+
config: "gui.config.ts",
|
|
155
|
+
components: ["gui", "@hanzogui/core"],
|
|
156
|
+
...guiOptions
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
const buildFilePath =
|
|
159
|
+
function loadGuiBuildConfigSync(guiOptions) {
|
|
160
|
+
const buildFilePath = guiOptions?.buildFile ?? "./gui.build.ts";
|
|
161
161
|
if (fsExtra.existsSync(buildFilePath)) {
|
|
162
162
|
const registered = (0, import_registerRequire.registerRequire)("web");
|
|
163
163
|
try {
|
|
164
164
|
const out = (buildFilePath[0] === "." ? require((0, import_node_path.join)(process.cwd(), buildFilePath)) : require(buildFilePath)).default;
|
|
165
165
|
if (!out) throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
166
|
-
|
|
167
|
-
...
|
|
166
|
+
guiOptions = {
|
|
167
|
+
...guiOptions,
|
|
168
168
|
...out
|
|
169
169
|
};
|
|
170
170
|
} finally {
|
|
171
171
|
registered.unregister();
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
if (!
|
|
174
|
+
if (!guiOptions) throw new Error(`No gui build options found either via input props or at gui.build.ts`);
|
|
175
175
|
return {
|
|
176
|
-
config: "
|
|
177
|
-
components: ["
|
|
178
|
-
...
|
|
176
|
+
config: "gui.config.ts",
|
|
177
|
+
components: ["gui", "@hanzogui/core"],
|
|
178
|
+
...guiOptions
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function loadGuiSync({
|
|
182
182
|
forceExports,
|
|
183
183
|
cacheKey,
|
|
184
184
|
...propsIn
|
|
@@ -190,7 +190,7 @@ function loadHanzoguiSync({
|
|
|
190
190
|
lastVersion[key] = cacheKey || "";
|
|
191
191
|
const props = getFilledOptions(propsIn);
|
|
192
192
|
process.env.IS_STATIC = "is_static";
|
|
193
|
-
process.env.
|
|
193
|
+
process.env.GUI_IS_SERVER = "true";
|
|
194
194
|
const {
|
|
195
195
|
unregister
|
|
196
196
|
} = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
@@ -200,40 +200,40 @@ function loadHanzoguiSync({
|
|
|
200
200
|
const devValueOG = globalThis["__DEV__"];
|
|
201
201
|
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
202
202
|
try {
|
|
203
|
-
let
|
|
203
|
+
let guiConfig = null;
|
|
204
204
|
if (propsIn.config) {
|
|
205
|
-
const configPath = (0,
|
|
205
|
+
const configPath = (0, import_getGuiConfigPathFromOptionsConfig.getGuiConfigPathFromOptionsConfig)(propsIn.config);
|
|
206
206
|
const exp = require(configPath);
|
|
207
207
|
if (!exp || exp._isProxyWorm) throw new Error(`Got a empty / proxied config!`);
|
|
208
|
-
|
|
209
|
-
if (!
|
|
208
|
+
guiConfig = exp["default"] || exp["config"] || exp;
|
|
209
|
+
if (!guiConfig || !guiConfig.parsed) {
|
|
210
210
|
const confPath = require.resolve(configPath);
|
|
211
211
|
throw new Error(`Can't find valid config in ${confPath}:
|
|
212
212
|
|
|
213
213
|
Be sure you "export default" or "export const config" the config.`);
|
|
214
214
|
}
|
|
215
|
-
if (
|
|
215
|
+
if (guiConfig) {
|
|
216
216
|
const {
|
|
217
|
-
|
|
218
|
-
} = (0,
|
|
219
|
-
|
|
217
|
+
createGui
|
|
218
|
+
} = (0, import_requireGuiCore.requireGuiCore)(props.platform || "web");
|
|
219
|
+
createGui(guiConfig);
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
const components = (0, import_bundleConfig.loadComponentsSync)(props, forceExports);
|
|
223
223
|
if (!components) throw new Error(`No components loaded`);
|
|
224
|
-
if (process.env.DEBUG === "
|
|
224
|
+
if (process.env.DEBUG === "gui") console.info(`components`, components);
|
|
225
225
|
process.env.IS_STATIC = void 0;
|
|
226
226
|
globalThis["__DEV__"] = devValueOG;
|
|
227
227
|
const info = {
|
|
228
228
|
components,
|
|
229
|
-
|
|
229
|
+
guiConfig,
|
|
230
230
|
nameToPaths: (0, import_registerRequire.getNameToPaths)()
|
|
231
231
|
};
|
|
232
|
-
if (
|
|
232
|
+
if (guiConfig) {
|
|
233
233
|
const {
|
|
234
234
|
outputCSS
|
|
235
235
|
} = props;
|
|
236
|
-
if (outputCSS) (0, import_bundleConfig.
|
|
236
|
+
if (outputCSS) (0, import_bundleConfig.writeGuiCSS)(outputCSS, guiConfig);
|
|
237
237
|
(0, import_regenerateConfig.regenerateConfigSync)(props, info);
|
|
238
238
|
}
|
|
239
239
|
last[key] = {
|
|
@@ -244,17 +244,17 @@ function loadHanzoguiSync({
|
|
|
244
244
|
} catch (err) {
|
|
245
245
|
if (err instanceof Error) {
|
|
246
246
|
if (!import_constants.SHOULD_DEBUG && !forceExports) {
|
|
247
|
-
console.warn(`Error loading
|
|
247
|
+
console.warn(`Error loading gui.config.ts (set DEBUG=gui to see full stack), running gui without custom config`);
|
|
248
248
|
console.info(`
|
|
249
249
|
|
|
250
250
|
${err.message}
|
|
251
251
|
|
|
252
252
|
`);
|
|
253
253
|
} else if (import_constants.SHOULD_DEBUG) console.error(err);
|
|
254
|
-
} else console.error(`Error loading
|
|
254
|
+
} else console.error(`Error loading gui.config.ts`, err);
|
|
255
255
|
return {
|
|
256
256
|
components: [],
|
|
257
|
-
|
|
257
|
+
guiConfig: null,
|
|
258
258
|
nameToPaths: {}
|
|
259
259
|
};
|
|
260
260
|
}
|
|
@@ -265,11 +265,11 @@ function loadHanzoguiSync({
|
|
|
265
265
|
async function getOptions({
|
|
266
266
|
root = process.cwd(),
|
|
267
267
|
tsconfigPath = "tsconfig.json",
|
|
268
|
-
|
|
268
|
+
guiOptions,
|
|
269
269
|
host,
|
|
270
270
|
debug
|
|
271
271
|
} = {}) {
|
|
272
|
-
const dotDir = (0, import_node_path.join)(root, ".
|
|
272
|
+
const dotDir = (0, import_node_path.join)(root, ".gui");
|
|
273
273
|
let pkgJson = {};
|
|
274
274
|
try {
|
|
275
275
|
pkgJson = await fsExtra.readJSON((0, import_node_path.join)(root, "package.json"));
|
|
@@ -281,16 +281,16 @@ async function getOptions({
|
|
|
281
281
|
pkgJson,
|
|
282
282
|
debug,
|
|
283
283
|
tsconfigPath,
|
|
284
|
-
|
|
284
|
+
guiOptions: {
|
|
285
285
|
platform: "web",
|
|
286
|
-
components: ["
|
|
287
|
-
...
|
|
288
|
-
config:
|
|
286
|
+
components: ["gui"],
|
|
287
|
+
...guiOptions,
|
|
288
|
+
config: guiOptions?.config ?? (await getDefaultGuiConfigPath(root, guiOptions?.config))
|
|
289
289
|
},
|
|
290
290
|
paths: {
|
|
291
291
|
root,
|
|
292
292
|
dotDir,
|
|
293
|
-
conf: (0, import_node_path.join)(dotDir, "
|
|
293
|
+
conf: (0, import_node_path.join)(dotDir, "gui.config.json"),
|
|
294
294
|
types: (0, import_node_path.join)(dotDir, "types.json")
|
|
295
295
|
}
|
|
296
296
|
};
|
|
@@ -306,14 +306,14 @@ function resolveWebOrNativeSpecificEntry(entry) {
|
|
|
306
306
|
if (fsExtra.existsSync(specificFile)) return specificFile;
|
|
307
307
|
return entry;
|
|
308
308
|
}
|
|
309
|
-
const defaultPaths = ["
|
|
309
|
+
const defaultPaths = ["gui.config.ts", (0, import_node_path.join)("src", "gui.config.ts")];
|
|
310
310
|
let hasWarnedOnce = false;
|
|
311
|
-
async function
|
|
311
|
+
async function getDefaultGuiConfigPath(root, configPath) {
|
|
312
312
|
const searchPaths = [...new Set([configPath, ...defaultPaths].filter(Boolean).map(p => (0, import_node_path.join)(root, p)))];
|
|
313
313
|
for (const path of searchPaths) if (await fsExtra.pathExists(path)) return path;
|
|
314
314
|
if (!hasWarnedOnce) {
|
|
315
315
|
hasWarnedOnce = true;
|
|
316
|
-
console.warn(`Warning: couldn't find
|
|
316
|
+
console.warn(`Warning: couldn't find gui.config.ts in the following paths given configuration "${configPath}":
|
|
317
317
|
${searchPaths.join(`
|
|
318
318
|
`)}
|
|
319
319
|
`);
|
|
@@ -33,7 +33,7 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
33
33
|
}), mod);
|
|
34
34
|
var regenerateConfig_exports = {};
|
|
35
35
|
__export(regenerateConfig_exports, {
|
|
36
|
-
|
|
36
|
+
generateGuiThemes: () => generateGuiThemes,
|
|
37
37
|
regenerateConfig: () => regenerateConfig,
|
|
38
38
|
regenerateConfigSync: () => regenerateConfigSync
|
|
39
39
|
});
|
|
@@ -41,45 +41,45 @@ module.exports = __toCommonJS(regenerateConfig_exports);
|
|
|
41
41
|
var import_node_path = require("node:path");
|
|
42
42
|
var import_generate_themes = require("@hanzogui/generate-themes");
|
|
43
43
|
var FS = __toESM(require("fs-extra"));
|
|
44
|
-
var
|
|
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 guiDir = (0, import_node_path.join)(process.cwd(), ".gui");
|
|
47
|
+
const confFile = (0, import_node_path.join)(guiDir, "gui.config.json");
|
|
48
|
+
async function regenerateConfig(guiOptions, configIn, rebuild = false) {
|
|
49
49
|
try {
|
|
50
|
-
const config = configIn ?? (await (0, import_bundleConfig.getBundledConfig)(
|
|
50
|
+
const config = configIn ?? (await (0, import_bundleConfig.getBundledConfig)(guiOptions, rebuild));
|
|
51
51
|
if (!config) return;
|
|
52
|
-
const out = transformConfig(config,
|
|
52
|
+
const out = transformConfig(config, guiOptions.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("gui") || process.env.IS_GUI_DEV) {
|
|
59
59
|
console.warn("regenerateConfig error", err);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
function regenerateConfigSync(
|
|
63
|
+
function regenerateConfigSync(_guiOptions, 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, _guiOptions.platform || "web"), {
|
|
67
67
|
spaces: 2
|
|
68
68
|
});
|
|
69
69
|
} catch (err) {
|
|
70
|
-
if (process.env.DEBUG?.includes("
|
|
70
|
+
if (process.env.DEBUG?.includes("gui") || process.env.IS_GUI_DEV) {
|
|
71
71
|
console.warn("regenerateConfig error", err);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
async function
|
|
76
|
-
if (!
|
|
75
|
+
async function generateGuiThemes(guiOptions, force = false) {
|
|
76
|
+
if (!guiOptions.themeBuilder) {
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
79
|
const {
|
|
80
80
|
input,
|
|
81
81
|
output
|
|
82
|
-
} =
|
|
82
|
+
} = guiOptions.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 generateHanzoguiThemes(hanzoguiOptions, 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)(guiDir, outPath, generatedOutput);
|
|
97
97
|
}
|
|
98
98
|
return hasChanged;
|
|
99
99
|
}
|
|
@@ -112,19 +112,19 @@ function transformConfig(config, platform) {
|
|
|
112
112
|
}
|
|
113
113
|
const {
|
|
114
114
|
getVariableValue
|
|
115
|
-
} = (0,
|
|
115
|
+
} = (0, import_requireGuiCore.requireGuiCore)(platform);
|
|
116
116
|
const next = cloneDeepSafe(config, {
|
|
117
117
|
validStyles: true
|
|
118
118
|
});
|
|
119
119
|
const {
|
|
120
120
|
components,
|
|
121
121
|
nameToPaths,
|
|
122
|
-
|
|
122
|
+
guiConfig
|
|
123
123
|
} = next;
|
|
124
124
|
const {
|
|
125
125
|
themes,
|
|
126
126
|
tokens
|
|
127
|
-
} =
|
|
127
|
+
} = guiConfig;
|
|
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.guiConfig;
|
|
169
169
|
return {
|
|
170
170
|
components,
|
|
171
171
|
nameToPaths,
|
|
172
|
-
|
|
172
|
+
guiConfig: {
|
|
173
173
|
...cleanedConfig,
|
|
174
174
|
// Output userShorthands as shorthands (excludes built-ins)
|
|
175
175
|
shorthands: userShorthands
|
|
@@ -20,15 +20,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
21
|
value: true
|
|
22
22
|
}), mod);
|
|
23
|
-
var
|
|
24
|
-
__export(
|
|
25
|
-
|
|
23
|
+
var watchGuiConfig_exports = {};
|
|
24
|
+
__export(watchGuiConfig_exports, {
|
|
25
|
+
watchGuiConfig: () => watchGuiConfig
|
|
26
26
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
28
|
-
var
|
|
27
|
+
module.exports = __toCommonJS(watchGuiConfig_exports);
|
|
28
|
+
var import_loadGui = require("./loadGui.cjs");
|
|
29
29
|
var import_regenerateConfig = require("./regenerateConfig.cjs");
|
|
30
30
|
let isWatching = false;
|
|
31
|
-
async function
|
|
31
|
+
async function watchGuiConfig(guiOptions) {
|
|
32
32
|
if (process.env.NODE_ENV === "production") {
|
|
33
33
|
return {
|
|
34
34
|
dispose() {}
|
|
@@ -38,26 +38,26 @@ async function watchHanzoguiConfig(hanzoguiOptions) {
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
isWatching = true;
|
|
41
|
-
const options = await (0,
|
|
42
|
-
|
|
41
|
+
const options = await (0, import_loadGui.getOptions)({
|
|
42
|
+
guiOptions
|
|
43
43
|
});
|
|
44
|
-
if (!options.
|
|
44
|
+
if (!options.guiOptions.config) {
|
|
45
45
|
isWatching = false;
|
|
46
46
|
throw new Error(`No config`);
|
|
47
47
|
}
|
|
48
|
-
const disposeConfigWatcher = await (0,
|
|
49
|
-
await (0,
|
|
50
|
-
await (0, import_regenerateConfig.regenerateConfig)(options.
|
|
48
|
+
const disposeConfigWatcher = await (0, import_loadGui.esbuildWatchFiles)(options.guiOptions.config, async () => {
|
|
49
|
+
await (0, import_loadGui.generateThemesAndLog)(options.guiOptions);
|
|
50
|
+
await (0, import_regenerateConfig.regenerateConfig)(options.guiOptions, null, true);
|
|
51
51
|
});
|
|
52
|
-
const themeBuilderInput = options.
|
|
52
|
+
const themeBuilderInput = options.guiOptions.themeBuilder?.input;
|
|
53
53
|
let disposeThemesWatcher;
|
|
54
54
|
if (themeBuilderInput) {
|
|
55
55
|
let inputPath = themeBuilderInput;
|
|
56
56
|
try {
|
|
57
57
|
inputPath = require.resolve(themeBuilderInput);
|
|
58
58
|
} catch {}
|
|
59
|
-
disposeThemesWatcher = await (0,
|
|
60
|
-
await (0,
|
|
59
|
+
disposeThemesWatcher = await (0, import_loadGui.esbuildWatchFiles)(inputPath, async () => {
|
|
60
|
+
await (0, import_loadGui.generateThemesAndLog)(options.guiOptions);
|
|
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?(gui-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 "gui-ignore":
|
|
49
49
|
shouldDisable = true;
|
|
50
50
|
break;
|
|
51
51
|
case "debug":
|
|
@@ -55,15 +55,15 @@ function getPragmaOptions({
|
|
|
55
55
|
shouldPrintDebug = "verbose";
|
|
56
56
|
break;
|
|
57
57
|
}
|
|
58
|
-
if (process.env.
|
|
59
|
-
if (path.includes(process.env.
|
|
58
|
+
if (process.env.GUI_DEBUG_FILE) {
|
|
59
|
+
if (path.includes(process.env.GUI_DEBUG_FILE)) {
|
|
60
60
|
shouldPrintDebug = "verbose";
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
if (process.env.DEBUG?.includes("
|
|
63
|
+
if (process.env.DEBUG?.includes("gui")) {
|
|
64
64
|
shouldPrintDebug ||= true;
|
|
65
65
|
}
|
|
66
|
-
if (process.env.DEBUG?.includes("
|
|
66
|
+
if (process.env.DEBUG?.includes("gui-verbose")) {
|
|
67
67
|
shouldPrintDebug = "verbose";
|
|
68
68
|
}
|
|
69
69
|
return {
|
|
@@ -20,21 +20,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
20
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
21
|
value: true
|
|
22
22
|
}), mod);
|
|
23
|
-
var
|
|
24
|
-
__export(
|
|
25
|
-
|
|
23
|
+
var requireGuiCore_exports = {};
|
|
24
|
+
__export(requireGuiCore_exports, {
|
|
25
|
+
requireGuiCore: () => requireGuiCore
|
|
26
26
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
28
|
-
function
|
|
27
|
+
module.exports = __toCommonJS(requireGuiCore_exports);
|
|
28
|
+
function requireGuiCore(platform, ogRequire = require) {
|
|
29
29
|
if (!platform) {
|
|
30
|
-
throw new Error(`No platform given to
|
|
30
|
+
throw new Error(`No platform given to requireGuiCore`);
|
|
31
31
|
}
|
|
32
|
-
const og1 = process.env.
|
|
33
|
-
const og2 = process.env.
|
|
34
|
-
process.env.
|
|
35
|
-
process.env.
|
|
32
|
+
const og1 = process.env.GUI_IS_SERVER;
|
|
33
|
+
const og2 = process.env.GUI_KEEP_THEMES;
|
|
34
|
+
process.env.GUI_IS_SERVER ||= "1";
|
|
35
|
+
process.env.GUI_KEEP_THEMES ||= "1";
|
|
36
36
|
const exported = ogRequire(platform === "native" ? "@hanzogui/core/native" : "@hanzogui/core");
|
|
37
|
-
process.env.
|
|
38
|
-
process.env.
|
|
37
|
+
process.env.GUI_IS_SERVER = og1;
|
|
38
|
+
process.env.GUI_KEEP_THEMES = og2;
|
|
39
39
|
return exported;
|
|
40
40
|
}
|
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_requireGuiCore = require("./helpers/requireGuiCore.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
|
+
guiRequire: 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") || /\/gui\/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 = guiRequire;
|
|
115
|
+
function guiRequire(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 === "gui" && platform === "native") {
|
|
121
|
+
return og.apply(this, ["gui/native"]);
|
|
122
122
|
}
|
|
123
123
|
if (path === "@hanzogui/core") {
|
|
124
|
-
return (0,
|
|
124
|
+
return (0, import_requireGuiCore.requireGuiCore)(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(".gui-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 isFromGuiPkg = callerFile.includes("@hanzogui") || callerFile.includes("node_modules/gui/");
|
|
151
|
+
const isFromStaticLoader = !callerFile || callerFile === "." || callerFile === "[eval]" || callerFile.endsWith("/[eval]") || callerFile.includes("/code/compiler/static/") || callerFile.includes("/.gui/");
|
|
152
|
+
if (path === "gui" || path.startsWith("@hanzogui/") || isFromGuiPkg || 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.GUI_ENABLE_WARN_DYNAMIC_LOAD && path.includes("gui-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.GUI_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(` [gui] skipped "${path}" (set GUI_IGNORE_BUNDLE_ERRORS="${path}" to silence)`);
|
|
171
171
|
}
|
|
172
172
|
return proxyWorm;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
return {
|
|
176
|
-
|
|
176
|
+
guiRequire,
|
|
177
177
|
unregister: () => {
|
|
178
178
|
if (hasWarnedForModules.size) {
|
|
179
|
-
console.info(` [
|
|
179
|
+
console.info(` [gui] skipped loading ${hasWarnedForModules.size} module, see: https://gui.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" ? [] : process.env.
|
|
188
|
+
const IGNORES = process.env.GUI_IGNORE_BUNDLE_ERRORS;
|
|
189
|
+
const extraIgnores = IGNORES === "true" ? [] : process.env.GUI_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
|
+
"gui/linear-gradient": true,
|
|
197
197
|
// animation libraries not needed for static extraction
|
|
198
198
|
"@emotion/is-prop-valid": true,
|
|
199
199
|
"framer-motion": true,
|