@volar/vscode 2.2.0-alpha.8 → 2.2.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.
package/index.d.ts CHANGED
@@ -3,7 +3,6 @@ export { activate as activateAutoInsertion } from './lib/features/autoInsertion'
3
3
  export { activate as activateDocumentDropEdit } from './lib/features/documentDropEdits';
4
4
  export { activate as activateWriteVirtualFiles } from './lib/features/writeVirtualFiles';
5
5
  export { activate as activateFindFileReferences } from './lib/features/fileReferences';
6
- export { activate as activateReloadProjects } from './lib/features/reloadProject';
7
6
  export { activate as activateTsConfigStatusItem } from './lib/features/tsconfig';
8
7
  export { activate as activateServerSys } from './lib/features/serverSys';
9
8
  export { activate as activateTsVersionStatusItem, getTsdk } from './lib/features/tsVersion';
package/index.js CHANGED
@@ -14,7 +14,7 @@ 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.createLabsInfo = exports.currentLabsVersion = exports.parseServerCommand = exports.middleware = exports.getTsdk = exports.activateTsVersionStatusItem = exports.activateServerSys = exports.activateTsConfigStatusItem = exports.activateReloadProjects = exports.activateFindFileReferences = exports.activateWriteVirtualFiles = exports.activateDocumentDropEdit = exports.activateAutoInsertion = void 0;
17
+ exports.createLabsInfo = exports.currentLabsVersion = exports.parseServerCommand = exports.middleware = exports.getTsdk = exports.activateTsVersionStatusItem = exports.activateServerSys = exports.activateTsConfigStatusItem = exports.activateFindFileReferences = exports.activateWriteVirtualFiles = exports.activateDocumentDropEdit = exports.activateAutoInsertion = void 0;
18
18
  const vscode = require("vscode");
19
19
  var autoInsertion_1 = require("./lib/features/autoInsertion");
20
20
  Object.defineProperty(exports, "activateAutoInsertion", { enumerable: true, get: function () { return autoInsertion_1.activate; } });
@@ -24,8 +24,6 @@ var writeVirtualFiles_1 = require("./lib/features/writeVirtualFiles");
24
24
  Object.defineProperty(exports, "activateWriteVirtualFiles", { enumerable: true, get: function () { return writeVirtualFiles_1.activate; } });
25
25
  var fileReferences_1 = require("./lib/features/fileReferences");
26
26
  Object.defineProperty(exports, "activateFindFileReferences", { enumerable: true, get: function () { return fileReferences_1.activate; } });
27
- var reloadProject_1 = require("./lib/features/reloadProject");
28
- Object.defineProperty(exports, "activateReloadProjects", { enumerable: true, get: function () { return reloadProject_1.activate; } });
29
27
  var tsconfig_1 = require("./lib/features/tsconfig");
30
28
  Object.defineProperty(exports, "activateTsConfigStatusItem", { enumerable: true, get: function () { return tsconfig_1.activate; } });
31
29
  var serverSys_1 = require("./lib/features/serverSys");
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.activate = void 0;
4
4
  const vscode = require("vscode");
5
5
  const protocol_1 = require("@volar/language-server/protocol");
6
+ const fs = require("../fs");
6
7
  function activate(client) {
7
8
  const subscriptions = [];
8
- const textDecoder = new TextDecoder();
9
9
  const jobs = new Map();
10
10
  const progressAssets = new Set();
11
11
  let startProgress = false;
@@ -70,7 +70,7 @@ function activate(client) {
70
70
  return;
71
71
  }
72
72
  const uri2 = client.protocol2CodeConverter.asUri(uri);
73
- return await _stat(uri2);
73
+ return await fs.stat(uri2);
74
74
  }
