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

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.
@@ -10759,7 +10759,7 @@ var NavigatorDeviceController = class extends Destroyable {
10759
10759
  enableAudioInput() {
10760
10760
  if (this._audioInputDisabled$.value) {
10761
10761
  this._audioInputDisabled$.next(false);
10762
- const restored = this._lastAudioInputBeforeDisable ?? this.audioInputDevices[0] ?? null;
10762
+ const restored = this._lastAudioInputBeforeDisable ?? this.audioInputDevices[0];
10763
10763
  this._selectedDevicesState$.next({
10764
10764
  ...this._selectedDevicesState$.value,
10765
10765
  audioinput: restored
@@ -10780,7 +10780,7 @@ var NavigatorDeviceController = class extends Destroyable {
10780
10780
  enableVideoInput() {
10781
10781
  if (this._videoInputDisabled$.value) {
10782
10782
  this._videoInputDisabled$.next(false);
10783
- const restored = this._lastVideoInputBeforeDisable ?? this.videoInputDevices[0] ?? null;
10783
+ const restored = this._lastVideoInputBeforeDisable ?? this.videoInputDevices[0];
10784
10784
  this._selectedDevicesState$.next({
10785
10785
  ...this._selectedDevicesState$.value,
10786
10786
  videoinput: restored
@@ -11717,7 +11717,7 @@ function detectScreenShareAudio() {
11717
11717
  * Safely retrieves navigator.mediaDevices, returning null if unavailable.
11718
11718
  */
11719
11719
  function getNavigatorMediaDevices() {
11720
- if (typeof navigator !== "undefined" && navigator.mediaDevices) return navigator.mediaDevices;
11720
+ if (typeof navigator !== "undefined") return navigator.mediaDevices;
11721
11721
  return null;
11722
11722
  }
11723
11723
 
@@ -15778,7 +15778,7 @@ var RTCPeerConnectionController = class extends Destroyable {
15778
15778
  const preferredAudioCodecs = this.options.preferredAudioCodecs ?? PreferencesContainer.instance.preferredAudioCodecs;
15779
15779
  const preferredVideoCodecs = this.options.preferredVideoCodecs ?? PreferencesContainer.instance.preferredVideoCodecs;
15780
15780
  const stereo = this.options.stereo ?? PreferencesContainer.instance.stereoAudio;
15781
- if (preferredAudioCodecs && preferredAudioCodecs.length > 0 || preferredVideoCodecs && preferredVideoCodecs.length > 0) {
15781
+ if (preferredAudioCodecs.length > 0 || preferredVideoCodecs.length > 0) {
15782
15782
  result = setCodecPreferences(result, preferredAudioCodecs, preferredVideoCodecs);
15783
15783
  logger$14.debug("[RTCPeerConnectionController] Applied codec preferences to SDP", {
15784
15784
  preferredAudioCodecs,
@@ -16020,11 +16020,9 @@ var RTCPeerConnectionController = class extends Destroyable {
16020
16020
  oldTrack.stop();
16021
16021
  this.localStreamController.removeTrack(trackId);
16022
16022
  const newTrack = (await this.getUserMedia({ audio: mergedConstraints })).getAudioTracks()[0];
16023
- if (newTrack) {
16024
- await sender.replaceTrack(newTrack);
16025
- this.localStreamController.addTrack(newTrack);
16026
- logger$14.debug(`[RTCPeerConnectionController] Audio track replaced for server-pushed params. New track: ${newTrack.id}`);
16027
- }
16023
+ await sender.replaceTrack(newTrack);
16024
+ this.localStreamController.addTrack(newTrack);
16025
+ logger$14.debug(`[RTCPeerConnectionController] Audio track replaced for server-pushed params. New track: ${newTrack.id}`);
16028
16026
  }
16029
16027
  }
16030
16028
  /**
@@ -16319,7 +16317,7 @@ var WebRTCVertoManager = class extends VertoManager {
16319
16317
  logger$13.warn("[WebRTCManager] No peer connection for keyframe request");
16320
16318
  return;
16321
16319
  }
16322
- const videoReceiver = pc.getReceivers().find((r) => r.track?.kind === "video");
16320
+ const videoReceiver = pc.getReceivers().find((r) => r.track.kind === "video");
16323
16321
  if (!videoReceiver) {
16324
16322
  logger$13.warn("[WebRTCManager] No video receiver for keyframe request");
16325
16323
  return;
@@ -16395,7 +16393,7 @@ var WebRTCVertoManager = class extends VertoManager {
16395
16393
  try {
16396
16394
  const pc = controller.peerConnection;
16397
16395
  if (!pc) continue;
16398
- const videoReceiver = pc.getReceivers().find((r) => r.track?.kind === "video");
16396
+ const videoReceiver = pc.getReceivers().find((r) => r.track.kind === "video");
16399
16397
  if (!videoReceiver) continue;
16400
16398
  if (typeof videoReceiver.requestKeyFrame === "function") {
16401
16399
  videoReceiver.requestKeyFrame();
@@ -18056,10 +18054,10 @@ var WebRTCCall = class extends Destroyable {
18056
18054
  logger$10.debug("[Call] Recovery manager failed to enable video");
18057
18055
  });
18058
18056
  },
18059
- isNegotiating: () => this.vertoManager.mainPeerConnection?.isNegotiating ?? false,
18057
+ isNegotiating: () => this.vertoManager.mainPeerConnection.isNegotiating,
18060
18058
  isWebSocketConnected: () => this._lastMergedStatus !== "disconnected",
18061
18059
  isCallConnected: () => this._lastMergedStatus === "connected",
18062
- getPeerConnectionState: () => pc.connectionState ?? null
18060
+ getPeerConnectionState: () => pc.connectionState
18063
18061
  }, {
18064
18062
  debounceTimeMs: prefs.recoveryDebounceTime,
18065
18063
  cooldownMs: prefs.recoveryCooldown,
@@ -19274,7 +19272,7 @@ var ClientSessionManager = class extends Destroyable {
19274
19272
  */
19275
19273
  async handleVertoAttach(attach) {
19276
19274
  const { callID } = attach;
19277
- if (this._calls$.value[callID]) {
19275
+ if (callID in this._calls$.value) {
19278
19276
  logger$7.debug(`[Session] Verto attach for existing call ${callID}, deferring to per-call handler`);
19279
19277
  return;
19280
19278
  }
@@ -19976,12 +19974,12 @@ var TransportManager = class extends Destroyable {
19976
19974
  this.discardStaleEvents = () => {
19977
19975
  return (0, import_cjs$1.filter)((message) => {
19978
19976
  if (!isSignalwireRequest(message)) return true;
19979
- const eventChannel = message.params?.event_channel;
19977
+ const eventChannel = message.params.event_channel;
19980
19978
  if (!eventChannel) return true;
19981
19979
  const currentProtocol = this._currentProtocol;
19982
19980
  if (!currentProtocol) return true;
19983
19981
  if (!eventChannel.includes(currentProtocol)) {
19984
- const eventType = message.params.event_type ?? "unknown";
19982
+ const eventType = message.params.event_type;
19985
19983
  logger$2.warn(`[Transport] Discarding stale event: ${eventType} (event_channel does not match current protocol)`);
19986
19984
  return false;
19987
19985
  }
@@ -20258,7 +20256,7 @@ var SignalWire = class extends Destroyable {
20258
20256
  }
20259
20257
  if (_credentials.expiry_at && credentialProvider?.refresh) {
20260
20258
  const refreshFn = async () => {
20261
- if (!credentialProvider?.refresh) throw new InvalidCredentialsError("Credential provider does not support refresh");
20259
+ if (!credentialProvider.refresh) throw new InvalidCredentialsError("Credential provider does not support refresh");
20262
20260
  return credentialProvider.refresh();
20263
20261
  };
20264
20262
  const refreshInterval = Math.max(_credentials.expiry_at - Date.now() - 5e3, 1e3);
@@ -20666,7 +20664,7 @@ var SignalWire = class extends Destroyable {
20666
20664
  * ```
20667
20665
  */
20668
20666
  async preflight(destination, options) {
20669
- const iceServers = this._clientSession?.iceServers ?? PreferencesContainer.instance.iceServers ?? [];
20667
+ const iceServers = this._clientSession.iceServers ?? PreferencesContainer.instance.iceServers ?? [];
20670
20668
  const isConnected = this._isConnected$.value;
20671
20669
  return new PreflightRunner(this._deviceController, iceServers, isConnected, 0, async (dest, opts) => this.dial(dest, opts), options).run(destination);
20672
20670
  }
@@ -20883,8 +20881,8 @@ var SignalWire = class extends Destroyable {
20883
20881
  this._deviceTokenManager?.destroy();
20884
20882
  this._dpopManager?.destroy();
20885
20883
  if (this._attachManager) this._attachManager.detachAll();
20886
- this._transport?.destroy();
20887
- this._clientSession?.destroy();
20884
+ this._transport.destroy();
20885
+ this._clientSession.destroy();
20888
20886
  try {
20889
20887
  this._networkMonitor?.destroy();
20890
20888
  } catch {}