king-design-analyzer 2.2.3 → 2.2.5

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.
@@ -47,6 +47,67 @@
47
47
  ],
48
48
  "usageExample": "<Tag type=\"primary\">主要标签</Tag>"
49
49
  },
50
+ {
51
+ "name": "color",
52
+ "description": "自定义标签颜色,支持预设颜色名和任意字符串色值",
53
+ "type": {
54
+ "raw": "\"default\" | \"primary\" | \"success\" | \"warning\" | \"danger\" | \"purple\" | \"teal\" | \"blue\" | \"yellow\" | string",
55
+ "kind": "union",
56
+ "unionTypes": [
57
+ "default",
58
+ "primary",
59
+ "success",
60
+ "warning",
61
+ "danger",
62
+ "purple",
63
+ "teal",
64
+ "blue",
65
+ "yellow",
66
+ "string"
67
+ ]
68
+ },
69
+ "required": false,
70
+ "default": "undefined",
71
+ "allowedValues": [
72
+ {
73
+ "value": "default",
74
+ "label": "默认灰色标签"
75
+ },
76
+ {
77
+ "value": "primary",
78
+ "label": "主题蓝色标签"
79
+ },
80
+ {
81
+ "value": "success",
82
+ "label": "成功绿色标签"
83
+ },
84
+ {
85
+ "value": "warning",
86
+ "label": "警告橙色标签"
87
+ },
88
+ {
89
+ "value": "danger",
90
+ "label": "危险红色标签"
91
+ },
92
+ {
93
+ "value": "purple",
94
+ "label": "紫色标签"
95
+ },
96
+ {
97
+ "value": "teal",
98
+ "label": "青绿色标签"
99
+ },
100
+ {
101
+ "value": "blue",
102
+ "label": "蓝色标签"
103
+ },
104
+ {
105
+ "value": "yellow",
106
+ "label": "黄色标签"
107
+ }
108
+ ],
109
+ "usageExample": "<Tag color=\"purple\">品牌标签</Tag>"
110
+ },
50
111
  {
51
112
  "name": "closable",
52
113
  "description": "是否可关闭,显示关闭按钮",
package/dist/ast/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  require('../chunk-YTEYDSDW.js');
4
- var chunkK6UQSWLC_js = require('../chunk-K6UQSWLC.js');
4
+ var chunk4ZZ6E4RS_js = require('../chunk-4ZZ6E4RS.js');
5
5
  require('../chunk-KF5YBEM5.js');
6
6
  require('../chunk-JSBRDJBE.js');
7
7
 
@@ -9,9 +9,9 @@ require('../chunk-JSBRDJBE.js');
9
9
 
10
10
  Object.defineProperty(exports, "analyzeCodeWithAST", {
11
11
  enumerable: true,
12
- get: function () { return chunkK6UQSWLC_js.analyzeCodeWithAST; }
12
+ get: function () { return chunk4ZZ6E4RS_js.analyzeCodeWithAST; }
13
13
  });
14
14
  Object.defineProperty(exports, "componentRegistry", {
15
15
  enumerable: true,
16
- get: function () { return chunkK6UQSWLC_js.componentRegistry; }
16
+ get: function () { return chunk4ZZ6E4RS_js.componentRegistry; }
17
17
  });
@@ -1,4 +1,4 @@
1
1
  import '../chunk-5H7N2A5X.mjs';
2
- export { analyzeCodeWithAST, componentRegistry } from '../chunk-7YBUXYUI.mjs';
2
+ export { analyzeCodeWithAST, componentRegistry } from '../chunk-ZW3HD2OD.mjs';
3
3
  import '../chunk-QC6VTSA3.mjs';
4
4
  import '../chunk-UJCSKKID.mjs';
@@ -3,10 +3,10 @@
3
3
  var chunkKF5YBEM5_js = require('./chunk-KF5YBEM5.js');
4
4
  var chunkJSBRDJBE_js = require('./chunk-JSBRDJBE.js');
5
5
  var fs = require('fs/promises');
6
- var fsSync = require('fs');
7
- var path = require('path');
6
+ var fs3 = require('fs');
7
+ var path3 = require('path');
8
8
  var compilerSfc = require('@vue/compiler-sfc');
9
- var ts = require('typescript');
9
+ var ts2 = require('typescript');
10
10
 
11
11
  function _interopNamespace(e) {
12
12
  if (e && e.__esModule) return e;
@@ -27,9 +27,9 @@ function _interopNamespace(e) {
27
27
  }
28
28
 
29
29
  var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
30
- var fsSync__namespace = /*#__PURE__*/_interopNamespace(fsSync);
31
- var path__namespace = /*#__PURE__*/_interopNamespace(path);
32
- var ts__namespace = /*#__PURE__*/_interopNamespace(ts);
30
+ var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
31
+ var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
32
+ var ts2__namespace = /*#__PURE__*/_interopNamespace(ts2);
33
33
 
34
34
  // node_modules/@vue/shared/dist/shared.cjs.prod.js
35
35
  var require_shared_cjs_prod = chunkJSBRDJBE_js.__commonJS({
@@ -16831,27 +16831,27 @@ var require_util = chunkJSBRDJBE_js.__commonJS({
16831
16831
  };
16832
16832
  }
16833
16833
  var normalize = lruMemoize(function normalize2(aPath) {
16834
- var path3 = aPath;
16834
+ var path4 = aPath;
16835
16835
  var url = urlParse(aPath);
16836
16836
  if (url) {
16837
16837
  if (!url.path) {
16838
16838
  return aPath;
16839
16839
  }
16840
- path3 = url.path;
16840
+ path4 = url.path;
16841
16841
  }
16842
- var isAbsolute = exports$1.isAbsolute(path3);
16842
+ var isAbsolute = exports$1.isAbsolute(path4);
16843
16843
  var parts = [];
16844
16844
  var start = 0;
16845
16845
  var i = 0;
16846
16846
  while (true) {
16847
16847
  start = i;
16848
- i = path3.indexOf("/", start);
16848
+ i = path4.indexOf("/", start);
16849
16849
  if (i === -1) {
16850
- parts.push(path3.slice(start));
16850
+ parts.push(path4.slice(start));
16851
16851
  break;
16852
16852
  } else {
16853
- parts.push(path3.slice(start, i));
16854
- while (i < path3.length && path3[i] === "/") {
16853
+ parts.push(path4.slice(start, i));
16854
+ while (i < path4.length && path4[i] === "/") {
16855
16855
  i++;
16856
16856
  }
16857
16857
  }
@@ -16872,18 +16872,18 @@ var require_util = chunkJSBRDJBE_js.__commonJS({
16872
16872
  }
16873
16873
  }
16874
16874
  }
16875
- path3 = parts.join("/");
16876
- if (path3 === "") {
16877
- path3 = isAbsolute ? "/" : ".";
16875
+ path4 = parts.join("/");
16876
+ if (path4 === "") {
16877
+ path4 = isAbsolute ? "/" : ".";
16878
16878
  }
16879
16879
  if (url) {
16880
- url.path = path3;
16880
+ url.path = path4;
16881
16881
  return urlGenerate(url);
16882
16882
  }
16883
- return path3;
16883
+ return path4;
16884
16884
  });
16885
16885
  exports$1.normalize = normalize;
16886
- function join3(aRoot, aPath) {
16886
+ function join4(aRoot, aPath) {
16887
16887
  if (aRoot === "") {
16888
16888
  aRoot = ".";
16889
16889
  }
@@ -16915,7 +16915,7 @@ var require_util = chunkJSBRDJBE_js.__commonJS({
16915
16915
  }
16916
16916
  return joined;
16917
16917
  }
16918
- exports$1.join = join3;
16918
+ exports$1.join = join4;
16919
16919
  exports$1.isAbsolute = function(aPath) {
16920
16920
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
16921
16921
  };
@@ -17129,7 +17129,7 @@ var require_util = chunkJSBRDJBE_js.__commonJS({
17129
17129
  parsed.path = parsed.path.substring(0, index + 1);
17130
17130
  }
17131
17131
  }
17132
- sourceURL = join3(urlGenerate(parsed), sourceURL);
17132
+ sourceURL = join4(urlGenerate(parsed), sourceURL);
17133
17133
  }
17134
17134
  return normalize(sourceURL);
17135
17135
  }
@@ -20517,14 +20517,14 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
20517
20517
  var whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
20518
20518
  var getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
20519
20519
  var isMemberExpressionBrowser = (exp) => {
20520
- const path3 = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
20520
+ const path4 = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
20521
20521
  let state = 0;
20522
20522
  let stateStack = [];
20523
20523
  let currentOpenBracketCount = 0;
20524
20524
  let currentOpenParensCount = 0;
20525
20525
  let currentStringType = null;
20526
- for (let i = 0; i < path3.length; i++) {
20527
- const char = path3.charAt(i);
20526
+ for (let i = 0; i < path4.length; i++) {
20527
+ const char = path4.charAt(i);
20528
20528
  switch (state) {
20529
20529
  case 0:
20530
20530
  if (char === "[") {
@@ -20560,7 +20560,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
20560
20560
  } else if (char === `(`) {
20561
20561
  currentOpenParensCount++;
20562
20562
  } else if (char === `)`) {
20563
- if (i === path3.length - 1) {
20563
+ if (i === path4.length - 1) {
20564
20564
  return false;
20565
20565
  }
20566
20566
  if (!--currentOpenParensCount) {
@@ -27287,14 +27287,14 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
27287
27287
  var whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
27288
27288
  var getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
27289
27289
  var isMemberExpressionBrowser = (exp) => {
27290
- const path3 = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
27290
+ const path4 = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
27291
27291
  let state = 0;
27292
27292
  let stateStack = [];
27293
27293
  let currentOpenBracketCount = 0;
27294
27294
  let currentOpenParensCount = 0;
27295
27295
  let currentStringType = null;
27296
- for (let i = 0; i < path3.length; i++) {
27297
- const char = path3.charAt(i);
27296
+ for (let i = 0; i < path4.length; i++) {
27297
+ const char = path4.charAt(i);
27298
27298
  switch (state) {
27299
27299
  case 0:
27300
27300
  if (char === "[") {
@@ -27330,7 +27330,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
27330
27330
  } else if (char === `(`) {
27331
27331
  currentOpenParensCount++;
27332
27332
  } else if (char === `)`) {
27333
- if (i === path3.length - 1) {
27333
+ if (i === path4.length - 1) {
27334
27334
  return false;
27335
27335
  }
27336
27336
  if (!--currentOpenParensCount) {
@@ -32265,7 +32265,7 @@ var ComponentRegistry = class {
32265
32265
  const files = await fs__namespace.readdir(this.metadataPath);
32266
32266
  for (const file of files) {
32267
32267
  if (!file.endsWith(".json")) continue;
32268
- const content = await fs__namespace.readFile(path__namespace.join(this.metadataPath, file), "utf-8");
32268
+ const content = await fs__namespace.readFile(path3__namespace.join(this.metadataPath, file), "utf-8");
32269
32269
  const data = JSON.parse(content);
32270
32270
  const importSource = data.importSource || data.source || extractImportSource(data.importStatement);
32271
32271
  const normalizedData = {
@@ -32313,7 +32313,7 @@ var ComponentRegistry = class {
32313
32313
  if (this.watcher) return;
32314
32314
  try {
32315
32315
  let reloadTimeout = null;
32316
- this.watcher = fsSync__namespace.watch(this.metadataPath, (eventType, filename) => {
32316
+ this.watcher = fs3__namespace.watch(this.metadataPath, (eventType, filename) => {
32317
32317
  if (!filename?.endsWith(".json")) return;
32318
32318
  console.log(`[ComponentRegistry] Detected change: ${filename} (${eventType})`);
32319
32319
  if (reloadTimeout) {
@@ -32394,7 +32394,7 @@ var HooksRegistry = class {
32394
32394
  const files = await fs__namespace.readdir(this.metadataPath);
32395
32395
  for (const file of files) {
32396
32396
  if (!file.endsWith(".json")) continue;
32397
- const content = await fs__namespace.readFile(path__namespace.join(this.metadataPath, file), "utf-8");
32397
+ const content = await fs__namespace.readFile(path3__namespace.join(this.metadataPath, file), "utf-8");
32398
32398
  const data = JSON.parse(content);
32399
32399
  newHooks.set(data.name, data);
32400
32400
  }
@@ -32415,7 +32415,7 @@ var HooksRegistry = class {
32415
32415
  if (this.watcher) return;
32416
32416
  try {
32417
32417
  let reloadTimeout = null;
32418
- this.watcher = fsSync__namespace.watch(this.metadataPath, (eventType, filename) => {
32418
+ this.watcher = fs3__namespace.watch(this.metadataPath, (eventType, filename) => {
32419
32419
  if (!filename?.endsWith(".json")) return;
32420
32420
  console.log(`[HooksRegistry] Detected change: ${filename} (${eventType})`);
32421
32421
  if (reloadTimeout) {
@@ -32464,6 +32464,104 @@ var HooksRegistry = class {
32464
32464
  }
32465
32465
  };
32466
32466
  var hooksRegistry = new HooksRegistry();
32467
+ function packagePathSegments(moduleSpecifier) {
32468
+ if (moduleSpecifier.startsWith("@")) {
32469
+ return moduleSpecifier.split("/").slice(0, 2);
32470
+ }
32471
+ return [moduleSpecifier.split("/")[0]];
32472
+ }
32473
+ function resolveInstalledPackageDir(moduleSpecifier) {
32474
+ const packageRoot = chunkKF5YBEM5_js.resolvePackageRoot();
32475
+ const segments = packagePathSegments(moduleSpecifier);
32476
+ const cwd = process.cwd();
32477
+ const candidates = [
32478
+ path3__namespace.join(cwd, "node_modules", ...segments),
32479
+ path3__namespace.join(cwd, "web", "node_modules", ...segments),
32480
+ packageRoot ? path3__namespace.join(packageRoot, "node_modules", ...segments) : null,
32481
+ packageRoot ? path3__namespace.join(packageRoot, "web", "node_modules", ...segments) : null
32482
+ ].filter((candidate) => Boolean(candidate));
32483
+ return candidates.find((candidate) => fs3__namespace.existsSync(candidate)) || null;
32484
+ }
32485
+ function resolvePackageTypesEntry(moduleSpecifier) {
32486
+ const packageDir = resolveInstalledPackageDir(moduleSpecifier);
32487
+ if (!packageDir) return null;
32488
+ const packageJsonPath = path3__namespace.join(packageDir, "package.json");
32489
+ if (fs3__namespace.existsSync(packageJsonPath)) {
32490
+ try {
32491
+ const packageJson = JSON.parse(fs3__namespace.readFileSync(packageJsonPath, "utf-8"));
32492
+ const declaredEntry = packageJson.types || packageJson.typings;
32493
+ if (declaredEntry) {
32494
+ const resolved = path3__namespace.join(packageDir, declaredEntry);
32495
+ if (fs3__namespace.existsSync(resolved)) {
32496
+ return resolved;
32497
+ }
32498
+ }
32499
+ } catch {
32500
+ }
32501
+ }
32502
+ const fallbackEntry = path3__namespace.join(packageDir, "index.d.ts");
32503
+ return fs3__namespace.existsSync(fallbackEntry) ? fallbackEntry : null;
32504
+ }
32505
+ function inferExportKind(exportName, declarationFile) {
32506
+ if (!declarationFile) return /^[A-Z]/.test(exportName) ? "component" : "value";
32507
+ const normalizedFile = declarationFile.replace(/\\/g, "/");
32508
+ if (normalizedFile.includes("/components/") && /^[A-Z]/.test(exportName)) {
32509
+ return "component";
32510
+ }
32511
+ return "value";
32512
+ }
32513
+ var PackageExportRegistry = class {
32514
+ constructor() {
32515
+ this.exportsByModule = /* @__PURE__ */ new Map();
32516
+ this.loadedModules = /* @__PURE__ */ new Set();
32517
+ }
32518
+ async load(moduleSpecifier) {
32519
+ if (this.loadedModules.has(moduleSpecifier)) {
32520
+ return;
32521
+ }
32522
+ const entry = resolvePackageTypesEntry(moduleSpecifier);
32523
+ if (!entry) {
32524
+ this.loadedModules.add(moduleSpecifier);
32525
+ this.exportsByModule.set(moduleSpecifier, /* @__PURE__ */ new Map());
32526
+ return;
32527
+ }
32528
+ const program = ts2__namespace.createProgram([entry], {
32529
+ target: ts2__namespace.ScriptTarget.ES2020,
32530
+ module: ts2__namespace.ModuleKind.ESNext,
32531
+ moduleResolution: ts2__namespace.ModuleResolutionKind.NodeJs,
32532
+ skipLibCheck: true
32533
+ });
32534
+ const checker = program.getTypeChecker();
32535
+ const sourceFile = program.getSourceFile(entry);
32536
+ if (!sourceFile) {
32537
+ this.loadedModules.add(moduleSpecifier);
32538
+ this.exportsByModule.set(moduleSpecifier, /* @__PURE__ */ new Map());
32539
+ return;
32540
+ }
32541
+ const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
32542
+ const exportsMap = /* @__PURE__ */ new Map();
32543
+ if (moduleSymbol) {
32544
+ for (const symbol of checker.getExportsOfModule(moduleSymbol)) {
32545
+ const declarationFile = symbol.declarations?.[0]?.getSourceFile().fileName;
32546
+ exportsMap.set(symbol.getName(), {
32547
+ name: symbol.getName(),
32548
+ moduleSpecifier,
32549
+ declarationFile,
32550
+ kind: inferExportKind(symbol.getName(), declarationFile)
32551
+ });
32552
+ }
32553
+ }
32554
+ this.exportsByModule.set(moduleSpecifier, exportsMap);
32555
+ this.loadedModules.add(moduleSpecifier);
32556
+ }
32557
+ getExport(name, moduleSpecifier) {
32558
+ return this.exportsByModule.get(moduleSpecifier)?.get(name);
32559
+ }
32560
+ isKnownExport(name, moduleSpecifier) {
32561
+ return this.exportsByModule.get(moduleSpecifier)?.has(name) || false;
32562
+ }
32563
+ };
32564
+ var packageExportRegistry = new PackageExportRegistry();
32467
32565
 
32468
32566
  // src/analysis/astReviewer.ts
32469
32567
  var VUE_BUILTINS = /* @__PURE__ */ new Set([
@@ -32802,6 +32900,8 @@ var NESTING_RULES = {
32802
32900
  async function analyzeCodeWithAST(code) {
32803
32901
  await componentRegistry.load();
32804
32902
  await hooksRegistry.load();
32903
+ await packageExportRegistry.load("@king-design/vue");
32904
+ await packageExportRegistry.load("@ksyun-internal/versatile");
32805
32905
  const violations = [];
32806
32906
  const componentImportContext = /* @__PURE__ */ new Map();
32807
32907
  const { descriptor, errors } = compilerSfc.parse(code);
@@ -32810,14 +32910,14 @@ async function analyzeCodeWithAST(code) {
32810
32910
  }
32811
32911
  const scriptContent = descriptor.scriptSetup?.content || descriptor.script?.content || "";
32812
32912
  if (scriptContent) {
32813
- const sourceFile = ts__namespace.createSourceFile(
32913
+ const sourceFile = ts2__namespace.createSourceFile(
32814
32914
  "temp.ts",
32815
32915
  scriptContent,
32816
- ts__namespace.ScriptTarget.Latest,
32916
+ ts2__namespace.ScriptTarget.Latest,
32817
32917
  true
32818
32918
  );
32819
- ts__namespace.forEachChild(sourceFile, (node) => {
32820
- if (ts__namespace.isImportDeclaration(node)) {
32919
+ ts2__namespace.forEachChild(sourceFile, (node) => {
32920
+ if (ts2__namespace.isImportDeclaration(node)) {
32821
32921
  checkImport(node, violations, sourceFile, componentImportContext);
32822
32922
  }
32823
32923
  });
@@ -32841,25 +32941,25 @@ function extractScriptBindings(scriptContent) {
32841
32941
  JS_GLOBALS.forEach((b) => bindings.add(b));
32842
32942
  try {
32843
32943
  let extractNames2 = function(name) {
32844
- if (ts__namespace.isIdentifier(name)) {
32944
+ if (ts2__namespace.isIdentifier(name)) {
32845
32945
  bindings.add(name.text);
32846
- } else if (ts__namespace.isObjectBindingPattern(name) || ts__namespace.isArrayBindingPattern(name)) {
32946
+ } else if (ts2__namespace.isObjectBindingPattern(name) || ts2__namespace.isArrayBindingPattern(name)) {
32847
32947
  name.elements.forEach((element) => {
32848
- if (ts__namespace.isBindingElement(element)) {
32948
+ if (ts2__namespace.isBindingElement(element)) {
32849
32949
  extractNames2(element.name);
32850
32950
  }
32851
32951
  });
32852
32952
  }
32853
32953
  }, visit2 = function(node) {
32854
- if (ts__namespace.isVariableStatement(node)) {
32954
+ if (ts2__namespace.isVariableStatement(node)) {
32855
32955
  node.declarationList.declarations.forEach((decl) => extractNames2(decl.name));
32856
- } else if (ts__namespace.isFunctionDeclaration(node) && node.name) {
32956
+ } else if (ts2__namespace.isFunctionDeclaration(node) && node.name) {
32857
32957
  bindings.add(node.name.text);
32858
- } else if (ts__namespace.isClassDeclaration(node) && node.name) {
32958
+ } else if (ts2__namespace.isClassDeclaration(node) && node.name) {
32859
32959
  bindings.add(node.name.text);
32860
- } else if (ts__namespace.isImportDeclaration(node)) {
32960
+ } else if (ts2__namespace.isImportDeclaration(node)) {
32861
32961
  const namedBindings = node.importClause?.namedBindings;
32862
- if (namedBindings && ts__namespace.isNamedImports(namedBindings)) {
32962
+ if (namedBindings && ts2__namespace.isNamedImports(namedBindings)) {
32863
32963
  namedBindings.elements.forEach((element) => {
32864
32964
  bindings.add(element.name.text);
32865
32965
  });
@@ -32870,10 +32970,10 @@ function extractScriptBindings(scriptContent) {
32870
32970
  }
32871
32971
  };
32872
32972
  var extractNames = extractNames2, visit = visit2;
32873
- const sourceFile = ts__namespace.createSourceFile(
32973
+ const sourceFile = ts2__namespace.createSourceFile(
32874
32974
  "temp.ts",
32875
32975
  scriptContent,
32876
- ts__namespace.ScriptTarget.Latest,
32976
+ ts2__namespace.ScriptTarget.Latest,
32877
32977
  true
32878
32978
  );
32879
32979
  sourceFile.statements.forEach(visit2);
@@ -32885,9 +32985,9 @@ function extractScriptBindings(scriptContent) {
32885
32985
  function checkScriptFunctionCalls(scriptContent, bindings, violations) {
32886
32986
  try {
32887
32987
  let visit2 = function(node) {
32888
- if (ts__namespace.isCallExpression(node)) {
32988
+ if (ts2__namespace.isCallExpression(node)) {
32889
32989
  const callee = node.expression;
32890
- if (ts__namespace.isIdentifier(callee)) {
32990
+ if (ts2__namespace.isIdentifier(callee)) {
32891
32991
  const funcName = callee.text;
32892
32992
  const isHookCall = funcName.startsWith("use") && funcName.length > 3 && funcName[3] === funcName[3].toUpperCase();
32893
32993
  if (isHookCall) {
@@ -32901,16 +33001,16 @@ function checkScriptFunctionCalls(scriptContent, bindings, violations) {
32901
33001
  }
32902
33002
  }
32903
33003
  }
32904
- ts__namespace.forEachChild(node, visit2);
33004
+ ts2__namespace.forEachChild(node, visit2);
32905
33005
  };
32906
33006
  var visit = visit2;
32907
- const sourceFile = ts__namespace.createSourceFile(
33007
+ const sourceFile = ts2__namespace.createSourceFile(
32908
33008
  "temp.ts",
32909
33009
  scriptContent,
32910
- ts__namespace.ScriptTarget.Latest,
33010
+ ts2__namespace.ScriptTarget.Latest,
32911
33011
  true
32912
33012
  );
32913
- ts__namespace.forEachChild(sourceFile, visit2);
33013
+ ts2__namespace.forEachChild(sourceFile, visit2);
32914
33014
  } catch (err) {
32915
33015
  }
32916
33016
  }
@@ -33023,7 +33123,7 @@ function extractIdentifiersFromExpression(expression) {
33023
33123
  }
33024
33124
  }
33025
33125
  const cleanExpr = expression.replace(/'[^']*'/g, "").replace(/"[^"]*"/g, "").replace(/`[^`]*`/g, "");
33026
- const idRegex = /(?:^|[^.\w$])([a-zA-Z_$][\w$]*)\b(?!\s*:)/g;
33126
+ const idRegex = /(?:^|[^.\w$])([a-zA-Z_$][\w$]*)(?![\w$])(?!\s*:)/g;
33027
33127
  let match;
33028
33128
  while ((match = idRegex.exec(cleanExpr)) !== null) {
33029
33129
  const id = match[1];
@@ -33054,7 +33154,7 @@ function checkImport(node, violations, sourceFile, componentImportContext) {
33054
33154
  const moduleSpecifier = node.moduleSpecifier.getText(sourceFile).replace(/['\"]/g, "");
33055
33155
  if (moduleSpecifier === "@king-design/vue" || moduleSpecifier === "@ksyun-internal/versatile") {
33056
33156
  const namedBindings = node.importClause?.namedBindings;
33057
- if (namedBindings && ts__namespace.isNamedImports(namedBindings)) {
33157
+ if (namedBindings && ts2__namespace.isNamedImports(namedBindings)) {
33058
33158
  namedBindings.elements.forEach((element) => {
33059
33159
  const originalName = element.propertyName ? element.propertyName.text : element.name.text;
33060
33160
  const localName = element.name.text;
@@ -33086,15 +33186,16 @@ function checkImport(node, violations, sourceFile, componentImportContext) {
33086
33186
  }
33087
33187
  return;
33088
33188
  }
33089
- if (isAlias) {
33189
+ componentImportContext.set(localName, moduleSpecifier);
33190
+ const metadata = componentRegistry.getComponent(originalName, moduleSpecifier);
33191
+ const packageExport = packageExportRegistry.getExport(originalName, moduleSpecifier);
33192
+ if (isAlias && (metadata || packageExport?.kind === "component")) {
33090
33193
  violations.push({
33091
33194
  rule: `\u7981\u6B62\u5BF9\u7EC4\u4EF6 ${originalName} \u4F7F\u7528\u522B\u540D\u5BFC\u5165`,
33092
33195
  match: `${originalName} as ${localName}`,
33093
33196
  suggestion: `\u76F4\u63A5\u4F7F\u7528\u539F\u540D: import { ${originalName} } from '${moduleSpecifier}'`
33094
33197
  });
33095
33198
  }
33096
- componentImportContext.set(localName, moduleSpecifier);
33097
- const metadata = componentRegistry.getComponent(originalName, moduleSpecifier);
33098
33199
  if (metadata) {
33099
33200
  const expectedPackage = resolveExpectedImportSource(metadata);
33100
33201
  if (expectedPackage && expectedPackage !== moduleSpecifier) {
@@ -33105,6 +33206,9 @@ function checkImport(node, violations, sourceFile, componentImportContext) {
33105
33206
  });
33106
33207
  }
33107
33208
  } else {
33209
+ if (packageExport) {
33210
+ return;
33211
+ }
33108
33212
  const knownMetadata = componentRegistry.getComponent(originalName);
33109
33213
  if (knownMetadata) {
33110
33214
  const expectedPackage = resolveExpectedImportSource(knownMetadata);
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkK6UQSWLC_js = require('./chunk-K6UQSWLC.js');
3
+ var chunk4ZZ6E4RS_js = require('./chunk-4ZZ6E4RS.js');
4
4
  var chunkV5N65MRP_js = require('./chunk-V5N65MRP.js');
5
5
  var chunkDHLWNT53_js = require('./chunk-DHLWNT53.js');
6
6
 
@@ -64,7 +64,7 @@ function validateCompilation(code) {
64
64
  }
65
65
  async function validateAST(code) {
66
66
  try {
67
- const violations = await chunkK6UQSWLC_js.analyzeCodeWithAST(code);
67
+ const violations = await chunk4ZZ6E4RS_js.analyzeCodeWithAST(code);
68
68
  if (violations.length > 0) {
69
69
  return {
70
70
  name: "AST\u89C4\u5219\u68C0\u67E5",
@@ -1,4 +1,4 @@
1
- import { analyzeCodeWithAST } from './chunk-7YBUXYUI.mjs';
1
+ import { analyzeCodeWithAST } from './chunk-ZW3HD2OD.mjs';
2
2
  import { validateRuntimePrecheck } from './chunk-6HOIRUQB.mjs';
3
3
  import { compileSFC } from './chunk-4OTQAQ6J.mjs';
4
4
 
@@ -1,10 +1,10 @@
1
- import { resolveMetadataInheritance, resolvePackageResourceDir } from './chunk-QC6VTSA3.mjs';
1
+ import { resolveMetadataInheritance, resolvePackageResourceDir, resolvePackageRoot } from './chunk-QC6VTSA3.mjs';
2
2
  import { __commonJS, __toESM } from './chunk-UJCSKKID.mjs';
3
3
  import * as fs from 'fs/promises';
4
- import * as fsSync from 'fs';
5
- import * as path from 'path';
4
+ import * as fs3 from 'fs';
5
+ import * as path3 from 'path';
6
6
  import { parse } from '@vue/compiler-sfc';
7
- import * as ts from 'typescript';
7
+ import * as ts2 from 'typescript';
8
8
 
9
9
  // node_modules/@vue/shared/dist/shared.cjs.prod.js
10
10
  var require_shared_cjs_prod = __commonJS({
@@ -16806,27 +16806,27 @@ var require_util = __commonJS({
16806
16806
  };
16807
16807
  }
16808
16808
  var normalize = lruMemoize(function normalize2(aPath) {
16809
- var path3 = aPath;
16809
+ var path4 = aPath;
16810
16810
  var url = urlParse(aPath);
16811
16811
  if (url) {
16812
16812
  if (!url.path) {
16813
16813
  return aPath;
16814
16814
  }
16815
- path3 = url.path;
16815
+ path4 = url.path;
16816
16816
  }
16817
- var isAbsolute = exports$1.isAbsolute(path3);
16817
+ var isAbsolute = exports$1.isAbsolute(path4);
16818
16818
  var parts = [];
16819
16819
  var start = 0;
16820
16820
  var i = 0;
16821
16821
  while (true) {
16822
16822
  start = i;
16823
- i = path3.indexOf("/", start);
16823
+ i = path4.indexOf("/", start);
16824
16824
  if (i === -1) {
16825
- parts.push(path3.slice(start));
16825
+ parts.push(path4.slice(start));
16826
16826
  break;
16827
16827
  } else {
16828
- parts.push(path3.slice(start, i));
16829
- while (i < path3.length && path3[i] === "/") {
16828
+ parts.push(path4.slice(start, i));
16829
+ while (i < path4.length && path4[i] === "/") {
16830
16830
  i++;
16831
16831
  }
16832
16832
  }
@@ -16847,18 +16847,18 @@ var require_util = __commonJS({
16847
16847
  }
16848
16848
  }
16849
16849
  }
16850
- path3 = parts.join("/");
16851
- if (path3 === "") {
16852
- path3 = isAbsolute ? "/" : ".";
16850
+ path4 = parts.join("/");
16851
+ if (path4 === "") {
16852
+ path4 = isAbsolute ? "/" : ".";
16853
16853
  }
16854
16854
  if (url) {
16855
- url.path = path3;
16855
+ url.path = path4;
16856
16856
  return urlGenerate(url);
16857
16857
  }
16858
- return path3;
16858
+ return path4;
16859
16859
  });
16860
16860
  exports$1.normalize = normalize;
16861
- function join3(aRoot, aPath) {
16861
+ function join4(aRoot, aPath) {
16862
16862
  if (aRoot === "") {
16863
16863
  aRoot = ".";
16864
16864
  }
@@ -16890,7 +16890,7 @@ var require_util = __commonJS({
16890
16890
  }
16891
16891
  return joined;
16892
16892
  }
16893
- exports$1.join = join3;
16893
+ exports$1.join = join4;
16894
16894
  exports$1.isAbsolute = function(aPath) {
16895
16895
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
16896
16896
  };
@@ -17104,7 +17104,7 @@ var require_util = __commonJS({
17104
17104
  parsed.path = parsed.path.substring(0, index + 1);
17105
17105
  }
17106
17106
  }
17107
- sourceURL = join3(urlGenerate(parsed), sourceURL);
17107
+ sourceURL = join4(urlGenerate(parsed), sourceURL);
17108
17108
  }
17109
17109
  return normalize(sourceURL);
17110
17110
  }
@@ -20492,14 +20492,14 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
20492
20492
  var whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
20493
20493
  var getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
20494
20494
  var isMemberExpressionBrowser = (exp) => {
20495
- const path3 = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
20495
+ const path4 = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
20496
20496
  let state = 0;
20497
20497
  let stateStack = [];
20498
20498
  let currentOpenBracketCount = 0;
20499
20499
  let currentOpenParensCount = 0;
20500
20500
  let currentStringType = null;
20501
- for (let i = 0; i < path3.length; i++) {
20502
- const char = path3.charAt(i);
20501
+ for (let i = 0; i < path4.length; i++) {
20502
+ const char = path4.charAt(i);
20503
20503
  switch (state) {
20504
20504
  case 0:
20505
20505
  if (char === "[") {
@@ -20535,7 +20535,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
20535
20535
  } else if (char === `(`) {
20536
20536
  currentOpenParensCount++;
20537
20537
  } else if (char === `)`) {
20538
- if (i === path3.length - 1) {
20538
+ if (i === path4.length - 1) {
20539
20539
  return false;
20540
20540
  }
20541
20541
  if (!--currentOpenParensCount) {
@@ -27262,14 +27262,14 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
27262
27262
  var whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
27263
27263
  var getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
27264
27264
  var isMemberExpressionBrowser = (exp) => {
27265
- const path3 = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
27265
+ const path4 = getExpSource(exp).trim().replace(whitespaceRE, (s) => s.trim());
27266
27266
  let state = 0;
27267
27267
  let stateStack = [];
27268
27268
  let currentOpenBracketCount = 0;
27269
27269
  let currentOpenParensCount = 0;
27270
27270
  let currentStringType = null;
27271
- for (let i = 0; i < path3.length; i++) {
27272
- const char = path3.charAt(i);
27271
+ for (let i = 0; i < path4.length; i++) {
27272
+ const char = path4.charAt(i);
27273
27273
  switch (state) {
27274
27274
  case 0:
27275
27275
  if (char === "[") {
@@ -27305,7 +27305,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
27305
27305
  } else if (char === `(`) {
27306
27306
  currentOpenParensCount++;
27307
27307
  } else if (char === `)`) {
27308
- if (i === path3.length - 1) {
27308
+ if (i === path4.length - 1) {
27309
27309
  return false;
27310
27310
  }
27311
27311
  if (!--currentOpenParensCount) {
@@ -32240,7 +32240,7 @@ var ComponentRegistry = class {
32240
32240
  const files = await fs.readdir(this.metadataPath);
32241
32241
  for (const file of files) {
32242
32242
  if (!file.endsWith(".json")) continue;
32243
- const content = await fs.readFile(path.join(this.metadataPath, file), "utf-8");
32243
+ const content = await fs.readFile(path3.join(this.metadataPath, file), "utf-8");
32244
32244
  const data = JSON.parse(content);
32245
32245
  const importSource = data.importSource || data.source || extractImportSource(data.importStatement);
32246
32246
  const normalizedData = {
@@ -32288,7 +32288,7 @@ var ComponentRegistry = class {
32288
32288
  if (this.watcher) return;
32289
32289
  try {
32290
32290
  let reloadTimeout = null;
32291
- this.watcher = fsSync.watch(this.metadataPath, (eventType, filename) => {
32291
+ this.watcher = fs3.watch(this.metadataPath, (eventType, filename) => {
32292
32292
  if (!filename?.endsWith(".json")) return;
32293
32293
  console.log(`[ComponentRegistry] Detected change: ${filename} (${eventType})`);
32294
32294
  if (reloadTimeout) {
@@ -32369,7 +32369,7 @@ var HooksRegistry = class {
32369
32369
  const files = await fs.readdir(this.metadataPath);
32370
32370
  for (const file of files) {
32371
32371
  if (!file.endsWith(".json")) continue;
32372
- const content = await fs.readFile(path.join(this.metadataPath, file), "utf-8");
32372
+ const content = await fs.readFile(path3.join(this.metadataPath, file), "utf-8");
32373
32373
  const data = JSON.parse(content);
32374
32374
  newHooks.set(data.name, data);
32375
32375
  }
@@ -32390,7 +32390,7 @@ var HooksRegistry = class {
32390
32390
  if (this.watcher) return;
32391
32391
  try {
32392
32392
  let reloadTimeout = null;
32393
- this.watcher = fsSync.watch(this.metadataPath, (eventType, filename) => {
32393
+ this.watcher = fs3.watch(this.metadataPath, (eventType, filename) => {
32394
32394
  if (!filename?.endsWith(".json")) return;
32395
32395
  console.log(`[HooksRegistry] Detected change: ${filename} (${eventType})`);
32396
32396
  if (reloadTimeout) {
@@ -32439,6 +32439,104 @@ var HooksRegistry = class {
32439
32439
  }
32440
32440
  };
32441
32441
  var hooksRegistry = new HooksRegistry();
32442
+ function packagePathSegments(moduleSpecifier) {
32443
+ if (moduleSpecifier.startsWith("@")) {
32444
+ return moduleSpecifier.split("/").slice(0, 2);
32445
+ }
32446
+ return [moduleSpecifier.split("/")[0]];
32447
+ }
32448
+ function resolveInstalledPackageDir(moduleSpecifier) {
32449
+ const packageRoot = resolvePackageRoot();
32450
+ const segments = packagePathSegments(moduleSpecifier);
32451
+ const cwd = process.cwd();
32452
+ const candidates = [
32453
+ path3.join(cwd, "node_modules", ...segments),
32454
+ path3.join(cwd, "web", "node_modules", ...segments),
32455
+ packageRoot ? path3.join(packageRoot, "node_modules", ...segments) : null,
32456
+ packageRoot ? path3.join(packageRoot, "web", "node_modules", ...segments) : null
32457
+ ].filter((candidate) => Boolean(candidate));
32458
+ return candidates.find((candidate) => fs3.existsSync(candidate)) || null;
32459
+ }
32460
+ function resolvePackageTypesEntry(moduleSpecifier) {
32461
+ const packageDir = resolveInstalledPackageDir(moduleSpecifier);
32462
+ if (!packageDir) return null;
32463
+ const packageJsonPath = path3.join(packageDir, "package.json");
32464
+ if (fs3.existsSync(packageJsonPath)) {
32465
+ try {
32466
+ const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
32467
+ const declaredEntry = packageJson.types || packageJson.typings;
32468
+ if (declaredEntry) {
32469
+ const resolved = path3.join(packageDir, declaredEntry);
32470
+ if (fs3.existsSync(resolved)) {
32471
+ return resolved;
32472
+ }
32473
+ }
32474
+ } catch {
32475
+ }
32476
+ }
32477
+ const fallbackEntry = path3.join(packageDir, "index.d.ts");
32478
+ return fs3.existsSync(fallbackEntry) ? fallbackEntry : null;
32479
+ }
32480
+ function inferExportKind(exportName, declarationFile) {
32481
+ if (!declarationFile) return /^[A-Z]/.test(exportName) ? "component" : "value";
32482
+ const normalizedFile = declarationFile.replace(/\\/g, "/");
32483
+ if (normalizedFile.includes("/components/") && /^[A-Z]/.test(exportName)) {
32484
+ return "component";
32485
+ }
32486
+ return "value";
32487
+ }
32488
+ var PackageExportRegistry = class {
32489
+ constructor() {
32490
+ this.exportsByModule = /* @__PURE__ */ new Map();
32491
+ this.loadedModules = /* @__PURE__ */ new Set();
32492
+ }
32493
+ async load(moduleSpecifier) {
32494
+ if (this.loadedModules.has(moduleSpecifier)) {
32495
+ return;
32496
+ }
32497
+ const entry = resolvePackageTypesEntry(moduleSpecifier);
32498
+ if (!entry) {
32499
+ this.loadedModules.add(moduleSpecifier);
32500
+ this.exportsByModule.set(moduleSpecifier, /* @__PURE__ */ new Map());
32501
+ return;
32502
+ }
32503
+ const program = ts2.createProgram([entry], {
32504
+ target: ts2.ScriptTarget.ES2020,
32505
+ module: ts2.ModuleKind.ESNext,
32506
+ moduleResolution: ts2.ModuleResolutionKind.NodeJs,
32507
+ skipLibCheck: true
32508
+ });
32509
+ const checker = program.getTypeChecker();
32510
+ const sourceFile = program.getSourceFile(entry);
32511
+ if (!sourceFile) {
32512
+ this.loadedModules.add(moduleSpecifier);
32513
+ this.exportsByModule.set(moduleSpecifier, /* @__PURE__ */ new Map());
32514
+ return;
32515
+ }
32516
+ const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
32517
+ const exportsMap = /* @__PURE__ */ new Map();
32518
+ if (moduleSymbol) {
32519
+ for (const symbol of checker.getExportsOfModule(moduleSymbol)) {
32520
+ const declarationFile = symbol.declarations?.[0]?.getSourceFile().fileName;
32521
+ exportsMap.set(symbol.getName(), {
32522
+ name: symbol.getName(),
32523
+ moduleSpecifier,
32524
+ declarationFile,
32525
+ kind: inferExportKind(symbol.getName(), declarationFile)
32526
+ });
32527
+ }
32528
+ }
32529
+ this.exportsByModule.set(moduleSpecifier, exportsMap);
32530
+ this.loadedModules.add(moduleSpecifier);
32531
+ }
32532
+ getExport(name, moduleSpecifier) {
32533
+ return this.exportsByModule.get(moduleSpecifier)?.get(name);
32534
+ }
32535
+ isKnownExport(name, moduleSpecifier) {
32536
+ return this.exportsByModule.get(moduleSpecifier)?.has(name) || false;
32537
+ }
32538
+ };
32539
+ var packageExportRegistry = new PackageExportRegistry();
32442
32540
 
32443
32541
  // src/analysis/astReviewer.ts
32444
32542
  var VUE_BUILTINS = /* @__PURE__ */ new Set([
@@ -32777,6 +32875,8 @@ var NESTING_RULES = {
32777
32875
  async function analyzeCodeWithAST(code) {
32778
32876
  await componentRegistry.load();
32779
32877
  await hooksRegistry.load();
32878
+ await packageExportRegistry.load("@king-design/vue");
32879
+ await packageExportRegistry.load("@ksyun-internal/versatile");
32780
32880
  const violations = [];
32781
32881
  const componentImportContext = /* @__PURE__ */ new Map();
32782
32882
  const { descriptor, errors } = parse(code);
@@ -32785,14 +32885,14 @@ async function analyzeCodeWithAST(code) {
32785
32885
  }
32786
32886
  const scriptContent = descriptor.scriptSetup?.content || descriptor.script?.content || "";
32787
32887
  if (scriptContent) {
32788
- const sourceFile = ts.createSourceFile(
32888
+ const sourceFile = ts2.createSourceFile(
32789
32889
  "temp.ts",
32790
32890
  scriptContent,
32791
- ts.ScriptTarget.Latest,
32891
+ ts2.ScriptTarget.Latest,
32792
32892
  true
32793
32893
  );
32794
- ts.forEachChild(sourceFile, (node) => {
32795
- if (ts.isImportDeclaration(node)) {
32894
+ ts2.forEachChild(sourceFile, (node) => {
32895
+ if (ts2.isImportDeclaration(node)) {
32796
32896
  checkImport(node, violations, sourceFile, componentImportContext);
32797
32897
  }
32798
32898
  });
@@ -32816,25 +32916,25 @@ function extractScriptBindings(scriptContent) {
32816
32916
  JS_GLOBALS.forEach((b) => bindings.add(b));
32817
32917
  try {
32818
32918
  let extractNames2 = function(name) {
32819
- if (ts.isIdentifier(name)) {
32919
+ if (ts2.isIdentifier(name)) {
32820
32920
  bindings.add(name.text);
32821
- } else if (ts.isObjectBindingPattern(name) || ts.isArrayBindingPattern(name)) {
32921
+ } else if (ts2.isObjectBindingPattern(name) || ts2.isArrayBindingPattern(name)) {
32822
32922
  name.elements.forEach((element) => {
32823
- if (ts.isBindingElement(element)) {
32923
+ if (ts2.isBindingElement(element)) {
32824
32924
  extractNames2(element.name);
32825
32925
  }
32826
32926
  });
32827
32927
  }
32828
32928
  }, visit2 = function(node) {
32829
- if (ts.isVariableStatement(node)) {
32929
+ if (ts2.isVariableStatement(node)) {
32830
32930
  node.declarationList.declarations.forEach((decl) => extractNames2(decl.name));
32831
- } else if (ts.isFunctionDeclaration(node) && node.name) {
32931
+ } else if (ts2.isFunctionDeclaration(node) && node.name) {
32832
32932
  bindings.add(node.name.text);
32833
- } else if (ts.isClassDeclaration(node) && node.name) {
32933
+ } else if (ts2.isClassDeclaration(node) && node.name) {
32834
32934
  bindings.add(node.name.text);
32835
- } else if (ts.isImportDeclaration(node)) {
32935
+ } else if (ts2.isImportDeclaration(node)) {
32836
32936
  const namedBindings = node.importClause?.namedBindings;
32837
- if (namedBindings && ts.isNamedImports(namedBindings)) {
32937
+ if (namedBindings && ts2.isNamedImports(namedBindings)) {
32838
32938
  namedBindings.elements.forEach((element) => {
32839
32939
  bindings.add(element.name.text);
32840
32940
  });
@@ -32845,10 +32945,10 @@ function extractScriptBindings(scriptContent) {
32845
32945
  }
32846
32946
  };
32847
32947
  var extractNames = extractNames2, visit = visit2;
32848
- const sourceFile = ts.createSourceFile(
32948
+ const sourceFile = ts2.createSourceFile(
32849
32949
  "temp.ts",
32850
32950
  scriptContent,
32851
- ts.ScriptTarget.Latest,
32951
+ ts2.ScriptTarget.Latest,
32852
32952
  true
32853
32953
  );
32854
32954
  sourceFile.statements.forEach(visit2);
@@ -32860,9 +32960,9 @@ function extractScriptBindings(scriptContent) {
32860
32960
  function checkScriptFunctionCalls(scriptContent, bindings, violations) {
32861
32961
  try {
32862
32962
  let visit2 = function(node) {
32863
- if (ts.isCallExpression(node)) {
32963
+ if (ts2.isCallExpression(node)) {
32864
32964
  const callee = node.expression;
32865
- if (ts.isIdentifier(callee)) {
32965
+ if (ts2.isIdentifier(callee)) {
32866
32966
  const funcName = callee.text;
32867
32967
  const isHookCall = funcName.startsWith("use") && funcName.length > 3 && funcName[3] === funcName[3].toUpperCase();
32868
32968
  if (isHookCall) {
@@ -32876,16 +32976,16 @@ function checkScriptFunctionCalls(scriptContent, bindings, violations) {
32876
32976
  }
32877
32977
  }
32878
32978
  }
32879
- ts.forEachChild(node, visit2);
32979
+ ts2.forEachChild(node, visit2);
32880
32980
  };
32881
32981
  var visit = visit2;
32882
- const sourceFile = ts.createSourceFile(
32982
+ const sourceFile = ts2.createSourceFile(
32883
32983
  "temp.ts",
32884
32984
  scriptContent,
32885
- ts.ScriptTarget.Latest,
32985
+ ts2.ScriptTarget.Latest,
32886
32986
  true
32887
32987
  );
32888
- ts.forEachChild(sourceFile, visit2);
32988
+ ts2.forEachChild(sourceFile, visit2);
32889
32989
  } catch (err) {
32890
32990
  }
32891
32991
  }
@@ -32998,7 +33098,7 @@ function extractIdentifiersFromExpression(expression) {
32998
33098
  }
32999
33099
  }
33000
33100
  const cleanExpr = expression.replace(/'[^']*'/g, "").replace(/"[^"]*"/g, "").replace(/`[^`]*`/g, "");
33001
- const idRegex = /(?:^|[^.\w$])([a-zA-Z_$][\w$]*)\b(?!\s*:)/g;
33101
+ const idRegex = /(?:^|[^.\w$])([a-zA-Z_$][\w$]*)(?![\w$])(?!\s*:)/g;
33002
33102
  let match;
33003
33103
  while ((match = idRegex.exec(cleanExpr)) !== null) {
33004
33104
  const id = match[1];
@@ -33029,7 +33129,7 @@ function checkImport(node, violations, sourceFile, componentImportContext) {
33029
33129
  const moduleSpecifier = node.moduleSpecifier.getText(sourceFile).replace(/['\"]/g, "");
33030
33130
  if (moduleSpecifier === "@king-design/vue" || moduleSpecifier === "@ksyun-internal/versatile") {
33031
33131
  const namedBindings = node.importClause?.namedBindings;
33032
- if (namedBindings && ts.isNamedImports(namedBindings)) {
33132
+ if (namedBindings && ts2.isNamedImports(namedBindings)) {
33033
33133
  namedBindings.elements.forEach((element) => {
33034
33134
  const originalName = element.propertyName ? element.propertyName.text : element.name.text;
33035
33135
  const localName = element.name.text;
@@ -33061,15 +33161,16 @@ function checkImport(node, violations, sourceFile, componentImportContext) {
33061
33161
  }
33062
33162
  return;
33063
33163
  }
33064
- if (isAlias) {
33164
+ componentImportContext.set(localName, moduleSpecifier);
33165
+ const metadata = componentRegistry.getComponent(originalName, moduleSpecifier);
33166
+ const packageExport = packageExportRegistry.getExport(originalName, moduleSpecifier);
33167
+ if (isAlias && (metadata || packageExport?.kind === "component")) {
33065
33168
  violations.push({
33066
33169
  rule: `\u7981\u6B62\u5BF9\u7EC4\u4EF6 ${originalName} \u4F7F\u7528\u522B\u540D\u5BFC\u5165`,
33067
33170
  match: `${originalName} as ${localName}`,
33068
33171
  suggestion: `\u76F4\u63A5\u4F7F\u7528\u539F\u540D: import { ${originalName} } from '${moduleSpecifier}'`
33069
33172
  });
33070
33173
  }
33071
- componentImportContext.set(localName, moduleSpecifier);
33072
- const metadata = componentRegistry.getComponent(originalName, moduleSpecifier);
33073
33174
  if (metadata) {
33074
33175
  const expectedPackage = resolveExpectedImportSource(metadata);
33075
33176
  if (expectedPackage && expectedPackage !== moduleSpecifier) {
@@ -33080,6 +33181,9 @@ function checkImport(node, violations, sourceFile, componentImportContext) {
33080
33181
  });
33081
33182
  }
33082
33183
  } else {
33184
+ if (packageExport) {
33185
+ return;
33186
+ }
33083
33187
  const knownMetadata = componentRegistry.getComponent(originalName);
33084
33188
  if (knownMetadata) {
33085
33189
  const expectedPackage = resolveExpectedImportSource(knownMetadata);
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk7CSMAJZ2_js = require('../chunk-7CSMAJZ2.js');
4
- require('../chunk-K6UQSWLC.js');
3
+ var chunkGCHRZSCK_js = require('../chunk-GCHRZSCK.js');
4
+ require('../chunk-4ZZ6E4RS.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 chunk7CSMAJZ2_js.validateCode; }
14
+ get: function () { return chunkGCHRZSCK_js.validateCode; }
15
15
  });
16
16
  Object.defineProperty(exports, "validateCodeSync", {
17
17
  enumerable: true,
18
- get: function () { return chunk7CSMAJZ2_js.validateCodeSync; }
18
+ get: function () { return chunkGCHRZSCK_js.validateCodeSync; }
19
19
  });
@@ -1,5 +1,5 @@
1
- export { validateCode, validateCodeSync } from '../chunk-RJQMTGRE.mjs';
2
- import '../chunk-7YBUXYUI.mjs';
1
+ export { validateCode, validateCodeSync } from '../chunk-SCECUJGJ.mjs';
2
+ import '../chunk-ZW3HD2OD.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 chunk7CSMAJZ2_js = require('./chunk-7CSMAJZ2.js');
6
- var chunkK6UQSWLC_js = require('./chunk-K6UQSWLC.js');
5
+ var chunkGCHRZSCK_js = require('./chunk-GCHRZSCK.js');
6
+ var chunk4ZZ6E4RS_js = require('./chunk-4ZZ6E4RS.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 chunk7CSMAJZ2_js.validateCode; }
20
+ get: function () { return chunkGCHRZSCK_js.validateCode; }
21
21
  });
22
22
  Object.defineProperty(exports, "validateCodeSync", {
23
23
  enumerable: true,
24
- get: function () { return chunk7CSMAJZ2_js.validateCodeSync; }
24
+ get: function () { return chunkGCHRZSCK_js.validateCodeSync; }
25
25
  });
26
26
  Object.defineProperty(exports, "analyzeCodeWithAST", {
27
27
  enumerable: true,
28
- get: function () { return chunkK6UQSWLC_js.analyzeCodeWithAST; }
28
+ get: function () { return chunk4ZZ6E4RS_js.analyzeCodeWithAST; }
29
29
  });
30
30
  Object.defineProperty(exports, "componentRegistry", {
31
31
  enumerable: true,
32
- get: function () { return chunkK6UQSWLC_js.componentRegistry; }
32
+ get: function () { return chunk4ZZ6E4RS_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-RJQMTGRE.mjs';
4
- export { analyzeCodeWithAST, componentRegistry } from './chunk-7YBUXYUI.mjs';
3
+ export { validateCode, validateCodeSync } from './chunk-SCECUJGJ.mjs';
4
+ export { analyzeCodeWithAST, componentRegistry } from './chunk-ZW3HD2OD.mjs';
5
5
  export { validateRuntimePrecheck } from './chunk-6HOIRUQB.mjs';
6
6
  export { compileSFC, scopeStyles } from './chunk-4OTQAQ6J.mjs';
7
7
  import './chunk-QC6VTSA3.mjs';
@@ -15,6 +15,7 @@ import { Tag, Tags } from '@king-design/vue';
15
15
  | 属性名 | 类型 | 默认值 | 必填 | 说明 | 标签 | 示例 |
16
16
  | --- | --- | --- | --- | --- | --- | --- |
17
17
  | type | `"default" | "primary" | "success" | "warning" | "danger"` | `"default"` | 否 | 组件类型,决定标签的视觉样式 | - | `<Tag type="primary">主要标签</Tag>` |
18
+ | color | `"default" | "primary" | "success" | "warning" | "danger" | "purple" | "teal" | "blue" | "yellow" | string` | `undefined` | 否 | 自定义标签颜色,支持预设颜色名和任意字符串色值 | - | `<Tag color="purple">品牌标签</Tag>` |
18
19
  | closable | `boolean` | `false` | 否 | 是否可关闭,显示关闭按钮 | - | `<Tag closable @close="handleClose">可关闭标签</Tag>` |
19
20
  | closed | `boolean` | `false` | 否 | 是否已关闭(受控模式) | - | `<Tag closable :closed="isClosed" @close="handleClose">标签</Tag>` |
20
21
  | disabled | `boolean` | `false` | 否 | 是否展示禁用状态 | - | `<Tag disabled>禁用标签</Tag>` |
@@ -414,4 +415,3 @@ const handleAdd = () => {
414
415
 
415
416
  ## 相关组件
416
417
  Tags, Badge
417
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "king-design-analyzer",
3
- "version": "2.2.3",
3
+ "version": "2.2.5",
4
4
  "description": "AST-based code analyzer for King Design Vue components with on-demand modular imports",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",