sip-connector 6.24.2 → 6.25.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 (61) hide show
  1. package/dist/SipConnector-BrUmibLH.cjs +1 -0
  2. package/dist/{SipConnector-BmPmOGi6.js → SipConnector-Dq76GLMy.js} +216 -205
  3. package/dist/SipConnector.d.ts +6 -4
  4. package/dist/__fixtures__/BaseSession.mock.d.ts +4 -4
  5. package/dist/__fixtures__/RTCPeerConnectionMock.d.ts +3 -2
  6. package/dist/__fixtures__/Registrator.mock.d.ts +2 -1
  7. package/dist/__fixtures__/Request.mock.d.ts +1 -0
  8. package/dist/__fixtures__/Session.mock.d.ts +3 -3
  9. package/dist/__fixtures__/UA.mock.d.ts +6 -7
  10. package/dist/__fixtures__/index.d.ts +5 -4
  11. package/dist/__fixtures__/jssip.mock.d.ts +5 -4
  12. package/dist/__fixtures__/participantMoveRequests.d.ts +1 -0
  13. package/dist/constants.d.ts +2 -0
  14. package/dist/doMock.cjs +1 -1
  15. package/dist/doMock.d.ts +2 -1
  16. package/dist/doMock.js +1 -1
  17. package/dist/eventNames.d.ts +2 -2
  18. package/dist/headers.d.ts +3 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.ts +2 -1
  21. package/dist/index.js +156 -155
  22. package/dist/logger.d.ts +2 -1
  23. package/dist/tools/__fixtures__/call.d.ts +3 -3
  24. package/dist/tools/__fixtures__/connectToServer.d.ts +3 -2
  25. package/dist/tools/__fixtures__/hasValidUri.d.ts +2 -1
  26. package/dist/tools/__fixtures__/processRequest.d.ts +2 -1
  27. package/dist/tools/answerIncomingCall.d.ts +13 -12
  28. package/dist/tools/callToServer.d.ts +13 -12
  29. package/dist/tools/connectToServer.d.ts +3 -2
  30. package/dist/tools/disconnectFromServer.d.ts +2 -1
  31. package/dist/tools/error/getLinkError.d.ts +2 -1
  32. package/dist/tools/error/getTypeFromError.d.ts +2 -1
  33. package/dist/tools/error/getValuesFromError.d.ts +2 -1
  34. package/dist/tools/getExtraHeaders.d.ts +4 -4
  35. package/dist/tools/getUserAgent.d.ts +2 -2
  36. package/dist/tools/index.d.ts +1 -0
  37. package/dist/tools/resolveAskPermissionToEnableCam.d.ts +2 -1
  38. package/dist/tools/resolveGetRemoteStreams.d.ts +2 -1
  39. package/dist/tools/resolveOnMoveToSpectators.d.ts +4 -0
  40. package/dist/tools/resolveOnMustStopPresentation.d.ts +2 -1
  41. package/dist/tools/resolveOnUseLicense.d.ts +3 -2
  42. package/dist/tools/resolveSendMediaState.d.ts +2 -1
  43. package/dist/tools/resolveSendRefusalToTurnOnCam.d.ts +2 -1
  44. package/dist/tools/resolveSendRefusalToTurnOnMic.d.ts +2 -1
  45. package/dist/tools/resolveStartPresentation.d.ts +3 -2
  46. package/dist/tools/resolveStopShareSipConnector.d.ts +3 -2
  47. package/dist/tools/resolveUpdatePresentation.d.ts +3 -2
  48. package/dist/tools/sendDTMFAccumulated.d.ts +1 -1
  49. package/dist/tools/syncMediaState/index.d.ts +2 -1
  50. package/dist/tools/syncMediaState/resolveOnStartMainCam.d.ts +2 -1
  51. package/dist/tools/syncMediaState/resolveOnStartMic.d.ts +2 -1
  52. package/dist/tools/syncMediaState/resolveOnStopMainCam.d.ts +2 -1
  53. package/dist/tools/syncMediaState/resolveOnStopMic.d.ts +2 -1
  54. package/dist/types.d.ts +2 -1
  55. package/dist/utils.d.ts +2 -2
  56. package/dist/videoSendingBalancer/balance.d.ts +7 -6
  57. package/dist/videoSendingBalancer/index.d.ts +7 -6
  58. package/dist/videoSendingBalancer/processSender.d.ts +5 -4
  59. package/dist/videoSendingBalancer/scaleBitrate.d.ts +1 -1
  60. package/package.json +8 -8
  61. package/dist/SipConnector-DMjzYyq_.cjs +0 -1
package/dist/index.js CHANGED
@@ -1,39 +1,39 @@
1
- import { l as c, B as V, N as $, E as P, s as q, S as nn } from "./SipConnector-BmPmOGi6.js";
2
- import { f as un, g as ln, i as Sn, c as dn, a as mn, d as fn, b as Cn, e as En, h as gn } from "./SipConnector-BmPmOGi6.js";
1
+ import { l as o, B as V, N as $, E as P, s as q, S as tn } from "./SipConnector-Dq76GLMy.js";
2
+ import { f as ln, g as Sn, i as dn, c as mn, a as fn, d as Cn, b as En, e as gn, h as Rn } from "./SipConnector-Dq76GLMy.js";
3
3
  import { debounce as J } from "ts-debounce";
