sip-connector 28.10.4 → 28.10.6

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.
@@ -1,6 +1,6 @@
1
1
  import { C as ee, NameAddrHeader as Mn, URI as On, SessionStatus as _n, IncomingResponse as Ot } from "@krivega/jssip";
2
2
  import { MediaStreamTrackMock as bn, createAudioMediaStreamTrackMock as yn, createVideoMediaStreamTrackMock as Dn } from "webrtc-mock";
3
- import { TypedEvents as k, EventEmitterProxy as w, Events as Pn } from "events-constructor";
3
+ import { TypedEvents as k, EventEmitterProxy as G, Events as Pn } from "events-constructor";
4
4
  import Ve from "debug";
5
5
  import { resolveRequesterByTimeout as _t, DelayRequester as bt, hasCanceledError as yt, SetTimeoutRequest as Dt } from "@krivega/timeout-requester";
6
6
  import { CancelableRequest as pe, isCanceledError as He } from "@krivega/cancelable-promise";
@@ -110,7 +110,7 @@ const x = (t) => typeof t == "string" && t.trim().length > 0, Fe = (t) => typeof
110
110
  };
111
111
  var U = /* @__PURE__ */ ((t) => (t.CHANNELS = "channels", t.WEBCAST_STARTED = "WebcastStarted", t.WEBCAST_STOPPED = "WebcastStopped", t.ACCOUNT_CHANGED = "accountChanged", t.ACCOUNT_DELETED = "accountDeleted", t.ADDED_TO_LIST_MODERATORS = "addedToListModerators", t.REMOVED_FROM_LIST_MODERATORS = "removedFromListModerators", t.ACCEPTING_WORD_REQUEST = "ParticipationRequestAccepted", t.CANCELLING_WORD_REQUEST = "ParticipationRequestRejected", t.MOVE_REQUEST_TO_STREAM = "ParticipantMovedToWebcast", t.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "ConferenceParticipantTokenIssued", t))(U || {});
112
112
  const Xe = N("ApiManager");
