@vue/language-core 2.0.7 → 2.0.11
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/generators/globalTypes.d.ts +2 -0
- package/lib/generators/globalTypes.js +135 -0
- package/lib/generators/inlineCss.d.ts +3 -0
- package/lib/generators/inlineCss.js +37 -0
- package/lib/generators/script.js +26 -129
- package/lib/generators/template.d.ts +13 -3
- package/lib/generators/template.js +144 -177
- package/lib/generators/utils.d.ts +1 -2
- package/lib/generators/utils.js +1 -5
- package/lib/languageModule.d.ts +7 -2
- package/lib/languageModule.js +40 -23
- package/lib/parsers/scriptSetupRanges.d.ts +1 -0
- package/lib/parsers/scriptSetupRanges.js +1 -0
- package/lib/plugins/vue-sfc-styles.js +37 -11
- package/lib/plugins/vue-template-inline-css.d.ts +3 -0
- package/lib/plugins/vue-template-inline-css.js +23 -0
- package/lib/plugins/vue-template-inline-ts.d.ts +3 -0
- package/lib/plugins/vue-template-inline-ts.js +151 -0
- package/lib/plugins/vue-tsx.d.ts +1 -4
- package/lib/plugins/vue-tsx.js +3 -73
- package/lib/plugins.js +4 -0
- package/lib/virtualFile/computedFiles.js +1 -10
- package/package.json +3 -3
package/lib/languageModule.js
CHANGED
|
@@ -35,7 +35,7 @@ function getFileRegistryKey(compilerOptions, vueCompilerOptions, plugins) {
|
|
|
35
35
|
];
|
|
36
36
|
return JSON.stringify(values);
|
|
37
37
|
}
|
|
38
|
-
function createVueLanguagePlugin(ts, getFileName,
|
|
38
|
+
function createVueLanguagePlugin(ts, getFileName, useCaseSensitiveFileNames, getProjectVersion, getScriptFileNames, compilerOptions, vueCompilerOptions, codegenStack = false) {
|
|
39
39
|
const allowLanguageIds = new Set(['vue']);
|
|
40
40
|
const pluginContext = {
|
|
41
41
|
modules: {
|
|
@@ -59,11 +59,23 @@ function createVueLanguagePlugin(ts, getFileName, isValidGlobalTypesHolder, comp
|
|
|
59
59
|
if (vueCompilerOptions.extensions.includes('.html')) {
|
|
60
60
|
allowLanguageIds.add('html');
|
|
61
61
|
}
|
|
62
|
+
const getCanonicalFileName = useCaseSensitiveFileNames
|
|
63
|
+
? (fileName) => fileName
|
|
64
|
+
: (fileName) => fileName.toLowerCase();
|
|
65
|
+
let canonicalRootFileNames = new Set();
|
|
66
|
+
let canonicalRootFileNamesVersion;
|
|
62
67
|
return {
|
|
68
|
+
getCanonicalFileName,
|
|
69
|
+
pluginContext,
|
|
63
70
|
createVirtualCode(fileId, languageId, snapshot) {
|
|
64
71
|
if (allowLanguageIds.has(languageId)) {
|
|
65
72
|
const fileName = getFileName(fileId);
|
|
66
|
-
|
|
73
|
+
const projectVersion = getProjectVersion();
|
|
74
|
+
if (projectVersion !== canonicalRootFileNamesVersion) {
|
|
75
|
+
canonicalRootFileNames = new Set([...getScriptFileNames()].map(getCanonicalFileName));
|
|
76
|
+
canonicalRootFileNamesVersion = projectVersion;
|
|
77
|
+
}
|
|
78
|
+
if (!pluginContext.globalTypesHolder && canonicalRootFileNames.has(getCanonicalFileName(fileName))) {
|
|
67
79
|
pluginContext.globalTypesHolder = fileName;
|
|
68
80
|
}
|
|
69
81
|
const fileRegistry = getFileRegistry(pluginContext.globalTypesHolder === fileName);
|
|
@@ -83,33 +95,38 @@ function createVueLanguagePlugin(ts, getFileName, isValidGlobalTypesHolder, comp
|
|
|
83
95
|
code.update(snapshot);
|
|
84
96
|
return code;
|
|
85
97
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
// TODO: when global types holder deleted, move global types to another file
|
|
99
|
+
// disposeVirtualCode(fileId, code) {
|
|
100
|
+
// const isGlobalTypesHolder = code.fileName === pluginContext.globalTypesHolder;
|
|
101
|
+
// const fileRegistry = getFileRegistry(isGlobalTypesHolder);
|
|
102
|
+
// fileRegistry.delete(fileId);
|
|
103
|
+
// if (isGlobalTypesHolder) {
|
|
104
|
+
// pluginContext.globalTypesHolder = undefined;
|
|
105
|
+
// const fileRegistry2 = getFileRegistry(false);
|
|
106
|
+
// for (const [fileId, code] of fileRegistry2) {
|
|
107
|
+
// if (isValidGlobalTypesHolder(code.fileName)) {
|
|
108
|
+
// pluginContext.globalTypesHolder = code.fileName;
|
|
109
|
+
// fileRegistry2.delete(fileId);
|
|
110
|
+
// // force dirty
|
|
111
|
+
// files?.delete(fileId);
|
|
112
|
+
// files?.set(
|
|
113
|
+
// fileId,
|
|
114
|
+
// code.languageId,
|
|
115
|
+
// code.snapshot,
|
|
116
|
+
// );
|
|
117
|
+
// break;
|
|
118
|
+
// }
|
|
119
|
+
// }
|
|
120
|
+
// }
|
|
121
|
+
// },
|
|
105
122
|
typescript: {
|
|
106
123
|
extraFileExtensions: vueCompilerOptions.extensions.map(ext => ({
|
|
107
124
|
extension: ext.slice(1),
|
|
108
125
|
isMixedContent: true,
|
|
109
126
|
scriptKind: 7,
|
|
110
127
|
})),
|
|
111
|
-
|
|
112
|
-
for (const code of (0, language_core_1.forEachEmbeddedCode)(
|
|
128
|
+
getServiceScript(root) {
|
|
129
|
+
for (const code of (0, language_core_1.forEachEmbeddedCode)(root)) {
|
|
113
130
|
if (code.id.startsWith('script_')) {
|
|
114
131
|
const lang = code.id.substring('script_'.length);
|
|
115
132
|
return {
|
|
@@ -43,6 +43,7 @@ export declare function parseScriptSetupRanges(ts: typeof import('typescript'),
|
|
|
43
43
|
name: TextRange | undefined;
|
|
44
44
|
nameIsString: boolean;
|
|
45
45
|
type: TextRange | undefined;
|
|
46
|
+
modifierType?: TextRange | undefined;
|
|
46
47
|
defaultValue: TextRange | undefined;
|
|
47
48
|
required: boolean;
|
|
48
49
|
isModel?: boolean | undefined;
|
|
@@ -87,6 +87,7 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
87
87
|
name,
|
|
88
88
|
nameIsString: true,
|
|
89
89
|
type: node.typeArguments?.length ? _getStartEnd(node.typeArguments[0]) : undefined,
|
|
90
|
+
modifierType: node.typeArguments && node.typeArguments?.length >= 2 ? _getStartEnd(node.typeArguments[1]) : undefined,
|
|
90
91
|
defaultValue: undefined,
|
|
91
92
|
required,
|
|
92
93
|
isModel: true,
|
|
@@ -5,21 +5,47 @@ const plugin = () => {
|
|
|
5
5
|
return {
|
|
6
6
|
version: 2,
|
|
7
7
|
getEmbeddedCodes(_fileName, sfc) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const result = [];
|
|
9
|
+
for (let i = 0; i < sfc.styles.length; i++) {
|
|
10
|
+
const style = sfc.styles[i];
|
|
11
|
+
if (style) {
|
|
12
|
+
result.push({
|
|
13
|
+
id: 'style_' + i,
|
|
14
|
+
lang: style.lang,
|
|
15
|
+
});
|
|
16
|
+
if (style.cssVars.length) {
|
|
17
|
+
result.push({
|
|
18
|
+
id: 'style_' + i + '_inline_ts',
|
|
19
|
+
lang: 'ts',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
12
25
|
},
|
|
13
26
|
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
|
|
14
27
|
if (embeddedFile.id.startsWith('style_')) {
|
|
15
|
-
const index = parseInt(embeddedFile.id.
|
|
28
|
+
const index = parseInt(embeddedFile.id.split('_')[1]);
|
|
16
29
|
const style = sfc.styles[index];
|
|
17
|
-
embeddedFile.
|
|
18
|
-
|
|
19
|
-
style.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
if (embeddedFile.id.endsWith('_inline_ts')) {
|
|
31
|
+
embeddedFile.parentCodeId = 'style_' + index;
|
|
32
|
+
for (const cssVar of style.cssVars) {
|
|
33
|
+
embeddedFile.content.push('(', [
|
|
34
|
+
cssVar.text,
|
|
35
|
+
style.name,
|
|
36
|
+
cssVar.offset,
|
|
37
|
+
(0, utils_1.enableAllFeatures)({}),
|
|
38
|
+
], ');\n');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
embeddedFile.content.push([
|
|
43
|
+
style.content,
|
|
44
|
+
style.name,
|
|
45
|
+
0,
|
|
46
|
+
(0, utils_1.enableAllFeatures)({}),
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
23
49
|
}
|
|
24
50
|
},
|
|
25
51
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const inlineCss_1 = require("../generators/inlineCss");
|
|
4
|
+
const plugin = () => {
|
|
5
|
+
return {
|
|
6
|
+
version: 2,
|
|
7
|
+
getEmbeddedCodes(_fileName, sfc) {
|
|
8
|
+
if (!sfc.template?.ast) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
return [{ id: 'template_inline_css', lang: 'css' }];
|
|
12
|
+
},
|
|
13
|
+
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
|
|
14
|
+
if (embeddedFile.id !== 'template_inline_css' || !sfc.template?.ast) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
embeddedFile.parentCodeId = 'template';
|
|
18
|
+
embeddedFile.content.push(...(0, inlineCss_1.generate)(sfc.template.ast));
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.default = plugin;
|
|
23
|
+
//# sourceMappingURL=vue-template-inline-css.js.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const template_1 = require("../generators/template");
|
|
4
|
+
const utils_1 = require("../generators/utils");
|
|
5
|
+
const CompilerDOM = require("@vue/compiler-dom");
|
|
6
|
+
const codeFeatures = (0, utils_1.disableAllFeatures)({
|
|
7
|
+
format: true,
|
|
8
|
+
// autoInserts: true, // TODO: support vue-autoinsert-parentheses
|
|
9
|
+
});
|
|
10
|
+
const formatBrackets = {
|
|
11
|
+
normal: ['`${', '}`;'],
|
|
12
|
+
if: ['if (', ') { }'],
|
|
13
|
+
for: ['for (', ') { }'],
|
|
14
|
+
// fix https://github.com/vuejs/language-tools/issues/3572
|
|
15
|
+
params: ['(', ') => {};'],
|
|
16
|
+
// fix https://github.com/vuejs/language-tools/issues/1210
|
|
17
|
+
// fix https://github.com/vuejs/language-tools/issues/2305
|
|
18
|
+
curly: ['0 +', '+ 0;'],
|
|
19
|
+
event: ['() => ', ';'],
|
|
20
|
+
};
|
|
21
|
+
const plugin = ctx => {
|
|
22
|
+
const parseds = new WeakMap();
|
|
23
|
+
return {
|
|
24
|
+
version: 2,
|
|
25
|
+
getEmbeddedCodes(_fileName, sfc) {
|
|
26
|
+
if (!sfc.template?.ast) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
const parsed = parse(sfc);
|
|
30
|
+
parseds.set(sfc, parsed);
|
|
31
|
+
const result = [];
|
|
32
|
+
for (const [id] of parsed) {
|
|
33
|
+
result.push({ id, lang: 'ts' });
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
},
|
|
37
|
+
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
|
|
38
|
+
// access template content to watch change
|
|
39
|
+
(() => sfc.template?.content)();
|
|
40
|
+
const parsed = parseds.get(sfc);
|
|
41
|
+
if (parsed) {
|
|
42
|
+
const codes = parsed.get(embeddedFile.id);
|
|
43
|
+
if (codes) {
|
|
44
|
+
embeddedFile.content.push(...codes);
|
|
45
|
+
embeddedFile.parentCodeId = 'template';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
function parse(sfc) {
|
|
51
|
+
const data = new Map();
|
|
52
|
+
if (!sfc.template?.ast) {
|
|
53
|
+
return data;
|
|
54
|
+
}
|
|
55
|
+
const templateContent = sfc.template.content;
|
|
56
|
+
let i = 0;
|
|
57
|
+
sfc.template.ast.children.forEach(visit);
|
|
58
|
+
return data;
|
|
59
|
+
function visit(node) {
|
|
60
|
+
if (node.type === CompilerDOM.NodeTypes.ELEMENT) {
|
|
61
|
+
for (const prop of node.props) {
|
|
62
|
+
if (prop.type !== CompilerDOM.NodeTypes.DIRECTIVE) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const isShorthand = prop.arg?.loc.start.offset === prop.exp?.loc.start.offset; // vue 3.4+
|
|
66
|
+
if (isShorthand) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && !prop.arg.isStatic) {
|
|
70
|
+
addFormatCodes(prop.arg.content, prop.arg.loc.start.offset, formatBrackets.normal);
|
|
71
|
+
}
|
|
72
|
+
if (prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
|
|
73
|
+
&& prop.exp.constType !== CompilerDOM.ConstantTypes.CAN_STRINGIFY // style='z-index: 2' will compile to {'z-index':'2'}
|
|
74
|
+
) {
|
|
75
|
+
if (prop.name === 'on') {
|
|
76
|
+
const ast = (0, template_1.createTsAst)(ctx.modules.typescript, prop.exp, prop.exp.content);
|
|
77
|
+
addFormatCodes(prop.exp.content, prop.exp.loc.start.offset, (0, template_1.isCompoundExpression)(ctx.modules.typescript, ast)
|
|
78
|
+
? formatBrackets.event
|
|
79
|
+
: formatBrackets.normal);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
addFormatCodes(prop.exp.content, prop.exp.loc.start.offset, formatBrackets.normal);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
for (const child of node.children) {
|
|
87
|
+
visit(child);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (node.type === CompilerDOM.NodeTypes.IF) {
|
|
91
|
+
for (let i = 0; i < node.branches.length; i++) {
|
|
92
|
+
const branch = node.branches[i];
|
|
93
|
+
if (branch.condition?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
94
|
+
addFormatCodes(branch.condition.content, branch.condition.loc.start.offset, formatBrackets.if);
|
|
95
|
+
}
|
|
96
|
+
for (const childNode of branch.children) {
|
|
97
|
+
visit(childNode);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else if (node.type === CompilerDOM.NodeTypes.FOR) {
|
|
102
|
+
const { leftExpressionRange, leftExpressionText } = (0, template_1.parseVForNode)(node);
|
|
103
|
+
const { source } = node.parseResult;
|
|
104
|
+
if (leftExpressionRange && leftExpressionText && source.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
105
|
+
const start = leftExpressionRange.start;
|
|
106
|
+
const end = source.loc.start.offset + source.content.length;
|
|
107
|
+
addFormatCodes(templateContent.substring(start, end), start, formatBrackets.for);
|
|
108
|
+
}
|
|
109
|
+
for (const child of node.children) {
|
|
110
|
+
visit(child);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else if (node.type === CompilerDOM.NodeTypes.TEXT_CALL) {
|
|
114
|
+
// {{ var }}
|
|
115
|
+
visit(node.content);
|
|
116
|
+
}
|
|
117
|
+
else if (node.type === CompilerDOM.NodeTypes.COMPOUND_EXPRESSION) {
|
|
118
|
+
// {{ ... }} {{ ... }}
|
|
119
|
+
for (const childNode of node.children) {
|
|
120
|
+
if (typeof childNode === 'object') {
|
|
121
|
+
visit(childNode);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else if (node.type === CompilerDOM.NodeTypes.INTERPOLATION) {
|
|
126
|
+
// {{ ... }}
|
|
127
|
+
const [content, start] = (0, template_1.parseInterpolationNode)(node, templateContent);
|
|
128
|
+
const lines = content.split('\n');
|
|
129
|
+
addFormatCodes(content, start, lines.length <= 1 ? formatBrackets.curly : [
|
|
130
|
+
lines[0].trim() === '' ? '(' : formatBrackets.curly[0],
|
|
131
|
+
lines[lines.length - 1].trim() === '' ? ');' : formatBrackets.curly[1],
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function addFormatCodes(code, offset, wrapper) {
|
|
136
|
+
const id = 'template_inline_ts_' + i++;
|
|
137
|
+
data.set(id, [
|
|
138
|
+
wrapper[0],
|
|
139
|
+
[
|
|
140
|
+
code,
|
|
141
|
+
'template',
|
|
142
|
+
offset,
|
|
143
|
+
codeFeatures,
|
|
144
|
+
],
|
|
145
|
+
wrapper[1],
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
exports.default = plugin;
|
|
151
|
+
//# sourceMappingURL=vue-template-inline-ts.js.map
|
package/lib/plugins/vue-tsx.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
53
53
|
name: import("../types").TextRange | undefined;
|
|
54
54
|
nameIsString: boolean;
|
|
55
55
|
type: import("../types").TextRange | undefined;
|
|
56
|
+
modifierType?: import("../types").TextRange | undefined;
|
|
56
57
|
defaultValue: import("../types").TextRange | undefined;
|
|
57
58
|
required: boolean;
|
|
58
59
|
isModel?: boolean | undefined;
|
|
@@ -67,10 +68,6 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
67
68
|
generatedTemplate: () => {
|
|
68
69
|
codes: Code[];
|
|
69
70
|
codeStacks: string[];
|
|
70
|
-
formatCodes: Code[];
|
|
71
|
-
formatCodeStacks: string[];
|
|
72
|
-
cssCodes: Code[];
|
|
73
|
-
cssCodeStacks: string[];
|
|
74
71
|
tagOffsetsMap: Map<string, number[]>;
|
|
75
72
|
accessedGlobalVariables: Set<string>;
|
|
76
73
|
hasSlot: boolean;
|
package/lib/plugins/vue-tsx.js
CHANGED
|
@@ -5,7 +5,6 @@ const language_core_1 = require("@volar/language-core");
|
|
|
5
5
|
const computeds_1 = require("computeds");
|
|
6
6
|
const script_1 = require("../generators/script");
|
|
7
7
|
const template_1 = require("../generators/template");
|
|
8
|
-
const utils_1 = require("../generators/utils");
|
|
9
8
|
const scriptRanges_1 = require("../parsers/scriptRanges");
|
|
10
9
|
const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
|
|
11
10
|
exports.tsCodegen = new WeakMap();
|
|
@@ -22,10 +21,6 @@ const plugin = ctx => {
|
|
|
22
21
|
if (['js', 'ts', 'jsx', 'tsx'].includes(tsx.lang())) {
|
|
23
22
|
files.push({ id: 'script_' + tsx.lang(), lang: tsx.lang() });
|
|
24
23
|
}
|
|
25
|
-
if (sfc.template) {
|
|
26
|
-
files.push({ id: 'template_format', lang: 'ts' });
|
|
27
|
-
files.push({ id: 'template_style', lang: 'css' });
|
|
28
|
-
}
|
|
29
24
|
return files;
|
|
30
25
|
},
|
|
31
26
|
resolveEmbeddedCode(fileName, sfc, embeddedFile) {
|
|
@@ -34,52 +29,11 @@ const plugin = ctx => {
|
|
|
34
29
|
const tsx = _tsx.generatedScript();
|
|
35
30
|
if (tsx) {
|
|
36
31
|
const [content, contentStacks] = ctx.codegenStack ? (0, language_core_1.track)([...tsx.codes], [...tsx.codeStacks]) : [[...tsx.codes], [...tsx.codeStacks]];
|
|
37
|
-
content.forEach(code => {
|
|
38
|
-
if (typeof code !== 'string') {
|
|
39
|
-
code[3].structure = false;
|
|
40
|
-
code[3].format = false;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
32
|
embeddedFile.content = content;
|
|
44
33
|
embeddedFile.contentStacks = contentStacks;
|
|
45
34
|
embeddedFile.linkedCodeMappings = [...tsx.linkedCodeMappings];
|
|
46
35
|
}
|
|
47
36
|
}
|
|
48
|
-
else if (embeddedFile.id === 'template_format') {
|
|
49
|
-
embeddedFile.parentCodeId = 'template';
|
|
50
|
-
const template = _tsx.generatedTemplate();
|
|
51
|
-
if (template) {
|
|
52
|
-
const [content, contentStacks] = ctx.codegenStack
|
|
53
|
-
? (0, language_core_1.track)([...template.formatCodes], template.formatCodeStacks.map(stack => ({ stack, length: 1 })))
|
|
54
|
-
: [[...template.formatCodes], template.formatCodeStacks.map(stack => ({ stack, length: 1 }))];
|
|
55
|
-
embeddedFile.content = content;
|
|
56
|
-
embeddedFile.contentStacks = contentStacks;
|
|
57
|
-
}
|
|
58
|
-
for (const style of sfc.styles) {
|
|
59
|
-
embeddedFile.content.push('\n\n');
|
|
60
|
-
for (const cssVar of style.cssVars) {
|
|
61
|
-
embeddedFile.content.push('(');
|
|
62
|
-
embeddedFile.content.push([
|
|
63
|
-
cssVar.text,
|
|
64
|
-
style.name,
|
|
65
|
-
cssVar.offset,
|
|
66
|
-
(0, utils_1.enableAllFeatures)({}),
|
|
67
|
-
]);
|
|
68
|
-
embeddedFile.content.push(');\n');
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else if (embeddedFile.id === 'template_style') {
|
|
73
|
-
embeddedFile.parentCodeId = 'template';
|
|
74
|
-
const template = _tsx.generatedTemplate();
|
|
75
|
-
if (template) {
|
|
76
|
-
const [content, contentStacks] = ctx.codegenStack
|
|
77
|
-
? (0, language_core_1.track)([...template.cssCodes], template.cssCodeStacks.map(stack => ({ stack, length: 1 })))
|
|
78
|
-
: [[...template.cssCodes], template.cssCodeStacks.map(stack => ({ stack, length: 1 }))];
|
|
79
|
-
embeddedFile.content = content;
|
|
80
|
-
embeddedFile.contentStacks = contentStacks;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
37
|
},
|
|
84
38
|
};
|
|
85
39
|
function useTsx(fileName, sfc) {
|
|
@@ -130,34 +84,14 @@ function createTsx(fileName, _sfc, ctx) {
|
|
|
130
84
|
return;
|
|
131
85
|
}
|
|
132
86
|
const tsCodes = [];
|
|
133
|
-
const tsFormatCodes = [];
|
|
134
|
-
const inlineCssCodes = [];
|
|
135
87
|
const tsCodegenStacks = [];
|
|
136
|
-
const tsFormatCodegenStacks = [];
|
|
137
|
-
const inlineCssCodegenStacks = [];
|
|
138
88
|
const codegen = (0, template_1.generate)(ts, ctx.compilerOptions, ctx.vueCompilerOptions, _sfc.template, shouldGenerateScopedClasses(), stylesScopedClasses(), hasScriptSetupSlots(), slotsAssignName(), propsAssignName(), ctx.codegenStack);
|
|
139
89
|
let current = codegen.next();
|
|
140
90
|
while (!current.done) {
|
|
141
|
-
const [
|
|
142
|
-
|
|
143
|
-
tsCodes.push(code);
|
|
144
|
-
}
|
|
145
|
-
else if (type === 'tsFormat') {
|
|
146
|
-
tsFormatCodes.push(code);
|
|
147
|
-
}
|
|
148
|
-
else if (type === 'inlineCss') {
|
|
149
|
-
inlineCssCodes.push(code);
|
|
150
|
-
}
|
|
91
|
+
const [code, stack] = current.value;
|
|
92
|
+
tsCodes.push(code);
|
|
151
93
|
if (ctx.codegenStack) {
|
|
152
|
-
|
|
153
|
-
tsCodegenStacks.push(stack);
|
|
154
|
-
}
|
|
155
|
-
else if (type === 'tsFormat') {
|
|
156
|
-
tsFormatCodegenStacks.push(stack);
|
|
157
|
-
}
|
|
158
|
-
else if (type === 'inlineCss') {
|
|
159
|
-
inlineCssCodegenStacks.push(stack);
|
|
160
|
-
}
|
|
94
|
+
tsCodegenStacks.push(stack);
|
|
161
95
|
}
|
|
162
96
|
current = codegen.next();
|
|
163
97
|
}
|
|
@@ -165,10 +99,6 @@ function createTsx(fileName, _sfc, ctx) {
|
|
|
165
99
|
...current.value,
|
|
166
100
|
codes: tsCodes,
|
|
167
101
|
codeStacks: tsCodegenStacks,
|
|
168
|
-
formatCodes: tsFormatCodes,
|
|
169
|
-
formatCodeStacks: tsFormatCodegenStacks,
|
|
170
|
-
cssCodes: inlineCssCodes,
|
|
171
|
-
cssCodeStacks: inlineCssCodegenStacks,
|
|
172
102
|
};
|
|
173
103
|
});
|
|
174
104
|
const hasScriptSetupSlots = (0, computeds_1.computed)(() => !!scriptSetupRanges()?.slots.define);
|
package/lib/plugins.js
CHANGED
|
@@ -9,6 +9,8 @@ const vue_sfc_scripts_1 = require("./plugins/vue-sfc-scripts");
|
|
|
9
9
|
const vue_sfc_styles_1 = require("./plugins/vue-sfc-styles");
|
|
10
10
|
const vue_sfc_template_1 = require("./plugins/vue-sfc-template");
|
|
11
11
|
const vue_template_html_1 = require("./plugins/vue-template-html");
|
|
12
|
+
const vue_template_inline_css_1 = require("./plugins/vue-template-inline-css");
|
|
13
|
+
const vue_template_inline_ts_1 = require("./plugins/vue-template-inline-ts");
|
|
12
14
|
const vue_tsx_1 = require("./plugins/vue-tsx");
|
|
13
15
|
const types_1 = require("./types");
|
|
14
16
|
function getDefaultVueLanguagePlugins(pluginContext) {
|
|
@@ -17,6 +19,8 @@ function getDefaultVueLanguagePlugins(pluginContext) {
|
|
|
17
19
|
file_html_1.default, // .html for PetiteVue
|
|
18
20
|
file_vue_1.default, // .vue and others for Vue
|
|
19
21
|
vue_template_html_1.default,
|
|
22
|
+
vue_template_inline_css_1.default,
|
|
23
|
+
vue_template_inline_ts_1.default,
|
|
20
24
|
vue_sfc_styles_1.default,
|
|
21
25
|
vue_sfc_customblocks_1.default,
|
|
22
26
|
vue_sfc_scripts_1.default,
|
|
@@ -36,16 +36,7 @@ function computedFiles(plugins, fileName, sfc, codegenStack) {
|
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
for (const { file
|
|
40
|
-
embeddedCodes.push({
|
|
41
|
-
id: file.id,
|
|
42
|
-
languageId: (0, language_core_1.resolveCommonLanguageId)(`/dummy.${file.lang}`),
|
|
43
|
-
linkedCodeMappings: file.linkedCodeMappings,
|
|
44
|
-
snapshot,
|
|
45
|
-
mappings,
|
|
46
|
-
codegenStacks,
|
|
47
|
-
embeddedCodes: [],
|
|
48
|
-
});
|
|
39
|
+
for (const { file } of remain) {
|
|
49
40
|
console.error('Unable to resolve embedded: ' + file.parentCodeId + ' -> ' + file.id);
|
|
50
41
|
}
|
|
51
42
|
return embeddedCodes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/language-core"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "~2.
|
|
15
|
+
"@volar/language-core": "~2.2.0-alpha.6",
|
|
16
16
|
"@vue/compiler-dom": "^3.4.0",
|
|
17
17
|
"@vue/shared": "^3.4.0",
|
|
18
18
|
"computeds": "^0.0.1",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"optional": true
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "c89f25ffc32c760130adeeac796b9a5d20585bf7"
|
|
38
38
|
}
|