@theia/plugin-ext 1.13.0-next.df062f62 → 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.
Files changed (81) hide show
  1. package/lib/common/plugin-api-rpc.d.ts +2 -0
  2. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  3. package/lib/common/plugin-api-rpc.js.map +1 -1
  4. package/lib/common/plugin-protocol.d.ts +7 -4
  5. package/lib/common/plugin-protocol.d.ts.map +1 -1
  6. package/lib/common/plugin-protocol.js +2 -1
  7. package/lib/common/plugin-protocol.js.map +1 -1
  8. package/lib/common/rpc-protocol.d.ts +4 -6
  9. package/lib/common/rpc-protocol.d.ts.map +1 -1
  10. package/lib/common/rpc-protocol.js +65 -64
  11. package/lib/common/rpc-protocol.js.map +1 -1
  12. package/lib/hosted/browser/hosted-plugin-watcher.d.ts +4 -1
  13. package/lib/hosted/browser/hosted-plugin-watcher.d.ts.map +1 -1
  14. package/lib/hosted/browser/hosted-plugin-watcher.js +2 -2
  15. package/lib/hosted/browser/hosted-plugin-watcher.js.map +1 -1
  16. package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
  17. package/lib/hosted/browser/hosted-plugin.js +11 -8
  18. package/lib/hosted/browser/hosted-plugin.js.map +1 -1
  19. package/lib/hosted/browser/worker/worker-main.js.map +1 -1
  20. package/lib/hosted/node/hosted-plugin-process.d.ts +2 -2
  21. package/lib/hosted/node/hosted-plugin-process.d.ts.map +1 -1
  22. package/lib/hosted/node/hosted-plugin-process.js +5 -5
  23. package/lib/hosted/node/hosted-plugin-process.js.map +1 -1
  24. package/lib/hosted/node/hosted-plugin.d.ts +1 -1
  25. package/lib/hosted/node/hosted-plugin.d.ts.map +1 -1
  26. package/lib/hosted/node/hosted-plugin.js +4 -5
  27. package/lib/hosted/node/hosted-plugin.js.map +1 -1
  28. package/lib/hosted/node/metadata-scanner.d.ts.map +1 -1
  29. package/lib/hosted/node/metadata-scanner.js +1 -1
  30. package/lib/hosted/node/metadata-scanner.js.map +1 -1
  31. package/lib/hosted/node/plugin-host.js +2 -2
  32. package/lib/hosted/node/plugin-host.js.map +1 -1
  33. package/lib/hosted/node/plugin-service.d.ts +1 -1
  34. package/lib/hosted/node/plugin-service.d.ts.map +1 -1
  35. package/lib/hosted/node/plugin-service.js +2 -2
  36. package/lib/hosted/node/plugin-service.js.map +1 -1
  37. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  38. package/lib/hosted/node/scanners/scanner-theia.js +2 -1
  39. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  40. package/lib/main/browser/keybindings/keybindings-contribution-handler.js +2 -2
  41. package/lib/main/browser/keybindings/keybindings-contribution-handler.js.map +1 -1
  42. package/lib/main/browser/plugin-worker.js.map +1 -1
  43. package/lib/main/browser/tasks-main.js +1 -1
  44. package/lib/main/browser/tasks-main.js.map +1 -1
  45. package/lib/plugin/plugin-context.d.ts.map +1 -1
  46. package/lib/plugin/plugin-context.js +1 -0
  47. package/lib/plugin/plugin-context.js.map +1 -1
  48. package/lib/plugin/tasks/tasks.d.ts +7 -5
  49. package/lib/plugin/tasks/tasks.d.ts.map +1 -1
  50. package/lib/plugin/tasks/tasks.js +27 -42
  51. package/lib/plugin/tasks/tasks.js.map +1 -1
  52. package/lib/plugin/type-converters.d.ts.map +1 -1
  53. package/lib/plugin/type-converters.js +6 -3
  54. package/lib/plugin/type-converters.js.map +1 -1
  55. package/lib/plugin/type-converters.spec.js +2 -0
  56. package/lib/plugin/type-converters.spec.js.map +1 -1
  57. package/lib/plugin/types-impl.d.ts +19 -7
  58. package/lib/plugin/types-impl.d.ts.map +1 -1
  59. package/lib/plugin/types-impl.js +21 -93
  60. package/lib/plugin/types-impl.js.map +1 -1
  61. package/package.json +22 -22
  62. package/src/common/plugin-api-rpc.ts +2 -0
  63. package/src/common/plugin-protocol.ts +10 -4
  64. package/src/common/rpc-protocol.ts +55 -73
  65. package/src/hosted/browser/hosted-plugin-watcher.ts +4 -4
  66. package/src/hosted/browser/hosted-plugin.ts +11 -8
  67. package/src/hosted/browser/worker/worker-main.ts +2 -2
  68. package/src/hosted/node/hosted-plugin-process.ts +6 -6
  69. package/src/hosted/node/hosted-plugin.ts +4 -5
  70. package/src/hosted/node/metadata-scanner.ts +2 -3
  71. package/src/hosted/node/plugin-host.ts +4 -4
  72. package/src/hosted/node/plugin-service.ts +2 -2
  73. package/src/hosted/node/scanners/scanner-theia.ts +2 -1
  74. package/src/main/browser/keybindings/keybindings-contribution-handler.ts +2 -2
  75. package/src/main/browser/plugin-worker.ts +2 -2
  76. package/src/main/browser/tasks-main.ts +1 -1
  77. package/src/plugin/plugin-context.ts +2 -0
  78. package/src/plugin/tasks/tasks.ts +28 -47
  79. package/src/plugin/type-converters.spec.ts +2 -0
  80. package/src/plugin/type-converters.ts +9 -6
  81. package/src/plugin/types-impl.ts +21 -71
