@hanzogui/static 3.0.6 → 4.3.1

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 (67) hide show
  1. package/dist/check-dep-versions.cjs +201 -96
  2. package/dist/checkDeps.cjs +163 -92
  3. package/dist/constants.cjs +32 -30
  4. package/dist/exports.cjs +15 -13
  5. package/dist/extractor/accessSafe.cjs +25 -23
  6. package/dist/extractor/babelParse.cjs +30 -28
  7. package/dist/extractor/buildClassName.cjs +59 -35
  8. package/dist/extractor/bundle.cjs +159 -104
  9. package/dist/extractor/bundleConfig.cjs +463 -263
  10. package/dist/extractor/concatClassName.cjs +41 -29
  11. package/dist/extractor/createEvaluator.cjs +54 -41
  12. package/dist/extractor/createExtractor.cjs +1338 -661
  13. package/dist/extractor/createLogger.cjs +30 -25
  14. package/dist/extractor/detectModuleFormat.cjs +22 -16
  15. package/dist/extractor/ensureImportingConcat.cjs +31 -25
  16. package/dist/extractor/errors.cjs +12 -10
  17. package/dist/extractor/esbuildAliasPlugin.cjs +28 -16
  18. package/dist/extractor/esbuildTsconfigPaths.cjs +58 -36
  19. package/dist/extractor/evaluateAstNode.cjs +104 -59
  20. package/dist/extractor/extractHelpers.cjs +130 -67
  21. package/dist/extractor/extractMediaStyle.cjs +110 -69
  22. package/dist/extractor/extractToClassNames.cjs +336 -230
  23. package/dist/extractor/extractToNative.cjs +244 -149
  24. package/dist/extractor/findTopmostFunction.cjs +22 -13
  25. package/dist/extractor/generatedUid.cjs +39 -28
  26. package/dist/extractor/getGuiConfigPathFromOptionsConfig.cjs +20 -14
  27. package/dist/extractor/getPrefixLogs.cjs +12 -10
  28. package/dist/extractor/getPropValueFromAttributes.cjs +52 -34
  29. package/dist/extractor/getSourceModule.cjs +73 -37
  30. package/dist/extractor/getStaticBindingsForScope.cjs +131 -68
  31. package/dist/extractor/hoistClassNames.cjs +46 -32
  32. package/dist/extractor/literalToAst.cjs +67 -42
  33. package/dist/extractor/loadFile.cjs +9 -3
  34. package/dist/extractor/loadGui.cjs +198 -109
  35. package/dist/extractor/logLines.cjs +27 -19
  36. package/dist/extractor/normalizeTernaries.cjs +66 -44
  37. package/dist/extractor/propsToFontFamilyCache.cjs +15 -11
  38. package/dist/extractor/regenerateConfig.cjs +109 -81
  39. package/dist/extractor/removeUnusedHooks.cjs +73 -41
  40. package/dist/extractor/timer.cjs +23 -14
  41. package/dist/extractor/validHTMLAttributes.cjs +61 -59
  42. package/dist/extractor/watchGuiConfig.cjs +35 -23
  43. package/dist/getPragmaOptions.cjs +34 -19
  44. package/dist/helpers/memoize.cjs +24 -16
  45. package/dist/helpers/requireGuiCore.cjs +22 -15
  46. package/dist/index.cjs +26 -24
  47. package/dist/registerRequire.cjs +132 -77
  48. package/dist/server.cjs +35 -28
  49. package/dist/types.cjs +7 -5
  50. package/dist/worker.cjs +62 -40
  51. package/package.json +2 -2
  52. package/src/checkDeps.ts +1 -1
  53. package/src/extractor/bundle.ts +1 -1
  54. package/src/extractor/bundleConfig.ts +5 -5
  55. package/src/extractor/createExtractor.ts +28 -13
  56. package/src/extractor/createLogger.ts +1 -3
  57. package/src/extractor/extractToNative.ts +35 -9
  58. package/src/extractor/loadGui.ts +4 -4
  59. package/src/extractor/regenerateConfig.ts +2 -2
  60. package/src/getPragmaOptions.ts +2 -2
  61. package/src/helpers/requireGuiCore.ts +6 -6
  62. package/src/registerRequire.ts +4 -4
  63. package/src/worker.ts +1 -1
  64. package/types/extractor/createExtractor.d.ts.map +1 -1
  65. package/types/extractor/createLogger.d.ts.map +1 -1
  66. package/types/extractor/extractToNative.d.ts.map +1 -1
  67. package/types/worker.d.ts +1 -1
