@volar/language-server 1.3.0-alpha.0 → 1.3.0-alpha.2
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/browser/fileSystems.d.ts +2 -2
- package/out/browser/fileSystems.js +151 -161
- package/out/browser/index.js +64 -32
- package/out/common/documents.d.ts +2 -1
- package/out/common/documents.js +2 -2
- package/out/common/features/customFeatures.d.ts +2 -1
- package/out/common/features/customFeatures.js +4 -5
- package/out/common/project.d.ts +1 -1
- package/out/common/project.js +26 -17
- package/out/common/schemaRequestHandlers/http.d.ts +1 -1
- package/out/common/schemaRequestHandlers/http.js +3 -0
- package/out/common/server.d.ts +2 -2
- package/out/common/server.js +18 -15
- package/out/common/utils/uriMap.d.ts +1 -1
- package/out/common/utils/uriMap.js +2 -3
- package/out/common/workspace.d.ts +9 -9
- package/out/common/workspace.js +16 -15
- package/out/common/workspaces.d.ts +12 -12
- package/out/common/workspaces.js +4 -3
- package/out/node/fileSystem.d.ts +2 -2
- package/out/node/fileSystem.js +3 -4
- package/out/node/index.js +72 -66
- package/out/protocol.d.ts +1 -4
- package/out/protocol.js +1 -5
- package/out/types.d.ts +35 -15
- package/package.json +5 -5
package/out/node/fileSystem.js
CHANGED
|
@@ -9,12 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.createNodeFileSystemHost = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
12
|
const vscode = require("vscode-languageserver");
|
|
14
13
|
const uriMap_1 = require("../common/utils/uriMap");
|
|
15
14
|
let currentCwd = '';
|
|
16
|
-
function createNodeFileSystemHost(ts, capabilities) {
|
|
17
|
-
const instances = (0, uriMap_1.createUriMap)();
|
|
15
|
+
function createNodeFileSystemHost(ts, capabilities, env, _initOptions) {
|
|
16
|
+
const instances = (0, uriMap_1.createUriMap)(env.fileNameToUri);
|
|
18
17
|
const onDidChangeWatchedFilesCb = new Set();
|
|
19
18
|
return {
|
|
20
19
|
ready(connection) {
|
|
@@ -51,7 +50,7 @@ function createNodeFileSystemHost(ts, capabilities) {
|
|
|
51
50
|
};
|
|
52
51
|
function createWorkspaceFileSystem(ts, capabilities, rootUri) {
|
|
53
52
|
var _a;
|
|
54
|
-
const rootPath =
|
|
53
|
+
const rootPath = env.uriToFileName(rootUri.toString());
|
|
55
54
|
const workspaceSys = new Proxy(ts.sys, {
|
|
56
55
|
get(target, prop) {
|
|
57
56
|
const fn = target[prop];
|
package/out/node/index.js
CHANGED
|
@@ -23,7 +23,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.startLanguageServer = exports.createConnection = void 0;
|
|
26
|
-
const shared = require("@volar/shared");
|
|
27
26
|
const fs = require("fs");
|
|
28
27
|
const request_light_1 = require("request-light");
|
|
29
28
|
const html = require("vscode-html-languageservice");
|
|
@@ -32,84 +31,91 @@ const server_1 = require("../common/server");
|
|
|
32
31
|
const file_1 = require("../common/schemaRequestHandlers/file");
|
|
33
32
|
const http_1 = require("../common/schemaRequestHandlers/http");
|
|
34
33
|
const fileSystem_1 = require("./fileSystem");
|
|
34
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
35
35
|
__exportStar(require("../index"), exports);
|
|
36
36
|
function createConnection() {
|
|
37
37
|
return vscode.createConnection(vscode.ProposedFeatures.all);
|
|
38
38
|
}
|
|
39
39
|
exports.createConnection = createConnection;
|
|
40
40
|
function startLanguageServer(connection, ...plugins) {
|
|
41
|
-
(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
const uriToFileName = (uri) => vscode_uri_1.URI.parse(uri).fsPath.replace(/\\/g, '/');
|
|
42
|
+
const fileNameToUri = (fileName) => vscode_uri_1.URI.file(fileName).toString();
|
|
43
|
+
(0, server_1.startCommonLanguageServer)(connection, () => {
|
|
44
|
+
return {
|
|
45
|
+
plugins,
|
|
46
|
+
connection,
|
|
47
|
+
runtimeEnv: {
|
|
48
|
+
uriToFileName,
|
|
49
|
+
fileNameToUri,
|
|
50
|
+
timer: {
|
|
51
|
+
setImmediate(callback, ...args) {
|
|
52
|
+
const handle = setImmediate(callback, ...args);
|
|
53
|
+
return { dispose: () => clearImmediate(handle) };
|
|
54
|
+
},
|
|
49
55
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
catch (_a) { }
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
loadTypescriptLocalized(tsdk, locale) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
try {
|
|
63
|
-
const path = require.resolve(`./${locale}/diagnosticMessages.generated.json`, { paths: [tsdk] });
|
|
64
|
-
return require(path);
|
|
56
|
+
loadTypescript(tsdk) {
|
|
57
|
+
for (const name of ['./typescript.js', './tsserverlibrary.js', './tsserver.js']) {
|
|
58
|
+
try {
|
|
59
|
+
const path = require.resolve(name, { paths: [tsdk] });
|
|
60
|
+
return require(path);
|
|
61
|
+
}
|
|
62
|
+
catch (_a) { }
|
|
65
63
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
onDidChangeConfiguration(settings) {
|
|
75
|
-
(0, request_light_1.configure)(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL);
|
|
76
|
-
},
|
|
77
|
-
createFileSystemHost: fileSystem_1.createNodeFileSystemHost,
|
|
78
|
-
fileSystemProvide: {
|
|
79
|
-
stat: (uri) => {
|
|
80
|
-
return new Promise((resolve, reject) => {
|
|
81
|
-
fs.stat(shared.uriToFileName(uri), (err, stats) => {
|
|
82
|
-
if (stats) {
|
|
83
|
-
resolve({
|
|
84
|
-
type: stats.isFile() ? html.FileType.File
|
|
85
|
-
: stats.isDirectory() ? html.FileType.Directory
|
|
86
|
-
: stats.isSymbolicLink() ? html.FileType.SymbolicLink
|
|
87
|
-
: html.FileType.Unknown,
|
|
88
|
-
ctime: stats.ctimeMs,
|
|
89
|
-
mtime: stats.mtimeMs,
|
|
90
|
-
size: stats.size,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
reject(err);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
64
|
+
},
|
|
65
|
+
loadTypescriptLocalized(tsdk, locale) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
try {
|
|
68
|
+
const path = require.resolve(`./${locale}/diagnosticMessages.generated.json`, { paths: [tsdk] });
|
|
69
|
+
return require(path);
|
|
70
|
+
}
|
|
71
|
+
catch (_a) { }
|
|
97
72
|
});
|
|
98
73
|
},
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
74
|
+
schemaRequestHandlers: {
|
|
75
|
+
file: file_1.default,
|
|
76
|
+
http: http_1.default,
|
|
77
|
+
https: http_1.default,
|
|
78
|
+
},
|
|
79
|
+
onDidChangeConfiguration(settings) {
|
|
80
|
+
(0, request_light_1.configure)(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL);
|
|
81
|
+
},
|
|
82
|
+
createFileSystemHost: fileSystem_1.createNodeFileSystemHost,
|
|
83
|
+
fileSystemProvide: {
|
|
84
|
+
stat: (uri) => {
|
|
85
|
+
return new Promise((resolve, reject) => {
|
|
86
|
+
fs.stat(uriToFileName(uri), (err, stats) => {
|
|
87
|
+
if (stats) {
|
|
88
|
+
resolve({
|
|
89
|
+
type: stats.isFile() ? html.FileType.File
|
|
90
|
+
: stats.isDirectory() ? html.FileType.Directory
|
|
91
|
+
: stats.isSymbolicLink() ? html.FileType.SymbolicLink
|
|
92
|
+
: html.FileType.Unknown,
|
|
93
|
+
ctime: stats.ctimeMs,
|
|
94
|
+
mtime: stats.mtimeMs,
|
|
95
|
+
size: stats.size,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
reject(err);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
108
102
|
});
|
|
109
|
-
}
|
|
103
|
+
},
|
|
104
|
+
readDirectory: (uri) => {
|
|
105
|
+
return new Promise((resolve, reject) => {
|
|
106
|
+
fs.readdir(uriToFileName(uri), (err, files) => {
|
|
107
|
+
if (files) {
|
|
108
|
+
resolve(files.map(file => [file, html.FileType.File]));
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
reject(err);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
},
|
|
110
116
|
},
|
|
111
117
|
},
|
|
112
|
-
}
|
|
118
|
+
};
|
|
113
119
|
});
|
|
114
120
|
}
|
|
115
121
|
exports.startLanguageServer = startLanguageServer;
|
package/out/protocol.d.ts
CHANGED
|
@@ -10,11 +10,8 @@ export declare namespace ShowReferencesNotification {
|
|
|
10
10
|
};
|
|
11
11
|
const type: vscode.NotificationType<ResponseType>;
|
|
12
12
|
}
|
|
13
|
-
export declare namespace FsStatRequest {
|
|
14
|
-
const type: vscode.RequestType<string, html.FileStat | null | undefined, unknown>;
|
|
15
|
-
}
|
|
16
13
|
export declare namespace FsReadFileRequest {
|
|
17
|
-
const type: vscode.RequestType<string,
|
|
14
|
+
const type: vscode.RequestType<string, Uint8Array | null | undefined, unknown>;
|
|
18
15
|
}
|
|
19
16
|
export declare namespace FsReadDirectoryRequest {
|
|
20
17
|
const type: vscode.RequestType<string, [string, html.FileType][], unknown>;
|
package/out/protocol.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.ReportStats = exports.GetVirtualFileRequest = exports.GetVirtualFileNamesRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.FsReadDirectoryRequest = exports.FsReadFileRequest = exports.
|
|
2
|
+
exports.ReportStats = exports.GetVirtualFileRequest = exports.GetVirtualFileNamesRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.FsReadDirectoryRequest = exports.FsReadFileRequest = exports.ShowReferencesNotification = void 0;
|
|
3
3
|
const vscode = require("vscode-languageserver-protocol");
|
|
4
4
|
/**
|
|
5
5
|
* Server request client
|
|
@@ -8,10 +8,6 @@ var ShowReferencesNotification;
|
|
|
8
8
|
(function (ShowReferencesNotification) {
|
|
9
9
|
ShowReferencesNotification.type = new vscode.NotificationType('volar/server/showReferences');
|
|
10
10
|
})(ShowReferencesNotification = exports.ShowReferencesNotification || (exports.ShowReferencesNotification = {}));
|
|
11
|
-
var FsStatRequest;
|
|
12
|
-
(function (FsStatRequest) {
|
|
13
|
-
FsStatRequest.type = new vscode.RequestType('volar/server/fs/stat');
|
|
14
|
-
})(FsStatRequest = exports.FsStatRequest || (exports.FsStatRequest = {}));
|
|
15
11
|
var FsReadFileRequest;
|
|
16
12
|
(function (FsReadFileRequest) {
|
|
17
13
|
FsReadFileRequest.type = new vscode.RequestType('volar/server/fs/readFile');
|
package/out/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
2
|
+
import { LanguageService, LanguageServiceOptions } from '@volar/language-service';
|
|
3
3
|
import * as embedded from '@volar/language-core';
|
|
4
4
|
import type { FileSystemProvider } from 'vscode-html-languageservice';
|
|
5
5
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
6
6
|
import * as vscode from 'vscode-languageserver';
|
|
7
7
|
import { URI } from 'vscode-uri';
|
|
8
|
-
import { Config
|
|
8
|
+
import { Config } from '@volar/language-service';
|
|
9
9
|
import { ProjectContext } from './common/project';
|
|
10
10
|
export type FileSystemHost = {
|
|
11
11
|
ready(connection: vscode.Connection): void;
|
|
@@ -15,35 +15,39 @@ export type FileSystemHost = {
|
|
|
15
15
|
};
|
|
16
16
|
export type FileSystem = Pick<ts.System, 'newLine' | 'useCaseSensitiveFileNames' | 'fileExists' | 'readFile' | 'readDirectory' | 'getCurrentDirectory' | 'realpath' | 'resolvePath'> & Partial<ts.System>;
|
|
17
17
|
export interface RuntimeEnvironment {
|
|
18
|
+
uriToFileName: (uri: string) => string;
|
|
19
|
+
fileNameToUri: (fileName: string) => string;
|
|
18
20
|
loadTypescript: (tsdk: string) => typeof import('typescript/lib/tsserverlibrary');
|
|
19
21
|
loadTypescriptLocalized: (tsdk: string, locale: string) => Promise<{} | undefined>;
|
|
20
22
|
schemaRequestHandlers: {
|
|
21
|
-
[schema: string]: (uri: string, encoding?: BufferEncoding) => Promise<string
|
|
23
|
+
[schema: string]: undefined | ((uri: string, encoding?: BufferEncoding) => Promise<string | undefined>);
|
|
22
24
|
};
|
|
23
25
|
onDidChangeConfiguration?: (settings: any) => void;
|
|
24
26
|
fileSystemProvide: FileSystemProvider | undefined;
|
|
25
|
-
createFileSystemHost: (ts: typeof import('typescript/lib/tsserverlibrary'), capabilities: vscode.ClientCapabilities) => FileSystemHost;
|
|
27
|
+
createFileSystemHost: (ts: typeof import('typescript/lib/tsserverlibrary'), capabilities: vscode.ClientCapabilities, env: RuntimeEnvironment, initOptions: LanguageServerInitializationOptions) => FileSystemHost;
|
|
26
28
|
readonly timer: {
|
|
27
29
|
setImmediate(callback: (...args: any[]) => void, ...args: any[]): vscode.Disposable;
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
32
|
export interface LanguageServiceContext {
|
|
31
33
|
project: ProjectContext;
|
|
32
|
-
|
|
34
|
+
options: LanguageServiceOptions;
|
|
33
35
|
host: embedded.LanguageServiceHost;
|
|
34
36
|
sys: FileSystem;
|
|
35
37
|
}
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
export interface LanguageServerPlugin {
|
|
39
|
+
(initOptions: LanguageServerInitializationOptions): {
|
|
40
|
+
tsconfigExtraFileExtensions: ts.FileExtensionInfo[];
|
|
41
|
+
diagnosticDocumentSelector: vscode.DocumentSelector;
|
|
42
|
+
extensions: {
|
|
43
|
+
fileRenameOperationFilter: string[];
|
|
44
|
+
fileWatcher: string[];
|
|
45
|
+
};
|
|
46
|
+
resolveConfig?(config: Config, ctx: LanguageServiceContext): void;
|
|
47
|
+
onInitialize?(_: vscode.InitializeResult, env: RuntimeEnvironment): void;
|
|
48
|
+
onInitialized?(getLanguageService: (uri: string) => Promise<LanguageService | undefined>, env: RuntimeEnvironment): void;
|
|
42
49
|
};
|
|
43
|
-
|
|
44
|
-
onInitialize?(_: vscode.InitializeResult): void;
|
|
45
|
-
onInitialized?(getLanguageService: (uri: string) => Promise<C>): void;
|
|
46
|
-
};
|
|
50
|
+
}
|
|
47
51
|
export declare enum ServerMode {
|
|
48
52
|
Semantic = 0,
|
|
49
53
|
Syntactic = 2
|
|
@@ -55,7 +59,23 @@ export declare enum DiagnosticModel {
|
|
|
55
59
|
}
|
|
56
60
|
export interface LanguageServerInitializationOptions {
|
|
57
61
|
typescript?: {
|
|
62
|
+
/**
|
|
63
|
+
* Absolute path to node_modules/typescript/lib
|
|
64
|
+
*/
|
|
58
65
|
tsdk: string;
|
|
66
|
+
/**
|
|
67
|
+
* Dependencies versions.
|
|
68
|
+
* @example
|
|
69
|
+
* {
|
|
70
|
+
* '@vue/compiler-sfc': '3.0.0',
|
|
71
|
+
* 'typescript': '4.0.0',
|
|
72
|
+
* }
|
|
73
|
+
*/
|
|
74
|
+
versions?: Record<string, string>;
|
|
75
|
+
/**
|
|
76
|
+
* CDN url for dependencies.
|
|
77
|
+
*/
|
|
78
|
+
cdn?: string;
|
|
59
79
|
};
|
|
60
80
|
l10n?: {
|
|
61
81
|
location: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "1.3.0-alpha.
|
|
3
|
+
"version": "1.3.0-alpha.2",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"directory": "packages/language-server"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@volar/language-core": "1.3.0-alpha.
|
|
21
|
-
"@volar/language-service": "1.3.0-alpha.
|
|
22
|
-
"@volar/shared": "1.3.0-alpha.
|
|
20
|
+
"@volar/language-core": "1.3.0-alpha.2",
|
|
21
|
+
"@volar/language-service": "1.3.0-alpha.2",
|
|
22
|
+
"@volar/shared": "1.3.0-alpha.2",
|
|
23
23
|
"@vscode/l10n": "^0.0.11",
|
|
24
24
|
"request-light": "^0.7.0",
|
|
25
25
|
"typesafe-path": "^0.2.2",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
30
30
|
"vscode-uri": "^3.0.7"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "84111017f289c36dfe4541159cad8a7e13c2be41"
|
|
33
33
|
}
|