stream-chat 10.0.0-rc.21 → 10.0.0-rc.23

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.
Files changed (269) hide show
  1. package/dist/cjs/index.browser.js +2196 -3902
  2. package/dist/cjs/index.browser.js.map +3 -3
  3. package/dist/cjs/index.node.js +2197 -3902
  4. package/dist/cjs/index.node.js.map +3 -3
  5. package/dist/esm/index.mjs +2199 -3905
  6. package/dist/esm/index.mjs.map +4 -4
  7. package/dist/types/ChannelManager.d.ts +120 -233
  8. package/dist/types/CooldownTimer.d.ts +8 -23
  9. package/dist/types/EventHandlerPipeline.d.ts +17 -37
  10. package/dist/types/LiveLocationManager.d.ts +22 -50
  11. package/dist/types/api-client.d.ts +9 -14
  12. package/dist/types/channel.d.ts +253 -448
  13. package/dist/types/channel_state.d.ts +48 -95
  14. package/dist/types/client.d.ts +245 -370
  15. package/dist/types/client_state.d.ts +1 -3
  16. package/dist/types/configuration/ConfigController.d.ts +30 -124
  17. package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +31 -123
  18. package/dist/types/configuration/keys.d.ts +5 -19
  19. package/dist/types/configuration/shape.d.ts +12 -29
  20. package/dist/types/configuration/types.d.ts +59 -87
  21. package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +13 -35
  22. package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
  23. package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
  24. package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
  25. package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
  26. package/dist/types/connection/ConnectionIdManager.d.ts +18 -40
  27. package/dist/types/connection/ConnectionRecoveryManager.d.ts +29 -120
  28. package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +32 -103
  29. package/dist/types/connection/networkConnection/reporters.d.ts +9 -32
  30. package/dist/types/connection/networkConnection/types.d.ts +12 -27
  31. package/dist/types/connection/wsConnection/StableWSConnection.d.ts +37 -116
  32. package/dist/types/connection/wsConnection/WSConnection.d.ts +41 -104
  33. package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +8 -16
  34. package/dist/types/connection/wsConnection/config.d.ts +8 -28
  35. package/dist/types/connection/wsConnection/types.d.ts +17 -70
  36. package/dist/types/entityStore/EntityStore.d.ts +153 -113
  37. package/dist/types/entityStore/StoreBackedItemIndex.d.ts +13 -46
  38. package/dist/types/errors.d.ts +7 -19
  39. package/dist/types/gen/chat/ChannelApi.d.ts +2 -1
  40. package/dist/types/gen/chat/ChatApi.d.ts +28 -14
  41. package/dist/types/gen/models/index.d.ts +769 -86
  42. package/dist/types/gen/moderation/ModerationApi.d.ts +4 -4
  43. package/dist/types/index.d.ts +2 -4
  44. package/dist/types/languageNames.d.ts +9 -24
  45. package/dist/types/logger.d.ts +1 -3
  46. package/dist/types/messageComposer/LocationComposer.d.ts +1 -1
  47. package/dist/types/messageComposer/attachmentIdentity.d.ts +1 -6
  48. package/dist/types/messageComposer/attachmentManager.d.ts +10 -32
  49. package/dist/types/messageComposer/attachmentUtils.d.ts +3 -14
  50. package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
  51. package/dist/types/messageComposer/configuration/types.d.ts +29 -56
  52. package/dist/types/messageComposer/linkPreviewsManager.d.ts +6 -9
  53. package/dist/types/messageComposer/messageComposer.d.ts +30 -164
  54. package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +4 -14
  55. package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +2 -9
  56. package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
  57. package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
  58. package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +9 -0
  59. package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +11 -18
  60. package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
  61. package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
  62. package/dist/types/messageComposer/pollComposer.d.ts +8 -4
  63. package/dist/types/messageComposer/textComposer.d.ts +3 -9
  64. package/dist/types/messageComposer/types.d.ts +5 -8
  65. package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +25 -79
  66. package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +15 -82
  67. package/dist/types/messageOperations/FailedSendCache.d.ts +4 -9
  68. package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +10 -20
  69. package/dist/types/messageOperations/MessageOperations.d.ts +20 -40
  70. package/dist/types/messageOperations/applyReactionLocally.d.ts +5 -22
  71. package/dist/types/messageOperations/createMessageOperations.d.ts +3 -5
  72. package/dist/types/messageOperations/reflectReactionEvent.d.ts +5 -13
  73. package/dist/types/messageOperations/sendOrdering.d.ts +4 -7
  74. package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +7 -15
  75. package/dist/types/messageOperations/types.d.ts +15 -30
  76. package/dist/types/middleware.d.ts +7 -5
  77. package/dist/types/moderation.d.ts +21 -14
  78. package/dist/types/notifications/NotificationManager.d.ts +8 -31
  79. package/dist/types/notifications/types.d.ts +19 -59
  80. package/dist/types/offline-support/offline_support_api.d.ts +145 -539
  81. package/dist/types/offline-support/offline_sync_manager.d.ts +18 -42
  82. package/dist/types/offline-support/queueableOperations.d.ts +24 -52
  83. package/dist/types/offline-support/types.d.ts +24 -187
  84. package/dist/types/pagination/ItemIndex.d.ts +4 -12
  85. package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
  86. package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -4
  87. package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +2 -3
  88. package/dist/types/pagination/paginators/BasePaginator.d.ts +235 -622
  89. package/dist/types/pagination/paginators/ChannelPaginator.d.ts +67 -125
  90. package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +133 -292
  91. package/dist/types/pagination/paginators/MessagePaginator.d.ts +69 -118
  92. package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +7 -26
  93. package/dist/types/pagination/paginators/ReminderPaginator.d.ts +2 -2
  94. package/dist/types/pagination/paginators/ThreadPaginator.d.ts +15 -23
  95. package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +2 -6
  96. package/dist/types/pagination/sortCompiler.d.ts +11 -22
  97. package/dist/types/pagination/utility.normalization.d.ts +5 -23
  98. package/dist/types/pagination/utility.search.d.ts +3 -8
  99. package/dist/types/poll.d.ts +14 -14
  100. package/dist/types/poll_manager.d.ts +11 -2
  101. package/dist/types/poll_optimistic_votes.d.ts +10 -14
  102. package/dist/types/reminders/Reminder.d.ts +4 -4
  103. package/dist/types/reminders/ReminderManager.d.ts +7 -20
  104. package/dist/types/search/BaseSearchSource.d.ts +7 -12
  105. package/dist/types/search/ChannelSearchSource.d.ts +7 -7
  106. package/dist/types/search/MessageSearchSource.d.ts +7 -9
  107. package/dist/types/search/SearchController.d.ts +17 -22
  108. package/dist/types/search/types.d.ts +6 -10
  109. package/dist/types/signing.d.ts +12 -3
  110. package/dist/types/thread.d.ts +23 -71
  111. package/dist/types/thread_manager.d.ts +45 -70
  112. package/dist/types/token_manager.d.ts +8 -13
  113. package/dist/types/types.d.ts +64 -125
  114. package/dist/types/types.utility.d.ts +3 -3
  115. package/dist/types/upload-utils.d.ts +5 -10
  116. package/dist/types/uploadManager.d.ts +17 -45
  117. package/dist/types/utils/FixedSizeQueueCache.d.ts +6 -11
  118. package/dist/types/utils/WithSubscriptions.d.ts +5 -15
  119. package/dist/types/utils/concurrency.d.ts +11 -19
  120. package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
  121. package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
  122. package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
  123. package/dist/types/utils/objectPath.d.ts +6 -41
  124. package/dist/types/utils/retryable.d.ts +8 -12
  125. package/dist/types/utils/throttling/throttle.d.ts +8 -23
  126. package/dist/types/utils/time.d.ts +24 -64
  127. package/dist/types/utils.d.ts +40 -86
  128. package/package.json +7 -2
  129. package/src/ChannelManager.ts +159 -300
  130. package/src/CooldownTimer.ts +11 -29
  131. package/src/EventHandlerPipeline.ts +21 -44
  132. package/src/LiveLocationManager.ts +35 -74
  133. package/src/api-client.ts +43 -61
  134. package/src/campaign.ts +1 -1
  135. package/src/channel.ts +396 -749
  136. package/src/channel_batch_updater.ts +1 -1
  137. package/src/channel_state.ts +50 -105
  138. package/src/client.ts +360 -588
  139. package/src/client_state.ts +1 -6
  140. package/src/configuration/ConfigController.ts +41 -157
  141. package/src/configuration/InstanceConfigurationRegistry.ts +42 -171
  142. package/src/configuration/index.ts +1 -1
  143. package/src/configuration/keys.ts +13 -32
  144. package/src/configuration/shape.ts +67 -70
  145. package/src/configuration/types.ts +60 -100
  146. package/src/configuration/utils/applyInstanceConfiguration.ts +21 -53
  147. package/src/configuration/utils/copyConfigPatch.ts +11 -32
  148. package/src/configuration/utils/declarativeSlices.ts +9 -39
  149. package/src/configuration/utils/deepFreezeConfig.ts +3 -17
  150. package/src/configuration/utils/index.ts +2 -4
  151. package/src/configuration/utils/serverAuthority.ts +20 -68
  152. package/src/connection/ConnectionIdManager.ts +20 -49
  153. package/src/connection/ConnectionRecoveryManager.ts +51 -178
  154. package/src/connection/networkConnection/NetworkConnectionObserver.ts +37 -114
  155. package/src/connection/networkConnection/reporters.ts +9 -36
  156. package/src/connection/networkConnection/types.ts +12 -27
  157. package/src/connection/wsConnection/StableWSConnection.ts +73 -193
  158. package/src/connection/wsConnection/WSConnection.ts +56 -131
  159. package/src/connection/wsConnection/WSConnectionFallback.ts +22 -31
  160. package/src/connection/wsConnection/config.ts +13 -48
  161. package/src/connection/wsConnection/types.ts +17 -70
  162. package/src/constants.ts +4 -4
  163. package/src/entityStore/EntityStore.ts +162 -167
  164. package/src/entityStore/StoreBackedItemIndex.ts +14 -47
  165. package/src/errors.ts +7 -19
  166. package/src/formatMessageMemo.ts +3 -9
  167. package/src/gen/chat/ChannelApi.ts +19 -0
  168. package/src/gen/chat/ChatApi.ts +87 -13
  169. package/src/gen/models/index.ts +793 -71
  170. package/src/gen/moderation/ModerationApi.ts +0 -4
  171. package/src/index.ts +10 -14
  172. package/src/languageNames.ts +9 -24
  173. package/src/logger.ts +1 -3
  174. package/src/messageComposer/LocationComposer.ts +7 -23
  175. package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
  176. package/src/messageComposer/attachmentIdentity.ts +2 -13
  177. package/src/messageComposer/attachmentManager.ts +17 -63
  178. package/src/messageComposer/attachmentUtils.ts +3 -17
  179. package/src/messageComposer/configuration/configuration.ts +5 -8
  180. package/src/messageComposer/configuration/types.ts +29 -56
  181. package/src/messageComposer/fileUtils.ts +1 -1
  182. package/src/messageComposer/linkPreviewsManager.ts +8 -20
  183. package/src/messageComposer/messageComposer.ts +54 -222
  184. package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +4 -16
  185. package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +1 -2
  186. package/src/messageComposer/middleware/messageComposer/attachments.ts +14 -40
  187. package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +3 -4
  188. package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
  189. package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +4 -11
  190. package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
  191. package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
  192. package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
  193. package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +1 -6
  194. package/src/messageComposer/middleware/textComposer/commandUtils.ts +1 -2
  195. package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
  196. package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
  197. package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
  198. package/src/messageComposer/middleware/textComposer/types.ts +1 -6
  199. package/src/messageComposer/pollComposer.ts +11 -8
  200. package/src/messageComposer/textComposer.ts +9 -59
  201. package/src/messageComposer/types.ts +9 -12
  202. package/src/messageDelivery/MessageDeliveryReporter.ts +60 -113
  203. package/src/messageDelivery/MessageReceiptsTracker.ts +21 -105
  204. package/src/messageOperations/FailedSendCache.ts +4 -9
  205. package/src/messageOperations/MessageOperationStatePolicy.ts +40 -67
  206. package/src/messageOperations/MessageOperations.ts +33 -62
  207. package/src/messageOperations/applyReactionLocally.ts +9 -28
  208. package/src/messageOperations/createMessageOperations.ts +17 -33
  209. package/src/messageOperations/reflectReactionEvent.ts +5 -13
  210. package/src/messageOperations/sendOrdering.ts +4 -7
  211. package/src/messageOperations/settlePendingAttachmentUploads.ts +10 -21
  212. package/src/messageOperations/types.ts +15 -30
  213. package/src/middleware.ts +7 -10
  214. package/src/moderation.ts +25 -21
  215. package/src/notifications/NotificationManager.ts +11 -35
  216. package/src/notifications/types.ts +19 -59
  217. package/src/offline-support/offline_support_api.ts +178 -608
  218. package/src/offline-support/offline_sync_manager.ts +25 -69
  219. package/src/offline-support/queueableOperations.ts +31 -84
  220. package/src/offline-support/types.ts +25 -188
  221. package/src/pagination/ItemIndex.ts +4 -12
  222. package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
  223. package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +13 -62
  224. package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
  225. package/src/pagination/cursorDerivation/linearPaginationFlags.ts +4 -6
  226. package/src/pagination/filterCompiler.ts +11 -25
  227. package/src/pagination/paginators/BasePaginator.ts +422 -976
  228. package/src/pagination/paginators/ChannelPaginator.ts +130 -190
  229. package/src/pagination/paginators/MessageIntervalPaginator.ts +226 -457
  230. package/src/pagination/paginators/MessagePaginator.ts +135 -175
  231. package/src/pagination/paginators/PinnedMessagePaginator.ts +13 -38
  232. package/src/pagination/paginators/ReminderPaginator.ts +12 -15
  233. package/src/pagination/paginators/ThreadPaginator.ts +16 -26
  234. package/src/pagination/paginators/UserGroupPaginator.ts +6 -17
  235. package/src/pagination/paginators/stateThrottling.ts +5 -10
  236. package/src/pagination/sortCompiler.ts +23 -50
  237. package/src/pagination/utility.normalization.ts +8 -30
  238. package/src/pagination/utility.search.ts +4 -11
  239. package/src/poll.ts +19 -19
  240. package/src/poll_manager.ts +16 -20
  241. package/src/poll_optimistic_votes.ts +17 -22
  242. package/src/reminders/Reminder.ts +5 -6
  243. package/src/reminders/ReminderManager.ts +9 -34
  244. package/src/reminders/ReminderTimer.ts +1 -2
  245. package/src/search/BaseSearchSource.ts +14 -29
  246. package/src/search/ChannelSearchSource.ts +8 -8
  247. package/src/search/MessageSearchSource.ts +19 -25
  248. package/src/search/SearchController.ts +18 -24
  249. package/src/search/types.ts +6 -10
  250. package/src/segment.ts +1 -1
  251. package/src/signing.ts +23 -3
  252. package/src/thread.ts +72 -173
  253. package/src/thread_manager.ts +59 -76
  254. package/src/token_manager.ts +11 -21
  255. package/src/types.ts +78 -126
  256. package/src/types.utility.ts +3 -3
  257. package/src/upload-utils.ts +5 -10
  258. package/src/uploadManager.ts +22 -54
  259. package/src/utils/FixedSizeQueueCache.ts +13 -21
  260. package/src/utils/WithSubscriptions.ts +5 -15
  261. package/src/utils/concurrency.ts +16 -55
  262. package/src/utils/mergeWith/mergeWith.ts +10 -13
  263. package/src/utils/mergeWith/mergeWithCore.ts +24 -81
  264. package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
  265. package/src/utils/objectPath.ts +6 -41
  266. package/src/utils/retryable.ts +10 -14
  267. package/src/utils/throttling/throttle.ts +9 -25
  268. package/src/utils/time.ts +26 -66
  269. package/src/utils.ts +72 -128
