@volar/language-core 1.5.4 → 1.6.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/out/types.d.ts +2 -1
- package/out/virtualFiles.js +20 -21
- package/package.json +3 -3
package/out/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mapping } from '@volar/source-map';
|
|
1
|
+
import { Mapping, Stack } from '@volar/source-map';
|
|
2
2
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
3
|
export interface FileCapabilities {
|
|
4
4
|
diagnostic?: boolean;
|
|
@@ -49,6 +49,7 @@ export interface VirtualFile {
|
|
|
49
49
|
kind: FileKind;
|
|
50
50
|
capabilities: FileCapabilities;
|
|
51
51
|
mappings: Mapping<FileRangeCapabilities>[];
|
|
52
|
+
codegenStacks: Stack[];
|
|
52
53
|
mirrorBehaviorMappings?: Mapping<[MirrorBehaviorCapabilities, MirrorBehaviorCapabilities]>[];
|
|
53
54
|
embeddedFiles: VirtualFile[];
|
|
54
55
|
}
|
package/out/virtualFiles.js
CHANGED
|
@@ -6,7 +6,7 @@ const sourceMaps_1 = require("./sourceMaps");
|
|
|
6
6
|
function createVirtualFiles(languages) {
|
|
7
7
|
const sourceFiles = new Map();
|
|
8
8
|
const virtualFiles = new Map();
|
|
9
|
-
const
|
|
9
|
+
const virtualFileMaps = new WeakMap();
|
|
10
10
|
const virtualFileToMirrorMap = new WeakMap();
|
|
11
11
|
let sourceFilesDirty = true;
|
|
12
12
|
return {
|
|
@@ -53,19 +53,19 @@ function createVirtualFiles(languages) {
|
|
|
53
53
|
},
|
|
54
54
|
hasSource: (fileName) => sourceFiles.has(normalizePath(fileName)),
|
|
55
55
|
getMirrorMap: getMirrorMap,
|
|
56
|
-
getMaps:
|
|
56
|
+
getMaps: getMapsByVirtualFile,
|
|
57
57
|
hasVirtualFile(fileName) {
|
|
58
|
-
return !!
|
|
58
|
+
return !!getVirtualFileToSourceFileMap().get(normalizePath(fileName));
|
|
59
59
|
},
|
|
60
60
|
getVirtualFile(fileName) {
|
|
61
|
-
const sourceAndVirtual =
|
|
61
|
+
const sourceAndVirtual = getVirtualFileToSourceFileMap().get(normalizePath(fileName));
|
|
62
62
|
if (sourceAndVirtual) {
|
|
63
63
|
return [sourceAndVirtual.virtualFile, sourceAndVirtual.source];
|
|
64
64
|
}
|
|
65
65
|
return [undefined, undefined];
|
|
66
66
|
},
|
|
67
67
|
};
|
|
68
|
-
function
|
|
68
|
+
function getVirtualFileToSourceFileMap() {
|
|
69
69
|
if (sourceFilesDirty) {
|
|
70
70
|
sourceFilesDirty = false;
|
|
71
71
|
virtualFiles.clear();
|
|
@@ -77,26 +77,25 @@ function createVirtualFiles(languages) {
|
|
|
77
77
|
}
|
|
78
78
|
return virtualFiles;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
sourceMapsBySourceFileName = new Map();
|
|
84
|
-
virtualFileToSourceMapsMap.set(virtualFile.snapshot, sourceMapsBySourceFileName);
|
|
80
|
+
function getMapsByVirtualFile(virtualFile) {
|
|
81
|
+
if (!virtualFileMaps.has(virtualFile.snapshot)) {
|
|
82
|
+
virtualFileMaps.set(virtualFile.snapshot, new Map());
|
|
85
83
|
}
|
|
84
|
+
const map = virtualFileMaps.get(virtualFile.snapshot);
|
|
86
85
|
const sources = new Set();
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
]);
|
|
86
|
+
const result = [];
|
|
87
|
+
for (const mapping of virtualFile.mappings) {
|
|
88
|
+
if (sources.has(mapping.source))
|
|
89
|
+
continue;
|
|
90
|
+
sources.add(mapping.source);
|
|
91
|
+
const sourceFileName = mapping.source ?? getVirtualFileToSourceFileMap().get(normalizePath(virtualFile.fileName)).source.fileName;
|
|
92
|
+
const sourceSnapshot = mapping.source ? sourceFiles.get(normalizePath(mapping.source)).snapshot : getVirtualFileToSourceFileMap().get(normalizePath(virtualFile.fileName)).source.snapshot;
|
|
93
|
+
if (!map.has(sourceSnapshot)) {
|
|
94
|
+
map.set(sourceSnapshot, [sourceFileName, new source_map_1.SourceMap(virtualFile.mappings.filter(mapping2 => mapping2.source === mapping.source))]);
|
|
97
95
|
}
|
|
96
|
+
result.push(map.get(sourceSnapshot));
|
|
98
97
|
}
|
|
99
|
-
return
|
|
98
|
+
return result;
|
|
100
99
|
}
|
|
101
100
|
function getMirrorMap(file) {
|
|
102
101
|
if (!virtualFileToMirrorMap.has(file.snapshot)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"directory": "packages/language-core"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/source-map": "1.
|
|
16
|
+
"@volar/source-map": "1.6.1"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "1e1e99f43ff39db5432a33c8013eda706e765001"
|
|
19
19
|
}
|