@theia/core 1.18.0-next.173 → 1.18.0-next.178
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/lib/common/promise-util.d.ts +3 -0
- package/lib/common/promise-util.d.ts.map +1 -1
- package/lib/common/promise-util.js +16 -1
- package/lib/common/promise-util.js.map +1 -1
- package/lib/common/promise-util.spec.d.ts +2 -0
- package/lib/common/promise-util.spec.d.ts.map +1 -0
- package/lib/common/promise-util.spec.js +42 -0
- package/lib/common/promise-util.spec.js.map +1 -0
- package/package.json +3 -3
- package/src/common/promise-util.spec.ts +41 -0
- package/src/common/promise-util.ts +20 -1
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
+
import { Disposable } from './disposable';
|
|
17
|
+
import { Event } from './event';
|
|
16
18
|
import { CancellationToken } from './cancellation';
|
|
17
19
|
/**
|
|
18
20
|
* Simple implementation of the deferred pattern.
|
|
@@ -44,4 +46,5 @@ export declare function delay<T>(ms: number): (value: T) => Promise<T>;
|
|
|
44
46
|
* @param ms the number of milliseconds to wait
|
|
45
47
|
*/
|
|
46
48
|
export declare function wait(ms: number): Promise<void>;
|
|
49
|
+
export declare function waitForEvent<T>(event: Event<T>, ms: number, thisArg?: any, disposables?: Disposable[]): Promise<T>;
|
|
47
50
|
//# sourceMappingURL=promise-util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise-util.d.ts","sourceRoot":"","sources":["../../src/common/promise-util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"promise-util.d.ts","sourceRoot":"","sources":["../../src/common/promise-util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAgC,MAAM,gBAAgB,CAAC;AAEjF;;;GAGG;AACH,qBAAa,QAAQ,CAAC,CAAC,GAAG,IAAI;IAC1B,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,YAAY,CAAgB;IAC7D,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAE5B,OAAO,aAaJ;CACN;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,oBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQjF;AAED,wBAAsB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CActG;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAE7D;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpD;AAGD,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAclH"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
16
|
********************************************************************************/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.wait = exports.delay = exports.retry = exports.timeout = exports.Deferred = void 0;
|
|
18
|
+
exports.waitForEvent = exports.wait = exports.delay = exports.retry = exports.timeout = exports.Deferred = void 0;
|
|
19
19
|
const cancellation_1 = require("./cancellation");
|
|
20
20
|
/**
|
|
21
21
|
* Simple implementation of the deferred pattern.
|
|
@@ -89,4 +89,19 @@ async function wait(ms) {
|
|
|
89
89
|
await delay(ms)(undefined);
|
|
90
90
|
}
|
|
91
91
|
exports.wait = wait;
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
93
|
+
function waitForEvent(event, ms, thisArg, disposables) {
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
const registration = setTimeout(() => {
|
|
96
|
+
listener.dispose();
|
|
97
|
+
reject(new cancellation_1.CancellationError());
|
|
98
|
+
}, ms);
|
|
99
|
+
const listener = event((evt) => {
|
|
100
|
+
clearTimeout(registration);
|
|
101
|
+
listener.dispose();
|
|
102
|
+
resolve(evt);
|
|
103
|
+
}, thisArg, disposables);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
exports.waitForEvent = waitForEvent;
|
|
92
107
|
//# sourceMappingURL=promise-util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise-util.js","sourceRoot":"","sources":["../../src/common/promise-util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;
|
|
1
|
+
{"version":3,"file":"promise-util.js","sourceRoot":"","sources":["../../src/common/promise-util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAIlF,iDAAiF;AAEjF;;;GAGG;AACH,MAAa,QAAQ;IAArB;QACI,UAAK,GAA2C,YAAY,CAAC;QAI7D,YAAO,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACzC,IAAI,CAAC,OAAO,GAAG,M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AED,MAAM,SAAS,CAAC;AACpB,CAAC;AAdD,sBAcC;AAED;;;;;;;GAOG;AACH,SAAgB,KAAK,CAAI,EAAU;IAC/B,OAAO,KAAK,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChG,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACI,KAAK,UAAU,IAAI,CAAC,EAAU;IACjC,MAAM,KAAK,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC;AAFD,oBAEC;AAED,8DAA8D;AAC9D,SAAgB,YAAY,CAAI,KAAe,EAAE,EAAU,EAAE,OAAa,EAAE,WAA0B;IAClG,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,YAAY,GAAG,UAAU,CAAC,GAAG,EAAE;YACjC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,CAAC,IAAI,gCAAiB,EAAE,CAAC,CAAC;QACpC,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,GAAM,EAAE,EAAE;YAC9B,YAAY,CAAC,YAAY,CAAC,CAAC;YAC3B,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IAE7B,CAAC,CAAC,CAAC;AACP,CAAC;AAdD,oCAcC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-util.spec.d.ts","sourceRoot":"","sources":["../../src/common/promise-util.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/********************************************************************************
|
|
4
|
+
* Copyright (C) 2021 Red Hat and others.
|
|
5
|
+
*
|
|
6
|
+
* This program and the accompanying materials are made available under the
|
|
7
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
8
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
9
|
+
*
|
|
10
|
+
* This Source Code may also be made available under the following Secondary
|
|
11
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
12
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
13
|
+
* with the GNU Classpath Exception which is available at
|
|
14
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
15
|
+
*
|
|
16
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
17
|
+
********************************************************************************/
|
|
18
|
+
const assert = require("assert");
|
|
19
|
+
const promise_util_1 = require("./promise-util");
|
|
20
|
+
const event_1 = require("./event");
|
|
21
|
+
describe('promise-util', () => {
|
|
22
|
+
it('should time out', async () => {
|
|
23
|
+
const emitter = new event_1.Emitter();
|
|
24
|
+
try {
|
|
25
|
+
await promise_util_1.waitForEvent(emitter.event, 1000);
|
|
26
|
+
assert.fail('did not time out');
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
// OK
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
describe('promise-util', () => {
|
|
33
|
+
it('should get event', async () => {
|
|
34
|
+
const emitter = new event_1.Emitter();
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
emitter.fire('abcd');
|
|
37
|
+
}, 500);
|
|
38
|
+
assert.strictEqual(await promise_util_1.waitForEvent(emitter.event, 1000), 'abcd');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=promise-util.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-util.spec.js","sourceRoot":"","sources":["../../src/common/promise-util.spec.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,iCAAiC;AACjC,iDAA8C;AAC9C,mCAAkC;AAElC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,iBAAiB,EAAE,KAAK,IAAI,EAAE;QAC7B,MAAM,OAAO,GAAG,IAAI,eAAO,EAAU,CAAC;QACtC,IAAI;YACA,MAAM,2BAAY,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACxC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;SACnC;QAAC,OAAO,CAAC,EAAE;YACR,KAAK;SACR;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;YAC9B,MAAM,OAAO,GAAG,IAAI,eAAO,EAAU,CAAC;YACtC,UAAU,CAAC,GAAG,EAAE;gBACZ,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACzB,CAAC,EAAE,GAAG,CAAC,CAAC;YACR,MAAM,CAAC,WAAW,CAAC,MAAM,2BAAY,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/core",
|
|
3
|
-
"version": "1.18.0-next.
|
|
3
|
+
"version": "1.18.0-next.178+cf1d1215fc9",
|
|
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.18.0-next.
|
|
20
|
+
"@theia/application-package": "1.18.0-next.178+cf1d1215fc9",
|
|
21
21
|
"@types/body-parser": "^1.16.4",
|
|
22
22
|
"@types/cookie": "^0.3.3",
|
|
23
23
|
"@types/dompurify": "^2.2.2",
|
|
@@ -177,5 +177,5 @@
|
|
|
177
177
|
"nyc": {
|
|
178
178
|
"extends": "../../configs/nyc.json"
|
|
179
179
|
},
|
|
180
|
-
"gitHead": "
|
|
180
|
+
"gitHead": "cf1d1215fc96dba43e9efa0672c6fafb27e9eba1"
|
|
181
181
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (C) 2021 Red Hat 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 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
import * as assert from 'assert';
|
|
17
|
+
import { waitForEvent } from './promise-util';
|
|
18
|
+
import { Emitter } from './event';
|
|
19
|
+
|
|
20
|
+
describe('promise-util', () => {
|
|
21
|
+
it('should time out', async () => {
|
|
22
|
+
const emitter = new Emitter<string>();
|
|
23
|
+
try {
|
|
24
|
+
await waitForEvent(emitter.event, 1000);
|
|
25
|
+
assert.fail('did not time out');
|
|
26
|
+
} catch (e) {
|
|
27
|
+
// OK
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('promise-util', () => {
|
|
32
|
+
it('should get event', async () => {
|
|
33
|
+
const emitter = new Emitter<string>();
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
emitter.fire('abcd');
|
|
36
|
+
}, 500);
|
|
37
|
+
assert.strictEqual(await waitForEvent(emitter.event, 1000), 'abcd');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
});
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { Disposable } from './disposable';
|
|
18
|
+
import { Event } from './event';
|
|
19
|
+
import { CancellationToken, CancellationError, cancelled } from './cancellation';
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* Simple implementation of the deferred pattern.
|
|
@@ -90,3 +92,20 @@ export function delay<T>(ms: number): (value: T) => Promise<T> {
|
|
|
90
92
|
export async function wait(ms: number): Promise<void> {
|
|
91
93
|
await delay(ms)(undefined);
|
|
92
94
|
}
|
|
95
|
+
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
+
export function waitForEvent<T>(event: Event<T>, ms: number, thisArg?: any, disposables?: Disposable[]): Promise<T> {
|
|
98
|
+
return new Promise<T>((resolve, reject) => {
|
|
99
|
+
const registration = setTimeout(() => {
|
|
100
|
+
listener.dispose();
|
|
101
|
+
reject(new CancellationError());
|
|
102
|
+
}, ms);
|
|
103
|
+
|
|
104
|
+
const listener = event((evt: T) => {
|
|
105
|
+
clearTimeout(registration);
|
|
106
|
+
listener.dispose();
|
|
107
|
+
resolve(evt);
|
|
108
|
+
}, thisArg, disposables);
|
|
109
|
+
|
|
110
|
+
});
|
|
111
|
+
}
|