@gitpod/gitpod-protocol 0.1.5-wth-argo.0 → 0.1.5-wth-test.41
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/data/builtin-theia-plugins.json +9 -9
- package/data/gitpod-schema.json +8 -22
- package/lib/accounting-protocol.d.ts +155 -0
- package/lib/accounting-protocol.d.ts.map +1 -0
- package/lib/accounting-protocol.js +109 -0
- package/lib/accounting-protocol.js.map +1 -0
- package/lib/admin-protocol.d.ts +20 -4
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +15 -0
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +45 -0
- package/lib/analytics.d.ts.map +1 -0
- package/lib/{util/without.js → analytics.js} +4 -2
- package/lib/analytics.js.map +1 -0
- package/lib/context-url.d.ts +18 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +49 -0
- package/lib/context-url.js.map +1 -0
- package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +3 -1
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +73 -0
- package/lib/context-url.spec.js.map +1 -0
- package/lib/email-protocol.d.ts +1 -2
- package/lib/email-protocol.d.ts.map +1 -1
- package/lib/email-protocol.js +4 -4
- package/lib/email-protocol.js.map +1 -1
- package/lib/encryption/container-module.js +5 -4
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.js +19 -20
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +29 -36
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.js +29 -43
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.js +25 -30
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -2
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +20 -21
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.js +25 -41
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +116 -116
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +132 -18
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +168 -256
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +8 -11
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +4 -7
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-frontend-service.d.ts +4 -0
- package/lib/ide-frontend-service.d.ts.map +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +5 -3
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +183 -33
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.js +35 -55
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +35 -0
- package/lib/messaging/client-call-metrics.d.ts.map +1 -0
- package/lib/messaging/client-call-metrics.js +83 -0
- package/lib/messaging/client-call-metrics.js.map +1 -0
- package/lib/messaging/connection-error-handler.js +11 -23
- package/lib/messaging/connection-error-handler.js.map +1 -1
- package/lib/messaging/error.d.ts +3 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +6 -2
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts +10 -0
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +22 -22
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +2 -0
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +74 -159
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/payment-protocol.d.ts +18 -0
- package/lib/payment-protocol.d.ts.map +1 -0
- package/lib/payment-protocol.js +13 -0
- package/lib/payment-protocol.js.map +1 -0
- package/lib/permission.d.ts +2 -1
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +14 -13
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +210 -0
- package/lib/plans.d.ts.map +1 -0
- package/lib/plans.js +570 -0
- package/lib/plans.js.map +1 -0
- package/lib/protocol.d.ts +94 -16
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +104 -130
- package/lib/protocol.js.map +1 -1
- package/lib/snapshot-url.d.ts +14 -0
- package/lib/snapshot-url.d.ts.map +1 -0
- package/lib/snapshot-url.js +26 -0
- package/lib/snapshot-url.js.map +1 -0
- package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
- package/lib/snapshot-url.spec.d.ts.map +1 -0
- package/lib/snapshot-url.spec.js +41 -0
- package/lib/snapshot-url.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +73 -0
- package/lib/team-subscription-protocol.d.ts.map +1 -0
- package/lib/team-subscription-protocol.js +63 -0
- package/lib/team-subscription-protocol.js.map +1 -0
- package/lib/teams-projects-protocol.d.ts +103 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +23 -0
- package/lib/teams-projects-protocol.js.map +1 -0
- package/lib/util/analytics.d.ts +8 -0
- package/lib/util/analytics.d.ts.map +1 -0
- package/lib/util/analytics.js +79 -0
- package/lib/util/analytics.js.map +1 -0
- package/lib/util/async-iterator.js +55 -133
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js +17 -59
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +8 -8
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deferred.js +10 -12
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.js +26 -39
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.js +58 -74
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.js +22 -46
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +13 -67
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +34 -79
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +20 -0
- package/lib/util/gitpod-cookie.d.ts.map +1 -0
- package/lib/util/gitpod-cookie.js +44 -0
- package/lib/util/gitpod-cookie.js.map +1 -0
- package/lib/util/gitpod-host-url.d.ts +1 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +98 -98
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts +7 -1
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +103 -31
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts +15 -0
- package/lib/util/grpc.d.ts.map +1 -0
- package/lib/util/grpc.js +18 -0
- package/lib/util/grpc.js.map +1 -0
- package/lib/util/logging.d.ts +49 -33
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +107 -110
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.js +2 -2
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/parse-workspace-id.d.ts +10 -0
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +32 -7
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +4 -0
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +123 -84
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.js +16 -55
- package/lib/util/queue.js.map +1 -1
- package/lib/util/queue.spec.js +144 -288
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/repeater.js +35 -88
- package/lib/util/repeater.js.map +1 -1
- package/lib/util/safe-promise.js +9 -12
- package/lib/util/safe-promise.js.map +1 -1
- package/lib/util/semaphore.js +15 -46
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.js +6 -6
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.js +28 -16
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.js +21 -24
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.js +43 -47
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/workspace-port-authentication.js +3 -2
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +74 -0
- package/lib/workspace-cluster.d.ts.map +1 -0
- package/lib/workspace-cluster.js +16 -0
- package/lib/workspace-cluster.js.map +1 -0
- package/lib/workspace-instance.d.ts +7 -2
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.d.ts +1 -1
- package/lib/wsready.js +2 -2
- package/package.json +28 -16
- package/pkg-yarn.lock +17 -9
- package/src/accounting-protocol.ts +229 -0
- package/src/admin-protocol.ts +39 -5
- package/src/analytics.ts +54 -0
- package/src/context-url.spec.ts +39 -0
- package/src/context-url.ts +51 -0
- package/src/email-protocol.ts +2 -3
- package/src/env.ts +10 -10
- package/src/gitpod-service.ts +198 -33
- package/src/headless-workspace-log.ts +7 -11
- package/src/ide-frontend-service.ts +4 -0
- package/src/index.ts +5 -1
- package/src/messaging/browser/connection.ts +195 -14
- package/src/messaging/client-call-metrics.ts +97 -0
- package/src/messaging/error.ts +8 -2
- package/src/messaging/handler.ts +12 -0
- package/src/messaging/node/connection.ts +2 -2
- package/src/messaging/proxy-factory.ts +14 -6
- package/src/payment-protocol.ts +20 -0
- package/src/permission.ts +2 -1
- package/src/plans.ts +632 -0
- package/src/protocol.ts +153 -43
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +113 -0
- package/src/teams-projects-protocol.ts +132 -0
- package/src/util/analytics.ts +87 -0
- package/src/util/deferred.ts +1 -1
- package/src/util/garbage-collected-cache.ts +2 -2
- package/src/util/generate-workspace-id.spec.ts +3 -3
- package/src/util/generate-workspace-id.ts +2 -0
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/gitpod-host-url.spec.ts +25 -1
- package/src/util/gitpod-host-url.ts +23 -10
- package/src/util/grpc.ts +15 -0
- package/src/util/logging.ts +102 -38
- package/src/util/parse-workspace-id.spec.ts +21 -1
- package/src/util/parse-workspace-id.ts +32 -6
- package/src/util/queue.spec.ts +1 -1
- package/src/util/semaphore.ts +2 -2
- package/src/util/skip-if.ts +1 -1
- package/src/util/timeutil.ts +4 -4
- package/src/workspace-cluster.ts +96 -0
- package/src/workspace-instance.ts +31 -13
- package/src/wsready.ts +2 -2
- package/lib/util/context-url.d.ts +0 -13
- package/lib/util/context-url.d.ts.map +0 -1
- package/lib/util/context-url.js +0 -26
- package/lib/util/context-url.js.map +0 -1
- package/lib/util/context-url.spec.d.ts.map +0 -1
- package/lib/util/context-url.spec.js +0 -52
- package/lib/util/context-url.spec.js.map +0 -1
- package/lib/util/without.d.ts +0 -7
- package/lib/util/without.d.ts.map +0 -1
- package/lib/util/without.js.map +0 -1
- package/src/util/context-url.spec.ts +0 -25
- package/src/util/context-url.ts +0 -23
package/lib/util/date-time.js
CHANGED
|
@@ -14,17 +14,17 @@ function formatHours(hours) {
|
|
|
14
14
|
if (hours === undefined) {
|
|
15
15
|
return '';
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
const h = Math.floor(Math.abs(hours));
|
|
18
|
+
const rm = (Math.abs(hours) - h) * 60.;
|
|
19
|
+
const m = Math.floor(rm);
|
|
20
|
+
const rs = (rm - m) * 60.;
|
|
21
|
+
const s = Math.floor(rs);
|
|
22
|
+
const result = h + ':' + pad2(m) + ':' + pad2(s);
|
|
23
23
|
if (hours < 0) {
|
|
24
|
-
return
|
|
24
|
+
return `-${result}`;
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
|
-
return
|
|
27
|
+
return `${result}`;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
exports.formatHours = formatHours;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-time.js","sourceRoot":"","sources":["../../src/util/date-time.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,SAAgB,UAAU,CAAC,IAAa;IACpC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACvD,CAAC;AAFD,gCAEC;AAED,SAAgB,WAAW,CAAC,KAAc;IACtC,IAAI,KAAK,KAAK,SAAS,EAAE;QACrB,OAAO,EAAE,CAAC;KACb;IACD,
|
|
1
|
+
{"version":3,"file":"date-time.js","sourceRoot":"","sources":["../../src/util/date-time.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,SAAgB,UAAU,CAAC,IAAa;IACpC,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACvD,CAAC;AAFD,gCAEC;AAED,SAAgB,WAAW,CAAC,KAAc;IACtC,IAAI,KAAK,KAAK,SAAS,EAAE;QACrB,OAAO,EAAE,CAAC;KACb;IACD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IACtC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;IACvC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzB,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;IAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzB,MAAM,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACjD,IAAI,KAAK,GAAG,CAAC,EAAE;QACX,OAAO,IAAI,MAAM,EAAE,CAAA;KACtB;SAAM;QACH,OAAO,GAAG,MAAM,EAAE,CAAA;KACrB;AACL,CAAC;AAfD,kCAeC;AAED,SAAS,IAAI,CAAC,CAAS;IACnB,OAAO,CAAC,GAAI,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACtC,CAAC"}
|
package/lib/util/deferred.js
CHANGED
|
@@ -6,26 +6,24 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.Deferred = void 0;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _this = this;
|
|
9
|
+
class Deferred {
|
|
10
|
+
constructor(timeout) {
|
|
12
11
|
this.isResolved = false;
|
|
13
|
-
this.promise = new Promise(
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
this.promise = new Promise((resolve, reject) => {
|
|
13
|
+
this.resolve = (o) => {
|
|
14
|
+
this.isResolved = true;
|
|
16
15
|
resolve(o);
|
|
17
|
-
clearTimeout(
|
|
16
|
+
clearTimeout(this.timer);
|
|
18
17
|
};
|
|
19
|
-
|
|
18
|
+
this.reject = (e) => {
|
|
20
19
|
reject(e);
|
|
21
|
-
clearTimeout(
|
|
20
|
+
clearTimeout(this.timer);
|
|
22
21
|
};
|
|
23
22
|
});
|
|
24
23
|
if (timeout) {
|
|
25
|
-
this.timer = setTimeout(
|
|
24
|
+
this.timer = setTimeout(() => this.reject(new Error(`Timeout of ${timeout} ms.`)), timeout);
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
}());
|
|
27
|
+
}
|
|
30
28
|
exports.Deferred = Deferred;
|
|
31
29
|
//# sourceMappingURL=deferred.js.map
|
package/lib/util/deferred.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deferred.js","sourceRoot":"","sources":["../../src/util/deferred.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH;
|
|
1
|
+
{"version":3,"file":"deferred.js","sourceRoot":"","sources":["../../src/util/deferred.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,MAAa,QAAQ;IAMjB,YAAY,OAAgB;QAH5B,eAAU,GAAY,KAAK,CAAC;QAS5B,YAAO,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACzC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,EAAE;gBACjB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;gBACvB,OAAO,CAAC,CAAQ,CAAC,CAAA;gBACjB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAC5B,CAAC,CAAC;YACF,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE;gBAChB,MAAM,CAAC,CAAC,CAAC,CAAA;gBACT,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAC5B,CAAC,CAAA;QACL,CAAC,CAAC,CAAC;QAfC,IAAI,OAAO,EAAE;YACT,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,cAAc,OAAO,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;SAC/F;IACL,CAAC;CAaJ;AAvBD,4BAuBC"}
|
package/lib/util/disposable.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.DisposableCollection = exports.Disposable = void 0;
|
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
8
8
|
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
const event_1 = require("./event");
|
|
11
11
|
var Disposable;
|
|
12
12
|
(function (Disposable) {
|
|
13
13
|
function create(func) {
|
|
@@ -16,33 +16,25 @@ var Disposable;
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
Disposable.create = create;
|
|
19
|
-
Disposable.NULL = create(
|
|
19
|
+
Disposable.NULL = create(() => { });
|
|
20
20
|
})(Disposable = exports.Disposable || (exports.Disposable = {}));
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
class DisposableCollection {
|
|
22
|
+
constructor() {
|
|
23
23
|
this.disposables = [];
|
|
24
24
|
this.onDisposeEmitter = new event_1.Emitter();
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
enumerable: false,
|
|
31
|
-
configurable: true
|
|
32
|
-
});
|
|
33
|
-
DisposableCollection.prototype.checkDisposed = function () {
|
|
26
|
+
get onDispose() {
|
|
27
|
+
return this.onDisposeEmitter.event;
|
|
28
|
+
}
|
|
29
|
+
checkDisposed() {
|
|
34
30
|
if (this.disposed) {
|
|
35
31
|
this.onDisposeEmitter.fire(undefined);
|
|
36
32
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
enumerable: false,
|
|
43
|
-
configurable: true
|
|
44
|
-
});
|
|
45
|
-
DisposableCollection.prototype.dispose = function () {
|
|
33
|
+
}
|
|
34
|
+
get disposed() {
|
|
35
|
+
return this.disposables.length === 0;
|
|
36
|
+
}
|
|
37
|
+
dispose() {
|
|
46
38
|
if (this.disposed) {
|
|
47
39
|
return;
|
|
48
40
|
}
|
|
@@ -50,32 +42,27 @@ var DisposableCollection = /** @class */ (function () {
|
|
|
50
42
|
this.disposables.pop().dispose();
|
|
51
43
|
}
|
|
52
44
|
this.checkDisposed();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var disposables = this.disposables;
|
|
45
|
+
}
|
|
46
|
+
push(disposable) {
|
|
47
|
+
const disposables = this.disposables;
|
|
57
48
|
disposables.push(disposable);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
const originalDispose = disposable.dispose.bind(disposable);
|
|
50
|
+
const toRemove = Disposable.create(() => {
|
|
51
|
+
const index = disposables.indexOf(disposable);
|
|
61
52
|
if (index !== -1) {
|
|
62
53
|
disposables.splice(index, 1);
|
|
63
54
|
}
|
|
64
|
-
|
|
55
|
+
this.checkDisposed();
|
|
65
56
|
});
|
|
66
|
-
disposable.dispose =
|
|
57
|
+
disposable.dispose = () => {
|
|
67
58
|
toRemove.dispose();
|
|
68
59
|
originalDispose();
|
|
69
60
|
};
|
|
70
61
|
return toRemove;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
return DisposableCollection;
|
|
79
|
-
}());
|
|
62
|
+
}
|
|
63
|
+
pushAll(disposables) {
|
|
64
|
+
return disposables.map(disposable => this.push(disposable));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
80
67
|
exports.DisposableCollection = DisposableCollection;
|
|
81
68
|
//# sourceMappingURL=disposable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disposable.js","sourceRoot":"","sources":["../../src/util/disposable.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,
|
|
1
|
+
{"version":3,"file":"disposable.js","sourceRoot":"","sources":["../../src/util/disposable.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,mCAAyC;AASzC,IAAiB,UAAU,CAO1B;AAPD,WAAiB,UAAU;IACvB,SAAgB,MAAM,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E;gBACd,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;aAChC;YACD,IAAI,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,UAAU,CAAC,OAAO,GAAG,GAAG,EAAE;YACtB,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,eAAe,EAAE,CAAC;QACtB,CAAC,CAAC;QACF,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,OAAO,CAAC,WAAyB;QAC7B,OAAO,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAChC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CACxB,CAAC;IACN,CAAC;CAEJ;AApDD,oDAoDC"}
|
package/lib/util/event.js
CHANGED
|
@@ -7,18 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.Emitter = exports.Event = void 0;
|
|
10
|
-
|
|
10
|
+
const logging_1 = require("./logging");
|
|
11
11
|
var Event;
|
|
12
12
|
(function (Event) {
|
|
13
|
-
|
|
13
|
+
const _disposable = { dispose() { } };
|
|
14
14
|
Event.None = function () { return _disposable; };
|
|
15
15
|
})(Event = exports.Event || (exports.Event = {}));
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
CallbackList.prototype.add = function (callback, context, bucket) {
|
|
20
|
-
var _this = this;
|
|
21
|
-
if (context === void 0) { context = null; }
|
|
16
|
+
class CallbackList {
|
|
17
|
+
add(callback, context = null, bucket) {
|
|
22
18
|
if (!this._callbacks) {
|
|
23
19
|
this._callbacks = [];
|
|
24
20
|
this._contexts = [];
|
|
@@ -26,16 +22,15 @@ var CallbackList = /** @class */ (function () {
|
|
|
26
22
|
this._callbacks.push(callback);
|
|
27
23
|
this._contexts.push(context);
|
|
28
24
|
if (Array.isArray(bucket)) {
|
|
29
|
-
bucket.push({ dispose:
|
|
25
|
+
bucket.push({ dispose: () => this.remove(callback, context) });
|
|
30
26
|
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (context === void 0) { context = null; }
|
|
27
|
+
}
|
|
28
|
+
remove(callback, context = null) {
|
|
34
29
|
if (!this._callbacks) {
|
|
35
30
|
return;
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
for (
|
|
32
|
+
let foundCallbackWithDifferentContext = false;
|
|
33
|
+
for (let i = 0, len = this._callbacks.length; i < len; i++) {
|
|
39
34
|
if (this._callbacks[i] === callback) {
|
|
40
35
|
if (this._contexts[i] === context) {
|
|
41
36
|
// callback & context match => remove it
|
|
@@ -51,19 +46,15 @@ var CallbackList = /** @class */ (function () {
|
|
|
51
46
|
if (foundCallbackWithDifferentContext) {
|
|
52
47
|
throw new Error('When adding a listener with a context, you should remove it with the same context');
|
|
53
48
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
var args = [];
|
|
57
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
58
|
-
args[_i] = arguments[_i];
|
|
59
|
-
}
|
|
49
|
+
}
|
|
50
|
+
invoke(...args) {
|
|
60
51
|
if (!this._callbacks) {
|
|
61
52
|
return [];
|
|
62
53
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
for (
|
|
54
|
+
const ret = [];
|
|
55
|
+
const callbacks = this._callbacks.slice(0);
|
|
56
|
+
const contexts = this._contexts.slice(0);
|
|
57
|
+
for (let i = 0, len = callbacks.length; i < len; i++) {
|
|
67
58
|
try {
|
|
68
59
|
ret.push(callbacks[i].apply(contexts[i], args));
|
|
69
60
|
}
|
|
@@ -72,74 +63,67 @@ var CallbackList = /** @class */ (function () {
|
|
|
72
63
|
}
|
|
73
64
|
}
|
|
74
65
|
return ret;
|
|
75
|
-
}
|
|
76
|
-
|
|
66
|
+
}
|
|
67
|
+
isEmpty() {
|
|
77
68
|
return !this._callbacks || this._callbacks.length === 0;
|
|
78
|
-
}
|
|
79
|
-
|
|
69
|
+
}
|
|
70
|
+
dispose() {
|
|
80
71
|
this._callbacks = undefined;
|
|
81
72
|
this._contexts = undefined;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
function Emitter(_options) {
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
class Emitter {
|
|
76
|
+
constructor(_options) {
|
|
87
77
|
this._options = _options;
|
|
88
78
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
dispose
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (_this._options && _this._options.onLastListenerRemove && _this._callbacks.isEmpty()) {
|
|
111
|
-
_this._options.onLastListenerRemove(_this);
|
|
112
|
-
}
|
|
79
|
+
/**
|
|
80
|
+
* For the public to allow to subscribe
|
|
81
|
+
* to events from this Emitter
|
|
82
|
+
*/
|
|
83
|
+
get event() {
|
|
84
|
+
if (!this._event) {
|
|
85
|
+
this._event = (listener, thisArgs, disposables) => {
|
|
86
|
+
if (!this._callbacks) {
|
|
87
|
+
this._callbacks = new CallbackList();
|
|
88
|
+
}
|
|
89
|
+
if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
|
|
90
|
+
this._options.onFirstListenerAdd(this);
|
|
91
|
+
}
|
|
92
|
+
this._callbacks.add(listener, thisArgs);
|
|
93
|
+
let result;
|
|
94
|
+
result = {
|
|
95
|
+
dispose: () => {
|
|
96
|
+
this._callbacks.remove(listener, thisArgs);
|
|
97
|
+
result.dispose = Emitter._noop;
|
|
98
|
+
if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
|
|
99
|
+
this._options.onLastListenerRemove(this);
|
|
113
100
|
}
|
|
114
|
-
};
|
|
115
|
-
if (Array.isArray(disposables)) {
|
|
116
|
-
disposables.push(result);
|
|
117
101
|
}
|
|
118
|
-
return result;
|
|
119
102
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
103
|
+
if (Array.isArray(disposables)) {
|
|
104
|
+
disposables.push(result);
|
|
105
|
+
}
|
|
106
|
+
return result;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return this._event;
|
|
110
|
+
}
|
|
126
111
|
/**
|
|
127
112
|
* To be kept private to fire an event to
|
|
128
113
|
* subscribers
|
|
129
114
|
*/
|
|
130
|
-
|
|
115
|
+
fire(event) {
|
|
131
116
|
if (this._callbacks) {
|
|
132
117
|
this._callbacks.invoke.call(this._callbacks, event);
|
|
133
118
|
}
|
|
134
|
-
}
|
|
135
|
-
|
|
119
|
+
}
|
|
120
|
+
dispose() {
|
|
136
121
|
if (this._callbacks) {
|
|
137
122
|
this._callbacks.dispose();
|
|
138
123
|
this._callbacks = undefined;
|
|
139
124
|
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return Emitter;
|
|
143
|
-
}());
|
|
125
|
+
}
|
|
126
|
+
}
|
|
144
127
|
exports.Emitter = Emitter;
|
|
128
|
+
Emitter._noop = function () { };
|
|
145
129
|
//# sourceMappingURL=event.js.map
|
package/lib/util/event.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/util/event.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/util/event.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,uCAAgC;AAiBhC,IAAiB,KAAK,CAGrB;AAHD,WAAiB,KAAK;IAClB,MAAM,WAAW,GAAG,EAAE,OAAO,KAAK,CAAC,EAAE,CAAC;IACzB,UAAI,GAAe,cAAc,OAAO,WAA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AAC;IAED,OAAO;QACH,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;SAC/B;IACL,CAAC;;AA5DL,0BA6DC;AA3DkB,aAAK,GAAG,cAAc,CAAC,CAAC"}
|
|
@@ -4,72 +4,48 @@
|
|
|
4
4
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
5
5
|
* See License-AGPL.txt in the project root for license information.
|
|
6
6
|
*/
|
|
7
|
-
var __values = (this && this.__values) || function(o) {
|
|
8
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
9
|
-
if (m) return m.call(o);
|
|
10
|
-
if (o && typeof o.length === "number") return {
|
|
11
|
-
next: function () {
|
|
12
|
-
if (o && i >= o.length) o = void 0;
|
|
13
|
-
return { value: o && o[i++], done: !o };
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
17
|
-
};
|
|
18
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
8
|
exports.GarbageCollectedCache = void 0;
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
class GarbageCollectedCache {
|
|
10
|
+
constructor(defaultMaxAgeSeconds, gcIntervalSeconds) {
|
|
22
11
|
this.defaultMaxAgeSeconds = defaultMaxAgeSeconds;
|
|
23
12
|
this.gcIntervalSeconds = gcIntervalSeconds;
|
|
24
13
|
this.store = new Map();
|
|
25
14
|
this.regularlyCollectGarbage();
|
|
26
15
|
}
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
set(key, value) {
|
|
17
|
+
const oldValue = this.store.get(key);
|
|
29
18
|
if (oldValue) {
|
|
30
19
|
// We don't want values to be cached indefinitely just because their queried often
|
|
31
20
|
return;
|
|
32
21
|
}
|
|
33
22
|
this.store.set(key, {
|
|
34
|
-
key
|
|
35
|
-
value
|
|
23
|
+
key,
|
|
24
|
+
value,
|
|
36
25
|
expiryDate: this.calcExpiryDate(),
|
|
37
26
|
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
}
|
|
28
|
+
get(key) {
|
|
29
|
+
const entry = this.store.get(key);
|
|
41
30
|
if (!entry) {
|
|
42
31
|
return undefined;
|
|
43
32
|
}
|
|
44
33
|
return entry.value;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
for (var _b = __values(this.store.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
55
|
-
var entry = _c.value;
|
|
56
|
-
if (entry.expiryDate < now) {
|
|
57
|
-
this.store.delete(entry.key);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
62
|
-
finally {
|
|
63
|
-
try {
|
|
64
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
34
|
+
}
|
|
35
|
+
regularlyCollectGarbage() {
|
|
36
|
+
setInterval(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
|
|
37
|
+
}
|
|
38
|
+
collectGarbage() {
|
|
39
|
+
const now = Date.now();
|
|
40
|
+
for (const entry of this.store.values()) {
|
|
41
|
+
if (entry.expiryDate < now) {
|
|
42
|
+
this.store.delete(entry.key);
|
|
65
43
|
}
|
|
66
|
-
finally { if (e_1) throw e_1.error; }
|
|
67
44
|
}
|
|
68
|
-
}
|
|
69
|
-
|
|
45
|
+
}
|
|
46
|
+
calcExpiryDate(maxAgeSeconds) {
|
|
70
47
|
return Date.now() + ((maxAgeSeconds || this.defaultMaxAgeSeconds) * 1000);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
}());
|
|
48
|
+
}
|
|
49
|
+
}
|
|
74
50
|
exports.GarbageCollectedCache = GarbageCollectedCache;
|
|
75
51
|
//# sourceMappingURL=garbage-collected-cache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"garbage-collected-cache.js","sourceRoot":"","sources":["../../src/util/garbage-collected-cache.ts"],"names":[],"mappings":";AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"garbage-collected-cache.js","sourceRoot":"","sources":["../../src/util/garbage-collected-cache.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AASH,MAAa,qBAAqB;IAG9B,YACuB,oBAA4B,EAC5B,iBAAyB;QADzB,yBAAoB,GAApB,oBAAoB,CAAQ;QAC5B,sBAAiB,GAAjB,iBAAiB,CAAQ;QAJ7B,UAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;QAKxD,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACnC,CAAC;IAEM,GAAG,CAAC,GAAW,EAAE,KAAQ;QAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,QAAQ,EAAE;YACV,kFAAkF;YAClF,OAAO;SACV;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;YAChB,GAAG;YACH,KAAK;YACL,UAAU,EAAE,IAAI,CAAC,cAAc,EAAE;SACpC,CAAC,CAAC;IACP,CAAC;IAEM,GAAG,CAAC,GAAW;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE;YACR,OAAO,SAAS,CAAC;SACpB;QACD,OAAO,KAAK,CAAC,KAAK,CAAC;IACvB,CAAC;IAES,uBAAuB;QAC7B,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IAC5E,CAAC;IAES,cAAc;QACpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE;YACrC,IAAI,KAAK,CAAC,UAAU,GAAG,GAAG,EAAE;gBACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aAChC;SACJ;IACL,CAAC;IAES,cAAc,CAAC,aAAsB;QAC3C,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,aAAa,IAAI,IAAI,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC,CAAC;IAC9E,CAAC;CACJ;AA9CD,sDA8CC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-workspace-id.d.ts","sourceRoot":"","sources":["../../src/util/generate-workspace-id.ts"],"names":[],"mappings":"AAOA,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAE3D;AAYD,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"generate-workspace-id.d.ts","sourceRoot":"","sources":["../../src/util/generate-workspace-id.ts"],"names":[],"mappings":"AAOA,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAE3D;AAYD,eAAO,MAAM,MAAM,UAsDhB,CAAC;AAEF,eAAO,MAAM,OAAO,UA2XnB,CAAA"}
|
|
@@ -8,33 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
12
|
exports.animals = exports.colors = exports.generateWorkspaceID = void 0;
|
|
40
13
|
/**
|
|
@@ -42,52 +15,23 @@ exports.animals = exports.colors = exports.generateWorkspaceID = void 0;
|
|
|
42
15
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
43
16
|
* See License-AGPL.txt in the project root for license information.
|
|
44
17
|
*/
|
|
45
|
-
|
|
18
|
+
const randomNumber = require("random-number-csprng");
|
|
46
19
|
function generateWorkspaceID() {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
|
|
49
|
-
return __generator(this, function (_c) {
|
|
50
|
-
switch (_c.label) {
|
|
51
|
-
case 0: return [4 /*yield*/, random(exports.colors)];
|
|
52
|
-
case 1:
|
|
53
|
-
_a = (_c.sent()) + '-';
|
|
54
|
-
return [4 /*yield*/, random(exports.animals)];
|
|
55
|
-
case 2:
|
|
56
|
-
_b = _a + (_c.sent()) + '-';
|
|
57
|
-
return [4 /*yield*/, random(characters, 8)];
|
|
58
|
-
case 3: return [2 /*return*/, _b + (_c.sent())];
|
|
59
|
-
}
|
|
60
|
-
});
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
return (yield random(exports.colors)) + '-' + (yield random(exports.animals)) + '-' + (yield random(characters, 8));
|
|
61
22
|
});
|
|
62
23
|
}
|
|
63
24
|
exports.generateWorkspaceID = generateWorkspaceID;
|
|
64
|
-
function random(array, length) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
result = '';
|
|
72
|
-
i = 0;
|
|
73
|
-
_c.label = 1;
|
|
74
|
-
case 1:
|
|
75
|
-
if (!(i < length)) return [3 /*break*/, 4];
|
|
76
|
-
_a = result;
|
|
77
|
-
_b = array;
|
|
78
|
-
return [4 /*yield*/, randomNumber(0, array.length - 1)];
|
|
79
|
-
case 2:
|
|
80
|
-
result = _a + _b[_c.sent()];
|
|
81
|
-
_c.label = 3;
|
|
82
|
-
case 3:
|
|
83
|
-
i++;
|
|
84
|
-
return [3 /*break*/, 1];
|
|
85
|
-
case 4: return [2 /*return*/, result];
|
|
86
|
-
}
|
|
87
|
-
});
|
|
25
|
+
function random(array, length = 1) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
var result = '';
|
|
28
|
+
for (var i = 0; i < length; i++) {
|
|
29
|
+
result += array[yield randomNumber(0, array.length - 1)];
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
88
32
|
});
|
|
89
33
|
}
|
|
90
|
-
|
|
34
|
+
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789'.split('');
|
|
91
35
|
exports.colors = [
|
|
92
36
|
'amaranth',
|
|
93
37
|
'amber',
|
|
@@ -117,6 +61,7 @@ exports.colors = [
|
|
|
117
61
|
'indigo',
|
|
118
62
|
'ivory',
|
|
119
63
|
'jade',
|
|
64
|
+
'kumquat',
|
|
120
65
|
'lavender',
|
|
121
66
|
'lime',
|
|
122
67
|
'magenta',
|
|
@@ -240,6 +185,7 @@ exports.animals = [
|
|
|
240
185
|
'deer',
|
|
241
186
|
'dingo',
|
|
242
187
|
'dinosaur',
|
|
188
|
+
'dodo',
|
|
243
189
|
'dog',
|
|
244
190
|
'dolphin',
|
|
245
191
|
'donkey',
|