@vue/language-core 1.8.4 → 1.8.6
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/out/generators/script.js +8 -7
- package/out/generators/template.js +12 -11
- package/out/languageModule.js +10 -4
- package/out/parsers/scriptSetupRanges.d.ts +1 -0
- package/out/parsers/scriptSetupRanges.js +11 -1
- package/out/plugins/file-html.js +2 -2
- package/out/plugins/file-md.js +11 -6
- package/out/plugins/vue-sfc-customblocks.js +2 -1
- package/out/plugins/vue-sfc-scripts.js +4 -2
- package/out/plugins/vue-sfc-styles.js +2 -1
- package/out/plugins/vue-sfc-template.js +2 -1
- package/out/plugins/vue-tsx.js +4 -2
- package/out/sourceFile.js +2 -1
- package/out/utils/globalTypes.js +2 -1
- package/out/utils/parseCssClassNames.js +3 -3
- package/out/utils/parseCssVars.js +7 -5
- package/out/utils/ts.js +1 -1
- package/package.json +4 -4
package/out/generators/script.js
CHANGED
|
@@ -37,6 +37,7 @@ function generate(ts, fileName, _sfc, lang, scriptRanges, scriptSetupRanges, htm
|
|
|
37
37
|
emitsTypeArg: undefined,
|
|
38
38
|
emitsTypeNums: 0,
|
|
39
39
|
exposeRuntimeArg: undefined,
|
|
40
|
+
leadingCommentEndOffset: 0,
|
|
40
41
|
importSectionEndOffset: 0,
|
|
41
42
|
defineProps: undefined,
|
|
42
43
|
propsAssignName: undefined,
|
|
@@ -229,7 +230,7 @@ function generate(ts, fileName, _sfc, lang, scriptRanges, scriptSetupRanges, htm
|
|
|
229
230
|
if (!scriptSetupRanges)
|
|
230
231
|
return;
|
|
231
232
|
codes.push([
|
|
232
|
-
sfc.scriptSetup.content.substring(0, scriptSetupRanges.importSectionEndOffset),
|
|
233
|
+
sfc.scriptSetup.content.substring(0, Math.max(scriptSetupRanges.importSectionEndOffset, scriptSetupRanges.leadingCommentEndOffset)),
|
|
233
234
|
'scriptSetup',
|
|
234
235
|
0,
|
|
235
236
|
language_core_1.FileRangeCapabilities.full,
|
|
@@ -648,7 +649,7 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
648
649
|
const templateStart = (0, source_map_1.getLength)(codes);
|
|
649
650
|
codes.push(varName);
|
|
650
651
|
const templateEnd = (0, source_map_1.getLength)(codes);
|
|
651
|
-
codes.push(`: {} as typeof `);
|
|
652
|
+
codes.push(`: ${varName} as typeof `);
|
|
652
653
|
const scriptStart = (0, source_map_1.getLength)(codes);
|
|
653
654
|
codes.push(varName);
|
|
654
655
|
const scriptEnd = (0, source_map_1.getLength)(codes);
|
|
@@ -723,7 +724,7 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
723
724
|
continue;
|
|
724
725
|
codes.push(`${style.module}: Record<string, string> & __VLS_Prettify<{}`);
|
|
725
726
|
for (const className of style.classNames) {
|
|
726
|
-
generateCssClassProperty(i, className.text.substring(1), { start: className.offset, end: className.offset + className.text.length }, 'string', false);
|
|
727
|
+
generateCssClassProperty(i, className.text.substring(1), { start: className.offset, end: className.offset + className.text.length }, 'string', false, true);
|
|
727
728
|
}
|
|
728
729
|
codes.push('>;\n');
|
|
729
730
|
}
|
|
@@ -739,10 +740,10 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
739
740
|
codes.push('type __VLS_StyleScopedClasses = {}');
|
|
740
741
|
for (let i = 0; i < _sfc.styles.length; i++) {
|
|
741
742
|
const style = _sfc.styles[i];
|
|
742
|
-
if (!style.scoped)
|
|
743
|
+
if (!style.scoped && vueCompilerOptions.experimentalResolveStyleCssClasses !== 'always')
|
|
743
744
|
continue;
|
|
744
745
|
for (const className of style.classNames) {
|
|
745
|
-
generateCssClassProperty(i, className.text.substring(1), { start: className.offset, end: className.offset + className.text.length }, 'boolean', true);
|
|
746
|
+
generateCssClassProperty(i, className.text.substring(1), { start: className.offset, end: className.offset + className.text.length }, 'boolean', true, !style.module);
|
|
746
747
|
}
|
|
747
748
|
}
|
|
748
749
|
codes.push(';\n');
|
|
@@ -773,7 +774,7 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
773
774
|
}
|
|
774
775
|
codes.push(`return __VLS_slots;\n`);
|
|
775
776
|
return { cssIds };
|
|
776
|
-
function generateCssClassProperty(styleIndex, className, classRange, propertyType, optional) {
|
|
777
|
+
function generateCssClassProperty(styleIndex, className, classRange, propertyType, optional, referencesCodeLens) {
|
|
777
778
|
codes.push(`\n & { `);
|
|
778
779
|
codes.push([
|
|
779
780
|
'',
|
|
@@ -781,7 +782,7 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
781
782
|
classRange.start,
|
|
782
783
|
{
|
|
783
784
|
references: true,
|
|
784
|
-
referencesCodeLens
|
|
785
|
+
referencesCodeLens,
|
|
785
786
|
},
|
|
786
787
|
]);
|
|
787
788
|
codes.push(`'`);
|
|
@@ -41,7 +41,8 @@ const formatBrackets = {
|
|
|
41
41
|
curly: ['0 +', '+ 0;'],
|
|
42
42
|
event: ['() => ', ';'],
|
|
43
43
|
};
|
|
44
|
-
const
|
|
44
|
+
const validTsVarReg = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
45
|
+
const colonReg = /:/g;
|
|
45
46
|
// @ts-ignore
|
|
46
47
|
const transformContext = {
|
|
47
48
|
onError: () => { },
|
|
@@ -121,7 +122,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
121
122
|
function generateStyleScopedClasses() {
|
|
122
123
|
const allClasses = new Set();
|
|
123
124
|
for (const block of sfc.styles) {
|
|
124
|
-
if (block.scoped) {
|
|
125
|
+
if (block.scoped || vueCompilerOptions.experimentalResolveStyleCssClasses === 'always') {
|
|
125
126
|
for (const className of block.classNames) {
|
|
126
127
|
allClasses.add(className.text.substring(1));
|
|
127
128
|
}
|
|
@@ -144,7 +145,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
144
145
|
codes.push('}\n');
|
|
145
146
|
}
|
|
146
147
|
function toCanonicalComponentName(tagText) {
|
|
147
|
-
return
|
|
148
|
+
return validTsVarReg.test(tagText) ? tagText : (0, shared_1.capitalize)((0, shared_1.camelize)(tagText.replace(colonReg, '-')));
|
|
148
149
|
}
|
|
149
150
|
function getPossibleOriginalComponentName(tagText) {
|
|
150
151
|
return [...new Set([
|
|
@@ -500,7 +501,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
500
501
|
else {
|
|
501
502
|
codes.push(`let ${var_originalComponent}!: `);
|
|
502
503
|
for (const componentName of getPossibleOriginalComponentName(tag)) {
|
|
503
|
-
codes.push(`'${componentName}' extends keyof typeof __VLS_ctx ? typeof __VLS_ctx${
|
|
504
|
+
codes.push(`'${componentName}' extends keyof typeof __VLS_ctx ? typeof __VLS_ctx${validTsVarReg.test(componentName) ? `.${componentName}` : `['${componentName}']`} : `);
|
|
504
505
|
}
|
|
505
506
|
codes.push(`typeof __VLS_resolvedLocalAndGlobalComponents['${toCanonicalComponentName(tag)}'];\n`);
|
|
506
507
|
}
|
|
@@ -584,9 +585,9 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
584
585
|
blockConditions.push(condition);
|
|
585
586
|
inScope = true;
|
|
586
587
|
}
|
|
587
|
-
generateDirectives(node
|
|
588
|
+
generateDirectives(node);
|
|
588
589
|
generateElReferences(node); // <el ref="foo" />
|
|
589
|
-
if (sfc.styles.some(s => s.scoped)) {
|
|
590
|
+
if (sfc.styles.some(s => s.scoped || vueCompilerOptions.experimentalResolveStyleCssClasses === 'always')) {
|
|
590
591
|
generateClassScoped(node);
|
|
591
592
|
}
|
|
592
593
|
if (componentCtxVar) {
|
|
@@ -1018,7 +1019,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
1018
1019
|
}
|
|
1019
1020
|
}
|
|
1020
1021
|
}
|
|
1021
|
-
function generateDirectives(node
|
|
1022
|
+
function generateDirectives(node) {
|
|
1022
1023
|
for (const prop of node.props) {
|
|
1023
1024
|
if (prop.type === 7 /* CompilerDOM.NodeTypes.DIRECTIVE */
|
|
1024
1025
|
&& prop.name !== 'slot'
|
|
@@ -1051,7 +1052,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
1051
1052
|
apply: getRenameApply(prop.name),
|
|
1052
1053
|
},
|
|
1053
1054
|
},
|
|
1054
|
-
], ')', '('
|
|
1055
|
+
], ')', '(');
|
|
1055
1056
|
if (prop.exp?.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */) {
|
|
1056
1057
|
codes.push(['', 'template', prop.exp.loc.start.offset, capabilitiesPresets.diagnosticOnly], ...createInterpolationCode(prop.exp.content, prop.exp.loc, prop.exp.loc.start.offset, capabilitiesPresets.all, '(', ')'), ['', 'template', prop.exp.loc.end.offset, capabilitiesPresets.diagnosticOnly]);
|
|
1057
1058
|
formatCodes.push(...createFormatCode(prop.exp.content, prop.exp.loc.start.offset, formatBrackets.normal));
|
|
@@ -1112,7 +1113,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
1112
1113
|
const varSlot = `__VLS_${elementIndex++}`;
|
|
1113
1114
|
const slotNameExpNode = getSlotNameExpNode();
|
|
1114
1115
|
if (hasScriptSetupSlots) {
|
|
1115
|
-
codes.push(['', 'template', node.loc.start.offset, capabilitiesPresets.diagnosticOnly], '__VLS_slots[', ['', 'template', node.loc.start.offset, capabilitiesPresets.diagnosticOnly], slotNameExpNode?.content ?? `('${getSlotName()}' as const)`, ['', 'template', node.loc.end.offset, capabilitiesPresets.diagnosticOnly], ']', ['', 'template', node.loc.end.offset, capabilitiesPresets.diagnosticOnly], '?.(', ['', 'template', startTagOffset, capabilitiesPresets.diagnosticOnly], '{\n');
|
|
1116
|
+
codes.push('__VLS_normalizeSlot(', ['', 'template', node.loc.start.offset, capabilitiesPresets.diagnosticOnly], '__VLS_slots[', ['', 'template', node.loc.start.offset, capabilitiesPresets.diagnosticOnly], slotNameExpNode?.content ?? `('${getSlotName()}' as const)`, ['', 'template', node.loc.end.offset, capabilitiesPresets.diagnosticOnly], ']', ['', 'template', node.loc.end.offset, capabilitiesPresets.diagnosticOnly], ')?.(', ['', 'template', startTagOffset, capabilitiesPresets.diagnosticOnly], '{\n');
|
|
1116
1117
|
}
|
|
1117
1118
|
else {
|
|
1118
1119
|
codes.push(`var ${varSlot} = {\n`);
|
|
@@ -1228,7 +1229,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
1228
1229
|
}
|
|
1229
1230
|
function createObjectPropertyCode(a, astHolder) {
|
|
1230
1231
|
const aStr = typeof a === 'string' ? a : a[0];
|
|
1231
|
-
if (
|
|
1232
|
+
if (validTsVarReg.test(aStr)) {
|
|
1232
1233
|
return [a];
|
|
1233
1234
|
}
|
|
1234
1235
|
else if (aStr.startsWith('[') && aStr.endsWith(']') && astHolder) {
|
|
@@ -1296,7 +1297,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
1296
1297
|
}
|
|
1297
1298
|
function createPropertyAccessCode(a, astHolder) {
|
|
1298
1299
|
const aStr = typeof a === 'string' ? a : a[0];
|
|
1299
|
-
if (!compilerOptions.noPropertyAccessFromIndexSignature &&
|
|
1300
|
+
if (!compilerOptions.noPropertyAccessFromIndexSignature && validTsVarReg.test(aStr)) {
|
|
1300
1301
|
return ['.', a];
|
|
1301
1302
|
}
|
|
1302
1303
|
else if (aStr.startsWith('[') && aStr.endsWith(']')) {
|
package/out/languageModule.js
CHANGED
|
@@ -10,11 +10,17 @@ function createLanguage(compilerOptions = {}, _vueCompilerOptions = {}, ts = req
|
|
|
10
10
|
const vueCompilerOptions = (0, ts_1.resolveVueCompilerOptions)(_vueCompilerOptions);
|
|
11
11
|
patchResolveModuleNames(ts, vueCompilerOptions);
|
|
12
12
|
const vueLanguagePlugin = (0, plugins_1.getDefaultVueLanguagePlugins)(ts, compilerOptions, vueCompilerOptions, codegenStack);
|
|
13
|
+
const allowLanguageIds = new Set(['vue']);
|
|
14
|
+
if (vueCompilerOptions.extensions.includes('.md')) {
|
|
15
|
+
allowLanguageIds.add('markdown');
|
|
16
|
+
}
|
|
17
|
+
if (vueCompilerOptions.extensions.includes('.html')) {
|
|
18
|
+
allowLanguageIds.add('html');
|
|
19
|
+
}
|
|
13
20
|
const languageModule = {
|
|
14
21
|
createVirtualFile(fileName, snapshot, languageId) {
|
|
15
|
-
if (languageId
|
|
16
|
-
|| (!languageId
|
|
17
|
-
&& vueCompilerOptions.extensions.some(ext => fileName.endsWith(ext)))) {
|
|
22
|
+
if ((languageId && allowLanguageIds.has(languageId))
|
|
23
|
+
|| (!languageId && vueCompilerOptions.extensions.some(ext => fileName.endsWith(ext)))) {
|
|
18
24
|
return new sourceFile_1.VueFile(fileName, snapshot, vueCompilerOptions, vueLanguagePlugin, ts, codegenStack);
|
|
19
25
|
}
|
|
20
26
|
},
|
|
@@ -23,7 +29,7 @@ function createLanguage(compilerOptions = {}, _vueCompilerOptions = {}, ts = req
|
|
|
23
29
|
},
|
|
24
30
|
resolveHost(host) {
|
|
25
31
|
const sharedTypesSnapshot = ts.ScriptSnapshot.fromString(sharedTypes.getTypesCode(vueCompilerOptions));
|
|
26
|
-
const sharedTypesFileName = path_1.posix.join(host.
|
|
32
|
+
const sharedTypesFileName = path_1.posix.join(host.rootPath, sharedTypes.baseName);
|
|
27
33
|
return {
|
|
28
34
|
...host,
|
|
29
35
|
getScriptFileNames() {
|
|
@@ -3,6 +3,7 @@ import type { VueCompilerOptions, TextRange } from '../types';
|
|
|
3
3
|
export interface ScriptSetupRanges extends ReturnType<typeof parseScriptSetupRanges> {
|
|
4
4
|
}
|
|
5
5
|
export declare function parseScriptSetupRanges(ts: typeof import('typescript/lib/tsserverlibrary'), ast: ts.SourceFile, vueCompilerOptions: VueCompilerOptions): {
|
|
6
|
+
leadingCommentEndOffset: number;
|
|
6
7
|
importSectionEndOffset: number;
|
|
7
8
|
bindings: TextRange[];
|
|
8
9
|
withDefaultsArg: TextRange | undefined;
|
|
@@ -19,6 +19,8 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
19
19
|
const definePropProposalB = vueCompilerOptions.experimentalDefinePropProposal === 'johnsonEdition' || ast.getFullText().trimStart().startsWith('// @experimentalDefinePropProposal=johnsonEdition');
|
|
20
20
|
const defineProp = [];
|
|
21
21
|
const bindings = parseBindingRanges(ts, ast, false);
|
|
22
|
+
const text = ast.getFullText();
|
|
23
|
+
const leadingCommentEndOffset = ts.getLeadingCommentRanges(text, 0)?.reverse()[0].end ?? 0;
|
|
22
24
|
ast.forEachChild(node => {
|
|
23
25
|
const isTypeExport = (ts.isTypeAliasDeclaration(node) || ts.isInterfaceDeclaration(node)) && node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword);
|
|
24
26
|
if (!foundNonImportExportNode
|
|
@@ -27,12 +29,20 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
27
29
|
&& !ts.isEmptyStatement(node)
|
|
28
30
|
// fix https://github.com/vuejs/language-tools/issues/1223
|
|
29
31
|
&& !ts.isImportEqualsDeclaration(node)) {
|
|
30
|
-
|
|
32
|
+
const commentRanges = ts.getLeadingCommentRanges(text, node.getFullStart());
|
|
33
|
+
if (commentRanges?.length) {
|
|
34
|
+
const commentRange = commentRanges.sort((a, b) => a.pos - b.pos)[0];
|
|
35
|
+
importSectionEndOffset = commentRange.pos;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
importSectionEndOffset = node.getStart(ast);
|
|
39
|
+
}
|
|
31
40
|
foundNonImportExportNode = true;
|
|
32
41
|
}
|
|
33
42
|
});
|
|
34
43
|
ast.forEachChild(child => visitNode(child, ast));
|
|
35
44
|
return {
|
|
45
|
+
leadingCommentEndOffset,
|
|
36
46
|
importSectionEndOffset,
|
|
37
47
|
bindings,
|
|
38
48
|
withDefaultsArg,
|
package/out/plugins/file-html.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const sfcBlockReg = /\<(script|style)\b([\s\S]*?)\>([\s\S]*?)\<\/\1\>/g;
|
|
3
|
+
const langReg = /\blang\s*=\s*(['\"]?)(\S*)\b\1/;
|
|
2
4
|
const plugin = () => {
|
|
3
5
|
return {
|
|
4
6
|
version: 1,
|
|
@@ -20,8 +22,6 @@ const plugin = () => {
|
|
|
20
22
|
errors: [],
|
|
21
23
|
};
|
|
22
24
|
let templateContent = content;
|
|
23
|
-
const sfcBlockReg = /\<(script|style)\b([\s\S]*?)\>([\s\S]*?)\<\/\1\>/g;
|
|
24
|
-
const langReg = /\blang\s*=\s*(['\"]?)(\S*)\b\1/;
|
|
25
25
|
for (const match of content.matchAll(sfcBlockReg)) {
|
|
26
26
|
const matchText = match[0];
|
|
27
27
|
const tag = match[1];
|
package/out/plugins/file-md.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const source_map_1 = require("@volar/source-map");
|
|
3
3
|
const parseSfc_1 = require("../utils/parseSfc");
|
|
4
|
+
const codeblockReg = /```[\s\S]+?```/g;
|
|
5
|
+
const inlineCodeblockReg = /`[^\n`]+?`/g;
|
|
6
|
+
const scriptSetupReg = /\\\<[\s\S]+?\>\n?/g;
|
|
7
|
+
const sfcBlockReg = /\<(script|style)\b[\s\S]*?\>([\s\S]*?)\<\/\1\>/g;
|
|
8
|
+
const angleBracketReg = /\<\S*\:\S*\>/g;
|
|
9
|
+
const linkReg = /\[[\s\S]*?\]\([\s\S]*?\)/g;
|
|
4
10
|
const plugin = () => {
|
|
5
11
|
return {
|
|
6
12
|
version: 1,
|
|
@@ -8,12 +14,11 @@ const plugin = () => {
|
|
|
8
14
|
if (fileName.endsWith('.md')) {
|
|
9
15
|
content = content
|
|
10
16
|
// code block
|
|
11
|
-
.replace(
|
|
17
|
+
.replace(codeblockReg, match => '```' + ' '.repeat(match.length - 6) + '```')
|
|
12
18
|
// inline code block
|
|
13
|
-
.replace(
|
|
19
|
+
.replace(inlineCodeblockReg, match => `\`${' '.repeat(match.length - 2)}\``)
|
|
14
20
|
// # \<script setup>
|
|
15
|
-
.replace(
|
|
16
|
-
const sfcBlockReg = /\<(script|style)\b[\s\S]*?\>([\s\S]*?)\<\/\1\>/g;
|
|
21
|
+
.replace(scriptSetupReg, match => ' '.repeat(match.length));
|
|
17
22
|
const codes = [];
|
|
18
23
|
for (const match of content.matchAll(sfcBlockReg)) {
|
|
19
24
|
if (match.index !== undefined) {
|
|
@@ -25,9 +30,9 @@ const plugin = () => {
|
|
|
25
30
|
}
|
|
26
31
|
content = content
|
|
27
32
|
// angle bracket: <http://foo.com>
|
|
28
|
-
.replace(
|
|
33
|
+
.replace(angleBracketReg, match => ' '.repeat(match.length))
|
|
29
34
|
// [foo](http://foo.com)
|
|
30
|
-
.replace(
|
|
35
|
+
.replace(linkReg, match => ' '.repeat(match.length));
|
|
31
36
|
codes.push('<template>\n');
|
|
32
37
|
codes.push([content, undefined, 0]);
|
|
33
38
|
codes.push('\n</template>');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const language_core_1 = require("@volar/language-core");
|
|
3
|
+
const customBlockReg = /^(.*)\.customBlock_([^_]+)_(\d+)\.([^.]+)$/;
|
|
3
4
|
const plugin = () => {
|
|
4
5
|
return {
|
|
5
6
|
version: 1,
|
|
@@ -12,7 +13,7 @@ const plugin = () => {
|
|
|
12
13
|
return names;
|
|
13
14
|
},
|
|
14
15
|
resolveEmbeddedFile(_fileName, sfc, embeddedFile) {
|
|
15
|
-
const match = embeddedFile.fileName.match(
|
|
16
|
+
const match = embeddedFile.fileName.match(customBlockReg);
|
|
16
17
|
if (match) {
|
|
17
18
|
const index = parseInt(match[3]);
|
|
18
19
|
const customBlock = sfc.customBlocks[index];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const language_core_1 = require("@volar/language-core");
|
|
3
|
+
const scriptFormatReg = /^(.*)\.script_format\.([^.]+)$/;
|
|
4
|
+
const scriptSetupFormatReg = /^(.*)\.scriptSetup_format\.([^.]+)$/;
|
|
3
5
|
const plugin = () => {
|
|
4
6
|
return {
|
|
5
7
|
version: 1,
|
|
@@ -14,8 +16,8 @@ const plugin = () => {
|
|
|
14
16
|
return names;
|
|
15
17
|
},
|
|
16
18
|
resolveEmbeddedFile(_fileName, sfc, embeddedFile) {
|
|
17
|
-
const scriptMatch = embeddedFile.fileName.match(
|
|
18
|
-
const scriptSetupMatch = embeddedFile.fileName.match(
|
|
19
|
+
const scriptMatch = embeddedFile.fileName.match(scriptFormatReg);
|
|
20
|
+
const scriptSetupMatch = embeddedFile.fileName.match(scriptSetupFormatReg);
|
|
19
21
|
const script = scriptMatch ? sfc.script : scriptSetupMatch ? sfc.scriptSetup : undefined;
|
|
20
22
|
if (script) {
|
|
21
23
|
embeddedFile.kind = language_core_1.FileKind.TextFile;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const language_core_1 = require("@volar/language-core");
|
|
3
|
+
const styleReg = /^(.*)\.style_(\d+)\.([^.]+)$/;
|
|
3
4
|
const plugin = () => {
|
|
4
5
|
return {
|
|
5
6
|
version: 1,
|
|
@@ -12,7 +13,7 @@ const plugin = () => {
|
|
|
12
13
|
return names;
|
|
13
14
|
},
|
|
14
15
|
resolveEmbeddedFile(_fileName, sfc, embeddedFile) {
|
|
15
|
-
const match = embeddedFile.fileName.match(
|
|
16
|
+
const match = embeddedFile.fileName.match(styleReg);
|
|
16
17
|
if (match) {
|
|
17
18
|
const index = parseInt(match[2]);
|
|
18
19
|
const style = sfc.styles[index];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const language_core_1 = require("@volar/language-core");
|
|
3
|
+
const templateReg = /^(.*)\.template\.([^.]+)$/;
|
|
3
4
|
const plugin = () => {
|
|
4
5
|
return {
|
|
5
6
|
version: 1,
|
|
@@ -10,7 +11,7 @@ const plugin = () => {
|
|
|
10
11
|
return [];
|
|
11
12
|
},
|
|
12
13
|
resolveEmbeddedFile(_fileName, sfc, embeddedFile) {
|
|
13
|
-
const match = embeddedFile.fileName.match(
|
|
14
|
+
const match = embeddedFile.fileName.match(templateReg);
|
|
14
15
|
if (match && sfc.template) {
|
|
15
16
|
embeddedFile.capabilities = language_core_1.FileCapabilities.full;
|
|
16
17
|
embeddedFile.content.push([
|
package/out/plugins/vue-tsx.js
CHANGED
|
@@ -7,6 +7,8 @@ const scriptRanges_1 = require("../parsers/scriptRanges");
|
|
|
7
7
|
const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
|
|
8
8
|
const language_core_1 = require("@volar/language-core");
|
|
9
9
|
const muggle = require("muggle-string");
|
|
10
|
+
const templateFormatReg = /^\.template_format\.ts$/;
|
|
11
|
+
const templateStyleCssReg = /^\.template_style\.css$/;
|
|
10
12
|
const plugin = ({ modules, vueCompilerOptions, compilerOptions, codegenStack }) => {
|
|
11
13
|
const ts = modules.typescript;
|
|
12
14
|
const instances = new WeakMap();
|
|
@@ -43,7 +45,7 @@ const plugin = ({ modules, vueCompilerOptions, compilerOptions, codegenStack })
|
|
|
43
45
|
embeddedFile.mirrorBehaviorMappings = [...tsx.mirrorBehaviorMappings];
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
|
-
else if (suffix.match(
|
|
48
|
+
else if (suffix.match(templateFormatReg)) {
|
|
47
49
|
embeddedFile.parentFileName = fileName + '.template.' + sfc.template?.lang;
|
|
48
50
|
embeddedFile.kind = language_core_1.FileKind.TextFile;
|
|
49
51
|
embeddedFile.capabilities = {
|
|
@@ -72,7 +74,7 @@ const plugin = ({ modules, vueCompilerOptions, compilerOptions, codegenStack })
|
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
else if (suffix.match(
|
|
77
|
+
else if (suffix.match(templateStyleCssReg)) {
|
|
76
78
|
embeddedFile.parentFileName = fileName + '.template.' + sfc.template?.lang;
|
|
77
79
|
if (_tsx.htmlGen.value) {
|
|
78
80
|
const [content, contentStacks] = codegenStack ? muggle.track([..._tsx.htmlGen.value.cssCodes], [..._tsx.htmlGen.value.cssCodeStacks]) : [[..._tsx.htmlGen.value.cssCodes], [..._tsx.htmlGen.value.cssCodeStacks]];
|
package/out/sourceFile.js
CHANGED
|
@@ -7,6 +7,7 @@ const reactivity_1 = require("@vue/reactivity");
|
|
|
7
7
|
const muggle = require("muggle-string");
|
|
8
8
|
const parseCssVars_1 = require("./utils/parseCssVars");
|
|
9
9
|
const parseCssClassNames_1 = require("./utils/parseCssClassNames");
|
|
10
|
+
const jsxReg = /^\.(js|ts)x?$/;
|
|
10
11
|
class VueEmbeddedFile {
|
|
11
12
|
constructor(fileName, content, contentStacks) {
|
|
12
13
|
this.fileName = fileName;
|
|
@@ -23,7 +24,7 @@ class VueFile {
|
|
|
23
24
|
return this._compiledSfcTemplate.value;
|
|
24
25
|
}
|
|
25
26
|
get mainScriptName() {
|
|
26
|
-
return this._allEmbeddedFiles.value.find(e => e.file.fileName.replace(this.fileName, '').match(
|
|
27
|
+
return this._allEmbeddedFiles.value.find(e => e.file.fileName.replace(this.fileName, '').match(jsxReg))?.file.fileName ?? '';
|
|
27
28
|
}
|
|
28
29
|
get embeddedFiles() {
|
|
29
30
|
return this._embeddedFiles.value;
|
package/out/utils/globalTypes.js
CHANGED
|
@@ -51,7 +51,7 @@ declare function __VLS_getVForSourceType<T>(source: T): [
|
|
|
51
51
|
declare function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
|
|
52
52
|
declare function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
|
|
53
53
|
declare function __VLS_directiveFunction<T>(dir: T):
|
|
54
|
-
T extends import('${vueCompilerOptions.lib}').ObjectDirective<infer E, infer V> | import('${vueCompilerOptions.lib}').FunctionDirective<infer E, infer V> ? (
|
|
54
|
+
T extends import('${vueCompilerOptions.lib}').ObjectDirective<infer E, infer V> | import('${vueCompilerOptions.lib}').FunctionDirective<infer E, infer V> ? (value: V) => void
|
|
55
55
|
: T;
|
|
56
56
|
declare function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K;
|
|
57
57
|
declare function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
|
|
@@ -111,6 +111,7 @@ declare function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K
|
|
|
111
111
|
>;
|
|
112
112
|
type __VLS_AsFunctionOrAny<F> = unknown extends F ? any : ((...args: any) => any) extends F ? F : any;
|
|
113
113
|
|
|
114
|
+
declare function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
|
|
114
115
|
declare function __VLS_componentProps<T, K>(comp: T, fnReturn: K):
|
|
115
116
|
__VLS_PickNotAny<K, {}> extends { __ctx: { props: infer P } } ? NonNullable<P>
|
|
116
117
|
: T extends (props: infer P, ...args: any) => any ? NonNullable<P> :
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseCssClassNames = void 0;
|
|
4
4
|
const parseCssVars_1 = require("./parseCssVars");
|
|
5
|
+
const cssClassNameReg = /(?=([\.]{1}[a-zA-Z_]+[\w\_\-]*)[\s\.\+\{\>#\:]{1})/g;
|
|
5
6
|
function* parseCssClassNames(styleContent) {
|
|
6
7
|
styleContent = (0, parseCssVars_1.clearComments)(styleContent);
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
for (const match of matchs) {
|
|
8
|
+
const matches = styleContent.matchAll(cssClassNameReg);
|
|
9
|
+
for (const match of matches) {
|
|
10
10
|
if (match.index !== undefined) {
|
|
11
11
|
const matchText = match[1];
|
|
12
12
|
if (matchText !== undefined) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/cssVars.ts#L47-L61
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.clearComments = exports.parseCssVars = void 0;
|
|
4
|
-
|
|
5
|
+
const vBindCssVarReg = /\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][^)]*))\s*\)/g;
|
|
6
|
+
const commentReg1 = /\/\*([\s\S]*?)\*\//g;
|
|
7
|
+
const commentReg2 = /\/\/([\s\S]*?)\n/g;
|
|
5
8
|
function* parseCssVars(styleContent) {
|
|
6
9
|
styleContent = clearComments(styleContent);
|
|
7
|
-
const
|
|
8
|
-
const matchs = styleContent.matchAll(reg);
|
|
10
|
+
const matchs = styleContent.matchAll(vBindCssVarReg);
|
|
9
11
|
for (const match of matchs) {
|
|
10
12
|
if (match.index !== undefined) {
|
|
11
13
|
const matchText = match[1] ?? match[2] ?? match[3];
|
|
@@ -19,8 +21,8 @@ function* parseCssVars(styleContent) {
|
|
|
19
21
|
exports.parseCssVars = parseCssVars;
|
|
20
22
|
function clearComments(css) {
|
|
21
23
|
return css
|
|
22
|
-
.replace(
|
|
23
|
-
.replace(
|
|
24
|
+
.replace(commentReg1, match => `/*${' '.repeat(match.length - 4)}*/`)
|
|
25
|
+
.replace(commentReg2, match => `//${' '.repeat(match.length - 3)}\n`);
|
|
24
26
|
}
|
|
25
27
|
exports.clearComments = clearComments;
|
|
26
28
|
//# sourceMappingURL=parseCssVars.js.map
|
package/out/utils/ts.js
CHANGED
|
@@ -60,7 +60,7 @@ function createParsedCommandLine(ts, parseConfigHost, tsConfigPath) {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
catch (err) {
|
|
63
|
-
console.warn('Failed to resolve tsconfig path:', tsConfigPath, err);
|
|
63
|
+
// console.warn('Failed to resolve tsconfig path:', tsConfigPath, err);
|
|
64
64
|
return {
|
|
65
65
|
fileNames: [],
|
|
66
66
|
options: {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.6",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"directory": "packages/vue-language-core"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "~1.
|
|
17
|
-
"@volar/source-map": "~1.
|
|
16
|
+
"@volar/language-core": "~1.9.0",
|
|
17
|
+
"@volar/source-map": "~1.9.0",
|
|
18
18
|
"@vue/compiler-dom": "^3.3.0",
|
|
19
19
|
"@vue/reactivity": "^3.3.0",
|
|
20
20
|
"@vue/shared": "^3.3.0",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"optional": true
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "9da8afee02bc7251ae97716480ba31f8aff2794a"
|
|
38
38
|
}
|