@theia/process 1.31.0-next.2 → 1.31.0-next.29

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.
@@ -4,7 +4,6 @@ import { ILogger } from '@theia/core/lib/common/logger';
4
4
  import { BackendApplicationContribution } from '@theia/core/lib/node';
5
5
  export declare class ProcessManager implements BackendApplicationContribution {
6
6
  protected logger: ILogger;
7
- protected id: number;
8
7
  protected readonly processes: Map<number, Process>;
9
8
  protected readonly deleteEmitter: Emitter<number>;
10
9
  constructor(logger: ILogger);
@@ -15,6 +14,10 @@ export declare class ProcessManager implements BackendApplicationContribution {
15
14
  * @param process the process to register.
16
15
  */
17
16
  register(process: Process): number;
17
+ /**
18
+ * @returns a random id for a process that is not assigned to a different process yet.
19
+ */
20
+ protected generateId(): number;
18
21
  /**
19
22
  * Removes the process from this process manager. Invoking this method, will make
20
23
  * sure that the process is terminated before eliminating it from the manager's cache.
@@ -1 +1 @@
1
- {"version":3,"file":"process-manager.d.ts","sourceRoot":"","sources":["../../src/node/process-manager.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAEtE,qBACa,cAAe,YAAW,8BAA8B;IAO1B,SAAS,CAAC,MAAM,EAAE,OAAO;IALhE,SAAS,CAAC,EAAE,EAAE,MAAM,CAAK;IACzB,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnD,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;gBAGD,MAAM,EAAE,OAAO;IAMhE;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAQlC;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAelC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIpC,IAAI,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,CAE5B;IAED,MAAM,IAAI,IAAI;IAUd,OAAO,CAAC,eAAe;CAI1B"}
1
+ {"version":3,"file":"process-manager.d.ts","sourceRoot":"","sources":["../../src/node/process-manager.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAGtE,qBACa,cAAe,YAAW,8BAA8B;IAM1B,SAAS,CAAC,MAAM,EAAE,OAAO;IAJhE,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnD,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;gBAGD,MAAM,EAAE,OAAO;IAMhE;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;IAOlC;;OAEG;IACH,SAAS,CAAC,UAAU,IAAI,MAAM;IAW9B;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAelC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIpC,IAAI,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,CAE5B;IAED,MAAM,IAAI,IAAI;IAUd,OAAO,CAAC,eAAe;CAI1B"}
@@ -31,10 +31,10 @@ exports.ProcessManager = void 0;
31
31
  const inversify_1 = require("@theia/core/shared/inversify");
32
32
  const common_1 = require("@theia/core/lib/common");
33
33
  const logger_1 = require("@theia/core/lib/common/logger");
34
+ const numbers_1 = require("@theia/core/lib/common/numbers");
34
35
  let ProcessManager = class ProcessManager {
35
36
  constructor(logger) {
36
37
  this.logger = logger;
37
- this.id = 0;
38
38
  this.processes = new Map();
39
39
  this.deleteEmitter = new common_1.Emitter();
40
40
  }
@@ -45,10 +45,22 @@ let ProcessManager = class ProcessManager {
45
45
  * @param process the process to register.
46
46
  */
47
47
  register(process) {
48
- const id = this.id;
48
+ const id = this.generateId();
49
49
  this.processes.set(id, process);
50
50
  process.onError(() => this.unregister(process));
51
- this.id++;
51
+ return id;
52
+ }
53
+ /**
54
+ * @returns a random id for a process that is not assigned to a different process yet.
55
+ */
56
+ generateId() {
57
+ let id = undefined;
58
+ while (id === undefined) {
59
+ const candidate = Math.floor(Math.random() * numbers_1.MAX_SAFE_INTEGER);
60
+ if (!this.processes.has(candidate)) {
61
+ id = candidate;
62
+ }
63
+ }
52
64
  return id;
53
65
  }
54
66
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"process-manager.js","sourceRoot":"","sources":["../../src/node/process-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;AAChF,4DAAyE;AAEzE,mDAAwD;AACxD,0DAAwD;AAIxD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAMvB,YACiD,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;QALtD,OAAE,GAAW,CAAC,CAAC;QAOrB,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,IAAI,gBAAO,EAAU,C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,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IACpC,CAAC;IAED,MAAM;QACF,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE;YAC3C,IAAI;gBACA,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;aAC5B;YAAC,OAAO,KAAK,EAAE;gBACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,8CAA8C,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;aAC3G;SACJ;IACL,CAAC;IAEO,eAAe,CAAC,OAAgB;QACpC,OAAO,QAAQ,OAAO,CAAC,EAAE,GAAG,CAAC;IACjC,CAAC;CAEJ,CAAA;AAlFY,cAAc;IAD1B,IAAA,sBAAU,GAAE;IAOJ,WAAA,IAAA,kBAAM,EAAC,gBAAO,CAAC,CAAA;IAAE,WAAA,IAAA,iBAAK,EAAC,SAAS,CAAC,CAAA;;GAN7B,cAAc,CAkF1B;AAlFY,wCAAc"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@theia/process",
3
- "version": "1.31.0-next.2+fd845f65c",
3
+ "version": "1.31.0-next.29+6ca2cfb56",
4
4
  "description": "Theia process support.",
5
5
  "dependencies": {
6
- "@theia/core": "1.31.0-next.2+fd845f65c",
6
+ "@theia/core": "1.31.0-next.29+6ca2cfb56",
7
7
  "node-pty": "0.11.0-beta17",
8
8
  "string-argv": "^0.1.1"
9
9
  },
@@ -49,5 +49,5 @@
49
49
  "nyc": {
50
50
  "extends": "../../configs/nyc.json"
51
51
  },
52
- "gitHead": "fd845f65c84bcc5b8064f04c621ae6b6baa014a0"
52
+ "gitHead": "6ca2cfb56125cd93bda95be3ba705aa4c7da62fe"
53
53
  }
@@ -18,11 +18,11 @@ import { Process } from './process';
18
18
  import { Emitter, Event } from '@theia/core/lib/common';
19
19
  import { ILogger } from '@theia/core/lib/common/logger';
20
20
  import { BackendApplicationContribution } from '@theia/core/lib/node';
21
+ import { MAX_SAFE_INTEGER } from '@theia/core/lib/common/numbers';
21
22
 
22
23
  @injectable()
23
24
  export class ProcessManager implements BackendApplicationContribution {
24
25
 
25
- protected id: number = 0;
26
26
  protected readonly processes: Map<number, Process>;
27
27
  protected readonly deleteEmitter: Emitter<number>;
28
28
 
@@ -40,10 +40,23 @@ export class ProcessManager implements BackendApplicationContribution {
40
40
  * @param process the process to register.
41
41
  */
42
42
  register(process: Process): number {
43
- const id = this.id;
43
+ const id = this.generateId();
44
44
  this.processes.set(id, process);
45
45
  process.onError(() => this.unregister(process));
46
- this.id++;
46
+ return id;
47
+ }
48
+
49
+ /**
50
+ * @returns a random id for a process that is not assigned to a different process yet.
51
+ */
52
+ protected generateId(): number {
53
+ let id = undefined;
54
+ while (id === undefined) {
55
+ const candidate = Math.floor(Math.random() * MAX_SAFE_INTEGER);
56
+ if (!this.processes.has(candidate)) {
57
+ id = candidate;
58
+ }
59
+ }
47
60
  return id;
48
61
  }
49
62