@hanzogui/static 4.3.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/check-dep-versions.cjs +1 -1
  2. package/dist/checkDeps.cjs +11 -11
  3. package/dist/constants.cjs +2 -2
  4. package/dist/exports.cjs +2 -2
  5. package/dist/extractor/babelParse.cjs +1 -1
  6. package/dist/extractor/bundle.cjs +23 -39
  7. package/dist/extractor/bundleConfig.cjs +51 -48
  8. package/dist/extractor/createExtractor.cjs +39 -39
  9. package/dist/extractor/createLogger.cjs +1 -1
  10. package/dist/extractor/extractHelpers.cjs +1 -1
  11. package/dist/extractor/extractMediaStyle.cjs +7 -7
  12. package/dist/extractor/extractToClassNames.cjs +9 -9
  13. package/dist/extractor/extractToNative.cjs +7 -7
  14. package/dist/extractor/{getGuiConfigPathFromOptionsConfig.cjs → getHanzoguiConfigPathFromOptionsConfig.cjs} +5 -5
  15. package/dist/extractor/getPrefixLogs.cjs +1 -1
  16. package/dist/extractor/getStaticBindingsForScope.cjs +2 -2
  17. package/dist/extractor/hasTopLevelAwait.cjs +62 -0
  18. package/dist/extractor/{loadGui.cjs → loadHanzogui.cjs} +97 -141
  19. package/dist/extractor/regenerateConfig.cjs +20 -20
  20. package/dist/extractor/{watchGuiConfig.cjs → watchHanzoguiConfig.cjs} +15 -15
  21. package/dist/getPragmaOptions.cjs +6 -6
  22. package/dist/helpers/{requireGuiCore.cjs → requireHanzoguiCore.cjs} +12 -12
  23. package/dist/registerRequire.cjs +58 -20
  24. package/dist/worker.cjs +3 -3
  25. package/package.json +22 -22
  26. package/src/check-dep-versions.ts +1 -5
  27. package/src/checkDeps.ts +28 -30
  28. package/src/constants.ts +2 -2
  29. package/src/exports.ts +2 -2
  30. package/src/extractor/babelParse.ts +1 -0
  31. package/src/extractor/bundle.ts +16 -18
  32. package/src/extractor/bundleConfig.ts +62 -62
  33. package/src/extractor/createEvaluator.ts +2 -2
  34. package/src/extractor/createExtractor.ts +62 -55
  35. package/src/extractor/createLogger.ts +5 -3
  36. package/src/extractor/esbuildTsconfigPaths.ts +1 -1
  37. package/src/extractor/extractHelpers.ts +15 -12
  38. package/src/extractor/extractMediaStyle.ts +19 -13
  39. package/src/extractor/extractToClassNames.ts +11 -11
  40. package/src/extractor/extractToNative.ts +13 -13
  41. package/src/extractor/{getGuiConfigPathFromOptionsConfig.ts → getHanzoguiConfigPathFromOptionsConfig.ts} +3 -3
  42. package/src/extractor/getPrefixLogs.ts +3 -3
  43. package/src/extractor/getStaticBindingsForScope.ts +2 -2
  44. package/src/extractor/hasTopLevelAwait.ts +28 -0
  45. package/src/extractor/{loadGui.ts → loadHanzogui.ts} +86 -83
  46. package/src/extractor/regenerateConfig.ts +34 -24
  47. package/src/extractor/{watchGuiConfig.ts → watchHanzoguiConfig.ts} +10 -10
  48. package/src/getPragmaOptions.ts +6 -6
  49. package/src/helpers/requireHanzoguiCore.ts +28 -0
  50. package/src/registerRequire.ts +79 -34
  51. package/src/server.ts +2 -2
  52. package/src/types.ts +13 -10
  53. package/src/worker.ts +7 -7
  54. package/types/check-dep-versions.d.ts.map +1 -1
  55. package/types/checkDeps.d.ts.map +1 -1
  56. package/types/constants.d.ts.map +1 -1
  57. package/types/exports.d.ts +2 -2
  58. package/types/exports.d.ts.map +1 -1
  59. package/types/extractor/babelParse.d.ts.map +1 -1
  60. package/types/extractor/bundle.d.ts +2 -2
  61. package/types/extractor/bundle.d.ts.map +1 -1
  62. package/types/extractor/bundleConfig.d.ts +12 -12
  63. package/types/extractor/bundleConfig.d.ts.map +1 -1
  64. package/types/extractor/createEvaluator.d.ts +2 -2
  65. package/types/extractor/createEvaluator.d.ts.map +1 -1
  66. package/types/extractor/createExtractor.d.ts +5 -5
  67. package/types/extractor/createExtractor.d.ts.map +1 -1
  68. package/types/extractor/createLogger.d.ts +2 -2
  69. package/types/extractor/createLogger.d.ts.map +1 -1
  70. package/types/extractor/extractHelpers.d.ts +8 -8
  71. package/types/extractor/extractHelpers.d.ts.map +1 -1
  72. package/types/extractor/extractMediaStyle.d.ts +4 -4
  73. package/types/extractor/extractMediaStyle.d.ts.map +1 -1
  74. package/types/extractor/extractToClassNames.d.ts +2 -2
  75. package/types/extractor/extractToClassNames.d.ts.map +1 -1
  76. package/types/extractor/extractToNative.d.ts +3 -3
  77. package/types/extractor/extractToNative.d.ts.map +1 -1
  78. package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts +3 -0
  79. package/types/extractor/getHanzoguiConfigPathFromOptionsConfig.d.ts.map +1 -0
  80. package/types/extractor/getPrefixLogs.d.ts +2 -2
  81. package/types/extractor/getPrefixLogs.d.ts.map +1 -1
  82. package/types/extractor/hasTopLevelAwait.d.ts +2 -0
  83. package/types/extractor/hasTopLevelAwait.d.ts.map +1 -0
  84. package/types/extractor/loadHanzogui.d.ts +22 -0
  85. package/types/extractor/loadHanzogui.d.ts.map +1 -0
  86. package/types/extractor/regenerateConfig.d.ts +4 -4
  87. package/types/extractor/regenerateConfig.d.ts.map +1 -1
  88. package/types/extractor/watchHanzoguiConfig.d.ts +5 -0
  89. package/types/extractor/watchHanzoguiConfig.d.ts.map +1 -0
  90. package/types/helpers/requireHanzoguiCore.d.ts +3 -0
  91. package/types/helpers/requireHanzoguiCore.d.ts.map +1 -0
  92. package/types/registerRequire.d.ts +3 -3
  93. package/types/registerRequire.d.ts.map +1 -1
  94. package/types/server.d.ts +2 -2
  95. package/types/server.d.ts.map +1 -1
  96. package/types/types.d.ts +10 -10
  97. package/types/types.d.ts.map +1 -1
  98. package/types/worker.d.ts +4 -4
  99. package/types/worker.d.ts.map +1 -1
  100. package/src/helpers/requireGuiCore.ts +0 -28
  101. package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts +0 -3
  102. package/types/extractor/getGuiConfigPathFromOptionsConfig.d.ts.map +0 -1
  103. package/types/extractor/loadGui.d.ts +0 -22
  104. package/types/extractor/loadGui.d.ts.map +0 -1
  105. package/types/extractor/watchGuiConfig.d.ts +0 -5
  106. package/types/extractor/watchGuiConfig.d.ts.map +0 -1
  107. package/types/helpers/requireGuiCore.d.ts +0 -3
  108. package/types/helpers/requireGuiCore.d.ts.map +0 -1
