@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateStringLiteralKey =
|
|
3
|
+
exports.generateStringLiteralKey = generateStringLiteralKey;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
function* generateStringLiteralKey(code, offset, info) {
|
|
6
6
|
if (offset === undefined || !info) {
|
|
@@ -10,5 +10,4 @@ function* generateStringLiteralKey(code, offset, info) {
|
|
|
10
10
|
yield* (0, common_1.wrapWith)(offset, offset + code.length, info, `"`, [code, 'template', offset, common_1.combineLastMapping], `"`);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
exports.generateStringLiteralKey = generateStringLiteralKey;
|
|
14
13
|
//# sourceMappingURL=stringLiteralKey.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateTemplateChild = generateTemplateChild;
|
|
4
|
+
exports.getVForNode = getVForNode;
|
|
5
|
+
exports.parseInterpolationNode = parseInterpolationNode;
|
|
4
6
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
7
|
const common_1 = require("../common");
|
|
6
8
|
const element_1 = require("./element");
|
|
@@ -97,7 +99,6 @@ function* generateTemplateChild(options, ctx, node, currentComponent, prevNode,
|
|
|
97
99
|
// not needed progress
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
|
-
exports.generateTemplateChild = generateTemplateChild;
|
|
101
102
|
// TODO: track https://github.com/vuejs/vue-next/issues/3498
|
|
102
103
|
function getVForNode(node) {
|
|
103
104
|
const forDirective = node.props.find((prop) => prop.type === CompilerDOM.NodeTypes.DIRECTIVE
|
|
@@ -117,7 +118,6 @@ function getVForNode(node) {
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
|
-
exports.getVForNode = getVForNode;
|
|
121
121
|
function getVIfNode(node) {
|
|
122
122
|
const forDirective = node.props.find((prop) => prop.type === CompilerDOM.NodeTypes.DIRECTIVE
|
|
123
123
|
&& prop.name === 'if');
|
|
@@ -156,5 +156,4 @@ function parseInterpolationNode(node, template) {
|
|
|
156
156
|
start,
|
|
157
157
|
];
|
|
158
158
|
}
|
|
159
|
-
exports.parseInterpolationNode = parseInterpolationNode;
|
|
160
159
|
//# sourceMappingURL=templateChild.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateVFor = generateVFor;
|
|
4
|
+
exports.parseVForNode = parseVForNode;
|
|
4
5
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
6
|
const common_1 = require("../common");
|
|
6
7
|
const interpolation_1 = require("./interpolation");
|
|
@@ -65,7 +66,6 @@ function* generateVFor(options, ctx, node, currentComponent, componentCtxVar) {
|
|
|
65
66
|
yield* ctx.generateAutoImportCompletion();
|
|
66
67
|
yield `}${common_1.newLine}`;
|
|
67
68
|
}
|
|
68
|
-
exports.generateVFor = generateVFor;
|
|
69
69
|
function parseVForNode(node) {
|
|
70
70
|
const { value, key, index } = node.parseResult;
|
|
71
71
|
const leftExpressionRange = (value || key || index)
|
|
@@ -82,5 +82,4 @@ function parseVForNode(node) {
|
|
|
82
82
|
leftExpressionText,
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
exports.parseVForNode = parseVForNode;
|
|
86
85
|
//# sourceMappingURL=vFor.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateVIf =
|
|
4
|
-
const language_core_1 = require("@volar/language-core");
|
|
3
|
+
exports.generateVIf = generateVIf;
|
|
5
4
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
|
+
const muggle_string_1 = require("muggle-string");
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
const interpolation_1 = require("./interpolation");
|
|
8
8
|
const templateChild_1 = require("./templateChild");
|
|
@@ -27,7 +27,7 @@ function* generateVIf(options, ctx, node, currentComponent, componentCtxVar) {
|
|
|
27
27
|
for (const code of codes) {
|
|
28
28
|
yield code;
|
|
29
29
|
}
|
|
30
|
-
ctx.blockConditions.push((0,
|
|
30
|
+
ctx.blockConditions.push((0, muggle_string_1.toString)(codes));
|
|
31
31
|
addedBlockCondition = true;
|
|
32
32
|
yield ` `;
|
|
33
33
|
}
|
|
@@ -48,7 +48,6 @@ function* generateVIf(options, ctx, node, currentComponent, componentCtxVar) {
|
|
|
48
48
|
}
|
|
49
49
|
ctx.blockConditions.length = originalBlockConditionsLength;
|
|
50
50
|
}
|
|
51
|
-
exports.generateVIf = generateVIf;
|
|
52
51
|
function isFragment(node) {
|
|
53
52
|
return node.codegenNode
|
|
54
53
|
&& 'consequent' in node.codegenNode
|
package/lib/languageModule.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createVueLanguagePlugin =
|
|
3
|
+
exports.createVueLanguagePlugin = createVueLanguagePlugin;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
const plugins_1 = require("./plugins");
|
|
6
6
|
const vueFile_1 = require("./virtualFile/vueFile");
|
|
@@ -155,5 +155,4 @@ function createVueLanguagePlugin(ts, asFileName, getProjectVersion, isRootFile,
|
|
|
155
155
|
return getVueFileRegistry(isGlobalTypesHolder, getFileRegistryKey(compilerOptions, vueCompilerOptions, basePlugins), vueCompilerOptions.plugins);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
exports.createVueLanguagePlugin = createVueLanguagePlugin;
|
|
159
158
|
//# sourceMappingURL=languageModule.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseScriptRanges =
|
|
3
|
+
exports.parseScriptRanges = parseScriptRanges;
|
|
4
4
|
const scriptSetupRanges_1 = require("./scriptSetupRanges");
|
|
5
5
|
function parseScriptRanges(ts, ast, hasScriptSetup, withNode) {
|
|
6
6
|
let exportDefault;
|
|
@@ -66,5 +66,4 @@ function parseScriptRanges(ts, ast, hasScriptSetup, withNode) {
|
|
|
66
66
|
return node.kind === ts.SyntaxKind.AsExpression;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
exports.parseScriptRanges = parseScriptRanges;
|
|
70
69
|
//# sourceMappingURL=scriptRanges.js.map
|
|
@@ -8,38 +8,38 @@ export declare function parseScriptSetupRanges(ts: typeof import('typescript'),
|
|
|
8
8
|
bindings: TextRange[];
|
|
9
9
|
importComponentNames: Set<string>;
|
|
10
10
|
props: {
|
|
11
|
-
name?: string
|
|
12
|
-
define?: (TextRange & {
|
|
13
|
-
arg?: TextRange
|
|
14
|
-
typeArg?: TextRange
|
|
15
|
-
} & {
|
|
11
|
+
name?: string;
|
|
12
|
+
define?: ReturnType<(node: ts.CallExpression) => TextRange & {
|
|
13
|
+
arg?: TextRange;
|
|
14
|
+
typeArg?: TextRange;
|
|
15
|
+
}> & {
|
|
16
16
|
statement: TextRange;
|
|
17
|
-
}
|
|
18
|
-
withDefaults?:
|
|
19
|
-
arg?: TextRange
|
|
20
|
-
}
|
|
17
|
+
};
|
|
18
|
+
withDefaults?: TextRange & {
|
|
19
|
+
arg?: TextRange;
|
|
20
|
+
};
|
|
21
21
|
};
|
|
22
22
|
slots: {
|
|
23
|
-
name?: string
|
|
24
|
-
isObjectBindingPattern?: boolean
|
|
25
|
-
define?: (TextRange & {
|
|
26
|
-
arg?: TextRange
|
|
27
|
-
typeArg?: TextRange
|
|
28
|
-
}
|
|
23
|
+
name?: string;
|
|
24
|
+
isObjectBindingPattern?: boolean;
|
|
25
|
+
define?: ReturnType<(node: ts.CallExpression) => TextRange & {
|
|
26
|
+
arg?: TextRange;
|
|
27
|
+
typeArg?: TextRange;
|
|
28
|
+
}>;
|
|
29
29
|
};
|
|
30
30
|
emits: {
|
|
31
|
-
name?: string
|
|
32
|
-
define?: (TextRange & {
|
|
33
|
-
arg?: TextRange
|
|
34
|
-
typeArg?: TextRange
|
|
35
|
-
}
|
|
31
|
+
name?: string;
|
|
32
|
+
define?: ReturnType<(node: ts.CallExpression) => TextRange & {
|
|
33
|
+
arg?: TextRange;
|
|
34
|
+
typeArg?: TextRange;
|
|
35
|
+
}>;
|
|
36
36
|
};
|
|
37
37
|
expose: {
|
|
38
|
-
name?: string
|
|
39
|
-
define?: (TextRange & {
|
|
40
|
-
arg?: TextRange
|
|
41
|
-
typeArg?: TextRange
|
|
42
|
-
}
|
|
38
|
+
name?: string;
|
|
39
|
+
define?: ReturnType<(node: ts.CallExpression) => TextRange & {
|
|
40
|
+
arg?: TextRange;
|
|
41
|
+
typeArg?: TextRange;
|
|
42
|
+
}>;
|
|
43
43
|
};
|
|
44
44
|
defineProp: {
|
|
45
45
|
name: TextRange | undefined;
|
|
@@ -48,10 +48,10 @@ export declare function parseScriptSetupRanges(ts: typeof import('typescript'),
|
|
|
48
48
|
modifierType?: TextRange | undefined;
|
|
49
49
|
defaultValue: TextRange | undefined;
|
|
50
50
|
required: boolean;
|
|
51
|
-
isModel?: boolean
|
|
51
|
+
isModel?: boolean;
|
|
52
52
|
}[];
|
|
53
53
|
options: {
|
|
54
|
-
name?: string
|
|
54
|
+
name?: string;
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
export declare function parseBindingRanges(ts: typeof import('typescript'), sourceFile: ts.SourceFile): TextRange[];
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseScriptSetupRanges = parseScriptSetupRanges;
|
|
4
|
+
exports.parseBindingRanges = parseBindingRanges;
|
|
5
|
+
exports.findBindingVars = findBindingVars;
|
|
6
|
+
exports.getStartEnd = getStartEnd;
|
|
7
|
+
exports.getNodeText = getNodeText;
|
|
4
8
|
function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
5
9
|
let foundNonImportExportNode = false;
|
|
6
10
|
let importSectionEndOffset = 0;
|
|
@@ -225,7 +229,6 @@ function parseScriptSetupRanges(ts, ast, vueCompilerOptions) {
|
|
|
225
229
|
});
|
|
226
230
|
}
|
|
227
231
|
}
|
|
228
|
-
exports.parseScriptSetupRanges = parseScriptSetupRanges;
|
|
229
232
|
function parseBindingRanges(ts, sourceFile) {
|
|
230
233
|
const bindings = [];
|
|
231
234
|
ts.forEachChild(sourceFile, node => {
|
|
@@ -279,7 +282,6 @@ function parseBindingRanges(ts, sourceFile) {
|
|
|
279
282
|
return findBindingVars(ts, left, sourceFile);
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
|
-
exports.parseBindingRanges = parseBindingRanges;
|
|
283
285
|
function findBindingVars(ts, left, sourceFile) {
|
|
284
286
|
const vars = [];
|
|
285
287
|
worker(left);
|
|
@@ -312,17 +314,14 @@ function findBindingVars(ts, left, sourceFile) {
|
|
|
312
314
|
}
|
|
313
315
|
}
|
|
314
316
|
}
|
|
315
|
-
exports.findBindingVars = findBindingVars;
|
|
316
317
|
function getStartEnd(ts, node, sourceFile) {
|
|
317
318
|
return {
|
|
318
319
|
start: ts.getTokenPosOfNode(node, sourceFile),
|
|
319
320
|
end: node.end,
|
|
320
321
|
};
|
|
321
322
|
}
|
|
322
|
-
exports.getStartEnd = getStartEnd;
|
|
323
323
|
function getNodeText(ts, node, sourceFile) {
|
|
324
324
|
const { start, end } = getStartEnd(ts, node, sourceFile);
|
|
325
325
|
return sourceFile.text.substring(start, end);
|
|
326
326
|
}
|
|
327
|
-
exports.getNodeText = getNodeText;
|
|
328
327
|
//# sourceMappingURL=scriptSetupRanges.js.map
|
package/lib/plugins/file-md.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const language_core_1 = require("@volar/language-core");
|
|
4
|
+
const muggle_string_1 = require("muggle-string");
|
|
5
|
+
const buildMappings_1 = require("../utils/buildMappings");
|
|
4
6
|
const parseSfc_1 = require("../utils/parseSfc");
|
|
5
7
|
const codeblockReg = /(`{3,})[\s\S]+?\1/g;
|
|
6
8
|
const inlineCodeblockReg = /`[^\n`]+?`/g;
|
|
@@ -39,8 +41,8 @@ const plugin = () => {
|
|
|
39
41
|
codes.push('<template>\n');
|
|
40
42
|
codes.push([content, undefined, 0]);
|
|
41
43
|
codes.push('\n</template>');
|
|
42
|
-
const file2VueSourceMap =
|
|
43
|
-
const sfc = (0, parseSfc_1.parse)((0,
|
|
44
|
+
const file2VueSourceMap = (0, language_core_1.defaultMapperFactory)((0, buildMappings_1.buildMappings)(codes));
|
|
45
|
+
const sfc = (0, parseSfc_1.parse)((0, muggle_string_1.toString)(codes));
|
|
44
46
|
if (sfc.descriptor.template) {
|
|
45
47
|
sfc.descriptor.template.lang = 'md';
|
|
46
48
|
transformRange(sfc.descriptor.template);
|
|
@@ -61,11 +63,11 @@ const plugin = () => {
|
|
|
61
63
|
function transformRange(block) {
|
|
62
64
|
block.loc.start.offset = -1;
|
|
63
65
|
block.loc.end.offset = -1;
|
|
64
|
-
for (const [start] of file2VueSourceMap.
|
|
66
|
+
for (const [start] of file2VueSourceMap.toSourceLocation(block.loc.start.offset)) {
|
|
65
67
|
block.loc.start.offset = start;
|
|
66
68
|
break;
|
|
67
69
|
}
|
|
68
|
-
for (const [end] of file2VueSourceMap.
|
|
70
|
+
for (const [end] of file2VueSourceMap.toSourceLocation(block.loc.end.offset)) {
|
|
69
71
|
block.loc.end.offset = end;
|
|
70
72
|
break;
|
|
71
73
|
}
|
package/lib/plugins/vue-tsx.d.ts
CHANGED
|
@@ -19,38 +19,38 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
19
19
|
bindings: import("../types").TextRange[];
|
|
20
20
|
importComponentNames: Set<string>;
|
|
21
21
|
props: {
|
|
22
|
-
name?: string
|
|
23
|
-
define?: (import("../types").TextRange & {
|
|
24
|
-
arg?: import("../types").TextRange
|
|
25
|
-
typeArg?: import("../types").TextRange
|
|
26
|
-
} & {
|
|
22
|
+
name?: string;
|
|
23
|
+
define?: ReturnType<(node: import("typescript").CallExpression) => import("../types").TextRange & {
|
|
24
|
+
arg?: import("../types").TextRange;
|
|
25
|
+
typeArg?: import("../types").TextRange;
|
|
26
|
+
}> & {
|
|
27
27
|
statement: import("../types").TextRange;
|
|
28
|
-
}
|
|
29
|
-
withDefaults?:
|
|
30
|
-
arg?: import("../types").TextRange
|
|
31
|
-
}
|
|
28
|
+
};
|
|
29
|
+
withDefaults?: import("../types").TextRange & {
|
|
30
|
+
arg?: import("../types").TextRange;
|
|
31
|
+
};
|
|
32
32
|
};
|
|
33
33
|
slots: {
|
|
34
|
-
name?: string
|
|
35
|
-
isObjectBindingPattern?: boolean
|
|
36
|
-
define?: (import("../types").TextRange & {
|
|
37
|
-
arg?: import("../types").TextRange
|
|
38
|
-
typeArg?: import("../types").TextRange
|
|
39
|
-
}
|
|
34
|
+
name?: string;
|
|
35
|
+
isObjectBindingPattern?: boolean;
|
|
36
|
+
define?: ReturnType<(node: import("typescript").CallExpression) => import("../types").TextRange & {
|
|
37
|
+
arg?: import("../types").TextRange;
|
|
38
|
+
typeArg?: import("../types").TextRange;
|
|
39
|
+
}>;
|
|
40
40
|
};
|
|
41
41
|
emits: {
|
|
42
|
-
name?: string
|
|
43
|
-
define?: (import("../types").TextRange & {
|
|
44
|
-
arg?: import("../types").TextRange
|
|
45
|
-
typeArg?: import("../types").TextRange
|
|
46
|
-
}
|
|
42
|
+
name?: string;
|
|
43
|
+
define?: ReturnType<(node: import("typescript").CallExpression) => import("../types").TextRange & {
|
|
44
|
+
arg?: import("../types").TextRange;
|
|
45
|
+
typeArg?: import("../types").TextRange;
|
|
46
|
+
}>;
|
|
47
47
|
};
|
|
48
48
|
expose: {
|
|
49
|
-
name?: string
|
|
50
|
-
define?: (import("../types").TextRange & {
|
|
51
|
-
arg?: import("../types").TextRange
|
|
52
|
-
typeArg?: import("../types").TextRange
|
|
53
|
-
}
|
|
49
|
+
name?: string;
|
|
50
|
+
define?: ReturnType<(node: import("typescript").CallExpression) => import("../types").TextRange & {
|
|
51
|
+
arg?: import("../types").TextRange;
|
|
52
|
+
typeArg?: import("../types").TextRange;
|
|
53
|
+
}>;
|
|
54
54
|
};
|
|
55
55
|
defineProp: {
|
|
56
56
|
name: import("../types").TextRange | undefined;
|
|
@@ -59,10 +59,10 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
59
59
|
modifierType?: import("../types").TextRange | undefined;
|
|
60
60
|
defaultValue: import("../types").TextRange | undefined;
|
|
61
61
|
required: boolean;
|
|
62
|
-
isModel?: boolean
|
|
62
|
+
isModel?: boolean;
|
|
63
63
|
}[];
|
|
64
64
|
options: {
|
|
65
|
-
name?: string
|
|
65
|
+
name?: string;
|
|
66
66
|
};
|
|
67
67
|
} | undefined;
|
|
68
68
|
lang: () => string;
|
|
@@ -74,7 +74,7 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
74
74
|
codes: Code[];
|
|
75
75
|
slots: {
|
|
76
76
|
name: string;
|
|
77
|
-
loc?: number
|
|
77
|
+
loc?: number;
|
|
78
78
|
tagRange: [number, number];
|
|
79
79
|
varName: string;
|
|
80
80
|
nodeLoc: any;
|
|
@@ -106,15 +106,15 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
106
106
|
}[];
|
|
107
107
|
emptyClassOffsets: number[];
|
|
108
108
|
hasSlot: boolean;
|
|
109
|
-
accessExternalVariable(name: string, offset?: number
|
|
109
|
+
accessExternalVariable(name: string, offset?: number): void;
|
|
110
110
|
hasLocalVariable: (name: string) => boolean;
|
|
111
111
|
addLocalVariable: (name: string) => void;
|
|
112
112
|
removeLocalVariable: (name: string) => void;
|
|
113
113
|
getInternalVariable: () => string;
|
|
114
|
-
ignoreError: () => Generator<Code
|
|
115
|
-
expectError: (prevNode: import("@vue/compiler-dom").CommentNode) => Generator<Code
|
|
116
|
-
resetDirectiveComments: (endStr: string) => Generator<Code
|
|
117
|
-
generateAutoImportCompletion: () => Generator<Code
|
|
114
|
+
ignoreError: () => Generator<Code>;
|
|
115
|
+
expectError: (prevNode: import("@vue/compiler-dom").CommentNode) => Generator<Code>;
|
|
116
|
+
resetDirectiveComments: (endStr: string) => Generator<Code>;
|
|
117
|
+
generateAutoImportCompletion: () => Generator<Code>;
|
|
118
118
|
} | undefined;
|
|
119
119
|
}>;
|
|
120
120
|
declare const plugin: VueLanguagePlugin;
|
package/lib/plugins.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type VueLanguagePlugin } from './types';
|
|
1
|
+
import { pluginVersion, type VueLanguagePlugin } from './types';
|
|
2
2
|
export * from './plugins/shared';
|
|
3
3
|
export declare function getBasePlugins(pluginContext: Parameters<VueLanguagePlugin>[0]): {
|
|
4
|
-
version:
|
|
5
|
-
name?: string
|
|
6
|
-
order?: number
|
|
7
|
-
requiredCompilerOptions?: string[]
|
|
4
|
+
version: typeof pluginVersion;
|
|
5
|
+
name?: string;
|
|
6
|
+
order?: number;
|
|
7
|
+
requiredCompilerOptions?: string[];
|
|
8
8
|
parseSFC?(fileName: string, content: string): import("@vue/compiler-sfc").SFCParseResult | undefined;
|
|
9
9
|
updateSFC?(oldResult: import("@vue/compiler-sfc").SFCParseResult, textChange: {
|
|
10
10
|
start: number;
|
package/lib/plugins.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getBasePlugins =
|
|
17
|
+
exports.getBasePlugins = getBasePlugins;
|
|
18
18
|
const vue_sfc_customblocks_1 = require("./plugins/vue-sfc-customblocks");
|
|
19
19
|
const vue_sfc_scripts_1 = require("./plugins/vue-sfc-scripts");
|
|
20
20
|
const vue_sfc_styles_1 = require("./plugins/vue-sfc-styles");
|
|
@@ -64,5 +64,4 @@ function getBasePlugins(pluginContext) {
|
|
|
64
64
|
return valid;
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
exports.getBasePlugins = getBasePlugins;
|
|
68
67
|
//# sourceMappingURL=plugins.js.map
|
package/lib/types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { CodeInformation } from '@volar/language-core';
|
|
1
2
|
import type * as CompilerDOM from '@vue/compiler-dom';
|
|
2
3
|
import type { SFCParseResult } from '@vue/compiler-sfc';
|
|
4
|
+
import type { Segment } from 'muggle-string';
|
|
3
5
|
import type * as ts from 'typescript';
|
|
4
6
|
import type { VueEmbeddedCode } from './virtualFile/embeddedFile';
|
|
5
|
-
import type { CodeInformation, Segment } from '@volar/language-core';
|
|
6
7
|
export type { SFCParseResult } from '@vue/compiler-sfc';
|
|
7
8
|
export { VueEmbeddedCode };
|
|
8
9
|
export type RawVueCompilerOptions = Partial<Omit<VueCompilerOptions, 'target' | 'plugins'>> & {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildMappings = buildMappings;
|
|
4
|
+
function buildMappings(chunks) {
|
|
5
|
+
let length = 0;
|
|
6
|
+
const mappings = [];
|
|
7
|
+
for (const segment of chunks) {
|
|
8
|
+
if (typeof segment === 'string') {
|
|
9
|
+
length += segment.length;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
mappings.push({
|
|
13
|
+
sourceOffsets: [segment[2]],
|
|
14
|
+
generatedOffsets: [length],
|
|
15
|
+
lengths: [segment[0].length],
|
|
16
|
+
data: segment[3],
|
|
17
|
+
});
|
|
18
|
+
length += segment[0].length;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return mappings;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=buildMappings.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCssClassNames =
|
|
3
|
+
exports.parseCssClassNames = parseCssClassNames;
|
|
4
4
|
const parseCssVars_1 = require("./parseCssVars");
|
|
5
5
|
const cssClassNameReg = /(?=([\.]{1}[a-zA-Z_]+[\w\_\-]*)[\s\.\,\+\{\>#\:]{1})/g;
|
|
6
6
|
function* parseCssClassNames(styleContent) {
|
|
@@ -15,5 +15,4 @@ function* parseCssClassNames(styleContent) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
exports.parseCssClassNames = parseCssClassNames;
|
|
19
18
|
//# sourceMappingURL=parseCssClassNames.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/cssVars.ts#L47-L61
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.parseCssVars = parseCssVars;
|
|
5
|
+
exports.clearComments = clearComments;
|
|
5
6
|
const vBindCssVarReg = /\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][^)]*))\s*\)/g;
|
|
6
7
|
const commentReg1 = /\/\*([\s\S]*?)\*\//g;
|
|
7
8
|
const commentReg2 = /\/\/([\s\S]*?)\n/g;
|
|
@@ -18,11 +19,9 @@ function* parseCssVars(styleContent) {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
|
-
exports.parseCssVars = parseCssVars;
|
|
22
22
|
function clearComments(css) {
|
|
23
23
|
return css
|
|
24
24
|
.replace(commentReg1, match => `/*${' '.repeat(match.length - 4)}*/`)
|
|
25
25
|
.replace(commentReg2, match => `//${' '.repeat(match.length - 3)}\n`);
|
|
26
26
|
}
|
|
27
|
-
exports.clearComments = clearComments;
|
|
28
27
|
//# sourceMappingURL=parseCssVars.js.map
|
package/lib/utils/parseSfc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parse =
|
|
3
|
+
exports.parse = parse;
|
|
4
4
|
const compiler = require("@vue/compiler-dom");
|
|
5
5
|
function parse(source) {
|
|
6
6
|
const errors = [];
|
|
@@ -61,7 +61,6 @@ function parse(source) {
|
|
|
61
61
|
errors,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
exports.parse = parse;
|
|
65
64
|
function createBlock(node, source) {
|
|
66
65
|
const type = node.tag;
|
|
67
66
|
let { start, end } = node.loc;
|
package/lib/utils/shared.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.hyphenateTag = void 0;
|
|
4
|
+
exports.getSlotsPropertyName = getSlotsPropertyName;
|
|
5
|
+
exports.hyphenateAttr = hyphenateAttr;
|
|
4
6
|
const shared_1 = require("@vue/shared");
|
|
5
7
|
function getSlotsPropertyName(vueVersion) {
|
|
6
8
|
return vueVersion < 3 ? '$scopedSlots' : '$slots';
|
|
7
9
|
}
|
|
8
|
-
exports.getSlotsPropertyName = getSlotsPropertyName;
|
|
9
10
|
var shared_2 = require("@vue/shared");
|
|
10
11
|
Object.defineProperty(exports, "hyphenateTag", { enumerable: true, get: function () { return shared_2.hyphenate; } });
|
|
11
12
|
function hyphenateAttr(str) {
|
|
@@ -16,5 +17,4 @@ function hyphenateAttr(str) {
|
|
|
16
17
|
}
|
|
17
18
|
return hyphencase;
|
|
18
19
|
}
|
|
19
|
-
exports.hyphenateAttr = hyphenateAttr;
|
|
20
20
|
//# sourceMappingURL=shared.js.map
|
package/lib/utils/ts.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createParsedCommandLineByJson = createParsedCommandLineByJson;
|
|
4
|
+
exports.createParsedCommandLine = createParsedCommandLine;
|
|
5
|
+
exports.resolveVueCompilerOptions = resolveVueCompilerOptions;
|
|
4
6
|
const path = require("path-browserify");
|
|
5
7
|
function createParsedCommandLineByJson(ts, parseConfigHost, rootDir, json, configFileName = rootDir + '/jsconfig.json') {
|
|
6
8
|
const proxyHost = proxyParseConfigHostForExtendConfigPaths(parseConfigHost);
|
|
@@ -34,7 +36,6 @@ function createParsedCommandLineByJson(ts, parseConfigHost, rootDir, json, confi
|
|
|
34
36
|
vueOptions: resolvedVueOptions,
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
|
-
exports.createParsedCommandLineByJson = createParsedCommandLineByJson;
|
|
38
39
|
function createParsedCommandLine(ts, parseConfigHost, tsConfigPath) {
|
|
39
40
|
try {
|
|
40
41
|
const proxyHost = proxyParseConfigHostForExtendConfigPaths(parseConfigHost);
|
|
@@ -79,7 +80,6 @@ function createParsedCommandLine(ts, parseConfigHost, tsConfigPath) {
|
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
exports.createParsedCommandLine = createParsedCommandLine;
|
|
83
83
|
function proxyParseConfigHostForExtendConfigPaths(parseConfigHost) {
|
|
84
84
|
const extendConfigPaths = [];
|
|
85
85
|
const host = new Proxy(parseConfigHost, {
|
|
@@ -212,5 +212,4 @@ function resolveVueCompilerOptions(vueOptions) {
|
|
|
212
212
|
},
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
|
-
exports.resolveVueCompilerOptions = resolveVueCompilerOptions;
|
|
216
215
|
//# sourceMappingURL=ts.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VirtualCode } from '@volar/language-core';
|
|
1
|
+
import type { VirtualCode } from '@volar/language-core';
|
|
2
2
|
import type { Sfc, VueLanguagePlugin } from '../types';
|
|
3
3
|
export declare function computedFiles(plugins: ReturnType<VueLanguagePlugin>[], fileName: string, sfc: Sfc): () => VirtualCode[];
|
|
4
4
|
export declare function resolveCommonLanguageId(lang: string): string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.computedFiles = computedFiles;
|
|
4
|
+
exports.resolveCommonLanguageId = resolveCommonLanguageId;
|
|
5
5
|
const computeds_1 = require("computeds");
|
|
6
|
+
const muggle_string_1 = require("muggle-string");
|
|
7
|
+
const buildMappings_1 = require("../utils/buildMappings");
|
|
6
8
|
const embeddedFile_1 = require("./embeddedFile");
|
|
7
9
|
function computedFiles(plugins, fileName, sfc) {
|
|
8
10
|
const nameToBlock = (0, computeds_1.computed)(() => {
|
|
@@ -85,7 +87,6 @@ function computedFiles(plugins, fileName, sfc) {
|
|
|
85
87
|
});
|
|
86
88
|
return structuredResult;
|
|
87
89
|
}
|
|
88
|
-
exports.computedFiles = computedFiles;
|
|
89
90
|
function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock) {
|
|
90
91
|
const computeds = new Map();
|
|
91
92
|
const getComputedKey = (code) => code.id + '__' + code.lang;
|
|
@@ -116,7 +117,7 @@ function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock
|
|
|
116
117
|
console.error(e);
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
|
-
const newText = (0,
|
|
120
|
+
const newText = (0, muggle_string_1.toString)(code.content);
|
|
120
121
|
const changeRanges = new Map();
|
|
121
122
|
const snapshot = {
|
|
122
123
|
getText: (start, end) => newText.slice(start, end),
|
|
@@ -149,7 +150,7 @@ function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock
|
|
|
149
150
|
return (0, computeds_1.computed)(() => {
|
|
150
151
|
return codes().map(_file => {
|
|
151
152
|
const { code, snapshot } = _file();
|
|
152
|
-
const mappings = (0,
|
|
153
|
+
const mappings = (0, buildMappings_1.buildMappings)(code.content.map(segment => {
|
|
153
154
|
if (typeof segment === 'string') {
|
|
154
155
|
return segment;
|
|
155
156
|
}
|
|
@@ -240,5 +241,4 @@ function resolveCommonLanguageId(lang) {
|
|
|
240
241
|
}
|
|
241
242
|
return lang;
|
|
242
243
|
}
|
|
243
|
-
exports.resolveCommonLanguageId = resolveCommonLanguageId;
|
|
244
244
|
//# sourceMappingURL=computedFiles.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeMapping } from '@volar/language-core';
|
|
1
|
+
import type { CodeMapping } from '@volar/language-core';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
3
|
import type { Sfc } from '../types';
|
|
4
4
|
export declare function computedMappings(snapshot: () => ts.IScriptSnapshot, sfc: Sfc): () => CodeMapping[];
|