king-design-analyzer 2.1.3 → 2.1.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.
- package/dist/{chunk-2L37YJOJ.js → chunk-2FV6BC3K.js} +29 -3
- package/dist/{chunk-Y77A3DEY.js → chunk-32HIMGM4.js} +2 -2
- package/dist/{chunk-4G533OEX.mjs → chunk-CVJFFX7X.mjs} +2 -2
- package/dist/{chunk-RHPVVTOE.js → chunk-D6QDTSMN.js} +5 -5
- package/dist/{chunk-WJAGRAWV.mjs → chunk-JAICJP7Q.mjs} +29 -3
- package/dist/{chunk-ZONZNAWA.mjs → chunk-KWZGUEDK.mjs} +2 -2
- package/dist/{chunk-YYKRQHUZ.mjs → chunk-UV564QXV.mjs} +1 -1
- package/dist/{chunk-REPE4KTQ.js → chunk-XKMKIWYX.js} +2 -2
- package/dist/full/index.js +5 -5
- package/dist/full/index.mjs +3 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -10
- package/dist/index.mjs +4 -4
- package/dist/runtime/index.d.mts +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +4 -4
- package/dist/runtime/index.mjs +2 -2
- package/dist/{sfcCompiler-m51JOfWs.d.mts → sfcCompiler-Co_Km3LU.d.mts} +16 -1
- package/dist/{sfcCompiler-m51JOfWs.d.ts → sfcCompiler-Co_Km3LU.d.ts} +16 -1
- package/dist/static/index.d.mts +1 -1
- package/dist/static/index.d.ts +1 -1
- package/dist/static/index.js +5 -5
- package/dist/static/index.mjs +2 -2
- package/package.json +2 -1
|
@@ -24,6 +24,12 @@ function _interopNamespace(e) {
|
|
|
24
24
|
var ts__namespace = /*#__PURE__*/_interopNamespace(ts);
|
|
25
25
|
|
|
26
26
|
// src/tools/sfcCompiler.ts
|
|
27
|
+
var ALLOWED_IMPORT_SOURCES = [
|
|
28
|
+
"vue",
|
|
29
|
+
"@vue/",
|
|
30
|
+
"@king-design/vue",
|
|
31
|
+
"@ksyun-internal/versatile"
|
|
32
|
+
];
|
|
27
33
|
function scopeStyles(css, scopeClass) {
|
|
28
34
|
return css.replace(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g, (match, selector, suffix) => {
|
|
29
35
|
if (selector.trim().startsWith("@")) return match;
|
|
@@ -35,7 +41,9 @@ function scopeStyles(css, scopeClass) {
|
|
|
35
41
|
return `${scopedSelector}${suffix}`;
|
|
36
42
|
});
|
|
37
43
|
}
|
|
38
|
-
function compileSFC(code, scopeId) {
|
|
44
|
+
function compileSFC(code, scopeId, options) {
|
|
45
|
+
const whitelist = options?.allowedImports ?? ALLOWED_IMPORT_SOURCES;
|
|
46
|
+
const strippedImports = [];
|
|
39
47
|
try {
|
|
40
48
|
const templateMatch = code.match(/<template>([\s\S]*)<\/template>/);
|
|
41
49
|
const scriptMatch = code.match(/<script[\s\S]*?>([\s\S]*)<\/script>/);
|
|
@@ -48,8 +56,25 @@ function compileSFC(code, scopeId) {
|
|
|
48
56
|
return { template: "", script: "", style: "", bindings: [] };
|
|
49
57
|
}
|
|
50
58
|
let cleanScript = script;
|
|
51
|
-
cleanScript = cleanScript.replace(/import\s+[\s\S]*?from\s+['"].*?['"];?/g, "");
|
|
52
59
|
cleanScript = cleanScript.replace(/import\s+type\s+[\s\S]*?from\s+['"].*?['"];?/g, "");
|
|
60
|
+
cleanScript = cleanScript.replace(
|
|
61
|
+
/import\s+[\s\S]*?from\s+['"]([^'"]+)['"];?/g,
|
|
62
|
+
(match, source) => {
|
|
63
|
+
const isWhitelisted = whitelist.some(
|
|
64
|
+
(w) => source === w || source.startsWith(w + "/")
|
|
65
|
+
);
|
|
66
|
+
if (isWhitelisted) {
|
|
67
|
+
strippedImports.push({ source, reason: "whitelisted" });
|
|
68
|
+
return "";
|
|
69
|
+
}
|
|
70
|
+
if (source.startsWith(".")) {
|
|
71
|
+
strippedImports.push({ source, reason: "relative" });
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
strippedImports.push({ source, reason: "unknown" });
|
|
75
|
+
return "";
|
|
76
|
+
}
|
|
77
|
+
);
|
|
53
78
|
const result = sucrase.transform(cleanScript, {
|
|
54
79
|
transforms: ["typescript"],
|
|
55
80
|
disableESTransforms: true
|
|
@@ -92,7 +117,8 @@ function compileSFC(code, scopeId) {
|
|
|
92
117
|
template,
|
|
93
118
|
script: cleanScript,
|
|
94
119
|
style,
|
|
95
|
-
bindings: [...varNames]
|
|
120
|
+
bindings: [...varNames],
|
|
121
|
+
strippedImports: strippedImports.length > 0 ? strippedImports : void 0
|
|
96
122
|
};
|
|
97
123
|
} catch (e) {
|
|
98
124
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2FV6BC3K_js = require('./chunk-2FV6BC3K.js');
|
|
4
4
|
|
|
5
5
|
// src/runtime/index.ts
|
|
6
6
|
var scopeIdCounter = 0;
|
|
@@ -86,7 +86,7 @@ var MOCK_VUE_CONTEXT = {
|
|
|
86
86
|
};
|
|
87
87
|
function validateRuntimePrecheck(code) {
|
|
88
88
|
const scopeId = `runtime-${Date.now()}-${++scopeIdCounter}`;
|
|
89
|
-
const { script, bindings, error } =
|
|
89
|
+
const { script, bindings, strippedImports, error } = chunk2FV6BC3K_js.compileSFC(code, scopeId);
|
|
90
90
|
if (error) {
|
|
91
91
|
return {
|
|
92
92
|
name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { analyzeCodeWithAST } from './chunk-UYVGHUC5.mjs';
|
|
2
|
-
import { validateRuntimePrecheck } from './chunk-
|
|
3
|
-
import { compileSFC } from './chunk-
|
|
2
|
+
import { validateRuntimePrecheck } from './chunk-KWZGUEDK.mjs';
|
|
3
|
+
import { compileSFC } from './chunk-JAICJP7Q.mjs';
|
|
4
4
|
|
|
5
5
|
// src/tools/unifiedValidator.ts
|
|
6
6
|
function validateCompilation(code) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkGW5YOUB7_js = require('./chunk-GW5YOUB7.js');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunk32HIMGM4_js = require('./chunk-32HIMGM4.js');
|
|
5
|
+
var chunk2FV6BC3K_js = require('./chunk-2FV6BC3K.js');
|
|
6
6
|
|
|
7
7
|
// src/tools/unifiedValidator.ts
|
|
8
8
|
function validateCompilation(code) {
|
|
@@ -41,7 +41,7 @@ function validateCompilation(code) {
|
|
|
41
41
|
errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 <template> \u6216 <script> \u6807\u7B7E"]
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
const result =
|
|
44
|
+
const result = chunk2FV6BC3K_js.compileSFC(code, scopeId);
|
|
45
45
|
if (result.error) {
|
|
46
46
|
return {
|
|
47
47
|
name: "\u7F16\u8BD1\u68C0\u67E5",
|
|
@@ -110,7 +110,7 @@ async function validateCode(code) {
|
|
|
110
110
|
summary: `\u274C AST\u89C4\u5219\u8FDD\u89C4 (${astResult.errors.length}\u9879)`
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
const runtimeResult =
|
|
113
|
+
const runtimeResult = chunk32HIMGM4_js.validateRuntimePrecheck(code);
|
|
114
114
|
if (!runtimeResult.passed) {
|
|
115
115
|
return {
|
|
116
116
|
passed: false,
|
|
@@ -144,7 +144,7 @@ function validateCodeSync(code) {
|
|
|
144
144
|
summary: `\u274C \u7F16\u8BD1\u5931\u8D25: ${compilationResult.errors[0]}`
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
|
-
const runtimeResult =
|
|
147
|
+
const runtimeResult = chunk32HIMGM4_js.validateRuntimePrecheck(code);
|
|
148
148
|
return {
|
|
149
149
|
passed: runtimeResult.passed,
|
|
150
150
|
layers: {
|
|
@@ -2,6 +2,12 @@ import { transform } from 'sucrase';
|
|
|
2
2
|
import * as ts from 'typescript';
|
|
3
3
|
|
|
4
4
|
// src/tools/sfcCompiler.ts
|
|
5
|
+
var ALLOWED_IMPORT_SOURCES = [
|
|
6
|
+
"vue",
|
|
7
|
+
"@vue/",
|
|
8
|
+
"@king-design/vue",
|
|
9
|
+
"@ksyun-internal/versatile"
|
|
10
|
+
];
|
|
5
11
|
function scopeStyles(css, scopeClass) {
|
|
6
12
|
return css.replace(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g, (match, selector, suffix) => {
|
|
7
13
|
if (selector.trim().startsWith("@")) return match;
|
|
@@ -13,7 +19,9 @@ function scopeStyles(css, scopeClass) {
|
|
|
13
19
|
return `${scopedSelector}${suffix}`;
|
|
14
20
|
});
|
|
15
21
|
}
|
|
16
|
-
function compileSFC(code, scopeId) {
|
|
22
|
+
function compileSFC(code, scopeId, options) {
|
|
23
|
+
const whitelist = options?.allowedImports ?? ALLOWED_IMPORT_SOURCES;
|
|
24
|
+
const strippedImports = [];
|
|
17
25
|
try {
|
|
18
26
|
const templateMatch = code.match(/<template>([\s\S]*)<\/template>/);
|
|
19
27
|
const scriptMatch = code.match(/<script[\s\S]*?>([\s\S]*)<\/script>/);
|
|
@@ -26,8 +34,25 @@ function compileSFC(code, scopeId) {
|
|
|
26
34
|
return { template: "", script: "", style: "", bindings: [] };
|
|
27
35
|
}
|
|
28
36
|
let cleanScript = script;
|
|
29
|
-
cleanScript = cleanScript.replace(/import\s+[\s\S]*?from\s+['"].*?['"];?/g, "");
|
|
30
37
|
cleanScript = cleanScript.replace(/import\s+type\s+[\s\S]*?from\s+['"].*?['"];?/g, "");
|
|
38
|
+
cleanScript = cleanScript.replace(
|
|
39
|
+
/import\s+[\s\S]*?from\s+['"]([^'"]+)['"];?/g,
|
|
40
|
+
(match, source) => {
|
|
41
|
+
const isWhitelisted = whitelist.some(
|
|
42
|
+
(w) => source === w || source.startsWith(w + "/")
|
|
43
|
+
);
|
|
44
|
+
if (isWhitelisted) {
|
|
45
|
+
strippedImports.push({ source, reason: "whitelisted" });
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
if (source.startsWith(".")) {
|
|
49
|
+
strippedImports.push({ source, reason: "relative" });
|
|
50
|
+
return "";
|
|
51
|
+
}
|
|
52
|
+
strippedImports.push({ source, reason: "unknown" });
|
|
53
|
+
return "";
|
|
54
|
+
}
|
|
55
|
+
);
|
|
31
56
|
const result = transform(cleanScript, {
|
|
32
57
|
transforms: ["typescript"],
|
|
33
58
|
disableESTransforms: true
|
|
@@ -70,7 +95,8 @@ function compileSFC(code, scopeId) {
|
|
|
70
95
|
template,
|
|
71
96
|
script: cleanScript,
|
|
72
97
|
style,
|
|
73
|
-
bindings: [...varNames]
|
|
98
|
+
bindings: [...varNames],
|
|
99
|
+
strippedImports: strippedImports.length > 0 ? strippedImports : void 0
|
|
74
100
|
};
|
|
75
101
|
} catch (e) {
|
|
76
102
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compileSFC } from './chunk-
|
|
1
|
+
import { compileSFC } from './chunk-JAICJP7Q.mjs';
|
|
2
2
|
|
|
3
3
|
// src/runtime/index.ts
|
|
4
4
|
var scopeIdCounter = 0;
|
|
@@ -84,7 +84,7 @@ var MOCK_VUE_CONTEXT = {
|
|
|
84
84
|
};
|
|
85
85
|
function validateRuntimePrecheck(code) {
|
|
86
86
|
const scopeId = `runtime-${Date.now()}-${++scopeIdCounter}`;
|
|
87
|
-
const { script, bindings, error } = compileSFC(code, scopeId);
|
|
87
|
+
const { script, bindings, strippedImports, error } = compileSFC(code, scopeId);
|
|
88
88
|
if (error) {
|
|
89
89
|
return {
|
|
90
90
|
name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2FV6BC3K_js = require('./chunk-2FV6BC3K.js');
|
|
4
4
|
|
|
5
5
|
// src/static/index.ts
|
|
6
6
|
var scopeIdCounter = 0;
|
|
@@ -44,7 +44,7 @@ function validateCompilation(code) {
|
|
|
44
44
|
errors: ["SFC \u7ED3\u6784\u9519\u8BEF: \u7F3A\u5C11 <template> \u6216 <script> \u6807\u7B7E"]
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
const result =
|
|
47
|
+
const result = chunk2FV6BC3K_js.compileSFC(code, scopeId);
|
|
48
48
|
if (result.error) {
|
|
49
49
|
return {
|
|
50
50
|
name: "\u7F16\u8BD1\u68C0\u67E5",
|
package/dist/full/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkD6QDTSMN_js = require('../chunk-D6QDTSMN.js');
|
|
4
4
|
require('../chunk-GW5YOUB7.js');
|
|
5
|
-
require('../chunk-
|
|
6
|
-
require('../chunk-
|
|
5
|
+
require('../chunk-32HIMGM4.js');
|
|
6
|
+
require('../chunk-2FV6BC3K.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "validateCode", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkD6QDTSMN_js.validateCode; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "validateCodeSync", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkD6QDTSMN_js.validateCodeSync; }
|
|
17
17
|
});
|
package/dist/full/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { validateCode, validateCodeSync } from '../chunk-
|
|
1
|
+
export { validateCode, validateCodeSync } from '../chunk-CVJFFX7X.mjs';
|
|
2
2
|
import '../chunk-UYVGHUC5.mjs';
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-KWZGUEDK.mjs';
|
|
4
|
+
import '../chunk-JAICJP7Q.mjs';
|
package/dist/index.d.mts
CHANGED
|
@@ -2,4 +2,4 @@ export { ValidationLayer as StaticValidationLayer, validateCompilation } from '.
|
|
|
2
2
|
export { ComponentEvent, ComponentMetadata, ComponentProp, ComponentSlot, MistakeEntry, RuleViolation, analyzeCodeWithAST, componentRegistry } from './ast/index.mjs';
|
|
3
3
|
export { ValidationLayer as RuntimeValidationLayer, validateRuntimePrecheck } from './runtime/index.mjs';
|
|
4
4
|
export { UnifiedValidationResult, ValidationLayer, validateCode, validateCodeSync } from './full/index.mjs';
|
|
5
|
-
export { C as CompilationResult, c as compileSFC, s as scopeStyles } from './sfcCompiler-
|
|
5
|
+
export { C as CompilationResult, c as compileSFC, s as scopeStyles } from './sfcCompiler-Co_Km3LU.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { ValidationLayer as StaticValidationLayer, validateCompilation } from '.
|
|
|
2
2
|
export { ComponentEvent, ComponentMetadata, ComponentProp, ComponentSlot, MistakeEntry, RuleViolation, analyzeCodeWithAST, componentRegistry } from './ast/index.js';
|
|
3
3
|
export { ValidationLayer as RuntimeValidationLayer, validateRuntimePrecheck } from './runtime/index.js';
|
|
4
4
|
export { UnifiedValidationResult, ValidationLayer, validateCode, validateCodeSync } from './full/index.js';
|
|
5
|
-
export { C as CompilationResult, c as compileSFC, s as scopeStyles } from './sfcCompiler-
|
|
5
|
+
export { C as CompilationResult, c as compileSFC, s as scopeStyles } from './sfcCompiler-Co_Km3LU.js';
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkXKMKIWYX_js = require('./chunk-XKMKIWYX.js');
|
|
4
4
|
require('./chunk-YTEYDSDW.js');
|
|
5
|
-
var
|
|
5
|
+
var chunkD6QDTSMN_js = require('./chunk-D6QDTSMN.js');
|
|
6
6
|
var chunkGW5YOUB7_js = require('./chunk-GW5YOUB7.js');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var chunk32HIMGM4_js = require('./chunk-32HIMGM4.js');
|
|
8
|
+
var chunk2FV6BC3K_js = require('./chunk-2FV6BC3K.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
Object.defineProperty(exports, "validateCompilation", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkXKMKIWYX_js.validateCompilation; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "validateCode", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkD6QDTSMN_js.validateCode; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "validateCodeSync", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkD6QDTSMN_js.validateCodeSync; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "analyzeCodeWithAST", {
|
|
25
25
|
enumerable: true,
|
|
@@ -31,13 +31,13 @@ Object.defineProperty(exports, "componentRegistry", {
|
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "validateRuntimePrecheck", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunk32HIMGM4_js.validateRuntimePrecheck; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "compileSFC", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunk2FV6BC3K_js.compileSFC; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "scopeStyles", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunk2FV6BC3K_js.scopeStyles; }
|
|
43
43
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { validateCompilation } from './chunk-
|
|
1
|
+
export { validateCompilation } from './chunk-UV564QXV.mjs';
|
|
2
2
|
import './chunk-5H7N2A5X.mjs';
|
|
3
|
-
export { validateCode, validateCodeSync } from './chunk-
|
|
3
|
+
export { validateCode, validateCodeSync } from './chunk-CVJFFX7X.mjs';
|
|
4
4
|
export { analyzeCodeWithAST, componentRegistry } from './chunk-UYVGHUC5.mjs';
|
|
5
|
-
export { validateRuntimePrecheck } from './chunk-
|
|
6
|
-
export { compileSFC, scopeStyles } from './chunk-
|
|
5
|
+
export { validateRuntimePrecheck } from './chunk-KWZGUEDK.mjs';
|
|
6
|
+
export { compileSFC, scopeStyles } from './chunk-JAICJP7Q.mjs';
|
package/dist/runtime/index.d.mts
CHANGED
package/dist/runtime/index.d.ts
CHANGED
package/dist/runtime/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk32HIMGM4_js = require('../chunk-32HIMGM4.js');
|
|
4
|
+
var chunk2FV6BC3K_js = require('../chunk-2FV6BC3K.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "validateRuntimePrecheck", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunk32HIMGM4_js.validateRuntimePrecheck; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "compileSFC", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunk2FV6BC3K_js.compileSFC; }
|
|
15
15
|
});
|
package/dist/runtime/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { validateRuntimePrecheck } from '../chunk-
|
|
2
|
-
export { compileSFC } from '../chunk-
|
|
1
|
+
export { validateRuntimePrecheck } from '../chunk-KWZGUEDK.mjs';
|
|
2
|
+
export { compileSFC } from '../chunk-JAICJP7Q.mjs';
|
|
@@ -3,8 +3,22 @@ interface CompilationResult {
|
|
|
3
3
|
script: string;
|
|
4
4
|
style: string;
|
|
5
5
|
bindings: string[];
|
|
6
|
+
/** 被移除的导入信息(用于调试) */
|
|
7
|
+
strippedImports?: StrippedImport[];
|
|
6
8
|
error?: string;
|
|
7
9
|
}
|
|
10
|
+
interface StrippedImport {
|
|
11
|
+
source: string;
|
|
12
|
+
reason: 'whitelisted' | 'relative' | 'unknown';
|
|
13
|
+
}
|
|
14
|
+
interface CompileSFCOptions {
|
|
15
|
+
/**
|
|
16
|
+
* 允许的模块导入来源白名单
|
|
17
|
+
* 匹配规则:模块名以白名单项开头即视为匹配
|
|
18
|
+
* 例如:'vue' 会匹配 'vue' 和 'vue/xxx'
|
|
19
|
+
*/
|
|
20
|
+
allowedImports?: string[];
|
|
21
|
+
}
|
|
8
22
|
/**
|
|
9
23
|
* Scopes CSS by prepending a unique class to selectors.
|
|
10
24
|
* Matches {selector} { ... } blocks.
|
|
@@ -15,8 +29,9 @@ declare function scopeStyles(css: string, scopeClass: string): string;
|
|
|
15
29
|
*
|
|
16
30
|
* @param code The SFC code string
|
|
17
31
|
* @param scopeId A unique ID for CSS scoping (e.g. 'preview-scope-123')
|
|
32
|
+
* @param options Optional configuration for import handling
|
|
18
33
|
* @returns CompilationResult containing extracted parts and transformed script
|
|
19
34
|
*/
|
|
20
|
-
declare function compileSFC(code: string, scopeId: string): CompilationResult;
|
|
35
|
+
declare function compileSFC(code: string, scopeId: string, options?: CompileSFCOptions): CompilationResult;
|
|
21
36
|
|
|
22
37
|
export { type CompilationResult as C, compileSFC as c, scopeStyles as s };
|
|
@@ -3,8 +3,22 @@ interface CompilationResult {
|
|
|
3
3
|
script: string;
|
|
4
4
|
style: string;
|
|
5
5
|
bindings: string[];
|
|
6
|
+
/** 被移除的导入信息(用于调试) */
|
|
7
|
+
strippedImports?: StrippedImport[];
|
|
6
8
|
error?: string;
|
|
7
9
|
}
|
|
10
|
+
interface StrippedImport {
|
|
11
|
+
source: string;
|
|
12
|
+
reason: 'whitelisted' | 'relative' | 'unknown';
|
|
13
|
+
}
|
|
14
|
+
interface CompileSFCOptions {
|
|
15
|
+
/**
|
|
16
|
+
* 允许的模块导入来源白名单
|
|
17
|
+
* 匹配规则:模块名以白名单项开头即视为匹配
|
|
18
|
+
* 例如:'vue' 会匹配 'vue' 和 'vue/xxx'
|
|
19
|
+
*/
|
|
20
|
+
allowedImports?: string[];
|
|
21
|
+
}
|
|
8
22
|
/**
|
|
9
23
|
* Scopes CSS by prepending a unique class to selectors.
|
|
10
24
|
* Matches {selector} { ... } blocks.
|
|
@@ -15,8 +29,9 @@ declare function scopeStyles(css: string, scopeClass: string): string;
|
|
|
15
29
|
*
|
|
16
30
|
* @param code The SFC code string
|
|
17
31
|
* @param scopeId A unique ID for CSS scoping (e.g. 'preview-scope-123')
|
|
32
|
+
* @param options Optional configuration for import handling
|
|
18
33
|
* @returns CompilationResult containing extracted parts and transformed script
|
|
19
34
|
*/
|
|
20
|
-
declare function compileSFC(code: string, scopeId: string): CompilationResult;
|
|
35
|
+
declare function compileSFC(code: string, scopeId: string, options?: CompileSFCOptions): CompilationResult;
|
|
21
36
|
|
|
22
37
|
export { type CompilationResult as C, compileSFC as c, scopeStyles as s };
|
package/dist/static/index.d.mts
CHANGED
package/dist/static/index.d.ts
CHANGED
package/dist/static/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkXKMKIWYX_js = require('../chunk-XKMKIWYX.js');
|
|
4
|
+
var chunk2FV6BC3K_js = require('../chunk-2FV6BC3K.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "validateCompilation", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkXKMKIWYX_js.validateCompilation; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "compileSFC", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunk2FV6BC3K_js.compileSFC; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "scopeStyles", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunk2FV6BC3K_js.scopeStyles; }
|
|
19
19
|
});
|
package/dist/static/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { validateCompilation } from '../chunk-
|
|
2
|
-
export { compileSFC, scopeStyles } from '../chunk-
|
|
1
|
+
export { validateCompilation } from '../chunk-UV564QXV.mjs';
|
|
2
|
+
export { compileSFC, scopeStyles } from '../chunk-JAICJP7Q.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "king-design-analyzer",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.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",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"author": "",
|
|
77
77
|
"license": "MIT",
|
|
78
78
|
"dependencies": {
|
|
79
|
+
"king-design-analyzer": "^2.1.4",
|
|
79
80
|
"sucrase": "^3.35.1"
|
|
80
81
|
},
|
|
81
82
|
"peerDependencies": {
|