@signalwire/js 4.0.0-dev-20260915014810 → 4.0.0-dev-20260915175740

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.
@@ -12542,8 +12542,36 @@ var AttachManager = class {
12542
12542
  logger$26.warn("[AttachManager] Skip attach for calls with no destination");
12543
12543
  return;
12544
12544
  }
12545
+ const attachment = this.buildAttachment(call, call.to);
12546
+ await this.mutate((attached) => ({
12547
+ ...attached,
12548
+ [call.id]: attachment
12549
+ }));
12550
+ }
12551
+ /**
12552
+ * Keep an already-stored call's reference alive and current — the periodic
12553
+ * refresh the `verto.ping` keepalive drives.
12554
+ *
12555
+ * Only ever updates: a call with no record is one nothing wants reattached,
12556
+ * and re-creating it here would undo a `detach`. That matters because a ping
12557
+ * can land in the window between `bye()` detaching and the call being torn
12558
+ * down, and a record revived there survives the hangup — so the next page
12559
+ * load dials a call nobody is on. The existence check and the write share
12560
+ * one {@link mutate} turn, so a concurrent detach cannot slip between them.
12561
+ */
12562
+ async refresh(call) {
12563
+ if (!call.to) return;
12545
12564
  const destination = call.to;
12546
- const attachment = {
12565
+ await this.mutate((attached) => {
12566
+ if (!Object.hasOwn(attached, call.id)) return attached;
12567
+ return {
12568
+ ...attached,
12569
+ [call.id]: this.buildAttachment(call, destination)
12570
+ };
12571
+ });
12572
+ }
12573
+ buildAttachment(call, destination) {
12574
+ return {
12547
12575
  nodeId: call.nodeId,
12548
12576
  destination,
12549
12577
  mediaDirections: call.mediaDirections,
@@ -12551,10 +12579,6 @@ var AttachManager = class {
12551
12579
  videoInputDevice: call.mediaDirections.video !== "inactive" ? this.deviceController.selectedVideoInputDevice : null,
12552
12580
  attachedAt: Date.now()
12553
12581
  };
12554
- await this.mutate((attached) => ({
12555
- ...attached,
12556
- [call.id]: attachment
12557
- }));
12558
12582
  }
12559
12583
  async detach(call) {
12560
12584
  await this.mutate((attached) => {
@@ -14342,22 +14366,31 @@ var SelfParticipant = class extends Participant {
14342
14366
  this.deviceController.selectAudioInputDevice(device);
14343
14367
  if (options.savePreference) PreferencesContainer.instance.preferredAudioInput = device;
14344
14368
  }
14345
- /** Updates the audio input track constraints for the active call. */
14369
+ /**
14370
+ * Updates the audio input track constraints for the active call.
14371
+ * @returns whether the constraints reached the media the call is sending.
14372
+ */
14346
14373
  async setAudioInputDeviceConstraints(constraints) {
14347
- await this.vertoManager.updateMediaConstraints({ audio: constraints });
14374
+ return this.vertoManager.updateMediaConstraints({ audio: constraints });
14348
14375
  }
14349
- /** Updates both audio and video input track constraints for the active call. */
14376
+ /**
14377
+ * Updates both audio and video input track constraints for the active call.
14378
+ * @returns whether both kinds took the constraints.
14379
+ */
14350
14380
  async setInputDevicesConstraints(constraints) {
14351
- await this.vertoManager.updateMediaConstraints(constraints);
14381
+ return this.vertoManager.updateMediaConstraints(constraints);
14352
14382
  }
14353
14383
  /** Selects the video input device for future calls. Optionally saves as a preference. */
14354
14384
  selectVideoInputDevice(device, options = {}) {
14355
14385
  this.deviceController.selectVideoInputDevice(device);
14356
14386
  if (options.savePreference) PreferencesContainer.instance.preferredVideoInput = device;
14357
14387
  }
14358
- /** Updates the video input track constraints for the active call. */
14388
+ /**
14389
+ * Updates the video input track constraints for the active call.
14390
+ * @returns whether the constraints reached the media the call is sending.
14391
+ */
14359
14392
  async setVideoInputDeviceConstraints(constraints) {
14360
- await this.vertoManager.updateMediaConstraints({ video: constraints });
14393
+ return this.vertoManager.updateMediaConstraints({ video: constraints });
14361
14394
  }
14362
14395
  /** Selects the audio output device. Optionally saves as a preference. */
14363
14396
  selectAudioOutputDevice(device, options = {}) {
@@ -17295,7 +17328,7 @@ var WebRTCVertoManager = class extends VertoManager {
17295
17328
  this.applyServerMediaParams(rtcPeerConnController, audio, video);
17296
17329
  });
17297
17330
  this.subscribeTo(this.vertoPing$, (vertoPing) => {
17298
- this.attachManager.attach(this.buildAttachableCall());
17331
+ this.attachManager.refresh(this.buildAttachableCall());
17299
17332
  this.sendVertoPong(vertoPing);
17300
17333
  });
17301
17334
  }
@@ -17399,16 +17432,25 @@ var WebRTCVertoManager = class extends VertoManager {
17399
17432
  this.onError?.(new VertoPongError(error));
17400
17433
  }
17401
17434
  }
17435
+ /**
17436
+ * @returns whether the constraints reached the media the call is sending.
17437
+ * `false` is an outcome, not a failure: the leg may have no live sender of
17438
+ * the kind, or carry media the SDK did not capture and may not replace.
17439
+ * A failure behind it still reaches the call's `errors$`, so a caller that
17440
+ * ignores this value learns of it there.
17441
+ */
17402
17442
  async updateMediaConstraints(options = {}) {
17403
17443
  const { audio, video } = options;
17444
+ let applied = true;
17404
17445
  try {
17405
- if (audio) await this.mainPeerConnection.updateSendersConstraints("audio", audio);
17406
- if (video) await this.mainPeerConnection.updateSendersConstraints("video", video);
17446
+ if (audio) applied = await this.mainPeerConnection.updateSendersConstraints("audio", audio) && applied;
17447
+ if (video) applied = await this.mainPeerConnection.updateSendersConstraints("video", video) && applied;
17407
17448
  } catch (error) {
17408
17449
  logger$16.warn("[WebRTCManager] Error updating media constraints:", error);
17409
17450
  this.reportLegError(toError(error), this.mainPeerConnection);
17410
17451
  throw error;
17411
17452
  }
17453
+ return applied;
17412
17454
  }
17413
17455
  get selfId() {
17414
17456
  return this._selfId$.value;
@@ -17648,7 +17690,7 @@ var WebRTCVertoManager = class extends VertoManager {
17648
17690
  this.emitMainSignalingStatus(rtcPeerConnController.id, "trying");
17649
17691
  const nodeId = getValueFrom(response, "result.node_id") ?? null;
17650
17692
  const memberId = getValueFrom(response, "result.result.result.memberID") ?? null;
17651
- const callId = getValueFrom(response, "result.result.result.callID") ?? null;
17693
+ const callId = getValueFrom(response, "result.result.result.callID");
17652
17694
  logger$16.debug("[WebRTCManager] Verto invite response:", {
17653
17695
  callId,
17654
17696
  memberId,
@@ -17659,14 +17701,9 @@ var WebRTCVertoManager = class extends VertoManager {
17659
17701
  if (rtcPeerConnController.isMainDevice) {
17660
17702
  this._selfId$.next(memberId);
17661
17703
  this._nodeId$.next(nodeId);
17662
- }
17663
- if (callId) {
17664
- this.webRtcCallSession.addCallId(callId);
17665
17704
  this.attachManager.attach(this.buildAttachableCall(callId, nodeId ?? void 0));
17666
- } else logger$16.warn("[WebRTCManager] Cannot attach call, missing callId:", {
17667
- nodeId: this.nodeId,
17668
- callId
17669
- });
17705
+ }
17706
+ if (callId) this.webRtcCallSession.addCallId(callId);
17670
17707
  logger$16.info("[WebRTCManager] Verto invite successful");
17671
17708
  logger$16.debug(`[WebRTCManager] nodeid: ${this._nodeId$.value}, selfId: ${this._selfId$.value}`);
17672
17709
  } else {
@@ -19967,17 +20004,28 @@ var WebRTCCall = class extends Destroyable {
19967
20004
  * (notably iOS Safari) fall back to re-acquiring the track with the new
19968
20005
  * constraint set and plumbing the replacement through the local audio
19969
20006
  * pipeline if one is active.
20007
+ *
20008
+ * @returns whether the constraint reached the microphone. `false` is an
20009
+ * outcome rather than an error — a leg sending media the SDK did not capture
20010
+ * is left alone — so a UI that reflects the toggle must read it. Any failure
20011
+ * behind a `false` is also reported on {@link errors$}.
19970
20012
  */
19971
20013
  async setEchoCancellation(enabled) {
19972
- await this.vertoManager.updateMediaConstraints({ audio: { echoCancellation: enabled } });
20014
+ return this.vertoManager.updateMediaConstraints({ audio: { echoCancellation: enabled } });
19973
20015
  }
19974
- /** Toggle browser noise suppression on the local mic at runtime. */
20016
+ /**
20017
+ * Toggle browser noise suppression on the local mic at runtime.
20018
+ * @returns whether the constraint reached the microphone.
20019
+ */
19975
20020
  async setNoiseSuppression(enabled) {
19976
- await this.vertoManager.updateMediaConstraints({ audio: { noiseSuppression: enabled } });
20021
+ return this.vertoManager.updateMediaConstraints({ audio: { noiseSuppression: enabled } });
19977
20022
  }
19978
- /** Toggle browser automatic gain control on the local mic at runtime. */
20023
+ /**
20024
+ * Toggle browser automatic gain control on the local mic at runtime.
20025
+ * @returns whether the constraint reached the microphone.
20026
+ */
19979
20027
  async setAutoGainControl(enabled) {
19980
- await this.vertoManager.updateMediaConstraints({ audio: { autoGainControl: enabled } });
20028
+ return this.vertoManager.updateMediaConstraints({ audio: { autoGainControl: enabled } });
19981
20029
  }
19982
20030
  /**
19983
20031
  * Observable of the aggregate remote audio level, 0..1 RMS. The server
@@ -23099,7 +23147,7 @@ var SignalWire = class extends Destroyable {
23099
23147
  logger$1.warn("[SignalWire] Failed to initialize VisibilityController:", error);
23100
23148
  }
23101
23149
  try {
23102
- this._diagnosticsCollector = new DiagnosticsCollector({ sdkVersion: "4.0.0-dev-20260915014810" });
23150
+ this._diagnosticsCollector = new DiagnosticsCollector({ sdkVersion: "4.0.0-dev-20260915175740" });
23103
23151
  } catch (error) {
23104
23152
  logger$1.warn("[SignalWire] Failed to initialize DiagnosticsCollector:", error);
23105
23153
  }
@@ -23654,7 +23702,7 @@ var StaticCredentialProvider = class {
23654
23702
  /**
23655
23703
  * Library version from package.json, injected at build time.
23656
23704
  */
23657
- const version = "4.0.0-dev-20260915014810";
23705
+ const version = "4.0.0-dev-20260915175740";
23658
23706
  /**
23659
23707
  * Flag indicating the library has been loaded and is ready to use.
23660
23708
  * For UMD builds: `window.SignalWire.ready`
@@ -23676,7 +23724,7 @@ const ready = true;
23676
23724
  */
23677
23725
  const emitReadyEvent = () => {
23678
23726
  if (typeof window !== "undefined") {
23679
- const event = new CustomEvent("signalwire:js:ready", { detail: { version: "4.0.0-dev-20260915014810" } });
23727
+ const event = new CustomEvent("signalwire:js:ready", { detail: { version: "4.0.0-dev-20260915175740" } });
23680
23728
  window.dispatchEvent(event);
23681
23729
  }
23682
23730
  };