@poolse/sdk 2.12.1 → 2.13.1
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/CHANGELOG.md +185 -159
- package/LICENSE +21 -21
- package/README.md +397 -397
- package/dist/index.cjs +108 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -3
- package/dist/index.d.ts +101 -3
- package/dist/index.js +108 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1468,6 +1468,25 @@ interface LiveKitPublication {
|
|
|
1468
1468
|
track?: LiveKitTrack | null | undefined;
|
|
1469
1469
|
isMuted?: boolean;
|
|
1470
1470
|
isSubscribed?: boolean;
|
|
1471
|
+
/**
|
|
1472
|
+
* The same track typed as video, when it is one.
|
|
1473
|
+
*
|
|
1474
|
+
* Separate from `track` because only this side carries
|
|
1475
|
+
* `restartTrack`, which is how the camera is flipped: LiveKit
|
|
1476
|
+
* re-acquires the capture device under the existing publication, so
|
|
1477
|
+
* the far side sees the picture change without a renegotiation and
|
|
1478
|
+
* without the tile blanking.
|
|
1479
|
+
*/
|
|
1480
|
+
videoTrack?: LiveKitLocalVideoTrack | null | undefined;
|
|
1481
|
+
}
|
|
1482
|
+
/** Which camera a video track is capturing from. */
|
|
1483
|
+
type CameraFacing = 'user' | 'environment';
|
|
1484
|
+
/** The slice of LiveKit's `LocalVideoTrack` used to flip the camera. */
|
|
1485
|
+
interface LiveKitLocalVideoTrack {
|
|
1486
|
+
restartTrack?(constraints?: {
|
|
1487
|
+
facingMode?: CameraFacing;
|
|
1488
|
+
deviceId?: string;
|
|
1489
|
+
}): Promise<unknown>;
|
|
1471
1490
|
}
|
|
1472
1491
|
interface LiveKitParticipant {
|
|
1473
1492
|
/** The poolse user id — we mint tokens with `sub` set to it. */
|
|
@@ -1479,7 +1498,14 @@ interface LiveKitParticipant {
|
|
|
1479
1498
|
getTrackPublication(source: string): LiveKitPublication | undefined;
|
|
1480
1499
|
}
|
|
1481
1500
|
interface LiveKitLocalParticipant extends LiveKitParticipant {
|
|
1482
|
-
|
|
1501
|
+
/**
|
|
1502
|
+
* `options` carries the capture constraints. It is how the call opens
|
|
1503
|
+
* on the front camera rather than whatever the OS picks by default,
|
|
1504
|
+
* which on Android is routinely the rear one.
|
|
1505
|
+
*/
|
|
1506
|
+
setCameraEnabled(enabled: boolean, options?: {
|
|
1507
|
+
facingMode?: CameraFacing;
|
|
1508
|
+
}): Promise<unknown>;
|
|
1483
1509
|
setMicrophoneEnabled(enabled: boolean): Promise<unknown>;
|
|
1484
1510
|
}
|
|
1485
1511
|
interface LiveKitRoomHandle {
|
|
@@ -1601,6 +1627,22 @@ interface CallRoomOptions {
|
|
|
1601
1627
|
video?: boolean;
|
|
1602
1628
|
/** Start muted. */
|
|
1603
1629
|
muted?: boolean;
|
|
1630
|
+
/**
|
|
1631
|
+
* Which camera to open with. Defaults to the front one — a call is a
|
|
1632
|
+
* conversation, so the selfie camera is what anyone expects.
|
|
1633
|
+
*/
|
|
1634
|
+
facing?: CameraFacing;
|
|
1635
|
+
/**
|
|
1636
|
+
* How long the last participant may sit alone before the call is
|
|
1637
|
+
* declared over, in milliseconds. Defaults to 1500. Pass `0` to
|
|
1638
|
+
* disable and keep the call open indefinitely.
|
|
1639
|
+
*
|
|
1640
|
+
* The delay is not cosmetic. Two people hanging up within a frame of
|
|
1641
|
+
* each other, or an SFU reconnect that briefly empties the roster,
|
|
1642
|
+
* would both otherwise trip an immediate check — and a call that ends
|
|
1643
|
+
* itself during a half-second blip is worse than one that lingers.
|
|
1644
|
+
*/
|
|
1645
|
+
aloneGraceMs?: number;
|
|
1604
1646
|
}
|
|
1605
1647
|
|
|
1606
1648
|
/**
|
|
@@ -1664,13 +1706,28 @@ declare class CallRoom {
|
|
|
1664
1706
|
private readonly tokenProvider;
|
|
1665
1707
|
private readonly startWithVideo;
|
|
1666
1708
|
private readonly startMuted;
|
|
1709
|
+
private readonly aloneGraceMs;
|
|
1710
|
+
private facing;
|
|
1667
1711
|
private room;
|
|
1668
1712
|
private status;
|
|
1669
1713
|
private selfId;
|
|
1670
1714
|
private holders;
|
|
1715
|
+
/**
|
|
1716
|
+
* Whether anyone else has ever been on this call.
|
|
1717
|
+
*
|
|
1718
|
+
* The whole point of the alone check is to end a call the other side
|
|
1719
|
+
* has vanished from, and "vanished" is only meaningful once they were
|
|
1720
|
+
* here. Without this flag the caller who connects first — alone, by
|
|
1721
|
+
* definition, for as long as it takes the callee to join — would end
|
|
1722
|
+
* their own call before it ever started.
|
|
1723
|
+
*/
|
|
1724
|
+
private hasSeenPeer;
|
|
1725
|
+
/** Pending alone verdict, cleared the moment anyone shows up. */
|
|
1726
|
+
private aloneTimer;
|
|
1671
1727
|
private readonly statusListeners;
|
|
1672
1728
|
private readonly participantListeners;
|
|
1673
1729
|
private readonly errorListeners;
|
|
1730
|
+
private readonly aloneListeners;
|
|
1674
1731
|
/** Bound once so `off()` in teardown removes the same references. */
|
|
1675
1732
|
private readonly onRoomChange;
|
|
1676
1733
|
/**
|
|
@@ -1691,6 +1748,20 @@ declare class CallRoom {
|
|
|
1691
1748
|
onStatus(fn: (status: CallRoomStatus) => void): Unsubscribe;
|
|
1692
1749
|
onParticipants(fn: (participants: CallParticipant[]) => void): Unsubscribe;
|
|
1693
1750
|
onError(fn: (error: Error) => void): Unsubscribe;
|
|
1751
|
+
/**
|
|
1752
|
+
* Everyone else has left and is not coming back.
|
|
1753
|
+
*
|
|
1754
|
+
* A call whose other participants hang up cleanly ends by signal:
|
|
1755
|
+
* `call:hangup` travels over poolse's own channel and the far side
|
|
1756
|
+
* closes its screen. This covers the case where no signal is ever
|
|
1757
|
+
* sent — the app was killed, the phone lost its network, the tab was
|
|
1758
|
+
* closed — where the only evidence is that the SFU roster emptied.
|
|
1759
|
+
*
|
|
1760
|
+
* Media is NOT torn down here. Whoever handles this owns hanging up,
|
|
1761
|
+
* because ending a call also means telling poolse about it, which is
|
|
1762
|
+
* a layer this class deliberately knows nothing about.
|
|
1763
|
+
*/
|
|
1764
|
+
onAlone(fn: () => void): Unsubscribe;
|
|
1694
1765
|
getParticipants(): CallParticipant[];
|
|
1695
1766
|
/**
|
|
1696
1767
|
* Connect to the SFU.
|
|
@@ -1710,6 +1781,21 @@ declare class CallRoom {
|
|
|
1710
1781
|
* renegotiates underneath.
|
|
1711
1782
|
*/
|
|
1712
1783
|
setCameraEnabled(enabled: boolean): Promise<void>;
|
|
1784
|
+
/**
|
|
1785
|
+
* Swap between the front and rear cameras.
|
|
1786
|
+
*
|
|
1787
|
+
* `restartTrack` re-acquires the capture device under the *existing*
|
|
1788
|
+
* publication, so the far side's tile keeps rendering throughout.
|
|
1789
|
+
* Unpublishing and republishing instead would blank their view and
|
|
1790
|
+
* force a renegotiation for what is, to them, the same camera.
|
|
1791
|
+
*
|
|
1792
|
+
* No-ops when the camera is off — there is nothing to restart, and
|
|
1793
|
+
* the next `setCameraEnabled(true)` will open whichever lens is
|
|
1794
|
+
* selected anyway.
|
|
1795
|
+
*/
|
|
1796
|
+
switchCamera(): Promise<void>;
|
|
1797
|
+
/** Which camera the local video track is capturing from. */
|
|
1798
|
+
getFacingMode(): CameraFacing;
|
|
1713
1799
|
/** Mute or unmute the microphone. */
|
|
1714
1800
|
setMicrophoneEnabled(enabled: boolean): Promise<void>;
|
|
1715
1801
|
isCameraEnabled(): boolean;
|
|
@@ -1730,6 +1816,18 @@ declare class CallRoom {
|
|
|
1730
1816
|
private teardown;
|
|
1731
1817
|
private setStatus;
|
|
1732
1818
|
private emitParticipants;
|
|
1819
|
+
/**
|
|
1820
|
+
* Decide whether this client is the last one standing.
|
|
1821
|
+
*
|
|
1822
|
+
* Runs on every roster change. Three things have to be true before a
|
|
1823
|
+
* call is declared over: it is actually connected, somebody else was
|
|
1824
|
+
* here at some point, and nobody is here now — and even then the
|
|
1825
|
+
* verdict waits out {@link CallRoomOptions.aloneGraceMs}, so a
|
|
1826
|
+
* simultaneous hang-up or a momentary SFU reconnect does not read as
|
|
1827
|
+
* abandonment.
|
|
1828
|
+
*/
|
|
1829
|
+
private checkAlone;
|
|
1830
|
+
private clearAloneTimer;
|
|
1733
1831
|
private emitError;
|
|
1734
1832
|
/** The local participant's poolse user id, once connected. */
|
|
1735
1833
|
getSelfId(): string | null;
|
|
@@ -1877,8 +1975,8 @@ declare class AuthError extends ApiError {
|
|
|
1877
1975
|
declare function isWebRtcAvailable(): boolean;
|
|
1878
1976
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
1879
1977
|
|
|
1880
|
-
declare const version = "2.
|
|
1978
|
+
declare const version = "2.13.1";
|
|
1881
1979
|
|
|
1882
1980
|
declare function safeUuid(): string;
|
|
1883
1981
|
|
|
1884
|
-
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 CheckedLiveKitModule, 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 };
|
|
1982
|
+
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 CameraFacing, type CheckedLiveKitModule, 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 LiveKitLocalVideoTrack, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1468,6 +1468,25 @@ interface LiveKitPublication {
|
|
|
1468
1468
|
track?: LiveKitTrack | null | undefined;
|
|
1469
1469
|
isMuted?: boolean;
|
|
1470
1470
|
isSubscribed?: boolean;
|
|
1471
|
+
/**
|
|
1472
|
+
* The same track typed as video, when it is one.
|
|
1473
|
+
*
|
|
1474
|
+
* Separate from `track` because only this side carries
|
|
1475
|
+
* `restartTrack`, which is how the camera is flipped: LiveKit
|
|
1476
|
+
* re-acquires the capture device under the existing publication, so
|
|
1477
|
+
* the far side sees the picture change without a renegotiation and
|
|
1478
|
+
* without the tile blanking.
|
|
1479
|
+
*/
|
|
1480
|
+
videoTrack?: LiveKitLocalVideoTrack | null | undefined;
|
|
1481
|
+
}
|
|
1482
|
+
/** Which camera a video track is capturing from. */
|
|
1483
|
+
type CameraFacing = 'user' | 'environment';
|
|
1484
|
+
/** The slice of LiveKit's `LocalVideoTrack` used to flip the camera. */
|
|
1485
|
+
interface LiveKitLocalVideoTrack {
|
|
1486
|
+
restartTrack?(constraints?: {
|
|
1487
|
+
facingMode?: CameraFacing;
|
|
1488
|
+
deviceId?: string;
|
|
1489
|
+
}): Promise<unknown>;
|
|
1471
1490
|
}
|
|
1472
1491
|
interface LiveKitParticipant {
|
|
1473
1492
|
/** The poolse user id — we mint tokens with `sub` set to it. */
|
|
@@ -1479,7 +1498,14 @@ interface LiveKitParticipant {
|
|
|
1479
1498
|
getTrackPublication(source: string): LiveKitPublication | undefined;
|
|
1480
1499
|
}
|
|
1481
1500
|
interface LiveKitLocalParticipant extends LiveKitParticipant {
|
|
1482
|
-
|
|
1501
|
+
/**
|
|
1502
|
+
* `options` carries the capture constraints. It is how the call opens
|
|
1503
|
+
* on the front camera rather than whatever the OS picks by default,
|
|
1504
|
+
* which on Android is routinely the rear one.
|
|
1505
|
+
*/
|
|
1506
|
+
setCameraEnabled(enabled: boolean, options?: {
|
|
1507
|
+
facingMode?: CameraFacing;
|
|
1508
|
+
}): Promise<unknown>;
|
|
1483
1509
|
setMicrophoneEnabled(enabled: boolean): Promise<unknown>;
|
|
1484
1510
|
}
|
|
1485
1511
|
interface LiveKitRoomHandle {
|
|
@@ -1601,6 +1627,22 @@ interface CallRoomOptions {
|
|
|
1601
1627
|
video?: boolean;
|
|
1602
1628
|
/** Start muted. */
|
|
1603
1629
|
muted?: boolean;
|
|
1630
|
+
/**
|
|
1631
|
+
* Which camera to open with. Defaults to the front one — a call is a
|
|
1632
|
+
* conversation, so the selfie camera is what anyone expects.
|
|
1633
|
+
*/
|
|
1634
|
+
facing?: CameraFacing;
|
|
1635
|
+
/**
|
|
1636
|
+
* How long the last participant may sit alone before the call is
|
|
1637
|
+
* declared over, in milliseconds. Defaults to 1500. Pass `0` to
|
|
1638
|
+
* disable and keep the call open indefinitely.
|
|
1639
|
+
*
|
|
1640
|
+
* The delay is not cosmetic. Two people hanging up within a frame of
|
|
1641
|
+
* each other, or an SFU reconnect that briefly empties the roster,
|
|
1642
|
+
* would both otherwise trip an immediate check — and a call that ends
|
|
1643
|
+
* itself during a half-second blip is worse than one that lingers.
|
|
1644
|
+
*/
|
|
1645
|
+
aloneGraceMs?: number;
|
|
1604
1646
|
}
|
|
1605
1647
|
|
|
1606
1648
|
/**
|
|
@@ -1664,13 +1706,28 @@ declare class CallRoom {
|
|
|
1664
1706
|
private readonly tokenProvider;
|
|
1665
1707
|
private readonly startWithVideo;
|
|
1666
1708
|
private readonly startMuted;
|
|
1709
|
+
private readonly aloneGraceMs;
|
|
1710
|
+
private facing;
|
|
1667
1711
|
private room;
|
|
1668
1712
|
private status;
|
|
1669
1713
|
private selfId;
|
|
1670
1714
|
private holders;
|
|
1715
|
+
/**
|
|
1716
|
+
* Whether anyone else has ever been on this call.
|
|
1717
|
+
*
|
|
1718
|
+
* The whole point of the alone check is to end a call the other side
|
|
1719
|
+
* has vanished from, and "vanished" is only meaningful once they were
|
|
1720
|
+
* here. Without this flag the caller who connects first — alone, by
|
|
1721
|
+
* definition, for as long as it takes the callee to join — would end
|
|
1722
|
+
* their own call before it ever started.
|
|
1723
|
+
*/
|
|
1724
|
+
private hasSeenPeer;
|
|
1725
|
+
/** Pending alone verdict, cleared the moment anyone shows up. */
|
|
1726
|
+
private aloneTimer;
|
|
1671
1727
|
private readonly statusListeners;
|
|
1672
1728
|
private readonly participantListeners;
|
|
1673
1729
|
private readonly errorListeners;
|
|
1730
|
+
private readonly aloneListeners;
|
|
1674
1731
|
/** Bound once so `off()` in teardown removes the same references. */
|
|
1675
1732
|
private readonly onRoomChange;
|
|
1676
1733
|
/**
|
|
@@ -1691,6 +1748,20 @@ declare class CallRoom {
|
|
|
1691
1748
|
onStatus(fn: (status: CallRoomStatus) => void): Unsubscribe;
|
|
1692
1749
|
onParticipants(fn: (participants: CallParticipant[]) => void): Unsubscribe;
|
|
1693
1750
|
onError(fn: (error: Error) => void): Unsubscribe;
|
|
1751
|
+
/**
|
|
1752
|
+
* Everyone else has left and is not coming back.
|
|
1753
|
+
*
|
|
1754
|
+
* A call whose other participants hang up cleanly ends by signal:
|
|
1755
|
+
* `call:hangup` travels over poolse's own channel and the far side
|
|
1756
|
+
* closes its screen. This covers the case where no signal is ever
|
|
1757
|
+
* sent — the app was killed, the phone lost its network, the tab was
|
|
1758
|
+
* closed — where the only evidence is that the SFU roster emptied.
|
|
1759
|
+
*
|
|
1760
|
+
* Media is NOT torn down here. Whoever handles this owns hanging up,
|
|
1761
|
+
* because ending a call also means telling poolse about it, which is
|
|
1762
|
+
* a layer this class deliberately knows nothing about.
|
|
1763
|
+
*/
|
|
1764
|
+
onAlone(fn: () => void): Unsubscribe;
|
|
1694
1765
|
getParticipants(): CallParticipant[];
|
|
1695
1766
|
/**
|
|
1696
1767
|
* Connect to the SFU.
|
|
@@ -1710,6 +1781,21 @@ declare class CallRoom {
|
|
|
1710
1781
|
* renegotiates underneath.
|
|
1711
1782
|
*/
|
|
1712
1783
|
setCameraEnabled(enabled: boolean): Promise<void>;
|
|
1784
|
+
/**
|
|
1785
|
+
* Swap between the front and rear cameras.
|
|
1786
|
+
*
|
|
1787
|
+
* `restartTrack` re-acquires the capture device under the *existing*
|
|
1788
|
+
* publication, so the far side's tile keeps rendering throughout.
|
|
1789
|
+
* Unpublishing and republishing instead would blank their view and
|
|
1790
|
+
* force a renegotiation for what is, to them, the same camera.
|
|
1791
|
+
*
|
|
1792
|
+
* No-ops when the camera is off — there is nothing to restart, and
|
|
1793
|
+
* the next `setCameraEnabled(true)` will open whichever lens is
|
|
1794
|
+
* selected anyway.
|
|
1795
|
+
*/
|
|
1796
|
+
switchCamera(): Promise<void>;
|
|
1797
|
+
/** Which camera the local video track is capturing from. */
|
|
1798
|
+
getFacingMode(): CameraFacing;
|
|
1713
1799
|
/** Mute or unmute the microphone. */
|
|
1714
1800
|
setMicrophoneEnabled(enabled: boolean): Promise<void>;
|
|
1715
1801
|
isCameraEnabled(): boolean;
|
|
@@ -1730,6 +1816,18 @@ declare class CallRoom {
|
|
|
1730
1816
|
private teardown;
|
|
1731
1817
|
private setStatus;
|
|
1732
1818
|
private emitParticipants;
|
|
1819
|
+
/**
|
|
1820
|
+
* Decide whether this client is the last one standing.
|
|
1821
|
+
*
|
|
1822
|
+
* Runs on every roster change. Three things have to be true before a
|
|
1823
|
+
* call is declared over: it is actually connected, somebody else was
|
|
1824
|
+
* here at some point, and nobody is here now — and even then the
|
|
1825
|
+
* verdict waits out {@link CallRoomOptions.aloneGraceMs}, so a
|
|
1826
|
+
* simultaneous hang-up or a momentary SFU reconnect does not read as
|
|
1827
|
+
* abandonment.
|
|
1828
|
+
*/
|
|
1829
|
+
private checkAlone;
|
|
1830
|
+
private clearAloneTimer;
|
|
1733
1831
|
private emitError;
|
|
1734
1832
|
/** The local participant's poolse user id, once connected. */
|
|
1735
1833
|
getSelfId(): string | null;
|
|
@@ -1877,8 +1975,8 @@ declare class AuthError extends ApiError {
|
|
|
1877
1975
|
declare function isWebRtcAvailable(): boolean;
|
|
1878
1976
|
declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
|
|
1879
1977
|
|
|
1880
|
-
declare const version = "2.
|
|
1978
|
+
declare const version = "2.13.1";
|
|
1881
1979
|
|
|
1882
1980
|
declare function safeUuid(): string;
|
|
1883
1981
|
|
|
1884
|
-
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 CheckedLiveKitModule, 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 };
|
|
1982
|
+
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 CameraFacing, type CheckedLiveKitModule, 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 LiveKitLocalVideoTrack, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1663,6 +1663,8 @@ var CallRoom = class {
|
|
|
1663
1663
|
tokenProvider;
|
|
1664
1664
|
startWithVideo;
|
|
1665
1665
|
startMuted;
|
|
1666
|
+
aloneGraceMs;
|
|
1667
|
+
facing;
|
|
1666
1668
|
room = null;
|
|
1667
1669
|
status = "idle";
|
|
1668
1670
|
selfId = null;
|
|
@@ -1670,9 +1672,22 @@ var CallRoom = class {
|
|
|
1670
1672
|
// both hold the same call, and the second holder must not open a
|
|
1671
1673
|
// second SFU connection or tear the first one down on leaving.
|
|
1672
1674
|
holders = 0;
|
|
1675
|
+
/**
|
|
1676
|
+
* Whether anyone else has ever been on this call.
|
|
1677
|
+
*
|
|
1678
|
+
* The whole point of the alone check is to end a call the other side
|
|
1679
|
+
* has vanished from, and "vanished" is only meaningful once they were
|
|
1680
|
+
* here. Without this flag the caller who connects first — alone, by
|
|
1681
|
+
* definition, for as long as it takes the callee to join — would end
|
|
1682
|
+
* their own call before it ever started.
|
|
1683
|
+
*/
|
|
1684
|
+
hasSeenPeer = false;
|
|
1685
|
+
/** Pending alone verdict, cleared the moment anyone shows up. */
|
|
1686
|
+
aloneTimer = null;
|
|
1673
1687
|
statusListeners = /* @__PURE__ */ new Set();
|
|
1674
1688
|
participantListeners = /* @__PURE__ */ new Set();
|
|
1675
1689
|
errorListeners = /* @__PURE__ */ new Set();
|
|
1690
|
+
aloneListeners = /* @__PURE__ */ new Set();
|
|
1676
1691
|
/** Bound once so `off()` in teardown removes the same references. */
|
|
1677
1692
|
onRoomChange = () => this.emitParticipants();
|
|
1678
1693
|
/**
|
|
@@ -1693,6 +1708,8 @@ var CallRoom = class {
|
|
|
1693
1708
|
this.tokenProvider = opts.tokenProvider;
|
|
1694
1709
|
this.startWithVideo = opts.video ?? false;
|
|
1695
1710
|
this.startMuted = opts.muted ?? false;
|
|
1711
|
+
this.facing = opts.facing ?? "user";
|
|
1712
|
+
this.aloneGraceMs = opts.aloneGraceMs ?? 1500;
|
|
1696
1713
|
}
|
|
1697
1714
|
// ── observation ─────────────────────────────────────────────────────
|
|
1698
1715
|
getStatus() {
|
|
@@ -1710,6 +1727,23 @@ var CallRoom = class {
|
|
|
1710
1727
|
this.errorListeners.add(fn);
|
|
1711
1728
|
return () => this.errorListeners.delete(fn);
|
|
1712
1729
|
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Everyone else has left and is not coming back.
|
|
1732
|
+
*
|
|
1733
|
+
* A call whose other participants hang up cleanly ends by signal:
|
|
1734
|
+
* `call:hangup` travels over poolse's own channel and the far side
|
|
1735
|
+
* closes its screen. This covers the case where no signal is ever
|
|
1736
|
+
* sent — the app was killed, the phone lost its network, the tab was
|
|
1737
|
+
* closed — where the only evidence is that the SFU roster emptied.
|
|
1738
|
+
*
|
|
1739
|
+
* Media is NOT torn down here. Whoever handles this owns hanging up,
|
|
1740
|
+
* because ending a call also means telling poolse about it, which is
|
|
1741
|
+
* a layer this class deliberately knows nothing about.
|
|
1742
|
+
*/
|
|
1743
|
+
onAlone(fn) {
|
|
1744
|
+
this.aloneListeners.add(fn);
|
|
1745
|
+
return () => this.aloneListeners.delete(fn);
|
|
1746
|
+
}
|
|
1713
1747
|
getParticipants() {
|
|
1714
1748
|
if (!this.room) return [];
|
|
1715
1749
|
const self = this.toParticipant(this.room.localParticipant, true);
|
|
@@ -1761,7 +1795,9 @@ var CallRoom = class {
|
|
|
1761
1795
|
await room.connect(connection.url, connection.token);
|
|
1762
1796
|
this.selfId = room.localParticipant.identity;
|
|
1763
1797
|
await room.localParticipant.setMicrophoneEnabled(!this.startMuted);
|
|
1764
|
-
if (this.startWithVideo)
|
|
1798
|
+
if (this.startWithVideo) {
|
|
1799
|
+
await room.localParticipant.setCameraEnabled(true, { facingMode: this.facing });
|
|
1800
|
+
}
|
|
1765
1801
|
try {
|
|
1766
1802
|
await room.startAudio?.();
|
|
1767
1803
|
} catch {
|
|
@@ -1793,7 +1829,41 @@ var CallRoom = class {
|
|
|
1793
1829
|
* renegotiates underneath.
|
|
1794
1830
|
*/
|
|
1795
1831
|
async setCameraEnabled(enabled) {
|
|
1796
|
-
await this.withLocal(
|
|
1832
|
+
await this.withLocal(
|
|
1833
|
+
(local) => enabled ? local.setCameraEnabled(true, { facingMode: this.facing }) : local.setCameraEnabled(false),
|
|
1834
|
+
"camera"
|
|
1835
|
+
);
|
|
1836
|
+
}
|
|
1837
|
+
/**
|
|
1838
|
+
* Swap between the front and rear cameras.
|
|
1839
|
+
*
|
|
1840
|
+
* `restartTrack` re-acquires the capture device under the *existing*
|
|
1841
|
+
* publication, so the far side's tile keeps rendering throughout.
|
|
1842
|
+
* Unpublishing and republishing instead would blank their view and
|
|
1843
|
+
* force a renegotiation for what is, to them, the same camera.
|
|
1844
|
+
*
|
|
1845
|
+
* No-ops when the camera is off — there is nothing to restart, and
|
|
1846
|
+
* the next `setCameraEnabled(true)` will open whichever lens is
|
|
1847
|
+
* selected anyway.
|
|
1848
|
+
*/
|
|
1849
|
+
async switchCamera() {
|
|
1850
|
+
const room = this.room;
|
|
1851
|
+
if (!room) return;
|
|
1852
|
+
const source = this.livekit.Track.Source["Camera"] ?? "camera";
|
|
1853
|
+
const track = room.localParticipant.getTrackPublication(source)?.videoTrack;
|
|
1854
|
+
if (!track?.restartTrack) return;
|
|
1855
|
+
const next = this.facing === "user" ? "environment" : "user";
|
|
1856
|
+
try {
|
|
1857
|
+
await track.restartTrack({ facingMode: next });
|
|
1858
|
+
this.facing = next;
|
|
1859
|
+
this.emitParticipants();
|
|
1860
|
+
} catch (err) {
|
|
1861
|
+
this.emitError(new Error(`could not switch camera: ${String(err)}`));
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
/** Which camera the local video track is capturing from. */
|
|
1865
|
+
getFacingMode() {
|
|
1866
|
+
return this.facing;
|
|
1797
1867
|
}
|
|
1798
1868
|
/** Mute or unmute the microphone. */
|
|
1799
1869
|
async setMicrophoneEnabled(enabled) {
|
|
@@ -1901,6 +1971,8 @@ var CallRoom = class {
|
|
|
1901
1971
|
this.room = null;
|
|
1902
1972
|
this.selfId = null;
|
|
1903
1973
|
this.holders = 0;
|
|
1974
|
+
this.hasSeenPeer = false;
|
|
1975
|
+
this.clearAloneTimer();
|
|
1904
1976
|
for (const track of [...this.audioSinks.keys()]) this.stopAudio(track);
|
|
1905
1977
|
if (room) {
|
|
1906
1978
|
try {
|
|
@@ -1919,6 +1991,39 @@ var CallRoom = class {
|
|
|
1919
1991
|
emitParticipants() {
|
|
1920
1992
|
const participants = this.getParticipants();
|
|
1921
1993
|
for (const fn of this.participantListeners) fn(participants);
|
|
1994
|
+
this.checkAlone();
|
|
1995
|
+
}
|
|
1996
|
+
/**
|
|
1997
|
+
* Decide whether this client is the last one standing.
|
|
1998
|
+
*
|
|
1999
|
+
* Runs on every roster change. Three things have to be true before a
|
|
2000
|
+
* call is declared over: it is actually connected, somebody else was
|
|
2001
|
+
* here at some point, and nobody is here now — and even then the
|
|
2002
|
+
* verdict waits out {@link CallRoomOptions.aloneGraceMs}, so a
|
|
2003
|
+
* simultaneous hang-up or a momentary SFU reconnect does not read as
|
|
2004
|
+
* abandonment.
|
|
2005
|
+
*/
|
|
2006
|
+
checkAlone() {
|
|
2007
|
+
if (this.aloneGraceMs <= 0) return;
|
|
2008
|
+
const others = this.room?.remoteParticipants.size ?? 0;
|
|
2009
|
+
if (others > 0) {
|
|
2010
|
+
this.hasSeenPeer = true;
|
|
2011
|
+
this.clearAloneTimer();
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
if (!this.hasSeenPeer || this.status !== "connected") return;
|
|
2015
|
+
if (this.aloneTimer) return;
|
|
2016
|
+
this.aloneTimer = setTimeout(() => {
|
|
2017
|
+
this.aloneTimer = null;
|
|
2018
|
+
if ((this.room?.remoteParticipants.size ?? 0) > 0) return;
|
|
2019
|
+
if (this.status !== "connected") return;
|
|
2020
|
+
for (const fn of this.aloneListeners) fn();
|
|
2021
|
+
}, this.aloneGraceMs);
|
|
2022
|
+
}
|
|
2023
|
+
clearAloneTimer() {
|
|
2024
|
+
if (!this.aloneTimer) return;
|
|
2025
|
+
clearTimeout(this.aloneTimer);
|
|
2026
|
+
this.aloneTimer = null;
|
|
1922
2027
|
}
|
|
1923
2028
|
emitError(error) {
|
|
1924
2029
|
for (const fn of this.errorListeners) fn(error);
|
|
@@ -2259,7 +2364,7 @@ var Poolse = class {
|
|
|
2259
2364
|
};
|
|
2260
2365
|
|
|
2261
2366
|
// src/version.ts
|
|
2262
|
-
var version = "2.
|
|
2367
|
+
var version = "2.13.1";
|
|
2263
2368
|
|
|
2264
2369
|
export { ApiError, AttachmentHandle, AttachmentsResource, AuthError, CallRoom, CallTokensResource, CallsResource, ConversationChannel, ConversationHandle, ConversationMessages, ConversationsResource, DevicesResource, IceServersResource, MeResource, MessageHandle, MessagesResource, NetworkError, POOLSE_API_URL, Poolse, PoolseError, PoolseRealtime, RateLimitedError, UserChannel, UsersResource, VoiceRoom, createBrowserWebRtcAdapter, isWebRtcAvailable, safeUuid, version };
|
|
2265
2370
|
//# sourceMappingURL=index.js.map
|