@poolse/react 3.2.0-dev.5 → 3.3.0

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/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { PoolseConfig, Poolse, Me, Uuid, Conversation, ConversationCreateRequest, Membership, MemberRole, Message, MessageCreateRequest, RealtimeStatus, Attachment, AttachmentUploadInput, PoolseUserProfile, CallRoomStatus, CallParticipant, CameraFacing, CallDeviceKind, CallDevice, LiveKitModule, LiveCall } from '@poolse/sdk';
3
- export { ApiError, Attachment, AttachmentStatus, AttachmentUploadInput, AttachmentUploadRequest, AttachmentUploadResponse, AuthError, CallEndReason, CallLog, CallLogDisplay, CallLogEntry, CallLogMedia, CallMissedEntry, CallParticipantStatus, Conversation, ConversationCreateRequest, DeviceKind, LiveCall, LiveCallMember, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageType, NetworkError, PoolseConfig, PoolseError, PoolseUserProfile, RateLimitedError, ReadReceiptsState, RealtimeStatus, RoomSession, Uuid, callLogDisplayFor, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, parseCallLog, parseCallLogBody } from '@poolse/sdk';
2
+ import { PoolseConfig, Poolse, Me, Uuid, Conversation, ConversationCreateRequest, Membership, MemberRole, Message, MessageCreateRequest, RealtimeStatus, Attachment, AttachmentUploadInput, PoolseUserProfile, AppEvent, CallRoomStatus, CallParticipant, CameraFacing, CallDeviceKind, CallDevice, LiveKitModule, LiveCall } from '@poolse/sdk';
3
+ export { ApiError, AppEvent, Attachment, AttachmentStatus, AttachmentUploadInput, AttachmentUploadRequest, AttachmentUploadResponse, AuthError, CallEndReason, CallLog, CallLogDisplay, CallLogEntry, CallLogMedia, CallMissedEntry, CallParticipantStatus, Conversation, ConversationCreateRequest, ConversationReadEvent, DeviceKind, LiveCall, LiveCallMember, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageType, NetworkError, NotificationPreferences, NotifyLevel, OwnMembership, OwnMembershipUpdateRequest, PoolseConfig, PoolseError, PoolseUserProfile, RateLimitedError, ReadReceiptsState, RealtimeStatus, RoomSession, Uuid, callLogDisplayFor, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, parseCallLog, parseCallLogBody } from '@poolse/sdk';
4
4
  import { ReactNode } from 'react';
5
5
 
