@vef-framework/dev 2.0.11 → 2.1.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 (104) hide show
  1. package/dist/cjs/_internal/_rolldown/runtime.cjs +1 -0
  2. package/dist/cjs/index.cjs +1 -1
  3. package/dist/cjs/lint/commitlint.cjs +1 -1
  4. package/dist/cjs/lint/eslint.cjs +1 -1
  5. package/dist/cjs/lint/index.cjs +1 -1
  6. package/dist/cjs/lint/local-react-plugin.cjs +1 -0
  7. package/dist/cjs/lint/stylelint.cjs +1 -1
  8. package/dist/cjs/vite/chunks.cjs +1 -1
  9. package/dist/cjs/vite/config.cjs +1 -1
  10. package/dist/cjs/vite/constants.cjs +1 -1
  11. package/dist/cjs/vite/define.cjs +10 -11
  12. package/dist/cjs/vite/index.cjs +1 -1
  13. package/dist/cjs/vite/plugin-app-config.cjs +1 -1
  14. package/dist/cjs/vite/plugin-auto-enhance/core.cjs +1 -1
  15. package/dist/cjs/vite/plugin-auto-enhance/index.cjs +1 -1
  16. package/dist/cjs/vite/plugin-auto-enhance/plugins/index.cjs +1 -1
  17. package/dist/cjs/vite/plugin-auto-enhance/plugins/operation-column-width.cjs +1 -1
  18. package/dist/cjs/vite/plugin-conventional-config.cjs +1 -1
  19. package/dist/cjs/vite/plugin-eslint.cjs +1 -1
  20. package/dist/cjs/vite/plugin-html.cjs +2 -2
  21. package/dist/cjs/vite/plugin-icons.cjs +1 -1
  22. package/dist/cjs/vite/plugin-injection.cjs +1 -1
  23. package/dist/cjs/vite/plugin-inspect.cjs +1 -1
  24. package/dist/cjs/vite/plugin-react.cjs +1 -1
  25. package/dist/cjs/vite/plugin-router.cjs +3 -3
  26. package/dist/cjs/vite/plugin-stylelint.cjs +1 -1
  27. package/dist/cjs/vite/plugin-svgr.cjs +1 -1
  28. package/dist/cjs/vite/plugin-tsconfig-paths.cjs +1 -1
  29. package/dist/cjs/vite/postcss.cjs +1 -1
  30. package/dist/cli/index.js +5 -5
  31. package/dist/es/index.js +8 -10
  32. package/dist/es/lint/commitlint.js +5 -4
  33. package/dist/es/lint/eslint.js +650 -931
  34. package/dist/es/lint/index.js +3 -8
  35. package/dist/es/lint/local-react-plugin.js +42 -0
  36. package/dist/es/lint/stylelint.js +55 -74
  37. package/dist/es/vite/chunks.js +19 -16
  38. package/dist/es/vite/config.js +59 -66
  39. package/dist/es/vite/constants.js +9 -9
  40. package/dist/es/vite/define.js +16 -16
  41. package/dist/es/vite/index.js +1 -4
  42. package/dist/es/vite/plugin-app-config.js +10 -14
  43. package/dist/es/vite/plugin-auto-enhance/core.js +85 -85
  44. package/dist/es/vite/plugin-auto-enhance/index.js +13 -14
  45. package/dist/es/vite/plugin-auto-enhance/plugins/index.js +1 -4
  46. package/dist/es/vite/plugin-auto-enhance/plugins/operation-column-width.js +174 -108
  47. package/dist/es/vite/plugin-conventional-config.js +28 -42
  48. package/dist/es/vite/plugin-eslint.js +9 -4
  49. package/dist/es/vite/plugin-html.js +50 -53
  50. package/dist/es/vite/plugin-icons.js +6 -5
  51. package/dist/es/vite/plugin-injection.js +1 -11
  52. package/dist/es/vite/plugin-react.js +21 -63
  53. package/dist/es/vite/plugin-router.js +38 -31
  54. package/dist/es/vite/plugin-stylelint.js +9 -4
  55. package/dist/es/vite/plugin-svgr.js +2 -7
  56. package/dist/es/vite/plugin-tsconfig-paths.js +3 -6
  57. package/dist/types/src/lint/commitlint.d.ts +2 -0
  58. package/dist/types/src/lint/local-react-plugin.d.ts +29 -0
  59. package/dist/types/src/lint/stylelint.d.ts +2 -0
  60. package/dist/types/{vite → src/vite}/chunks.d.ts +0 -5
  61. package/dist/types/src/vite/config.d.ts +12 -0
  62. package/dist/types/src/vite/constants.d.ts +12 -0
  63. package/dist/types/src/vite/define.d.ts +4 -0
  64. package/dist/types/src/vite/plugin-app-config.d.ts +19 -0
  65. package/dist/types/{vite → src/vite}/plugin-auto-enhance/core.d.ts +6 -21
  66. package/dist/types/src/vite/plugin-auto-enhance/index.d.ts +10 -0
  67. package/dist/types/src/vite/plugin-auto-enhance/plugins/operation-column-width.d.ts +5 -0
  68. package/dist/types/{vite → src/vite}/plugin-auto-enhance/types.d.ts +7 -9
  69. package/dist/types/{vite → src/vite}/plugin-conventional-config.d.ts +1 -14
  70. package/dist/types/src/vite/plugin-eslint.d.ts +7 -0
  71. package/dist/types/src/vite/plugin-html.d.ts +7 -0
  72. package/dist/types/{vite → src/vite}/plugin-icons.d.ts +3 -3
  73. package/dist/types/src/vite/plugin-injection.d.ts +5 -0
  74. package/dist/types/src/vite/plugin-inspect.d.ts +5 -0
  75. package/dist/types/{vite → src/vite}/plugin-react.d.ts +10 -5
  76. package/dist/types/src/vite/plugin-router.d.ts +14 -0
  77. package/dist/types/src/vite/plugin-stylelint.d.ts +7 -0
  78. package/dist/types/src/vite/plugin-svgr.d.ts +7 -0
  79. package/dist/types/src/vite/plugin-tsconfig-paths.d.ts +8 -0
  80. package/dist/types/{vite → src/vite}/postcss.d.ts +0 -5
  81. package/package.json +65 -65
  82. package/tsconfig.base.json +0 -1
  83. package/dist/types/lint/commitlint.d.ts +0 -8
  84. package/dist/types/lint/stylelint.d.ts +0 -7
  85. package/dist/types/vite/config.d.ts +0 -39
  86. package/dist/types/vite/constants.d.ts +0 -48
  87. package/dist/types/vite/define.d.ts +0 -12
  88. package/dist/types/vite/plugin-app-config.d.ts +0 -28
  89. package/dist/types/vite/plugin-auto-enhance/index.d.ts +0 -30
  90. package/dist/types/vite/plugin-auto-enhance/plugins/operation-column-width.d.ts +0 -14
  91. package/dist/types/vite/plugin-eslint.d.ts +0 -7
  92. package/dist/types/vite/plugin-html.d.ts +0 -7
  93. package/dist/types/vite/plugin-injection.d.ts +0 -7
  94. package/dist/types/vite/plugin-inspect.d.ts +0 -7
  95. package/dist/types/vite/plugin-router.d.ts +0 -9
  96. package/dist/types/vite/plugin-stylelint.d.ts +0 -7
  97. package/dist/types/vite/plugin-svgr.d.ts +0 -7
  98. package/dist/types/vite/plugin-tsconfig-paths.d.ts +0 -8
  99. package/dist/types/{cli → src/cli}/index.d.ts +0 -0
  100. package/dist/types/{index.d.ts → src/index.d.ts} +0 -0
  101. package/dist/types/{lint → src/lint}/eslint.d.ts +0 -0
  102. package/dist/types/{lint → src/lint}/index.d.ts +0 -0
  103. package/dist/types/{vite → src/vite}/index.d.ts +1 -1
  104. /package/dist/types/{vite → src/vite}/plugin-auto-enhance/plugins/index.d.ts +0 -0
