@signalwire/js 4.0.0-dev-20260304121917 → 4.0.0-dev-20260304174504

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
@@ -13847,7 +13847,10 @@ function isVertoAttachMessage(value) {
13847
13847
  return value.method === "verto.attach";
13848
13848
  }
13849
13849
  function isVertoAnswerInnerParams(value) {
13850
- return isObject(value) && hasProperty(value, "jsonrpc") && value.jsonrpc === "2.0" && hasProperty(value, "method") && value.method === "verto.answer" && isObject(value.params) && hasProperty(value.params, "callID") && hasProperty(value.params, "sdp");
13850
+ return isObject(value) && hasProperty(value, "jsonrpc") && value.jsonrpc === "2.0" && hasProperty(value, "method") && value.method === "verto.answer" && isObject(value.params) && hasProperty(value.params, "callID");
13851
+ }
13852
+ function isVertoMediaInnerParams(value) {
13853
+ return isObject(value) && hasProperty(value, "jsonrpc") && value.jsonrpc === "2.0" && hasProperty(value, "method") && value.method === "verto.media" && isObject(value.params) && hasProperty(value.params, "callID") && hasProperty(value.params, "sdp");
13851
13854
  }
13852
13855
  function isVertoMediaParamsInnerParams(value) {
13853
13856
  return isObject(value) && hasProperty(value, "jsonrpc") && value.jsonrpc === "2.0" && hasProperty(value, "method") && value.method === "verto.mediaParams" && isObject(value.params) && hasProperty(value.params, "mediaParams");
@@ -13957,10 +13960,19 @@ var WebRTCVertoManager = class extends VertoManager {
13957
13960
  ].includes(connectionState)))));
13958
13961
  }
13959
13962
  initSubscriptions() {
13963
+ this.subscribeTo(this.vertoMedia$, (event) => {
13964
+ logger$10.debug("[WebRTCManager] Received Verto media event (early media SDP):", event);
13965
+ this._signalingStatus$.next("ringing");
13966
+ const { sdp, callID } = event;
13967
+ this._rtcPeerConnectionsMap.get(callID)?.updateAnswerStatus({
13968
+ status: "received",
13969
+ sdp
13970
+ });
13971
+ });
13960
13972
  this.subscribeTo(this.vertoAnswer$, (event) => {
13961
13973
  logger$10.debug("[WebRTCManager] Received Verto answer event:", event);
13962
- const { sdp } = event;
13963
- this._rtcPeerConnectionsMap.get(event.callID)?.updateAnswerStatus({
13974
+ const { sdp, callID } = event;
13975
+ this._rtcPeerConnectionsMap.get(callID)?.updateAnswerStatus({
13964
13976
  status: "received",
13965
13977
  sdp
13966
13978
  });
@@ -14001,6 +14013,9 @@ var WebRTCVertoManager = class extends VertoManager {
14001
14013
  get selfId() {
14002
14014
  return this._selfId$.value;
14003
14015
  }
14016
+ get vertoMedia$() {
14017
+ return this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoMediaInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$));
14018
+ }
14004
14019
  get vertoAnswer$() {
14005
14020
  return this.cachedObservable("vertoAnswer$", () => this.webRtcCallSession.webrtcMessages$.pipe(filterAs(isVertoAnswerInnerParams, "params"), (0, import_cjs$10.takeUntil)(this.destroyed$)));
14006
14021
  }
@@ -14084,7 +14099,6 @@ var WebRTCVertoManager = class extends VertoManager {
14084
14099
  this._selfId$.next(memberId);
14085
14100
  rtcPeerConnController.setMemberId(memberId);
14086
14101
  if (callId) this.webRtcCallSession.addCallId(callId);
14087
- this._signalingStatus$.next("ringing");
14088
14102
  this.attachManager.attach(this.webRtcCallSession);
14089
14103
  logger$10.info("[WebRTCManager] Verto invite successful");
14090
14104
  logger$10.debug(`[WebRTCManager] nodeid: ${this._nodeId$.value}, selfId: ${this._selfId$.value}`);
@@ -14179,6 +14193,7 @@ var WebRTCVertoManager = class extends VertoManager {
14179
14193
  }
14180
14194
  setupVertoByeHandler() {
14181
14195
  this.subscribeTo(this.vertoBye$, () => {
14196
+ this._signalingStatus$.next("disconnected");
14182
14197
  this.attachManager.detach(this.webRtcCallSession);
14183
14198
  this.callSession?.destroy();
14184
14199
  });
@@ -14206,7 +14221,12 @@ var WebRTCVertoManager = class extends VertoManager {
14206
14221
  this.callSession?.destroy();
14207
14222
  } else if (!vertoByeOrAccepted) {
14208
14223
  logger$10.info("[WebRTCManager] Call was not accepted, sending verto.bye.");
14209
- await this.bye("USER_BUSY");
14224
+ try {
14225
+ await this.bye("USER_BUSY");
14226
+ } finally {
14227
+ this._signalingStatus$.next("disconnected");
14228
+ this.callSession?.destroy();
14229
+ }
14210
14230
  } else {
14211
14231
  logger$10.debug("[WebRTCManager] Call accepted, sending answer");
14212
14232
  try {
@@ -14814,7 +14834,6 @@ var WebRTCCall = class extends Destroyable {
14814
14834
  try {
14815
14835
  await this.vertoManager.bye();
14816
14836
  } finally {
14817
- this._status$.next("destroyed");
14818
14837
  this.destroy();
14819
14838
  }
14820
14839
  }
@@ -14853,6 +14872,7 @@ var WebRTCCall = class extends Destroyable {
14853
14872
  }
14854
14873
  /** Destroys the call, releasing all resources and subscriptions. */
14855
14874
  destroy() {
14875
+ this._status$.next("destroyed");
14856
14876
  this.vertoManager.destroy();
14857
14877
  this.callEventsManager.destroy();
14858
14878
  this.participantsMap.clear();
@@ -14940,7 +14960,6 @@ var EntityCollection = class extends Destroyable {
14940
14960
  this.onError = onError;
14941
14961
  this.loading$ = this.createBehaviorSubject(false);
14942
14962
  this.values$ = this.createReplaySubject(1);
14943
- this._hasMore$ = this.createBehaviorSubject(true);
14944
14963
  this.collectionData = /* @__PURE__ */ new Map();
14945
14964
  this.observablesRegistry = /* @__PURE__ */ new Map();
14946
14965
  this.upsertData = (data) => {
@@ -14953,6 +14972,7 @@ var EntityCollection = class extends Destroyable {
14953
14972
  this.observablesRegistry.get(data.id)?.next(updated);
14954
14973
  this.values$.next(Array.from(this.collectionData.values()));
14955
14974
  };
14975
+ this._hasMore$ = this.createBehaviorSubject(true);
14956
14976
  this._destroy$ = new import_cjs$8.Subject();
14957
14977
  this.updateSubscription = this.update$.subscribe(this.upsertData);
14958
14978
  this.loading$.next(false);