polfan-server-js-client 0.2.106 → 0.2.108

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.
@@ -4,7 +4,10 @@
4
4
  <option name="autoReloadType" value="SELECTIVE" />
5
5
  </component>
6
6
  <component name="ChangeListManager">
7
- <list default="true" id="831dae43-0da1-47fd-a5f7-33dd5eec2992" name="Changes" comment="Fix jumpTo when window is in LIVE state" />
7
+ <list default="true" id="831dae43-0da1-47fd-a5f7-33dd5eec2992" name="Changes" comment="Bump version">
8
+ <change beforePath="$PROJECT_DIR$/src/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.ts" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/src/state-tracker/FollowedTopicsManager.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/state-tracker/FollowedTopicsManager.ts" afterDir="false" />
10
+ </list>
8
11
  <option name="SHOW_DIALOG" value="false" />
9
12
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
13
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -28,6 +31,7 @@
28
31
  </option>
29
32
  <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
30
33
  <option name="ROOT_SYNC" value="DONT_SYNC" />
34
+ <option name="UPDATE_TYPE" value="REBASE" />
31
35
  </component>
32
36
  <component name="GitHubPullRequestSearchHistory">{
33
37
  &quot;lastFilter&quot;: {
@@ -68,7 +72,7 @@
68
72
  "codeWithMe.voiceChat.enabledByDefault": "false",
69
73
  "com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true",
70
74
  "git-widget-placeholder": "claude/chat-state-tracker-reconnect-6s4eha",
71
- "git.auto.fetch.suggestion.counter": "2",
75
+ "git.auto.fetch.suggestion.counter": "3",
72
76
  "ignore.virus.scanning.warn.message": "true",
73
77
  "junie.onboarding.icon.badge.shown": "true",
74
78
  "last_opened_file_path": "//wsl.localhost/Debian/home/jarek/polfan-js-client-library",
@@ -226,23 +230,7 @@
226
230
  <workItem from="1783939298935" duration="21428000" />
227
231
  <workItem from="1784102649250" duration="12484000" />
228
232
  <workItem from="1784524117686" duration="79000" />
229
- <workItem from="1784562428378" duration="8399000" />
230
- </task>
231
- <task id="LOCAL-00057" summary="Ephemeral room history support">
232
- <option name="closed" value="true" />
233
- <created>1756051989192</created>
234
- <option name="number" value="00057" />
235
- <option name="presentableId" value="LOCAL-00057" />
236
- <option name="project" value="LOCAL" />
237
- <updated>1756051989192</updated>
238
- </task>
239
- <task id="LOCAL-00058" summary="Protocol version support">
240
- <option name="closed" value="true" />
241
- <created>1756053336494</created>
242
- <option name="number" value="00058" />
243
- <option name="presentableId" value="LOCAL-00058" />
244
- <option name="project" value="LOCAL" />
245
- <updated>1756053336494</updated>
233
+ <workItem from="1784562428378" duration="12919000" />
246
234
  </task>
247
235
  <task id="LOCAL-00059" summary="Update room on recipient user change">
248
236
  <option name="closed" value="true" />
@@ -620,7 +608,23 @@
620
608
  <option name="project" value="LOCAL" />
621
609
  <updated>1784734559954</updated>
622
610
  </task>
623
- <option name="localTasksCounter" value="106" />
611
+ <task id="LOCAL-00106" summary="Bump version">
612
+ <option name="closed" value="true" />
613
+ <created>1784995701121</created>
614
+ <option name="number" value="00106" />
615
+ <option name="presentableId" value="LOCAL-00106" />
616
+ <option name="project" value="LOCAL" />
617
+ <updated>1784995701121</updated>
618
+ </task>
619
+ <task id="LOCAL-00107" summary="Bump version">
620
+ <option name="closed" value="true" />
621
+ <created>1784998935309</created>
622
+ <option name="number" value="00107" />
623
+ <option name="presentableId" value="LOCAL-00107" />
624
+ <option name="project" value="LOCAL" />
625
+ <updated>1784998935309</updated>
626
+ </task>
627
+ <option name="localTasksCounter" value="108" />
624
628
  <servers />
625
629
  </component>
626
630
  <component name="TypeScriptGeneratedFilesManager">
@@ -670,7 +674,6 @@
670
674
  </option>
671
675
  </component>
672
676
  <component name="VcsManagerConfiguration">
673
- <MESSAGE value="Remove unused exports" />
674
677
  <MESSAGE value="Added abuse reports and message redaction types" />
675
678
  <MESSAGE value="Added new permission" />
676
679
  <MESSAGE value="WIP: delete redacted messages" />
@@ -695,7 +698,8 @@
695
698
  <MESSAGE value="Fixes in WebApiChatClient" />
696
699
  <MESSAGE value="Fix resolve window status after jump to message" />
697
700
  <MESSAGE value="Fix jumpTo when window is in LIVE state" />
698
- <option name="LAST_COMMIT_MESSAGE" value="Fix jumpTo when window is in LIVE state" />
701
+ <MESSAGE value="Bump version" />
702
+ <option name="LAST_COMMIT_MESSAGE" value="Bump version" />
699
703
  </component>
700
704
  <component name="XSLT-Support.FileAssociations.UIState">
701
705
  <expand />
@@ -118,6 +118,12 @@ 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; }
121
127
  function AbstractChatClient_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
122
128
  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); } }
