@vue/language-core 3.3.5 → 3.3.6
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/index.d.ts +1 -0
- package/index.js +1 -0
- package/lib/codegen/codeFeatures.d.ts +24 -84
- package/lib/codegen/codeFeatures.js +46 -4
- package/lib/codegen/names.d.ts +3 -4
- package/lib/codegen/names.js +3 -4
- package/lib/codegen/script/index.js +5 -5
- package/lib/codegen/script/scriptSetup.js +4 -4
- package/lib/codegen/style/common.js +7 -11
- package/lib/codegen/style/index.d.ts +55 -27
- package/lib/codegen/style/index.js +3 -3
- package/lib/codegen/template/context.d.ts +55 -124
- package/lib/codegen/template/context.js +187 -269
- package/lib/codegen/template/element.js +16 -15
- package/lib/codegen/template/elementDirectives.js +11 -11
- package/lib/codegen/template/elementEvents.js +45 -44
- package/lib/codegen/template/elementProps.js +12 -12
- package/lib/codegen/template/index.d.ts +55 -27
- package/lib/codegen/template/index.js +7 -7
- package/lib/codegen/template/interpolation.js +28 -28
- package/lib/codegen/template/objectProperty.js +5 -5
- package/lib/codegen/template/propertyAccess.js +1 -1
- package/lib/codegen/template/slotOutlet.js +8 -10
- package/lib/codegen/template/styleScopedClasses.js +4 -4
- package/lib/codegen/template/vFor.js +3 -3
- package/lib/codegen/template/vIf.js +4 -4
- package/lib/codegen/template/vSlot.js +9 -9
- package/lib/codegen/utils/boundary.d.ts +7 -2
- package/lib/codegen/utils/boundary.js +15 -9
- package/lib/codegen/utils/camelized.js +5 -13
- package/lib/codegen/utils/escaped.js +4 -9
- package/lib/codegen/utils/index.d.ts +1 -1
- package/lib/codegen/utils/index.js +3 -3
- package/lib/codegen/utils/stringLiteralKey.js +3 -3
- package/lib/codegen/utils/unicode.d.ts +1 -1
- package/lib/codegen/utils/unicode.js +4 -4
- package/lib/languagePlugin.js +2 -1
- package/lib/parsers/scriptRanges.d.ts +2 -2
- package/lib/parsers/scriptRanges.js +3 -10
- package/lib/parsers/scriptSetupRanges.d.ts +2 -2
- package/lib/parsers/scriptSetupRanges.js +3 -10
- package/lib/parsers/utils.d.ts +1 -0
- package/lib/parsers/utils.js +10 -0
- package/lib/parsers/vueCompilerOptions.js +2 -2
- package/lib/plugins/file-html.js +4 -4
- package/lib/plugins/file-md.js +15 -15
- package/lib/plugins/file-vue.js +2 -2
- package/lib/plugins/vue-root-tags.js +3 -3
- package/lib/plugins/vue-sfc-customblocks.js +2 -2
- package/lib/plugins/vue-sfc-scripts.js +2 -4
- package/lib/plugins/vue-sfc-styles.js +3 -3
- package/lib/plugins/vue-sfc-template.js +2 -2
- package/lib/plugins/vue-style-css.js +86 -33
- package/lib/plugins/vue-template-html.js +3 -3
- package/lib/plugins/vue-template-inline-css.js +2 -7
- package/lib/plugins/vue-template-inline-ts.js +4 -5
- package/lib/plugins/vue-tsx.d.ts +61 -31
- package/lib/plugins/vue-tsx.js +26 -23
- package/lib/plugins.d.ts +0 -1
- package/lib/plugins.js +0 -15
- package/lib/utils/forEachTemplateNode.js +36 -43
- package/lib/virtualCode/index.js +2 -2
- package/package.json +2 -2
- package/types/template-helpers.d.ts +14 -24
- package/lib/plugins/shared.d.ts +0 -2
- package/lib/plugins/shared.js +0 -12
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const codeFeatures_1 = require("../codegen/codeFeatures");
|
|
4
4
|
const plugin = () => {
|
|
5
5
|
return {
|
|
6
6
|
version: 2.2,
|
|
@@ -19,7 +19,7 @@ const plugin = () => {
|
|
|
19
19
|
ir.template.content,
|
|
20
20
|
ir.template.name,
|
|
21
21
|
0,
|
|
22
|
-
|
|
22
|
+
codeFeatures_1.codeFeatures.full,
|
|
23
23
|
]);
|
|
24
24
|
}
|
|
25
25
|
},
|
|
@@ -13,50 +13,103 @@ const plugin = () => {
|
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
exports.default = plugin;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
16
|
+
const cssImportRE = /(?<=@import\s+url\()(["']?).*?\1(?=\))|(?<=@import\b\s*)(["']).*?\2/g;
|
|
17
|
+
const cssBindingRE = /\bv-bind\s*\(/g;
|
|
18
|
+
const cssClassNameRE = /\.[a-z_][-\w]*(?=[\s.,+~>:#)[{])/gi;
|
|
19
|
+
const commentRE = /(?<=\/\*)[\s\S]*?(?=\*\/)|(?<=\/\/)[\s\S]*?(?=\n)/g;
|
|
20
|
+
const fragmentRE = /(?<={)[^{]*(?=(?<!\\);)/g;
|
|
21
21
|
function* parseCssImports(css) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
let text = match[0];
|
|
25
|
-
let offset = match.index;
|
|
26
|
-
if (text.startsWith("'") || text.startsWith('"')) {
|
|
27
|
-
text = text.slice(1, -1);
|
|
28
|
-
offset += 1;
|
|
29
|
-
}
|
|
30
|
-
if (text) {
|
|
31
|
-
yield { text, offset };
|
|
32
|
-
}
|
|
22
|
+
for (const match of css.matchAll(cssImportRE)) {
|
|
23
|
+
yield trimQuotes(match[0], match.index);
|
|
33
24
|
}
|
|
34
25
|
}
|
|
35
26
|
function* parseCssBindings(css) {
|
|
36
|
-
css = fillBlank(css,
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
yield { offset, text: matchText };
|
|
27
|
+
css = fillBlank(css, commentRE);
|
|
28
|
+
for (const match of css.matchAll(cssBindingRE)) {
|
|
29
|
+
const start = match.index + match[0].length;
|
|
30
|
+
const end = lexBinding(css, start);
|
|
31
|
+
if (end !== null) {
|
|
32
|
+
yield trimQuotes(css.slice(start, end), start, false);
|
|
43
33
|
}
|
|
44
34
|
}
|
|
45
35
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
var LexerState;
|
|
37
|
+
(function (LexerState) {
|
|
38
|
+
LexerState[LexerState["inParens"] = 0] = "inParens";
|
|
39
|
+
LexerState[LexerState["inSingleQuoteString"] = 1] = "inSingleQuoteString";
|
|
40
|
+
LexerState[LexerState["inDoubleQuoteString"] = 2] = "inDoubleQuoteString";
|
|
41
|
+
})(LexerState || (LexerState = {}));
|
|
42
|
+
// https://github.com/vuejs/core/blob/c0606e91798c8dca4f33d101e1dd836d672592c1/packages/compiler-sfc/src/style/cssVars.ts#L93
|
|
43
|
+
function lexBinding(content, start) {
|
|
44
|
+
let state = LexerState.inParens;
|
|
45
|
+
let parenDepth = 0;
|
|
46
|
+
for (let i = start; i < content.length; i++) {
|
|
47
|
+
const char = content.charAt(i);
|
|
48
|
+
switch (state) {
|
|
49
|
+
case LexerState.inParens:
|
|
50
|
+
if (char === `'`) {
|
|
51
|
+
state = LexerState.inSingleQuoteString;
|
|
52
|
+
}
|
|
53
|
+
else if (char === `"`) {
|
|
54
|
+
state = LexerState.inDoubleQuoteString;
|
|
55
|
+
}
|
|
56
|
+
else if (char === `(`) {
|
|
57
|
+
parenDepth++;
|
|
58
|
+
}
|
|
59
|
+
else if (char === `)`) {
|
|
60
|
+
if (parenDepth > 0) {
|
|
61
|
+
parenDepth--;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return i;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case LexerState.inSingleQuoteString:
|
|
69
|
+
if (char === `'`) {
|
|
70
|
+
state = LexerState.inParens;
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
case LexerState.inDoubleQuoteString:
|
|
74
|
+
if (char === `"`) {
|
|
75
|
+
state = LexerState.inParens;
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
53
78
|
}
|
|
54
79
|
}
|
|
80
|
+
return null;
|
|
55
81
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
82
|
+
function* parseCssClassNames(css) {
|
|
83
|
+
css = fillBlank(css, commentRE, fragmentRE);
|
|
84
|
+
for (const match of css.matchAll(cssClassNameRE)) {
|
|
85
|
+
yield { text: match[0], offset: match.index };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function fillBlank(css, ...patterns) {
|
|
89
|
+
for (const pattern of patterns) {
|
|
90
|
+
css = css.replace(pattern, match => ' '.repeat(match.length));
|
|
59
91
|
}
|
|
60
92
|
return css;
|
|
61
93
|
}
|
|
94
|
+
function trimQuotes(text, offset, trim = true) {
|
|
95
|
+
let start = 0;
|
|
96
|
+
let end = text.length;
|
|
97
|
+
if (trim || text.includes('"') || text.includes("'")) {
|
|
98
|
+
while (start < text.length && !text[start]?.trim()) {
|
|
99
|
+
start++;
|
|
100
|
+
}
|
|
101
|
+
while (end >= 0 && !text[end - 1]?.trim()) {
|
|
102
|
+
end--;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (text[start] === '"' && text[end - 1] === '"'
|
|
106
|
+
|| text[start] === "'" && text[end - 1] === "'") {
|
|
107
|
+
start++;
|
|
108
|
+
end--;
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
text: text.slice(start, end),
|
|
112
|
+
offset: offset + start,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
62
115
|
//# sourceMappingURL=vue-style-css.js.map
|
|
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
37
37
|
const compile_1 = require("../template/compile");
|
|
38
|
-
const
|
|
38
|
+
const shouldAddSuffixRE = /(?<=<[^>/]+)$/;
|
|
39
39
|
const plugin = () => {
|
|
40
40
|
return {
|
|
41
41
|
version: 2.2,
|
|
@@ -43,7 +43,7 @@ const plugin = () => {
|
|
|
43
43
|
if (lang === 'html' || lang === 'md') {
|
|
44
44
|
let addedSuffix = false;
|
|
45
45
|
// #4583
|
|
46
|
-
if (
|
|
46
|
+
if (shouldAddSuffixRE.test(template)) {
|
|
47
47
|
template += '>';
|
|
48
48
|
addedSuffix = true;
|
|
49
49
|
}
|
|
@@ -63,7 +63,7 @@ const plugin = () => {
|
|
|
63
63
|
// @ts-expect-error
|
|
64
64
|
if (oldResult.__addedSuffix) {
|
|
65
65
|
const originalTemplate = newSource.slice(0, -1); // remove added '>'
|
|
66
|
-
if (!
|
|
66
|
+
if (!shouldAddSuffixRE.test(originalTemplate)) {
|
|
67
67
|
return undefined;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -34,14 +34,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
37
|
+
const codeFeatures_1 = require("../codegen/codeFeatures");
|
|
37
38
|
const forEachTemplateNode_1 = require("../utils/forEachTemplateNode");
|
|
38
39
|
const shared_1 = require("../utils/shared");
|
|
39
|
-
const shared_2 = require("./shared");
|
|
40
|
-
const codeFeatures = {
|
|
41
|
-
...shared_2.allCodeFeatures,
|
|
42
|
-
format: false,
|
|
43
|
-
structure: false,
|
|
44
|
-
};
|
|
45
40
|
const plugin = () => {
|
|
46
41
|
return {
|
|
47
42
|
version: 2.2,
|
|
@@ -69,7 +64,7 @@ function* generate(templateAst) {
|
|
|
69
64
|
&& prop.value) {
|
|
70
65
|
yield `x { `;
|
|
71
66
|
const [content, offset] = (0, shared_1.normalizeAttributeValue)(prop.value);
|
|
72
|
-
yield [content, 'template', offset, codeFeatures];
|
|
67
|
+
yield [content, 'template', offset, codeFeatures_1.codeFeatures.all];
|
|
73
68
|
yield ` }\n`;
|
|
74
69
|
}
|
|
75
70
|
}
|
|
@@ -34,13 +34,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
37
|
+
const codeFeatures_1 = require("../codegen/codeFeatures");
|
|
37
38
|
const elementEvents_1 = require("../codegen/template/elementEvents");
|
|
38
39
|
const templateChild_1 = require("../codegen/template/templateChild");
|
|
39
40
|
const vFor_1 = require("../codegen/template/vFor");
|
|
40
41
|
const utils_1 = require("../codegen/utils");
|
|
41
|
-
const codeFeatures = {
|
|
42
|
-
format: true,
|
|
43
|
-
};
|
|
44
42
|
const formatBrackets = {
|
|
45
43
|
normal: ['`${', '}`;'],
|
|
46
44
|
if: ['if (', ') { }'],
|
|
@@ -53,6 +51,7 @@ const formatBrackets = {
|
|
|
53
51
|
event: ['() => ', ';'],
|
|
54
52
|
generic: ['<', '>() => {};'],
|
|
55
53
|
};
|
|
54
|
+
const genericCommentRE = /^<!--\s*@vue-generic\s*\{(?<content>[\s\S]*)\}\s*-->$/;
|
|
56
55
|
const plugin = ({ modules: { typescript: ts } }) => {
|
|
57
56
|
const parseds = new WeakMap();
|
|
58
57
|
return {
|
|
@@ -96,7 +95,7 @@ const plugin = ({ modules: { typescript: ts } }) => {
|
|
|
96
95
|
return result;
|
|
97
96
|
function visit(node) {
|
|
98
97
|
if (node.type === CompilerDOM.NodeTypes.COMMENT) {
|
|
99
|
-
const match = node.loc.source.match(
|
|
98
|
+
const match = node.loc.source.match(genericCommentRE);
|
|
100
99
|
if (match) {
|
|
101
100
|
const { content } = match.groups;
|
|
102
101
|
addFormatCodes(content, node.loc.start.offset + node.loc.source.indexOf('{') + 1, formatBrackets.generic);
|
|
@@ -221,7 +220,7 @@ const plugin = ({ modules: { typescript: ts } }) => {
|
|
|
221
220
|
code,
|
|
222
221
|
'template',
|
|
223
222
|
offset,
|
|
224
|
-
codeFeatures,
|
|
223
|
+
codeFeatures_1.codeFeatures.format,
|
|
225
224
|
],
|
|
226
225
|
wrapper[1],
|
|
227
226
|
]);
|
package/lib/plugins/vue-tsx.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { IR, VueLanguagePlugin } from '../types';
|
|
2
|
+
export declare const serviceScriptRE: RegExp;
|
|
2
3
|
export declare const tsCodegen: WeakMap<IR, {
|
|
3
4
|
getScriptRanges: () => {
|
|
5
|
+
bindings: import("../types").TextRange<import("typescript").Node>[];
|
|
6
|
+
components: import("../types").TextRange<import("typescript").Node>[];
|
|
4
7
|
exportDefault: (import("../types").TextRange<import("typescript").Node> & {
|
|
5
8
|
expression: import("../types").TextRange<import("typescript").Expression>;
|
|
6
9
|
isObjectLiteral: boolean;
|
|
@@ -14,14 +17,12 @@ export declare const tsCodegen: WeakMap<IR, {
|
|
|
14
17
|
inheritAttrs: string | undefined;
|
|
15
18
|
};
|
|
16
19
|
}) | undefined;
|
|
17
|
-
bindings: import("../types").TextRange<import("typescript").Node>[];
|
|
18
|
-
components: import("../types").TextRange<import("typescript").Node>[];
|
|
19
20
|
} | undefined;
|
|
20
21
|
getScriptSetupRanges: () => {
|
|
21
|
-
leadingCommentEndOffset: number;
|
|
22
|
-
importSectionEndOffset: number;
|
|
23
22
|
bindings: import("../types").TextRange<import("typescript").Node>[];
|
|
24
23
|
components: import("../types").TextRange<import("typescript").Node>[];
|
|
24
|
+
leadingCommentEndOffset: number;
|
|
25
|
+
importSectionEndOffset: number;
|
|
25
26
|
defineModel: import("../parsers/scriptSetupRanges").DefineModel[];
|
|
26
27
|
defineProps: import("../parsers/scriptSetupRanges").DefineProps | undefined;
|
|
27
28
|
withDefaults: import("../parsers/scriptSetupRanges").CallExpressionRange | undefined;
|
|
@@ -49,8 +50,7 @@ export declare const tsCodegen: WeakMap<IR, {
|
|
|
49
50
|
codes: import("../types").Code[];
|
|
50
51
|
};
|
|
51
52
|
getGeneratedTemplate: () => {
|
|
52
|
-
|
|
53
|
-
currentInfo: {
|
|
53
|
+
getCommentInfo: () => {
|
|
54
54
|
ignoreError?: boolean;
|
|
55
55
|
expectError?: {
|
|
56
56
|
token: number;
|
|
@@ -61,45 +61,75 @@ export declare const tsCodegen: WeakMap<IR, {
|
|
|
61
61
|
offset: number;
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
|
+
enter: (node: import("@vue/compiler-dom").RootNode | import("@vue/compiler-dom").TemplateChildNode | import("@vue/compiler-dom").SimpleExpressionNode) => boolean;
|
|
65
|
+
exit: () => Generator<import("../types").Code>;
|
|
64
66
|
resolveCodeFeatures: (features: import("../types").VueCodeInformation) => import("../types").VueCodeInformation;
|
|
65
|
-
|
|
67
|
+
getInternalVariable: () => string;
|
|
68
|
+
scopes: {
|
|
69
|
+
add(value: string): /*elided*/ any;
|
|
70
|
+
declare(...variables: string[]): void;
|
|
71
|
+
end(): Generator<import("../types").Code, any, any>;
|
|
72
|
+
clear(): void;
|
|
73
|
+
delete(value: string): boolean;
|
|
74
|
+
forEach(callbackfn: (value: string, value2: string, set: Set<string>) => void, thisArg?: any): void;
|
|
75
|
+
has(value: string): boolean;
|
|
76
|
+
readonly size: number;
|
|
77
|
+
[Symbol.iterator](): SetIterator<string>;
|
|
78
|
+
entries(): SetIterator<[string, string]>;
|
|
79
|
+
keys(): SetIterator<string>;
|
|
80
|
+
values(): SetIterator<string>;
|
|
81
|
+
readonly [Symbol.toStringTag]: string;
|
|
82
|
+
}[];
|
|
83
|
+
scope: () => {
|
|
84
|
+
add(value: string): any;
|
|
85
|
+
declare(...variables: string[]): void;
|
|
86
|
+
end(): Generator<import("../types").Code, any, any>;
|
|
87
|
+
clear(): void;
|
|
88
|
+
delete(value: string): boolean;
|
|
89
|
+
forEach(callbackfn: (value: string, value2: string, set: Set<string>) => void, thisArg?: any): void;
|
|
90
|
+
has(value: string): boolean;
|
|
91
|
+
readonly size: number;
|
|
92
|
+
[Symbol.iterator](): SetIterator<string>;
|
|
93
|
+
entries(): SetIterator<[string, string]>;
|
|
94
|
+
keys(): SetIterator<string>;
|
|
95
|
+
values(): SetIterator<string>;
|
|
96
|
+
readonly [Symbol.toStringTag]: string;
|
|
97
|
+
};
|
|
98
|
+
contextAccesses: Map<string, Map<string, Set<number>>>;
|
|
99
|
+
accessVariable: (source: string, name: string, offset?: number) => void;
|
|
100
|
+
generateAutoImport: () => Generator<import("../types").Code>;
|
|
101
|
+
conditions: string[];
|
|
102
|
+
generateConditionGuards: () => Generator<string, void, unknown>;
|
|
103
|
+
hoistVars: Map<string, string>;
|
|
104
|
+
getHoistVariable: (originalVar: string) => string;
|
|
105
|
+
generateHoistVariables: () => Generator<string, void, unknown>;
|
|
106
|
+
templateRefs: Map<string, {
|
|
107
|
+
typeExp: string;
|
|
108
|
+
offset: number;
|
|
109
|
+
}[]>;
|
|
110
|
+
addTemplateRef: (name: string, typeExp: string, offset: number) => void;
|
|
111
|
+
components: (() => string)[];
|
|
112
|
+
dollarVars: Set<string>;
|
|
113
|
+
inlayHints: import("../codegen/inlayHints").InlayHintInfo[];
|
|
114
|
+
generatedTypes: Set<string>;
|
|
115
|
+
inheritedAttrVars: Set<string>;
|
|
116
|
+
singleRootElTypes: Set<string>;
|
|
117
|
+
singleRootNodes: Set<import("@vue/compiler-dom").ElementNode | null>;
|
|
66
118
|
slots: {
|
|
67
119
|
name: string;
|
|
68
120
|
offset?: number;
|
|
69
121
|
tagRange: [number, number];
|
|
70
|
-
nodeLoc: any;
|
|
71
122
|
propsVar: string;
|
|
72
123
|
}[];
|
|
73
124
|
dynamicSlots: {
|
|
74
125
|
expVar: string;
|
|
75
126
|
propsVar: string;
|
|
76
127
|
}[];
|
|
77
|
-
|
|
78
|
-
componentAccessMap: Map<string, Map<string, Set<number>>>;
|
|
79
|
-
blockConditions: string[];
|
|
80
|
-
inlayHints: import("../codegen/inlayHints").InlayHintInfo[];
|
|
81
|
-
inheritedAttrVars: Set<string>;
|
|
82
|
-
templateRefs: Map<string, {
|
|
83
|
-
typeExp: string;
|
|
84
|
-
offset: number;
|
|
85
|
-
}[]>;
|
|
86
|
-
singleRootElTypes: Set<string>;
|
|
87
|
-
singleRootNodes: Set<import("@vue/compiler-dom").ElementNode | null>;
|
|
88
|
-
addTemplateRef(name: string, typeExp: string, offset: number): void;
|
|
89
|
-
recordComponentAccess(source: string, name: string, offset?: number): void;
|
|
90
|
-
scopes: Set<string>[];
|
|
91
|
-
components: (() => string)[];
|
|
92
|
-
declare(...varNames: string[]): void;
|
|
93
|
-
startScope(): () => Generator<import("../types").Code, any, any>;
|
|
94
|
-
getInternalVariable(): string;
|
|
95
|
-
getHoistVariable(originalVar: string): string;
|
|
96
|
-
generateHoistVariables(): Generator<string, void, unknown>;
|
|
97
|
-
generateConditionGuards(): Generator<string, void, unknown>;
|
|
98
|
-
enter(node: import("@vue/compiler-dom").RootNode | import("@vue/compiler-dom").TemplateChildNode | import("@vue/compiler-dom").SimpleExpressionNode): boolean;
|
|
99
|
-
exit(): Generator<import("../types").Code>;
|
|
128
|
+
inVFor: boolean;
|
|
100
129
|
codes: import("../types").Code[];
|
|
101
130
|
} | undefined;
|
|
102
131
|
getImportedComponents: () => Set<string>;
|
|
132
|
+
getSetupBindings: () => Set<string>;
|
|
103
133
|
getSetupExposed: () => Set<string>;
|
|
104
134
|
}>;
|
|
105
135
|
declare const plugin: VueLanguagePlugin;
|
package/lib/plugins/vue-tsx.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.tsCodegen = void 0;
|
|
36
|
+
exports.tsCodegen = exports.serviceScriptRE = void 0;
|
|
37
37
|
const shared_1 = require("@vue/shared");
|
|
38
38
|
const alien_signals_1 = require("alien-signals");
|
|
39
39
|
const path = __importStar(require("path-browserify"));
|
|
@@ -45,6 +45,7 @@ const scriptRanges_1 = require("../parsers/scriptRanges");
|
|
|
45
45
|
const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
|
|
46
46
|
const vueCompilerOptions_1 = require("../parsers/vueCompilerOptions");
|
|
47
47
|
const signals_1 = require("../utils/signals");
|
|
48
|
+
exports.serviceScriptRE = /^script_(?:js|jsx|ts|tsx)$/;
|
|
48
49
|
exports.tsCodegen = new WeakMap();
|
|
49
50
|
const validLangs = new Set(['js', 'jsx', 'ts', 'tsx']);
|
|
50
51
|
const plugin = ({ modules: { typescript: ts }, vueCompilerOptions, }) => {
|
|
@@ -55,7 +56,7 @@ const plugin = ({ modules: { typescript: ts }, vueCompilerOptions, }) => {
|
|
|
55
56
|
return [{ lang, id: 'script_' + lang }];
|
|
56
57
|
},
|
|
57
58
|
resolveEmbeddedCode(fileName, ir, embeddedFile) {
|
|
58
|
-
if (
|
|
59
|
+
if (exports.serviceScriptRE.test(embeddedFile.id)) {
|
|
59
60
|
let codegen = exports.tsCodegen.get(ir);
|
|
60
61
|
if (!codegen) {
|
|
61
62
|
exports.tsCodegen.set(ir, codegen = useCodegen(ts, vueCompilerOptions, fileName, ir));
|
|
@@ -114,6 +115,22 @@ function useCodegen(ts, vueCompilerOptions, fileName, ir) {
|
|
|
114
115
|
}
|
|
115
116
|
return names;
|
|
116
117
|
});
|
|
118
|
+
const getSetupBindings = (0, signals_1.computedSet)(() => {
|
|
119
|
+
const names = new Set();
|
|
120
|
+
const scriptSetupRanges = getScriptSetupRanges();
|
|
121
|
+
if (ir.scriptSetup && scriptSetupRanges) {
|
|
122
|
+
for (const range of scriptSetupRanges.bindings) {
|
|
123
|
+
names.add(ir.scriptSetup.content.slice(range.start, range.end));
|
|
124
|
+
}
|
|
125
|
+
const scriptRanges = getScriptRanges();
|
|
126
|
+
if (ir.script && scriptRanges) {
|
|
127
|
+
for (const range of scriptRanges.bindings) {
|
|
128
|
+
names.add(ir.script.content.slice(range.start, range.end));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return names;
|
|
133
|
+
});
|
|
117
134
|
const getSetupConsts = (0, signals_1.computedSet)(() => {
|
|
118
135
|
const scriptSetupRanges = getScriptSetupRanges();
|
|
119
136
|
const names = new Set([
|
|
@@ -187,30 +204,15 @@ function useCodegen(ts, vueCompilerOptions, fileName, ir) {
|
|
|
187
204
|
});
|
|
188
205
|
});
|
|
189
206
|
const getSetupExposed = (0, signals_1.computedSet)(() => {
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return allVars;
|
|
194
|
-
}
|
|
195
|
-
for (const range of scriptSetupRanges.bindings) {
|
|
196
|
-
const name = ir.scriptSetup.content.slice(range.start, range.end);
|
|
197
|
-
allVars.add(name);
|
|
198
|
-
}
|
|
199
|
-
const scriptRanges = getScriptRanges();
|
|
200
|
-
if (ir.script && scriptRanges) {
|
|
201
|
-
for (const range of scriptRanges.bindings) {
|
|
202
|
-
const name = ir.script.content.slice(range.start, range.end);
|
|
203
|
-
allVars.add(name);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (!allVars.size) {
|
|
207
|
-
return allVars;
|
|
207
|
+
const bindings = getSetupBindings();
|
|
208
|
+
if (!bindings.size) {
|
|
209
|
+
return bindings;
|
|
208
210
|
}
|
|
209
211
|
return new Set([
|
|
210
|
-
...getGeneratedTemplate()?.
|
|
211
|
-
...getGeneratedStyle()?.
|
|
212
|
+
...getGeneratedTemplate()?.contextAccesses.keys() ?? [],
|
|
213
|
+
...getGeneratedStyle()?.contextAccesses.keys() ?? [],
|
|
212
214
|
...ir.template?.ast?.components.flatMap(name => [(0, shared_1.camelize)(name), (0, shared_1.capitalize)((0, shared_1.camelize)(name))]) ?? [],
|
|
213
|
-
].filter(name =>
|
|
215
|
+
].filter(name => bindings.has(name)));
|
|
214
216
|
});
|
|
215
217
|
const getGeneratedScript = (0, alien_signals_1.computed)(() => {
|
|
216
218
|
return (0, script_1.generateScript)({
|
|
@@ -237,6 +239,7 @@ function useCodegen(ts, vueCompilerOptions, fileName, ir) {
|
|
|
237
239
|
getGeneratedScript,
|
|
238
240
|
getGeneratedTemplate,
|
|
239
241
|
getImportedComponents,
|
|
242
|
+
getSetupBindings,
|
|
240
243
|
getSetupExposed,
|
|
241
244
|
};
|
|
242
245
|
}
|
package/lib/plugins.d.ts
CHANGED
package/lib/plugins.js
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
4
|
};
|
|
@@ -33,7 +19,6 @@ const vue_template_inline_css_1 = __importDefault(require("./plugins/vue-templat
|
|
|
33
19
|
const vue_template_inline_ts_1 = __importDefault(require("./plugins/vue-template-inline-ts"));
|
|
34
20
|
const vue_tsx_1 = __importDefault(require("./plugins/vue-tsx"));
|
|
35
21
|
const types_1 = require("./types");
|
|
36
|
-
__exportStar(require("./plugins/shared"), exports);
|
|
37
22
|
function createPlugins(pluginContext) {
|
|
38
23
|
const plugins = [
|
|
39
24
|
file_vue_1.default,
|
|
@@ -37,61 +37,54 @@ exports.forEachElementNode = forEachElementNode;
|
|
|
37
37
|
exports.forEachInterpolationNode = forEachInterpolationNode;
|
|
38
38
|
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
39
39
|
function* forEachElementNode(node) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
yield
|
|
40
|
+
switch (node.type) {
|
|
41
|
+
case CompilerDOM.NodeTypes.ELEMENT: {
|
|
42
|
+
yield node;
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else if (node.type === CompilerDOM.NodeTypes.IF) {
|
|
52
|
-
for (const branch of node.branches) {
|
|
53
|
-
for (const childNode of branch.children) {
|
|
54
|
-
yield* forEachElementNode(childNode);
|
|
44
|
+
case CompilerDOM.NodeTypes.IF_BRANCH:
|
|
45
|
+
case CompilerDOM.NodeTypes.FOR:
|
|
46
|
+
case CompilerDOM.NodeTypes.ROOT: {
|
|
47
|
+
for (const child of node.children) {
|
|
48
|
+
yield* forEachElementNode(child);
|
|
55
49
|
}
|
|
50
|
+
break;
|
|
56
51
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
case CompilerDOM.NodeTypes.IF: {
|
|
53
|
+
for (const branch of node.branches) {
|
|
54
|
+
yield* forEachElementNode(branch);
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
61
57
|
}
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
60
|
function* forEachInterpolationNode(node) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
for (const child of node.children) {
|
|
72
|
-
yield* forEachInterpolationNode(child);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else if (node.type === CompilerDOM.NodeTypes.COMPOUND_EXPRESSION) {
|
|
76
|
-
for (const child of node.children) {
|
|
77
|
-
if (typeof child === 'object') {
|
|
61
|
+
switch (node.type) {
|
|
62
|
+
case CompilerDOM.NodeTypes.ELEMENT:
|
|
63
|
+
case CompilerDOM.NodeTypes.IF_BRANCH:
|
|
64
|
+
case CompilerDOM.NodeTypes.FOR:
|
|
65
|
+
case CompilerDOM.NodeTypes.ROOT: {
|
|
66
|
+
for (const child of node.children) {
|
|
78
67
|
yield* forEachInterpolationNode(child);
|
|
79
68
|
}
|
|
69
|
+
break;
|
|
80
70
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
else if (node.type === CompilerDOM.NodeTypes.IF) {
|
|
86
|
-
for (const branch of node.branches) {
|
|
87
|
-
for (const childNode of branch.children) {
|
|
88
|
-
yield* forEachInterpolationNode(childNode);
|
|
71
|
+
case CompilerDOM.NodeTypes.IF: {
|
|
72
|
+
for (const branch of node.branches) {
|
|
73
|
+
yield* forEachInterpolationNode(branch);
|
|
89
74
|
}
|
|
75
|
+
break;
|
|
90
76
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
77
|
+
case CompilerDOM.NodeTypes.COMPOUND_EXPRESSION: {
|
|
78
|
+
for (const child of node.children) {
|
|
79
|
+
if (typeof child === 'object') {
|
|
80
|
+
yield* forEachInterpolationNode(child);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case CompilerDOM.NodeTypes.INTERPOLATION: {
|
|
86
|
+
yield node;
|
|
87
|
+
break;
|
|
95
88
|
}
|
|
96
89
|
}
|
|
97
90
|
}
|
package/lib/virtualCode/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VueVirtualCode = void 0;
|
|
4
4
|
const alien_signals_1 = require("alien-signals");
|
|
5
|
-
const
|
|
5
|
+
const codeFeatures_1 = require("../codegen/codeFeatures");
|
|
6
6
|
const embeddedCodes_1 = require("./embeddedCodes");
|
|
7
7
|
const ir_1 = require("./ir");
|
|
8
8
|
class VueVirtualCode {
|
|
@@ -40,7 +40,7 @@ class VueVirtualCode {
|
|
|
40
40
|
sourceOffsets: [0],
|
|
41
41
|
generatedOffsets: [0],
|
|
42
42
|
lengths: [this._snapshot().getLength()],
|
|
43
|
-
data:
|
|
43
|
+
data: codeFeatures_1.codeFeatures.full,
|
|
44
44
|
}];
|
|
45
45
|
});
|
|
46
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"index.d.ts",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"@volar/typescript": "2.4.28",
|
|
35
35
|
"@vue/compiler-sfc": "^3.5.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "4893ec6a4b5ca0d00f8add9aa36c17c47085f05a"
|
|
38
38
|
}
|