75
75
  async function readFile(uri) {
76
76
  // return early
@@ -81,33 +81,13 @@ function activate(client) {
81
81
  if (!entries.some(entry => entry[0] === baseName && entry[1] === vscode.FileType.File)) {
82
82
  return;
83
83
  }
84
- return await _readFile(uri2);
84
+ return await fs.readFile(uri2);
85
85
  }
86
86
  async function readDirectory(uri) {
87
87
  const uri2 = client.protocol2CodeConverter.asUri(uri);
88
- return await (await _readDirectory(uri2))
88
+ return await (await fs.readDirectory(uri2))
89
89
  .filter(([name]) => !name.startsWith('.'));
90
90
  }
91
- async function _readFile(uri) {
92
- try {
93
- return textDecoder.decode(await vscode.workspace.fs.readFile(uri));
94
- }
95
- catch { }
96
- }
97
- async function _readDirectory(uri) {
98
- try {
99
- return await vscode.workspace.fs.readDirectory(uri);
100
- }
101
- catch {
102
- return [];
103
- }
104
- }
105
- async function _stat(uri) {
106
- try {
107
- return await vscode.workspace.fs.stat(uri);
108
- }
109
- catch { }
110
- }
111
91
  }
112
92
  }
113
93
  exports.activate = activate;
@@ -4,6 +4,7 @@ exports.getTsdk = exports.activate = void 0;
4
4
  const path = require("path-browserify");
5
5
  const vscode = require("vscode");
6
6
  const common_1 = require("../common");
7
+ const fs = require("../fs");
7
8
  const defaultTsdkPath = 'node_modules/typescript/lib';
