@signalwire/js 4.0.0-dev-20260428062741 → 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/browser.mjs CHANGED
@@ -9544,7 +9544,7 @@ const wsTraffic = (options) => {
9544
9544
  loggerInstance.debug(`[WebSocket] ${options.type.toUpperCase()}: non-JSON message`);
9545
9545
  return;
9546
9546
  }
9547
- else payload = options.payload;
9547
+ else ({payload} = options);
9548
9548
  const msg = shouldStringify(payload) ? JSON.stringify(payload, null, 2) : payload;
9549
9549
  loggerInstance.debug(`${options.type.toUpperCase()}: \n`, msg, "\n");
9550
9550
  };
@@ -12478,9 +12478,9 @@ var AttachManager = class {
12478
12478
  * (e.g. after a reload).
12479
12479
  */
12480
12480
  async consumePendingAttachment(callId) {
12481
- const attachment = (await this.readAttached())[callId];
12482
- if (!attachment) return;
12483
- return this.buildCallOptions(attachment);
12481
+ const attached = await this.readAttached();
12482
+ if (!Object.hasOwn(attached, callId)) return;
12483
+ return this.buildCallOptions(attached[callId]);
12484
12484
  }
12485
12485
  async detachExpired() {
12486
12486
  const now = Date.now();
@@ -16285,10 +16285,9 @@ var RTCPeerConnectionController = class extends Destroyable {
16285
16285
  }
16286
16286
  async applyLocalAudioPipelineToSender() {
16287
16287
  if (!this._localAudioPipeline || !this.peerConnection) return;
16288
- const [raw] = this.localStreamController.localAudioTracks;
16288
+ const raw = this.localStreamController.localAudioTracks.at(0);
16289
16289
  this._localAudioPipeline.setInputTrack(raw ?? null);
16290
- const [audioTransceiver] = this.transceiverController?.audioTransceivers ?? [];
16291
- const sender = audioTransceiver?.sender ?? this.peerConnection.getSenders().find((s) => s.track?.kind === "audio");
16290
+ const sender = (this.transceiverController?.audioTransceivers.at(0))?.sender ?? this.peerConnection.getSenders().find((s) => s.track?.kind === "audio");
16292
16291
  if (!sender || !raw) return;
16293
16292
  try {
16294
16293
  await sender.replaceTrack(this._localAudioPipeline.outputTrack);
@@ -18654,7 +18653,7 @@ var WebRTCCall = class extends Destroyable {
18654
18653
  const pc = this.rtcPeerConnection;
18655
18654
  if (!pc) return false;
18656
18655
  const deadline = Date.now() + PEER_CONNECTION_RECOVERY_WAIT_MS;
18657
- while (true) {
18656
+ for (;;) {
18658
18657
  const state = pc.connectionState;
18659
18658
  if (state === "connected") return true;
18660
18659
  if (state === "failed" || state === "closed") return false;
@@ -18951,7 +18950,7 @@ var WebRTCCall = class extends Destroyable {
18951
18950
  get localMicrophoneGain$() {
18952
18951
  const pipeline = this.vertoManager.ensureLocalAudioPipeline();
18953
18952
  if (!pipeline) return (0, import_cjs$11.of)(100).pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
18954
- return pipeline.gain$.pipe((0, import_cjs$11.map)((multiplier) => multiplier * 100), (0, import_cjs$11.takeUntil)(this._destroyed$));
18953
+ return this.publicCachedObservable("localMicrophoneGain$", () => pipeline.gain$.pipe((0, import_cjs$11.map)((multiplier) => multiplier * 100), (0, import_cjs$11.takeUntil)(this._destroyed$)));
18955
18954
  }
18956
18955
  /**
18957
18956
  * Observable of the RMS audio level of the local microphone, 0..1.
@@ -18959,14 +18958,18 @@ var WebRTCCall = class extends Destroyable {
18959
18958
  * pipeline on first subscription.
18960
18959
  */
18961
18960
  get localAudioLevel$() {
18962
- return this.vertoManager.ensureLocalAudioPipeline()?.level$ ?? (0, import_cjs$11.of)(0).pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
18961
+ const pipeline = this.vertoManager.ensureLocalAudioPipeline();
18962
+ if (!pipeline) return (0, import_cjs$11.of)(0).pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
18963
+ return this.publicCachedObservable("localAudioLevel$", () => pipeline.level$.pipe((0, import_cjs$11.takeUntil)(this._destroyed$), (0, import_cjs$11.share)()));
18963
18964
  }
18964
18965
  /**
18965
18966
  * Observable that is `true` while the local participant is speaking
18966
18967
  * (RMS level above the VAD threshold, with hold time to avoid flicker).
18967
18968
  */
18968
18969
  get localSpeaking$() {
18969
- return this.vertoManager.ensureLocalAudioPipeline()?.speaking$ ?? (0, import_cjs$11.of)(false).pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
18970
+ const pipeline = this.vertoManager.ensureLocalAudioPipeline();
18971
+ if (!pipeline) return (0, import_cjs$11.of)(false).pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
18972
+ return this.publicCachedObservable("localSpeaking$", () => pipeline.speaking$.pipe((0, import_cjs$11.takeUntil)(this._destroyed$), (0, import_cjs$11.share)()));
18970
18973
  }
18971
18974
  /**
18972
18975
  * Enable push-to-talk: while {@link setPushToTalkActive} has been called
@@ -19029,12 +19032,14 @@ var WebRTCCall = class extends Destroyable {
19029
19032
  * caller's audio element playback.
19030
19033
  */
19031
19034
  get remoteAudioLevel$() {
19032
- this._remoteAudioMeter ??= new RemoteAudioMeter();
19033
- const meter = this._remoteAudioMeter;
19034
- this.subscribeTo(this.vertoManager.remoteStream$, (stream) => {
19035
- meter.setStream(stream);
19035
+ return this.publicCachedObservable("remoteAudioLevel$", () => {
19036
+ this._remoteAudioMeter ??= new RemoteAudioMeter();
19037
+ const meter = this._remoteAudioMeter;
19038
+ this.subscribeTo(this.vertoManager.remoteStream$, (stream) => {
19039
+ meter.setStream(stream);
19040
+ });
19041
+ return meter.level$.pipe((0, import_cjs$11.takeUntil)(this._destroyed$), (0, import_cjs$11.share)());
19036
19042
  });
19037
- return meter.level$.pipe((0, import_cjs$11.takeUntil)(this._destroyed$));
19038
19043
  }
19039
19044
  /** Destroys the call, releasing all resources and subscriptions. */
19040
19045
  destroy() {
@@ -20486,9 +20491,9 @@ const isEmptyArray = (a) => {
20486
20491
  };
20487
20492
 
20488
20493
  //#endregion
20489
- //#region src/utils/warnup.ts
20494
+ //#region src/utils/warmup.ts
20490
20495
  var import_cjs$4 = require_cjs();
20491
- const warnup = (observable) => {
20496
+ const warmup = (observable) => {
20492
20497
  observable.pipe((0, import_cjs$4.take)(1)).subscribe();
20493
20498
  };
20494
20499
 
@@ -20537,7 +20542,7 @@ var DirectoryManager = class extends Destroyable {
20537
20542
  return address;
20538
20543
  }));
20539
20544
  if (observable) {
20540
- warnup(observable);
20545
+ warmup(observable);
20541
20546
  this._observableRegistry.set(id, observable);
20542
20547
  }
20543
20548
  this._addressesInstances.set(id, address);