@theia/remote 1.43.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 (142) hide show
  1. package/README.md +61 -0
  2. package/lib/electron-browser/remote-electron-file-dialog-service.d.ts +14 -0
  3. package/lib/electron-browser/remote-electron-file-dialog-service.d.ts.map +1 -0
  4. package/lib/electron-browser/remote-electron-file-dialog-service.js +58 -0
  5. package/lib/electron-browser/remote-electron-file-dialog-service.js.map +1 -0
  6. package/lib/electron-browser/remote-frontend-contribution.d.ts +26 -0
  7. package/lib/electron-browser/remote-frontend-contribution.d.ts.map +1 -0
  8. package/lib/electron-browser/remote-frontend-contribution.js +165 -0
  9. package/lib/electron-browser/remote-frontend-contribution.js.map +1 -0
  10. package/lib/electron-browser/remote-frontend-module.d.ts +4 -0
  11. package/lib/electron-browser/remote-frontend-module.d.ts.map +1 -0
  12. package/lib/electron-browser/remote-frontend-module.js +43 -0
  13. package/lib/electron-browser/remote-frontend-module.js.map +1 -0
  14. package/lib/electron-browser/remote-preferences.d.ts +11 -0
  15. package/lib/electron-browser/remote-preferences.d.ts.map +1 -0
  16. package/lib/electron-browser/remote-preferences.js +49 -0
  17. package/lib/electron-browser/remote-preferences.js.map +1 -0
  18. package/lib/electron-browser/remote-registry-contribution.d.ts +19 -0
  19. package/lib/electron-browser/remote-registry-contribution.d.ts.map +1 -0
  20. package/lib/electron-browser/remote-registry-contribution.js +75 -0
  21. package/lib/electron-browser/remote-registry-contribution.js.map +1 -0
  22. package/lib/electron-browser/remote-service.d.ts +6 -0
  23. package/lib/electron-browser/remote-service.d.ts.map +1 -0
  24. package/lib/electron-browser/remote-service.js +38 -0
  25. package/lib/electron-browser/remote-service.js.map +1 -0
  26. package/lib/electron-browser/remote-ssh-contribution.d.ts +18 -0
  27. package/lib/electron-browser/remote-ssh-contribution.d.ts.map +1 -0
  28. package/lib/electron-browser/remote-ssh-contribution.js +118 -0
  29. package/lib/electron-browser/remote-ssh-contribution.js.map +1 -0
  30. package/lib/electron-common/remote-ssh-connection-provider.d.ts +11 -0
  31. package/lib/electron-common/remote-ssh-connection-provider.d.ts.map +1 -0
  32. package/lib/electron-common/remote-ssh-connection-provider.js +21 -0
  33. package/lib/electron-common/remote-ssh-connection-provider.js.map +1 -0
  34. package/lib/electron-common/remote-status-service.d.ts +15 -0
  35. package/lib/electron-common/remote-status-service.d.ts.map +1 -0
  36. package/lib/electron-common/remote-status-service.js +21 -0
  37. package/lib/electron-common/remote-status-service.js.map +1 -0
  38. package/lib/electron-node/backend-remote-service-impl.d.ts +12 -0
  39. package/lib/electron-node/backend-remote-service-impl.d.ts.map +1 -0
  40. package/lib/electron-node/backend-remote-service-impl.js +51 -0
  41. package/lib/electron-node/backend-remote-service-impl.js.map +1 -0
  42. package/lib/electron-node/remote-backend-module.d.ts +5 -0
  43. package/lib/electron-node/remote-backend-module.d.ts.map +1 -0
  44. package/lib/electron-node/remote-backend-module.js +75 -0
  45. package/lib/electron-node/remote-backend-module.js.map +1 -0
  46. package/lib/electron-node/remote-connection-service.d.ts +15 -0
  47. package/lib/electron-node/remote-connection-service.d.ts.map +1 -0
  48. package/lib/electron-node/remote-connection-service.js +66 -0
  49. package/lib/electron-node/remote-connection-service.js.map +1 -0
  50. package/lib/electron-node/remote-connection-socket-provider.d.ts +9 -0
  51. package/lib/electron-node/remote-connection-socket-provider.d.ts.map +1 -0
  52. package/lib/electron-node/remote-connection-socket-provider.js +38 -0
  53. package/lib/electron-node/remote-connection-socket-provider.js.map +1 -0
  54. package/lib/electron-node/remote-proxy-server-provider.d.ts +6 -0
  55. package/lib/electron-node/remote-proxy-server-provider.d.ts.map +1 -0
  56. package/lib/electron-node/remote-proxy-server-provider.js +44 -0
  57. package/lib/electron-node/remote-proxy-server-provider.js.map +1 -0
  58. package/lib/electron-node/remote-status-service.d.ts +7 -0
  59. package/lib/electron-node/remote-status-service.d.ts.map +1 -0
  60. package/lib/electron-node/remote-status-service.js +55 -0
  61. package/lib/electron-node/remote-status-service.js.map +1 -0
  62. package/lib/electron-node/remote-types.d.ts +35 -0
  63. package/lib/electron-node/remote-types.d.ts.map +1 -0
  64. package/lib/electron-node/remote-types.js +18 -0
  65. package/lib/electron-node/remote-types.js.map +1 -0
  66. package/lib/electron-node/setup/app-native-dependency-contribution.d.ts +8 -0
  67. package/lib/electron-node/setup/app-native-dependency-contribution.d.ts.map +1 -0
  68. package/lib/electron-node/setup/app-native-dependency-contribution.js +58 -0
  69. package/lib/electron-node/setup/app-native-dependency-contribution.js.map +1 -0
  70. package/lib/electron-node/setup/main-copy-contribution.d.ts +5 -0
  71. package/lib/electron-node/setup/main-copy-contribution.d.ts.map +1 -0
  72. package/lib/electron-node/setup/main-copy-contribution.js +38 -0
  73. package/lib/electron-node/setup/main-copy-contribution.js.map +1 -0
  74. package/lib/electron-node/setup/remote-copy-contribution.d.ts +29 -0
  75. package/lib/electron-node/setup/remote-copy-contribution.d.ts.map +1 -0
  76. package/lib/electron-node/setup/remote-copy-contribution.js +79 -0
  77. package/lib/electron-node/setup/remote-copy-contribution.js.map +1 -0
  78. package/lib/electron-node/setup/remote-copy-service.d.ts +19 -0
  79. package/lib/electron-node/setup/remote-copy-service.d.ts.map +1 -0
  80. package/lib/electron-node/setup/remote-copy-service.js +127 -0
  81. package/lib/electron-node/setup/remote-copy-service.js.map +1 -0
  82. package/lib/electron-node/setup/remote-native-dependency-contribution.d.ts +35 -0
  83. package/lib/electron-node/setup/remote-native-dependency-contribution.d.ts.map +1 -0
  84. package/lib/electron-node/setup/remote-native-dependency-contribution.js +35 -0
  85. package/lib/electron-node/setup/remote-native-dependency-contribution.js.map +1 -0
  86. package/lib/electron-node/setup/remote-native-dependency-service.d.ts +24 -0
  87. package/lib/electron-node/setup/remote-native-dependency-service.d.ts.map +1 -0
  88. package/lib/electron-node/setup/remote-native-dependency-service.js +119 -0
  89. package/lib/electron-node/setup/remote-native-dependency-service.js.map +1 -0
  90. package/lib/electron-node/setup/remote-node-setup-service.d.ts +23 -0
  91. package/lib/electron-node/setup/remote-node-setup-service.d.ts.map +1 -0
  92. package/lib/electron-node/setup/remote-node-setup-service.js +133 -0
  93. package/lib/electron-node/setup/remote-node-setup-service.js.map +1 -0
  94. package/lib/electron-node/setup/remote-setup-script-service.d.ts +41 -0
  95. package/lib/electron-node/setup/remote-setup-script-service.d.ts.map +1 -0
  96. package/lib/electron-node/setup/remote-setup-script-service.js +133 -0
  97. package/lib/electron-node/setup/remote-setup-script-service.js.map +1 -0
  98. package/lib/electron-node/setup/remote-setup-service.d.ts +29 -0
  99. package/lib/electron-node/setup/remote-setup-service.d.ts.map +1 -0
  100. package/lib/electron-node/setup/remote-setup-service.js +199 -0
  101. package/lib/electron-node/setup/remote-setup-service.js.map +1 -0
  102. package/lib/electron-node/ssh/remote-ssh-connection-provider.d.ts +56 -0
  103. package/lib/electron-node/ssh/remote-ssh-connection-provider.d.ts.map +1 -0
  104. package/lib/electron-node/ssh/remote-ssh-connection-provider.js +343 -0
  105. package/lib/electron-node/ssh/remote-ssh-connection-provider.js.map +1 -0
  106. package/lib/electron-node/ssh/ssh-identity-file-collector.d.ts +13 -0
  107. package/lib/electron-node/ssh/ssh-identity-file-collector.d.ts.map +1 -0
  108. package/lib/electron-node/ssh/ssh-identity-file-collector.js +132 -0
  109. package/lib/electron-node/ssh/ssh-identity-file-collector.js.map +1 -0
  110. package/lib/package.spec.d.ts +1 -0
  111. package/lib/package.spec.d.ts.map +1 -0
  112. package/lib/package.spec.js +26 -0
  113. package/lib/package.spec.js.map +1 -0
  114. package/package.json +67 -0
  115. package/src/electron-browser/remote-electron-file-dialog-service.ts +47 -0
  116. package/src/electron-browser/remote-frontend-contribution.ts +145 -0
  117. package/src/electron-browser/remote-frontend-module.ts +49 -0
  118. package/src/electron-browser/remote-preferences.ts +62 -0
  119. package/src/electron-browser/remote-registry-contribution.ts +70 -0
  120. package/src/electron-browser/remote-service.ts +31 -0
  121. package/src/electron-browser/remote-ssh-contribution.ts +102 -0
  122. package/src/electron-common/remote-ssh-connection-provider.ts +29 -0
  123. package/src/electron-common/remote-status-service.ts +35 -0
  124. package/src/electron-node/backend-remote-service-impl.ts +45 -0
  125. package/src/electron-node/remote-backend-module.ts +80 -0
  126. package/src/electron-node/remote-connection-service.ts +55 -0
  127. package/src/electron-node/remote-connection-socket-provider.ts +34 -0
  128. package/src/electron-node/remote-proxy-server-provider.ts +37 -0
  129. package/src/electron-node/remote-status-service.ts +41 -0
  130. package/src/electron-node/remote-types.ts +56 -0
  131. package/src/electron-node/setup/app-native-dependency-contribution.ts +48 -0
  132. package/src/electron-node/setup/main-copy-contribution.ts +28 -0
  133. package/src/electron-node/setup/remote-copy-contribution.ts +90 -0
  134. package/src/electron-node/setup/remote-copy-service.ts +114 -0
  135. package/src/electron-node/setup/remote-native-dependency-contribution.ts +63 -0
  136. package/src/electron-node/setup/remote-native-dependency-service.ts +111 -0
  137. package/src/electron-node/setup/remote-node-setup-service.ts +123 -0
  138. package/src/electron-node/setup/remote-setup-script-service.ts +146 -0
  139. package/src/electron-node/setup/remote-setup-service.ts +197 -0
  140. package/src/electron-node/ssh/remote-ssh-connection-provider.ts +356 -0
  141. package/src/electron-node/ssh/ssh-identity-file-collector.ts +137 -0
  142. package/src/package.spec.ts +29 -0