6
6
  interface PoolseProviderProps {
@@ -89,29 +89,38 @@ interface UseConversationsState {
89
89
  refetch: () => Promise<void>;
90
90
  create: (attrs: ConversationCreateRequest) => Promise<Conversation>;
91
91
  /**
92
- * Per-conversation unread count, keyed by conversation id. Sourced
93
- * from `Conversation.unread_count` on the initial fetch and kept
94
- * fresh as the caller marks conversations read (via `markRead`).
95
- *
96
- * Note: cross-conversation incrementing on a new inbound message
97
- * requires subscribing to every conversation channel, which the SDK
98
- * doesn't do by default. Counts in this map are accurate for the
99
- * conversation the caller has open + correct at fetch time for the
100
- * rest; refetch on a fresh tab focus for true reconciliation.
92
+ * Per-conversation unread count, keyed by conversation id (only
93
+ * conversations with unread messages appear). Sourced from
94
+ * `Conversation.unread_count` and kept fresh by realtime
95
+ * (`conversation:updated`, and `conversation:read` when the user
96
+ * reads on any of their devices) and by `markReadUpTo` /
97
+ * `markConversationRead` anywhere under the same provider.
101
98
  */
102
99
  unreadCounts: Record<Uuid, number>;
103
- /** Force a conversation's unread to 0 — invoked by `markReadUpTo`. */
100
+ /** Like `unreadCounts`, for unread messages that mention the user. */
101
+ mentionUnreadCounts: Record<Uuid, number>;
102
+ /**
103
+ * Force a conversation's unread and mention counts to 0 in every
104
+ * view. `useMessages().markReadUpTo` does this for you once the
105
+ * server accepts it.
106
+ */
104
107
  markConversationRead: (conversationId: Uuid) => void;
105
108
  }
106
109
  /**
107
110
  * List of conversations the current End User can see.
108
111
  *
109
- * On mount: REST-fetches the list and subscribes to the user's
110
- * `user:<id>` channel for `conversation:created` events — fired by
111
- * the server both when this user creates a conversation AND when
112
- * someone else adds them to one. New rows are prepended to local
113
- * state with id-based dedup so an optimistic `create()` followed by
114
- * the realtime echo doesn't insert twice.
112
+ * Every `useConversations()` under one `<PoolseProvider>` shares one
113
+ * list: a sidebar and an inbox header show the same rows and the same
114
+ * badges, and reading a conversation anywhere clears its badge
115
+ * everywhere.
116
+ *
117
+ * The first one mounted REST-fetches the list and subscribes to the
118
+ * user's `user:<id>` channel for `conversation:created` (this user
119
+ * created a conversation or was added to one), `conversation:updated`
120
+ * (a message was sent) and `conversation:read` (this user read it on
121
+ * some device). New rows are prepended with id-based dedup so an
122
+ * optimistic `create()` followed by the realtime echo doesn't insert
123
+ * twice.
115
124
  *
116
125
  * `refetch()` is still here for explicit re-syncs (e.g. after a
117
126
  * mutation that the SDK doesn't yet observe — name changes,
@@ -174,11 +183,21 @@ interface UseMessagesState {
174
183
  * body) locally, rolls back on error.
175
184
  */
176
185
  delete: (messageId: Uuid) => Promise<void>;
186
+ /**
187
+ * Load older pages until `messageId` is in `messages` — to jump to a
188
+ * message further back than what's loaded. Resolves `true` once it's
189
+ * there, `false` when history runs out (or after `maxPages` pages,
190
+ * default 20) without it: deleted, a thread reply, or not in this
191
+ * conversation.
192
+ */
193
+ loadUntil: (messageId: Uuid, maxPages?: number) => Promise<boolean>;
177
194
  /**
178
195
  * Advance the caller's read cursor to `messageId`. Server emits
179
- * read-receipt updates to other members; the conversation's
180
- * unread count drops to zero. No local state mutation — this is
181
- * "tell the server we read up to here".
196
+ * read-receipt updates to other members. Once it accepts, the
197
+ * conversation's unread and mention counts drop to zero in every
198
+ * `useConversations()` under the same provider (the server's
199
+ * `conversation:read` push then confirms the exact counts on all of
200
+ * the user's devices).
182
201
  */
183
202
  markReadUpTo: (messageId: Uuid) => Promise<void>;
184
203
  /**
@@ -485,9 +504,24 @@ interface UseUserState {
485
504
  *
486
505
  * Pass `null` / empty string to opt out (the hook becomes a no-op).
487
506
  * Useful for self bubbles (you already know who you are).
507
+ *
508
+ * After `chat.users.invalidate(externalId)` (or a `member:updated` app
509
+ * event) the hook re-resolves the user, showing the old profile until
510
+ * the new one lands.
488
511
  */
489
512
  declare function useUser(externalId: string | null | undefined): UseUserState;
490
513
 
514
+ /**
515
+ * Run `handler` for every app-defined event sent to the signed-in user
516
+ * (`app:event`: `{ type, data }`) — e.g. the Workspace API's
517
+ * `member:updated` or `workspace:updated`. A thin wrapper over
518
+ * `chat.onAppEvent`; the handler may change between renders.
519
+ *
520
+ * Profiles named by `member:updated` are refreshed for you; this is
521
+ * for anything else your app wants to do.
522
+ */
523
+ declare function useAppEvent(handler: (evt: AppEvent) => void): void;
524
+
491
525
  /**
492
526
  * Where this message sits inside a same-sender, same-day, in-window
493
527
  * cluster. Drives the bubble's corner treatment + the row's
@@ -732,4 +766,4 @@ declare function canEditOwnMessage(args: {
732
766
  now?: number;
733
767
  }): boolean;
734
768
 
735
- export { EDIT_WINDOW_MS, type GroupPosition, type MessageStream, PoolseProvider, type PoolseProviderProps, type ReactionMap, type UploadItem, type UploadItemStatus, type UseCallRoom, type UseCallRoomOptions, type UseLiveCall, type UseReadReceipts, type UseRoom, type UseRoomOptions, type UseUserState, canEditOwnMessage, computeGroupPosition, formatDayLabel, receiptsOf, sameDay, sameGroup, useAttachmentUpload, useAttachmentUrl, useCallRoom, useConversation, useConversations, useLiveCall, useMe, useMembers, useMessageStreams, useMessages, usePoolse, usePresence, useReactions, useReadReceipts, useRealtimeStatus, useRoom, useThread, useTyping, useUser };
769
+ export { EDIT_WINDOW_MS, type GroupPosition, type MessageStream, PoolseProvider, type PoolseProviderProps, type ReactionMap, type UploadItem, type UploadItemStatus, type UseCallRoom, type UseCallRoomOptions, type UseLiveCall, type UseReadReceipts, type UseRoom, type UseRoomOptions, type UseUserState, canEditOwnMessage, computeGroupPosition, formatDayLabel, receiptsOf, sameDay, sameGroup, useAppEvent, useAttachmentUpload, useAttachmentUrl, useCallRoom, useConversation, useConversations, useLiveCall, useMe, useMembers, useMessageStreams, useMessages, usePoolse, usePresence, useReactions, useReadReceipts, useRealtimeStatus, useRoom, useThread, useTyping, useUser };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { PoolseConfig, Poolse, Me, Uuid, Conversation, ConversationCreateRequest, Membership, MemberRole, Message, MessageCreateRequest, RealtimeStatus, Attachment, AttachmentUploadInput, PoolseUserProfile, CallRoomStatus, CallParticipant, CameraFacing, CallDeviceKind, CallDevice, LiveKitModule, LiveCall } from '@poolse/sdk';
3
- export { ApiError, Attachment, AttachmentStatus, AttachmentUploadInput, AttachmentUploadRequest, AttachmentUploadResponse, AuthError, CallEndReason, CallLog, CallLogDisplay, CallLogEntry, CallLogMedia, CallMissedEntry, CallParticipantStatus, Conversation, ConversationCreateRequest, DeviceKind, LiveCall, LiveCallMember, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageType, NetworkError, PoolseConfig, PoolseError, PoolseUserProfile, RateLimitedError, ReadReceiptsState, RealtimeStatus, RoomSession, Uuid, callLogDisplayFor, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, parseCallLog, parseCallLogBody } from '@poolse/sdk';
2
+ import { PoolseConfig, Poolse, Me, Uuid, Conversation, ConversationCreateRequest, Membership, MemberRole, Message, MessageCreateRequest, RealtimeStatus, Attachment, AttachmentUploadInput, PoolseUserProfile, AppEvent, CallRoomStatus, CallParticipant, CameraFacing, CallDeviceKind, CallDevice, LiveKitModule, LiveCall } from '@poolse/sdk';
3
+ export { ApiError, AppEvent, Attachment, AttachmentStatus, AttachmentUploadInput, AttachmentUploadRequest, AttachmentUploadResponse, AuthError, CallEndReason, CallLog, CallLogDisplay, CallLogEntry, CallLogMedia, CallMissedEntry, CallParticipantStatus, Conversation, ConversationCreateRequest, ConversationReadEvent, DeviceKind, LiveCall, LiveCallMember, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageType, NetworkError, NotificationPreferences, NotifyLevel, OwnMembership, OwnMembershipUpdateRequest, PoolseConfig, PoolseError, PoolseUserProfile, RateLimitedError, ReadReceiptsState, RealtimeStatus, RoomSession, Uuid, callLogDisplayFor, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, parseCallLog, parseCallLogBody } from '@poolse/sdk';
4
4
  import { ReactNode } from 'react';
5
5
 
6
6
  interface PoolseProviderProps {
@@ -89,29 +89,38 @@ interface UseConversationsState {
89
89
  refetch: () => Promise<void>;
90
90
  create: (attrs: ConversationCreateRequest) => Promise<Conversation>;
91
91
  /**
92
- * Per-conversation unread count, keyed by conversation id. Sourced
93
- * from `Conversation.unread_count` on the initial fetch and kept
94
- * fresh as the caller marks conversations read (via `markRead`).
95
- *
96
- * Note: cross-conversation incrementing on a new inbound message
97
- * requires subscribing to every conversation channel, which the SDK
98
- * doesn't do by default. Counts in this map are accurate for the
99
- * conversation the caller has open + correct at fetch time for the
100
- * rest; refetch on a fresh tab focus for true reconciliation.
92
+ * Per-conversation unread count, keyed by conversation id (only
93
+ * conversations with unread messages appear). Sourced from
94
+ * `Conversation.unread_count` and kept fresh by realtime
95
+ * (`conversation:updated`, and `conversation:read` when the user
96
+ * reads on any of their devices) and by `markReadUpTo` /
97
+ * `markConversationRead` anywhere under the same provider.
101
98
  */
102
99
  unreadCounts: Record<Uuid, number>;
103
- /** Force a conversation's unread to 0 — invoked by `markReadUpTo`. */
100
+ /** Like `unreadCounts`, for unread messages that mention the user. */
101
+ mentionUnreadCounts: Record<Uuid, number>;
102
+ /**
103
+ * Force a conversation's unread and mention counts to 0 in every
104
+ * view. `useMessages().markReadUpTo` does this for you once the
105
+ * server accepts it.
106
+ */
104
107
  markConversationRead: (conversationId: Uuid) => void;
105
108
  }
