@volar/vscode 2.0.0-alpha.0 → 2.0.0-alpha.10
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 +8 -4
- package/index.js +21 -19
- package/lib/features/autoInsertion.d.ts +1 -1
- package/lib/features/autoInsertion.js +18 -20
- package/lib/features/documentDropEdits.js +13 -0
- package/lib/features/reloadProject.d.ts +1 -1
- package/lib/features/reloadProject.js +2 -4
- package/lib/features/tsVersion.d.ts +1 -1
- package/lib/features/tsVersion.js +2 -11
- package/lib/features/tsconfig.d.ts +1 -1
- package/lib/features/tsconfig.js +2 -2
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -8,15 +8,19 @@ export { activate as activateTsConfigStatusItem } from './lib/features/tsconfig'
|
|
|
8
8
|
export { activate as activateServerSys } from './lib/features/serverSys';
|
|
9
9
|
export { activate as activateTsVersionStatusItem, getTsdk } from './lib/features/tsVersion';
|
|
10
10
|
export * from 'vscode-languageclient';
|
|
11
|
-
export declare function takeOverModeActive(context: vscode.ExtensionContext): boolean;
|
|
12
11
|
import type { BaseLanguageClient, Middleware } from 'vscode-languageclient';
|
|
13
12
|
export declare const middleware: Middleware;
|
|
14
13
|
export declare function parseServerCommand(command: vscode.Command): vscode.Command;
|
|
15
|
-
export declare const
|
|
16
|
-
export
|
|
14
|
+
export declare const currentLabsVersion = "2.0.0-alpha.9";
|
|
15
|
+
export declare function createLabsInfo(languageServerProtocol: typeof import('@volar/language-server/protocol')): {
|
|
16
|
+
extensionExports: LabsInfo;
|
|
17
|
+
addLanguageClient(languageClient: BaseLanguageClient): void;
|
|
18
|
+
};
|
|
19
|
+
export interface LabsInfo {
|
|
17
20
|
volarLabs: {
|
|
18
|
-
version: typeof
|
|
21
|
+
version: typeof currentLabsVersion;
|
|
19
22
|
languageClients: BaseLanguageClient[];
|
|
23
|
+
onDidAddLanguageClient: vscode.Event<BaseLanguageClient>;
|
|
20
24
|
languageServerProtocol: typeof import('@volar/language-server/protocol');
|
|
21
25
|
codegenStackSupport?: boolean;
|
|
22
26
|
};
|
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.
|
|
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;
|
|
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; } });
|
|
@@ -34,24 +34,7 @@ var tsVersion_1 = require("./lib/features/tsVersion");
|
|
|
34
34
|
Object.defineProperty(exports, "activateTsVersionStatusItem", { enumerable: true, get: function () { return tsVersion_1.activate; } });
|
|
35
35
|
Object.defineProperty(exports, "getTsdk", { enumerable: true, get: function () { return tsVersion_1.getTsdk; } });
|
|
36
36
|
__exportStar(require("vscode-languageclient"), exports);
|
|
37
|
-
function takeOverModeActive(context) {
|
|
38
|
-
if (vscode.workspace.getConfiguration('volar').get('takeOverMode.extension') === context.extension.id) {
|
|
39
|
-
return !vscode.extensions.getExtension('vscode.typescript-language-features');
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
exports.takeOverModeActive = takeOverModeActive;
|
|
44
37
|
exports.middleware = {
|
|
45
|
-
async provideHover(document, position, token, next) {
|
|
46
|
-
const hover = await next(document, position, token);
|
|
47
|
-
for (const content of hover?.contents ?? []) {
|
|
48
|
-
if (content instanceof vscode.MarkdownString) {
|
|
49
|
-
content.isTrusted = true;
|
|
50
|
-
content.supportHtml = true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return hover;
|
|
54
|
-
},
|
|
55
38
|
async provideCodeActions(document, range, context, token, next) {
|
|
56
39
|
let actions = await next(document, range, context, token);
|
|
57
40
|
actions = actions?.map(action => {
|
|
@@ -113,5 +96,24 @@ function parseServerCommand(command) {
|
|
|
113
96
|
return command;
|
|
114
97
|
}
|
|
115
98
|
exports.parseServerCommand = parseServerCommand;
|
|
116
|
-
exports.
|
|
99
|
+
exports.currentLabsVersion = '2.0.0-alpha.9';
|
|
100
|
+
function createLabsInfo(languageServerProtocol) {
|
|
101
|
+
const onDidAddLanguageClientEmitter = new vscode.EventEmitter();
|
|
102
|
+
const extensionExports = {
|
|
103
|
+
volarLabs: {
|
|
104
|
+
version: exports.currentLabsVersion,
|
|
105
|
+
languageClients: [],
|
|
106
|
+
languageServerProtocol,
|
|
107
|
+
onDidAddLanguageClient: onDidAddLanguageClientEmitter.event,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
return {
|
|
111
|
+
extensionExports,
|
|
112
|
+
addLanguageClient(languageClient) {
|
|
113
|
+
extensionExports.volarLabs.languageClients.push(languageClient);
|
|
114
|
+
onDidAddLanguageClientEmitter.fire(languageClient);
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
exports.createLabsInfo = createLabsInfo;
|
|
117
119
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode';
|
|
2
2
|
import type { BaseLanguageClient } from 'vscode-languageclient';
|
|
3
|
-
export declare function activate(
|
|
3
|
+
export declare function activate(selector: vscode.DocumentSelector, client: BaseLanguageClient): vscode.Disposable;
|
|
@@ -3,7 +3,7 @@ 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
|
-
function activate(
|
|
6
|
+
function activate(selector, client) {
|
|
7
7
|
let isEnabled = false;
|
|
8
8
|
let timeout;
|
|
9
9
|
updateEnabledState();
|
|
@@ -17,7 +17,7 @@ function activate(clients, active) {
|
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
let document = editor.document;
|
|
20
|
-
if (!
|
|
20
|
+
if (!vscode.languages.match(selector, document)) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
isEnabled = true;
|
|
@@ -32,24 +32,22 @@ function activate(clients, active) {
|
|
|
32
32
|
}
|
|
33
33
|
const lastChange = contentChanges[contentChanges.length - 1];
|
|
34
34
|
doAutoInsert(document, lastChange, async (document, position, lastChange, isCancel) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return client.protocol2CodeConverter.asTextEdit(result);
|
|
52
|
-
}
|
|
35
|
+
const params = {
|
|
36
|
+
...client.code2ProtocolConverter.asTextDocumentPositionParams(document, position),
|
|
37
|
+
lastChange: {
|
|
38
|
+
text: lastChange.text,
|
|
39
|
+
range: client.code2ProtocolConverter.asRange(lastChange.range),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
if (isCancel())
|
|
43
|
+
return;
|
|
44
|
+
const result = await client.sendRequest(protocol_1.AutoInsertRequest.type, params);
|
|
45
|
+
if (result !== undefined && result !== null) {
|
|
46
|
+
if (typeof result === 'string') {
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return client.protocol2CodeConverter.asTextEdit(result);
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
53
|
});
|
|
@@ -34,6 +34,19 @@ function activate(selector, client) {
|
|
|
34
34
|
if (result.additionalEdit) {
|
|
35
35
|
edit.additionalEdit = await client.protocol2CodeConverter.asWorkspaceEdit(result.additionalEdit);
|
|
36
36
|
}
|
|
37
|
+
if (result.createDataTransferFile) {
|
|
38
|
+
edit.additionalEdit ??= new vscode.WorkspaceEdit();
|
|
39
|
+
for (const create of result.createDataTransferFile) {
|
|
40
|
+
const file = dataTransfer.get(create.contentsMimeType)?.asFile();
|
|
41
|
+
if (file) {
|
|
42
|
+
edit.additionalEdit.createFile(client.protocol2CodeConverter.asUri(create.uri), {
|
|
43
|
+
ignoreIfExists: create.options?.ignoreIfExists,
|
|
44
|
+
overwrite: create.options?.overwrite,
|
|
45
|
+
contents: await file.data(),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
37
50
|
return edit;
|
|
38
51
|
}
|
|
39
52
|
},
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode';
|
|
2
2
|
import type { BaseLanguageClient } from 'vscode-languageclient';
|
|
3
|
-
export declare function activate(cmd: string,
|
|
3
|
+
export declare function activate(cmd: string, client: BaseLanguageClient): vscode.Disposable;
|
|
@@ -3,12 +3,10 @@ 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
|
-
function activate(cmd,
|
|
6
|
+
function activate(cmd, client) {
|
|
7
7
|
return vscode.commands.registerCommand(cmd, () => {
|
|
8
8
|
if (vscode.window.activeTextEditor) {
|
|
9
|
-
|
|
10
|
-
client.sendNotification(protocol_1.ReloadProjectNotification.type, client.code2ProtocolConverter.asTextDocumentIdentifier(vscode.window.activeTextEditor.document));
|
|
11
|
-
}
|
|
9
|
+
client.sendNotification(protocol_1.ReloadProjectNotification.type, client.code2ProtocolConverter.asTextDocumentIdentifier(vscode.window.activeTextEditor.document));
|
|
12
10
|
}
|
|
13
11
|
});
|
|
14
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vscode from 'vscode';
|
|
2
2
|
import type { BaseLanguageClient } from 'vscode-languageclient';
|
|
3
|
-
export declare function activate(cmd: string, context: vscode.ExtensionContext, client: BaseLanguageClient,
|
|
3
|
+
export declare function activate(selector: vscode.DocumentSelector, cmd: string, context: vscode.ExtensionContext, client: BaseLanguageClient, resolveStatusText: (text: string) => string): vscode.Disposable;
|
|
4
4
|
export declare function getTsdk(context: vscode.ExtensionContext): Promise<{
|
|
5
5
|
tsdk: string;
|
|
6
6
|
version: string | undefined;
|
|
@@ -5,7 +5,7 @@ const path = require("path-browserify");
|
|
|
5
5
|
const vscode = require("vscode");
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
const defaultTsdkPath = 'node_modules/typescript/lib';
|
|
8
|
-
function activate(cmd, context, client,
|
|
8
|
+
function activate(selector, cmd, context, client, resolveStatusText) {
|
|
9
9
|
const subscriptions = [];
|
|
10
10
|
const statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right);
|
|
11
11
|
statusBar.command = cmd;
|
|
@@ -37,19 +37,10 @@ function activate(cmd, context, client, shouldStatusBarShow, resolveStatusText,
|
|
|
37
37
|
detail: defaultTsdkPath,
|
|
38
38
|
} : undefined,
|
|
39
39
|
},
|
|
40
|
-
...(disableTakeOverMode ? [] : [{
|
|
41
|
-
takeover: {
|
|
42
|
-
label: 'What is Takeover Mode?',
|
|
43
|
-
},
|
|
44
|
-
}])
|
|
45
40
|
]);
|
|
46
41
|
if (select === undefined) {
|
|
47
42
|
return; // cancel
|
|
48
43
|
}
|
|
49
|
-
if (select === 'takeover') {
|
|
50
|
-
vscode.env.openExternal(vscode.Uri.parse('https://vuejs.org/guide/typescript/overview.html#volar-takeover-mode'));
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
44
|
if (select === 'useDefaultWorkspaceTsdk') {
|
|
54
45
|
await vscode.workspace.getConfiguration('typescript').update('tsdk', defaultTsdkPath);
|
|
55
46
|
}
|
|
@@ -67,7 +58,7 @@ function activate(cmd, context, client, shouldStatusBarShow, resolveStatusText,
|
|
|
67
58
|
}
|
|
68
59
|
async function updateStatusBar() {
|
|
69
60
|
if (!vscode.window.activeTextEditor
|
|
70
|
-
|| !
|
|
61
|
+
|| !vscode.languages.match(selector, vscode.window.activeTextEditor.document)) {
|
|
71
62
|
statusBar.hide();
|
|
72
63
|
}
|
|
73
64
|
else {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode';
|
|
2
2
|
import type { BaseLanguageClient } from 'vscode-languageclient';
|
|
3
|
-
export declare function activate(cmd: string, client: BaseLanguageClient
|
|
3
|
+
export declare function activate(selector: vscode.DocumentSelector, cmd: string, client: BaseLanguageClient): void;
|
package/lib/features/tsconfig.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.activate = void 0;
|
|
|
4
4
|
const vscode = require("vscode");
|
|
5
5
|
const protocol_1 = require("@volar/language-server/protocol");
|
|
6
6
|
const path = require("path-browserify");
|
|
7
|
-
function activate(cmd, client
|
|
7
|
+
function activate(selector, cmd, client) {
|
|
8
8
|
const subscriptions = [];
|
|
9
9
|
const statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right);
|
|
10
10
|
let currentTsconfigUri;
|
|
@@ -19,7 +19,7 @@ function activate(cmd, client, shouldStatusBarShow) {
|
|
|
19
19
|
subscriptions.push(...subscriptions);
|
|
20
20
|
async function updateStatusBar() {
|
|
21
21
|
if (!vscode.window.activeTextEditor
|
|
22
|
-
|| !
|
|
22
|
+
|| !vscode.languages.match(selector, vscode.window.activeTextEditor.document)) {
|
|
23
23
|
statusBar.hide();
|
|
24
24
|
}
|
|
25
25
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/vscode",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.10",
|
|
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.0.0-alpha.
|
|
15
|
+
"@volar/language-server": "2.0.0-alpha.10",
|
|
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": "
|
|
25
|
+
"gitHead": "f320632bcffa06981de169ee3cdad79c29ecc1b5"
|
|
26
26
|
}
|