@@ -3,43 +3,53 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var watchGuiConfig_exports = {};
22
24
  __export(watchGuiConfig_exports, {
23
25
  watchGuiConfig: () => watchGuiConfig
24
26
  });
25
27
  module.exports = __toCommonJS(watchGuiConfig_exports);
26
- var import_loadGui = require("./loadGui.cjs"),
27
- import_regenerateConfig = require("./regenerateConfig.cjs");
28
- let isWatching = !1;
28
+ var import_loadGui = require("./loadGui.cjs");
29
+ var import_regenerateConfig = require("./regenerateConfig.cjs");
30
+ let isWatching = false;
29
31
  async function watchGuiConfig(guiOptions) {
30
- if (process.env.NODE_ENV === "production") return {
31
- dispose() {}
32
- };
33
- if (isWatching) return;
34
- isWatching = !0;
32
+ if (process.env.NODE_ENV === "production") {
33
+ return {
34
+ dispose() {}
35
+ };
36
+ }
37
+ if (isWatching) {
38
+ return;
39
+ }
40
+ isWatching = true;
35
41
  const options = await (0, import_loadGui.getOptions)({
36
42
  guiOptions
37
43
  });
38
- if (!options.guiOptions.config) throw isWatching = !1, new Error("No config");
44
+ if (!options.guiOptions.config) {
45
+ isWatching = false;
46
+ throw new Error(`No config`);
47
+ }
39
48
  const disposeConfigWatcher = await (0, import_loadGui.esbuildWatchFiles)(options.guiOptions.config, async () => {
40
- await (0, import_loadGui.generateThemesAndLog)(options.guiOptions), await (0, import_regenerateConfig.regenerateConfig)(options.guiOptions, null, !0);
41
- }),
42
- themeBuilderInput = options.guiOptions.themeBuilder?.input;
49
+ await (0, import_loadGui.generateThemesAndLog)(options.guiOptions);
50
+ await (0, import_regenerateConfig.regenerateConfig)(options.guiOptions, null, true);
51
+ });
52
+ const themeBuilderInput = options.guiOptions.themeBuilder?.input;
43
53
  let disposeThemesWatcher;