@@ -13,38 +13,29 @@ type ChannelReadStatus = Record<string, {
13
13
  last_delivered_message_id?: string;
14
14
  }>;
15
15
  /**
16
- * Whether this client holds a server-side watch on the channel — i.e. whether channel events are
17
- * being delivered to it.
18
- *
19
- * Three values rather than a boolean, because "not watching" alone cannot say whether a re-watch is
20
- * wanted: a watch lost to a dead socket should be restored on reconnect, one the consumer stopped
21
- * deliberately must not be. The server keys watches by connection ID, so a dropped socket ends every
22
- * watch this client held — even if it reconnects moments later with a fresh ID.
16
+ * Whether this client holds a server-side watch on the channel (channel events are delivered to it).
17
+ * Three values because a watch lost to a dropped socket should be restored on reconnect, while one the
18
+ * consumer stopped must not be. The server keys watches by connection ID, so a dropped socket ends
19
+ * every watch this client held.
23
20
  */
24
21
  export declare const ChannelWatchStatus: {
25
- /** Never watched, or the consumer stopped watching on purpose — do NOT re-watch. */
22
+ /** Never watched, or the consumer stopped watching: do NOT re-watch. */
26
23
  readonly NotWatching: "notWatching";
27
- /** Was watching until the connection dropped — the watch is gone and SHOULD be restored. */
24
+ /** Was watching until the connection dropped: the watch is gone and SHOULD be restored. */
28
25
  readonly WasWatching: "wasWatching";
29
- /** Holding a live watch: events are flowing. */
26
+ /** Holds a live watch. */
30
27
  readonly Watching: "watching";
31
28
  };