123
129
  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; }
@@ -187,6 +193,30 @@ var AbstractChatClient = /*#__PURE__*/function (_EventTarget) {
187
193
  this.awaitingResponse.get(envelope.ref)[1](error);
188
194
  this.awaitingResponse["delete"](envelope.ref);
189
195
  }
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
+ }
190
220
  }]);
191
221
  }(EventTarget);
192
222
 
@@ -209,17 +239,17 @@ function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !==
209
239
  function IndexedObjectCollection_getPrototypeOf(t) { return IndexedObjectCollection_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, IndexedObjectCollection_getPrototypeOf(t); }
210
240
  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); }
211
241
  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); }
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(); }
242
+ function IndexedObjectCollection_slicedToArray(r, e) { return IndexedObjectCollection_arrayWithHoles(r) || IndexedObjectCollection_iterableToArrayLimit(r, e) || IndexedObjectCollection_unsupportedIterableToArray(r, e) || IndexedObjectCollection_nonIterableRest(); }
243
+ function IndexedObjectCollection_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."); }
244
+ function IndexedObjectCollection_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; } }
245
+ function IndexedObjectCollection_arrayWithHoles(r) { if (Array.isArray(r)) return r; }
246
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = IndexedObjectCollection_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; } } }; }
247
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || IndexedObjectCollection_unsupportedIterableToArray(r) || _nonIterableSpread(); }
218
248
  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."); }
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; } }
249
+ function IndexedObjectCollection_unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return IndexedObjectCollection_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) ? IndexedObjectCollection_arrayLikeToArray(r, a) : void 0; } }
220
250
  function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
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; }
251
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return IndexedObjectCollection_arrayLikeToArray(r); }
252
+ function IndexedObjectCollection_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; }
223
253
  function IndexedObjectCollection_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
224
254
  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); } }
225
255
  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; }
