@volar/language-server 1.10.10 → 1.11.0

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.
Files changed (48) hide show
  1. package/browser.d.ts +6 -1
  2. package/browser.js +138 -1
  3. package/index.d.ts +6 -0
  4. package/{out/index.js → index.js} +3 -3
  5. package/{out → lib}/common/features/customFeatures.js +1 -1
  6. package/{out → lib}/common/features/languageFeatures.js +1 -1
  7. package/{out → lib}/common/project.js +3 -3
  8. package/{out → lib}/common/server.d.ts +2 -2
  9. package/{out → lib}/common/server.js +16 -16
  10. package/{out → lib}/types.d.ts +3 -3
  11. package/node.d.ts +10 -1
  12. package/node.js +149 -1
  13. package/package.json +8 -11
  14. package/protocol.d.ts +79 -1
  15. package/protocol.js +55 -1
  16. package/out/browser/index.d.ts +0 -6
  17. package/out/browser/index.js +0 -169
  18. package/out/common/cancellationPipe.d.ts +0 -6
  19. package/out/common/cancellationPipe.js +0 -49
  20. package/out/index.d.ts +0 -6
  21. package/out/node/index.d.ts +0 -10
  22. package/out/node/index.js +0 -149
  23. package/out/protocol.d.ts +0 -79
  24. package/out/protocol.js +0 -55
  25. /package/{out → lib}/common/configurationHost.d.ts +0 -0
  26. /package/{out → lib}/common/configurationHost.js +0 -0
  27. /package/{out → lib}/common/documents.d.ts +0 -0
  28. /package/{out → lib}/common/documents.js +0 -0
  29. /package/{out → lib}/common/features/customFeatures.d.ts +0 -0
  30. /package/{out → lib}/common/features/languageFeatures.d.ts +0 -0
  31. /package/{out → lib}/common/project.d.ts +0 -0
  32. /package/{out → lib}/common/schemaRequestHandlers/http.d.ts +0 -0
  33. /package/{out → lib}/common/schemaRequestHandlers/http.js +0 -0
  34. /package/{out → lib}/common/utils/inferredCompilerOptions.d.ts +0 -0
  35. /package/{out → lib}/common/utils/inferredCompilerOptions.js +0 -0
  36. /package/{out → lib}/common/utils/isFileInDir.d.ts +0 -0
  37. /package/{out → lib}/common/utils/isFileInDir.js +0 -0
  38. /package/{out → lib}/common/utils/registerFeatures.d.ts +0 -0
  39. /package/{out → lib}/common/utils/registerFeatures.js +0 -0
  40. /package/{out → lib}/common/utils/serverConfig.d.ts +0 -0
  41. /package/{out → lib}/common/utils/serverConfig.js +0 -0
  42. /package/{out → lib}/common/utils/uriMap.d.ts +0 -0
  43. /package/{out → lib}/common/utils/uriMap.js +0 -0
  44. /package/{out → lib}/common/workspaces.d.ts +0 -0
  45. /package/{out → lib}/common/workspaces.js +0 -0
  46. /package/{out → lib}/node/cancellationPipe.d.ts +0 -0
  47. /package/{out → lib}/node/cancellationPipe.js +0 -0
  48. /package/{out → lib}/types.js +0 -0