32
29
  export type ChannelWatchStatus = (typeof ChannelWatchStatus)[keyof typeof ChannelWatchStatus];
33
- /**
34
- * Everything about watching this channel: who else is watching it, and whether *we* are.
35
- */
30
+ /** Who is watching the channel, and whether this client is. */
36
31
  export type ChannelWatchState = {
37
32
  watcherCount: number;
38
33
  watchers: Record<string, UserResponse>;
39
34
  /**
40
- * See {@link ChannelWatchStatus}. Goes to `Watching` when a query carrying `watch: true` succeeds
41
- * (`channel.watch()`, `channel.query({ watch: true })`, `client.queryChannels()`); to
42
- * `WasWatching` when the WS connection is lost (only from `Watching` — a deliberate stop is never
43
- * resurrected); and to `NotWatching` on `channel.stopWatching()` or `channel.disconnect()`.
44
- *
45
- * It is truthful by construction: `channel.watch()` and `client.queryChannels()` wait for a live
46
- * socket rather than degrading, so a query carrying `watch: true` can only succeed against a
47
- * connection ID that is actually current.
35
+ * See {@link ChannelWatchStatus}. Becomes `Watching` when a query with `watch: true` succeeds
36
+ * (`channel.watch()`, `channel.query({ watch: true })`, `client.queryChannelsAndHydrate()`, a
37
+ * thread query with `watch: true`), `WasWatching` when the connection is lost (only from
38
+ * `Watching`), and `NotWatching` on `channel.stopWatching()` or `channel.disconnect()`.
48
39
  */
49
40
  watchStatus: ChannelWatchStatus;
50
41
  };
