@hanzogui/static 2.0.0-rc.41-hanzoai.5

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.
Files changed (211) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/check-dep-versions.cjs +372 -0
  4. package/dist/checkDeps.cjs +271 -0
  5. package/dist/constants.cjs +51 -0
  6. package/dist/exports.cjs +46 -0
  7. package/dist/extractor/accessSafe.cjs +48 -0
  8. package/dist/extractor/babelParse.cjs +56 -0
  9. package/dist/extractor/buildClassName.cjs +86 -0
  10. package/dist/extractor/bundle.cjs +224 -0
  11. package/dist/extractor/bundleConfig.cjs +716 -0
  12. package/dist/extractor/concatClassName.cjs +92 -0
  13. package/dist/extractor/createEvaluator.cjs +88 -0
  14. package/dist/extractor/createExtractor.cjs +1827 -0
  15. package/dist/extractor/createLogger.cjs +50 -0
  16. package/dist/extractor/detectModuleFormat.cjs +55 -0
  17. package/dist/extractor/ensureImportingConcat.cjs +54 -0
  18. package/dist/extractor/errors.cjs +28 -0
  19. package/dist/extractor/esbuildAliasPlugin.cjs +56 -0
  20. package/dist/extractor/esbuildTsconfigPaths.cjs +108 -0
  21. package/dist/extractor/evaluateAstNode.cjs +128 -0
  22. package/dist/extractor/extractHelpers.cjs +182 -0
  23. package/dist/extractor/extractMediaStyle.cjs +169 -0
  24. package/dist/extractor/extractToClassNames.cjs +427 -0
  25. package/dist/extractor/extractToNative.cjs +361 -0
  26. package/dist/extractor/findTopmostFunction.cjs +43 -0
  27. package/dist/extractor/generatedUid.cjs +58 -0
  28. package/dist/extractor/getHanzoguiConfigPathFromOptionsConfig.cjs +41 -0
  29. package/dist/extractor/getPrefixLogs.cjs +31 -0
  30. package/dist/extractor/getPropValueFromAttributes.cjs +85 -0
  31. package/dist/extractor/getSourceModule.cjs +100 -0
  32. package/dist/extractor/getStaticBindingsForScope.cjs +213 -0
  33. package/dist/extractor/hasTopLevelAwait.cjs +62 -0
  34. package/dist/extractor/hoistClassNames.cjs +76 -0
  35. package/dist/extractor/literalToAst.cjs +109 -0
  36. package/dist/extractor/loadFile.cjs +17 -0
  37. package/dist/extractor/loadHanzogui.cjs +367 -0
  38. package/dist/extractor/logLines.cjs +43 -0
  39. package/dist/extractor/normalizeTernaries.cjs +95 -0
  40. package/dist/extractor/propsToFontFamilyCache.cjs +42 -0
  41. package/dist/extractor/regenerateConfig.cjs +178 -0
  42. package/dist/extractor/removeUnusedHooks.cjs +108 -0
  43. package/dist/extractor/timer.cjs +52 -0
  44. package/dist/extractor/validHTMLAttributes.cjs +79 -0
  45. package/dist/extractor/watchHanzoguiConfig.cjs +70 -0
  46. package/dist/getPragmaOptions.cjs +73 -0
  47. package/dist/helpers/memoize.cjs +45 -0
  48. package/dist/helpers/requireHanzoguiCore.cjs +40 -0
  49. package/dist/index.cjs +42 -0
  50. package/dist/registerRequire.cjs +208 -0
  51. package/dist/server.cjs +82 -0
  52. package/dist/setup.cjs +0 -0
  53. package/dist/types.cjs +18 -0
  54. package/dist/worker.cjs +111 -0
  55. package/package.json +101 -0
  56. package/src/check-dep-versions.ts +738 -0
  57. package/src/checkDeps.ts +371 -0
  58. package/src/constants.ts +14 -0
  59. package/src/exports.ts +15 -0
  60. package/src/extractor/accessSafe.ts +22 -0
  61. package/src/extractor/babelParse.ts +38 -0
  62. package/src/extractor/buildClassName.ts +76 -0
  63. package/src/extractor/bundle.ts +277 -0
  64. package/src/extractor/bundleConfig.ts +958 -0
  65. package/src/extractor/concatClassName.ts +105 -0
  66. package/src/extractor/createEvaluator.ts +82 -0
  67. package/src/extractor/createExtractor.ts +2680 -0
  68. package/src/extractor/createLogger.ts +41 -0
  69. package/src/extractor/detectModuleFormat.ts +42 -0
  70. package/src/extractor/ensureImportingConcat.ts +36 -0
  71. package/src/extractor/errors.ts +1 -0
  72. package/src/extractor/esbuildAliasPlugin.ts +40 -0
  73. package/src/extractor/esbuildTsconfigPaths.ts +103 -0
  74. package/src/extractor/evaluateAstNode.ts +136 -0
  75. package/src/extractor/extractHelpers.ts +211 -0
  76. package/src/extractor/extractMediaStyle.ts +194 -0
  77. package/src/extractor/extractToClassNames.ts +631 -0
  78. package/src/extractor/extractToNative.ts +489 -0
  79. package/src/extractor/findTopmostFunction.ts +24 -0
  80. package/src/extractor/generatedUid.ts +41 -0
  81. package/src/extractor/getHanzoguiConfigPathFromOptionsConfig.ts +24 -0
  82. package/src/extractor/getPrefixLogs.ts +9 -0
  83. package/src/extractor/getPropValueFromAttributes.ts +95 -0
  84. package/src/extractor/getSourceModule.ts +96 -0
  85. package/src/extractor/getStaticBindingsForScope.ts +237 -0
  86. package/src/extractor/hasTopLevelAwait.ts +28 -0
  87. package/src/extractor/hoistClassNames.ts +52 -0
  88. package/src/extractor/literalToAst.ts +85 -0
  89. package/src/extractor/loadFile.ts +17 -0
  90. package/src/extractor/loadHanzogui.ts +487 -0
  91. package/src/extractor/logLines.ts +16 -0
  92. package/src/extractor/normalizeTernaries.ts +75 -0
  93. package/src/extractor/propsToFontFamilyCache.ts +18 -0
  94. package/src/extractor/regenerateConfig.ts +186 -0
  95. package/src/extractor/removeUnusedHooks.ts +83 -0
  96. package/src/extractor/timer.ts +25 -0
  97. package/src/extractor/validHTMLAttributes.ts +52 -0
  98. package/src/extractor/watchHanzoguiConfig.ts +57 -0
  99. package/src/getPragmaOptions.ts +57 -0
  100. package/src/helpers/memoize.ts +24 -0
  101. package/src/helpers/requireHanzoguiCore.ts +28 -0
  102. package/src/index.ts +4 -0
  103. package/src/registerRequire.ts +283 -0
  104. package/src/server.ts +43 -0
  105. package/src/setup.ts +0 -0
  106. package/src/types.ts +109 -0
  107. package/src/worker.ts +142 -0
  108. package/types/check-dep-versions.d.ts +37 -0
  109. package/types/check-dep-versions.d.ts.map +1 -0
  110. package/types/checkDeps.d.ts +19 -0
  111. package/types/checkDeps.d.ts.map +1 -0
  112. package/types/constants.d.ts +6 -0
  113. package/types/constants.d.ts.map +1 -0
  114. package/types/exports.d.ts +16 -0
  115. package/types/exports.d.ts.map +1 -0
  116. package/types/extractor/accessSafe.d.ts +3 -0
  117. package/types/extractor/accessSafe.d.ts.map +1 -0
  118. package/types/extractor/babelParse.d.ts +5 -0
  119. package/types/extractor/babelParse.d.ts.map +1 -0
  120. package/types/extractor/buildClassName.d.ts +7 -0
  121. package/types/extractor/buildClassName.d.ts.map +1 -0
  122. package/types/extractor/bundle.d.ts +121 -0
  123. package/types/extractor/bundle.d.ts.map +1 -0
  124. package/types/extractor/bundleConfig.d.ts +49 -0
  125. package/types/extractor/bundleConfig.d.ts.map +1 -0
  126. package/types/extractor/concatClassName.d.ts +8 -0
  127. package/types/extractor/concatClassName.d.ts.map +1 -0
  128. package/types/extractor/createEvaluator.d.ts +12 -0
  129. package/types/extractor/createEvaluator.d.ts.map +1 -0
  130. package/types/extractor/createExtractor.d.ts +32 -0
  131. package/types/extractor/createExtractor.d.ts.map +1 -0
  132. package/types/extractor/createLogger.d.ts +3 -0
  133. package/types/extractor/createLogger.d.ts.map +1 -0
  134. package/types/extractor/detectModuleFormat.d.ts +5 -0
  135. package/types/extractor/detectModuleFormat.d.ts.map +1 -0
  136. package/types/extractor/ensureImportingConcat.d.ts +4 -0
  137. package/types/extractor/ensureImportingConcat.d.ts.map +1 -0
  138. package/types/extractor/errors.d.ts +3 -0
  139. package/types/extractor/errors.d.ts.map +1 -0
  140. package/types/extractor/esbuildAliasPlugin.d.ts +18 -0
  141. package/types/extractor/esbuildAliasPlugin.d.ts.map +1 -0
  142. package/types/extractor/esbuildTsconfigPaths.d.ts +11 -0
  143. package/types/extractor/esbuildTsconfigPaths.d.ts.map +1 -0
  144. package/types/extractor/evaluateAstNode.d.ts +3 -0
  145. package/types/extractor/evaluateAstNode.d.ts.map +1 -0
  146. package/types/extractor/extractHelpers.d.ts +28 -0
  147. package/types/extractor/extractHelpers.d.ts.map +1 -0
  148. package/types/extractor/extractMediaStyle.d.ts +11 -0
  149. package/types/extractor/extractMediaStyle.d.ts.map +1 -0
  150. package/types/extractor/extractToClassNames.d.ts +25 -0
  151. package/types/extractor/extractToClassNames.d.ts.map +1 -0
  152. package/types/extractor/extractToNative.d.ts +13 -0
  153. package/types/extractor/extractToNative.d.ts.map +1 -0
  154. package/types/extractor/findTopmostFunction.d.ts +4 -0
  155. package/types/extractor/findTopmostFunction.d.ts.map +1 -0
  156. package/types/extractor/generatedUid.d.ts +5 -0
  157. package/types/extractor/generatedUid.d.ts.map +1 -0
  158. package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts +3 -0
  159. package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts.map +1 -0
  160. package/types/extractor/getPrefixLogs.d.ts +3 -0
  161. package/types/extractor/getPrefixLogs.d.ts.map +1 -0
  162. package/types/extractor/getPropValueFromAttributes.d.ts +19 -0
  163. package/types/extractor/getPropValueFromAttributes.d.ts.map +1 -0
  164. package/types/extractor/getSourceModule.d.ts +16 -0
  165. package/types/extractor/getSourceModule.d.ts.map +1 -0
  166. package/types/extractor/getStaticBindingsForScope.d.ts +5 -0
  167. package/types/extractor/getStaticBindingsForScope.d.ts.map +1 -0
  168. package/types/extractor/hasTopLevelAwait.d.ts +2 -0
  169. package/types/extractor/hasTopLevelAwait.d.ts.map +1 -0
  170. package/types/extractor/hoistClassNames.d.ts +6 -0
  171. package/types/extractor/hoistClassNames.d.ts.map +1 -0
  172. package/types/extractor/literalToAst.d.ts +4 -0
  173. package/types/extractor/literalToAst.d.ts.map +1 -0
  174. package/types/extractor/loadFile.d.ts +1 -0
  175. package/types/extractor/loadFile.d.ts.map +1 -0
  176. package/types/extractor/loadHanzogui.d.ts +22 -0
  177. package/types/extractor/loadHanzogui.d.ts.map +1 -0
  178. package/types/extractor/logLines.d.ts +2 -0
  179. package/types/extractor/logLines.d.ts.map +1 -0
  180. package/types/extractor/normalizeTernaries.d.ts +3 -0
  181. package/types/extractor/normalizeTernaries.d.ts.map +1 -0
  182. package/types/extractor/propsToFontFamilyCache.d.ts +4 -0
  183. package/types/extractor/propsToFontFamilyCache.d.ts.map +1 -0
  184. package/types/extractor/regenerateConfig.d.ts +9 -0
  185. package/types/extractor/regenerateConfig.d.ts.map +1 -0
  186. package/types/extractor/removeUnusedHooks.d.ts +3 -0
  187. package/types/extractor/removeUnusedHooks.d.ts.map +1 -0
  188. package/types/extractor/timer.d.ts +5 -0
  189. package/types/extractor/timer.d.ts.map +1 -0
  190. package/types/extractor/validHTMLAttributes.d.ts +52 -0
  191. package/types/extractor/validHTMLAttributes.d.ts.map +1 -0
  192. package/types/extractor/watchHanzoguiConfig.d.ts +5 -0
  193. package/types/extractor/watchHanzoguiConfig.d.ts.map +1 -0
  194. package/types/getPragmaOptions.d.ts +8 -0
  195. package/types/getPragmaOptions.d.ts.map +1 -0
  196. package/types/helpers/memoize.d.ts +8 -0
  197. package/types/helpers/memoize.d.ts.map +1 -0
  198. package/types/helpers/requireHanzoguiCore.d.ts +3 -0
  199. package/types/helpers/requireHanzoguiCore.d.ts.map +1 -0
  200. package/types/index.d.ts +4 -0
  201. package/types/index.d.ts.map +1 -0
  202. package/types/registerRequire.d.ts +10 -0
  203. package/types/registerRequire.d.ts.map +1 -0
  204. package/types/server.d.ts +3 -0
  205. package/types/server.d.ts.map +1 -0
  206. package/types/setup.d.ts +1 -0
  207. package/types/setup.d.ts.map +1 -0
  208. package/types/types.d.ts +92 -0
  209. package/types/types.d.ts.map +1 -0
  210. package/types/worker.d.ts +46 -0
  211. package/types/worker.d.ts.map +1 -0