106
109
  /**
107
110
  * List of conversations the current End User can see.
108
111
  *
109
- * On mount: REST-fetches the list and subscribes to the user's
110
- * `user:<id>` channel for `conversation:created` events — fired by
111
- * the server both when this user creates a conversation AND when
112
- * someone else adds them to one. New rows are prepended to local
113
- * state with id-based dedup so an optimistic `create()` followed by
114
- * the realtime echo doesn't insert twice.
112
+ * Every `useConversations()` under one `<PoolseProvider>` shares one
113
+ * list: a sidebar and an inbox header show the same rows and the same
114
+ * badges, and reading a conversation anywhere clears its badge
115
+ * everywhere.
116
+ *
117
+ * The first one mounted REST-fetches the list and subscribes to the
118
+ * user's `user:<id>` channel for `conversation:created` (this user
119
+ * created a conversation or was added to one), `conversation:updated`
120
+ * (a message was sent) and `conversation:read` (this user read it on
121
+ * some device). New rows are prepended with id-based dedup so an
122
+ * optimistic `create()` followed by the realtime echo doesn't insert
123
+ * twice.
115
124
  *
116
125
  * `refetch()` is still here for explicit re-syncs (e.g. after a
117
126
  * mutation that the SDK doesn't yet observe — name changes,
@@ -174,11 +183,21 @@ interface UseMessagesState {
174
183
  * body) locally, rolls back on error.
175
184
  */
