stream-chat 10.0.0-rc.27 → 10.0.0-rc.28
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 +64 -26
- package/dist/cjs/index.browser.js.map +3 -3
- package/dist/cjs/index.node.js +64 -26
- package/dist/cjs/index.node.js.map +3 -3
- package/dist/esm/index.mjs +67 -29
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/errors.d.ts +5 -1
- package/dist/types/messageOperations/MessageOperations.d.ts +6 -1
- package/dist/types/pagination/paginators/BasePaginator.d.ts +6 -2
- package/package.json +3 -3
- package/src/ChannelManager.ts +25 -1
- package/src/errors.ts +20 -3
- package/src/messageOperations/MessageOperationStatePolicy.ts +2 -2
- package/src/messageOperations/MessageOperations.ts +27 -2
- package/src/pagination/paginators/BasePaginator.ts +6 -2
- package/src/thread.ts +19 -2
|
@@ -1645,6 +1645,28 @@ var isTokenExpiredError = (error) => errorIsApiError(error) && error.response?.d
|
|
|
1645
1645
|
|
|
1646
1646
|
// src/errors.ts
|
|
1647
1647
|
var import_axios3 = require("axios");
|
|
1648
|
+
|
|
1649
|
+
// src/offline-support/types.ts
|
|
1650
|
+
var OfflineError = class extends Error {
|
|
1651
|
+
constructor(message, {
|
|
1652
|
+
type
|
|
1653
|
+
}) {
|
|
1654
|
+
super(message);
|
|
1655
|
+
this.name = "OfflineError";
|
|
1656
|
+
this.type = type;
|
|
1657
|
+
}
|
|
1658
|
+
// Vitest helper (serialized errors are too large to read)
|
|
1659
|
+
// https://github.com/vitest-dev/vitest/blob/v3.1.3/packages/utils/src/error.ts#L60-L62
|
|
1660
|
+
toJSON() {
|
|
1661
|
+
return {
|
|
1662
|
+
message: `${this.type} - ${this.message}`,
|
|
1663
|
+
stack: this.stack,
|
|
1664
|
+
name: this.name
|
|
1665
|
+
};
|
|
1666
|
+
}
|
|
1667
|
+
};
|
|
1668
|
+
|
|
1669
|
+
// src/errors.ts
|
|
1648
1670
|
var APIErrorCodes = {
|
|
1649
1671
|
"-1": { name: "InternalSystemError", retryable: true },
|
|
1650
1672
|
"2": { name: "AccessKeyError", retryable: false },
|
|
@@ -1704,9 +1726,11 @@ function isWSFailure(err) {
|
|
|
1704
1726
|
return false;
|
|
1705
1727
|
}
|
|
1706
1728
|
}
|
|
1729
|
+
var isTransportFailure = (error) => error instanceof OfflineError || (0, import_axios3.isAxiosError)(error) && !error.response && !(0, import_axios3.isCancel)(error);
|
|
1707
1730
|
var parseError = (error) => {
|
|
1708
1731
|
const stringError = JSON.stringify(error);
|
|
1709
|
-
|
|
1732
|
+
const parsed = stringError ? JSON.parse(stringError) : {};
|
|
1733
|
+
return parsed.status == null && isTransportFailure(error) ? { ...parsed, status: 0 } : parsed;
|
|
1710
1734
|
};
|
|
1711
1735
|
var isAlreadyExistsError = (error, parsed) => parsed.code === 4 && error instanceof Error && error.message.includes("already exists");
|
|
1712
1736
|
|
|
@@ -14756,6 +14780,7 @@ var pickUpdateOptions = (options) => {
|
|
|
14756
14780
|
if (typeof options.skip_push === "boolean") picked.skip_push = options.skip_push;
|
|
14757
14781
|
return picked;
|
|
14758
14782
|
};
|
|
14783
|
+
var isFailedEdit = (localMessage) => localMessage.status === "failed" && localMessage.message_text_updated_at != null;
|
|
14759
14784
|
var MessageOperations = class {
|
|
14760
14785
|
constructor(ctx) {
|
|
14761
14786
|
this.failedSendCache = new FailedSendCache(() => this.config);
|
|
@@ -14881,11 +14906,22 @@ var MessageOperations = class {
|
|
|
14881
14906
|
handlers.send
|
|
14882
14907
|
);
|
|
14883
14908
|
}
|
|
14884
|
-
/**
|
|
14909
|
+
/**
|
|
14910
|
+
* A send with a cached payload: resends what failed, unless the caller passes a new one. A failed
|
|
14911
|
+
* edit is replayed as an edit instead: the server already has that message, so a send would be
|
|
14912
|
+
* rejected as a duplicate, and the duplicate taken for a delivered send. That holds even with a
|
|
14913
|
+
* cached payload: a send that failed after the server stored the message leaves one behind.
|
|
14914
|
+
*/
|
|
14885
14915
|
async retry(params) {
|
|
14916
|
+
if (isFailedEdit(params.localMessage)) {
|
|
14917
|
+
this.failedSendCache.clear(params.localMessage.id);
|
|
14918
|
+
return await this.update({
|
|
14919
|
+
localMessage: { ...params.localMessage, error: void 0, status: "received" }
|
|
14920
|
+
});
|
|
14921
|
+
}
|
|
14922
|
+
const cachedPayload = this.failedSendCache.get(params.localMessage.id);
|
|
14886
14923
|
const handlers = this.ctx.handlers();
|
|
14887
14924
|
const localMessage = { ...params.localMessage, type: "regular" };
|
|
14888
|
-
const cachedPayload = this.failedSendCache.get(localMessage.id);
|
|
14889
14925
|
await this.sendWithFailedSendCache(
|
|
14890
14926
|
"retry",
|
|
14891
14927
|
{
|
|
@@ -18891,7 +18927,10 @@ var Thread = class extends WithSubscriptions {
|
|
|
18891
18927
|
...current,
|
|
18892
18928
|
deletedAt: message.deleted_at ?? null,
|
|
18893
18929
|
parentMessage: message,
|
|
18894
|
-
participants:
|
|
18930
|
+
participants: mergeThreadParticipants(
|
|
18931
|
+
current.participants,
|
|
18932
|
+
normalizeThreadParticipants(message.thread_participants, current.channel.cid)
|
|
18933
|
+
),
|
|
18895
18934
|
replyCount: message.reply_count ?? current.replyCount
|
|
18896
18935
|
}));
|
|
18897
18936
|
});
|
|
@@ -19100,6 +19139,13 @@ var normalizeThreadParticipants = (participants, channelCid) => {
|
|
|
19100
19139
|
})
|
|
19101
19140
|
);
|
|
19102
19141
|
};
|
|
19142
|
+
var mergeThreadParticipants = (current, fromMessage) => {
|
|
19143
|
+
if (!fromMessage) return current;
|
|
19144
|
+
if (!current?.length) return fromMessage;
|
|
19145
|
+
const known = new Set(current.map((participant) => participant.user_id));
|
|
19146
|
+
const added = fromMessage.filter((participant) => !known.has(participant.user_id));
|
|
19147
|
+
return added.length ? [...current, ...added] : current;
|
|
19148
|
+
};
|
|
19103
19149
|
var DEFAULT_THREAD_PARTICIPANT_LIMIT = 100;
|
|
19104
19150
|
var ensureThreadChannel = (client, threadData) => {
|
|
19105
19151
|
if (!threadData.channel) {
|
|
@@ -20856,8 +20902,20 @@ var messageDeletedHandler = {
|
|
|
20856
20902
|
handle: (context) => context.event.hard_delete ? reinsertItem(context) : void 0,
|
|
20857
20903
|
id: "ChannelManager:default-handler:message.deleted"
|
|
20858
20904
|
};
|
|
20905
|
+
var reloadListsWithoutLoadedPage = (channelManager, channel) => {
|
|
20906
|
+
channelManager.paginators.forEach((paginator) => {
|
|
20907
|
+
if (paginator.items === void 0 || paginator.isLoading) return;
|
|
20908
|
+
if (paginator.anchoredHeadItems.length > 0) return;
|
|
20909
|
+
if (!paginator.matchesFilter(channel)) return;
|
|
20910
|
+
paginator.toTailDebounced({ reset: "yes" });
|
|
20911
|
+
});
|
|
20912
|
+
};
|
|
20859
20913
|
var channelVisibleHandler = {
|
|
20860
|
-
handle:
|
|
20914
|
+
handle: async (context) => {
|
|
20915
|
+
await updateLists(context);
|
|
20916
|
+
const channel = getCachedChannelFromEvent(context.event, context.ctx.channelManager);
|
|
20917
|
+
if (channel) reloadListsWithoutLoadedPage(context.ctx.channelManager, channel);
|
|
20918
|
+
},
|
|
20861
20919
|
id: "ChannelManager:default-handler:channel.visible"
|
|
20862
20920
|
};
|
|
20863
20921
|
var channelHiddenHandler = {
|
|
@@ -25071,7 +25129,7 @@ var StreamChat = class _StreamChat extends ChatApi {
|
|
|
25071
25129
|
return this.userAgent;
|
|
25072
25130
|
}
|
|
25073
25131
|
if (!this.cachedUserAgent) {
|
|
25074
|
-
const version = "10.0.0-rc.
|
|
25132
|
+
const version = "10.0.0-rc.28";
|
|
25075
25133
|
const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
|
|
25076
25134
|
const { name: appName, version: appVersion } = this.appIdentifier ?? {};
|
|
25077
25135
|
const { os, model: deviceModel } = this.deviceIdentifier ?? {};
|
|
@@ -26680,26 +26738,6 @@ var languageNameDefaults = Object.fromEntries(
|
|
|
26680
26738
|
Object.entries(LANGUAGE_NAMES).map(([code, name]) => [`language.${code}`, name])
|
|
26681
26739
|
);
|
|
26682
26740
|
|
|
26683
|
-
// src/offline-support/types.ts
|
|
26684
|
-
var OfflineError = class extends Error {
|
|
26685
|
-
constructor(message, {
|
|
26686
|
-
type
|
|
26687
|
-
}) {
|
|
26688
|
-
super(message);
|
|
26689
|
-
this.name = "OfflineError";
|
|
26690
|
-
this.type = type;
|
|
26691
|
-
}
|
|
26692
|
-
// Vitest helper (serialized errors are too large to read)
|
|
26693
|
-
// https://github.com/vitest-dev/vitest/blob/v3.1.3/packages/utils/src/error.ts#L60-L62
|
|
26694
|
-
toJSON() {
|
|
26695
|
-
return {
|
|
26696
|
-
message: `${this.type} - ${this.message}`,
|
|
26697
|
-
stack: this.stack,
|
|
26698
|
-
name: this.name
|
|
26699
|
-
};
|
|
26700
|
-
}
|
|
26701
|
-
};
|
|
26702
|
-
|
|
26703
26741
|
// src/offline-support/offline_sync_manager.ts
|
|
26704
26742
|
var import_axios6 = require("axios");
|
|
26705
26743
|
var logger20 = chatLoggerSystem.getLogger("offline-db");
|