@vue/language-core 2.0.15 → 2.0.17
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/script/component.js +2 -2
- package/lib/codegen/script/globalTypes.js +3 -3
- package/lib/codegen/script/index.d.ts +3 -6
- package/lib/codegen/script/index.js +12 -15
- package/lib/codegen/script/internalComponent.js +1 -1
- package/lib/codegen/script/scriptSetup.js +25 -23
- package/lib/codegen/script/template.d.ts +1 -1
- package/lib/codegen/script/template.js +45 -36
- package/lib/codegen/template/context.d.ts +8 -3
- package/lib/codegen/template/context.js +42 -13
- package/lib/codegen/template/element.js +81 -49
- package/lib/codegen/template/elementChildren.js +2 -1
- package/lib/codegen/template/elementDirectives.js +1 -1
- package/lib/codegen/template/elementEvents.d.ts +2 -2
- package/lib/codegen/template/elementEvents.js +16 -7
- package/lib/codegen/template/elementProps.js +18 -14
- package/lib/codegen/template/index.d.ts +4 -46
- package/lib/codegen/template/index.js +36 -21
- package/lib/codegen/template/interpolation.d.ts +2 -2
- package/lib/codegen/template/interpolation.js +12 -46
- package/lib/codegen/template/slotOutlet.js +29 -30
- package/lib/languageModule.d.ts +1 -1
- package/lib/languageModule.js +4 -4
- package/lib/parsers/scriptRanges.d.ts +1 -0
- package/lib/parsers/scriptRanges.js +7 -0
- package/lib/parsers/scriptSetupRanges.d.ts +4 -0
- package/lib/parsers/scriptSetupRanges.js +24 -0
- package/lib/plugins/vue-template-inline-ts.js +1 -1
- package/lib/plugins/vue-tsx.d.ts +46 -40
- package/lib/plugins/vue-tsx.js +34 -28
- package/lib/plugins.d.ts +1 -1
- package/lib/types.d.ts +1 -15
- package/lib/utils/parseCssClassNames.js +1 -1
- package/lib/utils/ts.js +0 -1
- package/lib/virtualFile/computedFiles.js +34 -33
- package/lib/virtualFile/computedSfc.js +0 -3
- package/package.json +3 -3
|
@@ -24,7 +24,7 @@ function computedFiles(plugins, fileName, sfc) {
|
|
|
24
24
|
}
|
|
25
25
|
return blocks;
|
|
26
26
|
});
|
|
27
|
-
const pluginsResult = plugins.map(plugin =>
|
|
27
|
+
const pluginsResult = plugins.map(plugin => computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock));
|
|
28
28
|
const flatResult = (0, computeds_1.computed)(() => pluginsResult.map(r => r()).flat());
|
|
29
29
|
const structuredResult = (0, computeds_1.computed)(() => {
|
|
30
30
|
const embeddedCodes = [];
|
|
@@ -36,18 +36,18 @@ function computedFiles(plugins, fileName, sfc) {
|
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
for (const {
|
|
40
|
-
console.error('Unable to resolve embedded: ' +
|
|
39
|
+
for (const { code } of remain) {
|
|
40
|
+
console.error('Unable to resolve embedded: ' + code.parentCodeId + ' -> ' + code.id);
|
|
41
41
|
}
|
|
42
42
|
return embeddedCodes;
|
|
43
43
|
function consumeRemain() {
|
|
44
44
|
for (let i = remain.length - 1; i >= 0; i--) {
|
|
45
|
-
const {
|
|
46
|
-
if (!
|
|
45
|
+
const { code, snapshot, mappings } = remain[i];
|
|
46
|
+
if (!code.parentCodeId) {
|
|
47
47
|
embeddedCodes.push({
|
|
48
|
-
id:
|
|
49
|
-
languageId: resolveCommonLanguageId(
|
|
50
|
-
linkedCodeMappings:
|
|
48
|
+
id: code.id,
|
|
49
|
+
languageId: resolveCommonLanguageId(code.lang),
|
|
50
|
+
linkedCodeMappings: code.linkedCodeMappings,
|
|
51
51
|
snapshot,
|
|
52
52
|
mappings,
|
|
53
53
|
embeddedCodes: [],
|
|
@@ -55,13 +55,13 @@ function computedFiles(plugins, fileName, sfc) {
|
|
|
55
55
|
remain.splice(i, 1);
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
-
const parent = findParentStructure(
|
|
58
|
+
const parent = findParentStructure(code.parentCodeId, embeddedCodes);
|
|
59
59
|
if (parent) {
|
|
60
60
|
parent.embeddedCodes ??= [];
|
|
61
61
|
parent.embeddedCodes.push({
|
|
62
|
-
id:
|
|
63
|
-
languageId: resolveCommonLanguageId(
|
|
64
|
-
linkedCodeMappings:
|
|
62
|
+
id: code.id,
|
|
63
|
+
languageId: resolveCommonLanguageId(code.lang),
|
|
64
|
+
linkedCodeMappings: code.linkedCodeMappings,
|
|
65
65
|
snapshot,
|
|
66
66
|
mappings,
|
|
67
67
|
embeddedCodes: [],
|
|
@@ -86,36 +86,37 @@ function computedFiles(plugins, fileName, sfc) {
|
|
|
86
86
|
return structuredResult;
|
|
87
87
|
}
|
|
88
88
|
exports.computedFiles = computedFiles;
|
|
89
|
-
function
|
|
90
|
-
const
|
|
91
|
-
const
|
|
89
|
+
function computedPluginEmbeddedCodes(plugins, plugin, fileName, sfc, nameToBlock) {
|
|
90
|
+
const computeds = new Map();
|
|
91
|
+
const getComputedKey = (code) => code.id + '__' + code.lang;
|
|
92
|
+
const codes = (0, computeds_1.computed)(() => {
|
|
92
93
|
try {
|
|
93
94
|
if (!plugin.getEmbeddedCodes) {
|
|
94
|
-
return
|
|
95
|
+
return [...computeds.values()];
|
|
95
96
|
}
|
|
96
|
-
const
|
|
97
|
-
for (const oldId of
|
|
98
|
-
if (!
|
|
99
|
-
delete
|
|
97
|
+
const embeddedCodeInfos = plugin.getEmbeddedCodes(fileName, sfc);
|
|
98
|
+
for (const oldId of computeds.keys()) {
|
|
99
|
+
if (!embeddedCodeInfos.some(code => getComputedKey(code) === oldId)) {
|
|
100
|
+
computeds.delete(oldId);
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
|
-
for (const
|
|
103
|
-
if (!
|
|
104
|
-
|
|
103
|
+
for (const codeInfo of embeddedCodeInfos) {
|
|
104
|
+
if (!computeds.has(getComputedKey(codeInfo))) {
|
|
105
|
+
computeds.set(getComputedKey(codeInfo), (0, computeds_1.computed)(() => {
|
|
105
106
|
const content = [];
|
|
106
|
-
const
|
|
107
|
+
const code = new embeddedFile_1.VueEmbeddedCode(codeInfo.id, codeInfo.lang, content);
|
|
107
108
|
for (const plugin of plugins) {
|
|
108
109
|
if (!plugin.resolveEmbeddedCode) {
|
|
109
110
|
continue;
|
|
110
111
|
}
|
|
111
112
|
try {
|
|
112
|
-
plugin.resolveEmbeddedCode(fileName, sfc,
|
|
113
|
+
plugin.resolveEmbeddedCode(fileName, sfc, code);
|
|
113
114
|
}
|
|
114
115
|
catch (e) {
|
|
115
116
|
console.error(e);
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
|
-
const newText = (0, language_core_1.toString)(
|
|
119
|
+
const newText = (0, language_core_1.toString)(code.content);
|
|
119
120
|
const changeRanges = new Map();
|
|
120
121
|
const snapshot = {
|
|
121
122
|
getText: (start, end) => newText.slice(start, end),
|
|
@@ -133,22 +134,22 @@ function computedPluginFiles(plugins, plugin, fileName, sfc, nameToBlock) {
|
|
|
133
134
|
},
|
|
134
135
|
};
|
|
135
136
|
return {
|
|
136
|
-
|
|
137
|
+
code,
|
|
137
138
|
snapshot,
|
|
138
139
|
};
|
|
139
|
-
});
|
|
140
|
+
}));
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
catch (e) {
|
|
144
145
|
console.error(e);
|
|
145
146
|
}
|
|
146
|
-
return
|
|
147
|
+
return [...computeds.values()];
|
|
147
148
|
});
|
|
148
149
|
return (0, computeds_1.computed)(() => {
|
|
149
|
-
return
|
|
150
|
-
const {
|
|
151
|
-
const mappings = (0, language_core_1.buildMappings)(
|
|
150
|
+
return codes().map(_file => {
|
|
151
|
+
const { code, snapshot } = _file();
|
|
152
|
+
const mappings = (0, language_core_1.buildMappings)(code.content);
|
|
152
153
|
const newMappings = [];
|
|
153
154
|
let lastValidMapping;
|
|
154
155
|
for (let i = 0; i < mappings.length; i++) {
|
|
@@ -185,7 +186,7 @@ function computedPluginFiles(plugins, plugin, fileName, sfc, nameToBlock) {
|
|
|
185
186
|
newMappings.push(mapping);
|
|
186
187
|
}
|
|
187
188
|
return {
|
|
188
|
-
|
|
189
|
+
code,
|
|
189
190
|
snapshot,
|
|
190
191
|
mappings: newMappings,
|
|
191
192
|
};
|
|
@@ -95,9 +95,6 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
|
95
95
|
get scriptSetup() { return scriptSetup(); },
|
|
96
96
|
get styles() { return styles; },
|
|
97
97
|
get customBlocks() { return customBlocks; },
|
|
98
|
-
get templateAst() { return template()?.ast; },
|
|
99
|
-
get scriptAst() { return script()?.ast; },
|
|
100
|
-
get scriptSetupAst() { return scriptSetup()?.ast; },
|
|
101
98
|
};
|
|
102
99
|
function computedTemplateAst(base) {
|
|
103
100
|
let cache;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/language-core"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "2.2.
|
|
15
|
+
"@volar/language-core": "~2.2.2",
|
|
16
16
|
"@vue/compiler-dom": "^3.4.0",
|
|
17
17
|
"@vue/shared": "^3.4.0",
|
|
18
18
|
"computeds": "^0.0.1",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"optional": true
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "968039cbb07961f318b4bf122bfa8e3e4a824277"
|
|
38
38
|
}
|