@volar/language-server 1.8.0 → 1.8.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/browser/index.js +76 -19
- package/out/common/project.js +2 -1
- package/out/common/server.js +1 -1
- package/out/common/utils/serverConfig.d.ts +2 -2
- package/out/common/utils/serverConfig.js +2 -2
- package/out/common/workspaces.js +5 -0
- package/out/node/index.js +1 -0
- package/out/protocol.d.ts +1 -1
- package/out/types.d.ts +6 -4
- package/package.json +7 -6
package/out/browser/index.js
CHANGED
|
@@ -20,6 +20,7 @@ const server_1 = require("../common/server");
|
|
|
20
20
|
const http_1 = require("../common/schemaRequestHandlers/http");
|
|
21
21
|
const vscode_uri_1 = require("vscode-uri");
|
|
22
22
|
const protocol_1 = require("../protocol");
|
|
23
|
+
const language_service_1 = require("@volar/language-service");
|
|
23
24
|
__exportStar(require("../index"), exports);
|
|
24
25
|
function createConnection() {
|
|
25
26
|
const messageReader = new vscode.BrowserMessageReader(self);
|
|
@@ -32,6 +33,7 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
32
33
|
(0, server_1.startCommonLanguageServer)(connection, plugins, () => ({
|
|
33
34
|
uriToFileName,
|
|
34
35
|
fileNameToUri,
|
|
36
|
+
console: connection.console,
|
|
35
37
|
timer: {
|
|
36
38
|
setImmediate(callback, ...args) {
|
|
37
39
|
const handle = setTimeout(callback, 0, ...args);
|
|
@@ -51,35 +53,91 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
51
53
|
}
|
|
52
54
|
catch { }
|
|
53
55
|
},
|
|
54
|
-
fs:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
fs: createFs(connection),
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
exports.startLanguageServer = startLanguageServer;
|
|
60
|
+
/**
|
|
61
|
+
* To avoid hitting the API hourly limit, we keep requests as low as possible.
|
|
62
|
+
*/
|
|
63
|
+
function createFs(connection) {
|
|
64
|
+
const readDirectoryResults = new Map();
|
|
65
|
+
return {
|
|
66
|
+
async stat(uri) {
|
|
67
|
+
if (uri.startsWith('__invalid__:')) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (uri.startsWith('http://') || uri.startsWith('https://')) {
|
|
71
|
+
const text = await this.readFile(uri); // TODO: perf
|
|
72
|
+
if (text !== undefined) {
|
|
73
|
+
return {
|
|
74
|
+
type: language_service_1.FileType.File,
|
|
75
|
+
size: text.length,
|
|
76
|
+
ctime: -1,
|
|
77
|
+
mtime: -1,
|
|
78
|
+
};
|
|
62
79
|
}
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const dirUri = uri.substring(0, uri.lastIndexOf('/'));
|
|
83
|
+
const baseName = uri.substring(uri.lastIndexOf('/') + 1);
|
|
84
|
+
const entries = await this.readDirectory(dirUri);
|
|
85
|
+
const matches = entries.filter(entry => entry[0] === baseName);
|
|
86
|
+
if (matches.length) {
|
|
87
|
+
return {
|
|
88
|
+
type: matches.some(entry => entry[1] === language_service_1.FileType.File) ? language_service_1.FileType.File : matches[0][1],
|
|
89
|
+
size: -1,
|
|
90
|
+
ctime: -1,
|
|
91
|
+
mtime: -1,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
async readFile(uri) {
|
|
96
|
+
if (uri.startsWith('__invalid__:')) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (uri.startsWith('http://') || uri.startsWith('https://')) {
|
|
100
|
+
return await (0, http_1.default)(uri);
|
|
101
|
+
}
|
|
102
|
+
const dirUri = uri.substring(0, uri.lastIndexOf('/'));
|
|
103
|
+
const baseName = uri.substring(uri.lastIndexOf('/') + 1);
|
|
104
|
+
const entries = await this.readDirectory(dirUri);
|
|
105
|
+
const file = entries.filter(entry => entry[0] === baseName && entry[1] === language_service_1.FileType.File);
|
|
106
|
+
if (file) {
|
|
107
|
+
const text = await connection.sendRequest(protocol_1.FsReadFileRequest.type, uri);
|
|
108
|
+
if (text !== undefined && text !== null) {
|
|
109
|
+
return text;
|
|
65
110
|
}
|
|
66
|
-
}
|
|
67
|
-
async readDirectory(uri) {
|
|
68
|
-
return connection.sendRequest(protocol_1.FsReadDirectoryRequest.type, uri);
|
|
69
|
-
},
|
|
111
|
+
}
|
|
70
112
|
},
|
|
71
|
-
|
|
113
|
+
async readDirectory(uri) {
|
|
114
|
+
if (uri.startsWith('__invalid__:')) {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
if (uri.startsWith('http://') || uri.startsWith('https://')) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
if (!readDirectoryResults.has(uri)) {
|
|
121
|
+
readDirectoryResults.set(uri, connection.sendRequest(protocol_1.FsReadDirectoryRequest.type, uri));
|
|
122
|
+
}
|
|
123
|
+
return await readDirectoryResults.get(uri);
|
|
124
|
+
},
|
|
125
|
+
};
|
|
72
126
|
}
|
|
73
|
-
exports.startLanguageServer = startLanguageServer;
|
|
74
127
|
function uriToFileName(uri) {
|
|
75
128
|
const parsed = vscode_uri_1.URI.parse(uri);
|
|
129
|
+
if (parsed.scheme === '__invalid__') {
|
|
130
|
+
return parsed.path;
|
|
131
|
+
}
|
|
76
132
|
return `/${parsed.scheme}${parsed.authority ? '@' + parsed.authority : ''}${parsed.path}`;
|
|
77
133
|
}
|
|
78
|
-
;
|
|
79
134
|
function fileNameToUri(fileName) {
|
|
80
135
|
const parts = fileName.split('/');
|
|
81
136
|
if (parts.length <= 1) {
|
|
82
|
-
return vscode_uri_1.URI.from({
|
|
137
|
+
return vscode_uri_1.URI.from({
|
|
138
|
+
scheme: '__invalid__',
|
|
139
|
+
path: fileName,
|
|
140
|
+
}).toString();
|
|
83
141
|
}
|
|
84
142
|
const firstParts = parts[1].split('@');
|
|
85
143
|
return vscode_uri_1.URI.from({
|
|
@@ -88,5 +146,4 @@ function fileNameToUri(fileName) {
|
|
|
88
146
|
path: '/' + parts.slice(2).join('/'),
|
|
89
147
|
}).toString();
|
|
90
148
|
}
|
|
91
|
-
;
|
|
92
149
|
//# sourceMappingURL=index.js.map
|
package/out/common/project.js
CHANGED
|
@@ -22,6 +22,7 @@ async function createProject(context) {
|
|
|
22
22
|
uriToFileName,
|
|
23
23
|
fileNameToUri,
|
|
24
24
|
fs,
|
|
25
|
+
console: context.server.runtimeEnv.console,
|
|
25
26
|
locale: context.workspaces.initParams.locale,
|
|
26
27
|
rootUri: context.project.rootUri,
|
|
27
28
|
clientCapabilities: context.workspaces.initParams.capabilities,
|
|
@@ -66,7 +67,7 @@ async function createProject(context) {
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
let parsedCommandLine = await createParsedCommandLine(context.workspaces.ts, env, uriToFileName(context.project.rootUri.toString()), context.project.tsConfig, context.workspaces.plugins, existingOptions);
|
|
69
|
-
let config = (context.workspace.rootUri.scheme === 'file' ? (0, serverConfig_1.loadConfig)(context.server.runtimeEnv.uriToFileName(context.workspace.rootUri.toString()), context.workspaces.initOptions.configFilePath) : {}) ?? {};
|
|
70
|
+
let config = (context.workspace.rootUri.scheme === 'file' ? (0, serverConfig_1.loadConfig)(context.server.runtimeEnv.console, context.server.runtimeEnv.uriToFileName(context.workspace.rootUri.toString()), context.workspaces.initOptions.configFilePath) : {}) ?? {};
|
|
70
71
|
for (const plugin of context.workspaces.plugins) {
|
|
71
72
|
if (plugin.resolveConfig) {
|
|
72
73
|
config = await plugin.resolveConfig(config, {
|
package/out/common/server.js
CHANGED
|
@@ -77,7 +77,7 @@ async function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
|
|
|
77
77
|
let config = {};
|
|
78
78
|
for (const root of roots) {
|
|
79
79
|
if (root.scheme === 'file') {
|
|
80
|
-
const workspaceConfig = (0, serverConfig_1.loadConfig)(root.path, options.configFilePath);
|
|
80
|
+
const workspaceConfig = (0, serverConfig_1.loadConfig)(env.console, root.path, options.configFilePath);
|
|
81
81
|
if (workspaceConfig) {
|
|
82
82
|
config = workspaceConfig;
|
|
83
83
|
break;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Config } from
|
|
2
|
-
export declare function loadConfig(dir: string, configFile: string | undefined): Config | undefined;
|
|
1
|
+
import type { Config, Console } from '@volar/language-service';
|
|
2
|
+
export declare function loadConfig(console: Console, dir: string, configFile: string | undefined): Config | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadConfig = void 0;
|
|
4
|
-
function loadConfig(dir, configFile) {
|
|
4
|
+
function loadConfig(console, dir, configFile) {
|
|
5
5
|
let configPath;
|
|
6
6
|
try {
|
|
7
7
|
configPath = require.resolve(configFile ?? './volar.config.js', { paths: [dir] });
|
|
@@ -15,7 +15,7 @@ function loadConfig(dir, configFile) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
catch (err) {
|
|
18
|
-
console.
|
|
18
|
+
console.warn(String(err));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.loadConfig = loadConfig;
|
package/out/common/workspaces.js
CHANGED
|
@@ -72,6 +72,11 @@ function createWorkspaces(context) {
|
|
|
72
72
|
if (context.workspaces.initParams.capabilities.workspace?.inlayHint?.refreshSupport) {
|
|
73
73
|
context.server.connection.languages.inlayHint.refresh();
|
|
74
74
|
}
|
|
75
|
+
if ((context.workspaces.initOptions.diagnosticModel ?? types_1.DiagnosticModel.Push) === types_1.DiagnosticModel.Pull) {
|
|
76
|
+
if (context.workspaces.initParams.capabilities.workspace?.diagnostics?.refreshSupport) {
|
|
77
|
+
context.server.connection.languages.diagnostics.refresh();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
81
|
}
|
|
77
82
|
async function updateDiagnostics(docUri) {
|
package/out/node/index.js
CHANGED
|
@@ -98,6 +98,7 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
98
98
|
(0, server_1.startCommonLanguageServer)(connection, plugins, (_, options) => ({
|
|
99
99
|
uriToFileName: exports.uriToFileName,
|
|
100
100
|
fileNameToUri: exports.fileNameToUri,
|
|
101
|
+
console: connection.console,
|
|
101
102
|
timer: {
|
|
102
103
|
setImmediate(callback, ...args) {
|
|
103
104
|
const handle = setImmediate(callback, ...args);
|
package/out/protocol.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { FileStat, FileType } from '@volar/language-service';
|
|
|
6
6
|
* Server request client
|
|
7
7
|
*/
|
|
8
8
|
export declare namespace FsReadFileRequest {
|
|
9
|
-
const type: vscode.RequestType<string,
|
|
9
|
+
const type: vscode.RequestType<string, string | null | undefined, unknown>;
|
|
10
10
|
}
|
|
11
11
|
export declare namespace FsReadDirectoryRequest {
|
|
12
12
|
const type: vscode.RequestType<string, [string, FileType][], unknown>;
|
package/out/types.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { FileSystem, LanguageService, ServiceEnvironment, SharedModules } from '@volar/language-service';
|
|
1
|
+
import { FileSystem, Console, LanguageService, ServiceEnvironment, SharedModules } from '@volar/language-service';
|
|
2
2
|
import type { TypeScriptLanguageHost } from '@volar/language-core';
|
|
3
3
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
4
4
|
import * as vscode from 'vscode-languageserver';
|
|
5
5
|
import { Config } from '@volar/language-service';
|
|
6
6
|
import { ProjectContext } from './common/project';
|
|
7
|
+
export interface Timer {
|
|
8
|
+
setImmediate(callback: (...args: any[]) => void, ...args: any[]): vscode.Disposable;
|
|
9
|
+
}
|
|
7
10
|
export interface RuntimeEnvironment {
|
|
8
11
|
uriToFileName(uri: string): string;
|
|
9
12
|
fileNameToUri(fileName: string): string;
|
|
10
13
|
loadTypescript(tsdk: string): typeof import('typescript/lib/tsserverlibrary');
|
|
11
14
|
loadTypescriptLocalized(tsdk: string, locale: string): Promise<{} | undefined>;
|
|
12
15
|
fs: FileSystem;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
+
timer: Timer;
|
|
17
|
+
console: Console;
|
|
16
18
|
}
|
|
17
19
|
export interface LanguageServerPlugin {
|
|
18
20
|
(initOptions: InitializationOptions, modules: SharedModules): {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"directory": "packages/language-server"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@volar/language-core": "1.8.
|
|
19
|
-
"@volar/language-service": "1.8.
|
|
20
|
-
"@volar/typescript": "1.8.
|
|
18
|
+
"@volar/language-core": "1.8.1",
|
|
19
|
+
"@volar/language-service": "1.8.1",
|
|
20
|
+
"@volar/typescript": "1.8.1",
|
|
21
21
|
"@vscode/l10n": "^0.0.11",
|
|
22
22
|
"request-light": "^0.7.0",
|
|
23
23
|
"typesafe-path": "^0.2.2",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"vscode-uri": "^3.0.7"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@volar/source-map": "1.8.
|
|
31
|
-
}
|
|
30
|
+
"@volar/source-map": "1.8.1"
|
|
31
|
+
},
|
|
32
|
+
"gitHead": "1fec004d7e3c5a28c0ad1d6a1d7a41ab98381abd"
|
|
32
33
|
}
|