polfan-server-js-client 0.2.52 → 0.2.53

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,11 @@
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="Protocol version support" />
7
+ <list default="true" id="831dae43-0da1-47fd-a5f7-33dd5eec2992" name="Changes" comment="Update room on recipient user change">
8
+ <change beforePath="$PROJECT_DIR$/build/types/types/src/schemes/events/Session.d.ts" beforeDir="false" afterPath="$PROJECT_DIR$/build/types/types/src/schemes/events/Session.d.ts" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/src/AbstractChatClient.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/AbstractChatClient.ts" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/src/WebSocketChatClient.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/WebSocketChatClient.ts" afterDir="false" />
11
+ </list>
8
12
  <option name="SHOW_DIALOG" value="false" />
9
13
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
14
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -129,15 +133,11 @@
129
133
  <workItem from="1755609872522" duration="1114000" />
130
134
  <workItem from="1756051973155" duration="2903000" />
131
135
  <workItem from="1756461761500" duration="6231000" />
132
- <workItem from="1756802984919" duration="379000" />
133
- </task>
134
- <task id="LOCAL-00010" summary="Emoticon permissions support">
135
- <option name="closed" value="true" />
136
- <created>1738413231680</created>
137
- <option name="number" value="00010" />
138
- <option name="presentableId" value="LOCAL-00010" />
139
- <option name="project" value="LOCAL" />
140
- <updated>1738413231680</updated>
136
+ <workItem from="1756802984919" duration="1908000" />
137
+ <workItem from="1757108361675" duration="5000" />
138
+ <workItem from="1759771277022" duration="584000" />
139
+ <workItem from="1759848250548" duration="413000" />
140
+ <workItem from="1761857165939" duration="2585000" />
141
141
  </task>
142
142
  <task id="LOCAL-00011" summary="Emoticon permissions support">
143
143
  <option name="closed" value="true" />
@@ -523,7 +523,15 @@
523
523
  <option name="project" value="LOCAL" />
524
524
  <updated>1756053336494</updated>
525
525
  </task>
526
- <option name="localTasksCounter" value="59" />
526
+ <task id="LOCAL-00059" summary="Update room on recipient user change">
527
+ <option name="closed" value="true" />
528
+ <created>1756804976724</created>
529
+ <option name="number" value="00059" />
530
+ <option name="presentableId" value="LOCAL-00059" />
531
+ <option name="project" value="LOCAL" />
532
+ <updated>1756804976724</updated>
533
+ </task>
534
+ <option name="localTasksCounter" value="60" />
527
535
  <servers />
528
536
  </component>
529
537
  <component name="TypeScriptGeneratedFilesManager">
@@ -541,7 +549,6 @@
541
549
  </option>
542
550
  </component>
543
551
  <component name="VcsManagerConfiguration">
544
- <MESSAGE value="New collections mutationCounter property and map method remove" />
545
552
  <MESSAGE value="Private rooms and space summaries" />
546
553
  <MESSAGE value="Custom nicks support" />
547
554
  <MESSAGE value="CustomNickChange message type" />
@@ -566,6 +573,7 @@
566
573
  <MESSAGE value="RoomSummaryUpdated event support" />
567
574
  <MESSAGE value="Ephemeral room history support" />
568
575
  <MESSAGE value="Protocol version support" />
569
- <option name="LAST_COMMIT_MESSAGE" value="Protocol version support" />
576
+ <MESSAGE value="Update room on recipient user change" />
577
+ <option name="LAST_COMMIT_MESSAGE" value="Update room on recipient user change" />
570
578
  </component>
571
579
  </project>
@@ -135,7 +135,7 @@ class AbstractChatClient extends EventTarget {
135
135
  if (!this.awaitingResponse.has(envelope.ref)) {
136
136
  return;
137
137
  }
138
- this.awaitingResponse.get(envelope.ref)[0](error);
138
+ this.awaitingResponse.get(envelope.ref)[1](error);
139
139
  this.awaitingResponse.delete(envelope.ref);
140
140
  }
141
141
  }
@@ -2145,23 +2145,21 @@ class WebSocketChatClient extends AbstractChatClient {
2145
2145
  this.ws = null;
2146
2146
  }
2147
2147
  async send(commandType, commandData) {
2148
- if (!this.ws || [this.ws.CLOSED, this.ws.CLOSING].includes(this.ws.readyState)) {
2149
- throw new Error('Cannot send; close or closing connection state');
2150
- }
2151
2148
  const envelope = this.createEnvelope(commandType, commandData);
2152
2149
  const promise = this.createPromiseFromCommandEnvelope(envelope);
2153
- if (this.ws.readyState === this.ws.CONNECTING || !this.authenticated) {
2150
+ if (this.isPendingReadyWsState()) {
2154
2151
  this.sendQueue.push(envelope);
2155
2152
  return promise;
2156
2153
  }
2157
- if (this.ws.readyState !== this.ws.OPEN) {
2158
- throw new Error(`Invalid websocket state=${this.ws.readyState}`);
2159
- }
2160
2154
  this.sendEnvelope(envelope);
2161
2155
  return promise;
2162
2156
  }
2163
2157
  sendEnvelope(envelope) {
2164
- this.ws.send(JSON.stringify(envelope));
2158
+ if (this.isReadyToSendWsState()) {
2159
+ this.ws.send(JSON.stringify(envelope));
2160
+ return;
2161
+ }
2162
+ this.handleEnvelopeSendError(envelope, new Error(`Cannot send; invalid websocket state=${this.ws?.readyState}`));
2165
2163
  }
2166
2164
  onMessage(event) {
2167
2165
  const envelope = JSON.parse(event.data);
@@ -2186,7 +2184,7 @@ class WebSocketChatClient extends AbstractChatClient {
2186
2184
  clearTimeout(this.connectingTimeoutId);
2187
2185
  const reconnect = event.code !== 1000; // Connection was closed because of error
2188
2186
  if (reconnect) {
2189
- this.connect();
2187
+ void this.connect();
2190
2188
  }
2191
2189
  this.emit(this.Event.disconnect, reconnect);
2192
2190
  }
@@ -2205,6 +2203,12 @@ class WebSocketChatClient extends AbstractChatClient {
2205
2203
  this.disconnect();
2206
2204
  this.emit(this.Event.error, new Error('Connection timeout'));
2207
2205
  }
2206
+ isPendingReadyWsState() {
2207
+ return this.ws.readyState === this.ws.CONNECTING || !this.authenticated;
2208
+ }
2209
+ isReadyToSendWsState() {
2210
+ return this.ws?.readyState === this.ws.OPEN && this.authenticated;
2211
+ }
2208
2212
  }
2209
2213
  ;// CONCATENATED MODULE: ./src/WebApiChatClient.ts
2210
2214
  function WebApiChatClient_defineProperty(obj, key, value) { key = WebApiChatClient_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }