@poolse/react 2.24.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.cjs +85 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -3
- package/dist/index.d.ts +20 -3
- package/dist/index.js +55 -5
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
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, Conversation, ConversationCreateRequest, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageType, NetworkError, PoolseConfig, PoolseError, PoolseUserProfile, RateLimitedError, RealtimeStatus, Uuid } 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
|
-
|
|
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, Conversation, ConversationCreateRequest, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageType, NetworkError, PoolseConfig, PoolseError, PoolseUserProfile, RateLimitedError, RealtimeStatus, Uuid } 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
|
-
|
|
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { Poolse, safeUuid } from '@poolse/sdk';
|
|
3
|
-
export { ApiError, AuthError, NetworkError, PoolseError, RateLimitedError } from '@poolse/sdk';
|
|
2
|
+
import { Poolse, safeUuid, isCallLogMessage } from '@poolse/sdk';
|
|
3
|
+
export { ApiError, AuthError, NetworkError, PoolseError, RateLimitedError, callLogDisplayFor, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, parseCallLog, parseCallLogBody } from '@poolse/sdk';
|
|
4
4
|
import { createContext, useRef, useMemo, useEffect, useContext, useState, useCallback } from 'react';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
|
|
@@ -1025,8 +1025,6 @@ function useUser(externalId) {
|
|
|
1025
1025
|
}, [chat, externalId]);
|
|
1026
1026
|
return state;
|
|
1027
1027
|
}
|
|
1028
|
-
|
|
1029
|
-
// src/grouping.ts
|
|
1030
1028
|
function computeGroupPosition(msg, prev, next, windowMs) {
|
|
1031
1029
|
const continuesPrev = sameGroup(msg, prev, windowMs);
|
|
1032
1030
|
const continuesNext = sameGroup(next, msg, windowMs);
|
|
@@ -1037,6 +1035,7 @@ function computeGroupPosition(msg, prev, next, windowMs) {
|
|
|
1037
1035
|
}
|
|
1038
1036
|
function sameGroup(a, b, windowMs) {
|
|
1039
1037
|
if (!a || !b) return false;
|
|
1038
|
+
if (isCallLogMessage(a) || isCallLogMessage(b)) return false;
|
|
1040
1039
|
if (a.sender_id !== b.sender_id) return false;
|
|
1041
1040
|
if (!sameDay(a.inserted_at, b.inserted_at)) return false;
|
|
1042
1041
|
const ta = new Date(a.inserted_at).getTime();
|
|
@@ -1613,7 +1612,58 @@ function useCalls(userId, opts = {}) {
|
|
|
1613
1612
|
reset
|
|
1614
1613
|
};
|
|
1615
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
|
+
}
|
|
1616
1666
|
|
|
1617
|
-
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 };
|
|
1618
1668
|
//# sourceMappingURL=index.js.map
|
|
1619
1669
|
//# sourceMappingURL=index.js.map
|