package/browser.d.ts CHANGED
@@ -1 +1,6 @@
1
- export * from './out/browser';
1
+ import * as vscode from 'vscode-languageserver/browser';
2
+ import { LanguageServerPlugin } from './lib/types';
3
+ export * from './index';
4
+ export declare function createConnection(): vscode.Connection;
5
+ export declare function startLanguageServer(connection: vscode.Connection, ...plugins: LanguageServerPlugin[]): void;
6
+ //# sourceMappingURL=browser.d.ts.map
package/browser.js CHANGED
@@ -1 +1,138 @@
1
- module.exports = require('./out/browser');
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.startLanguageServer = exports.createConnection = void 0;
18
+ const vscode = require("vscode-languageserver/browser");
19
+ const server_1 = require("./lib/common/server");
20
+ const http_1 = require("./lib/common/schemaRequestHandlers/http");
21
+ const vscode_uri_1 = require("vscode-uri");
22
+ const protocol_1 = require("./protocol");
23
+ const language_service_1 = require("@volar/language-service");
24
+ __exportStar(require("./index"), exports);
25
+ function createConnection() {
26
+ const messageReader = new vscode.BrowserMessageReader(self);
27
+ const messageWriter = new vscode.BrowserMessageWriter(self);
28
+ const connection = vscode.createConnection(messageReader, messageWriter);
29
+ return connection;
30
+ }
31
+ exports.createConnection = createConnection;
32
+ function startLanguageServer(connection, ...plugins) {
33
+ (0, server_1.startCommonLanguageServer)(connection, plugins, () => ({
34
+ uriToFileName,
35
+ fileNameToUri,
36
+ console: connection.console,
37
+ timer: {
38
+ setImmediate(callback, ...args) {
39
+ const handle = setTimeout(callback, 0, ...args);
40
+ return { dispose: () => clearTimeout(handle) };
41
+ },
42
+ },
43
+ async loadTypeScript(options) {
44
+ const tsdkUrl = options.typescript && 'tsdkUrl' in options.typescript
45
+ ? options.typescript.tsdkUrl
46
+ : undefined;
47
+ if (!tsdkUrl) {
48
+ return;
49
+ }
50
+ const _module = globalThis.module;
51
+ globalThis.module = { exports: {} };
52
+ await import(`${tsdkUrl}/typescript.js`);
53
+ const ts = globalThis.module.exports;
54
+ globalThis.module = _module;
55
+ return ts;
56
+ },
57
+ async loadTypeScriptLocalized(options, locale) {
58
+ const tsdkUrl = options.typescript && 'tsdkUrl' in options.typescript
59
+ ? options.typescript.tsdkUrl
60
+ : undefined;
61
+ if (!tsdkUrl) {
62
+ return;
63
+ }
64
+ try {
65
+ const json = await (0, http_1.default)(`${tsdkUrl}/${locale}/diagnosticMessages.generated.json`);
66
+ if (json) {
67
+ return JSON.parse(json);
68
+ }
69
+ }
70
+ catch { }
71
+ },
72
+ fs: {
73
+ async stat(uri) {
74
+ if (uri.startsWith('__invalid__:')) {
75
+ return;
76
+ }
77
+ if (uri.startsWith('http://') || uri.startsWith('https://')) { // perf
78
+ const text = await this.readFile(uri);
79
+ if (text !== undefined) {
80
+ return {
81
+ type: language_service_1.FileType.File,
82
+ size: text.length,
83
+ ctime: -1,
84
+ mtime: -1,
85
+ };
86
+ }
87
+ return undefined;
88
+ }
89
+ return await connection.sendRequest(protocol_1.FsStatRequest.type, uri);
90
+ },
91
+ async readFile(uri) {
92
+ if (uri.startsWith('__invalid__:')) {
93
+ return;
94
+ }
95
+ if (uri.startsWith('http://') || uri.startsWith('https://')) { // perf
96
+ return await (0, http_1.default)(uri);
97
+ }
98
+ return await connection.sendRequest(protocol_1.FsReadFileRequest.type, uri) ?? undefined;
99
+ },
100
+ async readDirectory(uri) {
101
+ if (uri.startsWith('__invalid__:')) {
102
+ return [];
103
+ }
104
+ if (uri.startsWith('http://') || uri.startsWith('https://')) { // perf
105
+ return [];
106
+ }
107
+ return await connection.sendRequest(protocol_1.FsReadDirectoryRequest.type, uri);
108
+ },
109
+ },
110
+ getCancellationToken(original) {
111
+ return original ?? vscode.CancellationToken.None;
112
+ },
113
+ }));
114
+ }
115
+ exports.startLanguageServer = startLanguageServer;
116
+ function uriToFileName(uri) {
117
+ const parsed = vscode_uri_1.URI.parse(uri);
118
+ if (parsed.scheme === '__invalid__') {
119
+ return parsed.path;
120
+ }
121
+ return `/${parsed.scheme}${parsed.authority ? '@' + parsed.authority : ''}${parsed.path}`;
122
+ }
123
+ function fileNameToUri(fileName) {
124
+ const parts = fileName.split('/');
125
+ if (parts.length <= 1) {
126
+ return vscode_uri_1.URI.from({
127
+ scheme: '__invalid__',
128
+ path: fileName,
129
+ }).toString();
130
+ }
131
+ const firstParts = parts[1].split('@');
132
+ return vscode_uri_1.URI.from({
133
+ scheme: firstParts[0],
134
+ authority: firstParts.length > 1 ? firstParts[1] : undefined,
135
+ path: '/' + parts.slice(2).join('/'),
136
+ }).toString();
137
+ }
138
+ //# sourceMappingURL=browser.js.map
package/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './protocol';
2
+ export * from './lib/types';
3
+ export * from 'vscode-languageserver';
4
+ export * from '@volar/language-core/lib/types';
5
+ export * from '@volar/language-service/lib/types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -15,9 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./protocol"), exports);
18
- __exportStar(require("./types"), exports);
18
+ __exportStar(require("./lib/types"), exports);
19
19
  // only export types of depend packages
