@volar/language-core 1.0.24 → 1.1.0-alpha.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/languageContext.d.ts +1 -1
- package/out/languageContext.js +8 -7
- package/out/types.d.ts +3 -2
- package/out/virtualFiles.d.ts +1 -1
- package/out/virtualFiles.js +2 -2
- package/package.json +4 -4
package/out/languageContext.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare function createLanguageContext(host: LanguageServiceHost, languag
|
|
|
7
7
|
};
|
|
8
8
|
virtualFiles: {
|
|
9
9
|
allSources(): import("./virtualFiles").Source[];
|
|
10
|
-
updateSource(fileName: string, snapshot: ts.IScriptSnapshot): import("./types").VirtualFile | undefined;
|
|
10
|
+
updateSource(fileName: string, snapshot: ts.IScriptSnapshot, languageId: string | undefined): import("./types").VirtualFile | undefined;
|
|
11
11
|
deleteSource(fileName: string): void;
|
|
12
12
|
getSource(fileName: string): import("./virtualFiles").Source | undefined;
|
|
13
13
|
hasSource: (fileName: string) => boolean;
|
package/out/languageContext.js
CHANGED
|
@@ -4,6 +4,7 @@ const path_1 = require("path");
|
|
|
4
4
|
const virtualFiles_1 = require("./virtualFiles");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
function createLanguageContext(host, languageModules) {
|
|
7
|
+
var _a;
|
|
7
8
|
for (const languageModule of languageModules.reverse()) {
|
|
8
9
|
if (languageModule.proxyLanguageServiceHost) {
|
|
9
10
|
const proxyApis = languageModule.proxyLanguageServiceHost(host);
|
|
@@ -20,7 +21,7 @@ function createLanguageContext(host, languageModules) {
|
|
|
20
21
|
let lastProjectVersion;
|
|
21
22
|
let tsProjectVersion = 0;
|
|
22
23
|
const virtualFiles = (0, virtualFiles_1.createVirtualFiles)(languageModules);
|
|
23
|
-
const ts = host.getTypeScriptModule();
|
|
24
|
+
const ts = (_a = host.getTypeScriptModule) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
24
25
|
const scriptSnapshots = new Map();
|
|
25
26
|
const sourceTsFileVersions = new Map();
|
|
26
27
|
const sourceFileVersions = new Map();
|
|
@@ -28,7 +29,7 @@ function createLanguageContext(host, languageModules) {
|
|
|
28
29
|
const _tsHost = {
|
|
29
30
|
fileExists: host.fileExists
|
|
30
31
|
? fileName => {
|
|
31
|
-
var _a;
|
|
32
|
+
var _a, _b;
|
|
32
33
|
const ext = fileName.substring(fileName.lastIndexOf('.'));
|
|
33
34
|
if (ext === '.js'
|
|
34
35
|
|| ext === '.ts'
|
|
@@ -45,14 +46,14 @@ function createLanguageContext(host, languageModules) {
|
|
|
45
46
|
if (!virtualFiles.hasSource(sourceFileName)) {
|
|
46
47
|
const scriptSnapshot = host.getScriptSnapshot(sourceFileName);
|
|
47
48
|
if (scriptSnapshot) {
|
|
48
|
-
virtualFiles.updateSource(sourceFileName, scriptSnapshot);
|
|
49
|
+
virtualFiles.updateSource(sourceFileName, scriptSnapshot, (_a = host.getScriptLanguageId) === null || _a === void 0 ? void 0 : _a.call(host, sourceFileName));
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
if (virtualFiles.hasVirtualFile(fileName)) {
|
|
53
54
|
return true;
|
|
54
55
|
}
|
|
55
|
-
return !!((
|
|
56
|
+
return !!((_b = host.fileExists) === null || _b === void 0 ? void 0 : _b.call(host, fileName));
|
|
56
57
|
}
|
|
57
58
|
: undefined,
|
|
58
59
|
getProjectVersion: () => {
|
|
@@ -111,7 +112,7 @@ function createLanguageContext(host, languageModules) {
|
|
|
111
112
|
}),
|
|
112
113
|
};
|
|
113
114
|
function update() {
|
|
114
|
-
var _a;
|
|
115
|
+
var _a, _b, _c;
|
|
115
116
|
const newProjectVersion = (_a = host.getProjectVersion) === null || _a === void 0 ? void 0 : _a.call(host);
|
|
116
117
|
const shouldUpdate = newProjectVersion === undefined || newProjectVersion !== lastProjectVersion;
|
|
117
118
|
lastProjectVersion = newProjectVersion;
|
|
@@ -135,7 +136,7 @@ function createLanguageContext(host, languageModules) {
|
|
|
135
136
|
if (sourceFileVersions.get(fileName) !== newVersion) {
|
|
136
137
|
// update
|
|
137
138
|
sourceFileVersions.set(fileName, newVersion);
|
|
138
|
-
virtualFiles.updateSource(fileName, snapshot);
|
|
139
|
+
virtualFiles.updateSource(fileName, snapshot, (_b = host.getScriptLanguageId) === null || _b === void 0 ? void 0 : _b.call(host, fileName));
|
|
139
140
|
virtualFilesUpdatedNum++;
|
|
140
141
|
}
|
|
141
142
|
}
|
|
@@ -147,7 +148,7 @@ function createLanguageContext(host, languageModules) {
|
|
|
147
148
|
for (const fileName of [...remainRootFiles]) {
|
|
148
149
|
const snapshot = host.getScriptSnapshot(fileName);
|
|
149
150
|
if (snapshot) {
|
|
150
|
-
const virtualFile = virtualFiles.updateSource(fileName, snapshot);
|
|
151
|
+
const virtualFile = virtualFiles.updateSource(fileName, snapshot, (_c = host.getScriptLanguageId) === null || _c === void 0 ? void 0 : _c.call(host, fileName));
|
|
151
152
|
if (virtualFile) {
|
|
152
153
|
remainRootFiles.delete(fileName);
|
|
153
154
|
}
|
package/out/types.d.ts
CHANGED
|
@@ -55,12 +55,13 @@ export interface VirtualFile {
|
|
|
55
55
|
embeddedFiles: VirtualFile[];
|
|
56
56
|
}
|
|
57
57
|
export interface LanguageModule<T extends VirtualFile = VirtualFile> {
|
|
58
|
-
createFile(fileName: string, snapshot: ts.IScriptSnapshot): T | undefined;
|
|
58
|
+
createFile(fileName: string, snapshot: ts.IScriptSnapshot, languageId: string | undefined): T | undefined;
|
|
59
59
|
updateFile(virtualFile: T, snapshot: ts.IScriptSnapshot): void;
|
|
60
60
|
deleteFile?(virtualFile: T): void;
|
|
61
61
|
proxyLanguageServiceHost?(host: LanguageServiceHost): Partial<LanguageServiceHost>;
|
|
62
62
|
}
|
|
63
63
|
export interface LanguageServiceHost extends ts.LanguageServiceHost {
|
|
64
|
-
getTypeScriptModule(): typeof import('typescript/lib/tsserverlibrary')
|
|
64
|
+
getTypeScriptModule?(): typeof import('typescript/lib/tsserverlibrary');
|
|
65
|
+
getScriptLanguageId?(fileName: string): string | undefined;
|
|
65
66
|
isTsc?: boolean;
|
|
66
67
|
}
|
package/out/virtualFiles.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface Source {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function createVirtualFiles(languageModules: LanguageModule[]): {
|
|
12
12
|
allSources(): Source[];
|
|
13
|
-
updateSource(fileName: string, snapshot: ts.IScriptSnapshot): VirtualFile | undefined;
|
|
13
|
+
updateSource(fileName: string, snapshot: ts.IScriptSnapshot, languageId: string | undefined): VirtualFile | undefined;
|
|
14
14
|
deleteSource(fileName: string): void;
|
|
15
15
|
getSource(fileName: string): Source | undefined;
|
|
16
16
|
hasSource: (fileName: string) => boolean;
|
package/out/virtualFiles.js
CHANGED
|
@@ -12,7 +12,7 @@ function createVirtualFiles(languageModules) {
|
|
|
12
12
|
allSources() {
|
|
13
13
|
return Array.from(sourceFiles.values());
|
|
14
14
|
},
|
|
15
|
-
updateSource(fileName, snapshot) {
|
|
15
|
+
updateSource(fileName, snapshot, languageId) {
|
|
16
16
|
const key = normalizePath(fileName);
|
|
17
17
|
const value = sourceFiles.get(key);
|
|
18
18
|
if (value) {
|
|
@@ -22,7 +22,7 @@ function createVirtualFiles(languageModules) {
|
|
|
22
22
|
return value.root; // updated
|
|
23
23
|
}
|
|
24
24
|
for (const languageModule of languageModules) {
|
|
25
|
-
const virtualFile = languageModule.createFile(fileName, snapshot);
|
|
25
|
+
const virtualFile = languageModule.createFile(fileName, snapshot, languageId);
|
|
26
26
|
if (virtualFile) {
|
|
27
27
|
sourceFiles.set(key, { fileName, snapshot, root: virtualFile, languageModule });
|
|
28
28
|
sourceFilesDirty = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-alpha.1",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
],
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/
|
|
12
|
+
"url": "https://github.com/volarjs/framework.git",
|
|
13
13
|
"directory": "packages/language-core"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/source-map": "1.0.
|
|
16
|
+
"@volar/source-map": "1.1.0-alpha.1",
|
|
17
17
|
"muggle-string": "^0.1.0"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "85666d83fafb0be442c55defb64fb0128b73bc0b"
|
|
20
20
|
}
|