113
- class zn extends w {
113
+ class zn extends G {
114
114
  callManager;
115
115
  constructor() {
116
116
  super(Hn());
@@ -1725,7 +1725,7 @@ class ce {
1725
1725
  }
1726
1726
  }
1727
1727
  const Ds = N("ConnectionManager");
1728
- class Ps extends w {
1728
+ class Ps extends G {
1729
1729
  stateMachine;
1730
1730
  ua;
1731
1731
  socket;
@@ -1850,7 +1850,7 @@ class Ls {
1850
1850
  this.connectionManager = e;
1851
1851
  }
1852
1852
  connect = async (...e) => this.stackPromises.run(async () => this.connectionManager.connect(...e));
1853
- disconnect = async () => this.stackPromises.run(async () => this.connectionManager.disconnect());
1853
+ disconnect = async () => (this.stop(), this.connectionManager.disconnect());
1854
1854
  stop() {
1855
1855
  this.stackPromises.stop();
1856
1856
  }
@@ -2479,9 +2479,10 @@ class er {
2479
2479
  }
2480
2480
  const tr = 250, nr = {
2481
2481
  LIMIT_REACHED: "Limit reached"
2482
- }, G = N("AutoConnectorManager"), sr = "start", rr = "manual-restart";
2483
- class ir extends w {
2482
+ }, w = N("AutoConnectorManager"), sr = "start", rr = "manual-restart";
2483
+ class ir extends G {
2484
2484
  stateMachine;
2485
+ stopSettledPromise;
2485
2486
  runtime;
2486
2487
  connectionManager;
2487
2488
  reconnectCoalescer = new er({
@@ -2506,7 +2507,7 @@ class ir extends w {
2506
2507
  this.events.trigger("limit-reached-attempts", new Error(nr.LIMIT_REACHED));
2507
2508
  },
2508
2509
  emitSuccess: () => {
2509
- G("handleSucceededAttempt"), this.events.trigger("success");
2510
+ w("handleSucceededAttempt"), this.events.trigger("success");
2510
2511
  },
2511
2512
  emitStopAttemptsByError: (a) => {
2512
2513
  this.events.trigger("stop-attempts-by-error", a);
@@ -2554,7 +2555,7 @@ class ir extends w {
2554
2555
  }));
2555
2556
  }
2556
2557
  async start(e) {
2557
- return G("auto connector start"), this.isStarted() ? (G(
2558
+ return w("auto connector start"), this.isStarted() ? (w(
2558
2559
  "auto connector start skipped: already started. Use restart() for force reconnect or stop() before next start()"
2559
2560
  ), {
2560
2561
  isSuccess: !1,
@@ -2599,16 +2600,31 @@ class ir extends w {
2599
2600
  };
2600
2601
  }
2601
2602
  restart() {
2602
- G("auto connector restart");
2603
+ w("auto connector restart");
2603
2604
  const { parameters: e } = this.stateMachine.context;
2604
2605
  if (!e) {
2605
- G("auto connector restart skipped: no parameters in context");
2606
+ w("auto connector restart skipped: no parameters in context");
2606
2607
  return;
2607
2608
  }
2608
2609
  this.requestReconnect(e, rr);
2609
2610
  }
2610
- stop() {
2611
- G("auto connector stop"), this.networkEventsReconnector?.stop(), this.resetReconnectCoalescingState(), this.stateMachine.toStop();
2611
+ async stop() {
2612
+ if (this.stopSettledPromise) {
2613
+ w("auto connector stop skipped: already in progress"), await this.stopSettledPromise;
2614
+ return;
2615
+ }
2616
+ this.stopSettledPromise = (async () => {
2617
+ w("auto connector stop"), this.networkEventsReconnector?.stop(), this.resetReconnectCoalescingState(), this.stateMachine.toStop(), !this.stateMachine.isInIdleState() && await new Promise((e) => {
2618
+ const n = this.stateMachine.onStateChange(() => {
2619
+ this.stateMachine.isInIdleState() && (n(), e());
2620
+ });
2621
+ });
2622
+ })();
2623
+ try {
2624
+ await this.stopSettledPromise;
2625
+ } finally {
2626
+ this.stopSettledPromise = void 0;
2627
+ }
2612
2628
  }
2613
2629
  // Test hook: allows deterministic cancellation of pending retry flow.
2614
2630
  cancelPendingRetry() {
@@ -2616,7 +2632,7 @@ class ir extends w {
2616
2632
  }
2617
2633
  requestReconnect = (e, n) => {
2618
2634
  const s = this.shouldRequestReconnect(n);
2619
- return G("auto connector requestReconnect", {
2635
+ return w("auto connector requestReconnect", {
2620
2636
  isAvailableToRestart: s,
2621
2637
  reason: n
2622
2638
  }), s ? (this.networkEventsReconnector?.setParameters(e), this.stateMachine.toRestart(e), !0) : !1;
@@ -2638,31 +2654,31 @@ class ir extends w {
2638
2654
  // сетевое событие триггернёт стандартный `requestReconnect`.
2639
2655
  probeServerReachability = async () => {
2640
2656
  if (this.stateMachine.isInConnectedMonitoringState()) {
2641
- G("probeServerReachability: isInConnectedMonitoringState");
2657
+ w("probeServerReachability: isInConnectedMonitoringState");
2642
2658
  try {
2643
2659
  return await this.connectionManager.ping(), !0;
2644
2660
  } catch (e) {
2645
- return G("probeServerReachability: ping failed", e), !1;
2661
+ return w("probeServerReachability: ping failed", e), !1;
2646
2662
  }
2647
2663
  }
2648
2664
  if (this.stateMachine.isInWaitingBeforeRetryState()) {
2649
- G("probeServerReachability: isInWaitingBeforeRetryState");
2665
+ w("probeServerReachability: isInWaitingBeforeRetryState");
2650
2666
  const { parameters: e } = this.stateMachine.context;
2651
2667
  try {
2652
2668
  const n = await e.getParameters();
2653
2669
  return await this.connectionManager.checkTelephony(n), !1;
2654
2670
  } catch (n) {
2655
- return G("probeServerReachability: checkTelephony failed", n), !0;
2671
+ return w("probeServerReachability: checkTelephony failed", n), !0;
2656
2672
  }
2657
2673
  }
2658
- return G("probeServerReachability: default return false"), !1;
2674
+ return w("probeServerReachability: default return false"), !1;
2659
2675
  };
2660
2676
  shouldRequestReconnect(e) {
2661
2677
  const n = this.reconnectCoalescer.register(e);
2662
- return n.shouldRequest ? (G(`auto connector reconnect requested: ${e}`, {
2678
+ return n.shouldRequest ? (w(`auto connector reconnect requested: ${e}`, {
2663
2679
  state: String(this.stateMachine.state),
2664
2680
  generation: n.generation
2665
- }), !0) : (G(`auto connector reconnect coalesced: ${e}`, {
2681
+ }), !0) : (w(`auto connector reconnect coalesced: ${e}`, {
2666
2682
  state: String(this.stateMachine.state),
2667
2683
  coalescedBy: n.coalescedBy,
2668
2684
  currentPriority: n.currentPriority,
@@ -3234,7 +3250,7 @@ const fr = (t) => new Ir(Nr(t)), vr = (t) => {
3234
3250
  "cancelled",
3235
3251
  "status-changed"
3236
3252
  ], Mr = () => new k(qt), ye = N("CallReconnectManager");
3237
- class Or extends w {
3253
+ class Or extends G {
3238
3254
  stateMachine;
3239
3255
  runtime;
3240
3256
  callManager;
@@ -4065,7 +4081,7 @@ const da = (t, e) => t.type !== e.type ? !1 : t.type !== "spectator" ? !0 : e.ty
4065
4081
  }
4066
4082
  };
4067
4083
  }, Et = je.VIDEO;
4068
- class ua extends w {
4084
+ class ua extends G {
4069
4085
  roleManager = new la();
4070
4086
  license = Et;
4071
4087
  isDuplexSendingMediaMode = !1;
@@ -5953,7 +5969,7 @@ const Fo = "udp", Uo = (t) => t.transport?.iceTransport ? t.transport.iceTranspo
5953
5969
  const s = Bo(t).filter(({ protocol: r, port: i }) => i !== null && Fo === r).map(({ port: r }) => r);
5954
5970
  return [...new Set(s)];
5955
5971
  }, St = (t) => t.streams[0]?.id;
5956
- class xo extends w {
5972
+ class xo extends G {
5957
5973
  stateMachine;
5958
5974
  sessionState;
5959
5975
  isPendingCall = !1;
@@ -6694,7 +6710,7 @@ const zo = 1, Jo = [
6694
6710
  "presentation:ended",
6695
6711
  "presentation:failed"
6696
6712
  ], Ko = (t) => t instanceof Error ? t : new Error(String(t)), bl = (t) => wn(t);
6697
- class Xo extends w {
6713
+ class Xo extends G {
6698
6714
  stateMachine;
6699
6715
  promisePendingStartPresentation;
6700
6716
  promisePendingStopPresentation;
@@ -6927,7 +6943,7 @@ const nc = [
6927
6943
  "not-available"
6928
6944
  /* NOT_AVAILABLE */
6929
6945
  ], sc = () => new k(nc);
6930
- class rc extends w {
6946
+ class rc extends G {
6931
6947
  stateMachine;
6932
6948
  constructor() {
6933
6949
  super(sc()), this.stateMachine = new tc(), this.proxyEvents();
@@ -7404,7 +7420,7 @@ const hc = 486, uc = 487, ke = (t) => ({
7404
7420
  incomingNumber: t.remote_identity.uri.user,
7405
7421
  rtcSession: t
7406
7422
  });
7407
- class gc extends w {
7423
+ class gc extends G {
7408
7424
  stateMachine;
7409
7425
  incomingRTCSession;
7410
7426
  connectionManager;
@@ -7522,7 +7538,7 @@ Ke(t.callReconnect, e.callReconnect), At = (t) => ({
7522
7538
  autoConnector: t.autoConnector.getSnapshot(),
7523
7539
  callReconnect: t.callReconnect.getSnapshot()
7524
7540
  });
7525
- class pc extends w {
7541
+ class pc extends G {
7526
7542
  machines;
7527
7543
  currentSnapshot;
7528
7544
  subscribers = /* @__PURE__ */ new Set();
@@ -7760,7 +7776,7 @@ const Tn = ["collected", "stopped"], Sc = () => new k(Tn), It = () => "performan
7760
7776
  };
7761
7777
  });
7762
7778
  }, vc = N("StatsPeerConnection");
7763
- class Mc extends w {
7779
+ class Mc extends G {
7764
7780
  setTimeoutRequest;
7765
7781
  requesterAllStatistics = new pe(fc);
7766
7782
  constructor() {
@@ -7812,7 +7828,7 @@ class Mc extends w {
7812
7828
  };
7813
7829
  }
7814
7830
  const Oc = 500, _c = N("StatsManager");
7815
- class bc extends w {
7831
+ class bc extends G {
7816
7832
  statsPeerConnection;
7817
7833
  availableStats;
7818
7834
  previousAvailableStats;
@@ -7949,7 +7965,7 @@ const yc = N("setCodecPreferences"), Dc = (t, e) => t.filter((s) => e.some((r) =
7949
7965
  "balancing-stopped",
7950
7966
  "parameters-updated"
7951
7967
  ], kc = () => new k(Sn), Fc = N("VideoSendingBalancerManager");
7952
- class Uc extends w {
7968
+ class Uc extends G {
7953
7969
  isBalancingActive = !1;
7954
7970
  callManager;
7955
7971
  balancingStartDelay;
@@ -8026,7 +8042,7 @@ const Cn = "health-snapshot", Rn = "inbound-video-problem-detected", Nn = "inbou
8026
8042
  Nn,
8027
8043
  An
8028
8044
  ], Bc = () => new k(In), $c = 3;
8029
- class me extends w {
8045
+ class me extends G {
8030
8046
  statsManager;
8031
8047
  callManager;
8032
8048
  minConsecutiveProblemSamplesCount;
@@ -8213,7 +8229,7 @@ const Qc = {
8213
8229
  ...il,
8214
8230
  ...al
8215
8231
  ], cl = () => new k(ol), Mt = N("SipConnector");
8216
- class yl extends w {
8232
+ class yl extends G {
8217
8233
  connectionManager;
8218
8234
  connectionQueueManager;
8219
8235
  contentedStreamManager;
@@ -8351,9 +8367,7 @@ class yl extends w {
8351
8367
  getConnectionConfiguration = () => this.connectionManager.getConnectionConfiguration();
8352
8368
  getUri = (e) => this.connectionManager.getUri(e);
8353
8369
  startAutoConnect = async (...e) => this.autoConnectorManager.start(...e);
8354
- stopAutoConnect = () => {
8355
- this.autoConnectorManager.stop();
8356
- };
8370
+ stopAutoConnect = async () => this.autoConnectorManager.stop();
8357
8371
  call = async (e, n = {}) => {
8358
8372
  const { onAddedTransceiver: s, ...r } = e, i = {
8359
8373
  ...r,