@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
|
@@ -2,26 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateElementChildren = generateElementChildren;
|
|
4
4
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
6
|
const templateChild_1 = require("./templateChild");
|
|
7
|
-
function* generateElementChildren(options, ctx, node,
|
|
7
|
+
function* generateElementChildren(options, ctx, node, isDefaultSlot = false) {
|
|
8
8
|
yield* ctx.resetDirectiveComments('end of element children start');
|
|
9
9
|
let prev;
|
|
10
10
|
for (const childNode of node.children) {
|
|
11
|
-
yield* (0, templateChild_1.generateTemplateChild)(options, ctx, childNode,
|
|
11
|
+
yield* (0, templateChild_1.generateTemplateChild)(options, ctx, childNode, prev);
|
|
12
12
|
prev = childNode;
|
|
13
13
|
}
|
|
14
14
|
yield* ctx.generateAutoImportCompletion();
|
|
15
15
|
// fix https://github.com/vuejs/language-tools/issues/932
|
|
16
|
-
if (
|
|
17
|
-
&&
|
|
16
|
+
if (ctx.currentComponent
|
|
17
|
+
&& isDefaultSlot
|
|
18
18
|
&& node.children.length
|
|
19
|
-
&& node.tagType
|
|
20
|
-
|
|
21
|
-
ctx.
|
|
22
|
-
yield
|
|
23
|
-
yield
|
|
24
|
-
yield common_1.endOfLine;
|
|
19
|
+
&& node.tagType === CompilerDOM.ElementTypes.COMPONENT) {
|
|
20
|
+
ctx.currentComponent.used = true;
|
|
21
|
+
yield `${ctx.currentComponent.ctxVar}.slots!.`;
|
|
22
|
+
yield* (0, utils_1.wrapWith)(node.children[0].loc.start.offset, node.children[node.children.length - 1].loc.end.offset, ctx.codeFeatures.navigation, `default`);
|
|
23
|
+
yield utils_1.endOfLine;
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
//# sourceMappingURL=elementChildren.js.map
|
|
@@ -3,3 +3,4 @@ import type { Code } from '../../types';
|
|
|
3
3
|
import type { TemplateCodegenContext } from './context';
|
|
4
4
|
import type { TemplateCodegenOptions } from './index';
|
|
5
5
|
export declare function generateElementDirectives(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode): Generator<Code>;
|
|
6
|
+
export declare function generateModifiers(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode, propertyName?: string): Generator<Code>;
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateElementDirectives = generateElementDirectives;
|
|
4
|
+
exports.generateModifiers = generateModifiers;
|
|
4
5
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
6
|
const shared_1 = require("@vue/shared");
|
|
6
7
|
const shared_2 = require("../../utils/shared");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
8
|
+
const codeFeatures_1 = require("../codeFeatures");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const camelized_1 = require("../utils/camelized");
|
|
11
|
+
const stringLiteralKey_1 = require("../utils/stringLiteralKey");
|
|
9
12
|
const interpolation_1 = require("./interpolation");
|
|
10
13
|
const objectProperty_1 = require("./objectProperty");
|
|
11
|
-
const
|
|
14
|
+
const builtInDirectives = new Set([
|
|
15
|
+
'cloak',
|
|
16
|
+
'html',
|
|
17
|
+
'memo',
|
|
18
|
+
'once',
|
|
19
|
+
'show',
|
|
20
|
+
'text',
|
|
21
|
+
]);
|
|
12
22
|
function* generateElementDirectives(options, ctx, node) {
|
|
13
23
|
for (const prop of node.props) {
|
|
14
24
|
if (prop.type !== CompilerDOM.NodeTypes.DIRECTIVE
|
|
@@ -21,24 +31,22 @@ function* generateElementDirectives(options, ctx, node) {
|
|
|
21
31
|
continue;
|
|
22
32
|
}
|
|
23
33
|
ctx.accessExternalVariable((0, shared_1.camelize)('v-' + prop.name), prop.loc.start.offset);
|
|
24
|
-
yield* (0,
|
|
25
|
-
yield
|
|
34
|
+
yield* (0, utils_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset, ctx.codeFeatures.verification, `__VLS_asFunctionalDirective(`, ...generateIdentifier(options, ctx, prop), `)(null!, { ...__VLS_directiveBindingRestFields, `, ...generateArg(options, ctx, prop), ...generateModifiers(options, ctx, prop), ...generateValue(options, ctx, prop), ` }, null!, null!)`);
|
|
35
|
+
yield utils_1.endOfLine;
|
|
26
36
|
}
|
|
27
37
|
}
|
|
28
|
-
function* generateIdentifier(ctx, prop) {
|
|
38
|
+
function* generateIdentifier(options, ctx, prop) {
|
|
29
39
|
const rawName = 'v-' + prop.name;
|
|
30
|
-
yield* (0,
|
|
31
|
-
...
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
isAdditional: true,
|
|
36
|
-
},
|
|
40
|
+
yield* (0, utils_1.wrapWith)(prop.loc.start.offset, prop.loc.start.offset + rawName.length, ctx.codeFeatures.verification, `__VLS_directives.`, ...(0, camelized_1.generateCamelized)(rawName, prop.loc.start.offset, ctx.resolveCodeFeatures({
|
|
41
|
+
...codeFeatures_1.codeFeatures.withoutHighlight,
|
|
42
|
+
// fix https://github.com/vuejs/language-tools/issues/1905
|
|
43
|
+
...codeFeatures_1.codeFeatures.additionalCompletion,
|
|
44
|
+
verification: options.vueCompilerOptions.checkUnknownDirectives && !builtInDirectives.has(prop.name),
|
|
37
45
|
navigation: {
|
|
38
46
|
resolveRenameNewName: shared_1.camelize,
|
|
39
47
|
resolveRenameEditText: getPropRenameApply(prop.name),
|
|
40
48
|
},
|
|
41
|
-
}));
|
|
49
|
+
})));
|
|
42
50
|
}
|
|
43
51
|
function* generateArg(options, ctx, prop) {
|
|
44
52
|
const { arg } = prop;
|
|
@@ -46,34 +54,39 @@ function* generateArg(options, ctx, prop) {
|
|
|
46
54
|
return;
|
|
47
55
|
}
|
|
48
56
|
const startOffset = arg.loc.start.offset + arg.loc.source.indexOf(arg.content);
|
|
49
|
-
yield* (0,
|
|
50
|
-
yield
|
|
57
|
+
yield* (0, utils_1.wrapWith)(startOffset, startOffset + arg.content.length, ctx.codeFeatures.verification, `arg`);
|
|
58
|
+
yield `: `;
|
|
51
59
|
if (arg.isStatic) {
|
|
52
|
-
yield* (0, stringLiteralKey_1.generateStringLiteralKey)(arg.content, startOffset, ctx.codeFeatures.
|
|
60
|
+
yield* (0, stringLiteralKey_1.generateStringLiteralKey)(arg.content, startOffset, ctx.codeFeatures.all);
|
|
53
61
|
}
|
|
54
62
|
else {
|
|
55
|
-
yield* (0, interpolation_1.generateInterpolation)(options, ctx,
|
|
63
|
+
yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.all, arg.content, startOffset, arg.loc, `(`, `)`);
|
|
56
64
|
}
|
|
57
|
-
yield
|
|
65
|
+
yield `, `;
|
|
58
66
|
}
|
|
59
|
-
function* generateModifiers(options, ctx, prop) {
|
|
60
|
-
|
|
67
|
+
function* generateModifiers(options, ctx, prop, propertyName = 'modifiers') {
|
|
68
|
+
const { modifiers } = prop;
|
|
69
|
+
if (!modifiers.length) {
|
|
61
70
|
return;
|
|
62
71
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
const startOffset = modifiers[0].loc.start.offset - 1;
|
|
73
|
+
const endOffset = modifiers.at(-1).loc.end.offset;
|
|
74
|
+
yield* (0, utils_1.wrapWith)(startOffset, endOffset, ctx.codeFeatures.verification, propertyName);
|
|
75
|
+
yield `: { `;
|
|
76
|
+
for (const mod of modifiers) {
|
|
77
|
+
yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, mod.content, mod.loc.start.offset, ctx.codeFeatures.withoutHighlightAndNavigation);
|
|
78
|
+
yield `: true, `;
|
|
67
79
|
}
|
|
68
|
-
yield
|
|
80
|
+
yield `}, `;
|
|
69
81
|
}
|
|
70
82
|
function* generateValue(options, ctx, prop) {
|
|
71
|
-
|
|
83
|
+
const { exp } = prop;
|
|
84
|
+
if (exp?.type !== CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
72
85
|
return;
|
|
73
86
|
}
|
|
74
|
-
yield* (0,
|
|
75
|
-
yield
|
|
76
|
-
yield* (0,
|
|
87
|
+
yield* (0, utils_1.wrapWith)(exp.loc.start.offset, exp.loc.end.offset, ctx.codeFeatures.verification, `value`);
|
|
88
|
+
yield `: `;
|
|
89
|
+
yield* (0, utils_1.wrapWith)(exp.loc.start.offset, exp.loc.end.offset, ctx.codeFeatures.verification, ...(0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.all, exp.content, exp.loc.start.offset, exp.loc, `(`, `)`));
|
|
77
90
|
}
|
|
78
91
|
function getPropRenameApply(oldName) {
|
|
79
92
|
return oldName === (0, shared_2.hyphenateAttr)(oldName) ? shared_2.hyphenateAttr : undefined;
|
|
@@ -3,7 +3,7 @@ import type * as ts from 'typescript';
|
|
|
3
3
|
import type { Code } from '../../types';
|
|
4
4
|
import type { TemplateCodegenContext } from './context';
|
|
5
5
|
import type { TemplateCodegenOptions } from './index';
|
|
6
|
-
export declare function generateElementEvents(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, componentVar: string, componentInstanceVar: string,
|
|
7
|
-
export declare function generateEventArg(ctx: TemplateCodegenContext,
|
|
6
|
+
export declare function generateElementEvents(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, componentVar: string, componentInstanceVar: string, eventsVar: string): Generator<Code, boolean>;
|
|
7
|
+
export declare function generateEventArg(ctx: TemplateCodegenContext, name: string, start: number, directive?: string): Generator<Code>;
|
|
8
8
|
export declare function generateEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>;
|
|
9
9
|
export declare function isCompoundExpression(ts: typeof import('typescript'), ast: ts.SourceFile): boolean;
|
|
@@ -6,11 +6,10 @@ exports.generateEventExpression = generateEventExpression;
|
|
|
6
6
|
exports.isCompoundExpression = isCompoundExpression;
|
|
7
7
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
8
8
|
const shared_1 = require("@vue/shared");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const camelized_1 = require("./camelized");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const camelized_1 = require("../utils/camelized");
|
|
12
11
|
const interpolation_1 = require("./interpolation");
|
|
13
|
-
function* generateElementEvents(options, ctx, node, componentVar, componentInstanceVar,
|
|
12
|
+
function* generateElementEvents(options, ctx, node, componentVar, componentInstanceVar, eventsVar) {
|
|
14
13
|
let usedComponentEventsVar = false;
|
|
15
14
|
let propsVar;
|
|
16
15
|
for (const prop of node.props) {
|
|
@@ -22,71 +21,39 @@ function* generateElementEvents(options, ctx, node, componentVar, componentInsta
|
|
|
22
21
|
usedComponentEventsVar = true;
|
|
23
22
|
if (!propsVar) {
|
|
24
23
|
propsVar = ctx.getInternalVariable();
|
|
25
|
-
yield `let ${propsVar}!: __VLS_FunctionalComponentProps<typeof ${componentVar}, typeof ${componentInstanceVar}>${
|
|
24
|
+
yield `let ${propsVar}!: __VLS_FunctionalComponentProps<typeof ${componentVar}, typeof ${componentInstanceVar}>${utils_1.endOfLine}`;
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
let source = prop.arg.loc.source;
|
|
27
|
+
let start = prop.arg.loc.start.offset;
|
|
28
|
+
let propPrefix = 'on';
|
|
29
|
+
let emitPrefix = '';
|
|
30
|
+
if (source.startsWith('vue:')) {
|
|
31
|
+
source = source.slice('vue:'.length);
|
|
32
|
+
start = start + 'vue:'.length;
|
|
33
|
+
propPrefix = 'onVnode';
|
|
34
|
+
emitPrefix = 'vnode-';
|
|
34
35
|
}
|
|
35
|
-
yield `(${
|
|
36
|
-
yield
|
|
37
|
-
yield `? typeof ${propsVar}${common_1.newLine}`;
|
|
38
|
-
yield `: __VLS_IsFunction<typeof ${eventsVar}, '${prop.arg.loc.source}'> extends true${common_1.newLine}`;
|
|
39
|
-
yield `? {${common_1.newLine}`;
|
|
40
|
-
yield `/**__VLS_emit,${emitVar},${prop.arg.loc.source}*/${common_1.newLine}`;
|
|
41
|
-
yield `${originalPropNameObjectKey}?: typeof ${eventsVar}['${prop.arg.loc.source}']${common_1.newLine}`;
|
|
42
|
-
yield `}${common_1.newLine}`;
|
|
43
|
-
if (prop.arg.loc.source !== (0, shared_1.camelize)(prop.arg.loc.source)) {
|
|
44
|
-
yield `: __VLS_IsFunction<typeof ${eventsVar}, '${(0, shared_1.camelize)(prop.arg.loc.source)}'> extends true${common_1.newLine}`;
|
|
45
|
-
yield `? {${common_1.newLine}`;
|
|
46
|
-
yield `/**__VLS_emit,${emitVar},${(0, shared_1.camelize)(prop.arg.loc.source)}*/${common_1.newLine}`;
|
|
47
|
-
yield `${originalPropNameObjectKey}?: typeof ${eventsVar}['${(0, shared_1.camelize)(prop.arg.loc.source)}']${common_1.newLine}`;
|
|
48
|
-
yield `}${common_1.newLine}`;
|
|
49
|
-
}
|
|
50
|
-
yield `: typeof ${propsVar}${common_1.newLine}`;
|
|
51
|
-
yield `) = {${common_1.newLine}`;
|
|
52
|
-
yield* generateEventArg(ctx, prop.arg, true);
|
|
36
|
+
yield `const ${ctx.getInternalVariable()}: __VLS_NormalizeComponentEvent<typeof ${propsVar}, typeof ${eventsVar}, '${(0, shared_1.camelize)(propPrefix + '-' + source)}', '${emitPrefix}${source}', '${(0, shared_1.camelize)(emitPrefix + source)}'> = {${utils_1.newLine}`;
|
|
37
|
+
yield* generateEventArg(ctx, source, start, propPrefix);
|
|
53
38
|
yield `: `;
|
|
54
39
|
yield* generateEventExpression(options, ctx, prop);
|
|
55
|
-
yield `}${
|
|
40
|
+
yield `}${utils_1.endOfLine}`;
|
|
56
41
|
}
|
|
57
42
|
}
|
|
58
43
|
return usedComponentEventsVar;
|
|
59
44
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if ((0, shared_2.hyphenateAttr)(newName).startsWith('on-')) {
|
|
70
|
-
return (0, shared_1.camelize)(hName.slice('on-'.length));
|
|
71
|
-
}
|
|
72
|
-
return newName;
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
function* generateEventArg(ctx, arg, enableHover) {
|
|
77
|
-
const features = enableHover
|
|
78
|
-
? {
|
|
79
|
-
...ctx.codeFeatures.withoutHighlightAndCompletion,
|
|
80
|
-
...eventArgFeatures,
|
|
81
|
-
}
|
|
82
|
-
: eventArgFeatures;
|
|
83
|
-
if (common_1.variableNameRegex.test((0, shared_1.camelize)(arg.loc.source))) {
|
|
84
|
-
yield ['', 'template', arg.loc.start.offset, features];
|
|
85
|
-
yield `on`;
|
|
86
|
-
yield* (0, camelized_1.generateCamelized)((0, shared_1.capitalize)(arg.loc.source), arg.loc.start.offset, common_1.combineLastMapping);
|
|
45
|
+
function* generateEventArg(ctx, name, start, directive = 'on') {
|
|
46
|
+
const features = {
|
|
47
|
+
...ctx.codeFeatures.withoutHighlightAndCompletion,
|
|
48
|
+
...ctx.codeFeatures.navigationWithoutRename,
|
|
49
|
+
};
|
|
50
|
+
if (utils_1.variableNameRegex.test((0, shared_1.camelize)(name))) {
|
|
51
|
+
yield ['', 'template', start, features];
|
|
52
|
+
yield directive;
|
|
53
|
+
yield* (0, camelized_1.generateCamelized)((0, shared_1.capitalize)(name), start, utils_1.combineLastMapping);
|
|
87
54
|
}
|
|
88
55
|
else {
|
|
89
|
-
yield* (0,
|
|
56
|
+
yield* (0, utils_1.wrapWith)(start, start + name.length, features, `'`, ['', 'template', start, utils_1.combineLastMapping], directive, ...(0, camelized_1.generateCamelized)((0, shared_1.capitalize)(name), start, utils_1.combineLastMapping), `'`);
|
|
90
57
|
}
|
|
91
58
|
}
|
|
92
59
|
function* generateEventExpression(options, ctx, prop) {
|
|
@@ -94,18 +61,18 @@ function* generateEventExpression(options, ctx, prop) {
|
|
|
94
61
|
let prefix = '(';
|
|
95
62
|
let suffix = ')';
|
|
96
63
|
let isFirstMapping = true;
|
|
97
|
-
const ast = (0,
|
|
64
|
+
const ast = (0, utils_1.createTsAst)(options.ts, prop.exp, prop.exp.content);
|
|
98
65
|
const _isCompoundExpression = isCompoundExpression(options.ts, ast);
|
|
99
66
|
if (_isCompoundExpression) {
|
|
100
|
-
yield `(...[$event]) => {${
|
|
67
|
+
yield `(...[$event]) => {${utils_1.newLine}`;
|
|
101
68
|
ctx.addLocalVariable('$event');
|
|
102
69
|
prefix = '';
|
|
103
70
|
suffix = '';
|
|
104
71
|
for (const blockCondition of ctx.blockConditions) {
|
|
105
|
-
prefix += `if (!(${blockCondition})) return${
|
|
72
|
+
prefix += `if (!(${blockCondition})) return${utils_1.endOfLine}`;
|
|
106
73
|
}
|
|
107
74
|
}
|
|
108
|
-
yield* (0, interpolation_1.generateInterpolation)(options, ctx,
|
|
75
|
+
yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', offset => {
|
|
109
76
|
if (_isCompoundExpression && isFirstMapping) {
|
|
110
77
|
isFirstMapping = false;
|
|
111
78
|
ctx.inlayHints.push({
|
|
@@ -122,10 +89,10 @@ function* generateEventExpression(options, ctx, prop) {
|
|
|
122
89
|
});
|
|
123
90
|
}
|
|
124
91
|
return ctx.codeFeatures.all;
|
|
125
|
-
}, prefix, suffix);
|
|
92
|
+
}, prop.exp.content, prop.exp.loc.start.offset, prop.exp.loc, prefix, suffix);
|
|
126
93
|
if (_isCompoundExpression) {
|
|
127
94
|
ctx.removeLocalVariable('$event');
|
|
128
|
-
yield
|
|
95
|
+
yield utils_1.endOfLine;
|
|
129
96
|
yield* ctx.generateAutoImportCompletion();
|
|
130
97
|
yield `}`;
|
|
131
98
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as CompilerDOM from '@vue/compiler-dom';
|
|
2
|
-
import type { Code } from '../../types';
|
|
2
|
+
import type { Code, VueCodeInformation } from '../../types';
|
|
3
3
|
import type { TemplateCodegenContext } from './context';
|
|
4
4
|
import type { TemplateCodegenOptions } from './index';
|
|
5
|
-
export
|
|
5
|
+
export interface FailedPropExpression {
|
|
6
6
|
node: CompilerDOM.SimpleExpressionNode;
|
|
7
7
|
prefix: string;
|
|
8
8
|
suffix: string;
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
|
+
export declare function generateElementProps(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, props: CompilerDOM.ElementNode['props'], strictPropsCheck: boolean, enableCodeFeatures: boolean, failedPropExps?: FailedPropExpression[]): Generator<Code>;
|
|
11
|
+
export declare function generatePropExp(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode, exp: CompilerDOM.SimpleExpressionNode | undefined, features: VueCodeInformation, enableCodeFeatures: boolean): Generator<Code>;
|