@theia/core 1.22.0-next.13 → 1.22.0-next.17

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.
package/README.md CHANGED
@@ -78,9 +78,9 @@ export class SomeClass {
78
78
  - [`@phosphor/signaling@1`](https://www.npmjs.com/package/@phosphor/signaling)
79
79
  - [`@phosphor/virtualdom@1`](https://www.npmjs.com/package/@phosphor/virtualdom)
80
80
  - [`@phosphor/widgets@1`](https://www.npmjs.com/package/@phosphor/widgets)
81
- - [`@theia/application-package@1.22.0-next.13+52a652922c4`](https://www.npmjs.com/package/@theia/application-package)
82
- - [`@theia/application-package/lib/api@1.22.0-next.13+52a652922c4`](https://www.npmjs.com/package/@theia/application-package)
83
- - [`@theia/application-package/lib/environment@1.22.0-next.13+52a652922c4`](https://www.npmjs.com/package/@theia/application-package)
81
+ - [`@theia/application-package@1.22.0-next.17+fb74ef0ed87`](https://www.npmjs.com/package/@theia/application-package)
82
+ - [`@theia/application-package/lib/api@1.22.0-next.17+fb74ef0ed87`](https://www.npmjs.com/package/@theia/application-package)
83
+ - [`@theia/application-package/lib/environment@1.22.0-next.17+fb74ef0ed87`](https://www.npmjs.com/package/@theia/application-package)
84
84
  - [`dompurify@^2.2.9`](https://www.npmjs.com/package/dompurify)
85
85
  - [`electron@^9.0.2`](https://www.npmjs.com/package/electron)
86
86
  - [`express@^4.16.3`](https://www.npmjs.com/package/express)
@@ -13,8 +13,12 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
- import URI from '../common/uri';
17
16
  import { MaybePromise } from '../common/types';
17
+ import URI from '../common/uri';
18
+ export interface AddressPort {
19
+ address: string;
20
+ port: number;
21
+ }
18
22
  export declare class ExternalUriService {
19
23
  /**
20
24
  * Maps local to remote URLs.
@@ -25,17 +29,12 @@ export declare class ExternalUriService {
25
29
  * Use `parseLocalhost` to retrieve localhost address and port information.
26
30
  */
27
31
  resolve(uri: URI): MaybePromise<URI>;
28
- protected toRemoteUrl(uri: URI, localhost: {
29
- address: string;
30
- port: number;
31
- }): URI;
32
- protected toRemoteHost(localhost: {
33
- address: string;
34
- port: number;
35
- }): string;
36
- parseLocalhost(uri: URI): {
37
- address: string;
38
- port: number;
39
- } | undefined;
32
+ parseLocalhost(uri: URI): AddressPort | undefined;
33
+ protected toRemoteUrl(uri: URI, address: AddressPort): URI;
34
+ protected toRemoteHost(address: AddressPort): string;
35
+ /**
36
+ * @returns The remote host (where the backend is running).
37
+ */
38
+ protected getRemoteHost(): string;
40
39
  }
41
40
  //# sourceMappingURL=external-uri-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-uri-service.d.ts","sourceRoot":"","sources":["../../src/browser/external-uri-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAGlF,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,qBACa,kBAAkB;IAE3B;;;;;;;OAOG;IACH,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC;IAQpC,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,GAAG;IAKlF,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAI5E,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;CAc1E"}
1
+ {"version":3,"file":"external-uri-service.d.ts","sourceRoot":"","sources":["../../src/browser/external-uri-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAIlF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,GAAG,MAAM,eAAe,CAAC;AAGhC,MAAM,WAAW,WAAW;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACf;AAED,qBACa,kBAAkB;IAE3B;;;;;;;OAOG;IACH,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC;IAQpC,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,GAAG,SAAS;IAcjD,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,GAAG,GAAG;IAQ1D,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM;IAIpD;;OAEG;IACH,SAAS,CAAC,aAAa,IAAI,MAAM;CAGpC"}
@@ -22,6 +22,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.ExternalUriService = void 0;
25
+ const environment_1 = require("@theia/application-package/lib/environment");
25
26
  const inversify_1 = require("inversify");
26
27
  const endpoint_1 = require("./endpoint");
27
28
  let ExternalUriService = class ExternalUriService {
@@ -34,32 +35,41 @@ let ExternalUriService = class ExternalUriService {
34
35
  * Use `parseLocalhost` to retrieve localhost address and port information.
35
36
  */
36
37
  resolve(uri) {
37
- const localhost = this.parseLocalhost(uri);
38
- if (localhost) {
39
- return this.toRemoteUrl(uri, localhost);
38
+ const address = this.parseLocalhost(uri);
39
+ if (address) {
40
+ return this.toRemoteUrl(uri, address);
40
41
  }
41
42
  return uri;
42
43
  }
43
- toRemoteUrl(uri, localhost) {
44
- const host = this.toRemoteHost(localhost);
45
- return new endpoint_1.Endpoint({ host }).getRestUrl().withPath(uri.path).withFragment(uri.fragment).withQuery(uri.query);
46
- }
47
- toRemoteHost(localhost) {
48
- return `${window.location.hostname}:${localhost.port}`;
49
- }
50
44
  parseLocalhost(uri) {
51
45
  if (uri.scheme !== 'http' && uri.scheme !== 'https') {
52
- return undefined;
46
+ return;
53
47
  }
54
48
  const localhostMatch = /^(localhost|127\.0\.0\.1|0\.0\.0\.0):(\d+)$/.exec(uri.authority);
55
49
  if (!localhostMatch) {
56
- return undefined;
50
+ return;
57
51
  }
58
52
  return {
59
53
  address: localhostMatch[1],
60
54
  port: +localhostMatch[2],
61
55
  };
62
56
  }
57
+ toRemoteUrl(uri, address) {
58
+ return new endpoint_1.Endpoint({ host: this.toRemoteHost(address) })
59
+ .getRestUrl()
60
+ .withPath(uri.path)
61
+ .withFragment(uri.fragment)
62
+ .withQuery(uri.query);
63
+ }
64
+ toRemoteHost(address) {
65
+ return `${this.getRemoteHost()}:${address.port}`;
66
+ }
67
+ /**
68
+ * @returns The remote host (where the backend is running).
69
+ */
70
+ getRemoteHost() {
71
+ return environment_1.environment.electron.is() ? 'localhost' : window.location.hostname;
72
+ }
63
73
  };
64
74
  ExternalUriService = __decorate([
65
75
  inversify_1.injectable()
@@ -1 +1 @@
1
- {"version":3,"file":"external-uri-service.js","sourceRoot":"","sources":["../../src/browser/external-uri-service.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;AAElF,yCAAuC;AAGvC,yCAAsC;AAGtC,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAE3B;;;;;;;OAOG;IACH,OAAO,CAAC,GAAQ;QACZ,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAC3C,IAAI,SAAS,EAAE;YACX,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;SAC3C;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAES,WAAW,CAAC,GAAQ,EAAE,SAA4C;QACxE,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC1C,OAAO,IA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C;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAED,cAAc,CAAC,GAAQ;QACnB,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,IAAI,GAAG,CAAC,MAAM,KAAK,OAAO,EAAE;YACjD,OAAO;SACV;QACD,MAAM,cAAc,GAAG,6CAA6C,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACzF,IAAI,CAAC,cAAc,EAAE;YACjB,OAAO;SACV;QACD,OAAO;YACH,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;YAC1B,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;SAC3B,CAAC;IACN,CAAC;IAES,WAAW,CAAC,GAAQ,EAAE,OAAoB;QAChD,OAAO,IAAI,mBAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;aACpD,UAAU,EAAE;aACZ,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;aAClB,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC;aAC1B,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAES,YAAY,CAAC,OAAoB;QACvC,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IACrD,CAAC;IAED;;OAEG;IACO,aAAa;QACnB,OAAO,yBAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC9E,CAAC;CACJ,CAAA;AAlDY,kBAAkB;IAD9B,sBAAU,EAAE;GACA,kBAAkB,CAkD9B;AAlDY,gDAAkB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theia/core",
3
- "version": "1.22.0-next.13+52a652922c4",
3
+ "version": "1.22.0-next.17+fb74ef0ed87",
4
4
  "description": "Theia is a cloud & desktop IDE framework implemented in TypeScript.",
5
5
  "main": "lib/common/index.js",
6
6
  "typings": "lib/common/index.d.ts",
@@ -17,7 +17,7 @@
17
17
  "@phosphor/virtualdom": "1",
18
18
  "@phosphor/widgets": "1",
19
19
  "@primer/octicons-react": "^9.0.0",
20
- "@theia/application-package": "1.22.0-next.13+52a652922c4",
20
+ "@theia/application-package": "1.22.0-next.17+fb74ef0ed87",
21
21
  "@types/body-parser": "^1.16.4",
22
22
  "@types/cookie": "^0.3.3",
23
23
  "@types/dompurify": "^2.2.2",
@@ -178,5 +178,5 @@
178
178
  "nyc": {
179
179
  "extends": "../../configs/nyc.json"
180
180
  },
181
- "gitHead": "52a652922c431bb26b171636004536921e46e908"
181
+ "gitHead": "fb74ef0ed87ecfc36a415a2d272fdcbae4ee4bf7"
182
182
  }
@@ -14,11 +14,17 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
+ import { environment } from '@theia/application-package/lib/environment';
17
18
  import { injectable } from 'inversify';
18
- import URI from '../common/uri';
19
19
  import { MaybePromise } from '../common/types';
20
+ import URI from '../common/uri';
20
21
  import { Endpoint } from './endpoint';
21
22
 
23
+ export interface AddressPort {
24
+ address: string
25
+ port: number
26
+ }
27
+
22
28
  @injectable()
23
29
  export class ExternalUriService {
24
30
 
@@ -31,29 +37,20 @@ export class ExternalUriService {
31
37
  * Use `parseLocalhost` to retrieve localhost address and port information.
32
38
  */
33
39
  resolve(uri: URI): MaybePromise<URI> {
34
- const localhost = this.parseLocalhost(uri);
35
- if (localhost) {
36
- return this.toRemoteUrl(uri, localhost);
40
+ const address = this.parseLocalhost(uri);
41
+ if (address) {
42
+ return this.toRemoteUrl(uri, address);
37
43
  }
38
44
  return uri;
39
45
  }
40
46
 
41
- protected toRemoteUrl(uri: URI, localhost: { address: string, port: number }): URI {
42
- const host = this.toRemoteHost(localhost);
43
- return new Endpoint({ host }).getRestUrl().withPath(uri.path).withFragment(uri.fragment).withQuery(uri.query);
44
- }
45
-
46
- protected toRemoteHost(localhost: { address: string, port: number }): string {
47
- return `${window.location.hostname}:${localhost.port}`;
48
- }
49
-
50
- parseLocalhost(uri: URI): { address: string, port: number } | undefined {
47
+ parseLocalhost(uri: URI): AddressPort | undefined {
51
48
  if (uri.scheme !== 'http' && uri.scheme !== 'https') {
52
- return undefined;
49
+ return;
53
50
  }
54
51
  const localhostMatch = /^(localhost|127\.0\.0\.1|0\.0\.0\.0):(\d+)$/.exec(uri.authority);
55
52
  if (!localhostMatch) {
56
- return undefined;
53
+ return;
57
54
  }
58
55
  return {
59
56
  address: localhostMatch[1],
@@ -61,4 +58,22 @@ export class ExternalUriService {
61
58
  };
62
59
  }
63
60
 
61
+ protected toRemoteUrl(uri: URI, address: AddressPort): URI {
62
+ return new Endpoint({ host: this.toRemoteHost(address) })
63
+ .getRestUrl()
64
+ .withPath(uri.path)
65
+ .withFragment(uri.fragment)
66
+ .withQuery(uri.query);
67
+ }
68
+
69
+ protected toRemoteHost(address: AddressPort): string {
70
+ return `${this.getRemoteHost()}:${address.port}`;
71
+ }
72
+
73
+ /**
74
+ * @returns The remote host (where the backend is running).
75
+ */
76
+ protected getRemoteHost(): string {
77
+ return environment.electron.is() ? 'localhost' : window.location.hostname;
78
+ }
64
79
  }