@@ -290,7 +320,7 @@ var IndexedCollection = /*#__PURE__*/function () {
290
320
  _step;
291
321
  try {
292
322
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
293
- var _step$value = _slicedToArray(_step.value, 2),
323
+ var _step$value = IndexedObjectCollection_slicedToArray(_step.value, 2),
294
324
  key = _step$value[0],
295
325
  value = _step$value[1];
296
326
  if (result.length >= limit) {
@@ -648,7 +678,19 @@ var PromiseRegistry = /*#__PURE__*/function () {
648
678
  return AsyncUtils_createClass(PromiseRegistry, [{
649
679
  key: "register",
650
680
  value: function register(promise, key) {
681
+ var _this2 = this;
651
682
  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
+ });
652
694
  }
653
695
  }, {
654
696
  key: "registerByFunction",
@@ -1689,9 +1731,9 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
1689
1731
  key: "resync",
1690
1732
  value: (function () {
1691
1733
  var _resync = RoomMessagesHistory_asyncToGenerator(/*#__PURE__*/RoomMessagesHistory_regenerator().m(function _callee2(room) {
1692
- var _i, _Array$from, _Array$from$_i, window;
1734
+ var _i, _Array$from, _Array$from$_i, window, _t;
1693
1735
  return RoomMessagesHistory_regenerator().w(function (_context2) {
1694
- while (1) switch (_context2.n) {
1736
+ while (1) switch (_context2.p = _context2.n) {
1695
1737
  case 0:
1696
1738
  this.room = room;
1697
1739
  this.updateTraverseLock(room);
@@ -1701,33 +1743,40 @@ var RoomMessagesHistory = /*#__PURE__*/function () {
1701
1743
  _i = 0, _Array$from = Array.from(this.historyWindows.items);
1702
1744
  case 1:
1703
1745
  if (!(_i < _Array$from.length)) {
1704
- _context2.n = 5;
1746
+ _context2.n = 8;
1705
1747
  break;
1706
1748
  }
1707
1749
  _Array$from$_i = RoomMessagesHistory_slicedToArray(_Array$from[_i], 2), window = _Array$from$_i[1];
1708
- _context2.n = 2;
1750
+ _context2.p = 2;
1751
+ _context2.n = 3;
1709
1752
  return window.setTraverseLock(this.traverseLock);
1710
- case 2:
1753
+ case 3:
1711
1754
  if (!this.traverseLock) {
1712
- _context2.n = 3;
1755
+ _context2.n = 4;
1713
1756
  break;
1714
1757
  }
1715
- return _context2.a(3, 4);
1716
- case 3:
1758
+ return _context2.a(3, 7);
1759
+ case 4:
1717
1760
  if (!(window.state === WindowState.LATEST)) {
1718
- _context2.n = 4;
1761
+ _context2.n = 5;
1719
1762
  break;
1720
1763
  }
1721
- _context2.n = 4;
1764
+ _context2.n = 5;
1722
1765
  return window.resetToLatest(true);
1723
- case 4:
1766
+ case 5:
1767
+ _context2.n = 7;
1768
+ break;
1769
+ case 6:
1770
+ _context2.p = 6;
1771
+ _t = _context2.v;
1772
+ case 7:
1724
1773
  _i++;
1725
1774
  _context2.n = 1;
1726
1775
  break;
1727
- case 5:
1776
+ case 8:
1728
1777
  return _context2.a(2);
1729
1778
  }
1730
- }, _callee2, this);
1779
+ }, _callee2, this, [[2, 6]]);
1731
1780
  }));
1732
1781
  function resync(_x2) {
1733
1782
  return _resync.apply(this, arguments);
@@ -2310,7 +2359,7 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
2310
2359
  key: "summarize",
2311
2360
  value: (function () {
2312
2361
  var _summarize = FollowedTopicsManager_asyncToGenerator(/*#__PURE__*/FollowedTopicsManager_regenerator().m(function _callee6(location) {
2313
- var cacheKey, roomIds, targetTopicId, rooms, mentionCount, isUnread, _iterator2, _step2, roomId, collection, _iterator3, _step3, _topic$mentionCount, topic, result, _t3, _t4;
2362
+ var cacheKey, roomIds, targetTopicId, rooms, mentionCount, unreadTopicCount, _iterator2, _step2, roomId, collection, _iterator3, _step3, _topic$mentionCount, topic, result, _t3, _t4;
2314
2363
  return FollowedTopicsManager_regenerator().w(function (_context6) {
2315
2364
  while (1) switch (_context6.p = _context6.n) {
2316
2365
  case 0:
@@ -2372,7 +2421,7 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
2372
2421
  });
2373
2422
  case 9:
2374
2423
  mentionCount = 0;
2375
- isUnread = false;
2424
+ unreadTopicCount = 0;
2376
2425
  _iterator2 = FollowedTopicsManager_createForOfIteratorHelper(roomIds);
2377
2426
  _context6.p = 10;
2378
2427
  _iterator2.s();
@@ -2408,7 +2457,7 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
2408
2457
  return _context6.a(3, 17);
2409
2458
  case 16:
2410
2459
  if (topic.isUnread) {
2411
- isUnread = true;
2460
+ unreadTopicCount++;
2412
2461
  }
2413
2462
  mentionCount += (_topic$mentionCount = topic.mentionCount) !== null && _topic$mentionCount !== void 0 ? _topic$mentionCount : 0;
2414
2463
  case 17:
@@ -2442,7 +2491,8 @@ var FollowedTopicsManager = /*#__PURE__*/function (_EventTarget) {
2442
2491
  case 25:
2443
2492
  result = {
2444
2493
  mentionCount: mentionCount,
2445
- isUnread: isUnread
2494
+ unreadTopicCount: unreadTopicCount,
2495
+ isUnread: unreadTopicCount > 0
2446
2496
  };
2447
2497
  this.summariesCache.set(cacheKey, result);
2448
2498
  return _context6.a(2, result);
@@ -5225,6 +5275,9 @@ var ChatStateTracker = /*#__PURE__*/function () {
5225
5275
  }();
5226
5276
  ;// ./src/WebSocketChatClient.ts
5227
5277
  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; }
5228
5281
  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 }; })(); }
5229
5282
  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); }
5230
5283
  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); }
@@ -5263,7 +5316,13 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
5263
5316
  WebSocketChatClient_defineProperty(_this, "sendQueue", []);
5264
5317
  WebSocketChatClient_defineProperty(_this, "connectingTimeoutId", void 0);
5265
5318
  WebSocketChatClient_defineProperty(_this, "authenticated", void 0);
5266
- WebSocketChatClient_defineProperty(_this, "authenticatedResolvers", void 0);
5319
+ WebSocketChatClient_defineProperty(_this, "authenticatedResolvers", null);
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);
5267
5326
  WebSocketChatClient_defineProperty(_this, "pingMonitorInterval", void 0);
5268
5327
  WebSocketChatClient_defineProperty(_this, "inFlightPingTimeout", void 0);
5269
5328
  WebSocketChatClient_defineProperty(_this, "lastReceivedMessageAt", void 0);
@@ -5282,10 +5341,11 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
5282
5341
  key: "connect",
5283
5342
  value: function () {
5284
5343
  var _connect = WebSocketChatClient_asyncToGenerator(/*#__PURE__*/WebSocketChatClient_regenerator().m(function _callee() {
5285
- var _this$options$queryPa,
5344
+ var _this$connectPromise2,
5286
5345
  _this2 = this,
5346
+ _this$options$queryPa,
5287
5347
  _this$options$connect;
5288
- var params;
5348
+ var _this$connectPromise, params;
5289
5349
  return WebSocketChatClient_regenerator().w(function (_context) {
5290
5350
  while (1) switch (_context.n) {
5291
5351
  case 0:
@@ -5293,8 +5353,17 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
5293
5353
  _context.n = 1;
5294
5354
  break;
5295
5355
  }
5296
- return _context.a(2);
5356
+ return _context.a(2, (_this$connectPromise = this.connectPromise) !== null && _this$connectPromise !== void 0 ? _this$connectPromise : undefined);
5297
5357
  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
+ });
5298
5367
  params = new URLSearchParams((_this$options$queryPa = this.options.queryParams) !== null && _this$options$queryPa !== void 0 ? _this$options$queryPa : {});
5299
5368
  params.set('token', this.options.token);
5300
5369
  this.ws = new WebSocket("".concat(this.options.url, "?").concat(params));
@@ -5308,12 +5377,7 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
5308
5377
  return _this2.triggerConnectionTimeout();
5309
5378
  }, (_this$options$connect = this.options.connectingTimeoutMs) !== null && _this$options$connect !== void 0 ? _this$options$connect : 10000);
5310
5379
  this.authenticated = false;
5311
- return _context.a(2, new Promise(function () {
5312
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
5313
- args[_key] = arguments[_key];
5314
- }
5315
- return _this2.authenticatedResolvers = args;
5316
- }));
5380
+ return _context.a(2, this.connectPromise);
5317
5381
  }
5318
5382
  }, _callee, this);
5319
5383
  }));
