@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/index.cjs CHANGED
@@ -1319,7 +1319,7 @@ var NavigatorDeviceController = class extends Destroyable {
1319
1319
  enableAudioInput() {
1320
1320
  if (this._audioInputDisabled$.value) {
1321
1321
  this._audioInputDisabled$.next(false);
1322
- const restored = this._lastAudioInputBeforeDisable ?? this.audioInputDevices[0] ?? null;
1322
+ const restored = this._lastAudioInputBeforeDisable ?? this.audioInputDevices[0];
1323
1323
  this._selectedDevicesState$.next({
1324
1324
  ...this._selectedDevicesState$.value,
1325
1325
  audioinput: restored
@@ -1340,7 +1340,7 @@ var NavigatorDeviceController = class extends Destroyable {
1340
1340
  enableVideoInput() {
1341
1341
  if (this._videoInputDisabled$.value) {
1342
1342
  this._videoInputDisabled$.next(false);
1343
- const restored = this._lastVideoInputBeforeDisable ?? this.videoInputDevices[0] ?? null;
1343
+ const restored = this._lastVideoInputBeforeDisable ?? this.videoInputDevices[0];
1344
1344
  this._selectedDevicesState$.next({
1345
1345
  ...this._selectedDevicesState$.value,
1346
1346
  videoinput: restored
@@ -2276,7 +2276,7 @@ function detectScreenShareAudio() {
2276
2276
  * Safely retrieves navigator.mediaDevices, returning null if unavailable.
2277
2277
  */
2278
2278
  function getNavigatorMediaDevices() {
2279
- if (typeof navigator !== "undefined" && navigator.mediaDevices) return navigator.mediaDevices;
2279
+ if (typeof navigator !== "undefined") return navigator.mediaDevices;
2280
2280
  return null;
2281
2281
  }
2282
2282
 
@@ -5298,7 +5298,7 @@ var RTCPeerConnectionController = class extends Destroyable {
5298
5298
  const preferredAudioCodecs = this.options.preferredAudioCodecs ?? PreferencesContainer.instance.preferredAudioCodecs;
5299
5299
  const preferredVideoCodecs = this.options.preferredVideoCodecs ?? PreferencesContainer.instance.preferredVideoCodecs;
5300
5300
  const stereo = this.options.stereo ?? PreferencesContainer.instance.stereoAudio;
5301
- if (preferredAudioCodecs && preferredAudioCodecs.length > 0 || preferredVideoCodecs && preferredVideoCodecs.length > 0) {
5301
+ if (preferredAudioCodecs.length > 0 || preferredVideoCodecs.length > 0) {
5302
5302
  result = setCodecPreferences(result, preferredAudioCodecs, preferredVideoCodecs);
5303
5303
  logger$14.debug("[RTCPeerConnectionController] Applied codec preferences to SDP", {
5304
5304
  preferredAudioCodecs,
@@ -5540,11 +5540,9 @@ var RTCPeerConnectionController = class extends Destroyable {
5540
5540
  oldTrack.stop();
5541
5541
  this.localStreamController.removeTrack(trackId);
5542
5542
  const newTrack = (await this.getUserMedia({ audio: mergedConstraints })).getAudioTracks()[0];
5543
- if (newTrack) {
5544
- await sender.replaceTrack(newTrack);
5545
- this.localStreamController.addTrack(newTrack);
5546
- logger$14.debug(`[RTCPeerConnectionController] Audio track replaced for server-pushed params. New track: ${newTrack.id}`);
5547
- }
5543
+ await sender.replaceTrack(newTrack);
5544
+ this.localStreamController.addTrack(newTrack);
5545
+ logger$14.debug(`[RTCPeerConnectionController] Audio track replaced for server-pushed params. New track: ${newTrack.id}`);
5548
5546
  }
5549
5547
  }
5550
5548
  /**
@@ -5838,7 +5836,7 @@ var WebRTCVertoManager = class extends VertoManager {
5838
5836
  logger$13.warn("[WebRTCManager] No peer connection for keyframe request");
5839
5837
  return;
5840
5838
  }
5841
- const videoReceiver = pc.getReceivers().find((r) => r.track?.kind === "video");
5839
+ const videoReceiver = pc.getReceivers().find((r) => r.track.kind === "video");
5842
5840
  if (!videoReceiver) {
5843
5841
  logger$13.warn("[WebRTCManager] No video receiver for keyframe request");
5844
5842
  return;
@@ -5914,7 +5912,7 @@ var WebRTCVertoManager = class extends VertoManager {
5914
5912
  try {
5915
5913
  const pc = controller.peerConnection;
5916
5914
  if (!pc) continue;
5917
- const videoReceiver = pc.getReceivers().find((r) => r.track?.kind === "video");
5915
+ const videoReceiver = pc.getReceivers().find((r) => r.track.kind === "video");
5918
5916
  if (!videoReceiver) continue;
5919
5917
  if (typeof videoReceiver.requestKeyFrame === "function") {
5920
5918
  videoReceiver.requestKeyFrame();
@@ -7578,10 +7576,10 @@ var WebRTCCall = class extends Destroyable {
7578
7576
  logger$10.debug("[Call] Recovery manager failed to enable video");
7579
7577
  });
7580
7578
  },
7581
- isNegotiating: () => this.vertoManager.mainPeerConnection?.isNegotiating ?? false,
7579
+ isNegotiating: () => this.vertoManager.mainPeerConnection.isNegotiating,
7582
7580
  isWebSocketConnected: () => this._lastMergedStatus !== "disconnected",
7583
7581
  isCallConnected: () => this._lastMergedStatus === "connected",
7584
- getPeerConnectionState: () => pc.connectionState ?? null
7582
+ getPeerConnectionState: () => pc.connectionState
7585
7583
  }, {
7586
7584
  debounceTimeMs: prefs.recoveryDebounceTime,
7587
7585
  cooldownMs: prefs.recoveryCooldown,
@@ -8792,7 +8790,7 @@ var ClientSessionManager = class extends Destroyable {
8792
8790
  */
8793
8791
  async handleVertoAttach(attach) {
8794
8792
  const { callID } = attach;
8795
- if (this._calls$.value[callID]) {
8793
+ if (callID in this._calls$.value) {
8796
8794
  logger$7.debug(`[Session] Verto attach for existing call ${callID}, deferring to per-call handler`);
8797
8795
  return;
8798
8796
  }
@@ -9490,12 +9488,12 @@ var TransportManager = class extends Destroyable {
9490
9488
  this.discardStaleEvents = () => {
9491
9489
  return (0, rxjs.filter)((message) => {
9492
9490
  if (!isSignalwireRequest(message)) return true;
9493
- const eventChannel = message.params?.event_channel;
9491
+ const eventChannel = message.params.event_channel;
9494
9492
  if (!eventChannel) return true;
9495
9493
  const currentProtocol = this._currentProtocol;
9496
9494
  if (!currentProtocol) return true;
9497
9495
  if (!eventChannel.includes(currentProtocol)) {
9498
- const eventType = message.params.event_type ?? "unknown";
9496
+ const eventType = message.params.event_type;
9499
9497
  logger$2.warn(`[Transport] Discarding stale event: ${eventType} (event_channel does not match current protocol)`);
9500
9498
  return false;
9501
9499
  }
@@ -9771,7 +9769,7 @@ var SignalWire = class extends Destroyable {
9771
9769
  }
9772
9770
  if (_credentials.expiry_at && credentialProvider?.refresh) {
9773
9771
  const refreshFn = async () => {
9774
- if (!credentialProvider?.refresh) throw new require_operators.InvalidCredentialsError("Credential provider does not support refresh");
9772
+ if (!credentialProvider.refresh) throw new require_operators.InvalidCredentialsError("Credential provider does not support refresh");
9775
9773
  return credentialProvider.refresh();
9776
9774
  };
9777
9775
  const refreshInterval = Math.max(_credentials.expiry_at - Date.now() - 5e3, 1e3);
@@ -10179,7 +10177,7 @@ var SignalWire = class extends Destroyable {
10179
10177
  * ```
10180
10178
  */
10181
10179
  async preflight(destination, options) {
10182
- const iceServers = this._clientSession?.iceServers ?? PreferencesContainer.instance.iceServers ?? [];
10180
+ const iceServers = this._clientSession.iceServers ?? PreferencesContainer.instance.iceServers ?? [];
10183
10181
  const isConnected = this._isConnected$.value;
10184
10182
  return new PreflightRunner(this._deviceController, iceServers, isConnected, 0, async (dest, opts) => this.dial(dest, opts), options).run(destination);
10185
10183
  }
@@ -10396,8 +10394,8 @@ var SignalWire = class extends Destroyable {
10396
10394
  this._deviceTokenManager?.destroy();
10397
10395
  this._dpopManager?.destroy();
10398
10396
  if (this._attachManager) this._attachManager.detachAll();
10399
- this._transport?.destroy();
10400
- this._clientSession?.destroy();
10397
+ this._transport.destroy();
10398
+ this._clientSession.destroy();
10401
10399
  try {
10402
10400
  this._networkMonitor?.destroy();
10403
10401
  } catch {}