stream-chat 9.54.0 → 9.54.1
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/dist/cjs/index.browser.js +46 -9
- package/dist/cjs/index.browser.js.map +2 -2
- package/dist/cjs/index.node.js +46 -9
- package/dist/cjs/index.node.js.map +2 -2
- package/dist/esm/index.mjs +46 -9
- package/dist/esm/index.mjs.map +2 -2
- package/dist/types/client.d.ts +4 -68
- package/dist/types/connection.d.ts +12 -0
- package/dist/types/types.d.ts +26 -6
- package/package.json +6 -1
- package/src/client.ts +3 -3
- package/src/connection.ts +47 -2
- package/src/poll.ts +9 -1
- package/src/thread.ts +11 -4
- package/src/types.ts +27 -6
package/dist/esm/index.mjs
CHANGED
|
@@ -8088,10 +8088,13 @@ var Thread = class extends WithSubscriptions {
|
|
|
8088
8088
|
}));
|
|
8089
8089
|
}
|
|
8090
8090
|
};
|
|
8091
|
-
const
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8091
|
+
const channelResponse = threadData.channel;
|
|
8092
|
+
const channelData = { name: channelResponse.name };
|
|
8093
|
+
const channel = client.channel(
|
|
8094
|
+
threadData.channel.type,
|
|
8095
|
+
threadData.channel.id,
|
|
8096
|
+
channelData
|
|
8097
|
+
);
|
|
8095
8098
|
channel._hydrateMembers({
|
|
8096
8099
|
members: threadData.channel.members ?? [],
|
|
8097
8100
|
overrideCurrentState: false
|
|
@@ -11491,6 +11494,10 @@ var StableWSConnection = class {
|
|
|
11491
11494
|
if (data.type === "health.check") {
|
|
11492
11495
|
this.scheduleNextPing();
|
|
11493
11496
|
}
|
|
11497
|
+
if (data?.type === "connection.error" && data?.error?.code === chatCodes.TOKEN_EXPIRED) {
|
|
11498
|
+
this._log("onmessage() - server reported that the token expired", { wsID });
|
|
11499
|
+
this.tokenExpiredByServer = true;
|
|
11500
|
+
}
|
|
11494
11501
|
this.client.dispatchEvent(data);
|
|
11495
11502
|
this.scheduleConnectionCheck();
|
|
11496
11503
|
};
|
|
@@ -11514,7 +11521,7 @@ var StableWSConnection = class {
|
|
|
11514
11521
|
this.isConnecting = false;
|
|
11515
11522
|
this.rejectPromise?.(this._errorFromWSEvent(event));
|
|
11516
11523
|
this._log(`onclose() - WS connection closed. Calling reconnect ...`, { event });
|
|
11517
|
-
this.
|
|
11524
|
+
this._reconnectAfterFailure();
|
|
11518
11525
|
}
|
|
11519
11526
|
};
|
|
11520
11527
|
this.onerror = (wsID, event) => {
|
|
@@ -11525,7 +11532,7 @@ var StableWSConnection = class {
|
|
|
11525
11532
|
this.isConnecting = false;
|
|
11526
11533
|
this.rejectPromise?.(this._errorFromWSEvent(event));
|
|
11527
11534
|
this._log(`onerror() - WS connection resulted into error`, { event });
|
|
11528
|
-
this.
|
|
11535
|
+
this._reconnectAfterFailure();
|
|
11529
11536
|
};
|
|
11530
11537
|
/**
|
|
11531
11538
|
* _setHealth - Sets the connection to healthy or unhealthy.
|
|
@@ -11578,6 +11585,7 @@ var StableWSConnection = class {
|
|
|
11578
11585
|
*/
|
|
11579
11586
|
this._setupConnectionPromise = () => {
|
|
11580
11587
|
this.isResolved = false;
|
|
11588
|
+
this.tokenExpiredByServer = false;
|
|
11581
11589
|
this.connectionOpen = new Promise((resolve, reject) => {
|
|
11582
11590
|
this.resolvePromise = resolve;
|
|
11583
11591
|
this.rejectPromise = reject;
|
|
@@ -11625,6 +11633,7 @@ var StableWSConnection = class {
|
|
|
11625
11633
|
this.isHealthy = false;
|
|
11626
11634
|
this.wsID = 1;
|
|
11627
11635
|
this.lastEvent = null;
|
|
11636
|
+
this.tokenExpiredByServer = false;
|
|
11628
11637
|
this.pingInterval = 25 * 1e3;
|
|
11629
11638
|
this.connectionCheckTimeout = this.pingInterval + 10 * 1e3;
|
|
11630
11639
|
addConnectionEventListeners(this.onlineStatusChanged);
|
|
@@ -11723,6 +11732,7 @@ var StableWSConnection = class {
|
|
|
11723
11732
|
this.wsID += 1;
|
|
11724
11733
|
this.isConnecting = false;
|
|
11725
11734
|
this.isDisconnected = true;
|
|
11735
|
+
this.tokenExpiredByServer = false;
|
|
11726
11736
|
if (this.healthCheckTimeoutRef) {
|
|
11727
11737
|
clearInterval(this.healthCheckTimeoutRef);
|
|
11728
11738
|
}
|
|
@@ -11855,6 +11865,10 @@ var StableWSConnection = class {
|
|
|
11855
11865
|
this._destroyCurrentWSConnection();
|
|
11856
11866
|
if (options.refreshToken) {
|
|
11857
11867
|
await this.client.tokenManager.loadToken();
|
|
11868
|
+
if (this.isConnecting || this.isHealthy) {
|
|
11869
|
+
this._log("_reconnect() - Abort (4) since already connecting or healthy");
|
|
11870
|
+
return;
|
|
11871
|
+
}
|
|
11858
11872
|
}
|
|
11859
11873
|
try {
|
|
11860
11874
|
await this._connect();
|
|
@@ -11878,6 +11892,21 @@ var StableWSConnection = class {
|
|
|
11878
11892
|
}
|
|
11879
11893
|
this._log("_reconnect() - == END ==");
|
|
11880
11894
|
}
|
|
11895
|
+
/**
|
|
11896
|
+
* _reconnectAfterFailure - Reconnects after the socket closed or failed. If the server
|
|
11897
|
+
* reported that the token expired, the token is refreshed before reconnecting.
|
|
11898
|
+
* Static tokens cannot be refreshed and reconnect as before.
|
|
11899
|
+
*/
|
|
11900
|
+
_reconnectAfterFailure() {
|
|
11901
|
+
if (this.tokenExpiredByServer && !this.client.tokenManager.isStatic()) {
|
|
11902
|
+
this._log(
|
|
11903
|
+
"_reconnectAfterFailure() - token expired, so going to reload token and reconnect"
|
|
11904
|
+
);
|
|
11905
|
+
this._reconnect({ refreshToken: true });
|
|
11906
|
+
return;
|
|
11907
|
+
}
|
|
11908
|
+
this._reconnect();
|
|
11909
|
+
}
|
|
11881
11910
|
/**
|
|
11882
11911
|
* _destroyCurrentWSConnection - Removes the current WS connection
|
|
11883
11912
|
*
|
|
@@ -13240,7 +13269,15 @@ var Poll = class {
|
|
|
13240
13269
|
if (!isPollUpdatedEvent(event)) return;
|
|
13241
13270
|
const { id, ...pollData } = extractPollData(event.poll);
|
|
13242
13271
|
if (pollData.is_closed) this.closeConfirmed = true;
|
|
13243
|
-
this.state.partialNext({
|
|
13272
|
+
this.state.partialNext({
|
|
13273
|
+
...pollData,
|
|
13274
|
+
// Server-owned translations, which `extractPollData` (an update request) leaves out. Copied
|
|
13275
|
+
// even when absent: the event carries the whole poll, and a change made under channel-only
|
|
13276
|
+
// translation drops the stale ones.
|
|
13277
|
+
description_i18n: event.poll.description_i18n,
|
|
13278
|
+
lastActivityAt: new Date(event.created_at),
|
|
13279
|
+
name_i18n: event.poll.name_i18n
|
|
13280
|
+
});
|
|
13244
13281
|
this.upsertOfflineDb();
|
|
13245
13282
|
};
|
|
13246
13283
|
this.handlePollClosed = (event) => {
|
|
@@ -15233,7 +15270,7 @@ var StreamChat = class _StreamChat {
|
|
|
15233
15270
|
return this.userAgent;
|
|
15234
15271
|
}
|
|
15235
15272
|
if (!this.cachedUserAgent) {
|
|
15236
|
-
const version = "9.54.
|
|
15273
|
+
const version = "9.54.1";
|
|
15237
15274
|
const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
|
|
15238
15275
|
const { name: appName, version: appVersion } = this.appIdentifier ?? {};
|
|
15239
15276
|
const { os, model: deviceModel } = this.deviceIdentifier ?? {};
|
|
@@ -16822,7 +16859,7 @@ var StreamChat = class _StreamChat {
|
|
|
16822
16859
|
* @param {string} messageId
|
|
16823
16860
|
* @param {string} language
|
|
16824
16861
|
*
|
|
16825
|
-
* @return {MessageResponse} Response that includes the message
|
|
16862
|
+
* @return {APIResponse & { message: MessageResponse }} Response that includes the translated message
|
|
16826
16863
|
*/
|
|
16827
16864
|
async translateMessage(messageId, language) {
|
|
16828
16865
|
return await this.post(
|