king-design-analyzer 1.0.2 → 1.0.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/dist/ast/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  require('../chunk-YTEYDSDW.js');
4
- var chunkDVIHET2R_js = require('../chunk-DVIHET2R.js');
4
+ var chunk6S2QBZUD_js = require('../chunk-6S2QBZUD.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "analyzeCodeWithAST", {
9
9
  enumerable: true,
10
- get: function () { return chunkDVIHET2R_js.analyzeCodeWithAST; }
10
+ get: function () { return chunk6S2QBZUD_js.analyzeCodeWithAST; }
11
11
  });
12
12
  Object.defineProperty(exports, "componentRegistry", {
13
13
  enumerable: true,
14
- get: function () { return chunkDVIHET2R_js.componentRegistry; }
14
+ get: function () { return chunk6S2QBZUD_js.componentRegistry; }
15
15
  });
@@ -1,2 +1,2 @@
1
1
  import '../chunk-5H7N2A5X.mjs';
2
- export { analyzeCodeWithAST, componentRegistry } from '../chunk-FT4HL7ZJ.mjs';
2
+ export { analyzeCodeWithAST, componentRegistry } from '../chunk-6QIOW6QE.mjs';
@@ -526,12 +526,12 @@ function checkTemplate(node, violations, parentTagName) {
526
526
  if (prop.type === 6) {
527
527
  const propName = prop.name;
528
528
  const camelCaseProp = propName.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
529
- const isPropValid = metadata.props.some(
529
+ const isPropValid = metadata.props?.some(
530
530
  (p) => p.name === propName || p.name === camelCaseProp || p.name.toLowerCase() === propName.toLowerCase()
531
531
  );
532
532
  const isDynamicallyAllowed = dynamicAllowedProps.includes(propName);
533
533
  if (!isPropValid && !isDynamicallyAllowed && !["class", "style", "key", "ref"].includes(propName) && !propName.startsWith("data-")) {
534
- if (metadata.props.length > 0) {
534
+ if (metadata.props && metadata.props.length > 0) {
535
535
  violations.push({
536
536
  rule: `\u5C5E\u6027 ${propName} \u4E0D\u5B58\u5728\u4E8E ${tagName}`,
537
537
  match: propName,
@@ -539,7 +539,7 @@ function checkTemplate(node, violations, parentTagName) {
539
539
  });
540
540
  }
541
541
  }
542
- if (isPropValid) {
542
+ if (isPropValid && metadata.props) {
543
543
  const targetProp = metadata.props.find(
544
544
  (p) => p.name === propName || p.name === camelCaseProp || p.name.toLowerCase() === propName.toLowerCase()
545
545
  );
@@ -575,7 +575,7 @@ function checkTemplate(node, violations, parentTagName) {
575
575
  return;
576
576
  }
577
577
  const camelCaseEvent = eventName.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
578
- const isEventValid = metadata.events.some(
578
+ const isEventValid = metadata.events?.some(
579
579
  (e) => e.name === eventName || e.name === camelCaseEvent || e.name.toLowerCase() === eventName.toLowerCase()
580
580
  );
581
581
  const nativeEvents = [
@@ -602,7 +602,7 @@ function checkTemplate(node, violations, parentTagName) {
602
602
  "touchmove"
603
603
  ];
604
604
  const isNativeEvent = nativeEvents.includes(eventName);
605
- if (!isEventValid && !isNativeEvent && metadata.events.length > 0) {
605
+ if (!isEventValid && !isNativeEvent && metadata.events && metadata.events.length > 0) {
606
606
  violations.push({
607
607
  rule: `\u4E8B\u4EF6 @${eventName} \u4E0D\u5B58\u5728\u4E8E ${tagName}`,
608
608
  match: `@${eventName}`,
@@ -612,13 +612,13 @@ function checkTemplate(node, violations, parentTagName) {
612
612
  }
613
613
  }
614
614
  });
615
- if (node.children && metadata.slots && metadata.slots.length > 0) {
615
+ if (node.children && metadata.slots?.length > 0) {
616
616
  node.children.forEach((child) => {
617
617
  if (child.type === 1 && child.tag === "template") {
618
618
  child.props.forEach((prop) => {
619
619
  if (prop.type === 7 && prop.name === "slot") {
620
620
  const slotName = prop.arg?.content || "default";
621
- const isSlotValid = metadata.slots.some((s) => s.name === slotName);
621
+ const isSlotValid = metadata.slots?.some((s) => s.name === slotName);
622
622
  if (!isSlotValid) {
623
623
  violations.push({
624
624
  rule: `\u63D2\u69FD #${slotName} \u4E0D\u5B58\u5728\u4E8E ${tagName}`,
@@ -551,12 +551,12 @@ function checkTemplate(node, violations, parentTagName) {
551
551
  if (prop.type === 6) {
552
552
  const propName = prop.name;
553
553
  const camelCaseProp = propName.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
554
- const isPropValid = metadata.props.some(
554
+ const isPropValid = metadata.props?.some(
555
555
  (p) => p.name === propName || p.name === camelCaseProp || p.name.toLowerCase() === propName.toLowerCase()
556
556
  );
557
557
  const isDynamicallyAllowed = dynamicAllowedProps.includes(propName);
558
558
  if (!isPropValid && !isDynamicallyAllowed && !["class", "style", "key", "ref"].includes(propName) && !propName.startsWith("data-")) {
559
- if (metadata.props.length > 0) {
559
+ if (metadata.props && metadata.props.length > 0) {
560
560
  violations.push({
561
561
  rule: `\u5C5E\u6027 ${propName} \u4E0D\u5B58\u5728\u4E8E ${tagName}`,
562
562
  match: propName,
@@ -564,7 +564,7 @@ function checkTemplate(node, violations, parentTagName) {
564
564
  });
565
565
  }
566
566
  }
567
- if (isPropValid) {
567
+ if (isPropValid && metadata.props) {
568
568
  const targetProp = metadata.props.find(
569
569
  (p) => p.name === propName || p.name === camelCaseProp || p.name.toLowerCase() === propName.toLowerCase()
570
570
  );
@@ -600,7 +600,7 @@ function checkTemplate(node, violations, parentTagName) {
600
600
  return;
601
601
  }
602
602
  const camelCaseEvent = eventName.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
603
- const isEventValid = metadata.events.some(
603
+ const isEventValid = metadata.events?.some(
604
604
  (e) => e.name === eventName || e.name === camelCaseEvent || e.name.toLowerCase() === eventName.toLowerCase()
605
605
  );
606
606
  const nativeEvents = [
@@ -627,7 +627,7 @@ function checkTemplate(node, violations, parentTagName) {
627
627
  "touchmove"
628
628
  ];
629
629
  const isNativeEvent = nativeEvents.includes(eventName);
630
- if (!isEventValid && !isNativeEvent && metadata.events.length > 0) {
630
+ if (!isEventValid && !isNativeEvent && metadata.events && metadata.events.length > 0) {
631
631
  violations.push({
632
632
  rule: `\u4E8B\u4EF6 @${eventName} \u4E0D\u5B58\u5728\u4E8E ${tagName}`,
633
633
  match: `@${eventName}`,
@@ -637,13 +637,13 @@ function checkTemplate(node, violations, parentTagName) {
637
637
  }
638
638
  }
639
639
  });
640
- if (node.children && metadata.slots && metadata.slots.length > 0) {
640
+ if (node.children && metadata.slots?.length > 0) {
641
641
  node.children.forEach((child) => {
642
642
  if (child.type === 1 && child.tag === "template") {
643
643
  child.props.forEach((prop) => {
644
644
  if (prop.type === 7 && prop.name === "slot") {
645
645
  const slotName = prop.arg?.content || "default";
646
- const isSlotValid = metadata.slots.some((s) => s.name === slotName);
646
+ const isSlotValid = metadata.slots?.some((s) => s.name === slotName);
647
647
  if (!isSlotValid) {
648
648
  violations.push({
649
649
  rule: `\u63D2\u69FD #${slotName} \u4E0D\u5B58\u5728\u4E8E ${tagName}`,
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkDVIHET2R_js = require('./chunk-DVIHET2R.js');
3
+ var chunk6S2QBZUD_js = require('./chunk-6S2QBZUD.js');
4
4
  var chunkUIHTWWBN_js = require('./chunk-UIHTWWBN.js');
5
5
 
6
6
  // src/tools/unifiedValidator.ts
@@ -63,7 +63,7 @@ function validateCompilation(code) {
63
63
  }
64
64
  async function validateAST(code) {
65
65
  try {
66
- const violations = await chunkDVIHET2R_js.analyzeCodeWithAST(code);
66
+ const violations = await chunk6S2QBZUD_js.analyzeCodeWithAST(code);
67
67
  if (violations.length > 0) {
68
68
  return {
69
69
  name: "AST\u89C4\u5219\u68C0\u67E5",
@@ -1,4 +1,4 @@
1
- import { analyzeCodeWithAST } from './chunk-FT4HL7ZJ.mjs';
1
+ import { analyzeCodeWithAST } from './chunk-6QIOW6QE.mjs';
2
2
  import { compileSFC } from './chunk-RPNK7QXK.mjs';
3
3
 
4
4
  // src/tools/unifiedValidator.ts
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkWULARPGF_js = require('../chunk-WULARPGF.js');
4
- require('../chunk-DVIHET2R.js');
3
+ var chunkPH2WUQZA_js = require('../chunk-PH2WUQZA.js');
4
+ require('../chunk-6S2QBZUD.js');
5
5
  require('../chunk-UIHTWWBN.js');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, "validateCode", {
10
10
  enumerable: true,
11
- get: function () { return chunkWULARPGF_js.validateCode; }
11
+ get: function () { return chunkPH2WUQZA_js.validateCode; }
12
12
  });
13
13
  Object.defineProperty(exports, "validateCodeSync", {
14
14
  enumerable: true,
15
- get: function () { return chunkWULARPGF_js.validateCodeSync; }
15
+ get: function () { return chunkPH2WUQZA_js.validateCodeSync; }
16
16
  });
@@ -1,3 +1,3 @@
1
- export { validateCode, validateCodeSync } from '../chunk-YP57ELM4.mjs';
2
- import '../chunk-FT4HL7ZJ.mjs';
1
+ export { validateCode, validateCodeSync } from '../chunk-YCVB3UOP.mjs';
2
+ import '../chunk-6QIOW6QE.mjs';
3
3
  import '../chunk-RPNK7QXK.mjs';
package/dist/index.js CHANGED
@@ -3,8 +3,8 @@
3
3
  var chunkFQBDUMJD_js = require('./chunk-FQBDUMJD.js');
4
4
  require('./chunk-YTEYDSDW.js');
5
5
  var chunkVF5B4PW7_js = require('./chunk-VF5B4PW7.js');
6
- var chunkWULARPGF_js = require('./chunk-WULARPGF.js');
7
- var chunkDVIHET2R_js = require('./chunk-DVIHET2R.js');
6
+ var chunkPH2WUQZA_js = require('./chunk-PH2WUQZA.js');
7
+ var chunk6S2QBZUD_js = require('./chunk-6S2QBZUD.js');
8
8
  var chunkUIHTWWBN_js = require('./chunk-UIHTWWBN.js');
9
9
 
10
10
 
@@ -19,19 +19,19 @@ Object.defineProperty(exports, "validateRuntimePrecheck", {
19
19
  });
20
20
  Object.defineProperty(exports, "validateCode", {
21
21
  enumerable: true,
22
- get: function () { return chunkWULARPGF_js.validateCode; }
22
+ get: function () { return chunkPH2WUQZA_js.validateCode; }
23
23
  });
24
24
  Object.defineProperty(exports, "validateCodeSync", {
25
25
  enumerable: true,
26
- get: function () { return chunkWULARPGF_js.validateCodeSync; }
26
+ get: function () { return chunkPH2WUQZA_js.validateCodeSync; }
27
27
  });
28
28
  Object.defineProperty(exports, "analyzeCodeWithAST", {
29
29
  enumerable: true,
30
- get: function () { return chunkDVIHET2R_js.analyzeCodeWithAST; }
30
+ get: function () { return chunk6S2QBZUD_js.analyzeCodeWithAST; }
31
31
  });
32
32
  Object.defineProperty(exports, "componentRegistry", {
33
33
  enumerable: true,
34
- get: function () { return chunkDVIHET2R_js.componentRegistry; }
34
+ get: function () { return chunk6S2QBZUD_js.componentRegistry; }
35
35
  });
36
36
  Object.defineProperty(exports, "compileSFC", {
37
37
  enumerable: true,
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  export { validateCompilation } from './chunk-DJVJXIT7.mjs';
2
2
  import './chunk-5H7N2A5X.mjs';
3
3
  export { validateRuntimePrecheck } from './chunk-DHO63GQC.mjs';
4
- export { validateCode, validateCodeSync } from './chunk-YP57ELM4.mjs';
5
- export { analyzeCodeWithAST, componentRegistry } from './chunk-FT4HL7ZJ.mjs';
4
+ export { validateCode, validateCodeSync } from './chunk-YCVB3UOP.mjs';
5
+ export { analyzeCodeWithAST, componentRegistry } from './chunk-6QIOW6QE.mjs';
6
6
  export { compileSFC, scopeStyles } from './chunk-RPNK7QXK.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "king-design-analyzer",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
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",