@vue/language-core 3.3.5 → 3.3.7
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/index.d.ts +1 -0
- package/index.js +1 -0
- package/lib/codegen/codeFeatures.d.ts +24 -84
- package/lib/codegen/codeFeatures.js +46 -4
- package/lib/codegen/names.d.ts +3 -4
- package/lib/codegen/names.js +3 -4
- package/lib/codegen/script/index.js +5 -5
- package/lib/codegen/script/scriptSetup.js +4 -4
- package/lib/codegen/style/common.js +7 -11
- package/lib/codegen/style/index.d.ts +55 -27
- package/lib/codegen/style/index.js +4 -4
- package/lib/codegen/style/modules.d.ts +1 -1
- package/lib/codegen/style/modules.js +1 -1
- package/lib/codegen/style/scopedClasses.d.ts +2 -1
- package/lib/codegen/style/scopedClasses.js +5 -4
- package/lib/codegen/template/context.d.ts +55 -124
- package/lib/codegen/template/context.js +187 -269
- package/lib/codegen/template/element.js +18 -103
- package/lib/codegen/template/elementDirectives.js +11 -11
- package/lib/codegen/template/elementEvents.js +50 -45
- package/lib/codegen/template/elementProps.js +12 -12
- package/lib/codegen/template/index.d.ts +55 -27
- package/lib/codegen/template/index.js +7 -7
- package/lib/codegen/template/interpolation.js +28 -28
- package/lib/codegen/template/objectProperty.js +5 -5
- package/lib/codegen/template/propertyAccess.js +1 -1
- package/lib/codegen/template/slotOutlet.js +8 -10
- package/lib/codegen/template/styleScopedClasses.d.ts +3 -0
- package/lib/codegen/template/styleScopedClasses.js +126 -4
- package/lib/codegen/template/vFor.js +3 -3
- package/lib/codegen/template/vIf.js +4 -4
- package/lib/codegen/template/vSlot.js +9 -9
- package/lib/codegen/utils/boundary.d.ts +7 -2
- package/lib/codegen/utils/boundary.js +15 -9
- package/lib/codegen/utils/camelized.js +5 -13
- package/lib/codegen/utils/escaped.js +4 -9
- package/lib/codegen/utils/index.d.ts +1 -1
- package/lib/codegen/utils/index.js +3 -3
- package/lib/codegen/utils/stringLiteralKey.js +3 -3
- package/lib/codegen/utils/unicode.d.ts +1 -1
- package/lib/codegen/utils/unicode.js +4 -4
- package/lib/languagePlugin.js +2 -1
- package/lib/parsers/scriptRanges.d.ts +2 -2
- package/lib/parsers/scriptRanges.js +3 -10
- package/lib/parsers/scriptSetupRanges.d.ts +2 -2
- package/lib/parsers/scriptSetupRanges.js +3 -10
- package/lib/parsers/utils.d.ts +1 -0
- package/lib/parsers/utils.js +10 -0
- package/lib/parsers/vueCompilerOptions.js +2 -2
- package/lib/plugins/file-html.js +4 -4
- package/lib/plugins/file-md.js +15 -15
- package/lib/plugins/file-vue.js +2 -2
- package/lib/plugins/vue-root-tags.js +3 -3
- package/lib/plugins/vue-sfc-customblocks.js +2 -2
- package/lib/plugins/vue-sfc-scripts.js +2 -4
- package/lib/plugins/vue-sfc-styles.js +3 -3
- package/lib/plugins/vue-sfc-template.js +2 -2
- package/lib/plugins/vue-style-css.js +86 -33
- package/lib/plugins/vue-template-html.js +3 -3
- package/lib/plugins/vue-template-inline-css.js +2 -7
- package/lib/plugins/vue-template-inline-ts.js +4 -5
- package/lib/plugins/vue-tsx.d.ts +61 -31
- package/lib/plugins/vue-tsx.js +26 -23
- package/lib/plugins.d.ts +0 -1
- package/lib/plugins.js +0 -15
- package/lib/types.d.ts +1 -1
- package/lib/utils/forEachTemplateNode.js +36 -43
- package/lib/virtualCode/index.js +2 -2
- package/package.json +4 -4
- package/types/template-helpers.d.ts +14 -24
- package/lib/plugins/shared.d.ts +0 -2
- package/lib/plugins/shared.js +0 -12
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.identifierRE = exports.endOfLine = exports.newLine = void 0;
|
|
4
4
|
exports.getTypeScriptAST = getTypeScriptAST;
|
|
5
5
|
exports.generateSfcBlockSection = generateSfcBlockSection;
|
|
6
6
|
exports.forEachNode = forEachNode;
|
|
7
7
|
const codeFeatures_1 = require("../codeFeatures");
|
|
8
8
|
exports.newLine = `\n`;
|
|
9
9
|
exports.endOfLine = `;${exports.newLine}`;
|
|
10
|
-
exports.
|
|
11
|
-
const cacheMaps = new
|
|
10
|
+
exports.identifierRE = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
11
|
+
const cacheMaps = new WeakMap();
|
|
12
12
|
function getTypeScriptAST(ts, block, text) {
|
|
13
13
|
if (!cacheMaps.has(block)) {
|
|
14
14
|
cacheMaps.set(block, [block.content, new Map()]);
|
|
@@ -7,11 +7,11 @@ function* generateStringLiteralKey(code, offset, info) {
|
|
|
7
7
|
yield `'${code}'`;
|
|
8
8
|
}
|
|
9
9
|
else {
|
|
10
|
-
const
|
|
10
|
+
const boundary = yield* boundary_1.Boundary.start('template', offset, info);
|
|
11
11
|
yield `'`;
|
|
12
|
-
yield [code, 'template', offset,
|
|
12
|
+
yield [code, 'template', offset, boundary.features];
|
|
13
13
|
yield `'`;
|
|
14
|
-
yield
|
|
14
|
+
yield boundary.end(offset + code.length);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=stringLiteralKey.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Code, VueCodeInformation } from '../../types';
|
|
2
|
-
export declare function generateUnicode(code: string, offset: number,
|
|
2
|
+
export declare function generateUnicode(code: string, offset: number, features: VueCodeInformation): Generator<Code>;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateUnicode = generateUnicode;
|
|
4
4
|
const boundary_1 = require("./boundary");
|
|
5
|
-
function* generateUnicode(code, offset,
|
|
5
|
+
function* generateUnicode(code, offset, features) {
|
|
6
6
|
if (needToUnicode(code)) {
|
|
7
|
-
const
|
|
7
|
+
const boundary = yield* boundary_1.Boundary.start('template', offset, features);
|
|
8
8
|
yield toUnicode(code);
|
|
9
|
-
yield
|
|
9
|
+
yield boundary.end(offset + code.length);
|
|
10
10
|
}
|
|
11
11
|
else {
|
|
12
|
-
yield [code, 'template', offset,
|
|
12
|
+
yield [code, 'template', offset, features];
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
function needToUnicode(str) {
|
package/lib/languagePlugin.js
CHANGED
|
@@ -40,6 +40,7 @@ const language_core_1 = require("@volar/language-core");
|
|
|
40
40
|
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
41
41
|
const LanguageCore = __importStar(require("../index"));
|
|
42
42
|
const plugins_1 = require("./plugins");
|
|
43
|
+
const vue_tsx_1 = require("./plugins/vue-tsx");
|
|
43
44
|
const virtualCode_1 = require("./virtualCode");
|
|
44
45
|
const fileRegistries = {};
|
|
45
46
|
function getVueFileRegistry(compilerOptions, vueCompilerOptions, plugins) {
|
|
@@ -111,7 +112,7 @@ function createVueLanguagePlugin(ts, compilerOptions, vueCompilerOptions, asFile
|
|
|
111
112
|
})),
|
|
112
113
|
getServiceScript(root) {
|
|
113
114
|
for (const code of (0, language_core_1.forEachEmbeddedCode)(root)) {
|
|
114
|
-
if (
|
|
115
|
+
if (vue_tsx_1.serviceScriptRE.test(code.id)) {
|
|
115
116
|
const lang = code.id.slice('script_'.length);
|
|
116
117
|
return {
|
|
117
118
|
code,
|
|
@@ -3,6 +3,8 @@ import type { TextRange, VueCompilerOptions } from '../types';
|
|
|
3
3
|
export interface ScriptRanges extends ReturnType<typeof parseScriptRanges> {
|
|
4
4
|
}
|
|
5
5
|
export declare function parseScriptRanges(ts: typeof import('typescript'), sourceFile: ts.SourceFile, vueCompilerOptions: VueCompilerOptions): {
|
|
6
|
+
bindings: TextRange<ts.Node>[];
|
|
7
|
+
components: TextRange<ts.Node>[];
|
|
6
8
|
exportDefault: (TextRange<ts.Node> & {
|
|
7
9
|
expression: TextRange<ts.Expression>;
|
|
8
10
|
isObjectLiteral: boolean;
|
|
@@ -16,8 +18,6 @@ export declare function parseScriptRanges(ts: typeof import('typescript'), sourc
|
|
|
16
18
|
inheritAttrs: string | undefined;
|
|
17
19
|
};
|
|
18
20
|
}) | undefined;
|
|
19
|
-
bindings: TextRange<ts.Node>[];
|
|
20
|
-
components: TextRange<ts.Node>[];
|
|
21
21
|
};
|
|
22
22
|
export declare function parseOptionsFromExtression(ts: typeof import('typescript'), exp: ts.Node, sourceFile: ts.SourceFile): {
|
|
23
23
|
isObjectLiteral: boolean;
|
|
@@ -6,7 +6,6 @@ const shared_1 = require("../utils/shared");
|
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
function parseScriptRanges(ts, sourceFile, vueCompilerOptions) {
|
|
8
8
|
let exportDefault;
|
|
9
|
-
const { bindings, components } = (0, utils_1.parseBindingRanges)(ts, sourceFile, vueCompilerOptions.extensions);
|
|
10
9
|
ts.forEachChild(sourceFile, child => {
|
|
11
10
|
if (ts.isExportAssignment(child)) {
|
|
12
11
|
exportDefault = {
|
|
@@ -22,16 +21,14 @@ function parseScriptRanges(ts, sourceFile, vueCompilerOptions) {
|
|
|
22
21
|
}
|
|
23
22
|
});
|
|
24
23
|
return {
|
|
24
|
+
...(0, utils_1.parseBindingRanges)(ts, sourceFile, vueCompilerOptions.extensions),
|
|
25
25
|
exportDefault,
|
|
26
|
-
bindings,
|
|
27
|
-
components,
|
|
28
26
|
};
|
|
29
27
|
}
|
|
30
28
|
function parseOptionsFromExtression(ts, exp, sourceFile) {
|
|
31
29
|
let obj;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
30
|
+
// #1882
|
|
31
|
+
exp = (0, utils_1.getUnwrappedExpression)(ts, exp);
|
|
35
32
|
if (ts.isObjectLiteralExpression(exp)) {
|
|
36
33
|
obj = exp;
|
|
37
34
|
}
|
|
@@ -83,8 +80,4 @@ function parseOptionsFromExtression(ts, exp, sourceFile) {
|
|
|
83
80
|
return (0, shared_1.getNodeText)(ts, node, sourceFile);
|
|
84
81
|
}
|
|
85
82
|
}
|
|
86
|
-
// isAsExpression is missing in tsc
|
|
87
|
-
function isAsExpression(ts, node) {
|
|
88
|
-
return node.kind === ts.SyntaxKind.AsExpression;
|
|
89
|
-
}
|
|
90
83
|
//# sourceMappingURL=scriptRanges.js.map
|
|
@@ -42,10 +42,10 @@ export interface UseTemplateRef extends CallExpressionRange {
|
|
|
42
42
|
export interface ScriptSetupRanges extends ReturnType<typeof parseScriptSetupRanges> {
|
|
43
43
|
}
|
|
44
44
|
export declare function parseScriptSetupRanges(ts: typeof import('typescript'), sourceFile: ts.SourceFile, vueCompilerOptions: VueCompilerOptions): {
|
|
45
|
-
leadingCommentEndOffset: number;
|
|
46
|
-
importSectionEndOffset: number;
|
|
47
45
|
bindings: TextRange<ts.Node>[];
|
|
48
46
|
components: TextRange<ts.Node>[];
|
|
47
|
+
leadingCommentEndOffset: number;
|
|
48
|
+
importSectionEndOffset: number;
|
|
49
49
|
defineModel: DefineModel[];
|
|
50
50
|
defineProps: DefineProps | undefined;
|
|
51
51
|
withDefaults: CallExpressionRange | undefined;
|
|
@@ -4,7 +4,7 @@ exports.parseScriptSetupRanges = parseScriptSetupRanges;
|
|
|
4
4
|
const collectBindings_1 = require("../utils/collectBindings");
|
|
5
5
|
const shared_1 = require("../utils/shared");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
|
-
const
|
|
7
|
+
const tsCheckRE = /^\/\/\s*@ts-(?:no)?check(?:$|\s)/;
|
|
8
8
|
function parseScriptSetupRanges(ts, sourceFile, vueCompilerOptions) {
|
|
9
9
|
const defineModel = [];
|
|
10
10
|
let defineProps;
|
|
@@ -19,8 +19,7 @@ function parseScriptSetupRanges(ts, sourceFile, vueCompilerOptions) {
|
|
|
19
19
|
const useTemplateRef = [];
|
|
20
20
|
const text = sourceFile.text;
|
|
21
21
|
const leadingCommentRanges = ts.getLeadingCommentRanges(text, 0)?.reverse() ?? [];
|
|
22
|
-
const leadingCommentEndOffset = leadingCommentRanges.find(range =>
|
|
23
|
-
let { bindings, components } = (0, utils_1.parseBindingRanges)(ts, sourceFile, vueCompilerOptions.extensions);
|
|
22
|
+
const leadingCommentEndOffset = leadingCommentRanges.find(range => tsCheckRE.test(text.slice(range.pos, range.end)))?.end ?? 0;
|
|
24
23
|
let foundNonImportExportNode = false;
|
|
25
24
|
let importSectionEndOffset = 0;
|
|
26
25
|
ts.forEachChild(sourceFile, node => {
|
|
@@ -47,16 +46,10 @@ function parseScriptSetupRanges(ts, sourceFile, vueCompilerOptions) {
|
|
|
47
46
|
foundNonImportExportNode = true;
|
|
48
47
|
});
|
|
49
48
|
ts.forEachChild(sourceFile, node => visitNode(node, [sourceFile]));
|
|
50
|
-
const templateRefNames = new Set(useTemplateRef.map(ref => ref.name));
|
|
51
|
-
bindings = bindings.filter(range => {
|
|
52
|
-
const name = text.slice(range.start, range.end);
|
|
53
|
-
return !templateRefNames.has(name);
|
|
54
|
-
});
|
|
55
49
|
return {
|
|
50
|
+
...(0, utils_1.parseBindingRanges)(ts, sourceFile, vueCompilerOptions.extensions),
|
|
56
51
|
leadingCommentEndOffset,
|
|
57
52
|
importSectionEndOffset,
|
|
58
|
-
bindings,
|
|
59
|
-
components,
|
|
60
53
|
defineModel,
|
|
61
54
|
defineProps,
|
|
62
55
|
withDefaults,
|
package/lib/parsers/utils.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare function parseBindingRanges(ts: typeof import('typescript'), ast:
|
|
|
5
5
|
components: TextRange<ts.Node>[];
|
|
6
6
|
};
|
|
7
7
|
export declare function getClosestMultiLineCommentRange(ts: typeof import('typescript'), node: ts.Node, parents: ts.Node[], ast: ts.SourceFile): TextRange | undefined;
|
|
8
|
+
export declare function getUnwrappedExpression(ts: typeof import('typescript'), node: ts.Node): ts.Node;
|
package/lib/parsers/utils.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseBindingRanges = parseBindingRanges;
|
|
4
4
|
exports.getClosestMultiLineCommentRange = getClosestMultiLineCommentRange;
|
|
5
|
+
exports.getUnwrappedExpression = getUnwrappedExpression;
|
|
5
6
|
const collectBindings_1 = require("../utils/collectBindings");
|
|
6
7
|
const shared_1 = require("../utils/shared");
|
|
7
8
|
function parseBindingRanges(ts, ast, componentExtsensions) {
|
|
@@ -91,4 +92,13 @@ function getClosestMultiLineCommentRange(ts, node, parents, ast) {
|
|
|
91
92
|
};
|
|
92
93
|
}
|
|
93
94
|
}
|
|
95
|
+
function getUnwrappedExpression(ts, node) {
|
|
96
|
+
while (ts.isParenthesizedExpression(node)
|
|
97
|
+
|| ts.isAssertionExpression(node)
|
|
98
|
+
|| ts.isNonNullExpression(node)
|
|
99
|
+
|| ts.isSatisfiesExpression(node)) {
|
|
100
|
+
node = node.expression;
|
|
101
|
+
}
|
|
102
|
+
return node;
|
|
103
|
+
}
|
|
94
104
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseVueCompilerOptions = parseVueCompilerOptions;
|
|
4
|
-
const
|
|
4
|
+
const syntaxRE = /^\s*@(?<key>.+?)\s+(?<value>.+?)\s*$/m;
|
|
5
5
|
function parseVueCompilerOptions(comments) {
|
|
6
6
|
const entries = comments
|
|
7
7
|
.map(text => {
|
|
8
8
|
try {
|
|
9
|
-
const match = text.match(
|
|
9
|
+
const match = text.match(syntaxRE);
|
|
10
10
|
if (match) {
|
|
11
11
|
const { key, value } = match.groups ?? {};
|
|
12
12
|
return [key, JSON.parse(value)];
|
package/lib/plugins/file-html.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const sfcBlockRE = /<(script|style)\b([\s\S]*?)>([\s\S]*?)<\/\1>/g;
|
|
4
|
+
const langRE = /\blang\s*=\s*(['"]?)(\S*)\b\1/;
|
|
5
5
|
const plugin = ({ vueCompilerOptions }) => {
|
|
6
6
|
return {
|
|
7
7
|
version: 2.2,
|
|
@@ -34,11 +34,11 @@ const plugin = ({ vueCompilerOptions }) => {
|
|
|
34
34
|
errors: [],
|
|
35
35
|
};
|
|
36
36
|
let templateContent = content;
|
|
37
|
-
for (const match of content.matchAll(
|
|
37
|
+
for (const match of content.matchAll(sfcBlockRE)) {
|
|
38
38
|
const matchText = match[0];
|
|
39
39
|
const tag = match[1];
|
|
40
40
|
const attrs = match[2];
|
|
41
|
-
const lang = attrs.match(
|
|
41
|
+
const lang = attrs.match(langRE)?.[2];
|
|
42
42
|
const content = match[3];
|
|
43
43
|
const contentStart = match.index + matchText.indexOf(content);
|
|
44
44
|
if (tag === 'style') {
|
package/lib/plugins/file-md.js
CHANGED
|
@@ -4,14 +4,14 @@ const language_core_1 = require("@volar/language-core");
|
|
|
4
4
|
const muggle_string_1 = require("muggle-string");
|
|
5
5
|
const buildMappings_1 = require("../utils/buildMappings");
|
|
6
6
|
const parseSfc_1 = require("../utils/parseSfc");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
7
|
+
const frontmatterRE = /^---[\s\S]*?\n---(?:\r?\n|$)/;
|
|
8
|
+
const codeblockRE = /(`{3}|\${2})[\s\S]+?\1/g;
|
|
9
|
+
const codeSnippetImportRE = /^\s*<<<\s*.+/gm;
|
|
10
|
+
const sfcBlockRE = /<(script|style)\b[^>]*>([\s\S]*?)<\/\1>/g;
|
|
11
|
+
const htmlTagRE = /(?<=<\/?)([a-z][a-z0-9-]*)\b[^>]*(?=>)/gi;
|
|
12
|
+
const interpolationRE = /(?<=\{\{)[\s\S]*?(?=\}\})/g;
|
|
13
|
+
const inlineCodeRE = /(`{1,2})[^`]+\1/g;
|
|
14
|
+
const angleBracketRE = /<[^\s:]*:\S*>/g;
|
|
15
15
|
const plugin = ({ vueCompilerOptions }) => {
|
|
16
16
|
return {
|
|
17
17
|
version: 2.2,
|
|
@@ -27,23 +27,23 @@ const plugin = ({ vueCompilerOptions }) => {
|
|
|
27
27
|
if (languageId !== 'markdown') {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
for (const
|
|
31
|
-
content = content.replace(
|
|
30
|
+
for (const pattern of [frontmatterRE, codeblockRE, codeSnippetImportRE]) {
|
|
31
|
+
content = content.replace(pattern, match => ' '.repeat(match.length));
|
|
32
32
|
}
|
|
33
33
|
const codes = [];
|
|
34
|
-
for (const { 0: text, index } of content.matchAll(
|
|
34
|
+
for (const { 0: text, index } of content.matchAll(sfcBlockRE)) {
|
|
35
35
|
codes.push([text, undefined, index]);
|
|
36
36
|
codes.push('\n\n');
|
|
37
37
|
content = content.slice(0, index) + ' '.repeat(text.length) + content.slice(index + text.length);
|
|
38
38
|
}
|
|
39
39
|
const ranges = [];
|
|
40
|
-
for (const
|
|
41
|
-
for (const { 0: text, index } of content.matchAll(
|
|
40
|
+
for (const pattern of [htmlTagRE, interpolationRE]) {
|
|
41
|
+
for (const { 0: text, index } of content.matchAll(pattern)) {
|
|
42
42
|
ranges.push([index, index + text.length]);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
for (const
|
|
46
|
-
for (const { 0: text, index } of content.matchAll(
|
|
45
|
+
for (const pattern of [inlineCodeRE, angleBracketRE]) {
|
|
46
|
+
for (const { 0: text, index } of content.matchAll(pattern)) {
|
|
47
47
|
if (ranges.some(([start, end]) => index >= start && index < end)) {
|
|
48
48
|
continue;
|
|
49
49
|
}
|
package/lib/plugins/file-vue.js
CHANGED
|
@@ -50,8 +50,8 @@ const plugin = ({ vueCompilerOptions }) => {
|
|
|
50
50
|
+ change.newText
|
|
51
51
|
+ hitBlock.content.slice(change.end - hitBlock.loc.start.offset);
|
|
52
52
|
// #3449
|
|
53
|
-
const
|
|
54
|
-
const insertedEndTag =
|
|
53
|
+
const endTagRE = new RegExp(`</\\s*${hitBlock.type}\\s*>`);
|
|
54
|
+
const insertedEndTag = endTagRE.test(oldContent) !== endTagRE.test(newContent);
|
|
55
55
|
if (insertedEndTag) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const muggle_string_1 = require("muggle-string");
|
|
4
|
-
const
|
|
4
|
+
const codeFeatures_1 = require("../codegen/codeFeatures");
|
|
5
5
|
const plugin = () => {
|
|
6
6
|
return {
|
|
7
7
|
version: 2.2,
|
|
@@ -13,7 +13,7 @@ const plugin = () => {
|
|
|
13
13
|
},
|
|
14
14
|
resolveEmbeddedCode(_fileName, ir, embeddedFile) {
|
|
15
15
|
if (embeddedFile.id === 'root_tags') {
|
|
16
|
-
embeddedFile.content.push([ir.content, undefined, 0,
|
|
16
|
+
embeddedFile.content.push([ir.content, undefined, 0, codeFeatures_1.codeFeatures.full]);
|
|
17
17
|
for (const block of [
|
|
18
18
|
ir.template,
|
|
19
19
|
ir.script,
|
|
@@ -30,7 +30,7 @@ const plugin = () => {
|
|
|
30
30
|
'',
|
|
31
31
|
undefined,
|
|
32
32
|
block.startTagEnd + offset,
|
|
33
|
-
|
|
33
|
+
codeFeatures_1.codeFeatures.structure,
|
|
34
34
|
], ir.content.slice(block.startTagEnd + offset, block.endTagStart));
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const codeFeatures_1 = require("../codegen/codeFeatures");
|
|
4
4
|
const plugin = () => {
|
|
5
5
|
return {
|
|
6
6
|
version: 2.2,
|
|
@@ -18,7 +18,7 @@ const plugin = () => {
|
|
|
18
18
|
customBlock.content,
|
|
19
19
|
customBlock.name,
|
|
20
20
|
0,
|
|
21
|
-
|
|
21
|
+
codeFeatures_1.codeFeatures.full,
|
|
22
22
|
]);
|
|
23
23
|
}
|
|
24
24
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const codeFeatures_1 = require("../codegen/codeFeatures");
|
|
3
4
|
const plugin = () => {
|
|
4
5
|
return {
|
|
5
6
|
version: 2.2,
|
|
@@ -24,10 +25,7 @@ const plugin = () => {
|
|
|
24
25
|
script.content,
|
|
25
26
|
script.name,
|
|
26
27
|
0,
|
|
27
|
-
|
|
28
|
-
structure: true,
|
|
29
|
-
format: true,
|
|
30
|
-
},
|
|
28
|
+
codeFeatures_1.codeFeatures.structureAndFormat,
|
|
31
29
|
]);
|
|
32
30
|
}
|
|
33
31
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const codeFeatures_1 = require("../codegen/codeFeatures");
|
|
4
4
|
const plugin = () => {
|
|
5
5
|
return {
|
|
6
6
|
version: 2.2,
|
|
@@ -34,7 +34,7 @@ const plugin = () => {
|
|
|
34
34
|
binding.text,
|
|
35
35
|
style.name,
|
|
36
36
|
binding.offset,
|
|
37
|
-
|
|
37
|
+
codeFeatures_1.codeFeatures.full,
|
|
38
38
|
], ');\n');
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -43,7 +43,7 @@ const plugin = () => {
|
|
|
43
43
|
style.content,
|
|
44
44
|
style.name,
|
|
45
45
|
0,
|
|
46
|
-
|
|
46
|
+
codeFeatures_1.codeFeatures.full,
|
|
47
47
|
]);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const codeFeatures_1 = require("../codegen/codeFeatures");
|
|
4
4
|
const plugin = () => {
|
|
5
5
|
return {
|
|
6
6
|
version: 2.2,
|
|
@@ -19,7 +19,7 @@ const plugin = () => {
|
|
|
19
19
|
ir.template.content,
|
|
20
20
|
ir.template.name,
|
|
21
21
|
0,
|
|
22
|
-
|
|
22
|
+
codeFeatures_1.codeFeatures.full,
|
|
23
23
|
]);
|
|
24
24
|
}
|
|
25
25
|
},
|
|
@@ -13,50 +13,103 @@ const plugin = () => {
|
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
exports.default = plugin;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
16
|
+
const cssImportRE = /(?<=@import\s+url\()(["']?).*?\1(?=\))|(?<=@import\b\s*)(["']).*?\2/g;
|
|
17
|
+
const cssBindingRE = /\bv-bind\s*\(/g;
|
|
18
|
+
const cssClassNameRE = /\.[a-z_][-\w]*(?=[\s.,+~>:#)[{])/gi;
|
|
19
|
+
const commentRE = /(?<=\/\*)[\s\S]*?(?=\*\/)|(?<=\/\/)[\s\S]*?(?=\n)/g;
|
|
20
|
+
const fragmentRE = /(?<={)[^{]*(?=(?<!\\);)/g;
|
|
21
21
|
function* parseCssImports(css) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
let text = match[0];
|
|
25
|
-
let offset = match.index;
|
|
26
|
-
if (text.startsWith("'") || text.startsWith('"')) {
|
|
27
|
-
text = text.slice(1, -1);
|
|
28
|
-
offset += 1;
|
|
29
|
-
}
|
|
30
|
-
if (text) {
|
|
31
|
-
yield { text, offset };
|
|
32
|
-
}
|
|
22
|
+
for (const match of css.matchAll(cssImportRE)) {
|
|
23
|
+
yield trimQuotes(match[0], match.index);
|
|
33
24
|
}
|
|
34
25
|
}
|
|
35
26
|
function* parseCssBindings(css) {
|
|
36
|
-
css = fillBlank(css,
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
yield { offset, text: matchText };
|
|
27
|
+
css = fillBlank(css, commentRE);
|
|
28
|
+
for (const match of css.matchAll(cssBindingRE)) {
|
|
29
|
+
const start = match.index + match[0].length;
|
|
30
|
+
const end = lexBinding(css, start);
|
|
31
|
+
if (end !== null) {
|
|
32
|
+
yield trimQuotes(css.slice(start, end), start, false);
|
|
43
33
|
}
|
|
44
34
|
}
|
|
45
35
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
var LexerState;
|
|
37
|
+
(function (LexerState) {
|
|
38
|
+
LexerState[LexerState["inParens"] = 0] = "inParens";
|
|
39
|
+
LexerState[LexerState["inSingleQuoteString"] = 1] = "inSingleQuoteString";
|
|
40
|
+
LexerState[LexerState["inDoubleQuoteString"] = 2] = "inDoubleQuoteString";
|
|
41
|
+
})(LexerState || (LexerState = {}));
|
|
42
|
+
// https://github.com/vuejs/core/blob/c0606e91798c8dca4f33d101e1dd836d672592c1/packages/compiler-sfc/src/style/cssVars.ts#L93
|
|
43
|
+
function lexBinding(content, start) {
|
|
44
|
+
let state = LexerState.inParens;
|
|
45
|
+
let parenDepth = 0;
|
|
46
|
+
for (let i = start; i < content.length; i++) {
|
|
47
|
+
const char = content.charAt(i);
|
|
48
|
+
switch (state) {
|
|
49
|
+
case LexerState.inParens:
|
|
50
|
+
if (char === `'`) {
|
|
51
|
+
state = LexerState.inSingleQuoteString;
|
|
52
|
+
}
|
|
53
|
+
else if (char === `"`) {
|
|
54
|
+
state = LexerState.inDoubleQuoteString;
|
|
55
|
+
}
|
|
56
|
+
else if (char === `(`) {
|
|
57
|
+
parenDepth++;
|
|
58
|
+
}
|
|
59
|
+
else if (char === `)`) {
|
|
60
|
+
if (parenDepth > 0) {
|
|
61
|
+
parenDepth--;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return i;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case LexerState.inSingleQuoteString:
|
|
69
|
+
if (char === `'`) {
|
|
70
|
+
state = LexerState.inParens;
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
case LexerState.inDoubleQuoteString:
|
|
74
|
+
if (char === `"`) {
|
|
75
|
+
state = LexerState.inParens;
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
53
78
|
}
|
|
54
79
|
}
|
|
80
|
+
return null;
|
|
55
81
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
82
|
+
function* parseCssClassNames(css) {
|
|
83
|
+
css = fillBlank(css, commentRE, fragmentRE);
|
|
84
|
+
for (const match of css.matchAll(cssClassNameRE)) {
|
|
85
|
+
yield { text: match[0], offset: match.index };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function fillBlank(css, ...patterns) {
|
|
89
|
+
for (const pattern of patterns) {
|
|
90
|
+
css = css.replace(pattern, match => ' '.repeat(match.length));
|
|
59
91
|
}
|
|
60
92
|
return css;
|
|
61
93
|
}
|
|
94
|
+
function trimQuotes(text, offset, trim = true) {
|
|
95
|
+
let start = 0;
|
|
96
|
+
let end = text.length;
|
|
97
|
+
if (trim || text.includes('"') || text.includes("'")) {
|
|
98
|
+
while (start < text.length && !text[start]?.trim()) {
|
|
99
|
+
start++;
|
|
100
|
+
}
|
|
101
|
+
while (end >= 0 && !text[end - 1]?.trim()) {
|
|
102
|
+
end--;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (text[start] === '"' && text[end - 1] === '"'
|
|
106
|
+
|| text[start] === "'" && text[end - 1] === "'") {
|
|
107
|
+
start++;
|
|
108
|
+
end--;
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
text: text.slice(start, end),
|
|
112
|
+
offset: offset + start,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
62
115
|
//# sourceMappingURL=vue-style-css.js.map
|
|
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
37
37
|
const compile_1 = require("../template/compile");
|
|
38
|
-
const
|
|
38
|
+
const shouldAddSuffixRE = /(?<=<[^>/]+)$/;
|
|
39
39
|
const plugin = () => {
|
|
40
40
|
return {
|
|
41
41
|
version: 2.2,
|
|
@@ -43,7 +43,7 @@ const plugin = () => {
|
|
|
43
43
|
if (lang === 'html' || lang === 'md') {
|
|
44
44
|
let addedSuffix = false;
|
|
45
45
|
// #4583
|
|
46
|
-
if (
|
|
46
|
+
if (shouldAddSuffixRE.test(template)) {
|
|
47
47
|
template += '>';
|
|
48
48
|
addedSuffix = true;
|
|
49
49
|
}
|
|
@@ -63,7 +63,7 @@ const plugin = () => {
|
|
|
63
63
|
// @ts-expect-error
|
|
64
64
|
if (oldResult.__addedSuffix) {
|
|
65
65
|
const originalTemplate = newSource.slice(0, -1); // remove added '>'
|
|
66
|
-
if (!
|
|
66
|
+
if (!shouldAddSuffixRE.test(originalTemplate)) {
|
|
67
67
|
return undefined;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -34,14 +34,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
37
|
+
const codeFeatures_1 = require("../codegen/codeFeatures");
|
|
37
38
|
const forEachTemplateNode_1 = require("../utils/forEachTemplateNode");
|
|
38
39
|
const shared_1 = require("../utils/shared");
|
|
39
|
-
const shared_2 = require("./shared");
|
|
40
|
-
const codeFeatures = {
|
|
41
|
-
...shared_2.allCodeFeatures,
|
|
42
|
-
format: false,
|
|
43
|
-
structure: false,
|
|
44
|
-
};
|
|
45
40
|
const plugin = () => {
|
|
46
41
|
return {
|
|
47
42
|
version: 2.2,
|
|
@@ -69,7 +64,7 @@ function* generate(templateAst) {
|
|
|
69
64
|
&& prop.value) {
|
|
70
65
|
yield `x { `;
|
|
71
66
|
const [content, offset] = (0, shared_1.normalizeAttributeValue)(prop.value);
|
|
72
|
-
yield [content, 'template', offset, codeFeatures];
|
|
67
|
+
yield [content, 'template', offset, codeFeatures_1.codeFeatures.all];
|
|
73
68
|
yield ` }\n`;
|
|
74
69
|
}
|
|
75
70
|
}
|