44
54
  if (themeBuilderInput) {
45
55
  let inputPath = themeBuilderInput;
@@ -52,7 +62,9 @@ async function watchGuiConfig(guiOptions) {
52
62
  }
53
63
  return {
54
64
  dispose() {
55
- isWatching = !1, disposeConfigWatcher(), disposeThemesWatcher?.();
65
+ isWatching = false;
66
+ disposeConfigWatcher();
67
+ disposeThemesWatcher?.();
56
68
  }
57
69
  };
58
70
  }
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var getPragmaOptions_exports = {};
22
24
  __export(getPragmaOptions_exports, {
@@ -27,31 +29,44 @@ function getPragmaOptions({
27
29
  source,
28
30
  path
29
31
  }) {
30
- let shouldPrintDebug = !1,
31
- shouldDisable = !1;
32
+ let shouldPrintDebug = false;
33
+ let shouldDisable = false;
32
34
  const firstLines = source.slice(0, 800);
33
35
  let pragma = "";
34
- for (const line of firstLines.split(`
35
- `)) {
36
+ for (const line of firstLines.split("\n")) {
36
37
  const trimmed = line.trim();
37
- if (trimmed && !trimmed.startsWith("//") && !trimmed.startsWith("/*")) break;
38
- if (pragma = trimmed.match(/(\/\/|\/\*)\s?!?\s?(gui-ignore|debug|debug-verbose)(\n|\s|$).*/)?.[2].trim() || "", pragma) {
38
+ if (trimmed && !trimmed.startsWith("//") && !trimmed.startsWith("/*")) {
39
+ break;
40
+ }
41
+ pragma = trimmed.match(/(\/\/|\/\*)\s?!?\s?(gui-ignore|debug|debug-verbose)(\n|\s|$).*/)?.[2].trim() || "";
42
+ if (pragma) {
39
43
  pragma = pragma.replace("!", "").trim();
40
44
  break;
41
45
  }
42
46
  }
43
47
  switch (pragma) {
44
48
  case "gui-ignore":
45
- shouldDisable = !0;
49
+ shouldDisable = true;
46
50
  break;
47
51
  case "debug":
48
- shouldPrintDebug = !0;
52
+ shouldPrintDebug = true;
49
53
  break;
50
54
  case "debug-verbose":
51
55
  shouldPrintDebug = "verbose";
52
56
  break;
53
57
  }
54
- return process.env.HANZO_GUI_DEBUG_FILE && path.includes(process.env.HANZO_GUI_DEBUG_FILE) && (shouldPrintDebug = "verbose"), process.env.DEBUG?.includes("@hanzo/gui") && (shouldPrintDebug ||= !0), process.env.DEBUG?.includes("gui-verbose") && (shouldPrintDebug = "verbose"), {
58
+ if (process.env.GUI_DEBUG_FILE) {
59
+ if (path.includes(process.env.GUI_DEBUG_FILE)) {
60
+ shouldPrintDebug = "verbose";
61
+ }
62
+ }
63
+ if (process.env.DEBUG?.includes("@hanzo/gui")) {
64
+ shouldPrintDebug ||= true;
65
+ }
66
+ if (process.env.DEBUG?.includes("gui-verbose")) {
67
+ shouldPrintDebug = "verbose";
68
+ }
69
+ return {
55
70
  shouldPrintDebug,
56
71
  shouldDisable
57
72
  };
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var memoize_exports = {};
22
24
  __export(memoize_exports, {
@@ -24,14 +26,20 @@ __export(memoize_exports, {
24
26
  });
25
27
  module.exports = __toCommonJS(memoize_exports);
26
28
  function memoize(func, resolver) {
27
- if (typeof func != "function" || resolver != null && typeof resolver != "function") throw new TypeError("Expected a function");
29
+ if (typeof func !== "function" || resolver != null && typeof resolver !== "function") {
30
+ throw new TypeError("Expected a function");
31
+ }
28
32
  const memoized = function (...args) {
29
- const key = resolver ? resolver.apply(this, args) : args[0],
30
- cache = memoized.cache;
31
- if (cache.has(key)) return cache.get(key);
33
+ const key = resolver ? resolver.apply(this, args) : args[0];
34
+ const cache = memoized.cache;
35
+ if (cache.has(key)) {
36
+ return cache.get(key);
37
+ }
32
38
  const result = func.apply(this, args);
33
- return memoized.cache = cache.set(key, result) || cache, result;
39
+ memoized.cache = cache.set(key, result) || cache;
40
+ return result;
34
41
  };
35
- return memoized.cache = new (memoize.Cache || Map)(), memoized;
42
+ memoized.cache = new (memoize.Cache || Map)();
43
+ return memoized;
36
44
  }
37
45
  memoize.Cache = Map;
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var requireGuiCore_exports = {};
22
24
  __export(requireGuiCore_exports, {
@@ -24,10 +26,15 @@ __export(requireGuiCore_exports, {
24
26
  });
25
27
  module.exports = __toCommonJS(requireGuiCore_exports);
26
28
  function requireGuiCore(platform, ogRequire = require) {
27
- if (!platform) throw new Error("No platform given to requireGuiCore");
28
- const og1 = process.env.HANZO_GUI_IS_SERVER,
29
- og2 = process.env.HANZO_GUI_KEEP_THEMES;
30
- process.env.HANZO_GUI_IS_SERVER ||= "1", process.env.HANZO_GUI_KEEP_THEMES ||= "1";
29
+ if (!platform) {
30
+ throw new Error(`No platform given to requireGuiCore`);
31
+ }
32
+ const og1 = process.env.GUI_IS_SERVER;
33
+ const og2 = process.env.GUI_KEEP_THEMES;
34
+ process.env.GUI_IS_SERVER ||= "1";
35
+ process.env.GUI_KEEP_THEMES ||= "1";
31
36
  const exported = ogRequire(platform === "native" ? "@hanzogui/core/native" : "@hanzogui/core");
32
- return process.env.HANZO_GUI_IS_SERVER = og1, process.env.HANZO_GUI_KEEP_THEMES = og2, exported;
37
+ process.env.GUI_IS_SERVER = og1;
38
+ process.env.GUI_KEEP_THEMES = og2;
39
+ return exported;
33
40
  }
package/dist/index.cjs CHANGED
@@ -2,34 +2,36 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- },
20
- __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")),
21
- __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
27
- value: mod,
28
- enumerable: !0
29
- }) : target, mod)),
30
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
31
- value: !0
32
- }), mod);
19
+ }
20
+ return to;
21
+ };
22
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
29
+ value: mod,
30
+ enumerable: true
31
+ }) : target, mod));
32
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
33
+ value: true
34
+ }), mod);
33
35
  var index_exports = {};