@@ -275,7 +275,7 @@ const DEFAULT_DEP_TYPES = ["dependencies" /* dependencies */, "devDependencies"
275
275
  ];
276
276
  function check(path) {
277
277
  const options = {
278
- includeDepPattern: ["@hanzo/gui", "react-native-web-lite", "react-native-web-internals"]
278
+ includeDepPattern: ["hanzogui", "react-native-web-lite", "react-native-web-internals"]
279
279
  };
280
280
  if (options && options.depType && options.depType.some(dt => !Object.keys(DEPENDENCY_TYPE).includes(dt))) {
281
281
  throw new Error(`Invalid depType provided. Choices are: ${Object.keys(DEPENDENCY_TYPE).join(", ")}.`);
@@ -37,7 +37,7 @@ var DEPENDENCY_TYPE = /* @__PURE__ */(DEPENDENCY_TYPE2 => {
37
37
  DEPENDENCY_TYPE2["resolutions"] = "resolutions";
38
38
  return DEPENDENCY_TYPE2;
39
39
  })(DEPENDENCY_TYPE || {});
40
- const CRITICAL_PACKAGES = ["@hanzogui/web", "@hanzogui/core", "@hanzo/gui"];
40
+ const CRITICAL_PACKAGES = ["@hanzogui/web", "@hanzogui/core", "hanzogui"];
41
41
  function checkDuplicateInstalls(root) {
42
42
  const nodeModules = (0, import_node_path.join)(root, "node_modules");
43
43
  if (!(0, import_node_fs.existsSync)(nodeModules)) return "";
@@ -64,7 +64,7 @@ function checkDuplicateInstalls(root) {
64
64
  }
65
65
  }
66
66
  if (duplicates.size === 0) return "";
67
- const lines = ["Found duplicate gui installations in node_modules:", "", "This causes multiple runtime instances, which breaks theme/config detection.", ""];
67
+ const lines = ["Found duplicate hanzogui installations in node_modules:", "", "This causes multiple runtime instances, which breaks theme/config detection.", ""];
68
68
  for (const [pkg, locations] of duplicates) {
69
69
  lines.push(` ${pkg}:`);
70
70
  for (const loc of locations) {
@@ -130,7 +130,7 @@ function checkBunLockDuplicates(lockPath) {
130
130
  const content = (0, import_node_fs.readFileSync)(lockPath, "utf8");
131
131
  const duplicates = /* @__PURE__ */new Map();
132
132
  const criticalSet = new Set(CRITICAL_PACKAGES);
133
- const packagePattern = /["'](@gui\/[\w-]+|gui)@([^"'\s,]+)["']/g;
133
+ const packagePattern = /["'](@hanzogui\/[\w-]+|hanzogui)@([^"'\s,]+)["']/g;
134
134
  let match;
135
135
  while ((match = packagePattern.exec(content)) !== null) {
136
136
  const name = match[1];
@@ -150,7 +150,7 @@ function checkYarnLockDuplicates(lockPath) {
150
150
  const content = (0, import_node_fs.readFileSync)(lockPath, "utf8");
151
151
  const duplicates = /* @__PURE__ */new Map();
152
152
  const criticalSet = new Set(CRITICAL_PACKAGES);
153
- const entryPattern = /^"?(@gui\/[\w-]+|gui)@[^":\n]+[":]?\s*$/gm;
153
+ const entryPattern = /^"?(@hanzogui\/[\w-]+|hanzogui)@[^":\n]+[":]?\s*$/gm;
154
154
  const versionPattern = /^\s+version\s+"([^"]+)"/gm;
155
155
  let entryMatch;
156
156
  while ((entryMatch = entryPattern.exec(content)) !== null) {
@@ -204,11 +204,11 @@ function formatLockfileDuplicates(duplicates, lockfileName) {
204
204
  }
205
205
  lines.push("");
206
206
  lines.push("Multiple versions cause duplicate runtime instances, breaking config/theme detection.");
207
- lines.push("Fix: ensure all hanzo-gui packages use the same version range, then dedupe.");
207
+ lines.push("Fix: ensure all hanzogui packages use the same version range, then dedupe.");
208
208
  return lines.join("\n");
209
209
  }
210
210
  function checkConfigExists(root) {
211
- const configNames = ["gui.config.ts", "gui.config.tsx", "gui.config.js", "gui.config.mjs", "gui.config.cjs"];
211
+ const configNames = ["hanzogui.config.ts", "hanzogui.config.tsx", "hanzogui.config.js", "hanzogui.config.mjs", "hanzogui.config.cjs"];
212
212
  const searchDirs = [root, (0, import_node_path.join)(root, "src"), (0, import_node_path.join)(root, "app"), (0, import_node_path.join)(root, "config")];
213
213
  for (const dir of searchDirs) {
214
214
  for (const name of configNames) {
@@ -217,7 +217,7 @@ function checkConfigExists(root) {
217
217
  }
218
218
  }
219
219
  }
220
- const buildConfigNames = ["gui.build.ts", "gui.build.js", "gui.build.mjs", "gui.build.cjs"];
220
+ const buildConfigNames = ["hanzogui.build.ts", "hanzogui.build.js", "hanzogui.build.mjs", "hanzogui.build.cjs"];
221
221
  for (const name of buildConfigNames) {
222
222
  const buildPath = (0, import_node_path.join)(root, name);
223
223
  if ((0, import_node_fs.existsSync)(buildPath)) {
@@ -235,8 +235,8 @@ function checkConfigExists(root) {
235
235
  if ((0, import_node_fs.existsSync)(pkgJsonPath)) {
236
236
  try {
237
237
  const pkg = JSON.parse((0, import_node_fs.readFileSync)(pkgJsonPath, "utf8"));
238
- if (pkg.gui?.config) {
239
- const configPath = (0, import_node_path.join)(root, pkg.gui.config);
238
+ if (pkg.hanzogui?.config) {
239
+ const configPath = (0, import_node_path.join)(root, pkg.hanzogui.config);
240
240
  if ((0, import_node_fs.existsSync)(configPath)) return "";
241
241
  }
242
242
  } catch {}
@@ -247,7 +247,7 @@ function checkConfigExists(root) {
247
247
  if (pkg.workspaces) return "";
248
248
  } catch {}
249
249
  }
250
- return ["No gui.config file found.", "", "Gui requires a config file (e.g. gui.config.ts) that calls createGui().", `Without it, components will throw "Can't find GUI configuration" at runtime.`, "", "See: https://gui.hanzo.ai/docs/core/configuration"].join("\n");
250
+ return ["No hanzogui.config file found.", "", "Hanzogui requires a config file (e.g. hanzogui.config.ts) that calls createHanzogui().", `Without it, components will throw "Can't find Hanzogui configuration" at runtime.`, "", "See: https://hanzogui.dev/docs/core/configuration"].join("\n");
251
251
  }
252
252
  async function checkDeps(root) {
253
253
  const issues = [];
@@ -260,7 +260,7 @@ async function checkDeps(root) {
260
260
  const configSummary = checkConfigExists(root);
261
261
  if (configSummary) issues.push(configSummary);
262
262
  if (issues.length === 0) {
263
- console.info(`Gui dependencies look good \u2705`);
263
+ console.info(`Hanzogui dependencies look good \u2705`);
264
264
  process.exit(0);
265
265
  }
266
266
  for (let i = 0; i < issues.length; i++) {
@@ -44,8 +44,8 @@ var import_find_cache_dir = __toESM(require("find-cache-dir"));
44
44
  const CSS_FILE_NAME = "__snack.css";
45
45
  const MEDIA_SEP = "_";
46
46
  const cacheDir = (0, import_find_cache_dir.default)({
47
- name: "hanzo-gui",
47
+ name: "hanzogui",
48
48
  create: true
49
49
  });
50
50
  const FAILED_EVAL = /* @__PURE__ */Symbol("failed_style_eval");
51
- const SHOULD_DEBUG = process.env.DEBUG === "*" || process.env.DEBUG?.startsWith("@hanzo/gui");
51
+ const SHOULD_DEBUG = process.env.DEBUG === "*" || process.env.DEBUG?.startsWith("hanzogui");
package/dist/exports.cjs CHANGED
@@ -38,8 +38,8 @@ __reExport(exports_exports, require("./extractor/extractToClassNames.cjs"), modu
38
38
  __reExport(exports_exports, require("./extractor/concatClassName.cjs"), module.exports);
39
39
  __reExport(exports_exports, require("./extractor/extractToNative.cjs"), module.exports);
40
40
  __reExport(exports_exports, require("./extractor/extractHelpers.cjs"), module.exports);
41
- __reExport(exports_exports, require("./extractor/loadGui.cjs"), module.exports);
42
- __reExport(exports_exports, require("./extractor/watchGuiConfig.cjs"), module.exports);
41
+ __reExport(exports_exports, require("./extractor/loadHanzogui.cjs"), module.exports);
42
+ __reExport(exports_exports, require("./extractor/watchHanzoguiConfig.cjs"), module.exports);
43
43
  __reExport(exports_exports, require("./extractor/createLogger.cjs"), module.exports);
44
44
  __reExport(exports_exports, require("./registerRequire.cjs"), module.exports);
45
45
  var import_detectModuleFormat = require("./extractor/detectModuleFormat.cjs");
@@ -38,7 +38,7 @@ __export(babelParse_exports, {
38
38
  });
39
39
  module.exports = __toCommonJS(babelParse_exports);
40
40
  var babelParser = __toESM(require("@babel/parser"));
41
- const plugins = ["asyncGenerators", "classProperties", "dynamicImport", "functionBind", "jsx", "numericSeparator", "objectRestSpread", "optionalCatchBinding", "decorators-legacy", "typescript", "optionalChaining", "nullishCoalescingOperator"];
41
+ const plugins = ["asyncGenerators", "classProperties", "dynamicImport", "functionBind", "jsx", "numericSeparator", "objectRestSpread", "optionalCatchBinding", "decorators-legacy", "typescript", "optionalChaining", "nullishCoalescingOperator", "topLevelAwait"];
42
42
  const parserOptions = Object.freeze({
43
43
  plugins,
44
44
  sourceType: "module"
@@ -35,7 +35,7 @@ var bundle_exports = {};
35
35
  __export(bundle_exports, {
36
36
  esbuildIgnoreFilesRegex: () => esbuildIgnoreFilesRegex,
37
37
  esbuildLoaderConfig: () => esbuildLoaderConfig,
38
- esbundleGuiConfig: () => esbundleGuiConfig
38
+ esbundleHanzoguiConfig: () => esbundleHanzoguiConfig
39
39
  });
40
40
  module.exports = __toCommonJS(bundle_exports);
41
41
  var import_node_fs = require("node:fs");
@@ -43,7 +43,8 @@ var import_esbuild = __toESM(require("esbuild"));
43
43
  var FS = __toESM(require("fs-extra"));
44
44
  var import_detectModuleFormat = require("./detectModuleFormat.cjs");
45
45
  var import_esbuildAliasPlugin = require("./esbuildAliasPlugin.cjs");
46
- var import_loadGui = require("./loadGui.cjs");
46
+ var import_hasTopLevelAwait = require("./hasTopLevelAwait.cjs");
47
+ var import_loadHanzogui = require("./loadHanzogui.cjs");
47
48
  var import_esbuildTsconfigPaths = require("./esbuildTsconfigPaths.cjs");
48
49
  const esbuildLoaderConfig = {
49
50
  ".js": "jsx",
@@ -77,20 +78,17 @@ function getESBuildConfig({
77
78
  resolvePlatformSpecificEntries,
78
79
  ...options
79
80
  }, platform, aliases) {
80
- if (process.env.DEBUG?.startsWith("@hanzo/gui")) {
81
- console.info(`Building`, entryPoints);
82
- }
83
- const resolvedEntryPoints = !resolvePlatformSpecificEntries ? entryPoints : entryPoints.map(import_loadGui.resolveWebOrNativeSpecificEntry);
81
+ if (process.env.DEBUG?.startsWith("hanzogui")) console.info(`Building`, entryPoints);
82
+ const resolvedEntryPoints = !resolvePlatformSpecificEntries ? entryPoints : entryPoints.map(import_loadHanzogui.resolveWebOrNativeSpecificEntry);
84
83
  const detectedFormat = options.format || detectEntryFormat(resolvedEntryPoints[0]);
85
- const res = {
84
+ return {
86
85
  bundle: true,
87
86
  entryPoints: resolvedEntryPoints,
88
87
  format: detectedFormat,
89
- // for ESM: prefer "module" field for resolution, add require() shim for bundled CJS deps
90
88
  ...(detectedFormat === "esm" ? {
91
89
  mainFields: ["module", "main"],
92
90
  banner: {
93
- js: 'import { createRequire as __cr } from "module"; const require = __cr(import.meta.url);'
91
+ js: "import { createRequire as __cr } from \"module\"; const require = __cr(import.meta.url);"
94
92
  }
95
93
  } : {}),
96
94
  target: "node24",
@@ -98,7 +96,7 @@ function getESBuildConfig({
98
96
  jsxFactory: "react",
99
97
  allowOverwrite: true,
100
98
  keepNames: true,
101
- resolveExtensions: [...(true ? [".web.tsx", ".web.ts", ".web.jsx", ".web.js"] : [".native.tsx", ".native.ts", ".native.jsx", ".native.js"]), ".tsx", ".ts", ".jsx", ".js"],
99
+ resolveExtensions: [...[".web.tsx", ".web.ts", ".web.jsx", ".web.js"], ".tsx", ".ts", ".jsx", ".js"],
102
100
  platform: "node",
103
101
  tsconfigRaw: {
104
102
  compilerOptions: {
@@ -116,12 +114,8 @@ function getESBuildConfig({
116
114
  build.onLoad({
117
115
  filter: /\.(ts|tsx|js|jsx|mjs)$/
118
116
  }, args => {
119
- if (!isCjs) {
120
- return null;
121
- }
122
- if (args.path.includes("node_modules") && !args.path.includes("@gui")) {
123
- return null;
124
- }
117
+ if (!isCjs) return null;
118
+ if (args.path.includes("node_modules") && !args.path.includes("@hanzogui")) return null;
125
119
  let contents = (0, import_node_fs.readFileSync)(args.path, "utf8");
126
120
  let modified = false;
127
121
  if (contents.includes("import.meta.env")) {
@@ -129,29 +123,25 @@ function getESBuildConfig({
129
123
  modified = true;
130
124
  }
131
125
  if (contents.includes("import.meta.url")) {
132
- contents = contents.replace(/import\.meta\.url/g, '""');
126
+ contents = contents.replace(/import\.meta\.url/g, "\"\"");
133
127
  modified = true;
134
128
  }
135
129
  if (contents.includes("import.meta.main")) {
136
130
  contents = contents.replace(/import\.meta\.main/g, "false");
137
131
  modified = true;
138
132
  }
139
- if (/^\s*(?:const|let|var|export)\s+[^=]*=\s*await\b/m.test(contents) || /^await\s/m.test(contents)) {
140
- if (process.env.DEBUG?.startsWith("@hanzo/gui")) {
141
- console.info(`[hanzo-gui] stubbing file with top-level await: ${args.path}`);
142
- }
133
+ if ((0, import_hasTopLevelAwait.hasTopLevelAwait)(contents, args.path)) {
134
+ if (process.env.DEBUG?.startsWith("hanzogui")) console.info(`[hanzogui] stubbing file with top-level await: ${args.path}`);
143
135
  return {
144
136
  contents: `// stubbed - contains top-level await
145
- module.exports = {}`,
137
+ export default {}`,
146
138
  loader: "js"
147
139
  };
148
140
  }
149
- if (modified) {
150
- return {
151
- contents,
152
- loader: args.path.endsWith(".tsx") ? "tsx" : args.path.endsWith(".ts") ? "ts" : args.path.endsWith(".jsx") ? "jsx" : "js"
153
- };
154
- }
141
+ if (modified) return {
142
+ contents,
143
+ loader: args.path.endsWith(".tsx") ? "tsx" : args.path.endsWith(".ts") ? "ts" : args.path.endsWith(".jsx") ? "jsx" : "js"
144
+ };
155
145
  return null;
156
146
  });
157
147
  }
@@ -160,11 +150,9 @@ module.exports = {}`,
160
150
  setup(build) {
161
151
  const proxyWormPath = require.resolve("@hanzogui/proxy-worm");
162
152
  build.onResolve({
163
- filter: /^@gui\/(core|web)$/
153
+ filter: /^@hanzogui\/(core|web)$/
164
154
  }, args => {
165
- if (args.kind === "entry-point") {
166
- return null;
167
- }
155
+ if (args.kind === "entry-point") return null;
168
156
  return {
169
157
  path: platform === "native" ? "@hanzogui/core/native" : args.path,
170
158
  external: true
@@ -214,21 +202,17 @@ module.exports = {}`,
214
202
  })],
215
203
  ...options
216
204
  };
217
- return res;
218
205
  }
219
206
  function detectEntryFormat(entryPoint) {
220
- if (entryPoint.startsWith("/") || entryPoint.startsWith(".")) {
221
- return (0, import_detectModuleFormat.detectModuleFormat)(entryPoint);
222
- }
207
+ if (entryPoint.startsWith("/") || entryPoint.startsWith(".")) return (0, import_detectModuleFormat.detectModuleFormat)(entryPoint);
223
208
  try {
224
209
  const pkgJsonPath = require.resolve(entryPoint + "/package.json");
225
- const pkg = JSON.parse((0, import_node_fs.readFileSync)(pkgJsonPath, "utf-8"));
226
- return pkg.type === "module" ? "esm" : "cjs";
210
+ return JSON.parse((0, import_node_fs.readFileSync)(pkgJsonPath, "utf-8")).type === "module" ? "esm" : "cjs";
227
211
  } catch {
228
212
  return "cjs";
229
213
  }
230
214
  }
231
- async function esbundleGuiConfig(props, platform, aliases) {
215
+ async function esbundleHanzoguiConfig(props, platform, aliases) {
232
216
  const config = getESBuildConfig(props, platform, aliases);
233
217
  const tmpFile = props.outfile + ".tmp." + process.pid;
234
218
  const result = await import_esbuild.default.build({
@@ -43,7 +43,7 @@ __export(bundleConfig_exports, {
43
43
  loadComponentsInner: () => loadComponentsInner,
44
44
  loadComponentsInnerSync: () => loadComponentsInnerSync,
45
45
  loadComponentsSync: () => loadComponentsSync,
46
- writeGuiCSS: () => writeGuiCSS
46
+ writeHanzoguiCSS: () => writeHanzoguiCSS
47
47
  });
48
48
  module.exports = __toCommonJS(bundleConfig_exports);
49
49
  var import_generator = __toESM(require("@babel/generator"));
@@ -60,14 +60,15 @@ var import_promises = require("node:fs/promises");
60
60
  var import_registerRequire = require("../registerRequire.cjs");
61
61
  var import_babelParse = require("./babelParse.cjs");
62
62
  var import_bundle = require("./bundle.cjs");
63
- var import_getGuiConfigPathFromOptionsConfig = require("./getGuiConfigPathFromOptionsConfig.cjs");
64
- var import_requireGuiCore = require("../helpers/requireGuiCore.cjs");
63
+ var import_getHanzoguiConfigPathFromOptionsConfig = require("./getHanzoguiConfigPathFromOptionsConfig.cjs");
64
+ var import_hasTopLevelAwait = require("./hasTopLevelAwait.cjs");
65
+ var import_requireHanzoguiCore = require("../helpers/requireHanzoguiCore.cjs");
65
66
  var import_detectModuleFormat = require("./detectModuleFormat.cjs");
66
67
  const activeTempFiles = /* @__PURE__ */new Set();
67
68
  function getDynamicEvalOutfile(name, format, contents) {
68
69
  const ext = format === "esm" ? "mjs" : "cjs";
69
70
  const hash = (0, import_node_crypto.createHash)("sha1").update(name).update("\0").update(format).update("\0").update(contents).digest("hex").slice(0, 10);
70
- return (0, import_node_path.join)(process.cwd(), ".gui", `dynamic-eval-${hash}-${(0, import_node_path.basename)(name)}.${ext}`);
71
+ return (0, import_node_path.join)(process.cwd(), ".hanzogui", `dynamic-eval-${hash}-${(0, import_node_path.basename)(name)}.${ext}`);
71
72
  }
72
73
  function getEsbuildStdinLoader(filePath) {
73
74
  if (filePath.endsWith(".tsx")) return "tsx";
@@ -122,7 +123,7 @@ const handleEsmFeaturesPlugin = {
122
123
  if (!isCjs) {
123
124
  return null;
124
125
  }
125
- if (args.path.includes("node_modules") && !args.path.includes("@gui")) {
126
+ if (args.path.includes("node_modules") && !args.path.includes("@hanzogui")) {
126
127
  return null;
127
128
  }
128
129
  let contents = (0, import_node_fs.readFileSync)(args.path, "utf8");
@@ -139,13 +140,15 @@ const handleEsmFeaturesPlugin = {
139
140
  contents = contents.replace(/import\.meta\.main/g, "false");
140
141
  modified = true;
141
142
  }
142
- if (/^\s*(?:const|let|var|export)\s+[^=]*=\s*await\b/m.test(contents) || /^await\s/m.test(contents)) {
143
- if (process.env.DEBUG?.startsWith("@hanzo/gui")) {
144
- console.info(`[hanzo-gui] stubbing file with top-level await: ${args.path}`);
143
+ if ((0, import_hasTopLevelAwait.hasTopLevelAwait)(contents, args.path)) {
144
+ if (process.env.DEBUG?.startsWith("hanzogui")) {
145
+ console.info(`[hanzogui] stubbing file with top-level await: ${args.path}`);
145
146
  }
146
147
  return {
148
+ // Keep this as an ESM-shaped stub so esbuild doesn't inline a top-level
149
+ // `module.exports = {}` into the parent bundle and wipe its exports.
147
150
  contents: `// stubbed - contains top-level await
148
- module.exports = {}`,
151
+ export default {}`,
149
152
  loader: "js"
150
153
  };
151
154
  }
@@ -196,24 +199,24 @@ async function getBundledConfig(props, rebuild = false) {
196
199
  }
197
200
  return currentBundle;
198
201
  }
199
- global.guiLastLoaded ||= 0;
202
+ global.hanzoguiLastLoaded ||= 0;
200
203
  function updateLastLoaded(config) {
201
- global.guiLastLoaded = Date.now();
202
- global.guiLastBundledConfig = config;
204
+ global.hanzoguiLastLoaded = Date.now();
205
+ global.hanzoguiLastBundledConfig = config;
203
206
  }
204
207
  let hasBundledOnce = false;
205
208
  let hasLoggedBuild = false;
206
209
  async function bundleConfig(props) {
207
- if (global.guiLastBundledConfig && Date.now() - global.guiLastLoaded < 3e3) {
208
- return global.guiLastBundledConfig;
210
+ if (global.hanzoguiLastBundledConfig && Date.now() - global.hanzoguiLastLoaded < 3e3) {
211
+ return global.hanzoguiLastBundledConfig;
209
212
  }
210
213
  try {
211
214
  isBundling = true;
212
- const configEntry = props.config ? (0, import_getGuiConfigPathFromOptionsConfig.getGuiConfigPathFromOptionsConfig)(props.config) : "";
213
- const tmpDir = (0, import_node_path.join)(process.cwd(), ".gui");
215
+ const configEntry = props.config ? (0, import_getHanzoguiConfigPathFromOptionsConfig.getHanzoguiConfigPathFromOptionsConfig)(props.config) : "";
216
+ const tmpDir = (0, import_node_path.join)(process.cwd(), ".hanzogui");
214
217
  const configFormat = configEntry ? (0, import_detectModuleFormat.detectModuleFormat)(configEntry) : "cjs";
215
218
  const configExt = configFormat === "esm" ? ".mjs" : ".cjs";
216
- const configOutPath = (0, import_node_path.join)(tmpDir, `gui.config${configExt}`);
219
+ const configOutPath = (0, import_node_path.join)(tmpDir, `hanzogui.config${configExt}`);
217
220
  const baseComponents = (props.components || []).filter(x => x !== "@hanzogui/core");
218
221
  const componentFormats = baseComponents.map(mod => {
219
222
  try {
@@ -228,7 +231,7 @@ async function bundleConfig(props) {
228
231
  const ext = componentFormats[i] === "esm" ? ".mjs" : ".cjs";
229
232
  return (0, import_node_path.join)(tmpDir, `${componentModule.split(import_node_path.sep).join("-").replace(/[^a-z0-9]+/gi, "")}-components.config${ext}`);
230
233
  });
231
- if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("@hanzo/gui")) {
234
+ if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("hanzogui")) {
232
235
  console.info(`Building config entry`, configEntry);
233
236
  }
234
237
  let shouldBuild = !props.disableInitialBuild;
@@ -247,7 +250,7 @@ async function bundleConfig(props) {
247
250
  await FS.ensureDir(tmpDir);
248
251
  } catch {}
249
252
  const start = Date.now();
250
- await Promise.all([props.config ? (0, import_bundle.esbundleGuiConfig)({
253
+ await Promise.all([props.config ? (0, import_bundle.esbundleHanzoguiConfig)({
251
254
  entryPoints: [configEntry],
252
255
  external,
253
256
  outfile: configOutPath,
@@ -255,7 +258,7 @@ async function bundleConfig(props) {
255
258
  format: configFormat,
256
259
  ...esbuildExtraOptions
257
260
  }, props.platform || "web") : null, ...baseComponents.map((componentModule, i) => {
258
- return (0, import_bundle.esbundleGuiConfig)({
261
+ return (0, import_bundle.esbundleHanzoguiConfig)({
259
262
  entryPoints: [componentModule],
260
263
  resolvePlatformSpecificEntries: true,
261
264
  external,
@@ -268,8 +271,8 @@ async function bundleConfig(props) {
268
271
  if (!hasLoggedBuild && !props["_skipBuildLog"]) {
269
272
  hasLoggedBuild = true;
270
273
  (0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, `
271
- \u27A1 [hanzo-gui] built config, components, prompt (${Date.now() - start}ms)`);
272
- if (process.env.DEBUG?.startsWith("@hanzo/gui")) {
274
+ \u27A1 [hanzogui] built config, components, prompt (${Date.now() - start}ms)`);
275
+ if (process.env.DEBUG?.startsWith("hanzogui")) {
273
276
  (0, import_cli_color.colorLog)(import_cli_color.Color.Dim, `
274
277
  Config .${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), configOutPath)}
275
278
  Components ${componentOutPaths.map(p => `.${import_node_path.sep}${(0, import_node_path.relative)(process.cwd(), p)}`).join("\n ")}
@@ -303,17 +306,17 @@ async function bundleConfig(props) {
303
306
  throw new Error(`No config: ${config}`);
304
307
  }
305
308
  if (config._isProxyWorm) {
306
- throw new Error(`Got a proxied config - likely a module loading error. Set DEBUG=hanzo-gui for details.`);
309
+ throw new Error(`Got a proxied config - likely a module loading error. Set DEBUG=hanzogui for details.`);
307
310
  }
308
311
  loadedConfig = config;
309
312
  if (!config.parsed) {
310
313
  const {
311
- createGui
312
- } = (0, import_requireGuiCore.requireGuiCore)(props.platform || "web");
313
- config = createGui(config);
314
+ createHanzogui
315
+ } = (0, import_requireHanzoguiCore.requireHanzoguiCore)(props.platform || "web");
316
+ config = createHanzogui(config);
314
317
  }
315
318
  if (props.outputCSS) {
316
- await writeGuiCSS(props.outputCSS, config);
319
+ await writeHanzoguiCSS(props.outputCSS, config);
317
320
  }
318
321
  let components = await loadComponents({
319
322
  ...props,
@@ -325,25 +328,25 @@ async function bundleConfig(props) {
325
328
  for (const component of components) {
326
329
  component.moduleName = baseComponents[componentOutPaths.indexOf(component.moduleName)] || component.moduleName;
327
330
  if (!component.moduleName) {
328
- if (process.env.DEBUG?.includes("@hanzo/gui") || process.env.IS_GUI_DEV) {
331
+ if (process.env.DEBUG?.includes("hanzogui") || process.env.IS_TAMAGUI_DEV) {
329
332
  console.warn(`\u26A0\uFE0F no module name found: ${component.moduleName} ${JSON.stringify(baseComponents)} in ${JSON.stringify(componentOutPaths)}`);
330
333
  }
331
334
  }
332
335
  }
333
- if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("@hanzo/gui")) {
336
+ if (process.env.NODE_ENV === "development" && process.env.DEBUG?.startsWith("hanzogui")) {
334
337
  console.info("Loaded components", components);
335
338
  }
336
339
  const res = {
337
340
  components,
338
341
  nameToPaths: {},
339
- guiConfig: config
342
+ hanzoguiConfig: config
340
343
  };
341
344
  currentBundle = res;
342
345
  updateLastLoaded(res);
343
346
  return res;
344
347
  } catch (err) {
345
- console.error(`Error bundling gui config: ${err?.message} (run with DEBUG=hanzo-gui to see stack)`);
346
- if (process.env.DEBUG?.includes("@hanzo/gui")) {
348
+ console.error(`Error bundling hanzogui config: ${err?.message} (run with DEBUG=hanzogui to see stack)`);
349
+ if (process.env.DEBUG?.includes("hanzogui")) {
347
350
  console.error(err.stack);
348
351
  }
349
352
  } finally {
@@ -352,9 +355,9 @@ async function bundleConfig(props) {
352
355
  waitForBundle.clear();
353
356
  }
354
357
  }
355
- async function writeGuiCSS(outputCSS, config) {
358
+ async function writeHanzoguiCSS(outputCSS, config) {
356
359
  const flush = async () => {
357
- (0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [hanzo-gui] output css: ${outputCSS}`);
360
+ (0, import_cli_color.colorLog)(import_cli_color.Color.FgYellow, ` \u27A1 [hanzogui] output css: ${outputCSS}`);
358
361
  await FS.writeFile(outputCSS, css);
359
362
  };
360
363
  const css = config.getCSS();
@@ -444,7 +447,7 @@ async function loadComponentsInner(props, forceExports = false) {
444
447
  loader: import_bundle.esbuildLoaderConfig
445
448
  });
446
449
  }
447
- if (process.env.DEBUG === "@hanzo/gui") {
450
+ if (process.env.DEBUG === "hanzogui") {
448
451
  console.info(`loadModule`, loadModule, format);
449
452
  }
450
453
  let moduleResult;
@@ -477,7 +480,7 @@ async function loadComponentsInner(props, forceExports = false) {
477
480
  } catch (err) {
478
481
  console.info("babel err", err, writtenContents);
479
482
  writtenContents = fileContents;
480
- if (process.env.DEBUG?.startsWith("@hanzo/gui")) {
483
+ if (process.env.DEBUG?.startsWith("hanzogui")) {
481
484
  console.info(`Error parsing babel likely`, err);
482
485
  }
483
486
  try {
@@ -485,9 +488,9 @@ async function loadComponentsInner(props, forceExports = false) {
485
488
  forceExports: false
486
489
  });
487
490
  } catch (err2) {
488
- if (process.env.GUI_ENABLE_WARN_DYNAMIC_LOAD) {
491
+ if (process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
489
492
  console.info(`
490
- Gui attempted but failed to dynamically optimize components in:
493
+ Hanzogui attempted but failed to dynamically optimize components in:
491
494
  ${name}
492
495
  `);
493
496
  console.info(err2);
@@ -510,7 +513,7 @@ isDynamic: `, isDynamic);
510
513
  cacheComponents[key] = results;
511
514
  return results;
512
515
  } catch (err) {
513
- console.info(`Gui error bundling components`, err.message, err.stack);
516
+ console.info(`Hanzogui error bundling components`, err.message, err.stack);
514
517
  return null;
515
518
  } finally {
516
519
  unregister();
@@ -565,7 +568,7 @@ function loadComponentsInnerSync(props, forceExports = false) {
565
568
  loader: import_bundle.esbuildLoaderConfig
566
569
  });
567
570
  }
568
- if (process.env.DEBUG === "@hanzo/gui") {
571
+ if (process.env.DEBUG === "hanzogui") {
569
572
  console.info(`loadModule`, loadModule, require.resolve(loadModule));
570
573
  }
571
574
  const moduleResult = require(loadModule);
@@ -593,7 +596,7 @@ function loadComponentsInnerSync(props, forceExports = false) {
593
596
  } catch (err) {
594
597
  console.info("babel err", err, writtenContents);
595
598
  writtenContents = fileContents;
596
- if (process.env.DEBUG?.startsWith("@hanzo/gui")) {
599
+ if (process.env.DEBUG?.startsWith("hanzogui")) {
597
600
  console.info(`Error parsing babel likely`, err);
598
601
  }
599
602
  } finally {
@@ -604,9 +607,9 @@ function loadComponentsInnerSync(props, forceExports = false) {
604
607
  forceExports: false
605
608
  });
606
609
  } catch (err) {
607
- if (process.env.GUI_ENABLE_WARN_DYNAMIC_LOAD) {
610
+ if (process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
608
611
  console.info(`
609
- Gui attempted but failed to dynamically optimize components in:
612
+ Hanzogui attempted but failed to dynamically optimize components in:
610
613
  ${name}
611
614
  `);
612
615
  console.info(err);
@@ -623,7 +626,7 @@ isDynamic: `, isDynamic);
623
626
  cacheComponents[key] = info;
624
627
  return info;
625
628
  } catch (err) {
626
- console.info(`Gui error bundling components`, err.message, err.stack);
629
+ console.info(`Hanzogui error bundling components`, err.message, err.stack);
627
630
  return null;
628
631
  } finally {
629
632
  unregister();
@@ -648,7 +651,7 @@ function getComponentStaticConfigByName(name, exported) {
648
651
  throw new Error(`Invalid export from package ${name}: ${typeof exported}`);
649
652
  }
650
653
  for (const key in exported) {
651
- const found = getGuiComponent(key, exported[key]);
654
+ const found = getHanzoguiComponent(key, exported[key]);
652
655
  if (found) {
653
656
  const {
654
657
  Component,
@@ -660,14 +663,14 @@ function getComponentStaticConfigByName(name, exported) {
660
663
  }
661
664
  }
662
665
  } catch (err) {
663
- if (process.env.GUI_ENABLE_WARN_DYNAMIC_LOAD) {
664
- console.error(`Gui failed getting components from ${name} (Disable error by setting environment variable GUI_ENABLE_WARN_DYNAMIC_LOAD=1)`);
666
+ if (process.env.TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD) {
667
+ console.error(`Hanzogui failed getting components from ${name} (Disable error by setting environment variable TAMAGUI_ENABLE_WARN_DYNAMIC_LOAD=1)`);
665
668
  console.error(err);
666
669
  }
667
670
  }
668
671
  return components;
669
672
  }
670
- function getGuiComponent(name, Component) {
673
+ function getHanzoguiComponent(name, Component) {
671
674
  if (name[0].toUpperCase() !== name[0]) {
672
675
  return;
673
676
  }