jinbi-utils 1.0.21 → 1.0.23

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 (73) hide show
  1. package/dist/chunk-optimizer.cjs +703 -0
  2. package/dist/index.esm.js +3085 -0
  3. package/dist/index.esm.min.js +15 -0
  4. package/dist/index.umd.js +3198 -0
  5. package/dist/index.umd.min.js +16 -0
  6. package/package.json +36 -3
  7. package/.babelrc +0 -19
  8. package/.cz-config.js +0 -55
  9. package/.dockerignore +0 -3
  10. package/.editorconfig +0 -12
  11. package/.eslintignore +0 -8
  12. package/.eslintrc.js +0 -54
  13. package/.versionrc.json +0 -9
  14. package/CHUNK_OPTIMIZER_USAGE.md +0 -132
  15. package/Dockerfile +0 -3
  16. package/QUICK_RELEASE.md +0 -85
  17. package/RELEASE_GUIDE.md +0 -243
  18. package/api-extractor.json +0 -15
  19. package/commitlint.config.js +0 -3
  20. package/jest.config.js +0 -15
  21. package/rollup.config.chunk-optimizer.js +0 -32
  22. package/rollup.config.js +0 -73
  23. package/src/array/index.ts +0 -85
  24. package/src/build/chunk-optimizer/ARCHITECTURE.md +0 -347
  25. package/src/build/chunk-optimizer/QUICK_START.md +0 -370
  26. package/src/build/chunk-optimizer/README.md +0 -240
  27. package/src/build/chunk-optimizer/core/chunk-generator.ts +0 -166
  28. package/src/build/chunk-optimizer/core/classifier.ts +0 -148
  29. package/src/build/chunk-optimizer/core/dependency-reader.ts +0 -138
  30. package/src/build/chunk-optimizer/examples/basic-usage.ts +0 -234
  31. package/src/build/chunk-optimizer/index.ts +0 -166
  32. package/src/build/chunk-optimizer/rules/common-rules.ts +0 -131
  33. package/src/build/chunk-optimizer/rules/framework-rules.ts +0 -93
  34. package/src/build/chunk-optimizer/rules/index.ts +0 -27
  35. package/src/build/chunk-optimizer/test.ts +0 -94
  36. package/src/build/chunk-optimizer/types.ts +0 -128
  37. package/src/color/index.ts +0 -58
  38. package/src/common/index.ts +0 -353
  39. package/src/constant/common.constant.ts +0 -13
  40. package/src/date/index.ts +0 -143
  41. package/src/dom/index.ts +0 -198
  42. package/src/file/index.ts +0 -319
  43. package/src/http/apiBuilder/README.md +0 -648
  44. package/src/http/apiBuilder/api-builder.ts +0 -502
  45. package/src/http/apiBuilder/example.ts +0 -243
  46. package/src/http/apiBuilder/index.ts +0 -1
  47. package/src/http/apiBuilder//345/277/253/351/200/237/345/217/202/350/200/203.md +0 -199
  48. package/src/http/http.ts +0 -79
  49. package/src/http/httpEnums.ts +0 -61
  50. package/src/iam/index.ts +0 -46
  51. package/src/index.ts +0 -20
  52. package/src/middleware/requestLogger.middware.ts +0 -371
  53. package/src/middleware/requestLoggerUnified.ts +0 -371
  54. package/src/number/index.ts +0 -362
  55. package/src/object/index.ts +0 -54
  56. package/src/print/index.ts +0 -102
  57. package/src/string/index.ts +0 -189
  58. package/src/utils/curl.ts +0 -108
  59. package/src/validate/index.ts +0 -100
  60. package/src/websocket/emitter.ts +0 -39
  61. package/src/websocket/index.ts +0 -6
  62. package/src/websocket/manager.ts +0 -151
  63. package/src/websocket/pinia-store.ts +0 -91
  64. package/src/websocket/service.ts +0 -34
  65. package/src/websocket/types.ts +0 -45
  66. package/test/common/index.test.ts +0 -19
  67. package/test/date/index.test.ts +0 -107
  68. package/test/file/index.test.ts +0 -104
  69. package/test/number/index.test.ts +0 -108
  70. package/test/object/index.test.ts +0 -20
  71. package/test/string/index.test.ts +0 -82
  72. package/tsconfig.json +0 -39
  73. package/typedoc.json +0 -12