176
185
  delete: (messageId: Uuid) => Promise<void>;
186
+ /**
187
+ * Load older pages until `messageId` is in `messages` — to jump to a
188
+ * message further back than what's loaded. Resolves `true` once it's
189
+ * there, `false` when history runs out (or after `maxPages` pages,
190
+ * default 20) without it: deleted, a thread reply, or not in this
191
+ * conversation.
192
+ */
193
+ loadUntil: (messageId: Uuid, maxPages?: number) => Promise<boolean>;
177
194
  /**
178
195
  * Advance the caller's read cursor to `messageId`. Server emits
179
- * read-receipt updates to other members; the conversation's
180
- * unread count drops to zero. No local state mutation — this is
181
- * "tell the server we read up to here".
196
+ * read-receipt updates to other members. Once it accepts, the
197
+ * conversation's unread and mention counts drop to zero in every
198
+ * `useConversations()` under the same provider (the server's
199
+ * `conversation:read` push then confirms the exact counts on all of
200
+ * the user's devices).
182
201
  */
183
202
  markReadUpTo: (messageId: Uuid) => Promise<void>;
184
203
  /**
@@ -485,9 +504,24 @@ interface UseUserState {
485
504
  *
486
505
  * Pass `null` / empty string to opt out (the hook becomes a no-op).
487
506
  * Useful for self bubbles (you already know who you are).
507
+ *
508
+ * After `chat.users.invalidate(externalId)` (or a `member:updated` app
509
+ * event) the hook re-resolves the user, showing the old profile until
510
+ * the new one lands.
488
511
  */
