@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
@@ -2,33 +2,35 @@ 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
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
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);
32
34
  var hoistClassNames_exports = {};
33
35
  __export(hoistClassNames_exports, {
34
36
  hoistClassNames: () => hoistClassNames
@@ -38,25 +40,37 @@ var t = __toESM(require("@babel/types"));
38
40
  function hoistClassNames(path, existing, expr) {
39
41
  const hoist = hoistClassNames.bind(null, path, existing);
40
42
  if (t.isStringLiteral(expr)) {
41
- if (expr.value.trim() === "") return expr;
42
- if (existing[expr.value]) return existing[expr.value];
43
+ if (expr.value.trim() === "") {
44
+ return expr;
45
+ }
46
+ if (existing[expr.value]) {
47
+ return existing[expr.value];
48
+ }
43
49
  const identifier = replaceStringWithVariable(expr);
44
- return existing[expr.value] = identifier, identifier;
50
+ existing[expr.value] = identifier;
51
+ return identifier;
45
52
  }
46
53
  if (t.isBinaryExpression(expr)) {
47
- if (t.isPrivateName(expr.left)) throw new Error("no private name");
54
+ if (t.isPrivateName(expr.left)) {
55
+ throw new Error(`no private name`);
56
+ }
48
57
  return t.binaryExpression(expr.operator, hoist(expr.left), hoist(expr.right));
49
58
  }
50
- if (t.isLogicalExpression(expr)) return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right));
51
- if (t.isConditionalExpression(expr)) return t.conditionalExpression(expr.test, hoist(expr.consequent), hoist(expr.alternate));
59
+ if (t.isLogicalExpression(expr)) {
60
+ return t.logicalExpression(expr.operator, hoist(expr.left), hoist(expr.right));
61
+ }
62
+ if (t.isConditionalExpression(expr)) {
63
+ return t.conditionalExpression(expr.test, hoist(expr.consequent), hoist(expr.alternate));
64
+ }
52
65
  return expr;
53
66
  function replaceStringWithVariable(str) {
54
- const uid = path.scope.generateUidIdentifier("cn"),
55
- parent = path.findParent(path2 => path2.isProgram());
56
- if (!parent) throw new Error("no program?");
67
+ const uid = path.scope.generateUidIdentifier("cn");
68
+ const parent = path.findParent(path2 => path2.isProgram());
69
+ if (!parent) throw new Error(`no program?`);
57
70
  const variable = t.variableDeclaration("const", [
58
71
  // adding a space for extra safety
59
72
  t.variableDeclarator(uid, t.stringLiteral(` ${str.value}`))]);
60
- return parent.unshiftContainer("body", variable), uid;
73
+ parent.unshiftContainer("body", variable);
74
+ return uid;
61
75
  }
62
76
  }
@@ -2,33 +2,35 @@ 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
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
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);
32
34
  var literalToAst_exports = {};
