sip-connector 20.2.1 → 20.4.0

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.
Files changed (31) hide show
  1. package/README.md +116 -1
  2. package/dist/@SipConnector-DB4bLDI5.cjs +1 -0
  3. package/dist/{@SipConnector-OO78fz6E.js → @SipConnector-FYEV5h4G.js} +1948 -713
  4. package/dist/ApiManager/index.d.ts +1 -0
  5. package/dist/CallManager/CallStateMachine.d.ts +83 -0
  6. package/dist/ConferenceStateManager/@ConferenceStateManager.d.ts +22 -0
  7. package/dist/ConferenceStateManager/events.d.ts +18 -0
  8. package/dist/ConferenceStateManager/index.d.ts +4 -0
  9. package/dist/ConferenceStateManager/types.d.ts +12 -0
  10. package/dist/ConnectionManager/ConnectionStateMachine.d.ts +53 -4
  11. package/dist/IncomingCallManager/IncomingCallStateMachine.d.ts +114 -0
  12. package/dist/PresentationManager/PresentationStateMachine.d.ts +101 -0
  13. package/dist/SipConnector/@SipConnector.d.ts +11 -3
  14. package/dist/SipConnector/events.d.ts +2 -2
  15. package/dist/doMock.cjs +1 -1
  16. package/dist/doMock.js +1 -1
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.d.ts +2 -0
  19. package/dist/index.js +206 -188
  20. package/dist/session/createSession.d.ts +26 -0
  21. package/dist/session/index.d.ts +5 -0
  22. package/dist/session/selectors.d.ts +10 -0
  23. package/dist/session/types.d.ts +20 -0
  24. package/dist/tools/BaseStateMachine.d.ts +18 -0
  25. package/dist/tools/sendOffer.d.ts +8 -1
  26. package/package.json +1 -1
  27. package/dist/@SipConnector-BTqBRDjY.cjs +0 -1
  28. package/dist/CallManager/@CallManager.d.ts +0 -60
  29. package/dist/ConnectionManager/@ConnectionManager.d.ts +0 -57
  30. package/dist/IncomingCallManager/@IncomingCallManager.d.ts +0 -29
  31. package/dist/PresentationManager/@PresentationManager.d.ts +0 -49
package/dist/index.js CHANGED
@@ -1,34 +1,47 @@
1
- import { E as p, l as r, p as $, s as W, a as H, b as j, h as K } from "./@SipConnector-OO78fz6E.js";
2
- import { g as Ie, c as Ue, S as ke, i as xe, d as Le, e as Ve, j as Be, f as $e } from "./@SipConnector-OO78fz6E.js";
1
+ import { E as p, a as w, b as H, l as r, p as j, s as K, c as X, d as Y, h as G } from "./@SipConnector-FYEV5h4G.js";
2
+ import { n as He, o as je, j as Ke, e as Xe, S as Ye, k as Ge, f as qe, g as ze, m as Je, i as Qe } from "./@SipConnector-FYEV5h4G.js";
3
3
  import "events-constructor";