8
9
  function activate(selector, cmd, context, client, resolveStatusText) {
9
10
  const subscriptions = [];
@@ -77,13 +78,16 @@ function activate(selector, cmd, context, client, resolveStatusText) {
77
78
  exports.activate = activate;
78
79
  async function getTsdk(context) {
79
80
  if (isUseWorkspaceTsdk(context)) {
80
- const resolvedTsdk = await resolveWorkspaceTsdk(getConfigTsdkPath() || defaultTsdkPath);
81
- if (resolvedTsdk) {
82
- return {
83
- tsdk: resolvedTsdk,
84
- version: await getTsVersion(resolvedTsdk),
85
- isWorkspacePath: true,
86
- };
81
+ const tsdkPath = getConfigTsdkPath();
82
+ if (tsdkPath) {
83
+ const resolvedTsdk = await resolveWorkspaceTsdk(tsdkPath);
84
+ if (resolvedTsdk) {
85
+ return {
86
+ tsdk: resolvedTsdk,
87
+ version: await getTsVersion(resolvedTsdk),
88
+ isWorkspacePath: true,
89
+ };
90
+ }
87
91
  }
88
92
  }
89
93
  const tsdk = await getVScodeTsdk();
@@ -97,8 +101,8 @@ exports.getTsdk = getTsdk;
97
101
  async function resolveWorkspaceTsdk(tsdk) {
98
102
  if (path.isAbsolute(tsdk)) {
99
103
  const libUri = vscode.Uri.joinPath(vscode.Uri.file(tsdk), 'typescript.js');
100
- const stat = await vscode.workspace.fs.stat(libUri);
101
- if (stat.type === vscode.FileType.File) {
104
+ const stat = await fs.stat(libUri);
105
+ if (stat?.type === vscode.FileType.File) {
102
106
  return tsdk;
103
107
  }
104
108
  }
@@ -106,8 +110,8 @@ async function resolveWorkspaceTsdk(tsdk) {
106
110
  for (const folder of vscode.workspace.workspaceFolders) {
107
111
  const tsdkPath = path.join(folder.uri.fsPath.replace(/\\/g, '/'), tsdk);
108
112
  const libUri = vscode.Uri.joinPath(vscode.Uri.file(tsdkPath), 'typescript.js');
109
- const stat = await vscode.workspace.fs.stat(libUri);
110
- if (stat.type === vscode.FileType.File) {
113
+ const stat = await fs.stat(libUri);
114
+ if (stat?.type === vscode.FileType.File) {
111
115
  return tsdkPath;
112
116
  }
113
117
  }
@@ -150,7 +154,7 @@ async function getTsVersion(libPath) {
150
154
  const p2 = p.slice(0, -1);
151
155
  const modulePath = p2.join('/');
152
156
  const filePath = modulePath + '/package.json';
153
- const contents = await readFile(filePath);
157
+ const contents = await fs.readFile(vscode.Uri.file(filePath));
154
158
  if (contents === undefined) {
155
159
  return;
156
160
  }
@@ -166,11 +170,4 @@ async function getTsVersion(libPath) {
166
170
  }
167
171
  return desc.version;
168
172
  }
169
- async function readFile(path) {
170
- try {
171
- const data = await vscode.workspace.fs.readFile(vscode.Uri.file(path));
172
- return new TextDecoder('utf8').decode(data);
173
- }
174
- catch { }
175
- }
176
173
  //# sourceMappingURL=tsVersion.js.map
package/lib/fs.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import * as vscode from 'vscode';
2
+ export declare function readFile(uri: vscode.Uri): Promise<string | undefined>;
3
+ export declare function readDirectory(uri: vscode.Uri): Promise<[string, vscode.FileType][]>;
4
+ export declare function stat(uri: vscode.Uri): Promise<vscode.FileStat | undefined>;
package/lib/fs.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stat = exports.readDirectory = exports.readFile = void 0;
4
+ const vscode = require("vscode");
5
+ const textDecoder = new TextDecoder('utf8');
6
+ async function readFile(uri) {
7
+ try {
8
+ return textDecoder.decode(await vscode.workspace.fs.readFile(uri));
9
+ }
10
+ catch { }
11
+ }
12
+ exports.readFile = readFile;
13
+ async function readDirectory(uri) {
14
+ try {
15
+ return await vscode.workspace.fs.readDirectory(uri);
16
+ }
17
+ catch {
18
+ return [];
19
+ }
20
+ }
21
+ exports.readDirectory = readDirectory;
22
+ async function stat(uri) {
23
+ try {
24
+ return await vscode.workspace.fs.stat(uri);
25
+ }
26
+ catch { }
27
+ }
28
+ exports.stat = stat;
29
+ //# sourceMappingURL=fs.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/vscode",
3
- "version": "2.2.0-alpha.8",
3
+ "version": "2.2.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/vscode"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/language-server": "2.2.0-alpha.8",
15
+ "@volar/language-server": "2.2.0",
16
16
  "path-browserify": "^1.0.1",
17
17
  "vscode-languageclient": "^9.0.1",
18
18
  "vscode-nls": "^5.2.0"
@@ -22,5 +22,5 @@
22
22
  "@types/path-browserify": "latest",
23
23
  "@types/vscode": "^1.82.0"
24
24
  },
25
- "gitHead": "a48e2549a5bf216ab655e4ef7e6d8c545d10d558"
25
+ "gitHead": "c6e8d2765bbd2ec4a37374fd3a3a31c02661e8b3"
26
26
  }
@@ -1,3 +0,0 @@
1
- import * as vscode from 'vscode';
2
- import type { BaseLanguageClient } from 'vscode-languageclient';
3
- export declare function activate(cmd: string, client: BaseLanguageClient): vscode.Disposable;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.activate = void 0;
4
- const vscode = require("vscode");
5
- const protocol_1 = require("@volar/language-server/protocol");
6
- function activate(cmd, client) {
7
- return vscode.commands.registerCommand(cmd, () => {
8
- if (vscode.window.activeTextEditor) {
9
- client.sendNotification(protocol_1.ReloadProjectNotification.type, client.code2ProtocolConverter.asTextDocumentIdentifier(vscode.window.activeTextEditor.document));
10
- }
11
- });
12
- }
13
- exports.activate = activate;
14
- //# sourceMappingURL=reloadProject.js.map