@vue/language-core 1.9.0-alpha.3 → 2.0.1
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 +13 -0
- package/{out/index.js → index.js} +12 -14
- package/lib/generators/script.d.ts +13 -0
- package/lib/generators/script.js +1060 -0
- package/lib/generators/template.d.ts +9 -0
- package/lib/generators/template.js +1567 -0
- package/lib/generators/utils.d.ts +6 -0
- package/lib/generators/utils.js +58 -0
- package/lib/languageModule.d.ts +5 -0
- package/lib/languageModule.js +114 -0
- package/{out → lib}/parsers/scriptRanges.d.ts +2 -3
- package/{out → lib}/parsers/scriptRanges.js +11 -6
- package/{out → lib}/parsers/scriptSetupRanges.d.ts +17 -9
- package/{out → lib}/parsers/scriptSetupRanges.js +42 -35
- package/lib/plugins/file-html.d.ts +3 -0
- package/{out → lib}/plugins/file-html.js +1 -1
- package/lib/plugins/file-md.d.ts +3 -0
- package/{out → lib}/plugins/file-md.js +8 -8
- package/lib/plugins/file-vue.d.ts +3 -0
- package/{out → lib}/plugins/file-vue.js +9 -2
- package/lib/plugins/vue-sfc-customblocks.d.ts +3 -0
- package/lib/plugins/vue-sfc-customblocks.js +28 -0
- package/lib/plugins/vue-sfc-scripts.d.ts +3 -0
- package/lib/plugins/vue-sfc-scripts.js +36 -0
- package/lib/plugins/vue-sfc-styles.d.ts +3 -0
- package/lib/plugins/vue-sfc-styles.js +28 -0
- package/lib/plugins/vue-sfc-template.d.ts +3 -0
- package/lib/plugins/vue-sfc-template.js +29 -0
- package/lib/plugins/vue-template-html.d.ts +3 -0
- package/{out → lib}/plugins/vue-template-html.js +12 -12
- package/{out → lib}/plugins/vue-tsx.d.ts +25 -18
- package/lib/plugins/vue-tsx.js +212 -0
- package/{out → lib}/plugins.d.ts +19 -7
- package/{out → lib}/plugins.js +24 -18
- package/{out → lib}/types.d.ts +26 -9
- package/lib/types.js +5 -0
- package/{out → lib}/utils/parseCssClassNames.d.ts +0 -1
- package/{out → lib}/utils/parseCssVars.d.ts +0 -1
- package/{out → lib}/utils/parseSfc.d.ts +0 -1
- package/{out → lib}/utils/parseSfc.js +4 -18
- package/{out → lib}/utils/shared.d.ts +0 -1
- package/lib/utils/transform.d.ts +8 -0
- package/{out → lib}/utils/transform.js +62 -62
- package/{out → lib}/utils/ts.d.ts +3 -4
- package/{out → lib}/utils/ts.js +0 -12
- package/lib/utils/vue2TemplateCompiler.d.ts +2 -0
- package/{out → lib}/utils/vue2TemplateCompiler.js +5 -2
- package/{out → lib}/virtualFile/computedFiles.d.ts +2 -3
- package/{out → lib}/virtualFile/computedFiles.js +55 -42
- package/lib/virtualFile/computedMappings.d.ts +4 -0
- package/{out → lib}/virtualFile/computedMappings.js +9 -12
- package/lib/virtualFile/computedSfc.d.ts +4 -0
- package/{out → lib}/virtualFile/computedSfc.js +3 -3
- package/{out → lib}/virtualFile/computedVueSfc.d.ts +2 -3
- package/lib/virtualFile/embeddedFile.d.ts +12 -0
- package/lib/virtualFile/embeddedFile.js +15 -0
- package/lib/virtualFile/vueFile.d.ts +25 -0
- package/{out → lib}/virtualFile/vueFile.js +11 -21
- package/package.json +8 -11
- package/out/generators/script.d.ts +0 -15
- package/out/generators/script.js +0 -887
- package/out/generators/template.d.ts +0 -21
- package/out/generators/template.js +0 -1506
- package/out/index.d.ts +0 -16
- package/out/languageModule.d.ts +0 -10
- package/out/languageModule.js +0 -99
- package/out/plugins/file-html.d.ts +0 -4
- package/out/plugins/file-md.d.ts +0 -4
- package/out/plugins/file-vue.d.ts +0 -4
- package/out/plugins/vue-sfc-customblocks.d.ts +0 -4
- package/out/plugins/vue-sfc-customblocks.js +0 -33
- package/out/plugins/vue-sfc-scripts.d.ts +0 -4
- package/out/plugins/vue-sfc-scripts.js +0 -42
- package/out/plugins/vue-sfc-styles.d.ts +0 -4
- package/out/plugins/vue-sfc-styles.js +0 -33
- package/out/plugins/vue-sfc-template.d.ts +0 -4
- package/out/plugins/vue-sfc-template.js +0 -29
- package/out/plugins/vue-template-html.d.ts +0 -4
- package/out/plugins/vue-tsx.js +0 -159
- package/out/types.js +0 -3
- package/out/utils/globalTypes.d.ts +0 -4
- package/out/utils/globalTypes.js +0 -135
- package/out/utils/transform.d.ts +0 -9
- package/out/utils/vue2TemplateCompiler.d.ts +0 -3
- package/out/virtualFile/computedMappings.d.ts +0 -6
- package/out/virtualFile/computedSfc.d.ts +0 -5
- package/out/virtualFile/embeddedFile.d.ts +0 -13
- package/out/virtualFile/embeddedFile.js +0 -16
- package/out/virtualFile/vueFile.d.ts +0 -28
- /package/{out → lib}/utils/parseCssClassNames.js +0 -0
- /package/{out → lib}/utils/parseCssVars.js +0 -0
- /package/{out → lib}/utils/shared.js +0 -0
- /package/{out → lib}/virtualFile/computedVueSfc.js +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.computedFiles = void 0;
|
|
4
|
-
const
|
|
5
|
-
const muggle = require("muggle-string");
|
|
6
|
-
const embeddedFile_1 = require("./embeddedFile");
|
|
4
|
+
const language_core_1 = require("@volar/language-core");
|
|
7
5
|
const computeds_1 = require("computeds");
|
|
6
|
+
const embeddedFile_1 = require("./embeddedFile");
|
|
8
7
|
function computedFiles(plugins, fileName, sfc, codegenStack) {
|
|
9
8
|
const nameToBlock = (0, computeds_1.computed)(() => {
|
|
10
9
|
const blocks = {};
|
|
@@ -25,10 +24,10 @@ function computedFiles(plugins, fileName, sfc, codegenStack) {
|
|
|
25
24
|
}
|
|
26
25
|
return blocks;
|
|
27
26
|
});
|
|
28
|
-
const pluginsResult = plugins.map(plugin =>
|
|
27
|
+
const pluginsResult = plugins.map(plugin => computedPluginFiles(plugins, plugin, fileName, sfc, nameToBlock, codegenStack));
|
|
29
28
|
const flatResult = (0, computeds_1.computed)(() => pluginsResult.map(r => r()).flat());
|
|
30
29
|
const structuredResult = (0, computeds_1.computed)(() => {
|
|
31
|
-
const
|
|
30
|
+
const embeddedCodes = [];
|
|
32
31
|
let remain = [...flatResult()];
|
|
33
32
|
while (remain.length) {
|
|
34
33
|
const beforeLength = remain.length;
|
|
@@ -38,50 +37,57 @@ function computedFiles(plugins, fileName, sfc, codegenStack) {
|
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
for (const { file, snapshot, mappings, codegenStacks } of remain) {
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
embeddedCodes.push({
|
|
41
|
+
id: file.id,
|
|
42
|
+
languageId: (0, language_core_1.resolveCommonLanguageId)(`/dummy.${file.lang}`),
|
|
43
|
+
linkedCodeMappings: file.linkedCodeMappings,
|
|
43
44
|
snapshot,
|
|
44
45
|
mappings,
|
|
45
46
|
codegenStacks,
|
|
46
|
-
|
|
47
|
+
embeddedCodes: [],
|
|
47
48
|
});
|
|
48
|
-
console.error('Unable to resolve embedded: ' + file.
|
|
49
|
+
console.error('Unable to resolve embedded: ' + file.parentCodeId + ' -> ' + file.id);
|
|
49
50
|
}
|
|
50
|
-
return
|
|
51
|
+
return embeddedCodes;
|
|
51
52
|
function consumeRemain() {
|
|
52
53
|
for (let i = remain.length - 1; i >= 0; i--) {
|
|
53
54
|
const { file, snapshot, mappings, codegenStacks } = remain[i];
|
|
54
|
-
if (!file.
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
if (!file.parentCodeId) {
|
|
56
|
+
embeddedCodes.push({
|
|
57
|
+
id: file.id,
|
|
58
|
+
languageId: (0, language_core_1.resolveCommonLanguageId)(`/dummy.${file.lang}`),
|
|
59
|
+
linkedCodeMappings: file.linkedCodeMappings,
|
|
57
60
|
snapshot,
|
|
58
61
|
mappings,
|
|
59
62
|
codegenStacks,
|
|
60
|
-
|
|
63
|
+
embeddedCodes: [],
|
|
61
64
|
});
|
|
62
65
|
remain.splice(i, 1);
|
|
63
66
|
}
|
|
64
67
|
else {
|
|
65
|
-
const parent = findParentStructure(file.
|
|
68
|
+
const parent = findParentStructure(file.parentCodeId, embeddedCodes);
|
|
66
69
|
if (parent) {
|
|
67
|
-
parent.
|
|
68
|
-
|
|
70
|
+
parent.embeddedCodes ??= [];
|
|
71
|
+
parent.embeddedCodes.push({
|
|
72
|
+
id: file.id,
|
|
73
|
+
languageId: (0, language_core_1.resolveCommonLanguageId)(`/dummy.${file.lang}`),
|
|
74
|
+
linkedCodeMappings: file.linkedCodeMappings,
|
|
69
75
|
snapshot,
|
|
70
76
|
mappings,
|
|
71
77
|
codegenStacks,
|
|
72
|
-
|
|
78
|
+
embeddedCodes: [],
|
|
73
79
|
});
|
|
74
80
|
remain.splice(i, 1);
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
|
-
function findParentStructure(
|
|
85
|
+
function findParentStructure(id, current) {
|
|
80
86
|
for (const child of current) {
|
|
81
|
-
if (child.
|
|
87
|
+
if (child.id === id) {
|
|
82
88
|
return child;
|
|
83
89
|
}
|
|
84
|
-
let parent = findParentStructure(
|
|
90
|
+
let parent = findParentStructure(id, child.embeddedCodes ?? []);
|
|
85
91
|
if (parent) {
|
|
86
92
|
return parent;
|
|
87
93
|
}
|
|
@@ -91,36 +97,36 @@ function computedFiles(plugins, fileName, sfc, codegenStack) {
|
|
|
91
97
|
return structuredResult;
|
|
92
98
|
}
|
|
93
99
|
exports.computedFiles = computedFiles;
|
|
94
|
-
function
|
|
100
|
+
function computedPluginFiles(plugins, plugin, fileName, sfc, nameToBlock, codegenStack) {
|
|
95
101
|
const embeddedFiles = {};
|
|
96
102
|
const files = (0, computeds_1.computed)(() => {
|
|
97
103
|
try {
|
|
98
|
-
if (!plugin.
|
|
104
|
+
if (!plugin.getEmbeddedCodes) {
|
|
99
105
|
return Object.values(embeddedFiles);
|
|
100
106
|
}
|
|
101
|
-
const
|
|
102
|
-
for (const
|
|
103
|
-
if (!
|
|
104
|
-
delete embeddedFiles[
|
|
107
|
+
const fileInfos = plugin.getEmbeddedCodes(fileName, sfc);
|
|
108
|
+
for (const oldId of Object.keys(embeddedFiles)) {
|
|
109
|
+
if (!fileInfos.some(file => file.id === oldId)) {
|
|
110
|
+
delete embeddedFiles[oldId];
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
|
-
for (const
|
|
108
|
-
if (!embeddedFiles[
|
|
109
|
-
embeddedFiles[
|
|
110
|
-
const [content, stacks] = codegenStack ?
|
|
111
|
-
const file = new embeddedFile_1.
|
|
113
|
+
for (const fileInfo of fileInfos) {
|
|
114
|
+
if (!embeddedFiles[fileInfo.id]) {
|
|
115
|
+
embeddedFiles[fileInfo.id] = (0, computeds_1.computed)(() => {
|
|
116
|
+
const [content, stacks] = codegenStack ? (0, language_core_1.track)([]) : [[], []];
|
|
117
|
+
const file = new embeddedFile_1.VueEmbeddedCode(fileInfo.id, fileInfo.lang, content, stacks);
|
|
112
118
|
for (const plugin of plugins) {
|
|
113
|
-
if (!plugin.
|
|
119
|
+
if (!plugin.resolveEmbeddedCode) {
|
|
114
120
|
continue;
|
|
115
121
|
}
|
|
116
122
|
try {
|
|
117
|
-
plugin.
|
|
123
|
+
plugin.resolveEmbeddedCode(fileName, sfc, file);
|
|
118
124
|
}
|
|
119
125
|
catch (e) {
|
|
120
126
|
console.error(e);
|
|
121
127
|
}
|
|
122
128
|
}
|
|
123
|
-
const newText = (0,
|
|
129
|
+
const newText = (0, language_core_1.toString)(file.content);
|
|
124
130
|
const changeRanges = new Map();
|
|
125
131
|
const snapshot = {
|
|
126
132
|
getText: (start, end) => newText.slice(start, end),
|
|
@@ -153,27 +159,34 @@ function compiledPluginFiles(plugins, plugin, fileName, sfc, nameToBlock, codege
|
|
|
153
159
|
return (0, computeds_1.computed)(() => {
|
|
154
160
|
return files().map(_file => {
|
|
155
161
|
const { file, snapshot } = _file();
|
|
156
|
-
const mappings = (0,
|
|
162
|
+
const mappings = (0, language_core_1.buildMappings)(file.content);
|
|
163
|
+
let lastValidMapping;
|
|
157
164
|
for (const mapping of mappings) {
|
|
158
165
|
if (mapping.source !== undefined) {
|
|
159
166
|
const block = nameToBlock()[mapping.source];
|
|
160
167
|
if (block) {
|
|
161
|
-
mapping.
|
|
162
|
-
mapping.sourceRange[0] + block.startTagEnd,
|
|
163
|
-
mapping.sourceRange[1] + block.startTagEnd,
|
|
164
|
-
];
|
|
168
|
+
mapping.sourceOffsets = mapping.sourceOffsets.map(offset => offset + block.startTagEnd);
|
|
165
169
|
}
|
|
166
170
|
else {
|
|
167
171
|
// ignore
|
|
168
172
|
}
|
|
169
173
|
mapping.source = undefined;
|
|
170
174
|
}
|
|
175
|
+
if (mapping.data.__combineLastMappping) {
|
|
176
|
+
lastValidMapping.sourceOffsets.push(...mapping.sourceOffsets);
|
|
177
|
+
lastValidMapping.generatedOffsets.push(...mapping.generatedOffsets);
|
|
178
|
+
lastValidMapping.lengths.push(...mapping.lengths);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
lastValidMapping = mapping;
|
|
183
|
+
}
|
|
171
184
|
}
|
|
172
185
|
return {
|
|
173
186
|
file,
|
|
174
187
|
snapshot,
|
|
175
|
-
mappings,
|
|
176
|
-
codegenStacks: (0,
|
|
188
|
+
mappings: mappings.filter(mapping => !mapping.data.__combineLastMappping),
|
|
189
|
+
codegenStacks: (0, language_core_1.buildStacks)(file.content, file.contentStacks),
|
|
177
190
|
};
|
|
178
191
|
});
|
|
179
192
|
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Mapping } from '@volar/language-core';
|
|
2
|
+
import type * as ts from 'typescript';
|
|
3
|
+
import type { Sfc, VueCodeInformation } from '../types';
|
|
4
|
+
export declare function computedMappings(snapshot: () => ts.IScriptSnapshot, sfc: Sfc): () => Mapping<VueCodeInformation>[];
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.computedMappings = void 0;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
|
-
const muggle = require("muggle-string");
|
|
6
5
|
const computeds_1 = require("computeds");
|
|
6
|
+
const utils_1 = require("../generators/utils");
|
|
7
7
|
function computedMappings(snapshot, sfc) {
|
|
8
8
|
return (0, computeds_1.computed)(() => {
|
|
9
|
-
const str = [[snapshot().getText(0, snapshot().getLength()), undefined, 0,
|
|
9
|
+
const str = [[snapshot().getText(0, snapshot().getLength()), undefined, 0, (0, utils_1.enableAllFeatures)({})]];
|
|
10
10
|
for (const block of [
|
|
11
11
|
sfc.script,
|
|
12
12
|
sfc.scriptSetup,
|
|
@@ -15,21 +15,18 @@ function computedMappings(snapshot, sfc) {
|
|
|
15
15
|
...sfc.customBlocks,
|
|
16
16
|
]) {
|
|
17
17
|
if (block) {
|
|
18
|
-
|
|
19
|
-
block.content,
|
|
20
|
-
undefined,
|
|
21
|
-
block.startTagEnd,
|
|
22
|
-
{},
|
|
23
|
-
]);
|
|
18
|
+
(0, language_core_1.replaceSourceRange)(str, undefined, block.startTagEnd, block.endTagStart, '\n\n');
|
|
24
19
|
}
|
|
25
20
|
}
|
|
26
|
-
return str
|
|
21
|
+
return str
|
|
22
|
+
.filter(s => typeof s !== 'string')
|
|
23
|
+
.map((m) => {
|
|
27
24
|
const text = m[0];
|
|
28
25
|
const start = m[2];
|
|
29
|
-
const end = start + text.length;
|
|
30
26
|
return {
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
sourceOffsets: [start],
|
|
28
|
+
generatedOffsets: [start],
|
|
29
|
+
lengths: [text.length],
|
|
33
30
|
data: m[3],
|
|
34
31
|
};
|
|
35
32
|
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SFCParseResult } from '@vue/compiler-sfc';
|
|
2
|
+
import type * as ts from 'typescript';
|
|
3
|
+
import type { Sfc, VueLanguagePlugin } from '../types';
|
|
4
|
+
export declare function computedSfc(ts: typeof import('typescript'), plugins: ReturnType<VueLanguagePlugin>[], fileName: string, snapshot: () => ts.IScriptSnapshot, parsed: () => SFCParseResult | undefined): Sfc;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.computedSfc = void 0;
|
|
4
|
+
const computeds_1 = require("computeds");
|
|
4
5
|
const parseCssClassNames_1 = require("../utils/parseCssClassNames");
|
|
5
6
|
const parseCssVars_1 = require("../utils/parseCssVars");
|
|
6
|
-
const computeds_1 = require("computeds");
|
|
7
7
|
function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
8
8
|
const untrackedSnapshot = () => {
|
|
9
9
|
(0, computeds_1.pauseTracking)();
|
|
@@ -25,7 +25,7 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
|
25
25
|
const _src = src();
|
|
26
26
|
return _src ? untrackedSnapshot().getText(0, base.startTagEnd).lastIndexOf(_src) - base.startTagEnd : -1;
|
|
27
27
|
});
|
|
28
|
-
const ast = (0, computeds_1.computed)(() => ts.createSourceFile(fileName + '.' + base.lang, base.content,
|
|
28
|
+
const ast = (0, computeds_1.computed)(() => ts.createSourceFile(fileName + '.' + base.lang, base.content, 99));
|
|
29
29
|
return mergeObject(base, {
|
|
30
30
|
get src() { return src(); },
|
|
31
31
|
get srcOffset() { return srcOffset(); },
|
|
@@ -41,7 +41,7 @@ function computedSfc(ts, plugins, fileName, snapshot, parsed) {
|
|
|
41
41
|
const _generic = generic();
|
|
42
42
|
return _generic !== undefined ? untrackedSnapshot().getText(0, base.startTagEnd).lastIndexOf(_generic) - base.startTagEnd : -1;
|
|
43
43
|
});
|
|
44
|
-
const ast = (0, computeds_1.computed)(() => ts.createSourceFile(fileName + '.' + base.lang, base.content,
|
|
44
|
+
const ast = (0, computeds_1.computed)(() => ts.createSourceFile(fileName + '.' + base.lang, base.content, 99));
|
|
45
45
|
return mergeObject(base, {
|
|
46
46
|
get generic() { return generic(); },
|
|
47
47
|
get genericOffset() { return genericOffset(); },
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { SFCParseResult } from '@vue/compiler-sfc';
|
|
2
|
-
import type * as ts from 'typescript
|
|
3
|
-
import { VueLanguagePlugin } from '../types';
|
|
2
|
+
import type * as ts from 'typescript';
|
|
3
|
+
import type { VueLanguagePlugin } from '../types';
|
|
4
4
|
export declare function computedVueSfc(plugins: ReturnType<VueLanguagePlugin>[], fileName: string, snapshot: () => ts.IScriptSnapshot): () => SFCParseResult | undefined;
|
|
5
|
-
//# sourceMappingURL=computedVueSfc.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Mapping, StackNode } from '@volar/language-core';
|
|
2
|
+
import type { Code } from '../types';
|
|
3
|
+
export declare class VueEmbeddedCode {
|
|
4
|
+
id: string;
|
|
5
|
+
lang: string;
|
|
6
|
+
content: Code[];
|
|
7
|
+
contentStacks: StackNode[];
|
|
8
|
+
parentCodeId?: string;
|
|
9
|
+
linkedCodeMappings: Mapping[];
|
|
10
|
+
embeddedCodes: VueEmbeddedCode[];
|
|
11
|
+
constructor(id: string, lang: string, content: Code[], contentStacks: StackNode[]);
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VueEmbeddedCode = void 0;
|
|
4
|
+
class VueEmbeddedCode {
|
|
5
|
+
constructor(id, lang, content, contentStacks) {
|
|
6
|
+
this.id = id;
|
|
7
|
+
this.lang = lang;
|
|
8
|
+
this.content = content;
|
|
9
|
+
this.contentStacks = contentStacks;
|
|
10
|
+
this.linkedCodeMappings = [];
|
|
11
|
+
this.embeddedCodes = [];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.VueEmbeddedCode = VueEmbeddedCode;
|
|
15
|
+
//# sourceMappingURL=embeddedFile.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Stack, VirtualCode } from '@volar/language-core';
|
|
2
|
+
import { Signal } from 'computeds';
|
|
3
|
+
import type * as ts from 'typescript';
|
|
4
|
+
import type { VueCompilerOptions, VueLanguagePlugin } from '../types';
|
|
5
|
+
export declare class VueGeneratedCode implements VirtualCode {
|
|
6
|
+
fileName: string;
|
|
7
|
+
languageId: string;
|
|
8
|
+
initSnapshot: ts.IScriptSnapshot;
|
|
9
|
+
vueCompilerOptions: VueCompilerOptions;
|
|
10
|
+
plugins: ReturnType<VueLanguagePlugin>[];
|
|
11
|
+
ts: typeof import('typescript');
|
|
12
|
+
codegenStack: boolean;
|
|
13
|
+
id: string;
|
|
14
|
+
_snapshot: Signal<ts.IScriptSnapshot>;
|
|
15
|
+
getVueSfc: () => import("@vue/compiler-sfc").SFCParseResult | undefined;
|
|
16
|
+
sfc: import("../types").Sfc;
|
|
17
|
+
getMappings: () => import("@volar/language-core").Mapping<import("../types").VueCodeInformation>[];
|
|
18
|
+
getEmbeddedCodes: () => VirtualCode[];
|
|
19
|
+
codegenStacks: Stack[];
|
|
20
|
+
get embeddedCodes(): VirtualCode[];
|
|
21
|
+
get snapshot(): ts.IScriptSnapshot;
|
|
22
|
+
get mappings(): import("@volar/language-core").Mapping<import("../types").VueCodeInformation>[];
|
|
23
|
+
constructor(fileName: string, languageId: string, initSnapshot: ts.IScriptSnapshot, vueCompilerOptions: VueCompilerOptions, plugins: ReturnType<VueLanguagePlugin>[], ts: typeof import('typescript'), codegenStack: boolean);
|
|
24
|
+
update(newSnapshot: ts.IScriptSnapshot): void;
|
|
25
|
+
}
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
3
|
+
exports.VueGeneratedCode = void 0;
|
|
4
|
+
const computeds_1 = require("computeds");
|
|
5
5
|
const computedFiles_1 = require("./computedFiles");
|
|
6
6
|
const computedMappings_1 = require("./computedMappings");
|
|
7
7
|
const computedSfc_1 = require("./computedSfc");
|
|
8
8
|
const computedVueSfc_1 = require("./computedVueSfc");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get embeddedFiles() {
|
|
13
|
-
return this.getEmbeddedFiles();
|
|
14
|
-
}
|
|
15
|
-
get mainScriptName() {
|
|
16
|
-
let res = '';
|
|
17
|
-
(0, language_core_1.forEachEmbeddedFile)(this, file => {
|
|
18
|
-
if (file.kind === language_core_1.FileKind.TypeScriptHostFile && file.fileName.replace(this.fileName, '').match(jsxReg)) {
|
|
19
|
-
res = file.fileName;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
return res;
|
|
9
|
+
class VueGeneratedCode {
|
|
10
|
+
get embeddedCodes() {
|
|
11
|
+
return this.getEmbeddedCodes();
|
|
23
12
|
}
|
|
24
13
|
get snapshot() {
|
|
25
14
|
return this._snapshot();
|
|
@@ -27,21 +16,22 @@ class VueFile {
|
|
|
27
16
|
get mappings() {
|
|
28
17
|
return this.getMappings();
|
|
29
18
|
}
|
|
30
|
-
constructor(fileName, initSnapshot, vueCompilerOptions, plugins, ts, codegenStack) {
|
|
19
|
+
constructor(fileName, languageId, initSnapshot, vueCompilerOptions, plugins, ts, codegenStack) {
|
|
31
20
|
this.fileName = fileName;
|
|
21
|
+
this.languageId = languageId;
|
|
32
22
|
this.initSnapshot = initSnapshot;
|
|
33
23
|
this.vueCompilerOptions = vueCompilerOptions;
|
|
34
24
|
this.plugins = plugins;
|
|
35
25
|
this.ts = ts;
|
|
36
26
|
this.codegenStack = codegenStack;
|
|
27
|
+
// sources
|
|
28
|
+
this.id = 'main';
|
|
37
29
|
// computeds
|
|
38
30
|
this.getVueSfc = (0, computedVueSfc_1.computedVueSfc)(this.plugins, this.fileName, () => this._snapshot());
|
|
39
31
|
this.sfc = (0, computedSfc_1.computedSfc)(this.ts, this.plugins, this.fileName, () => this._snapshot(), this.getVueSfc);
|
|
40
32
|
this.getMappings = (0, computedMappings_1.computedMappings)(() => this._snapshot(), this.sfc);
|
|
41
|
-
this.
|
|
33
|
+
this.getEmbeddedCodes = (0, computedFiles_1.computedFiles)(this.plugins, this.fileName, this.sfc, this.codegenStack);
|
|
42
34
|
// others
|
|
43
|
-
this.capabilities = language_core_1.FileCapabilities.full;
|
|
44
|
-
this.kind = language_core_1.FileKind.TextFile;
|
|
45
35
|
this.codegenStacks = [];
|
|
46
36
|
this._snapshot = (0, computeds_1.signal)(initSnapshot);
|
|
47
37
|
}
|
|
@@ -49,5 +39,5 @@ class VueFile {
|
|
|
49
39
|
this._snapshot.set(newSnapshot);
|
|
50
40
|
}
|
|
51
41
|
}
|
|
52
|
-
exports.
|
|
42
|
+
exports.VueGeneratedCode = VueGeneratedCode;
|
|
53
43
|
//# sourceMappingURL=vueFile.js.map
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "
|
|
4
|
-
"main": "out/index.js",
|
|
3
|
+
"version": "2.0.1",
|
|
5
4
|
"license": "MIT",
|
|
6
5
|
"files": [
|
|
7
|
-
"
|
|
8
|
-
"
|
|
6
|
+
"**/*.js",
|
|
7
|
+
"**/*.d.ts"
|
|
9
8
|
],
|
|
10
9
|
"repository": {
|
|
11
10
|
"type": "git",
|
|
@@ -13,13 +12,11 @@
|
|
|
13
12
|
"directory": "packages/language-core"
|
|
14
13
|
},
|
|
15
14
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "~1.
|
|
17
|
-
"@
|
|
18
|
-
"@vue/
|
|
19
|
-
"@vue/shared": "^3.3.0",
|
|
15
|
+
"@volar/language-core": "~2.1.0",
|
|
16
|
+
"@vue/compiler-dom": "^3.4.0",
|
|
17
|
+
"@vue/shared": "^3.4.0",
|
|
20
18
|
"computeds": "^0.0.1",
|
|
21
19
|
"minimatch": "^9.0.3",
|
|
22
|
-
"muggle-string": "^0.3.1",
|
|
23
20
|
"path-browserify": "^1.0.1",
|
|
24
21
|
"vue-template-compiler": "^2.7.14"
|
|
25
22
|
},
|
|
@@ -27,7 +24,7 @@
|
|
|
27
24
|
"@types/minimatch": "^5.1.2",
|
|
28
25
|
"@types/node": "latest",
|
|
29
26
|
"@types/path-browserify": "^1.0.1",
|
|
30
|
-
"@vue/compiler-sfc": "^3.
|
|
27
|
+
"@vue/compiler-sfc": "^3.4.0"
|
|
31
28
|
},
|
|
32
29
|
"peerDependencies": {
|
|
33
30
|
"typescript": "*"
|
|
@@ -37,5 +34,5 @@
|
|
|
37
34
|
"optional": true
|
|
38
35
|
}
|
|
39
36
|
},
|
|
40
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "adedfd0983c910370d080e955702cca7d2275420"
|
|
41
38
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FileRangeCapabilities, MirrorBehaviorCapabilities } from '@volar/language-core';
|
|
2
|
-
import * as SourceMaps from '@volar/source-map';
|
|
3
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
4
|
-
import type * as templateGen from '../generators/template';
|
|
5
|
-
import type { ScriptRanges } from '../parsers/scriptRanges';
|
|
6
|
-
import type { ScriptSetupRanges } from '../parsers/scriptSetupRanges';
|
|
7
|
-
import type { VueCompilerOptions } from '../types';
|
|
8
|
-
import { Sfc } from '../types';
|
|
9
|
-
export declare function generate(ts: typeof import('typescript/lib/tsserverlibrary'), fileName: string, script: Sfc['script'], scriptSetup: Sfc['scriptSetup'], styles: Sfc['styles'], // TODO: computed it
|
|
10
|
-
lang: string, scriptRanges: ScriptRanges | undefined, scriptSetupRanges: ScriptSetupRanges | undefined, htmlGen: ReturnType<typeof templateGen['generate']> | undefined, compilerOptions: ts.CompilerOptions, vueCompilerOptions: VueCompilerOptions, codegenStack: boolean): {
|
|
11
|
-
codes: SourceMaps.Segment<FileRangeCapabilities>[];
|
|
12
|
-
codeStacks: SourceMaps.StackNode[];
|
|
13
|
-
mirrorBehaviorMappings: SourceMaps.Mapping<[MirrorBehaviorCapabilities, MirrorBehaviorCapabilities]>[];
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=script.d.ts.map
|