@vue/language-core 3.3.0 → 3.3.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.
|
@@ -210,7 +210,7 @@ function* generatePropExp(options, ctx, prop, exp) {
|
|
|
210
210
|
...codeFeatures_1.codeFeatures.withoutHighlightAndCompletion,
|
|
211
211
|
__shorthandExpression: 'html',
|
|
212
212
|
});
|
|
213
|
-
if (
|
|
213
|
+
if ((0, interpolation_1.shouldIdentifierSkipped)(ctx, propVariableName)) {
|
|
214
214
|
yield* codes;
|
|
215
215
|
}
|
|
216
216
|
else if (options.setupRefs.has(propVariableName)) {
|
|
@@ -4,3 +4,4 @@ export declare function generateInterpolation({ typescript, setupRefs }: {
|
|
|
4
4
|
typescript: typeof import('typescript');
|
|
5
5
|
setupRefs: Set<string>;
|
|
6
6
|
}, ctx: TemplateCodegenContext, block: IRBlock, data: VueCodeInformation, code: string, start: number, prefix?: string, suffix?: string): Generator<Code>;
|
|
7
|
+
export declare function shouldIdentifierSkipped(ctx: TemplateCodegenContext, text: string): boolean;
|
|
@@ -1,95 +1,96 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateInterpolation = generateInterpolation;
|
|
4
|
+
exports.shouldIdentifierSkipped = shouldIdentifierSkipped;
|
|
4
5
|
const shared_1 = require("@vue/shared");
|
|
5
6
|
const collectBindings_1 = require("../../utils/collectBindings");
|
|
6
7
|
const shared_2 = require("../../utils/shared");
|
|
7
8
|
const codeFeatures_1 = require("../codeFeatures");
|
|
8
9
|
const names_1 = require("../names");
|
|
9
10
|
const utils_1 = require("../utils");
|
|
11
|
+
const boundary_1 = require("../utils/boundary");
|
|
10
12
|
// https://github.com/vuejs/core/blob/fb0c3ca519f1fccf52049cd6b8db3a67a669afe9/packages/compiler-core/src/transforms/transformExpression.ts#L47
|
|
11
13
|
const isLiteralWhitelisted = /*@__PURE__*/ (0, shared_1.makeMap)('true,false,null,this');
|
|
12
14
|
function* generateInterpolation({ typescript, setupRefs }, ctx, block, data, code, start, prefix = '', suffix = '') {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
yield segment;
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
let [section, offset, type] = segment;
|
|
19
|
-
offset -= prefix.length;
|
|
20
|
-
let addSuffix = '';
|
|
21
|
-
const overLength = offset + section.length - code.length;
|
|
22
|
-
if (overLength > 0) {
|
|
23
|
-
addSuffix = section.slice(section.length - overLength);
|
|
24
|
-
section = section.slice(0, -overLength);
|
|
25
|
-
}
|
|
26
|
-
if (offset < 0) {
|
|
27
|
-
yield section.slice(0, -offset);
|
|
28
|
-
section = section.slice(-offset);
|
|
29
|
-
offset = 0;
|
|
30
|
-
}
|
|
31
|
-
const shouldSkip = section.length === 0 && type === 'startEnd';
|
|
32
|
-
if (!shouldSkip) {
|
|
33
|
-
yield [
|
|
34
|
-
section,
|
|
35
|
-
block.name,
|
|
36
|
-
start + offset,
|
|
37
|
-
type === 'errorMappingOnly'
|
|
38
|
-
? codeFeatures_1.codeFeatures.verification
|
|
39
|
-
: type === 'shorthand'
|
|
40
|
-
? { ...data, __shorthandExpression: 'js' }
|
|
41
|
-
: data,
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
yield addSuffix;
|
|
15
|
+
if (prefix) {
|
|
16
|
+
yield prefix;
|
|
45
17
|
}
|
|
46
|
-
}
|
|
47
|
-
function* forEachInterpolationSegment(ts, setupRefs, ctx, block, originalCode, start, prefix, suffix) {
|
|
48
|
-
const code = prefix + originalCode + suffix;
|
|
49
18
|
let prevEnd = 0;
|
|
50
|
-
for (const [name, offset, isShorthand] of forEachIdentifiers(
|
|
19
|
+
for (const [name, offset, isShorthand] of forEachIdentifiers(typescript, ctx, block, code, prefix, suffix)) {
|
|
51
20
|
if (isShorthand) {
|
|
52
|
-
yield [
|
|
21
|
+
yield [
|
|
22
|
+
code.slice(prevEnd, offset + name.length),
|
|
23
|
+
block.name,
|
|
24
|
+
start + prevEnd,
|
|
25
|
+
data,
|
|
26
|
+
];
|
|
53
27
|
yield `: `;
|
|
54
28
|
}
|
|
55
|
-
else {
|
|
56
|
-
yield [
|
|
29
|
+
else if (prevEnd < offset) {
|
|
30
|
+
yield [
|
|
31
|
+
code.slice(prevEnd, offset),
|
|
32
|
+
block.name,
|
|
33
|
+
start + prevEnd,
|
|
34
|
+
data,
|
|
35
|
+
];
|
|
57
36
|
}
|
|
58
37
|
if (setupRefs.has(name)) {
|
|
59
|
-
yield [
|
|
38
|
+
yield [
|
|
39
|
+
name,
|
|
40
|
+
block.name,
|
|
41
|
+
start + offset,
|
|
42
|
+
data,
|
|
43
|
+
];
|
|
60
44
|
yield `.value`;
|
|
61
45
|
}
|
|
62
46
|
else {
|
|
63
|
-
|
|
47
|
+
// #1205, #1264
|
|
48
|
+
const token = yield* (0, boundary_1.startBoundary)(block.name, start + offset, codeFeatures_1.codeFeatures.verification);
|
|
64
49
|
if (ctx.dollarVars.has(name)) {
|
|
65
50
|
yield names_1.names.dollars;
|
|
66
51
|
}
|
|
67
52
|
else {
|
|
68
|
-
ctx.recordComponentAccess(block.name, name, start
|
|
53
|
+
ctx.recordComponentAccess(block.name, name, start + offset);
|
|
69
54
|
yield names_1.names.ctx;
|
|
70
55
|
}
|
|
71
56
|
yield `.`;
|
|
72
|
-
yield [
|
|
57
|
+
yield [
|
|
58
|
+
name,
|
|
59
|
+
block.name,
|
|
60
|
+
start + offset,
|
|
61
|
+
isShorthand
|
|
62
|
+
? { ...data, __shorthandExpression: 'js' }
|
|
63
|
+
: data,
|
|
64
|
+
];
|
|
65
|
+
yield (0, boundary_1.endBoundary)(token, start + offset + name.length);
|
|
73
66
|
}
|
|
74
67
|
prevEnd = offset + name.length;
|
|
75
68
|
}
|
|
76
69
|
if (prevEnd < code.length) {
|
|
77
|
-
yield [
|
|
70
|
+
yield [
|
|
71
|
+
code.slice(prevEnd),
|
|
72
|
+
block.name,
|
|
73
|
+
start + prevEnd,
|
|
74
|
+
data,
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
if (suffix) {
|
|
78
|
+
yield suffix;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
function* forEachIdentifiers(ts, ctx, block,
|
|
81
|
-
if (utils_1.identifierRegex.test(
|
|
82
|
-
yield [
|
|
81
|
+
function* forEachIdentifiers(ts, ctx, block, code, prefix, suffix) {
|
|
82
|
+
if (utils_1.identifierRegex.test(code) && !shouldIdentifierSkipped(ctx, code)) {
|
|
83
|
+
yield [code, 0, false];
|
|
83
84
|
return;
|
|
84
85
|
}
|
|
85
86
|
const endScope = ctx.startScope();
|
|
86
|
-
const ast = (0, utils_1.getTypeScriptAST)(ts, block, code);
|
|
87
|
+
const ast = (0, utils_1.getTypeScriptAST)(ts, block, prefix + code + suffix);
|
|
87
88
|
for (const [id, isShorthand] of forEachDeclarations(ts, ast, ast, ctx)) {
|
|
88
89
|
const text = (0, shared_2.getNodeText)(ts, id, ast);
|
|
89
90
|
if (shouldIdentifierSkipped(ctx, text)) {
|
|
90
91
|
continue;
|
|
91
92
|
}
|
|
92
|
-
yield [text, (0, shared_2.getStartEnd)(ts, id, ast).start, isShorthand];
|
|
93
|
+
yield [text, (0, shared_2.getStartEnd)(ts, id, ast).start - prefix.length, isShorthand];
|
|
93
94
|
}
|
|
94
95
|
endScope();
|
|
95
96
|
}
|
|
@@ -46,12 +46,19 @@ const transformElement = (node, context) => {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
if (isComponent) {
|
|
49
|
-
let hasTemplateSlots = false;
|
|
50
49
|
let hasNamedDefaultSlot = false;
|
|
51
50
|
const implicitDefaultChildren = [];
|
|
52
51
|
const seenSlotNames = new Set();
|
|
53
52
|
const onComponentSlot = (0, compiler_dom_1.findDir)(node, 'slot', true);
|
|
54
|
-
for (
|
|
53
|
+
for (let child of node.children) {
|
|
54
|
+
// <template v-for> -> for > template
|
|
55
|
+
if (child.type === compiler_dom_1.NodeTypes.FOR) {
|
|
56
|
+
child = child.children[0];
|
|
57
|
+
}
|
|
58
|
+
// <template v-if> -> if > branch > template
|
|
59
|
+
else if (child.type === compiler_dom_1.NodeTypes.IF) {
|
|
60
|
+
child = child.branches[0].children[0];
|
|
61
|
+
}
|
|
55
62
|
let slotDir;
|
|
56
63
|
if (!(0, compiler_dom_1.isTemplateNode)(child) || !(slotDir = (0, compiler_dom_1.findDir)(child, 'slot', true))) {
|
|
57
64
|
if (child.type !== compiler_dom_1.NodeTypes.COMMENT) {
|
|
@@ -63,10 +70,6 @@ const transformElement = (node, context) => {
|
|
|
63
70
|
context.onError((0, compiler_dom_1.createCompilerError)(compiler_dom_1.ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE, slotDir.loc));
|
|
64
71
|
break;
|
|
65
72
|
}
|
|
66
|
-
if ((0, compiler_dom_1.findDir)(child, /^(?:if|else-if|else|for)$/, true)) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
hasTemplateSlots = true;
|
|
70
73
|
const staticSlotName = slotDir.arg
|
|
71
74
|
? (0, compiler_dom_1.isStaticExp)(slotDir.arg)
|
|
72
75
|
? slotDir.arg.content
|
|
@@ -83,7 +86,7 @@ const transformElement = (node, context) => {
|
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
|
-
if (
|
|
89
|
+
if (hasNamedDefaultSlot
|
|
87
90
|
&& implicitDefaultChildren.some(node => node.type !== compiler_dom_1.NodeTypes.TEXT || !!node.content.trim())) {
|
|
88
91
|
context.onError((0, compiler_dom_1.createCompilerError)(compiler_dom_1.ErrorCodes.X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN, implicitDefaultChildren[0].loc));
|
|
89
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.2",
|
|
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": "7a00047bb6d133bf26fa6e916e856fdca40b3c49"
|
|
38
38
|
}
|
|
@@ -109,7 +109,7 @@ declare global {
|
|
|
109
109
|
};
|
|
110
110
|
type __VLS_PrettifyGlobal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
111
111
|
|
|
112
|
-
function __VLS_vFor<T>(source: T): T extends number ? [number, number][]
|
|
112
|
+
function __VLS_vFor<const T>(source: T): T extends number ? [number, number][]
|
|
113
113
|
: T extends string ? [string, number][]
|
|
114
114
|
: T extends readonly (infer U)[] ? [U, number][]
|
|
115
115
|
: T extends Iterable<infer V> ? [V, number][]
|