@theia/plugin-ext 1.13.0-next.fd91f213 → 1.13.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/lib/common/plugin-api-rpc.d.ts +2 -0
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/common/plugin-protocol.d.ts +7 -15
- package/lib/common/plugin-protocol.d.ts.map +1 -1
- package/lib/common/plugin-protocol.js +2 -1
- package/lib/common/plugin-protocol.js.map +1 -1
- package/lib/common/rpc-protocol.d.ts +4 -6
- package/lib/common/rpc-protocol.d.ts.map +1 -1
- package/lib/common/rpc-protocol.js +65 -64
- package/lib/common/rpc-protocol.js.map +1 -1
- package/lib/hosted/browser/hosted-plugin-watcher.d.ts +4 -1
- package/lib/hosted/browser/hosted-plugin-watcher.d.ts.map +1 -1
- package/lib/hosted/browser/hosted-plugin-watcher.js +2 -2
- package/lib/hosted/browser/hosted-plugin-watcher.js.map +1 -1
- package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
- package/lib/hosted/browser/hosted-plugin.js +11 -8
- package/lib/hosted/browser/hosted-plugin.js.map +1 -1
- package/lib/hosted/browser/worker/worker-main.js.map +1 -1
- package/lib/hosted/node/hosted-plugin-process.d.ts +2 -2
- package/lib/hosted/node/hosted-plugin-process.d.ts.map +1 -1
- package/lib/hosted/node/hosted-plugin-process.js +5 -5
- package/lib/hosted/node/hosted-plugin-process.js.map +1 -1
- package/lib/hosted/node/hosted-plugin.d.ts +1 -1
- package/lib/hosted/node/hosted-plugin.d.ts.map +1 -1
- package/lib/hosted/node/hosted-plugin.js +4 -5
- package/lib/hosted/node/hosted-plugin.js.map +1 -1
- package/lib/hosted/node/metadata-scanner.d.ts.map +1 -1
- package/lib/hosted/node/metadata-scanner.js +1 -1
- package/lib/hosted/node/metadata-scanner.js.map +1 -1
- package/lib/hosted/node/plugin-host.js +2 -2
- package/lib/hosted/node/plugin-host.js.map +1 -1
- package/lib/hosted/node/plugin-service.d.ts +1 -1
- package/lib/hosted/node/plugin-service.d.ts.map +1 -1
- package/lib/hosted/node/plugin-service.js +2 -2
- package/lib/hosted/node/plugin-service.js.map +1 -1
- package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
- package/lib/hosted/node/scanners/scanner-theia.js +2 -1
- package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
- package/lib/main/browser/custom-editors/custom-editor-opener.d.ts +1 -2
- package/lib/main/browser/custom-editors/custom-editor-opener.d.ts.map +1 -1
- package/lib/main/browser/custom-editors/custom-editor-opener.js +1 -1
- package/lib/main/browser/custom-editors/custom-editor-opener.js.map +1 -1
- package/lib/main/browser/keybindings/keybindings-contribution-handler.js +2 -2
- package/lib/main/browser/keybindings/keybindings-contribution-handler.js.map +1 -1
- package/lib/main/browser/plugin-worker.js.map +1 -1
- package/lib/main/browser/tasks-main.js +1 -1
- package/lib/main/browser/tasks-main.js.map +1 -1
- package/lib/main/browser/view/plugin-view-registry.js +8 -1
- package/lib/main/browser/view/plugin-view-registry.js.map +1 -1
- package/lib/main/browser/webview/webview-theme-data-provider.d.ts +1 -1
- package/lib/main/browser/webview/webview-theme-data-provider.d.ts.map +1 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +1 -0
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/tasks/tasks.d.ts +7 -5
- package/lib/plugin/tasks/tasks.d.ts.map +1 -1
- package/lib/plugin/tasks/tasks.js +27 -42
- package/lib/plugin/tasks/tasks.js.map +1 -1
- package/lib/plugin/type-converters.d.ts.map +1 -1
- package/lib/plugin/type-converters.js +6 -3
- package/lib/plugin/type-converters.js.map +1 -1
- package/lib/plugin/type-converters.spec.js +2 -0
- package/lib/plugin/type-converters.spec.js.map +1 -1
- package/lib/plugin/types-impl.d.ts +19 -7
- package/lib/plugin/types-impl.d.ts.map +1 -1
- package/lib/plugin/types-impl.js +21 -93
- package/lib/plugin/types-impl.js.map +1 -1
- package/package.json +22 -23
- package/src/common/plugin-api-rpc.ts +2 -0
- package/src/common/plugin-protocol.ts +10 -16
- package/src/common/rpc-protocol.ts +55 -73
- package/src/hosted/browser/hosted-plugin-watcher.ts +4 -4
- package/src/hosted/browser/hosted-plugin.ts +11 -8
- package/src/hosted/browser/worker/worker-main.ts +2 -2
- package/src/hosted/node/hosted-plugin-process.ts +6 -6
- package/src/hosted/node/hosted-plugin.ts +4 -5
- package/src/hosted/node/metadata-scanner.ts +2 -3
- package/src/hosted/node/plugin-host.ts +4 -4
- package/src/hosted/node/plugin-service.ts +2 -2
- package/src/hosted/node/scanners/scanner-theia.ts +2 -1
- package/src/main/browser/custom-editors/custom-editor-opener.tsx +1 -2
- package/src/main/browser/keybindings/keybindings-contribution-handler.ts +2 -2
- package/src/main/browser/plugin-worker.ts +2 -2
- package/src/main/browser/tasks-main.ts +1 -1
- package/src/main/browser/view/plugin-view-registry.ts +1 -1
- package/src/plugin/plugin-context.ts +2 -0
- package/src/plugin/tasks/tasks.ts +28 -47
- package/src/plugin/type-converters.spec.ts +2 -0
- package/src/plugin/type-converters.ts +9 -6
- package/src/plugin/types-impl.ts +21 -71
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
24
24
|
|
|
25
|
-
import { Event } from '@theia/core/lib/common/event';
|
|
25
|
+
import { Emitter, Event } from '@theia/core/lib/common/event';
|
|
26
26
|
import { DisposableCollection, Disposable } from '@theia/core/lib/common/disposable';
|
|
27
27
|
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
28
28
|
import { URI as VSCodeURI } from '@theia/core/shared/vscode-uri';
|
|
@@ -32,8 +32,8 @@ import { Range, Position } from '../plugin/types-impl';
|
|
|
32
32
|
import { BinaryBuffer } from '@theia/core/lib/common/buffer';
|
|
33
33
|
|
|
34
34
|
export interface MessageConnection {
|
|
35
|
-
send(msg:
|
|
36
|
-
onMessage: Event<
|
|
35
|
+
send(msg: string): void;
|
|
36
|
+
onMessage: Event<string>;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export const RPCProtocol = Symbol('RPCProtocol');
|
|
@@ -83,17 +83,17 @@ export class RPCProtocolImpl implements RPCProtocol {
|
|
|
83
83
|
private lastMessageId = 0;
|
|
84
84
|
private readonly cancellationTokenSources = new Map<string, CancellationTokenSource>();
|
|
85
85
|
private readonly pendingRPCReplies = new Map<string, Deferred<any>>();
|
|
86
|
-
private readonly
|
|
87
|
-
private messageToSendHostId: string | undefined;
|
|
86
|
+
private readonly multiplexer: RPCMultiplexer;
|
|
88
87
|
|
|
89
88
|
private readonly toDispose = new DisposableCollection(
|
|
90
89
|
Disposable.create(() => { /* mark as no disposed */ })
|
|
91
90
|
);
|
|
92
91
|
|
|
93
|
-
constructor(connection: MessageConnection
|
|
92
|
+
constructor(connection: MessageConnection) {
|
|
94
93
|
this.toDispose.push(
|
|
95
|
-
this.
|
|
94
|
+
this.multiplexer = new RPCMultiplexer(connection)
|
|
96
95
|
);
|
|
96
|
+
this.multiplexer.onMessage(msg => this.receiveOneMessage(msg));
|
|
97
97
|
this.toDispose.push(Disposable.create(() => {
|
|
98
98
|
this.proxies.clear();
|
|
99
99
|
for (const reply of this.pendingRPCReplies.values()) {
|
|
@@ -163,12 +163,12 @@ export class RPCProtocolImpl implements RPCProtocol {
|
|
|
163
163
|
if (cancellationToken) {
|
|
164
164
|
args.push('add.cancellation.token');
|
|
165
165
|
cancellationToken.onCancellationRequested(() =>
|
|
166
|
-
this.
|
|
166
|
+
this.multiplexer.send(MessageFactory.cancel(callId))
|
|
167
167
|
);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
this.pendingRPCReplies.set(callId, result);
|
|
171
|
-
this.
|
|
171
|
+
this.multiplexer.send(MessageFactory.request(callId, proxyId, methodName, args));
|
|
172
172
|
return result.promise;
|
|
173
173
|
}
|
|
174
174
|
|
|
@@ -176,34 +176,29 @@ export class RPCProtocolImpl implements RPCProtocol {
|
|
|
176
176
|
if (this.isDisposed) {
|
|
177
177
|
return;
|
|
178
178
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
179
|
+
try {
|
|
180
|
+
const msg = <RPCMessage>JSON.parse(rawmsg, ObjectsTransferrer.reviver);
|
|
181
|
+
|
|
182
|
+
switch (msg.type) {
|
|
183
|
+
case MessageType.Request:
|
|
184
|
+
this.receiveRequest(msg);
|
|
185
|
+
break;
|
|
186
|
+
case MessageType.Reply:
|
|
187
|
+
this.receiveReply(msg);
|
|
188
|
+
break;
|
|
189
|
+
case MessageType.ReplyErr:
|
|
190
|
+
this.receiveReplyErr(msg);
|
|
191
|
+
break;
|
|
192
|
+
case MessageType.Cancel:
|
|
193
|
+
this.receiveCancel(msg);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
} catch (e) {
|
|
197
|
+
// exception does not show problematic content: log it!
|
|
198
|
+
console.log('failed to parse message: ' + rawmsg);
|
|
199
|
+
throw e;
|
|
191
200
|
}
|
|
192
201
|
|
|
193
|
-
switch (msg.type) {
|
|
194
|
-
case MessageType.Request:
|
|
195
|
-
this.receiveRequest(msg);
|
|
196
|
-
break;
|
|
197
|
-
case MessageType.Reply:
|
|
198
|
-
this.receiveReply(msg);
|
|
199
|
-
break;
|
|
200
|
-
case MessageType.ReplyErr:
|
|
201
|
-
this.receiveReplyErr(msg);
|
|
202
|
-
break;
|
|
203
|
-
case MessageType.Cancel:
|
|
204
|
-
this.receiveCancel(msg);
|
|
205
|
-
break;
|
|
206
|
-
}
|
|
207
202
|
}
|
|
208
203
|
|
|
209
204
|
private receiveCancel(msg: CancelMessage): void {
|
|
@@ -229,10 +224,10 @@ export class RPCProtocolImpl implements RPCProtocol {
|
|
|
229
224
|
|
|
230
225
|
invocation.then(result => {
|
|
231
226
|
this.cancellationTokenSources.delete(callId);
|
|
232
|
-
this.
|
|
227
|
+
this.multiplexer.send(MessageFactory.replyOK(callId, result));
|
|
233
228
|
}, error => {
|
|
234
229
|
this.cancellationTokenSources.delete(callId);
|
|
235
|
-
this.
|
|
230
|
+
this.multiplexer.send(MessageFactory.replyErr(callId, error));
|
|
236
231
|
});
|
|
237
232
|
}
|
|
238
233
|
|
|
@@ -296,41 +291,44 @@ function canceled(): Error {
|
|
|
296
291
|
* - multiple messages to be sent from one stack get sent in bulk at `process.nextTick`.
|
|
297
292
|
* - each incoming message is handled in a separate `process.nextTick`.
|
|
298
293
|
*/
|
|
299
|
-
class RPCMultiplexer implements Disposable {
|
|
294
|
+
class RPCMultiplexer implements Disposable, MessageConnection {
|
|
300
295
|
|
|
301
296
|
private readonly connection: MessageConnection;
|
|
302
297
|
private readonly sendAccumulatedBound: () => void;
|
|
303
298
|
|
|
304
299
|
private messagesToSend: string[];
|
|
305
300
|
|
|
301
|
+
private readonly messageEmitter = new Emitter<string>();
|
|
306
302
|
private readonly toDispose = new DisposableCollection();
|
|
307
303
|
|
|
308
|
-
constructor(connection: MessageConnection
|
|
304
|
+
constructor(connection: MessageConnection) {
|
|
309
305
|
this.connection = connection;
|
|
310
306
|
this.sendAccumulatedBound = this.sendAccumulated.bind(this);
|
|
311
307
|
|
|
312
308
|
this.toDispose.push(Disposable.create(() => this.messagesToSend = []));
|
|
313
|
-
this.toDispose.push(this.connection.onMessage((
|
|
314
|
-
const
|
|
315
|
-
for (
|
|
316
|
-
|
|
309
|
+
this.toDispose.push(this.connection.onMessage((msg: string) => {
|
|
310
|
+
const messages = JSON.parse(msg);
|
|
311
|
+
for (const message of messages) {
|
|
312
|
+
this.messageEmitter.fire(message);
|
|
317
313
|
}
|
|
318
314
|
}));
|
|
315
|
+
this.toDispose.push(this.messageEmitter);
|
|
319
316
|
|
|
320
317
|
this.messagesToSend = [];
|
|
321
|
-
if (remoteHostId) {
|
|
322
|
-
this.send(`{"setHostID":"${remoteHostId}"}`);
|
|
323
|
-
}
|
|
324
318
|
}
|
|
325
319
|
|
|
326
320
|
dispose(): void {
|
|
327
321
|
this.toDispose.dispose();
|
|
328
322
|
}
|
|
329
323
|
|
|
324
|
+
get onMessage(): Event<string> {
|
|
325
|
+
return this.messageEmitter.event;
|
|
326
|
+
}
|
|
327
|
+
|
|
330
328
|
private sendAccumulated(): void {
|
|
331
329
|
const tmp = this.messagesToSend;
|
|
332
330
|
this.messagesToSend = [];
|
|
333
|
-
this.connection.send(tmp);
|
|
331
|
+
this.connection.send(JSON.stringify(tmp));
|
|
334
332
|
}
|
|
335
333
|
|
|
336
334
|
public send(msg: string): void {
|
|
@@ -350,43 +348,27 @@ class RPCMultiplexer implements Disposable {
|
|
|
350
348
|
|
|
351
349
|
class MessageFactory {
|
|
352
350
|
|
|
353
|
-
static cancel(req: string
|
|
354
|
-
|
|
355
|
-
if (messageToSendHostId) {
|
|
356
|
-
prefix = `"hostID":"${messageToSendHostId}",`;
|
|
357
|
-
}
|
|
358
|
-
return `{${prefix}"type":${MessageType.Cancel},"id":"${req}"}`;
|
|
351
|
+
static cancel(req: string): string {
|
|
352
|
+
return `{"type":${MessageType.Cancel},"id":"${req}"}`;
|
|
359
353
|
}
|
|
360
354
|
|
|
361
|
-
public static request(req: string, rpcId: string, method: string, args: any[]
|
|
362
|
-
|
|
363
|
-
if (messageToSendHostId) {
|
|
364
|
-
prefix = `"hostID":"${messageToSendHostId}",`;
|
|
365
|
-
}
|
|
366
|
-
return `{${prefix}"type":${MessageType.Request},"id":"${req}","proxyId":"${rpcId}","method":"${method}","args":${JSON.stringify(args, ObjectsTransferrer.replacer)}}`;
|
|
355
|
+
public static request(req: string, rpcId: string, method: string, args: any[]): string {
|
|
356
|
+
return `{"type":${MessageType.Request},"id":"${req}","proxyId":"${rpcId}","method":"${method}","args":${JSON.stringify(args, ObjectsTransferrer.replacer)}}`;
|
|
367
357
|
}
|
|
368
358
|
|
|
369
|
-
public static replyOK(req: string, res: any
|
|
370
|
-
let prefix = '';
|
|
371
|
-
if (messageToSendHostId) {
|
|
372
|
-
prefix = `"hostID":"${messageToSendHostId}",`;
|
|
373
|
-
}
|
|
359
|
+
public static replyOK(req: string, res: any): string {
|
|
374
360
|
if (typeof res === 'undefined') {
|
|
375
|
-
return `{
|
|
361
|
+
return `{"type":${MessageType.Reply},"id":"${req}"}`;
|
|
376
362
|
}
|
|
377
|
-
return `{
|
|
363
|
+
return `{"type":${MessageType.Reply},"id":"${req}","res":${safeStringify(res, ObjectsTransferrer.replacer)}}`;
|
|
378
364
|
}
|
|
379
365
|
|
|
380
|
-
public static replyErr(req: string, err: any
|
|
381
|
-
let prefix = '';
|
|
382
|
-
if (messageToSendHostId) {
|
|
383
|
-
prefix = `"hostID":"${messageToSendHostId}",`;
|
|
384
|
-
}
|
|
366
|
+
public static replyErr(req: string, err: any): string {
|
|
385
367
|
err = typeof err === 'string' ? new Error(err) : err;
|
|
386
368
|
if (err instanceof Error) {
|
|
387
|
-
return `{
|
|
369
|
+
return `{"type":${MessageType.ReplyErr},"id":"${req}","err":${safeStringify(transformErrorForSerialization(err))}}`;
|
|
388
370
|
}
|
|
389
|
-
return `{
|
|
371
|
+
return `{"type":${MessageType.ReplyErr},"id":"${req}","err":null}`;
|
|
390
372
|
}
|
|
391
373
|
}
|
|
392
374
|
|
|
@@ -21,7 +21,7 @@ import { LogPart } from '../../common/types';
|
|
|
21
21
|
|
|
22
22
|
@injectable()
|
|
23
23
|
export class HostedPluginWatcher {
|
|
24
|
-
private onPostMessage = new Emitter<string
|
|
24
|
+
private onPostMessage = new Emitter<{ pluginHostId: string, message: string }>();
|
|
25
25
|
private onLogMessage = new Emitter<LogPart>();
|
|
26
26
|
|
|
27
27
|
private readonly onDidDeployEmitter = new Emitter<void>();
|
|
@@ -31,8 +31,8 @@ export class HostedPluginWatcher {
|
|
|
31
31
|
const messageEmitter = this.onPostMessage;
|
|
32
32
|
const logEmitter = this.onLogMessage;
|
|
33
33
|
return {
|
|
34
|
-
postMessage(message: string): Promise<void> {
|
|
35
|
-
messageEmitter.fire(
|
|
34
|
+
postMessage(pluginHostId, message: string): Promise<void> {
|
|
35
|
+
messageEmitter.fire({ pluginHostId, message });
|
|
36
36
|
return Promise.resolve();
|
|
37
37
|
},
|
|
38
38
|
log(logPart: LogPart): Promise<void> {
|
|
@@ -43,7 +43,7 @@ export class HostedPluginWatcher {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
get onPostMessageEvent(): Event<string
|
|
46
|
+
get onPostMessageEvent(): Event<{ pluginHostId: string, message: string }> {
|
|
47
47
|
return this.onPostMessage.event;
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -489,22 +489,25 @@ export class HostedPluginSupport {
|
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
protected initRpc(host: PluginHost, pluginId: string): RPCProtocol {
|
|
492
|
-
const rpc = host === 'frontend' ? new PluginWorker().rpc : this.createServerRpc(
|
|
492
|
+
const rpc = host === 'frontend' ? new PluginWorker().rpc : this.createServerRpc(host);
|
|
493
493
|
setUpPluginApi(rpc, this.container);
|
|
494
494
|
this.mainPluginApiProviders.getContributions().forEach(p => p.initialize(rpc, this.container));
|
|
495
495
|
return rpc;
|
|
496
496
|
}
|
|
497
497
|
|
|
498
|
-
private createServerRpc(
|
|
498
|
+
private createServerRpc(pluginHostId: string): RPCProtocol {
|
|
499
|
+
const emitter = new Emitter<string>();
|
|
500
|
+
this.watcher.onPostMessageEvent(received => {
|
|
501
|
+
if (pluginHostId === received.pluginHostId) {
|
|
502
|
+
emitter.fire(received.message);
|
|
503
|
+
}
|
|
504
|
+
});
|
|
499
505
|
return new RPCProtocolImpl({
|
|
500
|
-
onMessage:
|
|
506
|
+
onMessage: emitter.event,
|
|
501
507
|
send: message => {
|
|
502
|
-
|
|
503
|
-
wrappedMessage['pluginID'] = pluginID;
|
|
504
|
-
wrappedMessage['content'] = message;
|
|
505
|
-
this.server.onMessage(JSON.stringify(wrappedMessage));
|
|
508
|
+
this.server.onMessage(pluginHostId, message);
|
|
506
509
|
}
|
|
507
|
-
}
|
|
510
|
+
});
|
|
508
511
|
}
|
|
509
512
|
|
|
510
513
|
private async updateStoragePath(): Promise<void> {
|
|
@@ -40,10 +40,10 @@ const ctx = self as any;
|
|
|
40
40
|
const pluginsApiImpl = new Map<string, typeof theia>();
|
|
41
41
|
const pluginsModulesNames = new Map<string, Plugin>();
|
|
42
42
|
|
|
43
|
-
const emitter = new Emitter();
|
|
43
|
+
const emitter = new Emitter<string>();
|
|
44
44
|
const rpc = new RPCProtocolImpl({
|
|
45
45
|
onMessage: emitter.event,
|
|
46
|
-
send: (m:
|
|
46
|
+
send: (m: string) => {
|
|
47
47
|
ctx.postMessage(m);
|
|
48
48
|
}
|
|
49
49
|
});
|
|
@@ -18,7 +18,7 @@ import * as cp from 'child_process';
|
|
|
18
18
|
import { injectable, inject, named } from '@theia/core/shared/inversify';
|
|
19
19
|
import { ILogger, ConnectionErrorHandler, ContributionProvider, MessageService } from '@theia/core/lib/common';
|
|
20
20
|
import { createIpcEnv } from '@theia/core/lib/node/messaging/ipc-protocol';
|
|
21
|
-
import { HostedPluginClient, ServerPluginRunner, PluginHostEnvironmentVariable, DeployedPlugin } from '../../common/plugin-protocol';
|
|
21
|
+
import { HostedPluginClient, ServerPluginRunner, PluginHostEnvironmentVariable, DeployedPlugin, PLUGIN_HOST_BACKEND } from '../../common/plugin-protocol';
|
|
22
22
|
import { MessageType } from '../../common/rpc-protocol';
|
|
23
23
|
import { HostedPluginCliContribution } from './hosted-plugin-cli-contribution';
|
|
24
24
|
import * as psTree from 'ps-tree';
|
|
@@ -78,14 +78,14 @@ export class HostedPluginProcess implements ServerPluginRunner {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
-
public acceptMessage(
|
|
82
|
-
return
|
|
81
|
+
public acceptMessage(pluginHostId: string, message: string): boolean {
|
|
82
|
+
return pluginHostId === 'main';
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
-
public onMessage(jsonMessage:
|
|
86
|
+
public onMessage(pluginHostId: string, jsonMessage: string): void {
|
|
87
87
|
if (this.childProcess) {
|
|
88
|
-
this.childProcess.send(
|
|
88
|
+
this.childProcess.send(jsonMessage);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -154,7 +154,7 @@ export class HostedPluginProcess implements ServerPluginRunner {
|
|
|
154
154
|
});
|
|
155
155
|
this.childProcess.on('message', message => {
|
|
156
156
|
if (this.client) {
|
|
157
|
-
this.client.postMessage(message);
|
|
157
|
+
this.client.postMessage(PLUGIN_HOST_BACKEND, message);
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
160
|
}
|
|
@@ -71,18 +71,17 @@ export class HostedPluginSupport {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
onMessage(message: string): void {
|
|
74
|
+
onMessage(pluginHostId: string, message: string): void {
|
|
75
75
|
// need to perform routing
|
|
76
76
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
-
const jsonMessage: any = JSON.parse(message);
|
|
78
77
|
if (this.pluginRunners.length > 0) {
|
|
79
78
|
this.pluginRunners.forEach(runner => {
|
|
80
|
-
if (runner.acceptMessage(
|
|
81
|
-
runner.onMessage(
|
|
79
|
+
if (runner.acceptMessage(pluginHostId, message)) {
|
|
80
|
+
runner.onMessage(pluginHostId, message);
|
|
82
81
|
}
|
|
83
82
|
});
|
|
84
83
|
} else {
|
|
85
|
-
this.hostedPluginProcess.onMessage(
|
|
84
|
+
this.hostedPluginProcess.onMessage(pluginHostId, message);
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
87
|
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
17
|
import { injectable, multiInject } from '@theia/core/shared/inversify';
|
|
18
|
-
import { PluginPackage, PluginScanner, PluginMetadata } from '../../common/plugin-protocol';
|
|
19
|
-
|
|
18
|
+
import { PluginPackage, PluginScanner, PluginMetadata, PLUGIN_HOST_BACKEND } from '../../common/plugin-protocol';
|
|
20
19
|
@injectable()
|
|
21
20
|
export class MetadataScanner {
|
|
22
21
|
private scanners: Map<string, PluginScanner> = new Map();
|
|
@@ -32,7 +31,7 @@ export class MetadataScanner {
|
|
|
32
31
|
getPluginMetadata(plugin: PluginPackage): PluginMetadata {
|
|
33
32
|
const scanner = this.getScanner(plugin);
|
|
34
33
|
return {
|
|
35
|
-
host:
|
|
34
|
+
host: PLUGIN_HOST_BACKEND,
|
|
36
35
|
model: scanner.getModel(plugin),
|
|
37
36
|
lifecycle: scanner.getLifecycle(plugin)
|
|
38
37
|
};
|
|
@@ -72,12 +72,12 @@ process.on('rejectionHandled', (promise: Promise<any>) => {
|
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
let terminating = false;
|
|
75
|
-
const emitter = new Emitter();
|
|
75
|
+
const emitter = new Emitter<string>();
|
|
76
76
|
const rpc = new RPCProtocolImpl({
|
|
77
77
|
onMessage: emitter.event,
|
|
78
|
-
send: (m:
|
|
78
|
+
send: (m: string) => {
|
|
79
79
|
if (process.send && !terminating) {
|
|
80
|
-
process.send(
|
|
80
|
+
process.send(m);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
});
|
|
@@ -104,7 +104,7 @@ process.on('message', async (message: string) => {
|
|
|
104
104
|
process.send(JSON.stringify({ type: MessageType.Terminated }));
|
|
105
105
|
}
|
|
106
106
|
} else {
|
|
107
|
-
emitter.fire(
|
|
107
|
+
emitter.fire(message);
|
|
108
108
|
}
|
|
109
109
|
} catch (e) {
|
|
110
110
|
console.error(e);
|
|
@@ -105,8 +105,8 @@ export class HostedPluginServerImpl implements HostedPluginServer {
|
|
|
105
105
|
return plugins;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
onMessage(message: string): Promise<void> {
|
|
109
|
-
this.hostedPlugin.onMessage(message);
|
|
108
|
+
onMessage(pluginHostId: string, message: string): Promise<void> {
|
|
109
|
+
this.hostedPlugin.onMessage(pluginHostId, message);
|
|
110
110
|
return Promise.resolve();
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
17
|
import { inject } from '@theia/core/shared/inversify';
|
|
18
|
-
import { PreviewEditorOpenerOptions } from '@theia/editor-preview/lib/browser';
|
|
19
18
|
import URI from '@theia/core/lib/common/uri';
|
|
20
19
|
import { ApplicationShell, OpenerOptions, OpenHandler, Widget, WidgetManager } from '@theia/core/lib/browser';
|
|
21
20
|
import { CustomEditorPriority, CustomEditorSelector } from '../../../common';
|
|
@@ -42,7 +41,7 @@ export class CustomEditorOpener implements OpenHandler {
|
|
|
42
41
|
this.label = this.editor.displayName;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
canHandle(uri: URI
|
|
44
|
+
canHandle(uri: URI): number {
|
|
46
45
|
if (this.matches(this.editor.selector, uri)) {
|
|
47
46
|
return this.getPriority();
|
|
48
47
|
}
|
|
@@ -47,8 +47,8 @@ export class KeybindingsContributionPointHandler {
|
|
|
47
47
|
if (!keybinding) {
|
|
48
48
|
return undefined;
|
|
49
49
|
}
|
|
50
|
-
const { command, when } = pluginKeybinding;
|
|
51
|
-
return { keybinding, command, when };
|
|
50
|
+
const { command, when, args } = pluginKeybinding;
|
|
51
|
+
return { keybinding, command, when, args };
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
protected toOSKeybinding(pluginKeybinding: PluginKeybinding): string | undefined {
|
|
@@ -23,7 +23,7 @@ export class PluginWorker {
|
|
|
23
23
|
private worker: Worker;
|
|
24
24
|
public readonly rpc: RPCProtocol;
|
|
25
25
|
constructor() {
|
|
26
|
-
const emitter = new Emitter();
|
|
26
|
+
const emitter = new Emitter<string>();
|
|
27
27
|
this.worker = new (require('../../hosted/browser/worker/worker-main'));
|
|
28
28
|
this.worker.onmessage = message => {
|
|
29
29
|
emitter.fire(message.data);
|
|
@@ -32,7 +32,7 @@ export class PluginWorker {
|
|
|
32
32
|
|
|
33
33
|
this.rpc = new RPCProtocolImpl({
|
|
34
34
|
onMessage: emitter.event,
|
|
35
|
-
send: (m:
|
|
35
|
+
send: (m: string) => {
|
|
36
36
|
this.worker.postMessage(m);
|
|
37
37
|
}
|
|
38
38
|
});
|
|
@@ -109,7 +109,7 @@ export class TasksMainImpl implements TasksMain, Disposable {
|
|
|
109
109
|
|
|
110
110
|
const toDispose = new DisposableCollection(
|
|
111
111
|
this.taskProviderRegistry.register(type, taskProvider, handle),
|
|
112
|
-
this.taskResolverRegistry.
|
|
112
|
+
this.taskResolverRegistry.registerTaskResolver(type, taskResolver),
|
|
113
113
|
Disposable.create(() => this.taskProviders.delete(handle))
|
|
114
114
|
);
|
|
115
115
|
this.taskProviders.set(handle, toDispose);
|
|
@@ -309,7 +309,7 @@ export class PluginViewRegistry implements FrontendApplicationContribution {
|
|
|
309
309
|
open: () => this.openView(view.id, { activate: true })
|
|
310
310
|
}));
|
|
311
311
|
toDispose.push(this.commands.registerCommand({ id: `${view.id}.focus` }, {
|
|
312
|
-
execute: () => this.openView(view.id, { activate: true })
|
|
312
|
+
execute: async () => { await this.openView(view.id, { activate: true }); }
|
|
313
313
|
}));
|
|
314
314
|
return toDispose;
|
|
315
315
|
}
|
|
@@ -82,6 +82,7 @@ import {
|
|
|
82
82
|
CodeLens,
|
|
83
83
|
CodeActionKind,
|
|
84
84
|
CodeActionTrigger,
|
|
85
|
+
CodeActionTriggerKind,
|
|
85
86
|
TextDocumentSaveReason,
|
|
86
87
|
CodeAction,
|
|
87
88
|
TreeItem,
|
|
@@ -896,6 +897,7 @@ export function createAPIFactory(
|
|
|
896
897
|
CodeLens,
|
|
897
898
|
CodeActionKind,
|
|
898
899
|
CodeActionTrigger,
|
|
900
|
+
CodeActionTriggerKind,
|
|
899
901
|
TextDocumentSaveReason,
|
|
900
902
|
CodeAction,
|
|
901
903
|
TreeItem,
|