@volar/language-server 2.4.0-alpha.19 → 2.4.0-alpha.20

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/node.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { FileSystem } from '@volar/language-service';
1
2
  import * as vscode from 'vscode-languageserver/node';
2
3
  export * from 'vscode-languageserver/node';
3
4
  export * from './index';
@@ -6,50 +7,33 @@ export * from './lib/project/typescriptProject';
6
7
  export * from './lib/server';
7
8
  export declare function createConnection(): vscode._Connection<vscode._, vscode._, vscode._, vscode._, vscode._, vscode._, import("vscode-languageserver/lib/common/inlineCompletion.proposed").InlineCompletionFeatureShape, vscode._>;
8
9
  export declare function createServer(connection: vscode.Connection): {
10
+ connection: vscode.Connection;
11
+ fs: FileSystem;
9
12
  initializeParams: vscode.InitializeParams;
13
+ initializeResult: import("./index").VolarInitializeResult;
14
+ languageServicePlugins: import("@volar/language-service").LanguageServicePlugin[];
10
15
  project: import("./index").LanguageServerProject;
11
- languageServicePlugins: import("@volar/language-service/lib/types").LanguageServicePlugin<any>[];
12
- initialize(params: vscode.InitializeParams, project: import("./index").LanguageServerProject, languageServicePlugins: import("@volar/language-service/lib/types").LanguageServicePlugin[]): vscode.InitializeResult<import("./index").ExperimentalFeatures>;
13
- initialized(): void;
14
- shutdown(): void;
15
- configurations: {
16
- get: <T>(section: string, scopeUri?: string) => Promise<T | undefined>;
17
- onDidChange: (cb: vscode.NotificationHandler<vscode.DidChangeConfigurationParams>) => {
18
- dispose(): void;
19
- };
20
- };
21
- editorFeatures: void;
22
- documents: {
23
- all: () => import("./lib/utils/snapshotDocument").SnapshotDocument[];
24
- onDidChangeContent: vscode.Event<vscode.TextDocumentChangeEvent<import("./lib/utils/snapshotDocument").SnapshotDocument>>;
25
- onDidOpen: vscode.Event<vscode.TextDocumentChangeEvent<import("./lib/utils/snapshotDocument").SnapshotDocument>>;
26
- onDidClose: vscode.Event<vscode.TextDocumentChangeEvent<import("./lib/utils/snapshotDocument").SnapshotDocument>>;
27
- onDidSave: vscode.Event<vscode.TextDocumentChangeEvent<import("./lib/utils/snapshotDocument").SnapshotDocument>>;
28
- get(uri: import("vscode-uri").URI): import("./lib/utils/snapshotDocument").SnapshotDocument | undefined;
29
- };
30
- workspaceFolders: {
31
- readonly all: import("vscode-uri").URI[];
32
- has(uri: import("vscode-uri").URI): boolean;
16
+ pullModelDiagnostics: boolean;
17
+ documents: vscode.TextDocuments<import("@volar/snapshot-document/lib/snapshotDocument").SnapshotDocument>;
18
+ workspaceFolders: Map<import("vscode-uri").URI, boolean>;
19
+ getSyncedDocumentKey: (uri: import("vscode-uri").URI) => string | undefined;
20
+ initialize: (initializeParams: vscode.InitializeParams, project: import("./index").LanguageServerProject, languageServicePlugins: import("@volar/language-service").LanguageServicePlugin[], options?: {
21
+ pullModelDiagnostics?: boolean;
22
+ }) => import("./index").VolarInitializeResult;
23
+ initialized: () => void;
24
+ shutdown: () => void;
25
+ watchFiles: (patterns: string[]) => Promise<vscode.Disposable>;
26
+ getConfiguration: <T>(section: string, scopeUri?: string) => Promise<T | undefined>;
27
+ onDidChangeConfiguration: (cb: vscode.NotificationHandler<vscode.DidChangeConfigurationParams>) => {
28
+ dispose(): void;
33
29
  };
34
- fileWatcher: {
35
- watchFiles: (patterns: string[]) => Promise<vscode.Disposable>;
36
- onDidChangeWatchedFiles: (cb: vscode.NotificationHandler<vscode.DidChangeWatchedFilesParams>) => {
37
- dispose: () => void;
38
- };
30
+ onDidChangeWatchedFiles: (cb: vscode.NotificationHandler<vscode.DidChangeWatchedFilesParams>) => {
31
+ dispose: () => void;
39
32
  };
40
- languageFeatures: {
41
- requestRefresh: (clearDiagnostics: boolean) => Promise<void>;
42
- };
43
- fileSystem: {
44
- readFile(uri: import("vscode-uri").URI): string | Thenable<string | undefined>;
45
- stat(uri: import("vscode-uri").URI): import("@volar/language-service/lib/types").FileStat | Thenable<import("@volar/language-service/lib/types").FileStat | undefined>;
46
- readDirectory(uri: import("vscode-uri").URI): import("@volar/language-service/lib/types").ProviderResult<[string, import("@volar/language-service/lib/types").FileType][]>;
47
- install(scheme: string, provider: import("@volar/language-service/lib/types").FileSystem): void;
48
- };
49
- connection: vscode.Connection;
50
- onInitialize(callback: (serverCapabilities: vscode.ServerCapabilities<import("./index").ExperimentalFeatures>) => void): void;
51
- onInitialized(callback: () => void): void;
33
+ clearPushDiagnostics: () => void;
34
+ refresh: (project: import("./index").LanguageServerProject) => Promise<void>;
52
35
  };
36
+ export declare const fs: FileSystem;
53
37
  export declare function loadTsdkByPath(tsdk: string, locale: string | undefined): {
54
38
  typescript: typeof import("typescript");
55
39
  diagnosticMessages: import("typescript").MapLike<string> | undefined;
package/node.js CHANGED
@@ -14,12 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.fs = void 0;
17
18
  exports.createConnection = createConnection;
18
19
  exports.createServer = createServer;
19
20
  exports.loadTsdkByPath = loadTsdkByPath;
21
+ const language_service_1 = require("@volar/language-service");
22
+ const _fs = require("fs");
20
23
  const vscode = require("vscode-languageserver/node");
21
- const http_1 = require("./lib/fileSystemProviders/http");
22
- const node_1 = require("./lib/fileSystemProviders/node");
24
+ const http_1 = require("./lib/schemaRequestHandlers/http");
23
25
  const server_1 = require("./lib/server");
24
26
  __exportStar(require("vscode-languageserver/node"), exports);
25
27
  __exportStar(require("./index"), exports);
@@ -30,13 +32,61 @@ function createConnection() {
30
32
  return vscode.createConnection(vscode.ProposedFeatures.all);
31
33
  }
32
34
  function createServer(connection) {
33
- const server = (0, server_1.createServerBase)(connection);
34
- server.fileSystem.install('file', node_1.provider);
35
- server.fileSystem.install('http', http_1.provider);
36
- server.fileSystem.install('https', http_1.provider);
37
- server.onInitialized(() => (0, http_1.listenEditorSettings)(server));
38
- return server;
35
+ return (0, server_1.createServerBase)(connection, exports.fs);
39
36
  }
37
+ exports.fs = {
38
+ stat(uri) {
39
+ if (uri.scheme === 'file') {
40
+ try {
41
+ const stats = _fs.statSync(uri.fsPath, { throwIfNoEntry: false });
42
+ if (stats) {
43
+ return {
44
+ type: stats.isFile() ? language_service_1.FileType.File
45
+ : stats.isDirectory() ? language_service_1.FileType.Directory
46
+ : stats.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
47
+ : language_service_1.FileType.Unknown,
48
+ ctime: stats.ctimeMs,
49
+ mtime: stats.mtimeMs,
50
+ size: stats.size,
51
+ };
52
+ }
53
+ }
54
+ catch {
55
+ return undefined;
56
+ }
57
+ }
58
+ },
59
+ readFile(uri, encoding) {
60
+ if (uri.scheme === 'file') {
61
+ try {
62
+ return _fs.readFileSync(uri.fsPath, { encoding: encoding ?? 'utf-8' });
63
+ }
64
+ catch {
65
+ return undefined;
66
+ }
67
+ }
68
+ if (uri.scheme === 'http' || uri.scheme === 'https') {
69
+ return (0, http_1.default)(uri);
70
+ }
71
+ },
72
+ readDirectory(uri) {
73
+ if (uri.scheme === 'file') {
74
+ try {
75
+ const files = _fs.readdirSync(uri.fsPath, { withFileTypes: true });
76
+ return files.map(file => {
77
+ return [file.name, file.isFile() ? language_service_1.FileType.File
78
+ : file.isDirectory() ? language_service_1.FileType.Directory
79
+ : file.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
80
+ : language_service_1.FileType.Unknown];
81
+ });
82
+ }
83
+ catch {
84
+ return [];
85
+ }
86
+ }
87
+ return [];
88
+ },
89
+ };
40
90
  function loadTsdkByPath(tsdk, locale) {
41
91
  locale = locale?.toLowerCase();
42
92
  // webpack compatibility
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-server",
3
- "version": "2.4.0-alpha.19",
3
+ "version": "2.4.0-alpha.20",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,9 +12,10 @@
12
12
  "directory": "packages/language-server"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/language-core": "2.4.0-alpha.19",
16
- "@volar/language-service": "2.4.0-alpha.19",
17
- "@volar/typescript": "2.4.0-alpha.19",
15
+ "@volar/language-core": "2.4.0-alpha.20",
16
+ "@volar/language-service": "2.4.0-alpha.20",
17
+ "@volar/snapshot-document": "2.4.0-alpha.20",
18
+ "@volar/typescript": "2.4.0-alpha.20",
18
19
  "path-browserify": "^1.0.1",
19
20
  "request-light": "^0.7.0",
20
21
  "vscode-languageserver": "^9.0.1",
@@ -25,5 +26,5 @@
25
26
  "devDependencies": {
26
27
  "@types/path-browserify": "latest"
27
28
  },
28
- "gitHead": "cbb14a44f72c365c1e8d52eff9580fb4e9765f15"
29
+ "gitHead": "63ec0dfd91333c91a7c6443cedc1ae074b317867"
29
30
  }
package/protocol.d.ts CHANGED
@@ -1,7 +1,19 @@
1
1
  import type { CodeMapping } from '@volar/language-core';
2
- import type { DocumentDropEdit } from '@volar/language-service';
2
+ import type { FileStat, FileType, DocumentDropEdit } from '@volar/language-service';
3
3
  import * as vscode from 'vscode-languageserver-protocol';
4
4
  export * from 'vscode-languageserver-protocol';
5
+ /**
6
+ * Server request client
7
+ */
8
+ export declare namespace FsReadFileRequest {
9
+ const type: vscode.RequestType<string, string | null | undefined, unknown>;
10
+ }
11
+ export declare namespace FsReadDirectoryRequest {
12
+ const type: vscode.RequestType<string, [string, FileType][], unknown>;
13
+ }
14
+ export declare namespace FsStatRequest {
15
+ const type: vscode.RequestType<string, FileStat, unknown>;
16
+ }
5
17
  /**
6
18
  * Client request server
7
19
  */
package/protocol.js CHANGED
@@ -14,9 +14,24 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.LoadedTSFilesMetaRequest = exports.GetVirtualCodeRequest = exports.GetVirtualFileRequest = exports.GetServicePluginsRequest = exports.UpdateServicePluginStateNotification = exports.UpdateVirtualCodeStateNotification = exports.DocumentDrop_DataTransferItemFileDataRequest = exports.DocumentDrop_DataTransferItemAsStringRequest = exports.DocumentDropRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = void 0;
17
+ exports.LoadedTSFilesMetaRequest = exports.GetVirtualCodeRequest = exports.GetVirtualFileRequest = exports.GetServicePluginsRequest = exports.UpdateServicePluginStateNotification = exports.UpdateVirtualCodeStateNotification = exports.DocumentDrop_DataTransferItemFileDataRequest = exports.DocumentDrop_DataTransferItemAsStringRequest = exports.DocumentDropRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.FsStatRequest = exports.FsReadDirectoryRequest = exports.FsReadFileRequest = void 0;
18
18
  const vscode = require("vscode-languageserver-protocol");
19
19
  __exportStar(require("vscode-languageserver-protocol"), exports);
20
+ /**
21
+ * Server request client
22
+ */
23
+ var FsReadFileRequest;
24
+ (function (FsReadFileRequest) {
25
+ FsReadFileRequest.type = new vscode.RequestType('volar/server/fs/readFile');
26
+ })(FsReadFileRequest || (exports.FsReadFileRequest = FsReadFileRequest = {}));
27
+ var FsReadDirectoryRequest;
28
+ (function (FsReadDirectoryRequest) {
29
+ FsReadDirectoryRequest.type = new vscode.RequestType('volar/server/fs/readDirectory');
30
+ })(FsReadDirectoryRequest || (exports.FsReadDirectoryRequest = FsReadDirectoryRequest = {}));
31
+ var FsStatRequest;
32
+ (function (FsStatRequest) {
33
+ FsStatRequest.type = new vscode.RequestType('volar/server/fs/stat');
34
+ })(FsStatRequest || (exports.FsStatRequest = FsStatRequest = {}));
20
35
  /**
21
36
  * Client request server
22
37
  */