@poolse/sdk 2.8.4 → 2.10.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 +333 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +352 -30
- package/dist/index.d.ts +352 -30
- package/dist/index.js +331 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -526,6 +526,20 @@ interface VoiceRoomOptions {
|
|
|
526
526
|
* TURN server for participants behind symmetric NAT.
|
|
527
527
|
*/
|
|
528
528
|
iceServers?: VoiceIceServer[];
|
|
529
|
+
/**
|
|
530
|
+
* Resolve ICE servers just before connecting, overriding `iceServers`.
|
|
531
|
+
*
|
|
532
|
+
* TURN credentials expire, so they cannot be handed over once at
|
|
533
|
+
* construction and reused for the life of the app — by the second call
|
|
534
|
+
* they would be rejected. `PoolseRealtime` supplies a provider backed
|
|
535
|
+
* by `GET /v1/ice-servers`, which is what makes TURN work without any
|
|
536
|
+
* app wiring.
|
|
537
|
+
*
|
|
538
|
+
* Failures are non-fatal: the room falls back to `iceServers` (or the
|
|
539
|
+
* default STUN) rather than refusing to connect. Degraded beats dead —
|
|
540
|
+
* without TURN a call still works on most networks.
|
|
541
|
+
*/
|
|
542
|
+
iceServersProvider?: () => Promise<VoiceIceServer[]>;
|
|
529
543
|
/** Platform WebRTC binding. Defaults to the browser implementation. */
|
|
530
544
|
webrtc?: WebRtcAdapter;
|
|
531
545
|
/**
|
|
@@ -534,11 +548,23 @@ interface VoiceRoomOptions {
|
|
|
534
548
|
*/
|
|
535
549
|
detectSpeaking?: boolean;
|
|
536
550
|
}
|
|
551
|
+
/**
|
|
552
|
+
* What a call carries.
|
|
553
|
+
*
|
|
554
|
+
* Fixed when the call is placed, and travelling with the ring rather
|
|
555
|
+
* than the connection: CallKit shows a different answer button for a
|
|
556
|
+
* video call and cannot be changed once the call is reported. Either
|
|
557
|
+
* side can still turn their camera on or off mid-call — this is what
|
|
558
|
+
* the call *opens* as.
|
|
559
|
+
*/
|
|
560
|
+
type CallMedia = 'audio' | 'video';
|
|
537
561
|
/** An inbound ring, delivered on the user's own channel. */
|
|
538
562
|
interface IncomingCall {
|
|
539
563
|
callId: string;
|
|
540
564
|
conversationId: string;
|
|
541
565
|
callerUserId: string;
|
|
566
|
+
/** Defaults to `'audio'` against a server that predates the field. */
|
|
567
|
+
media: CallMedia;
|
|
542
568
|
}
|
|
543
569
|
/** The far side answered; both parties should now join the room. */
|
|
544
570
|
interface CallAccepted {
|
|
@@ -579,6 +605,7 @@ interface OutgoingCall {
|
|
|
579
605
|
conversationId: string;
|
|
580
606
|
/** Everyone who was rung — the conversation's members, minus you. */
|
|
581
607
|
calleeUserIds: string[];
|
|
608
|
+
media: CallMedia;
|
|
582
609
|
}
|
|
583
610
|
|
|
584
611
|
/**
|
|
@@ -603,7 +630,7 @@ interface OutgoingCall {
|
|
|
603
630
|
* gave up, and it can call {@link cancel} at that point.
|
|
604
631
|
*/
|
|
605
632
|
|
|
606
|
-
type Unsubscribe$
|
|
633
|
+
type Unsubscribe$3 = () => void;
|
|
607
634
|
declare class CallsResource {
|
|
608
635
|
/** Resolves the user channel lazily — it may not be joined yet. */
|
|
609
636
|
private readonly getChannel;
|
|
@@ -620,7 +647,7 @@ declare class CallsResource {
|
|
|
620
647
|
* has fanned the invite out, with the minted call id and who was rung
|
|
621
648
|
* — not when anyone answers; that arrives via {@link onAccepted}.
|
|
622
649
|
*/
|
|
623
|
-
invite(conversationId: string): Promise<OutgoingCall>;
|
|
650
|
+
invite(conversationId: string, media?: CallMedia): Promise<OutgoingCall>;
|
|
624
651
|
/**
|
|
625
652
|
* Answer a ringing call. This only tells the caller you picked up —
|
|
626
653
|
* join the voice room yourself to actually connect audio.
|
|
@@ -651,17 +678,17 @@ declare class CallsResource {
|
|
|
651
678
|
/** Withdraw an invite you placed — hung up before anyone answered. */
|
|
652
679
|
cancel(call: OutgoingCall): Promise<void>;
|
|
653
680
|
/** Somebody is ringing you. */
|
|
654
|
-
onIncoming(fn: (call: IncomingCall) => void): Unsubscribe$
|
|
681
|
+
onIncoming(fn: (call: IncomingCall) => void): Unsubscribe$3;
|
|
655
682
|
/** Your outbound call was answered — join the room now. */
|
|
656
|
-
onAccepted(fn: (call: CallAccepted) => void): Unsubscribe$
|
|
683
|
+
onAccepted(fn: (call: CallAccepted) => void): Unsubscribe$3;
|
|
657
684
|
/** Your outbound call was rejected. */
|
|
658
|
-
onDeclined(fn: (call: CallDeclined) => void): Unsubscribe$
|
|
685
|
+
onDeclined(fn: (call: CallDeclined) => void): Unsubscribe$3;
|
|
659
686
|
/** The person you called is already on another call. */
|
|
660
|
-
onBusy(fn: (call: CallBusy) => void): Unsubscribe$
|
|
687
|
+
onBusy(fn: (call: CallBusy) => void): Unsubscribe$3;
|
|
661
688
|
/** The other side ended a connected call. */
|
|
662
|
-
onEnded(fn: (call: CallEnded) => void): Unsubscribe$
|
|
689
|
+
onEnded(fn: (call: CallEnded) => void): Unsubscribe$3;
|
|
663
690
|
/** An inbound ring was withdrawn before you answered. */
|
|
664
|
-
onCancelled(fn: (call: CallCancelled) => void): Unsubscribe$
|
|
691
|
+
onCancelled(fn: (call: CallCancelled) => void): Unsubscribe$3;
|
|
665
692
|
/**
|
|
666
693
|
* One Phoenix binding per event regardless of listener count; we fan
|
|
667
694
|
* out ourselves, matching how the conversation channels do it.
|
|
@@ -689,12 +716,13 @@ declare class CallsResource {
|
|
|
689
716
|
* SFU belongs.
|
|
690
717
|
*/
|
|
691
718
|
|
|
692
|
-
type Unsubscribe$
|
|
719
|
+
type Unsubscribe$2 = () => void;
|
|
693
720
|
declare class VoiceRoom {
|
|
694
721
|
readonly conversationId: string;
|
|
695
722
|
private readonly socket;
|
|
696
723
|
private readonly webrtc;
|
|
697
|
-
private
|
|
724
|
+
private iceServers;
|
|
725
|
+
private readonly iceServersProvider;
|
|
698
726
|
private readonly detectSpeaking;
|
|
699
727
|
private channel;
|
|
700
728
|
private localStream;
|
|
@@ -726,9 +754,9 @@ declare class VoiceRoom {
|
|
|
726
754
|
isMuted(): boolean;
|
|
727
755
|
/** Everyone in the room, oldest join first. */
|
|
728
756
|
getParticipants(): VoiceParticipant[];
|
|
729
|
-
onStatus(fn: (status: VoiceStatus) => void): Unsubscribe$
|
|
730
|
-
onParticipants(fn: (participants: VoiceParticipant[]) => void): Unsubscribe$
|
|
731
|
-
onError(fn: (err: Error) => void): Unsubscribe$
|
|
757
|
+
onStatus(fn: (status: VoiceStatus) => void): Unsubscribe$2;
|
|
758
|
+
onParticipants(fn: (participants: VoiceParticipant[]) => void): Unsubscribe$2;
|
|
759
|
+
onError(fn: (err: Error) => void): Unsubscribe$2;
|
|
732
760
|
/** Acquire the mic, join the channel, and start negotiating. */
|
|
733
761
|
join(): Promise<void>;
|
|
734
762
|
/** Announce departure, then drop every peer connection and the mic. */
|
|
@@ -737,6 +765,15 @@ declare class VoiceRoom {
|
|
|
737
765
|
setMuted(muted: boolean): boolean;
|
|
738
766
|
toggleMute(): boolean;
|
|
739
767
|
private bindChannel;
|
|
768
|
+
/**
|
|
769
|
+
* Refresh ICE servers from the provider, if there is one.
|
|
770
|
+
*
|
|
771
|
+
* Never throws. A room that refused to connect because the ICE
|
|
772
|
+
* endpoint was briefly unreachable would be a worse outcome than one
|
|
773
|
+
* that connects without TURN — which is exactly how calls behaved
|
|
774
|
+
* before TURN existed, and works on most networks.
|
|
775
|
+
*/
|
|
776
|
+
private resolveIceServers;
|
|
740
777
|
/**
|
|
741
778
|
* Glare control: both sides learn about each other simultaneously, so
|
|
742
779
|
* without a rule both would offer at once. The lexicographically lower
|
|
@@ -868,7 +905,7 @@ type PresenceSnapshot = Record<Uuid, {
|
|
|
868
905
|
*/
|
|
869
906
|
type RealtimeStatus = 'idle' | 'connecting' | 'connected' | 'reconnecting' | 'closed';
|
|
870
907
|
/** Unsubscribe handle returned by `onX` listener registrations. */
|
|
871
|
-
type Unsubscribe = () => void;
|
|
908
|
+
type Unsubscribe$1 = () => void;
|
|
872
909
|
|
|
873
910
|
interface RealtimeOptions {
|
|
874
911
|
/**
|
|
@@ -884,11 +921,18 @@ interface RealtimeOptions {
|
|
|
884
921
|
* swapping http(s) → ws(s).
|
|
885
922
|
*/
|
|
886
923
|
wsUrl?: string;
|
|
924
|
+
/**
|
|
925
|
+
* Resolves ICE servers for voice rooms. Wired by `Poolse` to
|
|
926
|
+
* `GET /v1/ice-servers` so TURN reaches every room without the app
|
|
927
|
+
* plumbing anything.
|
|
928
|
+
*/
|
|
929
|
+
iceServersProvider?: () => Promise<VoiceIceServer[]>;
|
|
887
930
|
}
|
|
888
931
|
declare class PoolseRealtime {
|
|
889
932
|
private readonly config;
|
|
890
933
|
private readonly tokenCache;
|
|
891
934
|
private readonly socketPath;
|
|
935
|
+
private readonly iceServersProvider;
|
|
892
936
|
private readonly wsUrl;
|
|
893
937
|
private socket;
|
|
894
938
|
private readonly conversations;
|
|
@@ -901,7 +945,7 @@ declare class PoolseRealtime {
|
|
|
901
945
|
/** Current connection status. */
|
|
902
946
|
getStatus(): RealtimeStatus;
|
|
903
947
|
/** Subscribe to connection-status changes. */
|
|
904
|
-
onStatus(listener: (status: RealtimeStatus) => void): Unsubscribe;
|
|
948
|
+
onStatus(listener: (status: RealtimeStatus) => void): Unsubscribe$1;
|
|
905
949
|
/**
|
|
906
950
|
* Open the socket (idempotent). Synchronous construction so callers
|
|
907
951
|
* can join a channel on the next line; the underlying WebSocket
|
|
@@ -972,22 +1016,22 @@ declare class ConversationChannel {
|
|
|
972
1016
|
private presenceStateSeen;
|
|
973
1017
|
constructor(conversationId: string, channel: Channel);
|
|
974
1018
|
/** New message pushed to the conversation. */
|
|
975
|
-
onMessage(fn: (msg: MessageNewEvent) => void): Unsubscribe;
|
|
1019
|
+
onMessage(fn: (msg: MessageNewEvent) => void): Unsubscribe$1;
|
|
976
1020
|
/** Existing message edited by its sender. */
|
|
977
|
-
onMessageUpdated(fn: (msg: MessageUpdatedEvent) => void): Unsubscribe;
|
|
1021
|
+
onMessageUpdated(fn: (msg: MessageUpdatedEvent) => void): Unsubscribe$1;
|
|
978
1022
|
/** Tombstone for a soft-deleted message. */
|
|
979
|
-
onMessageDeleted(fn: (evt: MessageDeletedEvent) => void): Unsubscribe;
|
|
980
|
-
onTypingStart(fn: (evt: TypingEvent) => void): Unsubscribe;
|
|
981
|
-
onTypingStop(fn: (evt: TypingEvent) => void): Unsubscribe;
|
|
982
|
-
onReactionAdded(fn: (evt: ReactionEvent) => void): Unsubscribe;
|
|
983
|
-
onReactionRemoved(fn: (evt: ReactionEvent) => void): Unsubscribe;
|
|
1023
|
+
onMessageDeleted(fn: (evt: MessageDeletedEvent) => void): Unsubscribe$1;
|
|
1024
|
+
onTypingStart(fn: (evt: TypingEvent) => void): Unsubscribe$1;
|
|
1025
|
+
onTypingStop(fn: (evt: TypingEvent) => void): Unsubscribe$1;
|
|
1026
|
+
onReactionAdded(fn: (evt: ReactionEvent) => void): Unsubscribe$1;
|
|
1027
|
+
onReactionRemoved(fn: (evt: ReactionEvent) => void): Unsubscribe$1;
|
|
984
1028
|
/**
|
|
985
1029
|
* A conversation member advanced their read cursor. Used to flip the
|
|
986
1030
|
* sender's read-receipt glyph from "sent" to "read" in real time.
|
|
987
1031
|
*/
|
|
988
|
-
onMemberRead(fn: (evt: MemberReadEvent) => void): Unsubscribe;
|
|
989
|
-
onPresenceState(fn: (state: PresenceSnapshot) => void): Unsubscribe;
|
|
990
|
-
onPresenceDiff(fn: (diff: PresenceSnapshot) => void): Unsubscribe;
|
|
1032
|
+
onMemberRead(fn: (evt: MemberReadEvent) => void): Unsubscribe$1;
|
|
1033
|
+
onPresenceState(fn: (state: PresenceSnapshot) => void): Unsubscribe$1;
|
|
1034
|
+
onPresenceDiff(fn: (diff: PresenceSnapshot) => void): Unsubscribe$1;
|
|
991
1035
|
/** Current presence snapshot for sync access — usually used in tests. */
|
|
992
1036
|
getPresenceState(): PresenceSnapshot;
|
|
993
1037
|
/** Send a typing ping to the server. Debounced server-side. */
|
|
@@ -1015,7 +1059,7 @@ declare class UserChannel {
|
|
|
1015
1059
|
* @internal
|
|
1016
1060
|
*/
|
|
1017
1061
|
_channel(): Channel;
|
|
1018
|
-
onMention(fn: (evt: MentionEvent) => void): Unsubscribe;
|
|
1062
|
+
onMention(fn: (evt: MentionEvent) => void): Unsubscribe$1;
|
|
1019
1063
|
/**
|
|
1020
1064
|
* Subscribe to "you've been added to a conversation" notifications.
|
|
1021
1065
|
* Fires once per new membership — either because you created the
|
|
@@ -1024,7 +1068,7 @@ declare class UserChannel {
|
|
|
1024
1068
|
* Payload is the full {@link Conversation} row so consumers can
|
|
1025
1069
|
* prepend it to a local list without a refetch.
|
|
1026
1070
|
*/
|
|
1027
|
-
onConversationCreated(fn: (conv: ConversationCreatedEvent) => void): Unsubscribe;
|
|
1071
|
+
onConversationCreated(fn: (conv: ConversationCreatedEvent) => void): Unsubscribe$1;
|
|
1028
1072
|
/**
|
|
1029
1073
|
* Subscribe to "an existing conversation changed" notifications —
|
|
1030
1074
|
* fires after every `send_message` in any conversation you're a
|
|
@@ -1035,7 +1079,7 @@ declare class UserChannel {
|
|
|
1035
1079
|
* to increment a local unread counter; the server already keeps
|
|
1036
1080
|
* your own outbound messages out of your unread count.
|
|
1037
1081
|
*/
|
|
1038
|
-
onConversationUpdated(fn: (evt: ConversationUpdatedEvent) => void): Unsubscribe;
|
|
1082
|
+
onConversationUpdated(fn: (evt: ConversationUpdatedEvent) => void): Unsubscribe$1;
|
|
1039
1083
|
/** @internal */
|
|
1040
1084
|
_join(): void;
|
|
1041
1085
|
/** @internal */
|
|
@@ -1391,6 +1435,264 @@ declare class UsersResource {
|
|
|
1391
1435
|
private notify;
|
|
1392
1436
|
}
|
|
1393
1437
|
|
|
1438
|
+
/**
|
|
1439
|
+
* Structural types for `livekit-client`.
|
|
1440
|
+
*
|
|
1441
|
+
* Declared here rather than imported for the same reason `WebRtcAdapter`
|
|
1442
|
+
* exists: the module is passed IN by the app. tsup rewrites a literal
|
|
1443
|
+
* `require()` into `__require()`, which Metro cannot follow, so a
|
|
1444
|
+
* dependency this package imports for itself is absent from every React
|
|
1445
|
+
* Native bundle — development builds included. That failure already cost
|
|
1446
|
+
* us a release once with `react-native-webrtc`.
|
|
1447
|
+
*
|
|
1448
|
+
* Declaring the shape structurally also keeps the two platforms honest:
|
|
1449
|
+
* web passes `livekit-client`, React Native passes the same package with
|
|
1450
|
+
* `@livekit/react-native`'s globals registered, and neither has to match
|
|
1451
|
+
* a nominal type this package owns.
|
|
1452
|
+
*
|
|
1453
|
+
* Deliberately narrow — only what {@link CallRoom} actually touches.
|
|
1454
|
+
*/
|
|
1455
|
+
/** A media track. Opaque here; the platform renderer consumes it. */
|
|
1456
|
+
type LiveKitTrack = object;
|
|
1457
|
+
interface LiveKitPublication {
|
|
1458
|
+
track?: LiveKitTrack | null | undefined;
|
|
1459
|
+
isMuted?: boolean;
|
|
1460
|
+
isSubscribed?: boolean;
|
|
1461
|
+
}
|
|
1462
|
+
interface LiveKitParticipant {
|
|
1463
|
+
/** The poolse user id — we mint tokens with `sub` set to it. */
|
|
1464
|
+
identity: string;
|
|
1465
|
+
name?: string | undefined;
|
|
1466
|
+
isMicrophoneEnabled?: boolean;
|
|
1467
|
+
isCameraEnabled?: boolean;
|
|
1468
|
+
isSpeaking?: boolean;
|
|
1469
|
+
getTrackPublication(source: string): LiveKitPublication | undefined;
|
|
1470
|
+
}
|
|
1471
|
+
interface LiveKitLocalParticipant extends LiveKitParticipant {
|
|
1472
|
+
setCameraEnabled(enabled: boolean): Promise<unknown>;
|
|
1473
|
+
setMicrophoneEnabled(enabled: boolean): Promise<unknown>;
|
|
1474
|
+
}
|
|
1475
|
+
interface LiveKitRoomHandle {
|
|
1476
|
+
localParticipant: LiveKitLocalParticipant;
|
|
1477
|
+
/** Keyed by identity. `remoteParticipants` is the v2 name. */
|
|
1478
|
+
remoteParticipants: Map<string, LiveKitParticipant>;
|
|
1479
|
+
connect(url: string, token: string, options?: unknown): Promise<void>;
|
|
1480
|
+
disconnect(): Promise<void>;
|
|
1481
|
+
on(event: string, handler: (...args: never[]) => void): unknown;
|
|
1482
|
+
off(event: string, handler: (...args: never[]) => void): unknown;
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* The `livekit-client` namespace, as imported by your app:
|
|
1486
|
+
*
|
|
1487
|
+
* import * as livekit from 'livekit-client';
|
|
1488
|
+
*/
|
|
1489
|
+
interface LiveKitModule {
|
|
1490
|
+
Room: new (options?: unknown) => LiveKitRoomHandle;
|
|
1491
|
+
RoomEvent: Record<string, string>;
|
|
1492
|
+
Track: {
|
|
1493
|
+
Source: Record<string, string>;
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* A track plus the context a renderer needs to draw it.
|
|
1498
|
+
*
|
|
1499
|
+
* This is LiveKit's `TrackReference` shape, rebuilt structurally so the
|
|
1500
|
+
* SDK doesn't depend on `@livekit/components-react`. React Native's
|
|
1501
|
+
* `<VideoTrack trackRef={...}>` takes it directly; the web renderer
|
|
1502
|
+
* ignores it and attaches the track itself.
|
|
1503
|
+
*
|
|
1504
|
+
* Adaptive streaming is the reason the reference matters rather than
|
|
1505
|
+
* the bare track: LiveKit uses the publication to decide which quality
|
|
1506
|
+
* layer to send for the size the view is actually drawn at.
|
|
1507
|
+
*/
|
|
1508
|
+
interface LiveKitTrackReference {
|
|
1509
|
+
participant: LiveKitParticipant;
|
|
1510
|
+
publication: LiveKitPublication;
|
|
1511
|
+
source: string;
|
|
1512
|
+
}
|
|
1513
|
+
/** What `POST /v1/conversations/:id/call-token` returns. */
|
|
1514
|
+
interface CallConnection {
|
|
1515
|
+
url: string;
|
|
1516
|
+
token: string;
|
|
1517
|
+
room: string;
|
|
1518
|
+
expires_at: number;
|
|
1519
|
+
}
|
|
1520
|
+
/** Connection lifecycle for a call's media. */
|
|
1521
|
+
type CallRoomStatus = 'idle' | 'connecting' | 'connected' | 'error';
|
|
1522
|
+
/** Somebody on the call, including yourself. */
|
|
1523
|
+
interface CallParticipant {
|
|
1524
|
+
/** poolse user id. */
|
|
1525
|
+
userId: string;
|
|
1526
|
+
name?: string | undefined;
|
|
1527
|
+
isSelf: boolean;
|
|
1528
|
+
micEnabled: boolean;
|
|
1529
|
+
cameraEnabled: boolean;
|
|
1530
|
+
speaking: boolean;
|
|
1531
|
+
/**
|
|
1532
|
+
* The camera track, or null when their camera is off.
|
|
1533
|
+
*
|
|
1534
|
+
* Opaque on purpose — the web renderer attaches it to a `<video>`
|
|
1535
|
+
* element. Handing back a concrete type would force one platform's
|
|
1536
|
+
* renderer on the other.
|
|
1537
|
+
*/
|
|
1538
|
+
videoTrack: LiveKitTrack | null;
|
|
1539
|
+
/**
|
|
1540
|
+
* The same camera track as a renderable reference, or null.
|
|
1541
|
+
*
|
|
1542
|
+
* React Native's `<VideoTrack>` needs this rather than the bare track:
|
|
1543
|
+
* it reads the publication to pick a quality layer matching the size
|
|
1544
|
+
* the view is drawn at.
|
|
1545
|
+
*/
|
|
1546
|
+
videoTrackRef: LiveKitTrackReference | null;
|
|
1547
|
+
}
|
|
1548
|
+
interface CallRoomOptions {
|
|
1549
|
+
/**
|
|
1550
|
+
* `livekit-client`, imported by your app. Required — see the note at
|
|
1551
|
+
* the top of this file about why this package cannot import it.
|
|
1552
|
+
*/
|
|
1553
|
+
livekit: LiveKitModule;
|
|
1554
|
+
/**
|
|
1555
|
+
* Resolves SFU credentials for this conversation.
|
|
1556
|
+
*
|
|
1557
|
+
* Returning `null` means the deployment has no SFU configured (the API
|
|
1558
|
+
* answers 503), which callers treat as "fall back to the mesh" rather
|
|
1559
|
+
* than as an error.
|
|
1560
|
+
*/
|
|
1561
|
+
tokenProvider: () => Promise<CallConnection | null>;
|
|
1562
|
+
/** Publish the camera on join. Audio calls start with it off. */
|
|
1563
|
+
video?: boolean;
|
|
1564
|
+
/** Start muted. */
|
|
1565
|
+
muted?: boolean;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
/**
|
|
1569
|
+
* `/v1/conversations/:id/call-token` — SFU credentials for a call.
|
|
1570
|
+
*
|
|
1571
|
+
* This is the SFU's access control, not a convenience: LiveKit trusts
|
|
1572
|
+
* the token completely and checks no membership of its own, so the
|
|
1573
|
+
* server mints one only after verifying the caller is in the
|
|
1574
|
+
* conversation.
|
|
1575
|
+
*/
|
|
1576
|
+
declare class CallTokensResource {
|
|
1577
|
+
private readonly client;
|
|
1578
|
+
constructor(client: RestClient);
|
|
1579
|
+
/**
|
|
1580
|
+
* POST /v1/conversations/:conversationId/call-token
|
|
1581
|
+
*
|
|
1582
|
+
* Resolves `null` when the deployment has no SFU configured (503).
|
|
1583
|
+
* That is deliberately not an error — the caller falls back to the
|
|
1584
|
+
* peer-to-peer mesh, which is how every call worked before the SFU
|
|
1585
|
+
* existed. A 403 still throws: that one really is a refusal.
|
|
1586
|
+
*/
|
|
1587
|
+
create(conversationId: string, signal?: AbortSignal): Promise<CallConnection | null>;
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
type Unsubscribe = () => void;
|
|
1591
|
+
/**
|
|
1592
|
+
* A call's media, carried by the LiveKit SFU.
|
|
1593
|
+
*
|
|
1594
|
+
* ## What this is not
|
|
1595
|
+
*
|
|
1596
|
+
* It is not the call. Ringing, accept/decline/hangup, presence, the
|
|
1597
|
+
* roster and mute state all stay on poolse's own channels — see
|
|
1598
|
+
* `CallsResource` and `VoiceRoom`. This object owns audio and video
|
|
1599
|
+
* packets and nothing else. A client joins both: `voice:conversation:<id>`
|
|
1600
|
+
* for who is here and what they are doing, this for what they sound and
|
|
1601
|
+
* look like.
|
|
1602
|
+
*
|
|
1603
|
+
* ## Why an SFU rather than the mesh
|
|
1604
|
+
*
|
|
1605
|
+
* {@link VoiceRoom} connects every participant to every other one, so
|
|
1606
|
+
* each uploads N-1 encoded copies of their own camera. At four people
|
|
1607
|
+
* that is roughly 3 Mbps of sustained upload from a phone plus three
|
|
1608
|
+
* simultaneous encodes — the handset overheats, iOS throttles, and
|
|
1609
|
+
* quality collapses for everyone. Audio survives it because Opus is
|
|
1610
|
+
* ~25x cheaper; video does not.
|
|
1611
|
+
*
|
|
1612
|
+
* The SFU also makes the mid-call camera toggle tractable. Turning a
|
|
1613
|
+
* camera on mid-call means renegotiating a live peer connection, which
|
|
1614
|
+
* the mesh cannot do — it offers once, on peer discovery. Here it is
|
|
1615
|
+
* `setCameraEnabled`.
|
|
1616
|
+
*
|
|
1617
|
+
* ## Availability
|
|
1618
|
+
*
|
|
1619
|
+
* A deployment with no SFU configured answers 503, which arrives as
|
|
1620
|
+
* `tokenProvider` returning `null`. That is not an error: the caller
|
|
1621
|
+
* falls back to the mesh, which is what every call used before this
|
|
1622
|
+
* existed. `join()` resolves `false` to say so.
|
|
1623
|
+
*/
|
|
1624
|
+
declare class CallRoom {
|
|
1625
|
+
private readonly livekit;
|
|
1626
|
+
private readonly tokenProvider;
|
|
1627
|
+
private readonly startWithVideo;
|
|
1628
|
+
private readonly startMuted;
|
|
1629
|
+
private room;
|
|
1630
|
+
private status;
|
|
1631
|
+
private selfId;
|
|
1632
|
+
private holders;
|
|
1633
|
+
private readonly statusListeners;
|
|
1634
|
+
private readonly participantListeners;
|
|
1635
|
+
private readonly errorListeners;
|
|
1636
|
+
/** Bound once so `off()` in teardown removes the same references. */
|
|
1637
|
+
private readonly onRoomChange;
|
|
1638
|
+
constructor(opts: CallRoomOptions);
|
|
1639
|
+
getStatus(): CallRoomStatus;
|
|
1640
|
+
onStatus(fn: (status: CallRoomStatus) => void): Unsubscribe;
|
|
1641
|
+
onParticipants(fn: (participants: CallParticipant[]) => void): Unsubscribe;
|
|
1642
|
+
onError(fn: (error: Error) => void): Unsubscribe;
|
|
1643
|
+
getParticipants(): CallParticipant[];
|
|
1644
|
+
/**
|
|
1645
|
+
* Connect to the SFU.
|
|
1646
|
+
*
|
|
1647
|
+
* Resolves `true` once media is flowing, `false` when the deployment
|
|
1648
|
+
* has no SFU — the caller should fall back to the mesh rather than
|
|
1649
|
+
* treat that as a failed call.
|
|
1650
|
+
*/
|
|
1651
|
+
join(): Promise<boolean>;
|
|
1652
|
+
/** Release one holder; disconnects once none are left. */
|
|
1653
|
+
leave(): void;
|
|
1654
|
+
/**
|
|
1655
|
+
* Turn the camera on or off mid-call.
|
|
1656
|
+
*
|
|
1657
|
+
* Off genuinely stops publishing rather than sending black frames, so
|
|
1658
|
+
* the capture indicator goes out and the uplink is freed. LiveKit
|
|
1659
|
+
* renegotiates underneath.
|
|
1660
|
+
*/
|
|
1661
|
+
setCameraEnabled(enabled: boolean): Promise<void>;
|
|
1662
|
+
/** Mute or unmute the microphone. */
|
|
1663
|
+
setMicrophoneEnabled(enabled: boolean): Promise<void>;
|
|
1664
|
+
isCameraEnabled(): boolean;
|
|
1665
|
+
isMicrophoneEnabled(): boolean;
|
|
1666
|
+
private withLocal;
|
|
1667
|
+
private bind;
|
|
1668
|
+
private toParticipant;
|
|
1669
|
+
private teardown;
|
|
1670
|
+
private setStatus;
|
|
1671
|
+
private emitParticipants;
|
|
1672
|
+
private emitError;
|
|
1673
|
+
/** The local participant's poolse user id, once connected. */
|
|
1674
|
+
getSelfId(): string | null;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
interface IceServerResponse {
|
|
1678
|
+
ice_servers: VoiceIceServer[];
|
|
1679
|
+
ttl_seconds: number;
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1682
|
+
* `/v1/ice-servers` — STUN, and TURN when the deployment has it.
|
|
1683
|
+
*
|
|
1684
|
+
* Fetched rather than configured because TURN credentials are
|
|
1685
|
+
* deliberately short-lived. A client that held a static one could not
|
|
1686
|
+
* refresh it, and a TURN password compiled into a mobile binary is
|
|
1687
|
+
* extractable by anyone who wants it.
|
|
1688
|
+
*/
|
|
1689
|
+
declare class IceServersResource {
|
|
1690
|
+
private readonly client;
|
|
1691
|
+
constructor(client: RestClient);
|
|
1692
|
+
/** GET /v1/ice-servers */
|
|
1693
|
+
list(signal?: AbortSignal): Promise<IceServerResponse>;
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1394
1696
|
declare class Poolse {
|
|
1395
1697
|
/** `/v1/me` — current End User. */
|
|
1396
1698
|
readonly me: MeResource;
|
|
@@ -1429,9 +1731,29 @@ declare class Poolse {
|
|
|
1429
1731
|
* `config.wsUrl`.
|
|
1430
1732
|
*/
|
|
1431
1733
|
readonly realtime: PoolseRealtime;
|
|
1734
|
+
/** STUN/TURN servers for WebRTC — see `IceServersResource`. */
|
|
1735
|
+
readonly iceServers: IceServersResource;
|
|
1736
|
+
/** SFU credentials for a call's media — see `CallTokensResource`. */
|
|
1737
|
+
readonly callTokens: CallTokensResource;
|
|
1432
1738
|
private readonly resolved;
|
|
1433
1739
|
private readonly tokenCache;
|
|
1434
1740
|
constructor(config: PoolseConfig);
|
|
1741
|
+
/**
|
|
1742
|
+
* A call's media, carried by the SFU.
|
|
1743
|
+
*
|
|
1744
|
+
* Media only — ringing, presence, roster and mute state stay on
|
|
1745
|
+
* poolse's own channels, and a client joins both. See {@link CallRoom}.
|
|
1746
|
+
*
|
|
1747
|
+
* `livekit` is your app's `livekit-client` import. This package cannot
|
|
1748
|
+
* import it for you: tsup rewrites `require()` into `__require()`,
|
|
1749
|
+
* which Metro cannot follow, so a dependency required from in here is
|
|
1750
|
+
* absent from every React Native bundle.
|
|
1751
|
+
*
|
|
1752
|
+
* import * as livekit from 'livekit-client';
|
|
1753
|
+
* const call = poolse.call(conversationId, { livekit, video: true });
|
|
1754
|
+
* const usingSfu = await call.join(); // false = no SFU, use the mesh
|
|
1755
|
+
*/
|
|
1756
|
+
call(conversationId: string, opts: Omit<CallRoomOptions, 'tokenProvider'> & Partial<Pick<CallRoomOptions, 'tokenProvider'>>): CallRoom;
|
|
1435
1757
|
/**
|
|
1436
1758
|
* Tear down the SDK: close the WebSocket, drop all channels.
|
|
1437
1759
|
* No-op for REST — fetch() doesn't keep persistent state.
|
|
@@ -1494,8 +1816,8 @@ declare class AuthError extends ApiError {
|
|
|
1494
1816
|
declare function isWebRtcAvailable(): boolean;
|
|
1495
1817
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
1496
1818
|
|
|
1497
|
-
declare const version = "2.
|
|
1819
|
+
declare const version = "2.10.0";
|
|
1498
1820
|
|
|
1499
1821
|
declare function safeUuid(): string;
|
|
1500
1822
|
|
|
1501
|
-
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallDeclined, type CallEnded, CallsResource, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IncomingCall, type IsoDateTime, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
|
1823
|
+
export { type AddMemberOptions, ApiError, type Attachment, type AttachmentDownloadResponse, AttachmentHandle, type AttachmentOptions, type AttachmentProgressEvent, type AttachmentStatus, type AttachmentUploadInput, type AttachmentUploadRequest, type AttachmentUploadResponse, AttachmentsResource, AuthError, type CallAccepted, type CallBusy, type CallCancelled, type CallConnection, type CallDeclined, type CallEnded, type CallMedia, type CallParticipant, CallRoom, type CallRoomOptions, type CallRoomStatus, CallTokensResource, CallsResource, type Conversation, ConversationChannel, type ConversationCreateRequest, type ConversationCreatedEvent, ConversationHandle, type ConversationList, ConversationMessages, type ConversationType, type ConversationUpdateRequest, type ConversationUpdatedEvent, ConversationsResource, type Device, type DeviceEnvironment, type DevicePlatform, DevicesResource, type ErrorEnvelope, type IceServerResponse, IceServersResource, type IncomingCall, type IsoDateTime, type LiveKitModule, type LiveKitParticipant, type LiveKitPublication, type LiveKitRoomHandle, type LiveKitTrack, type LiveKitTrackReference, type Me, MeResource, type MemberReadEvent, type MemberRole, type Membership, type MembershipCreateRequest, type MembershipList, type MentionEvent, type Message, type MessageCreateRequest, type MessageDeletedEvent, MessageHandle, type MessageList, type MessageNewEvent, type MessageType, type MessageUpdateRequest, type MessageUpdatedEvent, MessagesResource, NetworkError, type OutgoingCall, POOLSE_API_URL, Poolse, type PoolseConfig, PoolseError, PoolseRealtime, type PoolseUserProfile, type PresenceSnapshot, type QuotedMessagePreview, RateLimitedError, type ReactionEvent, type ReactionRequest, type ReadRequest, type RealtimeStatus, type RegisterDeviceRequest, type TypingEvent, type Unsubscribe$1 as Unsubscribe, UserChannel, UsersResource, type Uuid, type VoiceCandidate, type VoiceDescription, type VoiceIceServer, type VoiceParticipant, type VoicePeerConnection, VoiceRoom, type VoiceRoomOptions, type VoiceStatus, type VoiceStream, type VoiceTrack, type WebRtcAdapter, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|