@poolse/sdk 2.13.1 → 2.14.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/dist/index.d.cts CHANGED
@@ -1481,6 +1481,28 @@ interface LiveKitPublication {
1481
1481
  }
1482
1482
  /** Which camera a video track is capturing from. */
1483
1483
  type CameraFacing = 'user' | 'environment';
1484
+ /**
1485
+ * A class of media device.
1486
+ *
1487
+ * Spelled out rather than reusing the DOM's `MediaDeviceKind` so the
1488
+ * type means the same thing on React Native, where there is no DOM but
1489
+ * `audiooutput` is still a real concept.
1490
+ */
1491
+ type CallDeviceKind = 'videoinput' | 'audioinput' | 'audiooutput';
1492
+ /** A selectable input or output. */
1493
+ interface CallDevice {
1494
+ deviceId: string;
1495
+ kind: CallDeviceKind;
1496
+ /**
1497
+ * The browser's own label, e.g. "FaceTime HD Camera".
1498
+ *
1499
+ * Empty until the page holds a matching permission — the browser
1500
+ * withholds labels from sites that have never been granted the
1501
+ * device, precisely so they cannot be fingerprinted. In a call that
1502
+ * permission is already held, so labels are normally present.
1503
+ */
1504
+ label: string;
1505
+ }
1484
1506
  /** The slice of LiveKit's `LocalVideoTrack` used to flip the camera. */
