polfan-server-js-client 0.2.51 → 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.
- package/.idea/workspace.xml +31 -25
- package/build/index.cjs.js +29 -10
- 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/WebSocketChatClient.d.ts +2 -0
- package/build/types/types/src/schemes/events/Session.d.ts +1 -0
- package/package.json +1 -1
- package/src/AbstractChatClient.ts +1 -1
- package/src/WebSocketChatClient.ts +19 -11
- package/src/state-tracker/RoomsManager.ts +12 -0
package/.idea/workspace.xml
CHANGED
|
@@ -4,10 +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="
|
|
8
|
-
<change beforePath="$PROJECT_DIR$/
|
|
9
|
-
<change beforePath="$PROJECT_DIR$/src/
|
|
10
|
-
<change beforePath="$PROJECT_DIR$/src/
|
|
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
11
|
</list>
|
|
12
12
|
<option name="SHOW_DIALOG" value="false" />
|
|
13
13
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -131,23 +131,13 @@
|
|
|
131
131
|
<workItem from="1755452202060" duration="1749000" />
|
|
132
132
|
<workItem from="1755600989345" duration="1221000" />
|
|
133
133
|
<workItem from="1755609872522" duration="1114000" />
|
|
134
|
-
<workItem from="1756051973155" duration="
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
<
|
|
138
|
-
<
|
|
139
|
-
<
|
|
140
|
-
<
|
|
141
|
-
<option name="project" value="LOCAL" />
|
|
142
|
-
<updated>1738005832363</updated>
|
|
143
|
-
</task>
|
|
144
|
-
<task id="LOCAL-00010" summary="Emoticon permissions support">
|
|
145
|
-
<option name="closed" value="true" />
|
|
146
|
-
<created>1738413231680</created>
|
|
147
|
-
<option name="number" value="00010" />
|
|
148
|
-
<option name="presentableId" value="LOCAL-00010" />
|
|
149
|
-
<option name="project" value="LOCAL" />
|
|
150
|
-
<updated>1738413231680</updated>
|
|
134
|
+
<workItem from="1756051973155" duration="2903000" />
|
|
135
|
+
<workItem from="1756461761500" duration="6231000" />
|
|
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" />
|
|
151
141
|
</task>
|
|
152
142
|
<task id="LOCAL-00011" summary="Emoticon permissions support">
|
|
153
143
|
<option name="closed" value="true" />
|
|
@@ -525,7 +515,23 @@
|
|
|
525
515
|
<option name="project" value="LOCAL" />
|
|
526
516
|
<updated>1756051989192</updated>
|
|
527
517
|
</task>
|
|
528
|
-
<
|
|
518
|
+
<task id="LOCAL-00058" summary="Protocol version support">
|
|
519
|
+
<option name="closed" value="true" />
|
|
520
|
+
<created>1756053336494</created>
|
|
521
|
+
<option name="number" value="00058" />
|
|
522
|
+
<option name="presentableId" value="LOCAL-00058" />
|
|
523
|
+
<option name="project" value="LOCAL" />
|
|
524
|
+
<updated>1756053336494</updated>
|
|
525
|
+
</task>
|
|
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" />
|
|
529
535
|
<servers />
|
|
530
536
|
</component>
|
|
531
537
|
<component name="TypeScriptGeneratedFilesManager">
|
|
@@ -543,8 +549,6 @@
|
|
|
543
549
|
</option>
|
|
544
550
|
</component>
|
|
545
551
|
<component name="VcsManagerConfiguration">
|
|
546
|
-
<MESSAGE value="Client data and room stream support" />
|
|
547
|
-
<MESSAGE value="New collections mutationCounter property and map method remove" />
|
|
548
552
|
<MESSAGE value="Private rooms and space summaries" />
|
|
549
553
|
<MESSAGE value="Custom nicks support" />
|
|
550
554
|
<MESSAGE value="CustomNickChange message type" />
|
|
@@ -568,6 +572,8 @@
|
|
|
568
572
|
<MESSAGE value="Version bump" />
|
|
569
573
|
<MESSAGE value="RoomSummaryUpdated event support" />
|
|
570
574
|
<MESSAGE value="Ephemeral room history support" />
|
|
571
|
-
<
|
|
575
|
+
<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" />
|
|
572
578
|
</component>
|
|
573
579
|
</project>
|
package/build/index.cjs.js
CHANGED
|
@@ -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)[
|
|
138
|
+
this.awaitingResponse.get(envelope.ref)[1](error);
|
|
139
139
|
this.awaitingResponse.delete(envelope.ref);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
@@ -1099,6 +1099,8 @@ class RoomsManager {
|
|
|
1099
1099
|
const member = members.get(ev.userId);
|
|
1100
1100
|
const newMember = ev.member;
|
|
1101
1101
|
const user = member.spaceMember?.user ?? member.user;
|
|
1102
|
+
|
|
1103
|
+
// Preserving user object, because it's not included in event
|
|
1102
1104
|
if (newMember.spaceMember) {
|
|
1103
1105
|
newMember.spaceMember.user = user;
|
|
1104
1106
|
} else {
|
|
@@ -1201,6 +1203,7 @@ class RoomsManager {
|
|
|
1201
1203
|
this.deferredSession.resolve();
|
|
1202
1204
|
}
|
|
1203
1205
|
handleUserUpdated(ev) {
|
|
1206
|
+
// Update room members users
|
|
1204
1207
|
this.members.items.forEach(members => {
|
|
1205
1208
|
const member = members.get(ev.user.id);
|
|
1206
1209
|
if (!member) {
|
|
@@ -1217,6 +1220,18 @@ class RoomsManager {
|
|
|
1217
1220
|
}
|
|
1218
1221
|
members.set(newMember);
|
|
1219
1222
|
});
|
|
1223
|
+
|
|
1224
|
+
// Update recipients users
|
|
1225
|
+
const newRooms = [];
|
|
1226
|
+
this.list.items.forEach(room => {
|
|
1227
|
+
if (room.recipients?.some(user => user.id === ev.user.id)) {
|
|
1228
|
+
room.recipients = room.recipients.map(user => user.id === ev.user.id ? ev.user : user);
|
|
1229
|
+
newRooms.push({
|
|
1230
|
+
...room
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
this.list.set(...newRooms);
|
|
1220
1235
|
}
|
|
1221
1236
|
handleNewMessage(ev) {
|
|
1222
1237
|
const topics = this.topics.get(ev.message.location.roomId);
|
|
@@ -2130,23 +2145,21 @@ class WebSocketChatClient extends AbstractChatClient {
|
|
|
2130
2145
|
this.ws = null;
|
|
2131
2146
|
}
|
|
2132
2147
|
async send(commandType, commandData) {
|
|
2133
|
-
if (!this.ws || [this.ws.CLOSED, this.ws.CLOSING].includes(this.ws.readyState)) {
|
|
2134
|
-
throw new Error('Cannot send; close or closing connection state');
|
|
2135
|
-
}
|
|
2136
2148
|
const envelope = this.createEnvelope(commandType, commandData);
|
|
2137
2149
|
const promise = this.createPromiseFromCommandEnvelope(envelope);
|
|
2138
|
-
if (this.
|
|
2150
|
+
if (this.isPendingReadyWsState()) {
|
|
2139
2151
|
this.sendQueue.push(envelope);
|
|
2140
2152
|
return promise;
|
|
2141
2153
|
}
|
|
2142
|
-
if (this.ws.readyState !== this.ws.OPEN) {
|
|
2143
|
-
throw new Error(`Invalid websocket state=${this.ws.readyState}`);
|
|
2144
|
-
}
|
|
2145
2154
|
this.sendEnvelope(envelope);
|
|
2146
2155
|
return promise;
|
|
2147
2156
|
}
|
|
2148
2157
|
sendEnvelope(envelope) {
|
|
2149
|
-
this.
|
|
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}`));
|
|
2150
2163
|
}
|
|
2151
2164
|
onMessage(event) {
|
|
2152
2165
|
const envelope = JSON.parse(event.data);
|
|
@@ -2171,7 +2184,7 @@ class WebSocketChatClient extends AbstractChatClient {
|
|
|
2171
2184
|
clearTimeout(this.connectingTimeoutId);
|
|
2172
2185
|
const reconnect = event.code !== 1000; // Connection was closed because of error
|
|
2173
2186
|
if (reconnect) {
|
|
2174
|
-
this.connect();
|
|
2187
|
+
void this.connect();
|
|
2175
2188
|
}
|
|
2176
2189
|
this.emit(this.Event.disconnect, reconnect);
|
|
2177
2190
|
}
|
|
@@ -2190,6 +2203,12 @@ class WebSocketChatClient extends AbstractChatClient {
|
|
|
2190
2203
|
this.disconnect();
|
|
2191
2204
|
this.emit(this.Event.error, new Error('Connection timeout'));
|
|
2192
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
|
+
}
|
|
2193
2212
|
}
|
|
2194
2213
|
;// CONCATENATED MODULE: ./src/WebApiChatClient.ts
|
|
2195
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; }
|