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