king-design-analyzer 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +151 -0
  2. package/components/affix.json +178 -0
  3. package/components/az.json +86 -0
  4. package/components/badge.json +162 -0
  5. package/components/billtypes.json +90 -0
  6. package/components/breadcrumb.json +220 -0
  7. package/components/button.json +511 -0
  8. package/components/card.json +334 -0
  9. package/components/cardcontent.json +144 -0
  10. package/components/carousel.json +207 -0
  11. package/components/cascader.json +373 -0
  12. package/components/checkbox.json +298 -0
  13. package/components/code.json +318 -0
  14. package/components/collapse.json +358 -0
  15. package/components/copy.json +220 -0
  16. package/components/datepicker.json +529 -0
  17. package/components/descriptions.json +309 -0
  18. package/components/dialog.json +460 -0
  19. package/components/divider.json +287 -0
  20. package/components/drawer.json +563 -0
  21. package/components/dropdown.json +407 -0
  22. package/components/editable.json +331 -0
  23. package/components/ellipsis.json +218 -0
  24. package/components/form.json +638 -0
  25. package/components/grid.json +377 -0
  26. package/components/icon.json +442 -0
  27. package/components/input.json +821 -0
  28. package/components/layoutcontent.json +210 -0
  29. package/components/menu.json +482 -0
  30. package/components/message.json +345 -0
  31. package/components/pagination.json +444 -0
  32. package/components/paginationplus.json +74 -0
  33. package/components/popover.json +456 -0
  34. package/components/progress.json +354 -0
  35. package/components/protable.json +132 -0
  36. package/components/radio.json +246 -0
  37. package/components/region.json +115 -0
  38. package/components/select.json +676 -0
  39. package/components/slider.json +422 -0
  40. package/components/spin.json +232 -0
  41. package/components/spinner.json +441 -0
  42. package/components/status.json +75 -0
  43. package/components/steps.json +292 -0
  44. package/components/switch.json +357 -0
  45. package/components/table.json +1057 -0
  46. package/components/tablecolumnid.json +217 -0
  47. package/components/tabs.json +363 -0
  48. package/components/tag.json +504 -0
  49. package/components/timepicker.json +447 -0
  50. package/components/tip.json +322 -0
  51. package/components/tooltip.json +416 -0
  52. package/components/tour.json +395 -0
  53. package/components/transfer.json +414 -0
  54. package/components/tree.json +480 -0
  55. package/components/treeselect.json +478 -0
  56. package/components/upload.json +499 -0
  57. package/components/virtuallist.json +178 -0
  58. package/dist/ast/index.d.mts +71 -0
  59. package/dist/ast/index.d.ts +71 -0
  60. package/dist/ast/index.js +15 -0
  61. package/dist/ast/index.mjs +2 -0
  62. package/dist/chunk-4BUGNH4F.mjs +62 -0
  63. package/dist/chunk-5H7N2A5X.mjs +1 -0
  64. package/dist/chunk-5IF32MBB.js +603 -0
  65. package/dist/chunk-ARWRNWDW.js +219 -0
  66. package/dist/chunk-C3L4IXJC.mjs +577 -0
  67. package/dist/chunk-GNVCC37B.js +102 -0
  68. package/dist/chunk-N4UIA6DN.js +68 -0
  69. package/dist/chunk-RAMIBZAU.mjs +216 -0
  70. package/dist/chunk-RNQHI7YG.js +64 -0
  71. package/dist/chunk-TB6BF5TJ.mjs +99 -0
  72. package/dist/chunk-UX7KGX45.mjs +66 -0
  73. package/dist/chunk-YTEYDSDW.js +2 -0
  74. package/dist/full/index.d.mts +29 -0
  75. package/dist/full/index.d.ts +29 -0
  76. package/dist/full/index.js +16 -0
  77. package/dist/full/index.mjs +3 -0
  78. package/dist/index.d.mts +5 -0
  79. package/dist/index.d.ts +5 -0
  80. package/dist/index.js +43 -0
  81. package/dist/index.mjs +6 -0
  82. package/dist/runtime/index.d.mts +14 -0
  83. package/dist/runtime/index.d.ts +14 -0
  84. package/dist/runtime/index.js +15 -0
  85. package/dist/runtime/index.mjs +2 -0
  86. package/dist/sfcCompiler-m51JOfWs.d.mts +22 -0
  87. package/dist/sfcCompiler-m51JOfWs.d.ts +22 -0
  88. package/dist/static/index.d.mts +14 -0
  89. package/dist/static/index.d.ts +14 -0
  90. package/dist/static/index.js +19 -0
  91. package/dist/static/index.mjs +2 -0
  92. package/package.json +88 -0
