@telnyx/ai-agent-lib 0.3.1-beta.1 → 0.3.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +607 -597
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ht, { useReducer as
|
|
1
|
+
import ht, { useReducer as On, useEffect as fe, useDebugValue as Mn, useCallback as Pn, useContext as zt, createContext as Kt, useState as Dn } from "react";
|
|
2
2
|
function Ne(n, e) {
|
|
3
3
|
var t = {};
|
|
4
4
|
for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
|
|
@@ -33,68 +33,68 @@ function O(n, e, t, i) {
|
|
|
33
33
|
c((i = i.apply(n, [])).next());
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
|
-
var mt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto),
|
|
37
|
-
function
|
|
36
|
+
var mt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), Nn = new Uint8Array(16);
|
|
37
|
+
function jn() {
|
|
38
38
|
if (!mt) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
39
|
-
return mt(
|
|
39
|
+
return mt(Nn);
|
|
40
40
|
}
|
|
41
|
-
for (var
|
|
41
|
+
for (var Xt = [], xe = 0; xe < 256; ++xe) Xt[xe] = (xe + 256).toString(16).substr(1);
|
|
42
42
|
function me(n, e, t) {
|
|
43
43
|
var i = e && t || 0;
|
|
44
44
|
typeof n == "string" && (e = n === "binary" ? new Array(16) : null, n = null);
|
|
45
|
-
var s = (n = n || {}).random || (n.rng ||
|
|
45
|
+
var s = (n = n || {}).random || (n.rng || jn)();
|
|
46
46
|
if (s[6] = 15 & s[6] | 64, s[8] = 63 & s[8] | 128, e) for (var o = 0; o < 16; ++o) e[i + o] = s[o];
|
|
47
47
|
return e || (function(r, l) {
|
|
48
|
-
var c = 0, u =
|
|
48
|
+
var c = 0, u = Xt;
|
|
49
49
|
return [u[r[c++]], u[r[c++]], u[r[c++]], u[r[c++]], "-", u[r[c++]], u[r[c++]], "-", u[r[c++]], u[r[c++]], "-", u[r[c++]], u[r[c++]], "-", u[r[c++]], u[r[c++]], u[r[c++]], u[r[c++]], u[r[c++]], u[r[c++]]].join("");
|
|
50
50
|
})(s);
|
|
51
51
|
}
|
|
52
|
-
const yt = "wss://rtc.telnyx.com",
|
|
52
|
+
const yt = "wss://rtc.telnyx.com", Un = 1006, Qt = { urls: "stun:stun.l.google.com:19302" }, Fn = [{ urls: "stun:stun.telnyx.com:3478" }, Qt, { urls: "turn:turn.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turn.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }], $n = [{ urls: "stun:stundev.telnyx.com:3478" }, Qt, { urls: "turn:turndev.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turndev.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }];
|
|
53
53
|
var x;
|
|
54
54
|
(function(n) {
|
|
55
55
|
n.SocketOpen = "telnyx.socket.open", n.SocketClose = "telnyx.socket.close", n.SocketError = "telnyx.socket.error", n.SocketMessage = "telnyx.socket.message", n.SpeedTest = "telnyx.internal.speedtest", n.Ready = "telnyx.ready", n.Error = "telnyx.error", n.Notification = "telnyx.notification", n.StatsFrame = "telnyx.stats.frame", n.StatsReport = "telnyx.stats.report", n.Messages = "telnyx.messages", n.Calls = "telnyx.calls", n.MediaError = "telnyx.rtc.mediaError", n.PeerConnectionFailureError = "telnyx.rtc.peerConnectionFailureError", n.PeerConnectionSignalingStateClosed = "telnyx.rtc.peerConnectionSignalingStateClosed";
|
|
56
56
|
})(x || (x = {}));
|
|
57
|
-
var
|
|
58
|
-
function
|
|
57
|
+
var Bn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
58
|
+
function Zt(n, e) {
|
|
59
59
|
return n(e = { exports: {} }, e.exports), e.exports;
|
|
60
60
|
}
|
|
61
|
-
var
|
|
61
|
+
var Vn = Zt((function(n) {
|
|
62
62
|
var e, t;
|
|
63
|
-
e =
|
|
63
|
+
e = Bn, t = function() {
|
|
64
64
|
var i = function() {
|
|
65
65
|
}, s = "undefined", o = typeof window !== s && typeof window.navigator !== s && /Trident\/|MSIE /.test(window.navigator.userAgent), r = ["trace", "debug", "info", "warn", "error"];
|
|
66
|
-
function l(
|
|
67
|
-
var R =
|
|
68
|
-
if (typeof R.bind == "function") return R.bind(
|
|
66
|
+
function l(v, w) {
|
|
67
|
+
var R = v[w];
|
|
68
|
+
if (typeof R.bind == "function") return R.bind(v);
|
|
69
69
|
try {
|
|
70
|
-
return Function.prototype.bind.call(R,
|
|
70
|
+
return Function.prototype.bind.call(R, v);
|
|
71
71
|
} catch {
|
|
72
72
|
return function() {
|
|
73
|
-
return Function.prototype.apply.apply(R, [
|
|
73
|
+
return Function.prototype.apply.apply(R, [v, arguments]);
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
function c() {
|
|
78
78
|
console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
|
|
79
79
|
}
|
|
80
|
-
function u(
|
|
80
|
+
function u(v, w) {
|
|
81
81
|
for (var R = 0; R < r.length; R++) {
|
|
82
82
|
var T = r[R];
|
|
83
|
-
this[T] = R <
|
|
83
|
+
this[T] = R < v ? i : this.methodFactory(T, v, w);
|
|
84
84
|
}
|
|
85
85
|
this.log = this.debug;
|
|
86
86
|
}
|
|
87
|
-
function p(
|
|
87
|
+
function p(v, w, R) {
|
|
88
88
|
return function() {
|
|
89
|
-
typeof console !== s && (u.call(this, w, R), this[
|
|
89
|
+
typeof console !== s && (u.call(this, w, R), this[v].apply(this, arguments));
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
function f(
|
|
92
|
+
function f(v, w, R) {
|
|
93
93
|
return (function(T) {
|
|
94
94
|
return T === "debug" && (T = "log"), typeof console !== s && (T === "trace" && o ? c : console[T] !== void 0 ? l(console, T) : console.log !== void 0 ? l(console, "log") : i);
|
|
95
|
-
})(
|
|
95
|
+
})(v) || p.apply(this, arguments);
|
|
96
96
|
}
|
|
97
|
-
function C(
|
|
97
|
+
function C(v, w, R) {
|
|
98
98
|
var T, A = this;
|
|
99
99
|
w = w ?? "WARN";
|
|
100
100
|
var D = "loglevel";
|
|
@@ -113,7 +113,7 @@ var Bn = Qt((function(n) {
|
|
|
113
113
|
return A.levels[M] === void 0 && (M = void 0), M;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
typeof
|
|
116
|
+
typeof v == "string" ? D += ":" + v : typeof v == "symbol" && (D = void 0), A.name = v, A.levels = { TRACE: 0, DEBUG: 1, INFO: 2, WARN: 3, ERROR: 4, SILENT: 5 }, A.methodFactory = R || f, A.getLevel = function() {
|
|
117
117
|
return T;
|
|
118
118
|
}, A.setLevel = function(M, a) {
|
|
119
119
|
if (typeof M == "string" && A.levels[M.toUpperCase()] !== void 0 && (M = A.levels[M.toUpperCase()]), !(typeof M == "number" && M >= 0 && M <= A.levels.SILENT)) throw "log.setLevel() called with invalid level: " + M;
|
|
@@ -129,7 +129,7 @@ var Bn = Qt((function(n) {
|
|
|
129
129
|
} catch {
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
})(M), u.call(A, M,
|
|
132
|
+
})(M), u.call(A, M, v), typeof console === s && M < A.levels.SILENT) return "No console available for logging";
|
|
133
133
|
}, A.setDefaultLevel = function(M) {
|
|
134
134
|
w = M, W() || A.setLevel(M, !1);
|
|
135
135
|
}, A.resetLevel = function() {
|
|
@@ -154,10 +154,10 @@ var Bn = Qt((function(n) {
|
|
|
154
154
|
B == null && (B = w), A.setLevel(B, !1);
|
|
155
155
|
}
|
|
156
156
|
var b = new C(), y = {};
|
|
157
|
-
b.getLogger = function(
|
|
158
|
-
if (typeof
|
|
159
|
-
var w = y[
|
|
160
|
-
return w || (w = y[
|
|
157
|
+
b.getLogger = function(v) {
|
|
158
|
+
if (typeof v != "symbol" && typeof v != "string" || v === "") throw new TypeError("You must supply a name when creating a logger.");
|
|
159
|
+
var w = y[v];
|
|
160
|
+
return w || (w = y[v] = new C(v, b.getLevel(), b.methodFactory)), w;
|
|
161
161
|
};
|
|
162
162
|
var I = typeof window !== s ? window.log : void 0;
|
|
163
163
|
return b.noConflict = function() {
|
|
@@ -168,7 +168,7 @@ var Bn = Qt((function(n) {
|
|
|
168
168
|
}, n.exports ? n.exports = t() : e.log = t();
|
|
169
169
|
}));
|
|
170
170
|
const bt = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
171
|
-
class
|
|
171
|
+
class Gn {
|
|
172
172
|
constructor(e = {}) {
|
|
173
173
|
var t, i, s;
|
|
174
174
|
this.buffer = [], this.isCapturing = !1, this.options = { enabled: (t = e.enabled) !== null && t !== void 0 && t, level: (i = e.level) !== null && i !== void 0 ? i : "debug", maxEntries: (s = e.maxEntries) !== null && s !== void 0 ? s : 1e3 };
|
|
@@ -204,15 +204,15 @@ class Vn {
|
|
|
204
204
|
return this.options.enabled;
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
let
|
|
208
|
-
function
|
|
209
|
-
return
|
|
207
|
+
let en = null;
|
|
208
|
+
function tn() {
|
|
209
|
+
return en;
|
|
210
210
|
}
|
|
211
211
|
function St(n) {
|
|
212
|
-
|
|
212
|
+
en = n;
|
|
213
213
|
}
|
|
214
|
-
const
|
|
215
|
-
let
|
|
214
|
+
const g = Vn.getLogger("telnyx"), je = { trace: 0, debug: 1, info: 2, warn: 3, error: 4 };
|
|
215
|
+
let nn = je.info;
|
|
216
216
|
function _t(n) {
|
|
217
217
|
if (n == null || typeof n != "object") return n;
|
|
218
218
|
try {
|
|
@@ -234,47 +234,47 @@ function _t(n) {
|
|
|
234
234
|
}
|
|
235
235
|
return Object.keys(e).length > 0 ? e : { value: String(n) };
|
|
236
236
|
}
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
const i =
|
|
237
|
+
const Hn = g.methodFactory;
|
|
238
|
+
g.methodFactory = (n, e, t) => {
|
|
239
|
+
const i = Hn(n, e, t);
|
|
240
240
|
return function(...s) {
|
|
241
|
-
if (je[n] >=
|
|
241
|
+
if (je[n] >= nn) {
|
|
242
242
|
const r = [(/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), "-"];
|
|
243
243
|
for (const l of s) r.push(l);
|
|
244
244
|
i(...r);
|
|
245
245
|
}
|
|
246
|
-
const o =
|
|
246
|
+
const o = tn();
|
|
247
247
|
if (o?.isActive()) {
|
|
248
248
|
const [r, ...l] = s, c = typeof r == "string" ? r : JSON.stringify(r);
|
|
249
249
|
let u;
|
|
250
250
|
l.length > 0 && (u = l.length === 1 && typeof l[0] == "object" && l[0] !== null ? _t(l[0]) : { args: l.map(_t) }), o.addEntry(n, c, u);
|
|
251
251
|
}
|
|
252
252
|
};
|
|
253
|
-
},
|
|
253
|
+
}, g.setLevel("debug", !1);
|
|
254
254
|
const Le = (n) => {
|
|
255
255
|
const [e, t, i, s, o, r] = n;
|
|
256
256
|
let l = {};
|
|
257
257
|
try {
|
|
258
258
|
l = JSON.parse(o.replace(/ID"/g, 'Id"'));
|
|
259
259
|
} catch {
|
|
260
|
-
|
|
260
|
+
g.warn("Verto LA invalid media JSON string:", o);
|
|
261
261
|
}
|
|
262
262
|
return { participantId: Number(e), participantNumber: t, participantName: i, codec: s, media: l, participantData: r };
|
|
263
|
-
},
|
|
263
|
+
}, sn = (n) => {
|
|
264
264
|
if (typeof n != "string") return n;
|
|
265
265
|
try {
|
|
266
266
|
return JSON.parse(n);
|
|
267
267
|
} catch {
|
|
268
268
|
return n;
|
|
269
269
|
}
|
|
270
|
-
}, ye = (n) => n instanceof Function || typeof n == "function", Ue = (n) => typeof document == "object" && "getElementById" in document ? typeof n == "string" ? document.getElementById(n) || null : typeof n == "function" ? n() : n instanceof HTMLMediaElement ? n : null : null,
|
|
270
|
+
}, ye = (n) => n instanceof Function || typeof n == "function", Ue = (n) => typeof document == "object" && "getElementById" in document ? typeof n == "string" ? document.getElementById(n) || null : typeof n == "function" ? n() : n instanceof HTMLMediaElement ? n : null : null, Wn = /^(ws|wss):\/\//, on = (n, e = null) => {
|
|
271
271
|
const { result: t = {}, error: i } = n;
|
|
272
272
|
if (i) return { error: i };
|
|
273
273
|
const { result: s = null } = t;
|
|
274
274
|
if (s === null) return e !== null && (t.node_id = e), { result: t };
|
|
275
275
|
const { code: o = null, node_id: r = null, result: l = null } = s;
|
|
276
|
-
return o && o !== "200" ? { error: s } : l ?
|
|
277
|
-
},
|
|
276
|
+
return o && o !== "200" ? { error: s } : l ? on(l, r) : { result: s };
|
|
277
|
+
}, rn = (n, e) => Math.floor(Math.random() * (e - n + 1) + n), Fe = ({ login: n, passwd: e, password: t, login_token: i }) => !!(n && (e || t) || i), ke = ({ anonymous_login: n }) => !!n && !!n.target_id && !!n.target_type, pt = (n) => {
|
|
278
278
|
var e, t, i, s, o, r;
|
|
279
279
|
let l = "", c = "";
|
|
280
280
|
return !((t = (e = n?.result) === null || e === void 0 ? void 0 : e.params) === null || t === void 0) && t.state && (l = (s = (i = n?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state), !((o = n?.params) === null || o === void 0) && o.state && (c = (r = n?.params) === null || r === void 0 ? void 0 : r.state), l || c;
|
|
@@ -282,10 +282,10 @@ const Le = (n) => {
|
|
|
282
282
|
function Ct({ debounceTime: n }) {
|
|
283
283
|
let e, t;
|
|
284
284
|
return { promise: new Promise(((i, s) => {
|
|
285
|
-
e = n ?
|
|
285
|
+
e = n ? qn(i, n) : i, t = s;
|
|
286
286
|
})), resolve: e, reject: t };
|
|
287
287
|
}
|
|
288
|
-
const
|
|
288
|
+
const qn = (n, e) => {
|
|
289
289
|
let t;
|
|
290
290
|
return (...i) => {
|
|
291
291
|
clearTimeout(t), t = window.setTimeout((() => {
|
|
@@ -296,7 +296,7 @@ const Wn = (n, e) => {
|
|
|
296
296
|
function he() {
|
|
297
297
|
return sessionStorage.getItem(ft);
|
|
298
298
|
}
|
|
299
|
-
var z, re,
|
|
299
|
+
var z, re, F;
|
|
300
300
|
typeof window < "u" && window.addEventListener("beforeunload", (() => {
|
|
301
301
|
sessionStorage.removeItem(ft);
|
|
302
302
|
})), (function(n) {
|
|
@@ -305,8 +305,8 @@ typeof window < "u" && window.addEventListener("beforeunload", (() => {
|
|
|
305
305
|
n.Inbound = "inbound", n.Outbound = "outbound";
|
|
306
306
|
})(re || (re = {})), (function(n) {
|
|
307
307
|
n.Invite = "telnyx_rtc.invite", n.Attach = "telnyx_rtc.attach", n.Answer = "telnyx_rtc.answer", n.Info = "telnyx_rtc.info", n.Candidate = "telnyx_rtc.candidate", n.EndOfCandidates = "telnyx_rtc.endOfCandidates", n.Display = "telnyx_rtc.display", n.Media = "telnyx_rtc.media", n.Event = "telnyx_rtc.event", n.Bye = "telnyx_rtc.bye", n.Punt = "telnyx_rtc.punt", n.Broadcast = "telnyx_rtc.broadcast", n.Subscribe = "telnyx_rtc.subscribe", n.Unsubscribe = "telnyx_rtc.unsubscribe", n.ClientReady = "telnyx_rtc.clientReady", n.Modify = "telnyx_rtc.modify", n.Ringing = "telnyx_rtc.ringing", n.GatewayState = "telnyx_rtc.gatewayState", n.Ping = "telnyx_rtc.ping", n.Pong = "telnyx_rtc.pong";
|
|
308
|
-
})(
|
|
309
|
-
const se = { generic: "event", [
|
|
308
|
+
})(F || (F = {}));
|
|
309
|
+
const se = { generic: "event", [F.Display]: "participantData", [F.Attach]: "participantData", conferenceUpdate: "conferenceUpdate", callUpdate: "callUpdate", vertoClientReady: "vertoClientReady", userMediaError: "userMediaError", peerConnectionFailureError: "peerConnectionFailureError", signalingStateClosed: "signalingStateClosed" }, Yn = { invalidCredentialsOptions: "InvalidCredentialsOptions" }, Jn = { destinationNumber: "", remoteCallerName: "Outbound Call", remoteCallerNumber: "", callerName: "", callerNumber: "", audio: !0, useStereo: !1, debug: !1, debugOutput: "socket", attach: !1, screenShare: !1, userVariables: {}, mediaSettings: { useSdpASBandwidthKbps: !1, sdpASBandwidthKbps: 0 }, mutedMicOnStart: !1, prefetchIceCandidates: !0 };
|
|
310
310
|
var N, it, ie, ae, ee;
|
|
311
311
|
(function(n) {
|
|
312
312
|
n[n.New = 0] = "New", n[n.Requesting = 1] = "Requesting", n[n.Trying = 2] = "Trying", n[n.Recovering = 3] = "Recovering", n[n.Ringing = 4] = "Ringing", n[n.Answering = 5] = "Answering", n[n.Early = 6] = "Early", n[n.Active = 7] = "Active", n[n.Held = 8] = "Held", n[n.Hangup = 9] = "Hangup", n[n.Destroy = 10] = "Destroy", n[n.Purge = 11] = "Purge";
|
|
@@ -319,16 +319,16 @@ var N, it, ie, ae, ee;
|
|
|
319
319
|
})(ae || (ae = {})), (function(n) {
|
|
320
320
|
n.REGED = "REGED", n.UNREGED = "UNREGED", n.NOREG = "NOREG", n.FAILED = "FAILED", n.FAIL_WAIT = "FAIL_WAIT", n.REGISTER = "REGISTER", n.TRYING = "TRYING", n.EXPIRED = "EXPIRED", n.UNREGISTER = "UNREGISTER";
|
|
321
321
|
})(ee || (ee = {}));
|
|
322
|
-
const be = "GLOBAL", ne = {}, Re = (n, e) => `${n}|${e}`,
|
|
322
|
+
const be = "GLOBAL", ne = {}, Re = (n, e) => `${n}|${e}`, an = (n, e = be) => Re(n, e) in ne, de = (n, e, t = be) => {
|
|
323
323
|
const i = Re(n, t);
|
|
324
324
|
i in ne || (ne[i] = []), ne[i].push(e);
|
|
325
|
-
},
|
|
325
|
+
}, cn = (n, e, t = be) => {
|
|
326
326
|
const i = function(s) {
|
|
327
327
|
ue(n, i, t), e(s);
|
|
328
328
|
};
|
|
329
329
|
return i.prototype.targetRef = e, de(n, i, t);
|
|
330
330
|
}, ue = (n, e, t = be) => {
|
|
331
|
-
if (!
|
|
331
|
+
if (!an(n, t)) return !1;
|
|
332
332
|
const i = Re(n, t);
|
|
333
333
|
if (ye(e))
|
|
334
334
|
for (let s = ne[i].length - 1; s >= 0; s--) {
|
|
@@ -339,7 +339,7 @@ const be = "GLOBAL", ne = {}, Re = (n, e) => `${n}|${e}`, rn = (n, e = be) => Re
|
|
|
339
339
|
return ne[i].length === 0 && delete ne[i], !0;
|
|
340
340
|
}, j = (n, e, t = be, i = !0) => {
|
|
341
341
|
const s = i && t !== be;
|
|
342
|
-
if (!
|
|
342
|
+
if (!an(n, t)) return s && j(n, e), !1;
|
|
343
343
|
const o = Re(n, t), r = ne[o].length;
|
|
344
344
|
if (!r) return s && j(n, e), !1;
|
|
345
345
|
for (let l = r - 1; l >= 0; l--) ne[o][l](e);
|
|
@@ -348,22 +348,22 @@ const be = "GLOBAL", ne = {}, Re = (n, e) => `${n}|${e}`, rn = (n, e = be) => Re
|
|
|
348
348
|
const e = Re(n, "");
|
|
349
349
|
Object.keys(ne).filter(((t) => t.indexOf(e) === 0)).forEach(((t) => delete ne[t]));
|
|
350
350
|
};
|
|
351
|
-
let
|
|
352
|
-
const
|
|
351
|
+
let zn = typeof WebSocket < "u" ? WebSocket : null;
|
|
352
|
+
const Kn = 0, Xn = 1, Qn = 2, wt = 3;
|
|
353
353
|
class It {
|
|
354
354
|
constructor(e) {
|
|
355
355
|
this.session = e, this.previousGatewayState = "", this._wsClient = null, this._host = yt, this._timers = {}, this._useCanaryRtcServer = !1, this._hasCanaryBeenUsed = !1, this._safetyTimeoutId = null, this.upDur = null, this.downDur = null;
|
|
356
356
|
const { host: t, env: i, region: s, useCanaryRtcServer: o } = e.options;
|
|
357
|
-
i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : yt), t && (this._host = ((r) => `${
|
|
357
|
+
i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : yt), t && (this._host = ((r) => `${Wn.test(r) ? "" : "wss://"}${r}`)(t)), s && (this._host = this._host.replace(/rtc(dev)?/, `${s}.rtc$1`)), o && (this._useCanaryRtcServer = !0);
|
|
358
358
|
}
|
|
359
359
|
get connected() {
|
|
360
|
-
return !!this._wsClient && this._wsClient.readyState ===
|
|
360
|
+
return !!this._wsClient && this._wsClient.readyState === Xn;
|
|
361
361
|
}
|
|
362
362
|
get connecting() {
|
|
363
|
-
return !!this._wsClient && this._wsClient.readyState ===
|
|
363
|
+
return !!this._wsClient && this._wsClient.readyState === Kn;
|
|
364
364
|
}
|
|
365
365
|
get closing() {
|
|
366
|
-
return !!this._wsClient && this._wsClient.readyState ===
|
|
366
|
+
return !!this._wsClient && this._wsClient.readyState === Qn;
|
|
367
367
|
}
|
|
368
368
|
get closed() {
|
|
369
369
|
return !!this._wsClient && this._wsClient.readyState === wt;
|
|
@@ -380,12 +380,12 @@ class It {
|
|
|
380
380
|
connect() {
|
|
381
381
|
const e = new URL(this._host);
|
|
382
382
|
let t = he();
|
|
383
|
-
this.session.options.rtcIp && this.session.options.rtcPort && (t = null, this._useCanaryRtcServer = !1, e.searchParams.set("rtc_ip", this.session.options.rtcIp), e.searchParams.set("rtc_port", this.session.options.rtcPort.toString())), t && e.searchParams.set("voice_sdk_id", t), this._useCanaryRtcServer && (e.searchParams.set("canary", "true"), t && !this._hasCanaryBeenUsed && (e.searchParams.delete("voice_sdk_id"),
|
|
383
|
+
this.session.options.rtcIp && this.session.options.rtcPort && (t = null, this._useCanaryRtcServer = !1, e.searchParams.set("rtc_ip", this.session.options.rtcIp), e.searchParams.set("rtc_port", this.session.options.rtcPort.toString())), t && e.searchParams.set("voice_sdk_id", t), this._useCanaryRtcServer && (e.searchParams.set("canary", "true"), t && !this._hasCanaryBeenUsed && (e.searchParams.delete("voice_sdk_id"), g.debug("first canary connection. Refreshing voice_sdk_id")), this._hasCanaryBeenUsed = !0);
|
|
384
384
|
try {
|
|
385
|
-
this._wsClient = new
|
|
385
|
+
this._wsClient = new zn(e.toString()), this._registerSocketEvents(this._wsClient);
|
|
386
386
|
} catch (i) {
|
|
387
387
|
const s = i instanceof Error ? i : new Error(`Failed to create WebSocket: ${String(i)}`);
|
|
388
|
-
j(x.Error, { error: s }, this.session.uuid),
|
|
388
|
+
j(x.Error, { error: s }, this.session.uuid), g.error("WebSocket connection failed:", s);
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
sendRawText(e) {
|
|
@@ -396,12 +396,12 @@ class It {
|
|
|
396
396
|
var t;
|
|
397
397
|
const { request: i } = e, s = new Promise(((o, r) => {
|
|
398
398
|
if (i.hasOwnProperty("result")) return o();
|
|
399
|
-
|
|
400
|
-
const { result: c, error: u } =
|
|
399
|
+
cn(i.id, ((l) => {
|
|
400
|
+
const { result: c, error: u } = on(l);
|
|
401
401
|
return u ? r(u) : o(c);
|
|
402
402
|
}));
|
|
403
403
|
}));
|
|
404
|
-
return
|
|
404
|
+
return g.debug(`SEND:
|
|
405
405
|
`, JSON.stringify(i, null, 2), `
|
|
406
406
|
`), (t = this._wsClient) === null || t === void 0 || t.send(JSON.stringify(i)), s;
|
|
407
407
|
}
|
|
@@ -413,10 +413,10 @@ class It {
|
|
|
413
413
|
_registerSocketEvents(e) {
|
|
414
414
|
e.onopen = (t) => j(x.SocketOpen, t, this.session.uuid), e.onclose = (t) => (this._clearSafetyTimeout(), this._safetyCleanupSocket(e, "close"), j(x.SocketClose, t, this.session.uuid)), e.onerror = (t) => (this._clearSafetyTimeout(), this._safetyCleanupSocket(e, "error"), j(x.SocketError, { error: t, sessionId: this.session.sessionid }, this.session.uuid)), e.onmessage = (t) => {
|
|
415
415
|
var i, s;
|
|
416
|
-
const o =
|
|
416
|
+
const o = sn(t.data);
|
|
417
417
|
var r;
|
|
418
418
|
if (typeof o != "string") {
|
|
419
|
-
if (o.voice_sdk_id && (r = o.voice_sdk_id, sessionStorage.setItem(ft, r)), this._unsetTimer(o.id),
|
|
419
|
+
if (o.voice_sdk_id && (r = o.voice_sdk_id, sessionStorage.setItem(ft, r)), this._unsetTimer(o.id), g.debug(`RECV:
|
|
420
420
|
`, JSON.stringify(o, null, 2), `
|
|
421
421
|
`), ee[`${(s = (i = o?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state}`] || !j(o.id, o)) {
|
|
422
422
|
const l = pt(o);
|
|
@@ -429,13 +429,13 @@ class It {
|
|
|
429
429
|
e.onopen = null, e.onclose = null, e.onerror = null, e.onmessage = null;
|
|
430
430
|
}
|
|
431
431
|
_handleCloseTimeout(e) {
|
|
432
|
-
this._safetyTimeoutId = null, e && e.readyState !== wt ? (
|
|
432
|
+
this._safetyTimeoutId = null, e && e.readyState !== wt ? (g.warn("Socket stuck in CLOSING after 5s — forcefully cleaning up"), this._deregisterSocketEvents(e), this._safetyCleanupSocket(e, "timeout"), this._wsClient && this._wsClient !== e || j(x.SocketClose, { code: Un, reason: "STUCK_WS_TIMEOUT: Socket got stuck in CLOSING state and was forcefully cleaned up by safety timeout", wasClean: !1 }, this.session.uuid)) : g.warn("Safety timeout fired but socket is already closed or cleaned up");
|
|
433
433
|
}
|
|
434
434
|
_clearSafetyTimeout() {
|
|
435
|
-
this._safetyTimeoutId && (
|
|
435
|
+
this._safetyTimeoutId && (g.debug("Clearing safety timeout"), clearTimeout(this._safetyTimeoutId), this._safetyTimeoutId = null);
|
|
436
436
|
}
|
|
437
437
|
_safetyCleanupSocket(e, t) {
|
|
438
|
-
this._wsClient === e ? (
|
|
438
|
+
this._wsClient === e ? (g.debug(`Nulling socket reference (reason: ${t})`), this._wsClient = null) : g.debug(`Skipping socket cleanup - old socket already replaced (reason: ${t})`);
|
|
439
439
|
}
|
|
440
440
|
_unsetTimer(e) {
|
|
441
441
|
clearTimeout(this._timers[e]), delete this._timers[e];
|
|
@@ -448,7 +448,7 @@ class It {
|
|
|
448
448
|
case "D":
|
|
449
449
|
this.downDur = parseInt(e.substring(4)), j(x.SpeedTest, { upDur: this.upDur, downDur: this.downDur }, this.session.uuid);
|
|
450
450
|
}
|
|
451
|
-
else
|
|
451
|
+
else g.warn("Unknown message from socket", e);
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
class Ae {
|
|
@@ -467,111 +467,111 @@ class Q extends Ae {
|
|
|
467
467
|
this.buildRequest({ method: this.toString(), params: e });
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
|
-
class
|
|
470
|
+
class ln extends Q {
|
|
471
471
|
constructor(e) {
|
|
472
|
-
super(), this.method =
|
|
472
|
+
super(), this.method = F.GatewayState, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
|
|
473
473
|
}
|
|
474
474
|
}
|
|
475
|
-
class
|
|
475
|
+
class Zn {
|
|
476
476
|
constructor(e) {
|
|
477
477
|
this.pendingRequestId = null, this.onSocketMessage = (t) => O(this, void 0, void 0, (function* () {
|
|
478
478
|
t.id === this.pendingRequestId && this.gatewayStateTask.resolve(pt(t));
|
|
479
479
|
})), this.getIsRegistered = () => O(this, void 0, void 0, (function* () {
|
|
480
|
-
const t = new
|
|
480
|
+
const t = new ln(he());
|
|
481
481
|
this.pendingRequestId = t.request.id, this.gatewayStateTask = Ct({}), this.session.execute(t);
|
|
482
482
|
const i = yield this.gatewayStateTask.promise;
|
|
483
483
|
return !!i && [ee.REGISTER, ee.REGED].includes(i);
|
|
484
484
|
})), this.session = e, this.gatewayStateTask = Ct({}), this.session.on("telnyx.socket.message", this.onSocketMessage);
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
|
-
class
|
|
487
|
+
class dn extends Q {
|
|
488
488
|
constructor(e) {
|
|
489
|
-
super(), this.method =
|
|
489
|
+
super(), this.method = F.Ping, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
|
-
var
|
|
493
|
-
class
|
|
492
|
+
var un = "2.25.25", gt = un;
|
|
493
|
+
class ei extends Q {
|
|
494
494
|
constructor(e, t, i, s, o = {}, r) {
|
|
495
495
|
super(), this.method = "login";
|
|
496
496
|
const l = { login: e, passwd: t, login_token: i, userVariables: o, reconnection: r, loginParams: {}, "User-Agent": { sdkVersion: gt, data: navigator.userAgent } };
|
|
497
497
|
s && (l.sessid = s), this.buildRequest({ method: this.method, params: l });
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
class
|
|
500
|
+
class ti extends Q {
|
|
501
501
|
constructor(e, t) {
|
|
502
502
|
super(), this.buildRequest({ id: e, result: { method: t } });
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
505
|
class Et extends Q {
|
|
506
506
|
toString() {
|
|
507
|
-
return
|
|
507
|
+
return F.Invite;
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
510
|
class Tt extends Q {
|
|
511
511
|
toString() {
|
|
512
|
-
return
|
|
512
|
+
return F.Answer;
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
515
|
class Rt extends Q {
|
|
516
516
|
toString() {
|
|
517
|
-
return
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
class ti extends Q {
|
|
521
|
-
toString() {
|
|
522
|
-
return $.Bye;
|
|
517
|
+
return F.Attach;
|
|
523
518
|
}
|
|
524
519
|
}
|
|
525
520
|
class ni extends Q {
|
|
526
521
|
toString() {
|
|
527
|
-
return
|
|
522
|
+
return F.Bye;
|
|
528
523
|
}
|
|
529
524
|
}
|
|
530
525
|
class ii extends Q {
|
|
531
526
|
toString() {
|
|
532
|
-
return
|
|
527
|
+
return F.Candidate;
|
|
533
528
|
}
|
|
534
529
|
}
|
|
535
|
-
class
|
|
530
|
+
class si extends Q {
|
|
536
531
|
toString() {
|
|
537
|
-
return
|
|
532
|
+
return F.EndOfCandidates;
|
|
538
533
|
}
|
|
539
534
|
}
|
|
540
|
-
class
|
|
535
|
+
class et extends Q {
|
|
541
536
|
toString() {
|
|
542
|
-
return
|
|
537
|
+
return F.Modify;
|
|
543
538
|
}
|
|
544
539
|
}
|
|
545
|
-
class
|
|
540
|
+
class At extends Q {
|
|
546
541
|
toString() {
|
|
547
|
-
return
|
|
542
|
+
return F.Info;
|
|
548
543
|
}
|
|
549
544
|
}
|
|
550
545
|
class oi extends Q {
|
|
551
546
|
toString() {
|
|
552
|
-
return
|
|
547
|
+
return F.Broadcast;
|
|
553
548
|
}
|
|
554
549
|
}
|
|
555
550
|
class ri extends Q {
|
|
556
551
|
toString() {
|
|
557
|
-
return
|
|
552
|
+
return F.Subscribe;
|
|
558
553
|
}
|
|
559
554
|
}
|
|
560
555
|
class ai extends Q {
|
|
556
|
+
toString() {
|
|
557
|
+
return F.Unsubscribe;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
class ci extends Q {
|
|
561
561
|
constructor(e) {
|
|
562
562
|
super(), this.method = "anonymous_login";
|
|
563
|
-
const { target_type: t, target_id: i, target_version_id: s,
|
|
564
|
-
|
|
563
|
+
const { target_type: t, target_id: i, target_version_id: s, target_params: o, userVariables: r, sessionId: l, reconnection: c } = e, u = { target_type: t, target_id: i, userVariables: r, reconnection: c, "User-Agent": { sdkVersion: gt, data: navigator.userAgent } };
|
|
564
|
+
l && (u.sessid = l), s && (u.target_version_id = s), o && (u.target_params = o), this.buildRequest({ method: this.method, params: u });
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
-
class
|
|
567
|
+
class li {
|
|
568
568
|
constructor(e) {
|
|
569
569
|
if (this.options = e, this.uuid = me(), this.sessionid = "", this.subscriptions = {}, this.signature = null, this.relayProtocol = null, this.contexts = [], this.timeoutErrorCode = -32e3, this.invalidMethodErrorCode = -32601, this.authenticationRequiredErrorCode = -32e3, this.callReportId = null, this.connection = null, this._jwtAuth = !1, this._autoReconnect = !0, this._idle = !1, this._executeQueue = [], !this.validateOptions()) throw new Error("Invalid init options");
|
|
570
570
|
var t, i;
|
|
571
|
-
t = e.debug ? "debug" : "info",
|
|
571
|
+
t = e.debug ? "debug" : "info", nn = (i = je[t]) !== null && i !== void 0 ? i : je.info, this._onSocketOpen = this._onSocketOpen.bind(this), this.onNetworkClose = this.onNetworkClose.bind(this), this._onSocketMessage = this._onSocketMessage.bind(this), this._handleLoginError = this._handleLoginError.bind(this), this._attachListeners(), this.connection = new It(this), this.registerAgent = new Zn(this);
|
|
572
572
|
}
|
|
573
573
|
get __logger() {
|
|
574
|
-
return
|
|
574
|
+
return g;
|
|
575
575
|
}
|
|
576
576
|
get connected() {
|
|
577
577
|
return this.connection && this.connection.connected;
|
|
@@ -582,11 +582,11 @@ class ci {
|
|
|
582
582
|
}));
|
|
583
583
|
}
|
|
584
584
|
get reconnectDelay() {
|
|
585
|
-
return 1e3 *
|
|
585
|
+
return 1e3 * rn(2, 6);
|
|
586
586
|
}
|
|
587
587
|
execute(e) {
|
|
588
588
|
return this._idle ? new Promise(((t) => this._executeQueue.push({ resolve: t, msg: e }))) : this.connected ? this.connection.send(e) : new Promise(((t) => {
|
|
589
|
-
this._executeQueue.push({ resolve: t, msg: e }),
|
|
589
|
+
this._executeQueue.push({ resolve: t, msg: e }), g.debug("Calling connect from execute since not currently connected."), this.connect();
|
|
590
590
|
}));
|
|
591
591
|
}
|
|
592
592
|
executeRaw(e) {
|
|
@@ -599,7 +599,7 @@ class ci {
|
|
|
599
599
|
}
|
|
600
600
|
disconnect() {
|
|
601
601
|
return O(this, void 0, void 0, (function* () {
|
|
602
|
-
clearTimeout(this._reconnectTimeout), this.subscriptions = {}, this._autoReconnect = !1, this.relayProtocol = null, this._closeConnection(), yield sessionStorage.removeItem(this.signature), this._executeQueue = [], this._detachListeners(),
|
|
602
|
+
clearTimeout(this._reconnectTimeout), this.subscriptions = {}, this._autoReconnect = !1, this.relayProtocol = null, this._closeConnection(), yield sessionStorage.removeItem(this.signature), this._executeQueue = [], this._detachListeners(), g.debug("Session disconnected. Cleaned up all listeners and subscriptions, closed connection, disabled auto-reconnect.");
|
|
603
603
|
}));
|
|
604
604
|
}
|
|
605
605
|
on(e, t) {
|
|
@@ -610,7 +610,7 @@ class ci {
|
|
|
610
610
|
}
|
|
611
611
|
connect() {
|
|
612
612
|
return O(this, void 0, void 0, (function* () {
|
|
613
|
-
this.connection || (
|
|
613
|
+
this.connection || (g.debug("No existing connection found, creating a new one."), this.connection = new It(this)), this._attachListeners(), this._autoReconnect = !0, this.connection.isAlive || (g.debug("Initiating connection to the server..."), this.connection.connect()), g.debug("Connect method called. Connection initiated.");
|
|
614
614
|
}));
|
|
615
615
|
}
|
|
616
616
|
_handleLoginError(e) {
|
|
@@ -623,7 +623,7 @@ class ci {
|
|
|
623
623
|
if (ke(this.options)) return this._login({ type: "anonymous_login", onSuccess: t, onError: i });
|
|
624
624
|
{
|
|
625
625
|
const s = "Invalid login options provided for authentication.";
|
|
626
|
-
return
|
|
626
|
+
return g.error(s), void j(x.Error, { error: new Error(s), type: Yn.invalidCredentialsOptions, sessionId: this.sessionid }, this.uuid);
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
629
|
}));
|
|
@@ -631,7 +631,7 @@ class ci {
|
|
|
631
631
|
_login({ type: e, onSuccess: t, onError: i }) {
|
|
632
632
|
return O(this, void 0, void 0, (function* () {
|
|
633
633
|
let s;
|
|
634
|
-
s = e === "login" ? new
|
|
634
|
+
s = e === "login" ? new ei(this.options.login, this.options.password || this.options.passwd, this.options.login_token, this.sessionid, this.options.userVariables, !!he()) : new ci({ target_id: this.options.anonymous_login.target_id, target_type: this.options.anonymous_login.target_type, target_version_id: this.options.anonymous_login.target_version_id, target_params: this.options.anonymous_login.target_params, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!he() });
|
|
635
635
|
const o = yield this.execute(s).catch(((r) => {
|
|
636
636
|
this._handleLoginError(r), i && i(r);
|
|
637
637
|
}));
|
|
@@ -646,7 +646,7 @@ class ci {
|
|
|
646
646
|
this.relayProtocol && Ze(this.relayProtocol);
|
|
647
647
|
for (const e in this.subscriptions) Ze(e);
|
|
648
648
|
this.subscriptions = {}, this.contexts = [], clearTimeout(this._keepAliveTimeout), clearTimeout(this._reconnectTimeout), this.connection && (this.connection.previousGatewayState = ""), this._autoReconnect && (this._reconnectTimeout = setTimeout((() => {
|
|
649
|
-
|
|
649
|
+
g.debug("Calling connect due to network close and auto-reconnect enabled."), this.connect();
|
|
650
650
|
}), this.reconnectDelay));
|
|
651
651
|
}
|
|
652
652
|
_onSocketMessage(e) {
|
|
@@ -675,13 +675,13 @@ class ci {
|
|
|
675
675
|
this._idle = !0, clearTimeout(this._keepAliveTimeout), this.connection && this.connection.close();
|
|
676
676
|
}
|
|
677
677
|
_resetKeepAlive() {
|
|
678
|
-
this._pong === !1 && (
|
|
678
|
+
this._pong === !1 && (g.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new dn(he()))), clearTimeout(this._keepAliveTimeout), this._triggerKeepAliveTimeoutCheck();
|
|
679
679
|
}
|
|
680
680
|
_triggerKeepAliveTimeoutCheck() {
|
|
681
681
|
this._pong = !1, this._keepAliveTimeout = setTimeout((() => this._resetKeepAlive()), 35e3);
|
|
682
682
|
}
|
|
683
683
|
setPingReceived() {
|
|
684
|
-
|
|
684
|
+
g.debug("Ping received"), this._pong = !0;
|
|
685
685
|
}
|
|
686
686
|
static on(e, t) {
|
|
687
687
|
de(e, t);
|
|
@@ -702,27 +702,27 @@ class ci {
|
|
|
702
702
|
const $e = (n) => navigator.mediaDevices.getUserMedia(n), ge = (n) => n && n instanceof MediaStream, Ee = (n, e) => {
|
|
703
703
|
const t = Ue(n);
|
|
704
704
|
t !== null && (t.getAttribute("autoplay") || t.setAttribute("autoplay", "autoplay"), t.getAttribute("playsinline") || t.setAttribute("playsinline", "playsinline"), t.srcObject = e);
|
|
705
|
-
},
|
|
705
|
+
}, hn = (n, e) => O(void 0, void 0, void 0, (function* () {
|
|
706
706
|
const t = Ue(n);
|
|
707
|
-
if (t === null) return
|
|
708
|
-
if (typeof e != "string") return
|
|
707
|
+
if (t === null) return g.info("No HTMLMediaElement to attach the speakerId"), !1;
|
|
708
|
+
if (typeof e != "string") return g.info(`Invalid speaker deviceId: '${e}'`), !1;
|
|
709
709
|
try {
|
|
710
710
|
return yield t.setSinkId(e), !0;
|
|
711
711
|
} catch {
|
|
712
712
|
return !1;
|
|
713
713
|
}
|
|
714
|
-
})),
|
|
714
|
+
})), di = (n) => {
|
|
715
715
|
n && n.readyState === "live" && n.stop();
|
|
716
716
|
}, Te = (n) => {
|
|
717
|
-
ge(n) && n.getTracks().forEach(
|
|
717
|
+
ge(n) && n.getTracks().forEach(di), n = null;
|
|
718
718
|
}, Be = (n) => O(void 0, void 0, void 0, (function* () {
|
|
719
|
-
|
|
719
|
+
g.info("RTCService.getUserMedia", n);
|
|
720
720
|
const { audio: e, video: t } = n;
|
|
721
721
|
if (!e && !t) return null;
|
|
722
722
|
try {
|
|
723
723
|
return yield $e(n);
|
|
724
724
|
} catch (i) {
|
|
725
|
-
if (
|
|
725
|
+
if (g.error("getUserMedia error: ", i), ((s) => s.name === "NotReadableError" || s.name === "NotFoundError" || s.name === "OverconstrainedError")(i)) {
|
|
726
726
|
const s = ((o) => {
|
|
727
727
|
const { audio: r, video: l } = o;
|
|
728
728
|
let c = !1, u = r, p = l;
|
|
@@ -739,11 +739,11 @@ const $e = (n) => navigator.mediaDevices.getUserMedia(n), ge = (n) => n && n ins
|
|
|
739
739
|
return c ? { audio: u, video: p } : null;
|
|
740
740
|
})(n);
|
|
741
741
|
if (s) {
|
|
742
|
-
|
|
742
|
+
g.warn("Device not found or not readable, falling back to default device");
|
|
743
743
|
try {
|
|
744
744
|
return yield $e(s);
|
|
745
745
|
} catch (o) {
|
|
746
|
-
throw
|
|
746
|
+
throw g.error("Fallback getUserMedia also failed: ", o), i;
|
|
747
747
|
}
|
|
748
748
|
}
|
|
749
749
|
}
|
|
@@ -751,7 +751,7 @@ const $e = (n) => navigator.mediaDevices.getUserMedia(n), ge = (n) => n && n ins
|
|
|
751
751
|
}
|
|
752
752
|
})), Ie = (n = null, e = !1) => O(void 0, void 0, void 0, (function* () {
|
|
753
753
|
let t = [];
|
|
754
|
-
const i = yield navigator.mediaDevices.getUserMedia(((s = null) => ({ audio: !s || s === ae.AudioIn || s === ae.AudioOut, video: !s || s === ae.Video }))(n)).catch(((s) => (
|
|
754
|
+
const i = yield navigator.mediaDevices.getUserMedia(((s = null) => ({ audio: !s || s === ae.AudioIn || s === ae.AudioOut, video: !s || s === ae.Video }))(n)).catch(((s) => (g.error(s), null)));
|
|
755
755
|
if (i) {
|
|
756
756
|
if (Te(i), t = yield navigator.mediaDevices.enumerateDevices(), n && (t = t.filter(((o) => o.kind === n))), e === !0) return t;
|
|
757
757
|
const s = [];
|
|
@@ -769,7 +769,7 @@ const $e = (n) => navigator.mediaDevices.getUserMedia(n), ge = (n) => n && n ins
|
|
|
769
769
|
if (n === o || e === r) return o;
|
|
770
770
|
}
|
|
771
771
|
return null;
|
|
772
|
-
})),
|
|
772
|
+
})), ui = (n) => {
|
|
773
773
|
const e = navigator.mediaDevices.getSupportedConstraints();
|
|
774
774
|
Object.keys(n).map(((t) => {
|
|
775
775
|
e.hasOwnProperty(t) && n[t] !== null && n[t] !== void 0 || delete n[t];
|
|
@@ -816,7 +816,7 @@ const $e = (n) => navigator.mediaDevices.getUserMedia(n), ge = (n) => n && n ins
|
|
|
816
816
|
ve(n, "audio", !1);
|
|
817
817
|
}, Ot = (n) => {
|
|
818
818
|
ve(n, "audio", null);
|
|
819
|
-
},
|
|
819
|
+
}, hi = (n) => ((e, t = null) => {
|
|
820
820
|
if (!ge(e)) return null;
|
|
821
821
|
let i = [];
|
|
822
822
|
switch (t) {
|
|
@@ -831,7 +831,7 @@ const $e = (n) => navigator.mediaDevices.getUserMedia(n), ge = (n) => n && n ins
|
|
|
831
831
|
}
|
|
832
832
|
return i.some(((s) => s.enabled));
|
|
833
833
|
})(n, "audio");
|
|
834
|
-
function
|
|
834
|
+
function pi() {
|
|
835
835
|
try {
|
|
836
836
|
const { browserInfo: n, name: e, version: t, supportAudio: i, supportVideo: s } = (function() {
|
|
837
837
|
if (!window || !window.navigator || !window.navigator.userAgent) throw new Error("You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari");
|
|
@@ -872,7 +872,7 @@ function Pt(n) {
|
|
|
872
872
|
n && (n._playFulfilled = !1, n._promise = n.play(), n._promise.then((() => {
|
|
873
873
|
n._playFulfilled = !0;
|
|
874
874
|
})).catch(((e) => {
|
|
875
|
-
|
|
875
|
+
g.error("playAudio", e), n._playFulfilled = !0;
|
|
876
876
|
})));
|
|
877
877
|
}
|
|
878
878
|
function Dt(n) {
|
|
@@ -885,7 +885,14 @@ function Dt(n) {
|
|
|
885
885
|
(function(n) {
|
|
886
886
|
n.not_supported = "not supported", n.full = "full", n.partial = "partial";
|
|
887
887
|
})(q || (q = {}));
|
|
888
|
-
|
|
888
|
+
const Nt = (n) => {
|
|
889
|
+
const e = [], t = [];
|
|
890
|
+
return n && n.length !== 0 ? (n.forEach(((i) => {
|
|
891
|
+
const s = i.mimeType.toLocaleLowerCase();
|
|
892
|
+
s.startsWith("audio/") ? e.push(i) : s.startsWith("video/") && t.push(i);
|
|
893
|
+
})), { audioCodecs: e, videoCodecs: t }) : { audioCodecs: e, videoCodecs: t };
|
|
894
|
+
};
|
|
895
|
+
class fi extends Ae {
|
|
889
896
|
constructor(e, t) {
|
|
890
897
|
super(), this.method = "ai_conversation", this.buildRequest({ method: this.method, params: { type: "conversation.item.create", previous_item_id: null, item: { id: me(), type: "message", role: "user", content: [{ type: "input_text", text: e }, ...t?.map(((i) => ({ type: "image_url", image_url: { url: i } })))] } } });
|
|
891
898
|
}
|
|
@@ -893,12 +900,12 @@ class pi extends Ae {
|
|
|
893
900
|
class ce {
|
|
894
901
|
constructor(e, t) {
|
|
895
902
|
this.peerConnection = null, this.intervalId = null, this.statsBuffer = [], this.intervalStartTime = null, this.callEndTime = null, this.logCollector = null, this.intervalAudioLevels = { outbound: [], inbound: [] }, this.intervalJitters = [], this.intervalRTTs = [], this.intervalBitrates = { outbound: [], inbound: [] }, this.previousStats = {}, this.previousCandidatePairId = null, this.MAX_BUFFER_SIZE = 360, this.onFlushNeeded = null, this._segmentIndex = 0, this._flushing = !1, this.options = e, this.logCollectorOptions = t || { enabled: !1, level: "debug", maxEntries: 1e3 }, this.callStartTime = /* @__PURE__ */ new Date(), this.logCollectorOptions.enabled && (this.logCollector = (function(i) {
|
|
896
|
-
return new
|
|
903
|
+
return new Gn(i);
|
|
897
904
|
})(this.logCollectorOptions), this.logCollector.start(), St(this.logCollector));
|
|
898
905
|
}
|
|
899
906
|
start(e) {
|
|
900
907
|
var t, i;
|
|
901
|
-
this.options.enabled && (this.peerConnection = e, this.intervalStartTime = /* @__PURE__ */ new Date(),
|
|
908
|
+
this.options.enabled && (this.peerConnection = e, this.intervalStartTime = /* @__PURE__ */ new Date(), g.info("CallReportCollector: Starting stats collection", { interval: this.options.interval, logCollectorActive: (i = (t = this.logCollector) === null || t === void 0 ? void 0 : t.isActive()) !== null && i !== void 0 && i }), this.intervalId = setInterval((() => {
|
|
902
909
|
this._collectStats();
|
|
903
910
|
}), this.options.interval));
|
|
904
911
|
}
|
|
@@ -907,7 +914,7 @@ class ce {
|
|
|
907
914
|
return O(this, void 0, void 0, (function* () {
|
|
908
915
|
this.intervalId && (clearInterval(this.intervalId), this.intervalId = null), this.callEndTime = /* @__PURE__ */ new Date(), this.peerConnection && this.intervalStartTime && (yield this._collectStats(!0));
|
|
909
916
|
const i = (t = (e = this.logCollector) === null || e === void 0 ? void 0 : e.getLogCount()) !== null && t !== void 0 ? t : 0;
|
|
910
|
-
this.logCollector && this.logCollector.stop(),
|
|
917
|
+
this.logCollector && this.logCollector.stop(), g.info("CallReportCollector: Stopped stats collection", { totalIntervals: this.statsBuffer.length, totalLogs: i, duration: this.callEndTime.getTime() - this.callStartTime.getTime() });
|
|
911
918
|
}));
|
|
912
919
|
}
|
|
913
920
|
flush(e) {
|
|
@@ -918,7 +925,7 @@ class ce {
|
|
|
918
925
|
const s = this._segmentIndex++, o = this.statsBuffer;
|
|
919
926
|
this.statsBuffer = [];
|
|
920
927
|
const r = (i = (t = this.logCollector) === null || t === void 0 ? void 0 : t.drain()) !== null && i !== void 0 ? i : [], l = /* @__PURE__ */ new Date(), c = Object.assign(Object.assign({ summary: Object.assign(Object.assign({}, e), { durationSeconds: (l.getTime() - this.callStartTime.getTime()) / 1e3, startTimestamp: this.callStartTime.toISOString(), endTimestamp: l.toISOString() }), stats: o }, r.length > 0 ? { logs: r } : {}), { segment: s });
|
|
921
|
-
return
|
|
928
|
+
return g.info("CallReportCollector: Flushed intermediate segment", { segment: s, intervals: o.length, logEntries: r.length, callId: e.callId }), c;
|
|
922
929
|
} finally {
|
|
923
930
|
this._flushing = !1;
|
|
924
931
|
}
|
|
@@ -927,8 +934,8 @@ class ce {
|
|
|
927
934
|
var o, r;
|
|
928
935
|
return O(this, void 0, void 0, (function* () {
|
|
929
936
|
const l = (o = this.logCollector) === null || o === void 0 ? void 0 : o.getLogs(), c = l && l.length > 0;
|
|
930
|
-
if (!this.options.enabled) return void
|
|
931
|
-
if (this.statsBuffer.length === 0 && !c) return void
|
|
937
|
+
if (!this.options.enabled) return void g.info("CallReportCollector: Skipping report — call reports disabled");
|
|
938
|
+
if (this.statsBuffer.length === 0 && !c) return void g.info("CallReportCollector: Skipping report — no stats or logs collected");
|
|
932
939
|
const u = this._segmentIndex > 0, p = this._segmentIndex, f = Object.assign(Object.assign({ summary: Object.assign(Object.assign({}, e), { durationSeconds: this.callEndTime && this.callStartTime ? (this.callEndTime.getTime() - this.callStartTime.getTime()) / 1e3 : void 0, startTimestamp: this.callStartTime.toISOString(), endTimestamp: (r = this.callEndTime) === null || r === void 0 ? void 0 : r.toISOString() }), stats: this.statsBuffer }, l && l.length > 0 ? { logs: l } : {}), u ? { segment: p } : {});
|
|
933
940
|
yield this._sendPayload(f, t, i, s);
|
|
934
941
|
}));
|
|
@@ -943,28 +950,28 @@ class ce {
|
|
|
943
950
|
return O(this, void 0, void 0, (function* () {
|
|
944
951
|
try {
|
|
945
952
|
const l = new URL(i), c = `${l.protocol.replace(/^ws/, "http")}//${l.host}/call_report`, u = e.segment !== void 0 && !e.summary.endTimestamp ? `intermediate segment ${e.segment}` : "final report";
|
|
946
|
-
|
|
953
|
+
g.info(`CallReportCollector: Posting ${u}`, { endpoint: c, intervals: e.stats.length, logEntries: (r = (o = e.logs) === null || o === void 0 ? void 0 : o.length) !== null && r !== void 0 ? r : 0, callId: e.summary.callId, segment: e.segment });
|
|
947
954
|
const p = { "Content-Type": "application/json", "x-call-report-id": t, "x-call-id": e.summary.callId };
|
|
948
955
|
s && (p["x-voice-sdk-id"] = s);
|
|
949
956
|
const f = JSON.stringify(e), C = () => fetch(c, { method: "POST", headers: p, body: f }), b = yield C();
|
|
950
|
-
if (b.ok)
|
|
957
|
+
if (b.ok) g.info(`CallReportCollector: Successfully posted ${u}`);
|
|
951
958
|
else {
|
|
952
959
|
const y = yield b.text();
|
|
953
|
-
|
|
960
|
+
g.error(`CallReportCollector: Failed to post ${u}`, { status: b.status, error: y });
|
|
954
961
|
}
|
|
955
962
|
} catch (l) {
|
|
956
|
-
|
|
963
|
+
g.warn(`CallReportCollector: Network error posting call report, retrying in ${ce.RETRY_DELAY_MS}ms`, { error: l }), yield new Promise(((c) => setTimeout(c, ce.RETRY_DELAY_MS)));
|
|
957
964
|
try {
|
|
958
965
|
const c = new URL(i), u = `${c.protocol.replace(/^ws/, "http")}//${c.host}/call_report`, p = { "Content-Type": "application/json", "x-call-report-id": t, "x-call-id": e.summary.callId };
|
|
959
966
|
s && (p["x-voice-sdk-id"] = s);
|
|
960
967
|
const f = yield fetch(u, { method: "POST", headers: p, body: JSON.stringify(e) });
|
|
961
|
-
if (f.ok)
|
|
968
|
+
if (f.ok) g.info("CallReportCollector: Successfully posted call report on retry");
|
|
962
969
|
else {
|
|
963
970
|
const C = yield f.text();
|
|
964
|
-
|
|
971
|
+
g.error("CallReportCollector: Failed to post call report on retry", { status: f.status, error: C });
|
|
965
972
|
}
|
|
966
973
|
} catch (c) {
|
|
967
|
-
|
|
974
|
+
g.error("CallReportCollector: Retry also failed, giving up", { error: c });
|
|
968
975
|
}
|
|
969
976
|
}
|
|
970
977
|
}));
|
|
@@ -977,7 +984,7 @@ class ce {
|
|
|
977
984
|
return (t = (e = this.logCollector) === null || e === void 0 ? void 0 : e.getLogs()) !== null && t !== void 0 ? t : [];
|
|
978
985
|
}
|
|
979
986
|
cleanup() {
|
|
980
|
-
this.logCollector && (this.logCollector.clear(),
|
|
987
|
+
this.logCollector && (this.logCollector.clear(), tn() === this.logCollector && St(null), this.logCollector = null);
|
|
981
988
|
}
|
|
982
989
|
_collectStats(e = !1) {
|
|
983
990
|
var t, i, s;
|
|
@@ -1002,9 +1009,9 @@ class ce {
|
|
|
1002
1009
|
})), u) {
|
|
1003
1010
|
const y = this._getOutboundAudioLevel(o, u);
|
|
1004
1011
|
if (y !== null && this.intervalAudioLevels.outbound.push(y), this.previousStats.outboundBytes !== void 0 && this.previousStats.timestamp !== void 0) {
|
|
1005
|
-
const I = (u.bytesSent || 0) - this.previousStats.outboundBytes,
|
|
1006
|
-
if (
|
|
1007
|
-
const w = 8 * I * 1e3 /
|
|
1012
|
+
const I = (u.bytesSent || 0) - this.previousStats.outboundBytes, v = (u.timestamp || r.getTime()) - this.previousStats.timestamp;
|
|
1013
|
+
if (v > 0) {
|
|
1014
|
+
const w = 8 * I * 1e3 / v;
|
|
1008
1015
|
this.intervalBitrates.outbound.push(w);
|
|
1009
1016
|
}
|
|
1010
1017
|
}
|
|
@@ -1013,33 +1020,33 @@ class ce {
|
|
|
1013
1020
|
if (p) {
|
|
1014
1021
|
const y = this._getInboundAudioLevel(o, p);
|
|
1015
1022
|
if (y !== null && this.intervalAudioLevels.inbound.push(y), p.jitter !== void 0 && this.intervalJitters.push(1e3 * p.jitter), this.previousStats.inboundBytes !== void 0 && this.previousStats.timestamp !== void 0) {
|
|
1016
|
-
const I = (p.bytesReceived || 0) - this.previousStats.inboundBytes,
|
|
1017
|
-
if (
|
|
1018
|
-
const w = 8 * I * 1e3 /
|
|
1023
|
+
const I = (p.bytesReceived || 0) - this.previousStats.inboundBytes, v = (p.timestamp || r.getTime()) - this.previousStats.timestamp;
|
|
1024
|
+
if (v > 0) {
|
|
1025
|
+
const w = 8 * I * 1e3 / v;
|
|
1019
1026
|
this.intervalBitrates.inbound.push(w);
|
|
1020
1027
|
}
|
|
1021
1028
|
}
|
|
1022
1029
|
this.previousStats.inboundBytes = p.bytesReceived;
|
|
1023
1030
|
}
|
|
1024
|
-
f && (f.currentRoundTripTime !== void 0 && this.intervalRTTs.push(f.currentRoundTripTime), this.previousCandidatePairId !== null && f.id !== this.previousCandidatePairId &&
|
|
1031
|
+
f && (f.currentRoundTripTime !== void 0 && this.intervalRTTs.push(f.currentRoundTripTime), this.previousCandidatePairId !== null && f.id !== this.previousCandidatePairId && g.debug("CallReportCollector: ICE candidate pair changed mid-call", { previous: this.previousCandidatePairId, current: f.id }), this.previousCandidatePairId = (t = f.id) !== null && t !== void 0 ? t : null), f && (l = this._resolveCandidate(o, f.localCandidateId), c = this._resolveCandidate(o, f.remoteCandidateId)), this.previousStats.timestamp = r.getTime();
|
|
1025
1032
|
const b = r.getTime() - this.intervalStartTime.getTime();
|
|
1026
1033
|
if (e || b >= this.options.interval) {
|
|
1027
1034
|
const y = this._createStatsEntry(this.intervalStartTime, r, u, p, f, l, c, C);
|
|
1028
|
-
if (this.statsBuffer.push(y), this.statsBuffer.length > this.MAX_BUFFER_SIZE && (this.statsBuffer.shift(),
|
|
1029
|
-
const I = this.statsBuffer.length,
|
|
1030
|
-
if (I >= ce.STATS_FLUSH_THRESHOLD ||
|
|
1031
|
-
|
|
1035
|
+
if (this.statsBuffer.push(y), this.statsBuffer.length > this.MAX_BUFFER_SIZE && (this.statsBuffer.shift(), g.warn("CallReportCollector: Buffer size limit reached, removing oldest entry")), this.onFlushNeeded && !this._flushing) {
|
|
1036
|
+
const I = this.statsBuffer.length, v = (s = (i = this.logCollector) === null || i === void 0 ? void 0 : i.getLogCount()) !== null && s !== void 0 ? s : 0;
|
|
1037
|
+
if (I >= ce.STATS_FLUSH_THRESHOLD || v >= ce.LOGS_FLUSH_THRESHOLD) {
|
|
1038
|
+
g.info("CallReportCollector: Approaching buffer limits, requesting flush", { statsIntervals: I, logEntries: v });
|
|
1032
1039
|
try {
|
|
1033
1040
|
this.onFlushNeeded();
|
|
1034
1041
|
} catch (w) {
|
|
1035
|
-
|
|
1042
|
+
g.error("CallReportCollector: onFlushNeeded callback error", { error: w });
|
|
1036
1043
|
}
|
|
1037
1044
|
}
|
|
1038
1045
|
}
|
|
1039
1046
|
this.intervalStartTime = r, this._resetIntervalAccumulators();
|
|
1040
1047
|
}
|
|
1041
1048
|
} catch (o) {
|
|
1042
|
-
|
|
1049
|
+
g.error("CallReportCollector: Error collecting stats", { error: o });
|
|
1043
1050
|
}
|
|
1044
1051
|
}));
|
|
1045
1052
|
}
|
|
@@ -1048,12 +1055,12 @@ class ce {
|
|
|
1048
1055
|
return i && (u.audio.outbound = { packetsSent: i.packetsSent, bytesSent: i.bytesSent, audioLevelAvg: this._average(this.intervalAudioLevels.outbound), bitrateAvg: this._average(this.intervalBitrates.outbound) }), s && (u.audio.inbound = { packetsReceived: s.packetsReceived, bytesReceived: s.bytesReceived, packetsLost: s.packetsLost, packetsDiscarded: s.packetsDiscarded, jitterBufferDelay: s.jitterBufferDelay, jitterBufferEmittedCount: s.jitterBufferEmittedCount, totalSamplesReceived: s.totalSamplesReceived, concealedSamples: s.concealedSamples, concealmentEvents: s.concealmentEvents, audioLevelAvg: this._average(this.intervalAudioLevels.inbound), jitterAvg: this._average(this.intervalJitters), bitrateAvg: this._average(this.intervalBitrates.inbound) }), o && (u.connection = { roundTripTimeAvg: this._average(this.intervalRTTs), packetsSent: o.packetsSent, packetsReceived: o.packetsReceived, bytesSent: o.bytesSent, bytesReceived: o.bytesReceived }, u.ice = Object.assign(Object.assign({ id: o.id, state: o.state, nominated: o.nominated, writable: o.writable, requestsSent: o.requestsSent, responsesReceived: o.responsesReceived }, r ? { local: r } : {}), l ? { remote: l } : {})), c && (u.transport = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, c.iceState !== void 0 ? { iceState: c.iceState } : {}), c.dtlsState !== void 0 ? { dtlsState: c.dtlsState } : {}), c.srtpCipher !== void 0 ? { srtpCipher: c.srtpCipher } : {}), c.tlsVersion !== void 0 ? { tlsVersion: c.tlsVersion } : {}), c.selectedCandidatePairChanges !== void 0 ? { selectedCandidatePairChanges: c.selectedCandidatePairChanges } : {})), u;
|
|
1049
1056
|
}
|
|
1050
1057
|
_resolveCandidate(e, t) {
|
|
1051
|
-
if (!t) return void
|
|
1058
|
+
if (!t) return void g.debug("CallReportCollector: candidateId is empty, skipping resolve");
|
|
1052
1059
|
const i = e.get(t);
|
|
1053
|
-
if (!i) return void
|
|
1060
|
+
if (!i) return void g.debug("CallReportCollector: candidate not found in stats report", { candidateId: t });
|
|
1054
1061
|
const s = {};
|
|
1055
1062
|
if (i.address !== void 0 && (s.address = i.address), i.port !== void 0 && (s.port = i.port), i.candidateType !== void 0 && (s.candidateType = i.candidateType), i.protocol !== void 0 && (s.protocol = i.protocol), i.networkType !== void 0 && (s.networkType = i.networkType), Object.keys(s).length !== 0) return s;
|
|
1056
|
-
|
|
1063
|
+
g.debug("CallReportCollector: candidate report has no usable fields", { candidateId: t });
|
|
1057
1064
|
}
|
|
1058
1065
|
_getOutboundAudioLevel(e, t) {
|
|
1059
1066
|
let i;
|
|
@@ -1096,7 +1103,7 @@ class ce {
|
|
|
1096
1103
|
}
|
|
1097
1104
|
}
|
|
1098
1105
|
ce.STATS_FLUSH_THRESHOLD = 300, ce.LOGS_FLUSH_THRESHOLD = 800, ce.RETRY_DELAY_MS = 500;
|
|
1099
|
-
var Oe,
|
|
1106
|
+
var Oe, pn = Zt((function(n, e) {
|
|
1100
1107
|
var t;
|
|
1101
1108
|
function i() {
|
|
1102
1109
|
}
|
|
@@ -1113,8 +1120,8 @@ var Oe, hn = Qt((function(n, e) {
|
|
|
1113
1120
|
if (typeof k == "function" ? k = E[d] = m ? [h, k] : [k, h] : m ? k.unshift(h) : k.push(h), !k.warned && (_ = o(a)) && 0 < _ && k.length > _) {
|
|
1114
1121
|
k.warned = !0;
|
|
1115
1122
|
var L = new Error("Possible EventEmitter memory leak detected. " + k.length + " " + d + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
1116
|
-
L.name = "MaxListenersExceededWarning", L.emitter = a, L.type = d, L.count = k.length, (function(
|
|
1117
|
-
typeof console.warn == "function" ? console.warn(
|
|
1123
|
+
L.name = "MaxListenersExceededWarning", L.emitter = a, L.type = d, L.count = k.length, (function($) {
|
|
1124
|
+
typeof console.warn == "function" ? console.warn($) : console.log($);
|
|
1118
1125
|
})(L);
|
|
1119
1126
|
}
|
|
1120
1127
|
} else k = E[d] = h, ++a._eventsCount;
|
|
@@ -1148,10 +1155,10 @@ var Oe, hn = Qt((function(n, e) {
|
|
|
1148
1155
|
}, s.prototype.getMaxListeners = function() {
|
|
1149
1156
|
return o(this);
|
|
1150
1157
|
}, s.prototype.emit = function(a) {
|
|
1151
|
-
var d, h, m, _, E, k, L,
|
|
1152
|
-
if (k = this._events)
|
|
1153
|
-
else if (
|
|
1154
|
-
if (L = this.domain,
|
|
1158
|
+
var d, h, m, _, E, k, L, $ = a === "error";
|
|
1159
|
+
if (k = this._events) $ = $ && k.error == null;
|
|
1160
|
+
else if (!$) return !1;
|
|
1161
|
+
if (L = this.domain, $) {
|
|
1155
1162
|
if (d = arguments[1], !L) {
|
|
1156
1163
|
if (d instanceof Error) throw d;
|
|
1157
1164
|
var Z = new Error('Uncaught, unspecified "error" event. (' + d + ")");
|
|
@@ -1219,8 +1226,8 @@ var Oe, hn = Qt((function(n, e) {
|
|
|
1219
1226
|
if (h.length === 1) {
|
|
1220
1227
|
if (h[0] = void 0, --this._eventsCount == 0) return this._events = new i(), this;
|
|
1221
1228
|
delete m[a];
|
|
1222
|
-
} else (function(L,
|
|
1223
|
-
for (var Z =
|
|
1229
|
+
} else (function(L, $) {
|
|
1230
|
+
for (var Z = $, te = Z + 1, G = L.length; te < G; Z += 1, te += 1) L[Z] = L[te];
|
|
1224
1231
|
L.pop();
|
|
1225
1232
|
})(h, _);
|
|
1226
1233
|
m.removeListener && this.emit("removeListener", a, k || d);
|
|
@@ -1256,7 +1263,7 @@ var Oe, hn = Qt((function(n, e) {
|
|
|
1256
1263
|
return p(f);
|
|
1257
1264
|
}
|
|
1258
1265
|
for (var b = /^(?:[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, y = [], I = 0; 256 > I; ++I) y.push((I + 256).toString(16).substr(1));
|
|
1259
|
-
function
|
|
1266
|
+
function v(a) {
|
|
1260
1267
|
var d = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0, h = (y[a[d + 0]] + y[a[d + 1]] + y[a[d + 2]] + y[a[d + 3]] + "-" + y[a[d + 4]] + y[a[d + 5]] + "-" + y[a[d + 6]] + y[a[d + 7]] + "-" + y[a[d + 8]] + y[a[d + 9]] + "-" + y[a[d + 10]] + y[a[d + 11]] + y[a[d + 12]] + y[a[d + 13]] + y[a[d + 14]] + y[a[d + 15]]).toLowerCase();
|
|
1261
1268
|
if (!(function(m) {
|
|
1262
1269
|
return typeof m == "string" && b.test(m);
|
|
@@ -1265,7 +1272,7 @@ var Oe, hn = Qt((function(n, e) {
|
|
|
1265
1272
|
}
|
|
1266
1273
|
function w(a, d, h) {
|
|
1267
1274
|
var m = (a = a || {}).random || (a.rng || C)();
|
|
1268
|
-
return m[6] = 64 | 15 & m[6], m[8] = 128 | 63 & m[8],
|
|
1275
|
+
return m[6] = 64 | 15 & m[6], m[8] = 128 | 63 & m[8], v(m);
|
|
1269
1276
|
}
|
|
1270
1277
|
function R(a, d) {
|
|
1271
1278
|
if (!a || !d) return {};
|
|
@@ -1303,8 +1310,8 @@ var Oe, hn = Qt((function(n, e) {
|
|
|
1303
1310
|
let L = {};
|
|
1304
1311
|
if (!["audio", "video"].includes(E)) continue;
|
|
1305
1312
|
if (_.codecId) {
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1313
|
+
const $ = a.get(_.codecId);
|
|
1314
|
+
$ && (k.clockRate = $.clockRate, k.mimeType = $.mimeType, k.payloadType = $.payloadType);
|
|
1308
1315
|
}
|
|
1309
1316
|
L = a.get(_.mediaSourceId) || a.get(_.trackId) || {}, m[E].outbound.push({ ..._, ...k, track: { ...L } });
|
|
1310
1317
|
break;
|
|
@@ -1318,13 +1325,13 @@ var Oe, hn = Qt((function(n, e) {
|
|
|
1318
1325
|
E = "audio";
|
|
1319
1326
|
}
|
|
1320
1327
|
if (_.codecId) {
|
|
1321
|
-
const
|
|
1322
|
-
|
|
1328
|
+
const $ = a.get(_.codecId);
|
|
1329
|
+
$ && (L.clockRate = $.clockRate, L.mimeType = $.mimeType, L.payloadType = $.payloadType);
|
|
1323
1330
|
}
|
|
1324
1331
|
if (!m.connection.id && _.transportId) {
|
|
1325
|
-
const
|
|
1326
|
-
if (
|
|
1327
|
-
const Z = a.get(
|
|
1332
|
+
const $ = a.get(_.transportId);
|
|
1333
|
+
if ($ && $.selectedCandidatePairId) {
|
|
1334
|
+
const Z = a.get($.selectedCandidatePairId);
|
|
1328
1335
|
m.connection = R(Z, a);
|
|
1329
1336
|
}
|
|
1330
1337
|
}
|
|
@@ -1350,8 +1357,8 @@ var Oe, hn = Qt((function(n, e) {
|
|
|
1350
1357
|
if (!m.connection.id && _.transportId) {
|
|
1351
1358
|
const L = a.get(_.transportId);
|
|
1352
1359
|
if (L && L.selectedCandidatePairId) {
|
|
1353
|
-
const
|
|
1354
|
-
m.connection = R(
|
|
1360
|
+
const $ = a.get(L.selectedCandidatePairId);
|
|
1361
|
+
m.connection = R($, a);
|
|
1355
1362
|
}
|
|
1356
1363
|
}
|
|
1357
1364
|
m.remote[E].inbound.push({ ..._, ...k });
|
|
@@ -1372,16 +1379,16 @@ var Oe, hn = Qt((function(n, e) {
|
|
|
1372
1379
|
if (!m.connection.id) for (const _ of a.values()) _.type === "candidate-pair" && _.nominated && _.state === "succeeded" && (m.connection = R(_, a));
|
|
1373
1380
|
return m = (function(_, E) {
|
|
1374
1381
|
return E && (_.audio.inbound.map(((k) => {
|
|
1375
|
-
let L = E.audio.inbound.find(((
|
|
1382
|
+
let L = E.audio.inbound.find((($) => $.id === k.id));
|
|
1376
1383
|
k.bitrate = T(k, L, "bytesReceived"), k.packetRate = T(k, L, "packetsReceived");
|
|
1377
1384
|
})), _.audio.outbound.map(((k) => {
|
|
1378
|
-
let L = E.audio.outbound.find(((
|
|
1385
|
+
let L = E.audio.outbound.find((($) => $.id === k.id));
|
|
1379
1386
|
k.bitrate = T(k, L, "bytesSent"), k.packetRate = T(k, L, "packetsSent");
|
|
1380
1387
|
})), _.video.inbound.map(((k) => {
|
|
1381
|
-
let L = E.video.inbound.find(((
|
|
1388
|
+
let L = E.video.inbound.find((($) => $.id === k.id));
|
|
1382
1389
|
k.bitrate = T(k, L, "bytesReceived"), k.packetRate = T(k, L, "packetsReceived");
|
|
1383
1390
|
})), _.video.outbound.map(((k) => {
|
|
1384
|
-
let L = E.video.outbound.find(((
|
|
1391
|
+
let L = E.video.outbound.find((($) => $.id === k.id));
|
|
1385
1392
|
k.bitrate = T(k, L, "bytesSent"), k.packetRate = T(k, L, "packetsSent");
|
|
1386
1393
|
}))), _;
|
|
1387
1394
|
})(m, d), m;
|
|
@@ -1496,9 +1503,9 @@ var Oe, hn = Qt((function(n, e) {
|
|
|
1496
1503
|
for (const m in d) for (const _ in d[m]) {
|
|
1497
1504
|
const E = d[m][_], k = E.pc;
|
|
1498
1505
|
if (k && !this.checkIfConnectionIsClosed(m, _, k)) try {
|
|
1499
|
-
const L = this.getTimestamp(),
|
|
1500
|
-
if (
|
|
1501
|
-
const Z = await
|
|
1506
|
+
const L = this.getTimestamp(), $ = k.getStats(null);
|
|
1507
|
+
if ($) {
|
|
1508
|
+
const Z = await $, te = this.getTimestamp(), G = A(Z), S = { remote: E.options.remote }, P = D(Z, E.stats.parsed, S), U = { event: "stats", tag: "stats", peerId: m, connectionId: _, timeTaken: te - L, data: P };
|
|
1502
1509
|
this.rawStats === !0 && (U.rawStats = Z), this.statsObject === !0 && (U.statsObject = G), this.filteredStats === !0 && (U.filteredStats = this.filteroutStats(G)), h.push(U), E.stats.parsed = P;
|
|
1503
1510
|
} else this.logger.error(`PeerConnection from peer ${m} did not return any stats data`);
|
|
1504
1511
|
} catch (L) {
|
|
@@ -1670,9 +1677,9 @@ var Oe, hn = Qt((function(n, e) {
|
|
|
1670
1677
|
}
|
|
1671
1678
|
};
|
|
1672
1679
|
}));
|
|
1673
|
-
(Oe =
|
|
1674
|
-
var
|
|
1675
|
-
function
|
|
1680
|
+
(Oe = pn) && Oe.__esModule && Object.prototype.hasOwnProperty.call(Oe, "default") && Oe.default;
|
|
1681
|
+
var gi = pn.WebRTCStats;
|
|
1682
|
+
function vi(n) {
|
|
1676
1683
|
const { packetsLost: e, packetsReceived: t, jitter: i, rtt: s } = n, o = (function(u) {
|
|
1677
1684
|
const { jitter: p, rtt: f } = u, C = p + f / 2;
|
|
1678
1685
|
return 0.024 * C + 0.11 * (C - 177.3) * (C > 177.3 ? 1 : 0);
|
|
@@ -1682,48 +1689,48 @@ function gi(n) {
|
|
|
1682
1689
|
})({ packetsLost: e, packetsReceived: t }), l = 93.2 - o - r + 0, c = 1 + 0.035 * l + 7e-6 * l * (l - 60) * (100 - l);
|
|
1683
1690
|
return Math.min(Math.max(c, 1), 5);
|
|
1684
1691
|
}
|
|
1685
|
-
function
|
|
1692
|
+
function mi(n) {
|
|
1686
1693
|
return isNaN(n) ? null : n > 4.2 ? "excellent" : n >= 4.1 && n <= 4.2 ? "good" : n >= 3.7 && n <= 4 ? "fair" : n >= 3.1 && n <= 3.6 ? "poor" : "bad";
|
|
1687
1694
|
}
|
|
1688
|
-
class
|
|
1695
|
+
class yi extends Ae {
|
|
1689
1696
|
constructor(e, t) {
|
|
1690
1697
|
super(), this.buildRequest({ type: "debug_report_start", debug_report_id: e, debug_report_version: 1, call_id: t });
|
|
1691
1698
|
}
|
|
1692
1699
|
}
|
|
1693
|
-
class
|
|
1700
|
+
class bi extends Ae {
|
|
1694
1701
|
constructor(e, t) {
|
|
1695
1702
|
super(), this.buildRequest({ type: "debug_report_stop", debug_report_id: e, debug_report_version: 1, call_id: t });
|
|
1696
1703
|
}
|
|
1697
1704
|
}
|
|
1698
|
-
class
|
|
1705
|
+
class Si extends Ae {
|
|
1699
1706
|
constructor(e, t) {
|
|
1700
1707
|
super(), this.buildRequest({ type: "debug_report_data", debug_report_id: e, debug_report_version: 1, debug_report_data: t });
|
|
1701
1708
|
}
|
|
1702
1709
|
}
|
|
1703
|
-
function
|
|
1710
|
+
function jt(n, e) {
|
|
1704
1711
|
var t, i;
|
|
1705
1712
|
return { errorCode: n.errorCode, errorText: n.errorText, url: n.url, address: n.address, port: n.port, connectionState: e.connectionState, iceConnectionState: e.iceConnectionState, iceGatheringState: e.iceGatheringState, signalingState: e.signalingState, localDescriptionType: (t = e.localDescription) === null || t === void 0 ? void 0 : t.type, remoteDescriptionType: (i = e.remoteDescription) === null || i === void 0 ? void 0 : i.type };
|
|
1706
1713
|
}
|
|
1707
|
-
function
|
|
1714
|
+
function _i(n, e) {
|
|
1708
1715
|
const t = me();
|
|
1709
1716
|
let i = !1;
|
|
1710
|
-
const s = new
|
|
1717
|
+
const s = new gi({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), o = (r) => O(this, void 0, void 0, (function* () {
|
|
1711
1718
|
r.event === "stats" && j(x.StatsFrame, (function({ data: l }) {
|
|
1712
1719
|
var c, u, p, f, C, b, y, I;
|
|
1713
|
-
const { audio:
|
|
1714
|
-
return { jitter: T, rtt: A, mos: B, quality:
|
|
1715
|
-
})(r), n.uuid), yield n.execute(new
|
|
1720
|
+
const { audio: v, remote: w } = l, { audio: R } = w, T = (u = (c = R.inbound[0]) === null || c === void 0 ? void 0 : c.jitter) !== null && u !== void 0 ? u : 1 / 0, A = (f = (p = R.inbound[0]) === null || p === void 0 ? void 0 : p.roundTripTime) !== null && f !== void 0 ? f : 1 / 0, D = (b = (C = v.inbound[0]) === null || C === void 0 ? void 0 : C.packetsReceived) !== null && b !== void 0 ? b : -1, W = (I = (y = v.inbound[0]) === null || y === void 0 ? void 0 : y.packetsLost) !== null && I !== void 0 ? I : -1, B = vi({ jitter: 1e3 * T, rtt: 1e3 * A, packetsLost: W, packetsReceived: D });
|
|
1721
|
+
return { jitter: T, rtt: A, mos: B, quality: mi(B), inboundAudio: v.inbound[0], outboundAudio: v.outbound[0], remoteInboundAudio: R.inbound[0], remoteOutboundAudio: R.outbound[0] };
|
|
1722
|
+
})(r), n.uuid), yield n.execute(new Si(t, r));
|
|
1716
1723
|
}));
|
|
1717
1724
|
return { get isRunning() {
|
|
1718
1725
|
return i;
|
|
1719
1726
|
}, start: (r, l, c) => O(this, void 0, void 0, (function* () {
|
|
1720
|
-
if (i)
|
|
1727
|
+
if (i) g.debug(`[${e}] Stats reporter already running, skipping start`);
|
|
1721
1728
|
else {
|
|
1722
|
-
yield n.execute(new
|
|
1729
|
+
yield n.execute(new yi(t, e)), s.on("timeline", o);
|
|
1723
1730
|
try {
|
|
1724
1731
|
yield s.addConnection({ pc: r, peerId: l, connectionId: c }), i = !0;
|
|
1725
1732
|
} catch (u) {
|
|
1726
|
-
|
|
1733
|
+
g.error(`[${e}] Failed to start stats reporter:`, u), s.removeAllPeers(), s.destroy();
|
|
1727
1734
|
}
|
|
1728
1735
|
}
|
|
1729
1736
|
})), stop: (r) => O(this, void 0, void 0, (function* () {
|
|
@@ -1731,7 +1738,7 @@ function Si(n, e) {
|
|
|
1731
1738
|
j(x.StatsReport, l, n.uuid), r === "file" && (function(c, u) {
|
|
1732
1739
|
const p = new Blob([JSON.stringify(c)], { type: "application/json" }), f = URL.createObjectURL(p), C = document.createElement("a");
|
|
1733
1740
|
C.href = f, C.download = `${u}.json`, C.click(), URL.revokeObjectURL(f);
|
|
1734
|
-
})(l, `webrtc-stats-${t}-${Date.now()}`), yield n.execute(new
|
|
1741
|
+
})(l, `webrtc-stats-${t}-${Date.now()}`), yield n.execute(new bi(t, e)), s.removeAllPeers(), s.destroy(), i = !1;
|
|
1735
1742
|
})), reportConnectionStateChange: (r) => {
|
|
1736
1743
|
const l = { event: "connectionstatechange-detailed", tag: "connection", timestamp: (/* @__PURE__ */ new Date()).toISOString(), data: r };
|
|
1737
1744
|
o(l);
|
|
@@ -1740,10 +1747,10 @@ function Si(n, e) {
|
|
|
1740
1747
|
o(l);
|
|
1741
1748
|
} };
|
|
1742
1749
|
}
|
|
1743
|
-
const
|
|
1750
|
+
const fn = (n, e) => {
|
|
1744
1751
|
const { contentType: t, canvasType: i, callID: s, canvasInfo: o = null, currentLayerIdx: r = -1 } = e;
|
|
1745
1752
|
o && i !== "mcu-personal-canvas" && delete o.memberID;
|
|
1746
|
-
const l = { type: se.conferenceUpdate, call: n.calls[s], canvasInfo:
|
|
1753
|
+
const l = { type: se.conferenceUpdate, call: n.calls[s], canvasInfo: Ci(o), currentLayerIdx: r };
|
|
1747
1754
|
switch (t) {
|
|
1748
1755
|
case "layer-info": {
|
|
1749
1756
|
const c = Object.assign({ action: ie.LayerInfo }, l);
|
|
@@ -1756,15 +1763,15 @@ const pn = (n, e) => {
|
|
|
1756
1763
|
break;
|
|
1757
1764
|
}
|
|
1758
1765
|
}
|
|
1759
|
-
},
|
|
1766
|
+
}, Ci = (n) => {
|
|
1760
1767
|
const e = JSON.stringify(n).replace(/memberID/g, "participantId").replace(/ID"/g, 'Id"').replace(/POS"/g, 'Pos"');
|
|
1761
|
-
return
|
|
1768
|
+
return sn(e);
|
|
1762
1769
|
};
|
|
1763
|
-
class
|
|
1770
|
+
class Ut {
|
|
1764
1771
|
constructor(e, t, i, s, o) {
|
|
1765
1772
|
this.type = e, this.options = t, this.onSdpReadyTwice = null, this.statsReporter = null, this._negotiating = !1, this._prevConnectionState = null, this._restartedIceOnConnectionStateFailed = !1, this._sleepWakeupIntervalId = null, this.handleConnectionStateChange = () => O(this, void 0, void 0, (function* () {
|
|
1766
1773
|
const { connectionState: r } = this.instance;
|
|
1767
|
-
if (
|
|
1774
|
+
if (g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}] Connection State changed: ${this._prevConnectionState} -> ${r}`), r === "failed" || r === "disconnected") {
|
|
1768
1775
|
const l = () => O(this, void 0, void 0, (function* () {
|
|
1769
1776
|
if (this.isDebugEnabled && this.statsReporter) {
|
|
1770
1777
|
const c = yield (function(u, p) {
|
|
@@ -1783,7 +1790,7 @@ class jt {
|
|
|
1783
1790
|
}))), y.type === "transport" && (f.dtlsCipher = y.dtlsCipher, f.srtpCipher = y.srtpCipher, f.tlsVersion = y.tlsVersion, y.dtlsState && (f.dtlsState = y.dtlsState));
|
|
1784
1791
|
}));
|
|
1785
1792
|
} catch (b) {
|
|
1786
|
-
|
|
1793
|
+
g.error("Error gathering connection state details:", b);
|
|
1787
1794
|
}
|
|
1788
1795
|
return f;
|
|
1789
1796
|
}));
|
|
@@ -1796,12 +1803,12 @@ class jt {
|
|
|
1796
1803
|
}
|
|
1797
1804
|
r === "failed" && j(x.PeerConnectionFailureError, { error: new Error(`Peer Connection failed. previous state: ${this._prevConnectionState}, current state: ${r}`), sessionId: this._session.sessionid }, this.options.id), this._prevConnectionState = r, this._isTrickleIce() && (r === "connecting" && performance.mark("peer-connection-connecting"), r === "connected" && (performance.mark("peer-connection-connected"), console.group("Performance Metrics"), console.table(this.trickleIcePerformanceMetrics), console.groupEnd(), performance.clearMarks()));
|
|
1798
1805
|
})), this._handleIceConnectionStateChange = () => {
|
|
1799
|
-
|
|
1806
|
+
g.debug(`[${(/* @__PURE__ */ new Date()).toISOString()}] ICE Connection State`, this.instance.iceConnectionState);
|
|
1800
1807
|
}, this._handleIceGatheringStateChange = () => {
|
|
1801
|
-
|
|
1808
|
+
g.debug(`[${(/* @__PURE__ */ new Date()).toISOString()}] ICE Gathering State`, this.instance.iceGatheringState);
|
|
1802
1809
|
}, this._setCodecs = (r, l) => {
|
|
1803
1810
|
if (r.setCodecPreferences) return r.setCodecPreferences(l);
|
|
1804
|
-
},
|
|
1811
|
+
}, g.debug("New Peer with type:", this.type, "Options:", this.options), this._constraints = { offerToReceiveAudio: !0, offerToReceiveVideo: !!t.video }, this._sdpReady = this._sdpReady.bind(this), this.handleSignalingStateChangeEvent = this.handleSignalingStateChangeEvent.bind(this), this.handleNegotiationNeededEvent = this.handleNegotiationNeededEvent.bind(this), this.handleTrackEvent = this.handleTrackEvent.bind(this), this.createPeerConnection = this.createPeerConnection.bind(this), this._session = i, this._trickleIceSdpFn = s, this._registerPeerEvents = o;
|
|
1805
1812
|
}
|
|
1806
1813
|
get isOffer() {
|
|
1807
1814
|
return this.type === z.Offer;
|
|
@@ -1830,28 +1837,28 @@ class jt {
|
|
|
1830
1837
|
}));
|
|
1831
1838
|
}
|
|
1832
1839
|
_logTransceivers() {
|
|
1833
|
-
this.instance ? (
|
|
1834
|
-
|
|
1835
|
-
}))) :
|
|
1840
|
+
this.instance ? (g.info("Number of transceivers:", this.instance.getTransceivers().length), this.instance.getTransceivers().forEach(((e, t) => {
|
|
1841
|
+
g.info(`>> Transceiver [${t}]:`, e.mid, e.direction, e.stopped), g.info(`>> Sender Params [${t}]:`, JSON.stringify(e.sender.getParameters(), null, 2));
|
|
1842
|
+
}))) : g.warn("Cannot log transceivers: peer connection is null");
|
|
1836
1843
|
}
|
|
1837
1844
|
get trickleIcePerformanceMetrics() {
|
|
1838
1845
|
const e = performance.measure("new-call", "new-call-start", "new-call-end"), t = performance.measure("peer-creation", "peer-creation-start", "peer-creation-end"), i = performance.measure("ice-gathering", "ice-gathering-start", "ice-gathering-end"), s = performance.measure("sdp-send", "sdp-send-start", "sdp-send-end"), o = performance.measure("invite-send", "new-call-start", "sdp-send-start"), r = performance.measure("total-duration", "peer-creation-start", "sdp-send-end"), l = (c) => `${c.toFixed(2)}ms`;
|
|
1839
1846
|
return { "New Call": { duration: l(e.duration) }, "Peer Creation": { duration: l(t.duration) }, "ICE Gathering": { duration: l(i.duration) }, [this._isOffer() ? "Invite Send" : "Answer Send"]: { duration: l(o.duration) }, "SDP Send": { duration: l(s.duration) }, "Total Duration": { duration: l(r.duration) } };
|
|
1840
1847
|
}
|
|
1841
1848
|
handleSignalingStateChangeEvent() {
|
|
1842
|
-
switch (
|
|
1849
|
+
switch (g.info("signalingState:", this.instance.signalingState), this.instance.signalingState) {
|
|
1843
1850
|
case "stable":
|
|
1844
1851
|
this._negotiating = !1;
|
|
1845
1852
|
break;
|
|
1846
1853
|
case "closed":
|
|
1847
|
-
j(x.PeerConnectionSignalingStateClosed, { sessionId: this._session.sessionid }, this.options.id), this.instance && (
|
|
1854
|
+
j(x.PeerConnectionSignalingStateClosed, { sessionId: this._session.sessionid }, this.options.id), this.instance && (g.debug(`[${this.options.id}] Closing peer due to signalingState closed`), this.close());
|
|
1848
1855
|
break;
|
|
1849
1856
|
default:
|
|
1850
1857
|
this._negotiating = !0;
|
|
1851
1858
|
}
|
|
1852
1859
|
}
|
|
1853
1860
|
handleNegotiationNeededEvent() {
|
|
1854
|
-
|
|
1861
|
+
g.info("Negotiation needed event"), this.instance.signalingState !== "stable" || this._negotiating ? g.debug("Skipping negotiation, state:", this.instance.signalingState, "negotiating:", this._negotiating) : this._isTrickleIce() ? this.startTrickleIceNegotiation() : this.startNegotiation();
|
|
1855
1862
|
}
|
|
1856
1863
|
handleTrackEvent(e) {
|
|
1857
1864
|
const { streams: [t] } = e, { remoteElement: i, screenShare: s } = this.options;
|
|
@@ -1862,32 +1869,26 @@ class jt {
|
|
|
1862
1869
|
var e;
|
|
1863
1870
|
this.instance = (e = this._config(), new window.RTCPeerConnection(e)), this.instance.onsignalingstatechange = this.handleSignalingStateChangeEvent, this.instance.onnegotiationneeded = this.handleNegotiationNeededEvent, this.instance.ontrack = this.handleTrackEvent, this.instance.addEventListener("connectionstatechange", this.handleConnectionStateChange), this.instance.addEventListener("iceconnectionstatechange", this._handleIceConnectionStateChange), this.instance.addEventListener("icegatheringstatechange", this._handleIceGatheringStateChange), this.instance.addEventListener("addstream", ((t) => {
|
|
1864
1871
|
this.options.remoteStream = t.stream;
|
|
1865
|
-
})), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: z.Offer })), this.options.localStream = yield this._retrieveLocalStream().catch(((t) => (j(x.MediaError, t, this.options.id), null))), this.options.mutedMicOnStart && ge(this.options.localStream) && (
|
|
1872
|
+
})), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: z.Offer })), this.options.localStream = yield this._retrieveLocalStream().catch(((t) => (j(x.MediaError, t, this.options.id), null))), this.options.mutedMicOnStart && ge(this.options.localStream) && (g.info("Muting local audio tracks on start"), rt(this.options.localStream)), this.options.localStream || (g.warn("No local media stream available"), !this.options.audio) ? performance.mark("peer-creation-end") : g.warn("Audio is required but no local stream — skipping negotiation");
|
|
1866
1873
|
}));
|
|
1867
1874
|
}
|
|
1868
1875
|
init() {
|
|
1869
1876
|
var e;
|
|
1870
1877
|
return O(this, void 0, void 0, (function* () {
|
|
1871
|
-
yield this.createPeerConnection(), this.isDebugEnabled && (this.statsReporter =
|
|
1878
|
+
yield this.createPeerConnection(), this.isDebugEnabled && (this.statsReporter = _i(this._session, this.options.id), yield (e = this.statsReporter) === null || e === void 0 ? void 0 : e.start(this.instance, this._session.sessionid, this._session.sessionid));
|
|
1872
1879
|
const { localElement: t, localStream: i = null, screenShare: s = !1 } = this.options;
|
|
1873
1880
|
if (ge(i)) {
|
|
1874
1881
|
const o = i.getAudioTracks();
|
|
1875
1882
|
let r = [...o];
|
|
1876
|
-
if (
|
|
1877
|
-
|
|
1883
|
+
if (g.info("Local audio tracks: ", o), typeof this.options.audio == "object" && o.forEach(((u) => {
|
|
1884
|
+
g.info("Local audio tracks constraints: ", u.getConstraints());
|
|
1878
1885
|
})), this.options.video) {
|
|
1879
1886
|
const u = i.getVideoTracks();
|
|
1880
|
-
r = [...o, ...u],
|
|
1881
|
-
|
|
1887
|
+
r = [...o, ...u], g.info("Local video tracks: ", u), typeof this.options.video == "object" && u.forEach(((p) => {
|
|
1888
|
+
g.info("Local video tracks constraints: ", p.getConstraints());
|
|
1882
1889
|
}));
|
|
1883
1890
|
}
|
|
1884
|
-
const { audioCodecs: l, videoCodecs: c } = (
|
|
1885
|
-
const p = [], f = [];
|
|
1886
|
-
return u && u.length !== 0 ? (u.forEach(((C) => {
|
|
1887
|
-
const b = C.mimeType.toLocaleLowerCase();
|
|
1888
|
-
b.startsWith("audio/") ? p.push(C) : b.startsWith("video/") && f.push(C);
|
|
1889
|
-
})), { audioCodecs: p, videoCodecs: f }) : { audioCodecs: p, videoCodecs: f };
|
|
1890
|
-
})(this.options.preferred_codecs);
|
|
1891
|
+
const { audioCodecs: l, videoCodecs: c } = Nt(this.options.preferred_codecs);
|
|
1891
1892
|
if (this.isOffer && typeof this.instance.addTransceiver == "function") {
|
|
1892
1893
|
const u = { direction: "sendrecv", streams: [i] };
|
|
1893
1894
|
r.forEach(((p) => {
|
|
@@ -1901,6 +1902,11 @@ class jt {
|
|
|
1901
1902
|
u.receiver.track.kind === "audio" && l.length > 0 && this._setCodecs(u, l), u.receiver.track.kind === "video" && c.length > 0 && this._setCodecs(u, c);
|
|
1902
1903
|
}))) : this.instance.addStream(i);
|
|
1903
1904
|
s === !1 && Ee(t, i);
|
|
1905
|
+
} else if (this.options.receiveOnlyAudio && typeof this.instance.addTransceiver == "function") {
|
|
1906
|
+
const o = this.instance.addTransceiver("audio", { direction: "recvonly" });
|
|
1907
|
+
g.info("Added recvonly audio transceiver for receive-only mode", o);
|
|
1908
|
+
const { audioCodecs: r } = Nt(this.options.preferred_codecs);
|
|
1909
|
+
r.length > 0 && this._setCodecs(o, r);
|
|
1904
1910
|
}
|
|
1905
1911
|
this.isOffer ? (this.options.negotiateAudio && this._checkMediaToNegotiate("audio"), this.options.negotiateVideo && this._checkMediaToNegotiate("video")) : this._isTrickleIce() || this.startNegotiation(), this._isTrickleIce() && this.startTrickleIceNegotiation(), this._logTransceivers();
|
|
1906
1912
|
}));
|
|
@@ -1911,37 +1917,37 @@ class jt {
|
|
|
1911
1917
|
_checkMediaToNegotiate(e) {
|
|
1912
1918
|
if (!this._getSenderByKind(e)) {
|
|
1913
1919
|
const t = this.instance.addTransceiver(e);
|
|
1914
|
-
|
|
1920
|
+
g.info("Add transceiver", e, t);
|
|
1915
1921
|
}
|
|
1916
1922
|
}
|
|
1917
1923
|
_createOffer() {
|
|
1918
1924
|
return O(this, void 0, void 0, (function* () {
|
|
1919
1925
|
if (this._isOffer()) {
|
|
1920
|
-
this._constraints.offerToReceiveAudio = this.options.audio !== !1, this._constraints.offerToReceiveVideo = !!this.options.video,
|
|
1926
|
+
this._constraints.offerToReceiveAudio = this.options.audio !== !1 || !!this.options.receiveOnlyAudio, this._constraints.offerToReceiveVideo = !!this.options.video, g.info("_createOffer - this._constraints", this._constraints);
|
|
1921
1927
|
try {
|
|
1922
1928
|
const e = yield this.instance.createOffer(this._constraints);
|
|
1923
1929
|
return yield this._setLocalDescription(e), this._isTrickleIce() || this._sdpReady(), e;
|
|
1924
1930
|
} catch (e) {
|
|
1925
|
-
|
|
1931
|
+
g.error("Peer _createOffer error:", e);
|
|
1926
1932
|
}
|
|
1927
1933
|
}
|
|
1928
1934
|
}));
|
|
1929
1935
|
}
|
|
1930
1936
|
_setRemoteDescription(e) {
|
|
1931
1937
|
return O(this, void 0, void 0, (function* () {
|
|
1932
|
-
|
|
1938
|
+
g.debug("Setting remote description", e), yield this.instance.setRemoteDescription(e);
|
|
1933
1939
|
}));
|
|
1934
1940
|
}
|
|
1935
1941
|
_createAnswer() {
|
|
1936
1942
|
return O(this, void 0, void 0, (function* () {
|
|
1937
1943
|
if (this._isAnswer()) {
|
|
1938
|
-
if (this.instance.signalingState !== "stable" && this.instance.signalingState !== "have-remote-offer") return
|
|
1944
|
+
if (this.instance.signalingState !== "stable" && this.instance.signalingState !== "have-remote-offer") return g.debug("Skipping negotiation, state:", this.instance.signalingState), g.debug(" - But the signaling state isn't stable, so triggering rollback"), void (yield Promise.all([this.instance.setLocalDescription({ type: "rollback" }), this.instance.setRemoteDescription({ sdp: this.options.remoteSdp, type: z.Offer })]));
|
|
1939
1945
|
this._logTransceivers();
|
|
1940
1946
|
try {
|
|
1941
1947
|
const e = yield this.instance.createAnswer();
|
|
1942
1948
|
return yield this._setLocalDescription(e), e;
|
|
1943
1949
|
} catch (e) {
|
|
1944
|
-
|
|
1950
|
+
g.error("Peer _createAnswer error:", e);
|
|
1945
1951
|
}
|
|
1946
1952
|
}
|
|
1947
1953
|
}));
|
|
@@ -1977,11 +1983,11 @@ class jt {
|
|
|
1977
1983
|
}
|
|
1978
1984
|
_config() {
|
|
1979
1985
|
const { prefetchIceCandidates: e, forceRelayCandidate: t, iceServers: i } = this.options, s = { bundlePolicy: "balanced", iceCandidatePoolSize: e ? 10 : 0, iceServers: i, iceTransportPolicy: t ? "relay" : "all" };
|
|
1980
|
-
return
|
|
1986
|
+
return g.info("RTC config", s), s;
|
|
1981
1987
|
}
|
|
1982
1988
|
restartStatsReporter() {
|
|
1983
1989
|
return O(this, void 0, void 0, (function* () {
|
|
1984
|
-
this.isDebugEnabled && this.statsReporter && (this.instance ? this.statsReporter.isRunning ?
|
|
1990
|
+
this.isDebugEnabled && this.statsReporter && (this.instance ? this.statsReporter.isRunning ? g.debug(`[${this.options.id}] Stats reporter already running, skipping restart`) : (g.debug(`[${this.options.id}] Restarting stats reporter after reconnect`), yield this.statsReporter.start(this.instance, this._session.sessionid, this._session.sessionid)) : g.debug(`[${this.options.id}] Cannot restart stats reporter - no peer connection instance`));
|
|
1985
1991
|
}));
|
|
1986
1992
|
}
|
|
1987
1993
|
close() {
|
|
@@ -1991,7 +1997,7 @@ class jt {
|
|
|
1991
1997
|
}
|
|
1992
1998
|
}
|
|
1993
1999
|
const Me = gt;
|
|
1994
|
-
class
|
|
2000
|
+
class gn {
|
|
1995
2001
|
constructor(e, t, i = !1) {
|
|
1996
2002
|
this.session = e, this._isRecovering = i, this._callReportCollector = null, this.id = "", this.state = N[N.New], this.prevState = "", this.channels = [], this.role = it.Participant, this.extension = null, this._state = N.New, this._prevState = N.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._pendingIceCandidates = [], this._isRemoteDescriptionSet = !1, this._signalingStateClosed = !1, this._creatingPeer = !1, this._checkConferenceSerno = (w) => {
|
|
1997
2003
|
const R = w < 0 || !this._lastSerno || this._lastSerno && w === this._lastSerno + 1;
|
|
@@ -2010,8 +2016,8 @@ class fn {
|
|
|
2010
2016
|
}));
|
|
2011
2017
|
}));
|
|
2012
2018
|
};
|
|
2013
|
-
const { iceServers: s, speaker: o, micId: r, micLabel: l, camId: c, camLabel: u, localElement: p, remoteElement: f, options: C, mediaConstraints: { audio: b, video: y }, ringtoneFile: I, ringbackFile:
|
|
2014
|
-
this.options = Object.assign({},
|
|
2019
|
+
const { iceServers: s, speaker: o, micId: r, micLabel: l, camId: c, camLabel: u, localElement: p, remoteElement: f, options: C, mediaConstraints: { audio: b, video: y }, ringtoneFile: I, ringbackFile: v } = e;
|
|
2020
|
+
this.options = Object.assign({}, Jn, { audio: b, video: y, iceServers: t?.iceServers && Array.isArray(t.iceServers) ? t.iceServers : s, localElement: p, remoteElement: f, micId: r, micLabel: l, camId: c, camLabel: u, speakerId: o, ringtoneFile: I, ringbackFile: v, debug: C.debug, debugOutput: C.debugOutput, trickleIce: C.trickleIce, prefetchIceCandidates: C.prefetchIceCandidates, forceRelayCandidate: C.forceRelayCandidate, keepConnectionAliveOnSocketClose: C.keepConnectionAliveOnSocketClose, mutedMicOnStart: C.mutedMicOnStart }, t), this._onMediaError = this._onMediaError.bind(this), this._onPeerConnectionFailureError = this._onPeerConnectionFailureError.bind(this), this._onPeerConnectionSignalingStateClosed = this._onPeerConnectionSignalingStateClosed.bind(this), this._onTrickleIceSdp = this._onTrickleIceSdp.bind(this), this._registerPeerEvents = this._registerPeerEvents.bind(this), this._registerTrickleIcePeerEvents = this._registerTrickleIcePeerEvents.bind(this), this._init(), this.options && (this._ringtone = Mt(this.options.ringtoneFile, "_ringtone"), this._ringback = Mt(this.options.ringbackFile, "_ringback"));
|
|
2015
2021
|
}
|
|
2016
2022
|
get creatingPeer() {
|
|
2017
2023
|
return this._creatingPeer;
|
|
@@ -2045,17 +2051,17 @@ class fn {
|
|
|
2045
2051
|
return `conference-member.${this.id}`;
|
|
2046
2052
|
}
|
|
2047
2053
|
get isAudioMuted() {
|
|
2048
|
-
return !
|
|
2054
|
+
return !hi(this.options.localStream);
|
|
2049
2055
|
}
|
|
2050
2056
|
invite() {
|
|
2051
2057
|
return O(this, void 0, void 0, (function* () {
|
|
2052
|
-
this._creatingPeer = !0, this.direction = re.Outbound, this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("peer-creation-start"), this.peer = new
|
|
2058
|
+
this._creatingPeer = !0, this.direction = re.Outbound, this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("peer-creation-start"), this.peer = new Ut(z.Offer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents), yield this.peer.init(), this._creatingPeer = !1;
|
|
2053
2059
|
}));
|
|
2054
2060
|
}
|
|
2055
2061
|
answer(e = {}) {
|
|
2056
2062
|
var t;
|
|
2057
2063
|
return O(this, void 0, void 0, (function* () {
|
|
2058
|
-
this._creatingPeer = !0, performance.mark("new-call-start"), this.stopRingtone(), this.direction = re.Inbound, ((t = e?.customHeaders) === null || t === void 0 ? void 0 : t.length) > 0 && (this.options = Object.assign(Object.assign({}, this.options), { customHeaders: e.customHeaders })), this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("peer-creation-start"), this.peer = new
|
|
2064
|
+
this._creatingPeer = !0, performance.mark("new-call-start"), this.stopRingtone(), this.direction = re.Inbound, ((t = e?.customHeaders) === null || t === void 0 ? void 0 : t.length) > 0 && (this.options = Object.assign(Object.assign({}, this.options), { customHeaders: e.customHeaders })), this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("peer-creation-start"), this.peer = new Ut(z.Answer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents), yield this.peer.init(), performance.mark("new-call-end"), this._creatingPeer = !1;
|
|
2059
2065
|
}));
|
|
2060
2066
|
}
|
|
2061
2067
|
playRingtone() {
|
|
@@ -2077,12 +2083,12 @@ class fn {
|
|
|
2077
2083
|
this.setState(N.Hangup);
|
|
2078
2084
|
const u = () => {
|
|
2079
2085
|
var p;
|
|
2080
|
-
|
|
2086
|
+
g.debug(`[${this.id}] Closing peer from hangup`), (p = this.peer) === null || p === void 0 || p.close(), this.setState(N.Destroy);
|
|
2081
2087
|
};
|
|
2082
2088
|
if (this.stopRingtone(), this.stopRingback(), l) {
|
|
2083
|
-
const p = new
|
|
2089
|
+
const p = new ni({ sipCode: this.sipCode, sip_call_id: this.sipCallId, sessid: this.session.sessionid, dialogParams: this.options, cause: this.cause, causeCode: this.causeCode });
|
|
2084
2090
|
this._execute(p).catch(((f) => {
|
|
2085
|
-
|
|
2091
|
+
g.error("telnyx_rtc.bye failed!", f), j(x.Error, { error: f, sessionId: this.session.sessionid }, this.session.uuid);
|
|
2086
2092
|
})).then(u.bind(this));
|
|
2087
2093
|
} else u();
|
|
2088
2094
|
}
|
|
@@ -2160,16 +2166,16 @@ class fn {
|
|
|
2160
2166
|
}
|
|
2161
2167
|
setBandwidthEncodingsMaxBps(e, t) {
|
|
2162
2168
|
return O(this, void 0, void 0, (function* () {
|
|
2163
|
-
if (!this || !this.peer) return void
|
|
2169
|
+
if (!this || !this.peer) return void g.error("Could not set bandwidth (reason: no peer connection). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
|
|
2164
2170
|
const { instance: i } = this.peer, s = i.getSenders();
|
|
2165
|
-
if (!s) return void
|
|
2171
|
+
if (!s) return void g.error("Could not set bandwidth (reason: no senders). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
|
|
2166
2172
|
const o = s.find((({ track: { kind: r } }) => r === t));
|
|
2167
2173
|
if (o) {
|
|
2168
2174
|
const r = o.getParameters();
|
|
2169
|
-
r.encodings || (r.encodings = [{ rid: "h" }]),
|
|
2170
|
-
|
|
2171
|
-
})).catch(((l) =>
|
|
2172
|
-
} else
|
|
2175
|
+
r.encodings || (r.encodings = [{ rid: "h" }]), g.info("Parameters: ", r), g.info("Setting max ", t === "audio" ? "audio" : "video", " bandwidth to: ", e, " [bps]"), r.encodings[0].maxBitrate = e, yield o.setParameters(r).then((() => {
|
|
2176
|
+
g.info(t === "audio" ? "New audio" : "New video", " bandwidth settings in use: ", o.getParameters());
|
|
2177
|
+
})).catch(((l) => g.error(l)));
|
|
2178
|
+
} else g.error("Could not set bandwidth (reason: no " + t + " sender). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
|
|
2173
2179
|
}));
|
|
2174
2180
|
}
|
|
2175
2181
|
setAudioBandwidthEncodingsMaxBps(e) {
|
|
@@ -2185,14 +2191,14 @@ class fn {
|
|
|
2185
2191
|
}
|
|
2186
2192
|
setState(e) {
|
|
2187
2193
|
var t;
|
|
2188
|
-
switch (this._prevState = this._state, this._state = e, this.state = N[this._state].toLowerCase(), this.prevState = N[this._prevState].toLowerCase(),
|
|
2194
|
+
switch (this._prevState = this._state, this._state = e, this.state = N[this._state].toLowerCase(), this.prevState = N[this._prevState].toLowerCase(), g.debug(`Call ${this.id} state change from ${this.prevState} to ${this.state}`), this._dispatchNotification({ type: se.callUpdate, call: this }), e) {
|
|
2189
2195
|
case N.Purge:
|
|
2190
|
-
|
|
2196
|
+
g.debug(`Call ${this.id} hangup call due to purge state`), this.hangup({ cause: "PURGE", causeCode: 1 }, !1);
|
|
2191
2197
|
break;
|
|
2192
2198
|
case N.Active:
|
|
2193
|
-
this._isRecovering && (this._isRecovering = !1,
|
|
2199
|
+
this._isRecovering && (this._isRecovering = !1, g.debug(`[${this.id}] Recovery complete, call is active`)), setTimeout((() => {
|
|
2194
2200
|
const { remoteElement: i, speakerId: s } = this.options;
|
|
2195
|
-
i && s &&
|
|
2201
|
+
i && s && hn(i, s);
|
|
2196
2202
|
}), 0), this._callReportCollector && (!((t = this.peer) === null || t === void 0) && t.instance) && this.session.callReportId && this._callReportCollector.start(this.peer.instance);
|
|
2197
2203
|
break;
|
|
2198
2204
|
case N.Destroy:
|
|
@@ -2202,41 +2208,41 @@ class fn {
|
|
|
2202
2208
|
handleMessage(e) {
|
|
2203
2209
|
const { method: t, params: i } = e;
|
|
2204
2210
|
switch (t) {
|
|
2205
|
-
case
|
|
2206
|
-
if (this.gotAnswer = !0, this._state >= N.Active) return;
|
|
2211
|
+
case F.Answer:
|
|
2212
|
+
if (this.gotAnswer = !0, i.telnyx_call_control_id && (this.options.telnyxCallControlId = i.telnyx_call_control_id), i.telnyx_session_id && (this.options.telnyxSessionId = i.telnyx_session_id), i.telnyx_leg_id && (this.options.telnyxLegId = i.telnyx_leg_id), this._state >= N.Active) return;
|
|
2207
2213
|
this._state >= N.Early && this.setState(N.Active), this.gotEarly || this._onRemoteSdp(i.sdp), this.stopRingback(), this.stopRingtone();
|
|
2208
2214
|
break;
|
|
2209
|
-
case
|
|
2215
|
+
case F.Media:
|
|
2210
2216
|
if (this._state >= N.Early) return;
|
|
2211
2217
|
this.gotEarly = !0, this._onRemoteSdp(i.sdp);
|
|
2212
2218
|
break;
|
|
2213
|
-
case
|
|
2219
|
+
case F.Display: {
|
|
2214
2220
|
const { display_name: o, display_number: r, display_direction: l } = i;
|
|
2215
2221
|
this.extension = r;
|
|
2216
2222
|
const c = l === re.Inbound ? re.Outbound : re.Inbound, u = { type: se[t], call: this, displayName: o, displayNumber: r, displayDirection: c };
|
|
2217
2223
|
j(x.Notification, u, this.id) || j(x.Notification, u, this.session.uuid);
|
|
2218
2224
|
break;
|
|
2219
2225
|
}
|
|
2220
|
-
case
|
|
2226
|
+
case F.Candidate:
|
|
2221
2227
|
this._addIceCandidate(i);
|
|
2222
2228
|
break;
|
|
2223
|
-
case
|
|
2224
|
-
case
|
|
2229
|
+
case F.Info:
|
|
2230
|
+
case F.Event: {
|
|
2225
2231
|
const o = Object.assign(Object.assign({}, i), { type: se.generic, call: this });
|
|
2226
2232
|
j(x.Notification, o, this.id) || j(x.Notification, o, this.session.uuid);
|
|
2227
2233
|
break;
|
|
2228
2234
|
}
|
|
2229
|
-
case
|
|
2235
|
+
case F.Ringing:
|
|
2230
2236
|
this.playRingback(), i.telnyx_call_control_id && (this.options.telnyxCallControlId = i.telnyx_call_control_id), i.telnyx_session_id && (this.options.telnyxSessionId = i.telnyx_session_id), i.telnyx_leg_id && (this.options.telnyxLegId = i.telnyx_leg_id);
|
|
2231
2237
|
break;
|
|
2232
|
-
case
|
|
2238
|
+
case F.Bye:
|
|
2233
2239
|
const s = i.client_state || i.clientState;
|
|
2234
2240
|
s && (this.options.clientState = s), this.stopRingback(), this.stopRingtone(), this.hangup(i, !1);
|
|
2235
2241
|
}
|
|
2236
2242
|
}
|
|
2237
2243
|
handleConferenceUpdate(e, t) {
|
|
2238
2244
|
return O(this, void 0, void 0, (function* () {
|
|
2239
|
-
if (!this._checkConferenceSerno(e.wireSerno) && e.name !== t.laName) return
|
|
2245
|
+
if (!this._checkConferenceSerno(e.wireSerno) && e.name !== t.laName) return g.error("ConferenceUpdate invalid wireSerno or packet name:", e), "INVALID_PACKET";
|
|
2240
2246
|
const { action: i, data: s, hashKey: o = String(this._lastSerno), arrIndex: r } = e;
|
|
2241
2247
|
switch (i) {
|
|
2242
2248
|
case "bootObj": {
|
|
@@ -2276,7 +2282,7 @@ class fn {
|
|
|
2276
2282
|
const { direction: o, from: r, fromDisplay: l, message: c, type: u } = s.data;
|
|
2277
2283
|
this._dispatchConferenceUpdate({ action: ie.ChatMessage, direction: o, participantNumber: r, participantName: l, messageText: c, messageType: u, messageId: s.eventSerno });
|
|
2278
2284
|
} }, i = yield this.session.vertoSubscribe(t).catch(((s) => {
|
|
2279
|
-
|
|
2285
|
+
g.error("ConfChat subscription error:", s);
|
|
2280
2286
|
}));
|
|
2281
2287
|
st(i, e) && (this._addChannel(e), Object.defineProperties(this, { sendChatMessage: { configurable: !0, value: (s, o) => {
|
|
2282
2288
|
this.session.vertoBroadcast({ nodeId: this.nodeId, channel: e, data: { action: "send", message: s, type: o } });
|
|
@@ -2287,9 +2293,9 @@ class fn {
|
|
|
2287
2293
|
return O(this, void 0, void 0, (function* () {
|
|
2288
2294
|
const t = { nodeId: this.nodeId, channels: [e], handler: (s) => {
|
|
2289
2295
|
const { eventData: o } = s;
|
|
2290
|
-
o.contentType === "layout-info" ? (o.callID = this.id,
|
|
2296
|
+
o.contentType === "layout-info" ? (o.callID = this.id, fn(this.session, o)) : g.error("Conference-Info unknown contentType", s);
|
|
2291
2297
|
} }, i = yield this.session.vertoSubscribe(t).catch(((s) => {
|
|
2292
|
-
|
|
2298
|
+
g.error("ConfInfo subscription error:", s);
|
|
2293
2299
|
}));
|
|
2294
2300
|
st(i, e) && this._addChannel(e);
|
|
2295
2301
|
}));
|
|
@@ -2302,7 +2308,7 @@ class fn {
|
|
|
2302
2308
|
return e.holdState === "active" ? this.setState(N.Active) : this.setState(N.Held), !0;
|
|
2303
2309
|
}
|
|
2304
2310
|
_handleChangeHoldStateError(e) {
|
|
2305
|
-
return
|
|
2311
|
+
return g.error(`Failed to ${e.action} on call ${this.id}`), !1;
|
|
2306
2312
|
}
|
|
2307
2313
|
_onRemoteSdp(e) {
|
|
2308
2314
|
return O(this, void 0, void 0, (function* () {
|
|
@@ -2310,7 +2316,7 @@ class fn {
|
|
|
2310
2316
|
yield this.peer.instance.setRemoteDescription(t).then((() => {
|
|
2311
2317
|
this.options.trickleIce && (this._isRemoteDescriptionSet = !0, this._flushPendingTrickleIceCandidates()), this.gotEarly && this.setState(N.Early), this.gotAnswer && this.setState(N.Active);
|
|
2312
2318
|
})).catch(((i) => {
|
|
2313
|
-
|
|
2319
|
+
g.error("Call setRemoteDescription Error: ", i), this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
|
|
2314
2320
|
}));
|
|
2315
2321
|
}));
|
|
2316
2322
|
}
|
|
@@ -2321,7 +2327,7 @@ class fn {
|
|
|
2321
2327
|
var t, i;
|
|
2322
2328
|
this._iceTimeout && clearTimeout(this._iceTimeout), this._iceTimeout = null, this._iceDone = !0;
|
|
2323
2329
|
const { sdp: s, type: o } = e;
|
|
2324
|
-
if (s.indexOf("candidate") === -1) return
|
|
2330
|
+
if (s.indexOf("candidate") === -1) return g.info(`No candidate - retry
|
|
2325
2331
|
`), void this._requestAnotherLocalDescription();
|
|
2326
2332
|
(i = (t = this.peer) === null || t === void 0 ? void 0 : t.instance) === null || i === void 0 || i.removeEventListener("icecandidate", this._onIce), performance.mark("ice-gathering-end");
|
|
2327
2333
|
let r = null;
|
|
@@ -2334,19 +2340,19 @@ class fn {
|
|
|
2334
2340
|
this._isRecovering || this.setState(N.Answering), r = this.options.attach === !0 ? new Rt(l) : new Tt(l);
|
|
2335
2341
|
break;
|
|
2336
2342
|
default:
|
|
2337
|
-
return
|
|
2343
|
+
return g.error(`${this.id} - Unknown local SDP type:`, e), this.hangup({}, !1);
|
|
2338
2344
|
}
|
|
2339
2345
|
performance.mark("sdp-send-start"), this._execute(r).then(((c) => {
|
|
2340
2346
|
const { node_id: u = null } = c;
|
|
2341
2347
|
this._targetNodeId = u, o === z.Offer ? this.setState(N.Trying) : this.setState(N.Active);
|
|
2342
2348
|
})).catch(((c) => {
|
|
2343
|
-
|
|
2349
|
+
g.error(`${this.id} - Sending ${o} error:`, c), this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
|
|
2344
2350
|
})).finally((() => {
|
|
2345
2351
|
performance.mark("sdp-send-end"), console.group("Performance Metrics"), console.table(this.performanceMetrics), console.groupEnd(), performance.clearMarks();
|
|
2346
2352
|
}));
|
|
2347
2353
|
}
|
|
2348
2354
|
_onTrickleIceSdp(e) {
|
|
2349
|
-
if (!e) return
|
|
2355
|
+
if (!e) return g.error("No SDP data provided"), this.hangup({}, !1);
|
|
2350
2356
|
const { sdp: t, type: i } = e;
|
|
2351
2357
|
let s = null;
|
|
2352
2358
|
const o = { sessid: this.session.sessionid, sdp: t, dialogParams: this.options, trickle: !0, "User-Agent": `Web-${Me}` };
|
|
@@ -2358,42 +2364,46 @@ class fn {
|
|
|
2358
2364
|
this._isRecovering || this.setState(N.Answering), s = this.options.attach === !0 ? new Rt(o) : new Tt(o);
|
|
2359
2365
|
break;
|
|
2360
2366
|
default:
|
|
2361
|
-
return
|
|
2367
|
+
return g.error(`${this.id} - Unknown local SDP type:`, e), this.hangup({}, !1);
|
|
2362
2368
|
}
|
|
2363
2369
|
performance.mark("sdp-send-start"), this._execute(s).then(((r) => {
|
|
2364
2370
|
const { node_id: l = null } = r;
|
|
2365
2371
|
this._targetNodeId = l, i === z.Offer ? this.setState(N.Trying) : this.setState(N.Active);
|
|
2366
2372
|
})).catch(((r) => {
|
|
2367
|
-
|
|
2373
|
+
g.error(`${this.id} - Sending ${i} error:`, r), this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
|
|
2368
2374
|
})).finally((() => {
|
|
2369
2375
|
performance.mark("sdp-send-end");
|
|
2370
2376
|
}));
|
|
2371
2377
|
}
|
|
2372
2378
|
_onIce(e) {
|
|
2373
2379
|
const { instance: t } = this.peer;
|
|
2374
|
-
this._iceTimeout === null
|
|
2380
|
+
if (this._iceTimeout === null) {
|
|
2381
|
+
const i = this.options.attach ? 5e3 : 1e3;
|
|
2382
|
+
this._iceTimeout = setTimeout((() => this._onIceSdp(t.localDescription)), i);
|
|
2383
|
+
}
|
|
2384
|
+
e.candidate ? g.debug("RTCPeer Candidate:", e.candidate) : this._onIceSdp(t.localDescription);
|
|
2375
2385
|
}
|
|
2376
2386
|
_onTrickleIce(e) {
|
|
2377
|
-
e.candidate && e.candidate.candidate ? (
|
|
2387
|
+
e.candidate && e.candidate.candidate ? (g.debug("RTCPeer Candidate:", e.candidate), this._sendIceCandidate(e.candidate)) : this._sendEndOfCandidates();
|
|
2378
2388
|
}
|
|
2379
2389
|
_sendIceCandidate(e) {
|
|
2380
|
-
const t = new
|
|
2390
|
+
const t = new ii({ sessid: this.session.sessionid, candidate: e.candidate, sdpMLineIndex: e.sdpMLineIndex, sdpMid: e.sdpMid, dialogParams: this.options });
|
|
2381
2391
|
this._execute(t);
|
|
2382
2392
|
}
|
|
2383
2393
|
_addIceCandidate(e) {
|
|
2384
|
-
if (!this._isRemoteDescriptionSet) return
|
|
2394
|
+
if (!this._isRemoteDescriptionSet) return g.debug("Remote description not set. Queued ICE candidate.", e), void this._pendingIceCandidates.push(e);
|
|
2385
2395
|
this._addIceCandidateToPeer(e);
|
|
2386
2396
|
}
|
|
2387
2397
|
_addIceCandidateToPeer(e) {
|
|
2388
2398
|
const t = this.peer.instance.addIceCandidate(e);
|
|
2389
2399
|
Promise.resolve(t).then((() => {
|
|
2390
|
-
|
|
2400
|
+
g.debug("Successfully added ICE candidate:", e);
|
|
2391
2401
|
})).catch(((i) => {
|
|
2392
|
-
|
|
2402
|
+
g.error("Failed to add ICE candidate:", i, e);
|
|
2393
2403
|
}));
|
|
2394
2404
|
}
|
|
2395
2405
|
_sendEndOfCandidates() {
|
|
2396
|
-
const e = new
|
|
2406
|
+
const e = new si({ sessid: this.session.sessionid, endOfCandidates: !0, dialogParams: this.options });
|
|
2397
2407
|
this._execute(e), performance.mark("ice-gathering-end");
|
|
2398
2408
|
}
|
|
2399
2409
|
_resetTrickleIceCandidateState() {
|
|
@@ -2411,8 +2421,8 @@ class fn {
|
|
|
2411
2421
|
this._iceDone || this._onIce(t);
|
|
2412
2422
|
}, e.onicecandidateerror = (t) => {
|
|
2413
2423
|
var i;
|
|
2414
|
-
if (
|
|
2415
|
-
const s =
|
|
2424
|
+
if (g.debug("ICE candidate error:", t), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
|
|
2425
|
+
const s = jt(t, e);
|
|
2416
2426
|
this.peer.statsReporter.reportIceCandidateError(s);
|
|
2417
2427
|
}
|
|
2418
2428
|
}, e.addEventListener("addstream", ((t) => {
|
|
@@ -2427,11 +2437,11 @@ class fn {
|
|
|
2427
2437
|
e.onicecandidate = (t) => {
|
|
2428
2438
|
this._onTrickleIce(t);
|
|
2429
2439
|
}, e.onicegatheringstatechange = (t) => {
|
|
2430
|
-
|
|
2440
|
+
g.debug("ICE gathering state changed:", e.iceGatheringState), e.iceGatheringState === "complete" && g.debug("Finished gathering candidates");
|
|
2431
2441
|
}, e.onicecandidateerror = (t) => {
|
|
2432
2442
|
var i;
|
|
2433
|
-
if (
|
|
2434
|
-
const s =
|
|
2443
|
+
if (g.debug("ICE candidate error:", t), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
|
|
2444
|
+
const s = jt(t, e);
|
|
2435
2445
|
this.peer.statsReporter.reportIceCandidateError(s);
|
|
2436
2446
|
}
|
|
2437
2447
|
}, e.addEventListener("addstream", ((t) => {
|
|
@@ -2444,13 +2454,13 @@ class fn {
|
|
|
2444
2454
|
}
|
|
2445
2455
|
_onMediaError(e) {
|
|
2446
2456
|
const t = e?.name || "UnknownError", i = e?.message || "Unknown media error";
|
|
2447
|
-
this._dispatchNotification({ type: se.userMediaError, error: e, call: this, errorName: t, errorMessage: i }),
|
|
2457
|
+
this._dispatchNotification({ type: se.userMediaError, error: e, call: this, errorName: t, errorMessage: i }), g.error(`Media error (${t}): ${i}`, e), this.hangup({}, !1);
|
|
2448
2458
|
}
|
|
2449
2459
|
_onPeerConnectionFailureError(e) {
|
|
2450
|
-
this._dispatchNotification({ type: se.peerConnectionFailureError, error: e }),
|
|
2460
|
+
this._dispatchNotification({ type: se.peerConnectionFailureError, error: e }), g.error("Peer connection failure error");
|
|
2451
2461
|
}
|
|
2452
2462
|
_onPeerConnectionSignalingStateClosed(e) {
|
|
2453
|
-
this._signalingStateClosed = !0, this._dispatchNotification(Object.assign({ type: se.signalingStateClosed }, e)),
|
|
2463
|
+
this._signalingStateClosed = !0, this._dispatchNotification(Object.assign({ type: se.signalingStateClosed }, e)), g.debug("Peer connection signaling state closed, call is not recoverable");
|
|
2454
2464
|
}
|
|
2455
2465
|
_dispatchConferenceUpdate(e) {
|
|
2456
2466
|
this._dispatchNotification(Object.assign({ type: se.conferenceUpdate, call: this }, e));
|
|
@@ -2468,42 +2478,42 @@ class fn {
|
|
|
2468
2478
|
const r = this.session.options.enableCallReports !== !1, l = this.session.options.callReportInterval || 5e3, c = this.session.options.debugLogLevel || "debug", u = this.session.options.debugLogMaxEntries || 1e3;
|
|
2469
2479
|
r && (this._callReportCollector = new ce({ enabled: !0, interval: l }, { enabled: !0, level: c, maxEntries: u }), this._callReportCollector.onFlushNeeded = () => {
|
|
2470
2480
|
this._flushIntermediateReport();
|
|
2471
|
-
}), this._isRecovering ? this.setState(N.Recovering) : this.setState(N.New),
|
|
2481
|
+
}), this._isRecovering ? this.setState(N.Recovering) : this.setState(N.New), g.info("New Call with Options:", this.options);
|
|
2472
2482
|
}
|
|
2473
2483
|
_finalize() {
|
|
2474
2484
|
var e;
|
|
2475
|
-
this._stopStats(),
|
|
2485
|
+
this._stopStats(), g.debug(`[${this.id}] Closing peer from _finalize`), (e = this.peer) === null || e === void 0 || e.close();
|
|
2476
2486
|
const { remoteStream: t, localStream: i } = this.options;
|
|
2477
2487
|
Te(t), Te(i), ue(x.MediaError, null, this.id), ue(x.PeerConnectionFailureError, null, this.id), ue(x.PeerConnectionSignalingStateClosed, null, this.id), this.session.calls[this.id] = null, delete this.session.calls[this.id], this._postCallReport().catch(((s) => {
|
|
2478
|
-
|
|
2488
|
+
g.error("Unexpected error in _postCallReport", { error: s });
|
|
2479
2489
|
}));
|
|
2480
2490
|
}
|
|
2481
2491
|
_flushIntermediateReport() {
|
|
2482
2492
|
var e;
|
|
2483
2493
|
if (!this._callReportCollector) return;
|
|
2484
2494
|
const t = this.session.callReportId;
|
|
2485
|
-
if (!t) return void
|
|
2495
|
+
if (!t) return void g.debug("Cannot flush intermediate report: call_report_id not available");
|
|
2486
2496
|
const i = (e = this.session.connection) === null || e === void 0 ? void 0 : e.host;
|
|
2487
|
-
if (!i) return void
|
|
2497
|
+
if (!i) return void g.debug("Cannot flush intermediate report: connection host not available");
|
|
2488
2498
|
const s = { callId: this.id, destinationNumber: this.options.destinationNumber, callerNumber: this.options.callerNumber, direction: this.direction === re.Inbound ? "inbound" : "outbound", state: this.state, telnyxSessionId: this.options.telnyxSessionId, telnyxLegId: this.options.telnyxLegId, sdkVersion: Me }, o = this._callReportCollector.flush(s);
|
|
2489
2499
|
if (!o) return;
|
|
2490
2500
|
const r = he() || void 0;
|
|
2491
2501
|
this._callReportCollector.sendPayload(o, t, i, r).catch(((l) => {
|
|
2492
|
-
|
|
2502
|
+
g.error("Failed to post intermediate call report segment", { error: l });
|
|
2493
2503
|
}));
|
|
2494
2504
|
}
|
|
2495
2505
|
_postCallReport() {
|
|
2496
2506
|
var e;
|
|
2497
2507
|
return O(this, void 0, void 0, (function* () {
|
|
2498
|
-
if (!this._callReportCollector) return void
|
|
2508
|
+
if (!this._callReportCollector) return void g.warn("Call report collector not initialized");
|
|
2499
2509
|
yield this._callReportCollector.stop();
|
|
2500
2510
|
const t = this.session.callReportId;
|
|
2501
|
-
if (!t) return
|
|
2511
|
+
if (!t) return g.debug("Cannot post call report: call_report_id not available"), void this._callReportCollector.cleanup();
|
|
2502
2512
|
const i = { callId: this.id, destinationNumber: this.options.destinationNumber, callerNumber: this.options.callerNumber, direction: this.direction === re.Inbound ? "inbound" : "outbound", state: this.state, telnyxSessionId: this.options.telnyxSessionId, telnyxLegId: this.options.telnyxLegId, sdkVersion: Me }, s = (e = this.session.connection) === null || e === void 0 ? void 0 : e.host;
|
|
2503
|
-
if (!s) return void
|
|
2513
|
+
if (!s) return void g.error("Cannot post call report: connection host not available");
|
|
2504
2514
|
const o = he() || void 0;
|
|
2505
2515
|
this._callReportCollector.postReport(i, t, s, o).catch(((r) => {
|
|
2506
|
-
|
|
2516
|
+
g.error("Failed to post call report", { error: r });
|
|
2507
2517
|
})).finally((() => {
|
|
2508
2518
|
var r;
|
|
2509
2519
|
(r = this._callReportCollector) === null || r === void 0 || r.cleanup();
|
|
@@ -2511,13 +2521,13 @@ class fn {
|
|
|
2511
2521
|
}));
|
|
2512
2522
|
}
|
|
2513
2523
|
_startStats(e) {
|
|
2514
|
-
this._statsIntervalId = setInterval(this._doStats, e),
|
|
2524
|
+
this._statsIntervalId = setInterval(this._doStats, e), g.info("Stats started");
|
|
2515
2525
|
}
|
|
2516
2526
|
_stopStats() {
|
|
2517
|
-
this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null),
|
|
2527
|
+
this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null), g.debug("Stats stopped");
|
|
2518
2528
|
}
|
|
2519
2529
|
}
|
|
2520
|
-
|
|
2530
|
+
gn.setStateTelnyx = (n) => {
|
|
2521
2531
|
if (n) {
|
|
2522
2532
|
switch (n._state) {
|
|
2523
2533
|
case N.Recovering:
|
|
@@ -2547,9 +2557,9 @@ fn.setStateTelnyx = (n) => {
|
|
|
2547
2557
|
return n;
|
|
2548
2558
|
}
|
|
2549
2559
|
};
|
|
2550
|
-
class pe extends
|
|
2560
|
+
class pe extends gn {
|
|
2551
2561
|
constructor() {
|
|
2552
|
-
super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, t) => this.session.execute(new
|
|
2562
|
+
super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, t) => this.session.execute(new fi(e, t));
|
|
2553
2563
|
}
|
|
2554
2564
|
hangup(e = {}, t = !0) {
|
|
2555
2565
|
this.screenShare instanceof pe && this.screenShare.hangup(e, t), super.hangup(e, t);
|
|
@@ -2574,7 +2584,7 @@ class pe extends fn {
|
|
|
2574
2584
|
return O(this, void 0, void 0, (function* () {
|
|
2575
2585
|
this.options.speakerId = e;
|
|
2576
2586
|
const { remoteElement: t, speakerId: i } = this.options;
|
|
2577
|
-
return !(!t || !i) &&
|
|
2587
|
+
return !(!t || !i) && hn(t, i);
|
|
2578
2588
|
}));
|
|
2579
2589
|
}
|
|
2580
2590
|
_finalize() {
|
|
@@ -2593,11 +2603,11 @@ ${r.type}
|
|
|
2593
2603
|
o.includes(l) || (i += ` ${l}: ${r[l]}
|
|
2594
2604
|
`);
|
|
2595
2605
|
})));
|
|
2596
|
-
})),
|
|
2606
|
+
})), g.info(i);
|
|
2597
2607
|
}))), 2e3);
|
|
2598
2608
|
}
|
|
2599
2609
|
}
|
|
2600
|
-
class
|
|
2610
|
+
class wi extends li {
|
|
2601
2611
|
constructor(e) {
|
|
2602
2612
|
super(e), this.calls = {}, this.autoRecoverCalls = !0, this._iceServers = [], this._localElement = null, this._remoteElement = null, this._jwtAuth = !0, this._audioConstraints = !0, this._previousAudioConstraints = !0, this._videoConstraints = !1, this._speaker = null, this._onlineHandler = null, this._offlineHandler = null, this._wasOffline = !1, this._videoConstraints = e.video || !1, this.iceServers = e.iceServers, this.ringtoneFile = e.ringtoneFile, this.ringbackFile = e.ringbackFile, this._setupNetworkListeners();
|
|
2603
2613
|
}
|
|
@@ -2643,7 +2653,7 @@ class Ci extends ci {
|
|
|
2643
2653
|
}
|
|
2644
2654
|
speedTest(e) {
|
|
2645
2655
|
return new Promise(((t, i) => {
|
|
2646
|
-
if (
|
|
2656
|
+
if (cn(x.SpeedTest, ((r) => {
|
|
2647
2657
|
const { upDur: l, downDur: c } = r, u = c ? 8 * e / (c / 1e3) / 1024 : 0;
|
|
2648
2658
|
t({ upDur: l, downDur: c, upKps: (l ? 8 * e / (l / 1e3) / 1024 : 0).toFixed(0), downKps: u.toFixed(0) });
|
|
2649
2659
|
}), this.uuid), !(e = Number(e))) return i(`Invalid parameter 'bytes': ${e}`);
|
|
@@ -2665,7 +2675,7 @@ class Ci extends ci {
|
|
|
2665
2675
|
return Ie(ae.AudioIn).catch(((e) => (j(x.MediaError, e, this.uuid), [])));
|
|
2666
2676
|
}
|
|
2667
2677
|
getAudioOutDevices() {
|
|
2668
|
-
return Ie(ae.AudioOut).catch(((e) => (
|
|
2678
|
+
return Ie(ae.AudioOut).catch(((e) => (g.error("getAudioOutDevices", e), j(x.MediaError, e, this.uuid), [])));
|
|
2669
2679
|
}
|
|
2670
2680
|
validateDeviceId(e, t, i) {
|
|
2671
2681
|
return Ve(e, t, i);
|
|
@@ -2693,7 +2703,7 @@ class Ci extends ci {
|
|
|
2693
2703
|
return O(this, void 0, void 0, (function* () {
|
|
2694
2704
|
if (!e) throw new Error("You need to provide the settings object");
|
|
2695
2705
|
const { micId: t, micLabel: i } = e, s = Ne(e, ["micId", "micLabel"]);
|
|
2696
|
-
return
|
|
2706
|
+
return ui(s), this._audioConstraints = yield ((o, r, l, c) => O(void 0, void 0, void 0, (function* () {
|
|
2697
2707
|
const { deviceId: u } = c;
|
|
2698
2708
|
if (u === void 0 && (o || r)) {
|
|
2699
2709
|
const p = yield Ve(o, r, l).catch(((f) => null));
|
|
@@ -2713,7 +2723,7 @@ class Ci extends ci {
|
|
|
2713
2723
|
if (e && Array.isArray(e)) this._iceServers = e;
|
|
2714
2724
|
else {
|
|
2715
2725
|
const t = this.options.env === "development";
|
|
2716
|
-
this._iceServers = t ?
|
|
2726
|
+
this._iceServers = t ? $n : Fn;
|
|
2717
2727
|
}
|
|
2718
2728
|
}
|
|
2719
2729
|
get iceServers() {
|
|
@@ -2739,13 +2749,13 @@ class Ci extends ci {
|
|
|
2739
2749
|
}
|
|
2740
2750
|
vertoBroadcast({ nodeId: e, channel: t = "", data: i }) {
|
|
2741
2751
|
if (!t) throw new Error(`Invalid channel for broadcast: ${t}`);
|
|
2742
|
-
const s = new
|
|
2752
|
+
const s = new oi({ sessid: this.sessionid, eventChannel: t, data: i });
|
|
2743
2753
|
e && (s.targetNodeId = e), this.execute(s).catch(((o) => o));
|
|
2744
2754
|
}
|
|
2745
2755
|
vertoSubscribe({ nodeId: e, channels: t = [], handler: i }) {
|
|
2746
2756
|
return O(this, void 0, void 0, (function* () {
|
|
2747
2757
|
if (!(t = t.filter(((c) => c && !this._existsSubscription(this.relayProtocol, c)))).length) return {};
|
|
2748
|
-
const s = new
|
|
2758
|
+
const s = new ri({ sessid: this.sessionid, eventChannel: t });
|
|
2749
2759
|
e && (s.targetNodeId = e);
|
|
2750
2760
|
const o = yield this.execute(s), { unauthorized: r = [], subscribed: l = [] } = ot(o);
|
|
2751
2761
|
return r.length && r.forEach(((c) => this._removeSubscription(this.relayProtocol, c))), l.forEach(((c) => this._addSubscription(this.relayProtocol, i, c))), o;
|
|
@@ -2754,7 +2764,7 @@ class Ci extends ci {
|
|
|
2754
2764
|
vertoUnsubscribe({ nodeId: e, channels: t = [] }) {
|
|
2755
2765
|
return O(this, void 0, void 0, (function* () {
|
|
2756
2766
|
if (!(t = t.filter(((l) => l && this._existsSubscription(this.relayProtocol, l)))).length) return {};
|
|
2757
|
-
const i = new
|
|
2767
|
+
const i = new ai({ sessid: this.sessionid, eventChannel: t });
|
|
2758
2768
|
e && (i.targetNodeId = e);
|
|
2759
2769
|
const s = yield this.execute(i), { unsubscribed: o = [], notSubscribed: r = [] } = ot(s);
|
|
2760
2770
|
return o.forEach(((l) => this._removeSubscription(this.relayProtocol, l))), r.forEach(((l) => this._removeSubscription(this.relayProtocol, l))), s;
|
|
@@ -2762,9 +2772,9 @@ class Ci extends ci {
|
|
|
2762
2772
|
}
|
|
2763
2773
|
_setupNetworkListeners() {
|
|
2764
2774
|
typeof window < "u" && (this._onlineHandler = () => {
|
|
2765
|
-
this._wasOffline && (
|
|
2775
|
+
this._wasOffline && (g.debug(`Network connectivity restored for session ${this.sessionid}. Reconnecting...`), this._wasOffline = !1, this._autoReconnect = !0, this.socketDisconnect());
|
|
2766
2776
|
}, this._offlineHandler = () => {
|
|
2767
|
-
this._wasOffline = !0,
|
|
2777
|
+
this._wasOffline = !0, g.debug(`Network connectivity lost for session ${this.sessionid}`);
|
|
2768
2778
|
}, window.addEventListener("online", this._onlineHandler), window.addEventListener("offline", this._offlineHandler));
|
|
2769
2779
|
}
|
|
2770
2780
|
_cleanupNetworkListeners() {
|
|
@@ -2774,21 +2784,21 @@ class Ci extends ci {
|
|
|
2774
2784
|
return pe.setStateTelnyx(e);
|
|
2775
2785
|
}
|
|
2776
2786
|
}
|
|
2777
|
-
class
|
|
2787
|
+
class Ft {
|
|
2778
2788
|
constructor(e, t) {
|
|
2779
2789
|
this.code = t, this.message = e;
|
|
2780
2790
|
}
|
|
2781
2791
|
}
|
|
2782
|
-
class
|
|
2792
|
+
class Ii {
|
|
2783
2793
|
constructor(e) {
|
|
2784
2794
|
this.session = e, this.retriedConnect = 0, this.retriedRegister = 0, this.receivedAuthenticationRequired = 0;
|
|
2785
2795
|
}
|
|
2786
2796
|
_ack(e, t) {
|
|
2787
|
-
const i = new
|
|
2797
|
+
const i = new ti(e, t);
|
|
2788
2798
|
this.nodeId && (i.targetNodeId = this.nodeId), this.session.execute(i);
|
|
2789
2799
|
}
|
|
2790
2800
|
reconnectDelay() {
|
|
2791
|
-
return 1e3 *
|
|
2801
|
+
return 1e3 * rn(2, 6);
|
|
2792
2802
|
}
|
|
2793
2803
|
handleMessage(e) {
|
|
2794
2804
|
var t, i, s;
|
|
@@ -2796,54 +2806,54 @@ class wi {
|
|
|
2796
2806
|
if (C === "channelPvtData") return this._handlePvtEvent(c.pvtData);
|
|
2797
2807
|
const I = (R = !1) => {
|
|
2798
2808
|
var T, A, D, W, B, M;
|
|
2799
|
-
const a = { audio: !0, video: o.options.video, remoteSdp: c.sdp, destinationNumber: c.callee_id_number, remoteCallerName: c.caller_id_name, remoteCallerNumber: c.caller_id_number, callerName: c.callee_id_name, callerNumber: c.callee_id_number, attach: l ===
|
|
2809
|
+
const a = { audio: !0, video: o.options.video, remoteSdp: c.sdp, destinationNumber: c.callee_id_number, remoteCallerName: c.caller_id_name, remoteCallerNumber: c.caller_id_number, callerName: c.callee_id_name, callerNumber: c.callee_id_number, attach: l === F.Attach, mediaSettings: c.mediaSettings, debug: (T = o.options.debug) !== null && T !== void 0 && T, debugOutput: (A = o.options.debugOutput) !== null && A !== void 0 ? A : "socket", trickleIce: l !== F.Attach && (D = o.options.trickleIce) !== null && D !== void 0 && D, prefetchIceCandidates: (W = o.options.prefetchIceCandidates) === null || W === void 0 || W, forceRelayCandidate: (B = o.options.forceRelayCandidate) !== null && B !== void 0 && B, keepConnectionAliveOnSocketClose: (M = o.options.keepConnectionAliveOnSocketClose) !== null && M !== void 0 && M };
|
|
2800
2810
|
p && (a.id = p), c.telnyx_call_control_id && (a.telnyxCallControlId = c.telnyx_call_control_id), c.telnyx_session_id && (a.telnyxSessionId = c.telnyx_session_id), c.telnyx_leg_id && (a.telnyxLegId = c.telnyx_leg_id), c.client_state && (a.clientState = c.client_state), c.dialogParams && c.dialogParams.custom_headers && c.dialogParams.custom_headers.length && (a.customHeaders = c.dialogParams.custom_headers);
|
|
2801
2811
|
const d = new pe(o, a, R);
|
|
2802
2812
|
return d.nodeId = this.nodeId, d;
|
|
2803
|
-
},
|
|
2813
|
+
}, v = new ln(u), w = new dn(u);
|
|
2804
2814
|
switch (l) {
|
|
2805
|
-
case
|
|
2806
|
-
case
|
|
2807
|
-
case
|
|
2808
|
-
case
|
|
2809
|
-
case
|
|
2810
|
-
case
|
|
2811
|
-
if (!p || !b) return void
|
|
2815
|
+
case F.Answer:
|
|
2816
|
+
case F.Display:
|
|
2817
|
+
case F.Candidate:
|
|
2818
|
+
case F.Ringing:
|
|
2819
|
+
case F.Bye:
|
|
2820
|
+
case F.Media:
|
|
2821
|
+
if (!p || !b) return void g.error(`Received ${l} for non existing call:`, c);
|
|
2812
2822
|
b.handleMessage(e), this._ack(r, l);
|
|
2813
2823
|
break;
|
|
2814
|
-
case
|
|
2824
|
+
case F.Ping:
|
|
2815
2825
|
this.session.setPingReceived(), this.session.execute(w).then((() => {
|
|
2816
2826
|
this.receivedAuthenticationRequired = 0;
|
|
2817
2827
|
})).catch(((A) => O(this, void 0, void 0, (function* () {
|
|
2818
|
-
A.code === this.session.authenticationRequiredErrorCode && this.receivedAuthenticationRequired >= 0 && (this.receivedAuthenticationRequired += 1, this.receivedAuthenticationRequired > 1 && this.session.hasAutoReconnect() && (
|
|
2828
|
+
A.code === this.session.authenticationRequiredErrorCode && this.receivedAuthenticationRequired >= 0 && (this.receivedAuthenticationRequired += 1, this.receivedAuthenticationRequired > 1 && this.session.hasAutoReconnect() && (g.warn("Ping failed twice with Authentication Required. Re-logging in..."), this.session.login(), this.receivedAuthenticationRequired = -1));
|
|
2819
2829
|
}))));
|
|
2820
2830
|
break;
|
|
2821
|
-
case
|
|
2822
|
-
o.options.keepConnectionAliveOnSocketClose && y ? (
|
|
2831
|
+
case F.Punt:
|
|
2832
|
+
o.options.keepConnectionAliveOnSocketClose && y ? (g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${p}] keeping session calls alive due to PUNT and keepConnectionAliveOnSocketClose. Disconnecting base session...`), o.socketDisconnect(), this._ack(r, l)) : o.disconnect();
|
|
2823
2833
|
break;
|
|
2824
|
-
case
|
|
2834
|
+
case F.Invite: {
|
|
2825
2835
|
const A = I();
|
|
2826
2836
|
A.direction = re.Inbound, A.playRingtone(), A.setState(N.Ringing), this._ack(r, l);
|
|
2827
2837
|
break;
|
|
2828
2838
|
}
|
|
2829
|
-
case
|
|
2839
|
+
case F.Attach: {
|
|
2830
2840
|
if (!b)
|
|
2831
2841
|
return I().answer(), void this._ack(r, l);
|
|
2832
2842
|
const A = !!b;
|
|
2833
|
-
|
|
2843
|
+
g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${p}] closing existing call on ATTACH.`), b.hangup({ isRecovering: A }, !1), g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${p}] Attach: Creating new call for recovery`), I(A).answer(), this._ack(r, l);
|
|
2834
2844
|
break;
|
|
2835
2845
|
}
|
|
2836
|
-
case
|
|
2846
|
+
case F.Event:
|
|
2837
2847
|
case "webrtc.event":
|
|
2838
|
-
if (!f) return void
|
|
2848
|
+
if (!f) return void g.error("Verto received an unknown event:", c);
|
|
2839
2849
|
const R = o.relayProtocol, T = f.split(".")[0];
|
|
2840
2850
|
o._existsSubscription(R, f) ? j(R, c, f) : f === o.sessionid ? this._handleSessionEvent(c.eventData) : o._existsSubscription(R, T) ? j(R, c, T) : o.calls.hasOwnProperty(f) ? o.calls[f].handleMessage(e) : j(x.Notification, c, o.uuid);
|
|
2841
2851
|
break;
|
|
2842
|
-
case
|
|
2852
|
+
case F.Info:
|
|
2843
2853
|
c.type = se.generic, j(x.Notification, c, o.uuid);
|
|
2844
2854
|
break;
|
|
2845
|
-
case
|
|
2846
|
-
this.session.execute(
|
|
2855
|
+
case F.ClientReady:
|
|
2856
|
+
this.session.execute(v);
|
|
2847
2857
|
break;
|
|
2848
2858
|
default: {
|
|
2849
2859
|
const A = pt(e);
|
|
@@ -2854,24 +2864,24 @@ class wi {
|
|
|
2854
2864
|
if (o.connection.previousGatewayState !== ee.REGED && o.connection.previousGatewayState !== ee.REGISTER) {
|
|
2855
2865
|
this.session._triggerKeepAliveTimeoutCheck(), this.retriedRegister = 0;
|
|
2856
2866
|
const D = (s = (i = e?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.call_report_id;
|
|
2857
|
-
D && (o.callReportId = D,
|
|
2867
|
+
D && (o.callReportId = D, g.debug("Captured call_report_id from REGED:", D)), c.type = se.vertoClientReady, j(x.Ready, c, o.uuid);
|
|
2858
2868
|
}
|
|
2859
2869
|
break;
|
|
2860
2870
|
case ee.UNREGED:
|
|
2861
2871
|
case ee.NOREG:
|
|
2862
2872
|
if (this.retriedRegister += 1, this.retriedRegister === 5) {
|
|
2863
|
-
this.retriedRegister = 0, j(x.Error, { error: new
|
|
2873
|
+
this.retriedRegister = 0, j(x.Error, { error: new Ft("Fail to register the user, the server tried 5 times", "UNREGED|NOREG"), sessionId: o.sessionid }, o.uuid);
|
|
2864
2874
|
break;
|
|
2865
2875
|
}
|
|
2866
2876
|
setTimeout((() => {
|
|
2867
|
-
this.session.execute(
|
|
2877
|
+
this.session.execute(v);
|
|
2868
2878
|
}), this.reconnectDelay());
|
|
2869
2879
|
break;
|
|
2870
2880
|
case ee.FAILED:
|
|
2871
2881
|
case ee.FAIL_WAIT:
|
|
2872
2882
|
if (o.connection.previousGatewayState !== ee.FAILED && o.connection.previousGatewayState !== ee.FAIL_WAIT) {
|
|
2873
2883
|
if (!this.session.hasAutoReconnect()) {
|
|
2874
|
-
this.retriedConnect = 0, j(x.Error, { error: new
|
|
2884
|
+
this.retriedConnect = 0, j(x.Error, { error: new Ft("Fail to connect the server, the server tried 5 times", "FAILED|FAIL_WAIT"), sessionId: o.sessionid }, o.uuid);
|
|
2875
2885
|
break;
|
|
2876
2886
|
}
|
|
2877
2887
|
if (this.retriedConnect += 1, this.retriedConnect === 5) {
|
|
@@ -2879,12 +2889,12 @@ class wi {
|
|
|
2879
2889
|
break;
|
|
2880
2890
|
}
|
|
2881
2891
|
setTimeout((() => {
|
|
2882
|
-
if (
|
|
2892
|
+
if (g.debug(`Reconnecting... Retry ${this.retriedConnect} of 5`), this.session.options.keepConnectionAliveOnSocketClose) {
|
|
2883
2893
|
if (Object.values(o.calls).some(((W) => {
|
|
2884
2894
|
var B;
|
|
2885
2895
|
return ((B = W.peer) === null || B === void 0 ? void 0 : B.instance) && !W.signalingStateClosed;
|
|
2886
|
-
}))) return
|
|
2887
|
-
|
|
2896
|
+
}))) return g.debug("Reconnecting by keeping the existing session due to keepConnectionAliveOnSocketClose option being set."), void this.session.socketDisconnect();
|
|
2897
|
+
g.debug("keepConnectionAliveOnSocketClose is set but all peer connections have signalingState closed, doing full reconnect");
|
|
2888
2898
|
}
|
|
2889
2899
|
this.session.disconnect().then((() => {
|
|
2890
2900
|
this.session.clearConnection(), this.session.connect();
|
|
@@ -2893,11 +2903,11 @@ class wi {
|
|
|
2893
2903
|
}
|
|
2894
2904
|
break;
|
|
2895
2905
|
default:
|
|
2896
|
-
|
|
2906
|
+
g.warn("GatewayState message unknown method:", e);
|
|
2897
2907
|
}
|
|
2898
2908
|
break;
|
|
2899
2909
|
}
|
|
2900
|
-
|
|
2910
|
+
g.debug("Verto message unknown method:", e);
|
|
2901
2911
|
break;
|
|
2902
2912
|
}
|
|
2903
2913
|
}
|
|
@@ -2917,16 +2927,16 @@ class wi {
|
|
|
2917
2927
|
case "conference-liveArray-join": {
|
|
2918
2928
|
const b = () => {
|
|
2919
2929
|
t.vertoBroadcast({ nodeId: this.nodeId, channel: o, data: { liveArray: { command: "bootstrap", context: o, name: r } } });
|
|
2920
|
-
}, y = { nodeId: this.nodeId, channels: [o], handler: ({ data:
|
|
2921
|
-
const w = C || this._retrieveCallId(
|
|
2930
|
+
}, y = { nodeId: this.nodeId, channels: [o], handler: ({ data: v }) => {
|
|
2931
|
+
const w = C || this._retrieveCallId(v, o);
|
|
2922
2932
|
if (w && t.calls.hasOwnProperty(w)) {
|
|
2923
2933
|
const R = t.calls[w];
|
|
2924
|
-
R._addChannel(o), R.extension = r, R.handleConferenceUpdate(
|
|
2934
|
+
R._addChannel(o), R.extension = r, R.handleConferenceUpdate(v, e).then(((T) => {
|
|
2925
2935
|
T === "INVALID_PACKET" && b();
|
|
2926
2936
|
}));
|
|
2927
2937
|
}
|
|
2928
|
-
} }, I = yield t.vertoSubscribe(y).catch(((
|
|
2929
|
-
|
|
2938
|
+
} }, I = yield t.vertoSubscribe(y).catch(((v) => {
|
|
2939
|
+
g.error("liveArray subscription error:", v);
|
|
2930
2940
|
}));
|
|
2931
2941
|
st(I, o) && b();
|
|
2932
2942
|
break;
|
|
@@ -2936,15 +2946,15 @@ class wi {
|
|
|
2936
2946
|
if (o && t._existsSubscription(i, o)) {
|
|
2937
2947
|
const { callId: I = null } = t.subscriptions[i][o];
|
|
2938
2948
|
if (b = t.calls[I] || null, I !== null) {
|
|
2939
|
-
const
|
|
2940
|
-
j(x.Notification,
|
|
2949
|
+
const v = { type: se.conferenceUpdate, action: ie.Leave, conferenceName: r, participantId: Number(p), role: f };
|
|
2950
|
+
j(x.Notification, v, I, !1) || j(x.Notification, v, t.uuid), b === null && ue(x.Notification, null, I);
|
|
2941
2951
|
}
|
|
2942
2952
|
}
|
|
2943
2953
|
const y = [o, l, c, u];
|
|
2944
2954
|
t.vertoUnsubscribe({ nodeId: this.nodeId, channels: y }).then((({ unsubscribedChannels: I = [] }) => {
|
|
2945
|
-
b && (b.channels = b.channels.filter(((
|
|
2955
|
+
b && (b.channels = b.channels.filter(((v) => !I.includes(v))));
|
|
2946
2956
|
})).catch(((I) => {
|
|
2947
|
-
|
|
2957
|
+
g.error("liveArray unsubscribe error:", I);
|
|
2948
2958
|
}));
|
|
2949
2959
|
break;
|
|
2950
2960
|
}
|
|
@@ -2955,7 +2965,7 @@ class wi {
|
|
|
2955
2965
|
switch (e.contentType) {
|
|
2956
2966
|
case "layout-info":
|
|
2957
2967
|
case "layer-info":
|
|
2958
|
-
|
|
2968
|
+
fn(this.session, e);
|
|
2959
2969
|
break;
|
|
2960
2970
|
case "logo-info": {
|
|
2961
2971
|
const t = { type: se.conferenceUpdate, action: ie.LogoInfo, logo: e.logoURL };
|
|
@@ -2965,7 +2975,7 @@ class wi {
|
|
|
2965
2975
|
}
|
|
2966
2976
|
}
|
|
2967
2977
|
}
|
|
2968
|
-
class
|
|
2978
|
+
class ki extends wi {
|
|
2969
2979
|
constructor(e) {
|
|
2970
2980
|
super(e), this.relayProtocol = "verto-protocol", this.timeoutErrorCode = -329990, this.handleLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
|
|
2971
2981
|
this._idle = !1;
|
|
@@ -2975,9 +2985,9 @@ class Ii extends Ci {
|
|
|
2975
2985
|
} });
|
|
2976
2986
|
})), this.handleAnonymousLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
|
|
2977
2987
|
this._idle = !1, yield this.login();
|
|
2978
|
-
})), this._vertoHandler = new
|
|
2988
|
+
})), this._vertoHandler = new Ii(this), window.addEventListener("beforeunload", ((t) => {
|
|
2979
2989
|
this.calls && Object.keys(this.calls).forEach(((i) => {
|
|
2980
|
-
this.calls[i] && (
|
|
2990
|
+
this.calls[i] && (g.info(`Hanging up call due to window unload: ${i}`), this.calls[i].hangup({}, !0));
|
|
2981
2991
|
}));
|
|
2982
2992
|
}));
|
|
2983
2993
|
}
|
|
@@ -3011,26 +3021,26 @@ class Ii extends Ci {
|
|
|
3011
3021
|
this._vertoHandler.handleMessage(e);
|
|
3012
3022
|
}
|
|
3013
3023
|
}
|
|
3014
|
-
class
|
|
3024
|
+
class Ei extends ki {
|
|
3015
3025
|
constructor(e) {
|
|
3016
|
-
super(e),
|
|
3026
|
+
super(e), g.info(`SDK version: ${un}`);
|
|
3017
3027
|
}
|
|
3018
3028
|
newCall(e) {
|
|
3019
3029
|
return super.newCall(e);
|
|
3020
3030
|
}
|
|
3021
3031
|
static webRTCInfo() {
|
|
3022
|
-
return
|
|
3032
|
+
return pi();
|
|
3023
3033
|
}
|
|
3024
3034
|
static webRTCSupportedBrowserList() {
|
|
3025
3035
|
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 }] }];
|
|
3026
3036
|
}
|
|
3027
3037
|
}
|
|
3028
|
-
function
|
|
3038
|
+
function vn(n) {
|
|
3029
3039
|
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
3030
3040
|
}
|
|
3031
|
-
var tt = { exports: {} },
|
|
3032
|
-
function
|
|
3033
|
-
return
|
|
3041
|
+
var tt = { exports: {} }, $t;
|
|
3042
|
+
function Ti() {
|
|
3043
|
+
return $t || ($t = 1, (function(n) {
|
|
3034
3044
|
var e = Object.prototype.hasOwnProperty, t = "~";
|
|
3035
3045
|
function i() {
|
|
3036
3046
|
}
|
|
@@ -3069,45 +3079,45 @@ function Ei() {
|
|
|
3069
3079
|
}, l.prototype.emit = function(u, p, f, C, b, y) {
|
|
3070
3080
|
var I = t ? t + u : u;
|
|
3071
3081
|
if (!this._events[I]) return !1;
|
|
3072
|
-
var
|
|
3073
|
-
if (
|
|
3074
|
-
switch (
|
|
3082
|
+
var v = this._events[I], w = arguments.length, R, T;
|
|
3083
|
+
if (v.fn) {
|
|
3084
|
+
switch (v.once && this.removeListener(u, v.fn, void 0, !0), w) {
|
|
3075
3085
|
case 1:
|
|
3076
|
-
return
|
|
3086
|
+
return v.fn.call(v.context), !0;
|
|
3077
3087
|
case 2:
|
|
3078
|
-
return
|
|
3088
|
+
return v.fn.call(v.context, p), !0;
|
|
3079
3089
|
case 3:
|
|
3080
|
-
return
|
|
3090
|
+
return v.fn.call(v.context, p, f), !0;
|
|
3081
3091
|
case 4:
|
|
3082
|
-
return
|
|
3092
|
+
return v.fn.call(v.context, p, f, C), !0;
|
|
3083
3093
|
case 5:
|
|
3084
|
-
return
|
|
3094
|
+
return v.fn.call(v.context, p, f, C, b), !0;
|
|
3085
3095
|
case 6:
|
|
3086
|
-
return
|
|
3096
|
+
return v.fn.call(v.context, p, f, C, b, y), !0;
|
|
3087
3097
|
}
|
|
3088
3098
|
for (T = 1, R = new Array(w - 1); T < w; T++)
|
|
3089
3099
|
R[T - 1] = arguments[T];
|
|
3090
|
-
|
|
3100
|
+
v.fn.apply(v.context, R);
|
|
3091
3101
|
} else {
|
|
3092
|
-
var A =
|
|
3102
|
+
var A = v.length, D;
|
|
3093
3103
|
for (T = 0; T < A; T++)
|
|
3094
|
-
switch (
|
|
3104
|
+
switch (v[T].once && this.removeListener(u, v[T].fn, void 0, !0), w) {
|
|
3095
3105
|
case 1:
|
|
3096
|
-
|
|
3106
|
+
v[T].fn.call(v[T].context);
|
|
3097
3107
|
break;
|
|
3098
3108
|
case 2:
|
|
3099
|
-
|
|
3109
|
+
v[T].fn.call(v[T].context, p);
|
|
3100
3110
|
break;
|
|
3101
3111
|
case 3:
|
|
3102
|
-
|
|
3112
|
+
v[T].fn.call(v[T].context, p, f);
|
|
3103
3113
|
break;
|
|
3104
3114
|
case 4:
|
|
3105
|
-
|
|
3115
|
+
v[T].fn.call(v[T].context, p, f, C);
|
|
3106
3116
|
break;
|
|
3107
3117
|
default:
|
|
3108
3118
|
if (!R) for (D = 1, R = new Array(w - 1); D < w; D++)
|
|
3109
3119
|
R[D - 1] = arguments[D];
|
|
3110
|
-
|
|
3120
|
+
v[T].fn.apply(v[T].context, R);
|
|
3111
3121
|
}
|
|
3112
3122
|
}
|
|
3113
3123
|
return !0;
|
|
@@ -3124,9 +3134,9 @@ function Ei() {
|
|
|
3124
3134
|
if (y.fn)
|
|
3125
3135
|
y.fn === p && (!C || y.once) && (!f || y.context === f) && r(this, b);
|
|
3126
3136
|
else {
|
|
3127
|
-
for (var I = 0,
|
|
3128
|
-
(y[I].fn !== p || C && !y[I].once || f && y[I].context !== f) &&
|
|
3129
|
-
|
|
3137
|
+
for (var I = 0, v = [], w = y.length; I < w; I++)
|
|
3138
|
+
(y[I].fn !== p || C && !y[I].once || f && y[I].context !== f) && v.push(y[I]);
|
|
3139
|
+
v.length ? this._events[b] = v.length === 1 ? v[0] : v : r(this, b);
|
|
3130
3140
|
}
|
|
3131
3141
|
return this;
|
|
3132
3142
|
}, l.prototype.removeAllListeners = function(u) {
|
|
@@ -3135,14 +3145,14 @@ function Ei() {
|
|
|
3135
3145
|
}, l.prototype.off = l.prototype.removeListener, l.prototype.addListener = l.prototype.on, l.prefixed = t, l.EventEmitter = l, n.exports = l;
|
|
3136
3146
|
})(tt)), tt.exports;
|
|
3137
3147
|
}
|
|
3138
|
-
var
|
|
3139
|
-
const vt = /* @__PURE__ */
|
|
3140
|
-
var De = { exports: {} },
|
|
3141
|
-
function
|
|
3142
|
-
return
|
|
3148
|
+
var Ri = Ti();
|
|
3149
|
+
const vt = /* @__PURE__ */ vn(Ri), Ge = new vt();
|
|
3150
|
+
var De = { exports: {} }, Ai = De.exports, Bt;
|
|
3151
|
+
function xi() {
|
|
3152
|
+
return Bt || (Bt = 1, (function(n) {
|
|
3143
3153
|
(function(e, t) {
|
|
3144
3154
|
n.exports ? n.exports = t() : e.log = t();
|
|
3145
|
-
})(
|
|
3155
|
+
})(Ai, function() {
|
|
3146
3156
|
var e = function() {
|
|
3147
3157
|
}, t = "undefined", i = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), s = [
|
|
3148
3158
|
"trace",
|
|
@@ -3151,8 +3161,8 @@ function Ai() {
|
|
|
3151
3161
|
"warn",
|
|
3152
3162
|
"error"
|
|
3153
3163
|
], o = {}, r = null;
|
|
3154
|
-
function l(I,
|
|
3155
|
-
var w = I[
|
|
3164
|
+
function l(I, v) {
|
|
3165
|
+
var w = I[v];
|
|
3156
3166
|
if (typeof w.bind == "function")
|
|
3157
3167
|
return w.bind(I);
|
|
3158
3168
|
try {
|
|
@@ -3170,9 +3180,9 @@ function Ai() {
|
|
|
3170
3180
|
return I === "debug" && (I = "log"), typeof console === t ? !1 : I === "trace" && i ? c : console[I] !== void 0 ? l(console, I) : console.log !== void 0 ? l(console, "log") : e;
|
|
3171
3181
|
}
|
|
3172
3182
|
function p() {
|
|
3173
|
-
for (var I = this.getLevel(),
|
|
3174
|
-
var w = s[
|
|
3175
|
-
this[w] =
|
|
3183
|
+
for (var I = this.getLevel(), v = 0; v < s.length; v++) {
|
|
3184
|
+
var w = s[v];
|
|
3185
|
+
this[w] = v < I ? e : this.methodFactory(w, I, this.name);
|
|
3176
3186
|
}
|
|
3177
3187
|
if (this.log = this.debug, typeof console === t && I < this.levels.SILENT)
|
|
3178
3188
|
return "No console available for logging";
|
|
@@ -3182,10 +3192,10 @@ function Ai() {
|
|
|
3182
3192
|
typeof console !== t && (p.call(this), this[I].apply(this, arguments));
|
|
3183
3193
|
};
|
|
3184
3194
|
}
|
|
3185
|
-
function C(I,
|
|
3195
|
+
function C(I, v, w) {
|
|
3186
3196
|
return u(I) || f.apply(this, arguments);
|
|
3187
3197
|
}
|
|
3188
|
-
function b(I,
|
|
3198
|
+
function b(I, v) {
|
|
3189
3199
|
var w = this, R, T, A, D = "loglevel";
|
|
3190
3200
|
typeof I == "string" ? D += ":" + I : typeof I == "symbol" && (D = void 0);
|
|
3191
3201
|
function W(h) {
|
|
@@ -3245,7 +3255,7 @@ function Ai() {
|
|
|
3245
3255
|
WARN: 3,
|
|
3246
3256
|
ERROR: 4,
|
|
3247
3257
|
SILENT: 5
|
|
3248
|
-
}, w.methodFactory =
|
|
3258
|
+
}, w.methodFactory = v || C, w.getLevel = function() {
|
|
3249
3259
|
return A ?? T ?? R;
|
|
3250
3260
|
}, w.setLevel = function(h, m) {
|
|
3251
3261
|
return A = a(h), m !== !1 && W(A), p.call(w);
|
|
@@ -3267,12 +3277,12 @@ function Ai() {
|
|
|
3267
3277
|
var d = B();
|
|
3268
3278
|
d != null && (A = a(d)), p.call(w);
|
|
3269
3279
|
}
|
|
3270
|
-
r = new b(), r.getLogger = function(
|
|
3271
|
-
if (typeof
|
|
3280
|
+
r = new b(), r.getLogger = function(v) {
|
|
3281
|
+
if (typeof v != "symbol" && typeof v != "string" || v === "")
|
|
3272
3282
|
throw new TypeError("You must supply a name when creating a logger.");
|
|
3273
|
-
var w = o[
|
|
3274
|
-
return w || (w = o[
|
|
3275
|
-
|
|
3283
|
+
var w = o[v];
|
|
3284
|
+
return w || (w = o[v] = new b(
|
|
3285
|
+
v,
|
|
3276
3286
|
r.methodFactory
|
|
3277
3287
|
)), w;
|
|
3278
3288
|
};
|
|
@@ -3285,24 +3295,24 @@ function Ai() {
|
|
|
3285
3295
|
});
|
|
3286
3296
|
})(De)), De.exports;
|
|
3287
3297
|
}
|
|
3288
|
-
var
|
|
3289
|
-
const
|
|
3298
|
+
var Li = xi();
|
|
3299
|
+
const Oi = /* @__PURE__ */ vn(Li), Mi = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), J = Oi.getLogger("telnyx-ai-agent"), Pi = J.methodFactory;
|
|
3290
3300
|
J.methodFactory = (n, e, t) => {
|
|
3291
|
-
const i =
|
|
3301
|
+
const i = Pi(n, e, t);
|
|
3292
3302
|
return function(...s) {
|
|
3293
|
-
i(
|
|
3303
|
+
i(Mi(), "-", ...s);
|
|
3294
3304
|
};
|
|
3295
3305
|
};
|
|
3296
3306
|
J.setLevel("info");
|
|
3297
|
-
function
|
|
3307
|
+
function Di(n, e) {
|
|
3298
3308
|
let t = 0;
|
|
3299
3309
|
return (...i) => {
|
|
3300
3310
|
const s = Date.now();
|
|
3301
3311
|
s - t >= e && (t = s, n(...i));
|
|
3302
3312
|
};
|
|
3303
3313
|
}
|
|
3304
|
-
const
|
|
3305
|
-
class
|
|
3314
|
+
const Ni = 10, ji = 500, Ui = 100, Vt = 20;
|
|
3315
|
+
class Fi {
|
|
3306
3316
|
remoteIntervalId = null;
|
|
3307
3317
|
localIntervalId = null;
|
|
3308
3318
|
remoteStream = null;
|
|
@@ -3329,9 +3339,9 @@ class Ui {
|
|
|
3329
3339
|
minSpeechDurationMs;
|
|
3330
3340
|
maxLatencyMs;
|
|
3331
3341
|
constructor(e) {
|
|
3332
|
-
this.volumeThreshold = e?.volumeThreshold ??
|
|
3342
|
+
this.volumeThreshold = e?.volumeThreshold ?? Ni, this.silenceDurationMs = e?.silenceDurationMs ?? ji, this.minSpeechDurationMs = e?.minSpeechDurationMs ?? Ui, this.maxLatencyMs = e?.maxLatencyMs;
|
|
3333
3343
|
}
|
|
3334
|
-
updateAgentState =
|
|
3344
|
+
updateAgentState = Di((e) => {
|
|
3335
3345
|
J.debug("AudioStreamMonitor updateAgentState", e), J.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state, Ge.emit("conversation.agent.state", e));
|
|
3336
3346
|
}, 100);
|
|
3337
3347
|
/**
|
|
@@ -3402,7 +3412,7 @@ class Ui {
|
|
|
3402
3412
|
this.thinkingStartTime === null && this.updateAgentState({ state: "listening" });
|
|
3403
3413
|
i = r;
|
|
3404
3414
|
};
|
|
3405
|
-
this.remoteIntervalId = window.setInterval(s,
|
|
3415
|
+
this.remoteIntervalId = window.setInterval(s, Vt);
|
|
3406
3416
|
}
|
|
3407
3417
|
/**
|
|
3408
3418
|
* Monitor local stream (user's microphone) for VAD
|
|
@@ -3427,46 +3437,46 @@ class Ui {
|
|
|
3427
3437
|
this.updateAgentState({ state: "thinking", thinkingStartedAt: l });
|
|
3428
3438
|
}
|
|
3429
3439
|
};
|
|
3430
|
-
this.localIntervalId = window.setInterval(t,
|
|
3440
|
+
this.localIntervalId = window.setInterval(t, Vt);
|
|
3431
3441
|
}
|
|
3432
3442
|
destroy() {
|
|
3433
3443
|
this.stopAudioStreamMonitor();
|
|
3434
3444
|
}
|
|
3435
3445
|
}
|
|
3436
|
-
function
|
|
3446
|
+
function $i(n) {
|
|
3437
3447
|
if (!n || typeof n != "object")
|
|
3438
3448
|
return !1;
|
|
3439
3449
|
const e = n;
|
|
3440
3450
|
return e.method === "ai_conversation" && typeof e.params == "object";
|
|
3441
3451
|
}
|
|
3442
|
-
function
|
|
3452
|
+
function Bi(n) {
|
|
3443
3453
|
if (!n || typeof n != "object")
|
|
3444
3454
|
return !1;
|
|
3445
3455
|
const e = n;
|
|
3446
3456
|
return e.params.type !== "response.text.delta" ? !1 : !!e.params.delta;
|
|
3447
3457
|
}
|
|
3448
|
-
function
|
|
3458
|
+
function Vi(n) {
|
|
3449
3459
|
if (!n || typeof n != "object")
|
|
3450
3460
|
return !1;
|
|
3451
3461
|
const e = n;
|
|
3452
3462
|
return e.params.type !== "conversation.item.created" ? !1 : !!e.params.item.content;
|
|
3453
3463
|
}
|
|
3454
|
-
function
|
|
3464
|
+
function Gi(n) {
|
|
3455
3465
|
if (!n || typeof n != "object")
|
|
3456
3466
|
return !1;
|
|
3457
3467
|
const e = n;
|
|
3458
3468
|
return e.params?.type !== "conversation.item.deleted" ? !1 : !!e.params.item_id;
|
|
3459
3469
|
}
|
|
3460
|
-
function
|
|
3461
|
-
return
|
|
3470
|
+
function Hi(n) {
|
|
3471
|
+
return Bi(n) ? {
|
|
3462
3472
|
id: `${n.params.item_id}-${Date.now()}`,
|
|
3463
3473
|
role: "assistant",
|
|
3464
3474
|
content: n.params.delta,
|
|
3465
3475
|
timestamp: /* @__PURE__ */ new Date()
|
|
3466
3476
|
} : null;
|
|
3467
3477
|
}
|
|
3468
|
-
function
|
|
3469
|
-
if (!
|
|
3478
|
+
function Wi(n) {
|
|
3479
|
+
if (!Vi(n) || n.params.item.role !== "user" || n.params.item.status !== "completed")
|
|
3470
3480
|
return null;
|
|
3471
3481
|
let e = "", t = [];
|
|
3472
3482
|
return Array.isArray(n.params.item.content) ? (e = n.params.item.content.reduce((i, s) => (s.type === "text" && (i += s.text), i), ""), t = n.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 = n.params.item.content, {
|
|
@@ -3477,29 +3487,29 @@ function Hi(n) {
|
|
|
3477
3487
|
attachments: t
|
|
3478
3488
|
};
|
|
3479
3489
|
}
|
|
3480
|
-
class
|
|
3490
|
+
class qi extends vt {
|
|
3481
3491
|
telnyxRTC;
|
|
3482
3492
|
transcript = [];
|
|
3483
3493
|
constructor(e) {
|
|
3484
3494
|
super(), this.telnyxRTC = e, this.telnyxRTC.on(x.SocketMessage, this.onSocketMessage);
|
|
3485
3495
|
}
|
|
3486
3496
|
onSocketMessage = (e) => {
|
|
3487
|
-
if (
|
|
3497
|
+
if ($i(e))
|
|
3488
3498
|
switch (e.params.type) {
|
|
3489
3499
|
case "response.text.delta": {
|
|
3490
|
-
const t =
|
|
3500
|
+
const t = Hi(e);
|
|
3491
3501
|
t && (this.transcript.push(t), this.emit("transcript.item", t), Ge.emit("conversation.agent.state", { state: "listening" }));
|
|
3492
3502
|
return;
|
|
3493
3503
|
}
|
|
3494
3504
|
case "conversation.item.deleted": {
|
|
3495
|
-
if (
|
|
3505
|
+
if (Gi(e)) {
|
|
3496
3506
|
const t = e.params.item_id, i = this.transcript.findIndex((s) => s.id === t);
|
|
3497
3507
|
i !== -1 && this.transcript.splice(i, 1);
|
|
3498
3508
|
}
|
|
3499
3509
|
return;
|
|
3500
3510
|
}
|
|
3501
3511
|
case "conversation.item.created": {
|
|
3502
|
-
const t =
|
|
3512
|
+
const t = Wi(e);
|
|
3503
3513
|
if (t) {
|
|
3504
3514
|
const i = this.transcript.findIndex(
|
|
3505
3515
|
(s) => s.id === t.id
|
|
@@ -3511,7 +3521,7 @@ class Wi extends vt {
|
|
|
3511
3521
|
}
|
|
3512
3522
|
};
|
|
3513
3523
|
}
|
|
3514
|
-
class
|
|
3524
|
+
class Gt extends vt {
|
|
3515
3525
|
telnyxRTC;
|
|
3516
3526
|
transcription;
|
|
3517
3527
|
agentId;
|
|
@@ -3534,15 +3544,15 @@ class Vt extends vt {
|
|
|
3534
3544
|
};
|
|
3535
3545
|
e.conversationId && (t.target_params = {
|
|
3536
3546
|
conversation_id: e.conversationId
|
|
3537
|
-
}), this.telnyxRTC = new
|
|
3547
|
+
}), this.telnyxRTC = new Ei({
|
|
3538
3548
|
env: e.environment || "production",
|
|
3539
3549
|
anonymous_login: t,
|
|
3540
3550
|
debug: e.debug || !1,
|
|
3541
3551
|
trickleIce: e.trickleIce
|
|
3542
|
-
}), this.telnyxRTC.on(x.Ready, this.onClientReady), this.telnyxRTC.on(x.Error, this.onClientOrSocketError), this.telnyxRTC.on(x.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(x.Notification, this.onNotification), this.transcription = new
|
|
3552
|
+
}), this.telnyxRTC.on(x.Ready, this.onClientReady), this.telnyxRTC.on(x.Error, this.onClientOrSocketError), this.telnyxRTC.on(x.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(x.Notification, this.onNotification), this.transcription = new qi(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem), Ge.addListener(
|
|
3543
3553
|
"conversation.agent.state",
|
|
3544
3554
|
this.onAgentStateChange
|
|
3545
|
-
), this.audioStreamMonitor = new
|
|
3555
|
+
), this.audioStreamMonitor = new Fi(e.vad);
|
|
3546
3556
|
}
|
|
3547
3557
|
/**
|
|
3548
3558
|
* Connects to the Telnyx WebRTC service and establishes a session with the AI agent.
|
|
@@ -3676,10 +3686,10 @@ class Vt extends vt {
|
|
|
3676
3686
|
};
|
|
3677
3687
|
}
|
|
3678
3688
|
var Pe = { exports: {} }, Se = {};
|
|
3679
|
-
var
|
|
3680
|
-
function
|
|
3681
|
-
if (
|
|
3682
|
-
|
|
3689
|
+
var Ht;
|
|
3690
|
+
function Yi() {
|
|
3691
|
+
if (Ht) return Se;
|
|
3692
|
+
Ht = 1;
|
|
3683
3693
|
var n = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
3684
3694
|
function t(i, s, o) {
|
|
3685
3695
|
var r = null;
|
|
@@ -3699,16 +3709,16 @@ function qi() {
|
|
|
3699
3709
|
return Se.Fragment = e, Se.jsx = t, Se.jsxs = t, Se;
|
|
3700
3710
|
}
|
|
3701
3711
|
var _e = {};
|
|
3702
|
-
var
|
|
3703
|
-
function
|
|
3704
|
-
return
|
|
3712
|
+
var Wt;
|
|
3713
|
+
function Ji() {
|
|
3714
|
+
return Wt || (Wt = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
3705
3715
|
function n(S) {
|
|
3706
3716
|
if (S == null) return null;
|
|
3707
3717
|
if (typeof S == "function")
|
|
3708
3718
|
return S.$$typeof === h ? null : S.displayName || S.name || null;
|
|
3709
3719
|
if (typeof S == "string") return S;
|
|
3710
3720
|
switch (S) {
|
|
3711
|
-
case
|
|
3721
|
+
case v:
|
|
3712
3722
|
return "Fragment";
|
|
3713
3723
|
case R:
|
|
3714
3724
|
return "Profiler";
|
|
@@ -3766,7 +3776,7 @@ function Yi() {
|
|
|
3766
3776
|
}
|
|
3767
3777
|
}
|
|
3768
3778
|
function i(S) {
|
|
3769
|
-
if (S ===
|
|
3779
|
+
if (S === v) return "<>";
|
|
3770
3780
|
if (typeof S == "object" && S !== null && S.$$typeof === a)
|
|
3771
3781
|
return "<...>";
|
|
3772
3782
|
try {
|
|
@@ -3804,7 +3814,7 @@ function Yi() {
|
|
|
3804
3814
|
}
|
|
3805
3815
|
function c() {
|
|
3806
3816
|
var S = n(this.type);
|
|
3807
|
-
return
|
|
3817
|
+
return $[S] || ($[S] = !0, console.error(
|
|
3808
3818
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
3809
3819
|
)), S = this.props.ref, S !== void 0 ? S : null;
|
|
3810
3820
|
}
|
|
@@ -3856,8 +3866,8 @@ function Yi() {
|
|
|
3856
3866
|
else f(H);
|
|
3857
3867
|
if (_.call(P, "key")) {
|
|
3858
3868
|
H = n(S);
|
|
3859
|
-
var oe = Object.keys(P).filter(function(
|
|
3860
|
-
return
|
|
3869
|
+
var oe = Object.keys(P).filter(function(Ln) {
|
|
3870
|
+
return Ln !== "key";
|
|
3861
3871
|
});
|
|
3862
3872
|
V = 0 < oe.length ? "{key: someKey, " + oe.join(": ..., ") + ": ...}" : "{key: someKey}", G[H + V] || (oe = 0 < oe.length ? "{" + oe.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
3863
3873
|
`A props object containing a "key" prop is being spread into JSX:
|
|
@@ -3895,7 +3905,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
3895
3905
|
function C(S) {
|
|
3896
3906
|
return typeof S == "object" && S !== null && S.$$typeof === y;
|
|
3897
3907
|
}
|
|
3898
|
-
var b = ht, y = Symbol.for("react.transitional.element"), I = Symbol.for("react.portal"),
|
|
3908
|
+
var b = ht, y = Symbol.for("react.transitional.element"), I = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), w = Symbol.for("react.strict_mode"), R = Symbol.for("react.profiler"), T = Symbol.for("react.consumer"), A = Symbol.for("react.context"), D = Symbol.for("react.forward_ref"), W = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), M = Symbol.for("react.memo"), a = Symbol.for("react.lazy"), d = Symbol.for("react.activity"), h = Symbol.for("react.client.reference"), m = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, _ = Object.prototype.hasOwnProperty, E = Array.isArray, k = console.createTask ? console.createTask : function() {
|
|
3899
3909
|
return null;
|
|
3900
3910
|
};
|
|
3901
3911
|
b = {
|
|
@@ -3903,11 +3913,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
3903
3913
|
return S();
|
|
3904
3914
|
}
|
|
3905
3915
|
};
|
|
3906
|
-
var L,
|
|
3916
|
+
var L, $ = {}, Z = b.react_stack_bottom_frame.bind(
|
|
3907
3917
|
b,
|
|
3908
3918
|
o
|
|
3909
3919
|
)(), te = k(i(o)), G = {};
|
|
3910
|
-
_e.Fragment =
|
|
3920
|
+
_e.Fragment = v, _e.jsx = function(S, P, U) {
|
|
3911
3921
|
var V = 1e4 > m.recentlyCreatedOwnerStacks++;
|
|
3912
3922
|
return p(
|
|
3913
3923
|
S,
|
|
@@ -3930,19 +3940,19 @@ React keys must be passed directly to JSX without using spread:
|
|
|
3930
3940
|
};
|
|
3931
3941
|
})()), _e;
|
|
3932
3942
|
}
|
|
3933
|
-
var
|
|
3934
|
-
function
|
|
3935
|
-
return
|
|
3943
|
+
var qt;
|
|
3944
|
+
function zi() {
|
|
3945
|
+
return qt || (qt = 1, process.env.NODE_ENV === "production" ? Pe.exports = Yi() : Pe.exports = Ji()), Pe.exports;
|
|
3936
3946
|
}
|
|
3937
|
-
var Ce =
|
|
3947
|
+
var Ce = zi();
|
|
3938
3948
|
const le = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
|
|
3939
|
-
function
|
|
3949
|
+
function mn(n) {
|
|
3940
3950
|
return "init" in n;
|
|
3941
3951
|
}
|
|
3942
3952
|
function at(n) {
|
|
3943
3953
|
return !!n.write;
|
|
3944
3954
|
}
|
|
3945
|
-
function
|
|
3955
|
+
function Yt(n) {
|
|
3946
3956
|
return "v" in n || "e" in n;
|
|
3947
3957
|
}
|
|
3948
3958
|
function He(n) {
|
|
@@ -3953,11 +3963,11 @@ function He(n) {
|
|
|
3953
3963
|
return n.v;
|
|
3954
3964
|
}
|
|
3955
3965
|
const We = /* @__PURE__ */ new WeakMap();
|
|
3956
|
-
function
|
|
3966
|
+
function yn(n) {
|
|
3957
3967
|
var e;
|
|
3958
3968
|
return qe(n) && !!((e = We.get(n)) != null && e[0]);
|
|
3959
3969
|
}
|
|
3960
|
-
function
|
|
3970
|
+
function Ki(n) {
|
|
3961
3971
|
const e = We.get(n);
|
|
3962
3972
|
e?.[0] && (e[0] = !1, e[1].forEach((t) => t()));
|
|
3963
3973
|
}
|
|
@@ -3975,14 +3985,14 @@ function ct(n, e) {
|
|
|
3975
3985
|
function qe(n) {
|
|
3976
3986
|
return typeof n?.then == "function";
|
|
3977
3987
|
}
|
|
3978
|
-
function
|
|
3988
|
+
function bn(n, e, t) {
|
|
3979
3989
|
if (!t.p.has(n)) {
|
|
3980
3990
|
t.p.add(n);
|
|
3981
3991
|
const i = () => t.p.delete(n);
|
|
3982
3992
|
e.then(i, i);
|
|
3983
3993
|
}
|
|
3984
3994
|
}
|
|
3985
|
-
function
|
|
3995
|
+
function Sn(n, e, t) {
|
|
3986
3996
|
var i;
|
|
3987
3997
|
const s = /* @__PURE__ */ new Set();
|
|
3988
3998
|
for (const o of ((i = t.get(n)) == null ? void 0 : i.t) || [])
|
|
@@ -3991,24 +4001,24 @@ function bn(n, e, t) {
|
|
|
3991
4001
|
s.add(o);
|
|
3992
4002
|
return s;
|
|
3993
4003
|
}
|
|
3994
|
-
const
|
|
4004
|
+
const Xi = (n, e, ...t) => e.read(...t), Qi = (n, e, ...t) => e.write(...t), Zi = (n, e) => {
|
|
3995
4005
|
if (e.INTERNAL_onInit)
|
|
3996
4006
|
return e.INTERNAL_onInit(n);
|
|
3997
4007
|
if (e.unstable_onInit)
|
|
3998
4008
|
return console.warn(
|
|
3999
4009
|
"[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."
|
|
4000
4010
|
), e.unstable_onInit(n);
|
|
4001
|
-
},
|
|
4011
|
+
}, es = (n, e, t) => {
|
|
4002
4012
|
var i;
|
|
4003
4013
|
return (i = e.onMount) == null ? void 0 : i.call(e, t);
|
|
4004
|
-
},
|
|
4014
|
+
}, ts = (n, e) => {
|
|
4005
4015
|
var t;
|
|
4006
4016
|
const i = X(n), s = i[0], o = i[6], r = i[9];
|
|
4007
4017
|
if ((le ? "production" : void 0) !== "production" && !e)
|
|
4008
4018
|
throw new Error("Atom is undefined or null");
|
|
4009
4019
|
let l = s.get(e);
|
|
4010
4020
|
return l || (l = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, s.set(e, l), (t = o.i) == null || t.call(o, e), r?.(n, e)), l;
|
|
4011
|
-
},
|
|
4021
|
+
}, ns = (n) => {
|
|
4012
4022
|
const e = X(n), t = e[1], i = e[3], s = e[4], o = e[5], r = e[6], l = e[13], c = [], u = (p) => {
|
|
4013
4023
|
try {
|
|
4014
4024
|
p();
|
|
@@ -4026,7 +4036,7 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
|
|
|
4026
4036
|
} while (i.size || o.size || s.size);
|
|
4027
4037
|
if (c.length)
|
|
4028
4038
|
throw new AggregateError(c);
|
|
4029
|
-
},
|
|
4039
|
+
}, is = (n) => {
|
|
4030
4040
|
const e = X(n), t = e[1], i = e[2], s = e[3], o = e[11], r = e[14], l = e[17], c = [], u = /* @__PURE__ */ new WeakSet(), p = /* @__PURE__ */ new WeakSet(), f = Array.from(s);
|
|
4031
4041
|
for (; f.length; ) {
|
|
4032
4042
|
const C = f[f.length - 1], b = o(n, C);
|
|
@@ -4043,35 +4053,35 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
|
|
|
4043
4053
|
continue;
|
|
4044
4054
|
}
|
|
4045
4055
|
u.add(C);
|
|
4046
|
-
for (const y of
|
|
4056
|
+
for (const y of Sn(C, b, t))
|
|
4047
4057
|
u.has(y) || f.push(y);
|
|
4048
4058
|
}
|
|
4049
4059
|
for (let C = c.length - 1; C >= 0; --C) {
|
|
4050
4060
|
const [b, y] = c[C];
|
|
4051
4061
|
let I = !1;
|
|
4052
|
-
for (const
|
|
4053
|
-
if (
|
|
4062
|
+
for (const v of y.d.keys())
|
|
4063
|
+
if (v !== b && s.has(v)) {
|
|
4054
4064
|
I = !0;
|
|
4055
4065
|
break;
|
|
4056
4066
|
}
|
|
4057
4067
|
I && (r(n, b), l(n, b)), i.delete(b);
|
|
4058
4068
|
}
|
|
4059
|
-
}, lt = /* @__PURE__ */ new WeakSet(),
|
|
4069
|
+
}, lt = /* @__PURE__ */ new WeakSet(), ss = (n, e) => {
|
|
4060
4070
|
var t, i;
|
|
4061
|
-
const s = X(n), o = s[1], r = s[2], l = s[3], c = s[6], u = s[7], p = s[11], f = s[12], C = s[13], b = s[14], y = s[16], I = s[17],
|
|
4062
|
-
if (
|
|
4063
|
-
if (o.has(e) && r.get(e) !==
|
|
4064
|
-
return
|
|
4071
|
+
const s = X(n), o = s[1], r = s[2], l = s[3], c = s[6], u = s[7], p = s[11], f = s[12], C = s[13], b = s[14], y = s[16], I = s[17], v = p(n, e);
|
|
4072
|
+
if (Yt(v)) {
|
|
4073
|
+
if (o.has(e) && r.get(e) !== v.n)
|
|
4074
|
+
return v;
|
|
4065
4075
|
let M = !1;
|
|
4066
|
-
for (const [a, d] of
|
|
4076
|
+
for (const [a, d] of v.d)
|
|
4067
4077
|
if (b(n, a).n !== d) {
|
|
4068
4078
|
M = !0;
|
|
4069
4079
|
break;
|
|
4070
4080
|
}
|
|
4071
4081
|
if (!M)
|
|
4072
|
-
return
|
|
4082
|
+
return v;
|
|
4073
4083
|
}
|
|
4074
|
-
|
|
4084
|
+
v.d.clear();
|
|
4075
4085
|
let w = !0;
|
|
4076
4086
|
function R() {
|
|
4077
4087
|
o.has(e) && (I(n, e), C(n), f(n));
|
|
@@ -4080,8 +4090,8 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
|
|
|
4080
4090
|
var a;
|
|
4081
4091
|
if (M === e) {
|
|
4082
4092
|
const h = p(n, M);
|
|
4083
|
-
if (!
|
|
4084
|
-
if (
|
|
4093
|
+
if (!Yt(h))
|
|
4094
|
+
if (mn(M))
|
|
4085
4095
|
Ye(n, M, M.init);
|
|
4086
4096
|
else
|
|
4087
4097
|
throw new Error("no atom init");
|
|
@@ -4091,7 +4101,7 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
|
|
|
4091
4101
|
try {
|
|
4092
4102
|
return He(d);
|
|
4093
4103
|
} finally {
|
|
4094
|
-
|
|
4104
|
+
v.d.set(M, d.n), yn(v.v) && bn(e, v.v, d), o.has(e) && ((a = o.get(M)) == null || a.t.add(e)), w || R();
|
|
4095
4105
|
}
|
|
4096
4106
|
}
|
|
4097
4107
|
let A, D;
|
|
@@ -4109,43 +4119,43 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
|
|
|
4109
4119
|
}
|
|
4110
4120
|
}), D;
|
|
4111
4121
|
}
|
|
4112
|
-
}, B =
|
|
4122
|
+
}, B = v.n;
|
|
4113
4123
|
try {
|
|
4114
4124
|
(le ? "production" : void 0) !== "production" && lt.delete(n);
|
|
4115
4125
|
const M = u(n, e, T, W);
|
|
4116
4126
|
return (le ? "production" : void 0) !== "production" && lt.has(n) && console.warn(
|
|
4117
4127
|
"Detected store mutation during atom read. This is not supported."
|
|
4118
|
-
), Ye(n, e, M), qe(M) && (ct(M, () => A?.abort()), M.then(R, R)), (t = c.r) == null || t.call(c, e),
|
|
4128
|
+
), Ye(n, e, M), qe(M) && (ct(M, () => A?.abort()), M.then(R, R)), (t = c.r) == null || t.call(c, e), v;
|
|
4119
4129
|
} catch (M) {
|
|
4120
|
-
return delete
|
|
4130
|
+
return delete v.v, v.e = M, ++v.n, v;
|
|
4121
4131
|
} finally {
|
|
4122
|
-
w = !1, B !==
|
|
4132
|
+
w = !1, B !== v.n && r.get(e) === B && (r.set(e, v.n), l.add(e), (i = c.c) == null || i.call(c, e));
|
|
4123
4133
|
}
|
|
4124
|
-
},
|
|
4134
|
+
}, os = (n, e) => {
|
|
4125
4135
|
const t = X(n), i = t[1], s = t[2], o = t[11], r = [e];
|
|
4126
4136
|
for (; r.length; ) {
|
|
4127
4137
|
const l = r.pop(), c = o(n, l);
|
|
4128
|
-
for (const u of
|
|
4138
|
+
for (const u of Sn(l, c, i)) {
|
|
4129
4139
|
const p = o(n, u);
|
|
4130
4140
|
s.set(u, p.n), r.push(u);
|
|
4131
4141
|
}
|
|
4132
4142
|
}
|
|
4133
|
-
},
|
|
4143
|
+
}, _n = (n, e, ...t) => {
|
|
4134
4144
|
const i = X(n), s = i[3], o = i[6], r = i[8], l = i[11], c = i[12], u = i[13], p = i[14], f = i[15], C = i[17];
|
|
4135
4145
|
let b = !0;
|
|
4136
|
-
const y = (
|
|
4146
|
+
const y = (v) => He(p(n, v)), I = (v, ...w) => {
|
|
4137
4147
|
var R;
|
|
4138
|
-
const T = l(n,
|
|
4148
|
+
const T = l(n, v);
|
|
4139
4149
|
try {
|
|
4140
|
-
if (
|
|
4141
|
-
if (!
|
|
4150
|
+
if (v === e) {
|
|
4151
|
+
if (!mn(v))
|
|
4142
4152
|
throw new Error("atom not writable");
|
|
4143
4153
|
(le ? "production" : void 0) !== "production" && lt.add(n);
|
|
4144
4154
|
const A = T.n, D = w[0];
|
|
4145
|
-
Ye(n,
|
|
4155
|
+
Ye(n, v, D), C(n, v), A !== T.n && (s.add(v), f(n, v), (R = o.c) == null || R.call(o, v));
|
|
4146
4156
|
return;
|
|
4147
4157
|
} else
|
|
4148
|
-
return
|
|
4158
|
+
return _n(n, v, ...w);
|
|
4149
4159
|
} finally {
|
|
4150
4160
|
b || (u(n), c(n));
|
|
4151
4161
|
}
|
|
@@ -4155,10 +4165,10 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
|
|
|
4155
4165
|
} finally {
|
|
4156
4166
|
b = !1;
|
|
4157
4167
|
}
|
|
4158
|
-
},
|
|
4168
|
+
}, rs = (n, e) => {
|
|
4159
4169
|
var t;
|
|
4160
4170
|
const i = X(n), s = i[1], o = i[3], r = i[6], l = i[11], c = i[15], u = i[18], p = i[19], f = l(n, e), C = s.get(e);
|
|
4161
|
-
if (C && !
|
|
4171
|
+
if (C && !yn(f.v)) {
|
|
4162
4172
|
for (const [b, y] of f.d)
|
|
4163
4173
|
if (!C.d.has(b)) {
|
|
4164
4174
|
const I = l(n, b);
|
|
@@ -4171,40 +4181,40 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
|
|
|
4171
4181
|
y?.t.delete(e);
|
|
4172
4182
|
}
|
|
4173
4183
|
}
|
|
4174
|
-
},
|
|
4184
|
+
}, Cn = (n, e) => {
|
|
4175
4185
|
var t;
|
|
4176
4186
|
const i = X(n), s = i[1], o = i[4], r = i[6], l = i[10], c = i[11], u = i[12], p = i[13], f = i[14], C = i[16], b = c(n, e);
|
|
4177
4187
|
let y = s.get(e);
|
|
4178
4188
|
if (!y) {
|
|
4179
4189
|
f(n, e);
|
|
4180
4190
|
for (const I of b.d.keys())
|
|
4181
|
-
|
|
4191
|
+
Cn(n, I).t.add(e);
|
|
4182
4192
|
if (y = {
|
|
4183
4193
|
l: /* @__PURE__ */ new Set(),
|
|
4184
4194
|
d: new Set(b.d.keys()),
|
|
4185
4195
|
t: /* @__PURE__ */ new Set()
|
|
4186
4196
|
}, s.set(e, y), at(e)) {
|
|
4187
4197
|
const I = () => {
|
|
4188
|
-
let
|
|
4198
|
+
let v = !0;
|
|
4189
4199
|
const w = (...R) => {
|
|
4190
4200
|
try {
|
|
4191
4201
|
return C(n, e, ...R);
|
|
4192
4202
|
} finally {
|
|
4193
|
-
|
|
4203
|
+
v || (p(n), u(n));
|
|
4194
4204
|
}
|
|
4195
4205
|
};
|
|
4196
4206
|
try {
|
|
4197
4207
|
const R = l(n, e, w);
|
|
4198
4208
|
R && (y.u = () => {
|
|
4199
|
-
|
|
4209
|
+
v = !0;
|
|
4200
4210
|
try {
|
|
4201
4211
|
R();
|
|
4202
4212
|
} finally {
|
|
4203
|
-
|
|
4213
|
+
v = !1;
|
|
4204
4214
|
}
|
|
4205
4215
|
});
|
|
4206
4216
|
} finally {
|
|
4207
|
-
|
|
4217
|
+
v = !1;
|
|
4208
4218
|
}
|
|
4209
4219
|
};
|
|
4210
4220
|
o.add(I);
|
|
@@ -4212,7 +4222,7 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
|
|
|
4212
4222
|
(t = r.m) == null || t.call(r, e);
|
|
4213
4223
|
}
|
|
4214
4224
|
return y;
|
|
4215
|
-
},
|
|
4225
|
+
}, as = (n, e) => {
|
|
4216
4226
|
var t, i;
|
|
4217
4227
|
const s = X(n), o = s[1], r = s[5], l = s[6], c = s[11], u = s[19], p = c(n, e);
|
|
4218
4228
|
let f = o.get(e);
|
|
@@ -4238,36 +4248,36 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
|
|
|
4238
4248
|
const i = X(n)[11], s = i(n, e), o = "v" in s, r = s.v;
|
|
4239
4249
|
if (qe(t))
|
|
4240
4250
|
for (const l of s.d.keys())
|
|
4241
|
-
|
|
4251
|
+
bn(
|
|
4242
4252
|
e,
|
|
4243
4253
|
t,
|
|
4244
4254
|
i(n, l)
|
|
4245
4255
|
);
|
|
4246
|
-
s.v = t, delete s.e, (!o || !Object.is(r, s.v)) && (++s.n, qe(r) &&
|
|
4247
|
-
},
|
|
4256
|
+
s.v = t, delete s.e, (!o || !Object.is(r, s.v)) && (++s.n, qe(r) && Ki(r));
|
|
4257
|
+
}, cs = (n, e) => {
|
|
4248
4258
|
const t = X(n)[14];
|
|
4249
4259
|
return He(t(n, e));
|
|
4250
|
-
},
|
|
4260
|
+
}, ls = (n, e, ...t) => {
|
|
4251
4261
|
const i = X(n), s = i[12], o = i[13], r = i[16];
|
|
4252
4262
|
try {
|
|
4253
4263
|
return r(n, e, ...t);
|
|
4254
4264
|
} finally {
|
|
4255
4265
|
o(n), s(n);
|
|
4256
4266
|
}
|
|
4257
|
-
},
|
|
4267
|
+
}, ds = (n, e, t) => {
|
|
4258
4268
|
const i = X(n), s = i[12], o = i[18], r = i[19], c = o(n, e).l;
|
|
4259
4269
|
return c.add(t), s(n), () => {
|
|
4260
4270
|
c.delete(t), r(n, e), s(n);
|
|
4261
4271
|
};
|
|
4262
|
-
},
|
|
4263
|
-
const e =
|
|
4272
|
+
}, wn = /* @__PURE__ */ new WeakMap(), X = (n) => {
|
|
4273
|
+
const e = wn.get(n);
|
|
4264
4274
|
if ((le ? "production" : void 0) !== "production" && !e)
|
|
4265
4275
|
throw new Error(
|
|
4266
4276
|
"Store must be created by buildStore to read its building blocks"
|
|
4267
4277
|
);
|
|
4268
4278
|
return e;
|
|
4269
4279
|
};
|
|
4270
|
-
function
|
|
4280
|
+
function us(...n) {
|
|
4271
4281
|
const e = {
|
|
4272
4282
|
get(i) {
|
|
4273
4283
|
const s = X(e)[21];
|
|
@@ -4298,61 +4308,61 @@ function ds(...n) {
|
|
|
4298
4308
|
{},
|
|
4299
4309
|
// storeHooks
|
|
4300
4310
|
// atom interceptors
|
|
4301
|
-
Ki,
|
|
4302
4311
|
Xi,
|
|
4303
4312
|
Qi,
|
|
4304
4313
|
Zi,
|
|
4305
|
-
// building-block functions
|
|
4306
4314
|
es,
|
|
4315
|
+
// building-block functions
|
|
4307
4316
|
ts,
|
|
4308
4317
|
ns,
|
|
4309
4318
|
is,
|
|
4310
4319
|
ss,
|
|
4311
|
-
Sn,
|
|
4312
4320
|
os,
|
|
4313
4321
|
_n,
|
|
4314
4322
|
rs,
|
|
4315
|
-
|
|
4323
|
+
Cn,
|
|
4316
4324
|
as,
|
|
4325
|
+
Ye,
|
|
4317
4326
|
cs,
|
|
4318
4327
|
ls,
|
|
4328
|
+
ds,
|
|
4319
4329
|
void 0
|
|
4320
4330
|
].map((i, s) => n[s] || i);
|
|
4321
|
-
return
|
|
4331
|
+
return wn.set(e, Object.freeze(t)), e;
|
|
4322
4332
|
}
|
|
4323
|
-
const
|
|
4324
|
-
let
|
|
4333
|
+
const In = {};
|
|
4334
|
+
let hs = 0;
|
|
4325
4335
|
function Je(n, e) {
|
|
4326
|
-
const t = `atom${++
|
|
4336
|
+
const t = `atom${++hs}`, i = {
|
|
4327
4337
|
toString() {
|
|
4328
|
-
return (
|
|
4338
|
+
return (In ? "production" : void 0) !== "production" && this.debugLabel ? t + ":" + this.debugLabel : t;
|
|
4329
4339
|
}
|
|
4330
4340
|
};
|
|
4331
|
-
return typeof n == "function" ? i.read = n : (i.init = n, i.read =
|
|
4341
|
+
return typeof n == "function" ? i.read = n : (i.init = n, i.read = ps, i.write = fs), i;
|
|
4332
4342
|
}
|
|
4333
|
-
function
|
|
4343
|
+
function ps(n) {
|
|
4334
4344
|
return n(this);
|
|
4335
4345
|
}
|
|
4336
|
-
function
|
|
4346
|
+
function fs(n, e, t) {
|
|
4337
4347
|
return e(
|
|
4338
4348
|
this,
|
|
4339
4349
|
typeof t == "function" ? t(n(this)) : t
|
|
4340
4350
|
);
|
|
4341
4351
|
}
|
|
4342
|
-
function
|
|
4343
|
-
return
|
|
4352
|
+
function gs() {
|
|
4353
|
+
return us();
|
|
4344
4354
|
}
|
|
4345
4355
|
let we;
|
|
4346
|
-
function
|
|
4347
|
-
return we || (we =
|
|
4356
|
+
function vs() {
|
|
4357
|
+
return we || (we = gs(), (In ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = we), globalThis.__JOTAI_DEFAULT_STORE__ !== we && console.warn(
|
|
4348
4358
|
"Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
|
|
4349
4359
|
))), we;
|
|
4350
4360
|
}
|
|
4351
|
-
const
|
|
4361
|
+
const ms = {}, ys = Kt(
|
|
4352
4362
|
void 0
|
|
4353
4363
|
);
|
|
4354
|
-
function
|
|
4355
|
-
return
|
|
4364
|
+
function kn(n) {
|
|
4365
|
+
return zt(ys) || vs();
|
|
4356
4366
|
}
|
|
4357
4367
|
const dt = (n) => typeof n?.then == "function", ut = (n) => {
|
|
4358
4368
|
n.status || (n.status = "pending", n.then(
|
|
@@ -4363,14 +4373,14 @@ const dt = (n) => typeof n?.then == "function", ut = (n) => {
|
|
|
4363
4373
|
n.status = "rejected", n.reason = e;
|
|
4364
4374
|
}
|
|
4365
4375
|
));
|
|
4366
|
-
},
|
|
4376
|
+
}, bs = ht.use || // A shim for older React versions
|
|
4367
4377
|
((n) => {
|
|
4368
4378
|
if (n.status === "pending")
|
|
4369
4379
|
throw n;
|
|
4370
4380
|
if (n.status === "fulfilled")
|
|
4371
4381
|
return n.value;
|
|
4372
4382
|
throw n.status === "rejected" ? n.reason : (ut(n), n);
|
|
4373
|
-
}), nt = /* @__PURE__ */ new WeakMap(),
|
|
4383
|
+
}), nt = /* @__PURE__ */ new WeakMap(), Jt = (n, e) => {
|
|
4374
4384
|
let t = nt.get(n);
|
|
4375
4385
|
return t || (t = new Promise((i, s) => {
|
|
4376
4386
|
let o = n;
|
|
@@ -4390,7 +4400,7 @@ const dt = (n) => typeof n?.then == "function", ut = (n) => {
|
|
|
4390
4400
|
}), nt.set(n, t)), t;
|
|
4391
4401
|
};
|
|
4392
4402
|
function ze(n, e) {
|
|
4393
|
-
const { delay: t, unstable_promiseStatus: i = !ht.use } = {}, s =
|
|
4403
|
+
const { delay: t, unstable_promiseStatus: i = !ht.use } = {}, s = kn(), [[o, r, l], c] = On(
|
|
4394
4404
|
(p) => {
|
|
4395
4405
|
const f = s.get(n);
|
|
4396
4406
|
return Object.is(p[0], f) && p[1] === s && p[2] === n ? p : [f, s, n];
|
|
@@ -4405,7 +4415,7 @@ function ze(n, e) {
|
|
|
4405
4415
|
try {
|
|
4406
4416
|
const f = s.get(n);
|
|
4407
4417
|
dt(f) && ut(
|
|
4408
|
-
|
|
4418
|
+
Jt(f, () => s.get(n))
|
|
4409
4419
|
);
|
|
4410
4420
|
} catch {
|
|
4411
4421
|
}
|
|
@@ -4416,38 +4426,38 @@ function ze(n, e) {
|
|
|
4416
4426
|
c();
|
|
4417
4427
|
});
|
|
4418
4428
|
return c(), p;
|
|
4419
|
-
}, [s, n, t, i]),
|
|
4420
|
-
const p =
|
|
4421
|
-
return i && ut(p),
|
|
4429
|
+
}, [s, n, t, i]), Mn(u), dt(u)) {
|
|
4430
|
+
const p = Jt(u, () => s.get(n));
|
|
4431
|
+
return i && ut(p), bs(p);
|
|
4422
4432
|
}
|
|
4423
4433
|
return u;
|
|
4424
4434
|
}
|
|
4425
4435
|
function Ke(n, e) {
|
|
4426
|
-
const t =
|
|
4427
|
-
return
|
|
4436
|
+
const t = kn();
|
|
4437
|
+
return Pn(
|
|
4428
4438
|
(...s) => {
|
|
4429
|
-
if ((
|
|
4439
|
+
if ((ms ? "production" : void 0) !== "production" && !("write" in n))
|
|
4430
4440
|
throw new Error("not writable atom");
|
|
4431
4441
|
return t.set(n, ...s);
|
|
4432
4442
|
},
|
|
4433
4443
|
[t, n]
|
|
4434
4444
|
);
|
|
4435
4445
|
}
|
|
4436
|
-
const
|
|
4437
|
-
function
|
|
4438
|
-
return ze(
|
|
4446
|
+
const En = Je([]);
|
|
4447
|
+
function As() {
|
|
4448
|
+
return ze(En);
|
|
4439
4449
|
}
|
|
4440
|
-
function
|
|
4441
|
-
return Ke(
|
|
4450
|
+
function Ss() {
|
|
4451
|
+
return Ke(En);
|
|
4442
4452
|
}
|
|
4443
4453
|
const Xe = () => {
|
|
4444
|
-
const n =
|
|
4454
|
+
const n = zt(xn);
|
|
4445
4455
|
if (!n)
|
|
4446
4456
|
throw new Error("useClient must be used within a TelnyxAIAgentProvider");
|
|
4447
4457
|
return n;
|
|
4448
4458
|
};
|
|
4449
|
-
function
|
|
4450
|
-
const n = Xe(), e =
|
|
4459
|
+
function _s() {
|
|
4460
|
+
const n = Xe(), e = Ss();
|
|
4451
4461
|
return fe(() => {
|
|
4452
4462
|
const t = (i) => e((s) => [...s, i]);
|
|
4453
4463
|
return n.addListener("transcript.item", t), () => {
|
|
@@ -4455,15 +4465,15 @@ function Ss() {
|
|
|
4455
4465
|
};
|
|
4456
4466
|
}, [n, e]), null;
|
|
4457
4467
|
}
|
|
4458
|
-
const
|
|
4459
|
-
function
|
|
4460
|
-
return ze(
|
|
4461
|
-
}
|
|
4462
|
-
function _s() {
|
|
4463
|
-
return Ke(En);
|
|
4468
|
+
const Tn = Je("connecting");
|
|
4469
|
+
function xs() {
|
|
4470
|
+
return ze(Tn);
|
|
4464
4471
|
}
|
|
4465
4472
|
function Cs() {
|
|
4466
|
-
|
|
4473
|
+
return Ke(Tn);
|
|
4474
|
+
}
|
|
4475
|
+
function ws() {
|
|
4476
|
+
const n = Xe(), e = Cs();
|
|
4467
4477
|
return fe(() => {
|
|
4468
4478
|
const t = () => e("connected"), i = () => e("disconnected"), s = () => e("error");
|
|
4469
4479
|
return n.addListener("agent.connected", t), n.addListener("agent.disconnected", i), n.addListener("agent.error", s), () => {
|
|
@@ -4471,15 +4481,15 @@ function Cs() {
|
|
|
4471
4481
|
};
|
|
4472
4482
|
}, [n, e]), null;
|
|
4473
4483
|
}
|
|
4474
|
-
const
|
|
4475
|
-
function
|
|
4476
|
-
return ze(
|
|
4484
|
+
const Rn = Je(null);
|
|
4485
|
+
function Ls() {
|
|
4486
|
+
return ze(Rn);
|
|
4477
4487
|
}
|
|
4478
|
-
function
|
|
4479
|
-
return Ke(
|
|
4488
|
+
function Is() {
|
|
4489
|
+
return Ke(Rn);
|
|
4480
4490
|
}
|
|
4481
|
-
const
|
|
4482
|
-
const n = Xe(), e =
|
|
4491
|
+
const ks = () => {
|
|
4492
|
+
const n = Xe(), e = Is();
|
|
4483
4493
|
return fe(() => {
|
|
4484
4494
|
const t = (i) => {
|
|
4485
4495
|
e(i);
|
|
@@ -4488,15 +4498,15 @@ const Is = () => {
|
|
|
4488
4498
|
n.removeListener("conversation.update", t);
|
|
4489
4499
|
};
|
|
4490
4500
|
}, [n, e]), null;
|
|
4491
|
-
},
|
|
4492
|
-
function
|
|
4493
|
-
return ze(
|
|
4494
|
-
}
|
|
4495
|
-
function ks() {
|
|
4496
|
-
return Ke(Rn);
|
|
4501
|
+
}, An = Je({ state: "listening" });
|
|
4502
|
+
function Os() {
|
|
4503
|
+
return ze(An);
|
|
4497
4504
|
}
|
|
4498
4505
|
function Es() {
|
|
4499
|
-
|
|
4506
|
+
return Ke(An);
|
|
4507
|
+
}
|
|
4508
|
+
function Ts() {
|
|
4509
|
+
const n = Xe(), e = Es();
|
|
4500
4510
|
return fe(() => {
|
|
4501
4511
|
const t = (i) => {
|
|
4502
4512
|
e(i);
|
|
@@ -4506,7 +4516,7 @@ function Es() {
|
|
|
4506
4516
|
};
|
|
4507
4517
|
}, [n, e]), null;
|
|
4508
4518
|
}
|
|
4509
|
-
const
|
|
4519
|
+
const xn = Kt(null), Ms = ({
|
|
4510
4520
|
children: n,
|
|
4511
4521
|
agentId: e,
|
|
4512
4522
|
environment: t,
|
|
@@ -4514,36 +4524,36 @@ const An = zt(null), Os = ({
|
|
|
4514
4524
|
debug: s,
|
|
4515
4525
|
vad: o
|
|
4516
4526
|
}) => {
|
|
4517
|
-
const [r, l] =
|
|
4527
|
+
const [r, l] = Dn(() => new Gt({ agentId: e, environment: t, versionId: i, debug: s, vad: o }));
|
|
4518
4528
|
return fe(() => {
|
|
4519
4529
|
if (!r) {
|
|
4520
|
-
const c = new
|
|
4530
|
+
const c = new Gt({ agentId: e, environment: t, versionId: i, vad: o });
|
|
4521
4531
|
return l(c), () => {
|
|
4522
4532
|
c.disconnect();
|
|
4523
4533
|
};
|
|
4524
4534
|
}
|
|
4525
4535
|
}, [e, r, t, i, o]), fe(() => {
|
|
4526
4536
|
r?.connect();
|
|
4527
|
-
}, [r]), /* @__PURE__ */ Ce.jsxs(
|
|
4528
|
-
/* @__PURE__ */ Ce.jsx(
|
|
4529
|
-
/* @__PURE__ */ Ce.jsx(
|
|
4530
|
-
/* @__PURE__ */ Ce.jsx(
|
|
4531
|
-
/* @__PURE__ */ Ce.jsx(
|
|
4537
|
+
}, [r]), /* @__PURE__ */ Ce.jsxs(xn.Provider, { value: r, children: [
|
|
4538
|
+
/* @__PURE__ */ Ce.jsx(_s, {}),
|
|
4539
|
+
/* @__PURE__ */ Ce.jsx(ws, {}),
|
|
4540
|
+
/* @__PURE__ */ Ce.jsx(ks, {}),
|
|
4541
|
+
/* @__PURE__ */ Ce.jsx(Ts, {}),
|
|
4532
4542
|
n
|
|
4533
4543
|
] });
|
|
4534
4544
|
};
|
|
4535
4545
|
export {
|
|
4536
|
-
|
|
4546
|
+
xn as ClientContext,
|
|
4537
4547
|
x as SwEvent,
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4548
|
+
Gt as TelnyxAIAgent,
|
|
4549
|
+
Ms as TelnyxAIAgentProvider,
|
|
4550
|
+
Os as useAgentState,
|
|
4541
4551
|
Xe as useClient,
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4552
|
+
xs as useConnectionState,
|
|
4553
|
+
Ls as useConversation,
|
|
4554
|
+
Es as useSetAgentState,
|
|
4555
|
+
Cs as useSetConnectionState,
|
|
4556
|
+
Is as useSetConversation,
|
|
4557
|
+
Ss as useSetTranscript,
|
|
4558
|
+
As as useTranscript
|
|
4549
4559
|
};
|