@vef-framework/dev 2.0.10 → 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.
- package/dist/cjs/_internal/_rolldown/runtime.cjs +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/lint/commitlint.cjs +1 -1
- package/dist/cjs/lint/eslint.cjs +1 -1
- package/dist/cjs/lint/index.cjs +1 -1
- package/dist/cjs/lint/local-react-plugin.cjs +1 -0
- package/dist/cjs/lint/stylelint.cjs +1 -1
- package/dist/cjs/vite/chunks.cjs +1 -1
- package/dist/cjs/vite/config.cjs +1 -1
- package/dist/cjs/vite/constants.cjs +1 -1
- package/dist/cjs/vite/define.cjs +10 -11
- package/dist/cjs/vite/index.cjs +1 -1
- package/dist/cjs/vite/plugin-app-config.cjs +1 -1
- package/dist/cjs/vite/plugin-auto-enhance/core.cjs +1 -1
- package/dist/cjs/vite/plugin-auto-enhance/index.cjs +1 -1
- package/dist/cjs/vite/plugin-auto-enhance/plugins/index.cjs +1 -1
- package/dist/cjs/vite/plugin-auto-enhance/plugins/operation-column-width.cjs +1 -1
- package/dist/cjs/vite/plugin-conventional-config.cjs +1 -1
- package/dist/cjs/vite/plugin-eslint.cjs +1 -1
- package/dist/cjs/vite/plugin-html.cjs +2 -2
- package/dist/cjs/vite/plugin-icons.cjs +1 -1
- package/dist/cjs/vite/plugin-injection.cjs +1 -1
- package/dist/cjs/vite/plugin-inspect.cjs +1 -1
- package/dist/cjs/vite/plugin-react.cjs +1 -1
- package/dist/cjs/vite/plugin-router.cjs +3 -3
- package/dist/cjs/vite/plugin-stylelint.cjs +1 -1
- package/dist/cjs/vite/plugin-svgr.cjs +1 -1
- package/dist/cjs/vite/plugin-tsconfig-paths.cjs +1 -1
- package/dist/cjs/vite/postcss.cjs +1 -1
- package/dist/cli/index.js +5 -5
- package/dist/es/index.js +8 -10
- package/dist/es/lint/commitlint.js +5 -4
- package/dist/es/lint/eslint.js +650 -931
- package/dist/es/lint/index.js +3 -8
- package/dist/es/lint/local-react-plugin.js +42 -0
- package/dist/es/lint/stylelint.js +55 -74
- package/dist/es/vite/chunks.js +19 -16
- package/dist/es/vite/config.js +59 -66
- package/dist/es/vite/constants.js +9 -9
- package/dist/es/vite/define.js +16 -16
- package/dist/es/vite/index.js +1 -4
- package/dist/es/vite/plugin-app-config.js +10 -14
- package/dist/es/vite/plugin-auto-enhance/core.js +85 -85
- package/dist/es/vite/plugin-auto-enhance/index.js +13 -14
- package/dist/es/vite/plugin-auto-enhance/plugins/index.js +1 -4
- package/dist/es/vite/plugin-auto-enhance/plugins/operation-column-width.js +174 -108
- package/dist/es/vite/plugin-conventional-config.js +28 -42
- package/dist/es/vite/plugin-eslint.js +9 -4
- package/dist/es/vite/plugin-html.js +50 -53
- package/dist/es/vite/plugin-icons.js +6 -5
- package/dist/es/vite/plugin-injection.js +1 -11
- package/dist/es/vite/plugin-react.js +21 -63
- package/dist/es/vite/plugin-router.js +38 -31
- package/dist/es/vite/plugin-stylelint.js +9 -4
- package/dist/es/vite/plugin-svgr.js +2 -7
- package/dist/es/vite/plugin-tsconfig-paths.js +3 -6
- package/dist/types/src/lint/commitlint.d.ts +2 -0
- package/dist/types/src/lint/local-react-plugin.d.ts +29 -0
- package/dist/types/src/lint/stylelint.d.ts +2 -0
- package/dist/types/{vite → src/vite}/chunks.d.ts +0 -5
- package/dist/types/src/vite/config.d.ts +12 -0
- package/dist/types/src/vite/constants.d.ts +12 -0
- package/dist/types/src/vite/define.d.ts +4 -0
- package/dist/types/src/vite/plugin-app-config.d.ts +19 -0
- package/dist/types/{vite → src/vite}/plugin-auto-enhance/core.d.ts +6 -21
- package/dist/types/src/vite/plugin-auto-enhance/index.d.ts +10 -0
- package/dist/types/src/vite/plugin-auto-enhance/plugins/operation-column-width.d.ts +5 -0
- package/dist/types/{vite → src/vite}/plugin-auto-enhance/types.d.ts +7 -9
- package/dist/types/{vite → src/vite}/plugin-conventional-config.d.ts +1 -14
- package/dist/types/src/vite/plugin-eslint.d.ts +7 -0
- package/dist/types/src/vite/plugin-html.d.ts +7 -0
- package/dist/types/{vite → src/vite}/plugin-icons.d.ts +3 -3
- package/dist/types/src/vite/plugin-injection.d.ts +5 -0
- package/dist/types/src/vite/plugin-inspect.d.ts +5 -0
- package/dist/types/{vite → src/vite}/plugin-react.d.ts +10 -5
- package/dist/types/src/vite/plugin-router.d.ts +14 -0
- package/dist/types/src/vite/plugin-stylelint.d.ts +7 -0
- package/dist/types/src/vite/plugin-svgr.d.ts +7 -0
- package/dist/types/src/vite/plugin-tsconfig-paths.d.ts +8 -0
- package/dist/types/{vite → src/vite}/postcss.d.ts +0 -5
- package/package.json +66 -66
- package/tsconfig.base.json +0 -1
- package/dist/types/lint/commitlint.d.ts +0 -8
- package/dist/types/lint/stylelint.d.ts +0 -7
- package/dist/types/vite/config.d.ts +0 -39
- package/dist/types/vite/constants.d.ts +0 -48
- package/dist/types/vite/define.d.ts +0 -12
- package/dist/types/vite/plugin-app-config.d.ts +0 -28
- package/dist/types/vite/plugin-auto-enhance/index.d.ts +0 -30
- package/dist/types/vite/plugin-auto-enhance/plugins/operation-column-width.d.ts +0 -14
- package/dist/types/vite/plugin-eslint.d.ts +0 -7
- package/dist/types/vite/plugin-html.d.ts +0 -7
- package/dist/types/vite/plugin-injection.d.ts +0 -7
- package/dist/types/vite/plugin-inspect.d.ts +0 -7
- package/dist/types/vite/plugin-router.d.ts +0 -9
- package/dist/types/vite/plugin-stylelint.d.ts +0 -7
- package/dist/types/vite/plugin-svgr.d.ts +0 -7
- package/dist/types/vite/plugin-tsconfig-paths.d.ts +0 -8
- package/dist/types/{cli → src/cli}/index.d.ts +0 -0
- package/dist/types/{index.d.ts → src/index.d.ts} +0 -0
- package/dist/types/{lint → src/lint}/eslint.d.ts +0 -0
- package/dist/types/{lint → src/lint}/index.d.ts +0 -0
- package/dist/types/{vite → src/vite}/index.d.ts +1 -1
- /package/dist/types/{vite → src/vite}/plugin-auto-enhance/plugins/index.d.ts +0 -0
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import { basename as
|
|
2
|
-
import { parse as
|
|
3
|
-
import { parse as g, print as
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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(
|
|
25
|
+
constructor(r = {}) {
|
|
11
26
|
this.options = {
|
|
12
|
-
include:
|
|
13
|
-
exclude:
|
|
14
|
-
logPrefix:
|
|
15
|
-
...
|
|
27
|
+
include: h,
|
|
28
|
+
exclude: p,
|
|
29
|
+
logPrefix: m,
|
|
30
|
+
...r
|
|
16
31
|
};
|
|
17
32
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
registerPlugin(e) {
|
|
22
|
-
this.plugins.push(e);
|
|
33
|
+
registerPlugin(r) {
|
|
34
|
+
this.plugins.push(r);
|
|
23
35
|
}
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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:
|
|
54
|
-
fileName:
|
|
62
|
+
id: r,
|
|
63
|
+
fileName: e,
|
|
55
64
|
code: s,
|
|
56
|
-
ast:
|
|
65
|
+
ast: n
|
|
57
66
|
};
|
|
58
67
|
}
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
77
|
+
const t = f(e.ast);
|
|
78
|
+
return {
|
|
79
|
+
code: t.code,
|
|
80
|
+
map: t.map || null
|
|
81
|
+
};
|
|
91
82
|
}
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
103
|
+
x as AutoEnhanceCore
|
|
104
104
|
};
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { AutoEnhanceCore as
|
|
2
|
-
import "./plugins/
|
|
3
|
-
import { types as
|
|
4
|
-
function
|
|
5
|
-
|
|
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
|
|
15
|
-
console.log(
|
|
16
|
-
for (const n of e)
|
|
17
|
-
|
|
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
|
-
|
|
27
|
-
|
|
25
|
+
f as createAutoEnhancePlugin,
|
|
26
|
+
l as types
|
|
28
27
|
};
|
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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
|
|
4
|
+
return I.some((e) => r === e || r.startsWith(`${e}/`));
|
|
8
5
|
}
|
|
9
|
-
function
|
|
6
|
+
function g(r) {
|
|
10
7
|
const e = /* @__PURE__ */ new Map();
|
|
11
|
-
return l(r, {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
18
|
+
return this.traverse(n), !1;
|
|
19
|
+
} }), e;
|
|
24
20
|
}
|
|
25
21
|
function O(r) {
|
|
26
22
|
let e = 0;
|
|
27
|
-
for (const
|
|
28
|
-
e +=
|
|
23
|
+
for (const n of r)
|
|
24
|
+
e += x.test(n) ? 14 : 8;
|
|
29
25
|
return e;
|
|
30
26
|
}
|
|
31
|
-
function
|
|
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
|
|
40
|
-
for (const [
|
|
41
|
-
let
|
|
42
|
-
|
|
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
|
|
43
|
+
const s = Math.ceil(e / 8) * 8;
|
|
46
44
|
return {
|
|
47
|
-
calculatedWidth:
|
|
48
|
-
buttonCount:
|
|
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
|
|
53
|
-
const { openingElement:
|
|
54
|
-
if (!
|
|
50
|
+
function w(r, e) {
|
|
51
|
+
const { openingElement: n } = r;
|
|
52
|
+
if (!t.namedTypes.JSXIdentifier.check(n.name))
|
|
55
53
|
return null;
|
|
56
|
-
const
|
|
57
|
-
if (!e.has(
|
|
54
|
+
const s = n.name.name;
|
|
55
|
+
if (!e.has(s))
|
|
58
56
|
return null;
|
|
59
|
-
const
|
|
57
|
+
const a = {
|
|
60
58
|
hasIcon: !1,
|
|
61
59
|
textContent: ""
|
|
62
60
|
};
|
|
63
|
-
for (const o of
|
|
64
|
-
|
|
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
|
-
|
|
67
|
-
return
|
|
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
|
|
70
|
-
const
|
|
71
|
-
return l(r, {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
77
|
+
function F(r) {
|
|
79
78
|
return r.properties.some((e) => {
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
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
|
|
85
|
+
function N(r) {
|
|
88
86
|
return r.properties.find((e) => {
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
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 (
|
|
161
|
+
if (t.namedTypes.JSXIdentifier.check(e.name))
|
|
99
162
|
return e.name.name;
|
|
100
|
-
if (
|
|
101
|
-
const { object:
|
|
102
|
-
return `${
|
|
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
|
-
|
|
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 =
|
|
185
|
+
const e = g(r.ast);
|
|
114
186
|
if (e.size === 0)
|
|
115
|
-
return {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
226
|
+
$ as operationColumnWidthPlugin
|
|
161
227
|
};
|