4
4
  import { isCanceledError as Q } from "@krivega/cancelable-promise";
5
- import { default as hn } from "debug";
6
- const G = "purgatory", A = (e) => e === G, k = (e) => () => (c("getRemoteStreams"), e.getRemoteStreams()), Z = ({ kind: e, readyState: n }) => e === "video" && n === "live", j = (e) => ({ track: n }) => {
5
+ import { default as Tn } from "debug";
6
+ const G = "purgatory", A = (e) => e === G, k = (e) => () => (o("getRemoteStreams"), e.getRemoteStreams()), Z = ({ kind: e, readyState: n }) => e === "video" && n === "live", j = (e) => ({ track: n }) => {
7
7
  Z(n) && e();
8
8
  }, D = ({
9
9
  getRemoteStreams: e,
10
10
  setRemoteStreams: n
11
11
  }) => J(() => {
12
12
  const t = e();
13
- c("remoteStreams", t), t && n(t);
13
+ o("remoteStreams", t), t && n(t);
14
14
  }, 200), ee = (e) => async (t) => {
15
15
  const {
16
16
  mediaStream: s,
17
17
  extraHeaders: r,
18
- iceServers: o,
18
+ iceServers: c,
19
19
  degradationPreference: a,
20
20
  setRemoteStreams: u,
21
21
  onBeforeProgressCall: m,
22
22
  onSuccessProgressCall: g,
23
23
  onEnterPurgatory: C,
24
24
  onEnterConference: f,
25
- onFailProgressCall: T,
25
+ onFailProgressCall: y,
26
26
  onFinishProgressCall: E,
27
- onEndedCall: y
27
+ onEndedCall: T
28
28
  } = t, R = D({
29
29
  setRemoteStreams: u,
30
30
  getRemoteStreams: k(e)
31
31
  }), M = j(R);
32
- c("answerIncomingCall", t);
33
- const v = async () => e.answerToIncomingCall({
32
+ o("answerIncomingCall", t);
33
+ const O = async () => e.answerToIncomingCall({
34
34
  mediaStream: s,
35
35
  extraHeaders: r,
36
- iceServers: o,
36
+ iceServers: c,
37
37
  degradationPreference: a,
38
38
  ontrack: M
39
39
  }), p = () => {
@@ -41,61 +41,61 @@ const G = "purgatory", A = (e) => e === G, k = (e) => () => (c("getRemoteStreams
41
41
  return l.incomingNumber;
42
42
  };
43
43
  let _ = !1, i;
44
- const S = (c("subscribeEnterConference: onEnterConference", f), C ?? f ? e.onSession("enterRoom", (l) => {
45
- c("enterRoom", { _room: l, isSuccessProgressCall: _ }), i = l, A(i) ? C && C() : f && f({ isSuccessProgressCall: _ });
44
+ const S = (o("subscribeEnterConference: onEnterConference", f), C ?? f ? e.onSession("enterRoom", (l) => {
45
+ o("enterRoom", { _room: l, isSuccessProgressCall: _ }), i = l, A(i) ? C && C() : f && f({ isSuccessProgressCall: _ });
46
46
  }) : () => {
47
- }), h = (l) => (c("onSuccess"), _ = !0, R(), g && g({ isPurgatory: A(i) }), e.onceRaceSession(["ended", "failed"], () => {
48
- S(), y && y();
47
+ }), h = (l) => (o("onSuccess"), _ = !0, R(), g && g({ isPurgatory: A(i) }), e.onceRaceSession(["ended", "failed"], () => {
48
+ S(), T && T();
49
49
  }), l), b = (l) => {
50
- throw c("onFail"), T && T(), S(), l;
51
- }, O = () => {
52
- c("onFinish"), E && E();
50
+ throw o("onFail"), y && y(), S(), l;
51
+ }, N = () => {
52
+ o("onFinish"), E && E();
53
53
  };
54
- if (c("onBeforeProgressCall"), m) {
54
+ if (o("onBeforeProgressCall"), m) {
55
55
  const l = p();
56
56
  m(l);
57
57
  }
58
- return v().then(h).catch((l) => b(l)).finally(O);
58
+ return O().then(h).catch((l) => b(l)).finally(N);
59
59
  }, ne = (e) => async (t) => {
60
60
  const {
61
61
  conference: s,
62
62
  mediaStream: r,
63
- extraHeaders: o,
63
+ extraHeaders: c,
64
64
  iceServers: a,
65
65
  degradationPreference: u,
66
66
  setRemoteStreams: m,
67
67
  onBeforeProgressCall: g,
68
68
  onSuccessProgressCall: C,
69
69
  onEnterPurgatory: f,
70
- onEnterConference: T,
70
+ onEnterConference: y,
71
71
  onFailProgressCall: E,
72
- onFinishProgressCall: y,
72
+ onFinishProgressCall: T,
73
73
  onEndedCall: R
74
74
  } = t, M = D({
75
75
  setRemoteStreams: m,
76
76
  getRemoteStreams: k(e)
77
- }), v = j(M);
78
- c("callToServer", t);
79
- const p = async () => (c("startCall"), e.call({
77
+ }), O = j(M);
78
+ o("callToServer", t);
79
+ const p = async () => (o("startCall"), e.call({
80
80
  mediaStream: r,
81
- extraHeaders: o,
81
+ extraHeaders: c,
82
82
  iceServers: a,
83
83
  degradationPreference: u,
84
84
  number: s,
85
- ontrack: v
85
+ ontrack: O
86
86
  }));
87
87
  let _ = !1, i;
88
- const S = (c("subscribeEnterConference: onEnterConference", T), f ?? T ? e.onSession("enterRoom", (l) => {
89
- c("enterRoom", { _room: l, isSuccessProgressCall: _ }), i = l, A(i) ? f && f() : T && T({ isSuccessProgressCall: _ });
88
+ const S = (o("subscribeEnterConference: onEnterConference", y), f ?? y ? e.onSession("enterRoom", (l) => {
89
+ o("enterRoom", { _room: l, isSuccessProgressCall: _ }), i = l, A(i) ? f && f() : y && y({ isSuccessProgressCall: _ });
90
90
  }) : () => {
91
- }), h = (l) => (c("onSuccess"), _ = !0, M(), C && C({ isPurgatory: A(i) }), e.onceRaceSession(["ended", "failed"], () => {
91
+ }), h = (l) => (o("onSuccess"), _ = !0, M(), C && C({ isPurgatory: A(i) }), e.onceRaceSession(["ended", "failed"], () => {
92
92
  S(), R && R();
93
93
  }), l), b = (l) => {
94
- throw c("onFail"), E && E(), S(), l;
95
- }, O = () => {
96
- c("onFinish"), y && y();
94
+ throw o("onFail"), E && E(), S(), l;
95
+ }, N = () => {
96
+ o("onFinish"), T && T();
97
97
  };
98
- return c("onBeforeProgressCall"), g && g(s), p().then(h).catch((l) => b(l)).finally(O);
98
+ return o("onBeforeProgressCall"), g && g(s), p().then(h).catch((l) => b(l)).finally(N);
99
99
  }, w = (e) => {
100
100
  if (!Q(e))
101
101
  throw e;
@@ -104,27 +104,27 @@ const G = "purgatory", A = (e) => e === G, k = (e) => () => (c("getRemoteStreams
104
104
  const {
105
105
  userAgent: s,
106
106
  sipWebSocketServerURL: r,
107
- sipServerUrl: o,
107
+ sipServerUrl: c,
108
108
  remoteAddress: a,
109
109
  displayName: u,
110
110
  name: m,
111
111
  password: g,
112
112
  isRegisteredUser: C,
113
113
  sdpSemantics: f,
114
- isDisconnectOnFail: T
114
+ isDisconnectOnFail: y
115
115
  } = t;
116
- return c("connectToServer", t), e.connect({
116
+ return o("connectToServer", t), e.connect({
117
117
  userAgent: s,
118
118
  sdpSemantics: f,
119
119
  sipWebSocketServerURL: r,
120
- sipServerUrl: o,
120
+ sipServerUrl: c,
121
121
  remoteAddress: a,
122
122
  displayName: u,
123
123
  password: g,
124
124
  user: m,
125
125
  register: C
126
- }).then((E) => (c("connectToServer then"), { ua: E, isSuccessful: !0 })).catch(async (E) => (c("connectToServer catch: error", E), T === !0 ? e.disconnect().then(() => w(E)).catch(() => w(E)) : w(E)));
127
- }, se = (e) => async () => (c("disconnectFromServer"), e.disconnect().then(() => (c("disconnectFromServer: then"), { isSuccessful: !0 })).catch((n) => (c("disconnectFromServer: catch", n), { isSuccessful: !1 }))), F = (e) => {
126
+ }).then((E) => (o("connectToServer then"), { ua: E, isSuccessful: !0 })).catch(async (E) => (o("connectToServer catch: error", E), y === !0 ? e.disconnect().then(() => w(E)).catch(() => w(E)) : w(E)));
127
+ }, se = (e) => async () => (o("disconnectFromServer"), e.disconnect().then(() => (o("disconnectFromServer: then"), { isSuccessful: !0 })).catch((n) => (o("disconnectFromServer: catch", n), { isSuccessful: !1 }))), F = (e) => {
128
128
  const { url: n, cause: t } = e;
129
129
  let s = n;
130
130
  return (t === V || t === $) && (s = `${e.message.to.uri.user}@${e.message.to.uri.host}`), s;
@@ -152,8 +152,8 @@ const re = (e = new Error()) => {
152
152
  }
153
153
  return s;
154
154
  }, oe = (e = new Error()) => {
155
- const { code: n, cause: t, message: s } = e, r = F(e), o = {};
156
- return s && (o.message = s), r && (o.link = r), n && (o.code = n), t && (o.cause = t), o;
155
+ const { code: n, cause: t, message: s } = e, r = F(e), c = {};
156
+ return s && (c.message = s), r && (c.link = r), n && (c.code = n), t && (c.cause = t), c;
157
157
  }, ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
158
158
  __proto__: null,
159
159
  EErrorTypes: X,
@@ -166,10 +166,10 @@ const re = (e = new Error()) => {
166
166
  isMutedAudio: t,
167
167
  isMutedVideo: s,
168
168
  isRegistered: r,
169
- isPresentationCall: o
169
+ isPresentationCall: c
170
170
  }) => {
171
171
  const a = [], u = t ? "0" : "1", m = s ? "0" : "1";
172
- return a.push(`X-Vinteo-Mic-State: ${u}`, `X-Vinteo-MainCam-State: ${m}`), r || a.push("X-Vinteo-Purgatory-Call: yes"), e && a.push(`X-Vinteo-Session: ${e}`), o && a.push("X-Vinteo-Presentation-Call: yes"), n && a.push(`X-Vinteo-Remote: ${n}`), a;
172
+ return a.push(`X-Vinteo-Mic-State: ${u}`, `X-Vinteo-MainCam-State: ${m}`), r || a.push("X-Vinteo-Purgatory-Call: yes"), e && a.push(`X-Vinteo-Session: ${e}`), c && a.push("X-Vinteo-Presentation-Call: yes"), n && a.push(`X-Vinteo-Remote: ${n}`), a;
173
173
  }, ie = ({
174
174
  appName: e,
175
175
  appVersion: n,
@@ -186,58 +186,58 @@ const re = (e = new Error()) => {
186
186
  appName: r
187
187
  }) => e ? ie({ appVersion: n, browserName: t, browserVersion: s, appName: r }) : "Chrome", le = (e) => async () => {
188
188
  if (e.isCallActive)
189
- return c("askPermissionToEnableCam"), e.askPermissionToEnableCam();
190
- }, Se = (e) => (t) => (c("onMustStopPresentation"), e.onSession("mustStopPresentation", t)), de = (e) => (t) => (c("onUseLicense"), e.onSession("useLicense", t)), me = (e) => async ({
189
+ return o("askPermissionToEnableCam"), e.askPermissionToEnableCam();
190
+ }, Se = (e) => (t) => (o("onMustStopPresentation"), e.onSession("mustStopPresentation", t)), de = (e) => (t) => (o("onMoveToSpectators"), e.onSession("participant:move-request-to-spectators", t)), me = (e) => (t) => (o("onUseLicense"), e.onSession("useLicense", t)), fe = (e) => async ({
191
191
  isEnabledCam: t,
192
192
  isEnabledMic: s
193
193
  }) => {
194
194
  if (e.isCallActive)
195
- return c("sendMediaState"), e.sendMediaState({ cam: t, mic: s });
196
- }, fe = (e) => async () => {
195
+ return o("sendMediaState"), e.sendMediaState({ cam: t, mic: s });
196
+ }, Ce = (e) => async () => {
197
197
  if (e.isCallActive)
198
- return c("sendRefusalToTurnOnCam"), e.sendRefusalToTurnOnCam().catch((t) => {
199
- c("sendRefusalToTurnOnCam: error", t);
198
+ return o("sendRefusalToTurnOnCam"), e.sendRefusalToTurnOnCam().catch((t) => {
199
+ o("sendRefusalToTurnOnCam: error", t);
200
200
  });
201
- }, Ce = (e) => async () => {
201
+ }, Ee = (e) => async () => {
202
202
  if (e.isCallActive)
203
- return c("sendRefusalToTurnOnMic"), e.sendRefusalToTurnOnMic().catch((t) => {
204
- c("sendRefusalToTurnOnMic: error", t);
203
+ return o("sendRefusalToTurnOnMic"), e.sendRefusalToTurnOnMic().catch((t) => {
204
+ o("sendRefusalToTurnOnMic: error", t);
205
205
  });
206
- }, Ee = 1e6, ge = ({
207
- maxBitrate: e = Ee,
206
+ }, ge = 1e6, Re = ({
207
+ maxBitrate: e = ge,
208
208
  sipConnector: n
209
209
  }) => async ({
210
210
  mediaStream: s,
211
211
  isP2P: r = !1
212
- }) => (c("startPresentation"), n.startPresentation(s, {
212
+ }) => (o("startPresentation"), n.startPresentation(s, {
213
213
  isP2P: r,
214
214
  maxBitrate: e
215
- })), Re = ({ sipConnector: e }) => async ({ isP2P: t = !1 } = {}) => (c("stopShareSipConnector"), e.stopPresentation({
215
+ })), he = ({ sipConnector: e }) => async ({ isP2P: t = !1 } = {}) => (o("stopShareSipConnector"), e.stopPresentation({
216
216
  isP2P: t
217
217
  }).catch((s) => {
218
- c(s);
219
- })), he = 1e6, ye = ({
218
+ o(s);
219
+ })), Te = 1e6, ye = ({
220
220
  sipConnector: e,
221
- maxBitrate: n = he
221
+ maxBitrate: n = Te
222
222
  }) => async ({
223
223
  mediaStream: s,
224
224
  isP2P: r = !1
225
- }) => (c("updatePresentation"), e.updatePresentation(s, {
225
+ }) => (o("updatePresentation"), e.updatePresentation(s, {
226
226
  isP2P: r,
227
227
  maxBitrate: n
228
- })), Te = "ERROR_NOT_RUNNING", Me = (e) => {
228
+ })), Me = "ERROR_NOT_RUNNING", _e = (e) => {
229
229
  const n = new Error("Promise was not running");
230
- return n.basePromise = e, n.id = Te, n.name = "Not running", n;
231
- }, _e = async (e, n) => e.reduce(
232
- async (t, s) => t.then(async ({ success: r, errors: o, results: a }) => (!n || n(s) ? s() : Promise.reject(Me(s))).then((u) => ({
233
- errors: o,
230
+ return n.basePromise = e, n.id = Me, n.name = "Not running", n;
231
+ }, be = async (e, n) => e.reduce(
232
+ async (t, s) => t.then(async ({ success: r, errors: c, results: a }) => (!n || n(s) ? s() : Promise.reject(_e(s))).then((u) => ({
233
+ errors: c,
234
234
  success: [...r, u],
235
235
  results: [...a, u],
236
236
  isSuccessful: !0,
237
237
  isError: !1
238
238
  })).catch((u) => ({
239
239
  success: r,
240
- errors: [...o, u],
240
+ errors: [...c, u],
241
241
  results: [...a, u],
242
242
  isSuccessful: !1,
243
243
  isError: !0
@@ -249,65 +249,65 @@ const re = (e = new Error()) => {
249
249
  isSuccessful: !1,
250
250
  isError: !1
251
251
  })
252
- ), be = (e) => (n) => [...n].map((s) => async () => e(s)), Ne = async ({
252
+ ), ve = (e) => (n) => [...n].map((s) => async () => e(s)), Ne = async ({
253
253
  accumulatedKeys: e,
254
254
  sendKey: n,
255
255
  canRunTask: t
256
256
  }) => {
257
- const r = be(n)(e);
258
- return _e(r, t);
259
- }, Oe = (e) => (t) => (c("onStartMainCam"), e.onSession("admin-start-main-cam", t)), ve = (e) => (t) => (c("onStartMic"), e.onSession("admin-start-mic", t)), pe = (e) => (t) => (c("onStopMainCam"), e.onSession("admin-stop-main-cam", t)), Ae = (e) => (t) => (c("onStopMic"), e.onSession("admin-stop-mic", t)), Pe = ({ sipConnector: e }) => {
260
- const n = (y, R) => ({ isSyncForced: M = !1 }) => {
257
+ const r = ve(n)(e);
258
+ return be(r, t);
259
+ }, Oe = (e) => (t) => (o("onStartMainCam"), e.onSession("admin-start-main-cam", t)), pe = (e) => (t) => (o("onStartMic"), e.onSession("admin-start-mic", t)), Ae = (e) => (t) => (o("onStopMainCam"), e.onSession("admin-stop-main-cam", t)), Pe = (e) => (t) => (o("onStopMic"), e.onSession("admin-stop-mic", t)), we = ({ sipConnector: e }) => {
260
+ const n = (T, R) => ({ isSyncForced: M = !1 }) => {
261
261
  if (M) {
262
- y();
262
+ T();
263
263
  return;
264
264
  }
265
265
  R();
266
- }, t = Oe(e), s = pe(e), r = ve(e), o = Ae(e);
266
+ }, t = Oe(e), s = Ae(e), r = pe(e), c = Pe(e);
267
267
  let a = () => {
268
268
  }, u = () => {
269
269
  }, m = () => {
270
270
  }, g = () => {
271
271
  };
272
272
  const C = ({
273
- onStartMainCamForced: y,
273
+ onStartMainCamForced: T,
274
274
  onStartMainCamNotForced: R,
275
275
  onStopMainCamForced: M,
276
- onStopMainCamNotForced: v,
276
+ onStopMainCamNotForced: O,
277
277
  onStartMicForced: p,
278
278
  onStartMicNotForced: _,
279
279
  onStopMicForced: i,
280
280
  onStopMicNotForced: d
281
281
  }) => {
282
282
  const S = n(
283
- y,
283
+ T,
284
284
  R
285
285
  );
286
286
  a = t(S);
287
287
  const h = n(
288
288
  M,
289
- v
289
+ O
290
290
  );
291
291
  u = s(h);
292
292
  const b = n(p, _);
293
293
  m = r(b);
294
- const O = n(i, d);
295
- g = o(O);
294
+ const N = n(i, d);
295
+ g = c(N);
296
296
  }, f = () => {
297
297
  a(), u(), m(), g();
298
298
  };
299
299
  return {
300
- start: (y) => {
301
- C(y);
300
+ start: (T) => {
301
+ C(T);
302
302
  },
303
303
  stop: () => {
304
304
  f();
305
305
  }
306
306
  };
307
- }, rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
307
+ }, on = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
308
308
  __proto__: null,
309
309
  PURGATORY_CONFERENCE_NUMBER: G,
310
- createSyncMediaState: Pe,
310
+ createSyncMediaState: we,
311
311
  error: ce,
312
312
  getExtraHeaders: ae,
313
313
  getUserAgent: ue,
@@ -318,35 +318,36 @@ const re = (e = new Error()) => {
318
318
  resolveConnectToServer: te,
319
319
  resolveDisconnectFromServer: se,
320
320
  resolveGetRemoteStreams: k,
321
+ resolveOnMoveToSpectators: de,
321
322
  resolveOnMustStopPresentation: Se,
322
- resolveOnUseLicense: de,
323
- resolveSendMediaState: me,
324
- resolveSendRefusalToTurnOnCam: fe,
325
- resolveSendRefusalToTurnOnMic: Ce,
326
- resolveStartPresentation: ge,
327
- resolveStopShareSipConnector: Re,
323
+ resolveOnUseLicense: me,
324
+ resolveSendMediaState: fe,
325
+ resolveSendRefusalToTurnOnCam: Ce,
326
+ resolveSendRefusalToTurnOnMic: Ee,
327
+ resolveStartPresentation: Re,
328
+ resolveStopShareSipConnector: he,
328
329
  resolveUpdatePresentation: ye,
329
330
  resolveUpdateRemoteStreams: D,
330
331
  sendDTMFAccumulated: Ne
331
- }, Symbol.toStringTag, { value: "Module" })), we = (e) => [...e.keys()].map((n) => e.get(n)), Ie = (e, n) => we(e).find((t) => t.type === n), Be = async (e) => e.getStats().then((n) => {
332
- const t = Ie(n, "codec");
332
+ }, Symbol.toStringTag, { value: "Module" })), Ie = (e) => [...e.keys()].map((n) => e.get(n)), Be = (e, n) => Ie(e).find((t) => t.type === n), ke = async (e) => e.getStats().then((n) => {
333
+ const t = Be(n, "codec");
333
334
  return t == null ? void 0 : t.mimeType;
334
- }), ke = (e) => e.find((n) => {
335
+ }), De = (e) => e.find((n) => {
335
336
  var t;
336
337
  return ((t = n == null ? void 0 : n.track) == null ? void 0 : t.kind) === "video";
337
- }), K = (e, n) => e !== void 0 && n !== void 0 && e.toLowerCase().includes(n.toLowerCase()), De = "ERROR_NOT_RUNNING", Fe = (e) => {
338
+ }), K = (e, n) => e !== void 0 && n !== void 0 && e.toLowerCase().includes(n.toLowerCase()), Fe = "ERROR_NOT_RUNNING", Ue = (e) => {
338
339
  const n = new Error("Promise was not running");
339
- return n.basePromise = e, n.id = De, n.name = "Not running", n;
340
- }, Ue = async (e, n) => e.reduce(
341
- async (t, s) => t.then(async ({ success: r, errors: o, results: a }) => (!n || n(s) ? s() : Promise.reject(Fe(s))).then((u) => ({
342
- errors: o,
340
+ return n.basePromise = e, n.id = Fe, n.name = "Not running", n;
341
+ }, Le = async (e, n) => e.reduce(
342
+ async (t, s) => t.then(async ({ success: r, errors: c, results: a }) => (!n || n(s) ? s() : Promise.reject(Ue(s))).then((u) => ({
343
+ errors: c,
343
344
  success: [...r, u],
344
345
  results: [...a, u],
345
346
  isSuccessful: !0,
346
347
  isError: !1
347
348
  })).catch((u) => ({
348
349
  success: r,
349
- errors: [...o, u],
350
+ errors: [...c, u],
350
351
  results: [...a, u],
351
352
  isSuccessful: !1,
352
353
  isError: !0
@@ -358,16 +359,16 @@ const re = (e = new Error()) => {
358
359
  isSuccessful: !1,
359
360
  isError: !1
360
361
  })
361
- ), Le = new Error("Stack is empty"), I = (e) => e[e.length - 1], xe = new Error("Promise is not actual"), Ve = new Error(
362
+ ), xe = new Error("Stack is empty"), I = (e) => e[e.length - 1], Ve = new Error("Promise is not actual"), $e = new Error(
362
363
  "stackPromises only works with functions that returns a Promise"
363
- ), $e = ({
364
+ ), Ge = ({
364
365
  noRejectIsNotActual: e = !1,
365
366
  noRunIsNotActual: n = !1
366
367
  } = {}) => {
367
368
  const t = [], s = [], r = ({ task: i, index: d }) => {
368
369
  s.push({ task: i, index: d });
369
- }, o = (i, { task: d, index: S }) => {
370
- const h = s.find(({ task: b, index: O }) => d === b && S === O);
370
+ }, c = (i, { task: d, index: S }) => {
371
+ const h = s.find(({ task: b, index: N }) => d === b && S === N);
371
372
  if (!h)
372
373
  throw new Error("Task not found");
373
374
  if (h.promise)
@@ -386,13 +387,13 @@ const re = (e = new Error()) => {
386
387
  }, m = ({ task: i, index: d }) => (r({ task: i, index: d }), async () => {
387
388
  let S = a({ task: i, index: d });
388
389
  const h = u({ task: i });
389
- return !S && n && !h ? Promise.resolve() : (S || (S = i({ isActual: h }), o(S, { task: i, index: d })), S);
390
+ return !S && n && !h ? Promise.resolve() : (S || (S = i({ isActual: h }), c(S, { task: i, index: d })), S);
390
391
  }), g = ({
391
392
  resolve: i,
392
393
  reject: d
393
394
  }) => ({ results: S, isSuccessful: h }) => {
394
- const b = S.length, O = t.length;
395
- if (b === O) {
395
+ const b = S.length, N = t.length;
396
+ if (b === N) {
396
397
  const l = I(S);
397
398
  if (h) {
398
399
  i(l);
@@ -406,43 +407,43 @@ const re = (e = new Error()) => {
406
407
  i(l);
407
408
  return;
408
409
  }
409
- d(xe);
410
+ d(Ve);
410
411
  };
411
412
  let C = !1;
412
413
  const f = () => {
413
414
  C = !0;
414
- }, T = () => {
415
+ }, y = () => {
415
416
  C = !1;
416
- }, E = () => C, y = async () => (f(), Ue(t, E)), R = async () => {
417
+ }, E = () => C, T = async () => (f(), Le(t, E)), R = async () => {
417
418
  if (t.length === 0)
418
- throw Le;
419
+ throw xe;
419
420
  return new Promise((i, d) => {
420
421
  const S = g({ resolve: i, reject: d });
421
- y().then(S).catch(S);
422
+ T().then(S).catch(S);
422
423
  });
423
424
  }, M = (i) => {
424
425
  if (typeof i != "function")
425
- throw Ve;
426
+ throw $e;
426
427
  const d = t.length;
427
428
  return t.push(m({ task: i, index: d })), R;
428
- }, v = async (i) => (M(i), R()), p = () => {
429
+ }, O = async (i) => (M(i), R()), p = () => {
429
430
  t.length = 0, s.length = 0;
430
431
  }, _ = () => {
431
- T(), p();
432
+ y(), p();
432
433
  };
433
- return R.add = M, R.run = v, R.stop = _, R;
434
- }, Ge = 1e6, N = (e) => e * Ge, W = N(0.06), je = N(4), Xe = (e) => e <= 64 ? W : e <= 128 ? N(0.12) : e <= 256 ? N(0.25) : e <= 384 ? N(0.32) : e <= 426 ? N(0.38) : e <= 640 ? N(0.5) : e <= 848 ? N(0.7) : e <= 1280 ? N(1) : e <= 1920 ? N(2) : je, Ke = "av1", We = (e) => K(e, Ke), He = 0.6, H = (e, n) => We(n) ? e * He : e, Ye = (e) => H(W, e), Y = (e, n) => {
435
- const t = Xe(e);
434
+ return R.add = M, R.run = O, R.stop = _, R;
435
+ }, je = 1e6, v = (e) => e * je, W = v(0.06), Xe = v(4), Ke = (e) => e <= 64 ? W : e <= 128 ? v(0.12) : e <= 256 ? v(0.25) : e <= 384 ? v(0.32) : e <= 426 ? v(0.38) : e <= 640 ? v(0.5) : e <= 848 ? v(0.7) : e <= 1280 ? v(1) : e <= 1920 ? v(2) : Xe, We = "av1", He = (e) => K(e, We), Ye = 0.6, H = (e, n) => He(n) ? e * Ye : e, ze = (e) => H(W, e), Y = (e, n) => {
436
+ const t = Ke(e);
436
437
  return H(t, n);
437
- }, z = $e(), ze = async () => z().catch((e) => {
438
- c("videoSendingBalancer: error", e);
439
- }), qe = async (e) => (z.add(e), ze()), U = async ({
438
+ }, z = Ge(), qe = async () => z().catch((e) => {
439
+ o("videoSendingBalancer: error", e);
440
+ }), Je = async (e) => (z.add(e), qe()), U = async ({
440
441
  sender: e,
441
442
  scaleResolutionDownBy: n,
442
443
  maxBitrate: t,
443
444
  onSetParameters: s
444
- }) => qe(async () => q(e, { scaleResolutionDownBy: n, maxBitrate: t }, s)), Je = async ({ sender: e, codec: n }, t) => {
445
- const r = Ye(n);
445
+ }) => Je(async () => q(e, { scaleResolutionDownBy: n, maxBitrate: t }, s)), Qe = async ({ sender: e, codec: n }, t) => {
446
+ const r = ze(n);
446
447
  return U({
447
448
  sender: e,
448
449
  maxBitrate: r,
@@ -457,38 +458,38 @@ const re = (e = new Error()) => {
457
458
  onSetParameters: s,
458
459
  scaleResolutionDownBy: 1
459
460
  });
460
- }, Qe = async ({
461
+ }, Ze = async ({
461
462
  sender: e,
462
463
  track: n,
463
464
  resolution: t,
464
465
  codec: s
465
466
  }, r) => {
466
- const o = n.getSettings(), a = o.width, u = o.height, [m, g] = t.split("x"), C = a / Number(m), f = u / Number(g), E = Math.max(C, f, 1), y = Y(Number(m), s);
467
+ const c = n.getSettings(), a = c.width, u = c.height, [m, g] = t.split("x"), C = a / Number(m), f = u / Number(g), E = Math.max(C, f, 1), T = Y(Number(m), s);
467
468
  return U({
468
469
  sender: e,
469
- maxBitrate: y,
470
+ maxBitrate: T,
470
471
  onSetParameters: r,
471
472
  scaleResolutionDownBy: E
472
473
  });
473
- }, Ze = async ({
474
+ }, en = async ({
474
475
  mainCam: e,
475
476
  resolutionMainCam: n,
476
477
  sender: t,
477
478
  track: s,
478
479
  codec: r
479
- }, o) => {
480
+ }, c) => {
480
481
  switch (e) {
481
482
  case P.PAUSE_MAIN_CAM:
482
- return Je({ sender: t, codec: r }, o);
483
+ return Qe({ sender: t, codec: r }, c);
483
484
  case P.RESUME_MAIN_CAM:
484
- return B({ sender: t, track: s, codec: r }, o);
485
+ return B({ sender: t, track: s, codec: r }, c);
485
486
  case P.MAX_MAIN_CAM_RESOLUTION:
486
- return n !== void 0 ? Qe(
487
+ return n !== void 0 ? Ze(
487
488
  { sender: t, track: s, codec: r, resolution: n },
488
- o
489
- ) : B({ sender: t, track: s, codec: r }, o);
489
+ c
490
+ ) : B({ sender: t, track: s, codec: r }, c);
490
491
  default:
491
- return B({ sender: t, track: s, codec: r }, o);
492
+ return B({ sender: t, track: s, codec: r }, c);
492
493
  }
493
494
  }, L = {
494
495
  isChanged: !1,
@@ -506,15 +507,15 @@ const re = (e = new Error()) => {
506
507
  onSetParameters: s,
507
508
  ignoreForCodec: r
508
509
  }) => {
509
- const o = t.getSenders(), a = ke(o);
510
+ const c = t.getSenders(), a = De(c);
510
511
  if (!(a != null && a.track))
511
512
  return L;
512
- const u = await Be(a);
513
- return K(u, r) ? L : Ze(
513
+ const u = await ke(a);
514
+ return K(u, r) ? L : en(
514
515
  { mainCam: e, resolutionMainCam: n, sender: a, codec: u, track: a.track },
515
516
  s
516
517
  );
517
- }, on = (e, {
518
+ }, cn = (e, {
518
519
  ignoreForCodec: n,
519
520
  onSetParameters: t
520
521
  } = {}) => {
@@ -529,7 +530,7 @@ const re = (e = new Error()) => {
529
530
  });
530
531
  };
531
532
  let r = s;
532
- const o = async (m) => (r = async () => {
533
+ const c = async (m) => (r = async () => {
533
534
  const { mainCam: g, resolutionMainCam: C } = m, { connection: f } = e;
534
535
  if (!f)
535
536
  throw new Error("connection is not exist");
@@ -543,10 +544,10 @@ const re = (e = new Error()) => {
543
544
  }, r());
544
545
  return {
545
546
  subscribe: () => {
546
- e.onSession("main-cam-control", o);
547
+ e.onSession("main-cam-control", c);
547
548
  },
548
549
  unsubscribe: () => {
549
- e.offSession("main-cam-control", o);
550
+ e.offSession("main-cam-control", c);
550
551
  },
551
552
  balanceByTrack: s,
552
553
  resetMainCamControl() {
@@ -559,18 +560,18 @@ const re = (e = new Error()) => {
559
560
  };
560
561
  export {
561
562
  P as EEventsMainCAM,
562
- un as EEventsMic,
563
- ln as EEventsSyncMediaState,
564
- Sn as EUseLicense,
565
- dn as causes,
566
- mn as constants,
567
- hn as debug,
568
- nn as default,
569
- fn as disableDebug,
570
- Cn as enableDebug,
571
- En as eventNames,
572
- Be as getCodecFromSender,
573
- gn as hasCanceledCallError,
574
- on as resolveVideoSendingBalancer,
575
- rn as tools
563
+ ln as EEventsMic,
564
+ Sn as EEventsSyncMediaState,
565
+ dn as EUseLicense,
566
+ mn as causes,
567
+ fn as constants,
568
+ Tn as debug,
569
+ tn as default,
570
+ Cn as disableDebug,
571
+ En as enableDebug,
572
+ gn as eventNames,
573
+ ke as getCodecFromSender,
574
+ Rn as hasCanceledCallError,
575
+ cn as resolveVideoSendingBalancer,
576
+ on as tools
576
577
  };
package/dist/logger.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import debug from 'debug';
1
+ import { default as debug } from 'debug';
2
+
2
3
  declare const logger: debug.Debugger;
3
4
  export declare const enableDebug: () => void;
4
5
  export declare const disableDebug: () => void;
@@ -1,7 +1,7 @@
1
- /// <reference types="jest" />
2
- import RTCPeerConnectionMock from '../../__fixtures__/RTCPeerConnectionMock';
1
+ import { default as RTCPeerConnectionMock } from '../../__fixtures__/RTCPeerConnectionMock';
2
+
3
3
  declare const data: {
4
- mediaStream: import("webrtc-mock").MediaStreamMock;
4
+ mediaStream: import('webrtc-mock').MediaStreamMock;
5
5
  conference: string;
6
6
  setOutgoingCall: jest.Mock<any, any, any>;
7
7
  setRemoteStreams: jest.Mock<any, any, any>;