@vue/language-core 1.8.3 → 1.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/generators/script.js +10 -10
- package/out/generators/template.js +64 -52
- package/out/index.d.ts +1 -1
- package/out/index.js +1 -1
- package/out/languageModule.js +2 -2
- package/out/parsers/scriptSetupRanges.js +8 -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.d.ts +4 -0
- package/out/utils/globalTypes.js +154 -0
- 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
|
@@ -7,7 +7,7 @@ const shared_1 = require("@vue/shared");
|
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const shared_2 = require("../utils/shared");
|
|
9
9
|
const transform_1 = require("../utils/transform");
|
|
10
|
-
const sharedTypes = require("../utils/
|
|
10
|
+
const sharedTypes = require("../utils/globalTypes");
|
|
11
11
|
const muggle = require("muggle-string");
|
|
12
12
|
function generate(ts, fileName, _sfc, lang, scriptRanges, scriptSetupRanges, htmlGen, compilerOptions, vueCompilerOptions, codegenStack) {
|
|
13
13
|
const [codes, codeStacks] = codegenStack ? muggle.track([]) : [[], []];
|
|
@@ -648,7 +648,7 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
648
648
|
const templateStart = (0, source_map_1.getLength)(codes);
|
|
649
649
|
codes.push(varName);
|
|
650
650
|
const templateEnd = (0, source_map_1.getLength)(codes);
|
|
651
|
-
codes.push(`: {} as typeof `);
|
|
651
|
+
codes.push(`: ${varName} as typeof `);
|
|
652
652
|
const scriptStart = (0, source_map_1.getLength)(codes);
|
|
653
653
|
codes.push(varName);
|
|
654
654
|
const scriptEnd = (0, source_map_1.getLength)(codes);
|
|
@@ -723,26 +723,26 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
723
723
|
continue;
|
|
724
724
|
codes.push(`${style.module}: Record<string, string> & __VLS_Prettify<{}`);
|
|
725
725
|
for (const className of style.classNames) {
|
|
726
|
-
generateCssClassProperty(i, className.text.substring(1), { start: className.offset, end: className.offset + className.text.length }, 'string', false);
|
|
726
|
+
generateCssClassProperty(i, className.text.substring(1), { start: className.offset, end: className.offset + className.text.length }, 'string', false, true);
|
|
727
727
|
}
|
|
728
728
|
codes.push('>;\n');
|
|
729
729
|
}
|
|
730
730
|
codes.push(`};\n`);
|
|
731
731
|
/* Components */
|
|
732
732
|
codes.push('/* Components */\n');
|
|
733
|
-
codes.push(`let
|
|
734
|
-
codes.push(`let __VLS_otherComponents!: typeof __VLS_localComponents & __VLS_GlobalComponents;\n`);
|
|
733
|
+
codes.push(`let __VLS_otherComponents!: NonNullable<typeof __VLS_internalComponent extends { components: infer C } ? C : {}> & typeof __VLS_componentsOption;\n`);
|
|
735
734
|
codes.push(`let __VLS_own!: __VLS_SelfComponent<typeof __VLS_name, typeof __VLS_internalComponent & typeof __VLS_publicComponent & (new () => { ${(0, shared_2.getSlotsPropertyName)(vueCompilerOptions.target)}: typeof __VLS_slots })>;\n`);
|
|
736
|
-
codes.push(`let
|
|
735
|
+
codes.push(`let __VLS_localComponents!: typeof __VLS_otherComponents & Omit<typeof __VLS_own, keyof typeof __VLS_otherComponents>;\n`);
|
|
736
|
+
codes.push(`let __VLS_components!: typeof __VLS_localComponents & __VLS_GlobalComponents & typeof __VLS_ctx;\n`); // for html completion, TS references...
|
|
737
737
|
/* Style Scoped */
|
|
738
738
|
codes.push('/* Style Scoped */\n');
|
|
739
739
|
codes.push('type __VLS_StyleScopedClasses = {}');
|
|
740
740
|
for (let i = 0; i < _sfc.styles.length; i++) {
|
|
741
741
|
const style = _sfc.styles[i];
|
|
742
|
-
if (!style.scoped)
|
|
742
|
+
if (!style.scoped && vueCompilerOptions.experimentalResolveStyleCssClasses !== 'always')
|
|
743
743
|
continue;
|
|
744
744
|
for (const className of style.classNames) {
|
|
745
|
-
generateCssClassProperty(i, className.text.substring(1), { start: className.offset, end: className.offset + className.text.length }, 'boolean', true);
|
|
745
|
+
generateCssClassProperty(i, className.text.substring(1), { start: className.offset, end: className.offset + className.text.length }, 'boolean', true, !style.module);
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
codes.push(';\n');
|
|
@@ -773,7 +773,7 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
773
773
|
}
|
|
774
774
|
codes.push(`return __VLS_slots;\n`);
|
|
775
775
|
return { cssIds };
|
|
776
|
-
function generateCssClassProperty(styleIndex, className, classRange, propertyType, optional) {
|
|
776
|
+
function generateCssClassProperty(styleIndex, className, classRange, propertyType, optional, referencesCodeLens) {
|
|
777
777
|
codes.push(`\n & { `);
|
|
778
778
|
codes.push([
|
|
779
779
|
'',
|
|
@@ -781,7 +781,7 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
|
|
|
781
781
|
classRange.start,
|
|
782
782
|
{
|
|
783
783
|
references: true,
|
|
784
|
-
referencesCodeLens
|
|
784
|
+
referencesCodeLens,
|
|
785
785
|
},
|
|
786
786
|
]);
|
|
787
787
|
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: () => { },
|
|
@@ -75,7 +76,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
75
76
|
let ignoreStart;
|
|
76
77
|
let expectedErrorStart;
|
|
77
78
|
let expectedErrorNode;
|
|
78
|
-
|
|
79
|
+
generatePreResolveComponents();
|
|
79
80
|
if (sfc.templateAst) {
|
|
80
81
|
visitNode(sfc.templateAst, undefined, undefined, undefined);
|
|
81
82
|
}
|
|
@@ -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
|
}
|
|
@@ -143,31 +144,34 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
143
144
|
}
|
|
144
145
|
codes.push('}\n');
|
|
145
146
|
}
|
|
146
|
-
function
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
function toCanonicalComponentName(tagText) {
|
|
148
|
+
return validTsVarReg.test(tagText) ? tagText : (0, shared_1.capitalize)((0, shared_1.camelize)(tagText.replace(colonReg, '-')));
|
|
149
|
+
}
|
|
150
|
+
function getPossibleOriginalComponentName(tagText) {
|
|
151
|
+
return [...new Set([
|
|
152
|
+
// order is important: https://github.com/vuejs/language-tools/issues/2010
|
|
153
|
+
(0, shared_1.capitalize)((0, shared_1.camelize)(tagText)),
|
|
154
|
+
(0, shared_1.camelize)(tagText),
|
|
155
|
+
tagText,
|
|
156
|
+
])];
|
|
157
|
+
}
|
|
158
|
+
function generatePreResolveComponents() {
|
|
159
|
+
codes.push(`let __VLS_resolvedLocalAndGlobalComponents!: {}\n`);
|
|
149
160
|
for (const tagName in tagNames) {
|
|
150
161
|
if (nativeTags.has(tagName))
|
|
151
162
|
continue;
|
|
152
163
|
const isNamespacedTag = tagName.indexOf('.') >= 0;
|
|
153
164
|
if (isNamespacedTag)
|
|
154
165
|
continue;
|
|
155
|
-
|
|
156
|
-
codes.push(`& __VLS_WithComponent<'${validName}', typeof __VLS_components, `,
|
|
166
|
+
codes.push(`& __VLS_WithComponent<'${toCanonicalComponentName(tagName)}', typeof __VLS_localComponents, `,
|
|
157
167
|
// order is important: https://github.com/vuejs/language-tools/issues/2010
|
|
158
168
|
`"${(0, shared_1.capitalize)((0, shared_1.camelize)(tagName))}", `, `"${(0, shared_1.camelize)(tagName)}", `, `"${tagName}"`, '>\n');
|
|
159
|
-
data[tagName] = validName;
|
|
160
169
|
}
|
|
161
170
|
codes.push(`;\n`);
|
|
162
171
|
for (const tagName in tagNames) {
|
|
163
172
|
const tagOffsets = tagNames[tagName];
|
|
164
173
|
const tagRanges = tagOffsets.map(offset => [offset, offset + tagName.length]);
|
|
165
|
-
const names =
|
|
166
|
-
// order is important: https://github.com/vuejs/language-tools/issues/2010
|
|
167
|
-
(0, shared_1.capitalize)((0, shared_1.camelize)(tagName)),
|
|
168
|
-
(0, shared_1.camelize)(tagName),
|
|
169
|
-
tagName,
|
|
170
|
-
]);
|
|
174
|
+
const names = nativeTags.has(tagName) ? [tagName] : getPossibleOriginalComponentName(tagName);
|
|
171
175
|
for (const name of names) {
|
|
172
176
|
for (const tagRange of tagRanges) {
|
|
173
177
|
codes.push(nativeTags.has(tagName) ? '({} as __VLS_IntrinsicElements)' : '__VLS_components', ...createPropertyAccessCode([
|
|
@@ -185,28 +189,30 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
185
189
|
}
|
|
186
190
|
}
|
|
187
191
|
codes.push('\n');
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
192
|
+
if (nativeTags.has(tagName))
|
|
193
|
+
continue;
|
|
194
|
+
const isNamespacedTag = tagName.indexOf('.') >= 0;
|
|
195
|
+
if (isNamespacedTag)
|
|
196
|
+
continue;
|
|
197
|
+
codes.push('// @ts-ignore\n', // #2304
|
|
198
|
+
'[');
|
|
199
|
+
const validName = toCanonicalComponentName(tagName);
|
|
200
|
+
for (const tagRange of tagRanges) {
|
|
201
|
+
codes.push([
|
|
202
|
+
validName,
|
|
203
|
+
'template',
|
|
204
|
+
tagRange,
|
|
205
|
+
{
|
|
206
|
+
completion: {
|
|
207
|
+
additional: true,
|
|
208
|
+
autoImportOnly: true,
|
|
202
209
|
},
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
codes.push(`];\n`);
|
|
210
|
+
},
|
|
211
|
+
]);
|
|
212
|
+
codes.push(',');
|
|
207
213
|
}
|
|
214
|
+
codes.push(`];\n`);
|
|
208
215
|
}
|
|
209
|
-
return data;
|
|
210
216
|
}
|
|
211
217
|
function collectTagOffsets() {
|
|
212
218
|
const tagOffsetsMap = {};
|
|
@@ -492,11 +498,12 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
492
498
|
else if (dynamicTagExp) {
|
|
493
499
|
codes.push(`const ${var_originalComponent} = `, ...createInterpolationCode(dynamicTagExp.loc.source, dynamicTagExp.loc, dynamicTagExp.loc.start.offset, capabilitiesPresets.all, '(', ')'), ';\n');
|
|
494
500
|
}
|
|
495
|
-
else if (componentVars[tag]) {
|
|
496
|
-
codes.push(`const ${var_originalComponent} = __VLS_templateComponents['${componentVars[tag]}'];\n`);
|
|
497
|
-
}
|
|
498
501
|
else {
|
|
499
|
-
codes.push(`
|
|
502
|
+
codes.push(`let ${var_originalComponent}!: `);
|
|
503
|
+
for (const componentName of getPossibleOriginalComponentName(tag)) {
|
|
504
|
+
codes.push(`'${componentName}' extends keyof typeof __VLS_ctx ? typeof __VLS_ctx${validTsVarReg.test(componentName) ? `.${componentName}` : `['${componentName}']`} : `);
|
|
505
|
+
}
|
|
506
|
+
codes.push(`typeof __VLS_resolvedLocalAndGlobalComponents['${toCanonicalComponentName(tag)}'];\n`);
|
|
500
507
|
}
|
|
501
508
|
codes.push(`const ${var_functionalComponent} = __VLS_asFunctionalComponent(`, `${var_originalComponent}, `);
|
|
502
509
|
if (isIntrinsicElement) {
|
|
@@ -507,21 +514,26 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
507
514
|
}
|
|
508
515
|
codes.push(');\n');
|
|
509
516
|
for (const offset of tagOffsets) {
|
|
510
|
-
if (isNamespacedTag) {
|
|
517
|
+
if (isNamespacedTag || dynamicTagExp) {
|
|
511
518
|
continue;
|
|
512
519
|
}
|
|
513
|
-
else if (
|
|
514
|
-
|
|
520
|
+
else if (isIntrinsicElement) {
|
|
521
|
+
codes.push(`({} as __VLS_IntrinsicElements).`);
|
|
522
|
+
codes.push([
|
|
523
|
+
tag,
|
|
524
|
+
'template',
|
|
525
|
+
[offset, offset + tag.length],
|
|
526
|
+
{
|
|
527
|
+
...capabilitiesPresets.tagHover,
|
|
528
|
+
...capabilitiesPresets.diagnosticOnly,
|
|
529
|
+
},
|
|
530
|
+
], ';\n');
|
|
515
531
|
}
|
|
516
532
|
else {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
520
|
-
else {
|
|
521
|
-
codes.push(`__VLS_templateComponents.`);
|
|
522
|
-
}
|
|
533
|
+
const key = toCanonicalComponentName(tag);
|
|
534
|
+
codes.push(`({} as { ${key}: typeof ${var_originalComponent} }).`);
|
|
523
535
|
codes.push([
|
|
524
|
-
|
|
536
|
+
key,
|
|
525
537
|
'template',
|
|
526
538
|
[offset, offset + tag.length],
|
|
527
539
|
{
|
|
@@ -575,7 +587,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
575
587
|
}
|
|
576
588
|
generateDirectives(node, var_originalComponent);
|
|
577
589
|
generateElReferences(node); // <el ref="foo" />
|
|
578
|
-
if (sfc.styles.some(s => s.scoped)) {
|
|
590
|
+
if (sfc.styles.some(s => s.scoped || vueCompilerOptions.experimentalResolveStyleCssClasses === 'always')) {
|
|
579
591
|
generateClassScoped(node);
|
|
580
592
|
}
|
|
581
593
|
if (componentCtxVar) {
|
|
@@ -1101,7 +1113,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
1101
1113
|
const varSlot = `__VLS_${elementIndex++}`;
|
|
1102
1114
|
const slotNameExpNode = getSlotNameExpNode();
|
|
1103
1115
|
if (hasScriptSetupSlots) {
|
|
1104
|
-
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');
|
|
1105
1117
|
}
|
|
1106
1118
|
else {
|
|
1107
1119
|
codes.push(`var ${varSlot} = {\n`);
|
|
@@ -1217,7 +1229,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
1217
1229
|
}
|
|
1218
1230
|
function createObjectPropertyCode(a, astHolder) {
|
|
1219
1231
|
const aStr = typeof a === 'string' ? a : a[0];
|
|
1220
|
-
if (
|
|
1232
|
+
if (validTsVarReg.test(aStr)) {
|
|
1221
1233
|
return [a];
|
|
1222
1234
|
}
|
|
1223
1235
|
else if (aStr.startsWith('[') && aStr.endsWith(']') && astHolder) {
|
|
@@ -1285,7 +1297,7 @@ function generate(ts, compilerOptions, vueCompilerOptions, sourceTemplate, sourc
|
|
|
1285
1297
|
}
|
|
1286
1298
|
function createPropertyAccessCode(a, astHolder) {
|
|
1287
1299
|
const aStr = typeof a === 'string' ? a : a[0];
|
|
1288
|
-
if (!compilerOptions.noPropertyAccessFromIndexSignature &&
|
|
1300
|
+
if (!compilerOptions.noPropertyAccessFromIndexSignature && validTsVarReg.test(aStr)) {
|
|
1289
1301
|
return ['.', a];
|
|
1290
1302
|
}
|
|
1291
1303
|
else if (aStr.startsWith('[') && aStr.endsWith(']')) {
|
package/out/index.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export * from './types';
|
|
|
7
7
|
export * from './utils/ts';
|
|
8
8
|
export * from './utils/parseSfc';
|
|
9
9
|
export * as scriptRanges from './parsers/scriptRanges';
|
|
10
|
-
export * as sharedTypes from './utils/
|
|
10
|
+
export * as sharedTypes from './utils/globalTypes';
|
|
11
11
|
export * from '@volar/language-core';
|
|
12
12
|
export * from '@volar/source-map';
|
package/out/index.js
CHANGED
|
@@ -24,7 +24,7 @@ __exportStar(require("./types"), exports);
|
|
|
24
24
|
__exportStar(require("./utils/ts"), exports);
|
|
25
25
|
__exportStar(require("./utils/parseSfc"), exports);
|
|
26
26
|
exports.scriptRanges = require("./parsers/scriptRanges");
|
|
27
|
-
exports.sharedTypes = require("./utils/
|
|
27
|
+
exports.sharedTypes = require("./utils/globalTypes");
|
|
28
28
|
__exportStar(require("@volar/language-core"), exports);
|
|
29
29
|
__exportStar(require("@volar/source-map"), exports);
|
|
30
30
|
//# sourceMappingURL=index.js.map
|
package/out/languageModule.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.createLanguages = exports.createLanguage = void 0;
|
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const plugins_1 = require("./plugins");
|
|
6
6
|
const sourceFile_1 = require("./sourceFile");
|
|
7
|
-
const sharedTypes = require("./utils/
|
|
7
|
+
const sharedTypes = require("./utils/globalTypes");
|
|
8
8
|
const ts_1 = require("./utils/ts");
|
|
9
9
|
function createLanguage(compilerOptions = {}, _vueCompilerOptions = {}, ts = require('typescript'), codegenStack = false) {
|
|
10
10
|
const vueCompilerOptions = (0, ts_1.resolveVueCompilerOptions)(_vueCompilerOptions);
|
|
@@ -23,7 +23,7 @@ function createLanguage(compilerOptions = {}, _vueCompilerOptions = {}, ts = req
|
|
|
23
23
|
},
|
|
24
24
|
resolveHost(host) {
|
|
25
25
|
const sharedTypesSnapshot = ts.ScriptSnapshot.fromString(sharedTypes.getTypesCode(vueCompilerOptions));
|
|
26
|
-
const sharedTypesFileName = path_1.posix.join(host.
|
|
26
|
+
const sharedTypesFileName = path_1.posix.join(host.rootPath, sharedTypes.baseName);
|
|
27
27
|
return {
|
|
28
28
|
...host,
|
|
29
29
|
getScriptFileNames() {
|
|
@@ -27,7 +27,14 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
27
27
|
&& !ts.isEmptyStatement(node)
|
|
28
28
|
// fix https://github.com/vuejs/language-tools/issues/1223
|
|
29
29
|
&& !ts.isImportEqualsDeclaration(node)) {
|
|
30
|
-
|
|
30
|
+
const commentRanges = ts.getLeadingCommentRanges(ast.getFullText(), node.getFullStart());
|
|
31
|
+
if (commentRanges?.length) {
|
|
32
|
+
const commentRange = commentRanges.sort((a, b) => a.pos - b.pos)[0];
|
|
33
|
+
importSectionEndOffset = commentRange.pos;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
importSectionEndOffset = node.getStart(ast);
|
|
37
|
+
}
|
|
31
38
|
foundNonImportExportNode = true;
|
|
32
39
|
}
|
|
33
40
|
});
|
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;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { VueCompilerOptions } from '../types';
|
|
2
|
+
export declare const baseName = "__VLS_types.d.ts";
|
|
3
|
+
export declare function getTypesCode(vueCompilerOptions: VueCompilerOptions): string;
|
|
4
|
+
export declare function genConstructorOverloads(name?: string, nums?: number): string;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.genConstructorOverloads = exports.getTypesCode = exports.baseName = void 0;
|
|
4
|
+
const shared_1 = require("./shared");
|
|
5
|
+
exports.baseName = '__VLS_types.d.ts';
|
|
6
|
+
function getTypesCode(vueCompilerOptions) {
|
|
7
|
+
return `
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
|
|
10
|
+
type __VLS_IntrinsicElements = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.IntrinsicElements, __VLS_PickNotAny<JSX.IntrinsicElements, Record<string, any>>>;
|
|
11
|
+
type __VLS_Element = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.Element, JSX.Element>;
|
|
12
|
+
|
|
13
|
+
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
|
|
14
|
+
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
|
|
15
|
+
|
|
16
|
+
type __VLS_Prettify<T> = {
|
|
17
|
+
[K in keyof T]: T[K];
|
|
18
|
+
} & {};
|
|
19
|
+
|
|
20
|
+
type __VLS_GlobalComponents =
|
|
21
|
+
__VLS_PickNotAny<import('vue').GlobalComponents, {}>
|
|
22
|
+
& __VLS_PickNotAny<import('@vue/runtime-core').GlobalComponents, {}>
|
|
23
|
+
& __VLS_PickNotAny<import('@vue/runtime-dom').GlobalComponents, {}>
|
|
24
|
+
& Pick<typeof import('${vueCompilerOptions.lib}'),
|
|
25
|
+
'Transition'
|
|
26
|
+
| 'TransitionGroup'
|
|
27
|
+
| 'KeepAlive'
|
|
28
|
+
| 'Suspense'
|
|
29
|
+
| 'Teleport'
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
// v-for
|
|
33
|
+
declare function __VLS_getVForSourceType(source: number): [number, number, number][];
|
|
34
|
+
declare function __VLS_getVForSourceType(source: string): [string, number, number][];
|
|
35
|
+
declare function __VLS_getVForSourceType<T extends any[]>(source: T): [
|
|
36
|
+
T[number], // item
|
|
37
|
+
number, // key
|
|
38
|
+
number, // index
|
|
39
|
+
][];
|
|
40
|
+
declare function __VLS_getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [
|
|
41
|
+
T extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never, // item
|
|
42
|
+
number, // key
|
|
43
|
+
undefined, // index
|
|
44
|
+
][];
|
|
45
|
+
declare function __VLS_getVForSourceType<T>(source: T): [
|
|
46
|
+
T[keyof T], // item
|
|
47
|
+
keyof T, // key
|
|
48
|
+
number, // index
|
|
49
|
+
][];
|
|
50
|
+
|
|
51
|
+
declare function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
|
|
52
|
+
declare function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
|
|
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> ? (el: E, value: V) => void
|
|
55
|
+
: T;
|
|
56
|
+
declare function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K;
|
|
57
|
+
declare function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
|
|
58
|
+
|
|
59
|
+
type __VLS_SelfComponent<N, C> = string extends N ? {} : N extends string ? { [P in N]: C } : {};
|
|
60
|
+
type __VLS_WithComponent<N0 extends string, LocalComponents, N1 extends string, N2 extends string, N3 extends string> =
|
|
61
|
+
N1 extends keyof LocalComponents ? N1 extends N0 ? Pick<LocalComponents, N0> : { [K in N0]: LocalComponents[N1] } :
|
|
62
|
+
N2 extends keyof LocalComponents ? N2 extends N0 ? Pick<LocalComponents, N0> : { [K in N0]: LocalComponents[N2] } :
|
|
63
|
+
N3 extends keyof LocalComponents ? N3 extends N0 ? Pick<LocalComponents, N0> : { [K in N0]: LocalComponents[N3] } :
|
|
64
|
+
N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0> : { [K in N0]: __VLS_GlobalComponents[N1] } :
|
|
65
|
+
N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0> : { [K in N0]: __VLS_GlobalComponents[N2] } :
|
|
66
|
+
N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0> : { [K in N0]: __VLS_GlobalComponents[N3] } :
|
|
67
|
+
${vueCompilerOptions.strictTemplates ? '{}' : '{ [K in N0]: unknown }'}
|
|
68
|
+
|
|
69
|
+
type __VLS_FillingEventArg_ParametersLength<E extends (...args: any) => any> = __VLS_IsAny<Parameters<E>> extends true ? -1 : Parameters<E>['length'];
|
|
70
|
+
type __VLS_FillingEventArg<E> = E extends (...args: any) => any ? __VLS_FillingEventArg_ParametersLength<E> extends 0 ? ($event?: undefined) => ReturnType<E> : E : E;
|
|
71
|
+
type __VLS_EmitEvent<F, E> =
|
|
72
|
+
F extends {
|
|
73
|
+
(event: E, ...payload: infer P): any
|
|
74
|
+
} ? (...payload: P) => void
|
|
75
|
+
: F extends {
|
|
76
|
+
(event: E, ...payload: infer P): any
|
|
77
|
+
(...args: any): any
|
|
78
|
+
} ? (...payload: P) => void
|
|
79
|
+
: F extends {
|
|
80
|
+
(event: E, ...payload: infer P): any
|
|
81
|
+
(...args: any): any
|
|
82
|
+
(...args: any): any
|
|
83
|
+
} ? (...payload: P) => void
|
|
84
|
+
: F extends {
|
|
85
|
+
(event: E, ...payload: infer P): any
|
|
86
|
+
(...args: any): any
|
|
87
|
+
(...args: any): any
|
|
88
|
+
(...args: any): any
|
|
89
|
+
} ? (...payload: P) => void
|
|
90
|
+
: unknown | '[Type Warning] Volar could not infer $emit event more than 4 overloads without DefineComponent. see https://github.com/vuejs/language-tools/issues/60';
|
|
91
|
+
declare function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
|
|
92
|
+
T extends new (...args: any) => any
|
|
93
|
+
? (props: (K extends { $props: infer Props } ? Props : any)${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: {
|
|
94
|
+
attrs?: any,
|
|
95
|
+
slots?: K extends { ${(0, shared_1.getSlotsPropertyName)(vueCompilerOptions.target)}: infer Slots } ? Slots : any,
|
|
96
|
+
emit?: K extends { $emit: infer Emit } ? Emit : any
|
|
97
|
+
}) => JSX.Element & { __ctx?: typeof ctx & { props?: typeof props; expose?(exposed: K): void; } }
|
|
98
|
+
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
|
|
99
|
+
: T extends (...args: any) => any ? T
|
|
100
|
+
: (_: T extends import('${vueCompilerOptions.lib}').VNode | import('${vueCompilerOptions.lib}').VNode[] | string ? {}: T${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: T${vueCompilerOptions.strictTemplates ? '' : ' & Record<string, unknown>'} } }; // IntrinsicElement
|
|
101
|
+
declare function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): Parameters<T>['length'] extends 2 ? [any] : [];
|
|
102
|
+
declare function __VLS_pickEvent<Emit, K, E>(emit: Emit, emitKey: K, event: E): __VLS_FillingEventArg<
|
|
103
|
+
__VLS_PickNotAny<
|
|
104
|
+
__VLS_AsFunctionOrAny<E>,
|
|
105
|
+
__VLS_AsFunctionOrAny<__VLS_EmitEvent<Emit, K>>
|
|
106
|
+
>
|
|
107
|
+
> | undefined;
|
|
108
|
+
declare function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): __VLS_PickNotAny<
|
|
109
|
+
K extends { __ctx?: infer Ctx } ? Ctx : any,
|
|
110
|
+
T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
|
|
111
|
+
>;
|
|
112
|
+
type __VLS_AsFunctionOrAny<F> = unknown extends F ? any : ((...args: any) => any) extends F ? F : any;
|
|
113
|
+
|
|
114
|
+
declare function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
|
|
115
|
+
declare function __VLS_componentProps<T, K>(comp: T, fnReturn: K):
|
|
116
|
+
__VLS_PickNotAny<K, {}> extends { __ctx: { props: infer P } } ? NonNullable<P>
|
|
117
|
+
: T extends (props: infer P, ...args: any) => any ? NonNullable<P> :
|
|
118
|
+
{};
|
|
119
|
+
`.trim();
|
|
120
|
+
}
|
|
121
|
+
exports.getTypesCode = getTypesCode;
|
|
122
|
+
// TODO: not working for overloads > n (n = 8)
|
|
123
|
+
// see: https://github.com/vuejs/language-tools/issues/60
|
|
124
|
+
function genConstructorOverloads(name = 'ConstructorOverloads', nums) {
|
|
125
|
+
let code = '';
|
|
126
|
+
code += `type ${name}<T> =\n`;
|
|
127
|
+
if (nums === undefined) {
|
|
128
|
+
for (let i = 8; i >= 1; i--) {
|
|
129
|
+
gen(i);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else if (nums > 0) {
|
|
133
|
+
gen(nums);
|
|
134
|
+
}
|
|
135
|
+
code += `// 0\n`;
|
|
136
|
+
code += `{};\n`;
|
|
137
|
+
return code;
|
|
138
|
+
function gen(i) {
|
|
139
|
+
code += `// ${i}\n`;
|
|
140
|
+
code += `T extends {\n`;
|
|
141
|
+
for (let j = 1; j <= i; j++) {
|
|
142
|
+
code += `(event: infer E${j}, ...payload: infer P${j}): void;\n`;
|
|
143
|
+
}
|
|
144
|
+
code += `} ? (\n`;
|
|
145
|
+
for (let j = 1; j <= i; j++) {
|
|
146
|
+
if (j > 1)
|
|
147
|
+
code += '& ';
|
|
148
|
+
code += `(E${j} extends string ? { [K${j} in E${j}]: (...payload: P${j}) => void } : {})\n`;
|
|
149
|
+
}
|
|
150
|
+
code += `) :\n`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.genConstructorOverloads = genConstructorOverloads;
|
|
154
|
+
//# sourceMappingURL=globalTypes.js.map
|
|
@@ -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.5",
|
|
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": "971820b55ea42cb7e8c8ba7c35c8998d5572b420"
|
|
38
38
|
}
|