@theia/plugin-ext-headless 1.46.0-next.106

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 (107) hide show
  1. package/README.md +32 -0
  2. package/lib/common/headless-plugin-container.d.ts +8 -0
  3. package/lib/common/headless-plugin-container.d.ts.map +1 -0
  4. package/lib/common/headless-plugin-container.js +26 -0
  5. package/lib/common/headless-plugin-container.js.map +1 -0
  6. package/lib/common/headless-plugin-protocol.d.ts +21 -0
  7. package/lib/common/headless-plugin-protocol.d.ts.map +1 -0
  8. package/lib/common/headless-plugin-protocol.js +26 -0
  9. package/lib/common/headless-plugin-protocol.js.map +1 -0
  10. package/lib/common/headless-plugin-rpc.d.ts +23 -0
  11. package/lib/common/headless-plugin-rpc.d.ts.map +1 -0
  12. package/lib/common/headless-plugin-rpc.js +31 -0
  13. package/lib/common/headless-plugin-rpc.js.map +1 -0
  14. package/lib/common/index.d.ts +5 -0
  15. package/lib/common/index.d.ts.map +1 -0
  16. package/lib/common/index.js +26 -0
  17. package/lib/common/index.js.map +1 -0
  18. package/lib/common/plugin-ext-headless-api-contribution.d.ts +38 -0
  19. package/lib/common/plugin-ext-headless-api-contribution.d.ts.map +1 -0
  20. package/lib/common/plugin-ext-headless-api-contribution.js +20 -0
  21. package/lib/common/plugin-ext-headless-api-contribution.js.map +1 -0
  22. package/lib/hosted/node/headless-hosted-plugin.d.ts +30 -0
  23. package/lib/hosted/node/headless-hosted-plugin.d.ts.map +1 -0
  24. package/lib/hosted/node/headless-hosted-plugin.js +184 -0
  25. package/lib/hosted/node/headless-hosted-plugin.js.map +1 -0
  26. package/lib/hosted/node/plugin-ext-headless-hosted-module.d.ts +4 -0
  27. package/lib/hosted/node/plugin-ext-headless-hosted-module.d.ts.map +1 -0
  28. package/lib/hosted/node/plugin-ext-headless-hosted-module.js +69 -0
  29. package/lib/hosted/node/plugin-ext-headless-hosted-module.js.map +1 -0
  30. package/lib/hosted/node/plugin-host-headless-module.d.ts +5 -0
  31. package/lib/hosted/node/plugin-host-headless-module.d.ts.map +1 -0
  32. package/lib/hosted/node/plugin-host-headless-module.js +73 -0
  33. package/lib/hosted/node/plugin-host-headless-module.js.map +1 -0
  34. package/lib/hosted/node/plugin-host-headless-rpc.d.ts +21 -0
  35. package/lib/hosted/node/plugin-host-headless-rpc.d.ts.map +1 -0
  36. package/lib/hosted/node/plugin-host-headless-rpc.js +74 -0
  37. package/lib/hosted/node/plugin-host-headless-rpc.js.map +1 -0
  38. package/lib/hosted/node/plugin-host-headless.d.ts +2 -0
  39. package/lib/hosted/node/plugin-host-headless.d.ts.map +1 -0
  40. package/lib/hosted/node/plugin-host-headless.js +104 -0
  41. package/lib/hosted/node/plugin-host-headless.js.map +1 -0
  42. package/lib/hosted/node/scanners/scanner-theia-headless.d.ts +26 -0
  43. package/lib/hosted/node/scanners/scanner-theia-headless.d.ts.map +1 -0
  44. package/lib/hosted/node/scanners/scanner-theia-headless.js +83 -0
  45. package/lib/hosted/node/scanners/scanner-theia-headless.js.map +1 -0
  46. package/lib/hosted/node-electron/plugin-ext-headless-hosted-electron-module.d.ts +3 -0
  47. package/lib/hosted/node-electron/plugin-ext-headless-hosted-electron-module.d.ts.map +1 -0
  48. package/lib/hosted/node-electron/plugin-ext-headless-hosted-electron-module.js +24 -0
  49. package/lib/hosted/node-electron/plugin-ext-headless-hosted-electron-module.js.map +1 -0
  50. package/lib/index.d.ts +2 -0
  51. package/lib/index.d.ts.map +1 -0
  52. package/lib/index.js +20 -0
  53. package/lib/index.js.map +1 -0
  54. package/lib/main/node/handlers/plugin-theia-headless-directory-handler.d.ts +7 -0
  55. package/lib/main/node/handlers/plugin-theia-headless-directory-handler.d.ts.map +1 -0
  56. package/lib/main/node/handlers/plugin-theia-headless-directory-handler.js +38 -0
  57. package/lib/main/node/handlers/plugin-theia-headless-directory-handler.js.map +1 -0
  58. package/lib/main/node/headless-progress-client.d.ts +10 -0
  59. package/lib/main/node/headless-progress-client.d.ts.map +1 -0
  60. package/lib/main/node/headless-progress-client.js +47 -0
  61. package/lib/main/node/headless-progress-client.js.map +1 -0
  62. package/lib/main/node/main-context.d.ts +4 -0
  63. package/lib/main/node/main-context.d.ts.map +1 -0
  64. package/lib/main/node/main-context.js +19 -0
  65. package/lib/main/node/main-context.js.map +1 -0
  66. package/lib/main/node/plugin-ext-headless-main-module.d.ts +4 -0
  67. package/lib/main/node/plugin-ext-headless-main-module.d.ts.map +1 -0
  68. package/lib/main/node/plugin-ext-headless-main-module.js +38 -0
  69. package/lib/main/node/plugin-ext-headless-main-module.js.map +1 -0
  70. package/lib/package.spec.d.ts +1 -0
  71. package/lib/package.spec.d.ts.map +1 -0
  72. package/lib/package.spec.js +24 -0
  73. package/lib/package.spec.js.map +1 -0
  74. package/lib/plugin/headless-plugin-manager.d.ts +10 -0
  75. package/lib/plugin/headless-plugin-manager.d.ts.map +1 -0
  76. package/lib/plugin/headless-plugin-manager.js +51 -0
  77. package/lib/plugin/headless-plugin-manager.js.map +1 -0
  78. package/lib/plugin-ext-headless-electron-module.d.ts +4 -0
  79. package/lib/plugin-ext-headless-electron-module.d.ts.map +1 -0
  80. package/lib/plugin-ext-headless-electron-module.js +32 -0
  81. package/lib/plugin-ext-headless-electron-module.js.map +1 -0
  82. package/lib/plugin-ext-headless-module.d.ts +4 -0
  83. package/lib/plugin-ext-headless-module.d.ts.map +1 -0
  84. package/lib/plugin-ext-headless-module.js +31 -0
  85. package/lib/plugin-ext-headless-module.js.map +1 -0
  86. package/package.json +57 -0
  87. package/src/common/headless-plugin-container.ts +23 -0
  88. package/src/common/headless-plugin-protocol.ts +38 -0
  89. package/src/common/headless-plugin-rpc.ts +46 -0
  90. package/src/common/index.ts +23 -0
  91. package/src/common/plugin-ext-headless-api-contribution.ts +60 -0
  92. package/src/hosted/node/headless-hosted-plugin.ts +199 -0
  93. package/src/hosted/node/plugin-ext-headless-hosted-module.ts +75 -0
  94. package/src/hosted/node/plugin-host-headless-module.ts +76 -0
  95. package/src/hosted/node/plugin-host-headless-rpc.ts +80 -0
  96. package/src/hosted/node/plugin-host-headless.ts +111 -0
  97. package/src/hosted/node/scanners/scanner-theia-headless.ts +85 -0
  98. package/src/hosted/node-electron/plugin-ext-headless-hosted-electron-module.ts +22 -0
  99. package/src/index.ts +17 -0
  100. package/src/main/node/handlers/plugin-theia-headless-directory-handler.ts +35 -0
  101. package/src/main/node/headless-progress-client.ts +44 -0
  102. package/src/main/node/main-context.ts +35 -0
  103. package/src/main/node/plugin-ext-headless-main-module.ts +42 -0
  104. package/src/package.spec.ts +25 -0
  105. package/src/plugin/headless-plugin-manager.ts +50 -0
  106. package/src/plugin-ext-headless-electron-module.ts +32 -0
  107. package/src/plugin-ext-headless-module.ts +31 -0