@@ -0,0 +1,367 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
34
+ var loadHanzogui_exports = {};
35
+ __export(loadHanzogui_exports, {
36
+ esbuildWatchFiles: () => esbuildWatchFiles,
37
+ generateThemesAndLog: () => generateThemesAndLog,
38
+ getOptions: () => getOptions,
39
+ loadHanzogui: () => loadHanzogui,
40
+ loadHanzoguiBuildConfigAsync: () => loadHanzoguiBuildConfigAsync,
41
+ loadHanzoguiBuildConfigSync: () => loadHanzoguiBuildConfigSync,
42
+ loadHanzoguiSync: () => loadHanzoguiSync,
43
+ resolveWebOrNativeSpecificEntry: () => resolveWebOrNativeSpecificEntry
44
+ });
45
+ module.exports = __toCommonJS(loadHanzogui_exports);
46
+ var import_node_path = require("node:path");
47
+ var import_cli_color = require("@hanzogui/cli-color");
48
+ var import_esbuild = __toESM(require("esbuild"));
49
+ var esbuildWasm = __toESM(require("esbuild-wasm"));
50
+ var fsExtra = __toESM(require("fs-extra"));
51
+ var import_constants = require("../constants.cjs");
52
+ var import_requireHanzoguiCore = require("../helpers/requireHanzoguiCore.cjs");
53
+ var import_registerRequire = require("../registerRequire.cjs");
54
+ var import_bundleConfig = require("./bundleConfig.cjs");
55
+ var import_getHanzoguiConfigPathFromOptionsConfig = require("./getHanzoguiConfigPathFromOptionsConfig.cjs");
56
+ var import_regenerateConfig = require("./regenerateConfig.cjs");
57
+ const getFilledOptions = propsIn => ({
58
+ platform: "web",
59
+ config: "hanzogui.config.ts",
60
+ components: ["hanzogui"],
61
+ ...propsIn
62
+ });
63
+ let isLoadingPromise;
64
+ async function loadHanzogui(propsIn) {
65
+ if (isLoadingPromise) return await isLoadingPromise;
66
+ let resolvePromise;
67
+ let rejectPromise;
68
+ isLoadingPromise = new Promise((res, rej) => {
69
+ resolvePromise = res;
70
+ rejectPromise = rej;
71
+ });
72
+ try {
73
+ const props = getFilledOptions(propsIn);
74
+ const bundleInfo = await (0, import_bundleConfig.getBundledConfig)(props);
75
+ if (!bundleInfo) {
76
+ console.warn(`No bundled config generated, maybe an error in bundling. Set DEBUG=hanzogui and re-run to get logs.`);
77
+ resolvePromise(null);
78
+ return null;
79
+ }
80
+ await generateThemesAndLog(props);
81
+ const maybeHanzoguiConfig = bundleInfo.hanzoguiConfig;
82
+ if (maybeHanzoguiConfig && !maybeHanzoguiConfig.parsed) {
83
+ const {
84
+ createHanzogui
85
+ } = (0, import_requireHanzoguiCore.requireHanzoguiCore)(props.platform || "web");
86
+ bundleInfo.hanzoguiConfig = createHanzogui(bundleInfo.hanzoguiConfig);
87
+ }
88
+ if (!(0, import_bundleConfig.hasBundledConfigChanged)()) {
89
+ resolvePromise(bundleInfo);
90
+ return bundleInfo;
91
+ }
92
+ await (0, import_regenerateConfig.regenerateConfig)(props, bundleInfo);
93
+ resolvePromise(bundleInfo);
94
+ return bundleInfo;
95
+ } catch (err) {
96
+ rejectPromise();
97
+ throw err;
98
+ } finally {
99
+ isLoadingPromise = null;
100
+ }
101
+ }
102
+ let waiting = false;
103
+ const generateThemesAndLog = async (options, force = false) => {
104
+ if (waiting) return;
105
+ if (!options.themeBuilder) return;
106
+ try {
107
+ waiting = true;
108
+ await new Promise(res => setTimeout(res, 30));
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)}`);
111
+ if (options.outputCSS) {
112
+ const loadedConfig = (0, import_bundleConfig.getLoadedConfig)();
113
+ if (loadedConfig) await (0, import_bundleConfig.writeHanzoguiCSS)(options.outputCSS, loadedConfig);
114
+ }
115
+ }
116
+ } finally {
117
+ waiting = false;
118
+ }
119
+ };
120
+ const last = {};
121
+ const lastVersion = {};
122
+ let esbuildWasmInitialized = false;
123
+ async function loadHanzoguiBuildConfigAsync(hanzoguiOptions) {
124
+ const buildFilePath = hanzoguiOptions?.buildFile ?? "./hanzogui.build.ts";
125
+ const absolutePath = buildFilePath[0] === "." ? (0, import_node_path.join)(process.cwd(), buildFilePath) : buildFilePath;
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;
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;
151
+ }
152
+ if (!hanzoguiOptions) throw new Error(`No hanzogui build options found either via input props or at hanzogui.build.ts`);
153
+ return {
154
+ config: "hanzogui.config.ts",
155
+ components: ["hanzogui", "@hanzogui/core"],
156
+ ...hanzoguiOptions
157
+ };
158
+ }
159
+ function loadHanzoguiBuildConfigSync(hanzoguiOptions) {
160
+ const buildFilePath = hanzoguiOptions?.buildFile ?? "./hanzogui.build.ts";
161
+ if (fsExtra.existsSync(buildFilePath)) {
162
+ const registered = (0, import_registerRequire.registerRequire)("web");
163
+ try {
164
+ const out = (buildFilePath[0] === "." ? require((0, import_node_path.join)(process.cwd(), buildFilePath)) : require(buildFilePath)).default;
165
+ if (!out) throw new Error(`No default export found in ${buildFilePath}: ${out}`);
166
+ hanzoguiOptions = {
167
+ ...hanzoguiOptions,
168
+ ...out
169
+ };
170
+ } finally {
171
+ registered.unregister();
172
+ }
173
+ }
174
+ if (!hanzoguiOptions) throw new Error(`No hanzogui build options found either via input props or at hanzogui.build.ts`);
175
+ return {
176
+ config: "hanzogui.config.ts",
177
+ components: ["hanzogui", "@hanzogui/core"],
178
+ ...hanzoguiOptions
179
+ };
180
+ }
181
+ function loadHanzoguiSync({
182
+ forceExports,
183
+ cacheKey,
184
+ ...propsIn
185
+ }) {
186
+ const key = JSON.stringify(propsIn);
187
+ if (last[key] && !(0, import_bundleConfig.hasBundledConfigChanged)()) {
188
+ if (!lastVersion[key] || lastVersion[key] === cacheKey) return last[key];
189
+ }
190
+ lastVersion[key] = cacheKey || "";
191
+ const props = getFilledOptions(propsIn);
192
+ process.env.IS_STATIC = "is_static";
193
+ process.env.TAMAGUI_IS_SERVER = "true";
194
+ const {
195
+ unregister
196
+ } = (0, import_registerRequire.registerRequire)(props.platform || "web", {
197
+ proxyWormImports: !!forceExports
198
+ });
199
+ try {
200
+ const devValueOG = globalThis["__DEV__"];
201
+ globalThis["__DEV__"] = process.env.NODE_ENV === "development";
202
+ try {
203
+ let hanzoguiConfig = null;
204
+ if (propsIn.config) {
205
+ const configPath = (0, import_getHanzoguiConfigPathFromOptionsConfig.getHanzoguiConfigPathFromOptionsConfig)(propsIn.config);
206
+ const exp = require(configPath);
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) {
210
+ const confPath = require.resolve(configPath);
211
+ throw new Error(`Can't find valid config in ${confPath}:
212
+
213
+ Be sure you "export default" or "export const config" the config.`);
214
+ }
215
+ if (hanzoguiConfig) {
216
+ const {
217
+ createHanzogui
218
+ } = (0, import_requireHanzoguiCore.requireHanzoguiCore)(props.platform || "web");
219
+ createHanzogui(hanzoguiConfig);
220
+ }
221
+ }
222
+ const components = (0, import_bundleConfig.loadComponentsSync)(props, forceExports);
223
+ if (!components) throw new Error(`No components loaded`);
224
+ if (process.env.DEBUG === "hanzogui") console.info(`components`, components);
225
+ process.env.IS_STATIC = void 0;
226
+ globalThis["__DEV__"] = devValueOG;
227
+ const info = {
228
+ components,
229
+ hanzoguiConfig,
230
+ nameToPaths: (0, import_registerRequire.getNameToPaths)()
231
+ };
232
+ if (hanzoguiConfig) {
233
+ const {
234
+ outputCSS
235
+ } = props;
236
+ if (outputCSS) (0, import_bundleConfig.writeHanzoguiCSS)(outputCSS, hanzoguiConfig);
237
+ (0, import_regenerateConfig.regenerateConfigSync)(props, info);
238
+ }
239
+ last[key] = {
240
+ ...info,
241
+ cached: true
242
+ };
243
+ return info;
244
+ } catch (err) {
245
+ if (err instanceof Error) {
246
+ if (!import_constants.SHOULD_DEBUG && !forceExports) {
247
+ console.warn(`Error loading hanzogui.config.ts (set DEBUG=hanzogui to see full stack), running hanzogui without custom config`);
248
+ console.info(`
249
+
250
+ ${err.message}
251
+
252
+ `);
253
+ } else if (import_constants.SHOULD_DEBUG) console.error(err);
254
+ } else console.error(`Error loading hanzogui.config.ts`, err);
255
+ return {
256
+ components: [],
257
+ hanzoguiConfig: null,
258
+ nameToPaths: {}
259
+ };
260
+ }
261
+ } finally {
262
+ unregister();
263
+ }
264
+ }
265
+ async function getOptions({
266
+ root = process.cwd(),
267
+ tsconfigPath = "tsconfig.json",
268
+ hanzoguiOptions,
269
+ host,
270
+ debug
271
+ } = {}) {
272
+ const dotDir = (0, import_node_path.join)(root, ".hanzogui");
273
+ let pkgJson = {};
274
+ try {
275
+ pkgJson = await fsExtra.readJSON((0, import_node_path.join)(root, "package.json"));
276
+ } catch (err) {}
277
+ return {
278
+ mode: process.env.NODE_ENV === "production" ? "production" : "development",
279
+ root,
280
+ host: host || "127.0.0.1",
281
+ pkgJson,
282
+ debug,
283
+ tsconfigPath,
284
+ hanzoguiOptions: {
285
+ platform: "web",
286
+ components: ["hanzogui"],
287
+ ...hanzoguiOptions,
288
+ config: hanzoguiOptions?.config ?? (await getDefaultHanzoguiConfigPath(root, hanzoguiOptions?.config))
289
+ },
290
+ paths: {
291
+ root,
292
+ dotDir,
293
+ conf: (0, import_node_path.join)(dotDir, "hanzogui.config.json"),
294
+ types: (0, import_node_path.join)(dotDir, "types.json")
295
+ }
296
+ };
297
+ }
298
+ function resolveWebOrNativeSpecificEntry(entry) {
299
+ const workspaceRoot = (0, import_node_path.resolve)();
300
+ const resolved = require.resolve(entry, {
301
+ paths: [workspaceRoot]
302
+ });
303
+ const ext = (0, import_node_path.extname)(resolved);
304
+ const fileName = (0, import_node_path.basename)(resolved).replace(ext, "");
305
+ const specificFile = (0, import_node_path.join)((0, import_node_path.dirname)(resolved), fileName + ".web" + ext);
306
+ if (fsExtra.existsSync(specificFile)) return specificFile;
307
+ return entry;
308
+ }
309
+ const defaultPaths = ["hanzogui.config.ts", (0, import_node_path.join)("src", "hanzogui.config.ts")];
310
+ let hasWarnedOnce = false;
311
+ async function getDefaultHanzoguiConfigPath(root, configPath) {
312
+ const searchPaths = [...new Set([configPath, ...defaultPaths].filter(Boolean).map(p => (0, import_node_path.join)(root, p)))];
313
+ for (const path of searchPaths) if (await fsExtra.pathExists(path)) return path;
314
+ if (!hasWarnedOnce) {
315
+ hasWarnedOnce = true;
316
+ console.warn(`Warning: couldn't find hanzogui.config.ts in the following paths given configuration "${configPath}":
317
+ ${searchPaths.join(`
318
+ `)}
319
+ `);
320
+ }
321
+ }
322
+ async function esbuildWatchFiles(entry, onChanged) {
323
+ let hasRunOnce = false;
324
+ const context = await import_esbuild.default.context({
325
+ bundle: true,
326
+ entryPoints: [entry],
327
+ resolveExtensions: [".ts", ".tsx", ".js", ".mjs"],
328
+ logLevel: "silent",
329
+ write: false,
330
+ alias: {
331
+ "@react-native/normalize-color": "@hanzogui/proxy-worm",
332
+ "react-native-web": "@hanzogui/react-native-web-lite",
333
+ "react-native": "@hanzogui/proxy-worm"
334
+ },
335
+ plugins: [
336
+ // to log what its watching:
337
+ // {
338
+ // name: 'test',
339
+ // setup({ onResolve }) {
340
+ // onResolve({ filter: /.*/ }, (args) => {
341
+ // console.log('wtf', args.path)
342
+ // })
343
+ // },
344
+ // },
345
+ {
346
+ name: `on-rebuild`,
347
+ setup({
348
+ onEnd,
349
+ onResolve
350
+ }) {
351
+ onResolve({
352
+ filter: /^[^./]|^\.[^./]|^\.\.[^/]/
353
+ }, args => ({
354
+ path: args.path,
355
+ external: true
356
+ }));
357
+ onEnd(() => {
358
+ if (!hasRunOnce) hasRunOnce = true;else onChanged();
359
+ });
360
+ }
361
+ }]
362
+ });
363
+ context.watch();
364
+ return () => {
365
+ context.dispose();
366
+ };
367
+ }
@@ -0,0 +1,43 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
22
+ }), mod);
23
+ var logLines_exports = {};
24
+ __export(logLines_exports, {
25
+ logLines: () => logLines
26
+ });
27
+ module.exports = __toCommonJS(logLines_exports);
28
+ const prefix = " ";
29
+ const logLines = (str, singleLine = false) => {
30
+ if (singleLine) {
31
+ return prefix + str.split(" ").join(`
32
+ ${prefix}`);
33
+ }
34
+ const lines = [""];
35
+ const items = str.split(" ");
36
+ for (const item of items) {
37
+ if (item.length + lines[lines.length - 1].length > 85) {
38
+ lines.push("");
39
+ }
40
+ lines[lines.length - 1] += item + " ";
41
+ }
42
+ return lines.map((line, i) => prefix + (i == 0 ? "" : " ") + line.trim()).join("\n");
43
+ };
@@ -0,0 +1,95 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
34
+ var normalizeTernaries_exports = {};
35
+ __export(normalizeTernaries_exports, {
36
+ normalizeTernaries: () => normalizeTernaries
37
+ });
38
+ module.exports = __toCommonJS(normalizeTernaries_exports);
39
+ var import_generator = __toESM(require("@babel/generator"));
40
+ var t = __toESM(require("@babel/types"));
41
+ var import_web = require("@hanzogui/web");
42
+ var import_invariant = __toESM(require("invariant"));
43
+ var import_propsToFontFamilyCache = require("./propsToFontFamilyCache.cjs");
44
+ function normalizeTernaries(ternaries) {
45
+ (0, import_invariant.default)(Array.isArray(ternaries), "extractStaticTernaries expects param 1 to be an array of ternaries");
46
+ if (ternaries.length === 0) {
47
+ return [];
48
+ }
49
+ const ternariesByKey = {};
50
+ for (let idx = -1, len = ternaries.length; ++idx < len;) {
51
+ const {
52
+ test,
53
+ consequent,
54
+ alternate,
55
+ remove,
56
+ ...rest
57
+ } = ternaries[idx];
58
+ let ternaryTest = test;
59
+ if (t.isExpressionStatement(test)) {
60
+ ternaryTest = test.expression;
61
+ }
62
+ let shouldSwap = false;
63
+ if (t.isUnaryExpression(test) && test.operator === "!") {
64
+ ternaryTest = test.argument;
65
+ shouldSwap = true;
66
+ } else if (t.isBinaryExpression(test)) {
67
+ if (test.operator === "!==" || test.operator === "!=") {
68
+ ternaryTest = t.binaryExpression(test.operator.replace("!", "="), test.left, test.right);
69
+ shouldSwap = true;
70
+ }
71
+ }
72
+ const key = (0, import_generator.default)(ternaryTest).code;
73
+ if (!ternariesByKey[key]) {
74
+ ternariesByKey[key] = {
75
+ ...rest,
76
+ alternate: {},
77
+ consequent: {},
78
+ test: ternaryTest,
79
+ remove
80
+ };
81
+ }
82
+ const altStyle = (shouldSwap ? consequent : alternate) ?? {};
83
+ const consStyle = (shouldSwap ? alternate : consequent) ?? {};
84
+ const nextAlt = ternariesByKey[key].alternate;
85
+ ternariesByKey[key].alternate = (0, import_web.mergeProps)(altStyle, nextAlt);
86
+ (0, import_propsToFontFamilyCache.forwardFontFamilyName)(altStyle, ternariesByKey[key].alternate);
87
+ const nextCons = ternariesByKey[key].consequent;
88
+ ternariesByKey[key].consequent = (0, import_web.mergeProps)(consStyle, nextCons);
89
+ (0, import_propsToFontFamilyCache.forwardFontFamilyName)(consStyle, ternariesByKey[key].consequent);
90
+ }
91
+ const ternaryExpression = Object.keys(ternariesByKey).map(key => {
92
+ return ternariesByKey[key];
93
+ });
94
+ return ternaryExpression;
95
+ }
@@ -0,0 +1,42 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: true
22
+ }), mod);
23
+ var propsToFontFamilyCache_exports = {};
24
+ __export(propsToFontFamilyCache_exports, {
25
+ forwardFontFamilyName: () => forwardFontFamilyName,
26
+ getFontFamilyNameFromProps: () => getFontFamilyNameFromProps,
27
+ setPropsToFontFamily: () => setPropsToFontFamily
28
+ });
29
+ module.exports = __toCommonJS(propsToFontFamilyCache_exports);
30
+ const cache = /* @__PURE__ */new WeakMap();
31
+ function setPropsToFontFamily(props, ff) {
32
+ cache.set(props, ff.replace("$", "").trim());
33
+ }
34
+ function getFontFamilyNameFromProps(props) {
35
+ return cache.get(props);
36
+ }
37
+ function forwardFontFamilyName(prev, next, fallback) {
38
+ const ff = getFontFamilyNameFromProps(prev) || fallback;
39
+ if (ff) {
40
+ setPropsToFontFamily(next, ff);
41
+ }
42
+ }