@theia/remote 1.49.0 → 1.50.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 (104) hide show
  1. package/lib/electron-browser/port-forwarding/port-forwading-contribution.js +3 -3
  2. package/lib/electron-browser/port-forwarding/port-forwading-contribution.js.map +1 -1
  3. package/lib/electron-browser/port-forwarding/port-forwarding-service.d.ts +1 -0
  4. package/lib/electron-browser/port-forwarding/port-forwarding-service.d.ts.map +1 -1
  5. package/lib/electron-browser/port-forwarding/port-forwarding-service.js +16 -4
  6. package/lib/electron-browser/port-forwarding/port-forwarding-service.js.map +1 -1
  7. package/lib/electron-browser/port-forwarding/port-forwarding-widget.js +12 -12
  8. package/lib/electron-browser/port-forwarding/port-forwarding-widget.js.map +1 -1
  9. package/lib/electron-browser/remote-electron-file-dialog-service.js +4 -4
  10. package/lib/electron-browser/remote-electron-file-dialog-service.js.map +1 -1
  11. package/lib/electron-browser/remote-frontend-contribution.js +17 -17
  12. package/lib/electron-browser/remote-frontend-contribution.js.map +1 -1
  13. package/lib/electron-browser/remote-preferences.d.ts +1 -1
  14. package/lib/electron-browser/remote-preferences.d.ts.map +1 -1
  15. package/lib/electron-browser/remote-registry-contribution.js +4 -4
  16. package/lib/electron-browser/remote-registry-contribution.js.map +1 -1
  17. package/lib/electron-browser/remote-service.js +2 -2
  18. package/lib/electron-browser/remote-service.js.map +1 -1
  19. package/lib/electron-browser/remote-ssh-contribution.js +11 -11
  20. package/lib/electron-browser/remote-ssh-contribution.js.map +1 -1
  21. package/lib/electron-common/remote-port-forwarding-provider.d.ts +1 -0
  22. package/lib/electron-common/remote-port-forwarding-provider.d.ts.map +1 -1
  23. package/lib/electron-common/remote-status-service.d.ts +1 -1
  24. package/lib/electron-common/remote-status-service.d.ts.map +1 -1
  25. package/lib/electron-node/backend-remote-service-impl.d.ts +1 -1
  26. package/lib/electron-node/backend-remote-service-impl.d.ts.map +1 -1
  27. package/lib/electron-node/backend-remote-service-impl.js +3 -3
  28. package/lib/electron-node/backend-remote-service-impl.js.map +1 -1
  29. package/lib/electron-node/remote-backend-module.d.ts.map +1 -1
  30. package/lib/electron-node/remote-backend-module.js +5 -4
  31. package/lib/electron-node/remote-backend-module.js.map +1 -1
  32. package/lib/electron-node/remote-connection-service.d.ts +2 -2
  33. package/lib/electron-node/remote-connection-service.d.ts.map +1 -1
  34. package/lib/electron-node/remote-connection-service.js +9 -9
  35. package/lib/electron-node/remote-connection-service.js.map +1 -1
  36. package/lib/electron-node/remote-connection-socket-provider.js +2 -2
  37. package/lib/electron-node/remote-connection-socket-provider.js.map +1 -1
  38. package/lib/electron-node/remote-port-forwarding-provider.d.ts +9 -1
  39. package/lib/electron-node/remote-port-forwarding-provider.d.ts.map +1 -1
  40. package/lib/electron-node/remote-port-forwarding-provider.js +19 -13
  41. package/lib/electron-node/remote-port-forwarding-provider.js.map +1 -1
  42. package/lib/electron-node/remote-proxy-server-provider.js +2 -2
  43. package/lib/electron-node/remote-proxy-server-provider.js.map +1 -1
  44. package/lib/electron-node/remote-status-service.js +4 -4
  45. package/lib/electron-node/remote-status-service.js.map +1 -1
  46. package/lib/electron-node/remote-types.d.ts +6 -7
  47. package/lib/electron-node/remote-types.d.ts.map +1 -1
  48. package/lib/electron-node/setup/app-native-dependency-contribution.d.ts +1 -1
  49. package/lib/electron-node/setup/app-native-dependency-contribution.d.ts.map +1 -1
  50. package/lib/electron-node/setup/app-native-dependency-contribution.js +2 -2
  51. package/lib/electron-node/setup/app-native-dependency-contribution.js.map +1 -1
  52. package/lib/electron-node/setup/main-copy-contribution.d.ts +1 -1
  53. package/lib/electron-node/setup/main-copy-contribution.d.ts.map +1 -1
  54. package/lib/electron-node/setup/main-copy-contribution.js +2 -2
  55. package/lib/electron-node/setup/main-copy-contribution.js.map +1 -1
  56. package/lib/electron-node/setup/remote-copy-contribution.d.ts +3 -19
  57. package/lib/electron-node/setup/remote-copy-contribution.d.ts.map +1 -1
  58. package/lib/electron-node/setup/remote-copy-contribution.js +18 -14
  59. package/lib/electron-node/setup/remote-copy-contribution.js.map +1 -1
  60. package/lib/electron-node/setup/remote-copy-service.d.ts +5 -3
  61. package/lib/electron-node/setup/remote-copy-service.d.ts.map +1 -1
  62. package/lib/electron-node/setup/remote-copy-service.js +13 -12
  63. package/lib/electron-node/setup/remote-copy-service.js.map +1 -1
  64. package/lib/electron-node/setup/remote-native-dependency-contribution.d.ts +2 -2
  65. package/lib/electron-node/setup/remote-native-dependency-contribution.d.ts.map +1 -1
  66. package/lib/electron-node/setup/remote-native-dependency-contribution.js +2 -2
  67. package/lib/electron-node/setup/remote-native-dependency-contribution.js.map +1 -1
  68. package/lib/electron-node/setup/remote-native-dependency-service.d.ts +1 -1
  69. package/lib/electron-node/setup/remote-native-dependency-service.d.ts.map +1 -1
  70. package/lib/electron-node/setup/remote-native-dependency-service.js +6 -6
  71. package/lib/electron-node/setup/remote-native-dependency-service.js.map +1 -1
  72. package/lib/electron-node/setup/remote-node-setup-service.d.ts +1 -1
  73. package/lib/electron-node/setup/remote-node-setup-service.d.ts.map +1 -1
  74. package/lib/electron-node/setup/remote-node-setup-service.js +6 -6
  75. package/lib/electron-node/setup/remote-node-setup-service.js.map +1 -1
  76. package/lib/electron-node/setup/remote-setup-script-service.d.ts +1 -1
  77. package/lib/electron-node/setup/remote-setup-script-service.d.ts.map +1 -1
  78. package/lib/electron-node/setup/remote-setup-script-service.js +10 -10
  79. package/lib/electron-node/setup/remote-setup-script-service.js.map +1 -1
  80. package/lib/electron-node/setup/remote-setup-service.d.ts +4 -1
  81. package/lib/electron-node/setup/remote-setup-service.d.ts.map +1 -1
  82. package/lib/electron-node/setup/remote-setup-service.js +29 -13
  83. package/lib/electron-node/setup/remote-setup-service.js.map +1 -1
  84. package/lib/electron-node/ssh/remote-ssh-connection-provider.js +17 -17
  85. package/lib/electron-node/ssh/remote-ssh-connection-provider.js.map +1 -1
  86. package/lib/electron-node/ssh/ssh-identity-file-collector.js +2 -2
  87. package/lib/electron-node/ssh/ssh-identity-file-collector.js.map +1 -1
  88. package/package.json +5 -5
  89. package/src/electron-browser/port-forwarding/port-forwarding-service.ts +9 -1
  90. package/src/electron-common/remote-port-forwarding-provider.ts +1 -0
  91. package/src/electron-node/backend-remote-service-impl.ts +1 -1
  92. package/src/electron-node/remote-backend-module.ts +4 -3
  93. package/src/electron-node/remote-connection-service.ts +4 -3
  94. package/src/electron-node/remote-port-forwarding-provider.ts +22 -6
  95. package/src/electron-node/remote-types.ts +1 -6
  96. package/src/electron-node/setup/app-native-dependency-contribution.ts +1 -1
  97. package/src/electron-node/setup/main-copy-contribution.ts +1 -1
  98. package/src/electron-node/setup/remote-copy-contribution.ts +13 -28
  99. package/src/electron-node/setup/remote-copy-service.ts +6 -4
  100. package/src/electron-node/setup/remote-native-dependency-contribution.ts +1 -1
  101. package/src/electron-node/setup/remote-native-dependency-service.ts +1 -1
  102. package/src/electron-node/setup/remote-node-setup-service.ts +1 -1
  103. package/src/electron-node/setup/remote-setup-script-service.ts +1 -1
  104. package/src/electron-node/setup/remote-setup-service.ts +18 -4