34
36
  __export(index_exports, {
35
37
  default: () => index_default
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: !0
9
- });
10
- },
11
- __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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, {
13
14
  get: () => from[key],
14
15
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
16
  });
16
- return to;
17
- };
17
+ }
18
+ return to;
19
+ };
18
20
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
- value: !0
21
+ value: true
20
22
  }), mod);
21
23
  var registerRequire_exports = {};
22
24
  __export(registerRequire_exports, {
@@ -25,91 +27,144 @@ __export(registerRequire_exports, {
25
27
  setRequireResult: () => setRequireResult
26
28
  });
27
29
  module.exports = __toCommonJS(registerRequire_exports);
28
- var import_node = require("esbuild-register/dist/node"),
29
- import_bundle = require("./extractor/bundle.cjs"),
30
- import_requireGuiCore = require("./helpers/requireGuiCore.cjs");
31
- const nameToPaths = {},
32
- getNameToPaths = () => nameToPaths,
33
- Module = require("node:module"),
34
- proxyWorm = require("@hanzogui/proxy-worm");
35
- let isRegistered = !1,
36
- og;
30
+ var import_node = require("esbuild-register/dist/node");
31
+ var import_bundle = require("./extractor/bundle.cjs");
32
+ var import_requireGuiCore = require("./helpers/requireGuiCore.cjs");
33
+ const nameToPaths = {};
34
+ const getNameToPaths = () => nameToPaths;
35
+ const Module = require("node:module");
36
+ const proxyWorm = require("@hanzogui/proxy-worm");
37
+ let isRegistered = false;
38
+ let og;
37
39
  const whitelisted = {
38
- react: !0
39
- },
40
- compiled = {};
40
+ react: true
41
+ };
42
+ const compiled = {};
41
43
  function setRequireResult(name, result) {
42
44
  compiled[name] = result;
43
45
  }
44
46
  function registerRequire(platform, {
45
47
  proxyWormImports
46
48
  } = {
47
- proxyWormImports: !1
49
+ proxyWormImports: false
48
50
  }) {
49
- if (isRegistered) return {
50
- guiRequire: require,
51
- unregister: () => {}
52
- };
53
- const originalResolveFilename = Module._resolveFilename,
54
- {
55
- unregister
56
- } = (0, import_node.register)({
57
- hookIgnoreNodeModules: !1,
58
- // don't transform @hanzo/gui packages - they have pre-built dist files
59
- hookMatcher: filename => !(filename.includes("@hanzo/gui") || filename.includes("@gui") || /\/(hanzo\/gui|gui)\/code\/(core|ui|packages)\//.test(filename))
60
- }),
61
- tsconfigPatchedResolve = Module._resolveFilename;
51
+ if (isRegistered) {
52
+ return {
53
+ guiRequire: require,
54
+ unregister: () => {}
55
+ };
56
+ }
57
+ const originalResolveFilename = Module._resolveFilename;
58
+ const {
59
+ unregister
60
+ } = (0, import_node.register)({
61
+ hookIgnoreNodeModules: false,
62
+ // don't transform @hanzo/gui packages - they have pre-built dist files
63
+ hookMatcher: filename => {
64
+ if (filename.includes("@hanzo/gui") || filename.includes("@gui") || /\/(hanzo\/gui|gui)\/code\/(core|ui|packages)\//.test(filename)) {
65
+ return false;
66
+ }
67
+ return true;
68
+ }
69
+ });
70
+ const tsconfigPatchedResolve = Module._resolveFilename;
62
71
  Module._resolveFilename = function (request, ...args) {
63
- return request.startsWith("@hanzogui/") ? originalResolveFilename.call(this, request, ...args) : tsconfigPatchedResolve.call(this, request, ...args);
64
- }, og || (og = Module.prototype.require), isRegistered = !0, Module.prototype.require = guiRequire;
72
+ if (request.startsWith("@hanzogui/")) {
73
+ return originalResolveFilename.call(this, request, ...args);
74
+ }
75
+ return tsconfigPatchedResolve.call(this, request, ...args);
76
+ };
77
+ if (!og) {
78
+ og = Module.prototype.require;
79
+ }
80
+ isRegistered = true;
81
+ Module.prototype.require = guiRequire;
65
82
  function guiRequire(path) {
66
- if (path === "@hanzo/gui" && platform === "native") return og.apply(this, ["@hanzo/gui/native"]);
67
- if (path === "@hanzogui/core") return (0, import_requireGuiCore.requireGuiCore)(platform, path2 => og.apply(this, [path2]));
68
- if (path in knownIgnorableModules || path.startsWith("react-native-reanimated") || import_bundle.esbuildIgnoreFilesRegex.test(path)) return proxyWorm;
69
- if (path in compiled) return compiled[path];
70
- if (path === "react-native-svg") return og.apply(this, ["@hanzogui/react-native-svg"]);
71
- if (path === "react-native/package.json") return og.apply(this, ["react-native-web/package.json"]);
72
- if (path === "@hanzogui/react-native-web-lite" || path === "react-native" || path.startsWith("react-native/")) try {
73
- return og.apply("react-native");
74
- } catch {
75
- return og.apply(this, ["@hanzogui/react-native-web-lite"]);
83
+ if (path === "@hanzo/gui" && platform === "native") {
84
+ return og.apply(this, ["@hanzo/gui/native"]);
85
+ }
86
+ if (path === "@hanzogui/core") {
87
+ return (0, import_requireGuiCore.requireGuiCore)(platform, path2 => {
88
+ return og.apply(this, [path2]);
89
+ });
90
+ }
91
+ if (path in knownIgnorableModules || path.startsWith("react-native-reanimated") || import_bundle.esbuildIgnoreFilesRegex.test(path)) {
92
+ return proxyWorm;
93
+ }
94
+ if (path in compiled) {
95
+ return compiled[path];
96
+ }
97
+ if (path === "react-native-svg") {
98
+ return og.apply(this, ["@hanzogui/react-native-svg"]);
99
+ }
100
+ if (path === "react-native/package.json") {
101
+ return og.apply(this, ["react-native-web/package.json"]);
102
+ }
103
+ if (path === "@hanzogui/react-native-web-lite" || path === "react-native" || path.startsWith("react-native/")) {
104
+ try {
105
+ return og.apply("react-native");
106
+ } catch {
107
+ return og.apply(this, ["@hanzogui/react-native-web-lite"]);
108
+ }
76
109
  }
77
- if (!whitelisted[path] && proxyWormImports && !path.includes(".gui-dynamic-eval")) {
78
- const callerFile = this?.filename || this?.id || "",
79
- isFromGuiPkg = callerFile.includes("@hanzo/gui") || callerFile.includes("@gui") || callerFile.includes("node_modules/@hanzo/");
80
- return path === "@hanzo/gui" || path.startsWith("@hanzogui/") || isFromGuiPkg ? og.apply(this, [path]) : proxyWorm;
110
+ if (!whitelisted[path]) {
111
+ if (proxyWormImports && !path.includes(".gui-dynamic-eval")) {
112
+ const callerFile = this?.filename || this?.id || "";
113
+ const isFromGuiPkg = callerFile.includes("@hanzo/gui") || callerFile.includes("@gui") || callerFile.includes("node_modules/@hanzo/");
114
+ if (path === "@hanzo/gui" || path.startsWith("@hanzogui/") || isFromGuiPkg) {
115
+ return og.apply(this, [path]);
116
+ }
117
+ return proxyWorm;
118
+ }
81
119
  }
82
120
  try {
83
- return og.apply(this, arguments);
84
- } catch {
85
- return !process.env.HANZO_GUI_ENABLE_WARN_DYNAMIC_LOAD && path.includes("gui-dynamic-eval") ? void 0 : (allowedIgnores[path] || IGNORES === "true" || (!process.env.HANZO_GUI_SHOW_FULL_BUNDLE_ERRORS && !process.env.DEBUG ? hasWarnedForModules.has(path) || hasWarnedForModules.add(path) : console.warn(` [hanzo-gui] skipped "${path}" (set HANZO_GUI_IGNORE_BUNDLE_ERRORS="${path}" to silence)`)), proxyWorm);
121
+ const out = og.apply(this, arguments);
122
+ return out;
123
+ } catch (err) {
124
+ if (!process.env.GUI_ENABLE_WARN_DYNAMIC_LOAD && path.includes("gui-dynamic-eval")) {
125
+ return;
126
+ }
127
+ if (allowedIgnores[path] || IGNORES === "true") {} else if (!process.env.GUI_SHOW_FULL_BUNDLE_ERRORS && !process.env.DEBUG) {
128
+ if (hasWarnedForModules.has(path)) {} else {
129
+ hasWarnedForModules.add(path);
130
+ }
131
+ } else {
132
+ console.warn(` [hanzo-gui] skipped "${path}" (set GUI_IGNORE_BUNDLE_ERRORS="${path}" to silence)`);
133
+ }
134
+ return proxyWorm;
86
135
  }
87
136
  }
88
137
  return {
89
138
  guiRequire,
90
139
  unregister: () => {
91
- hasWarnedForModules.size && (console.info(` [hanzo-gui] skipped loading ${hasWarnedForModules.size} module, see: https://gui.hanzo.ai/docs/intro/errors#warning-001`), hasWarnedForModules.clear()), unregister(), isRegistered = !1, Module.prototype.require = og;
140
+ if (hasWarnedForModules.size) {
141
+ console.info(` [hanzo-gui] skipped loading ${hasWarnedForModules.size} module, see: https://gui.hanzo.ai/docs/intro/errors#warning-001`);
142
+ hasWarnedForModules.clear();
143
+ }
144
+ unregister();
145
+ isRegistered = false;
146
+ Module.prototype.require = og;
92
147
  }
93
148
  };
94
149
  }
95
- const IGNORES = process.env.HANZO_GUI_IGNORE_BUNDLE_ERRORS || process.env.HANZO_GUI_IGNORE_BUNDLE_ERRORS,
96
- extraIgnores = IGNORES === "true" ? [] : IGNORES?.split(","),
97
- knownIgnorableModules = {
98
- "@gorhom/bottom-sheet": !0,
99
- "expo-modules": !0,
100
- solito: !0,
101
- "expo-linear-gradient": !0,
102
- "@expo/vector-icons": !0,
103
- "@hanzo/gui/linear-gradient": !0,
104
- // animation libraries not needed for static extraction
105
- "@emotion/is-prop-valid": !0,
106
- "framer-motion": !0,
107
- motion: !0,
108
- ...Object.fromEntries(extraIgnores?.map(k => [k, !0]) || [])
109
- },
110
- hasWarnedForModules = /* @__PURE__ */new Set(),
111
- allowedIgnores = {
112
- "expo-constants": !0,
113
- "./ExpoHaptics": !0,
114
- "./js/MaskedView": !0
115
- };
150
+ const IGNORES = process.env.GUI_IGNORE_BUNDLE_ERRORS || process.env.GUI_IGNORE_BUNDLE_ERRORS;
151
+ const extraIgnores = IGNORES === "true" ? [] : IGNORES?.split(",");
152
+ const knownIgnorableModules = {
153
+ "@gorhom/bottom-sheet": true,
154
+ "expo-modules": true,
155
+ solito: true,
156
+ "expo-linear-gradient": true,
157
+ "@expo/vector-icons": true,
158
+ "@hanzo/gui/linear-gradient": true,
159
+ // animation libraries not needed for static extraction
160
+ "@emotion/is-prop-valid": true,
161
+ "framer-motion": true,
162
+ motion: true,
163
+ ...Object.fromEntries(extraIgnores?.map(k => [k, true]) || [])
164
+ };
165
+ const hasWarnedForModules = /* @__PURE__ */new Set();
166
+ const allowedIgnores = {
167
+ "expo-constants": true,
168
+ "./ExpoHaptics": true,
169
+ "./js/MaskedView": true
170
+ };