@vue/language-core 2.1.10 → 2.2.2
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 +0 -1
- package/index.js +1 -2
- package/lib/codeFeatures.d.ts +1 -0
- package/lib/codeFeatures.js +3 -0
- package/lib/codegen/codeFeatures.d.ts +83 -0
- package/lib/codegen/codeFeatures.js +71 -0
- package/lib/codegen/globalTypes.d.ts +3 -1
- package/lib/codegen/globalTypes.js +39 -14
- package/lib/codegen/localTypes.d.ts +1 -1
- package/lib/codegen/localTypes.js +7 -7
- package/lib/codegen/script/binding.d.ts +4 -0
- package/lib/codegen/script/binding.js +41 -0
- package/lib/codegen/script/component.d.ts +1 -1
- package/lib/codegen/script/component.js +44 -44
- package/lib/codegen/script/componentSelf.d.ts +1 -1
- package/lib/codegen/script/componentSelf.js +14 -14
- package/lib/codegen/script/context.d.ts +1 -1
- package/lib/codegen/script/context.js +2 -2
- package/lib/codegen/script/index.d.ts +6 -11
- package/lib/codegen/script/index.js +21 -63
- package/lib/codegen/script/scriptSetup.d.ts +1 -1
- package/lib/codegen/script/scriptSetup.js +236 -205
- package/lib/codegen/script/src.js +8 -8
- package/lib/codegen/script/styleModulesType.d.ts +1 -1
- package/lib/codegen/script/styleModulesType.js +7 -7
- package/lib/codegen/script/template.d.ts +2 -2
- package/lib/codegen/script/template.js +81 -114
- package/lib/codegen/template/context.d.ts +29 -15
- package/lib/codegen/template/context.js +51 -96
- package/lib/codegen/template/element.d.ts +2 -4
- package/lib/codegen/template/element.js +124 -317
- package/lib/codegen/template/elementChildren.d.ts +1 -1
- package/lib/codegen/template/elementChildren.js +10 -11
- package/lib/codegen/template/elementDirectives.d.ts +1 -0
- package/lib/codegen/template/elementDirectives.js +43 -30
- package/lib/codegen/template/elementEvents.d.ts +2 -2
- package/lib/codegen/template/elementEvents.js +32 -65
- package/lib/codegen/template/elementProps.d.ts +5 -3
- package/lib/codegen/template/elementProps.js +116 -123
- package/lib/codegen/template/index.d.ts +1 -0
- package/lib/codegen/template/index.js +67 -69
- package/lib/codegen/template/interpolation.d.ts +5 -3
- package/lib/codegen/template/interpolation.js +30 -27
- package/lib/codegen/template/objectProperty.js +8 -8
- package/lib/codegen/template/propertyAccess.js +4 -4
- package/lib/codegen/template/slotOutlet.d.ts +1 -1
- package/lib/codegen/template/slotOutlet.js +47 -25
- package/lib/codegen/template/styleScopedClasses.d.ts +4 -1
- package/lib/codegen/template/styleScopedClasses.js +152 -8
- package/lib/codegen/template/templateChild.d.ts +1 -1
- package/lib/codegen/template/templateChild.js +39 -20
- package/lib/codegen/template/vFor.d.ts +1 -1
- package/lib/codegen/template/vFor.js +11 -11
- package/lib/codegen/template/vIf.d.ts +1 -1
- package/lib/codegen/template/vIf.js +6 -6
- package/lib/codegen/template/vSlot.d.ts +5 -0
- package/lib/codegen/template/vSlot.js +80 -0
- package/lib/codegen/utils/camelized.d.ts +2 -0
- package/lib/codegen/utils/camelized.js +31 -0
- package/lib/codegen/utils/index.d.ts +21 -0
- package/lib/codegen/utils/index.js +79 -0
- package/lib/codegen/utils/src.d.ts +2 -0
- package/lib/codegen/utils/src.js +19 -0
- package/lib/codegen/{template → utils}/stringLiteralKey.js +3 -3
- package/lib/codegen/utils/unicode.d.ts +2 -0
- package/lib/codegen/utils/unicode.js +25 -0
- package/lib/languagePlugin.js +1 -1
- package/lib/parsers/scriptRanges.d.ts +7 -2
- package/lib/parsers/scriptSetupRanges.d.ts +69 -83
- package/lib/parsers/scriptSetupRanges.js +194 -171
- package/lib/parsers/vueCompilerOptions.d.ts +2 -0
- package/lib/parsers/vueCompilerOptions.js +23 -0
- package/lib/plugins/file-html.js +4 -3
- package/lib/plugins/file-md.js +1 -1
- package/lib/plugins/file-vue.js +4 -4
- package/lib/plugins/vue-root-tags.js +2 -2
- package/lib/plugins/vue-style-class-names.d.ts +5 -0
- package/lib/plugins/vue-style-class-names.js +32 -0
- package/lib/plugins/vue-style-reference-link.d.ts +1 -0
- package/lib/plugins/vue-style-reference-link.js +3 -0
- package/lib/plugins/vue-style-reference-links.d.ts +3 -0
- package/lib/plugins/vue-style-reference-links.js +26 -0
- package/lib/plugins/vue-template-html.js +6 -2
- package/lib/plugins/vue-template-inline-css.js +1 -1
- package/lib/plugins/vue-template-inline-ts.js +66 -17
- package/lib/plugins/vue-tsx.d.ts +126 -92
- package/lib/plugins/vue-tsx.js +114 -97
- package/lib/plugins/vue-vine.d.ts +3 -0
- package/lib/plugins/vue-vine.js +35 -0
- package/lib/types.d.ts +25 -12
- package/lib/utils/buildMappings.d.ts +1 -1
- package/lib/utils/parseCssImports.d.ts +4 -0
- package/lib/utils/parseCssImports.js +19 -0
- package/lib/utils/parseSfc.d.ts +5 -0
- package/lib/utils/parseSfc.js +11 -5
- package/lib/utils/signals.d.ts +2 -0
- package/lib/utils/signals.js +54 -0
- package/lib/utils/ts.d.ts +14 -2
- package/lib/utils/ts.js +134 -91
- package/lib/virtualFile/computedEmbeddedCodes.d.ts +1 -2
- package/lib/virtualFile/computedEmbeddedCodes.js +11 -11
- package/lib/virtualFile/computedSfc.d.ts +1 -2
- package/lib/virtualFile/computedSfc.js +87 -79
- package/lib/virtualFile/computedVueSfc.d.ts +1 -2
- package/lib/virtualFile/computedVueSfc.js +7 -7
- package/lib/virtualFile/vueFile.d.ts +5 -5
- package/lib/virtualFile/vueFile.js +6 -6
- package/package.json +6 -6
- /package/lib/codegen/{template → utils}/stringLiteralKey.d.ts +0 -0
|
@@ -1,115 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createTemplateCodegenContext = createTemplateCodegenContext;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
all: {
|
|
7
|
-
verification: true,
|
|
8
|
-
completion: true,
|
|
9
|
-
semantic: true,
|
|
10
|
-
navigation: true,
|
|
11
|
-
},
|
|
12
|
-
verification: {
|
|
13
|
-
verification: true,
|
|
14
|
-
},
|
|
15
|
-
completion: {
|
|
16
|
-
completion: true,
|
|
17
|
-
},
|
|
18
|
-
additionalCompletion: {
|
|
19
|
-
completion: { isAdditional: true },
|
|
20
|
-
},
|
|
21
|
-
navigation: {
|
|
22
|
-
navigation: true,
|
|
23
|
-
},
|
|
24
|
-
navigationWithoutRename: {
|
|
25
|
-
navigation: {
|
|
26
|
-
shouldRename() {
|
|
27
|
-
return false;
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
navigationAndCompletion: {
|
|
32
|
-
navigation: true,
|
|
33
|
-
completion: true,
|
|
34
|
-
},
|
|
35
|
-
navigationAndAdditionalCompletion: {
|
|
36
|
-
navigation: true,
|
|
37
|
-
completion: { isAdditional: true },
|
|
38
|
-
},
|
|
39
|
-
withoutHighlight: {
|
|
40
|
-
semantic: { shouldHighlight: () => false },
|
|
41
|
-
verification: true,
|
|
42
|
-
navigation: true,
|
|
43
|
-
completion: true,
|
|
44
|
-
},
|
|
45
|
-
withoutHighlightAndCompletion: {
|
|
46
|
-
semantic: { shouldHighlight: () => false },
|
|
47
|
-
verification: true,
|
|
48
|
-
navigation: true,
|
|
49
|
-
},
|
|
50
|
-
withoutHighlightAndCompletionAndNavigation: {
|
|
51
|
-
semantic: { shouldHighlight: () => false },
|
|
52
|
-
verification: true,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
4
|
+
const codeFeatures_1 = require("../codeFeatures");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
55
6
|
function createTemplateCodegenContext(options) {
|
|
56
7
|
let ignoredError = false;
|
|
57
8
|
let expectErrorToken;
|
|
9
|
+
let lastGenericComment;
|
|
58
10
|
let variableId = 0;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
verification: false,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
if (expectErrorToken) {
|
|
70
|
-
const token = expectErrorToken;
|
|
71
|
-
if (typeof data.verification !== 'object' || !data.verification.shouldReport) {
|
|
72
|
-
return {
|
|
73
|
-
...data,
|
|
74
|
-
verification: {
|
|
75
|
-
shouldReport: () => {
|
|
76
|
-
token.errors++;
|
|
77
|
-
return false;
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
11
|
+
function resolveCodeFeatures(features) {
|
|
12
|
+
if (features.verification) {
|
|
13
|
+
if (ignoredError) {
|
|
14
|
+
return {
|
|
15
|
+
...features,
|
|
16
|
+
verification: false,
|
|
17
|
+
};
|
|
83
18
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
19
|
+
if (expectErrorToken) {
|
|
20
|
+
const token = expectErrorToken;
|
|
21
|
+
return {
|
|
22
|
+
...features,
|
|
23
|
+
verification: {
|
|
24
|
+
shouldReport: () => {
|
|
25
|
+
token.errors++;
|
|
26
|
+
return false;
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return features;
|
|
33
|
+
}
|
|
87
34
|
const localVars = new Map();
|
|
35
|
+
const specialVars = new Set();
|
|
88
36
|
const accessExternalVariables = new Map();
|
|
89
37
|
const slots = [];
|
|
90
38
|
const dynamicSlots = [];
|
|
91
|
-
const hasSlotElements = new Set();
|
|
92
|
-
;
|
|
93
39
|
const blockConditions = [];
|
|
94
|
-
const usedComponentCtxVars = new Set();
|
|
95
40
|
const scopedClasses = [];
|
|
96
41
|
const emptyClassOffsets = [];
|
|
97
42
|
const inlayHints = [];
|
|
43
|
+
const bindingAttrLocs = [];
|
|
44
|
+
const inheritedAttrVars = new Set();
|
|
98
45
|
const templateRefs = new Map();
|
|
99
46
|
return {
|
|
47
|
+
codeFeatures: new Proxy(codeFeatures_1.codeFeatures, {
|
|
48
|
+
get(target, key) {
|
|
49
|
+
const data = target[key];
|
|
50
|
+
return resolveCodeFeatures(data);
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
resolveCodeFeatures,
|
|
100
54
|
slots,
|
|
101
55
|
dynamicSlots,
|
|
102
|
-
|
|
56
|
+
specialVars,
|
|
103
57
|
accessExternalVariables,
|
|
104
|
-
|
|
58
|
+
lastGenericComment,
|
|
105
59
|
blockConditions,
|
|
106
|
-
usedComponentCtxVars,
|
|
107
60
|
scopedClasses,
|
|
108
61
|
emptyClassOffsets,
|
|
109
62
|
inlayHints,
|
|
110
63
|
hasSlot: false,
|
|
111
|
-
|
|
64
|
+
bindingAttrLocs,
|
|
65
|
+
inheritedAttrVars,
|
|
112
66
|
templateRefs,
|
|
67
|
+
currentComponent: undefined,
|
|
113
68
|
singleRootElType: undefined,
|
|
114
69
|
singleRootNode: undefined,
|
|
115
70
|
accessExternalVariable(name, offset) {
|
|
@@ -136,7 +91,7 @@ function createTemplateCodegenContext(options) {
|
|
|
136
91
|
ignoreError: function* () {
|
|
137
92
|
if (!ignoredError) {
|
|
138
93
|
ignoredError = true;
|
|
139
|
-
yield `// @vue-ignore start${
|
|
94
|
+
yield `// @vue-ignore start${utils_1.newLine}`;
|
|
140
95
|
}
|
|
141
96
|
},
|
|
142
97
|
expectError: function* (prevNode) {
|
|
@@ -145,24 +100,24 @@ function createTemplateCodegenContext(options) {
|
|
|
145
100
|
errors: 0,
|
|
146
101
|
node: prevNode,
|
|
147
102
|
};
|
|
148
|
-
yield `// @vue-expect-error start${
|
|
103
|
+
yield `// @vue-expect-error start${utils_1.newLine}`;
|
|
149
104
|
}
|
|
150
105
|
},
|
|
151
106
|
resetDirectiveComments: function* (endStr) {
|
|
152
107
|
if (expectErrorToken) {
|
|
153
108
|
const token = expectErrorToken;
|
|
154
|
-
yield* (0,
|
|
109
|
+
yield* (0, utils_1.wrapWith)(expectErrorToken.node.loc.start.offset, expectErrorToken.node.loc.end.offset, {
|
|
155
110
|
verification: {
|
|
156
111
|
shouldReport: () => token.errors === 0,
|
|
157
112
|
},
|
|
158
113
|
}, `// @ts-expect-error __VLS_TS_EXPECT_ERROR`);
|
|
159
|
-
yield `${
|
|
114
|
+
yield `${utils_1.newLine}${utils_1.endOfLine}`;
|
|
160
115
|
expectErrorToken = undefined;
|
|
161
|
-
yield `// @vue-expect-error ${endStr}${
|
|
116
|
+
yield `// @vue-expect-error ${endStr}${utils_1.newLine}`;
|
|
162
117
|
}
|
|
163
118
|
if (ignoredError) {
|
|
164
119
|
ignoredError = false;
|
|
165
|
-
yield `// @vue-ignore ${endStr}${
|
|
120
|
+
yield `// @vue-ignore ${endStr}${utils_1.newLine}`;
|
|
166
121
|
}
|
|
167
122
|
},
|
|
168
123
|
generateAutoImportCompletion: function* () {
|
|
@@ -173,7 +128,7 @@ function createTemplateCodegenContext(options) {
|
|
|
173
128
|
if (!all.some(([_, offsets]) => offsets.size)) {
|
|
174
129
|
return;
|
|
175
130
|
}
|
|
176
|
-
yield `// @ts-ignore${
|
|
131
|
+
yield `// @ts-ignore${utils_1.newLine}`; // #2304
|
|
177
132
|
yield `[`;
|
|
178
133
|
for (const [varName, offsets] of all) {
|
|
179
134
|
for (const offset of offsets) {
|
|
@@ -184,8 +139,8 @@ function createTemplateCodegenContext(options) {
|
|
|
184
139
|
'template',
|
|
185
140
|
offset,
|
|
186
141
|
{
|
|
187
|
-
...codeFeatures.additionalCompletion,
|
|
188
|
-
...codeFeatures.withoutHighlightAndCompletionAndNavigation,
|
|
142
|
+
...codeFeatures_1.codeFeatures.additionalCompletion,
|
|
143
|
+
...codeFeatures_1.codeFeatures.withoutHighlightAndCompletionAndNavigation,
|
|
189
144
|
},
|
|
190
145
|
];
|
|
191
146
|
}
|
|
@@ -194,14 +149,14 @@ function createTemplateCodegenContext(options) {
|
|
|
194
149
|
varName,
|
|
195
150
|
'template',
|
|
196
151
|
offset,
|
|
197
|
-
codeFeatures.additionalCompletion,
|
|
152
|
+
codeFeatures_1.codeFeatures.additionalCompletion,
|
|
198
153
|
];
|
|
199
154
|
}
|
|
200
155
|
yield `,`;
|
|
201
156
|
}
|
|
202
157
|
offsets.clear();
|
|
203
158
|
}
|
|
204
|
-
yield `]${
|
|
159
|
+
yield `]${utils_1.endOfLine}`;
|
|
205
160
|
}
|
|
206
161
|
};
|
|
207
162
|
}
|
|
@@ -2,7 +2,5 @@ import * as CompilerDOM from '@vue/compiler-dom';
|
|
|
2
2
|
import type { Code } from '../../types';
|
|
3
3
|
import type { TemplateCodegenContext } from './context';
|
|
4
4
|
import type { TemplateCodegenOptions } from './index';
|
|
5
|
-
export declare function generateComponent(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode
|
|
6
|
-
export declare function generateElement(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode,
|
|
7
|
-
export declare function getCanonicalComponentName(tagText: string): string;
|
|
8
|
-
export declare function getPossibleOriginalComponentNames(tagText: string, deduplicate: boolean): string[];
|
|
5
|
+
export declare function generateComponent(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode): Generator<Code>;
|
|
6
|
+
export declare function generateElement(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, isVForChild: boolean): Generator<Code>;
|