@@ -57,30 +48,22 @@ export type ReadState = {
57
48
  export type MembersState = {
58
49
  members: Record<string, ChannelMemberResponse>;
59
50
  /**
60
- * Total member count, sourced from `channel.data.member_count`. Set on query / watch / hydration
61
- * (incl. offline-DB rehydration) and on `channel.updated` — deliberately NOT on `member.added` /
62
- * `member.removed`. `channel.updated` fires on every member change and is the authoritative count;
63
- * incrementing per member event double-counted when several members changed at once.
64
- * See https://github.com/GetStream/stream-chat-js/pull/1761.
51
+ * From `channel.data.member_count`. Set on query, watch and hydration (including the offline DB) and
52
+ * on `channel.updated`, not on `member.added` / `member.removed`: `channel.updated` fires on every
53
+ * member change and is authoritative, while counting per member event double-counts.
65
54
  */
66
55
  memberCount: number;
67
56
  };
68
- /** The current user's own membership in this channel (role, pinned_at, archived_at, …). */
69
57
  export type MembershipState = {
70
58
  membership: ChannelMemberResponse;
71
59
  };
72
60
  export type OwnCapabilitiesState = {
73
61
  ownCapabilities: string[];
74
62
  };
75
- /**
76
- * The channel's server-provided `data` (name, image, frozen, hidden, blocked, config,
77
- * `member_count`, `own_capabilities`, …), mirrored reactively so consumers can subscribe to
78
- * channel-level changes via `useStateStore(channel.state, (s) => ({ data: s.data }))`.
79
- */
80
63
  export type ChannelDataState = {
81
64
  data: Channel['data'];
82
65
  };
83
- /** Whether THIS channel is muted for the current user, mirrored from `client.mutedChannels`. */
66
+ /** Whether this channel is muted for the current user, mirrored from `client.mutedChannels`. */
84
67
  export type ChannelMuteStatus = {
85
68
  muted: boolean;
86
69
  /** Unix nanoseconds, as the API sends it. */
@@ -89,103 +72,75 @@ export type ChannelMuteStatus = {
89
72
  expiresAt: TimestampNS | null;
90
73
  };
91
74
  /**
92
- * Reactive channel-mute state — is this channel muted for the current user. Mirrors the client-owned
93
- * `client.mutedChannels` (updated on `notification.channel_mutes_updated` + `health.check`) and is
94
- * subscribable via `useStateStore(channel.state, (s) => ({ muteStatus: s.muteStatus }))`. Muted
95
- * USERS remain client-global on `client.mutedUsersStore` and are NOT part of channel state.
75
+ * Kept in sync with `client.mutedChannels` (`notification.channel_mutes_updated`, `health.check`).
76
+ * Muted users are client-global (`client.mutedUsersStore`), not part of channel state.
96
77
  */
97
78
  export type MuteStatusState = {
98
79
  muteStatus: ChannelMuteStatus;
99
80
  };
100
81
  /**
101
- * Connection / initialization lifecycle flags for the channel. Previously plain fields on `Channel`;
102
- * now store-backed so consumers can react to them via `useStateStore(channel.state, selector)`.
103
- * Read through the `channel.initialized` / `channel.offlineMode` / `channel.pendingDisposal`
104
- * getters, which proxy this slice; `initialized` and `offlineMode` have setters too, while
105
- * `pendingDisposal` is set only by `channel.disconnect()`.
82
+ * Read through the `channel.initialized` / `offlineMode` / `pendingDisposal` / `supersededBy`
83
+ * getters. Only `channel.disconnect()` sets `pendingDisposal`.
106
84
  */
107
85
  export type ChannelLifecycleState = {
108
86
  /**
109
- * Whether a live server response was applied to this instance since it was created: a query
110
- * (`channel.query()`, and `watch()` and `create()`, which use it) or a `queryChannels` result.
111
- * Its data was current when it arrived; `watchStatus` tells whether it is kept current since.
112
- * `false` means nothing confirmed it yet: the channel may or may not exist on the server.
113
- * Data restored from the offline database doesn't count (see `offlineMode`). Never reset.
87
+ * Whether a live server response (a query or a `queryChannels` result) was applied to this instance
88
+ * since it was created. `false`: nothing confirmed the channel yet, so it may or may not exist on
89
+ * the server. Data restored from the offline database does not count (see `offlineMode`).
90
+ * `watchStatus` tells whether the data is kept current. Never reset.
114
91
  */
115
92
  initialized: boolean;
116
93
  /**
117
- * Whether the channel was initialized by manually populating its state (e.g. offline hydration)
118
- * rather than a live watch. Such static state means the channel exists on the backend but is not
119
- * being watched yet.
94
+ * Whether the state was populated manually (e.g. offline hydration) rather than by a live query: the
95
+ * channel exists on the backend but is not watched yet.
120
96
  */
121
97
  offlineMode: boolean;
122
98
  /**
123
99
  * Whether `channel.disconnect()` has run: the channel was deleted, the current user removed from
124
- * it, the client disconnected, or nothing used it any more. One-way and terminal — see
125
- * {@link Channel.pendingDisposal}: the instance is never revived.
100
+ * it, the client disconnected, or nothing uses it. Terminal, see {@link Channel.pendingDisposal}.
126
101
  */
127
102
  pendingDisposal: boolean;
128
103
  /**
129
- * The stored instance that replaced this one: this instance was created without an id, and when
130
- * the server answered with the real cid, another instance was already stored under it (put there by
131
- * an event or a channel list meanwhile). The stored instance took this one's server data, local
132
- * messages and, when this one was open and it wasn't, its composer. Anything still holding this
133
- * instance should switch to it. Set once.
104
+ * The stored instance that replaced this one: this one was created without an ID and, when the server
105
+ * answered with the cid, another instance was already stored under it. That instance took this one's
106
+ * server data, local messages and (if this one was open and it was not) its composer. Set once.
134
107
  */
135
108
  supersededBy: Channel | undefined;
136
109
  };
137
- /**
138
- * Whether the channel is currently being consumed — consumer-declared, never returned by the API.
139
- * Mirrors `thread.state.active`.
140
- */
110
+ /** Consumer-declared, never returned by the API. */
141
111
  export type ChannelActivationState = {
142
112
  /**
143
- * Whether a consumer has declared this channel as the one it is currently reading, via
144
- * `channel.activate()` and the release function it returns (refcounted, as a single `Channel`
145
- * instance can be held by several consumers at once). It carries no rendering semantics; it tells the client
146
- * that the channel's own state is being consumed and takes precedence over bulk state writes —
147
- * channel-list hydration does not re-seed the message list of an `active` channel (the channel's
148
- * own `channel.reload()` owns that window).
113
+ * Whether a consumer declared this channel as the one it is reading, via `channel.activate()`. Its
114
+ * own state then takes precedence over bulk writes: channel-list hydration does not re-seed the
115
+ * message list of an `active` channel (`channel.reload()` owns that window).
149
116
  */
150
117
  active: boolean;
151
118
  };
152
119
  /**
153
- * Reactive AI-indicator state — driven by the `ai_indicator.update` / `.clear` / `.stop` events (see
154
- * `Channel._handleChannelEvent`). Seeded to `AIStates.Idle` and subscribable via
155
- * `useStateStore(channel.state, (s) => ({ aiState: s.aiState }))`. Reset to `Idle` on unwatch /
156
- * disconnect (a live server sends `ai_indicator.clear` when the AI response starts streaming).
120
+ * Driven by the `ai_indicator.update` / `.clear` / `.stop` events. Reset to `Idle` when the connection
121
+ * closes or goes unhealthy, as the `clear`/`stop` that ends a response is missed and not replayed.
157
122
  */
158
123
  export type AIIndicatorState = {
159
124
  aiState: AIState;
160
125
  };
161
126
  /**
162
- * The single, unified reactive state for a channel. All per-channel reactive state is published
163
- * through this one `StateStore` and subscribed to with `useStateStore(channel.state, selector)`
164
- * (mirroring `thread.state`).
165
- *
166
- * The shape is FLAT — subscribe to any slice via a selector, e.g.
127
+ * All per-channel reactive state, in one flat `StateStore`. Subscribe with a selector, e.g.
167
128
  * `useStateStore(channel.state, (s) => ({ read: s.read }))`.
168
129
  */
169
130
  export type ChannelStateData = ChannelWatchState & TypingUsersState & ReadState & MembersState & MembershipState & OwnCapabilitiesState & ChannelDataState & MuteStatusState & ChannelLifecycleState & ChannelActivationState & AIIndicatorState;
170
131
  /**
171
- * ChannelState - the container for a channel's reactive state.
172
- *
173
- * It IS a `StateStore<ChannelStateData>` (so `useStateStore(channel.state, selector)` works,
174
- * mirroring `thread.state`) while additionally exposing convenience getters/setters
175
- * (`members`, `read`, `typing`, `watchers`, …) that read/write the same unified store.
132
+ * A `StateStore<ChannelStateData>` that also exposes getters/setters (`members`, `read`, `typing`,
133
+ * `watchers`, ...) over the same store.
176
134
  */
177
135
  export declare class ChannelState extends StateStore<ChannelStateData> {
178
136
  _channel: Channel;
179
137
  pending_messages: Array<PendingMessageResponse>;
180
138
  constructor(channel: Channel);
181
139
  /**
182
- * The current user's unread message count, derived from the `read` slice
183
- * (`read[ownUserId].unread_messages`) rather than stored a second time — there is exactly one
184
- * place holding this value, so the count the unread badge reads can never drift from the count
185
- * `channel.countUnread()` returns. Written through `Channel._setOwnUnreadCount`.
140
+ * The current user's unread count, derived from `read[ownUserId].unread_messages` so it cannot drift
141
+ * from `channel.countUnread()`. Written through `Channel._setOwnUnreadCount`.
186
142
  */
187
143
  get unreadCount(): number;
188
- /** The current user's own membership; store-backed so `useStateStore` can subscribe to it. */
189
144
  get membership(): ChannelMemberResponse;
190
145
  set membership(membership: ChannelMemberResponse);
191
146
  get members(): Record<string, ChannelMemberResponse>;
@@ -203,20 +158,18 @@ export declare class ChannelState extends StateStore<ChannelStateData> {
203
158
  get watcher_count(): number;
204
159
  set watcher_count(watcherCount: number);
205
160
  /**
206
- * Takes the message object, adds SDK-specific fields (status, error),
207
- * and returns a new message object.
161
+ * Adds the SDK-specific fields (`status`, `error`) to a message. Memoized per source object:
162
+ * callers share the result, so do not mutate it.
208
163
  *
209
- * @param message - `MessageResponse` object
164
+ * @param message - The message from the API, or a local one.
165
+ * @returns The `LocalMessage`.
210
166
  */
211
167
  formatMessage: (message: MessageResponse | LocalMessage) => LocalMessage;
212
- /**
213
- * clean - Remove stale data such as users that stayed in typing state for more than 5 seconds
214
- */
168
+ /** Removes users typing for more than 7 seconds without a new event, dispatching `typing.stop`. */
215
169
  clean(): void;
216
170
  /**
217
- * Resets the AI indicator to `Idle`. Called when the connection drops, as while the connection is
218
- * severed we miss the `ai_indicator.clear`/`.stop` that ends a response and it isn't replayed on
219
- * reconnect, so the indicator would otherwise stay stuck on "Generating". Noop when already `Idle`.
171
+ * Resets the AI indicator to `Idle`. Called when the connection closes or goes unhealthy: the
172
+ * `ai_indicator.clear`/`.stop` that ends a response is missed then and not replayed on reconnect.
220
173
  */
221
174
  resetAIState(): void;
222
175
  }