@@ -0,0 +1,178 @@
1
+ {
2
+ "id": "virtuallist",
3
+ "name": "VirtualList",
4
+ "displayName": "虚拟列表",
5
+ "category": "data-display",
6
+ "description": "虚拟列表组件,用于高性能渲染大量数据。只渲染可视区域内的元素,大幅减少 DOM 节点数量,提升滚动性能。适用于长列表、大数据量表格、无限滚动等场景。",
7
+ "importStatement": "import { VirtualList } from '@king-design/vue';",
8
+ "props": [
9
+ {
10
+ "name": "disabled",
11
+ "description": "是否禁用虚拟化,禁用后会渲染所有元素",
12
+ "type": {
13
+ "raw": "boolean",
14
+ "kind": "boolean"
15
+ },
16
+ "required": false,
17
+ "default": "false",
18
+ "usageExample": "<VirtualList disabled>"
19
+ }
20
+ ],
21
+ "events": [],
22
+ "methods": [],
23
+ "subComponents": [
24
+ {
25
+ "name": "VirtualListContainer",
26
+ "description": "虚拟列表容器组件,用于组合式使用"
27
+ },
28
+ {
29
+ "name": "VirtualListWrapper",
30
+ "description": "虚拟列表包装器组件,可通过 tagName 属性指定标签类型",
31
+ "props": [
32
+ {
33
+ "name": "tagName",
34
+ "description": "指定渲染的标签名",
35
+ "type": {
36
+ "raw": "string",
37
+ "kind": "string"
38
+ },
39
+ "required": false,
40
+ "default": "\"div\"",
41
+ "usageExample": "<VirtualListWrapper tagName=\"ul\">"
42
+ }
43
+ ]
44
+ },
45
+ {
46
+ "name": "VirtualListPhantom",
47
+ "description": "占位组件,用于撑开滚动高度"
48
+ },
49
+ {
50
+ "name": "VirtualListRows",
51
+ "description": "行渲染组件,包裹实际渲染的列表项"
52
+ }
53
+ ],
54
+ "examples": [
55
+ {
56
+ "id": "virtuallist_basic",
57
+ "title": "基础用法",
58
+ "description": "渲染大量数据",
59
+ "difficulty": "easy",
60
+ "code": "<script setup lang=\"ts\">\nimport { ref, onMounted } from 'vue';\nimport { VirtualList } from '@king-design/vue';\n\nconst data = ref<{value: number; label: string}[]>([]);\n\nonMounted(() => {\n const arr = [];\n for (let i = 0; i < 10000; i++) {\n arr.push({ value: i, label: `列表项 ${i}` });\n }\n data.value = arr;\n});\n</script>\n<template>\n <VirtualList style=\"height: 400px;\">\n <div v-for=\"item in data\" :key=\"item.value\" style=\"height: 40px; line-height: 40px;\">\n {{ item.label }}\n </div>\n </VirtualList>\n</template>",
61
+ "tags": [
62
+ "basic",
63
+ "large-data"
64
+ ],
65
+ "usedProps": [],
66
+ "usedEvents": [],
67
+ "usedMethods": [],
68
+ "scenario": "渲染万级数据量的列表"
69
+ },
70
+ {
71
+ "id": "virtuallist_variable_height",
72
+ "title": "不定高度",
73
+ "description": "支持不定高度的列表项",
74
+ "difficulty": "medium",
75
+ "code": "<script setup lang=\"ts\">\nimport { ref, onMounted } from 'vue';\nimport { VirtualList } from '@king-design/vue';\n\nconst data = ref<{value: number; label: string}[]>([]);\n\nonMounted(() => {\n const arr = [];\n for (let i = 0; i < 10000; i++) {\n const content = '内容'.repeat(Math.floor(Math.random() * 5) + 1);\n arr.push({ value: i, label: `项目 ${i}: ${content}` });\n }\n data.value = arr;\n});\n</script>\n<template>\n <VirtualList style=\"width: 300px; height: 400px;\">\n <div v-for=\"item in data\" :key=\"item.value\" style=\"padding: 10px; border-bottom: 1px solid #eee;\">\n {{ item.label }}\n </div>\n </VirtualList>\n</template>",
76
+ "tags": [
77
+ "variable-height"
78
+ ],
79
+ "usedProps": [],
80
+ "usedEvents": [],
81
+ "usedMethods": [],
82
+ "scenario": "处理不定高度的列表项"
83
+ },
84
+ {
85
+ "id": "virtuallist_composite",
86
+ "title": "组合式使用",
87
+ "description": "使用子组件进行组合",
88
+ "difficulty": "hard",
89
+ "code": "<script setup lang=\"ts\">\nimport { ref, onMounted } from 'vue';\nimport { VirtualListContainer, VirtualListWrapper, VirtualListPhantom, VirtualListRows } from '@king-design/vue';\n\nconst data = ref<{value: number; label: string}[]>([]);\n\nonMounted(() => {\n const arr = [];\n for (let i = 0; i < 10000; i++) {\n arr.push({ value: i, label: `列表项 ${i}` });\n }\n data.value = arr;\n});\n</script>\n<template>\n <div style=\"height: 400px;\">\n <VirtualListContainer>\n <VirtualListPhantom />\n <VirtualListWrapper tagName=\"ul\">\n <VirtualListRows>\n <li v-for=\"item in data\" :key=\"item.value\" style=\"height: 40px; line-height: 40px;\">\n {{ item.label }}\n </li>\n </VirtualListRows>\n </VirtualListWrapper>\n </VirtualListContainer>\n </div>\n</template>",
90
+ "tags": [
91
+ "composite",
92
+ "advanced"
93
+ ],
94
+ "usedProps": [],
95
+ "usedEvents": [],
96
+ "usedMethods": [],
97
+ "scenario": "使用子组件进行复杂布局"
98
+ },
99
+ {
100
+ "id": "virtuallist_dynamic",
101
+ "title": "动态更新",
102
+ "description": "动态添加和删除数据",
103
+ "difficulty": "medium",
104
+ "code": "<script setup lang=\"ts\">\nimport { ref, onMounted } from 'vue';\nimport { VirtualList, Button } from '@king-design/vue';\n\nconst data = ref<{value: number; label: string}[]>([]);\n\nonMounted(() => {\n initData();\n});\n\nconst initData = () => {\n const arr = [];\n for (let i = 0; i < 1000; i++) {\n arr.push({ value: i, label: `列表项 ${i}` });\n }\n data.value = arr;\n};\n\nconst addItems = () => {\n const len = data.value.length;\n for (let i = 0; i < 10; i++) {\n data.value.push({ value: len + i, label: `新增项 ${len + i}` });\n }\n};\n</script>\n<template>\n <div>\n <Button @click=\"addItems\">新增10项</Button>\n <VirtualList style=\"height: 400px;\">\n <div v-for=\"item in data\" :key=\"item.value\" style=\"height: 40px; line-height: 40px;\">\n {{ item.label }}\n </div>\n </VirtualList>\n </div>\n</template>",
105
+ "tags": [
106
+ "dynamic",
107
+ "update"
108
+ ],
109
+ "usedProps": [],
110
+ "usedEvents": [],
111
+ "usedMethods": [],
112
+ "scenario": "动态更新列表数据"
113
+ },
114
+ {
115
+ "id": "virtuallist_disabled",
116
+ "title": "禁用虚拟化",
117
+ "description": "禁用虚拟化渲染所有元素",
118
+ "difficulty": "easy",
119
+ "code": "<script setup lang=\"ts\">\nimport { ref } from 'vue';\nimport { VirtualList } from '@king-design/vue';\n\nconst data = ref([\n { value: 1, label: '项目 1' },\n { value: 2, label: '项目 2' },\n { value: 3, label: '项目 3' }\n]);\n</script>\n<template>\n <VirtualList disabled style=\"height: 200px;\">\n <div v-for=\"item in data\" :key=\"item.value\">\n {{ item.label }}\n </div>\n </VirtualList>\n</template>",
120
+ "tags": [
121
+ "disabled"
122
+ ],
123
+ "usedProps": [
124
+ "disabled"
125
+ ],
126
+ "usedEvents": [],
127
+ "usedMethods": [],
128
+ "scenario": "数据量较小时禁用虚拟化"
129
+ }
130
+ ],
131
+ "commonMistakes": [
132
+ {
133
+ "id": "virtuallist_no_height",
134
+ "description": "容器未设置高度",
135
+ "wrongCode": "<VirtualList> <!-- 没有高度,无法滚动 -->\n <div v-for=\"item in data\" :key=\"item.value\">...</div>\n</VirtualList>",
136
+ "correctCode": "<VirtualList style=\"height: 400px;\">\n <div v-for=\"item in data\" :key=\"item.value\">...</div>\n</VirtualList>",
137
+ "explanation": "VirtualList 容器必须设置固定高度才能正常工作",
138
+ "relatedProps": []
139
+ },
140
+ {
141
+ "id": "virtuallist_missing_key",
142
+ "description": "列表项缺少 key",
143
+ "wrongCode": "<div v-for=\"item in data\">{{ item.label }}</div>",
144
+ "correctCode": "<div v-for=\"item in data\" :key=\"item.value\">{{ item.label }}</div>",
145
+ "explanation": "每个列表项必须设置唯一的 key 以确保正确渲染",
146
+ "relatedProps": []
147
+ },
148
+ {
149
+ "id": "virtuallist_small_data",
150
+ "description": "数据量较小时启用虚拟化",
151
+ "wrongCode": "const data = [1, 2, 3]; // 只有 3 条数据\n<VirtualList>...</VirtualList>",
152
+ "correctCode": "const data = [1, 2, 3];\n<VirtualList disabled>...</VirtualList>",
153
+ "explanation": "数据量较小时建议禁用虚拟化,避免不必要的计算开销",
154
+ "relatedProps": [
155
+ "disabled"
156
+ ]
157
+ }
158
+ ],
159
+ "searchKeywords": [
160
+ "虚拟列表",
161
+ "virtuallist",
162
+ "大数据",
163
+ "无限滚动",
164
+ "高性能",
165
+ "长列表"
166
+ ],
167
+ "useCases": [
168
+ "长列表展示",
169
+ "聊天记录",
170
+ "日志列表",
171
+ "大数据表格",
172
+ "无限滚动"
173
+ ],
174
+ "relatedComponents": [
175
+ "Table",
176
+ "Select"
177
+ ]
178
+ }
@@ -0,0 +1,71 @@
1
+ interface RuleViolation {
2
+ rule: string;
3
+ match: string;
4
+ suggestion: string;
5
+ }
6
+ /**
7
+ * 使用 AST 分析 Vue 代码 (Async)
8
+ */
9
+ declare function analyzeCodeWithAST(code: string): Promise<RuleViolation[]>;
10
+
11
+ interface ComponentProp {
12
+ name: string;
13
+ description?: string;
14
+ type: {
15
+ raw: string;
16
+ kind: string;
17
+ unionTypes?: any[];
18
+ };
19
+ required: boolean;
20
+ allowedValues?: {
21
+ value: any;
22
+ }[];
23
+ }
24
+ interface ComponentEvent {
25
+ name: string;
26
+ }
27
+ interface ComponentSlot {
28
+ name: string;
29
+ }
30
+ interface MistakeEntry {
31
+ id: string;
32
+ description: string;
33
+ wrongCode: string;
34
+ correctCode: string;
35
+ explanation: string;
36
+ }
37
+ interface ComponentMetadata {
38
+ name: string;
39
+ props: ComponentProp[];
40
+ events: ComponentEvent[];
41
+ slots: ComponentSlot[];
42
+ subComponents?: ComponentMetadata[];
43
+ commonMistakes?: MistakeEntry[];
44
+ importStatement?: string;
45
+ requiredParent?: string;
46
+ }
47
+ declare class ComponentRegistry {
48
+ private components;
49
+ private loaded;
50
+ private watcher;
51
+ private metadataPath;
52
+ load(): Promise<void>;
53
+ /**
54
+ * 重新加载所有组件元数据
55
+ */
56
+ reload(): Promise<void>;
57
+ /**
58
+ * 开始监听文件变化
59
+ */
60
+ private startWatching;
61
+ /**
62
+ * 停止监听
63
+ */
64
+ stopWatching(): void;
65
+ getComponent(name: string): ComponentMetadata | undefined;
66
+ getAllComponentNames(): string[];
67
+ isKnownComponent(name: string): boolean;
68
+ }
69
+ declare const componentRegistry: ComponentRegistry;
70
+
71
+ export { type ComponentEvent, type ComponentMetadata, type ComponentProp, type ComponentSlot, type MistakeEntry, type RuleViolation, analyzeCodeWithAST, componentRegistry };
@@ -0,0 +1,71 @@
1
+ interface RuleViolation {
2
+ rule: string;
3
+ match: string;
4
+ suggestion: string;
5
+ }
6
+ /**
7
+ * 使用 AST 分析 Vue 代码 (Async)
8
+ */
9
+ declare function analyzeCodeWithAST(code: string): Promise<RuleViolation[]>;
10
+
11
+ interface ComponentProp {
12
+ name: string;
13
+ description?: string;
14
+ type: {
15
+ raw: string;
16
+ kind: string;
17
+ unionTypes?: any[];
18
+ };
19
+ required: boolean;
20
+ allowedValues?: {
21
+ value: any;
22
+ }[];
23
+ }
24
+ interface ComponentEvent {
25
+ name: string;
26
+ }
27
+ interface ComponentSlot {
28
+ name: string;
29
+ }
30
+ interface MistakeEntry {
31
+ id: string;
32
+ description: string;
33
+ wrongCode: string;
34
+ correctCode: string;
35
+ explanation: string;
36
+ }
37
+ interface ComponentMetadata {
38
+ name: string;
39
+ props: ComponentProp[];
40
+ events: ComponentEvent[];
41
+ slots: ComponentSlot[];
42
+ subComponents?: ComponentMetadata[];
43
+ commonMistakes?: MistakeEntry[];
44
+ importStatement?: string;
45
+ requiredParent?: string;
46
+ }
47
+ declare class ComponentRegistry {
48
+ private components;
49
+ private loaded;
50
+ private watcher;
51
+ private metadataPath;
52
+ load(): Promise<void>;
53
+ /**
54
+ * 重新加载所有组件元数据
55
+ */
56
+ reload(): Promise<void>;
57
+ /**
58
+ * 开始监听文件变化
59
+ */
60
+ private startWatching;
61
+ /**
62
+ * 停止监听
63
+ */
64
+ stopWatching(): void;
65
+ getComponent(name: string): ComponentMetadata | undefined;
66
+ getAllComponentNames(): string[];
67
+ isKnownComponent(name: string): boolean;
68
+ }
69
+ declare const componentRegistry: ComponentRegistry;
70
+
71
+ export { type ComponentEvent, type ComponentMetadata, type ComponentProp, type ComponentSlot, type MistakeEntry, type RuleViolation, analyzeCodeWithAST, componentRegistry };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ require('../chunk-YTEYDSDW.js');
4
+ var chunk5IF32MBB_js = require('../chunk-5IF32MBB.js');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "analyzeCodeWithAST", {
9
+ enumerable: true,
10
+ get: function () { return chunk5IF32MBB_js.analyzeCodeWithAST; }
11
+ });
12
+ Object.defineProperty(exports, "componentRegistry", {
13
+ enumerable: true,
14
+ get: function () { return chunk5IF32MBB_js.componentRegistry; }
15
+ });
@@ -0,0 +1,2 @@
1
+ import '../chunk-5H7N2A5X.mjs';
2
+ export { analyzeCodeWithAST, componentRegistry } from '../chunk-C3L4IXJC.mjs';
@@ -0,0 +1,62 @@
1
+ import { compileSFC } from './chunk-TB6BF5TJ.mjs';
2
+
3
+ // src/static/index.ts
4
+ function validateCompilation(code) {
5
+ const scopeId = `validate-${Date.now()}`;
6
+ const scriptOpenCount = (code.match(/<script[\s\S]*?>/g) || []).length;
7
+ const scriptCloseCount = (code.match(/<\/script>/g) || []).length;
8
+ const templateOpenCount = (code.match(/<template>/g) || []).length;
9
+ const templateCloseCount = (code.match(/<\/template>/g) || []).length;
10
+ if (scriptCloseCount > 0 && scriptOpenCount === 0) {
11
+ return {
12
+ name: "\u7F16\u8BD1\u68C0\u67E5",
13
+ passed: false,
14
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 <script> \u5F00\u59CB\u6807\u7B7E"]
15
+ };
16
+ }
17
+ if (scriptOpenCount > scriptCloseCount) {
18
+ return {
19
+ name: "\u7F16\u8BD1\u68C0\u67E5",
20
+ passed: false,
21
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 </script> \u7ED3\u675F\u6807\u7B7E"]
22
+ };
23
+ }
24
+ if (templateOpenCount > 0 && templateCloseCount === 0) {
25
+ return {
26
+ name: "\u7F16\u8BD1\u68C0\u67E5",
27
+ passed: false,
28
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 </template> \u7ED3\u675F\u6807\u7B7E"]
29
+ };
30
+ }
31
+ const hasValidScript = scriptOpenCount > 0 && scriptCloseCount > 0;
32
+ const hasValidTemplate = templateOpenCount > 0 && templateCloseCount > 0;
33
+ if (!hasValidScript && !hasValidTemplate) {
34
+ return {
35
+ name: "\u7F16\u8BD1\u68C0\u67E5",
36
+ passed: false,
37
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 <template> \u6216 <script> \u6807\u7B7E"]
38
+ };
39
+ }
40
+ const result = compileSFC(code, scopeId);
41
+ if (result.error) {
42
+ return {
43
+ name: "\u7F16\u8BD1\u68C0\u67E5",
44
+ passed: false,
45
+ errors: [result.error]
46
+ };
47
+ }
48
+ if (!result.template && !result.script) {
49
+ return {
50
+ name: "\u7F16\u8BD1\u68C0\u67E5",
51
+ passed: false,
52
+ errors: ["\u4EE3\u7801\u4E3A\u7A7A\u6216\u683C\u5F0F\u4E0D\u6B63\u786E"]
53
+ };
54
+ }
55
+ return {
56
+ name: "\u7F16\u8BD1\u68C0\u67E5",
57
+ passed: true,
58
+ errors: []
59
+ };
60
+ }
61
+
62
+ export { validateCompilation };
@@ -0,0 +1 @@
1
+