king-design-analyzer 2.2.1 → 2.2.3
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/components/aside.json +100 -0
- package/components/body.json +43 -0
- package/components/dropdown.json +9 -0
- package/components/footer.json +40 -0
- package/components/layout.json +53 -0
- package/components/layoutheader.json +113 -0
- package/components/popover.json +23 -0
- package/components/select.json +9 -0
- package/components/spinner.json +5 -1
- package/components/tour.json +16 -0
- package/components/transfer.json +11 -0
- package/components/upload.json +16 -0
- package/components/virtuallist.json +9 -0
- package/dist/ast/index.d.mts +7 -2
- package/dist/ast/index.d.ts +7 -2
- package/dist/ast/index.js +3 -3
- package/dist/ast/index.mjs +1 -1
- package/dist/{chunk-4WXOYU2N.js → chunk-7CSMAJZ2.js} +2 -2
- package/dist/{chunk-IPJJMPOO.mjs → chunk-7YBUXYUI.mjs} +75 -42
- package/dist/{chunk-JNRGUR3O.js → chunk-K6UQSWLC.js} +75 -42
- package/dist/{chunk-LRTDTFFQ.mjs → chunk-RJQMTGRE.mjs} +1 -1
- package/dist/full/index.js +4 -4
- package/dist/full/index.mjs +2 -2
- package/dist/index.js +6 -6
- package/dist/index.mjs +2 -2
- package/docs_for_llm/aside.doc.md +62 -0
- package/docs_for_llm/body.doc.md +44 -0
- package/docs_for_llm/dropdown.doc.md +17 -0
- package/docs_for_llm/footer.doc.md +46 -0
- package/docs_for_llm/layout-header.doc.md +61 -0
- package/docs_for_llm/layout.doc.md +53 -0
- package/docs_for_llm/popover.doc.md +34 -0
- package/docs_for_llm/select.doc.md +15 -0
- package/docs_for_llm/tour.doc.md +24 -0
- package/docs_for_llm/transfer.doc.md +1 -0
- package/docs_for_llm/upload.doc.md +21 -0
- package/docs_for_llm/virtuallist.doc.md +14 -0
- package/package.json +1 -1
|
@@ -32208,6 +32208,11 @@ var require_compiler_core = __commonJS({
|
|
|
32208
32208
|
function resolveComponentsPath() {
|
|
32209
32209
|
return resolvePackageResourceDir("components");
|
|
32210
32210
|
}
|
|
32211
|
+
function extractImportSource(importStatement) {
|
|
32212
|
+
if (!importStatement) return void 0;
|
|
32213
|
+
const match = importStatement.match(/from\s+['"]([^'"]+)['"]/);
|
|
32214
|
+
return match?.[1];
|
|
32215
|
+
}
|
|
32211
32216
|
var ComponentRegistry = class {
|
|
32212
32217
|
constructor() {
|
|
32213
32218
|
this.components = /* @__PURE__ */ new Map();
|
|
@@ -32237,16 +32242,25 @@ var ComponentRegistry = class {
|
|
|
32237
32242
|
if (!file.endsWith(".json")) continue;
|
|
32238
32243
|
const content = await fs.readFile(path.join(this.metadataPath, file), "utf-8");
|
|
32239
32244
|
const data = JSON.parse(content);
|
|
32240
|
-
|
|
32245
|
+
const importSource = data.importSource || data.source || extractImportSource(data.importStatement);
|
|
32246
|
+
const normalizedData = {
|
|
32247
|
+
...data,
|
|
32248
|
+
fileName: data.fileName || file.replace(/\.json$/, ""),
|
|
32249
|
+
importSource,
|
|
32250
|
+
source: data.source || importSource
|
|
32251
|
+
};
|
|
32252
|
+
rawComponents[`${normalizedData.fileName}:${normalizedData.name}:${normalizedData.importSource || ""}`] = normalizedData;
|
|
32241
32253
|
}
|
|
32242
32254
|
for (const data of Object.values(rawComponents)) {
|
|
32243
32255
|
const resolvedData = resolveMetadataInheritance(data, rawComponents);
|
|
32244
|
-
|
|
32256
|
+
this.appendComponent(newComponents, resolvedData);
|
|
32245
32257
|
if (resolvedData.subComponents) {
|
|
32246
32258
|
for (const sub of resolvedData.subComponents) {
|
|
32247
|
-
|
|
32259
|
+
this.appendComponent(newComponents, {
|
|
32248
32260
|
id: sub.name,
|
|
32249
32261
|
name: sub.name,
|
|
32262
|
+
source: resolvedData.source,
|
|
32263
|
+
importSource: resolvedData.importSource,
|
|
32250
32264
|
props: sub.props || [],
|
|
32251
32265
|
events: sub.events || [],
|
|
32252
32266
|
slots: sub.slots || [],
|
|
@@ -32256,11 +32270,17 @@ var ComponentRegistry = class {
|
|
|
32256
32270
|
}
|
|
32257
32271
|
}
|
|
32258
32272
|
this.components = newComponents;
|
|
32259
|
-
|
|
32273
|
+
const totalEntries = Array.from(this.components.values()).reduce((sum, items) => sum + items.length, 0);
|
|
32274
|
+
console.log(`[ComponentRegistry] ${this.loaded ? "Reloaded" : "Loaded"} ${totalEntries} components.`);
|
|
32260
32275
|
} catch (error) {
|
|
32261
32276
|
console.error("[ComponentRegistry] Failed to load metadata:", error);
|
|
32262
32277
|
}
|
|
32263
32278
|
}
|
|
32279
|
+
appendComponent(target, metadata) {
|
|
32280
|
+
const current = target.get(metadata.name) || [];
|
|
32281
|
+
current.push(metadata);
|
|
32282
|
+
target.set(metadata.name, current);
|
|
32283
|
+
}
|
|
32264
32284
|
/**
|
|
32265
32285
|
* 开始监听文件变化
|
|
32266
32286
|
*/
|
|
@@ -32293,14 +32313,28 @@ var ComponentRegistry = class {
|
|
|
32293
32313
|
console.log("[ComponentRegistry] Hot reload disabled.");
|
|
32294
32314
|
}
|
|
32295
32315
|
}
|
|
32296
|
-
getComponent(name) {
|
|
32297
|
-
|
|
32316
|
+
getComponent(name, importSource) {
|
|
32317
|
+
const candidates = this.components.get(name) || [];
|
|
32318
|
+
if (!importSource) return candidates[0];
|
|
32319
|
+
return candidates.find((item) => {
|
|
32320
|
+
const expectedSource = item.importSource || item.source || extractImportSource(item.importStatement);
|
|
32321
|
+
return expectedSource === importSource;
|
|
32322
|
+
}) || candidates[0];
|
|
32323
|
+
}
|
|
32324
|
+
getComponents(name) {
|
|
32325
|
+
return this.components.get(name) || [];
|
|
32298
32326
|
}
|
|
32299
32327
|
getAllComponentNames() {
|
|
32300
32328
|
return Array.from(this.components.keys());
|
|
32301
32329
|
}
|
|
32302
|
-
isKnownComponent(name) {
|
|
32303
|
-
|
|
32330
|
+
isKnownComponent(name, importSource) {
|
|
32331
|
+
if (!importSource) {
|
|
32332
|
+
return this.components.has(name);
|
|
32333
|
+
}
|
|
32334
|
+
return this.getComponents(name).some((item) => {
|
|
32335
|
+
const expectedSource = item.importSource || item.source || extractImportSource(item.importStatement);
|
|
32336
|
+
return expectedSource === importSource;
|
|
32337
|
+
});
|
|
32304
32338
|
}
|
|
32305
32339
|
};
|
|
32306
32340
|
var componentRegistry = new ComponentRegistry();
|
|
@@ -32744,6 +32778,7 @@ async function analyzeCodeWithAST(code) {
|
|
|
32744
32778
|
await componentRegistry.load();
|
|
32745
32779
|
await hooksRegistry.load();
|
|
32746
32780
|
const violations = [];
|
|
32781
|
+
const componentImportContext = /* @__PURE__ */ new Map();
|
|
32747
32782
|
const { descriptor, errors } = parse(code);
|
|
32748
32783
|
if (errors.length > 0) {
|
|
32749
32784
|
return violations;
|
|
@@ -32758,12 +32793,12 @@ async function analyzeCodeWithAST(code) {
|
|
|
32758
32793
|
);
|
|
32759
32794
|
ts.forEachChild(sourceFile, (node) => {
|
|
32760
32795
|
if (ts.isImportDeclaration(node)) {
|
|
32761
|
-
checkImport(node, violations, sourceFile);
|
|
32796
|
+
checkImport(node, violations, sourceFile, componentImportContext);
|
|
32762
32797
|
}
|
|
32763
32798
|
});
|
|
32764
32799
|
}
|
|
32765
32800
|
if (descriptor.template?.ast) {
|
|
32766
|
-
checkTemplate(descriptor.template.ast, violations, []);
|
|
32801
|
+
checkTemplate(descriptor.template.ast, violations, [], componentImportContext);
|
|
32767
32802
|
}
|
|
32768
32803
|
if (scriptContent && descriptor.template) {
|
|
32769
32804
|
const scriptBindings = extractScriptBindings(scriptContent);
|
|
@@ -32980,6 +33015,7 @@ function isJsKeyword(id) {
|
|
|
32980
33015
|
return JS_KEYWORDS.has(id);
|
|
32981
33016
|
}
|
|
32982
33017
|
function resolveExpectedImportSource(metadata) {
|
|
33018
|
+
if (metadata.importSource) return metadata.importSource;
|
|
32983
33019
|
const importStatement = metadata.importStatement || "";
|
|
32984
33020
|
if (importStatement.includes("@ksyun-internal/versatile")) {
|
|
32985
33021
|
return "@ksyun-internal/versatile";
|
|
@@ -32989,7 +33025,7 @@ function resolveExpectedImportSource(metadata) {
|
|
|
32989
33025
|
}
|
|
32990
33026
|
return null;
|
|
32991
33027
|
}
|
|
32992
|
-
function checkImport(node, violations, sourceFile) {
|
|
33028
|
+
function checkImport(node, violations, sourceFile, componentImportContext) {
|
|
32993
33029
|
const moduleSpecifier = node.moduleSpecifier.getText(sourceFile).replace(/['\"]/g, "");
|
|
32994
33030
|
if (moduleSpecifier === "@king-design/vue" || moduleSpecifier === "@ksyun-internal/versatile") {
|
|
32995
33031
|
const namedBindings = node.importClause?.namedBindings;
|
|
@@ -33032,7 +33068,8 @@ function checkImport(node, violations, sourceFile) {
|
|
|
33032
33068
|
suggestion: `\u76F4\u63A5\u4F7F\u7528\u539F\u540D: import { ${originalName} } from '${moduleSpecifier}'`
|
|
33033
33069
|
});
|
|
33034
33070
|
}
|
|
33035
|
-
|
|
33071
|
+
componentImportContext.set(localName, moduleSpecifier);
|
|
33072
|
+
const metadata = componentRegistry.getComponent(originalName, moduleSpecifier);
|
|
33036
33073
|
if (metadata) {
|
|
33037
33074
|
const expectedPackage = resolveExpectedImportSource(metadata);
|
|
33038
33075
|
if (expectedPackage && expectedPackage !== moduleSpecifier) {
|
|
@@ -33043,11 +33080,21 @@ function checkImport(node, violations, sourceFile) {
|
|
|
33043
33080
|
});
|
|
33044
33081
|
}
|
|
33045
33082
|
} else {
|
|
33046
|
-
|
|
33047
|
-
|
|
33048
|
-
|
|
33049
|
-
|
|
33050
|
-
|
|
33083
|
+
const knownMetadata = componentRegistry.getComponent(originalName);
|
|
33084
|
+
if (knownMetadata) {
|
|
33085
|
+
const expectedPackage = resolveExpectedImportSource(knownMetadata);
|
|
33086
|
+
violations.push({
|
|
33087
|
+
rule: `\u7EC4\u4EF6 ${originalName} \u5BFC\u5165\u6E90\u9519\u8BEF`,
|
|
33088
|
+
match: `import { ... } from '${moduleSpecifier}'`,
|
|
33089
|
+
suggestion: expectedPackage ? `\u5E94\u4ECE '${expectedPackage}' \u5BFC\u5165` : `\u8BF7\u786E\u8BA4 ${originalName} \u7684\u5BFC\u5165\u6765\u6E90`
|
|
33090
|
+
});
|
|
33091
|
+
} else {
|
|
33092
|
+
violations.push({
|
|
33093
|
+
rule: "\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u7EC4\u4EF6/\u5BFC\u51FA",
|
|
33094
|
+
match: originalName,
|
|
33095
|
+
suggestion: `\u8BF7\u786E\u8BA4 ${originalName} \u662F\u5426\u5B58\u5728\u4E8E ${moduleSpecifier}\u3002\u5EFA\u8BAE\u67E5\u770B\u6587\u6863\u3002`
|
|
33096
|
+
});
|
|
33097
|
+
}
|
|
33051
33098
|
}
|
|
33052
33099
|
});
|
|
33053
33100
|
}
|
|
@@ -33068,22 +33115,6 @@ function checkNestingRules(tagName, metadata, ancestors, violations) {
|
|
|
33068
33115
|
}
|
|
33069
33116
|
}
|
|
33070
33117
|
function checkComponentSpecificRules(tagName, node, metadata, violations) {
|
|
33071
|
-
if (tagName === "Dropdown") {
|
|
33072
|
-
node.children?.forEach((child) => {
|
|
33073
|
-
if (child.type === 1 && child.tag === "template") {
|
|
33074
|
-
const slotProp = child.props?.find(
|
|
33075
|
-
(p) => p.type === 7 && p.name === "slot" && p.arg?.content === "menu"
|
|
33076
|
-
);
|
|
33077
|
-
if (slotProp) {
|
|
33078
|
-
violations.push({
|
|
33079
|
-
rule: "DropdownMenu \u4E0D\u80FD\u653E\u5728 #menu \u63D2\u69FD\u4E2D",
|
|
33080
|
-
match: "<template #menu>",
|
|
33081
|
-
suggestion: "\u8BF7\u79FB\u9664 <template #menu>\uFF0C\u5C06 DropdownMenu \u76F4\u63A5\u4F5C\u4E3A Dropdown \u7684\u7B2C\u4E8C\u4E2A\u5B50\u5143\u7D20"
|
|
33082
|
-
});
|
|
33083
|
-
}
|
|
33084
|
-
}
|
|
33085
|
-
});
|
|
33086
|
-
}
|
|
33087
33118
|
if (tagName === "Table") {
|
|
33088
33119
|
node.props.forEach((prop) => {
|
|
33089
33120
|
if (prop.type === 6 && (prop.name === "rowKey" || prop.name === "row-key")) {
|
|
@@ -33312,14 +33343,16 @@ function checkEvents(tagName, node, metadata, violations) {
|
|
|
33312
33343
|
function kebabTagToPascalTag(tag) {
|
|
33313
33344
|
return tag.split("-").map((part) => part.length ? part.charAt(0).toUpperCase() + part.slice(1).toLowerCase() : "").join("");
|
|
33314
33345
|
}
|
|
33315
|
-
function resolveRegisteredComponent(tag) {
|
|
33316
|
-
|
|
33317
|
-
|
|
33346
|
+
function resolveRegisteredComponent(tag, componentImportContext) {
|
|
33347
|
+
const directImportSource = componentImportContext?.get(tag);
|
|
33348
|
+
if (componentRegistry.isKnownComponent(tag, directImportSource)) {
|
|
33349
|
+
return componentRegistry.getComponent(tag, directImportSource);
|
|
33318
33350
|
}
|
|
33319
33351
|
if (tag.includes("-")) {
|
|
33320
33352
|
const pascal = kebabTagToPascalTag(tag);
|
|
33321
|
-
|
|
33322
|
-
|
|
33353
|
+
const pascalImportSource = componentImportContext?.get(pascal);
|
|
33354
|
+
if (componentRegistry.isKnownComponent(pascal, pascalImportSource)) {
|
|
33355
|
+
return componentRegistry.getComponent(pascal, pascalImportSource);
|
|
33323
33356
|
}
|
|
33324
33357
|
}
|
|
33325
33358
|
return void 0;
|
|
@@ -33366,11 +33399,11 @@ function checkSlots(tagName, node, metadata, violations) {
|
|
|
33366
33399
|
});
|
|
33367
33400
|
}
|
|
33368
33401
|
}
|
|
33369
|
-
function checkTemplate(node, violations, ancestors) {
|
|
33402
|
+
function checkTemplate(node, violations, ancestors, componentImportContext) {
|
|
33370
33403
|
if (node.type === 1) {
|
|
33371
33404
|
const elementNode = node;
|
|
33372
33405
|
const tagName = elementNode.tag;
|
|
33373
|
-
const metadata = resolveRegisteredComponent(tagName);
|
|
33406
|
+
const metadata = resolveRegisteredComponent(tagName, componentImportContext);
|
|
33374
33407
|
const displayTag = metadata?.name ?? tagName;
|
|
33375
33408
|
if (metadata) {
|
|
33376
33409
|
checkNestingRules(displayTag, metadata, ancestors, violations);
|
|
@@ -33386,12 +33419,12 @@ function checkTemplate(node, violations, ancestors) {
|
|
|
33386
33419
|
let newAncestors = ancestors;
|
|
33387
33420
|
if (node.type === 1 && "tag" in node) {
|
|
33388
33421
|
const el = node;
|
|
33389
|
-
const meta = resolveRegisteredComponent(el.tag);
|
|
33422
|
+
const meta = resolveRegisteredComponent(el.tag, componentImportContext);
|
|
33390
33423
|
newAncestors = [...ancestors, meta?.name ?? el.tag];
|
|
33391
33424
|
}
|
|
33392
33425
|
node.children.forEach((child) => {
|
|
33393
33426
|
if (typeof child === "object" && child !== null && "type" in child) {
|
|
33394
|
-
checkTemplate(child, violations, newAncestors);
|
|
33427
|
+
checkTemplate(child, violations, newAncestors, componentImportContext);
|
|
33395
33428
|
}
|
|
33396
33429
|
});
|
|
33397
33430
|
}
|
|
@@ -32233,6 +32233,11 @@ var require_compiler_core = chunkJSBRDJBE_js.__commonJS({
|
|
|
32233
32233
|
function resolveComponentsPath() {
|
|
32234
32234
|
return chunkKF5YBEM5_js.resolvePackageResourceDir("components");
|
|
32235
32235
|
}
|
|
32236
|
+
function extractImportSource(importStatement) {
|
|
32237
|
+
if (!importStatement) return void 0;
|
|
32238
|
+
const match = importStatement.match(/from\s+['"]([^'"]+)['"]/);
|
|
32239
|
+
return match?.[1];
|
|
32240
|
+
}
|
|
32236
32241
|
var ComponentRegistry = class {
|
|
32237
32242
|
constructor() {
|
|
32238
32243
|
this.components = /* @__PURE__ */ new Map();
|
|
@@ -32262,16 +32267,25 @@ var ComponentRegistry = class {
|
|
|
32262
32267
|
if (!file.endsWith(".json")) continue;
|
|
32263
32268
|
const content = await fs__namespace.readFile(path__namespace.join(this.metadataPath, file), "utf-8");
|
|
32264
32269
|
const data = JSON.parse(content);
|
|
32265
|
-
|
|
32270
|
+
const importSource = data.importSource || data.source || extractImportSource(data.importStatement);
|
|
32271
|
+
const normalizedData = {
|
|
32272
|
+
...data,
|
|
32273
|
+
fileName: data.fileName || file.replace(/\.json$/, ""),
|
|
32274
|
+
importSource,
|
|
32275
|
+
source: data.source || importSource
|
|
32276
|
+
};
|
|
32277
|
+
rawComponents[`${normalizedData.fileName}:${normalizedData.name}:${normalizedData.importSource || ""}`] = normalizedData;
|
|
32266
32278
|
}
|
|
32267
32279
|
for (const data of Object.values(rawComponents)) {
|
|
32268
32280
|
const resolvedData = chunkKF5YBEM5_js.resolveMetadataInheritance(data, rawComponents);
|
|
32269
|
-
|
|
32281
|
+
this.appendComponent(newComponents, resolvedData);
|
|
32270
32282
|
if (resolvedData.subComponents) {
|
|
32271
32283
|
for (const sub of resolvedData.subComponents) {
|
|
32272
|
-
|
|
32284
|
+
this.appendComponent(newComponents, {
|
|
32273
32285
|
id: sub.name,
|
|
32274
32286
|
name: sub.name,
|
|
32287
|
+
source: resolvedData.source,
|
|
32288
|
+
importSource: resolvedData.importSource,
|
|
32275
32289
|
props: sub.props || [],
|
|
32276
32290
|
events: sub.events || [],
|
|
32277
32291
|
slots: sub.slots || [],
|
|
@@ -32281,11 +32295,17 @@ var ComponentRegistry = class {
|
|
|
32281
32295
|
}
|
|
32282
32296
|
}
|
|
32283
32297
|
this.components = newComponents;
|
|
32284
|
-
|
|
32298
|
+
const totalEntries = Array.from(this.components.values()).reduce((sum, items) => sum + items.length, 0);
|
|
32299
|
+
console.log(`[ComponentRegistry] ${this.loaded ? "Reloaded" : "Loaded"} ${totalEntries} components.`);
|
|
32285
32300
|
} catch (error) {
|
|
32286
32301
|
console.error("[ComponentRegistry] Failed to load metadata:", error);
|
|
32287
32302
|
}
|
|
32288
32303
|
}
|
|
32304
|
+
appendComponent(target, metadata) {
|
|
32305
|
+
const current = target.get(metadata.name) || [];
|
|
32306
|
+
current.push(metadata);
|
|
32307
|
+
target.set(metadata.name, current);
|
|
32308
|
+
}
|
|
32289
32309
|
/**
|
|
32290
32310
|
* 开始监听文件变化
|
|
32291
32311
|
*/
|
|
@@ -32318,14 +32338,28 @@ var ComponentRegistry = class {
|
|
|
32318
32338
|
console.log("[ComponentRegistry] Hot reload disabled.");
|
|
32319
32339
|
}
|
|
32320
32340
|
}
|
|
32321
|
-
getComponent(name) {
|
|
32322
|
-
|
|
32341
|
+
getComponent(name, importSource) {
|
|
32342
|
+
const candidates = this.components.get(name) || [];
|
|
32343
|
+
if (!importSource) return candidates[0];
|
|
32344
|
+
return candidates.find((item) => {
|
|
32345
|
+
const expectedSource = item.importSource || item.source || extractImportSource(item.importStatement);
|
|
32346
|
+
return expectedSource === importSource;
|
|
32347
|
+
}) || candidates[0];
|
|
32348
|
+
}
|
|
32349
|
+
getComponents(name) {
|
|
32350
|
+
return this.components.get(name) || [];
|
|
32323
32351
|
}
|
|
32324
32352
|
getAllComponentNames() {
|
|
32325
32353
|
return Array.from(this.components.keys());
|
|
32326
32354
|
}
|
|
32327
|
-
isKnownComponent(name) {
|
|
32328
|
-
|
|
32355
|
+
isKnownComponent(name, importSource) {
|
|
32356
|
+
if (!importSource) {
|
|
32357
|
+
return this.components.has(name);
|
|
32358
|
+
}
|
|
32359
|
+
return this.getComponents(name).some((item) => {
|
|
32360
|
+
const expectedSource = item.importSource || item.source || extractImportSource(item.importStatement);
|
|
32361
|
+
return expectedSource === importSource;
|
|
32362
|
+
});
|
|
32329
32363
|
}
|
|
32330
32364
|
};
|
|
32331
32365
|
var componentRegistry = new ComponentRegistry();
|
|
@@ -32769,6 +32803,7 @@ async function analyzeCodeWithAST(code) {
|
|
|
32769
32803
|
await componentRegistry.load();
|
|
32770
32804
|
await hooksRegistry.load();
|
|
32771
32805
|
const violations = [];
|
|
32806
|
+
const componentImportContext = /* @__PURE__ */ new Map();
|
|
32772
32807
|
const { descriptor, errors } = compilerSfc.parse(code);
|
|
32773
32808
|
if (errors.length > 0) {
|
|
32774
32809
|
return violations;
|
|
@@ -32783,12 +32818,12 @@ async function analyzeCodeWithAST(code) {
|
|
|
32783
32818
|
);
|
|
32784
32819
|
ts__namespace.forEachChild(sourceFile, (node) => {
|
|
32785
32820
|
if (ts__namespace.isImportDeclaration(node)) {
|
|
32786
|
-
checkImport(node, violations, sourceFile);
|
|
32821
|
+
checkImport(node, violations, sourceFile, componentImportContext);
|
|
32787
32822
|
}
|
|
32788
32823
|
});
|
|
32789
32824
|
}
|
|
32790
32825
|
if (descriptor.template?.ast) {
|
|
32791
|
-
checkTemplate(descriptor.template.ast, violations, []);
|
|
32826
|
+
checkTemplate(descriptor.template.ast, violations, [], componentImportContext);
|
|
32792
32827
|
}
|
|
32793
32828
|
if (scriptContent && descriptor.template) {
|
|
32794
32829
|
const scriptBindings = extractScriptBindings(scriptContent);
|
|
@@ -33005,6 +33040,7 @@ function isJsKeyword(id) {
|
|
|
33005
33040
|
return JS_KEYWORDS.has(id);
|
|
33006
33041
|
}
|
|
33007
33042
|
function resolveExpectedImportSource(metadata) {
|
|
33043
|
+
if (metadata.importSource) return metadata.importSource;
|
|
33008
33044
|
const importStatement = metadata.importStatement || "";
|
|
33009
33045
|
if (importStatement.includes("@ksyun-internal/versatile")) {
|
|
33010
33046
|
return "@ksyun-internal/versatile";
|
|
@@ -33014,7 +33050,7 @@ function resolveExpectedImportSource(metadata) {
|
|
|
33014
33050
|
}
|
|
33015
33051
|
return null;
|
|
33016
33052
|
}
|
|
33017
|
-
function checkImport(node, violations, sourceFile) {
|
|
33053
|
+
function checkImport(node, violations, sourceFile, componentImportContext) {
|
|
33018
33054
|
const moduleSpecifier = node.moduleSpecifier.getText(sourceFile).replace(/['\"]/g, "");
|
|
33019
33055
|
if (moduleSpecifier === "@king-design/vue" || moduleSpecifier === "@ksyun-internal/versatile") {
|
|
33020
33056
|
const namedBindings = node.importClause?.namedBindings;
|
|
@@ -33057,7 +33093,8 @@ function checkImport(node, violations, sourceFile) {
|
|
|
33057
33093
|
suggestion: `\u76F4\u63A5\u4F7F\u7528\u539F\u540D: import { ${originalName} } from '${moduleSpecifier}'`
|
|
33058
33094
|
});
|
|
33059
33095
|
}
|
|
33060
|
-
|
|
33096
|
+
componentImportContext.set(localName, moduleSpecifier);
|
|
33097
|
+
const metadata = componentRegistry.getComponent(originalName, moduleSpecifier);
|
|
33061
33098
|
if (metadata) {
|
|
33062
33099
|
const expectedPackage = resolveExpectedImportSource(metadata);
|
|
33063
33100
|
if (expectedPackage && expectedPackage !== moduleSpecifier) {
|
|
@@ -33068,11 +33105,21 @@ function checkImport(node, violations, sourceFile) {
|
|
|
33068
33105
|
});
|
|
33069
33106
|
}
|
|
33070
33107
|
} else {
|
|
33071
|
-
|
|
33072
|
-
|
|
33073
|
-
|
|
33074
|
-
|
|
33075
|
-
|
|
33108
|
+
const knownMetadata = componentRegistry.getComponent(originalName);
|
|
33109
|
+
if (knownMetadata) {
|
|
33110
|
+
const expectedPackage = resolveExpectedImportSource(knownMetadata);
|
|
33111
|
+
violations.push({
|
|
33112
|
+
rule: `\u7EC4\u4EF6 ${originalName} \u5BFC\u5165\u6E90\u9519\u8BEF`,
|
|
33113
|
+
match: `import { ... } from '${moduleSpecifier}'`,
|
|
33114
|
+
suggestion: expectedPackage ? `\u5E94\u4ECE '${expectedPackage}' \u5BFC\u5165` : `\u8BF7\u786E\u8BA4 ${originalName} \u7684\u5BFC\u5165\u6765\u6E90`
|
|
33115
|
+
});
|
|
33116
|
+
} else {
|
|
33117
|
+
violations.push({
|
|
33118
|
+
rule: "\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684\u7EC4\u4EF6/\u5BFC\u51FA",
|
|
33119
|
+
match: originalName,
|
|
33120
|
+
suggestion: `\u8BF7\u786E\u8BA4 ${originalName} \u662F\u5426\u5B58\u5728\u4E8E ${moduleSpecifier}\u3002\u5EFA\u8BAE\u67E5\u770B\u6587\u6863\u3002`
|
|
33121
|
+
});
|
|
33122
|
+
}
|
|
33076
33123
|
}
|
|
33077
33124
|
});
|
|
33078
33125
|
}
|
|
@@ -33093,22 +33140,6 @@ function checkNestingRules(tagName, metadata, ancestors, violations) {
|
|
|
33093
33140
|
}
|
|
33094
33141
|
}
|
|
33095
33142
|
function checkComponentSpecificRules(tagName, node, metadata, violations) {
|
|
33096
|
-
if (tagName === "Dropdown") {
|
|
33097
|
-
node.children?.forEach((child) => {
|
|
33098
|
-
if (child.type === 1 && child.tag === "template") {
|
|
33099
|
-
const slotProp = child.props?.find(
|
|
33100
|
-
(p) => p.type === 7 && p.name === "slot" && p.arg?.content === "menu"
|
|
33101
|
-
);
|
|
33102
|
-
if (slotProp) {
|
|
33103
|
-
violations.push({
|
|
33104
|
-
rule: "DropdownMenu \u4E0D\u80FD\u653E\u5728 #menu \u63D2\u69FD\u4E2D",
|
|
33105
|
-
match: "<template #menu>",
|
|
33106
|
-
suggestion: "\u8BF7\u79FB\u9664 <template #menu>\uFF0C\u5C06 DropdownMenu \u76F4\u63A5\u4F5C\u4E3A Dropdown \u7684\u7B2C\u4E8C\u4E2A\u5B50\u5143\u7D20"
|
|
33107
|
-
});
|
|
33108
|
-
}
|
|
33109
|
-
}
|
|
33110
|
-
});
|
|
33111
|
-
}
|
|
33112
33143
|
if (tagName === "Table") {
|
|
33113
33144
|
node.props.forEach((prop) => {
|
|
33114
33145
|
if (prop.type === 6 && (prop.name === "rowKey" || prop.name === "row-key")) {
|
|
@@ -33337,14 +33368,16 @@ function checkEvents(tagName, node, metadata, violations) {
|
|
|
33337
33368
|
function kebabTagToPascalTag(tag) {
|
|
33338
33369
|
return tag.split("-").map((part) => part.length ? part.charAt(0).toUpperCase() + part.slice(1).toLowerCase() : "").join("");
|
|
33339
33370
|
}
|
|
33340
|
-
function resolveRegisteredComponent(tag) {
|
|
33341
|
-
|
|
33342
|
-
|
|
33371
|
+
function resolveRegisteredComponent(tag, componentImportContext) {
|
|
33372
|
+
const directImportSource = componentImportContext?.get(tag);
|
|
33373
|
+
if (componentRegistry.isKnownComponent(tag, directImportSource)) {
|
|
33374
|
+
return componentRegistry.getComponent(tag, directImportSource);
|
|
33343
33375
|
}
|
|
33344
33376
|
if (tag.includes("-")) {
|
|
33345
33377
|
const pascal = kebabTagToPascalTag(tag);
|
|
33346
|
-
|
|
33347
|
-
|
|
33378
|
+
const pascalImportSource = componentImportContext?.get(pascal);
|
|
33379
|
+
if (componentRegistry.isKnownComponent(pascal, pascalImportSource)) {
|
|
33380
|
+
return componentRegistry.getComponent(pascal, pascalImportSource);
|
|
33348
33381
|
}
|
|
33349
33382
|
}
|
|
33350
33383
|
return void 0;
|
|
@@ -33391,11 +33424,11 @@ function checkSlots(tagName, node, metadata, violations) {
|
|
|
33391
33424
|
});
|
|
33392
33425
|
}
|
|
33393
33426
|
}
|
|
33394
|
-
function checkTemplate(node, violations, ancestors) {
|
|
33427
|
+
function checkTemplate(node, violations, ancestors, componentImportContext) {
|
|
33395
33428
|
if (node.type === 1) {
|
|
33396
33429
|
const elementNode = node;
|
|
33397
33430
|
const tagName = elementNode.tag;
|
|
33398
|
-
const metadata = resolveRegisteredComponent(tagName);
|
|
33431
|
+
const metadata = resolveRegisteredComponent(tagName, componentImportContext);
|
|
33399
33432
|
const displayTag = metadata?.name ?? tagName;
|
|
33400
33433
|
if (metadata) {
|
|
33401
33434
|
checkNestingRules(displayTag, metadata, ancestors, violations);
|
|
@@ -33411,12 +33444,12 @@ function checkTemplate(node, violations, ancestors) {
|
|
|
33411
33444
|
let newAncestors = ancestors;
|
|
33412
33445
|
if (node.type === 1 && "tag" in node) {
|
|
33413
33446
|
const el = node;
|
|
33414
|
-
const meta = resolveRegisteredComponent(el.tag);
|
|
33447
|
+
const meta = resolveRegisteredComponent(el.tag, componentImportContext);
|
|
33415
33448
|
newAncestors = [...ancestors, meta?.name ?? el.tag];
|
|
33416
33449
|
}
|
|
33417
33450
|
node.children.forEach((child) => {
|
|
33418
33451
|
if (typeof child === "object" && child !== null && "type" in child) {
|
|
33419
|
-
checkTemplate(child, violations, newAncestors);
|
|
33452
|
+
checkTemplate(child, violations, newAncestors, componentImportContext);
|
|
33420
33453
|
}
|
|
33421
33454
|
});
|
|
33422
33455
|
}
|
package/dist/full/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunk7CSMAJZ2_js = require('../chunk-7CSMAJZ2.js');
|
|
4
|
+
require('../chunk-K6UQSWLC.js');
|
|
5
5
|
require('../chunk-V5N65MRP.js');
|
|
6
6
|
require('../chunk-DHLWNT53.js');
|
|
7
7
|
require('../chunk-KF5YBEM5.js');
|
|
@@ -11,9 +11,9 @@ require('../chunk-JSBRDJBE.js');
|
|
|
11
11
|
|
|
12
12
|
Object.defineProperty(exports, "validateCode", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunk7CSMAJZ2_js.validateCode; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "validateCodeSync", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunk7CSMAJZ2_js.validateCodeSync; }
|
|
19
19
|
});
|
package/dist/full/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { validateCode, validateCodeSync } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { validateCode, validateCodeSync } from '../chunk-RJQMTGRE.mjs';
|
|
2
|
+
import '../chunk-7YBUXYUI.mjs';
|
|
3
3
|
import '../chunk-6HOIRUQB.mjs';
|
|
4
4
|
import '../chunk-4OTQAQ6J.mjs';
|
|
5
5
|
import '../chunk-QC6VTSA3.mjs';
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkJJ6AB4ZH_js = require('./chunk-JJ6AB4ZH.js');
|
|
4
4
|
require('./chunk-YTEYDSDW.js');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var chunk7CSMAJZ2_js = require('./chunk-7CSMAJZ2.js');
|
|
6
|
+
var chunkK6UQSWLC_js = require('./chunk-K6UQSWLC.js');
|
|
7
7
|
var chunkV5N65MRP_js = require('./chunk-V5N65MRP.js');
|
|
8
8
|
var chunkDHLWNT53_js = require('./chunk-DHLWNT53.js');
|
|
9
9
|
require('./chunk-KF5YBEM5.js');
|
|
@@ -17,19 +17,19 @@ Object.defineProperty(exports, "validateCompilation", {
|
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "validateCode", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunk7CSMAJZ2_js.validateCode; }
|
|
21
21
|
});
|
|
22
22
|
Object.defineProperty(exports, "validateCodeSync", {
|
|
23
23
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunk7CSMAJZ2_js.validateCodeSync; }
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "analyzeCodeWithAST", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkK6UQSWLC_js.analyzeCodeWithAST; }
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "componentRegistry", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkK6UQSWLC_js.componentRegistry; }
|
|
33
33
|
});
|
|
34
34
|
Object.defineProperty(exports, "validateRuntimePrecheck", {
|
|
35
35
|
enumerable: true,
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { validateCompilation } from './chunk-NZL6T22V.mjs';
|
|
2
2
|
import './chunk-5H7N2A5X.mjs';
|
|
3
|
-
export { validateCode, validateCodeSync } from './chunk-
|
|
4
|
-
export { analyzeCodeWithAST, componentRegistry } from './chunk-
|
|
3
|
+
export { validateCode, validateCodeSync } from './chunk-RJQMTGRE.mjs';
|
|
4
|
+
export { analyzeCodeWithAST, componentRegistry } from './chunk-7YBUXYUI.mjs';
|
|
5
5
|
export { validateRuntimePrecheck } from './chunk-6HOIRUQB.mjs';
|
|
6
6
|
export { compileSFC, scopeStyles } from './chunk-4OTQAQ6J.mjs';
|
|
7
7
|
import './chunk-QC6VTSA3.mjs';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# 侧边栏 (Aside)
|
|
2
|
+
|
|
3
|
+
布局侧边栏组件,适合承载导航菜单或辅助信息区域,可配置固定定位和折叠宽度。
|
|
4
|
+
|
|
5
|
+
## 导入语句
|
|
6
|
+
```typescript
|
|
7
|
+
import { Aside } from '@king-design/vue';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## 属性 (Props)
|
|
11
|
+
| 属性名 | 类型 | 默认值 | 必填 | 说明 | 标签 | 示例 |
|
|
12
|
+
| --- | --- | --- | --- | --- | --- | --- |
|
|
13
|
+
| collapse | `boolean` | `false` | 否 | 是否处于折叠状态。 | - | `<Aside collapse>折叠菜单</Aside>` |
|
|
14
|
+
| fixed | `boolean` | `false` | 否 | 是否固定在页面左侧。 | - | `<Aside fixed>固定侧边栏</Aside>` |
|
|
15
|
+
| theme | `MenuProps['theme']` | `"light"` | 否 | 侧边栏主题,沿用 Menu 组件的主题配置。 | - | `<Aside theme="dark">深色侧边栏</Aside>` |
|
|
16
|
+
| width | `number | string` | `240` | 否 | 侧边栏宽度,支持数字或带单位的字符串。 | - | `<Aside :width="220">自定义宽度</Aside>` |
|
|
17
|
+
| collapsedWidth | `number | string` | `64` | 否 | 折叠状态下的宽度。 | - | `<Aside :collapsedWidth="56" collapse>折叠侧边栏</Aside>` |
|
|
18
|
+
|
|
19
|
+
## 插槽 (Slots)
|
|
20
|
+
| 插槽名 | 说明 | 模板写法 | 示例 |
|
|
21
|
+
| --- | --- | --- | --- |
|
|
22
|
+
| default | 侧边栏内容,通常放置菜单、品牌信息或辅助操作。 | `#default` | `<Aside>
|
|
23
|
+
<Menu>
|
|
24
|
+
<MenuItem key="1">概览</MenuItem>
|
|
25
|
+
</Menu>
|
|
26
|
+
</Aside>` |
|
|
27
|
+
|
|
28
|
+
### 插槽参数说明
|
|
29
|
+
**default**
|
|
30
|
+
|
|
31
|
+
- 参数结构: 无参数
|
|
32
|
+
|
|
33
|
+
## 使用示例
|
|
34
|
+
### 基础侧边栏
|
|
35
|
+
**场景**: 在后台布局中承载主导航菜单。
|
|
36
|
+
|
|
37
|
+
在布局中放置导航菜单。
|
|
38
|
+
|
|
39
|
+
**使用的 API**: 属性: width
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<script setup lang="ts">
|
|
43
|
+
import { Layout, Aside, Body, Menu, MenuItem } from '@king-design/vue';
|
|
44
|
+
</script>
|
|
45
|
+
<template>
|
|
46
|
+
<Layout>
|
|
47
|
+
<Aside :width="220">
|
|
48
|
+
<Menu>
|
|
49
|
+
<MenuItem key="overview">概览</MenuItem>
|
|
50
|
+
<MenuItem key="instance">实例列表</MenuItem>
|
|
51
|
+
</Menu>
|
|
52
|
+
</Aside>
|
|
53
|
+
<Body>
|
|
54
|
+
<div style="padding: 16px;">内容区域</div>
|
|
55
|
+
</Body>
|
|
56
|
+
</Layout>
|
|
57
|
+
</template>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 相关组件
|
|
61
|
+
Layout, Body, Menu
|
|
62
|
+
|