@@ -5326,7 +5390,7 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
5326
5390
  key: "disconnect",
5327
5391
  value: function disconnect() {
5328
5392
  var _this$ws;
5329
- this.sendQueue = [];
5393
+ this.failPendingCommands(new Error('Client disconnected before the command was answered'));
5330
5394
  (_this$ws = this.ws) === null || _this$ws === void 0 || _this$ws.close(1000); // Normal closure
5331
5395
  this.ws = null;
5332
5396
  }
@@ -5387,11 +5451,11 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
5387
5451
  this.authenticated = isAuthenticated;
5388
5452
  if (isAuthenticated) {
5389
5453
  this.startConnectionMonitor();
5390
- this.authenticatedResolvers[0]();
5454
+ this.settleConnect();
5391
5455
  this.emit(this.Event.connect);
5392
5456
  this.sendFromQueue();
5393
5457
  } else {
5394
- this.authenticatedResolvers[1](envelope.data);
5458
+ this.settleConnect(envelope.data);
5395
5459
  }
5396
5460
  }
5397
5461
  }
@@ -5401,11 +5465,59 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
5401
5465
  this.stopConnectionMonitor();
5402
5466
  clearTimeout(this.connectingTimeoutId);
5403
5467
  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'));
5404
5472
  if (reconnect) {
5473
+ // Keep a pending connect() promise unsettled - the retry below is
5474
+ // expected to authenticate and will resolve it.
5405
5475
  void this.connect();
5476
+ } else {
5477
+ this.settleConnect(new Error('Connection closed before authentication'));
5406
5478
  }
5407
5479
  this.emit(this.Event.disconnect, reconnect);
5408
5480
  }
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
+ }
5409
5521
  }, {
5410
5522
  key: "sendFromQueue",
5411
5523
  value: function sendFromQueue() {
@@ -5470,7 +5582,12 @@ var WebSocketChatClient = /*#__PURE__*/function (_AbstractChatClient) {
5470
5582
  _this4.inFlightPingTimeout = undefined;
5471
5583
  _this4.ws.close(3000); // Service Restart (reconnect)
5472
5584
  }, _this4.options.ping.pongBackTimeoutMs);
5473
- _this4.send('Ping', {}).then(function () {
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 () {
5474
5591
  clearTimeout(_this4.inFlightPingTimeout);
5475
5592
  _this4.inFlightPingTimeout = undefined;
5476
5593
  });