@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/index.cjs CHANGED
@@ -3637,6 +3637,8 @@ var SelfParticipant = class extends Participant {
3637
3637
  *
3638
3638
  * The call is unaffected when acquisition fails.
3639
3639
  *
3640
+ * @param options - Pass `{ audio: true }` to also request the shared
3641
+ * surface's audio. Defaults to video only.
3640
3642
  * @throws {ScreenShareAlreadyActiveError} When this call is already
3641
3643
  * sharing a screen. Call {@link stopScreenShare} before starting another.
3642
3644
  * @throws {AuxiliaryLegCancelledError} When {@link stopScreenShare} removes
@@ -3645,9 +3647,9 @@ var SelfParticipant = class extends Participant {
3645
3647
  * permission denial rejects with a `NotAllowedError` `DOMException` —
3646
3648
  * inspect `error.name` to tell benign cancels apart from real failures.
3647
3649
  */
3648
- async startScreenShare() {
3650
+ async startScreenShare(options) {
3649
3651
  try {
3650
- await this.vertoManager.addScreenMedia();
3652
+ await this.vertoManager.addScreenMedia(options);
3651
3653
  } catch (error) {
3652
3654
  if (error instanceof require_operators.AuxiliaryLegCancelledError) logger$24.debug("[Participant.startScreenShare] Screen share cancelled before connecting.");
3653
3655
  else logger$24.error("[Participant.startScreenShare] Screen share error:", error);
@@ -4860,10 +4862,11 @@ var LocalStreamController = class extends Destroyable {
4860
4862
  stream = new MediaStream(tracks);
4861
4863
  this.tagTracks(tracks, "application");
4862
4864
  } else if (this.options.propose === "screenshare") {
4863
- logger$19.debug("[LocalStreamController] Requesting display media for screen sharing with audio:", Boolean(this.options.inputAudioDeviceConstraints));
4865
+ const audio = this.options.screenShareAudio ?? false;
4866
+ logger$19.debug("[LocalStreamController] Requesting display media for screen sharing with audio:", audio);
4864
4867
  stream = await this.options.getDisplayMedia({
4865
4868
  video: true,
4866
- audio: Boolean(this.options.inputAudioDeviceConstraints)
4869
+ audio
4867
4870
  });
4868
4871
  logger$19.debug("[LocalStreamController] Screen share media obtained:", stream);
4869
4872
  this.tagTracks(stream.getTracks(), "display");
@@ -5334,6 +5337,7 @@ var RTCPeerConnectionController = class extends Destroyable {
5334
5337
  };
5335
5338
  this._isNegotiating$ = this.createBehaviorSubject(false);
5336
5339
  this._memberId = null;
5340
+ this._nodeId = null;
5337
5341
  this._iceConnectionState$ = this.createReplaySubject(1);
5338
5342
  this._connectionState$ = this.createReplaySubject(1);
5339
5343
  this._signalingState$ = this.createReplaySubject(1);
@@ -5373,6 +5377,7 @@ var RTCPeerConnectionController = class extends Destroyable {
5373
5377
  inputVideoStream: this.options.inputVideoStream,
5374
5378
  inputAudioDeviceConstraints: this.inputAudioDeviceConstraints,
5375
5379
  inputVideoDeviceConstraints: this.inputVideoDeviceConstraints,
5380
+ screenShareAudio: this.options.screenShareAudio,
5376
5381
  getUserMedia: async (constraints) => this.getUserMedia(constraints),
5377
5382
  getDisplayMedia: async (options$1) => this.getDisplayMedia(options$1)
5378
5383
  });
@@ -5399,6 +5404,13 @@ var RTCPeerConnectionController = class extends Destroyable {
5399
5404
  get memberId() {
5400
5405
  return this._memberId;
5401
5406
  }
5407
+ /** The node this leg's invite landed on — auxiliary legs are placed independently. */
5408
+ setNodeId(nodeId) {
5409
+ this._nodeId = nodeId;
5410
+ }
5411
+ get nodeId() {
5412
+ return this._nodeId;
5413
+ }
5402
5414
  stopTrackSender(kind, options = { updateTransceiverDirection: false }) {
5403
5415
  const audioCovered = kind === "audio" || kind === "both";
5404
5416
  if (audioCovered && this._localAudioPipeline) this.stopRawAudioInputForPipeline();
@@ -6549,8 +6561,8 @@ var WebRTCVertoManager = class extends VertoManager {
6549
6561
  * these identifiers before the `verto.invite` RPC response (`CALL CREATED`)
6550
6562
  * arrives. These methods let early events populate them eagerly so that
6551
6563
  * downstream RPC calls (e.g. `call.layout.list`) don't fail with empty
6552
- * identifiers. `processInviteResponse()` remains the authoritative source
6553
- * and always overwrites unconditionally.
6564
+ * identifiers. `processInviteResponse()` remains the authoritative source and
6565
+ * overwrites unconditionally — for selfId, on the main leg only.
6554
6566
  */
6555
6567
  setNodeIdIfNull(nodeId) {
6556
6568
  if (!this._nodeId$.value && nodeId) {
@@ -6588,9 +6600,9 @@ var WebRTCVertoManager = class extends VertoManager {
6588
6600
  return this._selfId$.value;
6589
6601
  }
6590
6602
  /** Build an AttachableCall from the current call state. */
6591
- buildAttachableCall(idOverride) {
6603
+ buildAttachableCall(idOverride, nodeIdOverride) {
6592
6604
  return {
6593
- nodeId: this.nodeId ?? void 0,
6605
+ nodeId: nodeIdOverride ?? this.nodeId ?? void 0,
6594
6606
  id: idOverride ?? this.webRtcCallSession.id,
6595
6607
  to: this.webRtcCallSession.to,
6596
6608
  mediaDirections: this.webRtcCallSession.mediaDirections
@@ -6823,7 +6835,7 @@ var WebRTCVertoManager = class extends VertoManager {
6823
6835
  processInviteResponse(response, rtcPeerConnController) {
6824
6836
  if (!response.error && require_operators.getValueFrom(response, "result.result.result.message") === "CALL CREATED") {
6825
6837
  this.emitMainSignalingStatus(rtcPeerConnController.id, "trying");
6826
- this._nodeId$.next(require_operators.getValueFrom(response, "result.node_id") ?? null);
6838
+ const nodeId = require_operators.getValueFrom(response, "result.node_id") ?? null;
6827
6839
  const memberId = require_operators.getValueFrom(response, "result.result.result.memberID") ?? null;
6828
6840
  const callId = require_operators.getValueFrom(response, "result.result.result.callID") ?? null;
6829
6841
  logger$16.debug("[WebRTCManager] Verto invite response:", {
@@ -6831,11 +6843,15 @@ var WebRTCVertoManager = class extends VertoManager {
6831
6843
  memberId,
6832
6844
  response
6833
6845
  });
6834
- this._selfId$.next(memberId);
6835
6846
  rtcPeerConnController.setMemberId(memberId);
6847
+ rtcPeerConnController.setNodeId(nodeId);
6848
+ if (rtcPeerConnController.isMainDevice) {
6849
+ this._selfId$.next(memberId);
6850
+ this._nodeId$.next(nodeId);
6851
+ }
6836
6852
  if (callId) {
6837
6853
  this.webRtcCallSession.addCallId(callId);
6838
- this.attachManager.attach(this.buildAttachableCall(callId));
6854
+ this.attachManager.attach(this.buildAttachableCall(callId, nodeId ?? void 0));
6839
6855
  } else logger$16.warn("[WebRTCManager] Cannot attach call, missing callId:", {
6840
6856
  nodeId: this.nodeId,
6841
6857
  callId
@@ -6985,7 +7001,7 @@ var WebRTCVertoManager = class extends VertoManager {
6985
7001
  isInvite: isVertoInviteMessage(vertoMessage),
6986
7002
  reattach: this.webRtcCallSession.options.reattach === true,
6987
7003
  explicitNodeId: this.webRtcCallSession.options.nodeId,
6988
- currentNodeId: this._nodeId$.value
7004
+ currentNodeId: rtcPeerConnController.nodeId ?? this._nodeId$.value
6989
7005
  }),
6990
7006
  subscribe
6991
7007
  };
@@ -7093,8 +7109,11 @@ var WebRTCVertoManager = class extends VertoManager {
7093
7109
  throw error;
7094
7110
  }
7095
7111
  }
7096
- async addScreenMedia(options = { audio: false }) {
7097
- await this.initAdditionalPeerConnection("screenshare", options);
7112
+ async addScreenMedia(options = {}) {
7113
+ await this.initAdditionalPeerConnection("screenshare", {
7114
+ audio: false,
7115
+ screenShareAudio: options.audio ?? false
7116
+ });
7098
7117
  }
7099
7118
  async initAdditionalPeerConnection(propose, options) {
7100
7119
  const isScreenShare = propose === "screenshare";
@@ -7197,7 +7216,10 @@ var WebRTCVertoManager = class extends VertoManager {
7197
7216
  await this.executeVerto(VertoBye({
7198
7217
  ...causeParams,
7199
7218
  dialogParams: this.dialogParams(rtcPeerConnController)
7200
- }), { callID: rtcPeerConnController.id });
7219
+ }), {
7220
+ callID: rtcPeerConnController.id,
7221
+ node_id: rtcPeerConnController.nodeId ?? void 0
7222
+ });
7201
7223
  } catch (error) {
7202
7224
  logger$16.warn("[WebRTCManager] Call might already be disconnected, error sending Verto bye:", error);
7203
7225
  throw error;