stream-chat 10.0.0-rc.27 → 10.0.0-rc.29
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 +73 -29
- package/dist/cjs/index.browser.js.map +3 -3
- package/dist/cjs/index.node.js +75 -29
- package/dist/cjs/index.node.js.map +3 -3
- package/dist/esm/index.mjs +76 -32
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/errors.d.ts +5 -1
- package/dist/types/messageComposer/configuration/types.d.ts +4 -1
- package/dist/types/messageComposer/middleware/messageComposer/index.d.ts +1 -0
- package/dist/types/messageComposer/middleware/messageComposer/pollOnly.d.ts +6 -0
- 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/configuration/shape.ts +1 -1
- package/src/errors.ts +20 -3
- package/src/messageComposer/configuration/configuration.ts +9 -1
- package/src/messageComposer/configuration/types.ts +4 -1
- package/src/messageComposer/middleware/messageComposer/index.ts +1 -0
- package/src/messageComposer/middleware/messageComposer/pollOnly.ts +9 -1
- 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
|
@@ -109,6 +109,7 @@ __export(src_exports, {
|
|
|
109
109
|
OfflineDBSyncManager: () => OfflineDBSyncManager,
|
|
110
110
|
OfflineError: () => OfflineError,
|
|
111
111
|
POLL_COMPOSER_VALIDATION_CODE: () => POLL_COMPOSER_VALIDATION_CODE,
|
|
112
|
+
POLL_ONLY_COMPOSITION_MIDDLEWARE_ID: () => POLL_ONLY_COMPOSITION_MIDDLEWARE_ID,
|
|
112
113
|
PinnedMessagePaginator: () => PinnedMessagePaginator,
|
|
113
114
|
Poll: () => Poll,
|
|
114
115
|
PollComposer: () => PollComposer,
|
|
@@ -170,6 +171,7 @@ __export(src_exports, {
|
|
|
170
171
|
createMentionsMiddleware: () => createMentionsMiddleware,
|
|
171
172
|
createMessageComposerStateCompositionMiddleware: () => createMessageComposerStateCompositionMiddleware,
|
|
172
173
|
createPollComposerStateMiddleware: () => createPollComposerStateMiddleware,
|
|
174
|
+
createPollOnlyCompositionMiddleware: () => createPollOnlyCompositionMiddleware,
|
|
173
175
|
createPostUploadAttachmentEnrichmentMiddleware: () => createPostUploadAttachmentEnrichmentMiddleware,
|
|
174
176
|
createPriorityOwnershipResolver: () => createPriorityOwnershipResolver,
|
|
175
177
|
createSharedLocationCompositionMiddleware: () => createSharedLocationCompositionMiddleware,
|
|
@@ -1645,6 +1647,28 @@ var isTokenExpiredError = (error) => errorIsApiError(error) && error.response?.d
|
|
|
1645
1647
|
|
|
1646
1648
|
// src/errors.ts
|
|
1647
1649
|
var import_axios3 = require("axios");
|
|
1650
|
+
|
|
1651
|
+
// src/offline-support/types.ts
|
|
1652
|
+
var OfflineError = class extends Error {
|
|
1653
|
+
constructor(message, {
|
|
1654
|
+
type
|
|
1655
|
+
}) {
|
|
1656
|
+
super(message);
|
|
1657
|
+
this.name = "OfflineError";
|
|
1658
|
+
this.type = type;
|
|
1659
|
+
}
|
|
1660
|
+
// Vitest helper (serialized errors are too large to read)
|
|
1661
|
+
// https://github.com/vitest-dev/vitest/blob/v3.1.3/packages/utils/src/error.ts#L60-L62
|
|
1662
|
+
toJSON() {
|
|
1663
|
+
return {
|
|
1664
|
+
message: `${this.type} - ${this.message}`,
|
|
1665
|
+
stack: this.stack,
|
|
1666
|
+
name: this.name
|
|
1667
|
+
};
|
|
1668
|
+
}
|
|
1669
|
+
};
|
|
1670
|
+
|
|
1671
|
+
// src/errors.ts
|
|
1648
1672
|
var APIErrorCodes = {
|
|
1649
1673
|
"-1": { name: "InternalSystemError", retryable: true },
|
|
1650
1674
|
"2": { name: "AccessKeyError", retryable: false },
|
|
@@ -1704,9 +1728,11 @@ function isWSFailure(err) {
|
|
|
1704
1728
|
return false;
|
|
1705
1729
|
}
|
|
1706
1730
|
}
|
|
1731
|
+
var isTransportFailure = (error) => error instanceof OfflineError || (0, import_axios3.isAxiosError)(error) && !error.response && !(0, import_axios3.isCancel)(error);
|
|
1707
1732
|
var parseError = (error) => {
|
|
1708
1733
|
const stringError = JSON.stringify(error);
|
|
1709
|
-
|
|
1734
|
+
const parsed = stringError ? JSON.parse(stringError) : {};
|
|
1735
|
+
return parsed.status == null && isTransportFailure(error) ? { ...parsed, status: 0 } : parsed;
|
|
1710
1736
|
};
|
|
1711
1737
|
var isAlreadyExistsError = (error, parsed) => parsed.code === 4 && error instanceof Error && error.message.includes("already exists");
|
|
1712
1738
|
|
|
@@ -11623,8 +11649,9 @@ var pollLocalMessageNullifiedFields = {
|
|
|
11623
11649
|
quoted_message: void 0,
|
|
11624
11650
|
text: ""
|
|
11625
11651
|
};
|
|
11652
|
+
var POLL_ONLY_COMPOSITION_MIDDLEWARE_ID = "stream-io/message-composer-middleware/poll-only";
|
|
11626
11653
|
var createPollOnlyCompositionMiddleware = (composer) => ({
|
|
11627
|
-
id:
|
|
11654
|
+
id: POLL_ONLY_COMPOSITION_MIDDLEWARE_ID,
|
|
11628
11655
|
handlers: {
|
|
11629
11656
|
compose: ({
|
|
11630
11657
|
state,
|
|
@@ -12865,7 +12892,10 @@ var DEFAULT_COMPOSER_CONFIG = deepFreezeConfig({
|
|
|
12865
12892
|
linkPreviews: DEFAULT_LINK_PREVIEW_MANAGER_CONFIG,
|
|
12866
12893
|
location: DEFAULT_LOCATION_COMPOSER_CONFIG,
|
|
12867
12894
|
polls: DEFAULT_POLL_COMPOSER_CONFIG,
|
|
12868
|
-
|
|
12895
|
+
// Matches when the poll-only middleware sends the poll alone: never for an edit or a thread reply.
|
|
12896
|
+
retainCompositionOnSubmit: (composer) => !!composer.pollId && !composer.editedMessage && !composer.threadId && composer.compositionMiddlewareExecutor.installedMiddleware.some(
|
|
12897
|
+
({ id }) => id === POLL_ONLY_COMPOSITION_MIDDLEWARE_ID
|
|
12898
|
+
),
|
|
12869
12899
|
text: DEFAULT_TEXT_COMPOSER_CONFIG
|
|
12870
12900
|
});
|
|
12871
12901
|
|
|
@@ -14756,6 +14786,7 @@ var pickUpdateOptions = (options) => {
|
|
|
14756
14786
|
if (typeof options.skip_push === "boolean") picked.skip_push = options.skip_push;
|
|
14757
14787
|
return picked;
|
|
14758
14788
|
};
|
|
14789
|
+
var isFailedEdit = (localMessage) => localMessage.status === "failed" && localMessage.message_text_updated_at != null;
|
|
14759
14790
|
var MessageOperations = class {
|
|
14760
14791
|
constructor(ctx) {
|
|
14761
14792
|
this.failedSendCache = new FailedSendCache(() => this.config);
|
|
@@ -14881,11 +14912,22 @@ var MessageOperations = class {
|
|
|
14881
14912
|
handlers.send
|
|
14882
14913
|
);
|
|
14883
14914
|
}
|
|
14884
|
-
/**
|
|
14915
|
+
/**
|
|
14916
|
+
* A send with a cached payload: resends what failed, unless the caller passes a new one. A failed
|
|
14917
|
+
* edit is replayed as an edit instead: the server already has that message, so a send would be
|
|
14918
|
+
* rejected as a duplicate, and the duplicate taken for a delivered send. That holds even with a
|
|
14919
|
+
* cached payload: a send that failed after the server stored the message leaves one behind.
|
|
14920
|
+
*/
|
|
14885
14921
|
async retry(params) {
|
|
14922
|
+
if (isFailedEdit(params.localMessage)) {
|
|
14923
|
+
this.failedSendCache.clear(params.localMessage.id);
|
|
14924
|
+
return await this.update({
|
|
14925
|
+
localMessage: { ...params.localMessage, error: void 0, status: "received" }
|
|
14926
|
+
});
|
|
14927
|
+
}
|
|
14928
|
+
const cachedPayload = this.failedSendCache.get(params.localMessage.id);
|
|
14886
14929
|
const handlers = this.ctx.handlers();
|
|
14887
14930
|
const localMessage = { ...params.localMessage, type: "regular" };
|
|
14888
|
-
const cachedPayload = this.failedSendCache.get(localMessage.id);
|
|
14889
14931
|
await this.sendWithFailedSendCache(
|
|
14890
14932
|
"retry",
|
|
14891
14933
|
{
|
|
@@ -18891,7 +18933,10 @@ var Thread = class extends WithSubscriptions {
|
|
|
18891
18933
|
...current,
|
|
18892
18934
|
deletedAt: message.deleted_at ?? null,
|
|
18893
18935
|
parentMessage: message,
|
|
18894
|
-
participants:
|
|
18936
|
+
participants: mergeThreadParticipants(
|
|
18937
|
+
current.participants,
|
|
18938
|
+
normalizeThreadParticipants(message.thread_participants, current.channel.cid)
|
|
18939
|
+
),
|
|
18895
18940
|
replyCount: message.reply_count ?? current.replyCount
|
|
18896
18941
|
}));
|
|
18897
18942
|
});
|
|
@@ -19100,6 +19145,13 @@ var normalizeThreadParticipants = (participants, channelCid) => {
|
|
|
19100
19145
|
})
|
|
19101
19146
|
);
|
|
19102
19147
|
};
|
|
19148
|
+
var mergeThreadParticipants = (current, fromMessage) => {
|
|
19149
|
+
if (!fromMessage) return current;
|
|
19150
|
+
if (!current?.length) return fromMessage;
|
|
19151
|
+
const known = new Set(current.map((participant) => participant.user_id));
|
|
19152
|
+
const added = fromMessage.filter((participant) => !known.has(participant.user_id));
|
|
19153
|
+
return added.length ? [...current, ...added] : current;
|
|
19154
|
+
};
|
|
19103
19155
|
var DEFAULT_THREAD_PARTICIPANT_LIMIT = 100;
|
|
19104
19156
|
var ensureThreadChannel = (client, threadData) => {
|
|
19105
19157
|
if (!threadData.channel) {
|
|
@@ -20856,8 +20908,20 @@ var messageDeletedHandler = {
|
|
|
20856
20908
|
handle: (context) => context.event.hard_delete ? reinsertItem(context) : void 0,
|
|
20857
20909
|
id: "ChannelManager:default-handler:message.deleted"
|
|
20858
20910
|
};
|
|
20911
|
+
var reloadListsWithoutLoadedPage = (channelManager, channel) => {
|
|
20912
|
+
channelManager.paginators.forEach((paginator) => {
|
|
20913
|
+
if (paginator.items === void 0 || paginator.isLoading) return;
|
|
20914
|
+
if (paginator.anchoredHeadItems.length > 0) return;
|
|
20915
|
+
if (!paginator.matchesFilter(channel)) return;
|
|
20916
|
+
paginator.toTailDebounced({ reset: "yes" });
|
|
20917
|
+
});
|
|
20918
|
+
};
|
|
20859
20919
|
var channelVisibleHandler = {
|
|
20860
|
-
handle:
|
|
20920
|
+
handle: async (context) => {
|
|
20921
|
+
await updateLists(context);
|
|
20922
|
+
const channel = getCachedChannelFromEvent(context.event, context.ctx.channelManager);
|
|
20923
|
+
if (channel) reloadListsWithoutLoadedPage(context.ctx.channelManager, channel);
|
|
20924
|
+
},
|
|
20861
20925
|
id: "ChannelManager:default-handler:channel.visible"
|
|
20862
20926
|
};
|
|
20863
20927
|
var channelHiddenHandler = {
|
|
@@ -25071,7 +25135,7 @@ var StreamChat = class _StreamChat extends ChatApi {
|
|
|
25071
25135
|
return this.userAgent;
|
|
25072
25136
|
}
|
|
25073
25137
|
if (!this.cachedUserAgent) {
|
|
25074
|
-
const version = "10.0.0-rc.
|
|
25138
|
+
const version = "10.0.0-rc.29";
|
|
25075
25139
|
const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
|
|
25076
25140
|
const { name: appName, version: appVersion } = this.appIdentifier ?? {};
|
|
25077
25141
|
const { os, model: deviceModel } = this.deviceIdentifier ?? {};
|
|
@@ -26286,7 +26350,7 @@ var MESSAGE_COMPOSER_FIELDS = {
|
|
|
26286
26350
|
kind: "group"
|
|
26287
26351
|
},
|
|
26288
26352
|
retainCompositionOnSubmit: {
|
|
26289
|
-
description: "Decides whether submitting keeps the composer's contents instead of clearing them. Retains for a poll message by default.",
|
|
26353
|
+
description: "Decides whether submitting keeps the composer's contents instead of clearing them. Retains for a poll message by default, while the composition chain sends polls alone.",
|
|
26290
26354
|
kind: "value",
|
|
26291
26355
|
type: "function"
|
|
26292
26356
|
},
|
|
@@ -26680,26 +26744,6 @@ var languageNameDefaults = Object.fromEntries(
|
|
|
26680
26744
|
Object.entries(LANGUAGE_NAMES).map(([code, name]) => [`language.${code}`, name])
|
|
26681
26745
|
);
|
|
26682
26746
|
|
|
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
26747
|
// src/offline-support/offline_sync_manager.ts
|
|
26704
26748
|
var import_axios6 = require("axios");
|
|
26705
26749
|
var logger20 = chatLoggerSystem.getLogger("offline-db");
|