@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.
@@ -9548,7 +9548,7 @@ const wsTraffic = (options) => {
9548
9548
  loggerInstance.debug(`[WebSocket] ${options.type.toUpperCase()}: non-JSON message`);
9549
9549
  return;
9550
9550
  }
9551
- else payload = options.payload;
9551
+ else ({payload} = options);
9552
9552
  const msg = shouldStringify(payload) ? JSON.stringify(payload, null, 2) : payload;
9553
9553
  loggerInstance.debug(`${options.type.toUpperCase()}: \n`, msg, "\n");
9554
9554
  };
@@ -12482,9 +12482,9 @@ var AttachManager = class {
12482
12482
  * (e.g. after a reload).
12483
12483
  */
12484
12484
  async consumePendingAttachment(callId) {
12485
- const attachment = (await this.readAttached())[callId];
12486
- if (!attachment) return;
12487
- return this.buildCallOptions(attachment);
12485
+ const attached = await this.readAttached();
12486
+ if (!Object.hasOwn(attached, callId)) return;
12487
+ return this.buildCallOptions(attached[callId]);
12488
12488
  }
12489
12489
  async detachExpired() {
12490
12490
  const now = Date.now();
@@ -16289,10 +16289,9 @@ var RTCPeerConnectionController = class extends Destroyable {
16289
16289
  }
16290
16290
  async applyLocalAudioPipelineToSender() {
16291
16291
  if (!this._localAudioPipeline || !this.peerConnection) return;
16292
- const [raw] = this.localStreamController.localAudioTracks;
16292
+ const raw = this.localStreamController.localAudioTracks.at(0);
16293
16293
  this._localAudioPipeline.setInputTrack(raw ?? null);
16294
- const [audioTransceiver] = this.transceiverController?.audioTransceivers ?? [];
16295
- const sender = audioTransceiver?.sender ?? this.peerConnection.getSenders().find((s) => s.track?.kind === "audio");
16294
+ const sender = (this.transceiverController?.audioTransceivers.at(0))?.sender ?? this.peerConnection.getSenders().find((s) => s.track?.kind === "audio");
16296
16295
  if (!sender || !raw) return;
16297
16296
  try {
16298
16297
  await sender.replaceTrack(this._localAudioPipeline.outputTrack);
@@ -18658,7 +18657,7 @@ var WebRTCCall = class extends Destroyable {
18658
18657
  const pc = this.rtcPeerConnection;
18659
18658
  if (!pc) return false;
18660
18659
  const deadline = Date.now() + PEER_CONNECTION_RECOVERY_WAIT_MS;
18661
- while (true) {
18660
+ for (;;) {
18662
18661
  const state = pc.connectionState;
18663
18662
  if (state === "connected") return true;
18664
18663
  if (state === "failed" || state === "closed") return false;
@@ -18955,7 +18954,7 @@ var WebRTCCall = class extends Destroyable {
18955
18954
  get localMicrophoneGain$() {
18956
18955
  const pipeline = this.vertoManager.ensureLocalAudioPipeline();
18957
18956
  if (!pipeline) return (0, import_cjs$11.of)(100).pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
18958
- return pipeline.gain$.pipe((0, import_cjs$11.map)((multiplier) => multiplier * 100), (0, import_cjs$11.takeUntil)(this._destroyed$));
18957
+ return this.publicCachedObservable("localMicrophoneGain$", () => pipeline.gain$.pipe((0, import_cjs$11.map)((multiplier) => multiplier * 100), (0, import_cjs$11.takeUntil)(this._destroyed$)));
18959
18958
  }
18960
18959
  /**
18961
18960
  * Observable of the RMS audio level of the local microphone, 0..1.
@@ -18963,14 +18962,18 @@ var WebRTCCall = class extends Destroyable {
18963
18962
  * pipeline on first subscription.
18964
18963
  */
18965
18964
  get localAudioLevel$() {
18966
- return this.vertoManager.ensureLocalAudioPipeline()?.level$ ?? (0, import_cjs$11.of)(0).pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
18965
+ const pipeline = this.vertoManager.ensureLocalAudioPipeline();
18966
+ if (!pipeline) return (0, import_cjs$11.of)(0).pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
18967
+ return this.publicCachedObservable("localAudioLevel$", () => pipeline.level$.pipe((0, import_cjs$11.takeUntil)(this._destroyed$), (0, import_cjs$11.share)()));
18967
18968
  }
18968
18969
  /**
18969
18970
  * Observable that is `true` while the local participant is speaking
18970
18971
  * (RMS level above the VAD threshold, with hold time to avoid flicker).
18971
18972
  */
18972
18973
  get localSpeaking$() {
18973
- return this.vertoManager.ensureLocalAudioPipeline()?.speaking$ ?? (0, import_cjs$11.of)(false).pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
18974
+ const pipeline = this.vertoManager.ensureLocalAudioPipeline();
18975
+ if (!pipeline) return (0, import_cjs$11.of)(false).pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
18976
+ return this.publicCachedObservable("localSpeaking$", () => pipeline.speaking$.pipe((0, import_cjs$11.takeUntil)(this._destroyed$), (0, import_cjs$11.share)()));
18974
18977
  }
18975
18978
  /**
18976
18979
  * Enable push-to-talk: while {@link setPushToTalkActive} has been called
@@ -19033,12 +19036,14 @@ var WebRTCCall = class extends Destroyable {
19033
19036
  * caller's audio element playback.
19034
19037
  */
19035
19038
  get remoteAudioLevel$() {
19036
- this._remoteAudioMeter ??= new RemoteAudioMeter();
19037
- const meter = this._remoteAudioMeter;
19038
- this.subscribeTo(this.vertoManager.remoteStream$, (stream) => {
19039
- meter.setStream(stream);
19039
+ return this.publicCachedObservable("remoteAudioLevel$", () => {
19040
+ this._remoteAudioMeter ??= new RemoteAudioMeter();
19041
+ const meter = this._remoteAudioMeter;
19042
+ this.subscribeTo(this.vertoManager.remoteStream$, (stream) => {
19043
+ meter.setStream(stream);
19044
+ });
19045
+ return meter.level$.pipe((0, import_cjs$11.takeUntil)(this._destroyed$), (0, import_cjs$11.share)());
19040
19046
  });
19041
- return meter.level$.pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
19042
19047
  }
19043
19048
  /** Destroys the call, releasing all resources and subscriptions. */
19044
19049
  destroy() {
@@ -20490,9 +20495,9 @@ const isEmptyArray = (a) => {
20490
20495
  };
20491
20496
 
20492
20497
  //#endregion
20493
- //#region src/utils/warnup.ts
20498
+ //#region src/utils/warmup.ts
20494
20499
  var import_cjs$4 = require_cjs();
20495
- const warnup = (observable) => {
20500
+ const warmup = (observable) => {
20496
20501
  observable.pipe((0, import_cjs$4.take)(1)).subscribe();
20497
20502
  };
20498
20503
 
@@ -20541,7 +20546,7 @@ var DirectoryManager = class extends Destroyable {
20541
20546
  return address;
20542
20547
  }));
20543
20548
  if (observable) {
20544
- warnup(observable);
20549
+ warmup(observable);
20545
20550
  this._observableRegistry.set(id, observable);
20546
20551
  }
20547
20552
  this._addressesInstances.set(id, address);