@signalwire/js 4.0.0-dev-20260911173516 → 4.0.0-dev-20260911195739

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
@@ -14248,6 +14248,8 @@ var SelfParticipant = class extends Participant {
14248
14248
  *
14249
14249
  * The call is unaffected when acquisition fails.
14250
14250
  *
14251
+ * @param options - Pass `{ audio: true }` to also request the shared
14252
+ * surface's audio. Defaults to video only.
14251
14253
  * @throws {ScreenShareAlreadyActiveError} When this call is already
14252
14254
  * sharing a screen. Call {@link stopScreenShare} before starting another.
14253
14255
  * @throws {AuxiliaryLegCancelledError} When {@link stopScreenShare} removes
@@ -14256,9 +14258,9 @@ var SelfParticipant = class extends Participant {
14256
14258
  * permission denial rejects with a `NotAllowedError` `DOMException` —
14257
14259
  * inspect `error.name` to tell benign cancels apart from real failures.
14258
14260
  */
14259
- async startScreenShare() {
14261
+ async startScreenShare(options) {
14260
14262
  try {
14261
- await this.vertoManager.addScreenMedia();
14263
+ await this.vertoManager.addScreenMedia(options);
14262
14264
  } catch (error) {
14263
14265
  if (error instanceof AuxiliaryLegCancelledError) logger$25.debug("[Participant.startScreenShare] Screen share cancelled before connecting.");
14264
14266
  else logger$25.error("[Participant.startScreenShare] Screen share error:", error);
@@ -15608,10 +15610,11 @@ var LocalStreamController = class extends Destroyable {
15608
15610
  stream = new MediaStream(tracks);
15609
15611
  this.tagTracks(tracks, "application");
15610
15612
  } else if (this.options.propose === "screenshare") {
15611
- logger$19.debug("[LocalStreamController] Requesting display media for screen sharing with audio:", Boolean(this.options.inputAudioDeviceConstraints));
15613
+ const audio = this.options.screenShareAudio ?? false;
15614
+ logger$19.debug("[LocalStreamController] Requesting display media for screen sharing with audio:", audio);
15612
15615
  stream = await this.options.getDisplayMedia({
15613
15616
  video: true,
15614
- audio: Boolean(this.options.inputAudioDeviceConstraints)
15617
+ audio
15615
15618
  });
15616
15619
  logger$19.debug("[LocalStreamController] Screen share media obtained:", stream);
15617
15620
  this.tagTracks(stream.getTracks(), "display");
@@ -16083,6 +16086,7 @@ var RTCPeerConnectionController = class extends Destroyable {
16083
16086
  };
16084
16087
  this._isNegotiating$ = this.createBehaviorSubject(false);
16085
16088
  this._memberId = null;
16089
+ this._nodeId = null;
16086
16090
  this._iceConnectionState$ = this.createReplaySubject(1);
16087
16091
  this._connectionState$ = this.createReplaySubject(1);
16088
16092
  this._signalingState$ = this.createReplaySubject(1);
@@ -16122,6 +16126,7 @@ var RTCPeerConnectionController = class extends Destroyable {
16122
16126
  inputVideoStream: this.options.inputVideoStream,
16123
16127
  inputAudioDeviceConstraints: this.inputAudioDeviceConstraints,
16124
16128
  inputVideoDeviceConstraints: this.inputVideoDeviceConstraints,
16129
+ screenShareAudio: this.options.screenShareAudio,
16125
16130
  getUserMedia: async (constraints) => this.getUserMedia(constraints),
16126
16131
  getDisplayMedia: async (options$1) => this.getDisplayMedia(options$1)
16127
16132
  });
@@ -16148,6 +16153,13 @@ var RTCPeerConnectionController = class extends Destroyable {
16148
16153
  get memberId() {
16149
16154
  return this._memberId;
16150
16155
  }
16156
+ /** The node this leg's invite landed on — auxiliary legs are placed independently. */
16157
+ setNodeId(nodeId) {
16158
+ this._nodeId = nodeId;
16159
+ }
16160
+ get nodeId() {
16161
+ return this._nodeId;
16162
+ }
16151
16163
  stopTrackSender(kind, options = { updateTransceiverDirection: false }) {
16152
16164
  const audioCovered = kind === "audio" || kind === "both";
16153
16165
  if (audioCovered && this._localAudioPipeline) this.stopRawAudioInputForPipeline();
@@ -17299,8 +17311,8 @@ var WebRTCVertoManager = class extends VertoManager {
17299
17311
  * these identifiers before the `verto.invite` RPC response (`CALL CREATED`)
17300
17312
  * arrives. These methods let early events populate them eagerly so that
17301
17313
  * downstream RPC calls (e.g. `call.layout.list`) don't fail with empty
17302
- * identifiers. `processInviteResponse()` remains the authoritative source
17303
- * and always overwrites unconditionally.
17314
+ * identifiers. `processInviteResponse()` remains the authoritative source and
17315
+ * overwrites unconditionally — for selfId, on the main leg only.
17304
17316
  */
17305
17317
  setNodeIdIfNull(nodeId) {
17306
17318
  if (!this._nodeId$.value && nodeId) {
@@ -17338,9 +17350,9 @@ var WebRTCVertoManager = class extends VertoManager {
17338
17350
  return this._selfId$.value;
17339
17351
  }
17340
17352
  /** Build an AttachableCall from the current call state. */
17341
- buildAttachableCall(idOverride) {
17353
+ buildAttachableCall(idOverride, nodeIdOverride) {
17342
17354
  return {
17343
- nodeId: this.nodeId ?? void 0,
17355
+ nodeId: nodeIdOverride ?? this.nodeId ?? void 0,
17344
17356
  id: idOverride ?? this.webRtcCallSession.id,
17345
17357
  to: this.webRtcCallSession.to,
17346
17358
  mediaDirections: this.webRtcCallSession.mediaDirections
@@ -17573,7 +17585,7 @@ var WebRTCVertoManager = class extends VertoManager {
17573
17585
  processInviteResponse(response, rtcPeerConnController) {
17574
17586
  if (!response.error && getValueFrom(response, "result.result.result.message") === "CALL CREATED") {
17575
17587
  this.emitMainSignalingStatus(rtcPeerConnController.id, "trying");
17576
- this._nodeId$.next(getValueFrom(response, "result.node_id") ?? null);
17588
+ const nodeId = getValueFrom(response, "result.node_id") ?? null;
17577
17589
  const memberId = getValueFrom(response, "result.result.result.memberID") ?? null;
17578
17590
  const callId = getValueFrom(response, "result.result.result.callID") ?? null;
17579
17591
  logger$16.debug("[WebRTCManager] Verto invite response:", {
@@ -17581,11 +17593,15 @@ var WebRTCVertoManager = class extends VertoManager {
17581
17593
  memberId,
17582
17594
  response
17583
17595
  });
17584
- this._selfId$.next(memberId);
17585
17596
  rtcPeerConnController.setMemberId(memberId);
17597
+ rtcPeerConnController.setNodeId(nodeId);
17598
+ if (rtcPeerConnController.isMainDevice) {
17599
+ this._selfId$.next(memberId);
17600
+ this._nodeId$.next(nodeId);
17601
+ }
17586
17602
  if (callId) {
17587
17603
  this.webRtcCallSession.addCallId(callId);
17588
- this.attachManager.attach(this.buildAttachableCall(callId));
17604
+ this.attachManager.attach(this.buildAttachableCall(callId, nodeId ?? void 0));
17589
17605
  } else logger$16.warn("[WebRTCManager] Cannot attach call, missing callId:", {
17590
17606
  nodeId: this.nodeId,
17591
17607
  callId
@@ -17735,7 +17751,7 @@ var WebRTCVertoManager = class extends VertoManager {
17735
17751
  isInvite: isVertoInviteMessage(vertoMessage),
17736
17752
  reattach: this.webRtcCallSession.options.reattach === true,
17737
17753
  explicitNodeId: this.webRtcCallSession.options.nodeId,
17738
- currentNodeId: this._nodeId$.value
17754
+ currentNodeId: rtcPeerConnController.nodeId ?? this._nodeId$.value
17739
17755
  }),
17740
17756
  subscribe
17741
17757
  };
@@ -17843,8 +17859,11 @@ var WebRTCVertoManager = class extends VertoManager {
17843
17859
  throw error;
17844
17860
  }
17845
17861
  }
17846
- async addScreenMedia(options = { audio: false }) {
17847
- await this.initAdditionalPeerConnection("screenshare", options);
17862
+ async addScreenMedia(options = {}) {
17863
+ await this.initAdditionalPeerConnection("screenshare", {
17864
+ audio: false,
17865
+ screenShareAudio: options.audio ?? false
17866
+ });
17848
17867
  }
17849
17868
  async initAdditionalPeerConnection(propose, options) {
17850
17869
  const isScreenShare = propose === "screenshare";
@@ -17947,7 +17966,10 @@ var WebRTCVertoManager = class extends VertoManager {
17947
17966
  await this.executeVerto(VertoBye({
17948
17967
  ...causeParams,
17949
17968
  dialogParams: this.dialogParams(rtcPeerConnController)
17950
- }), { callID: rtcPeerConnController.id });
17969
+ }), {
17970
+ callID: rtcPeerConnController.id,
17971
+ node_id: rtcPeerConnController.nodeId ?? void 0
17972
+ });
17951
17973
  } catch (error) {
17952
17974
  logger$16.warn("[WebRTCManager] Call might already be disconnected, error sending Verto bye:", error);
17953
17975
  throw error;