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,219 @@
1
+ 'use strict';
2
+
3
+ var chunk5IF32MBB_js = require('./chunk-5IF32MBB.js');
4
+ var chunkGNVCC37B_js = require('./chunk-GNVCC37B.js');
5
+
6
+ // src/tools/unifiedValidator.ts
7
+ function validateCompilation(code) {
8
+ const scopeId = `validate-${Date.now()}`;
9
+ const scriptOpenCount = (code.match(/<script[\s\S]*?>/g) || []).length;
10
+ const scriptCloseCount = (code.match(/<\/script>/g) || []).length;
11
+ const templateOpenCount = (code.match(/<template>/g) || []).length;
12
+ const templateCloseCount = (code.match(/<\/template>/g) || []).length;
13
+ if (scriptCloseCount > 0 && scriptOpenCount === 0) {
14
+ return {
15
+ name: "\u7F16\u8BD1\u68C0\u67E5",
16
+ passed: false,
17
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 <script> \u5F00\u59CB\u6807\u7B7E"]
18
+ };
19
+ }
20
+ if (scriptOpenCount > scriptCloseCount) {
21
+ return {
22
+ name: "\u7F16\u8BD1\u68C0\u67E5",
23
+ passed: false,
24
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 </script> \u7ED3\u675F\u6807\u7B7E"]
25
+ };
26
+ }
27
+ if (templateOpenCount > 0 && templateCloseCount === 0) {
28
+ return {
29
+ name: "\u7F16\u8BD1\u68C0\u67E5",
30
+ passed: false,
31
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 </template> \u7ED3\u675F\u6807\u7B7E"]
32
+ };
33
+ }
34
+ const hasValidScript = scriptOpenCount > 0 && scriptCloseCount > 0;
35
+ const hasValidTemplate = templateOpenCount > 0 && templateCloseCount > 0;
36
+ if (!hasValidScript && !hasValidTemplate) {
37
+ return {
38
+ name: "\u7F16\u8BD1\u68C0\u67E5",
39
+ passed: false,
40
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 <template> \u6216 <script> \u6807\u7B7E"]
41
+ };
42
+ }
43
+ const result = chunkGNVCC37B_js.compileSFC(code, scopeId);
44
+ if (result.error) {
45
+ return {
46
+ name: "\u7F16\u8BD1\u68C0\u67E5",
47
+ passed: false,
48
+ errors: [result.error]
49
+ };
50
+ }
51
+ if (!result.template && !result.script) {
52
+ return {
53
+ name: "\u7F16\u8BD1\u68C0\u67E5",
54
+ passed: false,
55
+ errors: ["\u4EE3\u7801\u4E3A\u7A7A\u6216\u683C\u5F0F\u4E0D\u6B63\u786E"]
56
+ };
57
+ }
58
+ return {
59
+ name: "\u7F16\u8BD1\u68C0\u67E5",
60
+ passed: true,
61
+ errors: []
62
+ };
63
+ }
64
+ async function validateAST(code) {
65
+ try {
66
+ const violations = await chunk5IF32MBB_js.analyzeCodeWithAST(code);
67
+ if (violations.length > 0) {
68
+ return {
69
+ name: "AST\u89C4\u5219\u68C0\u67E5",
70
+ passed: false,
71
+ errors: violations.map((v) => `${v.rule}: ${v.match} \u2192 ${v.suggestion}`)
72
+ };
73
+ }
74
+ return {
75
+ name: "AST\u89C4\u5219\u68C0\u67E5",
76
+ passed: true,
77
+ errors: []
78
+ };
79
+ } catch (e) {
80
+ return {
81
+ name: "AST\u89C4\u5219\u68C0\u67E5",
82
+ passed: false,
83
+ errors: [`AST\u5206\u6790\u5F02\u5E38: ${String(e)}`]
84
+ };
85
+ }
86
+ }
87
+ function validateRuntimePrecheck(code) {
88
+ const scopeId = `runtime-${Date.now()}`;
89
+ const { script, bindings, error } = chunkGNVCC37B_js.compileSFC(code, scopeId);
90
+ if (error) {
91
+ return {
92
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
93
+ passed: false,
94
+ errors: [error]
95
+ };
96
+ }
97
+ try {
98
+ const funcBody = `
99
+ "use strict";
100
+ ${script}
101
+ return { ${bindings.join(", ")} };
102
+ `;
103
+ const mockContext = {
104
+ ref: (v) => ({ value: v }),
105
+ reactive: (v) => v,
106
+ computed: (fn) => ({ value: fn() }),
107
+ onMounted: () => {
108
+ },
109
+ onUnmounted: () => {
110
+ },
111
+ watch: () => {
112
+ },
113
+ shallowRef: (v) => ({ value: v }),
114
+ nextTick: () => Promise.resolve(),
115
+ toRef: () => ({}),
116
+ toRefs: () => ({}),
117
+ watchEffect: () => {
118
+ },
119
+ readonly: (v) => v,
120
+ h: () => ({})
121
+ };
122
+ const keys = Object.keys(mockContext);
123
+ const values = Object.values(mockContext);
124
+ const runner = new Function(...keys, funcBody);
125
+ const result = runner(...values);
126
+ for (const binding of bindings) {
127
+ if (!(binding in result)) {
128
+ return {
129
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
130
+ passed: false,
131
+ errors: [`\u53D8\u91CF ${binding} \u672A\u6B63\u786E\u5BFC\u51FA`]
132
+ };
133
+ }
134
+ }
135
+ return {
136
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
137
+ passed: true,
138
+ errors: []
139
+ };
140
+ } catch (e) {
141
+ return {
142
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
143
+ passed: false,
144
+ errors: [`JavaScript \u6267\u884C\u9519\u8BEF: ${e.message}`]
145
+ };
146
+ }
147
+ }
148
+ async function validateCode(code) {
149
+ const compilationResult = validateCompilation(code);
150
+ if (!compilationResult.passed) {
151
+ return {
152
+ passed: false,
153
+ layers: {
154
+ compilation: compilationResult,
155
+ ast: { name: "AST\u89C4\u5219\u68C0\u67E5", passed: false, errors: ["\u8DF3\u8FC7\uFF08\u7F16\u8BD1\u5931\u8D25\uFF09"] },
156
+ runtime: { name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5", passed: false, errors: ["\u8DF3\u8FC7\uFF08\u7F16\u8BD1\u5931\u8D25\uFF09"] }
157
+ },
158
+ summary: `\u274C \u7F16\u8BD1\u5931\u8D25: ${compilationResult.errors[0]}`
159
+ };
160
+ }
161
+ const astResult = await validateAST(code);
162
+ if (!astResult.passed) {
163
+ return {
164
+ passed: false,
165
+ layers: {
166
+ compilation: compilationResult,
167
+ ast: astResult,
168
+ runtime: { name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5", passed: false, errors: ["\u8DF3\u8FC7\uFF08AST\u68C0\u67E5\u5931\u8D25\uFF09"] }
169
+ },
170
+ summary: `\u274C AST\u89C4\u5219\u8FDD\u89C4 (${astResult.errors.length}\u9879)`
171
+ };
172
+ }
173
+ const runtimeResult = validateRuntimePrecheck(code);
174
+ if (!runtimeResult.passed) {
175
+ return {
176
+ passed: false,
177
+ layers: {
178
+ compilation: compilationResult,
179
+ ast: astResult,
180
+ runtime: runtimeResult
181
+ },
182
+ summary: `\u274C \u8FD0\u884C\u65F6\u9519\u8BEF: ${runtimeResult.errors[0]}`
183
+ };
184
+ }
185
+ return {
186
+ passed: true,
187
+ layers: {
188
+ compilation: compilationResult,
189
+ ast: astResult,
190
+ runtime: runtimeResult
191
+ },
192
+ summary: "\u2705 \u5168\u90E8\u68C0\u67E5\u901A\u8FC7"
193
+ };
194
+ }
195
+ function validateCodeSync(code) {
196
+ const compilationResult = validateCompilation(code);
197
+ if (!compilationResult.passed) {
198
+ return {
199
+ passed: false,
200
+ layers: {
201
+ compilation: compilationResult,
202
+ runtime: { name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5", passed: false, errors: ["\u8DF3\u8FC7"] }
203
+ },
204
+ summary: `\u274C \u7F16\u8BD1\u5931\u8D25: ${compilationResult.errors[0]}`
205
+ };
206
+ }
207
+ const runtimeResult = validateRuntimePrecheck(code);
208
+ return {
209
+ passed: runtimeResult.passed,
210
+ layers: {
211
+ compilation: compilationResult,
212
+ runtime: runtimeResult
213
+ },
214
+ summary: runtimeResult.passed ? "\u2705 \u68C0\u67E5\u901A\u8FC7" : `\u274C ${runtimeResult.errors[0]}`
215
+ };
216
+ }
217
+
218
+ exports.validateCode = validateCode;
219
+ exports.validateCodeSync = validateCodeSync;