20
20
  __exportStar(require("vscode-languageserver"), exports);
21
- __exportStar(require("@volar/language-core/out/types"), exports);
22
- __exportStar(require("@volar/language-service/out/types"), exports);
21
+ __exportStar(require("@volar/language-core/lib/types"), exports);
22
+ __exportStar(require("@volar/language-service/lib/types"), exports);
23
23
  //# sourceMappingURL=index.js.map
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.register = void 0;
4
4
  const language_core_1 = require("@volar/language-core");
5
- const protocol_1 = require("../../protocol");
5
+ const protocol_1 = require("../../../protocol");
6
6
  function register(connection, workspaces, env) {
7
7
  const scriptVersions = new Map();
8
8
  const scriptVersionSnapshots = new WeakSet();
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sleep = exports.register = void 0;
4
4
  const embedded = require("@volar/language-service");
5
5
  const vscode = require("vscode-languageserver");
6
- const protocol_1 = require("../../protocol");
6
+ const protocol_1 = require("../../../protocol");
7
7
  const types_1 = require("../../types");
8
8
  function register(connection, workspaces, initParams, initOptions, semanticTokensLegend, runtime, documents) {
9
9
  let lastCompleteUri;
@@ -136,17 +136,17 @@ async function createProject(context) {
136
136
  projectVersion++;
137
137
  }
138
138
  }
139
- for (const change of changes) {
139
+ await Promise.all(changes.map(async (change) => {
140
140
  if (askedFiles.uriGet(change.uri) && globalSnapshots.get(fs).uriGet(change.uri)) {
141
141
  if (change.type === vscode.FileChangeType.Changed) {
142
- updateRootScriptSnapshot(change.uri);
142
+ await updateRootScriptSnapshot(change.uri);
143
143
  }
144
144
  else if (change.type === vscode.FileChangeType.Deleted) {
145
145
  globalSnapshots.get(fs).uriSet(change.uri, undefined);
146
146
  }
147
147
  projectVersion++;
148
148
  }
149
- }
149
+ }));
150
150
  if (oldProjectVersion !== projectVersion) {
151
151
  token = context.server.runtimeEnv.getCancellationToken();
152
152
  }
@@ -1,6 +1,6 @@
1
1
  import * as vscode from 'vscode-languageserver';
2
- import { InitializationOptions, LanguageServerPlugin, RuntimeEnvironment } from '../types';
3
- import { createConfigurationHost } from './configurationHost';
2
+ import { InitializationOptions, LanguageServerPlugin, RuntimeEnvironment } from '../types.js';
3
+ import { createConfigurationHost } from './configurationHost.js';
4
4
  export interface ServerContext {
5
5
  server: {
6
6
  initializeParams: vscode.InitializeParams;
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.startCommonLanguageServer = void 0;
4
- const language_service_1 = require("@volar/language-service");
4
+ const index_js_1 = require("@volar/language-service/index.js");
5
5
  const l10n = require("@vscode/l10n");
6
6
  const vscode = require("vscode-languageserver");
7
7
  const vscode_uri_1 = require("vscode-uri");
8
- const types_1 = require("../types");
9
- const configurationHost_1 = require("./configurationHost");
10
- const documents_1 = require("./documents");
11
- const registerFeatures_1 = require("./utils/registerFeatures");
12
- const serverConfig_1 = require("./utils/serverConfig");
13
- const workspaces_1 = require("./workspaces");
8
+ const types_js_1 = require("../types.js");
9
+ const configurationHost_js_1 = require("./configurationHost.js");
10
+ const documents_js_1 = require("./documents.js");
11
+ const registerFeatures_js_1 = require("./utils/registerFeatures.js");
12
+ const serverConfig_js_1 = require("./utils/serverConfig.js");
13
+ const workspaces_js_1 = require("./workspaces.js");
14
14
  const request_light_1 = require("request-light");
15
15
  function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
16
16
  let initParams;
@@ -36,7 +36,7 @@ function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
36
36
  fs: createFsWithCache(env.fs),
37
37
  },
38
38
  plugins: _plugins,
39
- configurationHost: initParams.capabilities.workspace?.configuration ? (0, configurationHost_1.createConfigurationHost)(initParams, connection) : undefined,
39
+ configurationHost: initParams.capabilities.workspace?.configuration ? (0, configurationHost_js_1.createConfigurationHost)(initParams, connection) : undefined,
40
40
  onDidChangeWatchedFiles: cb => {
41
41
  didChangeWatchedFilesCallbacks.add(cb);
42
42
  return {
@@ -52,7 +52,7 @@ function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
52
52
  ? await context.server.runtimeEnv.loadTypeScriptLocalized(options, initParams.locale)
53
53
  : undefined;
54
54
  plugins = context.server.plugins.map(plugin => plugin(options, { typescript: ts }));
55
- documents = (0, documents_1.createDocuments)(context.server.runtimeEnv, connection);
55
+ documents = (0, documents_js_1.createDocuments)(context.server.runtimeEnv, connection);
56
56
  if (options.l10n) {
57
57
  await l10n.config({ uri: options.l10n.location });
58
58
  }
@@ -80,7 +80,7 @@ function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
80
80
  let config = {};
81
81
  for (const root of roots) {
82
82
  if (root.scheme === 'file') {
83
- const workspaceConfig = (0, serverConfig_1.loadConfig)(env.console, root.path, options.configFilePath);
83
+ const workspaceConfig = (0, serverConfig_js_1.loadConfig)(env.console, root.path, options.configFilePath);
84
84
  if (workspaceConfig) {
85
85
  config = workspaceConfig;
86
86
  break;
@@ -92,7 +92,7 @@ function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
92
92
  config = await plugin.resolveConfig(config, undefined);
93
93
  }
94
94
  }
95
- (0, registerFeatures_1.setupCapabilities)(result.capabilities, options, plugins, getSemanticTokensLegend(), config.services ?? {});
95
+ (0, registerFeatures_js_1.setupCapabilities)(result.capabilities, options, plugins, getSemanticTokensLegend(), config.services ?? {});
96
96
  await createLanguageServiceHost();
97
97
  try {
98
98
  // show version on LSP logs
@@ -119,7 +119,7 @@ function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
119
119
  }
120
120
  });
121
121
  }
122
- if (options.serverMode !== types_1.ServerMode.Syntactic
122
+ if (options.serverMode !== types_js_1.ServerMode.Syntactic
123
123
  && initParams.capabilities.workspace?.didChangeWatchedFiles?.dynamicRegistration) {
124
124
  const exts = plugins.map(plugin => plugin.watchFileExtensions).flat();
125
125
  if (exts.length) {
@@ -192,7 +192,7 @@ function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
192
192
  };
193
193
  }
194
194
  async function createLanguageServiceHost() {
195
- workspaces = (0, workspaces_1.createWorkspaces)({
195
+ workspaces = (0, workspaces_js_1.createWorkspaces)({
196
196
  ...context,
197
197
  workspaces: {
198
198
  ts,
@@ -215,11 +215,11 @@ function startCommonLanguageServer(connection, _plugins, getRuntimeEnv) {
215
215
  }
216
216
  function getSemanticTokensLegend() {
217
217
  if (!options.semanticTokensLegend) {
218
- return language_service_1.standardSemanticTokensLegend;
218
+ return index_js_1.standardSemanticTokensLegend;
219
219
  }
220
220
  return {
221
- tokenTypes: [...language_service_1.standardSemanticTokensLegend.tokenTypes, ...options.semanticTokensLegend.tokenTypes],
222
- tokenModifiers: [...language_service_1.standardSemanticTokensLegend.tokenModifiers, ...options.semanticTokensLegend.tokenModifiers],
221
+ tokenTypes: [...index_js_1.standardSemanticTokensLegend.tokenTypes, ...options.semanticTokensLegend.tokenTypes],
222
+ tokenModifiers: [...index_js_1.standardSemanticTokensLegend.tokenModifiers, ...options.semanticTokensLegend.tokenModifiers],
223
223
  };
224
224
  }
225
225
  }
@@ -48,9 +48,9 @@ export interface InitializationOptions {
48
48
  } | {
49
49
  /**
50
50
  * URI to node_modules/typescript/lib, available for web
51
- * @example "https://cdn.jsdelivr.net/npm/typescript"
52
- * @example "https://cdn.jsdelivr.net/npm/typescript@latest"
53
- * @example "https://cdn.jsdelivr.net/npm/typescript@5.0.0"
51
+ * @example "https://cdn.jsdelivr.net/npm/typescript/lib"
52
+ * @example "https://cdn.jsdelivr.net/npm/typescript@latest/lib"
53
+ * @example "https://cdn.jsdelivr.net/npm/typescript@5.0.0/lib"
54
54
  */
55
55
  tsdkUrl: string;
56
56
  };
package/node.d.ts CHANGED
@@ -1 +1,10 @@
1
- export * from './out/node';
1
+ import * as vscode from 'vscode-languageserver/node';
2
+ import { InitializationOptions, LanguageServerPlugin } from './lib/types';
3
+ import { FileSystem } from '@volar/language-service';
4
+ export * from './index';
5
+ export declare const uriToFileName: (uri: string) => string;
6
+ export declare const fileNameToUri: (fileName: string) => string;
7
+ export declare function createFs(options: InitializationOptions): FileSystem;
8
+ export declare function createConnection(): vscode._Connection<vscode._, vscode._, vscode._, vscode._, vscode._, vscode._, import("vscode-languageserver/lib/common/inlineCompletion.proposed").InlineCompletionFeatureShape, vscode._>;
9
+ export declare function startLanguageServer(connection: vscode.Connection, ...plugins: LanguageServerPlugin[]): void;
10
+ //# sourceMappingURL=node.d.ts.map
package/node.js CHANGED
@@ -1 +1,149 @@
1
- module.exports = require('./out/node');
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.startLanguageServer = exports.createConnection = exports.createFs = exports.fileNameToUri = exports.uriToFileName = void 0;
18
+ const fs = require("fs");
19
+ const vscode = require("vscode-languageserver/node");
20
+ const vscode_uri_1 = require("vscode-uri");
21
+ const http_1 = require("./lib/common/schemaRequestHandlers/http");
22
+ const server_1 = require("./lib/common/server");
23
+ const language_service_1 = require("@volar/language-service");
24
+ const cancellationPipe_1 = require("./lib/node/cancellationPipe");
25
+ __exportStar(require("./index"), exports);
26
+ const uriToFileName = (uri) => vscode_uri_1.URI.parse(uri).fsPath.replace(/\\/g, '/');
27
+ exports.uriToFileName = uriToFileName;
28
+ const fileNameToUri = (fileName) => vscode_uri_1.URI.file(fileName).toString();
29
+ exports.fileNameToUri = fileNameToUri;
30
+ function createFs(options) {
31
+ return {
32
+ stat(uri) {
33
+ if (uri.startsWith('file://')) {
34
+ try {
35
+ const stats = fs.statSync((0, exports.uriToFileName)(uri), { throwIfNoEntry: false });
36
+ if (stats) {
37
+ return {
38
+ type: stats.isFile() ? language_service_1.FileType.File
39
+ : stats.isDirectory() ? language_service_1.FileType.Directory
40
+ : stats.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
41
+ : language_service_1.FileType.Unknown,
42
+ ctime: stats.ctimeMs,
43
+ mtime: stats.mtimeMs,
44
+ size: stats.size,
45
+ };
46
+ }
47
+ }
48
+ catch {
49
+ return undefined;
50
+ }
51
+ }
52
+ },
53
+ readFile(uri, encoding) {
54
+ if (uri.startsWith('file://')) {
55
+ try {
56
+ if (options.maxFileSize) {
57
+ const stats = fs.statSync((0, exports.uriToFileName)(uri), { throwIfNoEntry: false });
58
+ if (stats && stats.size > options.maxFileSize) {
59
+ console.warn(`[volar] file size exceeded limit: ${uri} (${stats.size} > ${options.maxFileSize})`);
60
+ return undefined;
61
+ }
62
+ }
63
+ return fs.readFileSync((0, exports.uriToFileName)(uri), { encoding: encoding ?? 'utf-8' });
64
+ }
65
+ catch {
66
+ return undefined;
67
+ }
68
+ }
69
+ if (uri.startsWith('http://') || uri.startsWith('https://')) {
70
+ return (0, http_1.default)(uri);
71
+ }
72
+ },
73
+ readDirectory(uri) {
74
+ if (uri.startsWith('file://')) {
75
+ try {
76
+ const dirName = (0, exports.uriToFileName)(uri);
77
+ const files = fs.readdirSync(dirName, { withFileTypes: true });
78
+ return files.map(file => {
79
+ return [file.name, file.isFile() ? language_service_1.FileType.File
80
+ : file.isDirectory() ? language_service_1.FileType.Directory
81
+ : file.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
82
+ : language_service_1.FileType.Unknown];
83
+ });
84
+ }
85
+ catch {
86
+ return [];
87
+ }
88
+ }
89
+ return [];
90
+ },
91
+ };
92
+ }
93
+ exports.createFs = createFs;
94
+ function createConnection() {
95
+ return vscode.createConnection(vscode.ProposedFeatures.all);
96
+ }
97
+ exports.createConnection = createConnection;
98
+ function startLanguageServer(connection, ...plugins) {
99
+ (0, server_1.startCommonLanguageServer)(connection, plugins, (_, options) => ({
100
+ uriToFileName: exports.uriToFileName,
101
+ fileNameToUri: exports.fileNameToUri,
102
+ console: connection.console,
103
+ timer: {
104
+ setImmediate(callback, ...args) {
105
+ const handle = setImmediate(callback, ...args);
106
+ return { dispose: () => clearImmediate(handle) };
107
+ },
108
+ },
109
+ loadTypeScript(options) {
110
+ const tsdk = options.typescript && 'tsdk' in options.typescript
111
+ ? options.typescript.tsdk
112
+ : undefined;
113
+ if (!tsdk) {
114
+ return;
115
+ }
116
+ for (const name of ['./typescript.js', './tsserverlibrary.js']) {
117
+ try {
118
+ return require(require.resolve(name, { paths: [tsdk] }));
119
+ }
120
+ catch { }
121
+ }
122
+ // for bun
123
+ for (const name of ['typescript.js', 'tsserverlibrary.js']) {
124
+ try {
125
+ return require(tsdk + '/' + name);
126
+ }
127
+ catch { }
128
+ }
129
+ throw new Error(`Can't find typescript.js or tsserverlibrary.js in ${tsdk}`);
130
+ },
131
+ async loadTypeScriptLocalized(options, locale) {
132
+ const tsdk = options.typescript && 'tsdk' in options.typescript
133
+ ? options.typescript.tsdk
134
+ : undefined;
135
+ if (!tsdk) {
136
+ return;
137
+ }
138
+ try {
139
+ const path = require.resolve(`./${locale}/diagnosticMessages.generated.json`, { paths: [tsdk] });
140
+ return require(path);
141
+ }
142
+ catch { }
143
+ },
144
+ fs: createFs(options),
145
+ getCancellationToken: (0, cancellationPipe_1.createGetCancellationToken)(options.cancellationPipeName),
146
+ }));
147
+ }
148
+ exports.startLanguageServer = startLanguageServer;
149
+ //# sourceMappingURL=node.js.map
package/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "@volar/language-server",
3
- "version": "1.10.10",
4
- "main": "out/index.js",
3
+ "version": "1.11.0",
5
4
  "license": "MIT",
6
5
  "files": [
7
- "out/**/*.js",
8
- "out/**/*.d.ts",
9
- "*.js",
10
- "*.d.ts"
6
+ "**/*.js",
7
+ "**/*.d.ts"
11
8
  ],
12
9
  "repository": {
13
10
  "type": "git",
@@ -15,9 +12,9 @@
15
12
  "directory": "packages/language-server"
16
13
  },
17
14
  "dependencies": {
18
- "@volar/language-core": "1.10.10",
19
- "@volar/language-service": "1.10.10",
20
- "@volar/typescript": "1.10.10",
15
+ "@volar/language-core": "1.11.0",
16
+ "@volar/language-service": "1.11.0",
17
+ "@volar/typescript": "1.11.0",
21
18
  "@vscode/l10n": "^0.0.16",
22
19
  "path-browserify": "^1.0.1",
23
20
  "request-light": "^0.7.0",
@@ -28,7 +25,7 @@
28
25
  },
29
26
  "devDependencies": {
30
27
  "@types/path-browserify": "latest",
31
- "@volar/source-map": "1.10.10"
28
+ "@volar/source-map": "1.11.0"
32
29
  },
33
- "gitHead": "c3f1b9e52b738e5e5340ad1aeb827f7ca51bc573"
30
+ "gitHead": "e3f563cbbf4cc03c058f5df38df0498034e5feb5"
34
31
  }
package/protocol.d.ts CHANGED
@@ -1 +1,79 @@
1
- export * from './out/protocol';
1
+ import * as vscode from 'vscode-languageserver-protocol';
2
+ import type { VirtualFile, FileRangeCapabilities } from '@volar/language-core';
3
+ import type { Mapping, Stack } from '@volar/source-map';
4
+ import type { FileStat, FileType } from '@volar/language-service';
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
+ }
17
+ /**
18
+ * Client request server
19
+ */
20
+ export declare namespace FindFileReferenceRequest {
21
+ type ParamsType = {
22
+ textDocument: vscode.TextDocumentIdentifier;
23
+ };
24
+ type ResponseType = vscode.Location[] | null | undefined;
25
+ type ErrorType = never;
26
+ const type: vscode.RequestType<ParamsType, ResponseType, never>;
27
+ }
28
+ export declare namespace GetMatchTsConfigRequest {
29
+ type ParamsType = vscode.TextDocumentIdentifier;
30
+ type ResponseType = {
31
+ uri: string;
32
+ } | null | undefined;
33
+ type ErrorType = never;
34
+ const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
35
+ }
36
+ export declare namespace AutoInsertRequest {
37
+ type ParamsType = vscode.TextDocumentPositionParams & {
38
+ options: {
39
+ lastChange: {
40
+ range: vscode.Range;
41
+ rangeOffset: number;
42
+ rangeLength: number;
43
+ text: string;
44
+ };
45
+ };
46
+ };
47
+ type ResponseType = string | vscode.TextEdit | null | undefined;
48
+ type ErrorType = never;
49
+ const type: vscode.RequestType<ParamsType, ResponseType, never>;
50
+ }
51
+ export declare namespace LoadedTSFilesMetaRequest {
52
+ const type: vscode.RequestType0<unknown, unknown>;
53
+ }
54
+ export declare namespace WriteVirtualFilesNotification {
55
+ const type: vscode.NotificationType<vscode.TextDocumentIdentifier>;
56
+ }
57
+ export declare namespace ReloadProjectNotification {
58
+ const type: vscode.NotificationType<vscode.TextDocumentIdentifier>;
59
+ }
60
+ export declare namespace GetVirtualFilesRequest {
61
+ type ParamsType = vscode.TextDocumentIdentifier;
62
+ type ResponseType = VirtualFile | null | undefined;
63
+ type ErrorType = never;
64
+ const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
65
+ }
66
+ export declare namespace GetVirtualFileRequest {
67
+ type ParamsType = {
68
+ sourceFileUri: string;
69
+ virtualFileName: string;
70
+ };
71
+ type ResponseType = {
72
+ content: string;
73
+ mappings: Record<string, Mapping<FileRangeCapabilities>[]>;
74
+ codegenStacks: Stack[];
75
+ };
76
+ type ErrorType = never;
77
+ const type: vscode.RequestType<ParamsType, ResponseType, never>;
78
+ }
79
+ //# sourceMappingURL=protocol.d.ts.map