@signalwire/js 4.0.0-dev-20260911135809 → 4.0.0-dev-20260911172704

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
@@ -9441,6 +9441,22 @@ var MediaAccessError = class extends Error {
9441
9441
  return isMediaAccessDenial(this.originalError);
9442
9442
  }
9443
9443
  };
9444
+ /**
9445
+ * Thrown by `startScreenShare()` when the call is already sharing a screen.
9446
+ *
9447
+ * A call carries at most one screen share. Accepting a second one would
9448
+ * overwrite the only reference the SDK holds to the first, leaving it
9449
+ * capturing and sending with no way to stop it — so the second request is
9450
+ * rejected and the live share is left untouched. Call `stopScreenShare()`
9451
+ * first to replace it.
9452
+ */
9453
+ var ScreenShareAlreadyActiveError = class extends Error {
9454
+ constructor(screenShareId, options) {
9455
+ super(`A screen share is already active on this call (${screenShareId}). Call stopScreenShare() before starting another one.`, options);
9456
+ this.screenShareId = screenShareId;
9457
+ this.name = "ScreenShareAlreadyActiveError";
9458
+ }
9459
+ };
9444
9460
  var DPoPInitError = class extends Error {
9445
9461
  constructor(originalError, message = "Failed to initialize DPoP key pair") {
9446
9462
  super(message, { cause: originalError instanceof Error ? originalError : void 0 });
@@ -14213,11 +14229,16 @@ var SelfParticipant = class extends Participant {
14213
14229
  /**
14214
14230
  * Starts sharing the local screen.
14215
14231
  *
14232
+ * A call carries at most one screen share. Read `screenShareStatus` before
14233
+ * calling and treat `'starting'`/`'stopping'` as busy.
14234
+ *
14216
14235
  * The call is unaffected when acquisition fails.
14217
14236
  *
14218
14237
  * Known issue: stopping the share before its leg connects can leave this
14219
14238
  * promise pending until the call ends, so do not gate UI on it.
14220
14239
  *
14240
+ * @throws {ScreenShareAlreadyActiveError} When this call is already
14241
+ * sharing a screen. Call {@link stopScreenShare} before starting another.
14221
14242
  * @throws The raw `getDisplayMedia` error. A dismissed picker or a
14222
14243
  * permission denial rejects with a `NotAllowedError` `DOMException` —
14223
14244
  * inspect `error.name` to tell benign cancels apart from real failures.
@@ -17810,6 +17831,7 @@ var WebRTCVertoManager = class extends VertoManager {
17810
17831
  }
17811
17832
  async initAdditionalPeerConnection(propose, options) {
17812
17833
  const isScreenShare = propose === "screenshare";
17834
+ if (isScreenShare && this._screenShareId && this._rtcPeerConnectionsMap.has(this._screenShareId)) throw new ScreenShareAlreadyActiveError(this._screenShareId);
17813
17835
  let firstPeerConnectionError;
17814
17836
  let rtcPeerConnController = null;
17815
17837
  try {
@@ -17841,8 +17863,8 @@ var WebRTCVertoManager = class extends VertoManager {
17841
17863
  this._rtcPeerConnections$.next(Array.from(this._rtcPeerConnectionsMap.values()));
17842
17864
  }
17843
17865
  if (isScreenShare) {
17844
- this._screenShareStatus$.next("none");
17845
17866
  this._screenShareId = void 0;
17867
+ this._screenShareStatus$.next("none");
17846
17868
  }
17847
17869
  if (firstPeerConnectionError) throw firstPeerConnectionError instanceof MediaAccessError && firstPeerConnectionError.originalError instanceof Error ? firstPeerConnectionError.originalError : firstPeerConnectionError;
17848
17870
  if (error instanceof import_cjs$15.EmptyError) {
@@ -17866,7 +17888,10 @@ var WebRTCVertoManager = class extends VertoManager {
17866
17888
  if (removeTrack) return this.mainPeerConnection.stopTrackSender(removeTrack, { updateTransceiverDirection: true });
17867
17889
  }
17868
17890
  async removeScreenMedia() {
17869
- if (!["starting", "started"].includes(this._screenShareStatus$.value)) logger$16.warn("[WebRTCManager] No active screen share to stop.");
17891
+ if (!["starting", "started"].includes(this._screenShareStatus$.value)) {
17892
+ logger$16.warn("[WebRTCManager] No active screen share to stop.");
17893
+ return;
17894
+ }
17870
17895
  if (!this._screenShareId) {
17871
17896
  logger$16.debug("[WebRTCManager] No screen share peer connection found.");
17872
17897
  return;
@@ -23566,5 +23591,5 @@ emitReadyEvent();
23566
23591
  if (typeof process === "undefined") globalThis.process = { env: { NODE_ENV: "production" } };
23567
23592
 
23568
23593
  //#endregion
23569
- export { Address, AuxiliaryLegTimeoutError, CallCreateError, CallNotReadyError, ClientPreferences, CollectionFetchError, DPoPInitError, DeviceTokenError, EmbedTokenCredentialProvider, InvalidCredentialsError, MediaAccessError, MediaTrackError, MessageParseError, OverconstrainedFallbackError, Participant, ParticipantNotReadyError, PreflightError, RecoveryError, SelfCapabilities, SelfParticipant, SignalWire, StaticCredentialProvider, TokenRefreshError, UnexpectedError, User, VertoPongError, WebRTCCall, embeddableCall, getLogger, isSelfParticipant, ready, setDebugOptions, setLogLevel, setLogger, version };
23594
+ export { Address, AuxiliaryLegTimeoutError, CallCreateError, CallNotReadyError, ClientPreferences, CollectionFetchError, DPoPInitError, DeviceTokenError, EmbedTokenCredentialProvider, InvalidCredentialsError, MediaAccessError, MediaTrackError, MessageParseError, OverconstrainedFallbackError, Participant, ParticipantNotReadyError, PreflightError, RecoveryError, ScreenShareAlreadyActiveError, SelfCapabilities, SelfParticipant, SignalWire, StaticCredentialProvider, TokenRefreshError, UnexpectedError, User, VertoPongError, WebRTCCall, embeddableCall, getLogger, isSelfParticipant, ready, setDebugOptions, setLogLevel, setLogger, version };
23570
23595
  //# sourceMappingURL=browser.mjs.map