@signalwire/js 4.0.0-dev-20260428035205 → 4.0.0-dev-20260428141127

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
@@ -1,4 +1,4 @@
1
- const require_operators = require('./operators-BT3jl--r.cjs');
1
+ const require_operators = require('./operators-D6a2J1KA.cjs');
2
2
  let jwt_decode = require("jwt-decode");
3
3
  let rxjs = require("rxjs");
4
4
  let uuid = require("uuid");
@@ -2956,9 +2956,9 @@ var AttachManager = class {
2956
2956
  * (e.g. after a reload).
2957
2957
  */
2958
2958
  async consumePendingAttachment(callId) {
2959
- const attachment = (await this.readAttached())[callId];
2960
- if (!attachment) return;
2961
- return this.buildCallOptions(attachment);
2959
+ const attached = await this.readAttached();
2960
+ if (!Object.hasOwn(attached, callId)) return;
2961
+ return this.buildCallOptions(attached[callId]);
2962
2962
  }
2963
2963
  async detachExpired() {
2964
2964
  const now = Date.now();
@@ -5772,10 +5772,9 @@ var RTCPeerConnectionController = class extends Destroyable {
5772
5772
  }
5773
5773
  async applyLocalAudioPipelineToSender() {
5774
5774
  if (!this._localAudioPipeline || !this.peerConnection) return;
5775
- const [raw] = this.localStreamController.localAudioTracks;
5775
+ const raw = this.localStreamController.localAudioTracks.at(0);
5776
5776
  this._localAudioPipeline.setInputTrack(raw ?? null);
5777
- const [audioTransceiver] = this.transceiverController?.audioTransceivers ?? [];
5778
- const sender = audioTransceiver?.sender ?? this.peerConnection.getSenders().find((s) => s.track?.kind === "audio");
5777
+ const sender = (this.transceiverController?.audioTransceivers.at(0))?.sender ?? this.peerConnection.getSenders().find((s) => s.track?.kind === "audio");
5779
5778
  if (!sender || !raw) return;
5780
5779
  try {
5781
5780
  await sender.replaceTrack(this._localAudioPipeline.outputTrack);
@@ -8142,7 +8141,7 @@ var WebRTCCall = class extends Destroyable {
8142
8141
  const pc = this.rtcPeerConnection;
8143
8142
  if (!pc) return false;
8144
8143
  const deadline = Date.now() + PEER_CONNECTION_RECOVERY_WAIT_MS;
8145
- while (true) {
8144
+ for (;;) {
8146
8145
  const state = pc.connectionState;
8147
8146
  if (state === "connected") return true;
8148
8147
  if (state === "failed" || state === "closed") return false;
@@ -8439,7 +8438,7 @@ var WebRTCCall = class extends Destroyable {
8439
8438
  get localMicrophoneGain$() {
8440
8439
  const pipeline = this.vertoManager.ensureLocalAudioPipeline();
8441
8440
  if (!pipeline) return (0, rxjs.of)(100).pipe((0, rxjs.takeUntil)(this._destroyed$));
8442
- return pipeline.gain$.pipe((0, rxjs.map)((multiplier) => multiplier * 100), (0, rxjs.takeUntil)(this._destroyed$));
8441
+ return this.publicCachedObservable("localMicrophoneGain$", () => pipeline.gain$.pipe((0, rxjs.map)((multiplier) => multiplier * 100), (0, rxjs.takeUntil)(this._destroyed$)));
8443
8442
  }
8444
8443
  /**
8445
8444
  * Observable of the RMS audio level of the local microphone, 0..1.
@@ -8447,14 +8446,18 @@ var WebRTCCall = class extends Destroyable {
8447
8446
  * pipeline on first subscription.
8448
8447
  */
8449
8448
  get localAudioLevel$() {
8450
- return this.vertoManager.ensureLocalAudioPipeline()?.level$ ?? (0, rxjs.of)(0).pipe((0, rxjs.takeUntil)(this._destroyed$));
8449
+ const pipeline = this.vertoManager.ensureLocalAudioPipeline();
8450
+ if (!pipeline) return (0, rxjs.of)(0).pipe((0, rxjs.takeUntil)(this._destroyed$));
8451
+ return this.publicCachedObservable("localAudioLevel$", () => pipeline.level$.pipe((0, rxjs.takeUntil)(this._destroyed$), (0, rxjs.share)()));
8451
8452
  }
8452
8453
  /**
8453
8454
  * Observable that is `true` while the local participant is speaking
8454
8455
  * (RMS level above the VAD threshold, with hold time to avoid flicker).
8455
8456
  */
8456
8457
  get localSpeaking$() {
8457
- return this.vertoManager.ensureLocalAudioPipeline()?.speaking$ ?? (0, rxjs.of)(false).pipe((0, rxjs.takeUntil)(this._destroyed$));
8458
+ const pipeline = this.vertoManager.ensureLocalAudioPipeline();
8459
+ if (!pipeline) return (0, rxjs.of)(false).pipe((0, rxjs.takeUntil)(this._destroyed$));
8460
+ return this.publicCachedObservable("localSpeaking$", () => pipeline.speaking$.pipe((0, rxjs.takeUntil)(this._destroyed$), (0, rxjs.share)()));
8458
8461
  }
8459
8462
  /**
8460
8463
  * Enable push-to-talk: while {@link setPushToTalkActive} has been called
@@ -8517,12 +8520,14 @@ var WebRTCCall = class extends Destroyable {
8517
8520
  * caller's audio element playback.
8518
8521
  */
8519
8522
  get remoteAudioLevel$() {
8520
- this._remoteAudioMeter ??= new RemoteAudioMeter();
8521
- const meter = this._remoteAudioMeter;
8522
- this.subscribeTo(this.vertoManager.remoteStream$, (stream) => {
8523
- meter.setStream(stream);
8523
+ return this.publicCachedObservable("remoteAudioLevel$", () => {
8524
+ this._remoteAudioMeter ??= new RemoteAudioMeter();
8525
+ const meter = this._remoteAudioMeter;
8526
+ this.subscribeTo(this.vertoManager.remoteStream$, (stream) => {
8527
+ meter.setStream(stream);
8528
+ });
8529
+ return meter.level$.pipe((0, rxjs.takeUntil)(this._destroyed$), (0, rxjs.share)());
8524
8530
  });
8525
- return meter.level$.pipe((0, rxjs.takeUntil)(this._destroyed$));
8526
8531
  }
8527
8532
  /** Destroys the call, releasing all resources and subscriptions. */
8528
8533
  destroy() {
@@ -9968,8 +9973,8 @@ const isEmptyArray = (a) => {
9968
9973
  };
9969
9974
 
9970
9975
  //#endregion
9971
- //#region src/utils/warnup.ts
9972
- const warnup = (observable) => {
9976
+ //#region src/utils/warmup.ts
9977
+ const warmup = (observable) => {
9973
9978
  observable.pipe((0, rxjs.take)(1)).subscribe();
9974
9979
  };
9975
9980
 
@@ -10017,7 +10022,7 @@ var DirectoryManager = class extends Destroyable {
10017
10022
  return address;
10018
10023
  }));
10019
10024
  if (observable) {
10020
- warnup(observable);
10025
+ warmup(observable);
10021
10026
  this._observableRegistry.set(id, observable);
10022
10027
  }
10023
10028
  this._addressesInstances.set(id, address);