@vue/language-core 3.1.5 → 3.1.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 +2 -1
- package/index.js +3 -2
- package/lib/codegen/codeFeatures.d.ts +5 -9
- package/lib/codegen/codeFeatures.js +5 -5
- package/lib/codegen/globalTypes.js +12 -18
- package/lib/codegen/localTypes.d.ts +1 -1
- package/lib/codegen/localTypes.js +6 -6
- package/lib/codegen/names.d.ts +30 -0
- package/lib/codegen/names.js +34 -0
- package/lib/codegen/script/component.js +45 -54
- package/lib/codegen/script/context.d.ts +2 -5
- package/lib/codegen/script/context.js +1 -7
- package/lib/codegen/script/index.d.ts +10 -12
- package/lib/codegen/script/index.js +74 -73
- package/lib/codegen/script/scriptSetup.d.ts +3 -2
- package/lib/codegen/script/scriptSetup.js +209 -283
- package/lib/codegen/script/src.js +9 -3
- package/lib/codegen/script/template.js +64 -108
- package/lib/codegen/style/common.d.ts +3 -0
- package/lib/codegen/style/common.js +43 -0
- package/lib/codegen/style/index.d.ts +63 -0
- package/lib/codegen/style/index.js +38 -0
- package/lib/codegen/style/modules.d.ts +3 -2
- package/lib/codegen/style/modules.js +12 -11
- package/lib/codegen/style/scopedClasses.d.ts +2 -3
- package/lib/codegen/style/scopedClasses.js +23 -21
- package/lib/codegen/template/context.d.ts +7 -16
- package/lib/codegen/template/context.js +81 -93
- package/lib/codegen/template/element.js +151 -55
- package/lib/codegen/template/elementDirectives.js +32 -12
- package/lib/codegen/template/elementEvents.js +27 -28
- package/lib/codegen/template/elementProps.d.ts +2 -2
- package/lib/codegen/template/elementProps.js +49 -23
- package/lib/codegen/template/index.d.ts +8 -19
- package/lib/codegen/template/index.js +85 -80
- package/lib/codegen/template/interpolation.d.ts +3 -3
- package/lib/codegen/template/interpolation.js +90 -136
- package/lib/codegen/template/objectProperty.js +8 -4
- package/lib/codegen/template/propertyAccess.d.ts +1 -1
- package/lib/codegen/template/propertyAccess.js +5 -7
- package/lib/codegen/template/slotOutlet.js +25 -8
- package/lib/codegen/template/styleScopedClasses.d.ts +3 -6
- package/lib/codegen/template/styleScopedClasses.js +23 -149
- package/lib/codegen/template/templateChild.d.ts +0 -1
- package/lib/codegen/template/templateChild.js +11 -68
- package/lib/codegen/template/vFor.js +10 -13
- package/lib/codegen/template/vIf.js +5 -3
- package/lib/codegen/template/vSlot.js +20 -15
- package/lib/codegen/utils/boundary.d.ts +3 -0
- package/lib/codegen/utils/boundary.js +13 -0
- package/lib/codegen/utils/camelized.js +3 -3
- package/lib/codegen/utils/escaped.js +4 -2
- package/lib/codegen/utils/index.d.ts +3 -4
- package/lib/codegen/utils/index.js +42 -16
- package/lib/codegen/utils/merge.d.ts +2 -2
- package/lib/codegen/utils/merge.js +9 -9
- package/lib/codegen/utils/stringLiteralKey.js +6 -3
- package/lib/codegen/utils/transform.d.ts +8 -0
- package/lib/codegen/utils/transform.js +27 -0
- package/lib/codegen/utils/unicode.js +4 -2
- package/lib/compilerOptions.d.ts +5 -2
- package/lib/compilerOptions.js +67 -44
- package/lib/languagePlugin.d.ts +1 -1
- package/lib/languagePlugin.js +2 -2
- package/lib/plugins/vue-template-inline-css.js +2 -6
- package/lib/plugins/vue-template-inline-ts.js +12 -14
- package/lib/plugins/vue-tsx.d.ts +11 -20
- package/lib/plugins/vue-tsx.js +121 -68
- package/lib/plugins.js +1 -1
- package/lib/types.d.ts +5 -4
- package/lib/utils/parseSfc.js +7 -3
- package/lib/utils/shared.d.ts +1 -1
- package/lib/utils/shared.js +7 -6
- package/lib/utils/signals.d.ts +2 -2
- package/lib/utils/signals.js +8 -6
- package/lib/virtualCode/embeddedCodes.d.ts +12 -0
- package/lib/virtualCode/embeddedCodes.js +249 -0
- package/lib/{virtualFile/vueFile.d.ts → virtualCode/index.d.ts} +9 -9
- package/lib/virtualCode/index.js +81 -0
- package/lib/virtualCode/ir.d.ts +4 -0
- package/lib/{virtualFile/computedSfc.js → virtualCode/ir.js} +59 -94
- package/lib/virtualCode/normalize.d.ts +2 -0
- package/lib/virtualCode/normalize.js +170 -0
- package/package.json +4 -4
- package/lib/codegen/style/classProperty.d.ts +0 -2
- package/lib/codegen/style/classProperty.js +0 -18
- package/lib/codegen/style/imports.d.ts +0 -2
- package/lib/codegen/style/imports.js +0 -27
- package/lib/codegen/template/elementChildren.d.ts +0 -5
- package/lib/codegen/template/elementChildren.js +0 -12
- package/lib/codegen/utils/wrapWith.d.ts +0 -2
- package/lib/codegen/utils/wrapWith.js +0 -15
- package/lib/virtualFile/computedEmbeddedCodes.d.ts +0 -4
- package/lib/virtualFile/computedEmbeddedCodes.js +0 -262
- package/lib/virtualFile/computedSfc.d.ts +0 -6
- package/lib/virtualFile/computedVueSfc.d.ts +0 -4
- package/lib/virtualFile/computedVueSfc.js +0 -41
- package/lib/virtualFile/embeddedFile.d.ts +0 -11
- package/lib/virtualFile/embeddedFile.js +0 -14
- package/lib/virtualFile/vueFile.js +0 -49
|
@@ -5,12 +5,12 @@ const shared_1 = require("@vue/shared");
|
|
|
5
5
|
const collectBindings_1 = require("../../utils/collectBindings");
|
|
6
6
|
const shared_2 = require("../../utils/shared");
|
|
7
7
|
const codeFeatures_1 = require("../codeFeatures");
|
|
8
|
+
const names = require("../names");
|
|
8
9
|
const utils_1 = require("../utils");
|
|
9
10
|
// https://github.com/vuejs/core/blob/fb0c3ca519f1fccf52049cd6b8db3a67a669afe9/packages/compiler-core/src/transforms/transformExpression.ts#L47
|
|
10
11
|
const isLiteralWhitelisted = /*@__PURE__*/ (0, shared_1.makeMap)('true,false,null,this');
|
|
11
|
-
function* generateInterpolation(options, ctx,
|
|
12
|
-
const
|
|
13
|
-
for (const segment of forEachInterpolationSegment(ts, ctx.inlineTsAsts, destructuredPropNames, templateRefNames, ctx, code, start, prefix, suffix)) {
|
|
12
|
+
function* generateInterpolation(options, ctx, block, data, code, start, prefix = '', suffix = '') {
|
|
13
|
+
for (const segment of forEachInterpolationSegment(options, ctx, block, code, start, prefix, suffix)) {
|
|
14
14
|
if (typeof segment === 'string') {
|
|
15
15
|
yield segment;
|
|
16
16
|
continue;
|
|
@@ -28,222 +28,176 @@ function* generateInterpolation(options, ctx, source, data, code, start, prefix
|
|
|
28
28
|
section = section.slice(-offset);
|
|
29
29
|
offset = 0;
|
|
30
30
|
}
|
|
31
|
-
const shouldSkip = section.length === 0 &&
|
|
31
|
+
const shouldSkip = section.length === 0 && type === 'startEnd';
|
|
32
32
|
if (!shouldSkip) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
? data(start + offset)
|
|
42
|
-
: data,
|
|
43
|
-
];
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
yield section;
|
|
47
|
-
}
|
|
33
|
+
yield [
|
|
34
|
+
section,
|
|
35
|
+
block.name,
|
|
36
|
+
start + offset,
|
|
37
|
+
type === 'errorMappingOnly'
|
|
38
|
+
? codeFeatures_1.codeFeatures.verification
|
|
39
|
+
: data,
|
|
40
|
+
];
|
|
48
41
|
}
|
|
49
42
|
yield addSuffix;
|
|
50
43
|
}
|
|
51
44
|
}
|
|
52
|
-
function* forEachInterpolationSegment(ts,
|
|
45
|
+
function* forEachInterpolationSegment({ ts, setupRefs }, ctx, block, originalCode, start, prefix, suffix) {
|
|
53
46
|
const code = prefix + originalCode + suffix;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
ts.forEachChild(ast, node => walkIdentifiers(ts, node, ast, varCb, ctx, [], true));
|
|
75
|
-
}
|
|
76
|
-
ctxVars = ctxVars.sort((a, b) => a.offset - b.offset);
|
|
77
|
-
if (ctxVars.length) {
|
|
78
|
-
for (let i = 0; i < ctxVars.length; i++) {
|
|
79
|
-
const lastVar = ctxVars[i - 1];
|
|
80
|
-
const curVar = ctxVars[i];
|
|
81
|
-
const lastVarEnd = lastVar ? lastVar.offset + lastVar.text.length : 0;
|
|
82
|
-
if (curVar.isShorthand) {
|
|
83
|
-
yield [code.slice(lastVarEnd, curVar.offset + curVar.text.length), lastVarEnd];
|
|
84
|
-
yield `: `;
|
|
47
|
+
let prevEnd = 0;
|
|
48
|
+
for (const [name, offset, isShorthand] of forEachIdentifiers(ts, ctx, block, originalCode, code, prefix)) {
|
|
49
|
+
if (isShorthand) {
|
|
50
|
+
yield [code.slice(prevEnd, offset + name.length), prevEnd];
|
|
51
|
+
yield `: `;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
yield [code.slice(prevEnd, offset), prevEnd, prevEnd > 0 ? undefined : 'startEnd'];
|
|
55
|
+
}
|
|
56
|
+
if (setupRefs.has(name)) {
|
|
57
|
+
yield [name, offset];
|
|
58
|
+
yield `.value`;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
yield ['', offset, 'errorMappingOnly']; // #1205, #1264
|
|
62
|
+
if (ctx.dollarVars.has(name)) {
|
|
63
|
+
yield names.dollars;
|
|
85
64
|
}
|
|
86
65
|
else {
|
|
87
|
-
|
|
66
|
+
ctx.recordComponentAccess(block.name, name, start - prefix.length + offset);
|
|
67
|
+
yield names.ctx;
|
|
88
68
|
}
|
|
89
|
-
yield
|
|
90
|
-
|
|
91
|
-
const lastVar = ctxVars.at(-1);
|
|
92
|
-
if (lastVar.offset + lastVar.text.length < code.length) {
|
|
93
|
-
yield [code.slice(lastVar.offset + lastVar.text.length), lastVar.offset + lastVar.text.length, 'endText'];
|
|
69
|
+
yield `.`;
|
|
70
|
+
yield [name, offset];
|
|
94
71
|
}
|
|
72
|
+
prevEnd = offset + name.length;
|
|
95
73
|
}
|
|
96
|
-
|
|
97
|
-
yield [code,
|
|
74
|
+
if (prevEnd < code.length) {
|
|
75
|
+
yield [code.slice(prevEnd), prevEnd, 'startEnd'];
|
|
98
76
|
}
|
|
99
77
|
}
|
|
100
|
-
function*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (offset !== undefined) {
|
|
112
|
-
ctx.accessExternalVariable(curVar.text, offset + curVar.offset);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
ctx.accessExternalVariable(curVar.text);
|
|
116
|
-
}
|
|
117
|
-
if (ctx.dollarVars.has(curVar.text)) {
|
|
118
|
-
yield `__VLS_dollars.`;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
yield `__VLS_ctx.`;
|
|
78
|
+
function* forEachIdentifiers(ts, ctx, block, originalCode, code, prefix) {
|
|
79
|
+
if (utils_1.identifierRegex.test(originalCode) && !shouldIdentifierSkipped(ctx, originalCode)) {
|
|
80
|
+
yield [originalCode, prefix.length, false];
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const endScope = ctx.startScope();
|
|
84
|
+
const ast = (0, utils_1.getTypeScriptAST)(ts, block, code);
|
|
85
|
+
for (const [id, isShorthand] of forEachDeclarations(ts, ast, ast, ctx)) {
|
|
86
|
+
const text = (0, shared_2.getNodeText)(ts, id, ast);
|
|
87
|
+
if (shouldIdentifierSkipped(ctx, text)) {
|
|
88
|
+
continue;
|
|
122
89
|
}
|
|
123
|
-
yield [
|
|
90
|
+
yield [text, (0, shared_2.getStartEnd)(ts, id, ast).start, isShorthand];
|
|
124
91
|
}
|
|
92
|
+
endScope();
|
|
125
93
|
}
|
|
126
|
-
function
|
|
94
|
+
function* forEachDeclarations(ts, node, ast, ctx) {
|
|
127
95
|
if (ts.isIdentifier(node)) {
|
|
128
|
-
|
|
96
|
+
yield [node, false];
|
|
129
97
|
}
|
|
130
98
|
else if (ts.isShorthandPropertyAssignment(node)) {
|
|
131
|
-
|
|
99
|
+
yield [node.name, true];
|
|
132
100
|
}
|
|
133
101
|
else if (ts.isPropertyAccessExpression(node)) {
|
|
134
|
-
|
|
102
|
+
yield* forEachDeclarations(ts, node.expression, ast, ctx);
|
|
135
103
|
}
|
|
136
104
|
else if (ts.isVariableDeclaration(node)) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
ctx.addLocalVariable(name);
|
|
140
|
-
blockVars.push(name);
|
|
141
|
-
}
|
|
142
|
-
walkIdentifiersInBinding(ts, node, ast, cb, ctx, blockVars);
|
|
105
|
+
ctx.declare(...(0, collectBindings_1.collectBindingNames)(ts, node.name, ast));
|
|
106
|
+
yield* forEachDeclarationsInBinding(ts, node, ast, ctx);
|
|
143
107
|
}
|
|
144
108
|
else if (ts.isArrayBindingPattern(node) || ts.isObjectBindingPattern(node)) {
|
|
145
109
|
for (const element of node.elements) {
|
|
146
110
|
if (ts.isBindingElement(element)) {
|
|
147
|
-
|
|
111
|
+
yield* forEachDeclarationsInBinding(ts, element, ast, ctx);
|
|
148
112
|
}
|
|
149
113
|
}
|
|
150
114
|
}
|
|
151
115
|
else if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
|
|
152
|
-
|
|
116
|
+
yield* forEachDeclarationsInFunction(ts, node, ast, ctx);
|
|
153
117
|
}
|
|
154
118
|
else if (ts.isObjectLiteralExpression(node)) {
|
|
155
119
|
for (const prop of node.properties) {
|
|
156
120
|
if (ts.isPropertyAssignment(prop)) {
|
|
157
121
|
// fix https://github.com/vuejs/language-tools/issues/1176
|
|
158
122
|
if (ts.isComputedPropertyName(prop.name)) {
|
|
159
|
-
|
|
123
|
+
yield* forEachDeclarations(ts, prop.name.expression, ast, ctx);
|
|
160
124
|
}
|
|
161
|
-
|
|
125
|
+
yield* forEachDeclarations(ts, prop.initializer, ast, ctx);
|
|
162
126
|
}
|
|
163
127
|
// fix https://github.com/vuejs/language-tools/issues/1156
|
|
164
128
|
else if (ts.isShorthandPropertyAssignment(prop)) {
|
|
165
|
-
|
|
129
|
+
yield* forEachDeclarations(ts, prop, ast, ctx);
|
|
166
130
|
}
|
|
167
131
|
// fix https://github.com/vuejs/language-tools/issues/1148#issuecomment-1094378126
|
|
168
132
|
else if (ts.isSpreadAssignment(prop)) {
|
|
169
133
|
// TODO: cannot report "Spread types may only be created from object types.ts(2698)"
|
|
170
|
-
|
|
134
|
+
yield* forEachDeclarations(ts, prop.expression, ast, ctx);
|
|
171
135
|
}
|
|
172
136
|
// fix https://github.com/vuejs/language-tools/issues/4604
|
|
173
137
|
else if (ts.isFunctionLike(prop) && prop.body) {
|
|
174
|
-
|
|
138
|
+
yield* forEachDeclarationsInFunction(ts, prop, ast, ctx);
|
|
175
139
|
}
|
|
176
140
|
}
|
|
177
141
|
}
|
|
178
142
|
// fix https://github.com/vuejs/language-tools/issues/1422
|
|
179
143
|
else if (ts.isTypeNode(node)) {
|
|
180
|
-
|
|
144
|
+
yield* forEachDeclarationsInTypeNode(ts, node);
|
|
181
145
|
}
|
|
182
|
-
else {
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
ts.forEachChild(node, node => walkIdentifiers(ts, node, ast, cb, ctx, blockVars));
|
|
188
|
-
if (ts.isBlock(node)) {
|
|
189
|
-
for (const varName of blockVars) {
|
|
190
|
-
ctx.removeLocalVariable(varName);
|
|
191
|
-
}
|
|
146
|
+
else if (ts.isBlock(node)) {
|
|
147
|
+
const endScope = ctx.startScope();
|
|
148
|
+
for (const child of (0, utils_1.forEachNode)(ts, node)) {
|
|
149
|
+
yield* forEachDeclarations(ts, child, ast, ctx);
|
|
192
150
|
}
|
|
193
|
-
|
|
151
|
+
endScope();
|
|
194
152
|
}
|
|
195
|
-
|
|
196
|
-
for (const
|
|
197
|
-
ctx
|
|
153
|
+
else {
|
|
154
|
+
for (const child of (0, utils_1.forEachNode)(ts, node)) {
|
|
155
|
+
yield* forEachDeclarations(ts, child, ast, ctx);
|
|
198
156
|
}
|
|
199
157
|
}
|
|
200
158
|
}
|
|
201
|
-
function
|
|
159
|
+
function* forEachDeclarationsInBinding(ts, node, ast, ctx) {
|
|
202
160
|
if ('type' in node && node.type) {
|
|
203
|
-
|
|
161
|
+
yield* forEachDeclarationsInTypeNode(ts, node.type);
|
|
204
162
|
}
|
|
205
163
|
if (!ts.isIdentifier(node.name)) {
|
|
206
|
-
|
|
164
|
+
yield* forEachDeclarations(ts, node.name, ast, ctx);
|
|
207
165
|
}
|
|
208
166
|
if (node.initializer) {
|
|
209
|
-
|
|
167
|
+
yield* forEachDeclarations(ts, node.initializer, ast, ctx);
|
|
210
168
|
}
|
|
211
169
|
}
|
|
212
|
-
function
|
|
213
|
-
const
|
|
170
|
+
function* forEachDeclarationsInFunction(ts, node, ast, ctx) {
|
|
171
|
+
const endScope = ctx.startScope();
|
|
214
172
|
for (const param of node.parameters) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
for (const varName of functionArgs) {
|
|
219
|
-
ctx.addLocalVariable(varName);
|
|
173
|
+
ctx.declare(...(0, collectBindings_1.collectBindingNames)(ts, param.name, ast));
|
|
174
|
+
yield* forEachDeclarationsInBinding(ts, param, ast, ctx);
|
|
220
175
|
}
|
|
221
176
|
if (node.body) {
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
for (const varName of functionArgs) {
|
|
225
|
-
ctx.removeLocalVariable(varName);
|
|
177
|
+
yield* forEachDeclarations(ts, node.body, ast, ctx);
|
|
226
178
|
}
|
|
179
|
+
endScope();
|
|
227
180
|
}
|
|
228
|
-
function
|
|
181
|
+
function* forEachDeclarationsInTypeNode(ts, node) {
|
|
229
182
|
if (ts.isTypeQueryNode(node)) {
|
|
230
183
|
let id = node.exprName;
|
|
231
184
|
while (!ts.isIdentifier(id)) {
|
|
232
185
|
id = id.left;
|
|
233
186
|
}
|
|
234
|
-
|
|
187
|
+
yield [id, false];
|
|
235
188
|
}
|
|
236
189
|
else {
|
|
237
|
-
|
|
190
|
+
for (const child of (0, utils_1.forEachNode)(ts, node)) {
|
|
191
|
+
yield* forEachDeclarationsInTypeNode(ts, child);
|
|
192
|
+
}
|
|
238
193
|
}
|
|
239
194
|
}
|
|
240
|
-
function shouldIdentifierSkipped(ctx, text
|
|
241
|
-
return ctx.
|
|
195
|
+
function shouldIdentifierSkipped(ctx, text) {
|
|
196
|
+
return ctx.scopes.some(scope => scope.has(text))
|
|
242
197
|
// https://github.com/vuejs/core/blob/245230e135152900189f13a4281302de45fdcfaa/packages/compiler-core/src/transforms/transformExpression.ts#L342-L352
|
|
243
198
|
|| (0, shared_1.isGloballyAllowed)(text)
|
|
244
199
|
|| isLiteralWhitelisted(text)
|
|
245
200
|
|| text === 'require'
|
|
246
|
-
|| text.startsWith('__VLS_')
|
|
247
|
-
|| destructuredPropNames?.has(text);
|
|
201
|
+
|| text.startsWith('__VLS_');
|
|
248
202
|
}
|
|
249
203
|
//# sourceMappingURL=interpolation.js.map
|
|
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generateObjectProperty = generateObjectProperty;
|
|
4
4
|
const shared_1 = require("@vue/shared");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
+
const boundary_1 = require("../utils/boundary");
|
|
6
7
|
const camelized_1 = require("../utils/camelized");
|
|
7
8
|
const stringLiteralKey_1 = require("../utils/stringLiteralKey");
|
|
8
|
-
const wrapWith_1 = require("../utils/wrapWith");
|
|
9
9
|
const interpolation_1 = require("./interpolation");
|
|
10
10
|
function* generateObjectProperty(options, ctx, code, offset, features, shouldCamelize = false, shouldBeConstant = false) {
|
|
11
11
|
if (code.startsWith('[') && code.endsWith(']')) {
|
|
12
12
|
if (shouldBeConstant) {
|
|
13
|
-
yield* (0, interpolation_1.generateInterpolation)(options, ctx,
|
|
13
|
+
yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, features, code.slice(1, -1), offset + 1, `[__VLS_tryAsConstant(`, `)]`);
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
|
-
yield* (0, interpolation_1.generateInterpolation)(options, ctx,
|
|
16
|
+
yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, features, code, offset);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
else if (shouldCamelize) {
|
|
@@ -21,7 +21,11 @@ function* generateObjectProperty(options, ctx, code, offset, features, shouldCam
|
|
|
21
21
|
yield* (0, camelized_1.generateCamelized)(code, 'template', offset, features);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
yield* (0,
|
|
24
|
+
const token = yield* (0, boundary_1.startBoundary)('template', offset, features);
|
|
25
|
+
yield `'`;
|
|
26
|
+
yield* (0, camelized_1.generateCamelized)(code, 'template', offset, { __combineToken: token });
|
|
27
|
+
yield `'`;
|
|
28
|
+
yield (0, boundary_1.endBoundary)(token, offset + code.length);
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Code, VueCodeInformation } from '../../types';
|
|
2
2
|
import type { TemplateCodegenContext } from './context';
|
|
3
3
|
import type { TemplateCodegenOptions } from './index';
|
|
4
|
-
export declare function generatePropertyAccess(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, code: string, offset
|
|
4
|
+
export declare function generatePropertyAccess(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, code: string, offset: number, features: VueCodeInformation): Generator<Code>;
|
|
@@ -5,14 +5,12 @@ const utils_1 = require("../utils");
|
|
|
5
5
|
const stringLiteralKey_1 = require("../utils/stringLiteralKey");
|
|
6
6
|
const interpolation_1 = require("./interpolation");
|
|
7
7
|
function* generatePropertyAccess(options, ctx, code, offset, features) {
|
|
8
|
-
if (
|
|
9
|
-
yield
|
|
10
|
-
yield offset !== undefined && features
|
|
11
|
-
? [code, 'template', offset, features]
|
|
12
|
-
: code;
|
|
8
|
+
if (code.startsWith('[') && code.endsWith(']')) {
|
|
9
|
+
yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, features, code, offset);
|
|
13
10
|
}
|
|
14
|
-
else if (
|
|
15
|
-
yield
|
|
11
|
+
else if (utils_1.identifierRegex.test(code)) {
|
|
12
|
+
yield `.`;
|
|
13
|
+
yield [code, 'template', offset, features];
|
|
16
14
|
}
|
|
17
15
|
else {
|
|
18
16
|
yield `[`;
|
|
@@ -5,12 +5,13 @@ const CompilerDOM = require("@vue/compiler-dom");
|
|
|
5
5
|
const shared_1 = require("../../utils/shared");
|
|
6
6
|
const codeFeatures_1 = require("../codeFeatures");
|
|
7
7
|
const inlayHints_1 = require("../inlayHints");
|
|
8
|
+
const names = require("../names");
|
|
8
9
|
const utils_1 = require("../utils");
|
|
9
|
-
const
|
|
10
|
-
const elementChildren_1 = require("./elementChildren");
|
|
10
|
+
const boundary_1 = require("../utils/boundary");
|
|
11
11
|
const elementProps_1 = require("./elementProps");
|
|
12
12
|
const interpolation_1 = require("./interpolation");
|
|
13
13
|
const propertyAccess_1 = require("./propertyAccess");
|
|
14
|
+
const templateChild_1 = require("./templateChild");
|
|
14
15
|
function* generateSlotOutlet(options, ctx, node) {
|
|
15
16
|
const [startTagOffset] = (0, shared_1.getElementTagOffsets)(node, options.template);
|
|
16
17
|
const startTagEndOffset = startTagOffset + node.tag.length;
|
|
@@ -29,7 +30,8 @@ function* generateSlotOutlet(options, ctx, node) {
|
|
|
29
30
|
if (nameProp) {
|
|
30
31
|
let codes;
|
|
31
32
|
if (nameProp.type === CompilerDOM.NodeTypes.ATTRIBUTE && nameProp.value) {
|
|
32
|
-
|
|
33
|
+
const [content, offset] = (0, shared_1.normalizeAttributeValue)(nameProp.value);
|
|
34
|
+
codes = (0, propertyAccess_1.generatePropertyAccess)(options, ctx, content, offset, codeFeatures_1.codeFeatures.navigationAndVerification);
|
|
33
35
|
}
|
|
34
36
|
else if (nameProp.type === CompilerDOM.NodeTypes.DIRECTIVE
|
|
35
37
|
&& nameProp.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
@@ -42,13 +44,26 @@ function* generateSlotOutlet(options, ctx, node) {
|
|
|
42
44
|
else {
|
|
43
45
|
codes = [`['default']`];
|
|
44
46
|
}
|
|
45
|
-
yield* (0,
|
|
47
|
+
const token = yield* (0, boundary_1.startBoundary)('template', nameProp.loc.start.offset, codeFeatures_1.codeFeatures.verification);
|
|
48
|
+
yield options.slotsAssignName ?? names.slots;
|
|
49
|
+
yield* codes;
|
|
50
|
+
yield (0, boundary_1.endBoundary)(token, nameProp.loc.end.offset);
|
|
46
51
|
}
|
|
47
52
|
else {
|
|
48
|
-
|
|
53
|
+
const token = yield* (0, boundary_1.startBoundary)('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
|
|
54
|
+
yield `${options.slotsAssignName ?? names.slots}[`;
|
|
55
|
+
const token2 = yield* (0, boundary_1.startBoundary)('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
|
|
56
|
+
yield `'default'`;
|
|
57
|
+
yield (0, boundary_1.endBoundary)(token2, startTagEndOffset);
|
|
58
|
+
yield `]`;
|
|
59
|
+
yield (0, boundary_1.endBoundary)(token, startTagEndOffset);
|
|
49
60
|
}
|
|
50
61
|
yield `)(`;
|
|
51
|
-
yield* (0,
|
|
62
|
+
const token = yield* (0, boundary_1.startBoundary)('template', startTagOffset, codeFeatures_1.codeFeatures.verification);
|
|
63
|
+
yield `{${utils_1.newLine}`;
|
|
64
|
+
yield* (0, elementProps_1.generateElementProps)(options, ctx, node, node.props.filter(prop => prop !== nameProp), true);
|
|
65
|
+
yield `}`;
|
|
66
|
+
yield (0, boundary_1.endBoundary)(token, startTagEndOffset);
|
|
52
67
|
yield `)${utils_1.endOfLine}`;
|
|
53
68
|
}
|
|
54
69
|
else {
|
|
@@ -73,7 +88,7 @@ function* generateSlotOutlet(options, ctx, node) {
|
|
|
73
88
|
}
|
|
74
89
|
const expVar = ctx.getInternalVariable();
|
|
75
90
|
yield `var ${expVar} = __VLS_tryAsConstant(`;
|
|
76
|
-
yield* (0, interpolation_1.generateInterpolation)(options, ctx,
|
|
91
|
+
yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, codeFeatures_1.codeFeatures.all, nameProp.exp.content, nameProp.exp.loc.start.offset);
|
|
77
92
|
yield `)${utils_1.endOfLine}`;
|
|
78
93
|
ctx.dynamicSlots.push({
|
|
79
94
|
expVar: ctx.getHoistVariable(expVar),
|
|
@@ -89,6 +104,8 @@ function* generateSlotOutlet(options, ctx, node) {
|
|
|
89
104
|
});
|
|
90
105
|
}
|
|
91
106
|
}
|
|
92
|
-
|
|
107
|
+
for (const child of node.children) {
|
|
108
|
+
yield* (0, templateChild_1.generateTemplateChild)(options, ctx, child);
|
|
109
|
+
}
|
|
93
110
|
}
|
|
94
111
|
//# sourceMappingURL=slotOutlet.js.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { TemplateCodegenOptions } from './index';
|
|
5
|
-
export declare function generateStyleScopedClassReferences(ctx: TemplateCodegenContext, withDot?: boolean): Generator<Code>;
|
|
6
|
-
export declare function collectStyleScopedClassReferences(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode): void;
|
|
1
|
+
import type { Code, SfcBlock } from '../../types';
|
|
2
|
+
export declare const references: WeakMap<SfcBlock, [version: string, [className: string, offset: number][]]>;
|
|
3
|
+
export declare function generateStyleScopedClassReference(block: SfcBlock, className: string, offset: number, fullStart?: number): Generator<Code>;
|