@telnyx/ai-agent-lib 0.1.4 → 0.1.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.
- package/README.md +99 -1
- package/dist/client.d.ts +1 -0
- package/dist/index.js +348 -337
- package/dist/message.d.ts +9 -4
- package/dist/types.d.ts +5 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ function D(t, e, n, i) {
|
|
|
17
17
|
c(f);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function d(p) {
|
|
21
21
|
try {
|
|
22
22
|
h(i.throw(p));
|
|
23
23
|
} catch (f) {
|
|
@@ -28,7 +28,7 @@ function D(t, e, n, i) {
|
|
|
28
28
|
var f;
|
|
29
29
|
p.done ? s(p.value) : (f = p.value, f instanceof n ? f : new n(function(b) {
|
|
30
30
|
b(f);
|
|
31
|
-
})).then(a,
|
|
31
|
+
})).then(a, d);
|
|
32
32
|
}
|
|
33
33
|
h((i = i.apply(t, [])).next());
|
|
34
34
|
});
|
|
@@ -44,7 +44,7 @@ function pe(t, e, n) {
|
|
|
44
44
|
typeof t == "string" && (e = t === "binary" ? new Array(16) : null, t = null);
|
|
45
45
|
var s = (t = t || {}).random || (t.rng || wn)();
|
|
46
46
|
if (s[6] = 15 & s[6] | 64, s[8] = 63 & s[8] | 128, e) for (var c = 0; c < 16; ++c) e[i + c] = s[c];
|
|
47
|
-
return e || function(a,
|
|
47
|
+
return e || function(a, d) {
|
|
48
48
|
var h = 0, p = Wt;
|
|
49
49
|
return [p[a[h++]], p[a[h++]], p[a[h++]], p[a[h++]], "-", p[a[h++]], p[a[h++]], "-", p[a[h++]], p[a[h++]], "-", p[a[h++]], p[a[h++]], "-", p[a[h++]], p[a[h++]], p[a[h++]], p[a[h++]], p[a[h++]], p[a[h++]]].join("");
|
|
50
50
|
}(s);
|
|
@@ -63,7 +63,7 @@ var En = zt(function(t) {
|
|
|
63
63
|
e = In, n = function() {
|
|
64
64
|
var i = function() {
|
|
65
65
|
}, s = "undefined", c = typeof window !== s && typeof window.navigator !== s && /Trident\/|MSIE /.test(window.navigator.userAgent), a = ["trace", "debug", "info", "warn", "error"];
|
|
66
|
-
function
|
|
66
|
+
function d(m, A) {
|
|
67
67
|
var M = m[A];
|
|
68
68
|
if (typeof M.bind == "function") return M.bind(m);
|
|
69
69
|
try {
|
|
@@ -91,7 +91,7 @@ var En = zt(function(t) {
|
|
|
91
91
|
}
|
|
92
92
|
function b(m, A, M) {
|
|
93
93
|
return function(x) {
|
|
94
|
-
return x === "debug" && (x = "log"), typeof console !== s && (x === "trace" && c ? h : console[x] !== void 0 ?
|
|
94
|
+
return x === "debug" && (x = "log"), typeof console !== s && (x === "trace" && c ? h : console[x] !== void 0 ? d(console, x) : console.log !== void 0 ? d(console, "log") : i);
|
|
95
95
|
}(m) || f.apply(this, arguments);
|
|
96
96
|
}
|
|
97
97
|
function C(m, A, M) {
|
|
@@ -118,14 +118,14 @@ var En = zt(function(t) {
|
|
|
118
118
|
}, V.setLevel = function(E, o) {
|
|
119
119
|
if (typeof E == "string" && V.levels[E.toUpperCase()] !== void 0 && (E = V.levels[E.toUpperCase()]), !(typeof E == "number" && E >= 0 && E <= V.levels.SILENT)) throw "log.setLevel() called with invalid level: " + E;
|
|
120
120
|
if (x = E, o !== !1 && function(r) {
|
|
121
|
-
var
|
|
121
|
+
var l = (a[r] || "silent").toUpperCase();
|
|
122
122
|
if (typeof window !== s && G) {
|
|
123
123
|
try {
|
|
124
|
-
return void (window.localStorage[G] =
|
|
124
|
+
return void (window.localStorage[G] = l);
|
|
125
125
|
} catch {
|
|
126
126
|
}
|
|
127
127
|
try {
|
|
128
|
-
window.document.cookie = encodeURIComponent(G) + "=" +
|
|
128
|
+
window.document.cookie = encodeURIComponent(G) + "=" + l + ";";
|
|
129
129
|
} catch {
|
|
130
130
|
}
|
|
131
131
|
}
|
|
@@ -178,13 +178,13 @@ L.methodFactory = (t, e, n) => {
|
|
|
178
178
|
}, L.setLevel(L.getLevel());
|
|
179
179
|
const ft = (t) => Object.keys(t).length === 0, xe = (t) => {
|
|
180
180
|
const [e, n, i, s, c, a] = t;
|
|
181
|
-
let
|
|
181
|
+
let d = {};
|
|
182
182
|
try {
|
|
183
|
-
|
|
183
|
+
d = JSON.parse(c.replace(/ID"/g, 'Id"'));
|
|
184
184
|
} catch {
|
|
185
185
|
L.warn("Verto LA invalid media JSON string:", c);
|
|
186
186
|
}
|
|
187
|
-
return { participantId: Number(e), participantNumber: n, participantName: i, codec: s, media:
|
|
187
|
+
return { participantId: Number(e), participantNumber: n, participantName: i, codec: s, media: d, participantData: a };
|
|
188
188
|
}, Jt = (t) => {
|
|
189
189
|
if (typeof t != "string") return t;
|
|
190
190
|
try {
|
|
@@ -197,12 +197,12 @@ const ft = (t) => Object.keys(t).length === 0, xe = (t) => {
|
|
|
197
197
|
if (i) return { error: i };
|
|
198
198
|
const { result: s = null } = n;
|
|
199
199
|
if (s === null) return e !== null && (n.node_id = e), { result: n };
|
|
200
|
-
const { code: c = null, node_id: a = null, result:
|
|
201
|
-
return c && c !== "200" ? { error: s } :
|
|
200
|
+
const { code: c = null, node_id: a = null, result: d = null } = s;
|
|
201
|
+
return c && c !== "200" ? { error: s } : d ? Ht(d, a) : { result: s };
|
|
202
202
|
}, Kt = (t, e) => Math.floor(Math.random() * (e - t + 1) + t), et = ({ login: t, passwd: e, password: n, login_token: i }) => !!(t && (e || n) || i), Me = ({ anonymous_login: t }) => !!t && !!t.target_id && !!t.target_type, at = (t) => {
|
|
203
203
|
var e, n, i, s, c, a;
|
|
204
|
-
let
|
|
205
|
-
return !((n = (e = t?.result) === null || e === void 0 ? void 0 : e.params) === null || n === void 0) && n.state && (
|
|
204
|
+
let d = "", h = "";
|
|
205
|
+
return !((n = (e = t?.result) === null || e === void 0 ? void 0 : e.params) === null || n === void 0) && n.state && (d = (s = (i = t?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state), !((c = t?.params) === null || c === void 0) && c.state && (h = (a = t?.params) === null || a === void 0 ? void 0 : a.state), d || h;
|
|
206
206
|
};
|
|
207
207
|
function gt({ debounceTime: t }) {
|
|
208
208
|
let e, n;
|
|
@@ -244,14 +244,14 @@ var j, Se, Q, se, K;
|
|
|
244
244
|
}(se || (se = {})), function(t) {
|
|
245
245
|
t.REGED = "REGED", t.UNREGED = "UNREGED", t.NOREG = "NOREG", t.FAILED = "FAILED", t.FAIL_WAIT = "FAIL_WAIT", t.REGISTER = "REGISTER", t.TRYING = "TRYING", t.EXPIRED = "EXPIRED", t.UNREGISTER = "UNREGISTER";
|
|
246
246
|
}(K || (K = {}));
|
|
247
|
-
const ge = "GLOBAL", X = {}, ke = (t, e) => `${t}|${e}`, Qt = (t, e = ge) => ke(t, e) in X,
|
|
247
|
+
const ge = "GLOBAL", X = {}, ke = (t, e) => `${t}|${e}`, Qt = (t, e = ge) => ke(t, e) in X, de = (t, e, n = ge) => {
|
|
248
248
|
const i = ke(t, n);
|
|
249
249
|
i in X || (X[i] = []), X[i].push(e);
|
|
250
250
|
}, Xt = (t, e, n = ge) => {
|
|
251
251
|
const i = function(s) {
|
|
252
252
|
ue(t, i, n), e(s);
|
|
253
253
|
};
|
|
254
|
-
return i.prototype.targetRef = e,
|
|
254
|
+
return i.prototype.targetRef = e, de(t, i, n);
|
|
255
255
|
}, ue = (t, e, n = ge) => {
|
|
256
256
|
if (!Qt(t, n)) return !1;
|
|
257
257
|
const i = ke(t, n);
|
|
@@ -267,7 +267,7 @@ const ge = "GLOBAL", X = {}, ke = (t, e) => `${t}|${e}`, Qt = (t, e = ge) => ke(
|
|
|
267
267
|
if (!Qt(t, n)) return s && U(t, e), !1;
|
|
268
268
|
const c = ke(t, n), a = X[c].length;
|
|
269
269
|
if (!a) return s && U(t, e), !1;
|
|
270
|
-
for (let
|
|
270
|
+
for (let d = a - 1; d >= 0; d--) X[c][d](e);
|
|
271
271
|
return s && U(t, e), !0;
|
|
272
272
|
}, Ye = (t) => {
|
|
273
273
|
const e = ke(t, "");
|
|
@@ -304,9 +304,9 @@ class vt {
|
|
|
304
304
|
n && e.searchParams.set("voice_sdk_id", n), this._wsClient = new An(e.toString()), this._wsClient.onopen = (i) => U(O.SocketOpen, i, this.session.uuid), this._wsClient.onclose = (i) => U(O.SocketClose, i, this.session.uuid), this._wsClient.onerror = (i) => U(O.SocketError, { error: i, sessionId: this.session.sessionid }, this.session.uuid), this._wsClient.onmessage = (i) => {
|
|
305
305
|
var s, c;
|
|
306
306
|
const a = Jt(i.data);
|
|
307
|
-
var
|
|
307
|
+
var d;
|
|
308
308
|
if (typeof a != "string") {
|
|
309
|
-
if (a.voice_sdk_id && (
|
|
309
|
+
if (a.voice_sdk_id && (d = a.voice_sdk_id, sessionStorage.setItem(ct, d)), this._unsetTimer(a.id), L.debug(`RECV:
|
|
310
310
|
`, JSON.stringify(a, null, 2), `
|
|
311
311
|
`), K[`${(c = (s = a?.result) === null || s === void 0 ? void 0 : s.params) === null || c === void 0 ? void 0 : c.state}`] || !U(a.id, a)) {
|
|
312
312
|
const h = at(a);
|
|
@@ -322,8 +322,8 @@ class vt {
|
|
|
322
322
|
const { request: n } = e, i = new Promise((s, c) => {
|
|
323
323
|
if (n.hasOwnProperty("result")) return s();
|
|
324
324
|
Xt(n.id, (a) => {
|
|
325
|
-
const { result:
|
|
326
|
-
return h ? c(h) : s(
|
|
325
|
+
const { result: d, error: h } = Ht(a);
|
|
326
|
+
return h ? c(h) : s(d);
|
|
327
327
|
});
|
|
328
328
|
});
|
|
329
329
|
return L.debug(`SEND:
|
|
@@ -413,7 +413,7 @@ class Pn {
|
|
|
413
413
|
});
|
|
414
414
|
}
|
|
415
415
|
on(e, n) {
|
|
416
|
-
return
|
|
416
|
+
return de(e, n, this.uuid), this;
|
|
417
417
|
}
|
|
418
418
|
off(e, n) {
|
|
419
419
|
return ue(e, n, this.uuid), this;
|
|
@@ -441,7 +441,7 @@ class Pn {
|
|
|
441
441
|
this._existsSubscription(e, n) && (n ? (delete this.subscriptions[e][n], ue(e, null, n)) : (delete this.subscriptions[e], Ye(e)));
|
|
442
442
|
}
|
|
443
443
|
_addSubscription(e, n = null, i) {
|
|
444
|
-
this._existsSubscription(e, i) || (this._existsSubscription(e) || (this.subscriptions[e] = {}), this.subscriptions[e][i] = {}, fe(n) &&
|
|
444
|
+
this._existsSubscription(e, i) || (this._existsSubscription(e) || (this.subscriptions[e] = {}), this.subscriptions[e][i] = {}, fe(n) && de(e, n, i));
|
|
445
445
|
}
|
|
446
446
|
_existsSubscription(e, n) {
|
|
447
447
|
return !(!this.subscriptions.hasOwnProperty(e) || !(!n || n && this.subscriptions[e].hasOwnProperty(n)));
|
|
@@ -464,7 +464,7 @@ class Pn {
|
|
|
464
464
|
this._doKeepAlive === !0 && (this._pong = !1, this._keepAliveTimeout = setTimeout(() => this._keepAlive(), 3e4));
|
|
465
465
|
}
|
|
466
466
|
static on(e, n) {
|
|
467
|
-
|
|
467
|
+
de(e, n);
|
|
468
468
|
}
|
|
469
469
|
static off(e) {
|
|
470
470
|
ue(e);
|
|
@@ -603,8 +603,8 @@ function Un() {
|
|
|
603
603
|
return { browserInfo: navigator.userAgent, name: b, version: C, supportAudio: !0, supportVideo: !0 };
|
|
604
604
|
}
|
|
605
605
|
throw new Error("This browser does not support @telnyx/webrtc. To see browser support list: `TelnyxRTC.webRTCSupportedBrowserList()`");
|
|
606
|
-
}(), c = window.RTCPeerConnection, a = window.RTCSessionDescription,
|
|
607
|
-
return { browserInfo: t, browserName: e, browserVersion: n, supportWebRTC: !!(c && a &&
|
|
606
|
+
}(), c = window.RTCPeerConnection, a = window.RTCSessionDescription, d = window.RTCIceCandidate, h = window.navigator && window.navigator.mediaDevices, p = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia || navigator.mozGetUserMedia;
|
|
607
|
+
return { browserInfo: t, browserName: e, browserVersion: n, supportWebRTC: !!(c && a && d && h && p), supportWebRTCAudio: i, supportWebRTCVideo: s, supportRTCPeerConnection: !!c, supportSessionDescription: !!a, supportIceCandidate: !!d, supportMediaDevices: !!h, supportGetUserMedia: !!je };
|
|
608
608
|
} catch (t) {
|
|
609
609
|
return t.message;
|
|
610
610
|
}
|
|
@@ -636,12 +636,12 @@ function kt(t) {
|
|
|
636
636
|
(function(t) {
|
|
637
637
|
t.not_supported = "not supported", t.full = "full", t.partial = "partial";
|
|
638
638
|
})(q || (q = {}));
|
|
639
|
-
var tn = "2.22.
|
|
639
|
+
var tn = "2.22.16", lt = tn;
|
|
640
640
|
class $n extends Z {
|
|
641
641
|
constructor(e, n, i, s, c = {}, a) {
|
|
642
642
|
super(), this.method = "login";
|
|
643
|
-
const
|
|
644
|
-
s && (
|
|
643
|
+
const d = { login: e, passwd: n, login_token: i, userVariables: c, reconnection: a, loginParams: {}, "User-Agent": { sdkVersion: lt, data: navigator.userAgent } };
|
|
644
|
+
s && (d.sessid = s), this.buildRequest({ method: this.method, params: d });
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
647
|
class Vn extends Z {
|
|
@@ -695,22 +695,22 @@ class zn extends Z {
|
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
697
|
class Jn extends Te {
|
|
698
|
-
constructor(e) {
|
|
699
|
-
super(), this.method = "ai_conversation", this.buildRequest({ method: this.method, params: { type: "conversation.item.create", previous_item_id: null, item: { id: pe(), type: "message", role: "user", content: [{ type: "input_text", text: e }] } } });
|
|
698
|
+
constructor(e, n) {
|
|
699
|
+
super(), this.method = "ai_conversation", this.buildRequest({ method: this.method, params: { type: "conversation.item.create", previous_item_id: null, item: { id: pe(), type: "message", role: "user", content: [{ type: "input_text", text: e }, ...n?.map((i) => ({ type: "image_url", image_url: { url: i } }))] } } });
|
|
700
700
|
}
|
|
701
701
|
}
|
|
702
702
|
const nn = (t, e) => {
|
|
703
703
|
const { contentType: n, canvasType: i, callID: s, canvasInfo: c = null, currentLayerIdx: a = -1 } = e;
|
|
704
704
|
c && i !== "mcu-personal-canvas" && delete c.memberID;
|
|
705
|
-
const
|
|
705
|
+
const d = { type: ie.conferenceUpdate, call: t.calls[s], canvasInfo: Hn(c), currentLayerIdx: a };
|
|
706
706
|
switch (n) {
|
|
707
707
|
case "layer-info": {
|
|
708
|
-
const h = Object.assign({ action: Q.LayerInfo },
|
|
708
|
+
const h = Object.assign({ action: Q.LayerInfo }, d);
|
|
709
709
|
U(O.Notification, h, t.uuid);
|
|
710
710
|
break;
|
|
711
711
|
}
|
|
712
712
|
case "layout-info": {
|
|
713
|
-
const h = Object.assign({ action: Q.LayoutInfo },
|
|
713
|
+
const h = Object.assign({ action: Q.LayoutInfo }, d);
|
|
714
714
|
U(O.Notification, h, t.uuid);
|
|
715
715
|
break;
|
|
716
716
|
}
|
|
@@ -729,39 +729,39 @@ var Ae, sn = zt(function(t, e) {
|
|
|
729
729
|
function c(o) {
|
|
730
730
|
return o._maxListeners === void 0 ? s.defaultMaxListeners : o._maxListeners;
|
|
731
731
|
}
|
|
732
|
-
function a(o, r,
|
|
732
|
+
function a(o, r, l, u) {
|
|
733
733
|
var g, y, _;
|
|
734
|
-
if (typeof
|
|
735
|
-
if ((y = o._events) ? (y.newListener && (o.emit("newListener", r,
|
|
736
|
-
if (typeof _ == "function" ? _ = y[r] = u ? [
|
|
734
|
+
if (typeof l != "function") throw new TypeError('"listener" argument must be a function');
|
|
735
|
+
if ((y = o._events) ? (y.newListener && (o.emit("newListener", r, l.listener ? l.listener : l), y = o._events), _ = y[r]) : (y = o._events = new i(), o._eventsCount = 0), _) {
|
|
736
|
+
if (typeof _ == "function" ? _ = y[r] = u ? [l, _] : [_, l] : u ? _.unshift(l) : _.push(l), !_.warned && (g = c(o)) && 0 < g && _.length > g) {
|
|
737
737
|
_.warned = !0;
|
|
738
738
|
var k = new Error("Possible EventEmitter memory leak detected. " + _.length + " " + r + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
739
739
|
k.name = "MaxListenersExceededWarning", k.emitter = o, k.type = r, k.count = _.length, function(T) {
|
|
740
740
|
typeof console.warn == "function" ? console.warn(T) : console.log(T);
|
|
741
741
|
}(k);
|
|
742
742
|
}
|
|
743
|
-
} else _ = y[r] =
|
|
743
|
+
} else _ = y[r] = l, ++o._eventsCount;
|
|
744
744
|
return o;
|
|
745
745
|
}
|
|
746
|
-
function
|
|
746
|
+
function d(o, r, l) {
|
|
747
747
|
function u() {
|
|
748
|
-
o.removeListener(r, u), g || (g = !0,
|
|
748
|
+
o.removeListener(r, u), g || (g = !0, l.apply(o, arguments));
|
|
749
749
|
}
|
|
750
750
|
var g = !1;
|
|
751
|
-
return u.listener =
|
|
751
|
+
return u.listener = l, u;
|
|
752
752
|
}
|
|
753
753
|
function h(o) {
|
|
754
754
|
var r = this._events;
|
|
755
755
|
if (r) {
|
|
756
|
-
var
|
|
757
|
-
if (typeof
|
|
758
|
-
if (
|
|
756
|
+
var l = r[o];
|
|
757
|
+
if (typeof l == "function") return 1;
|
|
758
|
+
if (l) return l.length;
|
|
759
759
|
}
|
|
760
760
|
return 0;
|
|
761
761
|
}
|
|
762
762
|
function p(o, r) {
|
|
763
|
-
for (var
|
|
764
|
-
return
|
|
763
|
+
for (var l = Array(r); r--; ) l[r] = o[r];
|
|
764
|
+
return l;
|
|
765
765
|
}
|
|
766
766
|
Object.defineProperty(e, "__esModule", { value: !0 }), i.prototype = /* @__PURE__ */ Object.create(null), s.EventEmitter = s, s.usingDomains = !1, s.prototype.domain = void 0, s.prototype._events = void 0, s.prototype._maxListeners = void 0, s.defaultMaxListeners = 10, s.init = function() {
|
|
767
767
|
this.domain = null, s.usingDomains && n.active && !(this instanceof n.Domain) && (this.domain = n.active), this._events && this._events !== Object.getPrototypeOf(this)._events || (this._events = new i(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
@@ -771,7 +771,7 @@ var Ae, sn = zt(function(t, e) {
|
|
|
771
771
|
}, s.prototype.getMaxListeners = function() {
|
|
772
772
|
return c(this);
|
|
773
773
|
}, s.prototype.emit = function(o) {
|
|
774
|
-
var r,
|
|
774
|
+
var r, l, u, g, y, _, k, T = o === "error";
|
|
775
775
|
if (_ = this._events) T = T && _.error == null;
|
|
776
776
|
else if (!T) return !1;
|
|
777
777
|
if (k = this.domain, T) {
|
|
@@ -782,39 +782,39 @@ var Ae, sn = zt(function(t, e) {
|
|
|
782
782
|
}
|
|
783
783
|
return r || (r = new Error('Uncaught, unspecified "error" event')), r.domainEmitter = this, r.domain = k, r.domainThrown = !1, k.emit("error", r), !1;
|
|
784
784
|
}
|
|
785
|
-
if (!(
|
|
786
|
-
var J = typeof
|
|
785
|
+
if (!(l = _[o])) return !1;
|
|
786
|
+
var J = typeof l == "function";
|
|
787
787
|
switch (u = arguments.length) {
|
|
788
788
|
case 1:
|
|
789
789
|
(function(v, N, P) {
|
|
790
790
|
if (N) v.call(P);
|
|
791
791
|
else for (var $ = v.length, W = p(v, $), B = 0; B < $; ++B) W[B].call(P);
|
|
792
|
-
})(
|
|
792
|
+
})(l, J, this);
|
|
793
793
|
break;
|
|
794
794
|
case 2:
|
|
795
795
|
(function(v, N, P, $) {
|
|
796
796
|
if (N) v.call(P, $);
|
|
797
797
|
else for (var W = v.length, B = p(v, W), H = 0; H < W; ++H) B[H].call(P, $);
|
|
798
|
-
})(
|
|
798
|
+
})(l, J, this, arguments[1]);
|
|
799
799
|
break;
|
|
800
800
|
case 3:
|
|
801
801
|
(function(v, N, P, $, W) {
|
|
802
802
|
if (N) v.call(P, $, W);
|
|
803
803
|
else for (var B = v.length, H = p(v, B), oe = 0; oe < B; ++oe) H[oe].call(P, $, W);
|
|
804
|
-
})(
|
|
804
|
+
})(l, J, this, arguments[1], arguments[2]);
|
|
805
805
|
break;
|
|
806
806
|
case 4:
|
|
807
807
|
(function(v, N, P, $, W, B) {
|
|
808
808
|
if (N) v.call(P, $, W, B);
|
|
809
809
|
else for (var H = v.length, oe = p(v, H), z = 0; z < H; ++z) oe[z].call(P, $, W, B);
|
|
810
|
-
})(
|
|
810
|
+
})(l, J, this, arguments[1], arguments[2], arguments[3]);
|
|
811
811
|
break;
|
|
812
812
|
default:
|
|
813
813
|
for (g = Array(u - 1), y = 1; y < u; y++) g[y - 1] = arguments[y];
|
|
814
814
|
(function(v, N, P, $) {
|
|
815
815
|
if (N) v.apply(P, $);
|
|
816
816
|
else for (var W = v.length, B = p(v, W), H = 0; H < W; ++H) B[H].apply(P, $);
|
|
817
|
-
})(
|
|
817
|
+
})(l, J, this, g);
|
|
818
818
|
}
|
|
819
819
|
return !0;
|
|
820
820
|
}, s.prototype.addListener = function(o, r) {
|
|
@@ -823,51 +823,51 @@ var Ae, sn = zt(function(t, e) {
|
|
|
823
823
|
return a(this, o, r, !0);
|
|
824
824
|
}, s.prototype.once = function(o, r) {
|
|
825
825
|
if (typeof r != "function") throw new TypeError('"listener" argument must be a function');
|
|
826
|
-
return this.on(o,
|
|
826
|
+
return this.on(o, d(this, o, r)), this;
|
|
827
827
|
}, s.prototype.prependOnceListener = function(o, r) {
|
|
828
828
|
if (typeof r != "function") throw new TypeError('"listener" argument must be a function');
|
|
829
|
-
return this.prependListener(o,
|
|
829
|
+
return this.prependListener(o, d(this, o, r)), this;
|
|
830
830
|
}, s.prototype.removeListener = function(o, r) {
|
|
831
|
-
var
|
|
831
|
+
var l, u, g, y, _;
|
|
832
832
|
if (typeof r != "function") throw new TypeError('"listener" argument must be a function');
|
|
833
833
|
if (!(u = this._events)) return this;
|
|
834
|
-
if (!(
|
|
835
|
-
if (
|
|
836
|
-
else if (typeof
|
|
837
|
-
for (g = -1, y =
|
|
838
|
-
_ =
|
|
834
|
+
if (!(l = u[o])) return this;
|
|
835
|
+
if (l === r || l.listener && l.listener === r) --this._eventsCount == 0 ? this._events = new i() : (delete u[o], u.removeListener && this.emit("removeListener", o, l.listener || r));
|
|
836
|
+
else if (typeof l != "function") {
|
|
837
|
+
for (g = -1, y = l.length; 0 < y--; ) if (l[y] === r || l[y].listener && l[y].listener === r) {
|
|
838
|
+
_ = l[y].listener, g = y;
|
|
839
839
|
break;
|
|
840
840
|
}
|
|
841
841
|
if (0 > g) return this;
|
|
842
|
-
if (
|
|
843
|
-
if (
|
|
842
|
+
if (l.length === 1) {
|
|
843
|
+
if (l[0] = void 0, --this._eventsCount == 0) return this._events = new i(), this;
|
|
844
844
|
delete u[o];
|
|
845
845
|
} else (function(k, T) {
|
|
846
846
|
for (var Y = T, J = Y + 1, v = k.length; J < v; Y += 1, J += 1) k[Y] = k[J];
|
|
847
847
|
k.pop();
|
|
848
|
-
})(
|
|
848
|
+
})(l, g);
|
|
849
849
|
u.removeListener && this.emit("removeListener", o, _ || r);
|
|
850
850
|
}
|
|
851
851
|
return this;
|
|
852
852
|
}, s.prototype.removeAllListeners = function(o) {
|
|
853
|
-
var r,
|
|
854
|
-
if (!(
|
|
855
|
-
if (!
|
|
853
|
+
var r, l;
|
|
854
|
+
if (!(l = this._events)) return this;
|
|
855
|
+
if (!l.removeListener) return arguments.length === 0 ? (this._events = new i(), this._eventsCount = 0) : l[o] && (--this._eventsCount == 0 ? this._events = new i() : delete l[o]), this;
|
|
856
856
|
if (arguments.length === 0) {
|
|
857
|
-
for (var u, g = Object.keys(
|
|
857
|
+
for (var u, g = Object.keys(l), y = 0; y < g.length; ++y) (u = g[y]) !== "removeListener" && this.removeAllListeners(u);
|
|
858
858
|
return this.removeAllListeners("removeListener"), this._events = new i(), this._eventsCount = 0, this;
|
|
859
859
|
}
|
|
860
|
-
if (typeof (r =
|
|
860
|
+
if (typeof (r = l[o]) == "function") this.removeListener(o, r);
|
|
861
861
|
else if (r) do
|
|
862
862
|
this.removeListener(o, r[r.length - 1]);
|
|
863
863
|
while (r[0]);
|
|
864
864
|
return this;
|
|
865
865
|
}, s.prototype.listeners = function(o) {
|
|
866
|
-
var r,
|
|
867
|
-
return u ?
|
|
866
|
+
var r, l, u = this._events;
|
|
867
|
+
return u ? l = (r = u[o]) ? typeof r == "function" ? [r.listener || r] : function(g) {
|
|
868
868
|
for (var y = Array(g.length), _ = 0; _ < y.length; ++_) y[_] = g[_].listener || g[_];
|
|
869
869
|
return y;
|
|
870
|
-
}(r) : [] :
|
|
870
|
+
}(r) : [] : l = [], l;
|
|
871
871
|
}, s.listenerCount = function(o, r) {
|
|
872
872
|
return typeof o.listenerCount == "function" ? o.listenerCount(r) : h.call(o, r);
|
|
873
873
|
}, s.prototype.listenerCount = h, s.prototype.eventNames = function() {
|
|
@@ -880,46 +880,46 @@ var Ae, sn = zt(function(t, e) {
|
|
|
880
880
|
}
|
|
881
881
|
for (var I = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i, w = [], R = 0; 256 > R; ++R) w.push((R + 256).toString(16).substr(1));
|
|
882
882
|
function m(o) {
|
|
883
|
-
var r = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0,
|
|
883
|
+
var r = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0, l = (w[o[r + 0]] + w[o[r + 1]] + w[o[r + 2]] + w[o[r + 3]] + "-" + w[o[r + 4]] + w[o[r + 5]] + "-" + w[o[r + 6]] + w[o[r + 7]] + "-" + w[o[r + 8]] + w[o[r + 9]] + "-" + w[o[r + 10]] + w[o[r + 11]] + w[o[r + 12]] + w[o[r + 13]] + w[o[r + 14]] + w[o[r + 15]]).toLowerCase();
|
|
884
884
|
if (!function(u) {
|
|
885
885
|
return typeof u == "string" && I.test(u);
|
|
886
|
-
}(
|
|
887
|
-
return
|
|
886
|
+
}(l)) throw TypeError("Stringified UUID is invalid");
|
|
887
|
+
return l;
|
|
888
888
|
}
|
|
889
|
-
function A(o, r,
|
|
889
|
+
function A(o, r, l) {
|
|
890
890
|
var u = (o = o || {}).random || (o.rng || C)();
|
|
891
891
|
return u[6] = 64 | 15 & u[6], u[8] = 128 | 63 & u[8], m(u);
|
|
892
892
|
}
|
|
893
893
|
function M(o, r) {
|
|
894
894
|
if (!o || !r) return {};
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
897
|
-
const u = r.get(
|
|
898
|
-
|
|
895
|
+
const l = { ...o };
|
|
896
|
+
if (l.localCandidateId) {
|
|
897
|
+
const u = r.get(l.localCandidateId);
|
|
898
|
+
l.local = { ...u };
|
|
899
899
|
}
|
|
900
|
-
if (
|
|
901
|
-
const u = r.get(
|
|
902
|
-
|
|
900
|
+
if (l.remoteCandidateId) {
|
|
901
|
+
const u = r.get(l.remoteCandidateId);
|
|
902
|
+
l.remote = { ...u };
|
|
903
903
|
}
|
|
904
|
-
return
|
|
904
|
+
return l;
|
|
905
905
|
}
|
|
906
|
-
function x(o, r,
|
|
906
|
+
function x(o, r, l) {
|
|
907
907
|
return 8 * function(u, g, y) {
|
|
908
908
|
const _ = u[y], k = g ? g[y] : null;
|
|
909
909
|
return _ === null || k === null ? null : (_ - k) / (u.timestamp - g.timestamp) * 1e3;
|
|
910
|
-
}(o, r,
|
|
910
|
+
}(o, r, l);
|
|
911
911
|
}
|
|
912
912
|
function V(o) {
|
|
913
913
|
if (!o.entries) return o;
|
|
914
914
|
const r = {};
|
|
915
|
-
return o.forEach(function(
|
|
916
|
-
r[u] =
|
|
915
|
+
return o.forEach(function(l, u) {
|
|
916
|
+
r[u] = l;
|
|
917
917
|
}), r;
|
|
918
918
|
}
|
|
919
|
-
function G(o, r,
|
|
919
|
+
function G(o, r, l = {}) {
|
|
920
920
|
if (!o) return null;
|
|
921
921
|
let u = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] }, connection: { inbound: [], outbound: [] } };
|
|
922
|
-
|
|
922
|
+
l.remote && (u.remote = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] } });
|
|
923
923
|
for (const g of o.values()) switch (g.type) {
|
|
924
924
|
case "outbound-rtp": {
|
|
925
925
|
const y = g.mediaType || g.kind, _ = {};
|
|
@@ -958,7 +958,7 @@ var Ae, sn = zt(function(t, e) {
|
|
|
958
958
|
u.connection.dataChannelsClosed = g.dataChannelsClosed, u.connection.dataChannelsOpened = g.dataChannelsOpened;
|
|
959
959
|
break;
|
|
960
960
|
case "remote-inbound-rtp": {
|
|
961
|
-
if (!
|
|
961
|
+
if (!l.remote) break;
|
|
962
962
|
let y = g.mediaType || g.kind;
|
|
963
963
|
const _ = {};
|
|
964
964
|
if (!["audio", "video"].includes(y)) if (g.id.includes("Video")) y = "video";
|
|
@@ -981,7 +981,7 @@ var Ae, sn = zt(function(t, e) {
|
|
|
981
981
|
break;
|
|
982
982
|
}
|
|
983
983
|
case "remote-outbound-rtp": {
|
|
984
|
-
if (!
|
|
984
|
+
if (!l.remote) break;
|
|
985
985
|
const y = g.mediaType || g.kind, _ = {};
|
|
986
986
|
if (!["audio", "video"].includes(y)) continue;
|
|
987
987
|
if (g.codecId) {
|
|
@@ -1020,31 +1020,31 @@ var Ae, sn = zt(function(t, e) {
|
|
|
1020
1020
|
return console.warn("The addPeer() method has been deprecated, please use addConnection()"), this.addConnection({ peerId: o, pc: r });
|
|
1021
1021
|
}
|
|
1022
1022
|
async addConnection(o) {
|
|
1023
|
-
const { pc: r, peerId:
|
|
1023
|
+
const { pc: r, peerId: l } = o;
|
|
1024
1024
|
let { connectionId: u, remote: g } = o;
|
|
1025
1025
|
if (g = typeof g == "boolean" ? g : this.remote, !(r && r instanceof RTCPeerConnection)) throw new Error("Missing argument 'pc' or is not of instance RTCPeerConnection");
|
|
1026
|
-
if (!
|
|
1026
|
+
if (!l) throw new Error("Missing argument peerId");
|
|
1027
1027
|
if (this.isEdge) throw new Error("Can't monitor peers in Edge at this time.");
|
|
1028
|
-
if (this.peersToMonitor[
|
|
1029
|
-
if (u && u in this.peersToMonitor[
|
|
1030
|
-
for (let _ in this.peersToMonitor[
|
|
1031
|
-
const k = this.peersToMonitor[
|
|
1032
|
-
if (k.pc === r) throw new Error(`We are already monitoring peer with id ${
|
|
1028
|
+
if (this.peersToMonitor[l]) {
|
|
1029
|
+
if (u && u in this.peersToMonitor[l]) throw new Error(`We are already monitoring connection with id ${u}.`);
|
|
1030
|
+
for (let _ in this.peersToMonitor[l]) {
|
|
1031
|
+
const k = this.peersToMonitor[l][_];
|
|
1032
|
+
if (k.pc === r) throw new Error(`We are already monitoring peer with id ${l}.`);
|
|
1033
1033
|
k.pc.connectionState === "closed" && this.removeConnection({ pc: k.pc });
|
|
1034
1034
|
}
|
|
1035
1035
|
}
|
|
1036
1036
|
const y = r.getConfiguration();
|
|
1037
1037
|
return y.iceServers && y.iceServers.forEach(function(_) {
|
|
1038
1038
|
delete _.credential;
|
|
1039
|
-
}), u || (u = A()), this.emitEvent({ event: "addConnection", tag: "peer", peerId:
|
|
1039
|
+
}), u || (u = A()), this.emitEvent({ event: "addConnection", tag: "peer", peerId: l, connectionId: u, data: { options: o, peerConfiguration: y } }), this.monitorPeer({ peerId: l, connectionId: u, pc: r, remote: g }), { connectionId: u };
|
|
1040
1040
|
}
|
|
1041
1041
|
getTimeline(o) {
|
|
1042
|
-
return this.timeline = this.timeline.sort((r,
|
|
1042
|
+
return this.timeline = this.timeline.sort((r, l) => r.timestamp.getTime() - l.timestamp.getTime()), o ? this.timeline.filter((r) => r.tag === o) : this.timeline;
|
|
1043
1043
|
}
|
|
1044
1044
|
get logger() {
|
|
1045
1045
|
const o = (r) => {
|
|
1046
|
-
const
|
|
1047
|
-
return
|
|
1046
|
+
const l = ["none", "error", "warn", "info", "debug"];
|
|
1047
|
+
return l.slice(0, l.indexOf(this.logLevel) + 1).indexOf(r) > -1;
|
|
1048
1048
|
};
|
|
1049
1049
|
return { error(...r) {
|
|
1050
1050
|
this.debug && o("error") && console.error("[webrtc-stats][error] ", ...r);
|
|
@@ -1057,17 +1057,17 @@ var Ae, sn = zt(function(t, e) {
|
|
|
1057
1057
|
} };
|
|
1058
1058
|
}
|
|
1059
1059
|
removeConnection(o) {
|
|
1060
|
-
let r, { connectionId:
|
|
1061
|
-
if (!u && !
|
|
1062
|
-
if (
|
|
1063
|
-
if (typeof
|
|
1064
|
-
for (let g in this.peersToMonitor)
|
|
1060
|
+
let r, { connectionId: l, pc: u } = o;
|
|
1061
|
+
if (!u && !l) throw new Error("Missing arguments. You need to either send pc or a connectionId.");
|
|
1062
|
+
if (l) {
|
|
1063
|
+
if (typeof l != "string") throw new Error("connectionId must be a string.");
|
|
1064
|
+
for (let g in this.peersToMonitor) l in this.peersToMonitor[g] && (u = this.peersToMonitor[g][l].pc, r = g);
|
|
1065
1065
|
} else if (u) {
|
|
1066
1066
|
if (!(u instanceof RTCPeerConnection)) throw new Error("pc must be an instance of RTCPeerConnection.");
|
|
1067
|
-
for (let g in this.peersToMonitor) for (let y in this.peersToMonitor[g]) this.peersToMonitor[g][y].pc === u && (
|
|
1067
|
+
for (let g in this.peersToMonitor) for (let y in this.peersToMonitor[g]) this.peersToMonitor[g][y].pc === u && (l = y, r = g);
|
|
1068
1068
|
}
|
|
1069
|
-
if (!u || !
|
|
1070
|
-
return this.removePeerConnectionEventListeners(
|
|
1069
|
+
if (!u || !l) throw new Error("Could not find the desired connection.");
|
|
1070
|
+
return this.removePeerConnectionEventListeners(l, u), delete this.peersToMonitor[r][l], Object.values(this.peersToMonitor[r]).length === 0 && delete this.peersToMonitor[r], { connectionId: l };
|
|
1071
1071
|
}
|
|
1072
1072
|
removeAllPeers() {
|
|
1073
1073
|
for (let o in this.peersToMonitor) this.removePeer(o);
|
|
@@ -1075,8 +1075,8 @@ var Ae, sn = zt(function(t, e) {
|
|
|
1075
1075
|
removePeer(o) {
|
|
1076
1076
|
if (this.logger.info(`Removing PeerConnection with id ${o}.`), this.peersToMonitor[o]) {
|
|
1077
1077
|
for (let r in this.peersToMonitor[o]) {
|
|
1078
|
-
let
|
|
1079
|
-
this.removePeerConnectionEventListeners(r,
|
|
1078
|
+
let l = this.peersToMonitor[o][r].pc;
|
|
1079
|
+
this.removePeerConnectionEventListeners(r, l);
|
|
1080
1080
|
}
|
|
1081
1081
|
delete this.peersToMonitor[o];
|
|
1082
1082
|
}
|
|
@@ -1087,14 +1087,14 @@ var Ae, sn = zt(function(t, e) {
|
|
|
1087
1087
|
}), E = [], this.shouldWrapGetUserMedia && ee && (navigator.mediaDevices.getUserMedia = ee);
|
|
1088
1088
|
}
|
|
1089
1089
|
monitorPeer(o) {
|
|
1090
|
-
let { peerId: r, connectionId:
|
|
1090
|
+
let { peerId: r, connectionId: l, pc: u, remote: g } = o;
|
|
1091
1091
|
if (!u) return void this.logger.warn("Did not receive pc argument when calling monitorPeer()");
|
|
1092
|
-
const y = { pc: u, connectionId:
|
|
1092
|
+
const y = { pc: u, connectionId: l, stream: null, stats: { parsed: null, raw: null }, options: { remote: g } };
|
|
1093
1093
|
if (this.peersToMonitor[r]) {
|
|
1094
|
-
if (
|
|
1095
|
-
this.peersToMonitor[r][
|
|
1096
|
-
} else this.peersToMonitor[r] = { [
|
|
1097
|
-
this.addPeerConnectionEventListeners(r,
|
|
1094
|
+
if (l in this.peersToMonitor[r]) return void this.logger.warn(`Already watching connection with ID ${l}`);
|
|
1095
|
+
this.peersToMonitor[r][l] = y;
|
|
1096
|
+
} else this.peersToMonitor[r] = { [l]: y };
|
|
1097
|
+
this.addPeerConnectionEventListeners(r, l, u), this.numberOfMonitoredPeers === 1 && (this.startStatsMonitoring(), this.startConnectionStateMonitoring());
|
|
1098
1098
|
}
|
|
1099
1099
|
startStatsMonitoring() {
|
|
1100
1100
|
this.monitoringSetInterval || (this.monitoringSetInterval = window.setInterval(() => {
|
|
@@ -1115,35 +1115,35 @@ var Ae, sn = zt(function(t, e) {
|
|
|
1115
1115
|
if (!this.peersToMonitor[o]) throw new Error(`Cannot get stats. Peer with id ${o} does not exist`);
|
|
1116
1116
|
r[o] = this.peersToMonitor[o];
|
|
1117
1117
|
} else r = this.peersToMonitor;
|
|
1118
|
-
let
|
|
1118
|
+
let l = [];
|
|
1119
1119
|
for (const u in r) for (const g in r[u]) {
|
|
1120
1120
|
const y = r[u][g], _ = y.pc;
|
|
1121
1121
|
if (_ && !this.checkIfConnectionIsClosed(u, g, _)) try {
|
|
1122
1122
|
const k = this.getTimestamp(), T = _.getStats(null);
|
|
1123
1123
|
if (T) {
|
|
1124
1124
|
const Y = await T, J = this.getTimestamp(), v = V(Y), N = { remote: y.options.remote }, P = G(Y, y.stats.parsed, N), $ = { event: "stats", tag: "stats", peerId: u, connectionId: g, timeTaken: J - k, data: P };
|
|
1125
|
-
this.rawStats === !0 && ($.rawStats = Y), this.statsObject === !0 && ($.statsObject = v), this.filteredStats === !0 && ($.filteredStats = this.filteroutStats(v)),
|
|
1125
|
+
this.rawStats === !0 && ($.rawStats = Y), this.statsObject === !0 && ($.statsObject = v), this.filteredStats === !0 && ($.filteredStats = this.filteroutStats(v)), l.push($), y.stats.parsed = P;
|
|
1126
1126
|
} else this.logger.error(`PeerConnection from peer ${u} did not return any stats data`);
|
|
1127
1127
|
} catch (k) {
|
|
1128
1128
|
this.logger.error(k);
|
|
1129
1129
|
}
|
|
1130
1130
|
}
|
|
1131
|
-
return
|
|
1131
|
+
return l;
|
|
1132
1132
|
}
|
|
1133
1133
|
startConnectionStateMonitoring() {
|
|
1134
1134
|
this.connectionMonitoringSetInterval = window.setInterval(() => {
|
|
1135
1135
|
this.numberOfMonitoredPeers || this.stopConnectionStateMonitoring();
|
|
1136
1136
|
for (const o in this.peersToMonitor) for (const r in this.peersToMonitor[o]) {
|
|
1137
|
-
const
|
|
1138
|
-
this.checkIfConnectionIsClosed(o, r,
|
|
1137
|
+
const l = this.peersToMonitor[o][r].pc;
|
|
1138
|
+
this.checkIfConnectionIsClosed(o, r, l);
|
|
1139
1139
|
}
|
|
1140
1140
|
}, this.connectionMonitoringInterval);
|
|
1141
1141
|
}
|
|
1142
|
-
checkIfConnectionIsClosed(o, r,
|
|
1143
|
-
const u = this.isConnectionClosed(
|
|
1142
|
+
checkIfConnectionIsClosed(o, r, l) {
|
|
1143
|
+
const u = this.isConnectionClosed(l);
|
|
1144
1144
|
if (u) {
|
|
1145
|
-
this.removeConnection({ pc:
|
|
1146
|
-
let g =
|
|
1145
|
+
this.removeConnection({ pc: l });
|
|
1146
|
+
let g = l.connectionState === "closed" ? "onconnectionstatechange" : "oniceconnectionstatechange";
|
|
1147
1147
|
this.emitEvent({ event: g, peerId: o, connectionId: r, tag: "connection", data: "closed" });
|
|
1148
1148
|
}
|
|
1149
1149
|
return u;
|
|
@@ -1165,54 +1165,54 @@ var Ae, sn = zt(function(t, e) {
|
|
|
1165
1165
|
filteroutStats(o = {}) {
|
|
1166
1166
|
const r = { ...o };
|
|
1167
1167
|
for (const u in r) {
|
|
1168
|
-
var
|
|
1169
|
-
this.statsToMonitor.includes(
|
|
1168
|
+
var l = r[u];
|
|
1169
|
+
this.statsToMonitor.includes(l.type) || delete r[u];
|
|
1170
1170
|
}
|
|
1171
1171
|
return r;
|
|
1172
1172
|
}
|
|
1173
1173
|
get peerConnectionListeners() {
|
|
1174
|
-
return { icecandidate: (o, r,
|
|
1174
|
+
return { icecandidate: (o, r, l, u) => {
|
|
1175
1175
|
this.logger.debug("[pc-event] icecandidate | peerId: ${peerId}", u), this.emitEvent({ event: "onicecandidate", tag: "connection", peerId: o, connectionId: r, data: u.candidate });
|
|
1176
|
-
}, track: (o, r,
|
|
1176
|
+
}, track: (o, r, l, u) => {
|
|
1177
1177
|
this.logger.debug(`[pc-event] track | peerId: ${o}`, u);
|
|
1178
1178
|
const g = u.track, y = u.streams[0];
|
|
1179
1179
|
o in this.peersToMonitor && r in this.peersToMonitor[o] && (this.peersToMonitor[o][r].stream = y), this.addTrackEventListeners(g, r), this.emitEvent({ event: "ontrack", tag: "track", peerId: o, connectionId: r, data: { stream: y ? this.getStreamDetails(y) : null, track: g ? this.getMediaTrackDetails(g) : null, title: u.track.kind + ":" + u.track.id + " " + u.streams.map(function(_) {
|
|
1180
1180
|
return "stream:" + _.id;
|
|
1181
1181
|
}) } });
|
|
1182
|
-
}, signalingstatechange: (o, r,
|
|
1183
|
-
this.logger.debug(`[pc-event] signalingstatechange | peerId: ${o}`), this.emitEvent({ event: "onsignalingstatechange", tag: "connection", peerId: o, connectionId: r, data: { signalingState:
|
|
1184
|
-
}, iceconnectionstatechange: (o, r,
|
|
1185
|
-
this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${o}`), this.emitEvent({ event: "oniceconnectionstatechange", tag: "connection", peerId: o, connectionId: r, data:
|
|
1186
|
-
}, icegatheringstatechange: (o, r,
|
|
1187
|
-
this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${o}`), this.emitEvent({ event: "onicegatheringstatechange", tag: "connection", peerId: o, connectionId: r, data:
|
|
1188
|
-
}, icecandidateerror: (o, r,
|
|
1182
|
+
}, signalingstatechange: (o, r, l) => {
|
|
1183
|
+
this.logger.debug(`[pc-event] signalingstatechange | peerId: ${o}`), this.emitEvent({ event: "onsignalingstatechange", tag: "connection", peerId: o, connectionId: r, data: { signalingState: l.signalingState, localDescription: l.localDescription, remoteDescription: l.remoteDescription } });
|
|
1184
|
+
}, iceconnectionstatechange: (o, r, l) => {
|
|
1185
|
+
this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${o}`), this.emitEvent({ event: "oniceconnectionstatechange", tag: "connection", peerId: o, connectionId: r, data: l.iceConnectionState });
|
|
1186
|
+
}, icegatheringstatechange: (o, r, l) => {
|
|
1187
|
+
this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${o}`), this.emitEvent({ event: "onicegatheringstatechange", tag: "connection", peerId: o, connectionId: r, data: l.iceGatheringState });
|
|
1188
|
+
}, icecandidateerror: (o, r, l, u) => {
|
|
1189
1189
|
this.logger.debug(`[pc-event] icecandidateerror | peerId: ${o}`), this.emitEvent({ event: "onicecandidateerror", tag: "connection", peerId: o, connectionId: r, error: { errorCode: u.errorCode } });
|
|
1190
|
-
}, connectionstatechange: (o, r,
|
|
1191
|
-
this.logger.debug(`[pc-event] connectionstatechange | peerId: ${o}`), this.emitEvent({ event: "onconnectionstatechange", tag: "connection", peerId: o, connectionId: r, data:
|
|
1192
|
-
}, negotiationneeded: (o, r,
|
|
1190
|
+
}, connectionstatechange: (o, r, l) => {
|
|
1191
|
+
this.logger.debug(`[pc-event] connectionstatechange | peerId: ${o}`), this.emitEvent({ event: "onconnectionstatechange", tag: "connection", peerId: o, connectionId: r, data: l.connectionState });
|
|
1192
|
+
}, negotiationneeded: (o, r, l) => {
|
|
1193
1193
|
this.logger.debug(`[pc-event] negotiationneeded | peerId: ${o}`), this.emitEvent({ event: "onnegotiationneeded", tag: "connection", peerId: o, connectionId: r });
|
|
1194
|
-
}, datachannel: (o, r,
|
|
1194
|
+
}, datachannel: (o, r, l, u) => {
|
|
1195
1195
|
this.logger.debug(`[pc-event] datachannel | peerId: ${o}`, u), this.emitEvent({ event: "ondatachannel", tag: "datachannel", peerId: o, connectionId: r, data: u.channel });
|
|
1196
1196
|
} };
|
|
1197
1197
|
}
|
|
1198
|
-
addPeerConnectionEventListeners(o, r,
|
|
1198
|
+
addPeerConnectionEventListeners(o, r, l) {
|
|
1199
1199
|
this.logger.debug(`Adding event listeners for peer ${o} and connection ${r}.`), S[r] = {}, Object.keys(this.peerConnectionListeners).forEach((u) => {
|
|
1200
|
-
S[r][u] = this.peerConnectionListeners[u].bind(this, o, r,
|
|
1200
|
+
S[r][u] = this.peerConnectionListeners[u].bind(this, o, r, l), l.addEventListener(u, S[r][u], !1);
|
|
1201
1201
|
});
|
|
1202
1202
|
}
|
|
1203
1203
|
parseGetUserMedia(o) {
|
|
1204
1204
|
try {
|
|
1205
1205
|
const r = { event: "getUserMedia", tag: "getUserMedia", data: { ...o } };
|
|
1206
|
-
o.stream && (r.data.details = this.parseStream(o.stream), o.stream.getTracks().map((
|
|
1207
|
-
this.addTrackEventListeners(
|
|
1206
|
+
o.stream && (r.data.details = this.parseStream(o.stream), o.stream.getTracks().map((l) => {
|
|
1207
|
+
this.addTrackEventListeners(l), E.push(l);
|
|
1208
1208
|
})), this.emitEvent(r);
|
|
1209
1209
|
} catch {
|
|
1210
1210
|
}
|
|
1211
1211
|
}
|
|
1212
1212
|
parseStream(o) {
|
|
1213
1213
|
const r = { audio: [], video: [] };
|
|
1214
|
-
return o.getTracks().forEach((
|
|
1215
|
-
r[
|
|
1214
|
+
return o.getTracks().forEach((l) => {
|
|
1215
|
+
r[l.kind].push(this.getMediaTrackDetails(l));
|
|
1216
1216
|
}), r;
|
|
1217
1217
|
}
|
|
1218
1218
|
getMediaTrackDetails(o) {
|
|
@@ -1234,9 +1234,9 @@ var Ae, sn = zt(function(t, e) {
|
|
|
1234
1234
|
}
|
|
1235
1235
|
addTrackEventListeners(o, r) {
|
|
1236
1236
|
S[o.id] = {};
|
|
1237
|
-
const
|
|
1238
|
-
Object.keys(
|
|
1239
|
-
S[o.id][u] =
|
|
1237
|
+
const l = this.getTrackEventObject(r);
|
|
1238
|
+
Object.keys(l).forEach((u) => {
|
|
1239
|
+
S[o.id][u] = l[u].bind(this), o.addEventListener(u, S[o.id][u]);
|
|
1240
1240
|
}), S[o.id].readyState = setInterval(() => {
|
|
1241
1241
|
if (o.readyState === "ended") {
|
|
1242
1242
|
let u = new CustomEvent("ended", { detail: { check: "readyState" } });
|
|
@@ -1247,8 +1247,8 @@ var Ae, sn = zt(function(t, e) {
|
|
|
1247
1247
|
removeTrackEventListeners(o) {
|
|
1248
1248
|
if (o.id in S) {
|
|
1249
1249
|
const r = this.getTrackEventObject();
|
|
1250
|
-
Object.keys(r).forEach((
|
|
1251
|
-
o.removeEventListener(
|
|
1250
|
+
Object.keys(r).forEach((l) => {
|
|
1251
|
+
o.removeEventListener(l, S[o.id][l]);
|
|
1252
1252
|
}), clearInterval(S[o.id].readyState), delete S[o.id];
|
|
1253
1253
|
}
|
|
1254
1254
|
}
|
|
@@ -1267,12 +1267,12 @@ var Ae, sn = zt(function(t, e) {
|
|
|
1267
1267
|
return Object.keys(this.peersToMonitor).length;
|
|
1268
1268
|
}
|
|
1269
1269
|
removePeerConnectionEventListeners(o, r) {
|
|
1270
|
-
o in S && (Object.keys(this.peerConnectionListeners).forEach((
|
|
1271
|
-
r.removeEventListener(
|
|
1272
|
-
}), delete S[o]), r.getSenders().forEach((
|
|
1273
|
-
|
|
1274
|
-
}), r.getReceivers().forEach((
|
|
1275
|
-
|
|
1270
|
+
o in S && (Object.keys(this.peerConnectionListeners).forEach((l) => {
|
|
1271
|
+
r.removeEventListener(l, S[o][l], !1);
|
|
1272
|
+
}), delete S[o]), r.getSenders().forEach((l) => {
|
|
1273
|
+
l.track && this.removeTrackEventListeners(l.track);
|
|
1274
|
+
}), r.getReceivers().forEach((l) => {
|
|
1275
|
+
l.track && this.removeTrackEventListeners(l.track);
|
|
1276
1276
|
});
|
|
1277
1277
|
}
|
|
1278
1278
|
getTimestamp() {
|
|
@@ -1281,14 +1281,14 @@ var Ae, sn = zt(function(t, e) {
|
|
|
1281
1281
|
wrapGetDisplayMedia() {
|
|
1282
1282
|
const o = this;
|
|
1283
1283
|
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
|
|
1284
|
-
const r = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices),
|
|
1284
|
+
const r = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices), l = function() {
|
|
1285
1285
|
return o.debug("navigator.mediaDevices.getDisplayMedia", null, arguments[0]), r.apply(navigator.mediaDevices, arguments).then(function(u) {
|
|
1286
1286
|
return u;
|
|
1287
1287
|
}, function(u) {
|
|
1288
1288
|
return o.debug("navigator.mediaDevices.getDisplayMediaOnFailure", null, u.name), Promise.reject(u);
|
|
1289
1289
|
});
|
|
1290
1290
|
};
|
|
1291
|
-
navigator.mediaDevices.getDisplayMedia =
|
|
1291
|
+
navigator.mediaDevices.getDisplayMedia = l.bind(navigator.mediaDevices);
|
|
1292
1292
|
}
|
|
1293
1293
|
}
|
|
1294
1294
|
};
|
|
@@ -1302,7 +1302,7 @@ function Qn(t) {
|
|
|
1302
1302
|
}({ rtt: s, jitter: i }), a = function(p) {
|
|
1303
1303
|
const { packetsLost: f, packetsReceived: b } = p, C = f / (b + f) * 100;
|
|
1304
1304
|
return 20 * Math.log(1 + C);
|
|
1305
|
-
}({ packetsLost: e, packetsReceived: n }),
|
|
1305
|
+
}({ packetsLost: e, packetsReceived: n }), d = 93.2 - c - a + 0, h = 1 + 0.035 * d + 7e-6 * d * (d - 60) * (100 - d);
|
|
1306
1306
|
return Math.min(Math.max(h, 1), 5);
|
|
1307
1307
|
}
|
|
1308
1308
|
function Xn(t) {
|
|
@@ -1326,18 +1326,18 @@ class ti extends Te {
|
|
|
1326
1326
|
function ni(t) {
|
|
1327
1327
|
const e = pe(), n = new Kn({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), i = (s) => D(this, void 0, void 0, function* () {
|
|
1328
1328
|
s.event === "stats" && U(O.StatsFrame, function({ data: c }) {
|
|
1329
|
-
var a,
|
|
1330
|
-
const { audio: w, remote: R } = c, { audio: m } = R, A = (
|
|
1329
|
+
var a, d, h, p, f, b, C, I;
|
|
1330
|
+
const { audio: w, remote: R } = c, { audio: m } = R, A = (d = (a = m.inbound[0]) === null || a === void 0 ? void 0 : a.jitter) !== null && d !== void 0 ? d : 1 / 0, M = (p = (h = m.inbound[0]) === null || h === void 0 ? void 0 : h.roundTripTime) !== null && p !== void 0 ? p : 1 / 0, x = (b = (f = w.inbound[0]) === null || f === void 0 ? void 0 : f.packetsReceived) !== null && b !== void 0 ? b : -1, V = (I = (C = w.inbound[0]) === null || C === void 0 ? void 0 : C.packetsLost) !== null && I !== void 0 ? I : -1, G = Qn({ jitter: 1e3 * A, rtt: 1e3 * M, packetsLost: V, packetsReceived: x });
|
|
1331
1331
|
return { jitter: A, rtt: M, mos: G, quality: Xn(G), inboundAudio: w.inbound[0], outboundAudio: w.outbound[0], remoteInboundAudio: m.inbound[0], remoteOutboundAudio: m.outbound[0] };
|
|
1332
1332
|
}(s), t.uuid), yield t.execute(new ti(e, s));
|
|
1333
1333
|
});
|
|
1334
1334
|
return { start: (s, c, a) => D(this, void 0, void 0, function* () {
|
|
1335
|
-
yield t.execute(new Zn(e)), n.on("timeline", i), yield new Promise((
|
|
1335
|
+
yield t.execute(new Zn(e)), n.on("timeline", i), yield new Promise((d) => setTimeout(d, 500)), n.addConnection({ pc: s, peerId: c, connectionId: a });
|
|
1336
1336
|
}), stop: (s) => D(this, void 0, void 0, function* () {
|
|
1337
1337
|
const c = n.getTimeline();
|
|
1338
|
-
U(O.StatsReport, c, t.uuid), s === "file" && function(a,
|
|
1338
|
+
U(O.StatsReport, c, t.uuid), s === "file" && function(a, d) {
|
|
1339
1339
|
const h = new Blob([JSON.stringify(a)], { type: "application/json" }), p = URL.createObjectURL(h), f = document.createElement("a");
|
|
1340
|
-
f.href = p, f.download = `${
|
|
1340
|
+
f.href = p, f.download = `${d}.json`, f.click(), URL.revokeObjectURL(p);
|
|
1341
1341
|
}(c, `webrtc-stats-${e}-${Date.now()}`), yield t.execute(new ei(e)), n.removeAllPeers(), n.destroy();
|
|
1342
1342
|
}) };
|
|
1343
1343
|
}
|
|
@@ -1418,21 +1418,21 @@ class Rt {
|
|
|
1418
1418
|
L.info("Local audio tracks: ", c);
|
|
1419
1419
|
const a = i.getVideoTracks();
|
|
1420
1420
|
if (L.info("Local video tracks: ", a), this.isOffer && typeof this.instance.addTransceiver == "function") {
|
|
1421
|
-
const
|
|
1421
|
+
const d = { direction: "sendrecv", streams: [i] };
|
|
1422
1422
|
c.forEach((h) => {
|
|
1423
1423
|
this.options.userVariables.microphoneLabel = h.label;
|
|
1424
|
-
const p = this.instance.addTransceiver(h,
|
|
1424
|
+
const p = this.instance.addTransceiver(h, d);
|
|
1425
1425
|
this._setAudioCodec(p);
|
|
1426
|
-
}), console.debug("Applying video transceiverParams",
|
|
1427
|
-
this.options.userVariables.cameraLabel = h.label, this.instance.addTransceiver(h,
|
|
1426
|
+
}), console.debug("Applying video transceiverParams", d), a.forEach((h) => {
|
|
1427
|
+
this.options.userVariables.cameraLabel = h.label, this.instance.addTransceiver(h, d);
|
|
1428
1428
|
});
|
|
1429
|
-
} else typeof this.instance.addTrack == "function" ? (c.forEach((
|
|
1430
|
-
this.options.userVariables.microphoneLabel =
|
|
1431
|
-
}), this.instance.getTransceivers().forEach((
|
|
1432
|
-
this.options.userVariables.cameraLabel =
|
|
1429
|
+
} else typeof this.instance.addTrack == "function" ? (c.forEach((d) => {
|
|
1430
|
+
this.options.userVariables.microphoneLabel = d.label, this.instance.addTrack(d, i);
|
|
1431
|
+
}), this.instance.getTransceivers().forEach((d) => this._setAudioCodec(d)), a.forEach((d) => {
|
|
1432
|
+
this.options.userVariables.cameraLabel = d.label, this.instance.addTrack(d, i);
|
|
1433
1433
|
})) : this.instance.addStream(i);
|
|
1434
|
-
s === !1 && (((
|
|
1435
|
-
const h = Ce(
|
|
1434
|
+
s === !1 && (((d) => {
|
|
1435
|
+
const h = Ce(d);
|
|
1436
1436
|
h && (h.muted = !0);
|
|
1437
1437
|
})(n), Pe(n, i));
|
|
1438
1438
|
}
|
|
@@ -1470,10 +1470,10 @@ class Rt {
|
|
|
1470
1470
|
_setLocalDescription(e) {
|
|
1471
1471
|
return D(this, void 0, void 0, function* () {
|
|
1472
1472
|
const { useStereo: n, googleMaxBitrate: i, googleMinBitrate: s, googleStartBitrate: c, mediaSettings: a } = this.options;
|
|
1473
|
-
n && (e.sdp = ((
|
|
1474
|
-
const p =
|
|
1473
|
+
n && (e.sdp = ((d) => {
|
|
1474
|
+
const p = d.split(`\r
|
|
1475
1475
|
`), f = p.findIndex((w) => /^a=rtpmap/.test(w) && /opus\/48000/.test(w));
|
|
1476
|
-
if (f < 0) return
|
|
1476
|
+
if (f < 0) return d;
|
|
1477
1477
|
const b = ((w) => {
|
|
1478
1478
|
const R = new RegExp("a=rtpmap:(\\d+) \\w+\\/\\d+"), m = w.match(R);
|
|
1479
1479
|
return m && m.length == 2 ? m[1] : null;
|
|
@@ -1481,19 +1481,19 @@ class Rt {
|
|
|
1481
1481
|
return I >= 0 ? /stereo=1;/.test(p[I]) || (p[I] += "; stereo=1; sprop-stereo=1") : p[f] += `\r
|
|
1482
1482
|
a=fmtp:${b} stereo=1; sprop-stereo=1`, p.join(`\r
|
|
1483
1483
|
`);
|
|
1484
|
-
})(e.sdp)), i && s && c && (e.sdp = ((
|
|
1485
|
-
const b =
|
|
1484
|
+
})(e.sdp)), i && s && c && (e.sdp = ((d, h, p, f) => {
|
|
1485
|
+
const b = d.split(`\r
|
|
1486
1486
|
`);
|
|
1487
1487
|
return b.forEach((C, I) => {
|
|
1488
1488
|
/^a=fmtp:\d*/.test(C) ? b[I] += `;x-google-max-bitrate=${h};x-google-min-bitrate=${p};x-google-start-bitrate=${f}` : /^a=mid:(1|video)/.test(C) && (b[I] += `\r
|
|
1489
1489
|
b=AS:${h}`);
|
|
1490
1490
|
}), b.join(`\r
|
|
1491
1491
|
`);
|
|
1492
|
-
})(e.sdp, i, s, c)), a && a.useSdpASBandwidthKbps && a.sdpASBandwidthKbps !== null && (e.sdp = ((
|
|
1492
|
+
})(e.sdp, i, s, c)), a && a.useSdpASBandwidthKbps && a.sdpASBandwidthKbps !== null && (e.sdp = ((d, h) => {
|
|
1493
1493
|
let p = "AS", f = h;
|
|
1494
|
-
return !navigator.userAgent.match(/firefox/gim) || navigator.userAgent.match(/OPR\/[0-9]{2}/gi) || navigator.userAgent.match(/edg/gim) || (p = "TIAS", f = 1e3 * (h >>> 0)),
|
|
1494
|
+
return !navigator.userAgent.match(/firefox/gim) || navigator.userAgent.match(/OPR\/[0-9]{2}/gi) || navigator.userAgent.match(/edg/gim) || (p = "TIAS", f = 1e3 * (h >>> 0)), d.indexOf("b=" + p + ":") === -1 ? d.replace(/c=IN (.*)\r\n/, `c=IN $1\r
|
|
1495
1495
|
b=` + p + ":" + f + `\r
|
|
1496
|
-
`) :
|
|
1496
|
+
`) : d.replace(new RegExp("b=" + p + `:.*\r
|
|
1497
1497
|
`), "b=" + p + ":" + f + `\r
|
|
1498
1498
|
`);
|
|
1499
1499
|
})(e.sdp, a.sdpASBandwidthKbps)), yield this.instance.setLocalDescription(e);
|
|
@@ -1509,9 +1509,9 @@ b=` + p + ":" + f + `\r
|
|
|
1509
1509
|
let { audio: i = !0, micId: s } = n;
|
|
1510
1510
|
const { micLabel: c = "" } = n;
|
|
1511
1511
|
s && (s = yield Ue(s, c, se.AudioIn).catch((p) => null), s && (typeof i == "boolean" && (i = {}), i.deviceId = { exact: s }));
|
|
1512
|
-
let { camId: a } = n,
|
|
1512
|
+
let { camId: a } = n, d = n.video;
|
|
1513
1513
|
const { camLabel: h = "" } = n;
|
|
1514
|
-
return a && (a = yield Ue(a, h, se.Video).catch((p) => null), a && (typeof
|
|
1514
|
+
return a && (a = yield Ue(a, h, se.Video).catch((p) => null), a && (typeof d == "boolean" && (d = {}), d.deviceId = { exact: a })), { audio: i, video: d };
|
|
1515
1515
|
}));
|
|
1516
1516
|
var n;
|
|
1517
1517
|
return je(e);
|
|
@@ -1534,7 +1534,7 @@ b=` + p + ":" + f + `\r
|
|
|
1534
1534
|
});
|
|
1535
1535
|
}
|
|
1536
1536
|
}
|
|
1537
|
-
const ii =
|
|
1537
|
+
const ii = lt;
|
|
1538
1538
|
class on {
|
|
1539
1539
|
constructor(e, n) {
|
|
1540
1540
|
this.session = e, this.id = "", this.state = j[j.New], this.prevState = "", this.channels = [], this.role = Se.Participant, this.extension = null, this._state = j.New, this._prevState = j.New, this.gotAnswer = !1, this.gotEarly = !1, this._lastSerno = 0, this._targetNodeId = null, this._iceTimeout = null, this._iceDone = !1, this._statsBindings = [], this._statsIntervalId = null, this._checkConferenceSerno = (m) => {
|
|
@@ -1554,8 +1554,8 @@ class on {
|
|
|
1554
1554
|
});
|
|
1555
1555
|
});
|
|
1556
1556
|
};
|
|
1557
|
-
const { iceServers: i, speaker: s, micId: c, micLabel: a, camId:
|
|
1558
|
-
this.options = Object.assign({}, xn, { audio: C, video: I, iceServers: i, localElement: p, remoteElement: f, micId: c, micLabel: a, camId:
|
|
1557
|
+
const { iceServers: i, speaker: s, micId: c, micLabel: a, camId: d, camLabel: h, localElement: p, remoteElement: f, options: b, mediaConstraints: { audio: C, video: I }, ringtoneFile: w, ringbackFile: R } = e;
|
|
1558
|
+
this.options = Object.assign({}, xn, { audio: C, video: I, iceServers: i, localElement: p, remoteElement: f, micId: c, micLabel: a, camId: d, camLabel: h, speakerId: s, ringtoneFile: w, ringbackFile: R, debug: b.debug, debugOutput: b.debugOutput }, n), this._onMediaError = this._onMediaError.bind(this), this._init(), this.options && (this._ringtone = It(this.options.ringtoneFile, "_ringtone"), this._ringback = It(this.options.ringbackFile, "_ringback"));
|
|
1559
1559
|
}
|
|
1560
1560
|
get nodeId() {
|
|
1561
1561
|
return this._targetNodeId;
|
|
@@ -1596,13 +1596,13 @@ class on {
|
|
|
1596
1596
|
}
|
|
1597
1597
|
hangup(e, n) {
|
|
1598
1598
|
var i, s, c;
|
|
1599
|
-
let a = e || {},
|
|
1599
|
+
let a = e || {}, d = n !== !1;
|
|
1600
1600
|
this.cause = a.cause || "NORMAL_CLEARING", this.causeCode = a.causeCode || 16, this.sipCode = a.sipCode || null, this.sipReason = a.sipReason || null, this.sipCallId = a.sip_call_id || null, this.options.customHeaders = [...(i = this.options.customHeaders) !== null && i !== void 0 ? i : [], ...(c = (s = a?.dialogParams) === null || s === void 0 ? void 0 : s.customHeaders) !== null && c !== void 0 ? c : []], this.setState(j.Hangup);
|
|
1601
1601
|
const h = () => {
|
|
1602
1602
|
var p;
|
|
1603
1603
|
return (p = this.peer) === null || p === void 0 || p.close(), this.setState(j.Destroy);
|
|
1604
1604
|
};
|
|
1605
|
-
if (this.stopRingtone(), this.stopRingback(),
|
|
1605
|
+
if (this.stopRingtone(), this.stopRingback(), d) {
|
|
1606
1606
|
const p = new Wn({ sessid: this.session.sessionid, dialogParams: this.options, cause: "USER_BUSY", causeCode: 17 });
|
|
1607
1607
|
this._execute(p).catch((f) => {
|
|
1608
1608
|
L.error("telnyx_rtc.bye failed!", f), U(O.Error, { error: f, sessionId: this.session.sessionid }, this.session.uuid);
|
|
@@ -1645,7 +1645,7 @@ class on {
|
|
|
1645
1645
|
const s = yield nt({ audio: { deviceId: { exact: e } } }), c = s.getAudioTracks()[0];
|
|
1646
1646
|
i.replaceTrack(c), this.options.micId = e;
|
|
1647
1647
|
const { localStream: a } = this.options;
|
|
1648
|
-
a.getAudioTracks().forEach((
|
|
1648
|
+
a.getAudioTracks().forEach((d) => d.stop()), a.getVideoTracks().forEach((d) => s.addTrack(d)), this.options.localStream = s;
|
|
1649
1649
|
}
|
|
1650
1650
|
});
|
|
1651
1651
|
}
|
|
@@ -1667,8 +1667,8 @@ class on {
|
|
|
1667
1667
|
if (i) {
|
|
1668
1668
|
const s = yield nt({ video: { deviceId: { exact: e } } }), c = s.getVideoTracks()[0];
|
|
1669
1669
|
i.replaceTrack(c);
|
|
1670
|
-
const { localElement: a, localStream:
|
|
1671
|
-
Pe(a, s), this.options.camId = e,
|
|
1670
|
+
const { localElement: a, localStream: d } = this.options;
|
|
1671
|
+
Pe(a, s), this.options.camId = e, d.getAudioTracks().forEach((h) => s.addTrack(h)), d.getVideoTracks().forEach((h) => h.stop()), this.options.localStream = s;
|
|
1672
1672
|
}
|
|
1673
1673
|
});
|
|
1674
1674
|
}
|
|
@@ -1691,7 +1691,7 @@ class on {
|
|
|
1691
1691
|
const a = c.getParameters();
|
|
1692
1692
|
a.encodings || (a.encodings = [{ rid: "h" }]), L.info("Parameters: ", a), L.info("Setting max ", n === "audio" ? "audio" : "video", " bandwidth to: ", e, " [bps]"), a.encodings[0].maxBitrate = e, yield c.setParameters(a).then(() => {
|
|
1693
1693
|
L.info(n === "audio" ? "New audio" : "New video", " bandwidth settings in use: ", c.getParameters());
|
|
1694
|
-
}).catch((
|
|
1694
|
+
}).catch((d) => console.error(d));
|
|
1695
1695
|
} else L.error("Could not set bandwidth (reason: no " + n + " sender). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
|
|
1696
1696
|
});
|
|
1697
1697
|
}
|
|
@@ -1734,9 +1734,9 @@ class on {
|
|
|
1734
1734
|
break;
|
|
1735
1735
|
case F.Display:
|
|
1736
1736
|
case F.Attach: {
|
|
1737
|
-
const { display_name: c, display_number: a, display_direction:
|
|
1737
|
+
const { display_name: c, display_number: a, display_direction: d } = i;
|
|
1738
1738
|
this.extension = a;
|
|
1739
|
-
const h =
|
|
1739
|
+
const h = d === re.Inbound ? re.Outbound : re.Inbound, p = { type: ie[n], call: this, displayName: c, displayNumber: a, displayDirection: h };
|
|
1740
1740
|
U(O.Notification, p, this.id) || U(O.Notification, p, this.session.uuid);
|
|
1741
1741
|
break;
|
|
1742
1742
|
}
|
|
@@ -1761,8 +1761,8 @@ class on {
|
|
|
1761
1761
|
switch (i) {
|
|
1762
1762
|
case "bootObj": {
|
|
1763
1763
|
this._lastSerno = 0;
|
|
1764
|
-
const { chatChannel:
|
|
1765
|
-
this._dispatchConferenceUpdate({ action: Q.Join, conferenceName: f, participantId: Number(b), role: C }),
|
|
1764
|
+
const { chatChannel: d, infoChannel: h, modChannel: p, laName: f, conferenceMemberID: b, role: C } = n;
|
|
1765
|
+
this._dispatchConferenceUpdate({ action: Q.Join, conferenceName: f, participantId: Number(b), role: C }), d && (yield this._subscribeConferenceChat(d)), h && (yield this._subscribeConferenceInfo(h)), p && C === Se.Moderator && (yield this._subscribeConferenceModerator(p));
|
|
1766
1766
|
const I = [];
|
|
1767
1767
|
for (const w in s) I.push(Object.assign({ callId: s[w][0], index: Number(w) }, xe(s[w][1])));
|
|
1768
1768
|
this._dispatchConferenceUpdate({ action: Q.Bootstrap, participants: I });
|
|
@@ -1793,8 +1793,8 @@ class on {
|
|
|
1793
1793
|
_subscribeConferenceChat(e) {
|
|
1794
1794
|
return D(this, void 0, void 0, function* () {
|
|
1795
1795
|
const n = { nodeId: this.nodeId, channels: [e], handler: (s) => {
|
|
1796
|
-
const { direction: c, from: a, fromDisplay:
|
|
1797
|
-
this._dispatchConferenceUpdate({ action: Q.ChatMessage, direction: c, participantNumber: a, participantName:
|
|
1796
|
+
const { direction: c, from: a, fromDisplay: d, message: h, type: p } = s.data;
|
|
1797
|
+
this._dispatchConferenceUpdate({ action: Q.ChatMessage, direction: c, participantNumber: a, participantName: d, messageText: h, messageType: p, messageId: s.eventSerno });
|
|
1798
1798
|
} }, i = yield this.session.vertoSubscribe(n).catch((s) => {
|
|
1799
1799
|
L.error("ConfChat subscription error:", s);
|
|
1800
1800
|
});
|
|
@@ -1820,20 +1820,20 @@ class on {
|
|
|
1820
1820
|
}
|
|
1821
1821
|
_subscribeConferenceModerator(e) {
|
|
1822
1822
|
return D(this, void 0, void 0, function* () {
|
|
1823
|
-
const n = (a,
|
|
1824
|
-
const p = parseInt(
|
|
1823
|
+
const n = (a, d = null, h = null) => {
|
|
1824
|
+
const p = parseInt(d) || null;
|
|
1825
1825
|
this._confControl(e, { command: a, id: p, value: h });
|
|
1826
1826
|
}, i = () => {
|
|
1827
1827
|
const { video: a } = this.options;
|
|
1828
1828
|
if (typeof a == "boolean" && !a || typeof a == "object" && ft(a)) throw `Conference ${this.id} has no video!`;
|
|
1829
1829
|
}, s = { nodeId: this.nodeId, channels: [e], handler: (a) => {
|
|
1830
|
-
const { data:
|
|
1831
|
-
if (
|
|
1832
|
-
if (
|
|
1833
|
-
const h = JSON.stringify(
|
|
1830
|
+
const { data: d } = a;
|
|
1831
|
+
if (d["conf-command"] === "list-videoLayouts") {
|
|
1832
|
+
if (d.responseData) {
|
|
1833
|
+
const h = JSON.stringify(d.responseData).replace(/IDS"/g, 'Ids"');
|
|
1834
1834
|
this._dispatchConferenceUpdate({ action: Q.LayoutList, layouts: JSON.parse(h) });
|
|
1835
1835
|
}
|
|
1836
|
-
} else this._dispatchConferenceUpdate({ action: Q.ModCmdResponse, command:
|
|
1836
|
+
} else this._dispatchConferenceUpdate({ action: Q.ModCmdResponse, command: d["conf-command"], response: d.response });
|
|
1837
1837
|
} }, c = yield this.session.vertoSubscribe(s).catch((a) => {
|
|
1838
1838
|
L.error("ConfMod subscription error:", a);
|
|
1839
1839
|
});
|
|
@@ -1853,8 +1853,8 @@ class on {
|
|
|
1853
1853
|
n("recording", null, ["stop", "all"]);
|
|
1854
1854
|
} }, snapshot: { configurable: !0, value: (a) => {
|
|
1855
1855
|
i(), n("vid-write-png", null, a);
|
|
1856
|
-
} }, setVideoLayout: { configurable: !0, value: (a,
|
|
1857
|
-
i(), n("vid-layout", null,
|
|
1856
|
+
} }, setVideoLayout: { configurable: !0, value: (a, d) => {
|
|
1857
|
+
i(), n("vid-layout", null, d ? [a, d] : a);
|
|
1858
1858
|
} }, kick: { configurable: !0, value: (a) => {
|
|
1859
1859
|
n("kick", a);
|
|
1860
1860
|
} }, muteMic: { configurable: !0, value: (a) => {
|
|
@@ -1865,8 +1865,8 @@ class on {
|
|
|
1865
1865
|
i(), n("vid-res-id", a, "presenter");
|
|
1866
1866
|
} }, videoFloor: { configurable: !0, value: (a) => {
|
|
1867
1867
|
i(), n("vid-floor", a, "force");
|
|
1868
|
-
} }, banner: { configurable: !0, value: (a,
|
|
1869
|
-
i(), n("vid-banner", a, encodeURI(
|
|
1868
|
+
} }, banner: { configurable: !0, value: (a, d) => {
|
|
1869
|
+
i(), n("vid-banner", a, encodeURI(d));
|
|
1870
1870
|
} }, volumeDown: { configurable: !0, value: (a) => {
|
|
1871
1871
|
n("volume_out", a, "down");
|
|
1872
1872
|
} }, volumeUp: { configurable: !0, value: (a) => {
|
|
@@ -1875,8 +1875,8 @@ class on {
|
|
|
1875
1875
|
n("volume_in", a, "down");
|
|
1876
1876
|
} }, gainUp: { configurable: !0, value: (a) => {
|
|
1877
1877
|
n("volume_in", a, "up");
|
|
1878
|
-
} }, transfer: { configurable: !0, value: (a,
|
|
1879
|
-
n("transfer", a,
|
|
1878
|
+
} }, transfer: { configurable: !0, value: (a, d) => {
|
|
1879
|
+
n("transfer", a, d);
|
|
1880
1880
|
} } }));
|
|
1881
1881
|
});
|
|
1882
1882
|
}
|
|
@@ -1907,13 +1907,13 @@ class on {
|
|
|
1907
1907
|
`), void this._requestAnotherLocalDescription();
|
|
1908
1908
|
(i = (n = this.peer) === null || n === void 0 ? void 0 : n.instance) === null || i === void 0 || i.removeEventListener("icecandidate", this._onIce);
|
|
1909
1909
|
let a = null;
|
|
1910
|
-
const
|
|
1910
|
+
const d = { sessid: this.session.sessionid, sdp: s, dialogParams: this.options, "User-Agent": `Web-${ii}` };
|
|
1911
1911
|
switch (c) {
|
|
1912
1912
|
case te.Offer:
|
|
1913
|
-
this.setState(j.Requesting), a = new Fn(
|
|
1913
|
+
this.setState(j.Requesting), a = new Fn(d);
|
|
1914
1914
|
break;
|
|
1915
1915
|
case te.Answer:
|
|
1916
|
-
this.setState(j.Answering), a = this.options.attach === !0 ? new Bn(
|
|
1916
|
+
this.setState(j.Answering), a = this.options.attach === !0 ? new Bn(d) : new Gn(d);
|
|
1917
1917
|
break;
|
|
1918
1918
|
default:
|
|
1919
1919
|
return L.error(`${this.id} - Unknown local SDP type:`, e), this.hangup({}, !1);
|
|
@@ -1955,7 +1955,7 @@ class on {
|
|
|
1955
1955
|
}
|
|
1956
1956
|
_init() {
|
|
1957
1957
|
const { id: e, userVariables: n, remoteCallerNumber: i, onNotification: s } = this.options;
|
|
1958
|
-
e || (this.options.id = pe()), this.id = this.options.id, n && !ft(n) || (this.options.userVariables = this.session.options.userVariables || {}), i || (this.options.remoteCallerNumber = this.options.destinationNumber), this.session.calls[this.id] = this,
|
|
1958
|
+
e || (this.options.id = pe()), this.id = this.options.id, n && !ft(n) || (this.options.userVariables = this.session.options.userVariables || {}), i || (this.options.remoteCallerNumber = this.options.destinationNumber), this.session.calls[this.id] = this, de(O.MediaError, this._onMediaError, this.id), fe(s) && de(O.Notification, s.bind(this), this.id), this.setState(j.New), L.info("New Call with Options:", this.options);
|
|
1959
1959
|
}
|
|
1960
1960
|
_finalize() {
|
|
1961
1961
|
this._stopStats(), this.peer && this.peer.instance && (this.peer.instance.close(), this.peer = null);
|
|
@@ -1999,7 +1999,7 @@ on.setStateTelnyx = (t) => {
|
|
|
1999
1999
|
};
|
|
2000
2000
|
class ae extends on {
|
|
2001
2001
|
constructor() {
|
|
2002
|
-
super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e) => this.session.execute(new Jn(e));
|
|
2002
|
+
super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, n) => this.session.execute(new Jn(e, n));
|
|
2003
2003
|
}
|
|
2004
2004
|
hangup(e = {}, n = !0) {
|
|
2005
2005
|
this.screenShare instanceof ae && this.screenShare.hangup(e, n), super.hangup(e, n);
|
|
@@ -2013,7 +2013,7 @@ class ae extends on {
|
|
|
2013
2013
|
this.screenShare && this.screenShare.hangup();
|
|
2014
2014
|
});
|
|
2015
2015
|
});
|
|
2016
|
-
const { remoteCallerName: s, remoteCallerNumber: c, callerName: a, callerNumber:
|
|
2016
|
+
const { remoteCallerName: s, remoteCallerNumber: c, callerName: a, callerNumber: d } = this.options, h = Object.assign({ screenShare: !0, localStream: n, destinationNumber: `${this.extension}-screen`, remoteCallerName: s, remoteCallerNumber: `${c}-screen`, callerName: `${a} (Screen)`, callerNumber: `${d} (Screen)` }, e);
|
|
2017
2017
|
return this.screenShare = new ae(this.session, h), this.screenShare.invite(), this.screenShare;
|
|
2018
2018
|
});
|
|
2019
2019
|
}
|
|
@@ -2039,8 +2039,8 @@ class ae extends on {
|
|
|
2039
2039
|
n.forEach((a) => {
|
|
2040
2040
|
s.includes(a.type) || (i += `
|
|
2041
2041
|
${a.type}
|
|
2042
|
-
`, Object.keys(a).forEach((
|
|
2043
|
-
c.includes(
|
|
2042
|
+
`, Object.keys(a).forEach((d) => {
|
|
2043
|
+
c.includes(d) || (i += ` ${d}: ${a[d]}
|
|
2044
2044
|
`);
|
|
2045
2045
|
}));
|
|
2046
2046
|
}), L.info(i);
|
|
@@ -2082,8 +2082,8 @@ class si extends Pn {
|
|
|
2082
2082
|
speedTest(e) {
|
|
2083
2083
|
return new Promise((n, i) => {
|
|
2084
2084
|
if (Xt(O.SpeedTest, (a) => {
|
|
2085
|
-
const { upDur:
|
|
2086
|
-
n({ upDur:
|
|
2085
|
+
const { upDur: d, downDur: h } = a, p = h ? 8 * e / (h / 1e3) / 1024 : 0;
|
|
2086
|
+
n({ upDur: d, downDur: h, upKps: (d ? 8 * e / (d / 1e3) / 1024 : 0).toFixed(0), downKps: p.toFixed(0) });
|
|
2087
2087
|
}, this.uuid), !(e = Number(e))) return i(`Invalid parameter 'bytes': ${e}`);
|
|
2088
2088
|
this.executeRaw(`#SPU ${e}`);
|
|
2089
2089
|
let s = e / 1024;
|
|
@@ -2114,8 +2114,8 @@ class si extends Pn {
|
|
|
2114
2114
|
return yield ((n) => D(void 0, void 0, void 0, function* () {
|
|
2115
2115
|
const i = [], s = yield je({ video: { deviceId: { exact: n } } }), c = s.getVideoTracks()[0];
|
|
2116
2116
|
for (let a = 0; a < bt.length; a++) {
|
|
2117
|
-
const [
|
|
2118
|
-
(yield c.applyConstraints({ width: { exact:
|
|
2117
|
+
const [d, h] = bt[a];
|
|
2118
|
+
(yield c.applyConstraints({ width: { exact: d }, height: { exact: h } }).then(() => !0).catch(() => !1)) && i.push({ resolution: `${d}x${h}`, width: d, height: h });
|
|
2119
2119
|
}
|
|
2120
2120
|
return Ie(s), i;
|
|
2121
2121
|
}))(e);
|
|
@@ -2188,17 +2188,17 @@ class si extends Pn {
|
|
|
2188
2188
|
if (!(n = n.filter((h) => h && !this._existsSubscription(this.relayProtocol, h))).length) return {};
|
|
2189
2189
|
const s = new Yn({ sessid: this.sessionid, eventChannel: n });
|
|
2190
2190
|
e && (s.targetNodeId = e);
|
|
2191
|
-
const c = yield this.execute(s), { unauthorized: a = [], subscribed:
|
|
2192
|
-
return a.length && a.forEach((h) => this._removeSubscription(this.relayProtocol, h)),
|
|
2191
|
+
const c = yield this.execute(s), { unauthorized: a = [], subscribed: d = [] } = it(c);
|
|
2192
|
+
return a.length && a.forEach((h) => this._removeSubscription(this.relayProtocol, h)), d.forEach((h) => this._addSubscription(this.relayProtocol, i, h)), c;
|
|
2193
2193
|
});
|
|
2194
2194
|
}
|
|
2195
2195
|
vertoUnsubscribe({ nodeId: e, channels: n = [] }) {
|
|
2196
2196
|
return D(this, void 0, void 0, function* () {
|
|
2197
|
-
if (!(n = n.filter((
|
|
2197
|
+
if (!(n = n.filter((d) => d && this._existsSubscription(this.relayProtocol, d))).length) return {};
|
|
2198
2198
|
const i = new zn({ sessid: this.sessionid, eventChannel: n });
|
|
2199
2199
|
e && (i.targetNodeId = e);
|
|
2200
2200
|
const s = yield this.execute(i), { unsubscribed: c = [], notSubscribed: a = [] } = it(s);
|
|
2201
|
-
return c.forEach((
|
|
2201
|
+
return c.forEach((d) => this._removeSubscription(this.relayProtocol, d)), a.forEach((d) => this._removeSubscription(this.relayProtocol, d)), s;
|
|
2202
2202
|
});
|
|
2203
2203
|
}
|
|
2204
2204
|
static telnyxStateCall(e) {
|
|
@@ -2227,7 +2227,7 @@ class ne {
|
|
|
2227
2227
|
return 1e3 * Kt(2, 6);
|
|
2228
2228
|
}
|
|
2229
2229
|
handleMessage(e) {
|
|
2230
|
-
const { session: n } = this, { id: i, method: s, params: c = {} } = e, a = c?.callID,
|
|
2230
|
+
const { session: n } = this, { id: i, method: s, params: c = {} } = e, a = c?.callID, d = c?.eventChannel, h = c?.eventType, p = s === F.Attach;
|
|
2231
2231
|
if (h === "channelPvtData") return this._handlePvtEvent(c.pvtData);
|
|
2232
2232
|
if (a && n.calls.hasOwnProperty(a)) {
|
|
2233
2233
|
if (!p) return n.calls[a].handleMessage(e), void this._ack(i, s);
|
|
@@ -2259,9 +2259,9 @@ class ne {
|
|
|
2259
2259
|
}
|
|
2260
2260
|
case F.Event:
|
|
2261
2261
|
case "webrtc.event":
|
|
2262
|
-
if (!
|
|
2263
|
-
const I = n.relayProtocol, w =
|
|
2264
|
-
n._existsSubscription(I,
|
|
2262
|
+
if (!d) return void L.error("Verto received an unknown event:", c);
|
|
2263
|
+
const I = n.relayProtocol, w = d.split(".")[0];
|
|
2264
|
+
n._existsSubscription(I, d) ? U(I, c, d) : d === n.sessionid ? this._handleSessionEvent(c.eventData) : n._existsSubscription(I, w) ? U(I, c, w) : n.calls.hasOwnProperty(d) ? n.calls[d].handleMessage(e) : U(O.Notification, c, n.uuid);
|
|
2265
2265
|
break;
|
|
2266
2266
|
case F.Info:
|
|
2267
2267
|
c.type = ie.generic, U(O.Notification, c, n.uuid);
|
|
@@ -2325,7 +2325,7 @@ class ne {
|
|
|
2325
2325
|
}
|
|
2326
2326
|
_handlePvtEvent(e) {
|
|
2327
2327
|
return D(this, void 0, void 0, function* () {
|
|
2328
|
-
const { session: n } = this, i = n.relayProtocol, { action: s, laChannel: c, laName: a, chatChannel:
|
|
2328
|
+
const { session: n } = this, i = n.relayProtocol, { action: s, laChannel: c, laName: a, chatChannel: d, infoChannel: h, modChannel: p, conferenceMemberID: f, role: b, callID: C } = e;
|
|
2329
2329
|
switch (s) {
|
|
2330
2330
|
case "conference-liveArray-join": {
|
|
2331
2331
|
const I = () => {
|
|
@@ -2353,7 +2353,7 @@ class ne {
|
|
|
2353
2353
|
U(O.Notification, m, R, !1) || U(O.Notification, m, n.uuid), I === null && ue(O.Notification, null, R);
|
|
2354
2354
|
}
|
|
2355
2355
|
}
|
|
2356
|
-
const w = [c,
|
|
2356
|
+
const w = [c, d, h, p];
|
|
2357
2357
|
n.vertoUnsubscribe({ nodeId: this.nodeId, channels: w }).then(({ unsubscribedChannels: R = [] }) => {
|
|
2358
2358
|
I && (I.channels = I.channels.filter((m) => !R.includes(m)));
|
|
2359
2359
|
}).catch((R) => {
|
|
@@ -2382,7 +2382,7 @@ ne.retriedConnect = 0, ne.retriedRegister = 0;
|
|
|
2382
2382
|
class ri extends Z {
|
|
2383
2383
|
constructor(e) {
|
|
2384
2384
|
super(), this.method = "anonymous_login";
|
|
2385
|
-
const { target_type: n, target_id: i, target_version_id: s, userVariables: c, sessionId: a, reconnection:
|
|
2385
|
+
const { target_type: n, target_id: i, target_version_id: s, userVariables: c, sessionId: a, reconnection: d } = e, h = { target_type: n, target_id: i, userVariables: c, reconnection: d, "User-Agent": { sdkVersion: lt, data: navigator.userAgent } };
|
|
2386
2386
|
a && (h.sessid = a), s && (h.target_version_id = s), this.buildRequest({ method: this.method, params: h });
|
|
2387
2387
|
}
|
|
2388
2388
|
}
|
|
@@ -2390,8 +2390,8 @@ class ai extends si {
|
|
|
2390
2390
|
constructor(e) {
|
|
2391
2391
|
super(e), this.relayProtocol = "verto-protocol", this.timeoutErrorCode = -329990, this.handleLoginOnSocketOpen = () => D(this, void 0, void 0, function* () {
|
|
2392
2392
|
this._idle = !1;
|
|
2393
|
-
const { login: n, password: i, passwd: s, login_token: c, userVariables: a, autoReconnect:
|
|
2394
|
-
p && (this._autoReconnect =
|
|
2393
|
+
const { login: n, password: i, passwd: s, login_token: c, userVariables: a, autoReconnect: d = !0 } = this.options, h = new $n(n, i || s, c, this.sessionid, a, !!tt()), p = yield this.execute(h).catch(this._handleLoginError);
|
|
2394
|
+
p && (this._autoReconnect = d, this.sessionid = p.sessid);
|
|
2395
2395
|
}), this.handleAnonymousLoginOnSocketOpen = () => D(this, void 0, void 0, function* () {
|
|
2396
2396
|
this._idle = !1;
|
|
2397
2397
|
const { anonymous_login: n } = this.options, i = new ri({ target_id: n.target_id, target_type: n.target_type, target_version_id: n.target_version_id, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!tt() }), s = yield this.execute(i).catch(this._handleLoginError);
|
|
@@ -2446,11 +2446,11 @@ class ci extends ai {
|
|
|
2446
2446
|
return [{ operationSystem: "Android", supported: [{ browserName: "Chrome", features: ["audio"], supported: q.full }, { browserName: "Firefox", features: ["audio"], supported: q.partial }, { browserName: "Safari", supported: q.not_supported }, { browserName: "Edge", supported: q.not_supported }] }, { operationSystem: "iOS", supported: [{ browserName: "Chrome", supported: q.not_supported }, { browserName: "Firefox", supported: q.not_supported }, { browserName: "Safari", features: ["video", "audio"], supported: q.full }, { browserName: "Edge", supported: q.not_supported }] }, { operationSystem: "Linux", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: q.full }, { browserName: "Firefox", features: ["audio"], supported: q.partial }, { browserName: "Safari", supported: q.not_supported }, { browserName: "Edge", supported: q.not_supported }] }, { operationSystem: "MacOS", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: q.full }, { browserName: "Firefox", features: ["audio"], supported: q.partial }, { browserName: "Safari", features: ["video", "audio"], supported: q.full }, { browserName: "Edge", features: ["audio"], supported: q.partial }] }, { operationSystem: "Windows", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: q.full }, { browserName: "Firefox", features: ["audio"], supported: q.partial }, { browserName: "Safari", supported: q.not_supported }, { browserName: "Edge", features: ["audio"], supported: q.partial }] }];
|
|
2447
2447
|
}
|
|
2448
2448
|
}
|
|
2449
|
-
function
|
|
2449
|
+
function li(t) {
|
|
2450
2450
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
2451
2451
|
}
|
|
2452
2452
|
var Je = { exports: {} }, At;
|
|
2453
|
-
function
|
|
2453
|
+
function di() {
|
|
2454
2454
|
return At || (At = 1, function(t) {
|
|
2455
2455
|
var e = Object.prototype.hasOwnProperty, n = "~";
|
|
2456
2456
|
function i() {
|
|
@@ -2468,26 +2468,26 @@ function li() {
|
|
|
2468
2468
|
function a(h, p) {
|
|
2469
2469
|
--h._eventsCount === 0 ? h._events = new i() : delete h._events[p];
|
|
2470
2470
|
}
|
|
2471
|
-
function
|
|
2471
|
+
function d() {
|
|
2472
2472
|
this._events = new i(), this._eventsCount = 0;
|
|
2473
2473
|
}
|
|
2474
|
-
|
|
2474
|
+
d.prototype.eventNames = function() {
|
|
2475
2475
|
var p = [], f, b;
|
|
2476
2476
|
if (this._eventsCount === 0) return p;
|
|
2477
2477
|
for (b in f = this._events)
|
|
2478
2478
|
e.call(f, b) && p.push(n ? b.slice(1) : b);
|
|
2479
2479
|
return Object.getOwnPropertySymbols ? p.concat(Object.getOwnPropertySymbols(f)) : p;
|
|
2480
|
-
},
|
|
2480
|
+
}, d.prototype.listeners = function(p) {
|
|
2481
2481
|
var f = n ? n + p : p, b = this._events[f];
|
|
2482
2482
|
if (!b) return [];
|
|
2483
2483
|
if (b.fn) return [b.fn];
|
|
2484
2484
|
for (var C = 0, I = b.length, w = new Array(I); C < I; C++)
|
|
2485
2485
|
w[C] = b[C].fn;
|
|
2486
2486
|
return w;
|
|
2487
|
-
},
|
|
2487
|
+
}, d.prototype.listenerCount = function(p) {
|
|
2488
2488
|
var f = n ? n + p : p, b = this._events[f];
|
|
2489
2489
|
return b ? b.fn ? 1 : b.length : 0;
|
|
2490
|
-
},
|
|
2490
|
+
}, d.prototype.emit = function(p, f, b, C, I, w) {
|
|
2491
2491
|
var R = n ? n + p : p;
|
|
2492
2492
|
if (!this._events[R]) return !1;
|
|
2493
2493
|
var m = this._events[R], A = arguments.length, M, x;
|
|
@@ -2532,11 +2532,11 @@ function li() {
|
|
|
2532
2532
|
}
|
|
2533
2533
|
}
|
|
2534
2534
|
return !0;
|
|
2535
|
-
},
|
|
2535
|
+
}, d.prototype.on = function(p, f, b) {
|
|
2536
2536
|
return c(this, p, f, b, !1);
|
|
2537
|
-
},
|
|
2537
|
+
}, d.prototype.once = function(p, f, b) {
|
|
2538
2538
|
return c(this, p, f, b, !0);
|
|
2539
|
-
},
|
|
2539
|
+
}, d.prototype.removeListener = function(p, f, b, C) {
|
|
2540
2540
|
var I = n ? n + p : p;
|
|
2541
2541
|
if (!this._events[I]) return this;
|
|
2542
2542
|
if (!f)
|
|
@@ -2550,14 +2550,14 @@ function li() {
|
|
|
2550
2550
|
m.length ? this._events[I] = m.length === 1 ? m[0] : m : a(this, I);
|
|
2551
2551
|
}
|
|
2552
2552
|
return this;
|
|
2553
|
-
},
|
|
2553
|
+
}, d.prototype.removeAllListeners = function(p) {
|
|
2554
2554
|
var f;
|
|
2555
2555
|
return p ? (f = n ? n + p : p, this._events[f] && a(this, f)) : (this._events = new i(), this._eventsCount = 0), this;
|
|
2556
|
-
},
|
|
2556
|
+
}, d.prototype.off = d.prototype.removeListener, d.prototype.addListener = d.prototype.on, d.prefixed = n, d.EventEmitter = d, t.exports = d;
|
|
2557
2557
|
}(Je)), Je.exports;
|
|
2558
2558
|
}
|
|
2559
|
-
var ui =
|
|
2560
|
-
const
|
|
2559
|
+
var ui = di();
|
|
2560
|
+
const dt = /* @__PURE__ */ li(ui), Ee = new dt();
|
|
2561
2561
|
function hi(t) {
|
|
2562
2562
|
if (!t || typeof t != "object")
|
|
2563
2563
|
return !1;
|
|
@@ -2585,14 +2585,18 @@ function gi(t) {
|
|
|
2585
2585
|
} : null;
|
|
2586
2586
|
}
|
|
2587
2587
|
function vi(t) {
|
|
2588
|
-
|
|
2589
|
-
|
|
2588
|
+
if (!fi(t) || t.params.item.role !== "user" || t.params.item.status !== "completed")
|
|
2589
|
+
return null;
|
|
2590
|
+
let e = "", n = [];
|
|
2591
|
+
return Array.isArray(t.params.item.content) ? (e = t.params.item.content.reduce((i, s) => (s.type === "text" && (i += s.text), i), ""), n = t.params.item.content.reduce((i, s) => (s.type === "image_url" && s.image_url.url && i.push({ type: "image", url: s.image_url.url }), i), [])) : e = t.params.item.content, {
|
|
2592
|
+
id: t.params.item.id,
|
|
2590
2593
|
role: t.params.item.role,
|
|
2591
|
-
|
|
2592
|
-
|
|
2594
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
2595
|
+
content: e,
|
|
2596
|
+
attachments: n
|
|
2593
2597
|
};
|
|
2594
2598
|
}
|
|
2595
|
-
class mi extends
|
|
2599
|
+
class mi extends dt {
|
|
2596
2600
|
telnyxRTC;
|
|
2597
2601
|
transcript = [];
|
|
2598
2602
|
constructor(e) {
|
|
@@ -2603,7 +2607,7 @@ class mi extends lt {
|
|
|
2603
2607
|
switch (e.params.type) {
|
|
2604
2608
|
case "response.text.delta": {
|
|
2605
2609
|
const n = gi(e);
|
|
2606
|
-
n && (this.transcript.push(n), this.emit("transcript.item", n)
|
|
2610
|
+
n && (this.transcript.push(n), this.emit("transcript.item", n), Ee.emit("conversation.agent.state", "listening"));
|
|
2607
2611
|
return;
|
|
2608
2612
|
}
|
|
2609
2613
|
case "conversation.item.created": {
|
|
@@ -2647,7 +2651,7 @@ class _i {
|
|
|
2647
2651
|
this.animationFrameId = requestAnimationFrame(n);
|
|
2648
2652
|
}
|
|
2649
2653
|
}
|
|
2650
|
-
class Ot extends
|
|
2654
|
+
class Ot extends dt {
|
|
2651
2655
|
telnyxRTC;
|
|
2652
2656
|
transcription;
|
|
2653
2657
|
agentId;
|
|
@@ -2674,6 +2678,13 @@ class Ot extends lt {
|
|
|
2674
2678
|
async disconnect() {
|
|
2675
2679
|
this.audioStreamMonitor.stopAudioStreamMonitor(), this.telnyxRTC.disconnect(), this.telnyxRTC.off(O.Ready, this.onClientReady), this.telnyxRTC.off(O.Error, this.onClientOrSocketError), this.telnyxRTC.off(O.SocketError, this.onClientOrSocketError), this.telnyxRTC.off(O.Notification, this.onNotification), this.emit("agent.disconnected"), this.transcription.removeAllListeners(), Ee.removeAllListeners(), this.removeAllListeners();
|
|
2676
2680
|
}
|
|
2681
|
+
sendConversationMessage(e) {
|
|
2682
|
+
if (!this.activeCall) {
|
|
2683
|
+
console.error("No active call to send message.");
|
|
2684
|
+
return;
|
|
2685
|
+
}
|
|
2686
|
+
this.activeCall.sendConversationMessage(e);
|
|
2687
|
+
}
|
|
2677
2688
|
get transcript() {
|
|
2678
2689
|
return this.transcription.transcript;
|
|
2679
2690
|
}
|
|
@@ -2731,8 +2742,8 @@ function wi() {
|
|
|
2731
2742
|
var a = null;
|
|
2732
2743
|
if (c !== void 0 && (a = "" + c), s.key !== void 0 && (a = "" + s.key), "key" in s) {
|
|
2733
2744
|
c = {};
|
|
2734
|
-
for (var
|
|
2735
|
-
|
|
2745
|
+
for (var d in s)
|
|
2746
|
+
d !== "key" && (c[d] = s[d]);
|
|
2736
2747
|
} else c = s;
|
|
2737
2748
|
return s = c.ref, {
|
|
2738
2749
|
$$typeof: t,
|
|
@@ -2832,7 +2843,7 @@ function Si() {
|
|
|
2832
2843
|
}
|
|
2833
2844
|
}
|
|
2834
2845
|
function s() {
|
|
2835
|
-
var v =
|
|
2846
|
+
var v = l.A;
|
|
2836
2847
|
return v === null ? null : v.getOwner();
|
|
2837
2848
|
}
|
|
2838
2849
|
function c() {
|
|
@@ -2845,7 +2856,7 @@ function Si() {
|
|
|
2845
2856
|
}
|
|
2846
2857
|
return v.key !== void 0;
|
|
2847
2858
|
}
|
|
2848
|
-
function
|
|
2859
|
+
function d(v, N) {
|
|
2849
2860
|
function P() {
|
|
2850
2861
|
_ || (_ = !0, console.error(
|
|
2851
2862
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
@@ -2910,10 +2921,10 @@ function Si() {
|
|
|
2910
2921
|
else b(z);
|
|
2911
2922
|
if (u.call(N, "key")) {
|
|
2912
2923
|
z = t(v);
|
|
2913
|
-
var
|
|
2924
|
+
var le = Object.keys(N).filter(function(gn) {
|
|
2914
2925
|
return gn !== "key";
|
|
2915
2926
|
});
|
|
2916
|
-
$ = 0 <
|
|
2927
|
+
$ = 0 < le.length ? "{key: someKey, " + le.join(": ..., ") + ": ...}" : "{key: someKey}", J[z + $] || (le = 0 < le.length ? "{" + le.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
2917
2928
|
`A props object containing a "key" prop is being spread into JSX:
|
|
2918
2929
|
let props = %s;
|
|
2919
2930
|
<%s {...props} />
|
|
@@ -2922,7 +2933,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
2922
2933
|
<%s key={someKey} {...props} />`,
|
|
2923
2934
|
$,
|
|
2924
2935
|
z,
|
|
2925
|
-
|
|
2936
|
+
le,
|
|
2926
2937
|
z
|
|
2927
2938
|
), J[z + $] = !0);
|
|
2928
2939
|
}
|
|
@@ -2931,7 +2942,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
2931
2942
|
for (var qe in N)
|
|
2932
2943
|
qe !== "key" && (P[qe] = N[qe]);
|
|
2933
2944
|
} else P = N;
|
|
2934
|
-
return z &&
|
|
2945
|
+
return z && d(
|
|
2935
2946
|
P,
|
|
2936
2947
|
typeof v == "function" ? v.displayName || v.name || "Unknown" : v
|
|
2937
2948
|
), p(
|
|
@@ -2948,7 +2959,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
2948
2959
|
function b(v) {
|
|
2949
2960
|
typeof v == "object" && v !== null && v.$$typeof === I && v._store && (v._store.validated = 1);
|
|
2950
2961
|
}
|
|
2951
|
-
var C = rt, I = Symbol.for("react.transitional.element"), w = Symbol.for("react.portal"), R = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), A = Symbol.for("react.profiler"), M = Symbol.for("react.consumer"), x = Symbol.for("react.context"), V = Symbol.for("react.forward_ref"), G = Symbol.for("react.suspense"), ee = Symbol.for("react.suspense_list"), S = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), o = Symbol.for("react.activity"), r = Symbol.for("react.client.reference"),
|
|
2962
|
+
var C = rt, I = Symbol.for("react.transitional.element"), w = Symbol.for("react.portal"), R = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), A = Symbol.for("react.profiler"), M = Symbol.for("react.consumer"), x = Symbol.for("react.context"), V = Symbol.for("react.forward_ref"), G = Symbol.for("react.suspense"), ee = Symbol.for("react.suspense_list"), S = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), o = Symbol.for("react.activity"), r = Symbol.for("react.client.reference"), l = C.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, u = Object.prototype.hasOwnProperty, g = Array.isArray, y = console.createTask ? console.createTask : function() {
|
|
2952
2963
|
return null;
|
|
2953
2964
|
};
|
|
2954
2965
|
C = {
|
|
@@ -2961,7 +2972,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
2961
2972
|
c
|
|
2962
2973
|
)(), Y = y(i(c)), J = {};
|
|
2963
2974
|
me.Fragment = R, me.jsx = function(v, N, P, $, W) {
|
|
2964
|
-
var B = 1e4 >
|
|
2975
|
+
var B = 1e4 > l.recentlyCreatedOwnerStacks++;
|
|
2965
2976
|
return f(
|
|
2966
2977
|
v,
|
|
2967
2978
|
N,
|
|
@@ -2973,7 +2984,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
2973
2984
|
B ? y(i(v)) : Y
|
|
2974
2985
|
);
|
|
2975
2986
|
}, me.jsxs = function(v, N, P, $, W) {
|
|
2976
|
-
var B = 1e4 >
|
|
2987
|
+
var B = 1e4 > l.recentlyCreatedOwnerStacks++;
|
|
2977
2988
|
return f(
|
|
2978
2989
|
v,
|
|
2979
2990
|
N,
|
|
@@ -3055,7 +3066,7 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3055
3066
|
a?.delete(s), a.size || e.delete(c);
|
|
3056
3067
|
};
|
|
3057
3068
|
}, n;
|
|
3058
|
-
}, ki = (t) => (t.c || (t.c = Qe()), t.m || (t.m = Qe()), t.u || (t.u = Qe()), t.f || (t.f = Ei()), t), Ti = Symbol(), Ri = (t = /* @__PURE__ */ new WeakMap(), e = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), a = {},
|
|
3069
|
+
}, ki = (t) => (t.c || (t.c = Qe()), t.m || (t.m = Qe()), t.u || (t.u = Qe()), t.f || (t.f = Ei()), t), Ti = Symbol(), Ri = (t = /* @__PURE__ */ new WeakMap(), e = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), a = {}, d = (C, ...I) => C.read(...I), h = (C, ...I) => C.write(...I), p = (C, I) => {
|
|
3059
3070
|
var w;
|
|
3060
3071
|
return (w = C.unstable_onInit) == null ? void 0 : w.call(C, I);
|
|
3061
3072
|
}, f = (C, I) => {
|
|
@@ -3078,9 +3089,9 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3078
3089
|
do {
|
|
3079
3090
|
a.f && E(a.f);
|
|
3080
3091
|
const o = /* @__PURE__ */ new Set(), r = o.add.bind(o);
|
|
3081
|
-
i.forEach((
|
|
3092
|
+
i.forEach((l) => {
|
|
3082
3093
|
var u;
|
|
3083
|
-
return (u = e.get(
|
|
3094
|
+
return (u = e.get(l)) == null ? void 0 : u.l.forEach(r);
|
|
3084
3095
|
}), i.clear(), c.forEach(r), c.clear(), s.forEach(r), s.clear(), o.forEach(E), i.size && w();
|
|
3085
3096
|
} while (i.size || c.size || s.size);
|
|
3086
3097
|
if (S.length)
|
|
@@ -3088,25 +3099,25 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3088
3099
|
}), w = b[2] || (() => {
|
|
3089
3100
|
const S = [], E = /* @__PURE__ */ new WeakSet(), o = /* @__PURE__ */ new WeakSet(), r = Array.from(i);
|
|
3090
3101
|
for (; r.length; ) {
|
|
3091
|
-
const
|
|
3092
|
-
if (o.has(
|
|
3102
|
+
const l = r[r.length - 1], u = C(l);
|
|
3103
|
+
if (o.has(l)) {
|
|
3093
3104
|
r.pop();
|
|
3094
3105
|
continue;
|
|
3095
3106
|
}
|
|
3096
|
-
if (E.has(
|
|
3097
|
-
if (n.get(
|
|
3098
|
-
S.push([
|
|
3099
|
-
else if ((we ? "production" : void 0) !== "production" && n.has(
|
|
3107
|
+
if (E.has(l)) {
|
|
3108
|
+
if (n.get(l) === u.n)
|
|
3109
|
+
S.push([l, u]);
|
|
3110
|
+
else if ((we ? "production" : void 0) !== "production" && n.has(l))
|
|
3100
3111
|
throw new Error("[Bug] invalidated atom exists");
|
|
3101
|
-
o.add(
|
|
3112
|
+
o.add(l), r.pop();
|
|
3102
3113
|
continue;
|
|
3103
3114
|
}
|
|
3104
|
-
E.add(
|
|
3105
|
-
for (const g of $t(
|
|
3115
|
+
E.add(l);
|
|
3116
|
+
for (const g of $t(l, u, e))
|
|
3106
3117
|
E.has(g) || r.push(g);
|
|
3107
3118
|
}
|
|
3108
|
-
for (let
|
|
3109
|
-
const [u, g] = S[
|
|
3119
|
+
for (let l = S.length - 1; l >= 0; --l) {
|
|
3120
|
+
const [u, g] = S[l];
|
|
3110
3121
|
let y = !1;
|
|
3111
3122
|
for (const _ of g.d.keys())
|
|
3112
3123
|
if (_ !== u && i.has(_)) {
|
|
@@ -3128,7 +3139,7 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3128
3139
|
return o;
|
|
3129
3140
|
o.d.clear();
|
|
3130
3141
|
let r = !0;
|
|
3131
|
-
const
|
|
3142
|
+
const l = () => {
|
|
3132
3143
|
e.has(S) && (M(S), w(), I());
|
|
3133
3144
|
}, u = (T) => {
|
|
3134
3145
|
var Y;
|
|
@@ -3145,7 +3156,7 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3145
3156
|
try {
|
|
3146
3157
|
return Le(J);
|
|
3147
3158
|
} finally {
|
|
3148
|
-
o.d.set(T, J.n), Ut(o.v) && an(S, o.v, J), (Y = e.get(T)) == null || Y.t.add(S), r ||
|
|
3159
|
+
o.d.set(T, J.n), Ut(o.v) && an(S, o.v, J), (Y = e.get(T)) == null || Y.t.add(S), r || l();
|
|
3149
3160
|
}
|
|
3150
3161
|
};
|
|
3151
3162
|
let g, y;
|
|
@@ -3165,10 +3176,10 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3165
3176
|
}
|
|
3166
3177
|
}, k = o.n;
|
|
3167
3178
|
try {
|
|
3168
|
-
const T =
|
|
3179
|
+
const T = d(S, u, _);
|
|
3169
3180
|
return Ke(S, T, C), Ve(T) && (rn(T, () => g?.abort()), T.then(
|
|
3170
|
-
|
|
3171
|
-
|
|
3181
|
+
l,
|
|
3182
|
+
l
|
|
3172
3183
|
)), o;
|
|
3173
3184
|
} catch (T) {
|
|
3174
3185
|
return delete o.v, o.e = T, ++o.n, o;
|
|
@@ -3179,14 +3190,14 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3179
3190
|
const E = [S];
|
|
3180
3191
|
for (; E.length; ) {
|
|
3181
3192
|
const o = E.pop(), r = C(o);
|
|
3182
|
-
for (const
|
|
3183
|
-
const u = C(
|
|
3184
|
-
n.set(
|
|
3193
|
+
for (const l of $t(o, r, e)) {
|
|
3194
|
+
const u = C(l);
|
|
3195
|
+
n.set(l, u.n), E.push(l);
|
|
3185
3196
|
}
|
|
3186
3197
|
}
|
|
3187
3198
|
}), A = b[5] || ((S, ...E) => {
|
|
3188
3199
|
let o = !0;
|
|
3189
|
-
const r = (u) => Le(R(u)),
|
|
3200
|
+
const r = (u) => Le(R(u)), l = (u, ...g) => {
|
|
3190
3201
|
var y;
|
|
3191
3202
|
const _ = C(u);
|
|
3192
3203
|
try {
|
|
@@ -3203,7 +3214,7 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3203
3214
|
}
|
|
3204
3215
|
};
|
|
3205
3216
|
try {
|
|
3206
|
-
return h(S, r,
|
|
3217
|
+
return h(S, r, l, ...E);
|
|
3207
3218
|
} finally {
|
|
3208
3219
|
o = !1;
|
|
3209
3220
|
}
|
|
@@ -3211,15 +3222,15 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3211
3222
|
var E;
|
|
3212
3223
|
const o = C(S), r = e.get(S);
|
|
3213
3224
|
if (r && !Ut(o.v)) {
|
|
3214
|
-
for (const [
|
|
3215
|
-
if (!r.d.has(
|
|
3216
|
-
const g = C(
|
|
3217
|
-
x(
|
|
3225
|
+
for (const [l, u] of o.d)
|
|
3226
|
+
if (!r.d.has(l)) {
|
|
3227
|
+
const g = C(l);
|
|
3228
|
+
x(l).t.add(S), r.d.add(l), u !== g.n && (i.add(l), (E = a.c) == null || E.call(a, l), m(l));
|
|
3218
3229
|
}
|
|
3219
|
-
for (const
|
|
3220
|
-
if (!o.d.has(
|
|
3221
|
-
r.d.delete(
|
|
3222
|
-
const u = V(
|
|
3230
|
+
for (const l of r.d || [])
|
|
3231
|
+
if (!o.d.has(l)) {
|
|
3232
|
+
r.d.delete(l);
|
|
3233
|
+
const u = V(l);
|
|
3223
3234
|
u?.t.delete(S);
|
|
3224
3235
|
}
|
|
3225
3236
|
}
|
|
@@ -3229,14 +3240,14 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3229
3240
|
let r = e.get(S);
|
|
3230
3241
|
if (!r) {
|
|
3231
3242
|
R(S);
|
|
3232
|
-
for (const
|
|
3233
|
-
x(
|
|
3243
|
+
for (const l of o.d.keys())
|
|
3244
|
+
x(l).t.add(S);
|
|
3234
3245
|
if (r = {
|
|
3235
3246
|
l: /* @__PURE__ */ new Set(),
|
|
3236
3247
|
d: new Set(o.d.keys()),
|
|
3237
3248
|
t: /* @__PURE__ */ new Set()
|
|
3238
3249
|
}, e.set(S, r), (E = a.m) == null || E.call(a, S), He(S)) {
|
|
3239
|
-
const
|
|
3250
|
+
const l = () => {
|
|
3240
3251
|
let u = !0;
|
|
3241
3252
|
const g = (...y) => {
|
|
3242
3253
|
try {
|
|
@@ -3259,7 +3270,7 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3259
3270
|
u = !1;
|
|
3260
3271
|
}
|
|
3261
3272
|
};
|
|
3262
|
-
s.add(
|
|
3273
|
+
s.add(l);
|
|
3263
3274
|
}
|
|
3264
3275
|
}
|
|
3265
3276
|
return r;
|
|
@@ -3267,13 +3278,13 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3267
3278
|
var E;
|
|
3268
3279
|
const o = C(S);
|
|
3269
3280
|
let r = e.get(S);
|
|
3270
|
-
if (r && !r.l.size && !Array.from(r.t).some((
|
|
3281
|
+
if (r && !r.l.size && !Array.from(r.t).some((l) => {
|
|
3271
3282
|
var u;
|
|
3272
|
-
return (u = e.get(
|
|
3283
|
+
return (u = e.get(l)) == null ? void 0 : u.d.has(S);
|
|
3273
3284
|
})) {
|
|
3274
3285
|
r.u && c.add(r.u), r = void 0, e.delete(S), (E = a.u) == null || E.call(a, S);
|
|
3275
|
-
for (const
|
|
3276
|
-
const u = V(
|
|
3286
|
+
for (const l of o.d.keys()) {
|
|
3287
|
+
const u = V(l);
|
|
3277
3288
|
u?.t.delete(S);
|
|
3278
3289
|
}
|
|
3279
3290
|
return;
|
|
@@ -3289,7 +3300,7 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
|
|
|
3289
3300
|
c,
|
|
3290
3301
|
a,
|
|
3291
3302
|
// atom interceptors
|
|
3292
|
-
|
|
3303
|
+
d,
|
|
3293
3304
|
h,
|
|
3294
3305
|
p,
|
|
3295
3306
|
f,
|
|
@@ -3350,27 +3361,27 @@ const Mi = () => {
|
|
|
3350
3361
|
void 0,
|
|
3351
3362
|
e,
|
|
3352
3363
|
void 0,
|
|
3353
|
-
(
|
|
3364
|
+
(d, h, p, ...f) => t ? p(d, ...f) : d.write(h, p, ...f)
|
|
3354
3365
|
), c = /* @__PURE__ */ new Set();
|
|
3355
|
-
return e.m.add(void 0, (
|
|
3356
|
-
c.add(
|
|
3357
|
-
const h = n.get(
|
|
3358
|
-
h.m = i.get(
|
|
3359
|
-
}), e.u.add(void 0, (
|
|
3360
|
-
c.delete(
|
|
3361
|
-
const h = n.get(
|
|
3366
|
+
return e.m.add(void 0, (d) => {
|
|
3367
|
+
c.add(d);
|
|
3368
|
+
const h = n.get(d);
|
|
3369
|
+
h.m = i.get(d);
|
|
3370
|
+
}), e.u.add(void 0, (d) => {
|
|
3371
|
+
c.delete(d);
|
|
3372
|
+
const h = n.get(d);
|
|
3362
3373
|
delete h.m;
|
|
3363
3374
|
}), Object.assign(s, {
|
|
3364
3375
|
// store dev methods (these are tentative and subject to change without notice)
|
|
3365
3376
|
dev4_get_internal_weak_map: () => (console.log("Deprecated: Use devstore from the devtools library"), n),
|
|
3366
3377
|
dev4_get_mounted_atoms: () => c,
|
|
3367
|
-
dev4_restore_atoms: (
|
|
3378
|
+
dev4_restore_atoms: (d) => {
|
|
3368
3379
|
const h = {
|
|
3369
3380
|
read: () => null,
|
|
3370
3381
|
write: (p, f) => {
|
|
3371
3382
|
++t;
|
|
3372
3383
|
try {
|
|
3373
|
-
for (const [b, C] of
|
|
3384
|
+
for (const [b, C] of d)
|
|
3374
3385
|
"init" in b && f(b, C);
|
|
3375
3386
|
} finally {
|
|
3376
3387
|
--t;
|
|
@@ -3393,7 +3404,7 @@ function Di() {
|
|
|
3393
3404
|
const Pi = {}, ji = Bt(
|
|
3394
3405
|
void 0
|
|
3395
3406
|
);
|
|
3396
|
-
function
|
|
3407
|
+
function ln(t) {
|
|
3397
3408
|
return Gt(ji) || Di();
|
|
3398
3409
|
}
|
|
3399
3410
|
const st = (t) => typeof t?.then == "function", ot = (t) => {
|
|
@@ -3418,21 +3429,21 @@ const st = (t) => typeof t?.then == "function", ot = (t) => {
|
|
|
3418
3429
|
let c = t;
|
|
3419
3430
|
const a = (p) => (f) => {
|
|
3420
3431
|
c === p && i(f);
|
|
3421
|
-
},
|
|
3432
|
+
}, d = (p) => (f) => {
|
|
3422
3433
|
c === p && s(f);
|
|
3423
3434
|
}, h = () => {
|
|
3424
3435
|
try {
|
|
3425
3436
|
const p = e();
|
|
3426
|
-
st(p) ? (Xe.set(p, n), c = p, p.then(a(p),
|
|
3437
|
+
st(p) ? (Xe.set(p, n), c = p, p.then(a(p), d(p)), Vt(p, h)) : i(p);
|
|
3427
3438
|
} catch (p) {
|
|
3428
3439
|
s(p);
|
|
3429
3440
|
}
|
|
3430
3441
|
};
|
|
3431
|
-
t.then(a(t),
|
|
3442
|
+
t.then(a(t), d(t)), Vt(t, h);
|
|
3432
3443
|
}), Xe.set(t, n)), n;
|
|
3433
3444
|
};
|
|
3434
3445
|
function Ge(t, e) {
|
|
3435
|
-
const { delay: n, unstable_promiseStatus: i = !rt.use } = {}, s =
|
|
3446
|
+
const { delay: n, unstable_promiseStatus: i = !rt.use } = {}, s = ln(), [[c, a, d], h] = vn(
|
|
3436
3447
|
(f) => {
|
|
3437
3448
|
const b = s.get(t);
|
|
3438
3449
|
return Object.is(f[0], b) && f[1] === s && f[2] === t ? f : [b, s, t];
|
|
@@ -3441,7 +3452,7 @@ function Ge(t, e) {
|
|
|
3441
3452
|
() => [s.get(t), s, t]
|
|
3442
3453
|
);
|
|
3443
3454
|
let p = c;
|
|
3444
|
-
if ((a !== s ||
|
|
3455
|
+
if ((a !== s || d !== t) && (h(), p = s.get(t)), ce(() => {
|
|
3445
3456
|
const f = s.sub(t, () => {
|
|
3446
3457
|
if (i)
|
|
3447
3458
|
try {
|
|
@@ -3465,7 +3476,7 @@ function Ge(t, e) {
|
|
|
3465
3476
|
return p;
|
|
3466
3477
|
}
|
|
3467
3478
|
function Be(t, e) {
|
|
3468
|
-
const n =
|
|
3479
|
+
const n = ln();
|
|
3469
3480
|
return bn(
|
|
3470
3481
|
(...s) => {
|
|
3471
3482
|
if ((Pi ? "production" : void 0) !== "production" && !("write" in t))
|
|
@@ -3475,12 +3486,12 @@ function Be(t, e) {
|
|
|
3475
3486
|
[n, t]
|
|
3476
3487
|
);
|
|
3477
3488
|
}
|
|
3478
|
-
const
|
|
3489
|
+
const dn = Fe([]);
|
|
3479
3490
|
function Ji() {
|
|
3480
|
-
return Ge(
|
|
3491
|
+
return Ge(dn);
|
|
3481
3492
|
}
|
|
3482
3493
|
function $i() {
|
|
3483
|
-
return Be(
|
|
3494
|
+
return Be(dn);
|
|
3484
3495
|
}
|
|
3485
3496
|
const We = () => {
|
|
3486
3497
|
const t = Gt(fn);
|