polfan-server-js-client 0.2.108 → 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 +8 -3
- package/build/index.cjs.js +105 -520
- 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/state-tracker/FollowedTopicsManager.d.ts +0 -18
- 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/state-tracker/AsyncUtils.ts +0 -11
- package/src/state-tracker/EmoticonsManager.ts +3 -7
- package/src/state-tracker/FollowedTopicsManager.ts +6 -54
- 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
|
}
|
|
@@ -2525,22 +2325,7 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2525
2325
|
}, {
|
|
2526
2326
|
key: "handleSession",
|
|
2527
2327
|
value: function handleSession(ev) {
|
|
2528
|
-
|
|
2529
|
-
// that would otherwise blank on reconnect), but mark them stale and drop
|
|
2530
|
-
// the fetch guards so the next access/caching refetches and reconciles
|
|
2531
|
-
// them in place.
|
|
2532
|
-
var _iterator4 = FollowedTopicsManager_createForOfIteratorHelper(this.followedTopics.items.keys()),
|
|
2533
|
-
_step4;
|
|
2534
|
-
try {
|
|
2535
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
2536
|
-
var roomId = _step4.value;
|
|
2537
|
-
this.staleRooms.add(roomId);
|
|
2538
|
-
}
|
|
2539
|
-
} catch (err) {
|
|
2540
|
-
_iterator4.e(err);
|
|
2541
|
-
} finally {
|
|
2542
|
-
_iterator4.f();
|
|
2543
|
-
}
|
|
2328
|
+
this.followedTopics.deleteAll();
|
|
2544
2329
|
this.followedTopicsPromises.forgetAll();
|
|
2545
2330
|
this.invalidateUnreadSummaries();
|
|
2546
2331
|
this.deferredSession.resolve();
|
|
@@ -2640,34 +2425,34 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2640
2425
|
if (topicId) {
|
|
2641
2426
|
this.summariesCache["delete"]("topic:".concat(roomId, ":").concat(topicId));
|
|
2642
2427
|
} else {
|
|
2643
|
-
var
|
|
2644
|
-
|
|
2428
|
+
var _iterator4 = FollowedTopicsManager_createForOfIteratorHelper(this.summariesCache.keys()),
|
|
2429
|
+
_step4;
|
|
2645
2430
|
try {
|
|
2646
|
-
for (
|
|
2647
|
-
var key =
|
|
2431
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
2432
|
+
var key = _step4.value;
|
|
2648
2433
|
if (key.startsWith("topic:".concat(roomId, ":"))) {
|
|
2649
2434
|
this.summariesCache["delete"](key);
|
|
2650
2435
|
}
|
|
2651
2436
|
}
|
|
2652
2437
|
} catch (err) {
|
|
2653
|
-
|
|
2438
|
+
_iterator4.e(err);
|
|
2654
2439
|
} finally {
|
|
2655
|
-
|
|
2440
|
+
_iterator4.f();
|
|
2656
2441
|
}
|
|
2657
2442
|
}
|
|
2658
|
-
var
|
|
2659
|
-
|
|
2443
|
+
var _iterator5 = FollowedTopicsManager_createForOfIteratorHelper(this.summariesCache.keys()),
|
|
2444
|
+
_step5;
|
|
2660
2445
|
try {
|
|
2661
|
-
for (
|
|
2662
|
-
var _key2 =
|
|
2446
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
2447
|
+
var _key2 = _step5.value;
|
|
2663
2448
|
if (_key2.startsWith('space:') || _key2 === 'spaceless') {
|
|
2664
2449
|
this.summariesCache["delete"](_key2);
|
|
2665
2450
|
}
|
|
2666
2451
|
}
|
|
2667
2452
|
} catch (err) {
|
|
2668
|
-
|
|
2453
|
+
_iterator5.e(err);
|
|
2669
2454
|
} finally {
|
|
2670
|
-
|
|
2455
|
+
_iterator5.f();
|
|
2671
2456
|
}
|
|
2672
2457
|
} else {
|
|
2673
2458
|
this.summariesCache.clear();
|
|
@@ -2682,11 +2467,11 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2682
2467
|
roomIds.forEach(function (roomId) {
|
|
2683
2468
|
_this5.summariesCache["delete"]("room:".concat(roomId));
|
|
2684
2469
|
});
|
|
2685
|
-
var
|
|
2686
|
-
|
|
2470
|
+
var _iterator6 = FollowedTopicsManager_createForOfIteratorHelper(this.summariesCache.keys()),
|
|
2471
|
+
_step6;
|
|
2687
2472
|
try {
|
|
2688
|
-
for (
|
|
2689
|
-
var key =
|
|
2473
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
2474
|
+
var key = _step6.value;
|
|
2690
2475
|
if (key.startsWith('space:') || key === 'spaceless') {
|
|
2691
2476
|
this.summariesCache["delete"](key);
|
|
2692
2477
|
continue;
|
|
@@ -2699,9 +2484,9 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2699
2484
|
}
|
|
2700
2485
|
}
|
|
2701
2486
|
} catch (err) {
|
|
2702
|
-
|
|
2487
|
+
_iterator6.e(err);
|
|
2703
2488
|
} finally {
|
|
2704
|
-
|
|
2489
|
+
_iterator6.f();
|
|
2705
2490
|
}
|
|
2706
2491
|
this.emit('change');
|
|
2707
2492
|
}
|
|
@@ -2779,66 +2564,27 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2779
2564
|
}
|
|
2780
2565
|
return updateLocallyFollowedTopicOnNewMessage;
|
|
2781
2566
|
}()
|
|
2782
|
-
/**
|
|
2783
|
-
* Reconcile the followed-topics collection for a single room to exactly
|
|
2784
|
-
* match the provided list (upsert present, drop absent) without emitting an
|
|
2785
|
-
* intermediate empty state, and clear its stale marker. Does not touch the
|
|
2786
|
-
* unread summaries cache - callers decide how to invalidate it.
|
|
2787
|
-
*/
|
|
2788
|
-
}, {
|
|
2789
|
-
key: "applyRoomFollowedTopics",
|
|
2790
|
-
value: function applyRoomFollowedTopics(roomId, followedTopics) {
|
|
2791
|
-
var _this$followedTopics$5;
|
|
2792
|
-
if (!this.followedTopics.has(roomId)) {
|
|
2793
|
-
this.followedTopics.set([roomId, new ObservableIndexedObjectCollection(function (followedTopic) {
|
|
2794
|
-
return followedTopic.location.topicId;
|
|
2795
|
-
})]);
|
|
2796
|
-
}
|
|
2797
|
-
(_this$followedTopics$5 = this.followedTopics.get(roomId)).reconcile.apply(_this$followedTopics$5, FollowedTopicsManager_toConsumableArray(followedTopics));
|
|
2798
|
-
this.staleRooms["delete"](roomId);
|
|
2799
|
-
}
|
|
2800
|
-
|
|
2801
|
-
/**
|
|
2802
|
-
* Reconcile a batch of rooms from a single bulk GetFollowedTopics response.
|
|
2803
|
-
* Rooms with no followed topics in the response are reconciled to empty, so
|
|
2804
|
-
* topics unfollowed/removed during the downtime are correctly dropped.
|
|
2805
|
-
*/
|
|
2806
|
-
}, {
|
|
2807
|
-
key: "reconcileRoomsFollowedTopics",
|
|
2808
|
-
value: function reconcileRoomsFollowedTopics(roomIds, followedTopics) {
|
|
2809
|
-
var _this6 = this;
|
|
2810
|
-
var roomToTopics = {};
|
|
2811
|
-
followedTopics.forEach(function (followedTopic) {
|
|
2812
|
-
var _followedTopic$locati, _roomToTopics$_follow;
|
|
2813
|
-
((_roomToTopics$_follow = roomToTopics[_followedTopic$locati = followedTopic.location.roomId]) !== null && _roomToTopics$_follow !== void 0 ? _roomToTopics$_follow : roomToTopics[_followedTopic$locati] = []).push(followedTopic);
|
|
2814
|
-
});
|
|
2815
|
-
roomIds.forEach(function (roomId) {
|
|
2816
|
-
var _roomToTopics$roomId;
|
|
2817
|
-
return _this6.applyRoomFollowedTopics(roomId, (_roomToTopics$roomId = roomToTopics[roomId]) !== null && _roomToTopics$roomId !== void 0 ? _roomToTopics$roomId : []);
|
|
2818
|
-
});
|
|
2819
|
-
this.invalidateUnreadSummariesForRooms(roomIds);
|
|
2820
|
-
}
|
|
2821
2567
|
}, {
|
|
2822
2568
|
key: "setFollowedTopicsArray",
|
|
2823
2569
|
value: function setFollowedTopicsArray(roomIds, followedTopics) {
|
|
2824
|
-
var
|
|
2570
|
+
var _this6 = this;
|
|
2825
2571
|
var roomToTopics = {};
|
|
2826
2572
|
|
|
2827
2573
|
// Reassign followed topics to limit collection change event emit
|
|
2828
2574
|
followedTopics.forEach(function (followedTopic) {
|
|
2829
|
-
var _followedTopic$
|
|
2830
|
-
(_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] = [];
|
|
2831
2577
|
roomToTopics[followedTopic.location.roomId].push(followedTopic);
|
|
2832
2578
|
});
|
|
2833
2579
|
roomIds.forEach(function (roomId) {
|
|
2834
|
-
if (!
|
|
2835
|
-
|
|
2580
|
+
if (!_this6.followedTopics.has(roomId)) {
|
|
2581
|
+
_this6.followedTopics.set([roomId, new ObservableIndexedObjectCollection(function (followedTopic) {
|
|
2836
2582
|
return followedTopic.location.topicId;
|
|
2837
2583
|
})]);
|
|
2838
2584
|
}
|
|
2839
2585
|
if (roomToTopics[roomId]) {
|
|
2840
|
-
var
|
|
2841
|
-
(
|
|
2586
|
+
var _this6$followedTopics;
|
|
2587
|
+
(_this6$followedTopics = _this6.followedTopics.get(roomId)).set.apply(_this6$followedTopics, FollowedTopicsManager_toConsumableArray(roomToTopics[roomId]));
|
|
2842
2588
|
}
|
|
2843
2589
|
});
|
|
2844
2590
|
this.invalidateUnreadSummariesForRooms(roomIds);
|
|
@@ -2848,7 +2594,6 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
2848
2594
|
value: function clearRoomFollowedTopicsStructures(roomId) {
|
|
2849
2595
|
this.followedTopics["delete"](roomId);
|
|
2850
2596
|
this.followedTopicsPromises.forget(roomId);
|
|
2851
|
-
this.staleRooms["delete"](roomId);
|
|
2852
2597
|
this.invalidateUnreadSummaries(roomId);
|
|
2853
2598
|
}
|
|
2854
2599
|
}]);
|
|
@@ -3364,39 +3109,16 @@ var RoomsManager = /*#__PURE__*/function () {
|
|
|
3364
3109
|
var _member$user$id2, _member$user2;
|
|
3365
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;
|
|
3366
3111
|
}, ev.members)]);
|
|
3367
|
-
} else {
|
|
3368
|
-
var _this$members$get;
|
|
3369
|
-
// Reconcile into the existing (bound) collection so a reconnect
|
|
3370
|
-
// refetch updates it in place instead of leaving stale members.
|
|
3371
|
-
(_this$members$get = this.members.get(ev.id)).reconcile.apply(_this$members$get, RoomsManager_toConsumableArray(ev.members));
|
|
3372
3112
|
}
|
|
3373
3113
|
}
|
|
3374
3114
|
}, {
|
|
3375
3115
|
key: "handleSession",
|
|
3376
3116
|
value: function handleSession(ev) {
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
}));
|
|
3380
|
-
|
|
3381
|
-
// Remove only rooms that were left/deleted on the server during the
|
|
3382
|
-
// downtime, reusing the cascade cleanup (members, topics, followed
|
|
3383
|
-
// topics). Surviving rooms keep their identity and bindings.
|
|
3384
|
-
var removedRoomIds = this.list.items.filter(function (room) {
|
|
3385
|
-
return !stateRoomIds.has(room.id);
|
|
3386
|
-
}).map(function (room) {
|
|
3387
|
-
return room.id;
|
|
3388
|
-
});
|
|
3389
|
-
if (removedRoomIds.length) {
|
|
3390
|
-
this.deleteRoom.apply(this, RoomsManager_toConsumableArray(removedRoomIds));
|
|
3391
|
-
}
|
|
3392
|
-
|
|
3393
|
-
// Invalidate lazy caches so the next access refetches fresh data, but
|
|
3394
|
-
// keep the collection objects: handleRoomMembers reconciles into them,
|
|
3395
|
-
// so bound views refresh in place without blanking.
|
|
3396
|
-
this.membersPromises.forgetAll();
|
|
3117
|
+
this.list.deleteAll();
|
|
3118
|
+
this.topics.deleteAll();
|
|
3397
3119
|
this.topicsPromises.forgetAll();
|
|
3398
|
-
|
|
3399
|
-
|
|
3120
|
+
this.members.deleteAll();
|
|
3121
|
+
this.membersPromises.forgetAll();
|
|
3400
3122
|
this.addJoinedRooms.apply(this, RoomsManager_toConsumableArray(ev.state.rooms));
|
|
3401
3123
|
this.deferredSession.resolve();
|
|
3402
3124
|
}
|
|
@@ -3530,7 +3252,6 @@ function extractUserFromMember(member) {
|
|
|
3530
3252
|
}
|
|
3531
3253
|
;// ./src/state-tracker/SpacesManager.ts
|
|
3532
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); }
|
|
3533
|
-
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; } } }; }
|
|
3534
3255
|
function SpacesManager_toConsumableArray(r) { return SpacesManager_arrayWithoutHoles(r) || SpacesManager_iterableToArray(r) || SpacesManager_unsupportedIterableToArray(r) || SpacesManager_nonIterableSpread(); }
|
|
3535
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."); }
|
|
3536
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; } }
|
|
@@ -3934,11 +3655,6 @@ var SpacesManager = /*#__PURE__*/function () {
|
|
|
3934
3655
|
this.members.set([ev.id, new ObservableIndexedObjectCollection(function (member) {
|
|
3935
3656
|
return member === null || member === void 0 ? void 0 : member.user.id;
|
|
3936
3657
|
}, ev.members)]);
|
|
3937
|
-
} else {
|
|
3938
|
-
var _this$members$get;
|
|
3939
|
-
// Reconcile into the existing (bound) collection so a reconnect
|
|
3940
|
-
// refetch updates it in place instead of leaving stale members.
|
|
3941
|
-
(_this$members$get = this.members.get(ev.id)).reconcile.apply(_this$members$get, SpacesManager_toConsumableArray(ev.members));
|
|
3942
3658
|
}
|
|
3943
3659
|
}
|
|
3944
3660
|
}, {
|
|
@@ -3947,13 +3663,10 @@ var SpacesManager = /*#__PURE__*/function () {
|
|
|
3947
3663
|
var _this4 = this;
|
|
3948
3664
|
if (!this.rooms.has(ev.id)) {
|
|
3949
3665
|
this.rooms.set([ev.id, new ObservableIndexedObjectCollection('id', ev.summaries)]);
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3666
|
+
ev.summaries.forEach(function (summary) {
|
|
3667
|
+
return _this4.roomIdToSpaceId.set([summary.id, ev.id]);
|
|
3668
|
+
});
|
|
3953
3669
|
}
|
|
3954
|
-
ev.summaries.forEach(function (summary) {
|
|
3955
|
-
return _this4.roomIdToSpaceId.set([summary.id, ev.id]);
|
|
3956
|
-
});
|
|
3957
3670
|
}
|
|
3958
3671
|
}, {
|
|
3959
3672
|
key: "handleRoomSummaryUpdated",
|
|
@@ -4021,58 +3734,14 @@ var SpacesManager = /*#__PURE__*/function () {
|
|
|
4021
3734
|
}, {
|
|
4022
3735
|
key: "handleSession",
|
|
4023
3736
|
value: function handleSession(ev) {
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
}));
|
|
4028
|
-
|
|
4029
|
-
// Remove only spaces that were left/deleted on the server during the
|
|
4030
|
-
// downtime, reusing the cascade cleanup (roles, rooms, members, index).
|
|
4031
|
-
var removedSpaceIds = this.list.items.filter(function (space) {
|
|
4032
|
-
return !stateSpaceIds.has(space.id);
|
|
4033
|
-
}).map(function (space) {
|
|
4034
|
-
return space.id;
|
|
4035
|
-
});
|
|
4036
|
-
var _iterator = SpacesManager_createForOfIteratorHelper(removedSpaceIds),
|
|
4037
|
-
_step;
|
|
4038
|
-
try {
|
|
4039
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4040
|
-
var spaceId = _step.value;
|
|
4041
|
-
this.handleSpaceDeleted({
|
|
4042
|
-
id: spaceId
|
|
4043
|
-
});
|
|
4044
|
-
}
|
|
4045
|
-
|
|
4046
|
-
// Invalidate lazy caches (rooms/members) but keep their objects so the
|
|
4047
|
-
// next access refetches and reconciles them in place.
|
|
4048
|
-
} catch (err) {
|
|
4049
|
-
_iterator.e(err);
|
|
4050
|
-
} finally {
|
|
4051
|
-
_iterator.f();
|
|
4052
|
-
}
|
|
3737
|
+
this.list.deleteAll();
|
|
3738
|
+
this.roles.deleteAll();
|
|
3739
|
+
this.rooms.deleteAll();
|
|
4053
3740
|
this.roomsPromises.forgetAll();
|
|
3741
|
+
this.members.deleteAll();
|
|
4054
3742
|
this.membersPromises.forgetAll();
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
// spaces from the authoritative snapshot.
|
|
4058
|
-
var _iterator2 = SpacesManager_createForOfIteratorHelper(ev.state.spaces),
|
|
4059
|
-
_step2;
|
|
4060
|
-
try {
|
|
4061
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
4062
|
-
var space = _step2.value;
|
|
4063
|
-
if (this.roles.has(space.id)) {
|
|
4064
|
-
var _this$roles$get2;
|
|
4065
|
-
(_this$roles$get2 = this.roles.get(space.id)).reconcile.apply(_this$roles$get2, SpacesManager_toConsumableArray(space.roles));
|
|
4066
|
-
} else {
|
|
4067
|
-
this.roles.set([space.id, new ObservableIndexedObjectCollection('id', space.roles)]);
|
|
4068
|
-
}
|
|
4069
|
-
}
|
|
4070
|
-
} catch (err) {
|
|
4071
|
-
_iterator2.e(err);
|
|
4072
|
-
} finally {
|
|
4073
|
-
_iterator2.f();
|
|
4074
|
-
}
|
|
4075
|
-
(_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));
|
|
4076
3745
|
this.deferredSession.resolve();
|
|
4077
3746
|
}
|
|
4078
3747
|
}, {
|
|
@@ -4796,12 +4465,8 @@ var PermissionsManager = /*#__PURE__*/function (_EventTarget) {
|
|
|
4796
4465
|
}, {
|
|
4797
4466
|
key: "handleSession",
|
|
4798
4467
|
value: function handleSession(ev) {
|
|
4799
|
-
|
|
4800
|
-
// overwrites (getOverwrites refetches and upserts on the next access),
|
|
4801
|
-
// and notify consumers to recompute so bound permission UI is never
|
|
4802
|
-
// left showing stale results after a reconnect.
|
|
4468
|
+
this.overwrites.deleteAll();
|
|
4803
4469
|
this.overwritesPromises.forgetAll();
|
|
4804
|
-
this.emit('change');
|
|
4805
4470
|
}
|
|
4806
4471
|
}]);
|
|
4807
4472
|
}(EventTarget);
|
|
@@ -4899,16 +4564,13 @@ var EmoticonsManager = /*#__PURE__*/function () {
|
|
|
4899
4564
|
}, {
|
|
4900
4565
|
key: "handleEmoticons",
|
|
4901
4566
|
value: function handleEmoticons(event) {
|
|
4902
|
-
var _event$location$space
|
|
4567
|
+
var _event$location$space;
|
|
4903
4568
|
var spaceId = (_event$location$space = event.location.spaceId) !== null && _event$location$space !== void 0 ? _event$location$space : GLOBAL_KEY;
|
|
4904
4569
|
if (!this.list.has(spaceId)) {
|
|
4905
4570
|
this.list.set([spaceId, new ObservableIndexedObjectCollection('id')]);
|
|
4906
4571
|
}
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
// reconcile in place: a reconnect refetch drops removed emoticons and
|
|
4910
|
-
// adds new ones without blanking a bound (visible) collection.
|
|
4911
|
-
(_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));
|
|
4912
4574
|
}
|
|
4913
4575
|
}, {
|
|
4914
4576
|
key: "handleNewEmoticon",
|
|
@@ -4932,9 +4594,7 @@ var EmoticonsManager = /*#__PURE__*/function () {
|
|
|
4932
4594
|
}, {
|
|
4933
4595
|
key: "handleSession",
|
|
4934
4596
|
value: function handleSession() {
|
|
4935
|
-
|
|
4936
|
-
// pickers); just drop the fetch guards so the next access refetches and
|
|
4937
|
-
// reconciles them in place.
|
|
4597
|
+
this.list.deleteAll();
|
|
4938
4598
|
this.emoticonsPromises.forgetAll();
|
|
4939
4599
|
}
|
|
4940
4600
|
}]);
|
|
@@ -5023,9 +4683,7 @@ var UsersManager = /*#__PURE__*/function () {
|
|
|
5023
4683
|
}, {
|
|
5024
4684
|
key: "handleSession",
|
|
5025
4685
|
value: function handleSession(session) {
|
|
5026
|
-
|
|
5027
|
-
// not blank out; just ensure our own user is present/updated. Stale
|
|
5028
|
-
// entries are refreshed as member/message collections refetch.
|
|
4686
|
+
this.users.deleteAll();
|
|
5029
4687
|
this.handleUsers([session.user]);
|
|
5030
4688
|
}
|
|
5031
4689
|
}, {
|
|
@@ -5045,12 +4703,6 @@ var UsersManager = /*#__PURE__*/function () {
|
|
|
5045
4703
|
}();
|
|
5046
4704
|
;// ./src/state-tracker/RelationshipsManager.ts
|
|
5047
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); }
|
|
5048
|
-
function RelationshipsManager_toConsumableArray(r) { return RelationshipsManager_arrayWithoutHoles(r) || RelationshipsManager_iterableToArray(r) || RelationshipsManager_unsupportedIterableToArray(r) || RelationshipsManager_nonIterableSpread(); }
|
|
5049
|
-
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."); }
|
|
5050
|
-
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; } }
|
|
5051
|
-
function RelationshipsManager_iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
5052
|
-
function RelationshipsManager_arrayWithoutHoles(r) { if (Array.isArray(r)) return RelationshipsManager_arrayLikeToArray(r); }
|
|
5053
|
-
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; }
|
|
5054
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 }; })(); }
|
|
5055
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); }
|
|
5056
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); }
|
|
@@ -5152,10 +4804,11 @@ var RelationshipsManager = /*#__PURE__*/function () {
|
|
|
5152
4804
|
}, {
|
|
5153
4805
|
key: "handleRelationships",
|
|
5154
4806
|
value: function handleRelationships(ev) {
|
|
5155
|
-
var
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
4807
|
+
var _this3 = this;
|
|
4808
|
+
this.relationships.deleteAll();
|
|
4809
|
+
ev.relationships.forEach(function (relationship) {
|
|
4810
|
+
_this3.relationships.set(relationship);
|
|
4811
|
+
});
|
|
5159
4812
|
}
|
|
5160
4813
|
}, {
|
|
5161
4814
|
key: "handleNewRelationship",
|
|
@@ -5174,9 +4827,8 @@ var RelationshipsManager = /*#__PURE__*/function () {
|
|
|
5174
4827
|
}, {
|
|
5175
4828
|
key: "handleSession",
|
|
5176
4829
|
value: function handleSession() {
|
|
5177
|
-
// Keep the (possibly bound) collection; just drop the fetch guard so the
|
|
5178
|
-
// next get() refetches and reconciles it in place.
|
|
5179
4830
|
this.promises.forgetAll();
|
|
4831
|
+
this.relationships.deleteAll();
|
|
5180
4832
|
}
|
|
5181
4833
|
}]);
|
|
5182
4834
|
}();
|
|
@@ -5275,9 +4927,6 @@ var ChatStateTracker = /*#__PURE__*/function () {
|
|
|
5275
4927
|
}();
|
|
5276
4928
|
;// ./src/WebSocketChatClient.ts
|
|
5277
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); }
|
|
5278
|
-
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; } } }; }
|
|
5279
|
-
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; } }
|
|
5280
|
-
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; }
|
|
5281
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 }; })(); }
|
|
5282
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); }
|
|
5283
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); }
|
|
@@ -5316,13 +4965,7 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5316
4965
|
WebSocketChatClient_defineProperty(_this, "sendQueue", []);
|
|
5317
4966
|
WebSocketChatClient_defineProperty(_this, "connectingTimeoutId", void 0);
|
|
5318
4967
|
WebSocketChatClient_defineProperty(_this, "authenticated", void 0);
|
|
5319
|
-
WebSocketChatClient_defineProperty(_this, "authenticatedResolvers",
|
|
5320
|
-
/**
|
|
5321
|
-
* Pending promise returned by connect(). Kept until the client is either
|
|
5322
|
-
* authenticated or gives up, so that an automatic reconnect settles the
|
|
5323
|
-
* original caller instead of stranding it on a superseded promise.
|
|
5324
|
-
*/
|
|
5325
|
-
WebSocketChatClient_defineProperty(_this, "connectPromise", null);
|
|
4968
|
+
WebSocketChatClient_defineProperty(_this, "authenticatedResolvers", void 0);
|
|
5326
4969
|
WebSocketChatClient_defineProperty(_this, "pingMonitorInterval", void 0);
|
|
5327
4970
|
WebSocketChatClient_defineProperty(_this, "inFlightPingTimeout", void 0);
|
|
5328
4971
|
WebSocketChatClient_defineProperty(_this, "lastReceivedMessageAt", void 0);
|
|
@@ -5341,11 +4984,10 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5341
4984
|
key: "connect",
|
|
5342
4985
|
value: function () {
|
|
5343
4986
|
var _connect = WebSocketChatClient_asyncToGenerator(/*#__PURE__*/WebSocketChatClient_regenerator().m(function _callee() {
|
|
5344
|
-
var _this$
|
|
4987
|
+
var _this$options$queryPa,
|
|
5345
4988
|
_this2 = this,
|
|
5346
|
-
_this$options$queryPa,
|
|
5347
4989
|
_this$options$connect;
|
|
5348
|
-
var
|
|
4990
|
+
var params;
|
|
5349
4991
|
return WebSocketChatClient_regenerator().w(function (_context) {
|
|
5350
4992
|
while (1) switch (_context.n) {
|
|
5351
4993
|
case 0:
|
|
@@ -5353,17 +4995,8 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5353
4995
|
_context.n = 1;
|
|
5354
4996
|
break;
|
|
5355
4997
|
}
|
|
5356
|
-
return _context.a(2
|
|
4998
|
+
return _context.a(2);
|
|
5357
4999
|
case 1:
|
|
5358
|
-
// Reuse the promise of an attempt that has not settled yet (an
|
|
5359
|
-
// automatic reconnect), so the caller that started connecting is
|
|
5360
|
-
// resolved by whichever attempt eventually authenticates.
|
|
5361
|
-
(_this$connectPromise2 = this.connectPromise) !== null && _this$connectPromise2 !== void 0 ? _this$connectPromise2 : this.connectPromise = new Promise(function () {
|
|
5362
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5363
|
-
args[_key] = arguments[_key];
|
|
5364
|
-
}
|
|
5365
|
-
return _this2.authenticatedResolvers = args;
|
|
5366
|
-
});
|
|
5367
5000
|
params = new URLSearchParams((_this$options$queryPa = this.options.queryParams) !== null && _this$options$queryPa !== void 0 ? _this$options$queryPa : {});
|
|
5368
5001
|
params.set('token', this.options.token);
|
|
5369
5002
|
this.ws = new WebSocket("".concat(this.options.url, "?").concat(params));
|
|
@@ -5377,7 +5010,12 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5377
5010
|
return _this2.triggerConnectionTimeout();
|
|
5378
5011
|
}, (_this$options$connect = this.options.connectingTimeoutMs) !== null && _this$options$connect !== void 0 ? _this$options$connect : 10000);
|
|
5379
5012
|
this.authenticated = false;
|
|
5380
|
-
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
|
+
}));
|
|
5381
5019
|
}
|
|
5382
5020
|
}, _callee, this);
|
|
5383
5021
|
}));
|
|
@@ -5390,7 +5028,7 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5390
5028
|
key: "disconnect",
|
|
5391
5029
|
value: function disconnect() {
|
|
5392
5030
|
var _this$ws;
|
|
5393
|
-
this.
|
|
5031
|
+
this.sendQueue = [];
|
|
5394
5032
|
(_this$ws = this.ws) === null || _this$ws === void 0 || _this$ws.close(1000); // Normal closure
|
|
5395
5033
|
this.ws = null;
|
|
5396
5034
|
}
|
|
@@ -5451,11 +5089,11 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5451
5089
|
this.authenticated = isAuthenticated;
|
|
5452
5090
|
if (isAuthenticated) {
|
|
5453
5091
|
this.startConnectionMonitor();
|
|
5454
|
-
this.
|
|
5092
|
+
this.authenticatedResolvers[0]();
|
|
5455
5093
|
this.emit(this.Event.connect);
|
|
5456
5094
|
this.sendFromQueue();
|
|
5457
5095
|
} else {
|
|
5458
|
-
this.
|
|
5096
|
+
this.authenticatedResolvers[1](envelope.data);
|
|
5459
5097
|
}
|
|
5460
5098
|
}
|
|
5461
5099
|
}
|
|
@@ -5465,59 +5103,11 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5465
5103
|
this.stopConnectionMonitor();
|
|
5466
5104
|
clearTimeout(this.connectingTimeoutId);
|
|
5467
5105
|
var reconnect = event.code !== 1000; // Connection was closed because of error
|
|
5468
|
-
|
|
5469
|
-
// The server can no longer answer anything that was queued or in
|
|
5470
|
-
// flight, so settle those promises instead of leaving them pending.
|
|
5471
|
-
this.failPendingCommands(new Error('Connection closed before the command was answered'));
|
|
5472
5106
|
if (reconnect) {
|
|
5473
|
-
// Keep a pending connect() promise unsettled - the retry below is
|
|
5474
|
-
// expected to authenticate and will resolve it.
|
|
5475
5107
|
void this.connect();
|
|
5476
|
-
} else {
|
|
5477
|
-
this.settleConnect(new Error('Connection closed before authentication'));
|
|
5478
5108
|
}
|
|
5479
5109
|
this.emit(this.Event.disconnect, reconnect);
|
|
5480
5110
|
}
|
|
5481
|
-
|
|
5482
|
-
/**
|
|
5483
|
-
* Resolve (or reject, when an error is given) a pending connect() promise.
|
|
5484
|
-
* No-op when there is nothing pending.
|
|
5485
|
-
*/
|
|
5486
|
-
}, {
|
|
5487
|
-
key: "settleConnect",
|
|
5488
|
-
value: function settleConnect(error) {
|
|
5489
|
-
var resolvers = this.authenticatedResolvers;
|
|
5490
|
-
this.authenticatedResolvers = null;
|
|
5491
|
-
this.connectPromise = null;
|
|
5492
|
-
if (!resolvers) {
|
|
5493
|
-
return;
|
|
5494
|
-
}
|
|
5495
|
-
error ? resolvers[1](error) : resolvers[0]();
|
|
5496
|
-
}
|
|
5497
|
-
|
|
5498
|
-
/**
|
|
5499
|
-
* Reject every command that has not been answered yet - both the ones still
|
|
5500
|
-
* waiting in the send queue and the ones already sent to the server.
|
|
5501
|
-
*/
|
|
5502
|
-
}, {
|
|
5503
|
-
key: "failPendingCommands",
|
|
5504
|
-
value: function failPendingCommands(error) {
|
|
5505
|
-
var queued = this.sendQueue;
|
|
5506
|
-
this.sendQueue = [];
|
|
5507
|
-
var _iterator = WebSocketChatClient_createForOfIteratorHelper(queued),
|
|
5508
|
-
_step;
|
|
5509
|
-
try {
|
|
5510
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
5511
|
-
var envelope = _step.value;
|
|
5512
|
-
this.handleEnvelopeSendError(envelope, error);
|
|
5513
|
-
}
|
|
5514
|
-
} catch (err) {
|
|
5515
|
-
_iterator.e(err);
|
|
5516
|
-
} finally {
|
|
5517
|
-
_iterator.f();
|
|
5518
|
-
}
|
|
5519
|
-
this.failAwaitingResponses(error);
|
|
5520
|
-
}
|
|
5521
5111
|
}, {
|
|
5522
5112
|
key: "sendFromQueue",
|
|
5523
5113
|
value: function sendFromQueue() {
|
|
@@ -5582,12 +5172,7 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
|
|
|
5582
5172
|
_this4.inFlightPingTimeout = undefined;
|
|
5583
5173
|
_this4.ws.close(3000); // Service Restart (reconnect)
|
|
5584
5174
|
}, _this4.options.ping.pongBackTimeoutMs);
|
|
5585
|
-
|
|
5586
|
-
// A rejection here means the connection dropped while the ping was
|
|
5587
|
-
// in flight; onClose already handles that, so just stop waiting.
|
|
5588
|
-
_this4.send('Ping', {})["catch"](function () {
|
|
5589
|
-
return undefined;
|
|
5590
|
-
}).then(function () {
|
|
5175
|
+
_this4.send('Ping', {}).then(function () {
|
|
5591
5176
|
clearTimeout(_this4.inFlightPingTimeout);
|
|
5592
5177
|
_this4.inFlightPingTimeout = undefined;
|
|
5593
5178
|
});
|