@@ -0,0 +1,35 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable } from '@theia/core/shared/inversify';
18
+
19
+ import { PluginDeployerDirectoryHandlerContext, PluginDeployerEntryType, PluginPackage } from '@theia/plugin-ext';
20
+ import { AbstractPluginDirectoryHandler } from '@theia/plugin-ext/lib/main/node/handlers/plugin-theia-directory-handler';
21
+
22
+ @injectable()
23
+ export class PluginTheiaHeadlessDirectoryHandler extends AbstractPluginDirectoryHandler {
24
+
25
+ protected acceptManifest(plugin: PluginPackage): boolean {
26
+ return plugin?.engines?.theiaPlugin === undefined && 'theiaHeadlessPlugin' in plugin.engines;
27
+ }
28
+
29
+ async handle(context: PluginDeployerDirectoryHandlerContext): Promise<void> {
30
+ await this.copyDirectory(context);
31
+ const types: PluginDeployerEntryType[] = [PluginDeployerEntryType.HEADLESS];
32
+ context.pluginEntry().accept(...types);
33
+ }
34
+
35
+ }
@@ -0,0 +1,44 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable } from '@theia/core/shared/inversify';
18
+ import {
19
+ CancellationToken,
20
+ ProgressClient, ProgressMessage, ProgressUpdate
21
+ } from '@theia/core';
22
+
23
+ /**
24
+ * A simple progress client for headless plugins that just writes debug messages to the console
25
+ * because there is no one connected frontend to which it is appropriate to send the messages.
26
+ */
27
+ @injectable()
28
+ export class HeadlessProgressClient implements ProgressClient {
29
+ async showProgress(_progressId: string, message: ProgressMessage, cancellationToken: CancellationToken): Promise<string | undefined> {
30
+ if (cancellationToken.isCancellationRequested) {
31
+ return ProgressMessage.Cancel;
32
+ }
33
+ console.debug(message.text);
34
+ }
35
+
36
+ async reportProgress(_progressId: string, update: ProgressUpdate, message: ProgressMessage, cancellationToken: CancellationToken): Promise<void> {
37
+ if (cancellationToken.isCancellationRequested) {
38
+ return;
39
+ }
40
+ const progress = update.work && update.work.total ? `[${100 * Math.min(update.work.done, update.work.total) / update.work.total}%]` : '';
41
+ const text = `${progress} ${update.message ?? 'completed ...'}`;
42
+ console.debug(text);
43
+ }
44
+ }
@@ -0,0 +1,35 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+ import { interfaces } from '@theia/core/shared/inversify';
17
+ import { RPCProtocol } from '@theia/plugin-ext/lib/common/rpc-protocol';
18
+ import { EnvMainImpl } from '@theia/plugin-ext/lib/main/common/env-main';
19
+ import { BasicMessageRegistryMainImpl } from '@theia/plugin-ext/lib/main/common/basic-message-registry-main';
20
+ import { BasicNotificationMainImpl } from '@theia/plugin-ext/lib/main/common/basic-notification-main';
21
+
22
+ import { HEADLESSMAIN_RPC_CONTEXT, HEADLESSPLUGIN_RPC_CONTEXT } from '../../common/headless-plugin-rpc';
23
+
24
+ // This sets up only the minimal plugin API required by the plugin manager to report
25
+ // messages and notifications to the main side and to initialize plugins.
26
+ export function setUpPluginApi(rpc: RPCProtocol, container: interfaces.Container): void {
27
+ const envMain = new EnvMainImpl(rpc, container);
28
+ rpc.set(HEADLESSPLUGIN_RPC_CONTEXT.ENV_MAIN, envMain);
29
+
30
+ const messageRegistryMain = new BasicMessageRegistryMainImpl(container);
31
+ rpc.set(HEADLESSPLUGIN_RPC_CONTEXT.MESSAGE_REGISTRY_MAIN, messageRegistryMain);
32
+
33
+ const notificationMain = new BasicNotificationMainImpl(rpc, container, HEADLESSMAIN_RPC_CONTEXT.NOTIFICATION_EXT);
34
+ rpc.set(HEADLESSPLUGIN_RPC_CONTEXT.NOTIFICATION_MAIN, notificationMain);
35
+ }
@@ -0,0 +1,42 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { interfaces } from '@theia/core/shared/inversify';
18
+ import {
19
+ MessageClient, MessageService,
20
+ ProgressClient, ProgressService,
21
+ bindContributionProvider
22
+ } from '@theia/core';
23
+ import { MainPluginApiProvider, PluginDeployerDirectoryHandler } from '@theia/plugin-ext';
24
+ import { PluginTheiaHeadlessDirectoryHandler } from './handlers/plugin-theia-headless-directory-handler';
25
+ import { HeadlessProgressClient } from './headless-progress-client';
26
+
27
+ export function bindHeadlessMain(bind: interfaces.Bind): void {
28
+ bind(PluginDeployerDirectoryHandler).to(PluginTheiaHeadlessDirectoryHandler).inSingletonScope();
29
+ }
30
+
31
+ export function bindBackendMain(bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind): void {
32
+ bindContributionProvider(bind, MainPluginApiProvider);
33
+
34
+ //
35
+ // Main API dependencies
36
+ //
37
+
38
+ bind(MessageService).toSelf().inSingletonScope();
39
+ bind(MessageClient).toSelf().inSingletonScope(); // Just logs to console
40
+ bind(ProgressService).toSelf().inSingletonScope();
41
+ bind(ProgressClient).to(HeadlessProgressClient).inSingletonScope();
42
+ }
@@ -0,0 +1,25 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ /*
18
+ * This is a placeholder for tests that the extension package should implement
19
+ * but as yet does not.
20
+ * Please delete this file when a real test is implemented.
21
+ */
22
+
23
+ describe('plugin-ext-headless package', () => {
24
+ it('placeholder to enable mocha', () => true);
25
+ });
@@ -0,0 +1,50 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable } from '@theia/core/shared/inversify';
18
+ import { AbstractPluginManagerExtImpl } from '@theia/plugin-ext/lib/plugin/plugin-manager';
19
+ import { HeadlessPluginManagerExt, HeadlessPluginManagerInitializeParams } from '../common/headless-plugin-rpc';
20
+ import { Plugin } from '@theia/plugin-ext';
21
+
22
+ @injectable()
23
+ export class HeadlessPluginManagerExtImpl extends AbstractPluginManagerExtImpl<HeadlessPluginManagerInitializeParams> implements HeadlessPluginManagerExt {
24
+
25
+ private readonly supportedActivationEvents = new Set<string>();
26
+
27
+ async $init(params: HeadlessPluginManagerInitializeParams): Promise<void> {
28
+ params.activationEvents?.forEach(event => this.supportedActivationEvents.add(event));
29
+
30
+ this.storage.init(params.globalState, {});
31
+
32
+ this.envExt.setLanguage(params.env.language);
33
+ this.envExt.setApplicationName(params.env.appName);
34
+ this.envExt.setAppHost(params.env.appHost);
35
+
36
+ if (params.extApi) {
37
+ this.host.initExtApi(params.extApi);
38
+ }
39
+ }
40
+
41
+ protected override getActivationEvents(plugin: Plugin): string[] | undefined {
42
+ const result = plugin.rawModel?.headless?.activationEvents;
43
+ return Array.isArray(result) ? result : undefined;
44
+ }
45
+
46
+ protected isSupportedActivationEvent(activationEvent: string): boolean {
47
+ return this.supportedActivationEvents.has(activationEvent.split(':')[0]);
48
+ }
49
+
50
+ }
@@ -0,0 +1,32 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { ContainerModule } from '@theia/core/shared/inversify';
18
+ import { HeadlessPluginContainerModule } from './common/headless-plugin-container';
19
+ import { bindElectronBackend } from './hosted/node-electron/plugin-ext-headless-hosted-electron-module';
20
+ import { bindHeadlessMain, bindBackendMain } from './main/node/plugin-ext-headless-main-module';
21
+ import { bindHeadlessHosted } from './hosted/node/plugin-ext-headless-hosted-module';
22
+
23
+ const backendElectronModule = new ContainerModule((bind, unbind, isBound, rebind) => {
24
+ bindBackendMain(bind, unbind, isBound, rebind);
25
+ bindElectronBackend(bind);
26
+ });
27
+
28
+ export default new ContainerModule(bind => {
29
+ bind(HeadlessPluginContainerModule).toConstantValue(backendElectronModule);
30
+ bindHeadlessMain(bind);
31
+ bindHeadlessHosted(bind);
32
+ });
@@ -0,0 +1,31 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { ContainerModule } from '@theia/core/shared/inversify';
18
+ import { HeadlessPluginContainerModule } from './common/headless-plugin-container';
19
+ import { bindHeadlessHosted, bindCommonHostedBackend } from './hosted/node/plugin-ext-headless-hosted-module';
20
+ import { bindHeadlessMain, bindBackendMain } from './main/node/plugin-ext-headless-main-module';
21
+
22
+ const backendModule = new ContainerModule((bind, unbind, isBound, rebind) => {
23
+ bindBackendMain(bind, unbind, isBound, rebind);
24
+ bindCommonHostedBackend(bind);
25
+ });
26
+
27
+ export default new ContainerModule(bind => {
28
+ bind(HeadlessPluginContainerModule).toConstantValue(backendModule);
29
+ bindHeadlessMain(bind);
30
+ bindHeadlessHosted(bind);
31
+ });