@vef-framework-react/dev 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/README +15 -0
- package/bin/vef.js +13 -0
- package/dist/cjs/_internal/_rolldown/runtime.cjs +1 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/lint/commitlint.cjs +1 -0
- package/dist/cjs/lint/eslint.cjs +1 -0
- package/dist/cjs/lint/index.cjs +1 -0
- package/dist/cjs/lint/local-react-plugin.cjs +1 -0
- package/dist/cjs/lint/stylelint.cjs +1 -0
- package/dist/cjs/vite/chunks.cjs +1 -0
- package/dist/cjs/vite/config.cjs +1 -0
- package/dist/cjs/vite/constants.cjs +1 -0
- package/dist/cjs/vite/define.cjs +10 -0
- package/dist/cjs/vite/index.cjs +1 -0
- package/dist/cjs/vite/plugin-app-config.cjs +1 -0
- package/dist/cjs/vite/plugin-auto-enhance/core.cjs +1 -0
- package/dist/cjs/vite/plugin-auto-enhance/index.cjs +1 -0
- package/dist/cjs/vite/plugin-auto-enhance/plugins/index.cjs +1 -0
- package/dist/cjs/vite/plugin-auto-enhance/plugins/operation-column-width.cjs +1 -0
- package/dist/cjs/vite/plugin-conventional-config.cjs +1 -0
- package/dist/cjs/vite/plugin-eslint.cjs +1 -0
- package/dist/cjs/vite/plugin-html.cjs +144 -0
- package/dist/cjs/vite/plugin-icons.cjs +1 -0
- package/dist/cjs/vite/plugin-injection.cjs +1 -0
- package/dist/cjs/vite/plugin-inspect.cjs +1 -0
- package/dist/cjs/vite/plugin-react.cjs +1 -0
- package/dist/cjs/vite/plugin-router.cjs +11 -0
- package/dist/cjs/vite/plugin-stylelint.cjs +1 -0
- package/dist/cjs/vite/plugin-svgr.cjs +1 -0
- package/dist/cjs/vite/plugin-tsconfig-paths.cjs +1 -0
- package/dist/cjs/vite/postcss.cjs +1 -0
- package/dist/cli/index.js +5 -0
- package/dist/es/index.js +12 -0
- package/dist/es/lint/commitlint.js +10 -0
- package/dist/es/lint/eslint.js +675 -0
- package/dist/es/lint/index.js +3 -0
- package/dist/es/lint/local-react-plugin.js +42 -0
- package/dist/es/lint/stylelint.js +67 -0
- package/dist/es/vite/chunks.js +23 -0
- package/dist/es/vite/config.js +67 -0
- package/dist/es/vite/constants.js +15 -0
- package/dist/es/vite/define.js +21 -0
- package/dist/es/vite/index.js +2 -0
- package/dist/es/vite/plugin-app-config.js +29 -0
- package/dist/es/vite/plugin-auto-enhance/core.js +104 -0
- package/dist/es/vite/plugin-auto-enhance/index.js +27 -0
- package/dist/es/vite/plugin-auto-enhance/plugins/index.js +1 -0
- package/dist/es/vite/plugin-auto-enhance/plugins/operation-column-width.js +227 -0
- package/dist/es/vite/plugin-conventional-config.js +71 -0
- package/dist/es/vite/plugin-eslint.js +24 -0
- package/dist/es/vite/plugin-html.js +198 -0
- package/dist/es/vite/plugin-icons.js +17 -0
- package/dist/es/vite/plugin-injection.js +6 -0
- package/dist/es/vite/plugin-inspect.js +10 -0
- package/dist/es/vite/plugin-react.js +24 -0
- package/dist/es/vite/plugin-router.js +51 -0
- package/dist/es/vite/plugin-stylelint.js +24 -0
- package/dist/es/vite/plugin-svgr.js +49 -0
- package/dist/es/vite/plugin-tsconfig-paths.js +6 -0
- package/dist/es/vite/postcss.js +9 -0
- package/dist/types/src/cli/index.d.ts +1 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/lint/commitlint.d.ts +2 -0
- package/dist/types/src/lint/eslint.d.ts +2 -0
- package/dist/types/src/lint/index.d.ts +3 -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/src/vite/chunks.d.ts +5 -0
- 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/index.d.ts +3 -0
- package/dist/types/src/vite/plugin-app-config.d.ts +19 -0
- package/dist/types/src/vite/plugin-auto-enhance/core.d.ts +20 -0
- package/dist/types/src/vite/plugin-auto-enhance/index.d.ts +10 -0
- package/dist/types/src/vite/plugin-auto-enhance/plugins/index.d.ts +1 -0
- package/dist/types/src/vite/plugin-auto-enhance/plugins/operation-column-width.d.ts +5 -0
- package/dist/types/src/vite/plugin-auto-enhance/types.d.ts +81 -0
- package/dist/types/src/vite/plugin-conventional-config.d.ts +35 -0
- 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/src/vite/plugin-icons.d.ts +8 -0
- 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/src/vite/plugin-react.d.ts +30 -0
- 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/src/vite/postcss.d.ts +4 -0
- package/package.json +139 -0
- package/tsconfig.base.json +32 -0
- package/types.d.ts +16 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function a(e) {
|
|
2
|
+
return e !== null && typeof e == "object" && "type" in e && e.type === "JSXOpeningElement";
|
|
3
|
+
}
|
|
4
|
+
var p = {
|
|
5
|
+
create(e) {
|
|
6
|
+
const i = (e.options[0] ?? {}).ignoreCase ?? !1;
|
|
7
|
+
return { JSXOpeningElement(r) {
|
|
8
|
+
if (!a(r))
|
|
9
|
+
return;
|
|
10
|
+
const n = {};
|
|
11
|
+
for (const o of r.attributes) {
|
|
12
|
+
if (o.type === "JSXSpreadAttribute")
|
|
13
|
+
continue;
|
|
14
|
+
let { name: t } = o.name;
|
|
15
|
+
if (typeof t == "string") {
|
|
16
|
+
if (i && (t = t.toLowerCase()), Object.hasOwn(n, t)) {
|
|
17
|
+
e.report({
|
|
18
|
+
messageId: "noDuplicateProps",
|
|
19
|
+
node: o
|
|
20
|
+
});
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
n[t] = !0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
} };
|
|
27
|
+
},
|
|
28
|
+
meta: {
|
|
29
|
+
docs: { description: "Disallow duplicate properties in JSX." },
|
|
30
|
+
messages: { noDuplicateProps: "No duplicate props allowed." },
|
|
31
|
+
schema: [{
|
|
32
|
+
additionalProperties: !1,
|
|
33
|
+
properties: { ignoreCase: { type: "boolean" } },
|
|
34
|
+
type: "object"
|
|
35
|
+
}],
|
|
36
|
+
type: "problem"
|
|
37
|
+
}
|
|
38
|
+
}, l = { rules: { "jsx-no-duplicate-props": p } }, c = { "local-react/jsx-no-duplicate-props": "error" };
|
|
39
|
+
export {
|
|
40
|
+
l as localReactPlugin,
|
|
41
|
+
c as localReactRules
|
|
42
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import r from "stylelint-config-recess-order/groups";
|
|
2
|
+
var n = [
|
|
3
|
+
"px",
|
|
4
|
+
"em",
|
|
5
|
+
"rem",
|
|
6
|
+
"%",
|
|
7
|
+
"vw",
|
|
8
|
+
"vh",
|
|
9
|
+
"fr",
|
|
10
|
+
"deg",
|
|
11
|
+
"rad",
|
|
12
|
+
"grad",
|
|
13
|
+
"turn",
|
|
14
|
+
"ms",
|
|
15
|
+
"s"
|
|
16
|
+
], o = {
|
|
17
|
+
"order/order": [
|
|
18
|
+
"dollar-variables",
|
|
19
|
+
"at-variables",
|
|
20
|
+
"custom-properties",
|
|
21
|
+
"less-mixins",
|
|
22
|
+
"declarations",
|
|
23
|
+
"at-rules",
|
|
24
|
+
"rules"
|
|
25
|
+
],
|
|
26
|
+
"order/properties-order": r.map((e) => ({
|
|
27
|
+
...e,
|
|
28
|
+
emptyLineBefore: "never",
|
|
29
|
+
noEmptyLineBetween: !0
|
|
30
|
+
}))
|
|
31
|
+
}, l = {
|
|
32
|
+
"declaration-empty-line-before": "never",
|
|
33
|
+
"declaration-property-value-no-unknown": [!0, { ignoreProperties: {} }]
|
|
34
|
+
}, s = {
|
|
35
|
+
"at-rule-no-unknown": null,
|
|
36
|
+
"function-no-unknown": null,
|
|
37
|
+
"scss/at-rule-no-unknown": [!0, { ignoreAtRules: ["extend", "include"] }],
|
|
38
|
+
"scss/function-no-unknown": [!0, { ignoreFunctions: [] }]
|
|
39
|
+
}, t = {
|
|
40
|
+
"color-hex-alpha": "never",
|
|
41
|
+
"color-hex-length": "long",
|
|
42
|
+
"color-named": "never"
|
|
43
|
+
}, u = { "selector-pseudo-class-no-unknown": [!0, { ignorePseudoClasses: ["global"] }] }, i = {
|
|
44
|
+
"number-max-precision": null,
|
|
45
|
+
"unit-allowed-list": n
|
|
46
|
+
};
|
|
47
|
+
function c() {
|
|
48
|
+
return {
|
|
49
|
+
extends: [
|
|
50
|
+
"stylelint-config-recommended",
|
|
51
|
+
"stylelint-config-standard-scss",
|
|
52
|
+
"@stylistic/stylelint-config"
|
|
53
|
+
],
|
|
54
|
+
plugins: ["stylelint-order"],
|
|
55
|
+
rules: {
|
|
56
|
+
...o,
|
|
57
|
+
...l,
|
|
58
|
+
...s,
|
|
59
|
+
...t,
|
|
60
|
+
...u,
|
|
61
|
+
...i
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
c as defineStylelintConfig
|
|
67
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var r = [
|
|
2
|
+
["node_modules/@vef-framework-react/", "vef-framework"],
|
|
3
|
+
["/packages/", "vef-framework"],
|
|
4
|
+
["node_modules/lucide-react/", "lucide-icons"],
|
|
5
|
+
["node_modules/react/", "react"],
|
|
6
|
+
["node_modules/react-dom/", "react"],
|
|
7
|
+
["node_modules/scheduler/", "react"],
|
|
8
|
+
["node_modules/@tanstack/", "tanstack"],
|
|
9
|
+
["node_modules/pinyin-pro/", "pinyin-vendor"],
|
|
10
|
+
["node_modules/@pinyin-pro/", "pinyin-vendor"],
|
|
11
|
+
["node_modules/echarts/", "echarts"]
|
|
12
|
+
];
|
|
13
|
+
function d(e) {
|
|
14
|
+
for (const [n, o] of r)
|
|
15
|
+
if (e.includes(n))
|
|
16
|
+
return o;
|
|
17
|
+
}
|
|
18
|
+
function t() {
|
|
19
|
+
return d;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
t as createChunksConfig
|
|
23
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ENV_BUILD_PREFIX as u } from "./constants.js";
|
|
2
|
+
import { createAppConfigPlugin as f } from "./plugin-app-config.js";
|
|
3
|
+
import { operationColumnWidthPlugin as P } from "./plugin-auto-enhance/plugins/operation-column-width.js";
|
|
4
|
+
import { createAutoEnhancePlugin as g } from "./plugin-auto-enhance/index.js";
|
|
5
|
+
import { createConventionalConfigPlugin as _ } from "./plugin-conventional-config.js";
|
|
6
|
+
import { createEslintPlugin as E } from "./plugin-eslint.js";
|
|
7
|
+
import { createHtmlPlugin as v } from "./plugin-html.js";
|
|
8
|
+
import { createIconsPlugin as I } from "./plugin-icons.js";
|
|
9
|
+
import { createInjectionPlugin as U } from "./plugin-injection.js";
|
|
10
|
+
import { createInspectPlugin as V } from "./plugin-inspect.js";
|
|
11
|
+
import { createReactPlugin as A } from "./plugin-react.js";
|
|
12
|
+
import { createRouterPlugin as B } from "./plugin-router.js";
|
|
13
|
+
import { createStylelintPlugin as D } from "./plugin-stylelint.js";
|
|
14
|
+
import { createSvgrPlugin as b } from "./plugin-svgr.js";
|
|
15
|
+
import { createTsconfigPathsResolveConfig as d } from "./plugin-tsconfig-paths.js";
|
|
16
|
+
import { resolve as C } from "node:path";
|
|
17
|
+
import L from "node:process";
|
|
18
|
+
import R from "consola";
|
|
19
|
+
import F from "fs-extra";
|
|
20
|
+
import { defineConfig as T, loadEnv as h } from "vite";
|
|
21
|
+
async function N(e) {
|
|
22
|
+
return (await F.readJson(C(e, "package.json"), { encoding: "utf-8" })).version;
|
|
23
|
+
}
|
|
24
|
+
function oo(e = {}) {
|
|
25
|
+
const { resolve: t, plugins: n = [], autoEnhancePlugins: i = [], routerHistory: a = "browser", react: m, proxies: p } = e, r = L.cwd();
|
|
26
|
+
return T(async ({ mode: c }) => {
|
|
27
|
+
const o = h(c, "env", u);
|
|
28
|
+
Object.keys(o).length > 0 && (R.info("Loaded environment variables:"), console.table(o));
|
|
29
|
+
const s = await N(r), l = [
|
|
30
|
+
...n,
|
|
31
|
+
V(),
|
|
32
|
+
_({
|
|
33
|
+
appName: o.VEF_APP_NAME,
|
|
34
|
+
appVersion: s,
|
|
35
|
+
projectDir: r,
|
|
36
|
+
basePublicPath: o.VEF_BUILD_BASE_PUBLIC_PATH,
|
|
37
|
+
outputDir: o.VEF_BUILD_OUTPUT_DIR,
|
|
38
|
+
serverPort: Number(o.VEF_BUILD_SERVER_PORT),
|
|
39
|
+
proxies: p
|
|
40
|
+
}),
|
|
41
|
+
g({ plugins: [P, ...i] }),
|
|
42
|
+
B(r, a),
|
|
43
|
+
A(m),
|
|
44
|
+
v(),
|
|
45
|
+
U(),
|
|
46
|
+
f({
|
|
47
|
+
basePublicPath: o.VEF_BUILD_BASE_PUBLIC_PATH,
|
|
48
|
+
outputDir: o.VEF_BUILD_OUTPUT_DIR,
|
|
49
|
+
appName: o.VEF_APP_NAME
|
|
50
|
+
}),
|
|
51
|
+
I(r),
|
|
52
|
+
b(),
|
|
53
|
+
E(),
|
|
54
|
+
D()
|
|
55
|
+
];
|
|
56
|
+
return {
|
|
57
|
+
resolve: {
|
|
58
|
+
...t,
|
|
59
|
+
...d()
|
|
60
|
+
},
|
|
61
|
+
plugins: l.filter(Boolean)
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
oo as defineViteConfig
|
|
67
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var _ = "1.0.0", E = "public";
|
|
2
|
+
var R = "assets", r = "VEF_APP_", a = "VEF_BUILD_";
|
|
3
|
+
var P = "dist", v = 3833;
|
|
4
|
+
var I = "pages", D = "router";
|
|
5
|
+
export {
|
|
6
|
+
R as ASSETS_DIR,
|
|
7
|
+
P as DEFAULT_OUTPUT_DIR,
|
|
8
|
+
v as DEFAULT_SERVER_PORT,
|
|
9
|
+
r as ENV_APP_PREFIX,
|
|
10
|
+
a as ENV_BUILD_PREFIX,
|
|
11
|
+
I as PAGES_DIR,
|
|
12
|
+
E as PUBLIC_DIR,
|
|
13
|
+
D as ROUTER_DIR,
|
|
14
|
+
_ as VEF_FRAMEWORK_VERSION
|
|
15
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ENV_APP_PREFIX as i, VEF_FRAMEWORK_VERSION as r } from "./constants.js";
|
|
2
|
+
function o(_, e, n) {
|
|
3
|
+
const t = n ? `(function () {
|
|
4
|
+
const env = import.meta.env;
|
|
5
|
+
const config = Object.keys(env)
|
|
6
|
+
.filter(key => key.startsWith(${JSON.stringify(i)}))
|
|
7
|
+
.reduce((acc, key) => {
|
|
8
|
+
acc[key] = env[key];
|
|
9
|
+
return acc;
|
|
10
|
+
}, {});
|
|
11
|
+
return Object.freeze(config);
|
|
12
|
+
})()` : `window.__PRODUCTION__VEF_${_ ?? "APP"}__CONF__`;
|
|
13
|
+
return {
|
|
14
|
+
__VEF_FRAMEWORK_VERSION__: JSON.stringify(r),
|
|
15
|
+
__VEF_APP_VERSION__: JSON.stringify(e),
|
|
16
|
+
__VEF_APP_CONFIG__: t
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
o as defineConstants
|
|
21
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ENV_APP_PREFIX as i } from "./constants.js";
|
|
2
|
+
import { snake as o } from "radashi";
|
|
3
|
+
import r from "unplugin-config/vite";
|
|
4
|
+
function p(e) {
|
|
5
|
+
return o(e).toUpperCase();
|
|
6
|
+
}
|
|
7
|
+
function u({ basePublicPath: e, outputDir: n, appName: t = "APP" }) {
|
|
8
|
+
return r({
|
|
9
|
+
appName: `VEF_${p(t)}`,
|
|
10
|
+
baseDir: e,
|
|
11
|
+
configFile: {
|
|
12
|
+
generate: !0,
|
|
13
|
+
fileName: "app.config.js",
|
|
14
|
+
outputDir: n ?? "dist"
|
|
15
|
+
},
|
|
16
|
+
htmlInjection: {
|
|
17
|
+
enable: !0,
|
|
18
|
+
position: "head-prepend",
|
|
19
|
+
templates: ["index.html"]
|
|
20
|
+
},
|
|
21
|
+
envVariables: {
|
|
22
|
+
prefix: i,
|
|
23
|
+
files: ["env/.env", "env/.env.production"]
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
u as createAppConfigPlugin
|
|
29
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
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));
|
|
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 {
|
|
23
|
+
plugins = [];
|
|
24
|
+
options;
|
|
25
|
+
constructor(r = {}) {
|
|
26
|
+
this.options = {
|
|
27
|
+
include: h,
|
|
28
|
+
exclude: p,
|
|
29
|
+
logPrefix: m,
|
|
30
|
+
...r
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
registerPlugin(r) {
|
|
34
|
+
this.plugins.push(r);
|
|
35
|
+
}
|
|
36
|
+
registerPlugins(r) {
|
|
37
|
+
for (const s of r)
|
|
38
|
+
this.plugins.push(s);
|
|
39
|
+
}
|
|
40
|
+
getRegisteredPlugins() {
|
|
41
|
+
return this.plugins.map(({ name: r, description: s }) => ({
|
|
42
|
+
name: r,
|
|
43
|
+
description: s
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
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));
|
|
61
|
+
return {
|
|
62
|
+
id: r,
|
|
63
|
+
fileName: e,
|
|
64
|
+
code: s,
|
|
65
|
+
ast: n
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
executeTransform(r, s) {
|
|
69
|
+
const e = this.buildTransformInfo(s, r), n = this.getActivePlugins(e);
|
|
70
|
+
if (n.length === 0)
|
|
71
|
+
return null;
|
|
72
|
+
const { hasChanges: i, logs: o } = this.runPlugins(n, e);
|
|
73
|
+
for (const l of o)
|
|
74
|
+
console.log(l);
|
|
75
|
+
if (!i)
|
|
76
|
+
return null;
|
|
77
|
+
const t = f(e.ast);
|
|
78
|
+
return {
|
|
79
|
+
code: t.code,
|
|
80
|
+
map: t.map || null
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
getActivePlugins(r) {
|
|
84
|
+
return this.plugins.filter((s) => s.shouldProcess ? s.shouldProcess(r) : !0);
|
|
85
|
+
}
|
|
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
|
+
export {
|
|
103
|
+
x as AutoEnhanceCore
|
|
104
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
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);
|
|
6
|
+
return r && o.registerPlugins(r), {
|
|
7
|
+
name: "vef-framework:auto-enhance",
|
|
8
|
+
enforce: "pre",
|
|
9
|
+
buildStart() {
|
|
10
|
+
const e = o.getRegisteredPlugins();
|
|
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
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
transform(e, n) {
|
|
20
|
+
return o.transform(e, n);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
f as createAutoEnhancePlugin,
|
|
26
|
+
l as types
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./operation-column-width.js";
|
|
@@ -0,0 +1,227 @@
|
|
|
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-react/components", "@vef-framework-react/starter"];
|
|
3
|
+
function C(r) {
|
|
4
|
+
return I.some((e) => r === e || r.startsWith(`${e}/`));
|
|
5
|
+
}
|
|
6
|
+
function g(r) {
|
|
7
|
+
const e = /* @__PURE__ */ new Map();
|
|
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);
|
|
17
|
+
}
|
|
18
|
+
return this.traverse(n), !1;
|
|
19
|
+
} }), e;
|
|
20
|
+
}
|
|
21
|
+
function O(r) {
|
|
22
|
+
let e = 0;
|
|
23
|
+
for (const n of r)
|
|
24
|
+
e += x.test(n) ? 14 : 8;
|
|
25
|
+
return e;
|
|
26
|
+
}
|
|
27
|
+
function S(r) {
|
|
28
|
+
if (r.length === 0)
|
|
29
|
+
return {
|
|
30
|
+
calculatedWidth: 64,
|
|
31
|
+
buttonCount: 0,
|
|
32
|
+
analysis: "No buttons found, using minimum width"
|
|
33
|
+
};
|
|
34
|
+
let e = 0;
|
|
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);
|
|
41
|
+
}
|
|
42
|
+
e += 16;
|
|
43
|
+
const s = Math.ceil(e / 8) * 8;
|
|
44
|
+
return {
|
|
45
|
+
calculatedWidth: s,
|
|
46
|
+
buttonCount: n,
|
|
47
|
+
analysis: `${n} buttons, calculated: ${e}px, final: ${s}px`
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function w(r, e) {
|
|
51
|
+
const { openingElement: n } = r;
|
|
52
|
+
if (!t.namedTypes.JSXIdentifier.check(n.name))
|
|
53
|
+
return null;
|
|
54
|
+
const s = n.name.name;
|
|
55
|
+
if (!e.has(s))
|
|
56
|
+
return null;
|
|
57
|
+
const a = {
|
|
58
|
+
hasIcon: !1,
|
|
59
|
+
textContent: ""
|
|
60
|
+
};
|
|
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
|
+
}
|
|
66
|
+
for (const o of r.children || [])
|
|
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;
|
|
69
|
+
}
|
|
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;
|
|
76
|
+
}
|
|
77
|
+
function F(r) {
|
|
78
|
+
return r.properties.some((e) => {
|
|
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;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function N(r) {
|
|
86
|
+
return r.properties.find((e) => {
|
|
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;
|
|
91
|
+
});
|
|
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
|
+
}
|
|
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) {
|
|
160
|
+
const { openingElement: e } = r;
|
|
161
|
+
if (t.namedTypes.JSXIdentifier.check(e.name))
|
|
162
|
+
return e.name.name;
|
|
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;
|
|
175
|
+
}
|
|
176
|
+
return "Unknown";
|
|
177
|
+
}
|
|
178
|
+
var $ = {
|
|
179
|
+
name: "operation-column-width",
|
|
180
|
+
description: "Automatically calculate optimal width for operation columns based on button analysis",
|
|
181
|
+
shouldProcess(r) {
|
|
182
|
+
return r.code.includes(T);
|
|
183
|
+
},
|
|
184
|
+
transform(r) {
|
|
185
|
+
const e = g(r.ast);
|
|
186
|
+
if (e.size === 0)
|
|
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
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
export {
|
|
226
|
+
$ as operationColumnWidthPlugin
|
|
227
|
+
};
|