@croct/sdk 0.10.0 → 0.11.0-alpha
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/activeRecord.js +32 -36
- package/cache/fallbackCache.js +15 -32
- package/cache/inMemoryCache.js +9 -10
- package/cache/index.js +1 -1
- package/cache/localStorageCache.js +24 -25
- package/channel/beaconSocketChannel.d.ts +1 -1
- package/channel/beaconSocketChannel.js +49 -79
- package/channel/channel.d.ts +1 -1
- package/channel/encodedChannel.js +8 -10
- package/channel/guaranteedChannel.d.ts +4 -4
- package/channel/guaranteedChannel.js +41 -43
- package/channel/index.js +1 -1
- package/channel/queuedChannel.js +35 -64
- package/channel/retryChannel.d.ts +1 -1
- package/channel/retryChannel.js +44 -77
- package/channel/sandboxChannel.js +17 -18
- package/channel/socketChannel.d.ts +4 -4
- package/channel/socketChannel.js +77 -79
- package/cid/cachedAssigner.js +15 -27
- package/cid/fixedAssigner.js +5 -6
- package/cid/index.js +1 -1
- package/cid/remoteAssigner.js +23 -36
- package/constants.d.ts +3 -2
- package/constants.js +6 -5
- package/container.d.ts +13 -6
- package/container.js +152 -168
- package/contentFetcher.d.ts +59 -0
- package/contentFetcher.js +129 -0
- package/context.d.ts +3 -3
- package/context.js +36 -38
- package/error.js +2 -2
- package/evaluator.d.ts +33 -24
- package/evaluator.js +126 -117
- package/eventManager.d.ts +1 -1
- package/eventManager.js +14 -15
- package/facade/contentFetcherFacade.d.ts +27 -0
- package/facade/contentFetcherFacade.js +40 -0
- package/facade/evaluatorFacade.d.ts +13 -3
- package/facade/evaluatorFacade.js +57 -72
- package/facade/sdkFacade.d.ts +10 -3
- package/facade/sdkFacade.js +129 -141
- package/facade/sessionFacade.js +6 -7
- package/facade/sessionPatch.js +9 -13
- package/facade/trackerFacade.js +32 -38
- package/facade/userFacade.js +10 -11
- package/facade/userPatch.js +9 -13
- package/index.js +2 -2
- package/logging/consoleLogger.js +18 -35
- package/logging/index.js +1 -1
- package/logging/namespacedLogger.js +14 -15
- package/logging/nullLogger.js +10 -13
- package/namespacedStorage.js +30 -47
- package/package.json +13 -16
- package/patch.d.ts +1 -1
- package/queue/capacityRestrictedQueue.js +17 -18
- package/queue/inMemoryQueue.js +22 -28
- package/queue/index.js +1 -1
- package/queue/monitoredQueue.d.ts +2 -2
- package/queue/monitoredQueue.js +39 -40
- package/queue/persistentQueue.js +33 -38
- package/retry/arbitraryPolicy.js +8 -10
- package/retry/backoffPolicy.d.ts +1 -1
- package/retry/backoffPolicy.js +11 -13
- package/retry/index.js +1 -1
- package/retry/maxAttemptsPolicy.js +7 -8
- package/retry/neverPolicy.js +6 -9
- package/schema/attributeSchema.js +1 -1
- package/schema/contentFetcherSchemas.d.ts +2 -0
- package/schema/contentFetcherSchemas.js +22 -0
- package/schema/contentSchemas.js +1 -1
- package/schema/contextSchemas.js +1 -1
- package/schema/ecommerceSchemas.js +1 -1
- package/schema/evaluatorSchemas.d.ts +2 -0
- package/schema/{evaluationSchemas.js → evaluatorSchemas.js} +3 -3
- package/schema/eventSchemas.js +5 -7
- package/schema/index.d.ts +2 -1
- package/schema/index.js +3 -2
- package/schema/loggerSchema.js +1 -1
- package/schema/operationSchemas.js +8 -8
- package/schema/sdkFacadeSchemas.js +9 -6
- package/schema/sdkSchemas.js +8 -5
- package/schema/tokenSchema.js +5 -4
- package/schema/userSchema.js +2 -2
- package/sdk.d.ts +9 -3
- package/sdk.js +81 -127
- package/sdkEvents.d.ts +3 -3
- package/sourceLocation.d.ts +3 -3
- package/sourceLocation.js +13 -14
- package/tab.d.ts +5 -5
- package/tab.js +50 -80
- package/token/cachedTokenStore.js +9 -10
- package/token/inMemoryTokenStore.js +7 -8
- package/token/index.js +1 -1
- package/token/replicatedTokenStore.js +7 -8
- package/token/token.d.ts +9 -5
- package/token/token.js +63 -57
- package/tracker.d.ts +4 -4
- package/tracker.js +145 -122
- package/trackingEvents.d.ts +36 -36
- package/trackingEvents.js +12 -6
- package/transformer.js +1 -1
- package/utilityTypes.d.ts +2 -2
- package/uuid.js +9 -7
- package/validation/arrayType.d.ts +2 -2
- package/validation/arrayType.js +29 -27
- package/validation/booleanType.js +11 -15
- package/validation/functionType.js +11 -15
- package/validation/index.js +1 -1
- package/validation/jsonType.d.ts +2 -2
- package/validation/jsonType.js +61 -80
- package/validation/mixedSchema.js +4 -7
- package/validation/nullType.js +11 -15
- package/validation/numberType.d.ts +1 -1
- package/validation/numberType.js +23 -22
- package/validation/objectType.d.ts +1 -1
- package/validation/objectType.js +61 -72
- package/validation/schema.js +6 -10
- package/validation/stringType.d.ts +1 -1
- package/validation/stringType.js +36 -47
- package/validation/unionType.js +27 -77
- package/validation/violation.js +1 -2
- package/schema/evaluationSchemas.d.ts +0 -2
|
@@ -1,80 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GuaranteedChannel = exports.TimeStamper = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function TimeStamper() {
|
|
8
|
-
}
|
|
9
|
-
TimeStamper.prototype.generate = function () {
|
|
4
|
+
const logging_1 = require("../logging");
|
|
5
|
+
class TimeStamper {
|
|
6
|
+
generate() {
|
|
10
7
|
return String(Date.now());
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
}());
|
|
8
|
+
}
|
|
9
|
+
}
|
|
14
10
|
exports.TimeStamper = TimeStamper;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
var channel = _a.channel, logger = _a.logger, stamper = _a.stamper, options = tslib_1.__rest(_a, ["channel", "logger", "stamper"]);
|
|
11
|
+
class GuaranteedChannel {
|
|
12
|
+
constructor({ channel, logger, stamper, ...options }) {
|
|
13
|
+
var _a;
|
|
19
14
|
this.closed = false;
|
|
20
15
|
this.channel = channel;
|
|
21
16
|
this.logger = logger !== null && logger !== void 0 ? logger : new logging_1.NullLogger();
|
|
22
17
|
this.stamper = stamper;
|
|
23
|
-
this.options =
|
|
18
|
+
this.options = {
|
|
19
|
+
...options,
|
|
20
|
+
ackTimeout: (_a = options.ackTimeout) !== null && _a !== void 0 ? _a : 5000,
|
|
21
|
+
};
|
|
24
22
|
}
|
|
25
|
-
|
|
26
|
-
var _this = this;
|
|
23
|
+
publish(message) {
|
|
27
24
|
if (this.closed) {
|
|
28
25
|
return Promise.reject(new Error('Channel is closed.'));
|
|
29
26
|
}
|
|
30
|
-
return new Promise(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
const id = this.stamper.generate(message);
|
|
29
|
+
let timeoutTimer;
|
|
30
|
+
let closeWatcher;
|
|
31
|
+
let confirmed = false;
|
|
32
|
+
const start = Date.now();
|
|
33
|
+
const acknowledge = (response) => {
|
|
37
34
|
if (response === id) {
|
|
38
35
|
confirmed = true;
|
|
39
|
-
|
|
36
|
+
const elapsed = Date.now() - start;
|
|
40
37
|
window.clearTimeout(timeoutTimer);
|
|
41
38
|
window.clearInterval(closeWatcher);
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
this.logger.debug(`Delivery confirmed #${id}, elapsed ${elapsed}ms.`);
|
|
40
|
+
this.channel.unsubscribe(acknowledge);
|
|
44
41
|
resolve();
|
|
45
42
|
}
|
|
46
43
|
};
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
this.channel.subscribe(acknowledge);
|
|
45
|
+
const abort = (error) => {
|
|
49
46
|
window.clearTimeout(timeoutTimer);
|
|
50
47
|
window.clearInterval(closeWatcher);
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
this.logger.error(`Failed to send message #${id}`);
|
|
49
|
+
this.channel.unsubscribe(acknowledge);
|
|
53
50
|
reject(error);
|
|
54
51
|
};
|
|
55
|
-
|
|
52
|
+
const wait = () => {
|
|
56
53
|
if (confirmed) {
|
|
57
54
|
return;
|
|
58
55
|
}
|
|
59
|
-
closeWatcher = window.setInterval(
|
|
60
|
-
if (
|
|
56
|
+
closeWatcher = window.setInterval(() => {
|
|
57
|
+
if (this.closed) {
|
|
61
58
|
// Cancel delay immediately when the channel is closed
|
|
62
59
|
abort(new Error('Connection deliberately closed.'));
|
|
63
60
|
}
|
|
64
61
|
}, 0);
|
|
65
|
-
|
|
66
|
-
timeoutTimer = window.setTimeout(
|
|
62
|
+
this.logger.debug(`Waiting confirmation #${id}...`);
|
|
63
|
+
timeoutTimer = window.setTimeout(() => {
|
|
67
64
|
abort(new Error('Maximum confirmation time reached.'));
|
|
68
|
-
},
|
|
65
|
+
}, this.options.ackTimeout);
|
|
69
66
|
};
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
this.logger.debug(`Sending message #${id}...`);
|
|
68
|
+
this.channel
|
|
69
|
+
.publish({ id: id, message: message })
|
|
70
|
+
.then(wait, abort);
|
|
72
71
|
});
|
|
73
|
-
}
|
|
74
|
-
|
|
72
|
+
}
|
|
73
|
+
close() {
|
|
75
74
|
this.closed = true;
|
|
76
75
|
return this.channel.close();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
}());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
80
78
|
exports.GuaranteedChannel = GuaranteedChannel;
|
package/channel/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SocketChannel = exports.SandboxChannel = exports.RetryChannel = exports.QueuedChannel = exports.GuaranteedChannel = exports.EncodedChannel = exports.BeaconSocketChannel = void 0;
|
|
4
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./channel"), exports);
|
|
6
6
|
var beaconSocketChannel_1 = require("./beaconSocketChannel");
|
|
7
7
|
Object.defineProperty(exports, "BeaconSocketChannel", { enumerable: true, get: function () { return beaconSocketChannel_1.BeaconSocketChannel; } });
|
package/channel/queuedChannel.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QueuedChannel = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function QueuedChannel(channel, queue, logger) {
|
|
4
|
+
const logging_1 = require("../logging");
|
|
5
|
+
class QueuedChannel {
|
|
6
|
+
constructor(channel, queue, logger) {
|
|
8
7
|
this.closed = false;
|
|
9
8
|
this.channel = channel;
|
|
10
9
|
this.queue = queue;
|
|
11
10
|
this.logger = logger !== null && logger !== void 0 ? logger : new logging_1.NullLogger();
|
|
12
11
|
}
|
|
13
|
-
|
|
12
|
+
flush() {
|
|
14
13
|
if (this.pending === undefined) {
|
|
15
14
|
return this.requeue();
|
|
16
15
|
}
|
|
17
16
|
return this.pending.catch(this.requeue.bind(this));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
var _this = this;
|
|
17
|
+
}
|
|
18
|
+
publish(message) {
|
|
21
19
|
if (this.closed) {
|
|
22
20
|
return Promise.reject(new Error('Channel is closed.'));
|
|
23
21
|
}
|
|
@@ -31,22 +29,22 @@ var QueuedChannel = /** @class */ (function () {
|
|
|
31
29
|
: Promise.reject(new Error('The queue must be flushed.'));
|
|
32
30
|
}
|
|
33
31
|
this.enqueue(message);
|
|
34
|
-
this.pending = this.pending.then(
|
|
32
|
+
this.pending = this.pending.then(() => this.channel
|
|
33
|
+
.publish(message)
|
|
34
|
+
.then(this.dequeue.bind(this)));
|
|
35
35
|
return this.pending;
|
|
36
|
-
}
|
|
37
|
-
|
|
36
|
+
}
|
|
37
|
+
enqueue(message) {
|
|
38
38
|
this.logger.debug('Enqueueing message...');
|
|
39
|
-
this.logger.debug(
|
|
39
|
+
this.logger.debug(`Queue length: ${this.queue.length() + 1}`);
|
|
40
40
|
this.queue.push(message);
|
|
41
|
-
}
|
|
42
|
-
|
|
41
|
+
}
|
|
42
|
+
dequeue() {
|
|
43
43
|
this.logger.debug('Dequeuing message...');
|
|
44
|
-
this.logger.debug(
|
|
44
|
+
this.logger.debug(`Queue length: ${Math.max(0, this.queue.length() - 1)}`);
|
|
45
45
|
this.queue.shift();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
var e_1, _a;
|
|
49
|
-
var _this = this;
|
|
46
|
+
}
|
|
47
|
+
requeue() {
|
|
50
48
|
if (this.closed) {
|
|
51
49
|
return Promise.reject(new Error('Channel is closed.'));
|
|
52
50
|
}
|
|
@@ -54,54 +52,27 @@ var QueuedChannel = /** @class */ (function () {
|
|
|
54
52
|
if (this.queue.isEmpty()) {
|
|
55
53
|
return this.pending;
|
|
56
54
|
}
|
|
57
|
-
|
|
55
|
+
const length = this.queue.length();
|
|
58
56
|
this.logger.debug('Requeuing messages...');
|
|
59
|
-
this.logger.debug(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
for (var _b = tslib_1.__values(this.queue.all()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
66
|
-
var message = _c.value;
|
|
67
|
-
_loop_1(message);
|
|
68
|
-
}
|
|
57
|
+
this.logger.debug(`Queue length: ${length}`);
|
|
58
|
+
for (const message of this.queue.all()) {
|
|
59
|
+
this.pending = this.pending.then(() => this.channel
|
|
60
|
+
.publish(message)
|
|
61
|
+
.then(this.dequeue.bind(this)));
|
|
69
62
|
}
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
return this.pending;
|
|
64
|
+
}
|
|
65
|
+
async close() {
|
|
66
|
+
this.closed = true;
|
|
67
|
+
await this.channel.close();
|
|
68
|
+
if (this.pending !== undefined) {
|
|
72
69
|
try {
|
|
73
|
-
|
|
70
|
+
await this.pending;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// suppress errors
|
|
74
74
|
}
|
|
75
|
-
finally { if (e_1) throw e_1.error; }
|
|
76
75
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
QueuedChannel.prototype.close = function () {
|
|
80
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
81
|
-
var _a;
|
|
82
|
-
return tslib_1.__generator(this, function (_b) {
|
|
83
|
-
switch (_b.label) {
|
|
84
|
-
case 0:
|
|
85
|
-
this.closed = true;
|
|
86
|
-
return [4 /*yield*/, this.channel.close()];
|
|
87
|
-
case 1:
|
|
88
|
-
_b.sent();
|
|
89
|
-
if (!(this.pending !== undefined)) return [3 /*break*/, 5];
|
|
90
|
-
_b.label = 2;
|
|
91
|
-
case 2:
|
|
92
|
-
_b.trys.push([2, 4, , 5]);
|
|
93
|
-
return [4 /*yield*/, this.pending];
|
|
94
|
-
case 3:
|
|
95
|
-
_b.sent();
|
|
96
|
-
return [3 /*break*/, 5];
|
|
97
|
-
case 4:
|
|
98
|
-
_a = _b.sent();
|
|
99
|
-
return [3 /*break*/, 5];
|
|
100
|
-
case 5: return [2 /*return*/];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
return QueuedChannel;
|
|
106
|
-
}());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
107
78
|
exports.QueuedChannel = QueuedChannel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OutputChannel } from './channel';
|
|
2
2
|
import { Logger } from '../logging';
|
|
3
3
|
import { RetryPolicy } from '../retry';
|
|
4
|
-
|
|
4
|
+
type Configuration<T> = {
|
|
5
5
|
channel: OutputChannel<T>;
|
|
6
6
|
retryPolicy: RetryPolicy<T>;
|
|
7
7
|
logger?: Logger;
|
package/channel/retryChannel.js
CHANGED
|
@@ -1,91 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RetryChannel = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function RetryChannel(_a) {
|
|
8
|
-
var channel = _a.channel, retryPolicy = _a.retryPolicy, logger = _a.logger;
|
|
4
|
+
const logging_1 = require("../logging");
|
|
5
|
+
class RetryChannel {
|
|
6
|
+
constructor({ channel, retryPolicy, logger }) {
|
|
9
7
|
this.closed = false;
|
|
10
8
|
this.channel = channel;
|
|
11
9
|
this.retryPolicy = retryPolicy;
|
|
12
10
|
this.logger = logger !== null && logger !== void 0 ? logger : new logging_1.NullLogger();
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
var _this = this;
|
|
12
|
+
publish(message) {
|
|
16
13
|
if (this.closed) {
|
|
17
14
|
return Promise.reject(new Error('The channel is closed.'));
|
|
18
15
|
}
|
|
19
|
-
return this.channel
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
case 2:
|
|
58
|
-
_d.trys.push([2, 4, , 5]);
|
|
59
|
-
_b = {};
|
|
60
|
-
return [4 /*yield*/, this_1.channel.publish(message)];
|
|
61
|
-
case 3: return [2 /*return*/, (_b.value = _d.sent(), _b)];
|
|
62
|
-
case 4:
|
|
63
|
-
_c = _d.sent();
|
|
64
|
-
attempt += 1;
|
|
65
|
-
return [3 /*break*/, 5];
|
|
66
|
-
case 5: return [2 /*return*/];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
this_1 = this;
|
|
71
|
-
_a.label = 1;
|
|
72
|
-
case 1:
|
|
73
|
-
if (!this.retryPolicy.shouldRetry(attempt, message, error)) return [3 /*break*/, 3];
|
|
74
|
-
return [5 /*yield**/, _loop_1()];
|
|
75
|
-
case 2:
|
|
76
|
-
state_1 = _a.sent();
|
|
77
|
-
if (typeof state_1 === "object")
|
|
78
|
-
return [2 /*return*/, state_1.value];
|
|
79
|
-
return [3 /*break*/, 1];
|
|
80
|
-
case 3: throw new Error('Maximum retry attempts reached.');
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
RetryChannel.prototype.close = function () {
|
|
16
|
+
return this.channel
|
|
17
|
+
.publish(message)
|
|
18
|
+
.catch(error => this.retry(message, error));
|
|
19
|
+
}
|
|
20
|
+
async retry(message, error) {
|
|
21
|
+
let attempt = 0;
|
|
22
|
+
while (this.retryPolicy.shouldRetry(attempt, message, error)) {
|
|
23
|
+
if (this.closed) {
|
|
24
|
+
throw new Error('Connection deliberately closed.');
|
|
25
|
+
}
|
|
26
|
+
const delay = this.retryPolicy.getDelay(attempt);
|
|
27
|
+
this.logger.debug(`Retry attempt ${attempt + 1}`);
|
|
28
|
+
if (delay > 0) {
|
|
29
|
+
this.logger.debug(`Retry attempt delayed in ${delay}ms`);
|
|
30
|
+
await new Promise((resolve, reject) => {
|
|
31
|
+
const closeWatcher = window.setInterval(() => {
|
|
32
|
+
if (this.closed) {
|
|
33
|
+
// Cancel delay immediately when the channel is closed
|
|
34
|
+
window.clearInterval(closeWatcher);
|
|
35
|
+
reject(new Error('Connection deliberately closed.'));
|
|
36
|
+
}
|
|
37
|
+
}, 0);
|
|
38
|
+
window.setTimeout(() => {
|
|
39
|
+
window.clearInterval(closeWatcher);
|
|
40
|
+
resolve();
|
|
41
|
+
}, delay);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
return await this.channel.publish(message);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
attempt += 1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
throw new Error('Maximum retry attempts reached.');
|
|
52
|
+
}
|
|
53
|
+
close() {
|
|
86
54
|
this.closed = true;
|
|
87
55
|
return this.channel.close();
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
}());
|
|
56
|
+
}
|
|
57
|
+
}
|
|
91
58
|
exports.RetryChannel = RetryChannel;
|
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SandboxChannel = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class SandboxChannel {
|
|
5
|
+
constructor() {
|
|
6
6
|
this.listeners = [];
|
|
7
7
|
this.messages = [];
|
|
8
8
|
this.closed = false;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
publish(message) {
|
|
11
11
|
this.messages.push(message);
|
|
12
12
|
return Promise.resolve();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
this.listeners.forEach(
|
|
16
|
-
}
|
|
17
|
-
|
|
13
|
+
}
|
|
14
|
+
notify(message) {
|
|
15
|
+
this.listeners.forEach(dispatch => dispatch(message));
|
|
16
|
+
}
|
|
17
|
+
subscribe(listener) {
|
|
18
18
|
if (!this.listeners.includes(listener)) {
|
|
19
19
|
this.listeners.push(listener);
|
|
20
20
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
}
|
|
22
|
+
unsubscribe(listener) {
|
|
23
|
+
const index = this.listeners.indexOf(listener);
|
|
24
24
|
if (index >= 0) {
|
|
25
25
|
this.listeners.splice(index, 1);
|
|
26
26
|
}
|
|
27
|
-
}
|
|
28
|
-
|
|
27
|
+
}
|
|
28
|
+
close() {
|
|
29
29
|
this.closed = true;
|
|
30
30
|
return Promise.resolve();
|
|
31
|
-
}
|
|
32
|
-
|
|
31
|
+
}
|
|
32
|
+
isClosed() {
|
|
33
33
|
return this.closed;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
}());
|
|
34
|
+
}
|
|
35
|
+
}
|
|
37
36
|
exports.SandboxChannel = SandboxChannel;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Logger } from '../logging';
|
|
2
2
|
import { ChannelListener, DuplexChannel } from './channel';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
type Input = string | ArrayBufferLike | Blob | ArrayBufferView;
|
|
4
|
+
type Output = string | ArrayBuffer | Blob;
|
|
5
|
+
type Options = {
|
|
6
6
|
closeTimeout: number;
|
|
7
7
|
connectionTimeout: number;
|
|
8
8
|
protocols: string | string[];
|
|
9
9
|
binaryType?: BinaryType;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type Configuration = Partial<Options> & {
|
|
12
12
|
url: string;
|
|
13
13
|
logger?: Logger;
|
|
14
14
|
};
|