@vue/language-core 1.7.6 → 1.7.7
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/out/generators/template.js +93 -15
- package/package.json +4 -4
|
@@ -71,9 +71,12 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
71
71
|
const blockConditions = [];
|
|
72
72
|
let hasSlot = false;
|
|
73
73
|
let elementIndex = 0;
|
|
74
|
+
let ignoreStart;
|
|
75
|
+
let expectedErrorStart;
|
|
76
|
+
let expectedErrorNode;
|
|
74
77
|
const componentVars = generateComponentVars();
|
|
75
78
|
if (sfc.templateAst) {
|
|
76
|
-
visitNode(sfc.templateAst, undefined, undefined);
|
|
79
|
+
visitNode(sfc.templateAst, undefined, undefined, undefined);
|
|
77
80
|
}
|
|
78
81
|
generateStyleScopedClasses();
|
|
79
82
|
if (!hasScriptSetupSlots) {
|
|
@@ -237,11 +240,80 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
237
240
|
});
|
|
238
241
|
return tagOffsetsMap;
|
|
239
242
|
}
|
|
240
|
-
function
|
|
243
|
+
function resolveComment() {
|
|
244
|
+
if (ignoreStart !== undefined) {
|
|
245
|
+
for (let i = ignoreStart; i < codes.length; i++) {
|
|
246
|
+
const code = codes[i];
|
|
247
|
+
if (typeof code === 'string') {
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const cap = code[3];
|
|
251
|
+
if (cap.diagnostic) {
|
|
252
|
+
code[3] = {
|
|
253
|
+
...cap,
|
|
254
|
+
diagnostic: false,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
ignoreStart = undefined;
|
|
259
|
+
}
|
|
260
|
+
if (expectedErrorStart !== undefined && expectedErrorStart !== codes.length && expectedErrorNode) {
|
|
261
|
+
let errors = 0;
|
|
262
|
+
const suppressError = () => {
|
|
263
|
+
errors++;
|
|
264
|
+
return false;
|
|
265
|
+
};
|
|
266
|
+
for (let i = expectedErrorStart; i < codes.length; i++) {
|
|
267
|
+
const code = codes[i];
|
|
268
|
+
if (typeof code === 'string') {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
const cap = code[3];
|
|
272
|
+
if (cap.diagnostic) {
|
|
273
|
+
code[3] = {
|
|
274
|
+
...cap,
|
|
275
|
+
diagnostic: {
|
|
276
|
+
shouldReport: suppressError,
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
codes.push([
|
|
282
|
+
'// @ts-expect-error',
|
|
283
|
+
'template',
|
|
284
|
+
[expectedErrorNode.loc.start.offset, expectedErrorNode.loc.end.offset],
|
|
285
|
+
{
|
|
286
|
+
diagnostic: {
|
|
287
|
+
shouldReport: () => errors === 0,
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
], '\n{};\n');
|
|
291
|
+
expectedErrorStart = undefined;
|
|
292
|
+
expectedErrorNode = undefined;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
function visitNode(node, parentEl, prevNode, componentCtxVar) {
|
|
296
|
+
resolveComment();
|
|
297
|
+
if (prevNode?.type === 3 /* CompilerDOM.NodeTypes.COMMENT */) {
|
|
298
|
+
const commentText = prevNode.content.trim();
|
|
299
|
+
if (commentText === '@vue-skip') {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
else if (commentText === '@vue-ignore') {
|
|
303
|
+
ignoreStart = codes.length;
|
|
304
|
+
}
|
|
305
|
+
else if (commentText === '@vue-expected-error') {
|
|
306
|
+
expectedErrorStart = codes.length;
|
|
307
|
+
expectedErrorNode = prevNode;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
241
310
|
if (node.type === 0 /* CompilerDOM.NodeTypes.ROOT */) {
|
|
311
|
+
let prev;
|
|
242
312
|
for (const childNode of node.children) {
|
|
243
|
-
visitNode(childNode, parentEl, componentCtxVar);
|
|
313
|
+
visitNode(childNode, parentEl, prev, componentCtxVar);
|
|
314
|
+
prev = childNode;
|
|
244
315
|
}
|
|
316
|
+
resolveComment();
|
|
245
317
|
}
|
|
246
318
|
else if (node.type === 1 /* CompilerDOM.NodeTypes.ELEMENT */) {
|
|
247
319
|
const vForNode = getVForNode(node);
|
|
@@ -258,13 +330,13 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
258
330
|
}
|
|
259
331
|
else if (node.type === 12 /* CompilerDOM.NodeTypes.TEXT_CALL */) {
|
|
260
332
|
// {{ var }}
|
|
261
|
-
visitNode(node.content, parentEl, componentCtxVar);
|
|
333
|
+
visitNode(node.content, parentEl, undefined, componentCtxVar);
|
|
262
334
|
}
|
|
263
335
|
else if (node.type === 8 /* CompilerDOM.NodeTypes.COMPOUND_EXPRESSION */) {
|
|
264
336
|
// {{ ... }} {{ ... }}
|
|
265
337
|
for (const childNode of node.children) {
|
|
266
338
|
if (typeof childNode === 'object') {
|
|
267
|
-
visitNode(childNode, parentEl, componentCtxVar);
|
|
339
|
+
visitNode(childNode, parentEl, undefined, componentCtxVar);
|
|
268
340
|
}
|
|
269
341
|
}
|
|
270
342
|
}
|
|
@@ -300,12 +372,6 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
300
372
|
else if (node.type === 2 /* CompilerDOM.NodeTypes.TEXT */) {
|
|
301
373
|
// not needed progress
|
|
302
374
|
}
|
|
303
|
-
else if (node.type === 3 /* CompilerDOM.NodeTypes.COMMENT */) {
|
|
304
|
-
// not needed progress
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
codes.push(`// Unprocessed node type: ${node.type} json: ${JSON.stringify(node.loc)}\n`);
|
|
308
|
-
}
|
|
309
375
|
}
|
|
310
376
|
function visitVIfNode(node, parentEl, componentCtxVar) {
|
|
311
377
|
let originalBlockConditionsLength = blockConditions.length;
|
|
@@ -328,9 +394,12 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
328
394
|
addedBlockCondition = true;
|
|
329
395
|
}
|
|
330
396
|
codes.push(` {\n`);
|
|
397
|
+
let prev;
|
|
331
398
|
for (const childNode of branch.children) {
|
|
332
|
-
visitNode(childNode, parentEl, componentCtxVar);
|
|
399
|
+
visitNode(childNode, parentEl, prev, componentCtxVar);
|
|
400
|
+
prev = childNode;
|
|
333
401
|
}
|
|
402
|
+
resolveComment();
|
|
334
403
|
generateAutoImportCompletionCode();
|
|
335
404
|
codes.push('}\n');
|
|
336
405
|
if (addedBlockCondition) {
|
|
@@ -357,9 +426,12 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
357
426
|
if (source.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */) {
|
|
358
427
|
codes.push('(', ...createInterpolationCode(source.content, source.loc, source.loc.start.offset, capabilitiesPresets.all, '(', ')'), '!)', // #3102
|
|
359
428
|
') {\n');
|
|
429
|
+
let prev;
|
|
360
430
|
for (const childNode of node.children) {
|
|
361
|
-
visitNode(childNode, parentEl, componentCtxVar);
|
|
431
|
+
visitNode(childNode, parentEl, prev, componentCtxVar);
|
|
432
|
+
prev = childNode;
|
|
362
433
|
}
|
|
434
|
+
resolveComment();
|
|
363
435
|
generateAutoImportCompletionCode();
|
|
364
436
|
codes.push('}\n');
|
|
365
437
|
formatCodes.push(...createFormatCode(source.content, source.loc.start.offset, formatBrackets.normal));
|
|
@@ -543,9 +615,12 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
543
615
|
localVars[varName] ??= 0;
|
|
544
616
|
localVars[varName]++;
|
|
545
617
|
});
|
|
618
|
+
let prev;
|
|
546
619
|
for (const childNode of node.children) {
|
|
547
|
-
visitNode(childNode, parentEl, componentCtxVar);
|
|
620
|
+
visitNode(childNode, parentEl, prev, componentCtxVar);
|
|
621
|
+
prev = childNode;
|
|
548
622
|
}
|
|
623
|
+
resolveComment();
|
|
549
624
|
slotBlockVars.forEach(varName => {
|
|
550
625
|
localVars[varName]--;
|
|
551
626
|
});
|
|
@@ -564,9 +639,12 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
564
639
|
codes.push(`}\n`);
|
|
565
640
|
}
|
|
566
641
|
else {
|
|
642
|
+
let prev;
|
|
567
643
|
for (const childNode of node.children) {
|
|
568
|
-
visitNode(childNode, parentEl, componentCtxVar);
|
|
644
|
+
visitNode(childNode, parentEl, prev, componentCtxVar);
|
|
645
|
+
prev = childNode;
|
|
569
646
|
}
|
|
647
|
+
resolveComment();
|
|
570
648
|
}
|
|
571
649
|
codes.push(`}\n`);
|
|
572
650
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.7",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"directory": "packages/vue-language-core"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.6.
|
|
17
|
-
"@volar/source-map": "1.6.
|
|
16
|
+
"@volar/language-core": "1.6.9",
|
|
17
|
+
"@volar/source-map": "1.6.9",
|
|
18
18
|
"@vue/compiler-dom": "^3.3.0",
|
|
19
19
|
"@vue/reactivity": "^3.3.0",
|
|
20
20
|
"@vue/shared": "^3.3.0",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"optional": true
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "0e9411252a4fa30cc999e30acc5db0d126c33daf"
|
|
38
38
|
}
|