@poolse/react 2.25.0 → 2.26.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, VoiceStatus, VoiceParticipant, VoiceRoomOptions, IncomingCall, OutgoingCall, CallMedia } from '@poolse/sdk';
3
- export { ApiError, Attachment, AttachmentStatus, AttachmentUploadInput, AttachmentUploadRequest, AttachmentUploadResponse, AuthError, CallLog, CallLogDisplay, CallLogEntry, CallLogMedia, CallMissedEntry, Conversation, ConversationCreateRequest, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageType, NetworkError, PoolseConfig, PoolseError, PoolseUserProfile, RateLimitedError, RealtimeStatus, 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, CallRoomStatus, CallParticipant, CameraFacing, CallDeviceKind, CallDevice, LiveKitModule, VoiceStatus, VoiceParticipant, VoiceRoomOptions, IncomingCall, OutgoingCall, CallMedia, 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, RealtimeStatus, Uuid, callLogDisplayFor, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, parseCallLog, parseCallLogBody } from '@poolse/sdk';
4
4
  import { ReactNode } from 'react';
5
5
 
6
6
  interface PoolseProviderProps {
@@ -766,4 +766,21 @@ interface UseCalls {
766
766
  */
767
767
  declare function useCalls(userId: string | null, opts?: UseCallsOptions): UseCalls;
768
768
 
769
- export { type CallPhase, type GroupPosition, PoolseProvider, type PoolseProviderProps, type ReactionMap, type UploadItem, type UploadItemStatus, type UseCallRoom, type UseCallRoomOptions, type UseCalls, type UseUserState, type UseVoiceRoom, computeGroupPosition, formatDayLabel, sameDay, sameGroup, useAttachmentUpload, useAttachmentUrl, useCallRoom, useCalls, useConversation, useConversations, useMe, useMembers, useMessages, usePoolse, usePresence, useReactions, useRealtimeStatus, useThread, useTyping, useUser, useVoiceRoom };
769
+ interface UseLiveCall {
770
+ /** The call running on the conversation right now, or null. */
771
+ call: LiveCall | null;
772
+ /** User ids in the call's room at this moment (kept live by `call:participants`). */
773
+ participantIds: string[];
774
+ /** Re-read from the server. */
775
+ refresh: () => void;
776
+ }
777
+ /**
778
+ * Whether a call is running on `conversationId` — what a "Call in
779
+ * progress · Join" banner needs. Reads once on mount (and after every
780
+ * reconnect, since events sent while the socket was down are gone),
781
+ * then follows the conversation's `call:started`, `call:participants`
782
+ * and `call:finished` events. `null` id → always idle.
783
+ */
784
+ declare function useLiveCall(conversationId: string | null): UseLiveCall;
785
+
786
+ export { type CallPhase, type GroupPosition, PoolseProvider, type PoolseProviderProps, type ReactionMap, type UploadItem, type UploadItemStatus, type UseCallRoom, type UseCallRoomOptions, type UseCalls, type UseLiveCall, type UseUserState, type UseVoiceRoom, computeGroupPosition, formatDayLabel, sameDay, sameGroup, useAttachmentUpload, useAttachmentUrl, useCallRoom, useCalls, useConversation, useConversations, useLiveCall, useMe, useMembers, useMessages, usePoolse, usePresence, useReactions, useRealtimeStatus, useThread, useTyping, useUser, useVoiceRoom };
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, VoiceStatus, VoiceParticipant, VoiceRoomOptions, IncomingCall, OutgoingCall, CallMedia } from '@poolse/sdk';
3
- export { ApiError, Attachment, AttachmentStatus, AttachmentUploadInput, AttachmentUploadRequest, AttachmentUploadResponse, AuthError, CallLog, CallLogDisplay, CallLogEntry, CallLogMedia, CallMissedEntry, Conversation, ConversationCreateRequest, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageType, NetworkError, PoolseConfig, PoolseError, PoolseUserProfile, RateLimitedError, RealtimeStatus, 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, CallRoomStatus, CallParticipant, CameraFacing, CallDeviceKind, CallDevice, LiveKitModule, VoiceStatus, VoiceParticipant, VoiceRoomOptions, IncomingCall, OutgoingCall, CallMedia, 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, RealtimeStatus, Uuid, callLogDisplayFor, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, parseCallLog, parseCallLogBody } from '@poolse/sdk';
4
4
  import { ReactNode } from 'react';
5
5
 
6
6
  interface PoolseProviderProps {
@@ -766,4 +766,21 @@ interface UseCalls {
766
766
  */
767
767
  declare function useCalls(userId: string | null, opts?: UseCallsOptions): UseCalls;
768
768
 
769
- export { type CallPhase, type GroupPosition, PoolseProvider, type PoolseProviderProps, type ReactionMap, type UploadItem, type UploadItemStatus, type UseCallRoom, type UseCallRoomOptions, type UseCalls, type UseUserState, type UseVoiceRoom, computeGroupPosition, formatDayLabel, sameDay, sameGroup, useAttachmentUpload, useAttachmentUrl, useCallRoom, useCalls, useConversation, useConversations, useMe, useMembers, useMessages, usePoolse, usePresence, useReactions, useRealtimeStatus, useThread, useTyping, useUser, useVoiceRoom };
769
+ interface UseLiveCall {
770
+ /** The call running on the conversation right now, or null. */
771
+ call: LiveCall | null;
772
+ /** User ids in the call's room at this moment (kept live by `call:participants`). */
773
+ participantIds: string[];
774
+ /** Re-read from the server. */
775
+ refresh: () => void;
776
+ }
777
+ /**
778
+ * Whether a call is running on `conversationId` — what a "Call in
779
+ * progress · Join" banner needs. Reads once on mount (and after every
780
+ * reconnect, since events sent while the socket was down are gone),
781
+ * then follows the conversation's `call:started`, `call:participants`
782
+ * and `call:finished` events. `null` id → always idle.
783
+ */
784
+ declare function useLiveCall(conversationId: string | null): UseLiveCall;
785
+
786
+ export { type CallPhase, type GroupPosition, PoolseProvider, type PoolseProviderProps, type ReactionMap, type UploadItem, type UploadItemStatus, type UseCallRoom, type UseCallRoomOptions, type UseCalls, type UseLiveCall, type UseUserState, type UseVoiceRoom, computeGroupPosition, formatDayLabel, sameDay, sameGroup, useAttachmentUpload, useAttachmentUrl, useCallRoom, useCalls, useConversation, useConversations, useLiveCall, useMe, useMembers, useMessages, usePoolse, usePresence, useReactions, useRealtimeStatus, useThread, useTyping, useUser, useVoiceRoom };
package/dist/index.js CHANGED
@@ -1612,7 +1612,58 @@ function useCalls(userId, opts = {}) {
1612
1612
  reset
1613
1613
  };
1614
1614
  }
1615
+ function useLiveCall(conversationId) {
1616
+ const chat = usePoolse();
1617
+ const [call, setCall] = useState(null);
1618
+ const [participantIds, setParticipantIds] = useState([]);
1619
+ const callIdRef = useRef(null);
1620
+ const seq = useRef(0);
1621
+ const apply = useCallback((next) => {
1622
+ callIdRef.current = next?.id ?? null;
1623
+ setCall(next);
1624
+ setParticipantIds(next ? next.participants.map((p) => p.user_id) : []);
1625
+ }, []);
1626
+ const refresh = useCallback(() => {
1627
+ if (!conversationId) return;
1628
+ const mine = ++seq.current;
1629
+ chat.liveCalls.get(conversationId).then((c) => {
1630
+ if (mine === seq.current) apply(c);
1631
+ }).catch(() => {
1632
+ });
1633
+ }, [chat, conversationId, apply]);
1634
+ useEffect(() => {
1635
+ apply(null);
1636
+ if (!conversationId) return;
1637
+ refresh();
1638
+ const conv = chat.realtime.conversation(conversationId);
1639
+ const offStarted = conv.onCallStarted((evt) => {
1640
+ seq.current++;
1641
+ apply(evt.call);
1642
+ });
1643
+ const offParticipants = conv.onCallParticipants((evt) => {
1644
+ if (evt.call_id === callIdRef.current) setParticipantIds(evt.participants);
1645
+ else refresh();
1646
+ });
1647
+ const offFinished = conv.onCallFinished((evt) => {
1648
+ if (evt.call_id !== callIdRef.current) return;
1649
+ seq.current++;
1650
+ apply(null);
1651
+ });
1652
+ let wasConnected = chat.realtime.getStatus() === "connected";
1653
+ const offStatus = chat.realtime.onStatus((status) => {
1654
+ if (status === "connected" && !wasConnected) refresh();
1655
+ wasConnected = status === "connected";
1656
+ });
1657
+ return () => {
1658
+ offStarted();
1659
+ offParticipants();
1660
+ offFinished();
1661
+ offStatus();
1662
+ };
1663
+ }, [chat, conversationId, apply, refresh]);
1664
+ return { call, participantIds, refresh };
1665
+ }
1615
1666
 
1616
- export { PoolseProvider, computeGroupPosition, formatDayLabel, sameDay, sameGroup, useAttachmentUpload, useAttachmentUrl, useCallRoom, useCalls, useConversation, useConversations, useMe, useMembers, useMessages, usePoolse, usePresence, useReactions, useRealtimeStatus, useThread, useTyping, useUser, useVoiceRoom };
1667
+ export { PoolseProvider, computeGroupPosition, formatDayLabel, sameDay, sameGroup, useAttachmentUpload, useAttachmentUrl, useCallRoom, useCalls, useConversation, useConversations, useLiveCall, useMe, useMembers, useMessages, usePoolse, usePresence, useReactions, useRealtimeStatus, useThread, useTyping, useUser, useVoiceRoom };
1617
1668
  //# sourceMappingURL=index.js.map
1618
1669
  //# sourceMappingURL=index.js.map