489
512
  declare function useUser(externalId: string | null | undefined): UseUserState;
490
513
 
514
+ /**
515
+ * Run `handler` for every app-defined event sent to the signed-in user
516
+ * (`app:event`: `{ type, data }`) — e.g. the Workspace API's
517
+ * `member:updated` or `workspace:updated`. A thin wrapper over
518
+ * `chat.onAppEvent`; the handler may change between renders.
519
+ *
520
+ * Profiles named by `member:updated` are refreshed for you; this is
521
+ * for anything else your app wants to do.
522
+ */
523
+ declare function useAppEvent(handler: (evt: AppEvent) => void): void;
524
+
491
525
  /**
492
526
  * Where this message sits inside a same-sender, same-day, in-window
493
527
  * cluster. Drives the bubble's corner treatment + the row's
@@ -732,4 +766,4 @@ declare function canEditOwnMessage(args: {
732
766
  now?: number;
733
767
  }): boolean;
734
768
 
735
- export { EDIT_WINDOW_MS, type GroupPosition, type MessageStream, PoolseProvider, type PoolseProviderProps, type ReactionMap, type UploadItem, type UploadItemStatus, type UseCallRoom, type UseCallRoomOptions, type UseLiveCall, type UseReadReceipts, type UseRoom, type UseRoomOptions, type UseUserState, canEditOwnMessage, computeGroupPosition, formatDayLabel, receiptsOf, sameDay, sameGroup, useAttachmentUpload, useAttachmentUrl, useCallRoom, useConversation, useConversations, useLiveCall, useMe, useMembers, useMessageStreams, useMessages, usePoolse, usePresence, useReactions, useReadReceipts, useRealtimeStatus, useRoom, useThread, useTyping, useUser };
769
+ export { EDIT_WINDOW_MS, type GroupPosition, type MessageStream, PoolseProvider, type PoolseProviderProps, type ReactionMap, type UploadItem, type UploadItemStatus, type UseCallRoom, type UseCallRoomOptions, type UseLiveCall, type UseReadReceipts, type UseRoom, type UseRoomOptions, type UseUserState, canEditOwnMessage, computeGroupPosition, formatDayLabel, receiptsOf, sameDay, sameGroup, useAppEvent, useAttachmentUpload, useAttachmentUrl, useCallRoom, useConversation, useConversations, useLiveCall, useMe, useMembers, useMessageStreams, useMessages, usePoolse, usePresence, useReactions, useReadReceipts, useRealtimeStatus, useRoom, useThread, useTyping, useUser };