1485
1507
  interface LiveKitLocalVideoTrack {
1486
1508
  restartTrack?(constraints?: {
@@ -1510,6 +1532,16 @@ interface LiveKitLocalParticipant extends LiveKitParticipant {
1510
1532
  }
1511
1533
  interface LiveKitRoomHandle {
1512
1534
  localParticipant: LiveKitLocalParticipant;
1535
+ /**
1536
+ * Move every track of `kind` onto another device.
1537
+ *
1538
+ * `audiooutput` is the web's answer to a speakerphone button: it
1539
+ * re-points every incoming audio element with `setSinkId`. Not every
1540
+ * browser implements it, which is why the result is a boolean rather
1541
+ * than a throw.
1542
+ */
1543
+ switchActiveDevice?(kind: string, deviceId: string, exact?: boolean): Promise<unknown>;
1544
+ getActiveDevice?(kind: string): string | undefined;
1513
1545
  /** Keyed by identity. `remoteParticipants` is the v2 name. */
1514
1546
  remoteParticipants: Map<string, LiveKitParticipant>;
1515
1547
  connect(url: string, token: string, options?: unknown): Promise<void>;
@@ -1548,10 +1580,28 @@ interface LiveKitModule {
1548
1580
  }
1549
1581
  /** The precise shape, used internally once the module has been checked. */
1550
1582
  interface CheckedLiveKitModule {
1551
- Room: new (options?: {
1583
+ Room: (new (options?: {
1552
1584
  adaptiveStream?: boolean;
1553
1585
  dynacast?: boolean;
1554
- }) => LiveKitRoomHandle;
1586
+ }) => LiveKitRoomHandle) & {
1587
+ /**
1588
+ * Enumerates devices, prompting for permission if needed.
1589
+ *
1590
+ * Optional because it is a static on livekit-client's `Room`, and
1591
+ * `CallRoom` falls back to `navigator.mediaDevices` where it is
1592
+ * absent rather than losing the picker entirely.
1593
+ *
1594
+ * Typed as the raw device shape, NOT as {@link CallDevice}. These
1595
+ * are `MediaDeviceInfo` instances, whose fields are accessors on the
1596
+ * prototype — declaring them as plain objects invites the spread
1597
+ * that silently loses every id and label.
1598
+ */
1599
+ getLocalDevices?(kind?: string, requestPermissions?: boolean): Promise<readonly {
1600
+ deviceId?: string;
1601
+ kind?: string;
1602
+ label?: string;
1603
+ }[]>;
1604
+ };
1555
1605
  RoomEvent: Record<string, string>;
1556
1606
  Track: {
1557
1607
  Source: Record<string, string>;
@@ -1668,39 +1718,6 @@ declare class CallTokensResource {
1668
1718
  }
1669
1719
 
1670
1720
  type Unsubscribe = () => void;
1671
- /**
1672
- * A call's media, carried by the LiveKit SFU.
1673
- *
1674
- * ## What this is not
1675
- *
1676
- * It is not the call. Ringing, accept/decline/hangup, presence, the
1677
- * roster and mute state all stay on poolse's own channels — see
1678
- * `CallsResource` and `VoiceRoom`. This object owns audio and video
1679
- * packets and nothing else. A client joins both: `voice:conversation:<id>`
1680
- * for who is here and what they are doing, this for what they sound and
1681
- * look like.
1682
- *
1683
- * ## Why an SFU rather than the mesh
1684
- *
1685
- * {@link VoiceRoom} connects every participant to every other one, so
1686
- * each uploads N-1 encoded copies of their own camera. At four people
1687
- * that is roughly 3 Mbps of sustained upload from a phone plus three
1688
- * simultaneous encodes — the handset overheats, iOS throttles, and
1689
- * quality collapses for everyone. Audio survives it because Opus is
1690
- * ~25x cheaper; video does not.
1691
- *
1692
- * The SFU also makes the mid-call camera toggle tractable. Turning a
1693
- * camera on mid-call means renegotiating a live peer connection, which
1694
- * the mesh cannot do — it offers once, on peer discovery. Here it is
1695
- * `setCameraEnabled`.
1696
- *
1697
- * ## Availability
1698
- *
1699
- * A deployment with no SFU configured answers 503, which arrives as
1700
- * `tokenProvider` returning `null`. That is not an error: the caller
1701
- * falls back to the mesh, which is what every call used before this
1702
- * existed. `join()` resolves `false` to say so.
1703
- */
1704
1721
  declare class CallRoom {
1705
1722
  private readonly livekit;
1706
1723
  private readonly tokenProvider;
@@ -1728,6 +1745,7 @@ declare class CallRoom {
1728
1745
  private readonly participantListeners;
1729
1746
  private readonly errorListeners;
1730
1747
  private readonly aloneListeners;
1748
+ private readonly deviceListeners;
1731
1749
  /** Bound once so `off()` in teardown removes the same references. */
1732
1750
  private readonly onRoomChange;
1733
1751
  /**
@@ -1796,6 +1814,30 @@ declare class CallRoom {
1796
1814
  switchCamera(): Promise<void>;
1797
1815
  /** Which camera the local video track is capturing from. */
1798
1816
  getFacingMode(): CameraFacing;
1817
+ /**
1818
+ * Every device of a given kind that could carry this call.
1819
+ *
1820
+ * The web's equivalent of a phone's speaker button: a laptop has no
1821
+ * earpiece to switch to, but it does have three microphones and a
1822
+ * pair of headphones, and picking between them is the same job.
1823
+ *
1824
+ * Prefers livekit-client's own enumeration, which prompts for the
1825
+ * permission that makes labels visible, and falls back to the plain
1826
+ * browser API so a module without the static still lists something.
1827
+ */
1828
+ listDevices(kind: CallDeviceKind): Promise<CallDevice[]>;
1829
+ /** Which device of `kind` the call is currently using. */
1830
+ getActiveDevice(kind: CallDeviceKind): string | undefined;
1831
+ /**
1832
+ * Move the call onto another device.
1833
+ *
1834
+ * `audiooutput` re-points playback through `setSinkId`, which some
1835
+ * browsers do not implement — hence the boolean rather than a throw.
1836
+ * A refusal is reported as an error and leaves the call where it was.
1837
+ */
1838
+ setActiveDevice(kind: CallDeviceKind, deviceId: string): Promise<void>;
1839
+ /** Fires when devices are plugged in or removed. */
1840
+ onDevices(fn: () => void): Unsubscribe;
1799
1841
  /** Mute or unmute the microphone. */
1800
1842
  setMicrophoneEnabled(enabled: boolean): Promise<void>;
1801
1843
  isCameraEnabled(): boolean;
@@ -1975,8 +2017,8 @@ declare class AuthError extends ApiError {
1975
2017
  declare function isWebRtcAvailable(): boolean;
1976
2018
  declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
1977
2019
 
1978
- declare const version = "2.13.1";
2020
+ declare const version = "2.14.1";
1979
2021
 
1980
2022
  declare function safeUuid(): string;
1981
2023
 
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 };
2024
+ 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 CallDevice, type CallDeviceKind, 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
@@ -1481,6 +1481,28 @@ interface LiveKitPublication {
1481
1481
  }
1482
1482
  /** Which camera a video track is capturing from. */
1483
1483
  type CameraFacing = 'user' | 'environment';
1484
+ /**
1485
+ * A class of media device.
1486
+ *
1487
+ * Spelled out rather than reusing the DOM's `MediaDeviceKind` so the
1488
+ * type means the same thing on React Native, where there is no DOM but
1489
+ * `audiooutput` is still a real concept.
1490
+ */
1491
+ type CallDeviceKind = 'videoinput' | 'audioinput' | 'audiooutput';
1492
+ /** A selectable input or output. */
1493
+ interface CallDevice {
1494
+ deviceId: string;
1495
+ kind: CallDeviceKind;
1496
+ /**
1497
+ * The browser's own label, e.g. "FaceTime HD Camera".
1498
+ *
1499
+ * Empty until the page holds a matching permission — the browser
1500
+ * withholds labels from sites that have never been granted the
1501
+ * device, precisely so they cannot be fingerprinted. In a call that
1502
+ * permission is already held, so labels are normally present.
1503
+ */
1504
+ label: string;
1505
+ }
1484
1506
  /** The slice of LiveKit's `LocalVideoTrack` used to flip the camera. */
1485
1507
  interface LiveKitLocalVideoTrack {
1486
1508
  restartTrack?(constraints?: {
@@ -1510,6 +1532,16 @@ interface LiveKitLocalParticipant extends LiveKitParticipant {
1510
1532
  }
1511
1533
  interface LiveKitRoomHandle {
1512
1534
  localParticipant: LiveKitLocalParticipant;
1535
+ /**
1536
+ * Move every track of `kind` onto another device.
1537
+ *
1538
+ * `audiooutput` is the web's answer to a speakerphone button: it
1539
+ * re-points every incoming audio element with `setSinkId`. Not every
1540
+ * browser implements it, which is why the result is a boolean rather
1541
+ * than a throw.
1542
+ */
1543
+ switchActiveDevice?(kind: string, deviceId: string, exact?: boolean): Promise<unknown>;
1544
+ getActiveDevice?(kind: string): string | undefined;
1513
1545
  /** Keyed by identity. `remoteParticipants` is the v2 name. */
1514
1546
  remoteParticipants: Map<string, LiveKitParticipant>;
1515
1547
  connect(url: string, token: string, options?: unknown): Promise<void>;
@@ -1548,10 +1580,28 @@ interface LiveKitModule {
1548
1580
  }
1549
1581
  /** The precise shape, used internally once the module has been checked. */
1550
1582
  interface CheckedLiveKitModule {
1551
- Room: new (options?: {
1583
+ Room: (new (options?: {
1552
1584
  adaptiveStream?: boolean;
1553
1585
  dynacast?: boolean;
1554
- }) => LiveKitRoomHandle;
1586
+ }) => LiveKitRoomHandle) & {
1587
+ /**
1588
+ * Enumerates devices, prompting for permission if needed.
1589
+ *
1590
+ * Optional because it is a static on livekit-client's `Room`, and
1591
+ * `CallRoom` falls back to `navigator.mediaDevices` where it is
1592
+ * absent rather than losing the picker entirely.
1593
+ *
1594
+ * Typed as the raw device shape, NOT as {@link CallDevice}. These
1595
+ * are `MediaDeviceInfo` instances, whose fields are accessors on the
1596
+ * prototype — declaring them as plain objects invites the spread
1597
+ * that silently loses every id and label.
1598
+ */
1599
+ getLocalDevices?(kind?: string, requestPermissions?: boolean): Promise<readonly {
1600
+ deviceId?: string;
1601
+ kind?: string;
1602
+ label?: string;
1603
+ }[]>;
1604
+ };
1555
1605
  RoomEvent: Record<string, string>;
1556
1606
  Track: {
1557
1607
  Source: Record<string, string>;
@@ -1668,39 +1718,6 @@ declare class CallTokensResource {
1668
1718
  }
1669
1719
 
1670
1720
  type Unsubscribe = () => void;
1671
- /**
1672
- * A call's media, carried by the LiveKit SFU.
1673
- *
1674
- * ## What this is not
1675
- *
1676
- * It is not the call. Ringing, accept/decline/hangup, presence, the
1677
- * roster and mute state all stay on poolse's own channels — see
1678
- * `CallsResource` and `VoiceRoom`. This object owns audio and video
1679
- * packets and nothing else. A client joins both: `voice:conversation:<id>`
1680
- * for who is here and what they are doing, this for what they sound and
1681
- * look like.
1682
- *
1683
- * ## Why an SFU rather than the mesh
1684
- *
1685
- * {@link VoiceRoom} connects every participant to every other one, so
1686
- * each uploads N-1 encoded copies of their own camera. At four people
1687
- * that is roughly 3 Mbps of sustained upload from a phone plus three
1688
- * simultaneous encodes — the handset overheats, iOS throttles, and
1689
- * quality collapses for everyone. Audio survives it because Opus is
1690
- * ~25x cheaper; video does not.
1691
- *
1692
- * The SFU also makes the mid-call camera toggle tractable. Turning a
1693
- * camera on mid-call means renegotiating a live peer connection, which
1694
- * the mesh cannot do — it offers once, on peer discovery. Here it is
1695
- * `setCameraEnabled`.
1696
- *
1697
- * ## Availability
1698
- *
1699
- * A deployment with no SFU configured answers 503, which arrives as
1700
- * `tokenProvider` returning `null`. That is not an error: the caller
1701
- * falls back to the mesh, which is what every call used before this
1702
- * existed. `join()` resolves `false` to say so.
1703
- */
1704
1721
  declare class CallRoom {
1705
1722
  private readonly livekit;
1706
1723
  private readonly tokenProvider;
@@ -1728,6 +1745,7 @@ declare class CallRoom {
1728
1745
  private readonly participantListeners;
1729
1746
  private readonly errorListeners;
1730
1747
  private readonly aloneListeners;
1748
+ private readonly deviceListeners;
1731
1749
  /** Bound once so `off()` in teardown removes the same references. */
1732
1750
  private readonly onRoomChange;
1733
1751
  /**
@@ -1796,6 +1814,30 @@ declare class CallRoom {
1796
1814
  switchCamera(): Promise<void>;
1797
1815
  /** Which camera the local video track is capturing from. */
1798
1816
  getFacingMode(): CameraFacing;
1817
+ /**
1818
+ * Every device of a given kind that could carry this call.
1819
+ *
1820
+ * The web's equivalent of a phone's speaker button: a laptop has no
1821
+ * earpiece to switch to, but it does have three microphones and a
1822
+ * pair of headphones, and picking between them is the same job.
1823
+ *
1824
+ * Prefers livekit-client's own enumeration, which prompts for the
1825
+ * permission that makes labels visible, and falls back to the plain
1826
+ * browser API so a module without the static still lists something.
1827
+ */
1828
+ listDevices(kind: CallDeviceKind): Promise<CallDevice[]>;
1829
+ /** Which device of `kind` the call is currently using. */
1830
+ getActiveDevice(kind: CallDeviceKind): string | undefined;
1831
+ /**
1832
+ * Move the call onto another device.
1833
+ *
1834
+ * `audiooutput` re-points playback through `setSinkId`, which some
1835
+ * browsers do not implement — hence the boolean rather than a throw.
1836
+ * A refusal is reported as an error and leaves the call where it was.
1837
+ */
1838
+ setActiveDevice(kind: CallDeviceKind, deviceId: string): Promise<void>;
1839
+ /** Fires when devices are plugged in or removed. */
1840
+ onDevices(fn: () => void): Unsubscribe;
1799
1841
  /** Mute or unmute the microphone. */
1800
1842
  setMicrophoneEnabled(enabled: boolean): Promise<void>;
1801
1843
  isCameraEnabled(): boolean;
@@ -1975,8 +2017,8 @@ declare class AuthError extends ApiError {
1975
2017
  declare function isWebRtcAvailable(): boolean;
1976
2018
  declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
1977
2019
 
1978
- declare const version = "2.13.1";
2020
+ declare const version = "2.14.1";
1979
2021
 
1980
2022
  declare function safeUuid(): string;
1981
2023
 
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 };
2024
+ 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 CallDevice, type CallDeviceKind, 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
@@ -1658,6 +1658,16 @@ var CallTokensResource = class {
1658
1658
  };
1659
1659
 
1660
1660
  // src/voice/call-room.ts
1661
+ function toDevices(raw, kind) {
1662
+ const out = [];
1663
+ for (const device of raw) {
1664
+ if (device.kind && device.kind !== kind) continue;
1665
+ const deviceId = device.deviceId ?? "";
1666
+ if (!deviceId) continue;
1667
+ out.push({ deviceId, kind, label: device.label ?? "" });
1668
+ }
1669
+ return out;
1670
+ }
1661
1671
  var CallRoom = class {
1662
1672
  livekit;
1663
1673
  tokenProvider;
@@ -1688,6 +1698,7 @@ var CallRoom = class {
1688
1698
  participantListeners = /* @__PURE__ */ new Set();
1689
1699
  errorListeners = /* @__PURE__ */ new Set();
1690
1700
  aloneListeners = /* @__PURE__ */ new Set();
1701
+ deviceListeners = /* @__PURE__ */ new Set();
1691
1702
  /** Bound once so `off()` in teardown removes the same references. */
1692
1703
  onRoomChange = () => this.emitParticipants();
1693
1704
  /**
@@ -1865,6 +1876,58 @@ var CallRoom = class {
1865
1876
  getFacingMode() {
1866
1877
  return this.facing;
1867
1878
  }
1879
+ // ── device selection ────────────────────────────────────────────────
1880
+ /**
1881
+ * Every device of a given kind that could carry this call.
1882
+ *
1883
+ * The web's equivalent of a phone's speaker button: a laptop has no
1884
+ * earpiece to switch to, but it does have three microphones and a
1885
+ * pair of headphones, and picking between them is the same job.
1886
+ *
1887
+ * Prefers livekit-client's own enumeration, which prompts for the
1888
+ * permission that makes labels visible, and falls back to the plain
1889
+ * browser API so a module without the static still lists something.
1890
+ */
1891
+ async listDevices(kind) {
1892
+ try {
1893
+ const fromLiveKit = await this.livekit.Room.getLocalDevices?.(kind, false);
1894
+ if (fromLiveKit?.length) return toDevices(fromLiveKit, kind);
1895
+ } catch {
1896
+ }
1897
+ const media = globalThis.navigator?.mediaDevices;
1898
+ if (!media?.enumerateDevices) return [];
1899
+ try {
1900
+ return toDevices(await media.enumerateDevices(), kind);
1901
+ } catch {
1902
+ return [];
1903
+ }
1904
+ }
1905
+ /** Which device of `kind` the call is currently using. */
1906
+ getActiveDevice(kind) {
1907
+ return this.room?.getActiveDevice?.(kind);
1908
+ }
1909
+ /**
1910
+ * Move the call onto another device.
1911
+ *
1912
+ * `audiooutput` re-points playback through `setSinkId`, which some
1913
+ * browsers do not implement — hence the boolean rather than a throw.
1914
+ * A refusal is reported as an error and leaves the call where it was.
1915
+ */
1916
+ async setActiveDevice(kind, deviceId) {
1917
+ const room = this.room;
1918
+ if (!room?.switchActiveDevice) return;
1919
+ try {
1920
+ await room.switchActiveDevice(kind, deviceId);
1921
+ this.emitParticipants();
1922
+ } catch (err) {
1923
+ this.emitError(new Error(`could not switch ${kind}: ${String(err)}`));
1924
+ }
1925
+ }
1926
+ /** Fires when devices are plugged in or removed. */
1927
+ onDevices(fn) {
1928
+ this.deviceListeners.add(fn);
1929
+ return () => this.deviceListeners.delete(fn);
1930
+ }
1868
1931
  /** Mute or unmute the microphone. */
1869
1932
  async setMicrophoneEnabled(enabled) {
1870
1933
  await this.withLocal((local) => local.setMicrophoneEnabled(enabled), "microphone");
@@ -1910,6 +1973,12 @@ var CallRoom = class {
1910
1973
  if (unsubscribed) {
1911
1974
  room.on(unsubscribed, ((track) => this.stopAudio(track)));
1912
1975
  }
1976
+ const devicesChanged = RoomEvent["MediaDevicesChanged"];
1977
+ if (devicesChanged) {
1978
+ room.on(devicesChanged, () => {
1979
+ for (const fn of this.deviceListeners) fn();
1980
+ });
1981
+ }
1913
1982
  const disconnected = RoomEvent["Disconnected"];
1914
1983
  if (disconnected) {
1915
1984
  room.on(disconnected, () => {
@@ -2364,7 +2433,7 @@ var Poolse = class {
2364
2433
  };
2365
2434
 
2366
2435
  // src/version.ts
2367
- var version = "2.13.1";
2436
+ var version = "2.14.1";
2368
2437
 
2369
2438
  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 };
2370
2439
  //# sourceMappingURL=index.js.map