@poolse/sdk 2.14.0 → 2.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1590,8 +1590,17 @@ interface CheckedLiveKitModule {
1590
1590
  * Optional because it is a static on livekit-client's `Room`, and
1591
1591
  * `CallRoom` falls back to `navigator.mediaDevices` where it is
1592
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.
1593
1598
  */
1594
- getLocalDevices?(kind?: string, requestPermissions?: boolean): Promise<CallDevice[]>;
1599
+ getLocalDevices?(kind?: string, requestPermissions?: boolean): Promise<readonly {
1600
+ deviceId?: string;
1601
+ kind?: string;
1602
+ label?: string;
1603
+ }[]>;
1595
1604
  };
1596
1605
  RoomEvent: Record<string, string>;
1597
1606
  Track: {
@@ -1709,39 +1718,6 @@ declare class CallTokensResource {
1709
1718
  }
1710
1719
 
1711
1720
  type Unsubscribe = () => void;
1712
- /**
1713
- * A call's media, carried by the LiveKit SFU.
1714
- *
1715
- * ## What this is not
1716
- *
1717
- * It is not the call. Ringing, accept/decline/hangup, presence, the
1718
- * roster and mute state all stay on poolse's own channels — see
1719
- * `CallsResource` and `VoiceRoom`. This object owns audio and video
1720
- * packets and nothing else. A client joins both: `voice:conversation:<id>`
1721
- * for who is here and what they are doing, this for what they sound and
1722
- * look like.
1723
- *
1724
- * ## Why an SFU rather than the mesh
1725
- *
1726
- * {@link VoiceRoom} connects every participant to every other one, so
1727
- * each uploads N-1 encoded copies of their own camera. At four people
1728
- * that is roughly 3 Mbps of sustained upload from a phone plus three
1729
- * simultaneous encodes — the handset overheats, iOS throttles, and
1730
- * quality collapses for everyone. Audio survives it because Opus is
1731
- * ~25x cheaper; video does not.
1732
- *
1733
- * The SFU also makes the mid-call camera toggle tractable. Turning a
1734
- * camera on mid-call means renegotiating a live peer connection, which
1735
- * the mesh cannot do — it offers once, on peer discovery. Here it is
1736
- * `setCameraEnabled`.
1737
- *
1738
- * ## Availability
1739
- *
1740
- * A deployment with no SFU configured answers 503, which arrives as
1741
- * `tokenProvider` returning `null`. That is not an error: the caller
1742
- * falls back to the mesh, which is what every call used before this
1743
- * existed. `join()` resolves `false` to say so.
1744
- */
1745
1721
  declare class CallRoom {
1746
1722
  private readonly livekit;
1747
1723
  private readonly tokenProvider;
@@ -1866,6 +1842,14 @@ declare class CallRoom {
1866
1842
  setMicrophoneEnabled(enabled: boolean): Promise<void>;
1867
1843
  isCameraEnabled(): boolean;
1868
1844
  isMicrophoneEnabled(): boolean;
1845
+ /**
1846
+ * Publish one capture device, surviving its absence.
1847
+ *
1848
+ * Split out from {@link withLocal} because this runs mid-join, before
1849
+ * the room is marked connected — emitting a roster here would
1850
+ * advertise a call that has not finished starting.
1851
+ */
1852
+ private publish;
1869
1853
  private withLocal;
1870
1854
  private bind;
1871
1855
  /**
@@ -2041,7 +2025,7 @@ declare class AuthError extends ApiError {
2041
2025
  declare function isWebRtcAvailable(): boolean;
2042
2026
  declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
2043
2027
 
2044
- declare const version = "2.14.0";
2028
+ declare const version = "2.15.0";
2045
2029
 
2046
2030
  declare function safeUuid(): string;
2047
2031
 
package/dist/index.d.ts CHANGED
@@ -1590,8 +1590,17 @@ interface CheckedLiveKitModule {
1590
1590
  * Optional because it is a static on livekit-client's `Room`, and
1591
1591
  * `CallRoom` falls back to `navigator.mediaDevices` where it is
1592
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.
1593
1598
  */
1594
- getLocalDevices?(kind?: string, requestPermissions?: boolean): Promise<CallDevice[]>;
1599
+ getLocalDevices?(kind?: string, requestPermissions?: boolean): Promise<readonly {
1600
+ deviceId?: string;
1601
+ kind?: string;
1602
+ label?: string;
1603
+ }[]>;
1595
1604
  };
1596
1605
  RoomEvent: Record<string, string>;
1597
1606
  Track: {
@@ -1709,39 +1718,6 @@ declare class CallTokensResource {
1709
1718
  }
1710
1719
 
1711
1720
  type Unsubscribe = () => void;
1712
- /**
1713
- * A call's media, carried by the LiveKit SFU.
1714
- *
1715
- * ## What this is not
1716
- *
1717
- * It is not the call. Ringing, accept/decline/hangup, presence, the
1718
- * roster and mute state all stay on poolse's own channels — see
1719
- * `CallsResource` and `VoiceRoom`. This object owns audio and video
1720
- * packets and nothing else. A client joins both: `voice:conversation:<id>`
1721
- * for who is here and what they are doing, this for what they sound and
1722
- * look like.
1723
- *
1724
- * ## Why an SFU rather than the mesh
1725
- *
1726
- * {@link VoiceRoom} connects every participant to every other one, so
1727
- * each uploads N-1 encoded copies of their own camera. At four people
1728
- * that is roughly 3 Mbps of sustained upload from a phone plus three
1729
- * simultaneous encodes — the handset overheats, iOS throttles, and
1730
- * quality collapses for everyone. Audio survives it because Opus is
1731
- * ~25x cheaper; video does not.
1732
- *
1733
- * The SFU also makes the mid-call camera toggle tractable. Turning a
1734
- * camera on mid-call means renegotiating a live peer connection, which
1735
- * the mesh cannot do — it offers once, on peer discovery. Here it is
1736
- * `setCameraEnabled`.
1737
- *
1738
- * ## Availability
1739
- *
1740
- * A deployment with no SFU configured answers 503, which arrives as
1741
- * `tokenProvider` returning `null`. That is not an error: the caller
1742
- * falls back to the mesh, which is what every call used before this
1743
- * existed. `join()` resolves `false` to say so.
1744
- */
1745
1721
  declare class CallRoom {
1746
1722
  private readonly livekit;
1747
1723
  private readonly tokenProvider;
@@ -1866,6 +1842,14 @@ declare class CallRoom {
1866
1842
  setMicrophoneEnabled(enabled: boolean): Promise<void>;
1867
1843
  isCameraEnabled(): boolean;
1868
1844
  isMicrophoneEnabled(): boolean;
1845
+ /**
1846
+ * Publish one capture device, surviving its absence.
1847
+ *
1848
+ * Split out from {@link withLocal} because this runs mid-join, before
1849
+ * the room is marked connected — emitting a roster here would
1850
+ * advertise a call that has not finished starting.
1851
+ */
1852
+ private publish;
1869
1853
  private withLocal;
1870
1854
  private bind;
1871
1855
  /**
@@ -2041,7 +2025,7 @@ declare class AuthError extends ApiError {
2041
2025
  declare function isWebRtcAvailable(): boolean;
2042
2026
  declare function createBrowserWebRtcAdapter(): WebRtcAdapter;
2043
2027
 
2044
- declare const version = "2.14.0";
2028
+ declare const version = "2.15.0";
2045
2029
 
2046
2030
  declare function safeUuid(): string;
2047
2031
 
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;
@@ -1795,9 +1805,15 @@ var CallRoom = class {
1795
1805
  try {
1796
1806
  await room.connect(connection.url, connection.token);
1797
1807
  this.selfId = room.localParticipant.identity;
1798
- await room.localParticipant.setMicrophoneEnabled(!this.startMuted);
1808
+ await this.publish(
1809
+ () => room.localParticipant.setMicrophoneEnabled(!this.startMuted),
1810
+ "microphone"
1811
+ );
1799
1812
  if (this.startWithVideo) {
1800
- await room.localParticipant.setCameraEnabled(true, { facingMode: this.facing });
1813
+ await this.publish(
1814
+ () => room.localParticipant.setCameraEnabled(true, { facingMode: this.facing }),
1815
+ "camera"
1816
+ );
1801
1817
  }
1802
1818
  try {
1803
1819
  await room.startAudio?.();
@@ -1881,14 +1897,13 @@ var CallRoom = class {
1881
1897
  async listDevices(kind) {
1882
1898
  try {
1883
1899
  const fromLiveKit = await this.livekit.Room.getLocalDevices?.(kind, false);
1884
- if (fromLiveKit) return fromLiveKit.map((d) => ({ ...d, kind }));
1900
+ if (fromLiveKit?.length) return toDevices(fromLiveKit, kind);
1885
1901
  } catch {
1886
1902
  }
1887
1903
  const media = globalThis.navigator?.mediaDevices;
1888
1904
  if (!media?.enumerateDevices) return [];
1889
1905
  try {
1890
- const all = await media.enumerateDevices();
1891
- return all.filter((d) => d.kind === kind).map((d) => ({ deviceId: d.deviceId, kind, label: d.label }));
1906
+ return toDevices(await media.enumerateDevices(), kind);
1892
1907
  } catch {
1893
1908
  return [];
1894
1909
  }
@@ -1930,6 +1945,20 @@ var CallRoom = class {
1930
1945
  return this.room?.localParticipant.isMicrophoneEnabled ?? false;
1931
1946
  }
1932
1947
  // ── internals ───────────────────────────────────────────────────────
1948
+ /**
1949
+ * Publish one capture device, surviving its absence.
1950
+ *
1951
+ * Split out from {@link withLocal} because this runs mid-join, before
1952
+ * the room is marked connected — emitting a roster here would
1953
+ * advertise a call that has not finished starting.
1954
+ */
1955
+ async publish(fn, what) {
1956
+ try {
1957
+ await fn();
1958
+ } catch (err) {
1959
+ this.emitError(new Error(`no ${what} available: ${String(err)}`));
1960
+ }
1961
+ }
1933
1962
  async withLocal(fn, what) {
1934
1963
  const room = this.room;
1935
1964
  if (!room) return;
@@ -2424,7 +2453,7 @@ var Poolse = class {
2424
2453
  };
2425
2454
 
2426
2455
  // src/version.ts
2427
- var version = "2.14.0";
2456
+ var version = "2.15.0";
2428
2457
 
2429
2458
  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 };
2430
2459
  //# sourceMappingURL=index.js.map