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

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
@@ -9405,6 +9405,20 @@ var AuxiliaryLegTimeoutError = class extends Error {
9405
9405
  this.name = "AuxiliaryLegTimeoutError";
9406
9406
  }
9407
9407
  };
9408
+ /**
9409
+ * An auxiliary leg was removed before it finished connecting.
9410
+ *
9411
+ * Typed rather than a bare resolve so a caller awaiting the start can tell a
9412
+ * cancel apart from a share that actually came up — the public methods return
9413
+ * `void`, so the promise is the only signal they have.
9414
+ */
9415
+ var AuxiliaryLegCancelledError = class extends Error {
9416
+ constructor(leg) {
9417
+ super(`The ${leg} leg was removed before it finished connecting`);
9418
+ this.leg = leg;
9419
+ this.name = "AuxiliaryLegCancelledError";
9420
+ }
9421
+ };
9408
9422
  var MediaTrackError = class extends Error {
9409
9423
  constructor(operation, kind, originalError) {
9410
9424
  super(`Media track ${operation} failed for ${kind}`, { cause: originalError instanceof Error ? originalError : void 0 });
@@ -14234,11 +14248,10 @@ var SelfParticipant = class extends Participant {
14234
14248
  *
14235
14249
  * The call is unaffected when acquisition fails.
14236
14250
  *
14237
- * Known issue: stopping the share before its leg connects can leave this
14238
- * promise pending until the call ends, so do not gate UI on it.
14239
- *
14240
14251
  * @throws {ScreenShareAlreadyActiveError} When this call is already
14241
14252
  * sharing a screen. Call {@link stopScreenShare} before starting another.
14253
+ * @throws {AuxiliaryLegCancelledError} When {@link stopScreenShare} removes
14254
+ * the share before its leg finishes connecting.
14242
14255
  * @throws The raw `getDisplayMedia` error. A dismissed picker or a
14243
14256
  * permission denial rejects with a `NotAllowedError` `DOMException` —
14244
14257
  * inspect `error.name` to tell benign cancels apart from real failures.
@@ -14247,7 +14260,8 @@ var SelfParticipant = class extends Participant {
14247
14260
  try {
14248
14261
  await this.vertoManager.addScreenMedia();
14249
14262
  } catch (error) {
14250
- logger$25.error("[Participant.startScreenShare] Screen share error:", error);
14263
+ if (error instanceof AuxiliaryLegCancelledError) logger$25.debug("[Participant.startScreenShare] Screen share cancelled before connecting.");
14264
+ else logger$25.error("[Participant.startScreenShare] Screen share error:", error);
14251
14265
  throw error;
14252
14266
  }
14253
14267
  }
@@ -14268,9 +14282,8 @@ var SelfParticipant = class extends Participant {
14268
14282
  *
14269
14283
  * The call is unaffected when acquisition fails.
14270
14284
  *
14271
- * Known issue: removing the device before its leg connects can leave this
14272
- * promise pending until the call ends, so do not gate UI on it.
14273
- *
14285
+ * @throws {AuxiliaryLegCancelledError} When {@link removeAdditionalDevice}
14286
+ * removes the device before its leg finishes connecting.
14274
14287
  * @throws The raw `getUserMedia` error (e.g. `NotAllowedError` on
14275
14288
  * permission denial) — inspect `error.name` to decide how to react — or
14276
14289
  * `AuxiliaryLegTimeoutError` if the leg does not connect in time.
@@ -14279,7 +14292,8 @@ var SelfParticipant = class extends Participant {
14279
14292
  try {
14280
14293
  await this.vertoManager.addInputDevice(options);
14281
14294
  } catch (error) {
14282
- logger$25.error("[Participant.addAdditionalDevice] Additional device error:", error);
14295
+ if (error instanceof AuxiliaryLegCancelledError) logger$25.debug("[Participant.addAdditionalDevice] Device removed before connecting.");
14296
+ else logger$25.error("[Participant.addAdditionalDevice] Additional device error:", error);
14283
14297
  throw error;
14284
14298
  }
14285
14299
  }
@@ -16210,6 +16224,9 @@ var RTCPeerConnectionController = class extends Destroyable {
16210
16224
  get propose() {
16211
16225
  return this.options.propose ?? "main";
16212
16226
  }
16227
+ get connectionState() {
16228
+ return this.peerConnection?.connectionState;
16229
+ }
16213
16230
  get isAdditionalDevice() {
16214
16231
  return this.propose === "additional-device";
16215
16232
  }
@@ -17851,13 +17868,15 @@ var WebRTCVertoManager = class extends VertoManager {
17851
17868
  this.reportLegError(error, rtcPeerConnController);
17852
17869
  });
17853
17870
  const pc = rtcPeerConnController;
17854
- await (0, import_cjs$15.firstValueFrom)((0, import_cjs$15.merge)(pc.localMediaSettled$.pipe((0, import_cjs$15.take)(1), (0, import_cjs$15.switchMap)(() => pc.connectionState$.pipe((0, import_cjs$15.filter)((state) => state === "connected"), (0, import_cjs$15.take)(1), (0, import_cjs$15.timeout)(DEFAULT_AUX_LEG_CONNECT_TIMEOUT_MS)))), this.legError$(pc.id)).pipe((0, import_cjs$15.takeUntil)(this.destroyed$)));
17871
+ await (0, import_cjs$15.firstValueFrom)((0, import_cjs$15.merge)(pc.localMediaSettled$.pipe((0, import_cjs$15.take)(1), (0, import_cjs$15.switchMap)(() => pc.connectionState$.pipe((0, import_cjs$15.filter)((state) => state === "connected"), (0, import_cjs$15.take)(1), (0, import_cjs$15.timeout)(DEFAULT_AUX_LEG_CONNECT_TIMEOUT_MS)))), this.legError$(pc.id)).pipe((0, import_cjs$15.takeUntil)((0, import_cjs$15.merge)(this.destroyed$, pc.destroyed$))));
17855
17872
  if (isScreenShare) this._screenShareStatus$.next("started");
17856
17873
  logger$16.info(`[WebRTCManager] Additional peer connection connected (${propose}).`);
17857
17874
  return rtcPeerConnController.id;
17858
17875
  } catch (error) {
17859
- logger$16.warn("[WebRTCManager] Error initializing additional peer connection:", error);
17860
- if (rtcPeerConnController) {
17876
+ const cancelled = error instanceof AuxiliaryLegCancelledError;
17877
+ const aborted = error instanceof import_cjs$15.EmptyError && !firstPeerConnectionError;
17878
+ if (!cancelled && !aborted) logger$16.warn("[WebRTCManager] Error initializing additional peer connection:", error);
17879
+ if (rtcPeerConnController && this._rtcPeerConnectionsMap.has(rtcPeerConnController.id)) {
17861
17880
  rtcPeerConnController.destroy();
17862
17881
  this._rtcPeerConnectionsMap.delete(rtcPeerConnController.id);
17863
17882
  this._rtcPeerConnections$.next(Array.from(this._rtcPeerConnectionsMap.values()));
@@ -17866,6 +17885,10 @@ var WebRTCVertoManager = class extends VertoManager {
17866
17885
  this._screenShareId = void 0;
17867
17886
  this._screenShareStatus$.next("none");
17868
17887
  }
17888
+ if (cancelled) {
17889
+ logger$16.debug("[WebRTCManager] Additional peer connection removed before connecting.");
17890
+ throw error;
17891
+ }
17869
17892
  if (firstPeerConnectionError) throw firstPeerConnectionError instanceof MediaAccessError && firstPeerConnectionError.originalError instanceof Error ? firstPeerConnectionError.originalError : firstPeerConnectionError;
17870
17893
  if (error instanceof import_cjs$15.EmptyError) {
17871
17894
  logger$16.debug("[WebRTCManager] Additional peer connection aborted before connecting.");
@@ -17906,6 +17929,10 @@ var WebRTCVertoManager = class extends VertoManager {
17906
17929
  try {
17907
17930
  if (rtcPeerConnController) await this.executeVertoBye(rtcPeerConnController);
17908
17931
  } finally {
17932
+ if (rtcPeerConnController && rtcPeerConnController.connectionState !== "connected") this._legErrors$.next({
17933
+ legId: id,
17934
+ error: new AuxiliaryLegCancelledError(rtcPeerConnController.propose)
17935
+ });
17909
17936
  rtcPeerConnController?.destroy();
17910
17937
  this._rtcPeerConnectionsMap.delete(id);
17911
17938
  this._rtcPeerConnections$.next(Array.from(this._rtcPeerConnectionsMap.values()));
@@ -23591,5 +23618,5 @@ emitReadyEvent();
23591
23618
  if (typeof process === "undefined") globalThis.process = { env: { NODE_ENV: "production" } };
23592
23619
 
23593
23620
  //#endregion
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 };
23621
+ export { Address, AuxiliaryLegCancelledError, 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 };
23595
23622
  //# sourceMappingURL=browser.mjs.map