@@ -1,104 +1,104 @@
1
- import { basename as c } from "node:path";
2
- import { parse as f } from "@babel/parser";
3
- import { parse as g, print as p } from "recast";
4
- function a(o, e) {
5
- return (Array.isArray(o) ? o : [o]).some((r) => typeof r == "string" ? e.includes(r) : r.test(e));
1
+ import { basename as a } from "node:path";
2
+ import { parse as c } from "@babel/parser";
3
+ import { parse as g, print as f } from "recast";
4
+ var h = [/\.tsx?(?:\?.*)?$/], p = [/node_modules/, /\.d\.ts?(?:\?.*)?$/], m = "VEF Auto-Enhance";
5
+ function u(r, s) {
6
+ return (Array.isArray(r) ? r : [r]).some((n) => typeof n == "string" ? s.includes(n) : n.test(s));
6
7
  }
7
- class d {
8
+ function P(r, s) {
9
+ return g(r, {
10
+ sourceFileName: s,
11
+ parser: { parse: (e) => c(e, {
12
+ plugins: [
13
+ "jsx",
14
+ "typescript",
15
+ "explicitResourceManagement"
16
+ ],
17
+ sourceType: "module",
18
+ tokens: !0
19
+ }) }
20
+ });
21
+ }
22
+ var x = class {
8
23
  plugins = [];
9
24
  options;
10
- constructor(e = {}) {
25
+ constructor(r = {}) {
11
26
  this.options = {
12
- include: [/\.tsx?(?:\?.*)?$/],
13
- exclude: [/node_modules/, /\.d\.ts?(?:\?.*)?$/],
14
- logPrefix: "🚀 VEF Auto-Enhance",
15
- ...e
27
+ include: h,
28
+ exclude: p,
29
+ logPrefix: m,
30
+ ...r
16
31
  };
17
32
  }
18
- /**
19
- * Register a sub-plugin
20
- */
21
- registerPlugin(e) {
22
- this.plugins.push(e);
33
+ registerPlugin(r) {
34
+ this.plugins.push(r);
23
35
  }
24
- /**
25
- * Register multiple sub-plugins
26
- */
27
- registerPlugins(e) {
28
- for (const s of e)
29
- this.registerPlugin(s);
36
+ registerPlugins(r) {
37
+ for (const s of r)
38
+ this.plugins.push(s);
30
39
  }
31
- /**
32
- * Check if file should be processed
33
- */
34
- shouldProcessFile(e) {
35
- const { include: s, exclude: r } = this.options;
36
- return !(r && a(r, e) || s && !a(s, e));
40
+ getRegisteredPlugins() {
41
+ return this.plugins.map(({ name: r, description: s }) => ({
42
+ name: r,
43
+ description: s
44
+ }));
37
45
  }
38
- /**
39
- * Create processing context
40
- */
41
- createTransformationContext(e, s) {
42
- const r = e.split("/").slice(-3).join("/"), i = g(s, {
43
- sourceFileName: c(e),
44
- parser: {
45
- parse: (l) => f(l, {
46
- plugins: ["jsx", "typescript", "explicitResourceManagement"],
47
- sourceType: "module",
48
- tokens: !0
49
- })
50
- }
51
- });
46
+ transform(r, s) {
47
+ if (!this.shouldProcessFile(s) || this.plugins.length === 0)
48
+ return null;
49
+ try {
50
+ return this.executeTransform(r, s);
51
+ } catch (e) {
52
+ return console.warn(`${this.options.logPrefix}: Error processing ${s}:`, e), null;
53
+ }
54
+ }
55
+ shouldProcessFile(r) {
56
+ const { include: s, exclude: e } = this.options;
57
+ return !(e && u(e, r) || s && !u(s, r));
58
+ }
59
+ buildTransformInfo(r, s) {
60
+ const e = r.split("/").slice(-3).join("/"), n = P(s, a(r));
52
61
  return {
53
- id: e,
54
- fileName: r,
62
+ id: r,
63
+ fileName: e,
55
64
  code: s,
56
- ast: i
65
+ ast: n
57
66
  };
58
67
  }
59
- /**
60
- * Execute transformation
61
- */
62
- transform(e, s) {
63
- if (!this.shouldProcessFile(s) || this.plugins.length === 0)
68
+ executeTransform(r, s) {
69
+ const e = this.buildTransformInfo(s, r), n = this.getActivePlugins(e);
70
+ if (n.length === 0)
64
71
  return null;
65
- try {
66
- const r = this.createTransformationContext(s, e), i = this.plugins.filter((t) => t.shouldProcess ? t.shouldProcess(r) : !0);
67
- if (i.length === 0)
68
- return null;
69
- let l = !1;
70
- const u = [];
71
- for (const t of i)
72
- try {
73
- const n = t.transform(r);
74
- n.hasChanges && (l = !0), n.logs && u.push(...n.logs), n.hasChanges && console.log(`${this.options.logPrefix}: Plugin "${t.name}" made changes to ${r.fileName}`);
75
- } catch (n) {
76
- console.warn(`${this.options.logPrefix}: Plugin "${t.name}" failed:`, n);
77
- }
78
- for (const t of u)
79
- console.log(t);
80
- if (l) {
81
- const t = p(r.ast);
82
- return {
83
- code: t.code,
84
- map: t.map || null
85
- };
86
- }
72
+ const { hasChanges: i, logs: o } = this.runPlugins(n, e);
73
+ for (const l of o)
74
+ console.log(l);
75
+ if (!i)
87
76
  return null;
88
- } catch (r) {
89
- return console.warn(`${this.options.logPrefix}: Error processing ${s}:`, r), null;
90
- }
77
+ const t = f(e.ast);
78
+ return {
79
+ code: t.code,
80
+ map: t.map || null
81
+ };
91
82
  }
92
- /**
93
- * Get registered plugin information
94
- */
95
- getRegisteredPlugins() {
96
- return this.plugins.map((e) => ({
97
- name: e.name,
98
- description: e.description
99
- }));
83
+ getActivePlugins(r) {
84
+ return this.plugins.filter((s) => s.shouldProcess ? s.shouldProcess(r) : !0);
100
85
  }
101
- }
86
+ runPlugins(r, s) {
87
+ let e = !1;
88
+ const n = [], { logPrefix: i } = this.options;
89
+ for (const o of r)
90
+ try {
91
+ const t = o.transform(s);
92
+ t.hasChanges && (e = !0, console.log(`${i}: Plugin "${o.name}" made changes to ${s.fileName}`)), t.logs && n.push(...t.logs);
93
+ } catch (t) {
94
+ console.warn(`${i}: Plugin "${o.name}" failed:`, t);
95
+ }
96
+ return {
97
+ hasChanges: e,
98
+ logs: n
99
+ };
100
+ }
101
+ };
102
102
  export {
103
- d as AutoEnhanceCore
103
+ x as AutoEnhanceCore
104
104
  };
@@ -1,20 +1,19 @@
1
- import { AutoEnhanceCore as i } from "./core.js";
2
- import "./plugins/index.js";
3
- import { types as g } from "recast";
4
- function a({
5
- plugins: r,
6
- ...t
7
- } = {}) {
8
- const o = new i(t);
1
+ import { AutoEnhanceCore as s } from "./core.js";
2
+ import "./plugins/operation-column-width.js";
3
+ import { types as l } from "recast";
4
+ function f({ plugins: r, ...t } = {}) {
5
+ const o = new s(t);
9
6
  return r && o.registerPlugins(r), {
10
7
  name: "vef-framework:auto-enhance",
11
8
  enforce: "pre",
12
9
  buildStart() {
13
10
  const e = o.getRegisteredPlugins();
14
- if (e.length > 0) {
15
- console.log(`🚀 Auto-Enhance: Loaded ${e.length} plugins:`);
16
- for (const n of e)
17
- console.log(` • ${n.name}${n.description ? ` - ${n.description}` : ""}`);
11
+ if (e.length !== 0) {
12
+ console.log(`Auto-Enhance: Loaded ${e.length} plugins:`);
13
+ for (const n of e) {
14
+ const i = n.description ? ` - ${n.description}` : "";
15
+ console.log(` - ${n.name}${i}`);
16
+ }
18
17
  }
19
18
  },
20
19
  transform(e, n) {
@@ -23,6 +22,6 @@ function a({
23
22
  };
24
23
  }
25
24
  export {
26
- a as createAutoEnhancePlugin,
27
- g as types
25
+ f as createAutoEnhancePlugin,
26
+ l as types
28
27
  };
@@ -1,4 +1 @@
1
- import { operationColumnWidthPlugin as n } from "./operation-column-width.js";
2
- export {
3
- n as operationColumnWidthPlugin
4
- };
1
+ import "./operation-column-width.js";
@@ -1,34 +1,30 @@
1
- import { visit as l, types as n } from "recast";
2
- const v = /[\u4E00-\u9FFF\u3400-\u4DBF\uFF00-\uFFEF]/, T = "operationColumn", I = "OperationButton", x = [
3
- "@vef-framework/components",
4
- "@vef-framework/starter"
5
- ];
1
+ import { types as t, visit as l } from "recast";
2
+ var x = /[\u4E00-\u9FFF\u3400-\u4DBF\uFF00-\uFFEF]/, T = "operationColumn", E = "OperationButton", I = ["@vef-framework/components", "@vef-framework/starter"];
6
3
  function C(r) {
7
- return x.some((e) => r === e || r.startsWith(`${e}/`));
4
+ return I.some((e) => r === e || r.startsWith(`${e}/`));
8
5
  }
9
- function S(r) {
6
+ function g(r) {
10
7
  const e = /* @__PURE__ */ new Map();
11
- return l(r, {
12
- visitImportDeclaration(t) {
13
- const i = t.node.source.value;
14
- if (typeof i != "string" || !C(i))
15
- return this.traverse(t), !1;
16
- for (const s of t.node.specifiers || [])
17
- if (n.namedTypes.ImportSpecifier.check(s)) {
18
- const { imported: o } = s, { local: a } = s;
19
- n.namedTypes.Identifier.check(o) && n.namedTypes.Identifier.check(a) && o.name === I && e.set(a.name, o.name);
20
- }
21
- return this.traverse(t), !1;
8
+ return l(r, { visitImportDeclaration(n) {
9
+ const s = n.node.source.value;
10
+ if (typeof s != "string" || !C(s))
11
+ return this.traverse(n), !1;
12
+ for (const a of n.node.specifiers || []) {
13
+ if (!t.namedTypes.ImportSpecifier.check(a))
14
+ continue;
15
+ const { imported: o, local: i } = a;
16
+ t.namedTypes.Identifier.check(o) && t.namedTypes.Identifier.check(i) && o.name === E && e.set(i.name, o.name);
22
17
  }
23
- }), e;
18
+ return this.traverse(n), !1;
19
+ } }), e;
24
20
  }
25
21
  function O(r) {
26
22
  let e = 0;
27
- for (const t of r)
28
- e += v.test(t) ? 14 : 8;
23
+ for (const n of r)
24
+ e += x.test(n) ? 14 : 8;
29
25
  return e;
30
26
  }
31
- function P(r) {
27
+ function S(r) {
32
28
  if (r.length === 0)
33
29
  return {
34
30
  calculatedWidth: 64,
@@ -36,126 +32,196 @@ function P(r) {
36
32
  analysis: "No buttons found, using minimum width"
37
33
  };
38
34
  let e = 0;
39
- const t = r.length;
40
- for (const [o, a] of r.entries()) {
41
- let c = 16;
42
- a.hasIcon && (c += 16, a.textContent && (c += 8)), a.textContent && (c += O(a.textContent)), c = Math.max(c, a.hasIcon && !a.textContent ? 32 : 64), e += c, o < t - 1 && (e += 8);
35
+ const n = r.length;
36
+ for (const [a, o] of r.entries()) {
37
+ let i = 16;
38
+ o.hasIcon && (i += 16, o.textContent && (i += 8)), o.textContent && (i += O(o.textContent));
39
+ const c = o.hasIcon && !o.textContent ? 32 : 64;
40
+ i = Math.max(i, c), e += i, a < n - 1 && (e += 8);
43
41
  }
44
42
  e += 16;
45
- const i = Math.ceil(e / 8) * 8, s = `${t} buttons, calculated: ${e}px, final: ${i}px`;
43
+ const s = Math.ceil(e / 8) * 8;
46
44
  return {
47
- calculatedWidth: i,
48
- buttonCount: t,
49
- analysis: s
45
+ calculatedWidth: s,
46
+ buttonCount: n,
47
+ analysis: `${n} buttons, calculated: ${e}px, final: ${s}px`
50
48
  };
51
49
  }
52
- function g(r, e) {
53
- const { openingElement: t } = r;
54
- if (!n.namedTypes.JSXIdentifier.check(t.name))
50
+ function w(r, e) {
51
+ const { openingElement: n } = r;
52
+ if (!t.namedTypes.JSXIdentifier.check(n.name))
55
53
  return null;
56
- const i = t.name.name;
57
- if (!e.has(i))
54
+ const s = n.name.name;
55
+ if (!e.has(s))
58
56
  return null;
59
- const s = {
57
+ const a = {
60
58
  hasIcon: !1,
61
59
  textContent: ""
62
60
  };
63
- for (const o of t.attributes || [])
64
- n.namedTypes.JSXAttribute.check(o) && n.namedTypes.JSXIdentifier.check(o.name) && o.name.name === "icon" && (s.hasIcon = !0);
61
+ for (const o of n.attributes || [])
62
+ if (t.namedTypes.JSXAttribute.check(o) && t.namedTypes.JSXIdentifier.check(o.name) && o.name.name === "icon") {
63
+ a.hasIcon = !0;
64
+ break;
65
+ }
65
66
  for (const o of r.children || [])
66
- n.namedTypes.JSXText.check(o) ? s.textContent += o.value.trim() : n.namedTypes.JSXExpressionContainer.check(o) && n.namedTypes.StringLiteral.check(o.expression) && (s.textContent += o.expression.value);
67
- return s;
67
+ t.namedTypes.JSXText.check(o) ? a.textContent += o.value.trim() : t.namedTypes.JSXExpressionContainer.check(o) && t.namedTypes.StringLiteral.check(o.expression) && (a.textContent += o.expression.value);
68
+ return a;
68
69
  }
69
- function k(r, e) {
70
- const t = [];
71
- return l(r, {
72
- visitJSXElement(i) {
73
- const s = g(i.node, e);
74
- return s && t.push(s), this.traverse(i), !1;
75
- }
76
- }), t;
70
+ function M(r, e) {
71
+ const n = [];
72
+ return l(r, { visitJSXElement(s) {
73
+ const a = w(s.node, e);
74
+ return a && n.push(a), this.traverse(s), !1;
75
+ } }), n;
77
76
  }
78
- function E(r) {
77
+ function F(r) {
79
78
  return r.properties.some((e) => {
80
- if (n.namedTypes.ObjectProperty.check(e)) {
81
- const { key: t } = e;
82
- return n.namedTypes.Identifier.check(t) && t.name === "width" || n.namedTypes.StringLiteral.check(t) && t.value === "width";
83
- }
84
- return !1;
79
+ if (!t.namedTypes.ObjectProperty.check(e))
80
+ return !1;
81
+ const { key: n } = e;
82
+ return t.namedTypes.Identifier.check(n) ? n.name === "width" : t.namedTypes.StringLiteral.check(n) ? n.value === "width" : !1;
85
83
  });
86
84
  }
87
- function w(r) {
85
+ function N(r) {
88
86
  return r.properties.find((e) => {
89
- if (n.namedTypes.ObjectProperty.check(e) || n.namedTypes.ObjectMethod.check(e)) {
90
- const { key: t } = e;
91
- return n.namedTypes.Identifier.check(t) && t.name === "render" || n.namedTypes.StringLiteral.check(t) && t.value === "render";
92
- }
93
- return !1;
87
+ if (!t.namedTypes.ObjectProperty.check(e) && !t.namedTypes.ObjectMethod.check(e))
88
+ return !1;
89
+ const { key: n } = e;
90
+ return t.namedTypes.Identifier.check(n) ? n.name === "render" : t.namedTypes.StringLiteral.check(n) ? n.value === "render" : !1;
94
91
  });
95
92
  }
93
+ function b(r, e) {
94
+ const { callee: n } = r;
95
+ return t.namedTypes.Identifier.check(n) && n.name === e;
96
+ }
97
+ function A(r) {
98
+ const [e] = r.arguments;
99
+ return t.namedTypes.ArrowFunctionExpression.check(e) || t.namedTypes.FunctionExpression.check(e) ? e.body : null;
100
+ }
101
+ function j(r) {
102
+ const [e] = r.arguments;
103
+ if (!t.namedTypes.ArrowFunctionExpression.check(e) && !t.namedTypes.FunctionExpression.check(e))
104
+ return null;
105
+ const { body: n } = e;
106
+ if (t.namedTypes.ObjectExpression.check(n))
107
+ return n;
108
+ if (t.namedTypes.BlockStatement.check(n)) {
109
+ for (const s of n.body)
110
+ if (t.namedTypes.ReturnStatement.check(s) && t.namedTypes.ObjectExpression.check(s.argument))
111
+ return s.argument;
112
+ }
113
+ return null;
114
+ }
96
115
  function J(r) {
116
+ const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
117
+ return l(r, {
118
+ visitFunctionDeclaration(s) {
119
+ const { node: a } = s;
120
+ return t.namedTypes.Identifier.check(a.id) && e.set(a.id.name, a.body), this.traverse(s), !1;
121
+ },
122
+ visitVariableDeclarator(s) {
123
+ const { node: a } = s;
124
+ if (!t.namedTypes.Identifier.check(a.id) || !a.init)
125
+ return this.traverse(s), !1;
126
+ const o = a.id.name, { init: i } = a;
127
+ if (t.namedTypes.ArrowFunctionExpression.check(i) || t.namedTypes.FunctionExpression.check(i))
128
+ return e.set(o, i.body), this.traverse(s), !1;
129
+ if (t.namedTypes.ObjectExpression.check(i))
130
+ return n.set(o, i), this.traverse(s), !1;
131
+ if (t.namedTypes.CallExpression.check(i) && b(i, "useCallback")) {
132
+ const c = A(i);
133
+ return c && e.set(o, c), this.traverse(s), !1;
134
+ }
135
+ if (t.namedTypes.CallExpression.check(i) && b(i, "useMemo")) {
136
+ const c = j(i);
137
+ return c && n.set(o, c), this.traverse(s), !1;
138
+ }
139
+ return this.traverse(s), !1;
140
+ }
141
+ }), {
142
+ functionMap: e,
143
+ objectMap: n
144
+ };
145
+ }
146
+ function P(r, e) {
147
+ if (t.namedTypes.ObjectMethod.check(r))
148
+ return r.body;
149
+ const { value: n } = r;
150
+ if (t.namedTypes.ArrowFunctionExpression.check(n) || t.namedTypes.FunctionExpression.check(n))
151
+ return n.body;
152
+ if (t.namedTypes.Identifier.check(n)) {
153
+ const s = e.get(n.name);
154
+ if (s)
155
+ return s;
156
+ }
157
+ return null;
158
+ }
159
+ function X(r) {
97
160
  const { openingElement: e } = r;
98
- if (n.namedTypes.JSXIdentifier.check(e.name))
161
+ if (t.namedTypes.JSXIdentifier.check(e.name))
99
162
  return e.name.name;
100
- if (n.namedTypes.JSXMemberExpression.check(e.name)) {
101
- const { object: t, property: i } = e.name, s = n.namedTypes.JSXIdentifier.check(t) ? t.name : "?", o = n.namedTypes.JSXIdentifier.check(i) ? i.name : "?";
102
- return `${s}.${o}`;
163
+ if (t.namedTypes.JSXMemberExpression.check(e.name)) {
164
+ const { object: n, property: s } = e.name, a = t.namedTypes.JSXIdentifier.check(n) ? n.name : "?", o = t.namedTypes.JSXIdentifier.check(s) ? s.name : "?";
165
+ return `${a}.${o}`;
166
+ }
167
+ return "Unknown";
168
+ }
169
+ function W(r) {
170
+ let e = r.parentPath;
171
+ for (; e; ) {
172
+ if (t.namedTypes.JSXElement.check(e.node))
173
+ return X(e.node);
174
+ e = e.parentPath;
103
175
  }
104
176
  return "Unknown";
105
177
  }
106
- const N = {
178
+ var $ = {
107
179
  name: "operation-column-width",
108
180
  description: "Automatically calculate optimal width for operation columns based on button analysis",
109
181
  shouldProcess(r) {
110
182
  return r.code.includes(T);
111
183
  },
112
184
  transform(r) {
113
- const e = S(r.ast);
185
+ const e = g(r.ast);
114
186
  if (e.size === 0)
115
- return { hasChanges: !1, logs: [] };
116
- let t = !1;
117
- const i = [];
118
- return l(r.ast, {
119
- visitJSXAttribute(s) {
120
- const o = s.node;
121
- if (!n.namedTypes.JSXIdentifier.check(o.name) || o.name.name !== T)
122
- return this.traverse(s), !1;
123
- if (!n.namedTypes.JSXExpressionContainer.check(o.value) || !n.namedTypes.ObjectExpression.check(o.value.expression))
124
- return this.traverse(s), !1;
125
- const a = o.value.expression;
126
- if (E(a))
127
- return this.traverse(s), !1;
128
- const c = w(a);
129
- if (!c)
130
- return this.traverse(s), !1;
131
- const f = n.namedTypes.ObjectProperty.check(c) ? k(c.value, e) : k(c.body, e);
132
- if (f.length === 0)
133
- return this.traverse(s), !1;
134
- const { calculatedWidth: m, analysis: d } = P(f), p = n.builders.objectProperty(
135
- n.builders.identifier("width"),
136
- n.builders.numericLiteral(m)
137
- );
138
- p.comments = [n.builders.commentLine(` Auto-calculated: ${d} `, !0, !1)], a.properties.unshift(p), t = !0;
139
- let h = "Unknown", { parentPath: u } = s;
140
- for (; u; ) {
141
- const { node: y, parentPath: b } = u;
142
- if (n.namedTypes.JSXElement.check(y)) {
143
- h = J(y);
144
- break;
145
- }
146
- u = b;
147
- }
148
- return i.push(
149
- `📊 ${h}: ${r.fileName}`,
150
- ` └─ 🎯 Operation column auto-width: ${m}px (${d})`
151
- ), this.traverse(s), !1;
152
- }
153
- }), {
154
- hasChanges: t,
155
- logs: i
187
+ return {
188
+ hasChanges: !1,
189
+ logs: []
190
+ };
191
+ const { functionMap: n, objectMap: s } = J(r.ast);
192
+ let a = !1;
193
+ const o = [];
194
+ return l(r.ast, { visitJSXAttribute(i) {
195
+ const c = i.node;
196
+ if (!t.namedTypes.JSXIdentifier.check(c.name) || c.name.name !== T)
197
+ return this.traverse(i), !1;
198
+ if (!t.namedTypes.JSXExpressionContainer.check(c.value))
199
+ return this.traverse(i), !1;
200
+ const { expression: f } = c.value;
201
+ let u = null;
202
+ if (t.namedTypes.ObjectExpression.check(f) ? u = f : t.namedTypes.Identifier.check(f) && (u = s.get(f.name) ?? null), !u)
203
+ return this.traverse(i), !1;
204
+ if (F(u))
205
+ return this.traverse(i), !1;
206
+ const d = N(u);
207
+ if (!d)
208
+ return this.traverse(i), !1;
209
+ const m = P(d, n);
210
+ if (!m)
211
+ return this.traverse(i), !1;
212
+ const p = M(m, e);
213
+ if (p.length === 0)
214
+ return this.traverse(i), !1;
215
+ const { calculatedWidth: h, analysis: y } = S(p), k = t.builders.objectProperty(t.builders.identifier("width"), t.builders.numericLiteral(h));
216
+ k.comments = [t.builders.commentLine(` Auto-calculated: ${y} `, !0, !1)], u.properties.unshift(k), a = !0;
217
+ const v = W(i);
218
+ return o.push(`[${v}]: ${r.fileName}`, ` -> Operation column auto-width: ${h}px (${y})`), this.traverse(i), !1;
219
+ } }), {
220
+ hasChanges: a,
221
+ logs: o
156
222
  };
157
223
  }
158
224
  };
159
225
  export {
160
- N as operationColumnWidthPlugin
226
+ $ as operationColumnWidthPlugin
161
227
  };