@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.
package/dist/browser.mjs CHANGED
@@ -10755,7 +10755,7 @@ var NavigatorDeviceController = class extends Destroyable {
10755
10755
  enableAudioInput() {
10756
10756
  if (this._audioInputDisabled$.value) {
10757
10757
  this._audioInputDisabled$.next(false);
10758
- const restored = this._lastAudioInputBeforeDisable ?? this.audioInputDevices[0] ?? null;
10758
+ const restored = this._lastAudioInputBeforeDisable ?? this.audioInputDevices[0];
10759
10759
  this._selectedDevicesState$.next({
10760
10760
  ...this._selectedDevicesState$.value,
10761
10761
  audioinput: restored
@@ -10776,7 +10776,7 @@ var NavigatorDeviceController = class extends Destroyable {
10776
10776
  enableVideoInput() {
10777
10777
  if (this._videoInputDisabled$.value) {
10778
10778
  this._videoInputDisabled$.next(false);
10779
- const restored = this._lastVideoInputBeforeDisable ?? this.videoInputDevices[0] ?? null;
10779
+ const restored = this._lastVideoInputBeforeDisable ?? this.videoInputDevices[0];
10780
10780
  this._selectedDevicesState$.next({
10781
10781
  ...this._selectedDevicesState$.value,
10782
10782
  videoinput: restored
@@ -11713,7 +11713,7 @@ function detectScreenShareAudio() {
11713
11713
  * Safely retrieves navigator.mediaDevices, returning null if unavailable.
11714
11714
  */
11715
11715
  function getNavigatorMediaDevices() {
11716
- if (typeof navigator !== "undefined" && navigator.mediaDevices) return navigator.mediaDevices;
11716
+ if (typeof navigator !== "undefined") return navigator.mediaDevices;
11717
11717
  return null;
11718
11718
  }
11719
11719
 
@@ -15774,7 +15774,7 @@ var RTCPeerConnectionController = class extends Destroyable {
15774
15774
  const preferredAudioCodecs = this.options.preferredAudioCodecs ?? PreferencesContainer.instance.preferredAudioCodecs;
15775
15775
  const preferredVideoCodecs = this.options.preferredVideoCodecs ?? PreferencesContainer.instance.preferredVideoCodecs;
15776
15776
  const stereo = this.options.stereo ?? PreferencesContainer.instance.stereoAudio;
15777
- if (preferredAudioCodecs && preferredAudioCodecs.length > 0 || preferredVideoCodecs && preferredVideoCodecs.length > 0) {
15777
+ if (preferredAudioCodecs.length > 0 || preferredVideoCodecs.length > 0) {
15778
15778
  result = setCodecPreferences(result, preferredAudioCodecs, preferredVideoCodecs);
15779
15779
  logger$14.debug("[RTCPeerConnectionController] Applied codec preferences to SDP", {
15780
15780
  preferredAudioCodecs,
@@ -16016,11 +16016,9 @@ var RTCPeerConnectionController = class extends Destroyable {
16016
16016
  oldTrack.stop();
16017
16017
  this.localStreamController.removeTrack(trackId);
16018
16018
  const newTrack = (await this.getUserMedia({ audio: mergedConstraints })).getAudioTracks()[0];
16019
- if (newTrack) {
16020
- await sender.replaceTrack(newTrack);
16021
- this.localStreamController.addTrack(newTrack);
16022
- logger$14.debug(`[RTCPeerConnectionController] Audio track replaced for server-pushed params. New track: ${newTrack.id}`);
16023
- }
16019
+ await sender.replaceTrack(newTrack);
16020
+ this.localStreamController.addTrack(newTrack);
16021
+ logger$14.debug(`[RTCPeerConnectionController] Audio track replaced for server-pushed params. New track: ${newTrack.id}`);
16024
16022
  }
16025
16023
  }
16026
16024
  /**
@@ -16315,7 +16313,7 @@ var WebRTCVertoManager = class extends VertoManager {
16315
16313
  logger$13.warn("[WebRTCManager] No peer connection for keyframe request");
16316
16314
  return;
16317
16315
  }
16318
- const videoReceiver = pc.getReceivers().find((r) => r.track?.kind === "video");
16316
+ const videoReceiver = pc.getReceivers().find((r) => r.track.kind === "video");
16319
16317
  if (!videoReceiver) {
16320
16318
  logger$13.warn("[WebRTCManager] No video receiver for keyframe request");
16321
16319
  return;
@@ -16391,7 +16389,7 @@ var WebRTCVertoManager = class extends VertoManager {
16391
16389
  try {
16392
16390
  const pc = controller.peerConnection;
16393
16391
  if (!pc) continue;
16394
- const videoReceiver = pc.getReceivers().find((r) => r.track?.kind === "video");
16392
+ const videoReceiver = pc.getReceivers().find((r) => r.track.kind === "video");
16395
16393
  if (!videoReceiver) continue;
16396
16394
  if (typeof videoReceiver.requestKeyFrame === "function") {
16397
16395
  videoReceiver.requestKeyFrame();
@@ -18052,10 +18050,10 @@ var WebRTCCall = class extends Destroyable {
18052
18050
  logger$10.debug("[Call] Recovery manager failed to enable video");
18053
18051
  });
18054
18052
  },
18055
- isNegotiating: () => this.vertoManager.mainPeerConnection?.isNegotiating ?? false,
18053
+ isNegotiating: () => this.vertoManager.mainPeerConnection.isNegotiating,
18056
18054
  isWebSocketConnected: () => this._lastMergedStatus !== "disconnected",
18057
18055
  isCallConnected: () => this._lastMergedStatus === "connected",
18058
- getPeerConnectionState: () => pc.connectionState ?? null
18056
+ getPeerConnectionState: () => pc.connectionState
18059
18057
  }, {
18060
18058
  debounceTimeMs: prefs.recoveryDebounceTime,
18061
18059
  cooldownMs: prefs.recoveryCooldown,
@@ -19270,7 +19268,7 @@ var ClientSessionManager = class extends Destroyable {
19270
19268
  */
19271
19269
  async handleVertoAttach(attach) {
19272
19270
  const { callID } = attach;
19273
- if (this._calls$.value[callID]) {
19271
+ if (callID in this._calls$.value) {
19274
19272
  logger$7.debug(`[Session] Verto attach for existing call ${callID}, deferring to per-call handler`);
19275
19273
  return;
19276
19274
  }
@@ -19972,12 +19970,12 @@ var TransportManager = class extends Destroyable {
19972
19970
  this.discardStaleEvents = () => {
19973
19971
  return (0, import_cjs$1.filter)((message) => {
19974
19972
  if (!isSignalwireRequest(message)) return true;
19975
- const eventChannel = message.params?.event_channel;
19973
+ const eventChannel = message.params.event_channel;
19976
19974
  if (!eventChannel) return true;
19977
19975
  const currentProtocol = this._currentProtocol;
19978
19976
  if (!currentProtocol) return true;
19979
19977
  if (!eventChannel.includes(currentProtocol)) {
19980
- const eventType = message.params.event_type ?? "unknown";
19978
+ const eventType = message.params.event_type;
19981
19979
  logger$2.warn(`[Transport] Discarding stale event: ${eventType} (event_channel does not match current protocol)`);
19982
19980
  return false;
19983
19981
  }
@@ -20254,7 +20252,7 @@ var SignalWire = class extends Destroyable {
20254
20252
  }
20255
20253
  if (_credentials.expiry_at && credentialProvider?.refresh) {
20256
20254
  const refreshFn = async () => {
20257
- if (!credentialProvider?.refresh) throw new InvalidCredentialsError("Credential provider does not support refresh");
20255
+ if (!credentialProvider.refresh) throw new InvalidCredentialsError("Credential provider does not support refresh");
20258
20256
  return credentialProvider.refresh();
20259
20257
  };
20260
20258
  const refreshInterval = Math.max(_credentials.expiry_at - Date.now() - 5e3, 1e3);
@@ -20662,7 +20660,7 @@ var SignalWire = class extends Destroyable {
20662
20660
  * ```
20663
20661
  */
20664
20662
  async preflight(destination, options) {
20665
- const iceServers = this._clientSession?.iceServers ?? PreferencesContainer.instance.iceServers ?? [];
20663
+ const iceServers = this._clientSession.iceServers ?? PreferencesContainer.instance.iceServers ?? [];
20666
20664
  const isConnected = this._isConnected$.value;
20667
20665
  return new PreflightRunner(this._deviceController, iceServers, isConnected, 0, async (dest, opts) => this.dial(dest, opts), options).run(destination);
20668
20666
  }
@@ -20879,8 +20877,8 @@ var SignalWire = class extends Destroyable {
20879
20877
  this._deviceTokenManager?.destroy();
20880
20878
  this._dpopManager?.destroy();
20881
20879
  if (this._attachManager) this._attachManager.detachAll();
20882
- this._transport?.destroy();
20883
- this._clientSession?.destroy();
20880
+ this._transport.destroy();
20881
+ this._clientSession.destroy();
20884
20882
  try {
20885
20883
  this._networkMonitor?.destroy();
20886
20884
  } catch {}