@volar/language-server 1.6.9 → 1.7.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 +57 -62
- package/out/common/cancellationPipe.js +2 -6
- package/out/common/configurationHost.js +7 -2
- package/out/common/documents.d.ts +2 -2
- package/out/common/documents.js +10 -2
- package/out/common/features/customFeatures.js +43 -73
- package/out/common/features/languageFeatures.js +5 -5
- package/out/common/project.d.ts +111 -129
- package/out/common/project.js +137 -249
- package/out/common/server.d.ts +5 -1
- package/out/common/server.js +83 -12
- package/out/common/workspace.d.ts +298 -453
- package/out/common/workspace.js +17 -23
- package/out/common/workspaces.d.ts +367 -558
- package/out/common/workspaces.js +3 -6
- package/out/node/index.js +82 -83
- package/out/protocol.d.ts +5 -5
- package/out/protocol.js +5 -5
- package/out/types.d.ts +13 -44
- package/package.json +6 -6
package/out/common/workspaces.js
CHANGED
|
@@ -6,7 +6,7 @@ const types_1 = require("../types");
|
|
|
6
6
|
const workspace_1 = require("./workspace");
|
|
7
7
|
const isFileInDir_1 = require("./utils/isFileInDir");
|
|
8
8
|
function createWorkspaces(context) {
|
|
9
|
-
const uriToFileName = context.server.runtimeEnv
|
|
9
|
+
const { uriToFileName } = context.server.runtimeEnv;
|
|
10
10
|
const workspaces = new Map();
|
|
11
11
|
let semanticTokensReq = 0;
|
|
12
12
|
let documentUpdatedReq = 0;
|
|
@@ -16,7 +16,7 @@ function createWorkspaces(context) {
|
|
|
16
16
|
context.workspaces.documents.onDidClose(({ textDocument }) => {
|
|
17
17
|
context.server.connection.sendDiagnostics({ uri: textDocument.uri, diagnostics: [] });
|
|
18
18
|
});
|
|
19
|
-
context.
|
|
19
|
+
context.server.onDidChangeWatchedFiles(({ changes }) => {
|
|
20
20
|
const tsConfigChanges = changes.filter(change => workspace_1.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1)));
|
|
21
21
|
if (tsConfigChanges.length) {
|
|
22
22
|
reloadDiagnostics();
|
|
@@ -25,9 +25,7 @@ function createWorkspaces(context) {
|
|
|
25
25
|
updateDiagnosticsAndSemanticTokens();
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
context.server.
|
|
29
|
-
updateDiagnosticsAndSemanticTokens();
|
|
30
|
-
});
|
|
28
|
+
context.server.configurationHost?.onDidChangeConfiguration?.(updateDiagnosticsAndSemanticTokens);
|
|
31
29
|
return {
|
|
32
30
|
workspaces,
|
|
33
31
|
getProject: getProjectAndTsConfig,
|
|
@@ -51,7 +49,6 @@ function createWorkspaces(context) {
|
|
|
51
49
|
},
|
|
52
50
|
};
|
|
53
51
|
async function reloadProject() {
|
|
54
|
-
context.workspaces.fileSystemHost?.reload();
|
|
55
52
|
for (const [_, workspace] of workspaces) {
|
|
56
53
|
(await workspace).reload();
|
|
57
54
|
}
|
package/out/node/index.js
CHANGED
|
@@ -16,14 +16,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.startLanguageServer = exports.createConnection = void 0;
|
|
18
18
|
const fs = require("fs");
|
|
19
|
-
const request_light_1 = require("request-light");
|
|
20
|
-
const html = require("vscode-html-languageservice");
|
|
21
19
|
const vscode = require("vscode-languageserver/node");
|
|
22
|
-
const server_1 = require("../common/server");
|
|
23
|
-
const file_1 = require("../common/schemaRequestHandlers/file");
|
|
24
|
-
const http_1 = require("../common/schemaRequestHandlers/http");
|
|
25
|
-
const fileSystem_1 = require("./fileSystem");
|
|
26
20
|
const vscode_uri_1 = require("vscode-uri");
|
|
21
|
+
const http_1 = require("../common/schemaRequestHandlers/http");
|
|
22
|
+
const server_1 = require("../common/server");
|
|
23
|
+
const language_service_1 = require("@volar/language-service");
|
|
27
24
|
__exportStar(require("../index"), exports);
|
|
28
25
|
function createConnection() {
|
|
29
26
|
return vscode.createConnection(vscode.ProposedFeatures.all);
|
|
@@ -32,88 +29,90 @@ exports.createConnection = createConnection;
|
|
|
32
29
|
function startLanguageServer(connection, ...plugins) {
|
|
33
30
|
const uriToFileName = (uri) => vscode_uri_1.URI.parse(uri).fsPath.replace(/\\/g, '/');
|
|
34
31
|
const fileNameToUri = (fileName) => vscode_uri_1.URI.file(fileName).toString();
|
|
35
|
-
(0, server_1.startCommonLanguageServer)(connection, () => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
(0, server_1.startCommonLanguageServer)(connection, plugins, (_, options) => ({
|
|
33
|
+
uriToFileName,
|
|
34
|
+
fileNameToUri,
|
|
35
|
+
timer: {
|
|
36
|
+
setImmediate(callback, ...args) {
|
|
37
|
+
const handle = setImmediate(callback, ...args);
|
|
38
|
+
return { dispose: () => clearImmediate(handle) };
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
loadTypescript(tsdk) {
|
|
42
|
+
for (const name of ['./typescript.js', './tsserverlibrary.js']) {
|
|
43
|
+
try {
|
|
44
|
+
return require(require.resolve(name, { paths: [tsdk] }));
|
|
45
|
+
}
|
|
46
|
+
catch { }
|
|
47
|
+
}
|
|
48
|
+
// for bun
|
|
49
|
+
for (const name of ['typescript.js', 'tsserverlibrary.js']) {
|
|
50
|
+
try {
|
|
51
|
+
return require(tsdk + '/' + name);
|
|
52
|
+
}
|
|
53
|
+
catch { }
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`Can't find typescript.js or tsserverlibrary.js in ${tsdk}`);
|
|
56
|
+
},
|
|
57
|
+
async loadTypescriptLocalized(tsdk, locale) {
|
|
58
|
+
try {
|
|
59
|
+
const path = require.resolve(`./${locale}/diagnosticMessages.generated.json`, { paths: [tsdk] });
|
|
60
|
+
return require(path);
|
|
61
|
+
}
|
|
62
|
+
catch { }
|
|
63
|
+
},
|
|
64
|
+
fs: {
|
|
65
|
+
stat(uri) {
|
|
66
|
+
if (uri.startsWith('file://')) {
|
|
67
|
+
const stats = fs.statSync(uriToFileName(uri), { throwIfNoEntry: false });
|
|
68
|
+
if (stats) {
|
|
69
|
+
return {
|
|
70
|
+
type: stats.isFile() ? language_service_1.FileType.File
|
|
71
|
+
: stats.isDirectory() ? language_service_1.FileType.Directory
|
|
72
|
+
: stats.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
|
|
73
|
+
: language_service_1.FileType.Unknown,
|
|
74
|
+
ctime: stats.ctimeMs,
|
|
75
|
+
mtime: stats.mtimeMs,
|
|
76
|
+
size: stats.size,
|
|
77
|
+
};
|
|
54
78
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
readFile(uri, encoding) {
|
|
82
|
+
if (uri.startsWith('file://')) {
|
|
83
|
+
try {
|
|
84
|
+
if (options.maxFileSize) {
|
|
85
|
+
const stats = fs.statSync(uriToFileName(uri), { throwIfNoEntry: false });
|
|
86
|
+
if (stats && stats.size > options.maxFileSize) {
|
|
87
|
+
console.warn(`[volar] file size exceeded limit: ${uri} (${stats.size} > ${options.maxFileSize})`);
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
59
90
|
}
|
|
60
|
-
|
|
91
|
+
return fs.readFileSync(uriToFileName(uri), { encoding: encoding ?? 'utf-8' });
|
|
61
92
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
async loadTypescriptLocalized(tsdk, locale) {
|
|
65
|
-
try {
|
|
66
|
-
const path = require.resolve(`./${locale}/diagnosticMessages.generated.json`, { paths: [tsdk] });
|
|
67
|
-
return require(path);
|
|
93
|
+
catch {
|
|
94
|
+
return undefined;
|
|
68
95
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
type: stats.isFile() ? html.FileType.File
|
|
87
|
-
: stats.isDirectory() ? html.FileType.Directory
|
|
88
|
-
: stats.isSymbolicLink() ? html.FileType.SymbolicLink
|
|
89
|
-
: html.FileType.Unknown,
|
|
90
|
-
ctime: stats.ctimeMs,
|
|
91
|
-
mtime: stats.mtimeMs,
|
|
92
|
-
size: stats.size,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
reject(err);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
readDirectory: (uri) => {
|
|
102
|
-
return new Promise((resolve, reject) => {
|
|
103
|
-
fs.readdir(uriToFileName(uri), (err, files) => {
|
|
104
|
-
if (files) {
|
|
105
|
-
resolve(files.map(file => [file, html.FileType.File]));
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
reject(err);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
},
|
|
96
|
+
}
|
|
97
|
+
if (uri.startsWith('http://') || uri.startsWith('https://')) {
|
|
98
|
+
return (0, http_1.default)(uri);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
readDirectory(uri) {
|
|
102
|
+
if (uri.startsWith('file://')) {
|
|
103
|
+
const dirName = uriToFileName(uri);
|
|
104
|
+
const files = fs.existsSync(dirName) ? fs.readdirSync(dirName, { withFileTypes: true }) : [];
|
|
105
|
+
return files.map(file => {
|
|
106
|
+
return [file.name, file.isFile() ? language_service_1.FileType.File
|
|
107
|
+
: file.isDirectory() ? language_service_1.FileType.Directory
|
|
108
|
+
: file.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
|
|
109
|
+
: language_service_1.FileType.Unknown];
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return [];
|
|
114
113
|
},
|
|
115
|
-
}
|
|
116
|
-
});
|
|
114
|
+
},
|
|
115
|
+
}));
|
|
117
116
|
}
|
|
118
117
|
exports.startLanguageServer = startLanguageServer;
|
|
119
118
|
//# sourceMappingURL=index.js.map
|
package/out/protocol.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type * as html from 'vscode-html-languageservice';
|
|
3
2
|
import type { VirtualFile, FileRangeCapabilities } from '@volar/language-core';
|
|
4
3
|
import type { Mapping, Stack } from '@volar/source-map';
|
|
4
|
+
import type { FileStat, FileType } from '@volar/language-service';
|
|
5
5
|
/**
|
|
6
6
|
* Server request client
|
|
7
7
|
*/
|
|
@@ -9,7 +9,10 @@ export declare namespace FsReadFileRequest {
|
|
|
9
9
|
const type: vscode.RequestType<string, Uint8Array | null | undefined, unknown>;
|
|
10
10
|
}
|
|
11
11
|
export declare namespace FsReadDirectoryRequest {
|
|
12
|
-
const type: vscode.RequestType<string, [string,
|
|
12
|
+
const type: vscode.RequestType<string, [string, FileType][], unknown>;
|
|
13
|
+
}
|
|
14
|
+
export declare namespace FsStatRequest {
|
|
15
|
+
const type: vscode.RequestType<string, FileStat, unknown>;
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
15
18
|
* Client request server
|
|
@@ -91,6 +94,3 @@ export declare namespace GetVirtualFileRequest {
|
|
|
91
94
|
type ErrorType = never;
|
|
92
95
|
const type: vscode.RequestType<ParamsType, ResponseType, never>;
|
|
93
96
|
}
|
|
94
|
-
export declare namespace ReportStats {
|
|
95
|
-
const type: vscode.NotificationType0;
|
|
96
|
-
}
|
package/out/protocol.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.GetVirtualFileRequest = exports.GetVirtualFilesRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.AutoInsertRequest = exports.GetProjectFilesRequest = exports.GetProjectsRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.FsStatRequest = exports.FsReadDirectoryRequest = exports.FsReadFileRequest = void 0;
|
|
4
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
5
5
|
/**
|
|
6
6
|
* Server request client
|
|
@@ -13,6 +13,10 @@ var FsReadDirectoryRequest;
|
|
|
13
13
|
(function (FsReadDirectoryRequest) {
|
|
14
14
|
FsReadDirectoryRequest.type = new vscode.RequestType('volar/server/fs/readDirectory');
|
|
15
15
|
})(FsReadDirectoryRequest = exports.FsReadDirectoryRequest || (exports.FsReadDirectoryRequest = {}));
|
|
16
|
+
var FsStatRequest;
|
|
17
|
+
(function (FsStatRequest) {
|
|
18
|
+
FsStatRequest.type = new vscode.RequestType('volar/server/fs/stat');
|
|
19
|
+
})(FsStatRequest = exports.FsStatRequest || (exports.FsStatRequest = {}));
|
|
16
20
|
/**
|
|
17
21
|
* Client request server
|
|
18
22
|
*/
|
|
@@ -52,8 +56,4 @@ var GetVirtualFileRequest;
|
|
|
52
56
|
(function (GetVirtualFileRequest) {
|
|
53
57
|
GetVirtualFileRequest.type = new vscode.RequestType('volar/client/virtualFile');
|
|
54
58
|
})(GetVirtualFileRequest = exports.GetVirtualFileRequest || (exports.GetVirtualFileRequest = {}));
|
|
55
|
-
var ReportStats;
|
|
56
|
-
(function (ReportStats) {
|
|
57
|
-
ReportStats.type = new vscode.NotificationType0('volar/client/stats');
|
|
58
|
-
})(ReportStats = exports.ReportStats || (exports.ReportStats = {}));
|
|
59
59
|
//# sourceMappingURL=protocol.js.map
|
package/out/types.d.ts
CHANGED
|
@@ -1,45 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import * as embedded from '@volar/language-core';
|
|
4
|
-
import type { FileSystemProvider } from 'vscode-html-languageservice';
|
|
1
|
+
import { FileSystem, LanguageService, ServiceEnvironment, SharedModules } from '@volar/language-service';
|
|
2
|
+
import type { TypeScriptLanguageHost } from '@volar/language-core';
|
|
5
3
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
6
4
|
import * as vscode from 'vscode-languageserver';
|
|
7
|
-
import { URI } from 'vscode-uri';
|
|
8
5
|
import { Config } from '@volar/language-service';
|
|
9
6
|
import { ProjectContext } from './common/project';
|
|
10
|
-
export type FileSystemHost = {
|
|
11
|
-
ready(connection: vscode.Connection): void;
|
|
12
|
-
reload(): void;
|
|
13
|
-
getWorkspaceFileSystem(rootUri: URI): ts.System;
|
|
14
|
-
onDidChangeWatchedFiles(cb: (params: vscode.DidChangeWatchedFilesParams) => void): () => void;
|
|
15
|
-
};
|
|
16
7
|
export interface RuntimeEnvironment {
|
|
17
|
-
uriToFileName
|
|
18
|
-
fileNameToUri
|
|
19
|
-
loadTypescript
|
|
20
|
-
loadTypescriptLocalized
|
|
21
|
-
|
|
22
|
-
[schema: string]: undefined | ((uri: string, encoding?: BufferEncoding) => Promise<string | undefined>);
|
|
23
|
-
};
|
|
24
|
-
onDidChangeConfiguration?: (settings: any) => void;
|
|
25
|
-
fileSystemProvide: FileSystemProvider | undefined;
|
|
26
|
-
createFileSystemHost: (ts: typeof import('typescript/lib/tsserverlibrary'), capabilities: vscode.ClientCapabilities, env: RuntimeEnvironment, initOptions: InitializationOptions) => FileSystemHost;
|
|
8
|
+
uriToFileName(uri: string): string;
|
|
9
|
+
fileNameToUri(fileName: string): string;
|
|
10
|
+
loadTypescript(tsdk: string): typeof import('typescript/lib/tsserverlibrary');
|
|
11
|
+
loadTypescriptLocalized(tsdk: string, locale: string): Promise<{} | undefined>;
|
|
12
|
+
fs: FileSystem;
|
|
27
13
|
readonly timer: {
|
|
28
14
|
setImmediate(callback: (...args: any[]) => void, ...args: any[]): vscode.Disposable;
|
|
29
15
|
};
|
|
30
16
|
}
|
|
31
|
-
interface LanguageServerPluginContext extends ProjectContext {
|
|
32
|
-
env: ServiceEnvironment;
|
|
33
|
-
host: embedded.LanguageServiceHost;
|
|
34
|
-
sys: ts.System;
|
|
35
|
-
}
|
|
36
17
|
export interface LanguageServerPlugin {
|
|
37
|
-
(initOptions: InitializationOptions, modules: {
|
|
38
|
-
typescript?: typeof import('typescript/lib/tsserverlibrary');
|
|
39
|
-
}): {
|
|
18
|
+
(initOptions: InitializationOptions, modules: SharedModules): {
|
|
40
19
|
extraFileExtensions?: ts.FileExtensionInfo[];
|
|
41
20
|
watchFileExtensions?: string[];
|
|
42
|
-
resolveConfig?(config: Config, ctx:
|
|
21
|
+
resolveConfig?(config: Config, ctx: {
|
|
22
|
+
env: ServiceEnvironment;
|
|
23
|
+
host: TypeScriptLanguageHost;
|
|
24
|
+
} & ProjectContext | undefined): Config | Promise<Config>;
|
|
25
|
+
resolveExistingOptions?(options: ts.CompilerOptions | undefined): ts.CompilerOptions | undefined;
|
|
43
26
|
onInitialized?(getLanguageService: (uri: string) => Promise<LanguageService | undefined>, env: RuntimeEnvironment): void;
|
|
44
27
|
};
|
|
45
28
|
}
|
|
@@ -59,19 +42,6 @@ export interface InitializationOptions {
|
|
|
59
42
|
* Absolute path to node_modules/typescript/lib
|
|
60
43
|
*/
|
|
61
44
|
tsdk: string;
|
|
62
|
-
/**
|
|
63
|
-
* Dependencies versions.
|
|
64
|
-
* @example
|
|
65
|
-
* {
|
|
66
|
-
* '@vue/compiler-sfc': '3.0.0',
|
|
67
|
-
* 'typescript': '4.0.0',
|
|
68
|
-
* }
|
|
69
|
-
*/
|
|
70
|
-
versions?: Record<string, string>;
|
|
71
|
-
/**
|
|
72
|
-
* CDN url for dependencies.
|
|
73
|
-
*/
|
|
74
|
-
cdn?: string;
|
|
75
45
|
};
|
|
76
46
|
l10n?: {
|
|
77
47
|
location: string;
|
|
@@ -98,4 +68,3 @@ export interface InitializationOptions {
|
|
|
98
68
|
semanticTokensLegend?: vscode.SemanticTokensLegend;
|
|
99
69
|
codegenStack?: boolean;
|
|
100
70
|
}
|
|
101
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
"directory": "packages/language-server"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@volar/language-core": "1.
|
|
19
|
-
"@volar/language-service": "1.
|
|
18
|
+
"@volar/language-core": "1.7.1",
|
|
19
|
+
"@volar/language-service": "1.7.1",
|
|
20
|
+
"@volar/typescript": "1.7.1",
|
|
20
21
|
"@vscode/l10n": "^0.0.11",
|
|
21
22
|
"request-light": "^0.7.0",
|
|
22
23
|
"typesafe-path": "^0.2.2",
|
|
23
|
-
"vscode-html-languageservice": "^5.0.4",
|
|
24
24
|
"vscode-languageserver": "^8.1.0",
|
|
25
25
|
"vscode-languageserver-protocol": "^3.17.3",
|
|
26
26
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
27
27
|
"vscode-uri": "^3.0.7"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@volar/source-map": "1.
|
|
30
|
+
"@volar/source-map": "1.7.1"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "6d092d684c65ce43af8a401bc90d0b2769a2bf49"
|
|
33
33
|
}
|