@signalwire/js 4.0.0-dev-20260410161919 → 4.0.0-dev-20260410164129

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/browser.mjs CHANGED
@@ -11835,11 +11835,12 @@ var PreflightRunner = class extends Destroyable {
11835
11835
  let pc;
11836
11836
  try {
11837
11837
  pc = new RTCPeerConnection({ iceServers: this.iceServers });
11838
+ const peerConnection = pc;
11838
11839
  const candidateTypes = /* @__PURE__ */ new Set();
11839
11840
  const startTime = Date.now();
11840
11841
  const gatheringComplete = new Promise((resolve) => {
11841
11842
  const timer$2 = setTimeout(resolve, ICE_GATHERING_TIMEOUT_MS);
11842
- pc.onicecandidate = (event) => {
11843
+ peerConnection.onicecandidate = (event) => {
11843
11844
  if (event.candidate) {
11844
11845
  const candidateStr = event.candidate.candidate;
11845
11846
  if (candidateStr.includes("typ host")) candidateTypes.add("host");
@@ -14409,8 +14410,8 @@ var CallEventsManager = class extends Destroyable {
14409
14410
  }
14410
14411
  updateParticipantPositions(layoutChangedEvent) {
14411
14412
  if (Object.keys(this._participants$.value).length > 0 && !layoutChangedEvent.layers.some((layer) => !!layer.member_id)) logger$18.warn("[CallEventsManager] No layers with member_id found in layout.changed event. Nothing to update.");
14412
- layoutChangedEvent.layers.filter((layer) => Boolean(layer.member_id)).filter((layer) => {
14413
- if (!layer.member_id || !(layer.member_id in this._participants$.value)) {
14413
+ layoutChangedEvent.layers.filter((layer) => !!layer.member_id).filter((layer) => {
14414
+ if (!(layer.member_id in this._participants$.value)) {
14414
14415
  logger$18.warn(`[CallEventsManager] Skipping layout layer for unknown member_id: ${layer.member_id}`);
14415
14416
  return false;
14416
14417
  }
@@ -16868,6 +16869,12 @@ function computePacketLossPercent(lost, received) {
16868
16869
  if (total === 0) return 0;
16869
16870
  return lost / total * 100;
16870
16871
  }
16872
+ function isInboundRtpStat(stat) {
16873
+ return typeof stat === "object" && stat !== null && "type" in stat && stat.type === "inbound-rtp";
16874
+ }
16875
+ function isCandidatePairStat(stat) {
16876
+ return typeof stat === "object" && stat !== null && "type" in stat && stat.type === "candidate-pair";
16877
+ }
16871
16878
  var RTCStatsMonitor = class extends Destroyable {
16872
16879
  constructor(peerConnection, config = {}) {
16873
16880
  super();
@@ -16999,17 +17006,15 @@ var RTCStatsMonitor = class extends Destroyable {
16999
17006
  let roundTripTime = 0;
17000
17007
  let availableOutgoingBitrate;
17001
17008
  report.forEach((stat) => {
17002
- if (stat.type === "inbound-rtp") {
17003
- if (stat.kind === "audio") {
17004
- audioPacketsReceived += stat.packetsReceived ?? this.lastAudioPacketsReceived;
17005
- audioPacketsLost += stat.packetsLost ?? 0;
17006
- audioJitter = Math.max(audioJitter, (stat.jitter ?? 0) * 1e3);
17007
- } else if (stat.kind === "video") {
17008
- videoPacketsReceived += stat.packetsReceived ?? this.lastVideoPacketsReceived;
17009
- videoPacketsLost += stat.packetsLost ?? 0;
17010
- }
17009
+ if (isInboundRtpStat(stat)) if (stat.kind === "audio") {
17010
+ audioPacketsReceived += stat.packetsReceived ?? this.lastAudioPacketsReceived;
17011
+ audioPacketsLost += stat.packetsLost ?? 0;
17012
+ audioJitter = Math.max(audioJitter, (stat.jitter ?? 0) * 1e3);
17013
+ } else {
17014
+ videoPacketsReceived += stat.packetsReceived ?? this.lastVideoPacketsReceived;
17015
+ videoPacketsLost += stat.packetsLost ?? 0;
17011
17016
  }
17012
- if (stat.type === "candidate-pair" && stat.state === "succeeded" && stat.nominated) {
17017
+ if (isCandidatePairStat(stat) && stat.state === "succeeded" && stat.nominated) {
17013
17018
  roundTripTime = stat.currentRoundTripTime ? stat.currentRoundTripTime * 1e3 : this.lastRoundTripTime;
17014
17019
  availableOutgoingBitrate = stat.availableOutgoingBitrate ?? this.lastAvailableOutgoingBitrate;
17015
17020
  }
@@ -20812,6 +20817,8 @@ var SignalWire = class extends Destroyable {
20812
20817
  * Triggers the browser's media permission dialog and captures the user's device selections.
20813
20818
  *
20814
20819
  * @param options - Which permissions to request.
20820
+ * @param options.audio - Whether to request audio permission.
20821
+ * @param options.video - Whether to request video permission.
20815
20822
  * @returns The permission result with selected devices.
20816
20823
  */
20817
20824
  async requestMediaPermissions(options = {
@@ -20843,8 +20850,14 @@ var SignalWire = class extends Destroyable {
20843
20850
  logger$1.warn("[SignalWire] Media permission request failed:", error);
20844
20851
  }
20845
20852
  await this._deviceController.enumerateDevices();
20846
- if (audioGranted && selectedAudioDevice) selectedAudioDevice = this.audioInputDevices.find((d) => d.deviceId === selectedAudioDevice.deviceId) ?? selectedAudioDevice;
20847
- if (videoGranted && selectedVideoDevice) selectedVideoDevice = this.videoInputDevices.find((d) => d.deviceId === selectedVideoDevice.deviceId) ?? selectedVideoDevice;
20853
+ if (audioGranted && selectedAudioDevice) {
20854
+ const audioDeviceId = selectedAudioDevice.deviceId;
20855
+ selectedAudioDevice = this.audioInputDevices.find((d) => d.deviceId === audioDeviceId) ?? selectedAudioDevice;
20856
+ }
20857
+ if (videoGranted && selectedVideoDevice) {
20858
+ const videoDeviceId = selectedVideoDevice.deviceId;
20859
+ selectedVideoDevice = this.videoInputDevices.find((d) => d.deviceId === videoDeviceId) ?? selectedVideoDevice;
20860
+ }
20848
20861
  if (audioGranted && selectedAudioDevice && !this.selectedAudioInputDevice) this.selectAudioInputDevice(selectedAudioDevice);
20849
20862
  if (videoGranted && selectedVideoDevice && !this.selectedVideoInputDevice) this.selectVideoInputDevice(selectedVideoDevice);
20850
20863
  return {