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,68 @@
1
+ 'use strict';
2
+
3
+ var chunkGNVCC37B_js = require('./chunk-GNVCC37B.js');
4
+
5
+ // src/runtime/index.ts
6
+ function validateRuntimePrecheck(code) {
7
+ const scopeId = `runtime-${Date.now()}`;
8
+ const { script, bindings, error } = chunkGNVCC37B_js.compileSFC(code, scopeId);
9
+ if (error) {
10
+ return {
11
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
12
+ passed: false,
13
+ errors: [error]
14
+ };
15
+ }
16
+ try {
17
+ const funcBody = `
18
+ "use strict";
19
+ ${script}
20
+ return { ${bindings.join(", ")} };
21
+ `;
22
+ const mockContext = {
23
+ ref: (v) => ({ value: v }),
24
+ reactive: (v) => v,
25
+ computed: (fn) => ({ value: fn() }),
26
+ onMounted: () => {
27
+ },
28
+ onUnmounted: () => {
29
+ },
30
+ watch: () => {
31
+ },
32
+ shallowRef: (v) => ({ value: v }),
33
+ nextTick: () => Promise.resolve(),
34
+ toRef: () => ({}),
35
+ toRefs: () => ({}),
36
+ watchEffect: () => {
37
+ },
38
+ readonly: (v) => v,
39
+ h: () => ({})
40
+ };
41
+ const keys = Object.keys(mockContext);
42
+ const values = Object.values(mockContext);
43
+ const runner = new Function(...keys, funcBody);
44
+ const result = runner(...values);
45
+ for (const binding of bindings) {
46
+ if (!(binding in result)) {
47
+ return {
48
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
49
+ passed: false,
50
+ errors: [`\u53D8\u91CF ${binding} \u672A\u6B63\u786E\u5BFC\u51FA`]
51
+ };
52
+ }
53
+ }
54
+ return {
55
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
56
+ passed: true,
57
+ errors: []
58
+ };
59
+ } catch (e) {
60
+ return {
61
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
62
+ passed: false,
63
+ errors: [`JavaScript \u6267\u884C\u9519\u8BEF: ${e.message}`]
64
+ };
65
+ }
66
+ }
67
+
68
+ exports.validateRuntimePrecheck = validateRuntimePrecheck;
@@ -0,0 +1,216 @@
1
+ import { analyzeCodeWithAST } from './chunk-C3L4IXJC.mjs';
2
+ import { compileSFC } from './chunk-TB6BF5TJ.mjs';
3
+
4
+ // src/tools/unifiedValidator.ts
5
+ function validateCompilation(code) {
6
+ const scopeId = `validate-${Date.now()}`;
7
+ const scriptOpenCount = (code.match(/<script[\s\S]*?>/g) || []).length;
8
+ const scriptCloseCount = (code.match(/<\/script>/g) || []).length;
9
+ const templateOpenCount = (code.match(/<template>/g) || []).length;
10
+ const templateCloseCount = (code.match(/<\/template>/g) || []).length;
11
+ if (scriptCloseCount > 0 && scriptOpenCount === 0) {
12
+ return {
13
+ name: "\u7F16\u8BD1\u68C0\u67E5",
14
+ passed: false,
15
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 <script> \u5F00\u59CB\u6807\u7B7E"]
16
+ };
17
+ }
18
+ if (scriptOpenCount > scriptCloseCount) {
19
+ return {
20
+ name: "\u7F16\u8BD1\u68C0\u67E5",
21
+ passed: false,
22
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 </script> \u7ED3\u675F\u6807\u7B7E"]
23
+ };
24
+ }
25
+ if (templateOpenCount > 0 && templateCloseCount === 0) {
26
+ return {
27
+ name: "\u7F16\u8BD1\u68C0\u67E5",
28
+ passed: false,
29
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 </template> \u7ED3\u675F\u6807\u7B7E"]
30
+ };
31
+ }
32
+ const hasValidScript = scriptOpenCount > 0 && scriptCloseCount > 0;
33
+ const hasValidTemplate = templateOpenCount > 0 && templateCloseCount > 0;
34
+ if (!hasValidScript && !hasValidTemplate) {
35
+ return {
36
+ name: "\u7F16\u8BD1\u68C0\u67E5",
37
+ passed: false,
38
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 <template> \u6216 <script> \u6807\u7B7E"]
39
+ };
40
+ }
41
+ const result = compileSFC(code, scopeId);
42
+ if (result.error) {
43
+ return {
44
+ name: "\u7F16\u8BD1\u68C0\u67E5",
45
+ passed: false,
46
+ errors: [result.error]
47
+ };
48
+ }
49
+ if (!result.template && !result.script) {
50
+ return {
51
+ name: "\u7F16\u8BD1\u68C0\u67E5",
52
+ passed: false,
53
+ errors: ["\u4EE3\u7801\u4E3A\u7A7A\u6216\u683C\u5F0F\u4E0D\u6B63\u786E"]
54
+ };
55
+ }
56
+ return {
57
+ name: "\u7F16\u8BD1\u68C0\u67E5",
58
+ passed: true,
59
+ errors: []
60
+ };
61
+ }
62
+ async function validateAST(code) {
63
+ try {
64
+ const violations = await analyzeCodeWithAST(code);
65
+ if (violations.length > 0) {
66
+ return {
67
+ name: "AST\u89C4\u5219\u68C0\u67E5",
68
+ passed: false,
69
+ errors: violations.map((v) => `${v.rule}: ${v.match} \u2192 ${v.suggestion}`)
70
+ };
71
+ }
72
+ return {
73
+ name: "AST\u89C4\u5219\u68C0\u67E5",
74
+ passed: true,
75
+ errors: []
76
+ };
77
+ } catch (e) {
78
+ return {
79
+ name: "AST\u89C4\u5219\u68C0\u67E5",
80
+ passed: false,
81
+ errors: [`AST\u5206\u6790\u5F02\u5E38: ${String(e)}`]
82
+ };
83
+ }
84
+ }
85
+ function validateRuntimePrecheck(code) {
86
+ const scopeId = `runtime-${Date.now()}`;
87
+ const { script, bindings, error } = compileSFC(code, scopeId);
88
+ if (error) {
89
+ return {
90
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
91
+ passed: false,
92
+ errors: [error]
93
+ };
94
+ }
95
+ try {
96
+ const funcBody = `
97
+ "use strict";
98
+ ${script}
99
+ return { ${bindings.join(", ")} };
100
+ `;
101
+ const mockContext = {
102
+ ref: (v) => ({ value: v }),
103
+ reactive: (v) => v,
104
+ computed: (fn) => ({ value: fn() }),
105
+ onMounted: () => {
106
+ },
107
+ onUnmounted: () => {
108
+ },
109
+ watch: () => {
110
+ },
111
+ shallowRef: (v) => ({ value: v }),
112
+ nextTick: () => Promise.resolve(),
113
+ toRef: () => ({}),
114
+ toRefs: () => ({}),
115
+ watchEffect: () => {
116
+ },
117
+ readonly: (v) => v,
118
+ h: () => ({})
119
+ };
120
+ const keys = Object.keys(mockContext);
121
+ const values = Object.values(mockContext);
122
+ const runner = new Function(...keys, funcBody);
123
+ const result = runner(...values);
124
+ for (const binding of bindings) {
125
+ if (!(binding in result)) {
126
+ return {
127
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
128
+ passed: false,
129
+ errors: [`\u53D8\u91CF ${binding} \u672A\u6B63\u786E\u5BFC\u51FA`]
130
+ };
131
+ }
132
+ }
133
+ return {
134
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
135
+ passed: true,
136
+ errors: []
137
+ };
138
+ } catch (e) {
139
+ return {
140
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
141
+ passed: false,
142
+ errors: [`JavaScript \u6267\u884C\u9519\u8BEF: ${e.message}`]
143
+ };
144
+ }
145
+ }
146
+ async function validateCode(code) {
147
+ const compilationResult = validateCompilation(code);
148
+ if (!compilationResult.passed) {
149
+ return {
150
+ passed: false,
151
+ layers: {
152
+ compilation: compilationResult,
153
+ ast: { name: "AST\u89C4\u5219\u68C0\u67E5", passed: false, errors: ["\u8DF3\u8FC7\uFF08\u7F16\u8BD1\u5931\u8D25\uFF09"] },
154
+ runtime: { name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5", passed: false, errors: ["\u8DF3\u8FC7\uFF08\u7F16\u8BD1\u5931\u8D25\uFF09"] }
155
+ },
156
+ summary: `\u274C \u7F16\u8BD1\u5931\u8D25: ${compilationResult.errors[0]}`
157
+ };
158
+ }
159
+ const astResult = await validateAST(code);
160
+ if (!astResult.passed) {
161
+ return {
162
+ passed: false,
163
+ layers: {
164
+ compilation: compilationResult,
165
+ ast: astResult,
166
+ runtime: { name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5", passed: false, errors: ["\u8DF3\u8FC7\uFF08AST\u68C0\u67E5\u5931\u8D25\uFF09"] }
167
+ },
168
+ summary: `\u274C AST\u89C4\u5219\u8FDD\u89C4 (${astResult.errors.length}\u9879)`
169
+ };
170
+ }
171
+ const runtimeResult = validateRuntimePrecheck(code);
172
+ if (!runtimeResult.passed) {
173
+ return {
174
+ passed: false,
175
+ layers: {
176
+ compilation: compilationResult,
177
+ ast: astResult,
178
+ runtime: runtimeResult
179
+ },
180
+ summary: `\u274C \u8FD0\u884C\u65F6\u9519\u8BEF: ${runtimeResult.errors[0]}`
181
+ };
182
+ }
183
+ return {
184
+ passed: true,
185
+ layers: {
186
+ compilation: compilationResult,
187
+ ast: astResult,
188
+ runtime: runtimeResult
189
+ },
190
+ summary: "\u2705 \u5168\u90E8\u68C0\u67E5\u901A\u8FC7"
191
+ };
192
+ }
193
+ function validateCodeSync(code) {
194
+ const compilationResult = validateCompilation(code);
195
+ if (!compilationResult.passed) {
196
+ return {
197
+ passed: false,
198
+ layers: {
199
+ compilation: compilationResult,
200
+ runtime: { name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5", passed: false, errors: ["\u8DF3\u8FC7"] }
201
+ },
202
+ summary: `\u274C \u7F16\u8BD1\u5931\u8D25: ${compilationResult.errors[0]}`
203
+ };
204
+ }
205
+ const runtimeResult = validateRuntimePrecheck(code);
206
+ return {
207
+ passed: runtimeResult.passed,
208
+ layers: {
209
+ compilation: compilationResult,
210
+ runtime: runtimeResult
211
+ },
212
+ summary: runtimeResult.passed ? "\u2705 \u68C0\u67E5\u901A\u8FC7" : `\u274C ${runtimeResult.errors[0]}`
213
+ };
214
+ }
215
+
216
+ export { validateCode, validateCodeSync };
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ var chunkGNVCC37B_js = require('./chunk-GNVCC37B.js');
4
+
5
+ // src/static/index.ts
6
+ function validateCompilation(code) {
7
+ const scopeId = `validate-${Date.now()}`;
8
+ const scriptOpenCount = (code.match(/<script[\s\S]*?>/g) || []).length;
9
+ const scriptCloseCount = (code.match(/<\/script>/g) || []).length;
10
+ const templateOpenCount = (code.match(/<template>/g) || []).length;
11
+ const templateCloseCount = (code.match(/<\/template>/g) || []).length;
12
+ if (scriptCloseCount > 0 && scriptOpenCount === 0) {
13
+ return {
14
+ name: "\u7F16\u8BD1\u68C0\u67E5",
15
+ passed: false,
16
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 <script> \u5F00\u59CB\u6807\u7B7E"]
17
+ };
18
+ }
19
+ if (scriptOpenCount > scriptCloseCount) {
20
+ return {
21
+ name: "\u7F16\u8BD1\u68C0\u67E5",
22
+ passed: false,
23
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 </script> \u7ED3\u675F\u6807\u7B7E"]
24
+ };
25
+ }
26
+ if (templateOpenCount > 0 && templateCloseCount === 0) {
27
+ return {
28
+ name: "\u7F16\u8BD1\u68C0\u67E5",
29
+ passed: false,
30
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 </template> \u7ED3\u675F\u6807\u7B7E"]
31
+ };
32
+ }
33
+ const hasValidScript = scriptOpenCount > 0 && scriptCloseCount > 0;
34
+ const hasValidTemplate = templateOpenCount > 0 && templateCloseCount > 0;
35
+ if (!hasValidScript && !hasValidTemplate) {
36
+ return {
37
+ name: "\u7F16\u8BD1\u68C0\u67E5",
38
+ passed: false,
39
+ errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 <template> \u6216 <script> \u6807\u7B7E"]
40
+ };
41
+ }
42
+ const result = chunkGNVCC37B_js.compileSFC(code, scopeId);
43
+ if (result.error) {
44
+ return {
45
+ name: "\u7F16\u8BD1\u68C0\u67E5",
46
+ passed: false,
47
+ errors: [result.error]
48
+ };
49
+ }
50
+ if (!result.template && !result.script) {
51
+ return {
52
+ name: "\u7F16\u8BD1\u68C0\u67E5",
53
+ passed: false,
54
+ errors: ["\u4EE3\u7801\u4E3A\u7A7A\u6216\u683C\u5F0F\u4E0D\u6B63\u786E"]
55
+ };
56
+ }
57
+ return {
58
+ name: "\u7F16\u8BD1\u68C0\u67E5",
59
+ passed: true,
60
+ errors: []
61
+ };
62
+ }
63
+
64
+ exports.validateCompilation = validateCompilation;
@@ -0,0 +1,99 @@
1
+ import { transform } from 'sucrase';
2
+
3
+ // src/tools/sfcCompiler.ts
4
+ function scopeStyles(css, scopeClass) {
5
+ return css.replace(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g, (match, selector, suffix) => {
6
+ if (selector.trim().startsWith("@")) return match;
7
+ const scopedSelector = selector.split(",").map((s) => {
8
+ s = s.trim();
9
+ if (s === "body" || s === "html") return `.${scopeClass}`;
10
+ return `.${scopeClass} ${s}`;
11
+ }).join(", ");
12
+ return `${scopedSelector}${suffix}`;
13
+ });
14
+ }
15
+ function compileSFC(code, scopeId) {
16
+ try {
17
+ const templateMatch = code.match(/<template>([\s\S]*)<\/template>/);
18
+ const scriptMatch = code.match(/<script[\s\S]*?>([\s\S]*)<\/script>/);
19
+ const styleMatch = code.match(/<style[\s\S]*?>([\s\S]*)<\/style>/);
20
+ const template = templateMatch && templateMatch[1] || "";
21
+ const script = scriptMatch && scriptMatch[1] || "";
22
+ const styleRaw = styleMatch && styleMatch[1] || "";
23
+ const style = styleRaw ? scopeStyles(styleRaw, scopeId) : "";
24
+ if (!template && !script) {
25
+ return { template: "", script: "", style: "", bindings: [] };
26
+ }
27
+ let cleanScript = script;
28
+ cleanScript = cleanScript.replace(/import\s+[\s\S]*?from\s+['"].*?['"];?/g, "");
29
+ cleanScript = cleanScript.replace(/import\s+type\s+[\s\S]*?from\s+['"].*?['"];?/g, "");
30
+ const result = transform(cleanScript, {
31
+ transforms: ["typescript"],
32
+ disableESTransforms: true
33
+ });
34
+ if (result && typeof result.code === "string") {
35
+ cleanScript = result.code;
36
+ }
37
+ const varNames = [];
38
+ const lines = cleanScript.split("\n");
39
+ let baseIndent = -1;
40
+ for (const line of lines) {
41
+ if (line.trim()) {
42
+ const match = line.match(/^(\s*)/);
43
+ if (match && match[1] !== void 0) {
44
+ baseIndent = match[1].length;
45
+ break;
46
+ }
47
+ }
48
+ }
49
+ if (baseIndent === -1) baseIndent = 0;
50
+ for (const line of lines) {
51
+ const lineIndentMatch = line.match(/^(\s*)/);
52
+ const lineIndent = lineIndentMatch && typeof lineIndentMatch[1] === "string" ? lineIndentMatch[1].length : 0;
53
+ if (!line.trim() || line.trim().startsWith("//")) continue;
54
+ if (lineIndent === baseIndent) {
55
+ const trimmed = line.trim();
56
+ const stdMatch = trimmed.match(/^(?:const|let|var|function)\s+(\w+)/);
57
+ if (stdMatch && stdMatch[1]) {
58
+ varNames.push(stdMatch[1]);
59
+ continue;
60
+ }
61
+ const objMatch = trimmed.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);
62
+ if (objMatch && typeof objMatch[1] === "string") {
63
+ const content = objMatch[1];
64
+ const vars = content.split(",").map((v) => (v.split(":")[0] || "").trim());
65
+ vars.forEach((v) => {
66
+ const cleanName = v.replace(/\s+as\s+\w+/, "").trim();
67
+ if (/^[a-zA-Z_$][\w$]*$/.test(cleanName)) varNames.push(cleanName);
68
+ });
69
+ continue;
70
+ }
71
+ const arrMatch = trimmed.match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);
72
+ if (arrMatch && typeof arrMatch[1] === "string") {
73
+ const content = arrMatch[1];
74
+ const vars = content.split(",").map((v) => v.trim());
75
+ vars.forEach((v) => {
76
+ if (v && /^[a-zA-Z_$][\w$]*$/.test(v)) varNames.push(v);
77
+ });
78
+ continue;
79
+ }
80
+ }
81
+ }
82
+ return {
83
+ template,
84
+ script: cleanScript,
85
+ style,
86
+ bindings: [...new Set(varNames)]
87
+ };
88
+ } catch (e) {
89
+ return {
90
+ template: "",
91
+ script: "",
92
+ style: "",
93
+ bindings: [],
94
+ error: e.message
95
+ };
96
+ }
97
+ }
98
+
99
+ export { compileSFC, scopeStyles };
@@ -0,0 +1,66 @@
1
+ import { compileSFC } from './chunk-TB6BF5TJ.mjs';
2
+
3
+ // src/runtime/index.ts
4
+ function validateRuntimePrecheck(code) {
5
+ const scopeId = `runtime-${Date.now()}`;
6
+ const { script, bindings, error } = compileSFC(code, scopeId);
7
+ if (error) {
8
+ return {
9
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
10
+ passed: false,
11
+ errors: [error]
12
+ };
13
+ }
14
+ try {
15
+ const funcBody = `
16
+ "use strict";
17
+ ${script}
18
+ return { ${bindings.join(", ")} };
19
+ `;
20
+ const mockContext = {
21
+ ref: (v) => ({ value: v }),
22
+ reactive: (v) => v,
23
+ computed: (fn) => ({ value: fn() }),
24
+ onMounted: () => {
25
+ },
26
+ onUnmounted: () => {
27
+ },
28
+ watch: () => {
29
+ },
30
+ shallowRef: (v) => ({ value: v }),
31
+ nextTick: () => Promise.resolve(),
32
+ toRef: () => ({}),
33
+ toRefs: () => ({}),
34
+ watchEffect: () => {
35
+ },
36
+ readonly: (v) => v,
37
+ h: () => ({})
38
+ };
39
+ const keys = Object.keys(mockContext);
40
+ const values = Object.values(mockContext);
41
+ const runner = new Function(...keys, funcBody);
42
+ const result = runner(...values);
43
+ for (const binding of bindings) {
44
+ if (!(binding in result)) {
45
+ return {
46
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
47
+ passed: false,
48
+ errors: [`\u53D8\u91CF ${binding} \u672A\u6B63\u786E\u5BFC\u51FA`]
49
+ };
50
+ }
51
+ }
52
+ return {
53
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
54
+ passed: true,
55
+ errors: []
56
+ };
57
+ } catch (e) {
58
+ return {
59
+ name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
60
+ passed: false,
61
+ errors: [`JavaScript \u6267\u884C\u9519\u8BEF: ${e.message}`]
62
+ };
63
+ }
64
+ }
65
+
66
+ export { validateRuntimePrecheck };
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,29 @@
1
+ interface ValidationLayer {
2
+ name: string;
3
+ passed: boolean;
4
+ errors: string[];
5
+ }
6
+ interface UnifiedValidationResult {
7
+ passed: boolean;
8
+ layers: {
9
+ compilation: ValidationLayer;
10
+ ast: ValidationLayer;
11
+ runtime: ValidationLayer;
12
+ };
13
+ summary: string;
14
+ }
15
+ /**
16
+ * 统一验证入口
17
+ */
18
+ declare function validateCode(code: string): Promise<UnifiedValidationResult>;
19
+ /**
20
+ * 同步版本(不包含 AST 检查)
21
+ */
22
+ declare function validateCodeSync(code: string): Omit<UnifiedValidationResult, 'layers'> & {
23
+ layers: {
24
+ compilation: ValidationLayer;
25
+ runtime: ValidationLayer;
26
+ };
27
+ };
28
+
29
+ export { type UnifiedValidationResult, type ValidationLayer, validateCode, validateCodeSync };
@@ -0,0 +1,29 @@
1
+ interface ValidationLayer {
2
+ name: string;
3
+ passed: boolean;
4
+ errors: string[];
5
+ }
6
+ interface UnifiedValidationResult {
7
+ passed: boolean;
8
+ layers: {
9
+ compilation: ValidationLayer;
10
+ ast: ValidationLayer;
11
+ runtime: ValidationLayer;
12
+ };
13
+ summary: string;
14
+ }
15
+ /**
16
+ * 统一验证入口
17
+ */
18
+ declare function validateCode(code: string): Promise<UnifiedValidationResult>;
19
+ /**
20
+ * 同步版本(不包含 AST 检查)
21
+ */
22
+ declare function validateCodeSync(code: string): Omit<UnifiedValidationResult, 'layers'> & {
23
+ layers: {
24
+ compilation: ValidationLayer;
25
+ runtime: ValidationLayer;
26
+ };
27
+ };
28
+
29
+ export { type UnifiedValidationResult, type ValidationLayer, validateCode, validateCodeSync };
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var chunkARWRNWDW_js = require('../chunk-ARWRNWDW.js');
4
+ require('../chunk-5IF32MBB.js');
5
+ require('../chunk-GNVCC37B.js');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "validateCode", {
10
+ enumerable: true,
11
+ get: function () { return chunkARWRNWDW_js.validateCode; }
12
+ });
13
+ Object.defineProperty(exports, "validateCodeSync", {
14
+ enumerable: true,
15
+ get: function () { return chunkARWRNWDW_js.validateCodeSync; }
16
+ });
@@ -0,0 +1,3 @@
1
+ export { validateCode, validateCodeSync } from '../chunk-RAMIBZAU.mjs';
2
+ import '../chunk-C3L4IXJC.mjs';
3
+ import '../chunk-TB6BF5TJ.mjs';
@@ -0,0 +1,5 @@
1
+ export { ValidationLayer as StaticValidationLayer, validateCompilation } from './static/index.mjs';
2
+ export { ComponentEvent, ComponentMetadata, ComponentProp, ComponentSlot, MistakeEntry, RuleViolation, analyzeCodeWithAST, componentRegistry } from './ast/index.mjs';
3
+ export { ValidationLayer as RuntimeValidationLayer, validateRuntimePrecheck } from './runtime/index.mjs';
4
+ export { UnifiedValidationResult, ValidationLayer, validateCode, validateCodeSync } from './full/index.mjs';
5
+ export { C as CompilationResult, c as compileSFC, s as scopeStyles } from './sfcCompiler-m51JOfWs.mjs';
@@ -0,0 +1,5 @@
1
+ export { ValidationLayer as StaticValidationLayer, validateCompilation } from './static/index.js';
2
+ export { ComponentEvent, ComponentMetadata, ComponentProp, ComponentSlot, MistakeEntry, RuleViolation, analyzeCodeWithAST, componentRegistry } from './ast/index.js';
3
+ export { ValidationLayer as RuntimeValidationLayer, validateRuntimePrecheck } from './runtime/index.js';
4
+ export { UnifiedValidationResult, ValidationLayer, validateCode, validateCodeSync } from './full/index.js';
5
+ export { C as CompilationResult, c as compileSFC, s as scopeStyles } from './sfcCompiler-m51JOfWs.js';
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ var chunkRNQHI7YG_js = require('./chunk-RNQHI7YG.js');
4
+ require('./chunk-YTEYDSDW.js');
5
+ var chunkN4UIA6DN_js = require('./chunk-N4UIA6DN.js');
6
+ var chunkARWRNWDW_js = require('./chunk-ARWRNWDW.js');
7
+ var chunk5IF32MBB_js = require('./chunk-5IF32MBB.js');
8
+ var chunkGNVCC37B_js = require('./chunk-GNVCC37B.js');
9
+
10
+
11
+
12
+ Object.defineProperty(exports, "validateCompilation", {
13
+ enumerable: true,
14
+ get: function () { return chunkRNQHI7YG_js.validateCompilation; }
15
+ });
16
+ Object.defineProperty(exports, "validateRuntimePrecheck", {
17
+ enumerable: true,
18
+ get: function () { return chunkN4UIA6DN_js.validateRuntimePrecheck; }
19
+ });
20
+ Object.defineProperty(exports, "validateCode", {
21
+ enumerable: true,
22
+ get: function () { return chunkARWRNWDW_js.validateCode; }
23
+ });
24
+ Object.defineProperty(exports, "validateCodeSync", {
25
+ enumerable: true,
26
+ get: function () { return chunkARWRNWDW_js.validateCodeSync; }
27
+ });
28
+ Object.defineProperty(exports, "analyzeCodeWithAST", {
29
+ enumerable: true,
30
+ get: function () { return chunk5IF32MBB_js.analyzeCodeWithAST; }
31
+ });
32
+ Object.defineProperty(exports, "componentRegistry", {
33
+ enumerable: true,
34
+ get: function () { return chunk5IF32MBB_js.componentRegistry; }
35
+ });
36
+ Object.defineProperty(exports, "compileSFC", {
37
+ enumerable: true,
38
+ get: function () { return chunkGNVCC37B_js.compileSFC; }
39
+ });
40
+ Object.defineProperty(exports, "scopeStyles", {
41
+ enumerable: true,
42
+ get: function () { return chunkGNVCC37B_js.scopeStyles; }
43
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ export { validateCompilation } from './chunk-4BUGNH4F.mjs';
2
+ import './chunk-5H7N2A5X.mjs';
3
+ export { validateRuntimePrecheck } from './chunk-UX7KGX45.mjs';
4
+ export { validateCode, validateCodeSync } from './chunk-RAMIBZAU.mjs';
5
+ export { analyzeCodeWithAST, componentRegistry } from './chunk-C3L4IXJC.mjs';
6
+ export { compileSFC, scopeStyles } from './chunk-TB6BF5TJ.mjs';
@@ -0,0 +1,14 @@
1
+ export { C as CompilationResult, c as compileSFC } from '../sfcCompiler-m51JOfWs.mjs';
2
+
3
+ interface ValidationLayer {
4
+ name: string;
5
+ passed: boolean;
6
+ errors: string[];
7
+ }
8
+ /**
9
+ * 运行时预检查 (模拟执行)
10
+ * 验证脚本是否能正确解析和执行
11
+ */
12
+ declare function validateRuntimePrecheck(code: string): ValidationLayer;
13
+
14
+ export { type ValidationLayer, validateRuntimePrecheck };