@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.
@@ -14254,6 +14254,8 @@ var SelfParticipant = class extends Participant {
14254
14254
  *
14255
14255
  * The call is unaffected when acquisition fails.
14256
14256
  *
14257
+ * @param options - Pass `{ audio: true }` to also request the shared
14258
+ * surface's audio. Defaults to video only.
14257
14259
  * @throws {ScreenShareAlreadyActiveError} When this call is already
14258
14260
  * sharing a screen. Call {@link stopScreenShare} before starting another.
14259
14261
  * @throws {AuxiliaryLegCancelledError} When {@link stopScreenShare} removes
@@ -14262,9 +14264,9 @@ var SelfParticipant = class extends Participant {
14262
14264
  * permission denial rejects with a `NotAllowedError` `DOMException` —
14263
14265
  * inspect `error.name` to tell benign cancels apart from real failures.
14264
14266
  */
14265
- async startScreenShare() {
14267
+ async startScreenShare(options) {
14266
14268
  try {
14267
- await this.vertoManager.addScreenMedia();
14269
+ await this.vertoManager.addScreenMedia(options);
14268
14270
  } catch (error) {
14269
14271
  if (error instanceof AuxiliaryLegCancelledError) logger$25.debug("[Participant.startScreenShare] Screen share cancelled before connecting.");
14270
14272
  else logger$25.error("[Participant.startScreenShare] Screen share error:", error);
@@ -15614,10 +15616,11 @@ var LocalStreamController = class extends Destroyable {
15614
15616
  stream = new MediaStream(tracks);
15615
15617
  this.tagTracks(tracks, "application");
15616
15618
  } else if (this.options.propose === "screenshare") {
15617
- logger$19.debug("[LocalStreamController] Requesting display media for screen sharing with audio:", Boolean(this.options.inputAudioDeviceConstraints));
15619
+ const audio = this.options.screenShareAudio ?? false;
15620
+ logger$19.debug("[LocalStreamController] Requesting display media for screen sharing with audio:", audio);
15618
15621
  stream = await this.options.getDisplayMedia({
15619
15622
  video: true,
15620
- audio: Boolean(this.options.inputAudioDeviceConstraints)
15623
+ audio
15621
15624
  });
15622
15625
  logger$19.debug("[LocalStreamController] Screen share media obtained:", stream);
15623
15626
  this.tagTracks(stream.getTracks(), "display");
@@ -16089,6 +16092,7 @@ var RTCPeerConnectionController = class extends Destroyable {
16089
16092
  };
16090
16093
  this._isNegotiating$ = this.createBehaviorSubject(false);
16091
16094
  this._memberId = null;
16095
+ this._nodeId = null;
16092
16096
  this._iceConnectionState$ = this.createReplaySubject(1);
16093
16097
  this._connectionState$ = this.createReplaySubject(1);
16094
16098
  this._signalingState$ = this.createReplaySubject(1);
@@ -16128,6 +16132,7 @@ var RTCPeerConnectionController = class extends Destroyable {
16128
16132
  inputVideoStream: this.options.inputVideoStream,
16129
16133
  inputAudioDeviceConstraints: this.inputAudioDeviceConstraints,
16130
16134
  inputVideoDeviceConstraints: this.inputVideoDeviceConstraints,
16135
+ screenShareAudio: this.options.screenShareAudio,
16131
16136
  getUserMedia: async (constraints) => this.getUserMedia(constraints),
16132
16137
  getDisplayMedia: async (options$1) => this.getDisplayMedia(options$1)
16133
16138
  });
@@ -16154,6 +16159,13 @@ var RTCPeerConnectionController = class extends Destroyable {
16154
16159
  get memberId() {
16155
16160
  return this._memberId;
16156
16161
  }
16162
+ /** The node this leg's invite landed on — auxiliary legs are placed independently. */
16163
+ setNodeId(nodeId) {
16164
+ this._nodeId = nodeId;
16165
+ }
16166
+ get nodeId() {
16167
+ return this._nodeId;
16168
+ }
16157
16169
  stopTrackSender(kind, options = { updateTransceiverDirection: false }) {
16158
16170
  const audioCovered = kind === "audio" || kind === "both";
16159
16171
  if (audioCovered && this._localAudioPipeline) this.stopRawAudioInputForPipeline();
@@ -17305,8 +17317,8 @@ var WebRTCVertoManager = class extends VertoManager {
17305
17317
  * these identifiers before the `verto.invite` RPC response (`CALL CREATED`)
17306
17318
  * arrives. These methods let early events populate them eagerly so that
17307
17319
  * downstream RPC calls (e.g. `call.layout.list`) don't fail with empty
17308
- * identifiers. `processInviteResponse()` remains the authoritative source
17309
- * and always overwrites unconditionally.
17320
+ * identifiers. `processInviteResponse()` remains the authoritative source and
17321
+ * overwrites unconditionally — for selfId, on the main leg only.
17310
17322
  */
17311
17323
  setNodeIdIfNull(nodeId) {
17312
17324
  if (!this._nodeId$.value && nodeId) {
@@ -17344,9 +17356,9 @@ var WebRTCVertoManager = class extends VertoManager {
17344
17356
  return this._selfId$.value;
17345
17357
  }
17346
17358
  /** Build an AttachableCall from the current call state. */
17347
- buildAttachableCall(idOverride) {
17359
+ buildAttachableCall(idOverride, nodeIdOverride) {
17348
17360
  return {
17349
- nodeId: this.nodeId ?? void 0,
17361
+ nodeId: nodeIdOverride ?? this.nodeId ?? void 0,
17350
17362
  id: idOverride ?? this.webRtcCallSession.id,
17351
17363
  to: this.webRtcCallSession.to,
17352
17364
  mediaDirections: this.webRtcCallSession.mediaDirections
@@ -17579,7 +17591,7 @@ var WebRTCVertoManager = class extends VertoManager {
17579
17591
  processInviteResponse(response, rtcPeerConnController) {
17580
17592
  if (!response.error && getValueFrom(response, "result.result.result.message") === "CALL CREATED") {
17581
17593
  this.emitMainSignalingStatus(rtcPeerConnController.id, "trying");
17582
- this._nodeId$.next(getValueFrom(response, "result.node_id") ?? null);
17594
+ const nodeId = getValueFrom(response, "result.node_id") ?? null;
17583
17595
  const memberId = getValueFrom(response, "result.result.result.memberID") ?? null;
17584
17596
  const callId = getValueFrom(response, "result.result.result.callID") ?? null;
17585
17597
  logger$16.debug("[WebRTCManager] Verto invite response:", {
@@ -17587,11 +17599,15 @@ var WebRTCVertoManager = class extends VertoManager {
17587
17599
  memberId,
17588
17600
  response
17589
17601
  });
17590
- this._selfId$.next(memberId);
17591
17602
  rtcPeerConnController.setMemberId(memberId);
17603
+ rtcPeerConnController.setNodeId(nodeId);
17604
+ if (rtcPeerConnController.isMainDevice) {
17605
+ this._selfId$.next(memberId);
17606
+ this._nodeId$.next(nodeId);
17607
+ }
17592
17608
  if (callId) {
17593
17609
  this.webRtcCallSession.addCallId(callId);
17594
- this.attachManager.attach(this.buildAttachableCall(callId));
17610
+ this.attachManager.attach(this.buildAttachableCall(callId, nodeId ?? void 0));
17595
17611
  } else logger$16.warn("[WebRTCManager] Cannot attach call, missing callId:", {
17596
17612
  nodeId: this.nodeId,
17597
17613
  callId
@@ -17741,7 +17757,7 @@ var WebRTCVertoManager = class extends VertoManager {
17741
17757
  isInvite: isVertoInviteMessage(vertoMessage),
17742
17758
  reattach: this.webRtcCallSession.options.reattach === true,
17743
17759
  explicitNodeId: this.webRtcCallSession.options.nodeId,
17744
- currentNodeId: this._nodeId$.value
17760
+ currentNodeId: rtcPeerConnController.nodeId ?? this._nodeId$.value
17745
17761
  }),
17746
17762
  subscribe
17747
17763
  };
@@ -17849,8 +17865,11 @@ var WebRTCVertoManager = class extends VertoManager {
17849
17865
  throw error;
17850
17866
  }
17851
17867
  }
17852
- async addScreenMedia(options = { audio: false }) {
17853
- await this.initAdditionalPeerConnection("screenshare", options);
17868
+ async addScreenMedia(options = {}) {
17869
+ await this.initAdditionalPeerConnection("screenshare", {
17870
+ audio: false,
17871
+ screenShareAudio: options.audio ?? false
17872
+ });
17854
17873
  }
17855
17874
  async initAdditionalPeerConnection(propose, options) {
17856
17875
  const isScreenShare = propose === "screenshare";
@@ -17953,7 +17972,10 @@ var WebRTCVertoManager = class extends VertoManager {
17953
17972
  await this.executeVerto(VertoBye({
17954
17973
  ...causeParams,
17955
17974
  dialogParams: this.dialogParams(rtcPeerConnController)
17956
- }), { callID: rtcPeerConnController.id });
17975
+ }), {
17976
+ callID: rtcPeerConnController.id,
17977
+ node_id: rtcPeerConnController.nodeId ?? void 0
17978
+ });
17957
17979
  } catch (error) {
17958
17980
  logger$16.warn("[WebRTCManager] Call might already be disconnected, error sending Verto bye:", error);
17959
17981
  throw error;