centrifuge 5.2.0 → 5.2.2
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 +1 -1
- package/build/centrifuge.d.ts +1 -1
- package/build/index.js +78 -59
- package/build/index.mjs +78 -59
- package/build/protobuf/centrifuge.d.ts +1 -1
- package/build/protobuf/index.js +81 -62
- package/build/protobuf/index.mjs +81 -62
- package/build/protobuf/subscription.d.ts +1 -0
- package/build/subscription.d.ts +1 -0
- package/dist/centrifuge.js +3 -3
- package/dist/centrifuge.js.map +3 -3
- package/dist/centrifuge.protobuf.js +4 -4
- package/dist/centrifuge.protobuf.js.map +3 -3
- package/package.json +1 -1
package/build/protobuf/index.js
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
/******************************************************************************
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
***************************************************************************** */
|
|
17
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
21
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
31
|
+
var e = new Error(message);
|
|
32
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
33
|
+
};
|
|
34
|
+
|
|
3
35
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
4
36
|
|
|
5
37
|
function getDefaultExportFromCjs (x) {
|
|
@@ -616,6 +648,7 @@ class Subscription extends EventEmitter$2 {
|
|
|
616
648
|
this._delta = '';
|
|
617
649
|
this._delta_negotiated = false;
|
|
618
650
|
this._prevValue = null;
|
|
651
|
+
this._unsubPromise = Promise.resolve();
|
|
619
652
|
this._setOptions(options);
|
|
620
653
|
// @ts-ignore – we are hiding some symbols from public API autocompletion.
|
|
621
654
|
if (this._centrifuge._debugEnabled) {
|
|
@@ -666,7 +699,7 @@ class Subscription extends EventEmitter$2 {
|
|
|
666
699
|
}
|
|
667
700
|
/** unsubscribe from a channel, keeping position state.*/
|
|
668
701
|
unsubscribe() {
|
|
669
|
-
this._setUnsubscribed(exports.unsubscribedCodes.unsubscribeCalled, 'unsubscribe called', true);
|
|
702
|
+
this._unsubPromise = this._setUnsubscribed(exports.unsubscribedCodes.unsubscribeCalled, 'unsubscribe called', true);
|
|
670
703
|
}
|
|
671
704
|
/** publish data to a channel.*/
|
|
672
705
|
publish(data) {
|
|
@@ -785,16 +818,25 @@ class Subscription extends EventEmitter$2 {
|
|
|
785
818
|
}
|
|
786
819
|
}
|
|
787
820
|
_setSubscribing(code, reason) {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
this.
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
this.
|
|
796
|
-
|
|
797
|
-
|
|
821
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
822
|
+
if (this._isSubscribing()) {
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
if (this._isSubscribed()) {
|
|
826
|
+
this._clearSubscribedState();
|
|
827
|
+
}
|
|
828
|
+
if (this._setState(exports.SubscriptionState.Subscribing)) {
|
|
829
|
+
this.emit('subscribing', { channel: this.channel, code: code, reason: reason });
|
|
830
|
+
}
|
|
831
|
+
// @ts-ignore – for performance reasons only await _unsubPromise for emulution case where it's required.
|
|
832
|
+
if (this._centrifuge._transport && this._centrifuge._transport.emulation()) {
|
|
833
|
+
yield this._unsubPromise;
|
|
834
|
+
}
|
|
835
|
+
if (!this._isSubscribing()) {
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
this._subscribe();
|
|
839
|
+
});
|
|
798
840
|
}
|
|
799
841
|
_subscribe() {
|
|
800
842
|
// @ts-ignore – we are hiding some symbols from public API autocompletion.
|
|
@@ -949,19 +991,20 @@ class Subscription extends EventEmitter$2 {
|
|
|
949
991
|
}
|
|
950
992
|
_setUnsubscribed(code, reason, sendUnsubscribe) {
|
|
951
993
|
if (this._isUnsubscribed()) {
|
|
952
|
-
return;
|
|
994
|
+
return Promise.resolve();
|
|
953
995
|
}
|
|
996
|
+
let promise = Promise.resolve();
|
|
954
997
|
if (this._isSubscribed()) {
|
|
955
998
|
if (sendUnsubscribe) {
|
|
956
999
|
// @ts-ignore – we are hiding some methods from public API autocompletion.
|
|
957
|
-
this._centrifuge._unsubscribe(this);
|
|
1000
|
+
promise = this._centrifuge._unsubscribe(this);
|
|
958
1001
|
}
|
|
959
1002
|
this._clearSubscribedState();
|
|
960
1003
|
}
|
|
961
|
-
if (this._isSubscribing()) {
|
|
1004
|
+
else if (this._isSubscribing()) {
|
|
962
1005
|
if (this._inflight && sendUnsubscribe) {
|
|
963
1006
|
// @ts-ignore – we are hiding some methods from public API autocompletion.
|
|
964
|
-
this._centrifuge._unsubscribe(this);
|
|
1007
|
+
promise = this._centrifuge._unsubscribe(this);
|
|
965
1008
|
}
|
|
966
1009
|
this._clearSubscribingState();
|
|
967
1010
|
}
|
|
@@ -969,6 +1012,7 @@ class Subscription extends EventEmitter$2 {
|
|
|
969
1012
|
this.emit('unsubscribed', { channel: this.channel, code: code, reason: reason });
|
|
970
1013
|
}
|
|
971
1014
|
this._rejectPromises({ code: exports.errorCodes.subscriptionUnsubscribed, message: this.state });
|
|
1015
|
+
return promise;
|
|
972
1016
|
}
|
|
973
1017
|
_handlePublication(pub) {
|
|
974
1018
|
if (this._delta && this._delta_negotiated) {
|
|
@@ -1607,38 +1651,6 @@ class SseTransport {
|
|
|
1607
1651
|
}
|
|
1608
1652
|
}
|
|
1609
1653
|
|
|
1610
|
-
/******************************************************************************
|
|
1611
|
-
Copyright (c) Microsoft Corporation.
|
|
1612
|
-
|
|
1613
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
1614
|
-
purpose with or without fee is hereby granted.
|
|
1615
|
-
|
|
1616
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1617
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1618
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1619
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1620
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1621
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1622
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
1623
|
-
***************************************************************************** */
|
|
1624
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1628
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1629
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1630
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1631
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1632
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1633
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1634
|
-
});
|
|
1635
|
-
}
|
|
1636
|
-
|
|
1637
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1638
|
-
var e = new Error(message);
|
|
1639
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1640
|
-
};
|
|
1641
|
-
|
|
1642
1654
|
/** @internal */
|
|
1643
1655
|
class WebtransportTransport {
|
|
1644
1656
|
constructor(endpoint, options) {
|
|
@@ -1864,7 +1876,9 @@ let Writer$2 = class Writer {
|
|
|
1864
1876
|
}
|
|
1865
1877
|
// Copy from array at start to end.
|
|
1866
1878
|
putArray(a, start, end) {
|
|
1867
|
-
|
|
1879
|
+
// TODO: optimize.
|
|
1880
|
+
for (let i = start; i < end; i++)
|
|
1881
|
+
this.a.push(a[i]);
|
|
1868
1882
|
}
|
|
1869
1883
|
};
|
|
1870
1884
|
// Return a 32-bit checksum of the array.
|
|
@@ -3204,25 +3218,30 @@ class Centrifuge extends EventEmitter$2 {
|
|
|
3204
3218
|
}
|
|
3205
3219
|
_unsubscribe(sub) {
|
|
3206
3220
|
if (!this._transportIsOpen) {
|
|
3207
|
-
return;
|
|
3221
|
+
return Promise.resolve();
|
|
3208
3222
|
}
|
|
3209
3223
|
const req = {
|
|
3210
3224
|
channel: sub.channel
|
|
3211
3225
|
};
|
|
3212
3226
|
const cmd = { unsubscribe: req };
|
|
3213
3227
|
const self = this;
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3228
|
+
const unsubscribePromise = new Promise((resolve, _) => {
|
|
3229
|
+
this._call(cmd, false).then(resolveCtx => {
|
|
3230
|
+
resolve();
|
|
3217
3231
|
// @ts-ignore - improve later.
|
|
3218
|
-
resolveCtx.next
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3232
|
+
if (resolveCtx.next) {
|
|
3233
|
+
// @ts-ignore - improve later.
|
|
3234
|
+
resolveCtx.next();
|
|
3235
|
+
}
|
|
3236
|
+
}, rejectCtx => {
|
|
3237
|
+
resolve();
|
|
3238
|
+
if (rejectCtx.next) {
|
|
3239
|
+
rejectCtx.next();
|
|
3240
|
+
}
|
|
3241
|
+
self._disconnect(exports.connectingCodes.unsubscribeError, 'unsubscribe error', true);
|
|
3242
|
+
});
|
|
3225
3243
|
});
|
|
3244
|
+
return unsubscribePromise;
|
|
3226
3245
|
}
|
|
3227
3246
|
_getSub(channel) {
|
|
3228
3247
|
const sub = this._subs[channel];
|
|
@@ -11935,9 +11954,9 @@ var client_proto = {
|
|
|
11935
11954
|
};
|
|
11936
11955
|
|
|
11937
11956
|
var protoJSON = /*#__PURE__*/Object.freeze({
|
|
11938
|
-
|
|
11939
|
-
|
|
11940
|
-
|
|
11957
|
+
__proto__: null,
|
|
11958
|
+
default: client_proto,
|
|
11959
|
+
nested: nested
|
|
11941
11960
|
});
|
|
11942
11961
|
|
|
11943
11962
|
const proto = light.Root.fromJSON(protoJSON);
|
package/build/protobuf/index.mjs
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
19
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
20
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
21
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
22
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
23
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
24
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
29
|
+
var e = new Error(message);
|
|
30
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
31
|
+
};
|
|
32
|
+
|
|
1
33
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2
34
|
|
|
3
35
|
function getDefaultExportFromCjs (x) {
|
|
@@ -614,6 +646,7 @@ class Subscription extends EventEmitter$2 {
|
|
|
614
646
|
this._delta = '';
|
|
615
647
|
this._delta_negotiated = false;
|
|
616
648
|
this._prevValue = null;
|
|
649
|
+
this._unsubPromise = Promise.resolve();
|
|
617
650
|
this._setOptions(options);
|
|
618
651
|
// @ts-ignore – we are hiding some symbols from public API autocompletion.
|
|
619
652
|
if (this._centrifuge._debugEnabled) {
|
|
@@ -664,7 +697,7 @@ class Subscription extends EventEmitter$2 {
|
|
|
664
697
|
}
|
|
665
698
|
/** unsubscribe from a channel, keeping position state.*/
|
|
666
699
|
unsubscribe() {
|
|
667
|
-
this._setUnsubscribed(unsubscribedCodes.unsubscribeCalled, 'unsubscribe called', true);
|
|
700
|
+
this._unsubPromise = this._setUnsubscribed(unsubscribedCodes.unsubscribeCalled, 'unsubscribe called', true);
|
|
668
701
|
}
|
|
669
702
|
/** publish data to a channel.*/
|
|
670
703
|
publish(data) {
|
|
@@ -783,16 +816,25 @@ class Subscription extends EventEmitter$2 {
|
|
|
783
816
|
}
|
|
784
817
|
}
|
|
785
818
|
_setSubscribing(code, reason) {
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
this.
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
this.
|
|
794
|
-
|
|
795
|
-
|
|
819
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
820
|
+
if (this._isSubscribing()) {
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
if (this._isSubscribed()) {
|
|
824
|
+
this._clearSubscribedState();
|
|
825
|
+
}
|
|
826
|
+
if (this._setState(SubscriptionState.Subscribing)) {
|
|
827
|
+
this.emit('subscribing', { channel: this.channel, code: code, reason: reason });
|
|
828
|
+
}
|
|
829
|
+
// @ts-ignore – for performance reasons only await _unsubPromise for emulution case where it's required.
|
|
830
|
+
if (this._centrifuge._transport && this._centrifuge._transport.emulation()) {
|
|
831
|
+
yield this._unsubPromise;
|
|
832
|
+
}
|
|
833
|
+
if (!this._isSubscribing()) {
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
this._subscribe();
|
|
837
|
+
});
|
|
796
838
|
}
|
|
797
839
|
_subscribe() {
|
|
798
840
|
// @ts-ignore – we are hiding some symbols from public API autocompletion.
|
|
@@ -947,19 +989,20 @@ class Subscription extends EventEmitter$2 {
|
|
|
947
989
|
}
|
|
948
990
|
_setUnsubscribed(code, reason, sendUnsubscribe) {
|
|
949
991
|
if (this._isUnsubscribed()) {
|
|
950
|
-
return;
|
|
992
|
+
return Promise.resolve();
|
|
951
993
|
}
|
|
994
|
+
let promise = Promise.resolve();
|
|
952
995
|
if (this._isSubscribed()) {
|
|
953
996
|
if (sendUnsubscribe) {
|
|
954
997
|
// @ts-ignore – we are hiding some methods from public API autocompletion.
|
|
955
|
-
this._centrifuge._unsubscribe(this);
|
|
998
|
+
promise = this._centrifuge._unsubscribe(this);
|
|
956
999
|
}
|
|
957
1000
|
this._clearSubscribedState();
|
|
958
1001
|
}
|
|
959
|
-
if (this._isSubscribing()) {
|
|
1002
|
+
else if (this._isSubscribing()) {
|
|
960
1003
|
if (this._inflight && sendUnsubscribe) {
|
|
961
1004
|
// @ts-ignore – we are hiding some methods from public API autocompletion.
|
|
962
|
-
this._centrifuge._unsubscribe(this);
|
|
1005
|
+
promise = this._centrifuge._unsubscribe(this);
|
|
963
1006
|
}
|
|
964
1007
|
this._clearSubscribingState();
|
|
965
1008
|
}
|
|
@@ -967,6 +1010,7 @@ class Subscription extends EventEmitter$2 {
|
|
|
967
1010
|
this.emit('unsubscribed', { channel: this.channel, code: code, reason: reason });
|
|
968
1011
|
}
|
|
969
1012
|
this._rejectPromises({ code: errorCodes.subscriptionUnsubscribed, message: this.state });
|
|
1013
|
+
return promise;
|
|
970
1014
|
}
|
|
971
1015
|
_handlePublication(pub) {
|
|
972
1016
|
if (this._delta && this._delta_negotiated) {
|
|
@@ -1605,38 +1649,6 @@ class SseTransport {
|
|
|
1605
1649
|
}
|
|
1606
1650
|
}
|
|
1607
1651
|
|
|
1608
|
-
/******************************************************************************
|
|
1609
|
-
Copyright (c) Microsoft Corporation.
|
|
1610
|
-
|
|
1611
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
1612
|
-
purpose with or without fee is hereby granted.
|
|
1613
|
-
|
|
1614
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1615
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1616
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1617
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1618
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1619
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1620
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
1621
|
-
***************************************************************************** */
|
|
1622
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1626
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1627
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1628
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1629
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1630
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1631
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1632
|
-
});
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1636
|
-
var e = new Error(message);
|
|
1637
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1638
|
-
};
|
|
1639
|
-
|
|
1640
1652
|
/** @internal */
|
|
1641
1653
|
class WebtransportTransport {
|
|
1642
1654
|
constructor(endpoint, options) {
|
|
@@ -1862,7 +1874,9 @@ let Writer$2 = class Writer {
|
|
|
1862
1874
|
}
|
|
1863
1875
|
// Copy from array at start to end.
|
|
1864
1876
|
putArray(a, start, end) {
|
|
1865
|
-
|
|
1877
|
+
// TODO: optimize.
|
|
1878
|
+
for (let i = start; i < end; i++)
|
|
1879
|
+
this.a.push(a[i]);
|
|
1866
1880
|
}
|
|
1867
1881
|
};
|
|
1868
1882
|
// Return a 32-bit checksum of the array.
|
|
@@ -3202,25 +3216,30 @@ class Centrifuge extends EventEmitter$2 {
|
|
|
3202
3216
|
}
|
|
3203
3217
|
_unsubscribe(sub) {
|
|
3204
3218
|
if (!this._transportIsOpen) {
|
|
3205
|
-
return;
|
|
3219
|
+
return Promise.resolve();
|
|
3206
3220
|
}
|
|
3207
3221
|
const req = {
|
|
3208
3222
|
channel: sub.channel
|
|
3209
3223
|
};
|
|
3210
3224
|
const cmd = { unsubscribe: req };
|
|
3211
3225
|
const self = this;
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3226
|
+
const unsubscribePromise = new Promise((resolve, _) => {
|
|
3227
|
+
this._call(cmd, false).then(resolveCtx => {
|
|
3228
|
+
resolve();
|
|
3215
3229
|
// @ts-ignore - improve later.
|
|
3216
|
-
resolveCtx.next
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3230
|
+
if (resolveCtx.next) {
|
|
3231
|
+
// @ts-ignore - improve later.
|
|
3232
|
+
resolveCtx.next();
|
|
3233
|
+
}
|
|
3234
|
+
}, rejectCtx => {
|
|
3235
|
+
resolve();
|
|
3236
|
+
if (rejectCtx.next) {
|
|
3237
|
+
rejectCtx.next();
|
|
3238
|
+
}
|
|
3239
|
+
self._disconnect(connectingCodes.unsubscribeError, 'unsubscribe error', true);
|
|
3240
|
+
});
|
|
3223
3241
|
});
|
|
3242
|
+
return unsubscribePromise;
|
|
3224
3243
|
}
|
|
3225
3244
|
_getSub(channel) {
|
|
3226
3245
|
const sub = this._subs[channel];
|
|
@@ -11933,9 +11952,9 @@ var client_proto = {
|
|
|
11933
11952
|
};
|
|
11934
11953
|
|
|
11935
11954
|
var protoJSON = /*#__PURE__*/Object.freeze({
|
|
11936
|
-
|
|
11937
|
-
|
|
11938
|
-
|
|
11955
|
+
__proto__: null,
|
|
11956
|
+
default: client_proto,
|
|
11957
|
+
nested: nested
|
|
11939
11958
|
});
|
|
11940
11959
|
|
|
11941
11960
|
const proto = light.Root.fromJSON(protoJSON);
|
|
@@ -27,6 +27,7 @@ export declare class Subscription extends Subscription_base {
|
|
|
27
27
|
private _joinLeave;
|
|
28
28
|
private _inflight;
|
|
29
29
|
private _prevValue;
|
|
30
|
+
private _unsubPromise;
|
|
30
31
|
/** Subscription constructor should not be used directly, create subscriptions using Client method. */
|
|
31
32
|
constructor(centrifuge: Centrifuge, channel: string, options?: Partial<SubscriptionOptions>);
|
|
32
33
|
/** ready returns a Promise which resolves upon subscription goes to Subscribed
|
package/build/subscription.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare class Subscription extends Subscription_base {
|
|
|
27
27
|
private _joinLeave;
|
|
28
28
|
private _inflight;
|
|
29
29
|
private _prevValue;
|
|
30
|
+
private _unsubPromise;
|
|
30
31
|
/** Subscription constructor should not be used directly, create subscriptions using Client method. */
|
|
31
32
|
constructor(centrifuge: Centrifuge, channel: string, options?: Partial<SubscriptionOptions>);
|
|
32
33
|
/** ready returns a Promise which resolves upon subscription goes to Subscribed
|