@vue/language-core 3.3.3 → 3.3.5
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/lib/codegen/names.d.ts
CHANGED
|
@@ -56,7 +56,6 @@ declare const raw: {
|
|
|
56
56
|
FunctionalComponentProps: string;
|
|
57
57
|
IsAny: string;
|
|
58
58
|
IsFunction: string;
|
|
59
|
-
NormalizeComponentEvent: string;
|
|
60
59
|
NormalizeEmits: string;
|
|
61
60
|
OverloadUnion: string;
|
|
62
61
|
OverloadUnionInner: string;
|
|
@@ -64,6 +63,7 @@ declare const raw: {
|
|
|
64
63
|
PrettifyGlobal: string;
|
|
65
64
|
ResolveDirectives: string;
|
|
66
65
|
ResolveEmits: string;
|
|
66
|
+
ResolveEvent: string;
|
|
67
67
|
ShortEmits: string;
|
|
68
68
|
ShortEmitsToObject: string;
|
|
69
69
|
SpreadMerge: string;
|
package/lib/codegen/names.js
CHANGED
|
@@ -60,7 +60,6 @@ const raw = {
|
|
|
60
60
|
FunctionalComponentProps: '',
|
|
61
61
|
IsAny: '',
|
|
62
62
|
IsFunction: '',
|
|
63
|
-
NormalizeComponentEvent: '',
|
|
64
63
|
NormalizeEmits: '',
|
|
65
64
|
OverloadUnion: '',
|
|
66
65
|
OverloadUnionInner: '',
|
|
@@ -68,6 +67,7 @@ const raw = {
|
|
|
68
67
|
PrettifyGlobal: '',
|
|
69
68
|
ResolveDirectives: '',
|
|
70
69
|
ResolveEmits: '',
|
|
70
|
+
ResolveEvent: '',
|
|
71
71
|
ShortEmits: '',
|
|
72
72
|
ShortEmitsToObject: '',
|
|
73
73
|
SpreadMerge: '',
|
|
@@ -219,9 +219,14 @@ function* generateComponent(options, ctx, node) {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
if (shouldInheritAttrs) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
if (options.vueCompilerOptions.checkRequiredFallthroughAttributes) {
|
|
223
|
+
const restsVar = ctx.getInternalVariable();
|
|
224
|
+
yield `var ${restsVar} = ${names_1.names.omit}(${getPropsVar()}, {\n${propsStr}})${utils_1.endOfLine}`;
|
|
225
|
+
ctx.inheritedAttrVars.add(restsVar);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
ctx.inheritedAttrVars.add(getPropsVar());
|
|
229
|
+
}
|
|
225
230
|
}
|
|
226
231
|
yield* generateStyleScopedClassReferences(options, node);
|
|
227
232
|
const slotDir = node.props.find(CompilerDOM.isVSlot);
|
|
@@ -47,7 +47,7 @@ const boundary_1 = require("../utils/boundary");
|
|
|
47
47
|
const camelized_1 = require("../utils/camelized");
|
|
48
48
|
const interpolation_1 = require("./interpolation");
|
|
49
49
|
function* generateElementEvents(options, ctx, node, componentOriginalVar, getCtxVar, getPropsVar) {
|
|
50
|
-
|
|
50
|
+
const definitions = {};
|
|
51
51
|
for (const prop of node.props) {
|
|
52
52
|
if (prop.type === CompilerDOM.NodeTypes.DIRECTIVE
|
|
53
53
|
&& (prop.name === 'on'
|
|
@@ -55,12 +55,8 @@ function* generateElementEvents(options, ctx, node, componentOriginalVar, getCtx
|
|
|
55
55
|
|| options.vueCompilerOptions.strictVModel
|
|
56
56
|
&& prop.name === 'model'
|
|
57
57
|
&& (!prop.arg || prop.arg.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic))) {
|
|
58
|
-
if (!emitsVar) {
|
|
59
|
-
emitsVar = ctx.getInternalVariable();
|
|
60
|
-
yield `let ${emitsVar}!: ${names_1.names.ResolveEmits}<typeof ${componentOriginalVar}, typeof ${getCtxVar()}.emit>${utils_1.endOfLine}`;
|
|
61
|
-
}
|
|
62
58
|
let source = prop.arg?.loc.source ?? 'model-value';
|
|
63
|
-
let
|
|
59
|
+
let offset = prop.arg?.loc.start.offset;
|
|
64
60
|
let propPrefix = 'on-';
|
|
65
61
|
let emitPrefix = '';
|
|
66
62
|
if (prop.name === 'model') {
|
|
@@ -69,22 +65,46 @@ function* generateElementEvents(options, ctx, node, componentOriginalVar, getCtx
|
|
|
69
65
|
}
|
|
70
66
|
else if (source.startsWith('vue:')) {
|
|
71
67
|
source = source.slice('vue:'.length);
|
|
72
|
-
|
|
68
|
+
offset = offset + 'vue:'.length;
|
|
73
69
|
propPrefix = 'onVnode-';
|
|
74
70
|
emitPrefix = 'vnode-';
|
|
75
71
|
}
|
|
76
72
|
const propName = (0, shared_1.camelize)(propPrefix + source);
|
|
77
73
|
const emitName = emitPrefix + source;
|
|
78
|
-
const
|
|
79
|
-
|
|
74
|
+
const key = [
|
|
75
|
+
prop.name,
|
|
76
|
+
propName,
|
|
77
|
+
...prop.modifiers.map(modifier => modifier.content),
|
|
78
|
+
].join('+');
|
|
79
|
+
definitions[key] ??= {
|
|
80
|
+
propPrefix,
|
|
81
|
+
emitPrefix,
|
|
82
|
+
propName,
|
|
83
|
+
emitName,
|
|
84
|
+
items: [],
|
|
85
|
+
};
|
|
86
|
+
definitions[key].items.push({
|
|
87
|
+
prop,
|
|
88
|
+
source,
|
|
89
|
+
offset,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (!Object.keys(definitions).length) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const emitsVar = ctx.getInternalVariable();
|
|
97
|
+
yield `let ${emitsVar}!: ${names_1.names.ResolveEmits}<typeof ${componentOriginalVar}, typeof ${getCtxVar()}.emit>${utils_1.endOfLine}`;
|
|
98
|
+
for (const { propPrefix, emitPrefix, propName, emitName, items } of Object.values(definitions)) {
|
|
99
|
+
yield `const ${ctx.getInternalVariable()}: ${names_1.names.ResolveEvent}<typeof ${getPropsVar()}, typeof ${emitsVar}, '${propName}', '${emitName}', '${(0, shared_1.camelize)(emitName)}'> = {${utils_1.newLine}`;
|
|
100
|
+
for (const { prop, source, offset } of items) {
|
|
80
101
|
if (prop.name === 'on') {
|
|
81
|
-
yield
|
|
82
|
-
yield* generateEventArg(options, source,
|
|
83
|
-
yield
|
|
102
|
+
yield `/** @type {typeof ${emitsVar}.`;
|
|
103
|
+
yield* generateEventArg(options, source, offset, emitPrefix.slice(0, -1), codeFeatures_1.codeFeatures.navigation);
|
|
104
|
+
yield `} */${utils_1.newLine}`;
|
|
84
105
|
}
|
|
85
|
-
yield `{ `;
|
|
86
106
|
if (prop.name === 'on') {
|
|
87
|
-
yield* generateEventArg(options, source,
|
|
107
|
+
yield* generateEventArg(options, source, offset, propPrefix.slice(0, -1));
|
|
88
108
|
yield `: `;
|
|
89
109
|
yield* generateEventExpression(options, ctx, prop);
|
|
90
110
|
}
|
|
@@ -92,8 +112,9 @@ function* generateElementEvents(options, ctx, node, componentOriginalVar, getCtx
|
|
|
92
112
|
yield `'${propName}': `;
|
|
93
113
|
yield* generateModelEventExpression(options, ctx, prop);
|
|
94
114
|
}
|
|
95
|
-
yield
|
|
115
|
+
yield `,${utils_1.newLine}`;
|
|
96
116
|
}
|
|
117
|
+
yield `}${utils_1.endOfLine}`;
|
|
97
118
|
}
|
|
98
119
|
}
|
|
99
120
|
function* generateEventArg(options, name, start, directive = 'on', features) {
|
|
@@ -239,7 +239,8 @@ function getShouldCamelize(options, node, prop, propName) {
|
|
|
239
239
|
|| node.tagType === CompilerDOM.ElementTypes.SLOT) && (prop.type !== CompilerDOM.NodeTypes.DIRECTIVE
|
|
240
240
|
|| prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic)
|
|
241
241
|
&& (0, shared_2.hyphenateAttr)(propName) === propName
|
|
242
|
-
&&
|
|
242
|
+
&& (node.tagType === CompilerDOM.ElementTypes.SLOT
|
|
243
|
+
|| !options.vueCompilerOptions.htmlAttributes.some(pattern => (0, picomatch_1.isMatch)(propName, pattern)));
|
|
243
244
|
}
|
|
244
245
|
function getPropsCodeFeatures(checkUnknownProps) {
|
|
245
246
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.5",
|
|
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": "2fe255ca6d5809c93b71ec8185ec14562cff5945"
|
|
38
38
|
}
|