@@ -0,0 +1,102 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox 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 { Command, MessageService, nls, QuickInputService } from '@theia/core';
18
+ import { inject, injectable } from '@theia/core/shared/inversify';
19
+ import { RemoteSSHConnectionProvider } from '../electron-common/remote-ssh-connection-provider';
20
+ import { AbstractRemoteRegistryContribution, RemoteRegistry } from './remote-registry-contribution';
21
+ import { RemotePreferences } from './remote-preferences';
22
+
23
+ export namespace RemoteSSHCommands {
24
+ export const CONNECT: Command = Command.toLocalizedCommand({
25
+ id: 'remote.ssh.connect',
26
+ category: 'SSH',
27
+ label: 'Connect to Host...',
28
+ }, 'theia/remoteSSH/connect');
29
+ export const CONNECT_CURRENT_WINDOW: Command = Command.toLocalizedCommand({
30
+ id: 'remote.ssh.connectCurrentWindow',
31
+ category: 'SSH',
32
+ label: 'Connect Current Window to Host...',
33
+ }, 'theia/remoteSSH/connect');
34
+ }
35
+
36
+ @injectable()
37
+ export class RemoteSSHContribution extends AbstractRemoteRegistryContribution {
38
+
39
+ @inject(QuickInputService)
40
+ protected readonly quickInputService: QuickInputService;
41
+
42
+ @inject(RemoteSSHConnectionProvider)
43
+ protected readonly sshConnectionProvider: RemoteSSHConnectionProvider;
44
+
45
+ @inject(MessageService)
46
+ protected readonly messageService: MessageService;
47
+
48
+ @inject(RemotePreferences)
49
+ protected readonly remotePreferences: RemotePreferences;
50
+
51
+ registerRemoteCommands(registry: RemoteRegistry): void {
52
+ registry.registerCommand(RemoteSSHCommands.CONNECT, {
53
+ execute: () => this.connect(true)
54
+ });
55
+ registry.registerCommand(RemoteSSHCommands.CONNECT_CURRENT_WINDOW, {
56
+ execute: () => this.connect(false)
57
+ });
58
+ }
59
+
60
+ async connect(newWindow: boolean): Promise<void> {
61
+ let host: string | undefined;
62
+ let user: string | undefined;
63
+ host = await this.quickInputService.input({
64
+ title: nls.localize('theia/remote/enterHost', 'Enter SSH host name'),
65
+ placeHolder: nls.localize('theia/remote/hostPlaceHolder', 'E.g. hello@example.com')
66
+ });
67
+ if (!host) {
68
+ this.messageService.error(nls.localize('theia/remote/needsHost', 'Please enter a host name.'));
69
+ return;
70
+ }
71
+ if (host.includes('@')) {
72
+ const split = host.split('@');
73
+ user = split[0];
74
+ host = split[1];
75
+ }
76
+ if (!user) {
77
+ user = await this.quickInputService.input({
78
+ title: nls.localize('theia/remote/enterUser', 'Enter SSH user name'),
79
+ placeHolder: nls.localize('theia/remote/userPlaceHolder', 'E.g. hello')
80
+ });
81
+ }
82
+ if (!user) {
83
+ this.messageService.error(nls.localize('theia/remote/needsUser', 'Please enter a user name.'));
84
+ return;
85
+ }
86
+
87
+ try {
88
+ const remotePort = await this.sendSSHConnect(host!, user!);
89
+ this.openRemote(remotePort, newWindow);
90
+ } catch (err) {
91
+ this.messageService.error(`${nls.localize('theia/remote/sshFailure', 'Could not open SSH connection to remote.')} ${err.message ?? String(err)}`);
92
+ }
93
+ }
94
+
95
+ async sendSSHConnect(host: string, user: string): Promise<string> {
96
+ return this.sshConnectionProvider.establishConnection({
97
+ host,
98
+ user,
99
+ nodeDownloadTemplate: this.remotePreferences['remote.nodeDownloadTemplate']
100
+ });
101
+ }
102
+ }
@@ -0,0 +1,29 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox 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
+ export const RemoteSSHConnectionProviderPath = '/remote/ssh';
18
+
19
+ export const RemoteSSHConnectionProvider = Symbol('RemoteSSHConnectionProvider');
20
+
21
+ export interface RemoteSSHConnectionProviderOptions {
22
+ user: string;
23
+ host: string;
24
+ nodeDownloadTemplate?: string;
25
+ }
26
+
27
+ export interface RemoteSSHConnectionProvider {
28
+ establishConnection(options: RemoteSSHConnectionProviderOptions): Promise<string>;
29
+ }
@@ -0,0 +1,35 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox 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
+ export type RemoteStatus = RemoteConnectedStatus | RemoteDisconnectedStatus;
18
+
19
+ export interface RemoteDisconnectedStatus {
20
+ alive: false;
21
+ }
22
+
23
+ export interface RemoteConnectedStatus {
24
+ alive: true;
25
+ type: string;
26
+ name: string;
27
+ }
28
+
29
+ export const RemoteStatusServicePath = '/remote/status';
30
+
31
+ export const RemoteStatusService = Symbol('RemoteStatusService');
32
+
33
+ export interface RemoteStatusService {
34
+ getStatus(localPort: number): Promise<RemoteStatus>
35
+ }
@@ -0,0 +1,45 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox 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 { CliContribution } from '@theia/core/lib/node';
18
+ import { injectable } from '@theia/core/shared/inversify';
19
+ import { Arguments, Argv } from '@theia/core/shared/yargs';
20
+ import { BackendRemoteService } from '@theia/core/lib/node/backend-remote-service';
21
+
22
+ export const REMOTE_START = 'remote';
23
+
24
+ @injectable()
25
+ export class BackendRemoteServiceImpl extends BackendRemoteService implements CliContribution {
26
+
27
+ protected isRemote: boolean = false;
28
+
29
+ configure(conf: Argv): void {
30
+ conf.option(REMOTE_START, {
31
+ description: 'Starts the server as an endpoint for a remote connection (i.e. through SSH)',
32
+ type: 'boolean',
33
+ default: false
34
+ });
35
+ }
36
+
37
+ setArguments(args: Arguments): void {
38
+ this.isRemote = Boolean(args[REMOTE_START]);
39
+ }
40
+
41
+ override isRemoteServer(): boolean {
42
+ return this.isRemote;
43
+ }
44
+
45
+ }
@@ -0,0 +1,80 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox 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 { BackendApplicationContribution, CliContribution } from '@theia/core/lib/node';
19
+ import { RemoteConnectionService } from './remote-connection-service';
20
+ import { RemoteProxyServerProvider } from './remote-proxy-server-provider';
21
+ import { RemoteConnectionSocketProvider } from './remote-connection-socket-provider';
22
+ import { ConnectionContainerModule } from '@theia/core/lib/node/messaging/connection-container-module';
23
+ import { RemoteSSHConnectionProvider, RemoteSSHConnectionProviderPath } from '../electron-common/remote-ssh-connection-provider';
24
+ import { RemoteSSHConnectionProviderImpl } from './ssh/remote-ssh-connection-provider';
25
+ import { SSHIdentityFileCollector } from './ssh/ssh-identity-file-collector';
26
+ import { RemoteCopyService } from './setup/remote-copy-service';
27
+ import { RemoteSetupService } from './setup/remote-setup-service';
28
+ import { RemoteNativeDependencyService } from './setup/remote-native-dependency-service';
29
+ import { BackendRemoteServiceImpl } from './backend-remote-service-impl';
30
+ import { BackendRemoteService } from '@theia/core/lib/node/backend-remote-service';
31
+ import { RemoteNodeSetupService } from './setup/remote-node-setup-service';
32
+ import { RemotePosixScriptStrategy, RemoteSetupScriptService, RemoteWindowsScriptStrategy } from './setup/remote-setup-script-service';
33
+ import { RemoteStatusService, RemoteStatusServicePath } from '../electron-common/remote-status-service';
34
+ import { RemoteStatusServiceImpl } from './remote-status-service';
35
+ import { ConnectionHandler, RpcConnectionHandler, bindContributionProvider } from '@theia/core';
36
+ import { RemoteCopyContribution, RemoteCopyRegistry } from './setup/remote-copy-contribution';
37
+ import { MainCopyContribution } from './setup/main-copy-contribution';
38
+ import { RemoteNativeDependencyContribution } from './setup/remote-native-dependency-contribution';
39
+ import { AppNativeDependencyContribution } from './setup/app-native-dependency-contribution';
40
+
41
+ export const remoteConnectionModule = ConnectionContainerModule.create(({ bind, bindBackendService }) => {
42
+ bind(RemoteSSHConnectionProviderImpl).toSelf().inSingletonScope();
43
+ bind(RemoteSSHConnectionProvider).toService(RemoteSSHConnectionProviderImpl);
44
+ bindBackendService(RemoteSSHConnectionProviderPath, RemoteSSHConnectionProvider);
45
+ });
46
+
47
+ export default new ContainerModule((bind, _unbind, _isBound, rebind) => {
48
+ bind(RemoteProxyServerProvider).toSelf().inSingletonScope();
49
+ bind(RemoteConnectionSocketProvider).toSelf().inSingletonScope();
50
+ bind(RemoteConnectionService).toSelf().inSingletonScope();
51
+ bind(BackendApplicationContribution).toService(RemoteConnectionService);
52
+ bind(RemoteStatusServiceImpl).toSelf().inSingletonScope();
53
+ bind(RemoteStatusService).toService(RemoteStatusServiceImpl);
54
+ bind(ConnectionHandler).toDynamicValue(
55
+ ctx => new RpcConnectionHandler(RemoteStatusServicePath, () => ctx.container.get(RemoteStatusService))
56
+ ).inSingletonScope();
57
+
58
+ bind(RemoteCopyService).toSelf().inSingletonScope();
59
+ bind(RemoteSetupService).toSelf().inSingletonScope();
60
+ bind(RemoteNodeSetupService).toSelf().inSingletonScope();
61
+ bind(RemoteWindowsScriptStrategy).toSelf().inSingletonScope();
62
+ bind(RemotePosixScriptStrategy).toSelf().inSingletonScope();
63
+ bind(RemoteSetupScriptService).toSelf().inSingletonScope();
64
+ bind(RemoteNativeDependencyService).toSelf().inSingletonScope();
65
+ bind(RemoteCopyRegistry).toSelf().inSingletonScope();
66
+ bindContributionProvider(bind, RemoteCopyContribution);
67
+ bindContributionProvider(bind, RemoteNativeDependencyContribution);
68
+ bind(MainCopyContribution).toSelf().inSingletonScope();
69
+ bind(RemoteCopyContribution).toService(MainCopyContribution);
70
+ bind(AppNativeDependencyContribution).toSelf().inSingletonScope();
71
+ bind(RemoteNativeDependencyContribution).toService(AppNativeDependencyContribution);
72
+
73
+ bind(ConnectionContainerModule).toConstantValue(remoteConnectionModule);
74
+
75
+ bind(BackendRemoteServiceImpl).toSelf().inSingletonScope();
76
+ rebind(BackendRemoteService).toService(BackendRemoteServiceImpl);
77
+ bind(CliContribution).toService(BackendRemoteServiceImpl);
78
+
79
+ bind(SSHIdentityFileCollector).toSelf().inSingletonScope();
80
+ });
@@ -0,0 +1,55 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox 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 { inject, injectable } from '@theia/core/shared/inversify';
18
+ import { RemoteConnection } from './remote-types';
19
+ import { Disposable } from '@theia/core';
20
+ import { RemoteCopyService } from './setup/remote-copy-service';
21
+ import { RemoteNativeDependencyService } from './setup/remote-native-dependency-service';
22
+ import { BackendApplicationContribution } from '@theia/core/lib/node';
23
+
24
+ @injectable()
25
+ export class RemoteConnectionService implements BackendApplicationContribution {
26
+
27
+ @inject(RemoteCopyService)
28
+ protected readonly copyService: RemoteCopyService;
29
+
30
+ @inject(RemoteNativeDependencyService)
31
+ protected readonly nativeDependencyService: RemoteNativeDependencyService;
32
+
33
+ protected readonly connections = new Map<string, RemoteConnection>();
34
+
35
+ getConnection(id: string): RemoteConnection | undefined {
36
+ return this.connections.get(id);
37
+ }
38
+
39
+ getConnectionFromPort(port: number): RemoteConnection | undefined {
40
+ return Array.from(this.connections.values()).find(connection => connection.localPort === port);
41
+ }
42
+
43
+ register(connection: RemoteConnection): Disposable {
44
+ this.connections.set(connection.id, connection);
45
+ return Disposable.create(() => {
46
+ this.connections.delete(connection.id);
47
+ });
48
+ }
49
+
50
+ onStop(): void {
51
+ for (const connection of this.connections.values()) {
52
+ connection.dispose();
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,34 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox 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 { io, Socket } from 'socket.io-client';
19
+
20
+ export interface RemoteProxySocketProviderOptions {
21
+ port: number;
22
+ path: string;
23
+ }
24
+
25
+ @injectable()
26
+ export class RemoteConnectionSocketProvider {
27
+
28
+ getProxySocket(options: RemoteProxySocketProviderOptions): Socket {
29
+ const socket = io(`ws://localhost:${options.port}${options.path}`);
30
+ socket.connect();
31
+ return socket;
32
+ }
33
+
34
+ }
@@ -0,0 +1,37 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox 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 { Deferred } from '@theia/core/lib/common/promise-util';
18
+ import { injectable } from '@theia/core/shared/inversify';
19
+ import * as net from 'net';
20
+
21
+ @injectable()
22
+ export class RemoteProxyServerProvider {
23
+
24
+ async getProxyServer(callback?: (socket: net.Socket) => void): Promise<net.Server> {
25
+ const deferred = new Deferred();
26
+
27
+ const proxy = net.createServer(socket => {
28
+ callback?.(socket);
29
+ }).listen(0, () => {
30
+ deferred.resolve();
31
+ });
32
+
33
+ await deferred.promise;
34
+ return proxy;
35
+ }
36
+
37
+ }
@@ -0,0 +1,41 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox 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 { inject, injectable } from '@theia/core/shared/inversify';
18
+ import { RemoteStatus, RemoteStatusService } from '../electron-common/remote-status-service';
19
+ import { RemoteConnectionService } from './remote-connection-service';
20
+
21
+ @injectable()
22
+ export class RemoteStatusServiceImpl implements RemoteStatusService {
23
+
24
+ @inject(RemoteConnectionService)
25
+ protected remoteConnectionService: RemoteConnectionService;
26
+
27
+ async getStatus(localPort: number): Promise<RemoteStatus> {
28
+ const connection = this.remoteConnectionService.getConnectionFromPort(localPort);
29
+ if (connection) {
30
+ return {
31
+ alive: true,
32
+ name: connection.name,
33
+ type: connection.type
34
+ };
35
+ } else {
36
+ return {
37
+ alive: false
38
+ };
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,56 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox 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 { Disposable, Event, OS } from '@theia/core';
18
+ import * as net from 'net';
19
+
20
+ export interface RemotePlatform {
21
+ os: OS.Type
22
+ arch: string
23
+ }
24
+
25
+ export type RemoteStatusReport = (message: string) => void;
26
+
27
+ export interface ExpressLayer {
28
+ name: string
29
+ regexp: RegExp
30
+ handle: Function
31
+ path?: string
32
+ }
33
+
34
+ export interface RemoteExecOptions {
35
+ env?: NodeJS.ProcessEnv;
36
+ }
37
+
38
+ export interface RemoteExecResult {
39
+ stdout: string;
40
+ stderr: string;
41
+ }
42
+
43
+ export type RemoteExecTester = (stdout: string, stderr: string) => boolean;
44
+
45
+ export interface RemoteConnection extends Disposable {
46
+ id: string;
47
+ name: string;
48
+ type: string;
49
+ localPort: number;
50
+ remotePort: number;
51
+ onDidDisconnect: Event<void>;
52
+ forwardOut(socket: net.Socket): void;
53
+ exec(cmd: string, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
54
+ execPartial(cmd: string, tester: RemoteExecTester, args?: string[], options?: RemoteExecOptions): Promise<RemoteExecResult>;
55
+ copy(localPath: string | Buffer | NodeJS.ReadableStream, remotePath: string): Promise<void>;
56
+ }
@@ -0,0 +1,48 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox 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 { RemoteNativeDependencyContribution, DownloadOptions, DependencyDownload } from './remote-native-dependency-contribution';
19
+ import { RemotePlatform } from '../remote-types';
20
+ import { OS } from '@theia/core';
21
+
22
+ @injectable()
23
+ export class AppNativeDependencyContribution implements RemoteNativeDependencyContribution {
24
+
25
+ appDownloadUrlBase = 'https://github.com/eclipse-theia/theia/releases/download';
26
+
27
+ protected getDefaultURLForFile(remotePlatform: RemotePlatform, theiaVersion: string): string {
28
+ if (remotePlatform.arch !== 'x64') {
29
+ throw new Error(`Unsupported remote architecture '${remotePlatform.arch}'. Remote support is only available for x64 architectures.`);
30
+ }
31
+ let platform: string;
32
+ if (remotePlatform.os === OS.Type.Windows) {
33
+ platform = 'win32';
34
+ } else if (remotePlatform.os === OS.Type.OSX) {
35
+ platform = 'darwin';
36
+ } else {
37
+ platform = 'linux';
38
+ }
39
+ return `${this.appDownloadUrlBase}/v${theiaVersion}/native-dependencies-${platform}-${remotePlatform.arch}.zip`;
40
+ }
41
+
42
+ async download(options: DownloadOptions): Promise<DependencyDownload> {
43
+ return {
44
+ buffer: await options.download(this.getDefaultURLForFile(options.remotePlatform, options.theiaVersion)),
45
+ archive: 'zip'
46
+ };
47
+ }
48
+ }
@@ -0,0 +1,28 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox 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 { RemoteCopyContribution, RemoteCopyRegistry } from './remote-copy-contribution';
19
+
20
+ @injectable()
21
+ export class MainCopyContribution implements RemoteCopyContribution {
22
+ async copy(registry: RemoteCopyRegistry): Promise<void> {
23
+ registry.file('package.json');
24
+ await registry.glob('lib/backend/**/*.js');
25
+ await registry.directory('lib/frontend');
26
+ await registry.directory('lib/webview');
27
+ }
28
+ }