4
- import { isCanceledError as x } from "@krivega/cancelable-promise";
5
- import { hasCanceledError as X } from "repeated-calls";
6
- import { debounce as Y } from "ts-debounce";
7
- import { UAParser as G } from "ua-parser-js";
8
- import { sequentPromises as q } from "sequent-promises";
9
- import { isPromiseIsNotActualError as He } from "stack-promises";
10
- const z = (n) => n instanceof Object && ("originator" in n || "cause" in n), Ne = (n) => {
11
- if (x(n))
4
+ import { isCanceledError as L } from "@krivega/cancelable-promise";
5
+ import { hasCanceledError as q } from "repeated-calls";
6
+ import { debounce as z } from "ts-debounce";
7
+ import { UAParser as J } from "ua-parser-js";
8
+ import { sequentPromises as Q } from "sequent-promises";
9
+ import { isPromiseIsNotActualError as en } from "stack-promises";
10
+ const Z = (e) => e instanceof Object && ("originator" in e || "cause" in e), ke = (e) => {
11
+ if (L(e))
12
12
  return !0;
13
- if (!z(n))
13
+ if (!Z(e))
14
14
  return !1;
15
- const { originator: e, cause: t } = n;
16
- return typeof t == "string" ? t === p.REQUEST_TIMEOUT || t === p.REJECTED || e === "local" && (t === p.CANCELED || t === p.BYE) : !1;
17
- }, J = () => globalThis.process?.versions?.electron !== void 0, L = () => {
18
- const n = new G(), { name: e } = n.getBrowser(), t = J();
15
+ const { originator: n, cause: t } = e;
16
+ return typeof t == "string" ? t === p.REQUEST_TIMEOUT || t === p.REJECTED || n === "local" && (t === p.CANCELED || t === p.BYE) : !1;
17
+ }, ee = (e) => e.connection.value, V = (e) => e.call.value, ne = (e) => e.incoming.value, te = (e) => {
18
+ if (e.incoming.value !== H.IDLE)
19
+ return e.incoming.context.remoteCallerData;
20
+ }, oe = (e) => e.presentation.value, re = (e) => {
21
+ const n = V(e);
22
+ return n === w.IN_CALL || n === w.ACCEPTED;
23
+ }, xe = {
24
+ selectConnectionStatus: ee,
25
+ selectCallStatus: V,
26
+ selectIncomingStatus: ne,
27
+ selectIncomingRemoteCaller: te,
28
+ selectPresentationStatus: oe,
29
+ selectIsInCall: re
30
+ }, se = () => globalThis.process?.versions?.electron !== void 0, B = () => {
31
+ const e = new J(), { name: n } = e.getBrowser(), t = se();
19
32
  return {
20
- isChrome: e === "Chrome" || t
33
+ isChrome: n === "Chrome" || t
21
34
  };
22
- }, N = (n) => {
23
- const { url: e, cause: t } = n;
24
- let o = e;
25
- return (t === p.BAD_MEDIA_DESCRIPTION || t === p.NOT_FOUND) && (o = `${n.message.to.uri.user}@${n.message.to.uri.host}`), o;
35
+ }, N = (e) => {
36
+ const { url: n, cause: t } = e;
37
+ let o = n;
38
+ return (t === p.BAD_MEDIA_DESCRIPTION || t === p.NOT_FOUND) && (o = `${e.message.to.uri.user}@${e.message.to.uri.host}`), o;
26
39
  };
27
- var V = /* @__PURE__ */ ((n) => (n.CONNECT_SERVER_FAILED = "CONNECT_SERVER_FAILED", n.WRONG_USER_OR_PASSWORD = "WRONG_USER_OR_PASSWORD", n.BAD_MEDIA_ERROR = "BAD_MEDIA_ERROR", n.NOT_FOUND_ERROR = "NOT_FOUND_ERROR", n.WS_CONNECTION_FAILED = "WS_CONNECTION_FAILED", n.CONNECT_SERVER_FAILED_BY_LINK = "CONNECT_SERVER_FAILED_BY_LINK", n))(V || {});
28
- const Q = new Error("Unknown error"), Z = (n = Q) => {
29
- const { cause: e, socket: t } = n;
40
+ var $ = /* @__PURE__ */ ((e) => (e.CONNECT_SERVER_FAILED = "CONNECT_SERVER_FAILED", e.WRONG_USER_OR_PASSWORD = "WRONG_USER_OR_PASSWORD", e.BAD_MEDIA_ERROR = "BAD_MEDIA_ERROR", e.NOT_FOUND_ERROR = "NOT_FOUND_ERROR", e.WS_CONNECTION_FAILED = "WS_CONNECTION_FAILED", e.CONNECT_SERVER_FAILED_BY_LINK = "CONNECT_SERVER_FAILED_BY_LINK", e))($ || {});
41
+ const ae = new Error("Unknown error"), ce = (e = ae) => {
42
+ const { cause: n, socket: t } = e;
30
43
  let o = "CONNECT_SERVER_FAILED";
31
- switch (e) {
44
+ switch (n) {
32
45
  case "Forbidden": {
33
46
  o = "WRONG_USER_OR_PASSWORD";
34
47
  break;
@@ -42,129 +55,129 @@ const Q = new Error("Unknown error"), Z = (n = Q) => {
42
55
  break;
43
56
  }
44
57
  default:
45
- t !== void 0 && t._ws?.readyState === 3 ? o = "WS_CONNECTION_FAILED" : N(n) !== void 0 && N(n) !== "" && (o = "CONNECT_SERVER_FAILED_BY_LINK");
58
+ t !== void 0 && t._ws?.readyState === 3 ? o = "WS_CONNECTION_FAILED" : N(e) !== void 0 && N(e) !== "" && (o = "CONNECT_SERVER_FAILED_BY_LINK");
46
59
  }
47
60
  return o;
48
- }, ee = (n) => {
49
- let e = "";
61
+ }, ie = (e) => {
62
+ let n = "";
50
63
  try {
51
- e = JSON.stringify(n);
64
+ n = JSON.stringify(e);
52
65
  } catch (t) {
53
66
  r("failed to stringify message", t);
54
67
  }
55
- return e;
56
- }, ne = new Error("Unknown error"), te = (n = ne) => {
57
- const { code: e, cause: t, message: o } = n, a = N(n), s = { code: "", cause: "", message: "" };
58
- return typeof o == "object" && o !== null ? s.message = ee(o) : o && (s.message = String(o)), a !== void 0 && a !== "" && (s.link = a), e !== void 0 && e !== "" && (s.code = e), t !== void 0 && t !== "" && (s.cause = t), s;
59
- }, oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
68
+ return n;
69
+ }, ue = new Error("Unknown error"), le = (e = ue) => {
70
+ const { code: n, cause: t, message: o } = e, a = N(e), s = { code: "", cause: "", message: "" };
71
+ return typeof o == "object" && o !== null ? s.message = ie(o) : o && (s.message = String(o)), a !== void 0 && a !== "" && (s.link = a), n !== void 0 && n !== "" && (s.code = n), t !== void 0 && t !== "" && (s.cause = t), s;
72
+ }, de = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
60
73
  __proto__: null,
61
- EErrorTypes: V,
74
+ EErrorTypes: $,
62
75
  getLinkError: N,
63
- getTypeFromError: Z,
64
- getValuesFromError: te
65
- }, Symbol.toStringTag, { value: "Module" })), re = ({
66
- sessionId: n,
67
- remoteAddress: e,
76
+ getTypeFromError: ce,
77
+ getValuesFromError: le
78
+ }, Symbol.toStringTag, { value: "Module" })), Ce = ({
79
+ sessionId: e,
80
+ remoteAddress: n,
68
81
  isMutedAudio: t,
69
82
  isMutedVideo: o,
70
83
  isRegistered: a,
71
84
  isPresentationCall: s
72
85
  }) => {
73
86
  const c = [], u = t ? "0" : "1", d = o ? "0" : "1";
74
- return c.push(`X-Vinteo-Mic-State: ${u}`, `X-Vinteo-MainCam-State: ${d}`), (a === !1 || a === void 0) && c.push("X-Vinteo-Purgatory-Call: yes"), n !== void 0 && n !== "" && c.push(`X-Vinteo-Session: ${n}`), s === !0 && c.push("X-Vinteo-Presentation-Call: yes"), e !== void 0 && e !== "" && c.push(`X-Vinteo-Remote: ${e}`), c;
75
- }, se = "[@*!|]", ae = "_", ce = (n) => {
76
- let e = n;
77
- return e = e.replaceAll(new RegExp(se, "g"), ae), e;
78
- }, ie = ({
79
- appName: n,
80
- appVersion: e,
87
+ return c.push(`X-Vinteo-Mic-State: ${u}`, `X-Vinteo-MainCam-State: ${d}`), (a === !1 || a === void 0) && c.push("X-Vinteo-Purgatory-Call: yes"), e !== void 0 && e !== "" && c.push(`X-Vinteo-Session: ${e}`), s === !0 && c.push("X-Vinteo-Presentation-Call: yes"), n !== void 0 && n !== "" && c.push(`X-Vinteo-Remote: ${n}`), c;
88
+ }, Se = "[@*!|]", fe = "_", me = (e) => {
89
+ let n = e;
90
+ return n = n.replaceAll(new RegExp(Se, "g"), fe), n;
91
+ }, pe = ({
92
+ appName: e,
93
+ appVersion: n,
81
94
  browserName: t,
82
95
  browserVersion: o
83
96
  }) => {
84
- const s = `${ce(n)} ${e}`;
97
+ const s = `${me(e)} ${n}`;
85
98
  return `ChromeNew - ${t === void 0 ? s : `${t} ${o}, ${s}`}`;
86
- }, ue = ({
87
- isUnifiedSdpSemantic: n,
88
- appVersion: e,
99
+ }, he = ({
100
+ isUnifiedSdpSemantic: e,
101
+ appVersion: n,
89
102
  browserName: t,
90
103
  browserVersion: o,
91
104
  appName: a
92
- }) => n ? ie({ appVersion: e, browserName: t, browserVersion: o, appName: a }) : "Chrome", B = "purgatory", y = (n) => n === B, le = (n) => (e) => [...e].map((o) => async () => n(o)), de = async ({
93
- accumulatedKeys: n,
94
- sendKey: e,
105
+ }) => e ? pe({ appVersion: n, browserName: t, browserVersion: o, appName: a }) : "Chrome", W = "purgatory", A = (e) => e === W, Ee = (e) => (n) => [...n].map((o) => async () => e(o)), ge = async ({
106
+ accumulatedKeys: e,
107
+ sendKey: n,
95
108
  canRunTask: t
96
109
  }) => {
97
- const a = le(e)(n);
98
- return q(a, t);
99
- }, fe = (n) => (t) => (r("onStartMainCam"), n.on("api:admin-start-main-cam", t)), Ce = (n) => (t) => (r("onStartMic"), n.on("api:admin-start-mic", t)), Se = (n) => (t) => (r("onStopMainCam"), n.on("api:admin-stop-main-cam", t)), me = (n) => (t) => (r("onStopMic"), n.on("api:admin-stop-mic", t)), pe = ({ sipConnector: n }) => {
100
- const e = (l, f) => ({ isSyncForced: C }) => {
101
- if (C === !0) {
110
+ const a = Ee(n)(e);
111
+ return Q(a, t);
112
+ }, Re = (e) => (t) => (r("onStartMainCam"), e.on("api:admin-start-main-cam", t)), be = (e) => (t) => (r("onStartMic"), e.on("api:admin-start-mic", t)), ve = (e) => (t) => (r("onStopMainCam"), e.on("api:admin-stop-main-cam", t)), Te = (e) => (t) => (r("onStopMic"), e.on("api:admin-stop-mic", t)), _e = ({ sipConnector: e }) => {
113
+ const n = (l, C) => ({ isSyncForced: S }) => {
114
+ if (S === !0) {
102
115
  l();
103
116
  return;
104
117
  }
105
- f();
106
- }, t = fe(n), o = Se(n), a = Ce(n), s = me(n);
118
+ C();
119
+ }, t = Re(e), o = ve(e), a = be(e), s = Te(e);
107
120
  let c, u, d, E;
108
- const T = ({
121
+ const v = ({
109
122
  onStartMainCamForced: l,
110
- onStartMainCamNotForced: f,
111
- onStopMainCamForced: C,
123
+ onStartMainCamNotForced: C,
124
+ onStopMainCamForced: S,
112
125
  onStopMainCamNotForced: R,
113
126
  onStartMicForced: b,
114
- onStartMicNotForced: v,
127
+ onStartMicNotForced: O,
115
128
  onStopMicForced: P,
116
129
  onStopMicNotForced: M
117
130
  }) => {
118
- const S = e(
131
+ const f = n(
119
132
  l,
120
- f
133
+ C
121
134
  );
122
- c = t(S);
123
- const m = e(
124
- C,
135
+ c = t(f);
136
+ const m = n(
137
+ S,
125
138
  R
126
139
  );
127
140
  u = o(m);
128
- const A = e(b, v);
129
- d = a(A);
130
- const h = e(P, M);
141
+ const y = n(b, O);
142
+ d = a(y);
143
+ const h = n(P, M);
131
144
  E = s(h);
132
- }, _ = () => {
145
+ }, T = () => {
133
146
  c?.(), u?.(), d?.(), E?.();
134
147
  };
135
148
  return {
136
149
  start: (l) => {
137
- T(l);
150
+ v(l);
138
151
  },
139
152
  stop: () => {
140
- _();
153
+ T();
141
154
  }
142
155
  };
143
- }, ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
156
+ }, Le = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
144
157
  __proto__: null,
145
- PURGATORY_CONFERENCE_NUMBER: B,
146
- createSyncMediaState: pe,
147
- createUaParser: L,
148
- error: oe,
149
- getExtraHeaders: re,
150
- getUserAgent: ue,
151
- hasPurgatory: y,
152
- prepareMediaStream: $,
153
- sendDtmfAccumulated: de,
154
- sendOffer: W,
155
- setEncodingsToSender: H,
156
- setParametersToSender: j
157
- }, Symbol.toStringTag, { value: "Module" })), Ae = () => L().isChrome, he = (n) => {
158
- if (!x(n) && !X(n) && !K(n))
159
- throw n;
158
+ PURGATORY_CONFERENCE_NUMBER: W,
159
+ createSyncMediaState: _e,
160
+ createUaParser: B,
161
+ error: de,
162
+ getExtraHeaders: Ce,
163
+ getUserAgent: he,
164
+ hasPurgatory: A,
165
+ prepareMediaStream: j,
166
+ sendDtmfAccumulated: ge,
167
+ sendOffer: K,
168
+ setEncodingsToSender: X,
169
+ setParametersToSender: Y
170
+ }, Symbol.toStringTag, { value: "Module" })), Ve = () => B().isChrome, Oe = (e) => {
171
+ if (!L(e) && !q(e) && !G(e))
172
+ throw e;
160
173
  return { configuration: void 0, isSuccessful: !1 };
161
- }, Ee = ({ kind: n, readyState: e }) => n === "video" && e === "live", I = (n, e, { onEnterPurgatory: t, onEnterConference: o }) => {
162
- y(n) ? t && t() : o && o({ isSuccessProgressCall: e });
163
- }, U = (n, e) => {
164
- n(), e && e();
165
- }, k = (n, e, t) => {
166
- throw n && n(), e(), t;
167
- }, ge = /* @__PURE__ */ new Set([
174
+ }, Pe = ({ kind: e, readyState: n }) => e === "video" && n === "live", U = (e, n, { onEnterPurgatory: t, onEnterConference: o }) => {
175
+ A(e) ? t && t() : o && o({ isSuccessProgressCall: n });
176
+ }, k = (e, n) => {
177
+ e(), n && n();
178
+ }, x = (e, n, t) => {
179
+ throw e && e(), n(), t;
180
+ }, Me = /* @__PURE__ */ new Set([
168
181
  "on",
169
182
  "once",
170
183
  "onceRace",
@@ -183,7 +196,7 @@ const Q = new Error("Unknown error"), Z = (n = Q) => {
183
196
  "isConfigured",
184
197
  "isRegistered"
185
198
  ]);
186
- class Fe {
199
+ class Be {
187
200
  // @ts-expect-error: proxy method
188
201
  on;
189
202
  // @ts-expect-error: proxy method
@@ -219,10 +232,10 @@ class Fe {
219
232
  // @ts-expect-error: proxy method
220
233
  isRegistered;
221
234
  sipConnector;
222
- constructor(e) {
223
- return this.sipConnector = e, new Proxy(this, {
235
+ constructor(n) {
236
+ return this.sipConnector = n, new Proxy(this, {
224
237
  get: (t, o, a) => {
225
- if (typeof o == "string" && ge.has(o) && o in this.sipConnector) {
238
+ if (typeof o == "string" && Me.has(o) && o in this.sipConnector) {
226
239
  const c = Reflect.get(this.sipConnector, o, this.sipConnector);
227
240
  return typeof c == "function" ? c.bind(this.sipConnector) : c;
228
241
  }
@@ -231,8 +244,8 @@ class Fe {
231
244
  }
232
245
  });
233
246
  }
234
- connectToServer = async (e, t) => this.sipConnector.connect(e, t).then((o) => (r("connectToServer then"), { configuration: o, isSuccessful: !0 })).catch(async (o) => (r("connectToServer catch: error", o), he(o)));
235
- callToServer = async (e) => {
247
+ connectToServer = async (n, t) => this.sipConnector.connect(n, t).then((o) => (r("connectToServer then"), { configuration: o, isSuccessful: !0 })).catch(async (o) => (r("connectToServer catch: error", o), Oe(o)));
248
+ callToServer = async (n) => {
236
249
  const {
237
250
  conference: t,
238
251
  mediaStream: o,
@@ -242,48 +255,48 @@ class Fe {
242
255
  degradationPreference: u,
243
256
  sendEncodings: d,
244
257
  offerToReceiveAudio: E,
245
- offerToReceiveVideo: T,
246
- directionVideo: _,
247
- directionAudio: O,
258
+ offerToReceiveVideo: v,
259
+ directionVideo: T,
260
+ directionAudio: _,
248
261
  onBeforeProgressCall: g,
249
262
  onSuccessProgressCall: l,
250
- onEnterPurgatory: f,
251
- onEnterConference: C,
263
+ onEnterPurgatory: C,
264
+ onEnterConference: S,
252
265
  onFailProgressCall: R,
253
266
  onFinishProgressCall: b,
254
- onEndedCall: v,
267
+ onEndedCall: O,
255
268
  onAddedTransceiver: P
256
- } = e;
257
- r("callToServer", e);
269
+ } = n;
270
+ r("callToServer", n);
258
271
  const M = async () => (r("startCall"), this.sipConnector.call({
259
272
  mediaStream: o,
260
273
  extraHeaders: a,
261
274
  iceServers: s,
262
275
  contentHint: c,
263
276
  offerToReceiveAudio: E,
264
- offerToReceiveVideo: T,
265
- directionVideo: _,
266
- directionAudio: O,
277
+ offerToReceiveVideo: v,
278
+ directionVideo: T,
279
+ directionAudio: _,
267
280
  degradationPreference: u,
268
281
  onAddedTransceiver: P,
269
282
  sendEncodings: d,
270
283
  number: t
271
284
  }));
272
- let S = !1, m;
273
- const h = (r("subscribeEnterConference: onEnterConference", C), this.sipConnector.on("api:enterRoom", ({ room: i }) => {
274
- r("enterRoom", { _room: i, isSuccessProgressCall: S }), m = i, (f ?? C) && I(m, S, {
275
- onEnterPurgatory: f,
276
- onEnterConference: C
285
+ let f = !1, m;
286
+ const h = (r("subscribeEnterConference: onEnterConference", S), this.sipConnector.on("api:enterRoom", ({ room: i }) => {
287
+ r("enterRoom", { _room: i, isSuccessProgressCall: f }), m = i, (C ?? S) && U(m, f, {
288
+ onEnterPurgatory: C,
289
+ onEnterConference: S
277
290
  });
278
- })), F = (i) => (r("onSuccess"), S = !0, l && l({ isPurgatory: y(m) }), this.sipConnector.onceRace(["call:ended", "call:failed"], () => {
279
- U(h, v);
280
- }), i), D = (i) => (r("onFail"), k(R, h, i)), w = () => {
291
+ })), D = (i) => (r("onSuccess"), f = !0, l && l({ isPurgatory: A(m) }), this.sipConnector.onceRace(["call:ended", "call:failed"], () => {
292
+ k(h, O);
293
+ }), i), F = (i) => (r("onFail"), x(R, h, i)), I = () => {
281
294
  r("onFinish"), b && b();
282
295
  };
283
- return r("onBeforeProgressCall"), g && g(t), M().then(F).catch((i) => D(i)).finally(w);
296
+ return r("onBeforeProgressCall"), g && g(t), M().then(D).catch((i) => F(i)).finally(I);
284
297
  };
285
- disconnectFromServer = async () => this.sipConnector.disconnect().then(() => (r("disconnectFromServer: then"), { isSuccessful: !0 })).catch((e) => (r("disconnectFromServer: catch", e), { isSuccessful: !1 }));
286
- answerToIncomingCall = async (e) => {
298
+ disconnectFromServer = async () => this.sipConnector.disconnect().then(() => (r("disconnectFromServer: then"), { isSuccessful: !0 })).catch((n) => (r("disconnectFromServer: catch", n), { isSuccessful: !1 }));
299
+ answerToIncomingCall = async (n) => {
287
300
  const {
288
301
  mediaStream: t,
289
302
  extraHeaders: o,
@@ -293,18 +306,18 @@ class Fe {
293
306
  sendEncodings: u,
294
307
  offerToReceiveAudio: d,
295
308
  offerToReceiveVideo: E,
296
- directionVideo: T,
297
- directionAudio: _,
298
- onBeforeProgressCall: O,
309
+ directionVideo: v,
310
+ directionAudio: T,
311
+ onBeforeProgressCall: _,
299
312
  onSuccessProgressCall: g,
300
313
  onEnterPurgatory: l,
301
- onEnterConference: f,
302
- onFailProgressCall: C,
314
+ onEnterConference: C,
315
+ onFailProgressCall: S,
303
316
  onFinishProgressCall: R,
304
317
  onEndedCall: b,
305
- onAddedTransceiver: v
306
- } = e;
307
- r("answerToIncomingCall", e);
318
+ onAddedTransceiver: O
319
+ } = n;
320
+ r("answerToIncomingCall", n);
308
321
  const P = async () => this.sipConnector.answerToIncomingCall({
309
322
  mediaStream: t,
310
323
  extraHeaders: o,
@@ -312,40 +325,40 @@ class Fe {
312
325
  contentHint: s,
313
326
  offerToReceiveAudio: d,
314
327
  offerToReceiveVideo: E,
315
- directionVideo: T,
316
- directionAudio: _,
328
+ directionVideo: v,
329
+ directionAudio: T,
317
330
  degradationPreference: c,
318
- onAddedTransceiver: v,
331
+ onAddedTransceiver: O,
319
332
  sendEncodings: u
320
333
  }), M = () => {
321
334
  const { remoteCallerData: i } = this.sipConnector;
322
335
  return i.incomingNumber;
323
336
  };
324
- let S = !1, m;
325
- const h = (r("subscribeEnterConference: onEnterConference", f), this.sipConnector.on("api:enterRoom", (i) => {
326
- r("enterRoom", { room: i.room, isSuccessProgressCall: S }), m = i.room, (l ?? f) && I(m, S, {
337
+ let f = !1, m;
338
+ const h = (r("subscribeEnterConference: onEnterConference", C), this.sipConnector.on("api:enterRoom", (i) => {
339
+ r("enterRoom", { room: i.room, isSuccessProgressCall: f }), m = i.room, (l ?? C) && U(m, f, {
327
340
  onEnterPurgatory: l,
328
- onEnterConference: f
341
+ onEnterConference: C
329
342
  });
330
- })), F = (i) => (r("onSuccess"), S = !0, g && g({ isPurgatory: y(m) }), this.sipConnector.onceRace(["call:ended", "call:failed"], () => {
331
- U(h, b);
332
- }), i), D = (i) => (r("onFail"), k(C, h, i)), w = () => {
343
+ })), D = (i) => (r("onSuccess"), f = !0, g && g({ isPurgatory: A(m) }), this.sipConnector.onceRace(["call:ended", "call:failed"], () => {
344
+ k(h, b);
345
+ }), i), F = (i) => (r("onFail"), x(S, h, i)), I = () => {
333
346
  r("onFinish"), R && R();
334
347
  };
335
- if (r("onBeforeProgressCall"), O) {
348
+ if (r("onBeforeProgressCall"), _) {
336
349
  const i = M();
337
- O(i);
350
+ _(i);
338
351
  }
339
- return P().then(F).catch((i) => D(i)).finally(w);
352
+ return P().then(D).catch((i) => F(i)).finally(I);
340
353
  };
341
354
  updatePresentation = async ({
342
- mediaStream: e,
355
+ mediaStream: n,
343
356
  isP2P: t,
344
357
  contentHint: o,
345
358
  degradationPreference: a,
346
359
  sendEncodings: s,
347
360
  onAddedTransceiver: c
348
- }) => (r("updatePresentation"), this.sipConnector.updatePresentation(e, {
361
+ }) => (r("updatePresentation"), this.sipConnector.updatePresentation(n, {
349
362
  isP2P: t,
350
363
  contentHint: o,
351
364
  degradationPreference: a,
@@ -353,14 +366,14 @@ class Fe {
353
366
  sendEncodings: s
354
367
  }));
355
368
  startPresentation = async ({
356
- mediaStream: e,
369
+ mediaStream: n,
357
370
  isP2P: t,
358
371
  contentHint: o,
359
372
  degradationPreference: a,
360
373
  sendEncodings: s,
361
374
  callLimit: c,
362
375
  onAddedTransceiver: u
363
- }) => (r("startPresentation"), this.sipConnector.startPresentation(e, {
376
+ }) => (r("startPresentation"), this.sipConnector.startPresentation(n, {
364
377
  isP2P: t,
365
378
  contentHint: o,
366
379
  callLimit: c,
@@ -368,28 +381,28 @@ class Fe {
368
381
  onAddedTransceiver: u,
369
382
  sendEncodings: s
370
383
  }));
371
- stopShareSipConnector = async ({ isP2P: e = !1 } = {}) => (r("stopShareSipConnector"), this.sipConnector.stopPresentation({
372
- isP2P: e
384
+ stopShareSipConnector = async ({ isP2P: n = !1 } = {}) => (r("stopShareSipConnector"), this.sipConnector.stopPresentation({
385
+ isP2P: n
373
386
  }).catch((t) => {
374
387
  r(t);
375
388
  }));
376
389
  sendRefusalToTurnOnMic = async () => {
377
- r("sendRefusalToTurnOnMic"), await this.sipConnector.sendRefusalToTurnOnMic().catch((e) => {
378
- r("sendRefusalToTurnOnMic: error", e);
390
+ r("sendRefusalToTurnOnMic"), await this.sipConnector.sendRefusalToTurnOnMic().catch((n) => {
391
+ r("sendRefusalToTurnOnMic: error", n);
379
392
  });
380
393
  };
381
394
  sendRefusalToTurnOnCam = async () => {
382
- r("sendRefusalToTurnOnCam"), await this.sipConnector.sendRefusalToTurnOnCam().catch((e) => {
383
- r("sendRefusalToTurnOnCam: error", e);
395
+ r("sendRefusalToTurnOnCam"), await this.sipConnector.sendRefusalToTurnOnCam().catch((n) => {
396
+ r("sendRefusalToTurnOnCam: error", n);
384
397
  });
385
398
  };
386
399
  sendMediaState = async ({
387
- isEnabledCam: e,
400
+ isEnabledCam: n,
388
401
  isEnabledMic: t
389
402
  }) => {
390
- r("sendMediaState"), await this.sipConnector.sendMediaState({ cam: e, mic: t });
403
+ r("sendMediaState"), await this.sipConnector.sendMediaState({ cam: n, mic: t });
391
404
  };
392
- replaceMediaStream = async (e, {
405
+ replaceMediaStream = async (n, {
393
406
  deleteExisting: t,
394
407
  addMissing: o,
395
408
  forceRenegotiation: a,
@@ -397,7 +410,7 @@ class Fe {
397
410
  degradationPreference: c,
398
411
  sendEncodings: u,
399
412
  onAddedTransceiver: d
400
- }) => (r("replaceMediaStream"), this.sipConnector.replaceMediaStream(e, {
413
+ }) => (r("replaceMediaStream"), this.sipConnector.replaceMediaStream(n, {
401
414
  deleteExisting: t,
402
415
  addMissing: o,
403
416
  forceRenegotiation: a,
@@ -410,42 +423,47 @@ class Fe {
410
423
  r("askPermissionToEnableCam"), await this.sipConnector.askPermissionToEnableCam();
411
424
  };
412
425
  resolveHandleReadyRemoteStreamsDebounced = ({
413
- onReadyRemoteStreams: e
414
- }) => Y(() => {
426
+ onReadyRemoteStreams: n
427
+ }) => z(() => {
415
428
  const t = this.sipConnector.getRemoteStreams();
416
- r("remoteStreams", t), e(t);
429
+ r("remoteStreams", t), n(t);
417
430
  }, 200);
418
431
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
419
432
  resolveHandleReadyRemoteStreams = ({
420
- onReadyRemoteStreams: e
433
+ onReadyRemoteStreams: n
421
434
  }) => ({ track: t }) => {
422
- Ee(t) && e();
435
+ Pe(t) && n();
423
436
  };
424
437
  getRemoteStreams = () => (r("getRemoteStreams"), this.sipConnector.getRemoteStreams());
425
- onUseLicense = (e) => (r("onUseLicense"), this.sipConnector.on("api:useLicense", e));
426
- onMustStopPresentation = (e) => (r("onMustStopPresentation"), this.sipConnector.on("api:mustStopPresentation", e));
427
- onMoveToSpectators = (e) => (r("onMoveToSpectators"), this.sipConnector.on("api:participant:move-request-to-spectators", e));
428
- onMoveToParticipants = (e) => (r("onMoveToParticipants"), this.sipConnector.on("api:participant:move-request-to-participants", e));
429
- onStats = (e) => (r("onStats"), this.sipConnector.on("stats:collected", e));
430
- offStats = (e) => {
431
- r("offStats"), this.sipConnector.off("stats:collected", e);
438
+ onUseLicense = (n) => (r("onUseLicense"), this.sipConnector.on("api:useLicense", n));
439
+ onMustStopPresentation = (n) => (r("onMustStopPresentation"), this.sipConnector.on("api:mustStopPresentation", n));
440
+ onMoveToSpectators = (n) => (r("onMoveToSpectators"), this.sipConnector.on("api:participant:move-request-to-spectators", n));
441
+ onMoveToParticipants = (n) => (r("onMoveToParticipants"), this.sipConnector.on("api:participant:move-request-to-participants", n));
442
+ onStats = (n) => (r("onStats"), this.sipConnector.on("stats:collected", n));
443
+ offStats = (n) => {
444
+ r("offStats"), this.sipConnector.off("stats:collected", n);
432
445
  };
433
446
  }
434
- var Re = /* @__PURE__ */ ((n) => (n.VP8 = "video/VP8", n.VP9 = "video/VP9", n.H264 = "video/H264", n.AV1 = "video/AV1", n.rtx = "video/rtx", n.red = "video/red", n.flexfec03 = "video/flexfec-03", n))(Re || {});
447
+ var Ne = /* @__PURE__ */ ((e) => (e.VP8 = "video/VP8", e.VP9 = "video/VP9", e.H264 = "video/H264", e.AV1 = "video/AV1", e.rtx = "video/rtx", e.red = "video/red", e.flexfec03 = "video/flexfec-03", e))(Ne || {});
435
448
  export {
436
449
  p as ECallCause,
437
- Re as EMimeTypesVideoCodecs,
438
- Ie as EStatsTypes,
439
- Ue as EUseLicense,
440
- ke as SipConnector,
441
- Fe as SipConnectorFacade,
442
- xe as StatsPeerConnection,
443
- Le as disableDebug,
444
- Ve as enableDebug,
445
- Be as getCodecFromSender,
446
- Ae as hasAvailableStats,
447
- Ne as hasCanceledCallError,
448
- $e as hasCanceledStartPresentationError,
449
- He as hasConnectionPromiseIsNotActualError,
450
- ye as tools
450
+ w as ECallStatus,
451
+ He as EConnectionStatus,
452
+ H as EIncomingStatus,
453
+ Ne as EMimeTypesVideoCodecs,
454
+ je as EPresentationStatus,
455
+ Ke as EStatsTypes,
456
+ Xe as EUseLicense,
457
+ Ye as SipConnector,
458
+ Be as SipConnectorFacade,
459
+ Ge as StatsPeerConnection,
460
+ qe as disableDebug,
461
+ ze as enableDebug,
462
+ Je as getCodecFromSender,
463
+ Ve as hasAvailableStats,
464
+ ke as hasCanceledCallError,
465
+ Qe as hasCanceledStartPresentationError,
466
+ en as hasConnectionPromiseIsNotActualError,
467
+ xe as sessionSelectors,
468
+ Le as tools
451
469
  };
@@ -0,0 +1,26 @@
1
+ import { CallManager } from '../CallManager';
2
+ import { ConnectionManager } from '../ConnectionManager';
3
+ import { IncomingCallManager } from '../IncomingCallManager';
4
+ import { PresentationManager } from '../PresentationManager';
5
+ import { TSessionActors, TSessionSnapshot } from './types';
6
+ type TEqualityFunction<T> = (previous: T, next: T) => boolean;
7
+ type TSelector<T> = (snapshot: TSessionSnapshot) => T;
8
+ type TSubscribeOverload = {
9
+ (listener: (snapshot: TSessionSnapshot) => void): () => void;
10
+ <T>(selector: TSelector<T>, listener: (value: T) => void, equals?: TEqualityFunction<T>): () => void;
11
+ };
12
+ export interface ISession {
13
+ getSnapshot: () => TSessionSnapshot;
14
+ subscribe: TSubscribeOverload;
15
+ stop: () => void;
16
+ actors: TSessionActors;
17
+ actor: TSessionActors;
18
+ }
19
+ type TSessionDeps = {
20
+ connectionManager: Pick<ConnectionManager, 'connectionActor'>;
21
+ callManager: Pick<CallManager, 'callActor'>;
22
+ incomingCallManager: Pick<IncomingCallManager, 'incomingActor'>;
23
+ presentationManager: Pick<PresentationManager, 'presentationActor'>;
24
+ };
25
+ export declare const createSession: (deps: TSessionDeps) => ISession;
26
+ export {};
@@ -0,0 +1,5 @@
1
+ export { createSession } from './createSession';
2
+ export { sessionSelectors } from './selectors';
3
+ export { ECallStatus, EConnectionStatus, EIncomingStatus, EPresentationStatus } from './types';
4
+ export type { ISession } from './createSession';
5
+ export type { TSessionActors, TSessionSnapshot } from './types';
@@ -0,0 +1,10 @@
1
+ import { EIncomingStatus, ECallStatus, EConnectionStatus, EPresentationStatus, TSessionSnapshot } from './types';
2
+ import { TRemoteCallerData } from '../IncomingCallManager';
3
+ export declare const sessionSelectors: {
4
+ selectConnectionStatus: (snapshot: TSessionSnapshot) => EConnectionStatus;
5
+ selectCallStatus: (snapshot: TSessionSnapshot) => ECallStatus;
6
+ selectIncomingStatus: (snapshot: TSessionSnapshot) => EIncomingStatus;
7
+ selectIncomingRemoteCaller: (snapshot: TSessionSnapshot) => TRemoteCallerData | undefined;
8
+ selectPresentationStatus: (snapshot: TSessionSnapshot) => EPresentationStatus;
9
+ selectIsInCall: (snapshot: TSessionSnapshot) => boolean;
10
+ };