@theia/plugin-ext 1.33.0-next.4 → 1.33.0-next.8

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 (82) hide show
  1. package/lib/common/index.js +2 -0
  2. package/lib/common/index.js.map +1 -1
  3. package/lib/common/plugin-api-rpc.d.ts +5 -3
  4. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  5. package/lib/common/plugin-api-rpc.js +0 -2
  6. package/lib/common/plugin-api-rpc.js.map +1 -1
  7. package/lib/common/plugin-protocol.d.ts +4 -4
  8. package/lib/common/plugin-protocol.d.ts.map +1 -1
  9. package/lib/common/proxy-handler.d.ts +66 -0
  10. package/lib/common/proxy-handler.d.ts.map +1 -0
  11. package/lib/common/proxy-handler.js +98 -0
  12. package/lib/common/proxy-handler.js.map +1 -0
  13. package/lib/common/rpc-protocol.d.ts +25 -51
  14. package/lib/common/rpc-protocol.d.ts.map +1 -1
  15. package/lib/common/rpc-protocol.js +126 -323
  16. package/lib/common/rpc-protocol.js.map +1 -1
  17. package/lib/hosted/browser/hosted-plugin-watcher.d.ts +1 -1
  18. package/lib/hosted/browser/hosted-plugin-watcher.d.ts.map +1 -1
  19. package/lib/hosted/browser/hosted-plugin-watcher.js.map +1 -1
  20. package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
  21. package/lib/hosted/browser/hosted-plugin.js +13 -8
  22. package/lib/hosted/browser/hosted-plugin.js.map +1 -1
  23. package/lib/hosted/browser/plugin-worker.d.ts.map +1 -1
  24. package/lib/hosted/browser/plugin-worker.js +14 -9
  25. package/lib/hosted/browser/plugin-worker.js.map +1 -1
  26. package/lib/hosted/browser/worker/worker-main.d.ts +1 -1
  27. package/lib/hosted/browser/worker/worker-main.d.ts.map +1 -1
  28. package/lib/hosted/browser/worker/worker-main.js +23 -22
  29. package/lib/hosted/browser/worker/worker-main.js.map +1 -1
  30. package/lib/hosted/node/hosted-plugin-process.d.ts +5 -4
  31. package/lib/hosted/node/hosted-plugin-process.d.ts.map +1 -1
  32. package/lib/hosted/node/hosted-plugin-process.js +20 -13
  33. package/lib/hosted/node/hosted-plugin-process.js.map +1 -1
  34. package/lib/hosted/node/hosted-plugin-protocol.d.ts +22 -0
  35. package/lib/hosted/node/hosted-plugin-protocol.d.ts.map +1 -0
  36. package/lib/hosted/node/hosted-plugin-protocol.js +37 -0
  37. package/lib/hosted/node/hosted-plugin-protocol.js.map +1 -0
  38. package/lib/hosted/node/hosted-plugin.d.ts +1 -1
  39. package/lib/hosted/node/hosted-plugin.d.ts.map +1 -1
  40. package/lib/hosted/node/hosted-plugin.js.map +1 -1
  41. package/lib/hosted/node/plugin-host.d.ts +1 -1
  42. package/lib/hosted/node/plugin-host.d.ts.map +1 -1
  43. package/lib/hosted/node/plugin-host.js +10 -21
  44. package/lib/hosted/node/plugin-host.js.map +1 -1
  45. package/lib/hosted/node/plugin-service.d.ts +1 -1
  46. package/lib/hosted/node/plugin-service.d.ts.map +1 -1
  47. package/lib/hosted/node/plugin-service.js.map +1 -1
  48. package/lib/main/browser/main-context.d.ts.map +1 -1
  49. package/lib/main/browser/main-context.js +0 -3
  50. package/lib/main/browser/main-context.js.map +1 -1
  51. package/lib/main/browser/tasks-main.d.ts.map +1 -1
  52. package/lib/main/browser/tasks-main.js +13 -9
  53. package/lib/main/browser/tasks-main.js.map +1 -1
  54. package/lib/plugin/type-converters.d.ts.map +1 -1
  55. package/lib/plugin/type-converters.js +6 -14
  56. package/lib/plugin/type-converters.js.map +1 -1
  57. package/lib/plugin/type-converters.spec.js +5 -4
  58. package/lib/plugin/type-converters.spec.js.map +1 -1
  59. package/lib/plugin/types-impl.d.ts +4 -8
  60. package/lib/plugin/types-impl.d.ts.map +1 -1
  61. package/lib/plugin/types-impl.js +8 -29
  62. package/lib/plugin/types-impl.js.map +1 -1
  63. package/package.json +25 -25
  64. package/src/common/index.ts +4 -0
  65. package/src/common/plugin-api-rpc.ts +5 -3
  66. package/src/common/plugin-protocol.ts +4 -4
  67. package/src/common/proxy-handler.ts +126 -0
  68. package/src/common/rpc-protocol.ts +128 -401
  69. package/src/hosted/browser/hosted-plugin-watcher.ts +4 -3
  70. package/src/hosted/browser/hosted-plugin.ts +17 -8
  71. package/src/hosted/browser/plugin-worker.ts +16 -10
  72. package/src/hosted/browser/worker/worker-main.ts +25 -26
  73. package/src/hosted/node/hosted-plugin-process.ts +25 -16
  74. package/src/hosted/node/hosted-plugin-protocol.ts +49 -0
  75. package/src/hosted/node/hosted-plugin.ts +1 -1
  76. package/src/hosted/node/plugin-host.ts +11 -22
  77. package/src/hosted/node/plugin-service.ts +1 -1
  78. package/src/main/browser/main-context.ts +0 -4
  79. package/src/main/browser/tasks-main.ts +13 -9
  80. package/src/plugin/type-converters.spec.ts +5 -4
  81. package/src/plugin/type-converters.ts +10 -12
  82. package/src/plugin/types-impl.ts +6 -26