@@ -18,6 +18,13 @@ import { inject, injectable } from '@theia/core/shared/inversify';
18
18
  import { ForwardedPort, RemotePortForwardingProvider } from '../electron-common/remote-port-forwarding-provider';
19
19
  import { createServer, Server } from 'net';
20
20
  import { RemoteConnectionService } from './remote-connection-service';
21
+ import { RemoteConnection } from './remote-types';
22
+
23
+ interface ForwardInfo {
24
+ connection: RemoteConnection
25
+ port: ForwardedPort
26
+ server: Server
27
+ }
21
28
 
22
29
  @injectable()
23
30
  export class RemotePortForwardingProviderImpl implements RemotePortForwardingProvider {
@@ -25,7 +32,7 @@ export class RemotePortForwardingProviderImpl implements RemotePortForwardingPro
25
32
  @inject(RemoteConnectionService)
26
33
  protected readonly connectionService: RemoteConnectionService;
27
34
 
28
- protected forwardedPorts: Map<number, Server> = new Map();
35
+ protected static forwardedPorts: ForwardInfo[] = [];
29
36
 
30
37
  async forwardPort(connectionPort: number, portToForward: ForwardedPort): Promise<void> {
31
38
  const currentConnection = this.connectionService.getConnectionFromPort(connectionPort);
@@ -36,15 +43,24 @@ export class RemotePortForwardingProviderImpl implements RemotePortForwardingPro
36
43
  const server = createServer(socket => {
37
44
  currentConnection?.forwardOut(socket, portToForward.port);
38
45
  }).listen(portToForward.port, portToForward.address);
39
- this.forwardedPorts.set(portToForward.port, server);
46
+
47
+ currentConnection.onDidDisconnect(() => {
48
+ this.portRemoved(portToForward);
49
+ });
50
+
51
+ RemotePortForwardingProviderImpl.forwardedPorts.push({ connection: currentConnection, port: portToForward, server });
40
52
  }
41
53
 
42
54
  async portRemoved(forwardedPort: ForwardedPort): Promise<void> {
43
- const proxy = this.forwardedPorts.get(forwardedPort.port);
44
- if (proxy) {
45
- proxy.close();
46
- this.forwardedPorts.delete(forwardedPort.port);
55
+ const forwardInfo = RemotePortForwardingProviderImpl.forwardedPorts.find(info => info.port.port === forwardedPort.port);
56
+ if (forwardInfo) {
57
+ forwardInfo.server.close();
58
+ RemotePortForwardingProviderImpl.forwardedPorts.splice(RemotePortForwardingProviderImpl.forwardedPorts.indexOf(forwardInfo), 1);
47
59
  }
48
60
  }
49
61
 
62
+ async getForwardedPorts(): Promise<ForwardedPort[]> {
63
+ return Array.from(RemotePortForwardingProviderImpl.forwardedPorts)
64
+ .map(forwardInfo => ({ ...forwardInfo.port, editing: false }));
65
+ }
50
66
  }
@@ -14,14 +14,9 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { Disposable, Event, OS } from '@theia/core';
17
+ import { Disposable, Event } from '@theia/core';
18
18
  import * as net from 'net';
19
19
 
20
- export interface RemotePlatform {
21
- os: OS.Type
22
- arch: string
23
- }
24
-
25
20
  export type RemoteStatusReport = (message: string) => void;
26
21
 
27
22
  export interface ExpressLayer {
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { injectable } from '@theia/core/shared/inversify';
18
18
  import { RemoteNativeDependencyContribution, DownloadOptions, DependencyDownload } from './remote-native-dependency-contribution';
19
- import { RemotePlatform } from '../remote-types';
19
+ import { RemotePlatform } from '@theia/core/lib/node/remote/remote-cli-contribution';
20
20
  import { OS } from '@theia/core';
21
21
 
22
22
  @injectable()
@@ -15,7 +15,7 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import { injectable } from '@theia/core/shared/inversify';
18
- import { RemoteCopyContribution, RemoteCopyRegistry } from './remote-copy-contribution';
18
+ import { RemoteCopyContribution, RemoteCopyRegistry } from '@theia/core/lib/node/remote/remote-copy-contribution';
19
19
 
20
20
  @injectable()
21
21
  export class MainCopyContribution implements RemoteCopyContribution {
@@ -16,36 +16,15 @@
16
16
 
17
17
  import { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
18
18
  import { inject, injectable } from '@theia/core/shared/inversify';
19
+ import { RemoteCopyRegistry, RemoteFile, RemoteCopyOptions } from '@theia/core/lib/node/remote/remote-copy-contribution';
19
20
  import { glob as globCallback } from 'glob';
20
21
  import { promisify } from 'util';
21
22
  import * as path from 'path';
22
- import { MaybePromise } from '@theia/core';
23
23
 
24
24
  const promiseGlob = promisify(globCallback);
25
25
 
26
- export const RemoteCopyContribution = Symbol('RemoteCopyContribution');
27
-
28
- export interface RemoteCopyContribution {
29
- copy(registry: RemoteCopyRegistry): MaybePromise<void>
30
- }
31
-
32
- export interface RemoteCopyOptions {
33
- /**
34
- * The mode that the file should be set to once copied to the remote.
35
- *
36
- * Only relevant for POSIX-like systems
37
- */
38
- mode?: number;
39
- }
40
-
41
- export interface RemoteFile {
42
- path: string
43
- target: string
44
- options?: RemoteCopyOptions;
45
- }
46
-
47
26
  @injectable()
48
- export class RemoteCopyRegistry {
27
+ export class RemoteCopyRegistryImpl implements RemoteCopyRegistry {
49
28
 
50
29
  @inject(ApplicationPackage)
51
30
  protected readonly applicationPackage: ApplicationPackage;
@@ -57,14 +36,16 @@ export class RemoteCopyRegistry {
57
36
  }
58
37
 
59
38
  async glob(pattern: string, target?: string): Promise<void> {
39
+ return this.doGlob(pattern, this.applicationPackage.projectPath, target);
40
+ }
41
+
42
+ async doGlob(pattern: string, cwd: string, target?: string): Promise<void> {
60
43
  const projectPath = this.applicationPackage.projectPath;
61
- const globResult = await promiseGlob(pattern, {
62
- cwd: projectPath
63
- });
44
+ const globResult = await promiseGlob(pattern, { cwd, nodir: true });
64
45
  for (const file of globResult) {
65
46
  const targetFile = this.withTarget(file, target);
66
47
  this.files.push({
67
- path: file,
48
+ path: path.relative(projectPath, path.resolve(cwd, file)),
68
49
  target: targetFile
69
50
  });
70
51
  }
@@ -80,7 +61,11 @@ export class RemoteCopyRegistry {
80
61
  }
81
62
 
82
63
  async directory(dir: string, target?: string): Promise<void> {
83
- return this.glob(dir + '/**', target);
64
+ let absoluteDir = dir;
65
+ if (!path.isAbsolute(absoluteDir)) {
66
+ absoluteDir = path.join(this.applicationPackage.projectPath, dir);
67
+ }
68
+ return this.doGlob('**/*', absoluteDir, target ?? dir);
84
69
  }
85
70
 
86
71
  protected withTarget(file: string, target?: string): string {
@@ -20,10 +20,12 @@ import * as fs from 'fs';
20
20
  import * as os from 'os';
21
21
  import { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
22
22
  import { inject, injectable, named } from '@theia/core/shared/inversify';
23
- import { RemoteConnection, RemotePlatform } from '../remote-types';
23
+ import { RemoteConnection } from '../remote-types';
24
+ import { RemotePlatform } from '@theia/core/lib/node/remote/remote-cli-contribution';
24
25
  import { RemoteNativeDependencyService } from './remote-native-dependency-service';
25
26
  import { ContributionProvider } from '@theia/core';
26
- import { RemoteCopyContribution, RemoteCopyRegistry, RemoteFile } from './remote-copy-contribution';
27
+ import { RemoteCopyRegistryImpl } from './remote-copy-contribution';
28
+ import { RemoteCopyContribution, RemoteFile } from '@theia/core/lib/node/remote/remote-copy-contribution';
27
29
 
28
30
  @injectable()
29
31
  export class RemoteCopyService {
@@ -31,8 +33,8 @@ export class RemoteCopyService {
31
33
  @inject(ApplicationPackage)
32
34
  protected readonly applicationPackage: ApplicationPackage;
33
35
 
34
- @inject(RemoteCopyRegistry)
35
- protected readonly copyRegistry: RemoteCopyRegistry;
36
+ @inject(RemoteCopyRegistryImpl)
37
+ protected readonly copyRegistry: RemoteCopyRegistryImpl;
36
38
 
37
39
  @inject(RemoteNativeDependencyService)
38
40
  protected readonly nativeDependencyService: RemoteNativeDependencyService;
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { isObject } from '@theia/core';
18
18
  import { RequestOptions } from '@theia/core/shared/@theia/request';
19
- import { RemotePlatform } from '../remote-types';
19
+ import { RemotePlatform } from '@theia/core/lib/node/remote/remote-cli-contribution';
20
20
 
21
21
  export interface FileDependencyResult {
22
22
  path: string;
@@ -21,7 +21,7 @@ import * as decompress from 'decompress';
21
21
  import * as path from 'path';
22
22
  import * as fs from 'fs/promises';
23
23
  import { DependencyDownload, DirectoryDependencyDownload, RemoteNativeDependencyContribution } from './remote-native-dependency-contribution';
24
- import { RemotePlatform } from '../remote-types';
24
+ import { RemotePlatform } from '@theia/core/lib/node/remote/remote-cli-contribution';
25
25
 
26
26
  const decompressTar = require('decompress-tar');
27
27
  const decompressTargz = require('decompress-targz');
@@ -21,7 +21,7 @@ import * as os from 'os';
21
21
  import { inject, injectable } from '@theia/core/shared/inversify';
22
22
  import { RequestService } from '@theia/core/shared/@theia/request';
23
23
  import { RemoteSetupScriptService } from './remote-setup-script-service';
24
- import { RemotePlatform } from '../remote-types';
24
+ import { RemotePlatform } from '@theia/core/lib/node/remote/remote-cli-contribution';
25
25
  import { OS } from '@theia/core';
26
26
 
27
27
  /**
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { OS } from '@theia/core';
18
18
  import { inject, injectable } from '@theia/core/shared/inversify';
19
- import { RemotePlatform } from '../remote-types';
19
+ import { RemotePlatform } from '@theia/core/lib/node/remote/remote-cli-contribution';
20
20
 
21
21
  export interface RemoteScriptStrategy {
22
22
  exec(): string;
@@ -14,12 +14,13 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { inject, injectable } from '@theia/core/shared/inversify';
18
- import { RemoteConnection, RemoteExecResult, RemotePlatform, RemoteStatusReport } from '../remote-types';
17
+ import { inject, injectable, named } from '@theia/core/shared/inversify';
18
+ import { RemoteConnection, RemoteExecResult, RemoteStatusReport } from '../remote-types';
19
+ import { RemoteCliContext, RemoteCliContribution, RemotePlatform } from '@theia/core/lib/node/remote/remote-cli-contribution';
19
20
  import { ApplicationPackage } from '@theia/core/shared/@theia/application-package';
20
21
  import { RemoteCopyService } from './remote-copy-service';
21
22
  import { RemoteNativeDependencyService } from './remote-native-dependency-service';
22
- import { OS, THEIA_VERSION } from '@theia/core';
23
+ import { ContributionProvider, OS, THEIA_VERSION } from '@theia/core';
23
24
  import { RemoteNodeSetupService } from './remote-node-setup-service';
24
25
  import { RemoteSetupScriptService } from './remote-setup-script-service';
25
26
 
@@ -52,6 +53,9 @@ export class RemoteSetupService {
52
53
  @inject(ApplicationPackage)
53
54
  protected readonly applicationPackage: ApplicationPackage;
54
55
 
56
+ @inject(ContributionProvider) @named(RemoteCliContribution)
57
+ protected readonly cliContributions: ContributionProvider<RemoteCliContribution>;
58
+
55
59
  async setup(options: RemoteSetupOptions): Promise<RemoteSetupResult> {
56
60
  const {
57
61
  connection,
@@ -106,11 +110,21 @@ export class RemoteSetupService {
106
110
  // We might to switch to PowerShell beforehand on Windows
107
111
  prefix = this.scriptService.exec(platform) + ' ';
108
112
  }
113
+ const remoteContext: RemoteCliContext = {
114
+ platform,
115
+ directory: remotePath
116
+ };
117
+ const args: string[] = ['--hostname=0.0.0.0', `--port=${connection.remotePort ?? 0}`, '--remote'];
118
+ for (const cli of this.cliContributions.getContributions()) {
119
+ if (cli.enhanceArgs) {
120
+ args.push(...await cli.enhanceArgs(remoteContext));
121
+ }
122
+ }
109
123
  // Change to the remote application path and start a node process with the copied main.js file
110
124
  // This way, our current working directory is set as expected
111
125
  const result = await connection.execPartial(`${prefix}cd "${remotePath}";${nodeExecutable}`,
112
126
  stdout => localAddressRegex.test(stdout),
113
- [mainJsFile, '--hostname=0.0.0.0', `--port=${connection.remotePort ?? 0}`, '--remote']);
127
+ [mainJsFile, ...args]);
114
128
 
115
129
  const match = localAddressRegex.exec(result.stdout);
116
130
  if (!match) {