@hanzogui/static 4.4.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/check-dep-versions.cjs +1 -1
- package/dist/checkDeps.cjs +11 -11
- package/dist/constants.cjs +2 -2
- package/dist/exports.cjs +2 -2
- package/dist/extractor/bundle.cjs +20 -39
- package/dist/extractor/bundleConfig.cjs +46 -46
- package/dist/extractor/createExtractor.cjs +39 -39
- package/dist/extractor/createLogger.cjs +1 -1
- package/dist/extractor/extractHelpers.cjs +1 -1
- package/dist/extractor/extractMediaStyle.cjs +7 -7
- package/dist/extractor/extractToClassNames.cjs +9 -9
- package/dist/extractor/extractToNative.cjs +7 -7
- package/dist/extractor/{getGuiConfigPathFromOptionsConfig.cjs → getHanzoguiConfigPathFromOptionsConfig.cjs} +5 -5
- package/dist/extractor/getPrefixLogs.cjs +1 -1
- package/dist/extractor/getStaticBindingsForScope.cjs +2 -2
- package/dist/extractor/{loadGui.cjs → loadHanzogui.cjs} +97 -141
- package/dist/extractor/regenerateConfig.cjs +20 -20
- package/dist/extractor/{watchGuiConfig.cjs → watchHanzoguiConfig.cjs} +15 -15
- package/dist/getPragmaOptions.cjs +6 -6
- package/dist/helpers/{requireGuiCore.cjs → requireHanzoguiCore.cjs} +12 -12
- package/dist/registerRequire.cjs +21 -21
- package/dist/worker.cjs +3 -3
- package/package.json +22 -22
- package/src/check-dep-versions.ts +1 -5
- package/src/checkDeps.ts +28 -30
- package/src/constants.ts +2 -2
- package/src/exports.ts +2 -2
- package/src/extractor/bundle.ts +11 -13
- package/src/extractor/bundleConfig.ts +57 -57
- package/src/extractor/createEvaluator.ts +2 -2
- package/src/extractor/createExtractor.ts +62 -55
- package/src/extractor/createLogger.ts +5 -3
- package/src/extractor/esbuildTsconfigPaths.ts +1 -1
- package/src/extractor/extractHelpers.ts +15 -12
- package/src/extractor/extractMediaStyle.ts +19 -13
- package/src/extractor/extractToClassNames.ts +11 -11
- package/src/extractor/extractToNative.ts +13 -13
- package/src/extractor/{getGuiConfigPathFromOptionsConfig.ts → getHanzoguiConfigPathFromOptionsConfig.ts} +3 -3
- package/src/extractor/getPrefixLogs.ts +3 -3
- package/src/extractor/getStaticBindingsForScope.ts +2 -2
- package/src/extractor/{loadGui.ts → loadHanzogui.ts} +86 -83
- package/src/extractor/regenerateConfig.ts +34 -24
- package/src/extractor/{watchGuiConfig.ts → watchHanzoguiConfig.ts} +10 -10
- package/src/getPragmaOptions.ts +6 -6
- package/src/helpers/requireHanzoguiCore.ts +28 -0
- package/src/registerRequire.ts +34 -36
- package/src/server.ts +2 -2
- package/src/types.ts +13 -10
- package/src/worker.ts +7 -7
- package/types/check-dep-versions.d.ts.map +1 -1
- package/types/checkDeps.d.ts.map +1 -1
- package/types/constants.d.ts.map +1 -1
- package/types/exports.d.ts +2 -2
- package/types/exports.d.ts.map +1 -1
- package/types/extractor/bundle.d.ts +2 -2
- package/types/extractor/bundle.d.ts.map +1 -1
- package/types/extractor/bundleConfig.d.ts +12 -12
- package/types/extractor/bundleConfig.d.ts.map +1 -1
- package/types/extractor/createEvaluator.d.ts +2 -2
- package/types/extractor/createEvaluator.d.ts.map +1 -1
- package/types/extractor/createExtractor.d.ts +5 -5
- package/types/extractor/createExtractor.d.ts.map +1 -1
- package/types/extractor/createLogger.d.ts +2 -2
- package/types/extractor/createLogger.d.ts.map +1 -1
- package/types/extractor/extractHelpers.d.ts +8 -8
- package/types/extractor/extractHelpers.d.ts.map +1 -1
- package/types/extractor/extractMediaStyle.d.ts +4 -4
- package/types/extractor/extractMediaStyle.d.ts.map +1 -1
- package/types/extractor/extractToClassNames.d.ts +2 -2
- package/types/extractor/extractToClassNames.d.ts.map +1 -1
- package/types/extractor/extractToNative.d.ts +3 -3
- package/types/extractor/extractToNative.d.ts.map +1 -1
- package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts +3 -0
- package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts.map +1 -0
- package/types/extractor/getPrefixLogs.d.ts +2 -2
- package/types/extractor/getPrefixLogs.d.ts.map +1 -1
- package/types/extractor/loadHanzogui.d.ts +22 -0
- package/types/extractor/loadHanzogui.d.ts.map +1 -0
- package/types/extractor/regenerateConfig.d.ts +4 -4
- package/types/extractor/regenerateConfig.d.ts.map +1 -1
- package/types/extractor/watchHanzoguiConfig.d.ts +5 -0
- package/types/extractor/watchHanzoguiConfig.d.ts.map +1 -0
- package/types/helpers/requireHanzoguiCore.d.ts +3 -0
- package/types/helpers/requireHanzoguiCore.d.ts.map +1 -0
- package/types/registerRequire.d.ts +3 -3
- package/types/registerRequire.d.ts.map +1 -1
- package/types/server.d.ts +2 -2
- package/types/server.d.ts.map +1 -1
- package/types/types.d.ts +10 -10
- package/types/types.d.ts.map +1 -1
- package/types/worker.d.ts +4 -4
- package/types/worker.d.ts.map +1 -1
- package/src/helpers/requireGuiCore.ts +0 -28
- package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts +0 -3
- package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts.map +0 -1
- package/types/extractor/loadGui.d.ts +0 -22
- package/types/extractor/loadGui.d.ts.map +0 -1
- package/types/extractor/watchGuiConfig.d.ts +0 -5
- package/types/extractor/watchGuiConfig.d.ts.map +0 -1
- package/types/helpers/requireGuiCore.d.ts +0 -3
- package/types/helpers/requireGuiCore.d.ts.map +0 -1
|
@@ -31,38 +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 loadHanzogui_exports = {};
|
|
35
|
+
__export(loadHanzogui_exports, {
|
|
36
36
|
esbuildWatchFiles: () => esbuildWatchFiles,
|
|
37
37
|
generateThemesAndLog: () => generateThemesAndLog,
|
|
38
38
|
getOptions: () => getOptions,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
loadHanzogui: () => loadHanzogui,
|
|
40
|
+
loadHanzoguiBuildConfigAsync: () => loadHanzoguiBuildConfigAsync,
|
|
41
|
+
loadHanzoguiBuildConfigSync: () => loadHanzoguiBuildConfigSync,
|
|
42
|
+
loadHanzoguiSync: () => loadHanzoguiSync,
|
|
43
43
|
resolveWebOrNativeSpecificEntry: () => resolveWebOrNativeSpecificEntry
|
|
44
44
|
});
|
|
45
|
-
module.exports = __toCommonJS(
|
|
45
|
+
module.exports = __toCommonJS(loadHanzogui_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_requireHanzoguiCore = require("../helpers/requireHanzoguiCore.cjs");
|
|
53
53
|
var import_registerRequire = require("../registerRequire.cjs");
|
|
54
54
|
var import_bundleConfig = require("./bundleConfig.cjs");
|
|
55
|
-
var
|
|
55
|
+
var import_getHanzoguiConfigPathFromOptionsConfig = require("./getHanzoguiConfigPathFromOptionsConfig.cjs");
|
|
56
56
|
var import_regenerateConfig = require("./regenerateConfig.cjs");
|
|
57
57
|
const getFilledOptions = propsIn => ({
|
|
58
|
-
// defaults
|
|
59
58
|
platform: "web",
|
|
60
|
-
config: "
|
|
61
|
-
components: ["
|
|
59
|
+
config: "hanzogui.config.ts",
|
|
60
|
+
components: ["hanzogui"],
|
|
62
61
|
...propsIn
|
|
63
62
|
});
|
|
64
63
|
let isLoadingPromise;
|
|
65
|
-
async function
|
|
64
|
+
async function loadHanzogui(propsIn) {
|
|
66
65
|
if (isLoadingPromise) return await isLoadingPromise;
|
|
67
66
|
let resolvePromise;
|
|
68
67
|
let rejectPromise;
|
|
@@ -74,17 +73,17 @@ async function loadGui(propsIn) {
|
|
|
74
73
|
const props = getFilledOptions(propsIn);
|
|
75
74
|
const bundleInfo = await (0, import_bundleConfig.getBundledConfig)(props);
|
|
76
75
|
if (!bundleInfo) {
|
|
77
|
-
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.`);
|
|
78
77
|
resolvePromise(null);
|
|
79
78
|
return null;
|
|
80
79
|
}
|
|
81
80
|
await generateThemesAndLog(props);
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
81
|
+
const maybeHanzoguiConfig = bundleInfo.hanzoguiConfig;
|
|
82
|
+
if (maybeHanzoguiConfig && !maybeHanzoguiConfig.parsed) {
|
|
84
83
|
const {
|
|
85
|
-
|
|
86
|
-
} = (0,
|
|
87
|
-
bundleInfo.
|
|
84
|
+
createHanzogui
|
|
85
|
+
} = (0, import_requireHanzoguiCore.requireHanzoguiCore)(props.platform || "web");
|
|
86
|
+
bundleInfo.hanzoguiConfig = createHanzogui(bundleInfo.hanzoguiConfig);
|
|
88
87
|
}
|
|
89
88
|
if (!(0, import_bundleConfig.hasBundledConfigChanged)()) {
|
|
90
89
|
resolvePromise(bundleInfo);
|
|
@@ -107,15 +106,11 @@ const generateThemesAndLog = async (options, force = false) => {
|
|
|
107
106
|
try {
|
|
108
107
|
waiting = true;
|
|
109
108
|
await new Promise(res => setTimeout(res, 30));
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const whitespaceBefore = ` `;
|
|
113
|
-
(0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, `${whitespaceBefore}\u27A1 [hanzo-gui] generated themes: ${(0, import_node_path.relative)(process.cwd(), options.themeBuilder.output)}`);
|
|
109
|
+
if (await (0, import_regenerateConfig.generateHanzoguiThemes)(options, force)) {
|
|
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)}`);
|
|
114
111
|
if (options.outputCSS) {
|
|
115
112
|
const loadedConfig = (0, import_bundleConfig.getLoadedConfig)();
|
|
116
|
-
if (loadedConfig)
|
|
117
|
-
await (0, import_bundleConfig.writeGuiCSS)(options.outputCSS, loadedConfig);
|
|
118
|
-
}
|
|
113
|
+
if (loadedConfig) await (0, import_bundleConfig.writeHanzoguiCSS)(options.outputCSS, loadedConfig);
|
|
119
114
|
}
|
|
120
115
|
}
|
|
121
116
|
} finally {
|
|
@@ -125,90 +120,77 @@ const generateThemesAndLog = async (options, force = false) => {
|
|
|
125
120
|
const last = {};
|
|
126
121
|
const lastVersion = {};
|
|
127
122
|
let esbuildWasmInitialized = false;
|
|
128
|
-
async function
|
|
129
|
-
const buildFilePath =
|
|
123
|
+
async function loadHanzoguiBuildConfigAsync(hanzoguiOptions) {
|
|
124
|
+
const buildFilePath = hanzoguiOptions?.buildFile ?? "./hanzogui.build.ts";
|
|
130
125
|
const absolutePath = buildFilePath[0] === "." ? (0, import_node_path.join)(process.cwd(), buildFilePath) : buildFilePath;
|
|
131
|
-
if (fsExtra.existsSync(absolutePath)) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
esbuildWasmInitialized = true;
|
|
137
|
-
}
|
|
138
|
-
const result = await esbuildWasm.transform(source, {
|
|
139
|
-
loader: "ts",
|
|
140
|
-
format: "cjs",
|
|
141
|
-
target: "node18",
|
|
142
|
-
sourcefile: absolutePath
|
|
143
|
-
});
|
|
144
|
-
const module2 = {
|
|
145
|
-
exports: {}
|
|
146
|
-
};
|
|
147
|
-
const fn = new Function("module", "exports", "require", "process", result.code);
|
|
148
|
-
fn(module2, module2.exports, require, process);
|
|
149
|
-
const out = module2.exports.default || module2.exports;
|
|
150
|
-
if (!out || typeof out !== "object") {
|
|
151
|
-
throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
152
|
-
}
|
|
153
|
-
guiOptions = {
|
|
154
|
-
...guiOptions,
|
|
155
|
-
...out
|
|
156
|
-
};
|
|
157
|
-
} catch (err) {
|
|
158
|
-
console.error(`[hanzo-gui] Error loading ${buildFilePath}:`, err);
|
|
159
|
-
throw err;
|
|
126
|
+
if (fsExtra.existsSync(absolutePath)) try {
|
|
127
|
+
const source = await fsExtra.readFile(absolutePath, "utf-8");
|
|
128
|
+
if (!esbuildWasmInitialized) {
|
|
129
|
+
await esbuildWasm.initialize({});
|
|
130
|
+
esbuildWasmInitialized = true;
|
|
160
131
|
}
|
|
132
|
+
const result = await esbuildWasm.transform(source, {
|
|
133
|
+
loader: "ts",
|
|
134
|
+
format: "cjs",
|
|
135
|
+
target: "node18",
|
|
136
|
+
sourcefile: absolutePath
|
|
137
|
+
});
|
|
138
|
+
const module2 = {
|
|
139
|
+
exports: {}
|
|
140
|
+
};
|
|
141
|
+
new Function("module", "exports", "require", "process", result.code)(module2, module2.exports, require, process);
|
|
142
|
+
const out = module2.exports.default || module2.exports;
|
|
143
|
+
if (!out || typeof out !== "object") throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
144
|
+
hanzoguiOptions = {
|
|
145
|
+
...hanzoguiOptions,
|
|
146
|
+
...out
|
|
147
|
+
};
|
|
148
|
+
} catch (err) {
|
|
149
|
+
console.error(`[hanzogui] Error loading ${buildFilePath}:`, err);
|
|
150
|
+
throw err;
|
|
161
151
|
}
|
|
162
|
-
if (!
|
|
163
|
-
throw new Error(`No hanzo-gui build options found either via input props or at gui.build.ts`);
|
|
164
|
-
}
|
|
152
|
+
if (!hanzoguiOptions) throw new Error(`No hanzogui build options found either via input props or at hanzogui.build.ts`);
|
|
165
153
|
return {
|
|
166
|
-
config: "
|
|
167
|
-
components: ["
|
|
168
|
-
...
|
|
154
|
+
config: "hanzogui.config.ts",
|
|
155
|
+
components: ["hanzogui", "@hanzogui/core"],
|
|
156
|
+
...hanzoguiOptions
|
|
169
157
|
};
|
|
170
158
|
}
|
|
171
|
-
function
|
|
172
|
-
const buildFilePath =
|
|
159
|
+
function loadHanzoguiBuildConfigSync(hanzoguiOptions) {
|
|
160
|
+
const buildFilePath = hanzoguiOptions?.buildFile ?? "./hanzogui.build.ts";
|
|
173
161
|
if (fsExtra.existsSync(buildFilePath)) {
|
|
174
162
|
const registered = (0, import_registerRequire.registerRequire)("web");
|
|
175
163
|
try {
|
|
176
164
|
const out = (buildFilePath[0] === "." ? require((0, import_node_path.join)(process.cwd(), buildFilePath)) : require(buildFilePath)).default;
|
|
177
|
-
if (!out) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
guiOptions = {
|
|
181
|
-
...guiOptions,
|
|
165
|
+
if (!out) throw new Error(`No default export found in ${buildFilePath}: ${out}`);
|
|
166
|
+
hanzoguiOptions = {
|
|
167
|
+
...hanzoguiOptions,
|
|
182
168
|
...out
|
|
183
169
|
};
|
|
184
170
|
} finally {
|
|
185
171
|
registered.unregister();
|
|
186
172
|
}
|
|
187
173
|
}
|
|
188
|
-
if (!
|
|
189
|
-
throw new Error(`No hanzo-gui build options found either via input props or at gui.build.ts`);
|
|
190
|
-
}
|
|
174
|
+
if (!hanzoguiOptions) throw new Error(`No hanzogui build options found either via input props or at hanzogui.build.ts`);
|
|
191
175
|
return {
|
|
192
|
-
config: "
|
|
193
|
-
components: ["
|
|
194
|
-
...
|
|
176
|
+
config: "hanzogui.config.ts",
|
|
177
|
+
components: ["hanzogui", "@hanzogui/core"],
|
|
178
|
+
...hanzoguiOptions
|
|
195
179
|
};
|
|
196
180
|
}
|
|
197
|
-
function
|
|
181
|
+
function loadHanzoguiSync({
|
|
198
182
|
forceExports,
|
|
199
183
|
cacheKey,
|
|
200
184
|
...propsIn
|
|
201
185
|
}) {
|
|
202
186
|
const key = JSON.stringify(propsIn);
|
|
203
187
|
if (last[key] && !(0, import_bundleConfig.hasBundledConfigChanged)()) {
|
|
204
|
-
if (!lastVersion[key] || lastVersion[key] === cacheKey)
|
|
205
|
-
return last[key];
|
|
206
|
-
}
|
|
188
|
+
if (!lastVersion[key] || lastVersion[key] === cacheKey) return last[key];
|
|
207
189
|
}
|
|
208
190
|
lastVersion[key] = cacheKey || "";
|
|
209
191
|
const props = getFilledOptions(propsIn);
|
|
210
192
|
process.env.IS_STATIC = "is_static";
|
|
211
|
-
process.env.
|
|
193
|
+
process.env.TAMAGUI_IS_SERVER = "true";
|
|
212
194
|
const {
|
|
213
195
|
unregister
|
|
214
196
|
} = (0, import_registerRequire.registerRequire)(props.platform || "web", {
|
|
@@ -218,48 +200,40 @@ function loadGuiSync({
|
|
|
218
200
|
const devValueOG = globalThis["__DEV__"];
|
|
219
201
|
globalThis["__DEV__"] = process.env.NODE_ENV === "development";
|
|
220
202
|
try {
|
|
221
|
-
let
|
|
203
|
+
let hanzoguiConfig = null;
|
|
222
204
|
if (propsIn.config) {
|
|
223
|
-
const configPath = (0,
|
|
205
|
+
const configPath = (0, import_getHanzoguiConfigPathFromOptionsConfig.getHanzoguiConfigPathFromOptionsConfig)(propsIn.config);
|
|
224
206
|
const exp = require(configPath);
|
|
225
|
-
if (!exp || exp._isProxyWorm)
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
guiConfig = exp["default"] || exp["config"] || exp;
|
|
229
|
-
if (!guiConfig || !guiConfig.parsed) {
|
|
207
|
+
if (!exp || exp._isProxyWorm) throw new Error(`Got a empty / proxied config!`);
|
|
208
|
+
hanzoguiConfig = exp["default"] || exp["config"] || exp;
|
|
209
|
+
if (!hanzoguiConfig || !hanzoguiConfig.parsed) {
|
|
230
210
|
const confPath = require.resolve(configPath);
|
|
231
211
|
throw new Error(`Can't find valid config in ${confPath}:
|
|
232
212
|
|
|
233
213
|
Be sure you "export default" or "export const config" the config.`);
|
|
234
214
|
}
|
|
235
|
-
if (
|
|
215
|
+
if (hanzoguiConfig) {
|
|
236
216
|
const {
|
|
237
|
-
|
|
238
|
-
} = (0,
|
|
239
|
-
|
|
217
|
+
createHanzogui
|
|
218
|
+
} = (0, import_requireHanzoguiCore.requireHanzoguiCore)(props.platform || "web");
|
|
219
|
+
createHanzogui(hanzoguiConfig);
|
|
240
220
|
}
|
|
241
221
|
}
|
|
242
222
|
const components = (0, import_bundleConfig.loadComponentsSync)(props, forceExports);
|
|
243
|
-
if (!components)
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
if (process.env.DEBUG === "@hanzo/gui") {
|
|
247
|
-
console.info(`components`, components);
|
|
248
|
-
}
|
|
223
|
+
if (!components) throw new Error(`No components loaded`);
|
|
224
|
+
if (process.env.DEBUG === "hanzogui") console.info(`components`, components);
|
|
249
225
|
process.env.IS_STATIC = void 0;
|
|
250
226
|
globalThis["__DEV__"] = devValueOG;
|
|
251
227
|
const info = {
|
|
252
228
|
components,
|
|
253
|
-
|
|
229
|
+
hanzoguiConfig,
|
|
254
230
|
nameToPaths: (0, import_registerRequire.getNameToPaths)()
|
|
255
231
|
};
|
|
256
|
-
if (
|
|
232
|
+
if (hanzoguiConfig) {
|
|
257
233
|
const {
|
|
258
234
|
outputCSS
|
|
259
235
|
} = props;
|
|
260
|
-
if (outputCSS)
|
|
261
|
-
(0, import_bundleConfig.writeGuiCSS)(outputCSS, guiConfig);
|
|
262
|
-
}
|
|
236
|
+
if (outputCSS) (0, import_bundleConfig.writeHanzoguiCSS)(outputCSS, hanzoguiConfig);
|
|
263
237
|
(0, import_regenerateConfig.regenerateConfigSync)(props, info);
|
|
264
238
|
}
|
|
265
239
|
last[key] = {
|
|
@@ -270,23 +244,17 @@ function loadGuiSync({
|
|
|
270
244
|
} catch (err) {
|
|
271
245
|
if (err instanceof Error) {
|
|
272
246
|
if (!import_constants.SHOULD_DEBUG && !forceExports) {
|
|
273
|
-
console.warn(`Error loading
|
|
247
|
+
console.warn(`Error loading hanzogui.config.ts (set DEBUG=hanzogui to see full stack), running hanzogui without custom config`);
|
|
274
248
|
console.info(`
|
|
275
249
|
|
|
276
250
|
${err.message}
|
|
277
251
|
|
|
278
252
|
`);
|
|
279
|
-
} else
|
|
280
|
-
|
|
281
|
-
console.error(err);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
} else {
|
|
285
|
-
console.error(`Error loading gui.config.ts`, err);
|
|
286
|
-
}
|
|
253
|
+
} else if (import_constants.SHOULD_DEBUG) console.error(err);
|
|
254
|
+
} else console.error(`Error loading hanzogui.config.ts`, err);
|
|
287
255
|
return {
|
|
288
256
|
components: [],
|
|
289
|
-
|
|
257
|
+
hanzoguiConfig: null,
|
|
290
258
|
nameToPaths: {}
|
|
291
259
|
};
|
|
292
260
|
}
|
|
@@ -297,11 +265,11 @@ function loadGuiSync({
|
|
|
297
265
|
async function getOptions({
|
|
298
266
|
root = process.cwd(),
|
|
299
267
|
tsconfigPath = "tsconfig.json",
|
|
300
|
-
|
|
268
|
+
hanzoguiOptions,
|
|
301
269
|
host,
|
|
302
270
|
debug
|
|
303
271
|
} = {}) {
|
|
304
|
-
const dotDir = (0, import_node_path.join)(root, ".
|
|
272
|
+
const dotDir = (0, import_node_path.join)(root, ".hanzogui");
|
|
305
273
|
let pkgJson = {};
|
|
306
274
|
try {
|
|
307
275
|
pkgJson = await fsExtra.readJSON((0, import_node_path.join)(root, "package.json"));
|
|
@@ -313,16 +281,16 @@ async function getOptions({
|
|
|
313
281
|
pkgJson,
|
|
314
282
|
debug,
|
|
315
283
|
tsconfigPath,
|
|
316
|
-
|
|
284
|
+
hanzoguiOptions: {
|
|
317
285
|
platform: "web",
|
|
318
|
-
components: ["
|
|
319
|
-
...
|
|
320
|
-
config:
|
|
286
|
+
components: ["hanzogui"],
|
|
287
|
+
...hanzoguiOptions,
|
|
288
|
+
config: hanzoguiOptions?.config ?? (await getDefaultHanzoguiConfigPath(root, hanzoguiOptions?.config))
|
|
321
289
|
},
|
|
322
290
|
paths: {
|
|
323
291
|
root,
|
|
324
292
|
dotDir,
|
|
325
|
-
conf: (0, import_node_path.join)(dotDir, "
|
|
293
|
+
conf: (0, import_node_path.join)(dotDir, "hanzogui.config.json"),
|
|
326
294
|
types: (0, import_node_path.join)(dotDir, "types.json")
|
|
327
295
|
}
|
|
328
296
|
};
|
|
@@ -334,25 +302,18 @@ function resolveWebOrNativeSpecificEntry(entry) {
|
|
|
334
302
|
});
|
|
335
303
|
const ext = (0, import_node_path.extname)(resolved);
|
|
336
304
|
const fileName = (0, import_node_path.basename)(resolved).replace(ext, "");
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
if (fsExtra.existsSync(specificFile)) {
|
|
340
|
-
return specificFile;
|
|
341
|
-
}
|
|
305
|
+
const specificFile = (0, import_node_path.join)((0, import_node_path.dirname)(resolved), fileName + ".web" + ext);
|
|
306
|
+
if (fsExtra.existsSync(specificFile)) return specificFile;
|
|
342
307
|
return entry;
|
|
343
308
|
}
|
|
344
|
-
const defaultPaths = ["
|
|
309
|
+
const defaultPaths = ["hanzogui.config.ts", (0, import_node_path.join)("src", "hanzogui.config.ts")];
|
|
345
310
|
let hasWarnedOnce = false;
|
|
346
|
-
async function
|
|
311
|
+
async function getDefaultHanzoguiConfigPath(root, configPath) {
|
|
347
312
|
const searchPaths = [...new Set([configPath, ...defaultPaths].filter(Boolean).map(p => (0, import_node_path.join)(root, p)))];
|
|
348
|
-
for (const path of searchPaths)
|
|
349
|
-
if (await fsExtra.pathExists(path)) {
|
|
350
|
-
return path;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
313
|
+
for (const path of searchPaths) if (await fsExtra.pathExists(path)) return path;
|
|
353
314
|
if (!hasWarnedOnce) {
|
|
354
315
|
hasWarnedOnce = true;
|
|
355
|
-
console.warn(`Warning: couldn't find
|
|
316
|
+
console.warn(`Warning: couldn't find hanzogui.config.ts in the following paths given configuration "${configPath}":
|
|
356
317
|
${searchPaths.join(`
|
|
357
318
|
`)}
|
|
358
319
|
`);
|
|
@@ -387,24 +348,19 @@ async function esbuildWatchFiles(entry, onChanged) {
|
|
|
387
348
|
onEnd,
|
|
388
349
|
onResolve
|
|
389
350
|
}) {
|
|
390
|
-
let filter = /^[^./]|^\.[^./]|^\.\.[^/]/;
|
|
391
351
|
onResolve({
|
|
392
|
-
filter
|
|
352
|
+
filter: /^[^./]|^\.[^./]|^\.\.[^/]/
|
|
393
353
|
}, args => ({
|
|
394
354
|
path: args.path,
|
|
395
355
|
external: true
|
|
396
356
|
}));
|
|
397
357
|
onEnd(() => {
|
|
398
|
-
if (!hasRunOnce)
|
|
399
|
-
hasRunOnce = true;
|
|
400
|
-
} else {
|
|
401
|
-
onChanged();
|
|
402
|
-
}
|
|
358
|
+
if (!hasRunOnce) hasRunOnce = true;else onChanged();
|
|
403
359
|
});
|
|
404
360
|
}
|
|
405
361
|
}]
|
|
406
362
|
});
|
|
407
|
-
|
|
363
|
+
context.watch();
|
|
408
364
|
return () => {
|
|
409
365
|
context.dispose();
|
|
410
366
|
};
|
|
@@ -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
|
+
generateHanzoguiThemes: () => generateHanzoguiThemes,
|
|
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_requireHanzoguiCore = require("../helpers/requireHanzoguiCore.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_TAMAGUI_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_TAMAGUI_DEV) {
|
|
71
71
|
console.warn("regenerateConfig error", err);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
async function
|
|
76
|
-
if (!
|
|
75
|
+
async function generateHanzoguiThemes(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
|
}
|
|
@@ -112,19 +112,19 @@ function transformConfig(config, platform) {
|
|
|
112
112
|
}
|
|
113
113
|
const {
|
|
114
114
|
getVariableValue
|
|
115
|
-
} = (0,
|
|
115
|
+
} = (0, import_requireHanzoguiCore.requireHanzoguiCore)(platform);
|
|
116
116
|
const next = cloneDeepSafe(config, {
|
|
117
117
|
validStyles: true
|
|
118
118
|
});
|
|
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
|
|
@@ -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 watchHanzoguiConfig_exports = {};
|
|
24
|
+
__export(watchHanzoguiConfig_exports, {
|
|
25
|
+
watchHanzoguiConfig: () => watchHanzoguiConfig
|
|
26
26
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
28
|
-
var
|
|
27
|
+
module.exports = __toCommonJS(watchHanzoguiConfig_exports);
|
|
28
|
+
var import_loadHanzogui = require("./loadHanzogui.cjs");
|
|
29
29
|
var import_regenerateConfig = require("./regenerateConfig.cjs");
|
|
30
30
|
let isWatching = false;
|
|
31
|
-
async function
|
|
31
|
+
async function watchHanzoguiConfig(hanzoguiOptions) {
|
|
32
32
|
if (process.env.NODE_ENV === "production") {
|
|
33
33
|
return {
|
|
34
34
|
dispose() {}
|
|
@@ -38,26 +38,26 @@ async function watchGuiConfig(guiOptions) {
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
isWatching = true;
|
|
41
|
-
const options = await (0,
|
|
42
|
-
|
|
41
|
+
const options = await (0, import_loadHanzogui.getOptions)({
|
|
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,
|
|
49
|
-
await (0,
|
|
50
|
-
await (0, import_regenerateConfig.regenerateConfig)(options.
|
|
48
|
+
const disposeConfigWatcher = await (0, import_loadHanzogui.esbuildWatchFiles)(options.hanzoguiOptions.config, async () => {
|
|
49
|
+
await (0, import_loadHanzogui.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;
|
|
56
56
|
try {
|
|
57
57
|
inputPath = require.resolve(themeBuilderInput);
|
|
58
58
|
} catch {}
|
|
59
|
-
disposeThemesWatcher = await (0,
|
|
60
|
-
await (0,
|
|
59
|
+
disposeThemesWatcher = await (0, import_loadHanzogui.esbuildWatchFiles)(inputPath, async () => {
|
|
60
|
+
await (0, import_loadHanzogui.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":
|
|
@@ -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.TAMAGUI_DEBUG_FILE) {
|
|
59
|
+
if (path.includes(process.env.TAMAGUI_DEBUG_FILE)) {
|
|
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 {
|
|
@@ -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 requireHanzoguiCore_exports = {};
|
|
24
|
+
__export(requireHanzoguiCore_exports, {
|
|
25
|
+
requireHanzoguiCore: () => requireHanzoguiCore
|
|
26
26
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
28
|
-
function
|
|
27
|
+
module.exports = __toCommonJS(requireHanzoguiCore_exports);
|
|
28
|
+
function requireHanzoguiCore(platform, ogRequire = require) {
|
|
29
29
|
if (!platform) {
|
|
30
|
-
throw new Error(`No platform given to
|
|
30
|
+
throw new Error(`No platform given to requireHanzoguiCore`);
|
|
31
31
|
}
|
|
32
|
-
const og1 = process.env.
|
|
33
|
-
const og2 = process.env.
|
|
34
|
-
process.env.
|
|
35
|
-
process.env.
|
|
32
|
+
const og1 = process.env.TAMAGUI_IS_SERVER;
|
|
33
|
+
const og2 = process.env.TAMAGUI_KEEP_THEMES;
|
|
34
|
+
process.env.TAMAGUI_IS_SERVER ||= "1";
|
|
35
|
+
process.env.TAMAGUI_KEEP_THEMES ||= "1";
|
|
36
36
|
const exported = ogRequire(platform === "native" ? "@hanzogui/core/native" : "@hanzogui/core");
|
|
37
|
-
process.env.
|
|
38
|
-
process.env.
|
|
37
|
+
process.env.TAMAGUI_IS_SERVER = og1;
|
|
38
|
+
process.env.TAMAGUI_KEEP_THEMES = og2;
|
|
39
39
|
return exported;
|
|
40
40
|
}
|