@@ -13,8 +13,9 @@
13
13
  //
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
+ import { BasicChannel } from '@theia/core/lib/common/message-rpc/channel';
17
+ import { Uint8ArrayReadBuffer, Uint8ArrayWriteBuffer } from '@theia/core/lib/common/message-rpc/uint8-array-message-buffer';
16
18
  import { injectable } from '@theia/core/shared/inversify';
17
- import { Emitter } from '@theia/core/lib/common/event';
18
19
  import { RPCProtocol, RPCProtocolImpl } from '../../common/rpc-protocol';
19
20
 
20
21
  @injectable()
@@ -25,22 +26,27 @@ export class PluginWorker {
25
26
  public readonly rpc: RPCProtocol;
26
27
 
27
28
  constructor() {
28
- const emitter = new Emitter<string>();
29
-
30
29
  this.worker = new Worker(new URL('./worker/worker-main',
31
30
  // @ts-expect-error (TS1343)
32
31
  // We compile to CommonJS but `import.meta` is still available in the browser
33
32
  import.meta.url));
34
33
 
35
- this.worker.onmessage = m => emitter.fire(m.data);
36
- this.worker.onerror = e => console.error(e);
34
+ const channel = new BasicChannel(() => {
35
+ const writer = new Uint8ArrayWriteBuffer();
36
+ writer.onCommit(buffer => {
37
+ this.worker.postMessage(buffer);
38
+ });
39
+ return writer;
40
+ });
41
+
42
+ this.rpc = new RPCProtocolImpl(channel);
37
43
 
38
- this.rpc = new RPCProtocolImpl({
39
- onMessage: emitter.event,
40
- send: (m: string) => {
41
- this.worker.postMessage(m);
42
- }
44
+ // eslint-disable-next-line arrow-body-style
45
+ this.worker.onmessage = buffer => channel.onMessageEmitter.fire(() => {
46
+ return new Uint8ArrayReadBuffer(buffer.data);
43
47
  });
48
+
49
+ this.worker.onerror = e => channel.onErrorEmitter.fire(e);
44
50
  }
45
51
 
46
52
  }
@@ -13,28 +13,29 @@
13
13
  //
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
-
17
- import { Emitter } from '@theia/core/lib/common/event';
18
- import { RPCProtocolImpl } from '../../../common/rpc-protocol';
19
- import { PluginManagerExtImpl } from '../../../plugin/plugin-manager';
20
- import { MAIN_RPC_CONTEXT, Plugin, emptyPlugin, TerminalServiceExt } from '../../../common/plugin-api-rpc';
21
- import { createAPIFactory } from '../../../plugin/plugin-context';
22
- import { getPluginId, PluginMetadata } from '../../../common/plugin-protocol';
16
+ // eslint-disable-next-line import/no-extraneous-dependencies
17
+ import 'reflect-metadata';
18
+ import { BasicChannel } from '@theia/core/lib/common/message-rpc/channel';
19
+ import { Uint8ArrayReadBuffer, Uint8ArrayWriteBuffer } from '@theia/core/lib/common/message-rpc/uint8-array-message-buffer';
23
20
  import * as theia from '@theia/plugin';
24
- import { PreferenceRegistryExtImpl } from '../../../plugin/preference-registry';
21
+ import { emptyPlugin, MAIN_RPC_CONTEXT, Plugin, TerminalServiceExt } from '../../../common/plugin-api-rpc';
25
22
  import { ExtPluginApi } from '../../../common/plugin-ext-api-contribution';
26
- import { createDebugExtStub } from './debug-stub';
23
+ import { getPluginId, PluginMetadata } from '../../../common/plugin-protocol';
24
+ import { RPCProtocolImpl } from '../../../common/rpc-protocol';
25
+ import { ClipboardExt } from '../../../plugin/clipboard-ext';
27
26
  import { EditorsAndDocumentsExtImpl } from '../../../plugin/editors-and-documents';
28
- import { WorkspaceExtImpl } from '../../../plugin/workspace';
29
27
  import { MessageRegistryExt } from '../../../plugin/message-registry';
30
- import { WorkerEnvExtImpl } from './worker-env-ext';
31
- import { ClipboardExt } from '../../../plugin/clipboard-ext';
28
+ import { createAPIFactory } from '../../../plugin/plugin-context';
29
+ import { PluginManagerExtImpl } from '../../../plugin/plugin-manager';
32
30
  import { KeyValueStorageProxy } from '../../../plugin/plugin-storage';
31
+ import { PreferenceRegistryExtImpl } from '../../../plugin/preference-registry';
32
+ import { SecretsExtImpl } from '../../../plugin/secrets-ext';
33
+ import { TerminalServiceExtImpl } from '../../../plugin/terminal-ext';
33
34
  import { WebviewsExtImpl } from '../../../plugin/webviews';
35
+ import { WorkspaceExtImpl } from '../../../plugin/workspace';
36
+ import { createDebugExtStub } from './debug-stub';
34
37
  import { loadManifest } from './plugin-manifest-loader';
35
- import { TerminalServiceExtImpl } from '../../../plugin/terminal-ext';
36
- import { reviver } from '../../../plugin/types-impl';
37
- import { SecretsExtImpl } from '../../../plugin/secrets-ext';
38
+ import { WorkerEnvExtImpl } from './worker-env-ext';
38
39
 
39
40
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
41
  const ctx = self as any;
@@ -42,22 +43,20 @@ const ctx = self as any;
42
43
  const pluginsApiImpl = new Map<string, typeof theia>();
43
44
  const pluginsModulesNames = new Map<string, Plugin>();
44
45
 
45
- const emitter = new Emitter<string>();
46
- const rpc = new RPCProtocolImpl({
47
- onMessage: emitter.event,
48
- send: (m: string) => {
49
- ctx.postMessage(m);
50
- },
51
- },
52
- {
53
- reviver: reviver
46
+ const channel = new BasicChannel(() => {
47
+ const writeBuffer = new Uint8ArrayWriteBuffer();
48
+ writeBuffer.onCommit(buffer => {
49
+ ctx.postMessage(buffer);
50
+ });
51
+ return writeBuffer;
54
52
  });
55
-
56
53
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
54
  addEventListener('message', (message: any) => {
58
- emitter.fire(message.data);
55
+ channel.onMessageEmitter.fire(() => new Uint8ArrayReadBuffer(message.data));
59
56
  });
60
57
 
58
+ const rpc = new RPCProtocolImpl(channel);
59
+
61
60
  const scripts = new Set<string>();
62
61
 
63
62
  function initialize(contextPath: string, pluginMetadata: PluginMetadata): void {
@@ -14,16 +14,18 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import * as cp from 'child_process';
18
- import { injectable, inject, named } from '@theia/core/shared/inversify';
19
- import { ILogger, ConnectionErrorHandler, ContributionProvider, MessageService } from '@theia/core/lib/common';
17
+ import { ConnectionErrorHandler, ContributionProvider, ILogger, MessageService } from '@theia/core/lib/common';
18
+ import { Deferred } from '@theia/core/lib/common/promise-util';
20
19
  import { createIpcEnv } from '@theia/core/lib/node/messaging/ipc-protocol';
21
- import { HostedPluginClient, ServerPluginRunner, PluginHostEnvironmentVariable, DeployedPlugin, PLUGIN_HOST_BACKEND, PluginIdentifiers } from '../../common/plugin-protocol';
22
- import { MessageType } from '../../common/rpc-protocol';
20
+ import { inject, injectable, named } from '@theia/core/shared/inversify';
21
+ import * as cp from 'child_process';
23
22
  import { HostedPluginCliContribution } from './hosted-plugin-cli-contribution';
24
- import * as psTree from 'ps-tree';
25
- import { Deferred } from '@theia/core/lib/common/promise-util';
26
23
  import { HostedPluginLocalizationService } from './hosted-plugin-localization-service';
24
+ import { ProcessTerminatedMessage, ProcessTerminateMessage } from './hosted-plugin-protocol';
25
+ import { BinaryMessagePipe } from '@theia/core/lib/node/messaging/binary-message-pipe';
26
+ import { DeployedPlugin, HostedPluginClient, PluginHostEnvironmentVariable, PluginIdentifiers, PLUGIN_HOST_BACKEND, ServerPluginRunner } from '../../common/plugin-protocol';
27
+ import psTree = require('ps-tree');
28
+ import { Duplex } from 'stream';
27
29
 
28
30
  export interface IPCConnectionOptions {
29
31
  readonly serverName: string;
@@ -60,6 +62,7 @@ export class HostedPluginProcess implements ServerPluginRunner {
60
62
  protected readonly localizationService: HostedPluginLocalizationService;
61
63
 
62
64
  private childProcess: cp.ChildProcess | undefined;
65
+ private messagePipe?: BinaryMessagePipe;
63
66
  private client: HostedPluginClient;
64
67
 
65
68
  private terminatingPluginServer = false;
@@ -82,14 +85,14 @@ export class HostedPluginProcess implements ServerPluginRunner {
82
85
  }
83
86
 
84
87
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
- public acceptMessage(pluginHostId: string, message: string): boolean {
88
+ public acceptMessage(pluginHostId: string, message: Uint8Array): boolean {
86
89
  return pluginHostId === 'main';
87
90
  }
88
91
 
89
92
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
90
- public onMessage(pluginHostId: string, jsonMessage: string): void {
91
- if (this.childProcess) {
92
- this.childProcess.send(jsonMessage);
93
+ public onMessage(pluginHostId: string, message: Uint8Array): void {
94
+ if (this.messagePipe) {
95
+ this.messagePipe.send(message);
93
96
  }
94
97
  }
95
98
 
@@ -106,12 +109,12 @@ export class HostedPluginProcess implements ServerPluginRunner {
106
109
  const waitForTerminated = new Deferred<void>();
107
110
  cp.on('message', message => {
108
111
  const msg = JSON.parse(message as string);
109
- if ('type' in msg && msg.type === MessageType.Terminated) {
112
+ if (ProcessTerminatedMessage.is(msg)) {
110
113
  waitForTerminated.resolve();
111
114
  }
112
115
  });
113
116
  const stopTimeout = this.cli.pluginHostStopTimeout;
114
- cp.send(JSON.stringify({ type: MessageType.Terminate, stopTimeout }));
117
+ cp.send(JSON.stringify({ type: ProcessTerminateMessage.TYPE, stopTimeout }));
115
118
 
116
119
  const terminateTimeout = this.cli.pluginHostTerminateTimeout;
117
120
  if (terminateTimeout) {
@@ -156,9 +159,11 @@ export class HostedPluginProcess implements ServerPluginRunner {
156
159
  logger: this.logger,
157
160
  args: []
158
161
  });
159
- this.childProcess.on('message', message => {
162
+
163
+ this.messagePipe = new BinaryMessagePipe(this.childProcess.stdio[4] as Duplex);
164
+ this.messagePipe.onMessage(buffer => {
160
165
  if (this.client) {
161
- this.client.postMessage(PLUGIN_HOST_BACKEND, message as string);
166
+ this.client.postMessage(PLUGIN_HOST_BACKEND, buffer);
162
167
  }
163
168
  });
164
169
  }
@@ -184,7 +189,11 @@ export class HostedPluginProcess implements ServerPluginRunner {
184
189
  silent: true,
185
190
  env: env,
186
191
  execArgv: [],
187
- stdio: ['pipe', 'pipe', 'pipe', 'ipc']
192
+ // 5th element MUST be 'overlapped' for it to work properly on Windows.
193
+ // 'overlapped' works just like 'pipe' on non-Windows platforms.
194
+ // See: https://nodejs.org/docs/latest-v14.x/api/child_process.html#child_process_options_stdio
195
+ // Note: For some reason `@types/node` does not know about 'overlapped'.
196
+ stdio: ['pipe', 'pipe', 'pipe', 'ipc', 'overlapped' as 'pipe']
188
197
  };
189
198
  const inspectArgPrefix = `--${options.serverName}-inspect`;
190
199
  const inspectArg = process.argv.find(v => v.startsWith(inspectArgPrefix));
@@ -0,0 +1,49 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2022 STMicroelectronics and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ // Custom message protocol between `HostedPluginProcess` and its `PluginHost` child process.
18
+
19
+ /**
20
+ * Sent to initiate termination of the counterpart process.
21
+ */
22
+ export interface ProcessTerminateMessage {
23
+ type: typeof ProcessTerminateMessage.TYPE,
24
+ stopTimeout?: number
25
+ }
26
+
27
+ export namespace ProcessTerminateMessage {
28
+ export const TYPE = 0;
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ export function is(object: any): object is ProcessTerminateMessage {
31
+ return typeof object === 'object' && object.type === TYPE;
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Sent to inform the counter part process that the process termination has been completed.
37
+ */
38
+ export interface ProcessTerminatedMessage {
39
+ type: typeof ProcessTerminateMessage.TYPE,
40
+ }
41
+
42
+ export namespace ProcessTerminatedMessage {
43
+ export const TYPE = 1;
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
+ export function is(object: any): object is ProcessTerminateMessage {
46
+ return typeof object === 'object' && object.type === TYPE;
47
+ }
48
+ }
49
+
@@ -71,7 +71,7 @@ export class HostedPluginSupport {
71
71
  }
72
72
  }
73
73
 
74
- onMessage(pluginHostId: string, message: string): void {
74
+ onMessage(pluginHostId: string, message: Uint8Array): void {
75
75
  // need to perform routing
76
76
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
77
  if (this.pluginRunners.length > 0) {
@@ -13,11 +13,12 @@
13
13
  //
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
-
17
- import { Emitter } from '@theia/core/lib/common/event';
18
- import { RPCProtocolImpl, MessageType, ConnectionClosedError } from '../../common/rpc-protocol';
16
+ // eslint-disable-next-line import/no-extraneous-dependencies
17
+ import 'reflect-metadata';
18
+ import { ConnectionClosedError, RPCProtocolImpl } from '../../common/rpc-protocol';
19
+ import { ProcessTerminatedMessage, ProcessTerminateMessage } from './hosted-plugin-protocol';
19
20
  import { PluginHostRPC } from './plugin-host-rpc';
20
- import { reviver } from '../../plugin/types-impl';
21
+ import { IPCChannel } from '@theia/core/lib/node';
21
22
 
22
23
  console.log('PLUGIN_HOST(' + process.pid + ') starting instance');
23
24
 
@@ -74,18 +75,8 @@ process.on('rejectionHandled', (promise: Promise<any>) => {
74
75
  });
75
76
 
76
77
  let terminating = false;
77
- const emitter = new Emitter<string>();
78
- const rpc = new RPCProtocolImpl({
79
- onMessage: emitter.event,
80
- send: (m: string) => {
81
- if (process.send && !terminating) {
82
- process.send(m);
83
- }
84
- }
85
- },
86
- {
87
- reviver: reviver
88
- });
78
+ const channel = new IPCChannel();
79
+ const rpc = new RPCProtocolImpl(channel);
89
80
 
90
81
  process.on('message', async (message: string) => {
91
82
  if (terminating) {
@@ -93,10 +84,9 @@ process.on('message', async (message: string) => {
93
84
  }
94
85
  try {
95
86
  const msg = JSON.parse(message);
96
- if ('type' in msg && msg.type === MessageType.Terminate) {
87
+ if (ProcessTerminateMessage.is(msg)) {
97
88
  terminating = true;
98
- emitter.dispose();
99
- if ('stopTimeout' in msg && typeof msg.stopTimeout === 'number' && msg.stopTimeout) {
89
+ if (msg.stopTimeout) {
100
90
  await Promise.race([
101
91
  pluginHostRPC.terminate(),
102
92
  new Promise(resolve => setTimeout(resolve, msg.stopTimeout))
@@ -106,10 +96,9 @@ process.on('message', async (message: string) => {
106
96
  }
107
97
  rpc.dispose();
108
98
  if (process.send) {
109
- process.send(JSON.stringify({ type: MessageType.Terminated }));
99
+ process.send(JSON.stringify({ type: ProcessTerminatedMessage.TYPE }));
110
100
  }
111
- } else {
112
- emitter.fire(message);
101
+
113
102
  }
114
103
  } catch (e) {
115
104
  console.error(e);
@@ -164,7 +164,7 @@ export class HostedPluginServerImpl implements HostedPluginServer {
164
164
  return Promise.all(plugins.map(plugin => this.localizationService.localizePlugin(plugin)));
165
165
  }
166
166
 
167
- onMessage(pluginHostId: string, message: string): Promise<void> {
167
+ onMessage(pluginHostId: string, message: Uint8Array): Promise<void> {
168
168
  this.hostedPlugin.onMessage(pluginHostId, message);
169
169
  return Promise.resolve();
170
170
  }
@@ -56,7 +56,6 @@ import { CustomEditorsMainImpl } from './custom-editors/custom-editors-main';
56
56
  import { SecretsMainImpl } from './secrets-main';
57
57
  import { WebviewViewsMainImpl } from './webview-views/webview-views-main';
58
58
  import { MonacoLanguages } from '@theia/monaco/lib/browser/monaco-languages';
59
- import { NotificationExtImpl } from '../../plugin/notification';
60
59
  import { UntitledResourceResolver } from '@theia/core/lib/common/resource';
61
60
  import { ThemeService } from '@theia/core/lib/browser/theming';
62
61
 
@@ -110,9 +109,6 @@ export function setUpPluginApi(rpc: RPCProtocol, container: interfaces.Container
110
109
  const notificationMain = new NotificationMainImpl(rpc, container);
111
110
  rpc.set(PLUGIN_RPC_CONTEXT.NOTIFICATION_MAIN, notificationMain);
112
111
 
113
- const notificationExt = new NotificationExtImpl(rpc);
114
- rpc.set(MAIN_RPC_CONTEXT.NOTIFICATION_EXT, notificationExt);
115
-
116
112
  const terminalMain = new TerminalServiceMainImpl(rpc, container);
117
113
  rpc.set(PLUGIN_RPC_CONTEXT.TERMINAL_MAIN, terminalMain);
118
114
 
@@ -26,7 +26,7 @@ import { RPCProtocol } from '../../common/rpc-protocol';
26
26
  import { Disposable, DisposableCollection } from '@theia/core/lib/common';
27
27
  import { TaskProviderRegistry, TaskResolverRegistry, TaskProvider, TaskResolver } from '@theia/task/lib/browser/task-contribution';
28
28
  import { interfaces } from '@theia/core/shared/inversify';
29
- import { TaskInfo, TaskExitedEvent, TaskConfiguration, TaskCustomization, TaskOutputPresentation, RevealKind, PanelKind } from '@theia/task/lib/common/task-protocol';
29
+ import { TaskInfo, TaskExitedEvent, TaskConfiguration, TaskOutputPresentation, RevealKind, PanelKind } from '@theia/task/lib/common/task-protocol';
30
30
  import { TaskWatcher } from '@theia/task/lib/common/task-watcher';
31
31
  import { TaskService } from '@theia/task/lib/browser/task-service';
32
32
  import { TaskDefinitionRegistry } from '@theia/task/lib/browser';
@@ -207,8 +207,11 @@ export class TasksMainImpl implements TasksMain, Disposable {
207
207
  if (presentation) {
208
208
  partialConfig.presentation = this.convertTaskPresentation(presentation);
209
209
  }
210
- if (group === 'build' || group === 'test') {
211
- partialConfig.group = group;
210
+ if (group) {
211
+ partialConfig.group = {
212
+ kind: group.kind,
213
+ isDefault: group.isDefault
214
+ };
212
215
  }
213
216
  return {
214
217
  ...common,
@@ -225,12 +228,13 @@ export class TasksMainImpl implements TasksMain, Disposable {
225
228
  if (presentation) {
226
229
  partialDto.presentation = this.convertTaskPresentation(presentation);
227
230
  }
228
- if (group) {
229
- if (TaskCustomization.isBuildTask(task)) {
230
- partialDto.group = 'build';
231
- } else if (TaskCustomization.isTestTask(task)) {
232
- partialDto.group = 'test';
233
- }
231
+ if (group === 'build' || group === 'test') {
232
+ partialDto.group = {
233
+ kind: group,
234
+ isDefault: false
235
+ };
236
+ } else if (typeof group === 'object') {
237
+ partialDto.group = group;
234
238
  }
235
239
  return {
236
240
  ...common,
@@ -22,7 +22,6 @@ import * as model from '../common/plugin-api-rpc-model';
22
22
  import { MarkdownString } from './markdown-string';
23
23
  import { MarkdownString as MarkdownStringInterface } from '@theia/core/lib/common/markdown-rendering';
24
24
  import { TaskDto } from '../common/plugin-api-rpc';
25
- import { TaskGroup } from './types-impl';
26
25
 
27
26
  describe('Type converters:', () => {
28
27
 
@@ -185,8 +184,7 @@ describe('Type converters:', () => {
185
184
  const args = ['run', 'build'];
186
185
  const cwd = '/projects/theia';
187
186
  const additionalProperty = 'some property';
188
- const groupDto = 'build';
189
- const group = TaskGroup.Build;
187
+ const group = new types.TaskGroup('build', 'Build');
190
188
 
191
189
  const shellTaskDto: TaskDto = {
192
190
  type: shellType,
@@ -202,7 +200,10 @@ describe('Type converters:', () => {
202
200
  reveal: 3,
203
201
  focus: true
204
202
  },
205
- group: groupDto,
203
+ group: {
204
+ kind: 'build',
205
+ isDefault: false
206
+ },
206
207
  runOptions: {
207
208
  reevaluateOnRerun: false
208
209
  }
@@ -31,8 +31,6 @@ import { MarkdownString as MarkdownStringDTO } from '@theia/core/lib/common/mark
31
31
 
32
32
  const SIDE_GROUP = -2;
33
33
  const ACTIVE_GROUP = -1;
34
- const BUILD_GROUP = 'build';
35
- const TEST_GROUP = 'test';
36
34
 
37
35
  export function toViewColumn(ep?: EditorPosition): theia.ViewColumn | undefined {
38
36
  if (typeof ep !== 'number') {
@@ -846,11 +844,11 @@ export function fromTask(task: theia.Task): TaskDto | undefined {
846
844
  taskDto.presentation = task.presentationOptions;
847
845
  }
848
846
 
849
- const group = task.group;
850
- if (group === types.TaskGroup.Build) {
851
- taskDto.group = BUILD_GROUP;
852
- } else if (group === types.TaskGroup.Test) {
853
- taskDto.group = TEST_GROUP;
847
+ if (task.group) {
848
+ taskDto.group = {
849
+ kind: <rpc.TaskGroupKind>task.group.id,
850
+ isDefault: !!task.group.isDefault
851
+ };
854
852
  }
855
853
 
856
854
  const taskDefinition = task.definition;
@@ -936,11 +934,11 @@ export function toTask(taskDto: TaskDto): theia.Task {
936
934
  }
937
935
 
938
936
  if (group) {
939
- if (group === BUILD_GROUP) {
940
- result.group = types.TaskGroup.Build;
941
- } else if (group === TEST_GROUP) {
942
- result.group = types.TaskGroup.Test;
943
- }
937
+ result.group = new types.TaskGroup(
938
+ group.kind,
939
+ group.kind,
940
+ group.isDefault
941
+ );
944
942
  }
945
943
 
946
944
  if (presentation) {
@@ -30,22 +30,8 @@ import { startsWithIgnoreCase } from '@theia/core/lib/common/strings';
30
30
  import { SymbolKind } from '../common/plugin-api-rpc-model';
31
31
  import { FileSystemProviderErrorCode, markAsFileSystemProviderError } from '@theia/filesystem/lib/common/files';
32
32
  import * as paths from 'path';
33
- import { ObjectsTransferrer } from '../common/rpc-protocol';
34
33
  import { es5ClassCompat } from '../common/types';
35
34
 
36
- /**
37
- * A reviver that takes URI's transferred via JSON.stringify() and makes
38
- * instances of our local plugin API URI class (below)
39
- */
40
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
- export function reviver(key: string | undefined, value: any): any {
42
- const revived = ObjectsTransferrer.reviver(key, value);
43
- if (CodeURI.isUri(revived)) {
44
- return URI.revive(revived);
45
- }
46
- return revived;
47
- }
48
-
49
35
  /**
50
36
  * This is an implementation of #theia.Uri based on vscode-uri.
51
37
  * This is supposed to fix https://github.com/eclipse-theia/theia/issues/8752
@@ -2008,7 +1994,6 @@ export class CustomExecution {
2008
1994
 
2009
1995
  @es5ClassCompat
2010
1996
  export class TaskGroup {
2011
- private groupId: string;
2012
1997
 
2013
1998
  public static Clean: TaskGroup = new TaskGroup('clean', 'Clean');
2014
1999
  public static Build: TaskGroup = new TaskGroup('build', 'Build');
@@ -2030,19 +2015,13 @@ export class TaskGroup {
2030
2015
  }
2031
2016
  }
2032
2017
 
2033
- constructor(id: string, label: string) {
2034
- if (typeof id !== 'string') {
2035
- throw illegalArgument('id');
2036
- }
2037
- if (typeof label !== 'string') {
2038
- throw illegalArgument('name');
2039
- }
2040
- this.groupId = id;
2018
+ constructor(id: 'clean' | 'build' | 'rebuild' | 'test', label: string);
2019
+ constructor(id: 'clean' | 'build' | 'rebuild' | 'test', label: string, isDefault?: boolean | undefined);
2020
+ constructor(readonly id: 'clean' | 'build' | 'rebuild' | 'test', label: string, isDefault?: boolean | undefined) {
2021
+ this.isDefault = !!isDefault;
2041
2022
  }
2042
2023
 
2043
- get id(): string {
2044
- return this.groupId;
2045
- }
2024
+ readonly isDefault: boolean;
2046
2025
  }
2047
2026
 
2048
2027
  export enum TaskScope {
@@ -2127,6 +2106,7 @@ export class Task {
2127
2106
  }
2128
2107
  this.isTaskBackground = false;
2129
2108
  this.presentationOptions = Object.create(null);
2109
+ this.taskRunOptions = Object.create(null);
2130
2110
  }
2131
2111
 
2132
2112
  get definition(): theia.TaskDefinition {