@vue/language-core 2.2.2 → 2.2.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/lib/codegen/globalTypes.js +21 -34
- package/lib/codegen/script/component.js +11 -9
- package/lib/codegen/script/componentSelf.js +4 -11
- package/lib/codegen/script/context.d.ts +0 -1
- package/lib/codegen/script/context.js +0 -1
- package/lib/codegen/script/index.d.ts +1 -4
- package/lib/codegen/script/index.js +8 -12
- package/lib/codegen/script/scriptSetup.js +90 -70
- package/lib/codegen/script/src.d.ts +2 -2
- package/lib/codegen/script/src.js +36 -37
- package/lib/codegen/script/styleModulesType.d.ts +1 -1
- package/lib/codegen/script/styleModulesType.js +2 -2
- package/lib/codegen/script/template.d.ts +1 -2
- package/lib/codegen/script/template.js +5 -53
- package/lib/codegen/style/classProperty.d.ts +2 -0
- package/lib/codegen/style/classProperty.js +18 -0
- package/lib/codegen/style/modules.d.ts +3 -0
- package/lib/codegen/style/modules.js +34 -0
- package/lib/codegen/style/scopedClasses.d.ts +4 -0
- package/lib/codegen/style/scopedClasses.js +32 -0
- package/lib/codegen/template/context.d.ts +106 -5
- package/lib/codegen/template/context.js +131 -6
- package/lib/codegen/template/element.d.ts +1 -1
- package/lib/codegen/template/element.js +74 -97
- package/lib/codegen/template/elementChildren.d.ts +1 -1
- package/lib/codegen/template/elementChildren.js +1 -13
- package/lib/codegen/template/elementDirectives.js +8 -6
- package/lib/codegen/template/elementEvents.d.ts +2 -1
- package/lib/codegen/template/elementEvents.js +52 -28
- package/lib/codegen/template/elementProps.d.ts +1 -1
- package/lib/codegen/template/elementProps.js +23 -20
- package/lib/codegen/template/index.js +29 -14
- package/lib/codegen/template/interpolation.js +5 -5
- package/lib/codegen/template/objectProperty.js +5 -4
- package/lib/codegen/template/propertyAccess.js +1 -1
- package/lib/codegen/template/slotOutlet.js +13 -11
- package/lib/codegen/template/styleScopedClasses.js +8 -58
- package/lib/codegen/template/templateChild.js +60 -28
- package/lib/codegen/template/vFor.js +2 -2
- package/lib/codegen/template/vIf.js +4 -8
- package/lib/codegen/template/vSlot.d.ts +1 -0
- package/lib/codegen/template/vSlot.js +14 -1
- package/lib/codegen/utils/camelized.d.ts +1 -1
- package/lib/codegen/utils/camelized.js +6 -6
- package/lib/codegen/utils/escaped.d.ts +2 -0
- package/lib/codegen/utils/escaped.js +23 -0
- package/lib/codegen/utils/index.d.ts +3 -3
- package/lib/codegen/utils/index.js +19 -15
- package/lib/codegen/utils/objectProperty.d.ts +3 -0
- package/lib/codegen/utils/objectProperty.js +41 -0
- package/lib/codegen/utils/stringLiteralKey.js +2 -1
- package/lib/codegen/utils/unicode.js +2 -2
- package/lib/codegen/utils/wrapWith.d.ts +3 -0
- package/lib/codegen/utils/wrapWith.js +24 -0
- package/lib/parsers/scriptSetupRanges.d.ts +2 -0
- package/lib/parsers/scriptSetupRanges.js +84 -106
- package/lib/plugins/file-md.js +3 -0
- package/lib/plugins/vue-template-inline-ts.js +3 -3
- package/lib/plugins/vue-tsx.d.ts +11 -8
- package/lib/plugins/vue-tsx.js +19 -28
- package/lib/types.d.ts +24 -14
- package/lib/utils/parseSfc.js +40 -16
- package/lib/utils/ts.js +17 -0
- package/lib/virtualFile/computedEmbeddedCodes.js +18 -11
- package/lib/virtualFile/computedSfc.js +21 -28
- package/lib/virtualFile/vueFile.d.ts +7 -10
- package/lib/virtualFile/vueFile.js +10 -4
- package/package.json +2 -2
- package/lib/codeFeatures.d.ts +0 -1
- package/lib/codeFeatures.js +0 -3
- package/lib/codegen/common.d.ts +0 -12
- package/lib/codegen/common.js +0 -79
- package/lib/codegen/script/binding.d.ts +0 -4
- package/lib/codegen/script/binding.js +0 -41
- package/lib/codegen/template/camelized.d.ts +0 -2
- package/lib/codegen/template/camelized.js +0 -31
- package/lib/codegen/utils/src.d.ts +0 -2
- package/lib/codegen/utils/src.js +0 -19
- package/lib/plugins/vue-style-class-names.d.ts +0 -5
- package/lib/plugins/vue-style-class-names.js +0 -32
- package/lib/plugins/vue-style-reference-link.d.ts +0 -1
- package/lib/plugins/vue-style-reference-link.js +0 -3
- package/lib/plugins/vue-style-reference-links.d.ts +0 -3
- package/lib/plugins/vue-style-reference-links.js +0 -26
- package/lib/plugins/vue-vine.d.ts +0 -3
- package/lib/plugins/vue-vine.js +0 -35
- package/lib/utils/findDestructuredProps.d.ts +0 -1
- package/lib/utils/findDestructuredProps.js +0 -3
- package/lib/utils/parseCssImports.d.ts +0 -4
- package/lib/utils/parseCssImports.js +0 -19
package/lib/codegen/common.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.variableNameRegex = exports.combineLastMapping = exports.endOfLine = exports.newLine = void 0;
|
|
4
|
-
exports.conditionWrapWith = conditionWrapWith;
|
|
5
|
-
exports.wrapWith = wrapWith;
|
|
6
|
-
exports.collectVars = collectVars;
|
|
7
|
-
exports.collectIdentifiers = collectIdentifiers;
|
|
8
|
-
exports.createTsAst = createTsAst;
|
|
9
|
-
exports.generateSfcBlockSection = generateSfcBlockSection;
|
|
10
|
-
const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
|
|
11
|
-
exports.newLine = '\n';
|
|
12
|
-
exports.endOfLine = `;${exports.newLine}`;
|
|
13
|
-
exports.combineLastMapping = { __combineLastMapping: true };
|
|
14
|
-
exports.variableNameRegex = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
15
|
-
function* conditionWrapWith(condition, startOffset, endOffset, features, ...wrapCodes) {
|
|
16
|
-
if (condition) {
|
|
17
|
-
yield* wrapWith(startOffset, endOffset, features, ...wrapCodes);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
for (const wrapCode of wrapCodes) {
|
|
21
|
-
yield wrapCode;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function* wrapWith(startOffset, endOffset, features, ...wrapCodes) {
|
|
26
|
-
yield ['', 'template', startOffset, features];
|
|
27
|
-
let offset = 1;
|
|
28
|
-
for (const wrapCode of wrapCodes) {
|
|
29
|
-
if (typeof wrapCode !== 'string') {
|
|
30
|
-
offset++;
|
|
31
|
-
}
|
|
32
|
-
yield wrapCode;
|
|
33
|
-
}
|
|
34
|
-
yield ['', 'template', endOffset, { __combineOffsetMapping: offset }];
|
|
35
|
-
}
|
|
36
|
-
function collectVars(ts, node, ast, results = []) {
|
|
37
|
-
const identifiers = collectIdentifiers(ts, node, []);
|
|
38
|
-
for (const [id] of identifiers) {
|
|
39
|
-
results.push((0, scriptSetupRanges_1.getNodeText)(ts, id, ast));
|
|
40
|
-
}
|
|
41
|
-
return results;
|
|
42
|
-
}
|
|
43
|
-
function collectIdentifiers(ts, node, results = [], isRest = false) {
|
|
44
|
-
if (ts.isIdentifier(node)) {
|
|
45
|
-
results.push([node, isRest]);
|
|
46
|
-
}
|
|
47
|
-
else if (ts.isObjectBindingPattern(node)) {
|
|
48
|
-
for (const el of node.elements) {
|
|
49
|
-
collectIdentifiers(ts, el.name, results, !!el.dotDotDotToken);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else if (ts.isArrayBindingPattern(node)) {
|
|
53
|
-
for (const el of node.elements) {
|
|
54
|
-
if (ts.isBindingElement(el)) {
|
|
55
|
-
collectIdentifiers(ts, el.name, results, !!el.dotDotDotToken);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
ts.forEachChild(node, node => collectIdentifiers(ts, node, results, false));
|
|
61
|
-
}
|
|
62
|
-
return results;
|
|
63
|
-
}
|
|
64
|
-
function createTsAst(ts, astHolder, text) {
|
|
65
|
-
if (astHolder.__volar_ast_text !== text) {
|
|
66
|
-
astHolder.__volar_ast_text = text;
|
|
67
|
-
astHolder.__volar_ast = ts.createSourceFile('/a.ts', text, 99);
|
|
68
|
-
}
|
|
69
|
-
return astHolder.__volar_ast;
|
|
70
|
-
}
|
|
71
|
-
function generateSfcBlockSection(block, start, end, features) {
|
|
72
|
-
return [
|
|
73
|
-
block.content.substring(start, end),
|
|
74
|
-
block.name,
|
|
75
|
-
start,
|
|
76
|
-
features,
|
|
77
|
-
];
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=common.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { TemplateCodegenContext } from '../template/context';
|
|
2
|
-
import type { ScriptCodegenContext } from './context';
|
|
3
|
-
import type { ScriptCodegenOptions } from './index';
|
|
4
|
-
export declare function generateBindings(options: ScriptCodegenOptions, ctx: ScriptCodegenContext, templateCodegenCtx: TemplateCodegenContext): Generator<import("../../types").Code, void, any>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateBindings = generateBindings;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const component_1 = require("./component");
|
|
6
|
-
const template_1 = require("./template");
|
|
7
|
-
function* generateBindings(options, ctx, templateCodegenCtx) {
|
|
8
|
-
if (!options.sfc.scriptSetup || !options.scriptSetupRanges) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
yield `const __VLS_bindings = {`;
|
|
12
|
-
if (ctx.bypassDefineComponent) {
|
|
13
|
-
yield* (0, component_1.generateComponentSetupReturns)(options.scriptSetupRanges);
|
|
14
|
-
}
|
|
15
|
-
const templateUsageVars = (0, template_1.getTemplateUsageVars)(options, ctx);
|
|
16
|
-
for (const [content, bindings] of [
|
|
17
|
-
[options.sfc.scriptSetup.content, options.scriptSetupRanges.bindings],
|
|
18
|
-
options.sfc.script && options.scriptRanges
|
|
19
|
-
? [options.sfc.script.content, options.scriptRanges.bindings]
|
|
20
|
-
: ['', []],
|
|
21
|
-
]) {
|
|
22
|
-
for (const { range } of bindings) {
|
|
23
|
-
const varName = content.slice(range.start, range.end);
|
|
24
|
-
if (!templateUsageVars.has(varName) && !templateCodegenCtx.accessExternalVariables.has(varName)) {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
const templateOffset = options.getGeneratedLength();
|
|
28
|
-
yield `${varName}: ${varName} as typeof `;
|
|
29
|
-
const scriptOffset = options.getGeneratedLength();
|
|
30
|
-
yield `${varName},${utils_1.newLine}`;
|
|
31
|
-
options.linkedCodeMappings.push({
|
|
32
|
-
sourceOffsets: [scriptOffset],
|
|
33
|
-
generatedOffsets: [templateOffset],
|
|
34
|
-
lengths: [varName.length],
|
|
35
|
-
data: undefined,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
yield `}${utils_1.endOfLine}`;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=binding.js.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateCamelized = generateCamelized;
|
|
4
|
-
const shared_1 = require("@vue/shared");
|
|
5
|
-
const common_1 = require("../common");
|
|
6
|
-
function* generateCamelized(code, offset, info) {
|
|
7
|
-
const parts = code.split('-');
|
|
8
|
-
for (let i = 0; i < parts.length; i++) {
|
|
9
|
-
const part = parts[i];
|
|
10
|
-
if (part !== '') {
|
|
11
|
-
if (i === 0) {
|
|
12
|
-
yield [
|
|
13
|
-
part,
|
|
14
|
-
'template',
|
|
15
|
-
offset,
|
|
16
|
-
info,
|
|
17
|
-
];
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
yield [
|
|
21
|
-
(0, shared_1.capitalize)(part),
|
|
22
|
-
'template',
|
|
23
|
-
offset,
|
|
24
|
-
common_1.combineLastMapping,
|
|
25
|
-
];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
offset += part.length + 1;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=camelized.js.map
|
package/lib/codegen/utils/src.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateSfcBlockSrc = generateSfcBlockSrc;
|
|
4
|
-
function* generateSfcBlockSrc(src, text, features) {
|
|
5
|
-
const { offset, quotes } = src;
|
|
6
|
-
if (!quotes) {
|
|
7
|
-
yield [``, 'main', offset, { verification: true }];
|
|
8
|
-
}
|
|
9
|
-
yield [
|
|
10
|
-
quotes ? text : `'${text}'`,
|
|
11
|
-
'main',
|
|
12
|
-
quotes ? offset : offset - 1,
|
|
13
|
-
features
|
|
14
|
-
];
|
|
15
|
-
if (!quotes) {
|
|
16
|
-
yield [``, 'main', offset + text.length, { __combineOffsetMapping: 2 }];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=src.js.map
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.commentReg = void 0;
|
|
4
|
-
exports.fillBlank = fillBlank;
|
|
5
|
-
exports.commentReg = /(?<=\/\*)[\s\S]*?(?=\*\/)|(?<=\/\/)[\s\S]*?(?=\n)/g;
|
|
6
|
-
const cssClassNameReg = /(?=(\.[a-z_][-\w]*)[\s.,+~>:#)[{])/gi;
|
|
7
|
-
const fragmentReg = /(?<={)[^{]*(?=(?<!\\);)/g;
|
|
8
|
-
const plugin = () => {
|
|
9
|
-
return {
|
|
10
|
-
version: 2.1,
|
|
11
|
-
resolveStyleReferenceLinks(block) {
|
|
12
|
-
const result = [];
|
|
13
|
-
const content = fillBlank(block.content, exports.commentReg, fragmentReg);
|
|
14
|
-
const matches = content.matchAll(cssClassNameReg);
|
|
15
|
-
for (const match of matches) {
|
|
16
|
-
const matchText = match[1];
|
|
17
|
-
if (matchText) {
|
|
18
|
-
result.push({ text: matchText, offset: match.index });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
exports.default = plugin;
|
|
26
|
-
function fillBlank(css, ...regs) {
|
|
27
|
-
for (const reg of regs) {
|
|
28
|
-
css = css.replace(reg, match => ' '.repeat(match.length));
|
|
29
|
-
}
|
|
30
|
-
return css;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=vue-style-class-names.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const cssImportReg = /(?<=@import\s+url\()(["']?).*?\1(?=\))|(?<=@import\b\s*)(["']).*?\2/g;
|
|
4
|
-
const plugin = () => {
|
|
5
|
-
return {
|
|
6
|
-
version: 2.1,
|
|
7
|
-
resolveStyleReferenceLinks(block) {
|
|
8
|
-
const result = [];
|
|
9
|
-
const matches = block.content.matchAll(cssImportReg);
|
|
10
|
-
for (const match of matches) {
|
|
11
|
-
let text = match[0];
|
|
12
|
-
let offset = match.index;
|
|
13
|
-
if (text.startsWith('\'') || text.startsWith('"')) {
|
|
14
|
-
text = text.slice(1, -1);
|
|
15
|
-
offset += 1;
|
|
16
|
-
}
|
|
17
|
-
if (text) {
|
|
18
|
-
result.push({ text, offset });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
exports.default = plugin;
|
|
26
|
-
//# sourceMappingURL=vue-style-reference-links.js.map
|
package/lib/plugins/vue-vine.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const shared_1 = require("./shared");
|
|
4
|
-
const plugin = () => {
|
|
5
|
-
return {
|
|
6
|
-
version: 2.1,
|
|
7
|
-
getEmbeddedCodes(_fileName, sfc) {
|
|
8
|
-
const result = [];
|
|
9
|
-
for (let i = 0; i < sfc.customBlocks.length; i++) {
|
|
10
|
-
const block = sfc.customBlocks[i];
|
|
11
|
-
if (block.type === 'vine') {
|
|
12
|
-
result.push({
|
|
13
|
-
id: 'vine_' + i,
|
|
14
|
-
lang: block.lang,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
},
|
|
20
|
-
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
|
|
21
|
-
if (embeddedFile.id.startsWith('vine_')) {
|
|
22
|
-
const index = parseInt(embeddedFile.id.slice('vine_'.length));
|
|
23
|
-
const block = sfc.customBlocks[index];
|
|
24
|
-
embeddedFile.content.push([
|
|
25
|
-
block.content,
|
|
26
|
-
block.name,
|
|
27
|
-
0,
|
|
28
|
-
shared_1.allCodeFeatures,
|
|
29
|
-
]);
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
exports.default = plugin;
|
|
35
|
-
//# sourceMappingURL=vue-vine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCssImports = parseCssImports;
|
|
4
|
-
const cssImportReg = /(?<=@import\s+url\()(["']?).*?\1(?=\))|(?<=@import\b\s*)(["']).*?\2/g;
|
|
5
|
-
function* parseCssImports(css) {
|
|
6
|
-
const matches = css.matchAll(cssImportReg);
|
|
7
|
-
for (const match of matches) {
|
|
8
|
-
let text = match[0];
|
|
9
|
-
let offset = match.index;
|
|
10
|
-
if (text.startsWith('\'') || text.startsWith('"')) {
|
|
11
|
-
text = text.slice(1, -1);
|
|
12
|
-
offset += 1;
|
|
13
|
-
}
|
|
14
|
-
if (text) {
|
|
15
|
-
yield { text, offset };
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=parseCssImports.js.map
|