@vef-framework/dev 1.0.135 → 2.0.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.
- package/README +15 -0
- package/dist/cjs/index.cjs +23 -0
- package/dist/cjs/lint/commitlint.cjs +14 -0
- package/dist/cjs/lint/eslint.cjs +981 -0
- package/dist/cjs/lint/index.cjs +14 -0
- package/dist/cjs/lint/stylelint.cjs +92 -0
- package/dist/cjs/vite/chunks.cjs +30 -0
- package/dist/cjs/vite/config.cjs +83 -0
- package/dist/cjs/vite/constants.cjs +30 -0
- package/dist/cjs/vite/define.cjs +26 -0
- package/dist/cjs/vite/index.cjs +11 -0
- package/dist/cjs/vite/plugin-app-config.cjs +38 -0
- package/dist/cjs/vite/plugin-auto-enhance/core.cjs +147 -0
- package/dist/cjs/vite/plugin-auto-enhance/index.cjs +40 -0
- package/dist/cjs/vite/plugin-auto-enhance/plugins/index.cjs +10 -0
- package/dist/cjs/vite/plugin-auto-enhance/plugins/operation-column-width.cjs +229 -0
- package/dist/cjs/vite/plugin-conventional-config.cjs +91 -0
- package/dist/cjs/vite/plugin-eslint.cjs +24 -0
- package/dist/cjs/vite/plugin-html.cjs +216 -0
- package/dist/cjs/vite/plugin-icons.cjs +22 -0
- package/dist/cjs/vite/plugin-injection.cjs +20 -0
- package/dist/cjs/vite/plugin-inspect.cjs +15 -0
- package/dist/cjs/vite/plugin-react.cjs +80 -0
- package/dist/cjs/vite/plugin-router.cjs +49 -0
- package/dist/cjs/vite/plugin-stylelint.cjs +24 -0
- package/dist/cjs/vite/plugin-svgr.cjs +59 -0
- package/dist/cjs/vite/plugin-tsconfig-paths.cjs +14 -0
- package/dist/cjs/vite/postcss.cjs +13 -0
- package/dist/es/index.js +8 -0
- package/dist/es/lint/commitlint.js +10 -0
- package/dist/es/lint/eslint.js +958 -0
- package/dist/es/lint/index.js +4 -0
- package/dist/es/lint/stylelint.js +88 -0
- package/dist/es/vite/chunks.js +26 -0
- package/dist/es/vite/config.js +79 -0
- package/dist/es/vite/constants.js +15 -0
- package/dist/es/vite/define.js +22 -0
- package/dist/es/vite/index.js +3 -0
- package/dist/es/vite/plugin-app-config.js +34 -0
- package/dist/es/vite/plugin-auto-enhance/core.js +143 -0
- package/dist/es/vite/plugin-auto-enhance/index.js +32 -0
- package/dist/es/vite/plugin-auto-enhance/plugins/index.js +2 -0
- package/dist/es/vite/plugin-auto-enhance/plugins/operation-column-width.js +225 -0
- package/dist/es/vite/plugin-conventional-config.js +87 -0
- package/dist/es/vite/plugin-eslint.js +20 -0
- package/dist/es/vite/plugin-html.js +212 -0
- package/dist/es/vite/plugin-icons.js +17 -0
- package/dist/es/vite/plugin-injection.js +16 -0
- package/dist/es/vite/plugin-inspect.js +11 -0
- package/dist/es/vite/plugin-react.js +76 -0
- package/dist/es/vite/plugin-router.js +45 -0
- package/dist/es/vite/plugin-stylelint.js +20 -0
- package/dist/es/vite/plugin-svgr.js +55 -0
- package/dist/es/vite/plugin-tsconfig-paths.js +10 -0
- package/dist/es/vite/postcss.js +9 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/lint/commitlint.d.ts +8 -0
- package/dist/types/lint/eslint.d.ts +2 -0
- package/dist/types/lint/index.d.ts +3 -0
- package/dist/types/lint/stylelint.d.ts +7 -0
- package/dist/types/vite/chunks.d.ts +10 -0
- package/dist/types/vite/config.d.ts +39 -0
- package/{types → dist/types/vite}/constants.d.ts +4 -0
- package/dist/types/vite/define.d.ts +12 -0
- package/dist/types/vite/index.d.ts +3 -0
- package/{types → dist/types/vite}/plugin-app-config.d.ts +2 -1
- package/dist/types/vite/plugin-auto-enhance/core.d.ts +35 -0
- package/dist/types/vite/plugin-auto-enhance/index.d.ts +30 -0
- package/dist/types/vite/plugin-auto-enhance/plugins/index.d.ts +1 -0
- package/dist/types/vite/plugin-auto-enhance/plugins/operation-column-width.d.ts +14 -0
- package/dist/types/vite/plugin-auto-enhance/types.d.ts +83 -0
- package/{types → dist/types/vite}/plugin-conventional-config.d.ts +2 -2
- package/dist/types/vite/plugin-eslint.d.ts +7 -0
- package/{types → dist/types/vite}/plugin-html.d.ts +1 -1
- package/dist/types/vite/plugin-icons.d.ts +8 -0
- package/{types → dist/types/vite}/plugin-injection.d.ts +1 -1
- package/{types → dist/types/vite}/plugin-inspect.d.ts +2 -1
- package/dist/types/vite/plugin-react.d.ts +25 -0
- package/{types → dist/types/vite}/plugin-router.d.ts +2 -2
- package/dist/types/vite/plugin-stylelint.d.ts +7 -0
- package/dist/types/vite/plugin-svgr.d.ts +7 -0
- package/{types → dist/types/vite}/plugin-tsconfig-paths.d.ts +2 -1
- package/dist/types/vite/postcss.d.ts +9 -0
- package/package.json +94 -74
- package/{tsconfig.app.json → tsconfig.base.json} +13 -9
- package/{client.d.ts → types.d.ts} +0 -6
- package/README.md +0 -25
- package/bin/hoist-patterns.js +0 -1
- package/bin/vef.js +0 -18
- package/cjs/cli.cjs +0 -5
- package/cjs/commitlint-config.cjs +0 -2
- package/cjs/config.cjs +0 -2
- package/cjs/constants.cjs +0 -2
- package/cjs/eslint-config.cjs +0 -2
- package/cjs/index.cjs +0 -2
- package/cjs/json/monaco.nls.json.cjs +0 -15920
- package/cjs/json/monaco.theme.github-light.json.cjs +0 -349
- package/cjs/modules.d.cjs +0 -2
- package/cjs/plugin-app-config.cjs +0 -2
- package/cjs/plugin-conventional-config.cjs +0 -12
- package/cjs/plugin-eslint.cjs +0 -2
- package/cjs/plugin-html.cjs +0 -17
- package/cjs/plugin-icons.cjs +0 -2
- package/cjs/plugin-initialization.cjs +0 -135
- package/cjs/plugin-injection.cjs +0 -3
- package/cjs/plugin-inspect.cjs +0 -2
- package/cjs/plugin-monaco-nls.cjs +0 -80
- package/cjs/plugin-react-swc.cjs +0 -2
- package/cjs/plugin-router.cjs +0 -11
- package/cjs/plugin-stylelint.cjs +0 -2
- package/cjs/plugin-svgr.cjs +0 -2
- package/cjs/plugin-tailwind.cjs +0 -2
- package/cjs/plugin-tailwindcss.cjs +0 -3
- package/cjs/plugin-tsconfig-paths.cjs +0 -2
- package/cjs/plugin-visualizer.cjs +0 -2
- package/cjs/plugin-webfont.cjs +0 -2
- package/cjs/stylelint-config.cjs +0 -2
- package/cjs/tailwind-config.cjs +0 -2
- package/cjs/types.cjs +0 -2
- package/esm/cli.js +0 -5
- package/esm/commitlint-config.js +0 -2
- package/esm/config.js +0 -2
- package/esm/constants.js +0 -2
- package/esm/eslint-config.js +0 -2
- package/esm/index.js +0 -2
- package/esm/json/monaco.nls.json.js +0 -15920
- package/esm/json/monaco.theme.github-light.json.js +0 -349
- package/esm/modules.d.js +0 -2
- package/esm/plugin-app-config.js +0 -2
- package/esm/plugin-conventional-config.js +0 -12
- package/esm/plugin-eslint.js +0 -2
- package/esm/plugin-html.js +0 -17
- package/esm/plugin-icons.js +0 -2
- package/esm/plugin-initialization.js +0 -135
- package/esm/plugin-injection.js +0 -3
- package/esm/plugin-inspect.js +0 -2
- package/esm/plugin-monaco-nls.js +0 -80
- package/esm/plugin-react-swc.js +0 -2
- package/esm/plugin-router.js +0 -11
- package/esm/plugin-stylelint.js +0 -2
- package/esm/plugin-svgr.js +0 -2
- package/esm/plugin-tailwind.js +0 -2
- package/esm/plugin-tailwindcss.js +0 -3
- package/esm/plugin-tsconfig-paths.js +0 -2
- package/esm/plugin-visualizer.js +0 -2
- package/esm/plugin-webfont.js +0 -2
- package/esm/stylelint-config.js +0 -2
- package/esm/tailwind-config.js +0 -2
- package/esm/types.js +0 -2
- package/template/.vscode/settings.json +0 -6
- package/template/_gitignore +0 -35
- package/template/_package.json +0 -43
- package/template/_tsconfig.json +0 -7
- package/template/commitlint.config.js +0 -3
- package/template/env/.env +0 -7
- package/template/env/.env.development +0 -0
- package/template/env/.env.production +0 -0
- package/template/env.d.ts +0 -1
- package/template/eslint.config.js +0 -3
- package/template/index.html +0 -0
- package/template/public/favicon.svg +0 -1
- package/template/src/main.ts +0 -145
- package/template/src/pages/__root.ts +0 -3
- package/template/src/pages/_common/access-denied.ts +0 -6
- package/template/src/pages/_common/login.ts +0 -8
- package/template/src/pages/_layout/index.tsx +0 -35
- package/template/src/pages/_layout/route.ts +0 -9
- package/template/src/pages/_layout/system/data-dictionary.tsx +0 -14
- package/template/src/pages/_layout/system/index.ts +0 -7
- package/template/src/pages/_layout/system/tenant.tsx +0 -14
- package/template/src/router/index.ts +0 -1
- package/template/style.css +0 -2
- package/template/stylelint.config.js +0 -3
- package/template/tailwind.config.js +0 -3
- package/template/tsconfig.app.json +0 -4
- package/template/tsconfig.build.json +0 -4
- package/template/vef.config.ts +0 -7
- package/tsconfig.build.json +0 -26
- package/types/cli.d.ts +0 -1
- package/types/commitlint-config.d.ts +0 -7
- package/types/config.d.ts +0 -38
- package/types/eslint-config.d.ts +0 -7
- package/types/index.d.ts +0 -5
- package/types/plugin-eslint.d.ts +0 -6
- package/types/plugin-icons.d.ts +0 -7
- package/types/plugin-initialization.d.ts +0 -7
- package/types/plugin-monaco-nls.d.ts +0 -15
- package/types/plugin-react-swc.d.ts +0 -6
- package/types/plugin-stylelint.d.ts +0 -6
- package/types/plugin-svgr.d.ts +0 -6
- package/types/plugin-tailwind.d.ts +0 -7
- package/types/plugin-tailwindcss.d.ts +0 -7
- package/types/plugin-visualizer.d.ts +0 -7
- package/types/plugin-webfont.d.ts +0 -6
- package/types/stylelint-config.d.ts +0 -7
- package/types/tailwind-config.d.ts +0 -7
- package/types/types.d.ts +0 -15
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*! @vef-framework/dev v2.0.0 made with ❤️ by Venus | 2025-11-25T10:06:28.561Z */
|
|
2
|
+
import propertyGroups from 'stylelint-config-recess-order/groups';
|
|
3
|
+
|
|
4
|
+
function defineStylelintConfig() {
|
|
5
|
+
return {
|
|
6
|
+
extends: [
|
|
7
|
+
"stylelint-config-standard-scss",
|
|
8
|
+
"stylelint-config-recommended"
|
|
9
|
+
],
|
|
10
|
+
plugins: ["stylelint-order"],
|
|
11
|
+
rules: {
|
|
12
|
+
"order/order": [
|
|
13
|
+
"dollar-variables",
|
|
14
|
+
"at-variables",
|
|
15
|
+
"custom-properties",
|
|
16
|
+
"less-mixins",
|
|
17
|
+
"declarations",
|
|
18
|
+
"at-rules",
|
|
19
|
+
"rules"
|
|
20
|
+
],
|
|
21
|
+
"order/properties-order": propertyGroups.map((group) => {
|
|
22
|
+
return {
|
|
23
|
+
...group,
|
|
24
|
+
emptyLineBefore: "never",
|
|
25
|
+
noEmptyLineBetween: true
|
|
26
|
+
};
|
|
27
|
+
}),
|
|
28
|
+
"declaration-empty-line-before": "never",
|
|
29
|
+
"declaration-property-value-no-unknown": [
|
|
30
|
+
true,
|
|
31
|
+
{
|
|
32
|
+
ignoreProperties: {}
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"at-rule-no-unknown": [
|
|
36
|
+
true,
|
|
37
|
+
{
|
|
38
|
+
ignoreAtRules: ["extend", "include"]
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"function-no-unknown": [
|
|
42
|
+
true,
|
|
43
|
+
{
|
|
44
|
+
ignoreFunctions: []
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"number-max-precision": null,
|
|
48
|
+
"color-hex-length": "long",
|
|
49
|
+
"color-hex-alpha": "never",
|
|
50
|
+
"color-named": "never",
|
|
51
|
+
"unit-allowed-list": [
|
|
52
|
+
"px",
|
|
53
|
+
"em",
|
|
54
|
+
"rem",
|
|
55
|
+
"%",
|
|
56
|
+
"vw",
|
|
57
|
+
"vh",
|
|
58
|
+
"fr",
|
|
59
|
+
"deg",
|
|
60
|
+
"rad",
|
|
61
|
+
"grad",
|
|
62
|
+
"turn",
|
|
63
|
+
"ms",
|
|
64
|
+
"s"
|
|
65
|
+
],
|
|
66
|
+
"selector-pseudo-class-no-unknown": [
|
|
67
|
+
true,
|
|
68
|
+
{
|
|
69
|
+
ignorePseudoClasses: ["global"]
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"scss/function-no-unknown": [
|
|
73
|
+
true,
|
|
74
|
+
{
|
|
75
|
+
ignoreFunctions: []
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"scss/at-rule-no-unknown": [
|
|
79
|
+
true,
|
|
80
|
+
{
|
|
81
|
+
ignoreAtRules: []
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { defineStylelintConfig };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*! @vef-framework/dev v2.0.0 made with ❤️ by Venus | 2025-11-25T10:06:28.561Z */
|
|
2
|
+
function getChunk(id) {
|
|
3
|
+
if (id.includes("node_modules/@vef-framework/")) {
|
|
4
|
+
return "vef-framework";
|
|
5
|
+
}
|
|
6
|
+
if (id.includes("node_modules/lucide-react")) {
|
|
7
|
+
return "lucide-icons";
|
|
8
|
+
}
|
|
9
|
+
if (id.includes("node_modules/react/") || id.includes("node_modules/react-dom/") || id.includes("node_modules/scheduler/")) {
|
|
10
|
+
return "react";
|
|
11
|
+
}
|
|
12
|
+
if (id.includes("node_modules/@tanstack/")) {
|
|
13
|
+
return "tanstack";
|
|
14
|
+
}
|
|
15
|
+
if (id.includes("node_modules/pinyin-pro/") || id.includes("node_modules/@pinyin-pro/")) {
|
|
16
|
+
return "pinyin-vendor";
|
|
17
|
+
}
|
|
18
|
+
if (id.includes("node_modules/echarts/")) {
|
|
19
|
+
return "echarts";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function createChunksConfig() {
|
|
23
|
+
return getChunk;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { createChunksConfig };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*! @vef-framework/dev v2.0.0 made with ❤️ by Venus | 2025-11-25T10:06:28.561Z */
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import process from 'node:process';
|
|
4
|
+
import consola from 'consola';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
import { defineConfig, loadEnv } from 'vite';
|
|
7
|
+
import { ENV_DIR, ENV_BUILD_PREFIX } from './constants.js';
|
|
8
|
+
import { createAppConfigPlugin } from './plugin-app-config.js';
|
|
9
|
+
import { createAutoEnhancePlugin } from './plugin-auto-enhance/index.js';
|
|
10
|
+
import { createConventionalConfigPlugin } from './plugin-conventional-config.js';
|
|
11
|
+
import { createEslintPlugin } from './plugin-eslint.js';
|
|
12
|
+
import { createHtmlPlugin } from './plugin-html.js';
|
|
13
|
+
import { createIconsPlugin } from './plugin-icons.js';
|
|
14
|
+
import { createInjectionPlugin } from './plugin-injection.js';
|
|
15
|
+
import { createInspectPlugin } from './plugin-inspect.js';
|
|
16
|
+
import { createReactPlugin } from './plugin-react.js';
|
|
17
|
+
import { createRouterPlugin } from './plugin-router.js';
|
|
18
|
+
import { createStylelintPlugin } from './plugin-stylelint.js';
|
|
19
|
+
import { createSvgrPlugin } from './plugin-svgr.js';
|
|
20
|
+
import { createTsconfigPathsPlugin } from './plugin-tsconfig-paths.js';
|
|
21
|
+
import { operationColumnWidthPlugin } from './plugin-auto-enhance/plugins/operation-column-width.js';
|
|
22
|
+
|
|
23
|
+
function defineViteConfig({
|
|
24
|
+
resolve: resolve2,
|
|
25
|
+
plugins = [],
|
|
26
|
+
autoEnhancePlugins = [],
|
|
27
|
+
routerHistory = "browser",
|
|
28
|
+
react,
|
|
29
|
+
proxies
|
|
30
|
+
} = {}) {
|
|
31
|
+
const projectDir = process.cwd();
|
|
32
|
+
return defineConfig(async ({ mode }) => {
|
|
33
|
+
const env = loadEnv(mode, ENV_DIR, ENV_BUILD_PREFIX);
|
|
34
|
+
if (Object.keys(env).length > 0) {
|
|
35
|
+
consola.info("Loaded environment variables:");
|
|
36
|
+
console.table(env);
|
|
37
|
+
}
|
|
38
|
+
const appVersion = await getAppVersion(projectDir);
|
|
39
|
+
return {
|
|
40
|
+
resolve: resolve2,
|
|
41
|
+
plugins: [
|
|
42
|
+
...plugins,
|
|
43
|
+
createInspectPlugin(),
|
|
44
|
+
createConventionalConfigPlugin({
|
|
45
|
+
appName: env.VEF_APP_NAME,
|
|
46
|
+
appVersion,
|
|
47
|
+
projectDir,
|
|
48
|
+
basePublicPath: env.VEF_BUILD_BASE_PUBLIC_PATH,
|
|
49
|
+
outputDir: env.VEF_BUILD_OUTPUT_DIR,
|
|
50
|
+
serverPort: Number(env.VEF_BUILD_SERVER_PORT),
|
|
51
|
+
proxies
|
|
52
|
+
}),
|
|
53
|
+
createAutoEnhancePlugin({
|
|
54
|
+
plugins: [operationColumnWidthPlugin, ...autoEnhancePlugins]
|
|
55
|
+
}),
|
|
56
|
+
createRouterPlugin(projectDir, routerHistory),
|
|
57
|
+
createReactPlugin(react),
|
|
58
|
+
createTsconfigPathsPlugin(projectDir),
|
|
59
|
+
createHtmlPlugin(),
|
|
60
|
+
createInjectionPlugin(),
|
|
61
|
+
createAppConfigPlugin({
|
|
62
|
+
basePublicPath: env.VEF_BUILD_BASE_PUBLIC_PATH,
|
|
63
|
+
outputDir: env.VEF_BUILD_OUTPUT_DIR,
|
|
64
|
+
appName: env.VEF_APP_NAME
|
|
65
|
+
}),
|
|
66
|
+
createIconsPlugin(projectDir),
|
|
67
|
+
createSvgrPlugin(),
|
|
68
|
+
createEslintPlugin(),
|
|
69
|
+
createStylelintPlugin()
|
|
70
|
+
].filter(Boolean)
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async function getAppVersion(projectDir) {
|
|
75
|
+
const packageJson = await fs.readJson(resolve(projectDir, "package.json"), { encoding: "utf-8" });
|
|
76
|
+
return packageJson.version;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { defineViteConfig };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*! @vef-framework/dev v2.0.0 made with ❤️ by Venus | 2025-11-25T10:06:28.561Z */
|
|
2
|
+
const VEF_FRAMEWORK_VERSION = "1.0.0";
|
|
3
|
+
const PUBLIC_DIR = "public";
|
|
4
|
+
const ENV_DIR = "env";
|
|
5
|
+
const ASSETS_DIR = "assets";
|
|
6
|
+
const ENV_APP_PREFIX = "VEF_APP_";
|
|
7
|
+
const ENV_BUILD_PREFIX = "VEF_BUILD_";
|
|
8
|
+
const SRC_DIR = "src";
|
|
9
|
+
const DEFAULT_OUTPUT_DIR = "dist";
|
|
10
|
+
const DEFAULT_SERVER_PORT = 3833;
|
|
11
|
+
const DEFAULT_APP_NAME = "APP";
|
|
12
|
+
const PAGES_DIR = "pages";
|
|
13
|
+
const ROUTER_DIR = "router";
|
|
14
|
+
|
|
15
|
+
export { ASSETS_DIR, DEFAULT_APP_NAME, DEFAULT_OUTPUT_DIR, DEFAULT_SERVER_PORT, ENV_APP_PREFIX, ENV_BUILD_PREFIX, ENV_DIR, PAGES_DIR, PUBLIC_DIR, ROUTER_DIR, SRC_DIR, VEF_FRAMEWORK_VERSION };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*! @vef-framework/dev v2.0.0 made with ❤️ by Venus | 2025-11-25T10:06:28.561Z */
|
|
2
|
+
import { DEFAULT_APP_NAME, VEF_FRAMEWORK_VERSION, ENV_APP_PREFIX } from './constants.js';
|
|
3
|
+
|
|
4
|
+
function defineConstants(appName, appVersion, isDev) {
|
|
5
|
+
return {
|
|
6
|
+
__VEF_FRAMEWORK_VERSION__: `"${VEF_FRAMEWORK_VERSION}"`,
|
|
7
|
+
__VEF_APP_VERSION__: `"${appVersion}"`,
|
|
8
|
+
__VEF_APP_CONFIG__: isDev ? `
|
|
9
|
+
(function () {
|
|
10
|
+
const env = import.meta.env;
|
|
11
|
+
const config = Object.keys(env).filter(key => key.startsWith(${JSON.stringify(ENV_APP_PREFIX)}))
|
|
12
|
+
.reduce((acc, key) => {
|
|
13
|
+
acc[key] = env[key];
|
|
14
|
+
return acc;
|
|
15
|
+
}, {});
|
|
16
|
+
return Object.freeze(config);
|
|
17
|
+
})()
|
|
18
|
+
` : `window.__PRODUCTION__VEF_${appName ?? DEFAULT_APP_NAME}__CONF__`
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { defineConstants };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*! @vef-framework/dev v2.0.0 made with ❤️ by Venus | 2025-11-25T10:06:28.561Z */
|
|
2
|
+
import { snake } from 'radashi';
|
|
3
|
+
import config from 'unplugin-config/vite';
|
|
4
|
+
import { ENV_APP_PREFIX, DEFAULT_OUTPUT_DIR, DEFAULT_APP_NAME } from './constants.js';
|
|
5
|
+
|
|
6
|
+
function createAppConfigPlugin({
|
|
7
|
+
basePublicPath,
|
|
8
|
+
outputDir,
|
|
9
|
+
appName = DEFAULT_APP_NAME
|
|
10
|
+
}) {
|
|
11
|
+
return config({
|
|
12
|
+
appName: `VEF_${constantCase(appName)}`,
|
|
13
|
+
baseDir: basePublicPath,
|
|
14
|
+
configFile: {
|
|
15
|
+
generate: true,
|
|
16
|
+
fileName: "app.config.js",
|
|
17
|
+
outputDir: outputDir ?? DEFAULT_OUTPUT_DIR
|
|
18
|
+
},
|
|
19
|
+
htmlInjection: {
|
|
20
|
+
enable: true,
|
|
21
|
+
position: "head-prepend",
|
|
22
|
+
templates: ["index.html"]
|
|
23
|
+
},
|
|
24
|
+
envVariables: {
|
|
25
|
+
prefix: ENV_APP_PREFIX,
|
|
26
|
+
files: ["env/.env", "env/.env.production"]
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function constantCase(value) {
|
|
31
|
+
return snake(value).toUpperCase();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { createAppConfigPlugin };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/*! @vef-framework/dev v2.0.0 made with ❤️ by Venus | 2025-11-25T10:06:28.561Z */
|
|
2
|
+
import { basename } from 'node:path';
|
|
3
|
+
import { parse as parse$1 } from '@babel/parser';
|
|
4
|
+
import { parse, print } from 'recast';
|
|
5
|
+
|
|
6
|
+
function matchesPattern(patterns, target) {
|
|
7
|
+
const patternArray = Array.isArray(patterns) ? patterns : [patterns];
|
|
8
|
+
return patternArray.some((pattern) => {
|
|
9
|
+
if (typeof pattern === "string") {
|
|
10
|
+
return target.includes(pattern);
|
|
11
|
+
}
|
|
12
|
+
return pattern.test(target);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
class AutoEnhanceCore {
|
|
16
|
+
plugins = [];
|
|
17
|
+
options;
|
|
18
|
+
constructor(options = {}) {
|
|
19
|
+
this.options = {
|
|
20
|
+
include: [/\.tsx?(?:\?.*)?$/],
|
|
21
|
+
exclude: [/node_modules/, /\.d\.ts?(?:\?.*)?$/],
|
|
22
|
+
logPrefix: "🚀 VEF Auto-Enhance",
|
|
23
|
+
...options
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Register a sub-plugin
|
|
28
|
+
*/
|
|
29
|
+
registerPlugin(plugin) {
|
|
30
|
+
this.plugins.push(plugin);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Register multiple sub-plugins
|
|
34
|
+
*/
|
|
35
|
+
registerPlugins(plugins) {
|
|
36
|
+
for (const plugin of plugins) {
|
|
37
|
+
this.registerPlugin(plugin);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check if file should be processed
|
|
42
|
+
*/
|
|
43
|
+
shouldProcessFile(id) {
|
|
44
|
+
const { include, exclude } = this.options;
|
|
45
|
+
if (exclude && matchesPattern(exclude, id)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (include && !matchesPattern(include, id)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Create processing context
|
|
55
|
+
*/
|
|
56
|
+
createTransformationContext(id, code) {
|
|
57
|
+
const fileName = id.split("/").slice(-3).join("/");
|
|
58
|
+
const ast = parse(code, {
|
|
59
|
+
sourceFileName: basename(id),
|
|
60
|
+
parser: {
|
|
61
|
+
parse: (code2) => parse$1(code2, {
|
|
62
|
+
plugins: ["jsx", "typescript", "explicitResourceManagement"],
|
|
63
|
+
sourceType: "module",
|
|
64
|
+
tokens: true
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
id,
|
|
70
|
+
fileName,
|
|
71
|
+
code,
|
|
72
|
+
ast
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Execute transformation
|
|
77
|
+
*/
|
|
78
|
+
transform(code, id) {
|
|
79
|
+
if (!this.shouldProcessFile(id)) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
if (this.plugins.length === 0) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const context = this.createTransformationContext(id, code);
|
|
87
|
+
const activePlugins = this.plugins.filter((plugin) => {
|
|
88
|
+
if (plugin.shouldProcess) {
|
|
89
|
+
return plugin.shouldProcess(context);
|
|
90
|
+
}
|
|
91
|
+
return true;
|
|
92
|
+
});
|
|
93
|
+
if (activePlugins.length === 0) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
let hasAnyChanges = false;
|
|
97
|
+
const allLogs = [];
|
|
98
|
+
for (const plugin of activePlugins) {
|
|
99
|
+
try {
|
|
100
|
+
const result = plugin.transform(context);
|
|
101
|
+
if (result.hasChanges) {
|
|
102
|
+
hasAnyChanges = true;
|
|
103
|
+
}
|
|
104
|
+
if (result.logs) {
|
|
105
|
+
allLogs.push(...result.logs);
|
|
106
|
+
}
|
|
107
|
+
if (result.hasChanges) {
|
|
108
|
+
console.log(`${this.options.logPrefix}: Plugin "${plugin.name}" made changes to ${context.fileName}`);
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.warn(`${this.options.logPrefix}: Plugin "${plugin.name}" failed:`, error);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
for (const log of allLogs) {
|
|
115
|
+
console.log(log);
|
|
116
|
+
}
|
|
117
|
+
if (hasAnyChanges) {
|
|
118
|
+
const result = print(context.ast);
|
|
119
|
+
return {
|
|
120
|
+
code: result.code,
|
|
121
|
+
map: result.map || null
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
console.warn(`${this.options.logPrefix}: Error processing ${id}:`, error);
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Get registered plugin information
|
|
132
|
+
*/
|
|
133
|
+
getRegisteredPlugins() {
|
|
134
|
+
return this.plugins.map((plugin) => {
|
|
135
|
+
return {
|
|
136
|
+
name: plugin.name,
|
|
137
|
+
description: plugin.description
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { AutoEnhanceCore };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*! @vef-framework/dev v2.0.0 made with ❤️ by Venus | 2025-11-25T10:06:28.561Z */
|
|
2
|
+
import { AutoEnhanceCore } from './core.js';
|
|
3
|
+
import './plugins/index.js';
|
|
4
|
+
export { types } from 'recast';
|
|
5
|
+
|
|
6
|
+
function createAutoEnhancePlugin({
|
|
7
|
+
plugins,
|
|
8
|
+
...options
|
|
9
|
+
} = {}) {
|
|
10
|
+
const core = new AutoEnhanceCore(options);
|
|
11
|
+
if (plugins) {
|
|
12
|
+
core.registerPlugins(plugins);
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
name: "vef-framework:auto-enhance",
|
|
16
|
+
enforce: "pre",
|
|
17
|
+
buildStart() {
|
|
18
|
+
const plugins2 = core.getRegisteredPlugins();
|
|
19
|
+
if (plugins2.length > 0) {
|
|
20
|
+
console.log(`🚀 Auto-Enhance: Loaded ${plugins2.length} plugins:`);
|
|
21
|
+
for (const plugin of plugins2) {
|
|
22
|
+
console.log(` • ${plugin.name}${plugin.description ? ` - ${plugin.description}` : ""}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
transform(code, id) {
|
|
27
|
+
return core.transform(code, id);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { createAutoEnhancePlugin };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/*! @vef-framework/dev v2.0.0 made with ❤️ by Venus | 2025-11-25T10:06:28.561Z */
|
|
2
|
+
import { visit, types } from 'recast';
|
|
3
|
+
|
|
4
|
+
const CJK_CHAR_REGEX = /[\u4E00-\u9FFF\u3400-\u4DBF\uFF00-\uFFEF]/;
|
|
5
|
+
const OPERATION_COLUMN_ATTR = "operationColumn";
|
|
6
|
+
const OPERATION_BUTTON_COMPONENT = "OperationButton";
|
|
7
|
+
const VALID_IMPORT_SOURCES = [
|
|
8
|
+
"@vef-framework/components",
|
|
9
|
+
"@vef-framework/starter"
|
|
10
|
+
];
|
|
11
|
+
function isValidImportSource(source) {
|
|
12
|
+
return VALID_IMPORT_SOURCES.some((pkg) => source === pkg || source.startsWith(`${pkg}/`));
|
|
13
|
+
}
|
|
14
|
+
function collectOperationButtonAliases(ast) {
|
|
15
|
+
const aliasMap = /* @__PURE__ */ new Map();
|
|
16
|
+
visit(ast, {
|
|
17
|
+
visitImportDeclaration(path) {
|
|
18
|
+
const source = path.node.source.value;
|
|
19
|
+
if (typeof source !== "string" || !isValidImportSource(source)) {
|
|
20
|
+
this.traverse(path);
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
for (const specifier of path.node.specifiers || []) {
|
|
24
|
+
if (types.namedTypes.ImportSpecifier.check(specifier)) {
|
|
25
|
+
const { imported } = specifier;
|
|
26
|
+
const { local } = specifier;
|
|
27
|
+
if (types.namedTypes.Identifier.check(imported) && types.namedTypes.Identifier.check(local) && imported.name === OPERATION_BUTTON_COMPONENT) {
|
|
28
|
+
aliasMap.set(local.name, imported.name);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
this.traverse(path);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return aliasMap;
|
|
37
|
+
}
|
|
38
|
+
function calculateTextWidth(text) {
|
|
39
|
+
let width = 0;
|
|
40
|
+
for (const char of text) {
|
|
41
|
+
width += CJK_CHAR_REGEX.test(char) ? 14 : 8;
|
|
42
|
+
}
|
|
43
|
+
return width;
|
|
44
|
+
}
|
|
45
|
+
function calculateOperationColumnWidth(buttons) {
|
|
46
|
+
if (buttons.length === 0) {
|
|
47
|
+
return {
|
|
48
|
+
calculatedWidth: 64,
|
|
49
|
+
buttonCount: 0,
|
|
50
|
+
analysis: "No buttons found, using minimum width"
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
let totalWidth = 0;
|
|
54
|
+
const buttonCount = buttons.length;
|
|
55
|
+
for (const [index, button] of buttons.entries()) {
|
|
56
|
+
let buttonWidth = 16;
|
|
57
|
+
if (button.hasIcon) {
|
|
58
|
+
buttonWidth += 16;
|
|
59
|
+
if (button.textContent) {
|
|
60
|
+
buttonWidth += 8;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (button.textContent) {
|
|
64
|
+
buttonWidth += calculateTextWidth(button.textContent);
|
|
65
|
+
}
|
|
66
|
+
buttonWidth = Math.max(buttonWidth, button.hasIcon && !button.textContent ? 32 : 64);
|
|
67
|
+
totalWidth += buttonWidth;
|
|
68
|
+
if (index < buttonCount - 1) {
|
|
69
|
+
totalWidth += 8;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
totalWidth += 16;
|
|
73
|
+
const finalWidth = Math.ceil(totalWidth / 8) * 8;
|
|
74
|
+
const analysis = `${buttonCount} buttons, calculated: ${totalWidth}px, final: ${finalWidth}px`;
|
|
75
|
+
return {
|
|
76
|
+
calculatedWidth: finalWidth,
|
|
77
|
+
buttonCount,
|
|
78
|
+
analysis
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function extractButtonInfo(jsxElement, aliasMap) {
|
|
82
|
+
const { openingElement } = jsxElement;
|
|
83
|
+
if (!types.namedTypes.JSXIdentifier.check(openingElement.name)) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const componentName = openingElement.name.name;
|
|
87
|
+
if (!aliasMap.has(componentName)) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const buttonInfo = {
|
|
91
|
+
hasIcon: false,
|
|
92
|
+
textContent: ""
|
|
93
|
+
};
|
|
94
|
+
for (const attr of openingElement.attributes || []) {
|
|
95
|
+
if (types.namedTypes.JSXAttribute.check(attr) && types.namedTypes.JSXIdentifier.check(attr.name) && attr.name.name === "icon") {
|
|
96
|
+
buttonInfo.hasIcon = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const child of jsxElement.children || []) {
|
|
100
|
+
if (types.namedTypes.JSXText.check(child)) {
|
|
101
|
+
buttonInfo.textContent += child.value.trim();
|
|
102
|
+
} else if (types.namedTypes.JSXExpressionContainer.check(child) && types.namedTypes.StringLiteral.check(child.expression)) {
|
|
103
|
+
buttonInfo.textContent += child.expression.value;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return buttonInfo;
|
|
107
|
+
}
|
|
108
|
+
function findOperationButtons(node, aliasMap) {
|
|
109
|
+
const buttons = [];
|
|
110
|
+
visit(node, {
|
|
111
|
+
visitJSXElement(path) {
|
|
112
|
+
const buttonInfo = extractButtonInfo(path.node, aliasMap);
|
|
113
|
+
if (buttonInfo) {
|
|
114
|
+
buttons.push(buttonInfo);
|
|
115
|
+
}
|
|
116
|
+
this.traverse(path);
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return buttons;
|
|
121
|
+
}
|
|
122
|
+
function hasWidthProperty(objectExpression) {
|
|
123
|
+
return objectExpression.properties.some((prop) => {
|
|
124
|
+
if (types.namedTypes.ObjectProperty.check(prop)) {
|
|
125
|
+
const { key } = prop;
|
|
126
|
+
return types.namedTypes.Identifier.check(key) && key.name === "width" || types.namedTypes.StringLiteral.check(key) && key.value === "width";
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function getRenderProperty(objectExpression) {
|
|
132
|
+
return objectExpression.properties.find((prop) => {
|
|
133
|
+
if (types.namedTypes.ObjectProperty.check(prop) || types.namedTypes.ObjectMethod.check(prop)) {
|
|
134
|
+
const { key } = prop;
|
|
135
|
+
return types.namedTypes.Identifier.check(key) && key.name === "render" || types.namedTypes.StringLiteral.check(key) && key.value === "render";
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function getComponentName(jsxElement) {
|
|
141
|
+
const { openingElement } = jsxElement;
|
|
142
|
+
if (types.namedTypes.JSXIdentifier.check(openingElement.name)) {
|
|
143
|
+
return openingElement.name.name;
|
|
144
|
+
}
|
|
145
|
+
if (types.namedTypes.JSXMemberExpression.check(openingElement.name)) {
|
|
146
|
+
const { object, property } = openingElement.name;
|
|
147
|
+
const objectName = types.namedTypes.JSXIdentifier.check(object) ? object.name : "?";
|
|
148
|
+
const propertyName = types.namedTypes.JSXIdentifier.check(property) ? property.name : "?";
|
|
149
|
+
return `${objectName}.${propertyName}`;
|
|
150
|
+
}
|
|
151
|
+
return "Unknown";
|
|
152
|
+
}
|
|
153
|
+
const operationColumnWidthPlugin = {
|
|
154
|
+
name: "operation-column-width",
|
|
155
|
+
description: "Automatically calculate optimal width for operation columns based on button analysis",
|
|
156
|
+
shouldProcess(context) {
|
|
157
|
+
return context.code.includes(OPERATION_COLUMN_ATTR);
|
|
158
|
+
},
|
|
159
|
+
transform(context) {
|
|
160
|
+
const aliasMap = collectOperationButtonAliases(context.ast);
|
|
161
|
+
if (aliasMap.size === 0) {
|
|
162
|
+
return { hasChanges: false, logs: [] };
|
|
163
|
+
}
|
|
164
|
+
let hasChanges = false;
|
|
165
|
+
const logs = [];
|
|
166
|
+
visit(context.ast, {
|
|
167
|
+
visitJSXAttribute(path) {
|
|
168
|
+
const attr = path.node;
|
|
169
|
+
if (!types.namedTypes.JSXIdentifier.check(attr.name) || attr.name.name !== OPERATION_COLUMN_ATTR) {
|
|
170
|
+
this.traverse(path);
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
if (!types.namedTypes.JSXExpressionContainer.check(attr.value) || !types.namedTypes.ObjectExpression.check(attr.value.expression)) {
|
|
174
|
+
this.traverse(path);
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
const objectExpression = attr.value.expression;
|
|
178
|
+
if (hasWidthProperty(objectExpression)) {
|
|
179
|
+
this.traverse(path);
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
const renderProperty = getRenderProperty(objectExpression);
|
|
183
|
+
if (!renderProperty) {
|
|
184
|
+
this.traverse(path);
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
const buttons = types.namedTypes.ObjectProperty.check(renderProperty) ? findOperationButtons(renderProperty.value, aliasMap) : findOperationButtons(renderProperty.body, aliasMap);
|
|
188
|
+
if (buttons.length === 0) {
|
|
189
|
+
this.traverse(path);
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
const { calculatedWidth, analysis } = calculateOperationColumnWidth(buttons);
|
|
193
|
+
const widthProperty = types.builders.objectProperty(
|
|
194
|
+
types.builders.identifier("width"),
|
|
195
|
+
types.builders.numericLiteral(calculatedWidth)
|
|
196
|
+
);
|
|
197
|
+
widthProperty.comments = [types.builders.commentLine(` Auto-calculated: ${analysis} `, true, false)];
|
|
198
|
+
objectExpression.properties.unshift(widthProperty);
|
|
199
|
+
hasChanges = true;
|
|
200
|
+
let componentName = "Unknown";
|
|
201
|
+
let { parentPath } = path;
|
|
202
|
+
while (parentPath) {
|
|
203
|
+
const { node, parentPath: nextParentPath } = parentPath;
|
|
204
|
+
if (types.namedTypes.JSXElement.check(node)) {
|
|
205
|
+
componentName = getComponentName(node);
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
parentPath = nextParentPath;
|
|
209
|
+
}
|
|
210
|
+
logs.push(
|
|
211
|
+
`📊 ${componentName}: ${context.fileName}`,
|
|
212
|
+
` └─ 🎯 Operation column auto-width: ${calculatedWidth}px (${analysis})`
|
|
213
|
+
);
|
|
214
|
+
this.traverse(path);
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
return {
|
|
219
|
+
hasChanges,
|
|
220
|
+
logs
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export { operationColumnWidthPlugin };
|