@@ -1354,6 +1354,8 @@ export interface CommandProperties {
1354
1354
 
1355
1355
  export interface TaskDto {
1356
1356
  type: string;
1357
+ taskType?: 'shell' | 'process' | 'customExecution'; // the task execution type
1358
+ executionId?: string,
1357
1359
  label: string;
1358
1360
  source?: string;
1359
1361
  scope: string | number;
@@ -154,6 +154,8 @@ export interface PluginPackageKeybinding {
154
154
  mac?: string;
155
155
  linux?: string;
156
156
  win?: string;
157
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
158
+ args?: any;
157
159
  }
158
160
 
159
161
  export interface PluginPackageGrammarsContribution {
@@ -706,6 +708,8 @@ export interface Keybinding {
706
708
  mac?: string;
707
709
  linux?: string;
708
710
  win?: string;
711
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
712
+ args?: any;
709
713
  }
710
714
 
711
715
  /**
@@ -768,7 +772,7 @@ export function buildFrontendModuleName(plugin: PluginPackage | PluginModel): st
768
772
 
769
773
  export const HostedPluginClient = Symbol('HostedPluginClient');
770
774
  export interface HostedPluginClient {
771
- postMessage(message: string): Promise<void>;
775
+ postMessage(pluginHost: string, message: string): Promise<void>;
772
776
 
773
777
  log(logPart: LogPart): void;
774
778
 
@@ -812,10 +816,12 @@ export interface HostedPluginServer extends JsonRpcServer<HostedPluginClient> {
812
816
 
813
817
  getExtPluginAPI(): Promise<ExtPluginApi[]>;
814
818
 
815
- onMessage(message: string): Promise<void>;
819
+ onMessage(targetHost: string, message: string): Promise<void>;
816
820
 
817
821
  }
818
822
 
823
+ export const PLUGIN_HOST_BACKEND = 'main';
824
+
819
825
  export interface WorkspaceStorageKind {
820
826
  workspace?: string | undefined;
821
827
  roots: string[];
@@ -847,9 +853,9 @@ export interface PluginServer {
847
853
  export const ServerPluginRunner = Symbol('ServerPluginRunner');
848
854
  export interface ServerPluginRunner {
849
855
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
850
- acceptMessage(jsonMessage: any): boolean;
856
+ acceptMessage(pluginHostId: string, jsonMessage: string): boolean;
851
857
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
852
- onMessage(jsonMessage: any): void;
858
+ onMessage(pluginHostId: string, jsonMessage: string): void;
853
859
  setClient(client: HostedPluginClient): void;
854
860
  setDefault(defaultRunner: ServerPluginRunner): void;
855
861
  clientClosed(): void;
@@ -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: {}): void;
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 multiplexor: RPCMultiplexer;
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, readonly remoteHostID?: string) {
92
+ constructor(connection: MessageConnection) {
94
93
  this.toDispose.push(
95
- this.multiplexor = new RPCMultiplexer(connection, msg => this.receiveOneMessage(msg), remoteHostID)
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.multiplexor.send(MessageFactory.cancel(callId, this.messageToSendHostId))
166
+ this.multiplexer.send(MessageFactory.cancel(callId))
167
167
  );
168
168
  }
169
169
 
170
170
  this.pendingRPCReplies.set(callId, result);
171
- this.multiplexor.send(MessageFactory.request(callId, proxyId, methodName, args, this.messageToSendHostId));
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
- const msg = <RPCMessage>JSON.parse(rawmsg, ObjectsTransferrer.reviver);
181
-
182
- // handle message that sets the Host ID
183
- if ((<any>msg).setHostID) {
184
- this.messageToSendHostId = (<any>msg).setHostID;
185
- return;
186
- }
187
-
188
- // skip message if not matching host
189
- if (this.remoteHostID && (<any>msg).hostID && this.remoteHostID !== (<any>msg).hostID) {
190
- return;
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.multiplexor.send(MessageFactory.replyOK(callId, result, this.messageToSendHostId));
227
+ this.multiplexer.send(MessageFactory.replyOK(callId, result));
233
228
  }, error => {
234
229
  this.cancellationTokenSources.delete(callId);
235
- this.multiplexor.send(MessageFactory.replyErr(callId, error, this.messageToSendHostId));
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, onMessage: (msg: string) => void, remoteHostId?: string) {
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((data: string[]) => {
314
- const len = data.length;
315
- for (let i = 0; i < len; i++) {
316
- onMessage(data[i]);
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, messageToSendHostId?: string): string {
354
- let prefix = '';
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[], messageToSendHostId?: string): string {
362
- let prefix = '';
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, messageToSendHostId?: string): string {
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 `{${prefix}"type":${MessageType.Reply},"id":"${req}"}`;
361
+ return `{"type":${MessageType.Reply},"id":"${req}"}`;
376
362
  }
377
- return `{${prefix}"type":${MessageType.Reply},"id":"${req}","res":${safeStringify(res, ObjectsTransferrer.replacer)}}`;
363
+ return `{"type":${MessageType.Reply},"id":"${req}","res":${safeStringify(res, ObjectsTransferrer.replacer)}}`;
378
364
  }
379
365
 
380
- public static replyErr(req: string, err: any, messageToSendHostId?: string): string {
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 `{${prefix}"type":${MessageType.ReplyErr},"id":"${req}","err":${safeStringify(transformErrorForSerialization(err))}}`;
369
+ return `{"type":${MessageType.ReplyErr},"id":"${req}","err":${safeStringify(transformErrorForSerialization(err))}}`;
388
370
  }
389
- return `{${prefix}"type":${MessageType.ReplyErr},"id":"${req}","err":null}`;
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(JSON.parse(message));
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(pluginId, host);
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(pluginID: string, hostID: string): RPCProtocol {
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: this.watcher.onPostMessageEvent,
506
+ onMessage: emitter.event,
501
507
  send: message => {
502
- const wrappedMessage: any = {};
503
- wrappedMessage['pluginID'] = pluginID;
504
- wrappedMessage['content'] = message;
505
- this.server.onMessage(JSON.stringify(wrappedMessage));
508
+ this.server.onMessage(pluginHostId, message);
506
509
  }
507
- }, hostID);
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(jsonMessage: any): boolean {
82
- return jsonMessage.type !== undefined && jsonMessage.id;
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: any): void {
86
+ public onMessage(pluginHostId: string, jsonMessage: string): void {
87
87
  if (this.childProcess) {
88
- this.childProcess.send(JSON.stringify(jsonMessage));
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(jsonMessage)) {
81
- runner.onMessage(jsonMessage);
79
+ if (runner.acceptMessage(pluginHostId, message)) {
80
+ runner.onMessage(pluginHostId, message);
82
81
  }
83
82
  });
84
83
  } else {
85
- this.hostedPluginProcess.onMessage(jsonMessage.content);
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: 'main',
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(JSON.stringify(m));
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(msg);
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
 
@@ -492,7 +492,8 @@ export class TheiaPluginScanner implements PluginScanner {
492
492
  when: rawKeybinding.when,
493
493
  mac: rawKeybinding.mac,
494
494
  linux: rawKeybinding.linux,
495
- win: rawKeybinding.win
495
+ win: rawKeybinding.win,
496
+ args: rawKeybinding.args
496
497
  };
497
498
  }
498
499
 
@@ -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.register(type, taskResolver),
112
+ this.taskResolverRegistry.registerTaskResolver(type, taskResolver),
113
113
  Disposable.create(() => this.taskProviders.delete(handle))
114
114
  );
115
115
  this.taskProviders.set(handle, toDispose);
@@ -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,