polfan-server-js-client 0.2.107 → 0.2.109
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/.idea/shelf/Uncommitted_changes_before_Checkout_at_26_07_2026_21_26_[Changes]/shelved.patch +174 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_26_07_2026_21_26__Changes_.xml +4 -0
- package/.idea/workspace.xml +21 -13
- package/build/index.cjs.js +110 -524
- package/build/index.cjs.js.map +1 -1
- package/build/index.umd.js +1 -1
- package/build/index.umd.js.map +1 -1
- package/build/types/AbstractChatClient.d.ts +0 -10
- package/build/types/IndexedObjectCollection.d.ts +0 -8
- package/build/types/WebSocketChatClient.d.ts +1 -17
- package/build/types/index.d.ts +2 -1
- package/build/types/state-tracker/FollowedTopicsManager.d.ts +6 -22
- package/build/types/state-tracker/RoomMessagesHistory.d.ts +0 -12
- package/build/types/state-tracker/TopicHistoryWindow.d.ts +2 -2
- package/package.json +1 -1
- package/src/AbstractChatClient.ts +0 -22
- package/src/IndexedObjectCollection.ts +0 -31
- package/src/WebSocketChatClient.ts +7 -63
- package/src/index.ts +2 -0
- package/src/state-tracker/AsyncUtils.ts +0 -11
- package/src/state-tracker/EmoticonsManager.ts +3 -7
- package/src/state-tracker/FollowedTopicsManager.ts +17 -59
- package/src/state-tracker/MessagesManager.ts +2 -21
- package/src/state-tracker/PermissionsManager.ts +1 -5
- package/src/state-tracker/RelationshipsManager.ts +5 -5
- package/src/state-tracker/RoomMessagesHistory.ts +1 -41
- package/src/state-tracker/RoomsManager.ts +4 -21
- package/src/state-tracker/SpacesManager.ts +8 -35
- package/src/state-tracker/TopicHistoryWindow.ts +4 -4
- package/src/state-tracker/UsersManager.ts +1 -3
- package/tests/collections.test.ts +0 -92
- package/tests/pending-commands.test.ts +0 -171
- package/tests/state-reconnect.test.ts +0 -257
package/build/index.cjs.js
CHANGED
|
@@ -118,12 +118,6 @@ var EventTarget = /*#__PURE__*/function () {
|
|
|
118
118
|
}();
|
|
119
119
|
;// ./src/AbstractChatClient.ts
|
|
120
120
|
function AbstractChatClient_typeof(o) { "@babel/helpers - typeof"; return AbstractChatClient_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, AbstractChatClient_typeof(o); }
|
|
121
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
122
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
123
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
124
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
125
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
126
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
127
121
|
function AbstractChatClient_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
128
122
|
function AbstractChatClient_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, AbstractChatClient_toPropertyKey(o.key), o); } }
|
|
129
123
|
function AbstractChatClient_createClass(e, r, t) { return r && AbstractChatClient_defineProperties(e.prototype, r), t && AbstractChatClient_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -193,30 +187,6 @@ var AbstractChatClient = /*#__PURE__*/function (_EventTarget) {
|
|
|
193
187
|
this.awaitingResponse.get(envelope.ref)[1](error);
|
|
194
188
|
this.awaitingResponse["delete"](envelope.ref);
|
|
195
189
|
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Reject every command that is still waiting for a response.
|
|
199
|
-
*
|
|
200
|
-
* Call this whenever the transport can no longer deliver an answer (the
|
|
201
|
-
* connection dropped). The server will never reply to those commands, so
|
|
202
|
-
* leaving them pending would hang every caller awaiting them forever -
|
|
203
|
-
* including cached lookups in the state tracker, which would then keep a
|
|
204
|
-
* view stuck on a loader even after a successful reconnect.
|
|
205
|
-
*/
|
|
206
|
-
}, {
|
|
207
|
-
key: "failAwaitingResponses",
|
|
208
|
-
value: function failAwaitingResponses(error) {
|
|
209
|
-
if (!this.awaitingResponse.size) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
var pending = Array.from(this.awaitingResponse.values());
|
|
213
|
-
this.awaitingResponse.clear();
|
|
214
|
-
for (var _i = 0, _pending = pending; _i < _pending.length; _i++) {
|
|
215
|
-
var _pending$_i = _slicedToArray(_pending[_i], 2),
|
|
216
|
-
reject = _pending$_i[1];
|
|
217
|
-
reject(error);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
190
|
}]);
|
|
221
191
|
}(EventTarget);
|
|
222
192
|
|
|
@@ -239,17 +209,17 @@ function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !==
|
|
|
239
209
|
function IndexedObjectCollection_getPrototypeOf(t) { return IndexedObjectCollection_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, IndexedObjectCollection_getPrototypeOf(t); }
|
|
240
210
|
function IndexedObjectCollection_inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && IndexedObjectCollection_setPrototypeOf(t, e); }
|
|
241
211
|
function IndexedObjectCollection_setPrototypeOf(t, e) { return IndexedObjectCollection_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, IndexedObjectCollection_setPrototypeOf(t, e); }
|
|
242
|
-
function
|
|
243
|
-
function
|
|
244
|
-
function
|
|
245
|
-
function
|
|
246
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t =
|
|
247
|
-
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) ||
|
|
212
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
213
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
214
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
215
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
216
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
217
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
248
218
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
249
|
-
function
|
|
219
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
250
220
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
251
|
-
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return
|
|
252
|
-
function
|
|
221
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
222
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
253
223
|
function IndexedObjectCollection_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
254
224
|
function IndexedObjectCollection_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, IndexedObjectCollection_toPropertyKey(o.key), o); } }
|
|
255
225
|
function IndexedObjectCollection_createClass(e, r, t) { return r && IndexedObjectCollection_defineProperties(e.prototype, r), t && IndexedObjectCollection_defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -320,7 +290,7 @@ var IndexedCollection = /*#__PURE__*/function () {
|
|
|
320
290
|
_step;
|
|
321
291
|
try {
|
|
322
292
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
323
|
-
var _step$value =
|
|
293
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
324
294
|
key = _step$value[0],
|
|
325
295
|
value = _step$value[1];
|
|
326
296
|
if (result.length >= limit) {
|
|
@@ -577,53 +547,6 @@ var ObservableIndexedObjectCollection = /*#__PURE__*/function (_IndexedObjectCol
|
|
|
577
547
|
});
|
|
578
548
|
}
|
|
579
549
|
}
|
|
580
|
-
|
|
581
|
-
/**
|
|
582
|
-
* Bring the collection to exactly match the provided items: upsert every
|
|
583
|
-
* provided item and remove any existing item whose id is not present in the
|
|
584
|
-
* provided set. Emits at most a single `change` event describing both the
|
|
585
|
-
* set and the deleted ids, so bound consumers can update in place without
|
|
586
|
-
* ever observing an intermediate empty state (unlike deleteAll + set).
|
|
587
|
-
*/
|
|
588
|
-
}, {
|
|
589
|
-
key: "reconcile",
|
|
590
|
-
value: function reconcile() {
|
|
591
|
-
var _this8 = this,
|
|
592
|
-
_this$_items3;
|
|
593
|
-
for (var _len8 = arguments.length, items = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
594
|
-
items[_key8] = arguments[_key8];
|
|
595
|
-
}
|
|
596
|
-
var incomingIds = new Set(items.map(function (item) {
|
|
597
|
-
return _this8.getId(item);
|
|
598
|
-
}));
|
|
599
|
-
var deletedItems = [];
|
|
600
|
-
var _iterator3 = _createForOfIteratorHelper(this.items),
|
|
601
|
-
_step3;
|
|
602
|
-
try {
|
|
603
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
604
|
-
var existing = _step3.value;
|
|
605
|
-
var _id2 = this.getId(existing);
|
|
606
|
-
if (!incomingIds.has(_id2)) {
|
|
607
|
-
deletedItems.push(_id2);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
} catch (err) {
|
|
611
|
-
_iterator3.e(err);
|
|
612
|
-
} finally {
|
|
613
|
-
_iterator3.f();
|
|
614
|
-
}
|
|
615
|
-
if (!items.length && !deletedItems.length) {
|
|
616
|
-
return;
|
|
617
|
-
}
|
|
618
|
-
(_this$_items3 = this._items)["delete"].apply(_this$_items3, deletedItems);
|
|
619
|
-
_superPropGet(ObservableIndexedObjectCollection, "set", this, 3)(items);
|
|
620
|
-
this.eventTarget.emit('change', {
|
|
621
|
-
setItems: items.map(function (item) {
|
|
622
|
-
return _this8.getId(item);
|
|
623
|
-
}),
|
|
624
|
-
deletedItems: deletedItems
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
550
|
}, {
|
|
628
551
|
key: "createMirror",
|
|
629
552
|
value: function createMirror() {
|
|
@@ -678,19 +601,7 @@ var PromiseRegistry = /*#__PURE__*/function () {
|
|
|
678
601
|
return AsyncUtils_createClass(PromiseRegistry, [{
|
|
679
602
|
key: "register",
|
|
680
603
|
value: function register(promise, key) {
|
|
681
|
-
var _this2 = this;
|
|
682
604
|
this.promises.set([key, promise]);
|
|
683
|
-
|
|
684
|
-
// Never cache a failed lookup: drop it so the next access retries
|
|
685
|
-
// instead of replaying the same rejection forever (a request issued
|
|
686
|
-
// while the client was offline would otherwise poison the key). The
|
|
687
|
-
// handler also keeps the cached promise from surfacing as an unhandled
|
|
688
|
-
// rejection - callers still receive the rejection from their own await.
|
|
689
|
-
promise["catch"](function () {
|
|
690
|
-
if (_this2.promises.get(key) === promise) {
|
|
691
|
-
_this2.promises["delete"](key);
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
605
|
}
|
|
695
606
|
}, {
|
|
696
607
|
key: "registerByFunction",
|
|
@@ -870,15 +781,11 @@ var TraversableRemoteCollection = /*#__PURE__*/function (_ObservableIndexedObj)
|
|
|
870
781
|
key: "resetToLatest",
|
|
871
782
|
value: function () {
|
|
872
783
|
var _resetToLatest = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
873
|
-
var
|
|
874
|
-
result,
|
|
875
|
-
originalState,
|
|
876
|
-
_args = arguments;
|
|
784
|
+
var result, originalState;
|
|
877
785
|
return _regenerator().w(function (_context) {
|
|
878
786
|
while (1) switch (_context.p = _context.n) {
|
|
879
787
|
case 0:
|
|
880
|
-
|
|
881
|
-
if (!(this.internalState.ongoing || !force && this.internalState.current === WindowState.LATEST)) {
|
|
788
|
+
if (!(this.internalState.ongoing || this.internalState.current === WindowState.LATEST)) {
|
|
882
789
|
_context.n = 1;
|
|
883
790
|
break;
|
|
884
791
|
}
|
|
@@ -1226,19 +1133,16 @@ var TopicHistoryWindow = /*#__PURE__*/function (_TraversableRemoteCol) {
|
|
|
1226
1133
|
key: "resetToLatest",
|
|
1227
1134
|
value: function () {
|
|
1228
1135
|
var _resetToLatest2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
1229
|
-
var force,
|
|
1230
|
-
_args7 = arguments;
|
|
1231
1136
|
return _regenerator().w(function (_context7) {
|
|
1232
1137
|
while (1) switch (_context7.n) {
|
|
1233
1138
|
case 0:
|
|
1234
|
-
force = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : false;
|
|
1235
1139
|
if (!this.internalState.traverseLock) {
|
|
1236
1140
|
_context7.n = 1;
|
|
1237
1141
|
break;
|
|
1238
1142
|
}
|
|
1239
1143
|
return _context7.a(2);
|
|
1240
1144
|
case 1:
|
|
1241
|
-
return _context7.a(2, TopicHistoryWindow_superPropGet(TopicHistoryWindow, "resetToLatest", this, 3)([
|
|
1145
|
+
return _context7.a(2, TopicHistoryWindow_superPropGet(TopicHistoryWindow, "resetToLatest", this, 3)([]));
|
|
1242
1146
|
}
|
|
1243
1147
|
}, _callee7, this);
|
|
1244
1148
|
}));
|
|
@@ -1714,85 +1618,17 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
|
|
|
1714
1618
|
return _getMessagesWindow.apply(this, arguments);
|
|
1715
1619
|
}
|
|
1716
1620
|
return getMessagesWindow;
|
|
1717
|
-
}()
|
|
1718
|
-
/**
|
|
1719
|
-
* Re-synchronise this room's history after a reconnect without discarding
|
|
1720
|
-
* the existing window objects (which would blank the UI and, for ephemeral
|
|
1721
|
-
* rooms, permanently drop live-only history).
|
|
1722
|
-
*
|
|
1723
|
-
* The window bindings are preserved; only windows that the application had
|
|
1724
|
-
* actually pulled to the latest page (state === LATEST) are refreshed, with
|
|
1725
|
-
* a single resetToLatest instead of a chain of catch-up requests. Windows
|
|
1726
|
-
* that were never pulled (LIVE) or belong to an ephemeral room are left
|
|
1727
|
-
* untouched so their in-memory context survives the reconnect.
|
|
1728
|
-
*/
|
|
1729
|
-
)
|
|
1730
|
-
}, {
|
|
1731
|
-
key: "resync",
|
|
1732
|
-
value: (function () {
|
|
1733
|
-
var _resync = RoomMessagesHistory_asyncToGenerator(/*#__PURE__*/RoomMessagesHistory_regenerator().m(function _callee2(room) {
|
|
1734
|
-
var _i, _Array$from, _Array$from$_i, window, _t;
|
|
1735
|
-
return RoomMessagesHistory_regenerator().w(function (_context2) {
|
|
1736
|
-
while (1) switch (_context2.p = _context2.n) {
|
|
1737
|
-
case 0:
|
|
1738
|
-
this.room = room;
|
|
1739
|
-
this.updateTraverseLock(room);
|
|
1740
|
-
if (this.room.defaultTopic) {
|
|
1741
|
-
this.createHistoryWindowForTopic(this.room.defaultTopic);
|
|
1742
|
-
}
|
|
1743
|
-
_i = 0, _Array$from = Array.from(this.historyWindows.items);
|
|
1744
|
-
case 1:
|
|
1745
|
-
if (!(_i < _Array$from.length)) {
|
|
1746
|
-
_context2.n = 8;
|
|
1747
|
-
break;
|
|
1748
|
-
}
|
|
1749
|
-
_Array$from$_i = RoomMessagesHistory_slicedToArray(_Array$from[_i], 2), window = _Array$from$_i[1];
|
|
1750
|
-
_context2.p = 2;
|
|
1751
|
-
_context2.n = 3;
|
|
1752
|
-
return window.setTraverseLock(this.traverseLock);
|
|
1753
|
-
case 3:
|
|
1754
|
-
if (!this.traverseLock) {
|
|
1755
|
-
_context2.n = 4;
|
|
1756
|
-
break;
|
|
1757
|
-
}
|
|
1758
|
-
return _context2.a(3, 7);
|
|
1759
|
-
case 4:
|
|
1760
|
-
if (!(window.state === WindowState.LATEST)) {
|
|
1761
|
-
_context2.n = 5;
|
|
1762
|
-
break;
|
|
1763
|
-
}
|
|
1764
|
-
_context2.n = 5;
|
|
1765
|
-
return window.resetToLatest(true);
|
|
1766
|
-
case 5:
|
|
1767
|
-
_context2.n = 7;
|
|
1768
|
-
break;
|
|
1769
|
-
case 6:
|
|
1770
|
-
_context2.p = 6;
|
|
1771
|
-
_t = _context2.v;
|
|
1772
|
-
case 7:
|
|
1773
|
-
_i++;
|
|
1774
|
-
_context2.n = 1;
|
|
1775
|
-
break;
|
|
1776
|
-
case 8:
|
|
1777
|
-
return _context2.a(2);
|
|
1778
|
-
}
|
|
1779
|
-
}, _callee2, this, [[2, 6]]);
|
|
1780
|
-
}));
|
|
1781
|
-
function resync(_x2) {
|
|
1782
|
-
return _resync.apply(this, arguments);
|
|
1783
|
-
}
|
|
1784
|
-
return resync;
|
|
1785
1621
|
}())
|
|
1786
1622
|
}, {
|
|
1787
1623
|
key: "handleRoomUpdated",
|
|
1788
1624
|
value: function () {
|
|
1789
|
-
var _handleRoomUpdated = RoomMessagesHistory_asyncToGenerator(/*#__PURE__*/RoomMessagesHistory_regenerator().m(function
|
|
1790
|
-
var
|
|
1791
|
-
return RoomMessagesHistory_regenerator().w(function (
|
|
1792
|
-
while (1) switch (
|
|
1625
|
+
var _handleRoomUpdated = RoomMessagesHistory_asyncToGenerator(/*#__PURE__*/RoomMessagesHistory_regenerator().m(function _callee2(ev) {
|
|
1626
|
+
var _i, _Array$from, _Array$from$_i, window;
|
|
1627
|
+
return RoomMessagesHistory_regenerator().w(function (_context2) {
|
|
1628
|
+
while (1) switch (_context2.n) {
|
|
1793
1629
|
case 0:
|
|
1794
1630
|
if (!(this.room.id === ev.room.id)) {
|
|
1795
|
-
|
|
1631
|
+
_context2.n = 3;
|
|
1796
1632
|
break;
|
|
1797
1633
|
}
|
|
1798
1634
|
this.room = ev.room;
|
|
@@ -1800,25 +1636,25 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
|
|
|
1800
1636
|
if (ev.room.defaultTopic) {
|
|
1801
1637
|
this.createHistoryWindowForTopic(ev.room.defaultTopic);
|
|
1802
1638
|
}
|
|
1803
|
-
|
|
1639
|
+
_i = 0, _Array$from = Array.from(this.historyWindows.items);
|
|
1804
1640
|
case 1:
|
|
1805
|
-
if (!(
|
|
1806
|
-
|
|
1641
|
+
if (!(_i < _Array$from.length)) {
|
|
1642
|
+
_context2.n = 3;
|
|
1807
1643
|
break;
|
|
1808
1644
|
}
|
|
1809
|
-
_Array$
|
|
1810
|
-
|
|
1645
|
+
_Array$from$_i = RoomMessagesHistory_slicedToArray(_Array$from[_i], 2), window = _Array$from$_i[1];
|
|
1646
|
+
_context2.n = 2;
|
|
1811
1647
|
return window.setTraverseLock(this.traverseLock);
|
|
1812
1648
|
case 2:
|
|
1813
|
-
|
|
1814
|
-
|
|
1649
|
+
_i++;
|
|
1650
|
+
_context2.n = 1;
|
|
1815
1651
|
break;
|
|
1816
1652
|
case 3:
|
|
1817
|
-
return
|
|
1653
|
+
return _context2.a(2);
|
|
1818
1654
|
}
|
|
1819
|
-
},
|
|
1655
|
+
}, _callee2, this);
|
|
1820
1656
|
}));
|
|
1821
|
-
function handleRoomUpdated(
|
|
1657
|
+
function handleRoomUpdated(_x2) {
|
|
1822
1658
|
return _handleRoomUpdated.apply(this, arguments);
|
|
1823
1659
|
}
|
|
1824
1660
|
return handleRoomUpdated;
|
|
@@ -1882,9 +1718,6 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
|
|
|
1882
1718
|
}();
|
|
1883
1719
|
;// ./src/state-tracker/MessagesManager.ts
|
|
1884
1720
|
function MessagesManager_typeof(o) { "@babel/helpers - typeof"; return MessagesManager_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, MessagesManager_typeof(o); }
|
|
1885
|
-
function MessagesManager_createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = MessagesManager_unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
1886
|
-
function MessagesManager_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return MessagesManager_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? MessagesManager_arrayLikeToArray(r, a) : void 0; } }
|
|
1887
|
-
function MessagesManager_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
1888
1721
|
function MessagesManager_regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return MessagesManager_regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (MessagesManager_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, MessagesManager_regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, MessagesManager_regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), MessagesManager_regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", MessagesManager_regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), MessagesManager_regeneratorDefine2(u), MessagesManager_regeneratorDefine2(u, o, "Generator"), MessagesManager_regeneratorDefine2(u, n, function () { return this; }), MessagesManager_regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (MessagesManager_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
1889
1722
|
function MessagesManager_regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } MessagesManager_regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { MessagesManager_regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, MessagesManager_regeneratorDefine2(e, r, n, t); }
|
|
1890
1723
|
function MessagesManager_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
@@ -2007,38 +1840,11 @@ var MessagesManager = /*#__PURE__*/function () {
|
|
|
2007
1840
|
}, {
|
|
2008
1841
|
key: "handleSession",
|
|
2009
1842
|
value: function handleSession(ev) {
|
|
2010
|
-
var
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
for (var _i = 0, _Array$from = Array.from(this.roomHistories.items.keys()); _i < _Array$from.length; _i++) {
|
|
2016
|
-
var roomId = _Array$from[_i];
|
|
2017
|
-
if (!stateRoomIds.has(roomId)) {
|
|
2018
|
-
this.roomHistories["delete"](roomId);
|
|
2019
|
-
}
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
// Keep existing histories (preserving loaded messages and, crucially,
|
|
2023
|
-
// live-only ephemeral history), create histories for newly joined
|
|
2024
|
-
// rooms, and resync survivors against the fresh room snapshot.
|
|
2025
|
-
var _iterator = MessagesManager_createForOfIteratorHelper(ev.state.rooms),
|
|
2026
|
-
_step;
|
|
2027
|
-
try {
|
|
2028
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2029
|
-
var room = _step.value;
|
|
2030
|
-
var history = this.roomHistories.get(room.id);
|
|
2031
|
-
if (history) {
|
|
2032
|
-
void history.resync(room);
|
|
2033
|
-
} else {
|
|
2034
|
-
this.createHistoryForNewRoom(room);
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
} catch (err) {
|
|
2038
|
-
_iterator.e(err);
|
|
2039
|
-
} finally {
|
|
2040
|
-
_iterator.f();
|
|
2041
|
-
}
|
|
1843
|
+
var _this2 = this;
|
|
1844
|
+
this.roomHistories.deleteAll();
|
|
1845
|
+
ev.state.rooms.forEach(function (room) {
|
|
1846
|
+
return _this2.createHistoryForNewRoom(room);
|
|
1847
|
+
});
|
|
2042
1848
|
this.deferredSession.resolve();
|
|
2043
1849
|
}
|
|
2044
1850
|
}]);
|
|
@@ -2083,11 +1889,6 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2083
1889
|
FollowedTopicsManager_defineProperty(_this, "followedTopicsPromises", new PromiseRegistry());
|
|
2084
1890
|
FollowedTopicsManager_defineProperty(_this, "deferredSession", new DeferredTask());
|
|
2085
1891
|
FollowedTopicsManager_defineProperty(_this, "summariesCache", new Map());
|
|
2086
|
-
/**
|
|
2087
|
-
* Rooms whose cached followed-topics are stale after a reconnect and must
|
|
2088
|
-
* be refetched (and reconciled in place) the next time they are accessed.
|
|
2089
|
-
*/
|
|
2090
|
-
FollowedTopicsManager_defineProperty(_this, "staleRooms", new Set());
|
|
2091
1892
|
_this.tracker = tracker;
|
|
2092
1893
|
_this.tracker.client.on('Session', function (ev) {
|
|
2093
1894
|
return _this.handleSession(ev);
|
|
@@ -2133,7 +1934,7 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2133
1934
|
value: (function () {
|
|
2134
1935
|
var _cacheForSpace = FollowedTopicsManager_asyncToGenerator(/*#__PURE__*/FollowedTopicsManager_regenerator().m(function _callee2(spaceId) {
|
|
2135
1936
|
var _this2 = this;
|
|
2136
|
-
var rooms, roomIds,
|
|
1937
|
+
var rooms, roomIds, isAlreadyCached, spaceRegistryKey, _t;
|
|
2137
1938
|
return FollowedTopicsManager_regenerator().w(function (_context2) {
|
|
2138
1939
|
while (1) switch (_context2.n) {
|
|
2139
1940
|
case 0:
|
|
@@ -2170,10 +1971,10 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2170
1971
|
}
|
|
2171
1972
|
return _context2.a(2);
|
|
2172
1973
|
case 5:
|
|
2173
|
-
|
|
2174
|
-
return
|
|
1974
|
+
isAlreadyCached = roomIds.every(function (roomId) {
|
|
1975
|
+
return _this2.followedTopics.has(roomId);
|
|
2175
1976
|
});
|
|
2176
|
-
if (
|
|
1977
|
+
if (!isAlreadyCached) {
|
|
2177
1978
|
_context2.n = 6;
|
|
2178
1979
|
break;
|
|
2179
1980
|
}
|
|
@@ -2200,7 +2001,7 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2200
2001
|
}
|
|
2201
2002
|
throw result.error;
|
|
2202
2003
|
case 2:
|
|
2203
|
-
_this2.
|
|
2004
|
+
_this2.setFollowedTopicsArray(roomIds, result.data.followedTopics);
|
|
2204
2005
|
case 3:
|
|
2205
2006
|
return _context.a(2);
|
|
2206
2007
|
}
|
|
@@ -2241,7 +2042,7 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2241
2042
|
}
|
|
2242
2043
|
return _context4.a(2, undefined);
|
|
2243
2044
|
case 2:
|
|
2244
|
-
if (
|
|
2045
|
+
if (this.followedTopics.has(roomId)) {
|
|
2245
2046
|
_context4.n = 3;
|
|
2246
2047
|
break;
|
|
2247
2048
|
}
|
|
@@ -2265,8 +2066,7 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2265
2066
|
}
|
|
2266
2067
|
throw result.error;
|
|
2267
2068
|
case 2:
|
|
2268
|
-
_this3.
|
|
2269
|
-
_this3.invalidateUnreadSummaries(roomId);
|
|
2069
|
+
_this3.setFollowedTopicsArray([roomId], result.data.followedTopics);
|
|
2270
2070
|
case 3:
|
|
2271
2071
|
return _context3.a(2);
|
|
2272
2072
|
}
|
|
@@ -2359,7 +2159,7 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2359
2159
|
key: "summarize",
|
|
2360
2160
|
value: (function () {
|
|
2361
2161
|
var _summarize = FollowedTopicsManager_asyncToGenerator(/*#__PURE__*/FollowedTopicsManager_regenerator().m(function _callee6(location) {
|
|
2362
|
-
var cacheKey, roomIds, targetTopicId, rooms, mentionCount,
|
|
2162
|
+
var cacheKey, roomIds, targetTopicId, rooms, mentionCount, unreadTopicCount, _iterator2, _step2, roomId, collection, _iterator3, _step3, _topic$mentionCount, topic, result, _t3, _t4;
|
|
2363
2163
|
return FollowedTopicsManager_regenerator().w(function (_context6) {
|
|
2364
2164
|
while (1) switch (_context6.p = _context6.n) {
|
|
2365
2165
|
case 0:
|
|
@@ -2421,7 +2221,7 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2421
2221
|
});
|
|
2422
2222
|
case 9:
|
|
2423
2223
|
mentionCount = 0;
|
|
2424
|
-
|
|
2224
|
+
unreadTopicCount = 0;
|
|
2425
2225
|
_iterator2 = FollowedTopicsManager_createForOfIteratorHelper(roomIds);
|
|
2426
2226
|
_context6.p = 10;
|
|
2427
2227
|
_iterator2.s();
|
|
@@ -2457,7 +2257,7 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2457
2257
|
return _context6.a(3, 17);
|
|
2458
2258
|
case 16:
|
|
2459
2259
|
if (topic.isUnread) {
|
|
2460
|
-
|
|
2260
|
+
unreadTopicCount++;
|
|
2461
2261
|
}
|
|
2462
2262
|
mentionCount += (_topic$mentionCount = topic.mentionCount) !== null && _topic$mentionCount !== void 0 ? _topic$mentionCount : 0;
|
|
2463
2263
|
case 17:
|
|
@@ -2491,7 +2291,8 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2491
2291
|
case 25:
|
|
2492
2292
|
result = {
|
|
2493
2293
|
mentionCount: mentionCount,
|
|
2494
|
-
|
|
2294
|
+
unreadTopicCount: unreadTopicCount,
|
|
2295
|
+
isUnread: unreadTopicCount > 0
|
|
2495
2296
|
};
|
|
2496
2297
|
this.summariesCache.set(cacheKey, result);
|
|
2497
2298
|
return _context6.a(2, result);
|
|
@@ -2524,22 +2325,7 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2524
2325
|
}, {
|
|
2525
2326
|
key: "handleSession",
|
|
2526
2327
|
value: function handleSession(ev) {
|
|
2527
|
-
|
|
2528
|
-
// that would otherwise blank on reconnect), but mark them stale and drop
|
|
2529
|
-
// the fetch guards so the next access/caching refetches and reconciles
|
|
2530
|
-
// them in place.
|
|
2531
|
-
var _iterator4 = FollowedTopicsManager_createForOfIteratorHelper(this.followedTopics.items.keys()),
|
|
2532
|
-
_step4;
|
|
2533
|
-
try {
|
|
2534
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
2535
|
-
var roomId = _step4.value;
|
|
2536
|
-
this.staleRooms.add(roomId);
|
|
2537
|
-
}
|
|
2538
|
-
} catch (err) {
|
|
2539
|
-
_iterator4.e(err);
|
|
2540
|
-
} finally {
|
|
2541
|
-
_iterator4.f();
|
|
2542
|
-
}
|
|
2328
|
+
this.followedTopics.deleteAll();
|
|
2543
2329
|
this.followedTopicsPromises.forgetAll();
|
|
2544
2330
|
this.invalidateUnreadSummaries();
|
|
2545
2331
|
this.deferredSession.resolve();
|
|
@@ -2639,34 +2425,34 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2639
2425
|
if (topicId) {
|
|
2640
2426
|
this.summariesCache["delete"]("topic:".concat(roomId, ":").concat(topicId));
|
|
2641
2427
|
} else {
|
|
2642
|
-
var
|
|
2643
|
-
|
|
2428
|
+
var _iterator4 = FollowedTopicsManager_createForOfIteratorHelper(this.summariesCache.keys()),
|
|
2429
|
+
_step4;
|
|
2644
2430
|
try {
|
|
2645
|
-
for (
|
|
2646
|
-
var key =
|
|
2431
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
2432
|
+
var key = _step4.value;
|
|
2647
2433
|
if (key.startsWith("topic:".concat(roomId, ":"))) {
|
|
2648
2434
|
this.summariesCache["delete"](key);
|
|
2649
2435
|
}
|
|
2650
2436
|
}
|
|
2651
2437
|
} catch (err) {
|
|
2652
|
-
|
|
2438
|
+
_iterator4.e(err);
|
|
2653
2439
|
} finally {
|
|
2654
|
-
|
|
2440
|
+
_iterator4.f();
|
|
2655
2441
|
}
|
|
2656
2442
|
}
|
|
2657
|
-
var
|
|
2658
|
-
|
|
2443
|
+
var _iterator5 = FollowedTopicsManager_createForOfIteratorHelper(this.summariesCache.keys()),
|
|
2444
|
+
_step5;
|
|
2659
2445
|
try {
|
|
2660
|
-
for (
|
|
2661
|
-
var _key2 =
|
|
2446
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
2447
|
+
var _key2 = _step5.value;
|
|
2662
2448
|
if (_key2.startsWith('space:') || _key2 === 'spaceless') {
|
|
2663
2449
|
this.summariesCache["delete"](_key2);
|
|
2664
2450
|
}
|
|
2665
2451
|
}
|
|
2666
2452
|
} catch (err) {
|
|
2667
|
-
|
|
2453
|
+
_iterator5.e(err);
|
|
2668
2454
|
} finally {
|
|
2669
|
-
|
|
2455
|
+
_iterator5.f();
|
|
2670
2456
|
}
|
|
2671
2457
|
} else {
|
|
2672
2458
|
this.summariesCache.clear();
|
|
@@ -2681,11 +2467,11 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2681
2467
|
roomIds.forEach(function (roomId) {
|
|
2682
2468
|
_this5.summariesCache["delete"]("room:".concat(roomId));
|
|
2683
2469
|
});
|
|
2684
|
-
var
|
|
2685
|
-
|
|
2470
|
+
var _iterator6 = FollowedTopicsManager_createForOfIteratorHelper(this.summariesCache.keys()),
|
|
2471
|
+
_step6;
|
|
2686
2472
|
try {
|
|
2687
|
-
for (
|
|
2688
|
-
var key =
|
|
2473
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
2474
|
+
var key = _step6.value;
|
|
2689
2475
|
if (key.startsWith('space:') || key === 'spaceless') {
|
|
2690
2476
|
this.summariesCache["delete"](key);
|
|
2691
2477
|
continue;
|
|
@@ -2698,9 +2484,9 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2698
2484
|
}
|
|
2699
2485
|
}
|
|
2700
2486
|
} catch (err) {
|
|
2701
|
-
|
|
2487
|
+
_iterator6.e(err);
|
|
2702
2488
|
} finally {
|
|
2703
|
-
|
|
2489
|
+
_iterator6.f();
|
|
2704
2490
|
}
|
|
2705
2491
|
this.emit('change');
|
|
2706
2492
|
}
|
|
@@ -2778,66 +2564,27 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2778
2564
|
}
|
|
2779
2565
|
return updateLocallyFollowedTopicOnNewMessage;
|
|
2780
2566
|
}()
|
|
2781
|
-
/**
|
|
2782
|
-
* Reconcile the followed-topics collection for a single room to exactly
|
|
2783
|
-
* match the provided list (upsert present, drop absent) without emitting an
|
|
2784
|
-
* intermediate empty state, and clear its stale marker. Does not touch the
|
|
2785
|
-
* unread summaries cache - callers decide how to invalidate it.
|
|
2786
|
-
*/
|
|
2787
|
-
}, {
|
|
2788
|
-
key: "applyRoomFollowedTopics",
|
|
2789
|
-
value: function applyRoomFollowedTopics(roomId, followedTopics) {
|
|
2790
|
-
var _this$followedTopics$5;
|
|
2791
|
-
if (!this.followedTopics.has(roomId)) {
|
|
2792
|
-
this.followedTopics.set([roomId, new ObservableIndexedObjectCollection(function (followedTopic) {
|
|
2793
|
-
return followedTopic.location.topicId;
|
|
2794
|
-
})]);
|
|
2795
|
-
}
|
|
2796
|
-
(_this$followedTopics$5 = this.followedTopics.get(roomId)).reconcile.apply(_this$followedTopics$5, FollowedTopicsManager_toConsumableArray(followedTopics));
|
|
2797
|
-
this.staleRooms["delete"](roomId);
|
|
2798
|
-
}
|
|
2799
|
-
|
|
2800
|
-
/**
|
|
2801
|
-
* Reconcile a batch of rooms from a single bulk GetFollowedTopics response.
|
|
2802
|
-
* Rooms with no followed topics in the response are reconciled to empty, so
|
|
2803
|
-
* topics unfollowed/removed during the downtime are correctly dropped.
|
|
2804
|
-
*/
|
|
2805
|
-
}, {
|
|
2806
|
-
key: "reconcileRoomsFollowedTopics",
|
|
2807
|
-
value: function reconcileRoomsFollowedTopics(roomIds, followedTopics) {
|
|
2808
|
-
var _this6 = this;
|
|
2809
|
-
var roomToTopics = {};
|
|
2810
|
-
followedTopics.forEach(function (followedTopic) {
|
|
2811
|
-
var _followedTopic$locati, _roomToTopics$_follow;
|
|
2812
|
-
((_roomToTopics$_follow = roomToTopics[_followedTopic$locati = followedTopic.location.roomId]) !== null && _roomToTopics$_follow !== void 0 ? _roomToTopics$_follow : roomToTopics[_followedTopic$locati] = []).push(followedTopic);
|
|
2813
|
-
});
|
|
2814
|
-
roomIds.forEach(function (roomId) {
|
|
2815
|
-
var _roomToTopics$roomId;
|
|
2816
|
-
return _this6.applyRoomFollowedTopics(roomId, (_roomToTopics$roomId = roomToTopics[roomId]) !== null && _roomToTopics$roomId !== void 0 ? _roomToTopics$roomId : []);
|
|
2817
|
-
});
|
|
2818
|
-
this.invalidateUnreadSummariesForRooms(roomIds);
|
|
2819
|
-
}
|
|
2820
2567
|
}, {
|
|
2821
2568
|
key: "setFollowedTopicsArray",
|
|
2822
2569
|
value: function setFollowedTopicsArray(roomIds, followedTopics) {
|
|
2823
|
-
var
|
|
2570
|
+
var _this6 = this;
|
|
2824
2571
|
var roomToTopics = {};
|
|
2825
2572
|
|
|
2826
2573
|
// Reassign followed topics to limit collection change event emit
|
|
2827
2574
|
followedTopics.forEach(function (followedTopic) {
|
|
2828
|
-
var _followedTopic$
|
|
2829
|
-
(_roomToTopics$
|
|
2575
|
+
var _followedTopic$locati, _roomToTopics$_follow;
|
|
2576
|
+
(_roomToTopics$_follow = roomToTopics[_followedTopic$locati = followedTopic.location.roomId]) !== null && _roomToTopics$_follow !== void 0 ? _roomToTopics$_follow : roomToTopics[_followedTopic$locati] = [];
|
|
2830
2577
|
roomToTopics[followedTopic.location.roomId].push(followedTopic);
|
|
2831
2578
|
});
|
|
2832
2579
|
roomIds.forEach(function (roomId) {
|
|
2833
|
-
if (!
|
|
2834
|
-
|
|
2580
|
+
if (!_this6.followedTopics.has(roomId)) {
|
|
2581
|
+
_this6.followedTopics.set([roomId, new ObservableIndexedObjectCollection(function (followedTopic) {
|
|
2835
2582
|
return followedTopic.location.topicId;
|
|
2836
2583
|
})]);
|
|
2837
2584
|
}
|
|
2838
2585
|
if (roomToTopics[roomId]) {
|
|
2839
|
-
var
|
|
2840
|
-
(
|
|
2586
|
+
var _this6$followedTopics;
|
|
2587
|
+
(_this6$followedTopics = _this6.followedTopics.get(roomId)).set.apply(_this6$followedTopics, FollowedTopicsManager_toConsumableArray(roomToTopics[roomId]));
|
|
2841
2588
|
}
|
|
2842
2589
|
});
|
|
2843
2590
|
this.invalidateUnreadSummariesForRooms(roomIds);
|
|
@@ -2847,7 +2594,6 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2847
2594
|
value: function clearRoomFollowedTopicsStructures(roomId) {
|
|
2848
2595
|
this.followedTopics["delete"](roomId);
|
|
2849
2596
|
this.followedTopicsPromises.forget(roomId);
|
|
2850
|
-
this.staleRooms["delete"](roomId);
|
|
2851
2597
|
this.invalidateUnreadSummaries(roomId);
|
|
2852
2598
|
}
|
|
2853
2599
|
}]);
|
|
@@ -3363,39 +3109,16 @@ var RoomsManager = /*#__PURE__*/function () {
|
|
|
3363
3109
|
var _member$user$id2, _member$user2;
|
|
3364
3110
|
return (_member$user$id2 = (_member$user2 = member.user) === null || _member$user2 === void 0 ? void 0 : _member$user2.id) !== null && _member$user$id2 !== void 0 ? _member$user$id2 : member.spaceMember.user.id;
|
|
3365
3111
|
}, ev.members)]);
|
|
3366
|
-
} else {
|
|
3367
|
-
var _this$members$get;
|
|
3368
|
-
// Reconcile into the existing (bound) collection so a reconnect
|
|
3369
|
-
// refetch updates it in place instead of leaving stale members.
|
|
3370
|
-
(_this$members$get = this.members.get(ev.id)).reconcile.apply(_this$members$get, RoomsManager_toConsumableArray(ev.members));
|
|
3371
3112
|
}
|
|
3372
3113
|
}
|
|
3373
3114
|
}, {
|
|
3374
3115
|
key: "handleSession",
|
|
3375
3116
|
value: function handleSession(ev) {
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
}));
|
|
3379
|
-
|
|
3380
|
-
// Remove only rooms that were left/deleted on the server during the
|
|
3381
|
-
// downtime, reusing the cascade cleanup (members, topics, followed
|
|
3382
|
-
// topics). Surviving rooms keep their identity and bindings.
|
|
3383
|
-
var removedRoomIds = this.list.items.filter(function (room) {
|
|
3384
|
-
return !stateRoomIds.has(room.id);
|
|
3385
|
-
}).map(function (room) {
|
|
3386
|
-
return room.id;
|
|
3387
|
-
});
|
|
3388
|
-
if (removedRoomIds.length) {
|
|
3389
|
-
this.deleteRoom.apply(this, RoomsManager_toConsumableArray(removedRoomIds));
|
|
3390
|
-
}
|
|
3391
|
-
|
|
3392
|
-
// Invalidate lazy caches so the next access refetches fresh data, but
|
|
3393
|
-
// keep the collection objects: handleRoomMembers reconciles into them,
|
|
3394
|
-
// so bound views refresh in place without blanking.
|
|
3395
|
-
this.membersPromises.forgetAll();
|
|
3117
|
+
this.list.deleteAll();
|
|
3118
|
+
this.topics.deleteAll();
|
|
3396
3119
|
this.topicsPromises.forgetAll();
|
|
3397
|
-
|
|
3398
|
-
|
|
3120
|
+
this.members.deleteAll();
|
|
3121
|
+
this.membersPromises.forgetAll();
|
|
3399
3122
|
this.addJoinedRooms.apply(this, RoomsManager_toConsumableArray(ev.state.rooms));
|
|
3400
3123
|
this.deferredSession.resolve();
|
|
3401
3124
|
}
|
|
@@ -3529,7 +3252,6 @@ function extractUserFromMember(member) {
|
|
|
3529
3252
|
}
|
|
3530
3253
|
;// ./src/state-tracker/SpacesManager.ts
|
|
3531
3254
|
function SpacesManager_typeof(o) { "@babel/helpers - typeof"; return SpacesManager_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, SpacesManager_typeof(o); }
|
|
3532
|
-
function SpacesManager_createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = SpacesManager_unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
3533
3255
|
function SpacesManager_toConsumableArray(r) { return SpacesManager_arrayWithoutHoles(r) || SpacesManager_iterableToArray(r) || SpacesManager_unsupportedIterableToArray(r) || SpacesManager_nonIterableSpread(); }
|
|
3534
3256
|
function SpacesManager_nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3535
3257
|
function SpacesManager_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return SpacesManager_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? SpacesManager_arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -3933,11 +3655,6 @@ var SpacesManager = /*#__PURE__*/function () {
|
|
|
3933
3655
|
this.members.set([ev.id, new ObservableIndexedObjectCollection(function (member) {
|
|
3934
3656
|
return member === null || member === void 0 ? void 0 : member.user.id;
|
|
3935
3657
|
}, ev.members)]);
|
|
3936
|
-
} else {
|
|
3937
|
-
var _this$members$get;
|
|
3938
|
-
// Reconcile into the existing (bound) collection so a reconnect
|
|
3939
|
-
// refetch updates it in place instead of leaving stale members.
|
|
3940
|
-
(_this$members$get = this.members.get(ev.id)).reconcile.apply(_this$members$get, SpacesManager_toConsumableArray(ev.members));
|
|
3941
3658
|
}
|
|
3942
3659
|
}
|
|
3943
3660
|
}, {
|
|
@@ -3946,13 +3663,10 @@ var SpacesManager = /*#__PURE__*/function () {
|
|
|
3946
3663
|
var _this4 = this;
|
|
3947
3664
|
if (!this.rooms.has(ev.id)) {
|
|
3948
3665
|
this.rooms.set([ev.id, new ObservableIndexedObjectCollection('id', ev.summaries)]);
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3666
|
+
ev.summaries.forEach(function (summary) {
|
|
3667
|
+
return _this4.roomIdToSpaceId.set([summary.id, ev.id]);
|
|
3668
|
+
});
|
|
3952
3669
|
}
|
|
3953
|
-
ev.summaries.forEach(function (summary) {
|
|
3954
|
-
return _this4.roomIdToSpaceId.set([summary.id, ev.id]);
|
|
3955
|
-
});
|
|
3956
3670
|
}
|
|
3957
3671
|
}, {
|
|
3958
3672
|
key: "handleRoomSummaryUpdated",
|
|
@@ -4020,58 +3734,14 @@ var SpacesManager = /*#__PURE__*/function () {
|
|
|
4020
3734
|
}, {
|
|
4021
3735
|
key: "handleSession",
|
|
4022
3736
|
value: function handleSession(ev) {
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
}));
|
|
4027
|
-
|
|
4028
|
-
// Remove only spaces that were left/deleted on the server during the
|
|
4029
|
-
// downtime, reusing the cascade cleanup (roles, rooms, members, index).
|
|
4030
|
-
var removedSpaceIds = this.list.items.filter(function (space) {
|
|
4031
|
-
return !stateSpaceIds.has(space.id);
|
|
4032
|
-
}).map(function (space) {
|
|
4033
|
-
return space.id;
|
|
4034
|
-
});
|
|
4035
|
-
var _iterator = SpacesManager_createForOfIteratorHelper(removedSpaceIds),
|
|
4036
|
-
_step;
|
|
4037
|
-
try {
|
|
4038
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4039
|
-
var spaceId = _step.value;
|
|
4040
|
-
this.handleSpaceDeleted({
|
|
4041
|
-
id: spaceId
|
|
4042
|
-
});
|
|
4043
|
-
}
|
|
4044
|
-
|
|
4045
|
-
// Invalidate lazy caches (rooms/members) but keep their objects so the
|
|
4046
|
-
// next access refetches and reconciles them in place.
|
|
4047
|
-
} catch (err) {
|
|
4048
|
-
_iterator.e(err);
|
|
4049
|
-
} finally {
|
|
4050
|
-
_iterator.f();
|
|
4051
|
-
}
|
|
3737
|
+
this.list.deleteAll();
|
|
3738
|
+
this.roles.deleteAll();
|
|
3739
|
+
this.rooms.deleteAll();
|
|
4052
3740
|
this.roomsPromises.forgetAll();
|
|
3741
|
+
this.members.deleteAll();
|
|
4053
3742
|
this.membersPromises.forgetAll();
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
// spaces from the authoritative snapshot.
|
|
4057
|
-
var _iterator2 = SpacesManager_createForOfIteratorHelper(ev.state.spaces),
|
|
4058
|
-
_step2;
|
|
4059
|
-
try {
|
|
4060
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
4061
|
-
var space = _step2.value;
|
|
4062
|
-
if (this.roles.has(space.id)) {
|
|
4063
|
-
var _this$roles$get2;
|
|
4064
|
-
(_this$roles$get2 = this.roles.get(space.id)).reconcile.apply(_this$roles$get2, SpacesManager_toConsumableArray(space.roles));
|
|
4065
|
-
} else {
|
|
4066
|
-
this.roles.set([space.id, new ObservableIndexedObjectCollection('id', space.roles)]);
|
|
4067
|
-
}
|
|
4068
|
-
}
|
|
4069
|
-
} catch (err) {
|
|
4070
|
-
_iterator2.e(err);
|
|
4071
|
-
} finally {
|
|
4072
|
-
_iterator2.f();
|
|
4073
|
-
}
|
|
4074
|
-
(_this$list2 = this.list).set.apply(_this$list2, SpacesManager_toConsumableArray(ev.state.spaces));
|
|
3743
|
+
this.roomIdToSpaceId.deleteAll();
|
|
3744
|
+
this.addJoinedSpaces.apply(this, SpacesManager_toConsumableArray(ev.state.spaces));
|
|
4075
3745
|
this.deferredSession.resolve();
|
|
4076
3746
|
}
|
|
4077
3747
|
}, {
|
|
@@ -4795,12 +4465,8 @@ var PermissionsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
4795
4465
|
}, {
|
|
4796
4466
|
key: "handleSession",
|
|
4797
4467
|
value: function handleSession(ev) {
|
|
4798
|
-
|
|
4799
|
-
// overwrites (getOverwrites refetches and upserts on the next access),
|
|
4800
|
-
// and notify consumers to recompute so bound permission UI is never
|
|
4801
|
-
// left showing stale results after a reconnect.
|
|
4468
|
+
this.overwrites.deleteAll();
|
|
4802
4469
|
this.overwritesPromises.forgetAll();
|
|
4803
|
-
this.emit('change');
|
|
4804
4470
|
}
|
|
4805
4471
|
}]);
|
|
4806
4472
|
}(EventTarget);
|
|
@@ -4898,16 +4564,13 @@ var EmoticonsManager = /*#__PURE__*/function () {
|
|
|
4898
4564
|
}, {
|
|
4899
4565
|
key: "handleEmoticons",
|
|
4900
4566
|
value: function handleEmoticons(event) {
|
|
4901
|
-
var _event$location$space
|
|
4567
|
+
var _event$location$space;
|
|
4902
4568
|
var spaceId = (_event$location$space = event.location.spaceId) !== null && _event$location$space !== void 0 ? _event$location$space : GLOBAL_KEY;
|
|
4903
4569
|
if (!this.list.has(spaceId)) {
|
|
4904
4570
|
this.list.set([spaceId, new ObservableIndexedObjectCollection('id')]);
|
|
4905
4571
|
}
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
// reconcile in place: a reconnect refetch drops removed emoticons and
|
|
4909
|
-
// adds new ones without blanking a bound (visible) collection.
|
|
4910
|
-
(_this$list$get = this.list.get(spaceId)).reconcile.apply(_this$list$get, EmoticonsManager_toConsumableArray(event.emoticons));
|
|
4572
|
+
var collection = this.list.get(spaceId);
|
|
4573
|
+
collection.set.apply(collection, EmoticonsManager_toConsumableArray(event.emoticons));
|
|
4911
4574
|
}
|
|
4912
4575
|
}, {
|
|
4913
4576
|
key: "handleNewEmoticon",
|
|
@@ -4931,9 +4594,7 @@ var EmoticonsManager = /*#__PURE__*/function () {
|
|
|
4931
4594
|
}, {
|
|
4932
4595
|
key: "handleSession",
|
|
4933
4596
|
value: function handleSession() {
|
|
4934
|
-
|
|
4935
|
-
// pickers); just drop the fetch guards so the next access refetches and
|
|
4936
|
-
// reconciles them in place.
|
|
4597
|
+
this.list.deleteAll();
|
|
4937
4598
|
this.emoticonsPromises.forgetAll();
|
|
4938
4599
|
}
|
|
4939
4600
|
}]);
|
|
@@ -5022,9 +4683,7 @@ var UsersManager = /*#__PURE__*/function () {
|
|
|
5022
4683
|
}, {
|
|
5023
4684
|
key: "handleSession",
|
|
5024
4685
|
value: function handleSession(session) {
|
|
5025
|
-
|
|
5026
|
-
// not blank out; just ensure our own user is present/updated. Stale
|
|
5027
|
-
// entries are refreshed as member/message collections refetch.
|
|
4686
|
+
this.users.deleteAll();
|
|
5028
4687
|
this.handleUsers([session.user]);
|
|
5029
4688
|
}
|
|
5030
4689
|
}, {
|
|
@@ -5044,12 +4703,6 @@ var UsersManager = /*#__PURE__*/function () {
|
|
|
5044
4703
|
}();
|
|
5045
4704
|
;// ./src/state-tracker/RelationshipsManager.ts
|
|
5046
4705
|
function RelationshipsManager_typeof(o) { "@babel/helpers - typeof"; return RelationshipsManager_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, RelationshipsManager_typeof(o); }
|
|
5047
|
-
function RelationshipsManager_toConsumableArray(r) { return RelationshipsManager_arrayWithoutHoles(r) || RelationshipsManager_iterableToArray(r) || RelationshipsManager_unsupportedIterableToArray(r) || RelationshipsManager_nonIterableSpread(); }
|
|
5048
|
-
function RelationshipsManager_nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5049
|
-
function RelationshipsManager_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return RelationshipsManager_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? RelationshipsManager_arrayLikeToArray(r, a) : void 0; } }
|
|
5050
|
-
function RelationshipsManager_iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
5051
|
-
function RelationshipsManager_arrayWithoutHoles(r) { if (Array.isArray(r)) return RelationshipsManager_arrayLikeToArray(r); }
|
|
5052
|
-
function RelationshipsManager_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5053
4706
|
function RelationshipsManager_regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return RelationshipsManager_regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (RelationshipsManager_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, RelationshipsManager_regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, RelationshipsManager_regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), RelationshipsManager_regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", RelationshipsManager_regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), RelationshipsManager_regeneratorDefine2(u), RelationshipsManager_regeneratorDefine2(u, o, "Generator"), RelationshipsManager_regeneratorDefine2(u, n, function () { return this; }), RelationshipsManager_regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (RelationshipsManager_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
5054
4707
|
function RelationshipsManager_regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } RelationshipsManager_regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { RelationshipsManager_regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, RelationshipsManager_regeneratorDefine2(e, r, n, t); }
|
|
5055
4708
|
function RelationshipsManager_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
@@ -5151,10 +4804,11 @@ var RelationshipsManager = /*#__PURE__*/function () {
|
|
|
5151
4804
|
}, {
|
|
5152
4805
|
key: "handleRelationships",
|
|
5153
4806
|
value: function handleRelationships(ev) {
|
|
5154
|
-
var
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
4807
|
+
var _this3 = this;
|
|
4808
|
+
this.relationships.deleteAll();
|
|
4809
|
+
ev.relationships.forEach(function (relationship) {
|
|
4810
|
+
_this3.relationships.set(relationship);
|
|
4811
|
+
});
|
|
5158
4812
|
}
|
|
5159
4813
|
}, {
|
|
5160
4814
|
key: "handleNewRelationship",
|
|
@@ -5173,9 +4827,8 @@ var RelationshipsManager = /*#__PURE__*/function () {
|
|
|
5173
4827
|
}, {
|
|
5174
4828
|
key: "handleSession",
|
|
5175
4829
|
value: function handleSession() {
|
|
5176
|
-
// Keep the (possibly bound) collection; just drop the fetch guard so the
|
|
5177
|
-
// next get() refetches and reconciles it in place.
|
|
5178
4830
|
this.promises.forgetAll();
|
|
4831
|
+
this.relationships.deleteAll();
|
|
5179
4832
|
}
|
|
5180
4833
|
}]);
|
|
5181
4834
|
}();
|
|
@@ -5274,9 +4927,6 @@ var ChatStateTracker = /*#__PURE__*/function () {
|
|
|
5274
4927
|
}();
|
|
5275
4928
|
;// ./src/WebSocketChatClient.ts
|
|
5276
4929
|
function WebSocketChatClient_typeof(o) { "@babel/helpers - typeof"; return WebSocketChatClient_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, WebSocketChatClient_typeof(o); }
|
|
5277
|
-
function WebSocketChatClient_createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = WebSocketChatClient_unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
5278
|
-
function WebSocketChatClient_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return WebSocketChatClient_arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? WebSocketChatClient_arrayLikeToArray(r, a) : void 0; } }
|
|
5279
|
-
function WebSocketChatClient_arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5280
4930
|
function WebSocketChatClient_regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return WebSocketChatClient_regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (WebSocketChatClient_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, WebSocketChatClient_regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, WebSocketChatClient_regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), WebSocketChatClient_regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", WebSocketChatClient_regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), WebSocketChatClient_regeneratorDefine2(u), WebSocketChatClient_regeneratorDefine2(u, o, "Generator"), WebSocketChatClient_regeneratorDefine2(u, n, function () { return this; }), WebSocketChatClient_regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (WebSocketChatClient_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
5281
4931
|
function WebSocketChatClient_regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } WebSocketChatClient_regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { WebSocketChatClient_regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, WebSocketChatClient_regeneratorDefine2(e, r, n, t); }
|
|
5282
4932
|
function WebSocketChatClient_asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
@@ -5315,13 +4965,7 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5315
4965
|
WebSocketChatClient_defineProperty(_this, "sendQueue", []);
|
|
5316
4966
|
WebSocketChatClient_defineProperty(_this, "connectingTimeoutId", void 0);
|
|
5317
4967
|
WebSocketChatClient_defineProperty(_this, "authenticated", void 0);
|
|
5318
|
-
WebSocketChatClient_defineProperty(_this, "authenticatedResolvers",
|
|
5319
|
-
/**
|
|
5320
|
-
* Pending promise returned by connect(). Kept until the client is either
|
|
5321
|
-
* authenticated or gives up, so that an automatic reconnect settles the
|
|
5322
|
-
* original caller instead of stranding it on a superseded promise.
|
|
5323
|
-
*/
|
|
5324
|
-
WebSocketChatClient_defineProperty(_this, "connectPromise", null);
|
|
4968
|
+
WebSocketChatClient_defineProperty(_this, "authenticatedResolvers", void 0);
|
|
5325
4969
|
WebSocketChatClient_defineProperty(_this, "pingMonitorInterval", void 0);
|
|
5326
4970
|
WebSocketChatClient_defineProperty(_this, "inFlightPingTimeout", void 0);
|
|
5327
4971
|
WebSocketChatClient_defineProperty(_this, "lastReceivedMessageAt", void 0);
|
|
@@ -5340,11 +4984,10 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5340
4984
|
key: "connect",
|
|
5341
4985
|
value: function () {
|
|
5342
4986
|
var _connect = WebSocketChatClient_asyncToGenerator(/*#__PURE__*/WebSocketChatClient_regenerator().m(function _callee() {
|
|
5343
|
-
var _this$
|
|
4987
|
+
var _this$options$queryPa,
|
|
5344
4988
|
_this2 = this,
|
|
5345
|
-
_this$options$queryPa,
|
|
5346
4989
|
_this$options$connect;
|
|
5347
|
-
var
|
|
4990
|
+
var params;
|
|
5348
4991
|
return WebSocketChatClient_regenerator().w(function (_context) {
|
|
5349
4992
|
while (1) switch (_context.n) {
|
|
5350
4993
|
case 0:
|
|
@@ -5352,17 +4995,8 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5352
4995
|
_context.n = 1;
|
|
5353
4996
|
break;
|
|
5354
4997
|
}
|
|
5355
|
-
return _context.a(2
|
|
4998
|
+
return _context.a(2);
|
|
5356
4999
|
case 1:
|
|
5357
|
-
// Reuse the promise of an attempt that has not settled yet (an
|
|
5358
|
-
// automatic reconnect), so the caller that started connecting is
|
|
5359
|
-
// resolved by whichever attempt eventually authenticates.
|
|
5360
|
-
(_this$connectPromise2 = this.connectPromise) !== null && _this$connectPromise2 !== void 0 ? _this$connectPromise2 : this.connectPromise = new Promise(function () {
|
|
5361
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5362
|
-
args[_key] = arguments[_key];
|
|
5363
|
-
}
|
|
5364
|
-
return _this2.authenticatedResolvers = args;
|
|
5365
|
-
});
|
|
5366
5000
|
params = new URLSearchParams((_this$options$queryPa = this.options.queryParams) !== null && _this$options$queryPa !== void 0 ? _this$options$queryPa : {});
|
|
5367
5001
|
params.set('token', this.options.token);
|
|
5368
5002
|
this.ws = new WebSocket("".concat(this.options.url, "?").concat(params));
|
|
@@ -5376,7 +5010,12 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5376
5010
|
return _this2.triggerConnectionTimeout();
|
|
5377
5011
|
}, (_this$options$connect = this.options.connectingTimeoutMs) !== null && _this$options$connect !== void 0 ? _this$options$connect : 10000);
|
|
5378
5012
|
this.authenticated = false;
|
|
5379
|
-
return _context.a(2,
|
|
5013
|
+
return _context.a(2, new Promise(function () {
|
|
5014
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5015
|
+
args[_key] = arguments[_key];
|
|
5016
|
+
}
|
|
5017
|
+
return _this2.authenticatedResolvers = args;
|
|
5018
|
+
}));
|
|
5380
5019
|
}
|
|
5381
5020
|
}, _callee, this);
|
|
5382
5021
|
}));
|
|
@@ -5389,7 +5028,7 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5389
5028
|
key: "disconnect",
|
|
5390
5029
|
value: function disconnect() {
|
|
5391
5030
|
var _this$ws;
|
|
5392
|
-
this.
|
|
5031
|
+
this.sendQueue = [];
|
|
5393
5032
|
(_this$ws = this.ws) === null || _this$ws === void 0 || _this$ws.close(1000); // Normal closure
|
|
5394
5033
|
this.ws = null;
|
|
5395
5034
|
}
|
|
@@ -5450,11 +5089,11 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5450
5089
|
this.authenticated = isAuthenticated;
|
|
5451
5090
|
if (isAuthenticated) {
|
|
5452
5091
|
this.startConnectionMonitor();
|
|
5453
|
-
this.
|
|
5092
|
+
this.authenticatedResolvers[0]();
|
|
5454
5093
|
this.emit(this.Event.connect);
|
|
5455
5094
|
this.sendFromQueue();
|
|
5456
5095
|
} else {
|
|
5457
|
-
this.
|
|
5096
|
+
this.authenticatedResolvers[1](envelope.data);
|
|
5458
5097
|
}
|
|
5459
5098
|
}
|
|
5460
5099
|
}
|
|
@@ -5464,59 +5103,11 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5464
5103
|
this.stopConnectionMonitor();
|
|
5465
5104
|
clearTimeout(this.connectingTimeoutId);
|
|
5466
5105
|
var reconnect = event.code !== 1000; // Connection was closed because of error
|
|
5467
|
-
|
|
5468
|
-
// The server can no longer answer anything that was queued or in
|
|
5469
|
-
// flight, so settle those promises instead of leaving them pending.
|
|
5470
|
-
this.failPendingCommands(new Error('Connection closed before the command was answered'));
|
|
5471
5106
|
if (reconnect) {
|
|
5472
|
-
// Keep a pending connect() promise unsettled - the retry below is
|
|
5473
|
-
// expected to authenticate and will resolve it.
|
|
5474
5107
|
void this.connect();
|
|
5475
|
-
} else {
|
|
5476
|
-
this.settleConnect(new Error('Connection closed before authentication'));
|
|
5477
5108
|
}
|
|
5478
5109
|
this.emit(this.Event.disconnect, reconnect);
|
|
5479
5110
|
}
|
|
5480
|
-
|
|
5481
|
-
/**
|
|
5482
|
-
* Resolve (or reject, when an error is given) a pending connect() promise.
|
|
5483
|
-
* No-op when there is nothing pending.
|
|
5484
|
-
*/
|
|
5485
|
-
}, {
|
|
5486
|
-
key: "settleConnect",
|
|
5487
|
-
value: function settleConnect(error) {
|
|
5488
|
-
var resolvers = this.authenticatedResolvers;
|
|
5489
|
-
this.authenticatedResolvers = null;
|
|
5490
|
-
this.connectPromise = null;
|
|
5491
|
-
if (!resolvers) {
|
|
5492
|
-
return;
|
|
5493
|
-
}
|
|
5494
|
-
error ? resolvers[1](error) : resolvers[0]();
|
|
5495
|
-
}
|
|
5496
|
-
|
|
5497
|
-
/**
|
|
5498
|
-
* Reject every command that has not been answered yet - both the ones still
|
|
5499
|
-
* waiting in the send queue and the ones already sent to the server.
|
|
5500
|
-
*/
|
|
5501
|
-
}, {
|
|
5502
|
-
key: "failPendingCommands",
|
|
5503
|
-
value: function failPendingCommands(error) {
|
|
5504
|
-
var queued = this.sendQueue;
|
|
5505
|
-
this.sendQueue = [];
|
|
5506
|
-
var _iterator = WebSocketChatClient_createForOfIteratorHelper(queued),
|
|
5507
|
-
_step;
|
|
5508
|
-
try {
|
|
5509
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
5510
|
-
var envelope = _step.value;
|
|
5511
|
-
this.handleEnvelopeSendError(envelope, error);
|
|
5512
|
-
}
|
|
5513
|
-
} catch (err) {
|
|
5514
|
-
_iterator.e(err);
|
|
5515
|
-
} finally {
|
|
5516
|
-
_iterator.f();
|
|
5517
|
-
}
|
|
5518
|
-
this.failAwaitingResponses(error);
|
|
5519
|
-
}
|
|
5520
5111
|
}, {
|
|
5521
5112
|
key: "sendFromQueue",
|
|
5522
5113
|
value: function sendFromQueue() {
|
|
@@ -5581,12 +5172,7 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5581
5172
|
_this4.inFlightPingTimeout = undefined;
|
|
5582
5173
|
_this4.ws.close(3000); // Service Restart (reconnect)
|
|
5583
5174
|
}, _this4.options.ping.pongBackTimeoutMs);
|
|
5584
|
-
|
|
5585
|
-
// A rejection here means the connection dropped while the ping was
|
|
5586
|
-
// in flight; onClose already handles that, so just stop waiting.
|
|
5587
|
-
_this4.send('Ping', {})["catch"](function () {
|
|
5588
|
-
return undefined;
|
|
5589
|
-
}).then(function () {
|
|
5175
|
+
_this4.send('Ping', {}).then(function () {
|
|
5590
5176
|
clearTimeout(_this4.inFlightPingTimeout);
|
|
5591
5177
|
_this4.inFlightPingTimeout = undefined;
|
|
5592
5178
|
});
|