@vue/language-core 2.0.20 → 2.0.22
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/common.js +6 -6
- package/lib/codegen/script/component.js +4 -5
- package/lib/codegen/script/context.js +1 -2
- package/lib/codegen/script/globalTypes.js +26 -18
- package/lib/codegen/script/index.js +20 -2
- package/lib/codegen/script/internalComponent.js +1 -2
- package/lib/codegen/script/scriptSetup.js +2 -15
- package/lib/codegen/script/src.js +1 -2
- package/lib/codegen/script/template.js +2 -3
- package/lib/codegen/template/camelized.js +1 -2
- package/lib/codegen/template/context.d.ts +1 -1
- package/lib/codegen/template/context.js +1 -2
- package/lib/codegen/template/element.js +4 -5
- package/lib/codegen/template/elementChildren.js +1 -2
- package/lib/codegen/template/elementDirectives.js +1 -2
- package/lib/codegen/template/elementEvents.js +8 -9
- package/lib/codegen/template/elementProps.js +6 -7
- package/lib/codegen/template/index.js +2 -3
- package/lib/codegen/template/interpolation.js +2 -3
- package/lib/codegen/template/objectProperty.js +1 -2
- package/lib/codegen/template/propertyAccess.js +1 -2
- package/lib/codegen/template/slotOutlet.js +1 -2
- package/lib/codegen/template/stringLiteralKey.js +1 -2
- package/lib/codegen/template/templateChild.js +3 -4
- package/lib/codegen/template/vFor.js +2 -3
- package/lib/codegen/template/vIf.js +3 -4
- package/lib/languageModule.js +1 -2
- package/lib/parsers/scriptRanges.js +1 -2
- package/lib/parsers/scriptSetupRanges.d.ts +27 -27
- package/lib/parsers/scriptSetupRanges.js +5 -6
- package/lib/plugins/file-md.js +6 -4
- package/lib/plugins/vue-tsx.d.ts +33 -33
- package/lib/plugins.d.ts +5 -5
- package/lib/plugins.js +1 -2
- package/lib/types.d.ts +2 -1
- package/lib/utils/buildMappings.d.ts +3 -0
- package/lib/utils/buildMappings.js +23 -0
- package/lib/utils/parseCssClassNames.js +1 -2
- package/lib/utils/parseCssVars.js +2 -3
- package/lib/utils/parseSfc.js +1 -2
- package/lib/utils/shared.js +3 -3
- package/lib/utils/ts.js +3 -4
- package/lib/virtualFile/computedFiles.d.ts +1 -1
- package/lib/virtualFile/computedFiles.js +6 -6
- package/lib/virtualFile/computedMappings.d.ts +1 -1
- package/lib/virtualFile/computedMappings.js +3 -4
- package/lib/virtualFile/computedSfc.js +1 -2
- package/lib/virtualFile/computedVueSfc.js +1 -2
- package/package.json +4 -3
package/lib/codegen/common.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.variableNameRegex = exports.combineLastMapping = exports.endOfLine = exports.newLine = void 0;
|
|
4
|
+
exports.conditionWrapWith = conditionWrapWith;
|
|
5
|
+
exports.wrapWith = wrapWith;
|
|
6
|
+
exports.collectVars = collectVars;
|
|
7
|
+
exports.createTsAst = createTsAst;
|
|
8
|
+
exports.generateSfcBlockSection = generateSfcBlockSection;
|
|
4
9
|
const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
|
|
5
10
|
exports.newLine = '\n';
|
|
6
11
|
exports.endOfLine = `;${exports.newLine}`;
|
|
@@ -16,7 +21,6 @@ function* conditionWrapWith(condition, startOffset, endOffset, features, ...wrap
|
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
|
-
exports.conditionWrapWith = conditionWrapWith;
|
|
20
24
|
function* wrapWith(startOffset, endOffset, features, ...wrapCodes) {
|
|
21
25
|
yield ['', 'template', startOffset, features];
|
|
22
26
|
let offset = 1;
|
|
@@ -28,7 +32,6 @@ function* wrapWith(startOffset, endOffset, features, ...wrapCodes) {
|
|
|
28
32
|
}
|
|
29
33
|
yield ['', 'template', endOffset, { __combineOffsetMapping: offset }];
|
|
30
34
|
}
|
|
31
|
-
exports.wrapWith = wrapWith;
|
|
32
35
|
function collectVars(ts, node, ast, result) {
|
|
33
36
|
if (ts.isIdentifier(node)) {
|
|
34
37
|
result.push((0, scriptSetupRanges_1.getNodeText)(ts, node, ast));
|
|
@@ -49,7 +52,6 @@ function collectVars(ts, node, ast, result) {
|
|
|
49
52
|
ts.forEachChild(node, node => collectVars(ts, node, ast, result));
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
|
-
exports.collectVars = collectVars;
|
|
53
55
|
function createTsAst(ts, astHolder, text) {
|
|
54
56
|
if (astHolder.__volar_ast_text !== text) {
|
|
55
57
|
astHolder.__volar_ast_text = text;
|
|
@@ -57,7 +59,6 @@ function createTsAst(ts, astHolder, text) {
|
|
|
57
59
|
}
|
|
58
60
|
return astHolder.__volar_ast;
|
|
59
61
|
}
|
|
60
|
-
exports.createTsAst = createTsAst;
|
|
61
62
|
function generateSfcBlockSection(block, start, end, features) {
|
|
62
63
|
return [
|
|
63
64
|
block.content.substring(start, end),
|
|
@@ -66,5 +67,4 @@ function generateSfcBlockSection(block, start, end, features) {
|
|
|
66
67
|
features,
|
|
67
68
|
];
|
|
68
69
|
}
|
|
69
|
-
exports.generateSfcBlockSection = generateSfcBlockSection;
|
|
70
70
|
//# sourceMappingURL=common.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateComponent = generateComponent;
|
|
4
|
+
exports.generateComponentSetupReturns = generateComponentSetupReturns;
|
|
5
|
+
exports.generateScriptOptions = generateScriptOptions;
|
|
6
|
+
exports.generateScriptSetupOptions = generateScriptSetupOptions;
|
|
4
7
|
const common_1 = require("../common");
|
|
5
8
|
const index_1 = require("./index");
|
|
6
9
|
function* generateComponent(options, ctx, scriptSetup, scriptSetupRanges) {
|
|
@@ -30,7 +33,6 @@ function* generateComponent(options, ctx, scriptSetup, scriptSetupRanges) {
|
|
|
30
33
|
}
|
|
31
34
|
yield `})`;
|
|
32
35
|
}
|
|
33
|
-
exports.generateComponent = generateComponent;
|
|
34
36
|
function* generateComponentSetupReturns(scriptSetupRanges) {
|
|
35
37
|
// fill $props
|
|
36
38
|
if (scriptSetupRanges.props.define) {
|
|
@@ -43,13 +45,11 @@ function* generateComponentSetupReturns(scriptSetupRanges) {
|
|
|
43
45
|
yield `$emit: ${scriptSetupRanges.emits.name ?? '__VLS_emit'},${common_1.newLine}`;
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
|
-
exports.generateComponentSetupReturns = generateComponentSetupReturns;
|
|
47
48
|
function* generateScriptOptions(script, scriptRanges) {
|
|
48
49
|
if (scriptRanges.exportDefault?.args) {
|
|
49
50
|
yield (0, common_1.generateSfcBlockSection)(script, scriptRanges.exportDefault.args.start + 1, scriptRanges.exportDefault.args.end - 1, index_1.codeFeatures.all);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
exports.generateScriptOptions = generateScriptOptions;
|
|
53
53
|
function* generateScriptSetupOptions(options, ctx, scriptSetup, scriptSetupRanges) {
|
|
54
54
|
const propsCodegens = [];
|
|
55
55
|
if (ctx.generatedPropsType) {
|
|
@@ -105,5 +105,4 @@ function* generateScriptSetupOptions(options, ctx, scriptSetup, scriptSetupRange
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
exports.generateScriptSetupOptions = generateScriptSetupOptions;
|
|
109
108
|
//# sourceMappingURL=component.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createScriptCodegenContext =
|
|
3
|
+
exports.createScriptCodegenContext = createScriptCodegenContext;
|
|
4
4
|
const shared_1 = require("../../utils/shared");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
function createScriptCodegenContext(options) {
|
|
@@ -120,5 +120,4 @@ function createScriptCodegenContext(options) {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
exports.createScriptCodegenContext = createScriptCodegenContext;
|
|
124
123
|
//# sourceMappingURL=context.js.map
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateGlobalTypes =
|
|
3
|
+
exports.generateGlobalTypes = generateGlobalTypes;
|
|
4
4
|
const shared_1 = require("../../utils/shared");
|
|
5
5
|
function generateGlobalTypes(vueCompilerOptions) {
|
|
6
6
|
const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}`;
|
|
7
7
|
return `export const __VLS_globalTypesStart = {};
|
|
8
|
+
declare module '${vueCompilerOptions.lib}' {
|
|
9
|
+
interface GlobalComponents {}
|
|
10
|
+
}
|
|
8
11
|
declare global {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type __VLS_Element =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
`
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
type __VLS_IntrinsicElements = ${vueCompilerOptions.target >= 3.3
|
|
13
|
+
? `import('${vueCompilerOptions.lib}/jsx-runtime').JSX.IntrinsicElements;`
|
|
14
|
+
: `globalThis.JSX.IntrinsicElements;`}
|
|
15
|
+
type __VLS_Element = ${vueCompilerOptions.target >= 3.3
|
|
16
|
+
? `import('${vueCompilerOptions.lib}/jsx-runtime').JSX.Element;`
|
|
17
|
+
: `globalThis.JSX.Element;`}
|
|
18
|
+
type __VLS_GlobalComponents = import('${vueCompilerOptions.lib}').GlobalComponents
|
|
19
|
+
& Pick<typeof import('${vueCompilerOptions.lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;
|
|
20
|
+
type __VLS_BuiltInPublicProps = ${vueCompilerOptions.target >= 3.4
|
|
21
|
+
? `import('${vueCompilerOptions.lib}').PublicProps;`
|
|
22
|
+
: vueCompilerOptions.target >= 3.0
|
|
23
|
+
? `import('${vueCompilerOptions.lib}').VNodeProps
|
|
24
|
+
& import('${vueCompilerOptions.lib}').AllowedComponentProps
|
|
25
|
+
& import('${vueCompilerOptions.lib}').ComponentCustomProps;`
|
|
26
|
+
: `globalThis.JSX.IntrinsicAttributes;`}
|
|
24
27
|
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
|
|
25
28
|
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
|
|
26
29
|
|
|
@@ -91,7 +94,13 @@ declare global {
|
|
|
91
94
|
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
|
|
92
95
|
: T extends (props: infer P, ...args: any) => any ? P :
|
|
93
96
|
{};
|
|
94
|
-
type
|
|
97
|
+
type __VLS_IsFunction<T, K> = K extends keyof T
|
|
98
|
+
? __VLS_IsAny<T[K]> extends false
|
|
99
|
+
? unknown extends T[K]
|
|
100
|
+
? false
|
|
101
|
+
: true
|
|
102
|
+
: false
|
|
103
|
+
: false;
|
|
95
104
|
|
|
96
105
|
function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
|
|
97
106
|
|
|
@@ -126,6 +135,5 @@ declare global {
|
|
|
126
135
|
export const __VLS_globalTypesEnd = {};
|
|
127
136
|
`;
|
|
128
137
|
}
|
|
129
|
-
exports.generateGlobalTypes = generateGlobalTypes;
|
|
130
138
|
;
|
|
131
139
|
//# sourceMappingURL=globalTypes.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.codeFeatures = void 0;
|
|
4
|
+
exports.generateScript = generateScript;
|
|
4
5
|
const common_1 = require("../common");
|
|
5
6
|
const context_1 = require("./context");
|
|
6
7
|
const globalTypes_1 = require("./globalTypes");
|
|
@@ -41,6 +42,7 @@ function* generateScript(options) {
|
|
|
41
42
|
&& options.sfc.script.content[exportDefault.expression.start] === '{';
|
|
42
43
|
if (options.sfc.scriptSetup && options.scriptSetupRanges) {
|
|
43
44
|
yield* (0, scriptSetup_1.generateScriptSetupImports)(options.sfc.scriptSetup, options.scriptSetupRanges);
|
|
45
|
+
yield* generateDefineProp(options, options.sfc.scriptSetup);
|
|
44
46
|
if (exportDefault) {
|
|
45
47
|
yield (0, common_1.generateSfcBlockSection)(options.sfc.script, 0, exportDefault.expression.start, exports.codeFeatures.all);
|
|
46
48
|
yield* (0, scriptSetup_1.generateScriptSetup)(options, ctx, options.sfc.scriptSetup, options.scriptSetupRanges);
|
|
@@ -100,6 +102,7 @@ function* generateScript(options) {
|
|
|
100
102
|
}
|
|
101
103
|
else if (options.sfc.scriptSetup && options.scriptSetupRanges) {
|
|
102
104
|
yield* (0, scriptSetup_1.generateScriptSetupImports)(options.sfc.scriptSetup, options.scriptSetupRanges);
|
|
105
|
+
yield* generateDefineProp(options, options.sfc.scriptSetup);
|
|
103
106
|
yield* (0, scriptSetup_1.generateScriptSetup)(options, ctx, options.sfc.scriptSetup, options.scriptSetupRanges);
|
|
104
107
|
}
|
|
105
108
|
yield common_1.endOfLine;
|
|
@@ -120,5 +123,20 @@ function* generateScript(options) {
|
|
|
120
123
|
];
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
|
-
|
|
126
|
+
function* generateDefineProp(options, scriptSetup) {
|
|
127
|
+
const definePropProposalA = scriptSetup.content.trimStart().startsWith('// @experimentalDefinePropProposal=kevinEdition') || options.vueCompilerOptions.experimentalDefinePropProposal === 'kevinEdition';
|
|
128
|
+
const definePropProposalB = scriptSetup.content.trimStart().startsWith('// @experimentalDefinePropProposal=johnsonEdition') || options.vueCompilerOptions.experimentalDefinePropProposal === 'johnsonEdition';
|
|
129
|
+
if (definePropProposalA || definePropProposalB) {
|
|
130
|
+
yield `type __VLS_PropOptions<T> = Exclude<import('${options.vueCompilerOptions.lib}').Prop<T>, import('${options.vueCompilerOptions.lib}').PropType<T>>${common_1.endOfLine}`;
|
|
131
|
+
if (definePropProposalA) {
|
|
132
|
+
yield `declare function defineProp<T>(name: string, options: ({ required: true } | { default: T }) & __VLS_PropOptions<T>): import('${options.vueCompilerOptions.lib}').ComputedRef<T>${common_1.endOfLine}`;
|
|
133
|
+
yield `declare function defineProp<T>(name?: string, options?: __VLS_PropOptions<T>): import('${options.vueCompilerOptions.lib}').ComputedRef<T | undefined>${common_1.endOfLine}`;
|
|
134
|
+
}
|
|
135
|
+
if (definePropProposalB) {
|
|
136
|
+
yield `declare function defineProp<T>(value: T | (() => T), required?: boolean, options?: __VLS_PropOptions<T>): import('${options.vueCompilerOptions.lib}').ComputedRef<T>${common_1.endOfLine}`;
|
|
137
|
+
yield `declare function defineProp<T>(value: T | (() => T) | undefined, required: true, options?: __VLS_PropOptions<T>): import('${options.vueCompilerOptions.lib}').ComputedRef<T>${common_1.endOfLine}`;
|
|
138
|
+
yield `declare function defineProp<T>(value?: T | (() => T), required?: boolean, options?: __VLS_PropOptions<T>): import('${options.vueCompilerOptions.lib}').ComputedRef<T | undefined>${common_1.endOfLine}`;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
124
142
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateInternalComponent =
|
|
3
|
+
exports.generateInternalComponent = generateInternalComponent;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const component_1 = require("./component");
|
|
6
6
|
const template_1 = require("./template");
|
|
@@ -55,5 +55,4 @@ function* generateInternalComponent(options, ctx, templateCodegenCtx) {
|
|
|
55
55
|
yield `const __VLS_internalComponent = (await import('${options.vueCompilerOptions.lib}')).defineComponent({})${common_1.endOfLine}`;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
exports.generateInternalComponent = generateInternalComponent;
|
|
59
58
|
//# sourceMappingURL=internalComponent.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateScriptSetupImports = generateScriptSetupImports;
|
|
4
|
+
exports.generateScriptSetup = generateScriptSetup;
|
|
4
5
|
const common_1 = require("../common");
|
|
5
6
|
const component_1 = require("./component");
|
|
6
7
|
const index_1 = require("./index");
|
|
@@ -14,7 +15,6 @@ function* generateScriptSetupImports(scriptSetup, scriptSetupRanges) {
|
|
|
14
15
|
];
|
|
15
16
|
yield common_1.newLine;
|
|
16
17
|
}
|
|
17
|
-
exports.generateScriptSetupImports = generateScriptSetupImports;
|
|
18
18
|
function* generateScriptSetup(options, ctx, scriptSetup, scriptSetupRanges) {
|
|
19
19
|
const definePropMirrors = new Map();
|
|
20
20
|
if (scriptSetup.generic) {
|
|
@@ -81,10 +81,7 @@ function* generateScriptSetup(options, ctx, scriptSetup, scriptSetupRanges) {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
exports.generateScriptSetup = generateScriptSetup;
|
|
85
84
|
function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, syntax, definePropMirrors) {
|
|
86
|
-
const definePropProposalA = scriptSetup.content.trimStart().startsWith('// @experimentalDefinePropProposal=kevinEdition') || options.vueCompilerOptions.experimentalDefinePropProposal === 'kevinEdition';
|
|
87
|
-
const definePropProposalB = scriptSetup.content.trimStart().startsWith('// @experimentalDefinePropProposal=johnsonEdition') || options.vueCompilerOptions.experimentalDefinePropProposal === 'johnsonEdition';
|
|
88
85
|
if (options.vueCompilerOptions.target >= 3.3) {
|
|
89
86
|
yield `const { `;
|
|
90
87
|
for (const macro of Object.keys(options.vueCompilerOptions.macros)) {
|
|
@@ -94,16 +91,6 @@ function* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, sy
|
|
|
94
91
|
}
|
|
95
92
|
yield `} = await import('${options.vueCompilerOptions.lib}')${common_1.endOfLine}`;
|
|
96
93
|
}
|
|
97
|
-
if (definePropProposalA) {
|
|
98
|
-
yield `declare function defineProp<T>(name: string, options: { required: true } & Record<string, unknown>): import('${options.vueCompilerOptions.lib}').ComputedRef<T>${common_1.endOfLine}`;
|
|
99
|
-
yield `declare function defineProp<T>(name: string, options: { default: any } & Record<string, unknown>): import('${options.vueCompilerOptions.lib}').ComputedRef<T>${common_1.endOfLine}`;
|
|
100
|
-
yield `declare function defineProp<T>(name?: string, options?: any): import('${options.vueCompilerOptions.lib}').ComputedRef<T | undefined>${common_1.endOfLine}`;
|
|
101
|
-
}
|
|
102
|
-
if (definePropProposalB) {
|
|
103
|
-
yield `declare function defineProp<T>(value: T | (() => T), required?: boolean, rest?: any): import('${options.vueCompilerOptions.lib}').ComputedRef<T>${common_1.endOfLine}`;
|
|
104
|
-
yield `declare function defineProp<T>(value: T | (() => T) | undefined, required: true, rest?: any): import('${options.vueCompilerOptions.lib}').ComputedRef<T>${common_1.endOfLine}`;
|
|
105
|
-
yield `declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?: any): import('${options.vueCompilerOptions.lib}').ComputedRef<T | undefined>${common_1.endOfLine}`;
|
|
106
|
-
}
|
|
107
94
|
ctx.scriptSetupGeneratedOffset = options.getGeneratedLength() - scriptSetupRanges.importSectionEndOffset;
|
|
108
95
|
let setupCodeModifies = [];
|
|
109
96
|
const propsRange = scriptSetupRanges.props.withDefaults ?? scriptSetupRanges.props.define;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateSrc =
|
|
3
|
+
exports.generateSrc = generateSrc;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const index_1 = require("./index");
|
|
6
6
|
function* generateSrc(script, src) {
|
|
@@ -48,5 +48,4 @@ function* generateSrc(script, src) {
|
|
|
48
48
|
yield common_1.endOfLine;
|
|
49
49
|
yield `export { default } from '${src}'${common_1.endOfLine}`;
|
|
50
50
|
}
|
|
51
|
-
exports.generateSrc = generateSrc;
|
|
52
51
|
//# sourceMappingURL=src.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateTemplate = generateTemplate;
|
|
4
|
+
exports.getTemplateUsageVars = getTemplateUsageVars;
|
|
4
5
|
const shared_1 = require("../../utils/shared");
|
|
5
6
|
const common_1 = require("../common");
|
|
6
7
|
const context_1 = require("../template/context");
|
|
@@ -33,7 +34,6 @@ function* generateTemplate(options, ctx, isClassComponent) {
|
|
|
33
34
|
yield `}${common_1.newLine}`;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
exports.generateTemplate = generateTemplate;
|
|
37
37
|
function* generateExportOptions(options) {
|
|
38
38
|
yield common_1.newLine;
|
|
39
39
|
yield `const __VLS_componentsOption = `;
|
|
@@ -201,5 +201,4 @@ function getTemplateUsageVars(options, ctx) {
|
|
|
201
201
|
}
|
|
202
202
|
return usageVars;
|
|
203
203
|
}
|
|
204
|
-
exports.getTemplateUsageVars = getTemplateUsageVars;
|
|
205
204
|
//# sourceMappingURL=template.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateCamelized =
|
|
3
|
+
exports.generateCamelized = generateCamelized;
|
|
4
4
|
const shared_1 = require("@vue/shared");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
function* generateCamelized(code, offset, info) {
|
|
@@ -28,5 +28,4 @@ function* generateCamelized(code, offset, info) {
|
|
|
28
28
|
offset += part.length + 1;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
exports.generateCamelized = generateCamelized;
|
|
32
31
|
//# sourceMappingURL=camelized.js.map
|
|
@@ -5,7 +5,7 @@ export type TemplateCodegenContext = ReturnType<typeof createTemplateCodegenCont
|
|
|
5
5
|
export declare function createTemplateCodegenContext(scriptSetupBindingNames: TemplateCodegenOptions['scriptSetupBindingNames']): {
|
|
6
6
|
slots: {
|
|
7
7
|
name: string;
|
|
8
|
-
loc?: number
|
|
8
|
+
loc?: number;
|
|
9
9
|
tagRange: [number, number];
|
|
10
10
|
varName: string;
|
|
11
11
|
nodeLoc: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTemplateCodegenContext =
|
|
3
|
+
exports.createTemplateCodegenContext = createTemplateCodegenContext;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const _codeFeatures = {
|
|
6
6
|
all: {
|
|
@@ -195,5 +195,4 @@ function createTemplateCodegenContext(scriptSetupBindingNames) {
|
|
|
195
195
|
}
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
|
-
exports.createTemplateCodegenContext = createTemplateCodegenContext;
|
|
199
198
|
//# sourceMappingURL=context.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateComponent = generateComponent;
|
|
4
|
+
exports.generateElement = generateElement;
|
|
5
|
+
exports.getCanonicalComponentName = getCanonicalComponentName;
|
|
6
|
+
exports.getPossibleOriginalComponentNames = getPossibleOriginalComponentNames;
|
|
4
7
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
8
|
const shared_1 = require("@vue/shared");
|
|
6
9
|
const shared_2 = require("../../utils/shared");
|
|
@@ -180,7 +183,6 @@ function* generateComponent(options, ctx, node, currentComponent, componentCtxVa
|
|
|
180
183
|
yield `let ${var_componentEvents}!: __VLS_NormalizeEmits<typeof ${var_componentEmit}>${common_1.endOfLine}`;
|
|
181
184
|
}
|
|
182
185
|
}
|
|
183
|
-
exports.generateComponent = generateComponent;
|
|
184
186
|
function* generateElement(options, ctx, node, currentComponent, componentCtxVar) {
|
|
185
187
|
const startTagOffset = node.loc.start.offset + options.template.content.substring(node.loc.start.offset).indexOf(node.tag);
|
|
186
188
|
const endTagOffset = !node.isSelfClosing && options.template.lang === 'html'
|
|
@@ -209,7 +211,6 @@ function* generateElement(options, ctx, node, currentComponent, componentCtxVar)
|
|
|
209
211
|
yield* (0, elementChildren_1.generateElementChildren)(options, ctx, node, currentComponent, componentCtxVar);
|
|
210
212
|
}
|
|
211
213
|
}
|
|
212
|
-
exports.generateElement = generateElement;
|
|
213
214
|
function* generateVScope(options, ctx, node, props) {
|
|
214
215
|
const vScope = props.find(prop => prop.type === CompilerDOM.NodeTypes.DIRECTIVE && (prop.name === 'scope' || prop.name === 'data'));
|
|
215
216
|
let inScope = false;
|
|
@@ -242,7 +243,6 @@ function getCanonicalComponentName(tagText) {
|
|
|
242
243
|
? tagText
|
|
243
244
|
: (0, shared_1.capitalize)((0, shared_1.camelize)(tagText.replace(colonReg, '-')));
|
|
244
245
|
}
|
|
245
|
-
exports.getCanonicalComponentName = getCanonicalComponentName;
|
|
246
246
|
function getPossibleOriginalComponentNames(tagText, deduplicate) {
|
|
247
247
|
const name1 = (0, shared_1.capitalize)((0, shared_1.camelize)(tagText));
|
|
248
248
|
const name2 = (0, shared_1.camelize)(tagText);
|
|
@@ -256,7 +256,6 @@ function getPossibleOriginalComponentNames(tagText, deduplicate) {
|
|
|
256
256
|
}
|
|
257
257
|
return names;
|
|
258
258
|
}
|
|
259
|
-
exports.getPossibleOriginalComponentNames = getPossibleOriginalComponentNames;
|
|
260
259
|
function* generateCanonicalComponentName(tagText, offset, features) {
|
|
261
260
|
if (common_1.variableNameRegex.test(tagText)) {
|
|
262
261
|
yield [tagText, 'template', offset, features];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateElementChildren =
|
|
3
|
+
exports.generateElementChildren = generateElementChildren;
|
|
4
4
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const templateChild_1 = require("./templateChild");
|
|
@@ -23,5 +23,4 @@ function* generateElementChildren(options, ctx, node, currentComponent, componen
|
|
|
23
23
|
yield common_1.endOfLine;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
exports.generateElementChildren = generateElementChildren;
|
|
27
26
|
//# sourceMappingURL=elementChildren.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateElementDirectives =
|
|
3
|
+
exports.generateElementDirectives = generateElementDirectives;
|
|
4
4
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
5
|
const shared_1 = require("@vue/shared");
|
|
6
6
|
const shared_2 = require("../../utils/shared");
|
|
@@ -39,7 +39,6 @@ function* generateElementDirectives(options, ctx, node) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
exports.generateElementDirectives = generateElementDirectives;
|
|
43
42
|
function getPropRenameApply(oldName) {
|
|
44
43
|
return oldName === (0, shared_2.hyphenateAttr)(oldName) ? shared_2.hyphenateAttr : undefined;
|
|
45
44
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateElementEvents = generateElementEvents;
|
|
4
|
+
exports.generateEventArg = generateEventArg;
|
|
5
|
+
exports.generateEventExpression = generateEventExpression;
|
|
6
|
+
exports.isCompoundExpression = isCompoundExpression;
|
|
4
7
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
8
|
const shared_1 = require("@vue/shared");
|
|
6
9
|
const shared_2 = require("../../utils/shared");
|
|
@@ -29,16 +32,16 @@ function* generateElementEvents(options, ctx, node, componentVar, componentInsta
|
|
|
29
32
|
if (!options.vueCompilerOptions.strictTemplates) {
|
|
30
33
|
yield `Record<string, unknown> & `;
|
|
31
34
|
}
|
|
32
|
-
yield `(`;
|
|
33
|
-
yield `
|
|
35
|
+
yield `(${common_1.newLine}`;
|
|
36
|
+
yield `__VLS_IsFunction<typeof ${propsVar}, '${originalPropName}'> extends true${common_1.newLine}`;
|
|
34
37
|
yield `? typeof ${propsVar}${common_1.newLine}`;
|
|
35
|
-
yield `:
|
|
38
|
+
yield `: __VLS_IsFunction<typeof ${eventsVar}, '${prop.arg.loc.source}'> extends true${common_1.newLine}`;
|
|
36
39
|
yield `? {${common_1.newLine}`;
|
|
37
40
|
yield `/**__VLS_emit,${emitVar},${prop.arg.loc.source}*/${common_1.newLine}`;
|
|
38
41
|
yield `${originalPropNameObjectKey}?: typeof ${eventsVar}['${prop.arg.loc.source}']${common_1.newLine}`;
|
|
39
42
|
yield `}${common_1.newLine}`;
|
|
40
43
|
if (prop.arg.loc.source !== (0, shared_1.camelize)(prop.arg.loc.source)) {
|
|
41
|
-
yield `:
|
|
44
|
+
yield `: __VLS_IsFunction<typeof ${eventsVar}, '${(0, shared_1.camelize)(prop.arg.loc.source)}'> extends true${common_1.newLine}`;
|
|
42
45
|
yield `? {${common_1.newLine}`;
|
|
43
46
|
yield `/**__VLS_emit,${emitVar},${(0, shared_1.camelize)(prop.arg.loc.source)}*/${common_1.newLine}`;
|
|
44
47
|
yield `${originalPropNameObjectKey}?: typeof ${eventsVar}['${(0, shared_1.camelize)(prop.arg.loc.source)}']${common_1.newLine}`;
|
|
@@ -54,7 +57,6 @@ function* generateElementEvents(options, ctx, node, componentVar, componentInsta
|
|
|
54
57
|
}
|
|
55
58
|
return usedComponentEventsVar;
|
|
56
59
|
}
|
|
57
|
-
exports.generateElementEvents = generateElementEvents;
|
|
58
60
|
const eventArgFeatures = {
|
|
59
61
|
navigation: {
|
|
60
62
|
// @click-outside -> onClickOutside
|
|
@@ -87,7 +89,6 @@ function* generateEventArg(ctx, arg, enableHover) {
|
|
|
87
89
|
yield* (0, common_1.wrapWith)(arg.loc.start.offset, arg.loc.end.offset, features, `'`, ['', 'template', arg.loc.start.offset, common_1.combineLastMapping], 'on', ...(0, camelized_1.generateCamelized)((0, shared_1.capitalize)(arg.loc.source), arg.loc.start.offset, common_1.combineLastMapping), `'`);
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
|
-
exports.generateEventArg = generateEventArg;
|
|
91
92
|
function* generateEventExpression(options, ctx, prop) {
|
|
92
93
|
if (prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
93
94
|
let prefix = '(';
|
|
@@ -134,7 +135,6 @@ function* generateEventExpression(options, ctx, prop) {
|
|
|
134
135
|
yield `() => {}`;
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
|
-
exports.generateEventExpression = generateEventExpression;
|
|
138
138
|
function isCompoundExpression(ts, ast) {
|
|
139
139
|
let result = true;
|
|
140
140
|
if (ast.statements.length === 1) {
|
|
@@ -156,5 +156,4 @@ function isCompoundExpression(ts, ast) {
|
|
|
156
156
|
}
|
|
157
157
|
return result;
|
|
158
158
|
}
|
|
159
|
-
exports.isCompoundExpression = isCompoundExpression;
|
|
160
159
|
//# sourceMappingURL=elementEvents.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateElementProps =
|
|
3
|
+
exports.generateElementProps = generateElementProps;
|
|
4
4
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
5
|
const shared_1 = require("@vue/shared");
|
|
6
6
|
const minimatch_1 = require("minimatch");
|
|
7
|
+
const muggle_string_1 = require("muggle-string");
|
|
7
8
|
const shared_2 = require("../../utils/shared");
|
|
8
9
|
const common_1 = require("../common");
|
|
9
10
|
const camelized_1 = require("./camelized");
|
|
11
|
+
const elementEvents_1 = require("./elementEvents");
|
|
10
12
|
const interpolation_1 = require("./interpolation");
|
|
11
13
|
const objectProperty_1 = require("./objectProperty");
|
|
12
|
-
const language_core_1 = require("@volar/language-core");
|
|
13
|
-
const elementEvents_1 = require("./elementEvents");
|
|
14
14
|
function* generateElementProps(options, ctx, node, props, enableCodeFeatures, propsFailedExps) {
|
|
15
15
|
const isIntrinsicElement = node.tagType === CompilerDOM.ElementTypes.ELEMENT || node.tagType === CompilerDOM.ElementTypes.TEMPLATE;
|
|
16
16
|
const canCamelize = node.tagType === CompilerDOM.ElementTypes.COMPONENT;
|
|
@@ -88,7 +88,7 @@ function* generateElementProps(options, ctx, node, props, enableCodeFeatures, pr
|
|
|
88
88
|
}, prop.loc.name_2 ?? (prop.loc.name_2 = {}), shouldCamelize)
|
|
89
89
|
: [propName]), `: (`, ...genereatePropExp(options, ctx, prop.exp, ctx.codeFeatures.all, prop.arg?.loc.start.offset === prop.exp?.loc.start.offset, enableCodeFeatures), `)`);
|
|
90
90
|
if (!enableCodeFeatures) {
|
|
91
|
-
yield (0,
|
|
91
|
+
yield (0, muggle_string_1.toString)([...codes]);
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
94
|
yield* codes;
|
|
@@ -127,7 +127,7 @@ function* generateElementProps(options, ctx, node, props, enableCodeFeatures, pr
|
|
|
127
127
|
? generateAttrValue(prop.value, ctx.codeFeatures.all)
|
|
128
128
|
: [`true`]), `)`);
|
|
129
129
|
if (!enableCodeFeatures) {
|
|
130
|
-
yield (0,
|
|
130
|
+
yield (0, muggle_string_1.toString)([...codes]);
|
|
131
131
|
}
|
|
132
132
|
else {
|
|
133
133
|
yield* codes;
|
|
@@ -143,7 +143,7 @@ function* generateElementProps(options, ctx, node, props, enableCodeFeatures, pr
|
|
|
143
143
|
&& prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
144
144
|
const codes = (0, common_1.conditionWrapWith)(enableCodeFeatures, prop.exp.loc.start.offset, prop.exp.loc.end.offset, ctx.codeFeatures.verification, `...`, ...(0, interpolation_1.generateInterpolation)(options, ctx, prop.exp.content, prop.exp.loc, prop.exp.loc.start.offset, ctx.codeFeatures.all, '(', ')'));
|
|
145
145
|
if (!enableCodeFeatures) {
|
|
146
|
-
yield (0,
|
|
146
|
+
yield (0, muggle_string_1.toString)([...codes]);
|
|
147
147
|
}
|
|
148
148
|
else {
|
|
149
149
|
yield* codes;
|
|
@@ -156,7 +156,6 @@ function* generateElementProps(options, ctx, node, props, enableCodeFeatures, pr
|
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
exports.generateElementProps = generateElementProps;
|
|
160
159
|
function* genereatePropExp(options, ctx, exp, features, isShorthand, inlayHints) {
|
|
161
160
|
if (exp && exp.constType !== CompilerDOM.ConstantTypes.CAN_STRINGIFY) { // style='z-index: 2' will compile to {'z-index':'2'}
|
|
162
161
|
if (!isShorthand) { // vue 3.4+
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateTemplate = generateTemplate;
|
|
4
|
+
exports.forEachElementNode = forEachElementNode;
|
|
4
5
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
6
|
const common_1 = require("../common");
|
|
6
7
|
const context_1 = require("./context");
|
|
@@ -102,7 +103,6 @@ function* generateTemplate(options) {
|
|
|
102
103
|
yield common_1.endOfLine;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
exports.generateTemplate = generateTemplate;
|
|
106
106
|
function* forEachElementNode(node) {
|
|
107
107
|
if (node.type === CompilerDOM.NodeTypes.ROOT) {
|
|
108
108
|
for (const child of node.children) {
|
|
@@ -137,5 +137,4 @@ function* forEachElementNode(node) {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
exports.forEachElementNode = forEachElementNode;
|
|
141
140
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateInterpolation = generateInterpolation;
|
|
4
|
+
exports.forEachInterpolationSegment = forEachInterpolationSegment;
|
|
4
5
|
const shared_1 = require("@vue/shared");
|
|
5
6
|
const scriptSetupRanges_1 = require("../../parsers/scriptSetupRanges");
|
|
6
7
|
const common_1 = require("../common");
|
|
@@ -47,7 +48,6 @@ function* generateInterpolation(options, ctx, _code, astHolder, start, data, pre
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
exports.generateInterpolation = generateInterpolation;
|
|
51
51
|
function* forEachInterpolationSegment(ts, ctx, code, offset, ast) {
|
|
52
52
|
let ctxVars = [];
|
|
53
53
|
const varCb = (id, isShorthand) => {
|
|
@@ -104,7 +104,6 @@ function* forEachInterpolationSegment(ts, ctx, code, offset, ast) {
|
|
|
104
104
|
yield [code, 0];
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
exports.forEachInterpolationSegment = forEachInterpolationSegment;
|
|
108
107
|
function walkIdentifiers(ts, node, ast, cb, ctx, blockVars = [], isRoot = true) {
|
|
109
108
|
if (ts.isIdentifier(node)) {
|
|
110
109
|
cb(node, false);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateObjectProperty =
|
|
3
|
+
exports.generateObjectProperty = generateObjectProperty;
|
|
4
4
|
const shared_1 = require("@vue/shared");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const camelized_1 = require("./camelized");
|
|
@@ -27,5 +27,4 @@ function* generateObjectProperty(options, ctx, code, offset, features, astHolder
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
exports.generateObjectProperty = generateObjectProperty;
|
|
31
30
|
//# sourceMappingURL=objectProperty.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generatePropertyAccess =
|
|
3
|
+
exports.generatePropertyAccess = generatePropertyAccess;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const interpolation_1 = require("./interpolation");
|
|
6
6
|
const stringLiteralKey_1 = require("./stringLiteralKey");
|
|
@@ -20,5 +20,4 @@ function* generatePropertyAccess(options, ctx, code, offset, features, astHolder
|
|
|
20
20
|
yield `]`;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
exports.generatePropertyAccess = generatePropertyAccess;
|
|
24
23
|
//# sourceMappingURL=propertyAccess.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateSlotOutlet =
|
|
3
|
+
exports.generateSlotOutlet = generateSlotOutlet;
|
|
4
4
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const elementChildren_1 = require("./elementChildren");
|
|
@@ -67,5 +67,4 @@ function* generateSlotOutlet(options, ctx, node, currentComponent, componentCtxV
|
|
|
67
67
|
yield* ctx.generateAutoImportCompletion();
|
|
68
68
|
yield* (0, elementChildren_1.generateElementChildren)(options, ctx, node, currentComponent, componentCtxVar);
|
|
69
69
|
}
|
|
70
|
-
exports.generateSlotOutlet = generateSlotOutlet;
|
|
71
70
|
//# sourceMappingURL=slotOutlet.js.map
|