king-design-analyzer 2.2.5 → 2.2.8

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.
@@ -52,9 +52,10 @@
52
52
  "name": "size",
53
53
  "description": "卡片尺寸",
54
54
  "type": {
55
- "raw": "\"default\" | \"small\" | \"mini\"",
55
+ "raw": "\"large\" | \"default\" | \"small\" | \"mini\"",
56
56
  "kind": "union",
57
57
  "unionTypes": [
58
+ "large",
58
59
  "default",
59
60
  "small",
60
61
  "mini"
@@ -63,6 +64,10 @@
63
64
  "required": false,
64
65
  "default": "\"default\"",
65
66
  "allowedValues": [
67
+ {
68
+ "value": "large",
69
+ "label": "大尺寸"
70
+ },
66
71
  {
67
72
  "value": "default",
68
73
  "label": "默认尺寸",
@@ -170,9 +175,10 @@
170
175
  "title": "不同尺寸",
171
176
  "description": "不同尺寸的卡片",
172
177
  "difficulty": "easy",
173
- "code": "<script setup lang=\"ts\">\nimport { Card } from '@king-design/vue';\n</script>\n<template>\n <Card title=\"默认尺寸\" size=\"default\">默认尺寸卡片</Card>\n <Card title=\"小尺寸\" size=\"small\">小尺寸卡片</Card>\n <Card title=\"迷你尺寸\" size=\"mini\">迷你尺寸卡片</Card>\n</template>",
178
+ "code": "<script setup lang=\"ts\">\nimport { Card } from '@king-design/vue';\n</script>\n<template>\n <Card title=\"大尺寸\" size=\"large\">大尺寸卡片</Card>\n <Card title=\"默认尺寸\" size=\"default\">默认尺寸卡片</Card>\n <Card title=\"小尺寸\" size=\"small\">小尺寸卡片</Card>\n <Card title=\"迷你尺寸\" size=\"mini\">迷你尺寸卡片</Card>\n</template>",
174
179
  "tags": [
175
180
  "size",
181
+ "large",
176
182
  "small",
177
183
  "mini"
178
184
  ],
package/dist/ast/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  require('../chunk-YTEYDSDW.js');
4
- var chunk4ZZ6E4RS_js = require('../chunk-4ZZ6E4RS.js');
4
+ var chunk365WGIYE_js = require('../chunk-365WGIYE.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 chunk4ZZ6E4RS_js.analyzeCodeWithAST; }
12
+ get: function () { return chunk365WGIYE_js.analyzeCodeWithAST; }
13
13
  });
14
14
  Object.defineProperty(exports, "componentRegistry", {
15
15
  enumerable: true,
16
- get: function () { return chunk4ZZ6E4RS_js.componentRegistry; }
16
+ get: function () { return chunk365WGIYE_js.componentRegistry; }
17
17
  });
@@ -1,4 +1,4 @@
1
1
  import '../chunk-5H7N2A5X.mjs';
2
- export { analyzeCodeWithAST, componentRegistry } from '../chunk-ZW3HD2OD.mjs';
2
+ export { analyzeCodeWithAST, componentRegistry } from '../chunk-7S3VAJP7.mjs';
3
3
  import '../chunk-QC6VTSA3.mjs';
4
4
  import '../chunk-UJCSKKID.mjs';
@@ -5407,8 +5407,8 @@ var require_lib = chunkJSBRDJBE_js.__commonJS({
5407
5407
  super.setArrowFunctionParameters(node, params);
5408
5408
  }
5409
5409
  }
5410
- checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
5411
- if (isArrowFunction && this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(node.start))) {
5410
+ checkParams(node, allowDuplicates, isArrowFunction2, strictModeChanged = true) {
5411
+ if (isArrowFunction2 && this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(node.start))) {
5412
5412
  return;
5413
5413
  }
5414
5414
  for (let i = 0; i < node.params.length; i++) {
@@ -5416,7 +5416,7 @@ var require_lib = chunkJSBRDJBE_js.__commonJS({
5416
5416
  this.raise(FlowErrors.ThisParamMustBeFirst, node.params[i]);
5417
5417
  }
5418
5418
  }
5419
- super.checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged);
5419
+ super.checkParams(node, allowDuplicates, isArrowFunction2, strictModeChanged);
5420
5420
  }
5421
5421
  parseParenAndDistinguishExpression(canBeArrow) {
5422
5422
  return super.parseParenAndDistinguishExpression(canBeArrow && !this.state.noArrowAt.includes(this.sourceToOffsetPos(this.state.start)));
@@ -13970,7 +13970,7 @@ var require_lib = chunkJSBRDJBE_js.__commonJS({
13970
13970
  }
13971
13971
  return true;
13972
13972
  }
13973
- checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
13973
+ checkParams(node, allowDuplicates, isArrowFunction2, strictModeChanged = true) {
13974
13974
  const checkClashes = !allowDuplicates && /* @__PURE__ */ new Set();
13975
13975
  const formalParameters = {
13976
13976
  type: "FormalParameters"
@@ -18799,9 +18799,9 @@ var require_compiler_core_cjs_prod = chunkJSBRDJBE_js.__commonJS({
18799
18799
  loc: locStub
18800
18800
  };
18801
18801
  }
18802
- function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent2 = false, loc = locStub) {
18802
+ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock2 = false, disableTracking = false, isComponent2 = false, loc = locStub) {
18803
18803
  if (context) {
18804
- if (isBlock) {
18804
+ if (isBlock2) {
18805
18805
  context.helper(OPEN_BLOCK);
18806
18806
  context.helper(getVNodeBlockHelper(context.inSSR, isComponent2));
18807
18807
  } else {
@@ -18819,7 +18819,7 @@ var require_compiler_core_cjs_prod = chunkJSBRDJBE_js.__commonJS({
18819
18819
  patchFlag,
18820
18820
  dynamicProps,
18821
18821
  directives,
18822
- isBlock,
18822
+ isBlock: isBlock2,
18823
18823
  disableTracking,
18824
18824
  isComponent: isComponent2,
18825
18825
  loc
@@ -22708,7 +22708,7 @@ const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(",
22708
22708
  patchFlag,
22709
22709
  dynamicProps,
22710
22710
  directives,
22711
- isBlock,
22711
+ isBlock: isBlock2,
22712
22712
  disableTracking,
22713
22713
  isComponent: isComponent2
22714
22714
  } = node;
@@ -22721,20 +22721,20 @@ const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(",
22721
22721
  if (directives) {
22722
22722
  push(helper(WITH_DIRECTIVES) + `(`);
22723
22723
  }
22724
- if (isBlock) {
22724
+ if (isBlock2) {
22725
22725
  push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
22726
22726
  }
22727
22727
  if (pure) {
22728
22728
  push(PURE_ANNOTATION);
22729
22729
  }
22730
- const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent2) : getVNodeHelper(context.inSSR, isComponent2);
22730
+ const callHelper = isBlock2 ? getVNodeBlockHelper(context.inSSR, isComponent2) : getVNodeHelper(context.inSSR, isComponent2);
22731
22731
  push(helper(callHelper) + `(`, -2, node);
22732
22732
  genNodeList(
22733
22733
  genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
22734
22734
  context
22735
22735
  );
22736
22736
  push(`)`);
22737
- if (isBlock) {
22737
+ if (isBlock2) {
22738
22738
  push(`)`);
22739
22739
  }
22740
22740
  if (directives) {
@@ -25565,9 +25565,9 @@ var require_compiler_core_cjs = chunkJSBRDJBE_js.__commonJS({
25565
25565
  loc: locStub
25566
25566
  };
25567
25567
  }
25568
- function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent2 = false, loc = locStub) {
25568
+ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock2 = false, disableTracking = false, isComponent2 = false, loc = locStub) {
25569
25569
  if (context) {
25570
- if (isBlock) {
25570
+ if (isBlock2) {
25571
25571
  context.helper(OPEN_BLOCK);
25572
25572
  context.helper(getVNodeBlockHelper(context.inSSR, isComponent2));
25573
25573
  } else {
@@ -25585,7 +25585,7 @@ var require_compiler_core_cjs = chunkJSBRDJBE_js.__commonJS({
25585
25585
  patchFlag,
25586
25586
  dynamicProps,
25587
25587
  directives,
25588
- isBlock,
25588
+ isBlock: isBlock2,
25589
25589
  disableTracking,
25590
25590
  isComponent: isComponent2,
25591
25591
  loc
@@ -29544,7 +29544,7 @@ const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(",
29544
29544
  patchFlag,
29545
29545
  dynamicProps,
29546
29546
  directives,
29547
- isBlock,
29547
+ isBlock: isBlock2,
29548
29548
  disableTracking,
29549
29549
  isComponent: isComponent2
29550
29550
  } = node;
@@ -29562,20 +29562,20 @@ const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(",
29562
29562
  if (directives) {
29563
29563
  push(helper(WITH_DIRECTIVES) + `(`);
29564
29564
  }
29565
- if (isBlock) {
29565
+ if (isBlock2) {
29566
29566
  push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
29567
29567
  }
29568
29568
  if (pure) {
29569
29569
  push(PURE_ANNOTATION);
29570
29570
  }
29571
- const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent2) : getVNodeHelper(context.inSSR, isComponent2);
29571
+ const callHelper = isBlock2 ? getVNodeBlockHelper(context.inSSR, isComponent2) : getVNodeHelper(context.inSSR, isComponent2);
29572
29572
  push(helper(callHelper) + `(`, -2, node);
29573
29573
  genNodeList(
29574
29574
  genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
29575
29575
  context
29576
29576
  );
29577
29577
  push(`)`);
29578
- if (isBlock) {
29578
+ if (isBlock2) {
29579
29579
  push(`)`);
29580
29580
  }
29581
29581
  if (directives) {
@@ -32464,6 +32464,18 @@ var HooksRegistry = class {
32464
32464
  }
32465
32465
  };
32466
32466
  var hooksRegistry = new HooksRegistry();
32467
+ var FALLBACK_PACKAGE_EXPORTS = {
32468
+ "@king-design/vue": [
32469
+ { name: "_$", kind: "value" },
32470
+ { name: "localize", kind: "value" },
32471
+ { name: "setTheme", kind: "value" },
32472
+ { name: "theme", kind: "value" },
32473
+ { name: "normalize", kind: "value" },
32474
+ { name: "bind", kind: "value" },
32475
+ { name: "MenuTitle", kind: "component" },
32476
+ { name: "View", kind: "component" }
32477
+ ]
32478
+ };
32467
32479
  function packagePathSegments(moduleSpecifier) {
32468
32480
  if (moduleSpecifier.startsWith("@")) {
32469
32481
  return moduleSpecifier.split("/").slice(0, 2);
@@ -32515,14 +32527,27 @@ var PackageExportRegistry = class {
32515
32527
  this.exportsByModule = /* @__PURE__ */ new Map();
32516
32528
  this.loadedModules = /* @__PURE__ */ new Set();
32517
32529
  }
32530
+ createFallbackExportsMap(moduleSpecifier) {
32531
+ const fallbackExports = FALLBACK_PACKAGE_EXPORTS[moduleSpecifier] || [];
32532
+ const exportsMap = /* @__PURE__ */ new Map();
32533
+ for (const item of fallbackExports) {
32534
+ exportsMap.set(item.name, {
32535
+ name: item.name,
32536
+ moduleSpecifier,
32537
+ kind: item.kind
32538
+ });
32539
+ }
32540
+ return exportsMap;
32541
+ }
32518
32542
  async load(moduleSpecifier) {
32519
32543
  if (this.loadedModules.has(moduleSpecifier)) {
32520
32544
  return;
32521
32545
  }
32546
+ const exportsMap = this.createFallbackExportsMap(moduleSpecifier);
32522
32547
  const entry = resolvePackageTypesEntry(moduleSpecifier);
32523
32548
  if (!entry) {
32524
32549
  this.loadedModules.add(moduleSpecifier);
32525
- this.exportsByModule.set(moduleSpecifier, /* @__PURE__ */ new Map());
32550
+ this.exportsByModule.set(moduleSpecifier, exportsMap);
32526
32551
  return;
32527
32552
  }
32528
32553
  const program = ts2__namespace.createProgram([entry], {
@@ -32535,11 +32560,10 @@ var PackageExportRegistry = class {
32535
32560
  const sourceFile = program.getSourceFile(entry);
32536
32561
  if (!sourceFile) {
32537
32562
  this.loadedModules.add(moduleSpecifier);
32538
- this.exportsByModule.set(moduleSpecifier, /* @__PURE__ */ new Map());
32563
+ this.exportsByModule.set(moduleSpecifier, exportsMap);
32539
32564
  return;
32540
32565
  }
32541
32566
  const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
32542
- const exportsMap = /* @__PURE__ */ new Map();
32543
32567
  if (moduleSymbol) {
32544
32568
  for (const symbol of checker.getExportsOfModule(moduleSymbol)) {
32545
32569
  const declarationFile = symbol.declarations?.[0]?.getSourceFile().fileName;
@@ -33106,32 +33130,82 @@ function extractIdentifiersFromTemplateAST(node, set) {
33106
33130
  }
33107
33131
  }
33108
33132
  function extractIdentifiersFromExpression(expression) {
33109
- const identifiers = [];
33110
- const locals = [];
33111
- const arrowFuncRegex = /(?:(?:\(([^)]+)\))|([a-zA-Z_$][\w$]*))\s*=>/g;
33112
- let arrowMatch;
33113
- while ((arrowMatch = arrowFuncRegex.exec(expression)) !== null) {
33114
- const params = arrowMatch[1] || arrowMatch[2];
33115
- if (params) {
33116
- const paramNames = params.split(",").map((p) => p.trim().split(":")[0].trim());
33117
- paramNames.forEach((p) => {
33118
- const subMatches = p.match(/\b([a-zA-Z_$][\w$]*)\b/g);
33119
- if (subMatches) subMatches.forEach((sm) => {
33120
- if (!isJsKeyword(sm)) locals.push(sm);
33121
- });
33122
- });
33133
+ const identifiers = /* @__PURE__ */ new Set();
33134
+ const locals = /* @__PURE__ */ new Set();
33135
+ try {
33136
+ const sourceFile = ts2__namespace.createSourceFile(
33137
+ "temp-expression.ts",
33138
+ `const __expr = (${expression});`,
33139
+ ts2__namespace.ScriptTarget.Latest,
33140
+ true,
33141
+ ts2__namespace.ScriptKind.TS
33142
+ );
33143
+ const statement = sourceFile.statements[0];
33144
+ if (!statement || !ts2__namespace.isVariableStatement(statement)) {
33145
+ return { identifiers: [], locals: [] };
33123
33146
  }
33124
- }
33125
- const cleanExpr = expression.replace(/'[^']*'/g, "").replace(/"[^"]*"/g, "").replace(/`[^`]*`/g, "");
33126
- const idRegex = /(?:^|[^.\w$])([a-zA-Z_$][\w$]*)(?![\w$])(?!\s*:)/g;
33127
- let match;
33128
- while ((match = idRegex.exec(cleanExpr)) !== null) {
33129
- const id = match[1];
33130
- if (!isJsKeyword(id) && !locals.includes(id)) {
33131
- identifiers.push(id);
33147
+ const declaration = statement.declarationList.declarations[0];
33148
+ const rootExpression = declaration?.initializer;
33149
+ if (!rootExpression) {
33150
+ return { identifiers: [], locals: [] };
33132
33151
  }
33152
+ const addBindingName = (name, scope) => {
33153
+ if (ts2__namespace.isIdentifier(name)) {
33154
+ scope.add(name.text);
33155
+ locals.add(name.text);
33156
+ return;
33157
+ }
33158
+ name.elements.forEach((element) => {
33159
+ if (!ts2__namespace.isBindingElement(element)) return;
33160
+ addBindingName(element.name, scope);
33161
+ });
33162
+ };
33163
+ const isLocal = (name, scopes) => scopes.some((scope) => scope.has(name));
33164
+ const isReferenceIdentifier = (node) => {
33165
+ const parent = node.parent;
33166
+ if (!parent) return true;
33167
+ if (ts2__namespace.isPropertyAccessExpression(parent) && parent.name === node || ts2__namespace.isPropertyAssignment(parent) && parent.name === node || ts2__namespace.isShorthandPropertyAssignment(parent) && parent.name === node && !!parent.objectAssignmentInitializer || ts2__namespace.isBindingElement(parent) && parent.name === node || ts2__namespace.isVariableDeclaration(parent) && parent.name === node || ts2__namespace.isParameter(parent) && parent.name === node || ts2__namespace.isImportSpecifier(parent) && (parent.name === node || parent.propertyName === node) || ts2__namespace.isImportClause(parent) && parent.name === node || ts2__namespace.isNamespaceImport(parent) && parent.name === node || ts2__namespace.isFunctionDeclaration(parent) && parent.name === node || ts2__namespace.isFunctionExpression(parent) && parent.name === node || ts2__namespace.isArrowFunction(parent) || ts2__namespace.isMethodDeclaration(parent) && parent.name === node || ts2__namespace.isPropertyDeclaration(parent) && parent.name === node || ts2__namespace.isPropertySignature(parent) && parent.name === node || ts2__namespace.isMethodSignature(parent) && parent.name === node || ts2__namespace.isTypeReferenceNode(parent) || ts2__namespace.isExpressionWithTypeArguments(parent) || ts2__namespace.isTypeQueryNode(parent) || ts2__namespace.isQualifiedName(parent) && parent.right === node) {
33168
+ return false;
33169
+ }
33170
+ return true;
33171
+ };
33172
+ const walk = (node, scopes) => {
33173
+ if (ts2__namespace.isArrowFunction(node) || ts2__namespace.isFunctionExpression(node)) {
33174
+ const functionScope = /* @__PURE__ */ new Set();
33175
+ node.parameters.forEach((param) => {
33176
+ addBindingName(param.name, functionScope);
33177
+ if (param.initializer) {
33178
+ walk(param.initializer, [...scopes, functionScope]);
33179
+ }
33180
+ });
33181
+ if (ts2__namespace.isBlock(node.body)) {
33182
+ node.body.statements.forEach((statementNode) => walk(statementNode, [...scopes, functionScope]));
33183
+ } else {
33184
+ walk(node.body, [...scopes, functionScope]);
33185
+ }
33186
+ return;
33187
+ }
33188
+ if (ts2__namespace.isVariableDeclaration(node)) {
33189
+ const currentScope = scopes[scopes.length - 1];
33190
+ addBindingName(node.name, currentScope);
33191
+ if (node.initializer) {
33192
+ walk(node.initializer, scopes);
33193
+ }
33194
+ return;
33195
+ }
33196
+ if (ts2__namespace.isIdentifier(node)) {
33197
+ if (node.text !== "__expr" && isReferenceIdentifier(node) && !isLocal(node.text, scopes) && !isJsKeyword(node.text)) {
33198
+ identifiers.add(node.text);
33199
+ }
33200
+ return;
33201
+ }
33202
+ ts2__namespace.forEachChild(node, (child) => walk(child, scopes));
33203
+ };
33204
+ walk(rootExpression, [/* @__PURE__ */ new Set()]);
33205
+ return { identifiers: [...identifiers], locals: [...locals] };
33206
+ } catch {
33207
+ return { identifiers: [], locals: [] };
33133
33208
  }
33134
- return { identifiers: [...new Set(identifiers)], locals: [...new Set(locals)] };
33135
33209
  }
33136
33210
  function isTemplateBuiltin(id) {
33137
33211
  return TEMPLATE_BUILTINS.has(id);
@@ -5382,8 +5382,8 @@ var require_lib = __commonJS({
5382
5382
  super.setArrowFunctionParameters(node, params);
5383
5383
  }
5384
5384
  }
5385
- checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
5386
- if (isArrowFunction && this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(node.start))) {
5385
+ checkParams(node, allowDuplicates, isArrowFunction2, strictModeChanged = true) {
5386
+ if (isArrowFunction2 && this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(node.start))) {
5387
5387
  return;
5388
5388
  }
5389
5389
  for (let i = 0; i < node.params.length; i++) {
@@ -5391,7 +5391,7 @@ var require_lib = __commonJS({
5391
5391
  this.raise(FlowErrors.ThisParamMustBeFirst, node.params[i]);
5392
5392
  }
5393
5393
  }
5394
- super.checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged);
5394
+ super.checkParams(node, allowDuplicates, isArrowFunction2, strictModeChanged);
5395
5395
  }
5396
5396
  parseParenAndDistinguishExpression(canBeArrow) {
5397
5397
  return super.parseParenAndDistinguishExpression(canBeArrow && !this.state.noArrowAt.includes(this.sourceToOffsetPos(this.state.start)));
@@ -13945,7 +13945,7 @@ var require_lib = __commonJS({
13945
13945
  }
13946
13946
  return true;
13947
13947
  }
13948
- checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
13948
+ checkParams(node, allowDuplicates, isArrowFunction2, strictModeChanged = true) {
13949
13949
  const checkClashes = !allowDuplicates && /* @__PURE__ */ new Set();
13950
13950
  const formalParameters = {
13951
13951
  type: "FormalParameters"
@@ -18774,9 +18774,9 @@ var require_compiler_core_cjs_prod = __commonJS({
18774
18774
  loc: locStub
18775
18775
  };
18776
18776
  }
18777
- function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent2 = false, loc = locStub) {
18777
+ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock2 = false, disableTracking = false, isComponent2 = false, loc = locStub) {
18778
18778
  if (context) {
18779
- if (isBlock) {
18779
+ if (isBlock2) {
18780
18780
  context.helper(OPEN_BLOCK);
18781
18781
  context.helper(getVNodeBlockHelper(context.inSSR, isComponent2));
18782
18782
  } else {
@@ -18794,7 +18794,7 @@ var require_compiler_core_cjs_prod = __commonJS({
18794
18794
  patchFlag,
18795
18795
  dynamicProps,
18796
18796
  directives,
18797
- isBlock,
18797
+ isBlock: isBlock2,
18798
18798
  disableTracking,
18799
18799
  isComponent: isComponent2,
18800
18800
  loc
@@ -22683,7 +22683,7 @@ const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(",
22683
22683
  patchFlag,
22684
22684
  dynamicProps,
22685
22685
  directives,
22686
- isBlock,
22686
+ isBlock: isBlock2,
22687
22687
  disableTracking,
22688
22688
  isComponent: isComponent2
22689
22689
  } = node;
@@ -22696,20 +22696,20 @@ const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(",
22696
22696
  if (directives) {
22697
22697
  push(helper(WITH_DIRECTIVES) + `(`);
22698
22698
  }
22699
- if (isBlock) {
22699
+ if (isBlock2) {
22700
22700
  push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
22701
22701
  }
22702
22702
  if (pure) {
22703
22703
  push(PURE_ANNOTATION);
22704
22704
  }
22705
- const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent2) : getVNodeHelper(context.inSSR, isComponent2);
22705
+ const callHelper = isBlock2 ? getVNodeBlockHelper(context.inSSR, isComponent2) : getVNodeHelper(context.inSSR, isComponent2);
22706
22706
  push(helper(callHelper) + `(`, -2, node);
22707
22707
  genNodeList(
22708
22708
  genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
22709
22709
  context
22710
22710
  );
22711
22711
  push(`)`);
22712
- if (isBlock) {
22712
+ if (isBlock2) {
22713
22713
  push(`)`);
22714
22714
  }
22715
22715
  if (directives) {
@@ -25540,9 +25540,9 @@ var require_compiler_core_cjs = __commonJS({
25540
25540
  loc: locStub
25541
25541
  };
25542
25542
  }
25543
- function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent2 = false, loc = locStub) {
25543
+ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock2 = false, disableTracking = false, isComponent2 = false, loc = locStub) {
25544
25544
  if (context) {
25545
- if (isBlock) {
25545
+ if (isBlock2) {
25546
25546
  context.helper(OPEN_BLOCK);
25547
25547
  context.helper(getVNodeBlockHelper(context.inSSR, isComponent2));
25548
25548
  } else {
@@ -25560,7 +25560,7 @@ var require_compiler_core_cjs = __commonJS({
25560
25560
  patchFlag,
25561
25561
  dynamicProps,
25562
25562
  directives,
25563
- isBlock,
25563
+ isBlock: isBlock2,
25564
25564
  disableTracking,
25565
25565
  isComponent: isComponent2,
25566
25566
  loc
@@ -29519,7 +29519,7 @@ const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(",
29519
29519
  patchFlag,
29520
29520
  dynamicProps,
29521
29521
  directives,
29522
- isBlock,
29522
+ isBlock: isBlock2,
29523
29523
  disableTracking,
29524
29524
  isComponent: isComponent2
29525
29525
  } = node;
@@ -29537,20 +29537,20 @@ const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(",
29537
29537
  if (directives) {
29538
29538
  push(helper(WITH_DIRECTIVES) + `(`);
29539
29539
  }
29540
- if (isBlock) {
29540
+ if (isBlock2) {
29541
29541
  push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
29542
29542
  }
29543
29543
  if (pure) {
29544
29544
  push(PURE_ANNOTATION);
29545
29545
  }
29546
- const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent2) : getVNodeHelper(context.inSSR, isComponent2);
29546
+ const callHelper = isBlock2 ? getVNodeBlockHelper(context.inSSR, isComponent2) : getVNodeHelper(context.inSSR, isComponent2);
29547
29547
  push(helper(callHelper) + `(`, -2, node);
29548
29548
  genNodeList(
29549
29549
  genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
29550
29550
  context
29551
29551
  );
29552
29552
  push(`)`);
29553
- if (isBlock) {
29553
+ if (isBlock2) {
29554
29554
  push(`)`);
29555
29555
  }
29556
29556
  if (directives) {
@@ -32439,6 +32439,18 @@ var HooksRegistry = class {
32439
32439
  }
32440
32440
  };
32441
32441
  var hooksRegistry = new HooksRegistry();
32442
+ var FALLBACK_PACKAGE_EXPORTS = {
32443
+ "@king-design/vue": [
32444
+ { name: "_$", kind: "value" },
32445
+ { name: "localize", kind: "value" },
32446
+ { name: "setTheme", kind: "value" },
32447
+ { name: "theme", kind: "value" },
32448
+ { name: "normalize", kind: "value" },
32449
+ { name: "bind", kind: "value" },
32450
+ { name: "MenuTitle", kind: "component" },
32451
+ { name: "View", kind: "component" }
32452
+ ]
32453
+ };
32442
32454
  function packagePathSegments(moduleSpecifier) {
32443
32455
  if (moduleSpecifier.startsWith("@")) {
32444
32456
  return moduleSpecifier.split("/").slice(0, 2);
@@ -32490,14 +32502,27 @@ var PackageExportRegistry = class {
32490
32502
  this.exportsByModule = /* @__PURE__ */ new Map();
32491
32503
  this.loadedModules = /* @__PURE__ */ new Set();
32492
32504
  }
32505
+ createFallbackExportsMap(moduleSpecifier) {
32506
+ const fallbackExports = FALLBACK_PACKAGE_EXPORTS[moduleSpecifier] || [];
32507
+ const exportsMap = /* @__PURE__ */ new Map();
32508
+ for (const item of fallbackExports) {
32509
+ exportsMap.set(item.name, {
32510
+ name: item.name,
32511
+ moduleSpecifier,
32512
+ kind: item.kind
32513
+ });
32514
+ }
32515
+ return exportsMap;
32516
+ }
32493
32517
  async load(moduleSpecifier) {
32494
32518
  if (this.loadedModules.has(moduleSpecifier)) {
32495
32519
  return;
32496
32520
  }
32521
+ const exportsMap = this.createFallbackExportsMap(moduleSpecifier);
32497
32522
  const entry = resolvePackageTypesEntry(moduleSpecifier);
32498
32523
  if (!entry) {
32499
32524
  this.loadedModules.add(moduleSpecifier);
32500
- this.exportsByModule.set(moduleSpecifier, /* @__PURE__ */ new Map());
32525
+ this.exportsByModule.set(moduleSpecifier, exportsMap);
32501
32526
  return;
32502
32527
  }
32503
32528
  const program = ts2.createProgram([entry], {
@@ -32510,11 +32535,10 @@ var PackageExportRegistry = class {
32510
32535
  const sourceFile = program.getSourceFile(entry);
32511
32536
  if (!sourceFile) {
32512
32537
  this.loadedModules.add(moduleSpecifier);
32513
- this.exportsByModule.set(moduleSpecifier, /* @__PURE__ */ new Map());
32538
+ this.exportsByModule.set(moduleSpecifier, exportsMap);
32514
32539
  return;
32515
32540
  }
32516
32541
  const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
32517
- const exportsMap = /* @__PURE__ */ new Map();
32518
32542
  if (moduleSymbol) {
32519
32543
  for (const symbol of checker.getExportsOfModule(moduleSymbol)) {
32520
32544
  const declarationFile = symbol.declarations?.[0]?.getSourceFile().fileName;
@@ -33081,32 +33105,82 @@ function extractIdentifiersFromTemplateAST(node, set) {
33081
33105
  }
33082
33106
  }
33083
33107
  function extractIdentifiersFromExpression(expression) {
33084
- const identifiers = [];
33085
- const locals = [];
33086
- const arrowFuncRegex = /(?:(?:\(([^)]+)\))|([a-zA-Z_$][\w$]*))\s*=>/g;
33087
- let arrowMatch;
33088
- while ((arrowMatch = arrowFuncRegex.exec(expression)) !== null) {
33089
- const params = arrowMatch[1] || arrowMatch[2];
33090
- if (params) {
33091
- const paramNames = params.split(",").map((p) => p.trim().split(":")[0].trim());
33092
- paramNames.forEach((p) => {
33093
- const subMatches = p.match(/\b([a-zA-Z_$][\w$]*)\b/g);
33094
- if (subMatches) subMatches.forEach((sm) => {
33095
- if (!isJsKeyword(sm)) locals.push(sm);
33096
- });
33097
- });
33108
+ const identifiers = /* @__PURE__ */ new Set();
33109
+ const locals = /* @__PURE__ */ new Set();
33110
+ try {
33111
+ const sourceFile = ts2.createSourceFile(
33112
+ "temp-expression.ts",
33113
+ `const __expr = (${expression});`,
33114
+ ts2.ScriptTarget.Latest,
33115
+ true,
33116
+ ts2.ScriptKind.TS
33117
+ );
33118
+ const statement = sourceFile.statements[0];
33119
+ if (!statement || !ts2.isVariableStatement(statement)) {
33120
+ return { identifiers: [], locals: [] };
33098
33121
  }
33099
- }
33100
- const cleanExpr = expression.replace(/'[^']*'/g, "").replace(/"[^"]*"/g, "").replace(/`[^`]*`/g, "");
33101
- const idRegex = /(?:^|[^.\w$])([a-zA-Z_$][\w$]*)(?![\w$])(?!\s*:)/g;
33102
- let match;
33103
- while ((match = idRegex.exec(cleanExpr)) !== null) {
33104
- const id = match[1];
33105
- if (!isJsKeyword(id) && !locals.includes(id)) {
33106
- identifiers.push(id);
33122
+ const declaration = statement.declarationList.declarations[0];
33123
+ const rootExpression = declaration?.initializer;
33124
+ if (!rootExpression) {
33125
+ return { identifiers: [], locals: [] };
33107
33126
  }
33127
+ const addBindingName = (name, scope) => {
33128
+ if (ts2.isIdentifier(name)) {
33129
+ scope.add(name.text);
33130
+ locals.add(name.text);
33131
+ return;
33132
+ }
33133
+ name.elements.forEach((element) => {
33134
+ if (!ts2.isBindingElement(element)) return;
33135
+ addBindingName(element.name, scope);
33136
+ });
33137
+ };
33138
+ const isLocal = (name, scopes) => scopes.some((scope) => scope.has(name));
33139
+ const isReferenceIdentifier = (node) => {
33140
+ const parent = node.parent;
33141
+ if (!parent) return true;
33142
+ if (ts2.isPropertyAccessExpression(parent) && parent.name === node || ts2.isPropertyAssignment(parent) && parent.name === node || ts2.isShorthandPropertyAssignment(parent) && parent.name === node && !!parent.objectAssignmentInitializer || ts2.isBindingElement(parent) && parent.name === node || ts2.isVariableDeclaration(parent) && parent.name === node || ts2.isParameter(parent) && parent.name === node || ts2.isImportSpecifier(parent) && (parent.name === node || parent.propertyName === node) || ts2.isImportClause(parent) && parent.name === node || ts2.isNamespaceImport(parent) && parent.name === node || ts2.isFunctionDeclaration(parent) && parent.name === node || ts2.isFunctionExpression(parent) && parent.name === node || ts2.isArrowFunction(parent) || ts2.isMethodDeclaration(parent) && parent.name === node || ts2.isPropertyDeclaration(parent) && parent.name === node || ts2.isPropertySignature(parent) && parent.name === node || ts2.isMethodSignature(parent) && parent.name === node || ts2.isTypeReferenceNode(parent) || ts2.isExpressionWithTypeArguments(parent) || ts2.isTypeQueryNode(parent) || ts2.isQualifiedName(parent) && parent.right === node) {
33143
+ return false;
33144
+ }
33145
+ return true;
33146
+ };
33147
+ const walk = (node, scopes) => {
33148
+ if (ts2.isArrowFunction(node) || ts2.isFunctionExpression(node)) {
33149
+ const functionScope = /* @__PURE__ */ new Set();
33150
+ node.parameters.forEach((param) => {
33151
+ addBindingName(param.name, functionScope);
33152
+ if (param.initializer) {
33153
+ walk(param.initializer, [...scopes, functionScope]);
33154
+ }
33155
+ });
33156
+ if (ts2.isBlock(node.body)) {
33157
+ node.body.statements.forEach((statementNode) => walk(statementNode, [...scopes, functionScope]));
33158
+ } else {
33159
+ walk(node.body, [...scopes, functionScope]);
33160
+ }
33161
+ return;
33162
+ }
33163
+ if (ts2.isVariableDeclaration(node)) {
33164
+ const currentScope = scopes[scopes.length - 1];
33165
+ addBindingName(node.name, currentScope);
33166
+ if (node.initializer) {
33167
+ walk(node.initializer, scopes);
33168
+ }
33169
+ return;
33170
+ }
33171
+ if (ts2.isIdentifier(node)) {
33172
+ if (node.text !== "__expr" && isReferenceIdentifier(node) && !isLocal(node.text, scopes) && !isJsKeyword(node.text)) {
33173
+ identifiers.add(node.text);
33174
+ }
33175
+ return;
33176
+ }
33177
+ ts2.forEachChild(node, (child) => walk(child, scopes));
33178
+ };
33179
+ walk(rootExpression, [/* @__PURE__ */ new Set()]);
33180
+ return { identifiers: [...identifiers], locals: [...locals] };
33181
+ } catch {
33182
+ return { identifiers: [], locals: [] };
33108
33183
  }
33109
- return { identifiers: [...new Set(identifiers)], locals: [...new Set(locals)] };
33110
33184
  }
33111
33185
  function isTemplateBuiltin(id) {
33112
33186
  return TEMPLATE_BUILTINS.has(id);
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk4ZZ6E4RS_js = require('./chunk-4ZZ6E4RS.js');
3
+ var chunk365WGIYE_js = require('./chunk-365WGIYE.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 chunk4ZZ6E4RS_js.analyzeCodeWithAST(code);
67
+ const violations = await chunk365WGIYE_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-ZW3HD2OD.mjs';
1
+ import { analyzeCodeWithAST } from './chunk-7S3VAJP7.mjs';
2
2
  import { validateRuntimePrecheck } from './chunk-6HOIRUQB.mjs';
3
3
  import { compileSFC } from './chunk-4OTQAQ6J.mjs';
4
4
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkGCHRZSCK_js = require('../chunk-GCHRZSCK.js');
4
- require('../chunk-4ZZ6E4RS.js');
3
+ var chunkS7CUJ4G6_js = require('../chunk-S7CUJ4G6.js');
4
+ require('../chunk-365WGIYE.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 chunkGCHRZSCK_js.validateCode; }
14
+ get: function () { return chunkS7CUJ4G6_js.validateCode; }
15
15
  });
16
16
  Object.defineProperty(exports, "validateCodeSync", {
17
17
  enumerable: true,
18
- get: function () { return chunkGCHRZSCK_js.validateCodeSync; }
18
+ get: function () { return chunkS7CUJ4G6_js.validateCodeSync; }
19
19
  });
@@ -1,5 +1,5 @@
1
- export { validateCode, validateCodeSync } from '../chunk-SCECUJGJ.mjs';
2
- import '../chunk-ZW3HD2OD.mjs';
1
+ export { validateCode, validateCodeSync } from '../chunk-TTMAMBZV.mjs';
2
+ import '../chunk-7S3VAJP7.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 chunkGCHRZSCK_js = require('./chunk-GCHRZSCK.js');
6
- var chunk4ZZ6E4RS_js = require('./chunk-4ZZ6E4RS.js');
5
+ var chunkS7CUJ4G6_js = require('./chunk-S7CUJ4G6.js');
6
+ var chunk365WGIYE_js = require('./chunk-365WGIYE.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 chunkGCHRZSCK_js.validateCode; }
20
+ get: function () { return chunkS7CUJ4G6_js.validateCode; }
21
21
  });
22
22
  Object.defineProperty(exports, "validateCodeSync", {
23
23
  enumerable: true,
24
- get: function () { return chunkGCHRZSCK_js.validateCodeSync; }
24
+ get: function () { return chunkS7CUJ4G6_js.validateCodeSync; }
25
25
  });
26
26
  Object.defineProperty(exports, "analyzeCodeWithAST", {
27
27
  enumerable: true,
28
- get: function () { return chunk4ZZ6E4RS_js.analyzeCodeWithAST; }
28
+ get: function () { return chunk365WGIYE_js.analyzeCodeWithAST; }
29
29
  });
30
30
  Object.defineProperty(exports, "componentRegistry", {
31
31
  enumerable: true,
32
- get: function () { return chunk4ZZ6E4RS_js.componentRegistry; }
32
+ get: function () { return chunk365WGIYE_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-SCECUJGJ.mjs';
4
- export { analyzeCodeWithAST, componentRegistry } from './chunk-ZW3HD2OD.mjs';
3
+ export { validateCode, validateCodeSync } from './chunk-TTMAMBZV.mjs';
4
+ export { analyzeCodeWithAST, componentRegistry } from './chunk-7S3VAJP7.mjs';
5
5
  export { validateRuntimePrecheck } from './chunk-6HOIRUQB.mjs';
6
6
  export { compileSFC, scopeStyles } from './chunk-4OTQAQ6J.mjs';
7
7
  import './chunk-QC6VTSA3.mjs';
@@ -16,7 +16,7 @@ import { Card, CardColumn } from '@king-design/vue';
16
16
  | --- | --- | --- | --- | --- | --- | --- |
17
17
  | title | `string | VNode` | `undefined` | 否 | 卡片标题 | - | `<Card title="卡片标题">内容</Card>` |
18
18
  | type | `"shadow" | "border" | "none"` | `"shadow"` | 否 | 卡片类型,决定卡片的视觉样式 | - | `<Card type="border" title="边框卡片">内容</Card>` |
19
- | size | `"default" | "small" | "mini"` | `"default"` | 否 | 卡片尺寸 | - | `<Card size="small" title="小卡片">内容</Card>` |
19
+ | size | `"large" | "default" | "small" | "mini"` | `"default"` | 否 | 卡片尺寸 | - | `<Card size="small" title="小卡片">内容</Card>` |
20
20
 
21
21
  ## 插槽 (Slots)
22
22
  | 插槽名 | 说明 | 模板写法 | 示例 |
@@ -274,4 +274,3 @@ const items = ref([
274
274
 
275
275
  ## 相关组件
276
276
  CardColumn, Collapse
277
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "king-design-analyzer",
3
- "version": "2.2.5",
3
+ "version": "2.2.8",
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",