33
35
  __export(literalToAst_exports, {
34
36
  astToLiteral: () => astToLiteral,
@@ -37,7 +39,9 @@ __export(literalToAst_exports, {
37
39
  module.exports = __toCommonJS(literalToAst_exports);
38
40
  var t = __toESM(require("@babel/types"));
39
41
  function literalToAst(literal) {
40
- if (literal === null) return t.nullLiteral();
42
+ if (literal === null) {
43
+ return t.nullLiteral();
44
+ }
41
45
  switch (typeof literal) {
42
46
  case "function":
43
47
  throw new Error("Unsupported");
@@ -48,37 +52,58 @@ function literalToAst(literal) {
48
52
  case "boolean":
49
53
  return t.booleanLiteral(literal);
50
54
  case "undefined":
51
- return t.unaryExpression("void", t.numericLiteral(0), !0);
55
+ return t.unaryExpression("void", t.numericLiteral(0), true);
52
56
  default:
53
- return Array.isArray(literal) ? t.arrayExpression(literal.map(literalToAst)) : t.objectExpression(Object.keys(literal).filter(k => typeof literal[k] < "u").map(k => t.objectProperty(t.stringLiteral(k), literalToAst(literal[k]))));
57
+ if (Array.isArray(literal)) {
58
+ return t.arrayExpression(literal.map(literalToAst));
59
+ }
60
+ return t.objectExpression(Object.keys(literal).filter(k => {
61
+ return typeof literal[k] !== "undefined";
62
+ }).map(k => {
63
+ return t.objectProperty(t.stringLiteral(k), literalToAst(literal[k]));
64
+ }));
54
65
  }
55
66
  }
56
67
  const easyPeasies = ["BooleanLiteral", "StringLiteral", "NumericLiteral"];
57
68
  function astToLiteral(node) {
58
- if (node) {
59
- if (easyPeasies.includes(node.type)) return node.value;
60
- if (!(node.name === "undefined" && !node.value)) {
61
- if (t.isNullLiteral(node)) return null;
62
- if (t.isObjectExpression(node)) return computeProps(node.properties);
63
- if (t.isArrayExpression(node)) return node.elements.reduce(
64
- // @ts-ignore
65
- (acc, element) => [...acc, ...(element?.type === "SpreadElement" ? astToLiteral(element.argument) : [astToLiteral(element)])], []);
66
- }
69
+ if (!node) {
70
+ return;
71
+ }
72
+ if (easyPeasies.includes(node.type)) {
73
+ return node.value;
74
+ }
75
+ if (node.name === "undefined" && !node.value) {
76
+ return void 0;
77
+ }
78
+ if (t.isNullLiteral(node)) {
79
+ return null;
80
+ }
81
+ if (t.isObjectExpression(node)) {
82
+ return computeProps(node.properties);
83
+ }
84
+ if (t.isArrayExpression(node)) {
85
+ return node.elements.reduce(
86
+ // @ts-ignore
87
+ (acc, element) => [...acc, ...(element?.type === "SpreadElement" ? astToLiteral(element.argument) : [astToLiteral(element)])], []);
67
88
  }
68
89
  }
69
90
  function computeProps(props) {
70
91
  return props.reduce((acc, prop) => {
71
- if (prop.type === "SpreadElement") return {
72
- ...acc,
73
- ...astToLiteral(prop.argument)
74
- };
75
- if (prop.type !== "ObjectMethod") {
76
- const val = astToLiteral(prop.value);
77
- if (val !== void 0) return {
92
+ if (prop.type === "SpreadElement") {
93
+ return {
78
94
  ...acc,
79
- [prop.key.name]: val
95
+ ...astToLiteral(prop.argument)
80
96
  };
81
97
  }
98
+ if (prop.type !== "ObjectMethod") {
99
+ const val = astToLiteral(prop.value);
100
+ if (val !== void 0) {
101
+ return {
102
+ ...acc,
103
+ [prop.key.name]: val
104
+ };
105
+ }
106
+ }
82
107
  return acc;
83
108
  }, {});
84
109
  }
@@ -1,11 +1,17 @@
1
1
  process.on("message", path => {
2
- if (typeof path != "string") throw new Error(`Not a string: ${path}`);
2
+ if (typeof path !== "string") {
3
+ throw new Error(`Not a string: ${path}`);
4
+ }
3
5
  try {
4
6
  const out = require(path);
5
7
  process.send?.(JSON.stringify(out));
6
8
  } catch (err) {
7
- err instanceof Error ? process.send?.(`-${err.message}
8
- ${err.stack}`) : process.send?.(`-${err}`);
9
+ if (err instanceof Error) {
10
+ process.send?.(`-${err.message}
11
+ ${err.stack}`);
12
+ } else {
13
+ process.send?.(`-${err}`);
14
+ }
9
15
  }
10
16
  });
11
17
  setInterval(() => {}, 1e3);