@@ -1,234 +0,0 @@
1
- /**
2
- * Chunk Optimizer 使用示例
3
- */
4
-
5
- import { createChunkOptimizer } from '../index';
6
-
7
- // ============================================================
8
- // 示例 1: 零配置使用(推荐)
9
- // ============================================================
10
- export function example1() {
11
- const optimizer = createChunkOptimizer();
12
-
13
- return {
14
- build: {
15
- rollupOptions: {
16
- output: {
17
- manualChunks: optimizer.generate()
18
- }
19
- }
20
- }
21
- };
22
- }
23
-
24
- // ============================================================
25
- // 示例 2: 启用调试模式
26
- // ============================================================
27
- export function example2() {
28
- const optimizer = createChunkOptimizer({
29
- debug: true, // 会在构建时打印详细的分包信息
30
- });
31
-
32
- // 手动打印分析报告
33
- optimizer.printReport();
34
-
35
- return {
36
- build: {
37
- rollupOptions: {
38
- output: {
39
- manualChunks: optimizer.generate()
40
- }
41
- }
42
- }
43
- };
44
- }
45
-
46
- // ============================================================
47
- // 示例 3: 自定义规则
48
- // ============================================================
49
- export function example3() {
50
- const optimizer = createChunkOptimizer({
51
- framework: 'vue',
52
- customRules: {
53
- // 将公司内部库单独分包
54
- '@company/ui': 'vendor-company-ui',
55
- '@company/utils': 'vendor-company-utils',
56
-
57
- // 将某个大型库单独分包
58
- 'echarts': 'vendor-echarts',
59
-
60
- // 使用通配符匹配
61
- '@company/*': 'vendor-company',
62
- },
63
- });
64
-
65
- return {
66
- build: {
67
- rollupOptions: {
68
- output: {
69
- manualChunks: optimizer.generate()
70
- }
71
- }
72
- }
73
- };
74
- }
75
-
76
- // ============================================================
77
- // 示例 4: 排除某些包
78
- // ============================================================
79
- export function example4() {
80
- const optimizer = createChunkOptimizer({
81
- exclude: [
82
- '@types/*', // 排除所有类型定义
83
- 'vite', // 排除 vite
84
- 'rollup', // 排除 rollup
85
- 'esbuild', // 排除 esbuild
86
- ],
87
- });
88
-
89
- return {
90
- build: {
91
- rollupOptions: {
92
- output: {
93
- manualChunks: optimizer.generate()
94
- }
95
- }
96
- }
97
- };
98
- }
99
-
100
- // ============================================================
101
- // 示例 5: 自定义业务代码分包
102
- // ============================================================
103
- export function example5() {
104
- const optimizer = createChunkOptimizer({
105
- sourceCodeStrategy: {
106
- views: true, // 按 views 模块分包
107
- components: true, // 公共组件单独分包
108
- utils: true, // 工具函数分包
109
- store: true, // store 分包
110
- custom: [
111
- // 自定义业务代码分包规则
112
- {
113
- pattern: /\/src\/features\/([^/]+)\//,
114
- chunkName: 'feature-$1'
115
- },
116
- {
117
- pattern: /\/src\/modules\/([^/]+)\//,
118
- chunkName: 'module-$1'
119
- }
120
- ]
121
- }
122
- });
123
-
124
- return {
125
- build: {
126
- rollupOptions: {
127
- output: {
128
- manualChunks: optimizer.generate()
129
- }
130
- }
131
- }
132
- };
133
- }
134
-
135
- // ============================================================
136
- // 示例 6: React 项目使用
137
- // ============================================================
138
- export function example6React() {
139
- const optimizer = createChunkOptimizer({
140
- framework: 'react', // 指定框架为 React
141
- customRules: {
142
- // React 项目特定的规则
143
- 'react-query': 'vendor-query',
144
- '@tanstack/react-query': 'vendor-query',
145
- },
146
- });
147
-
148
- return {
149
- build: {
150
- rollupOptions: {
151
- output: {
152
- manualChunks: optimizer.generate()
153
- }
154
- }
155
- }
156
- };
157
- }
158
-
159
- // ============================================================
160
- // 示例 7: 完整配置示例
161
- // ============================================================
162
- export function example7Complete() {
163
- const optimizer = createChunkOptimizer({
164
- // 框架类型
165
- framework: 'vue',
166
-
167
- // 启用调试
168
- debug: process.env.NODE_ENV === 'development',
169
-
170
- // 自定义规则
171
- customRules: {
172
- '@company/*': 'vendor-company',
173
- 'echarts': 'vendor-echarts',
174
- },
175
-
176
- // 排除包
177
- exclude: ['@types/*', 'vite'],
178
-
179
- // 业务代码分包
180
- sourceCodeStrategy: {
181
- views: true,
182
- components: true,
183
- utils: true,
184
- store: true,
185
- custom: [
186
- {
187
- pattern: /\/src\/features\/([^/]+)\//,
188
- chunkName: 'feature-$1'
189
- }
190
- ]
191
- }
192
- });
193
-
194
- return {
195
- build: {
196
- rollupOptions: {
197
- output: {
198
- chunkFileNames: 'static/js/[name]-[hash].js',
199
- entryFileNames: 'static/js/[name]-[hash].js',
200
- assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
201
- manualChunks: optimizer.generate()
202
- }
203
- }
204
- }
205
- };
206
- }
207
-
208
- // ============================================================
209
- // 示例 8: 获取分析结果
210
- // ============================================================
211
- export function example8Analysis() {
212
- const optimizer = createChunkOptimizer();
213
-
214
- // 获取分析结果
215
- const result = optimizer.analyze();
216
-
217
- console.log('检测到的框架:', result.detectedFramework);
218
- console.log('依赖总数:', result.dependencies.length);
219
- console.log('分类统计:', result.categoryStats);
220
-
221
- // 打印详细报告
222
- optimizer.printReport();
223
-
224
- return {
225
- build: {
226
- rollupOptions: {
227
- output: {
228
- manualChunks: optimizer.generate()
229
- }
230
- }
231
- }
232
- };
233
- }
234
-
@@ -1,166 +0,0 @@
1
- /**
2
- * Vite Chunk Optimizer
3
- * 智能分包优化工具 - 自动分析依赖并生成最优的 manualChunks 配置
4
- *
5
- * @author Your Name
6
- * @license MIT
7
- */
8
-
9
- import type {
10
- ChunkOptimizerOptions,
11
- ManualChunksFunction,
12
- AnalysisResult,
13
- } from './types';
14
- import { DependencyReader } from './core/dependency-reader';
15
- import { DependencyClassifier } from './core/classifier';
16
- import { ChunkGenerator } from './core/chunk-generator';
17
-
18
- /**
19
- * Chunk 优化器类
20
- */
21
- export class ChunkOptimizer {
22
- private reader: DependencyReader;
23
- private classifier: DependencyClassifier;
24
- private generator: ChunkGenerator | null = null;
25
- private options: Required<ChunkOptimizerOptions>;
26
-
27
- constructor(options: ChunkOptimizerOptions = {}) {
28
- // 设置默认选项
29
- this.options = {
30
- framework: options.framework || 'auto',
31
- strategy: options.strategy || 'balanced',
32
- customRules: options.customRules || {},
33
- exclude: options.exclude || ['@types/*'],
34
- minChunkSize: options.minChunkSize || 0,
35
- debug: options.debug || false,
36
- sourceCodeStrategy: {
37
- views: true,
38
- components: true,
39
- utils: true,
40
- store: true,
41
- ...options.sourceCodeStrategy,
42
- },
43
- packageJsonPath: options.packageJsonPath || '',
44
- };
45
-
46
- // 初始化依赖读取器
47
- this.reader = new DependencyReader(this.options.packageJsonPath);
48
-
49
- // 自动检测框架
50
- if (this.options.framework === 'auto') {
51
- this.options.framework = this.reader.detectFramework();
52
- if (this.options.debug) {
53
- console.log(`🔍 Detected framework: ${this.options.framework}`);
54
- }
55
- }
56
-
57
- // 初始化分类器
58
- this.classifier = new DependencyClassifier(
59
- this.options.framework,
60
- this.options.customRules,
61
- this.options.exclude
62
- );
63
- }
64
-
65
- /**
66
- * 分析依赖
67
- */
68
- analyze(): AnalysisResult {
69
- const dependencies = this.reader.getDependencies();
70
- const classified = this.classifier.classifyAll(dependencies);
71
- const stats = this.classifier.getCategoryStats(classified);
72
-
73
- return {
74
- dependencies: classified,
75
- detectedFramework: this.options.framework,
76
- categoryStats: stats,
77
- };
78
- }
79
-
80
- /**
81
- * 生成 manualChunks 函数
82
- */
83
- generate(): ManualChunksFunction {
84
- if (this.generator) {
85
- return this.generator.generate();
86
- }
87
-
88
- // 分析依赖
89
- const result = this.analyze();
90
-
91
- // 如果开启调试模式,打印分类信息
92
- if (this.options.debug) {
93
- this.classifier.printClassification(result.dependencies);
94
- }
95
-
96
- // 创建生成器
97
- this.generator = new ChunkGenerator(
98
- result.dependencies,
99
- this.options.sourceCodeStrategy,
100
- this.options.debug
101
- );
102
-
103
- // 如果开启调试模式,打印统计信息
104
- if (this.options.debug) {
105
- this.generator.printStats();
106
- }
107
-
108
- return this.generator.generate();
109
- }
110
-
111
- /**
112
- * 获取分析结果
113
- */
114
- getAnalysisResult(): AnalysisResult {
115
- return this.analyze();
116
- }
117
-
118
- /**
119
- * 打印分析报告
120
- */
121
- printReport(): void {
122
- const result = this.analyze();
123
-
124
- console.log('\n' + '='.repeat(60));
125
- console.log('📦 Vite Chunk Optimizer - Analysis Report');
126
- console.log('='.repeat(60) + '\n');
127
-
128
- console.log(`Framework: ${result.detectedFramework}`);
129
- console.log(`Strategy: ${this.options.strategy}`);
130
- console.log(`Total Dependencies: ${result.dependencies.length}\n`);
131
-
132
- console.log('Chunk Distribution:');
133
- Object.entries(result.categoryStats)
134
- .sort(([, a], [, b]) => b - a)
135
- .forEach(([category, count]) => {
136
- const percentage = ((count / result.dependencies.length) * 100).toFixed(1);
137
- console.log(` ${category.padEnd(25)} ${count.toString().padStart(3)} (${percentage}%)`);
138
- });
139
-
140
- console.log('\n' + '='.repeat(60) + '\n');
141
- }
142
- }
143
-
144
- /**
145
- * 创建 Chunk 优化器(工厂函数)
146
- */
147
- export function createChunkOptimizer(
148
- options: ChunkOptimizerOptions = {}
149
- ): ChunkOptimizer {
150
- return new ChunkOptimizer(options);
151
- }
152
-
153
- // 导出类型
154
- export type {
155
- ChunkOptimizerOptions,
156
- ManualChunksFunction,
157
- AnalysisResult,
158
- Framework,
159
- Strategy,
160
- DependencyCategory,
161
- SourceCodeStrategy,
162
- } from './types';
163
-
164
- // 默认导出
165
- export default createChunkOptimizer;
166
-
@@ -1,131 +0,0 @@
1
- /**
2
- * 通用库的分包规则
3
- */
4
- import type { Rule } from '../types';
5
-
6
- /**
7
- * 工具库规则
8
- */
9
- export const utilsRules: Rule[] = [
10
- // 日期时间
11
- { match: 'dayjs', category: 'vendor-utils', priority: 60, description: '日期时间库' },
12
- { match: 'moment', category: 'vendor-utils', priority: 60, description: 'Moment.js' },
13
- { match: 'date-fns', category: 'vendor-utils', priority: 60, description: 'date-fns' },
14
-
15
- // HTTP 请求
16
- { match: 'axios', category: 'vendor-utils', priority: 70, description: 'Axios HTTP 客户端' },
17
- { match: 'ky', category: 'vendor-utils', priority: 70, description: 'Ky HTTP 客户端' },
18
-
19
- // 工具函数
20
- { match: 'lodash', category: 'vendor-utils', priority: 60, description: 'Lodash' },
21
- { match: 'lodash-es', category: 'vendor-utils', priority: 60, description: 'Lodash ES' },
22
- { match: 'ramda', category: 'vendor-utils', priority: 60, description: 'Ramda' },
23
-
24
- // Cookie & Storage
25
- { match: 'js-cookie', category: 'vendor-utils', priority: 50, description: 'JS Cookie' },
26
- { match: 'localforage', category: 'vendor-utils', priority: 50, description: 'LocalForage' },
27
- { match: 'responsive-storage', category: 'vendor-utils', priority: 50, description: 'Responsive Storage' },
28
-
29
- // 查询字符串
30
- { match: 'qs', category: 'vendor-utils', priority: 50, description: 'Query String' },
31
-
32
- // 事件总线
33
- { match: 'mitt', category: 'vendor-utils', priority: 50, description: 'Mitt 事件总线' },
34
- { match: 'eventemitter3', category: 'vendor-utils', priority: 50, description: 'EventEmitter3' },
35
-
36
- // 数学计算
37
- { match: 'decimal.js', category: 'vendor-utils', priority: 50, description: 'Decimal.js' },
38
- { match: 'big.js', category: 'vendor-utils', priority: 50, description: 'Big.js' },
39
-
40
- // 拖拽
41
- { match: 'sortablejs', category: 'vendor-utils', priority: 50, description: 'SortableJS' },
42
-
43
- // 动画
44
- { match: 'animate.css', category: 'vendor-utils', priority: 40, description: 'Animate.css' },
45
- { match: '@vueuse/motion', category: 'vendor-utils', priority: 40, description: 'VueUse Motion' },
46
-
47
- // 其他工具
48
- { match: 'nprogress', category: 'vendor-utils', priority: 40, description: 'NProgress' },
49
- { match: 'path-browserify', category: 'vendor-utils', priority: 40, description: 'Path Browserify' },
50
- ];
51
-
52
- /**
53
- * 图标库规则
54
- */
55
- export const iconRules: Rule[] = [
56
- { match: /^@iconify\//, category: 'vendor-icons', priority: 60, description: 'Iconify' },
57
- { match: 'unplugin-icons', category: 'vendor-icons', priority: 60, description: 'Unplugin Icons' },
58
- { match: /-icons?$/, category: 'vendor-icons', priority: 50, description: '图标库(通用匹配)' },
59
- ];
60
-
61
- /**
62
- * 表单和验证规则
63
- */
64
- export const formRules: Rule[] = [
65
- { match: 'vee-validate', category: 'vendor-utils', priority: 50, description: 'VeeValidate' },
66
- { match: 'yup', category: 'vendor-utils', priority: 50, description: 'Yup 验证' },
67
- { match: 'zod', category: 'vendor-utils', priority: 50, description: 'Zod 验证' },
68
- { match: '@zxcvbn-ts/core', category: 'vendor-utils', priority: 40, description: 'Zxcvbn 密码强度' },
69
- ];
70
-
71
- /**
72
- * 图表库规则
73
- */
74
- export const chartRules: Rule[] = [
75
- { match: 'echarts', category: 'vendor-charts', priority: 70, description: 'ECharts' },
76
- { match: 'chart.js', category: 'vendor-charts', priority: 70, description: 'Chart.js' },
77
- { match: 'd3', category: 'vendor-charts', priority: 70, description: 'D3.js' },
78
- { match: /^@antv\//, category: 'vendor-charts', priority: 70, description: 'AntV 图表' },
79
- ];
80
-
81
- /**
82
- * 富文本编辑器规则
83
- */
84
- export const editorRules: Rule[] = [
85
- { match: 'quill', category: 'vendor-editor', priority: 60, description: 'Quill 编辑器' },
86
- { match: '@wangeditor/editor', category: 'vendor-editor', priority: 60, description: 'wangEditor' },
87
- { match: 'tinymce', category: 'vendor-editor', priority: 60, description: 'TinyMCE' },
88
- { match: '@tiptap/vue-3', category: 'vendor-editor', priority: 60, description: 'Tiptap' },
89
- ];
90
-
91
- /**
92
- * 表格库规则
93
- */
94
- export const tableRules: Rule[] = [
95
- { match: 'vxe-table', category: 'vendor-table', priority: 70, description: 'VXE Table' },
96
- { match: 'ag-grid', category: 'vendor-table', priority: 70, description: 'AG Grid' },
97
- ];
98
-
99
- /**
100
- * 中国特色库规则
101
- */
102
- export const chinaRules: Rule[] = [
103
- { match: 'china-area-data', category: 'vendor-utils', priority: 40, description: '中国地区数据' },
104
- { match: 'pinyin-pro', category: 'vendor-utils', priority: 40, description: '拼音转换' },
105
- ];
106
-
107
- /**
108
- * 业务组件库规则
109
- */
110
- export const businessRules: Rule[] = [
111
- { match: 'plus-pro-components', category: 'vendor-pro', priority: 70, description: 'Plus Pro Components' },
112
- { match: 'vue-tippy', category: 'vendor-utils', priority: 40, description: 'Vue Tippy' },
113
- { match: 'vue-types', category: 'vendor-utils', priority: 40, description: 'Vue Types' },
114
- ];
115
-
116
- /**
117
- * 获取所有通用规则
118
- */
119
- export function getCommonRules(): Rule[] {
120
- return [
121
- ...utilsRules,
122
- ...iconRules,
123
- ...formRules,
124
- ...chartRules,
125
- ...editorRules,
126
- ...tableRules,
127
- ...chinaRules,
128
- ...businessRules,
129
- ];
130
- }
131
-
@@ -1,93 +0,0 @@
1
- /**
2
- * 框架相关的分包规则
3
- */
4
- import type { Rule } from '../types';
5
-
6
- /**
7
- * Vue 生态规则
8
- */
9
- export const vueRules: Rule[] = [
10
- // Vue 核心
11
- { match: 'vue', category: 'vendor-vue', priority: 100, description: 'Vue 核心框架' },
12
- { match: /^@vue\//, category: 'vendor-vue', priority: 100, description: 'Vue 官方包' },
13
-
14
- // 状态管理
15
- { match: 'pinia', category: 'vendor-vue', priority: 100, description: 'Pinia 状态管理' },
16
- { match: 'vuex', category: 'vendor-state', priority: 90, description: 'Vuex 状态管理' },
17
-
18
- // 路由
19
- { match: 'vue-router', category: 'vendor-router', priority: 100, description: 'Vue Router' },
20
-
21
- // UI 框架
22
- { match: 'element-plus', category: 'vendor-element', priority: 80, description: 'Element Plus UI' },
23
- { match: 'ant-design-vue', category: 'vendor-ui', priority: 80, description: 'Ant Design Vue' },
24
- { match: 'naive-ui', category: 'vendor-ui', priority: 80, description: 'Naive UI' },
25
- { match: 'vant', category: 'vendor-ui', priority: 80, description: 'Vant UI' },
26
- { match: 'arco-design', category: 'vendor-ui', priority: 80, description: 'Arco Design' },
27
-
28
- // VueUse
29
- { match: /^@vueuse\//, category: 'vendor-vueuse', priority: 70, description: 'VueUse 工具集' },
30
-
31
- // 国际化
32
- { match: 'vue-i18n', category: 'vendor-i18n', priority: 60, description: 'Vue I18n' },
33
- { match: /^@intlify\//, category: 'vendor-i18n', priority: 60, description: 'Intlify' },
34
- ];
35
-
36
- /**
37
- * React 生态规则
38
- */
39
- export const reactRules: Rule[] = [
40
- // React 核心
41
- { match: 'react', category: 'vendor-react', priority: 100, description: 'React 核心' },
42
- { match: 'react-dom', category: 'vendor-react', priority: 100, description: 'React DOM' },
43
-
44
- // 状态管理
45
- { match: 'redux', category: 'vendor-state', priority: 90, description: 'Redux' },
46
- { match: 'react-redux', category: 'vendor-state', priority: 90, description: 'React Redux' },
47
- { match: 'zustand', category: 'vendor-state', priority: 90, description: 'Zustand' },
48
- { match: 'mobx', category: 'vendor-state', priority: 90, description: 'MobX' },
49
- { match: 'mobx-react', category: 'vendor-state', priority: 90, description: 'MobX React' },
50
-
51
- // 路由
52
- { match: 'react-router', category: 'vendor-router', priority: 100, description: 'React Router' },
53
- { match: 'react-router-dom', category: 'vendor-router', priority: 100, description: 'React Router DOM' },
54
-
55
- // UI 框架
56
- { match: 'antd', category: 'vendor-ui', priority: 80, description: 'Ant Design' },
57
- { match: '@ant-design/icons', category: 'vendor-icons', priority: 70, description: 'Ant Design Icons' },
58
- { match: '@mui/material', category: 'vendor-ui', priority: 80, description: 'Material UI' },
59
- { match: 'chakra-ui', category: 'vendor-ui', priority: 80, description: 'Chakra UI' },
60
- ];
61
-
62
- /**
63
- * Angular 生态规则
64
- */
65
- export const angularRules: Rule[] = [
66
- { match: /^@angular\//, category: 'vendor-angular', priority: 100, description: 'Angular 框架' },
67
- ];
68
-
69
- /**
70
- * Svelte 生态规则
71
- */
72
- export const svelteRules: Rule[] = [
73
- { match: 'svelte', category: 'vendor-svelte', priority: 100, description: 'Svelte 框架' },
74
- ];
75
-
76
- /**
77
- * 获取框架规则
78
- */
79
- export function getFrameworkRules(framework: string): Rule[] {
80
- switch (framework) {
81
- case 'vue':
82
- return vueRules;
83
- case 'react':
84
- return reactRules;
85
- case 'angular':
86
- return angularRules;
87
- case 'svelte':
88
- return svelteRules;
89
- default:
90
- return [...vueRules, ...reactRules, ...angularRules, ...svelteRules];
91
- }
92
- }
93
-
@@ -1,27 +0,0 @@
1
- /**
2
- * 规则导出
3
- */
4
- import type { Rule, Framework } from '../types';
5
- import { getFrameworkRules } from './framework-rules';
6
- import { getCommonRules } from './common-rules';
7
-
8
- /**
9
- * 获取所有规则
10
- */
11
- export function getAllRules(framework: Framework = 'auto'): Rule[] {
12
- const frameworkRules = getFrameworkRules(framework === 'auto' ? 'all' : framework);
13
- const commonRules = getCommonRules();
14
-
15
- return [...frameworkRules, ...commonRules];
16
- }
17
-
18
- /**
19
- * 根据优先级排序规则
20
- */
21
- export function sortRulesByPriority(rules: Rule[]): Rule[] {
22
- return rules.sort((a, b) => (b.priority || 0) - (a.priority || 0));
23
- }
24
-
25
- export { getFrameworkRules } from './framework-rules';
26
- export { getCommonRules } from './common-rules';
27
-