@telnyx/ai-agent-lib 0.4.1 → 0.4.4
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/client.d.ts +29 -0
- package/dist/index.js +1094 -1017
- package/dist/types.d.ts +21 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
1
|
+
import St, { useReducer as Yn, useEffect as ve, useDebugValue as Jn, useCallback as Kn, useContext as cn, createContext as ln, useState as Xn } from "react";
|
|
2
|
+
function We(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]);
|
|
5
5
|
if (n != null && typeof Object.getOwnPropertySymbols == "function") {
|
|
@@ -12,113 +12,113 @@ function O(n, e, t, i) {
|
|
|
12
12
|
return new (t || (t = Promise))((function(s, o) {
|
|
13
13
|
function r(l) {
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
d(i.next(l));
|
|
16
16
|
} catch (f) {
|
|
17
17
|
o(f);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
function c(l) {
|
|
21
21
|
try {
|
|
22
|
-
|
|
22
|
+
d(i.throw(l));
|
|
23
23
|
} catch (f) {
|
|
24
24
|
o(f);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function d(l) {
|
|
28
28
|
var f;
|
|
29
29
|
l.done ? s(l.value) : (f = l.value, f instanceof t ? f : new t((function(h) {
|
|
30
30
|
h(f);
|
|
31
31
|
}))).then(r, c);
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
d((i = i.apply(n, [])).next());
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
|
-
var
|
|
37
|
-
function
|
|
38
|
-
if (!
|
|
39
|
-
return
|
|
36
|
+
var It = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), zn = new Uint8Array(16);
|
|
37
|
+
function Qn() {
|
|
38
|
+
if (!It) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
39
|
+
return It(zn);
|
|
40
40
|
}
|
|
41
|
-
for (var
|
|
41
|
+
for (var dn = [], Ue = 0; Ue < 256; ++Ue) dn[Ue] = (Ue + 256).toString(16).substr(1);
|
|
42
42
|
function ye(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 || Qn)();
|
|
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, c) {
|
|
48
|
-
var
|
|
49
|
-
return [l[r[
|
|
48
|
+
var d = 0, l = dn;
|
|
49
|
+
return [l[r[d++]], l[r[d++]], l[r[d++]], l[r[d++]], "-", l[r[d++]], l[r[d++]], "-", l[r[d++]], l[r[d++]], "-", l[r[d++]], l[r[d++]], "-", l[r[d++]], l[r[d++]], l[r[d++]], l[r[d++]], l[r[d++]], l[r[d++]]].join("");
|
|
50
50
|
})(s);
|
|
51
51
|
}
|
|
52
|
-
const
|
|
52
|
+
const Zn = { SDP_CREATE_OFFER_FAILED: 40001, SDP_CREATE_ANSWER_FAILED: 40002, SDP_SET_LOCAL_DESCRIPTION_FAILED: 40003, SDP_SET_REMOTE_DESCRIPTION_FAILED: 40004, SDP_SEND_FAILED: 40005, MEDIA_MICROPHONE_PERMISSION_DENIED: 42001, MEDIA_DEVICE_NOT_FOUND: 42002, MEDIA_GET_USER_MEDIA_FAILED: 42003, HOLD_FAILED: 44001, INVALID_CALL_PARAMETERS: 44002, BYE_SEND_FAILED: 44003, SUBSCRIBE_FAILED: 44004, PEER_CLOSED_DURING_INIT: 44005, WEBSOCKET_CONNECTION_FAILED: 45001, WEBSOCKET_ERROR: 45002, RECONNECTION_EXHAUSTED: 45003, GATEWAY_FAILED: 45004, LOGIN_FAILED: 46001, INVALID_CREDENTIALS: 46002, AUTHENTICATION_REQUIRED: 46003, NETWORK_OFFLINE: 48001, UNEXPECTED_ERROR: 49001 }, ei = { HIGH_RTT: 31001, HIGH_JITTER: 31002, HIGH_PACKET_LOSS: 31003, LOW_MOS: 31004, LOW_BYTES_RECEIVED: 32001, LOW_BYTES_SENT: 32002, ICE_CONNECTIVITY_LOST: 33001, ICE_GATHERING_TIMEOUT: 33002, ICE_GATHERING_EMPTY: 33003, PEER_CONNECTION_FAILED: 33004, ONLY_HOST_ICE_CANDIDATES: 33005, ANSWER_WHILE_PEER_ACTIVE: 33006, TOKEN_EXPIRING_SOON: 34001, SESSION_NOT_REATTACHED: 35001 }, { SDP_CREATE_OFFER_FAILED: ti, SDP_CREATE_ANSWER_FAILED: ni, SDP_SET_LOCAL_DESCRIPTION_FAILED: ii, SDP_SET_REMOTE_DESCRIPTION_FAILED: un, SDP_SEND_FAILED: Tt, MEDIA_MICROPHONE_PERMISSION_DENIED: si, MEDIA_DEVICE_NOT_FOUND: oi, MEDIA_GET_USER_MEDIA_FAILED: hn, HOLD_FAILED: ri, INVALID_CALL_PARAMETERS: ai, BYE_SEND_FAILED: ci, SUBSCRIBE_FAILED: li, PEER_CLOSED_DURING_INIT: rt, WEBSOCKET_CONNECTION_FAILED: di, WEBSOCKET_ERROR: ui, RECONNECTION_EXHAUSTED: hi, GATEWAY_FAILED: pi, LOGIN_FAILED: pn, INVALID_CREDENTIALS: fi, AUTHENTICATION_REQUIRED: gi, NETWORK_OFFLINE: vi, UNEXPECTED_ERROR: kt } = Zn, { HIGH_RTT: mi, HIGH_JITTER: _i, HIGH_PACKET_LOSS: yi, LOW_MOS: Rt, LOW_BYTES_RECEIVED: Si, LOW_BYTES_SENT: bi, ICE_CONNECTIVITY_LOST: Ci, ICE_GATHERING_TIMEOUT: wi, ICE_GATHERING_EMPTY: Ei, PEER_CONNECTION_FAILED: Ii, ONLY_HOST_ICE_CANDIDATES: Ti, ANSWER_WHILE_PEER_ACTIVE: ki, TOKEN_EXPIRING_SOON: Ri, SESSION_NOT_REATTACHED: Ai } = ei, Oi = /^a=candidate:.+typ (srflx|prflx|relay)/m, At = "wss://rtc.telnyx.com", Li = 1006, fn = { urls: "stun:stun.l.google.com:19302" }, xi = [{ urls: "stun:stun.telnyx.com:3478" }, fn, { urls: "turn:turn.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turn.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }], Ni = [{ urls: "stun:stundev.telnyx.com:3478" }, fn, { 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 T;
|
|
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.Warning = "telnyx.warning", 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
|
})(T || (T = {}));
|
|
57
|
-
const Oi = { 40001: { name: "SDP_CREATE_OFFER_FAILED", message: "Failed to create call offer", description: "The browser was unable to generate a local SDP offer. This typically indicates a WebRTC API error or invalid media constraints.", causes: ["Browser WebRTC API error", "Missing or invalid media constraints"], solutions: ["Check getUserMedia permissions", "Verify ICE server configuration"] }, 40002: { name: "SDP_CREATE_ANSWER_FAILED", message: "Failed to answer the call", description: "The browser was unable to generate a local SDP answer. The remote offer may be invalid or the browser state inconsistent.", causes: ["Browser WebRTC API error", "Invalid remote SDP offer"], solutions: ["Retry the call", "Check browser WebRTC compatibility"] }, 40003: { name: "SDP_SET_LOCAL_DESCRIPTION_FAILED", message: "Failed to apply local call settings", description: "setLocalDescription() was rejected by the browser. The generated SDP may be malformed or the browser state may be inconsistent.", causes: ["Malformed SDP", "Browser state inconsistency"], solutions: ["Retry the call"] }, 40004: { name: "SDP_SET_REMOTE_DESCRIPTION_FAILED", message: "Failed to apply remote call settings", description: "setRemoteDescription() was rejected by the browser. The remote SDP may be malformed or contain unsupported codecs.", causes: ["Malformed remote SDP", "Browser codec mismatch"], solutions: ["Retry the call", "Check codec configuration"] }, 40005: { name: "SDP_SEND_FAILED", message: "Failed to send call data to server", description: "The Invite or Answer message could not be delivered via the signaling WebSocket. The connection may have been lost.", causes: ["WebSocket connection lost", "Server error"], solutions: ["Check network connectivity", "Retry the call"] }, 42001: { name: "MEDIA_MICROPHONE_PERMISSION_DENIED", message: "Microphone access denied", description: "The user or operating system denied microphone permission. The browser permission prompt was dismissed or OS-level access is disabled.", causes: ["User denied browser permission prompt", "OS-level microphone access disabled"], solutions: ["Ask user to grant microphone permission in browser settings"] }, 42002: { name: "MEDIA_DEVICE_NOT_FOUND", message: "No microphone found", description: "The requested audio input device is not available. No microphone is connected, the device was disconnected, or an invalid deviceId was specified.", causes: ["No microphone connected", "Device was disconnected", "Invalid deviceId"], solutions: ["Check that a microphone is connected", "Select a valid audio input device"] }, 42003: { name: "MEDIA_GET_USER_MEDIA_FAILED", message: "Failed to access microphone", description: "getUserMedia() was rejected for an unexpected reason. The device may be in use by another application or the browser encountered an internal error.", causes: ["Browser error", "Device in use by another application"], solutions: ["Close other applications using the microphone", "Retry"] }, 44001: { name: "HOLD_FAILED", message: "Failed to hold the call", description: "The server rejected or did not respond to the hold request. The WebSocket connection may have been lost during the operation.", causes: ["Server error", "WebSocket connection lost during hold"], solutions: ["Retry the hold operation", "Check network connectivity"] }, 44002: { name: "INVALID_CALL_PARAMETERS", message: "Invalid call parameters", description: "The call could not be initiated because required parameters are missing or invalid. For example, no destination number was provided to newCall().", causes: ["Missing destinationNumber in call options", "Invalid or empty call parameters"], solutions: ["Provide a valid destinationNumber when calling newCall()", "Check the call options object for required fields"] }, 44003: { name: "BYE_SEND_FAILED", message: "Failed to hang up cleanly", description: "The hangup signal could not be delivered to the server. The call was terminated locally but the server may not be aware.", causes: ["WebSocket connection lost before BYE sent"], solutions: ["No action needed — call is terminated locally", "Check network connectivity"] }, 44004: { name: "SUBSCRIBE_FAILED", message: "Failed to subscribe to call events", description: "The Verto subscribe request for the call channel failed. This may prevent receiving call state updates from the server.", causes: ["WebSocket connection lost during subscribe", "Server rejected the subscription request"], solutions: ["Check network connectivity", "Retry the call"] }, 45001: { name: "WEBSOCKET_CONNECTION_FAILED", message: "Unable to connect to server", description: "The WebSocket connection to the signaling server could not be established. The server may be unreachable, the URL may be incorrect, or a firewall may be blocking the connection.", causes: ["Server unreachable", "Incorrect WebSocket URL", "Firewall blocking WebSocket connections", "Network interruption"], solutions: ["Check network connectivity", "Verify the signaling server URL", "Ensure WebSocket connections are not blocked by a firewall"] }, 45002: { name: "WEBSOCKET_ERROR", message: "Connection to server lost", description: "An error occurred on the WebSocket connection after it was established. The connection may have been dropped due to network issues or server-side closure.", causes: ["Network interruption", "Server closed the connection", "Idle timeout"], solutions: ["Check network connectivity", "SDK will attempt automatic reconnection if configured"] }, 45003: { name: "RECONNECTION_EXHAUSTED", message: "Unable to reconnect to server", description: "All automatic reconnection attempts have been exhausted. The SDK tried to re-establish the WebSocket connection multiple times but failed on every attempt.", causes: ["Prolonged network outage", "Server unreachable", "Firewall or proxy blocking reconnection"], solutions: ["Check network connectivity", "Call client.disconnect() and client.connect() to manually retry", "Notify the user that the connection was lost"] }, 45004: { name: "GATEWAY_FAILED", message: "Gateway connection failed", description: "The upstream gateway reported a FAILED or FAIL_WAIT state. The signaling server could not establish or maintain a connection to the gateway. When autoReconnect is disabled, this is immediately fatal. When enabled, the SDK will retry until RECONNECTION_EXHAUSTED.", causes: ["Gateway down or unreachable", "Server-side infrastructure issue", "Network partition between signaling server and gateway"], solutions: ["Wait for automatic reconnection (if autoReconnect is enabled)", "Call client.disconnect() and client.connect() to manually retry", "Check Telnyx service status"] }, 46001: { name: "LOGIN_FAILED", message: "Authentication failed", description: "The login request was rejected by the server. The credentials may be invalid, expired, or the account may be suspended.", causes: ["Invalid credentials (username/password or token)", "Expired authentication token", "Account suspended or disabled"], solutions: ["Verify credentials", "Generate a new authentication token", "Check account status"] }, 46002: { name: "INVALID_CREDENTIALS", message: "Invalid credential parameters", description: "The SDK rejected the login options before sending any request to the server. This is an internal client-side validation guard — the credentials object is missing required fields or has an invalid structure. No network request was made.", causes: ["Missing login and password fields", "Missing or malformed authentication token", "Invalid combination of credential fields in the options object"], solutions: ["Provide valid login/password or a valid authentication token", "Check the TelnyxRTC constructor options against the documentation", "Ensure the credential object matches one of the supported auth modes (credentials, token, or anonymous)"] }, 46003: { name: "AUTHENTICATION_REQUIRED", message: "Authentication required", description: "The server rejected a request because the session is not authenticated. This can happen when the client sends a message (e.g. Invite, Subscribe, or Ping) before login completes, after a token expires mid-session, or after the server drops the authenticated state for any reason.", causes: ["Message sent before login completed", "Authentication token expired during the session", "Server-side session was invalidated", "WebSocket reconnected but re-authentication did not complete"], solutions: ["Ensure the client is fully logged in before sending messages", "Re-authenticate using client.login() with fresh credentials", "Listen for telnyx.ready before making calls or sending requests"] }, 48001: { name: "NETWORK_OFFLINE", message: "Device is offline", description: "The browser reported that the device has lost network connectivity (navigator.onLine === false). All WebSocket and media connections will fail until the network is restored.", causes: ["Wi-Fi or ethernet disconnected", "Airplane mode enabled", "Network interface went down"], solutions: ["Check network connectivity", "Reconnect to Wi-Fi or ethernet", "Disable airplane mode"] }, 49001: { name: "UNEXPECTED_ERROR", message: "An unexpected error occurred", description: "An error was thrown that does not match any known SDK error category. This is a catch-all for unclassified failures.", causes: ["Unknown or unhandled error condition"], solutions: ["Check the originalError property for the underlying cause", "Report the issue if it persists"] } }, Li = { 31001: { name: "HIGH_RTT", message: "High network latency detected", description: "Round-trip time (RTT) exceeded the threshold for multiple consecutive samples. High latency causes perceptible audio delays.", causes: ["Poor network connection", "Geographic distance to media server", "Network congestion"], solutions: ["Check network connectivity", "Use a wired connection instead of Wi-Fi", "Close bandwidth-heavy applications"] }, 31002: { name: "HIGH_JITTER", message: "High jitter detected", description: "Jitter (variability in packet arrival time) exceeded the threshold for multiple consecutive samples. High jitter causes crackling and choppy audio.", causes: ["Network congestion", "Unstable Wi-Fi connection", "Overloaded network equipment"], solutions: ["Use a wired connection instead of Wi-Fi", "Close bandwidth-heavy applications", "Check network equipment"] }, 31003: { name: "HIGH_PACKET_LOSS", message: "High packet loss detected", description: "Packet loss exceeded the threshold for multiple consecutive samples. High packet loss causes choppy audio or dropped calls.", causes: ["Network congestion", "Unstable connection", "Firewall or QoS misconfiguration"], solutions: ["Check network connectivity", "Use a wired connection", "Contact network administrator"] }, 31004: { name: "LOW_MOS", message: "Low call quality score", description: "Mean Opinion Score (MOS) dropped below the acceptable threshold for multiple consecutive samples. This is a composite indicator of overall call quality.", causes: ["Combination of high latency, jitter, and/or packet loss", "Poor network conditions"], solutions: ["Check network connectivity", "Use a wired connection", "Close bandwidth-heavy applications"] }, 32001: { name: "LOW_BYTES_RECEIVED", message: "No audio data received", description: "No bytes have been received from the remote party for multiple consecutive seconds. This may indicate a network interruption or remote-side issue.", causes: ["Network interruption", "Remote party microphone issue", "Firewall blocking inbound media"], solutions: ["Check network connectivity", "Ask remote party to check their microphone", "Check firewall rules for media ports"] }, 32002: { name: "LOW_BYTES_SENT", message: "No audio data being sent", description: "No bytes have been sent for multiple consecutive seconds. This may indicate a local microphone issue or network interruption.", causes: ["Microphone muted or disconnected", "Network interruption", "Local media track ended"], solutions: ["Check that the microphone is not muted", "Verify the microphone is still connected", "Check network connectivity"] }, 33001: { name: "ICE_CONNECTIVITY_LOST", message: "Connection interrupted", description: "The ICE connection transitioned to the disconnected state. The previously selected connection path was lost and renegotiation may be required. The connection may recover automatically.", causes: ["Temporary network interruption", "Network interface change (e.g. Wi-Fi to cellular)", "NAT rebinding"], solutions: ["Wait for automatic recovery", "Check network connectivity"] }, 33002: { name: "ICE_GATHERING_TIMEOUT", message: "ICE gathering timed out", description: "ICE candidate gathering did not complete within the safety timeout. This is typically caused by network restrictions blocking STUN/TURN. The call may still succeed if candidates arrive late.", causes: ["Firewall blocking STUN/TURN", "Network unreachable", "STUN/TURN server not responding"], solutions: ["Check STUN/TURN server reachability", "Ensure UDP traffic is not blocked", "Try forceRelayCandidate option"] }, 33003: { name: "ICE_GATHERING_EMPTY", message: "No ICE candidates gathered", description: "No ICE candidates were gathered after sending the initial SDP. This may indicate a firewall blocking all STUN/TURN traffic or no available network interface.", causes: ["Firewall blocking all STUN/TURN traffic", "No network interface available", "VPN blocking UDP"], solutions: ["Check STUN/TURN server reachability", "Ensure UDP traffic is not blocked", "Use forceRelayCandidate option"] }, 33004: { name: "PEER_CONNECTION_FAILED", message: "Connection failed", description: "RTCPeerConnection entered the failed state. This is a recoverable condition — the SDK may attempt ICE restart or the connection may recover. If it does not recover, the call will eventually be terminated.", causes: ["ICE failure", "DTLS handshake failure", "Prolonged network interruption"], solutions: ["Wait for automatic recovery", "Check network connectivity", "Verify TURN server credentials"] }, 33005: { name: "ONLY_HOST_ICE_CANDIDATES", message: "Only local network candidates available", description: "ICE gathering completed but only host (local network) candidates were collected — no server-reflexive (srflx) or relay (turn) candidates were found. This typically means the STUN/TURN servers are unreachable, which will prevent connections outside the local network.", causes: ["STUN/TURN servers unreachable", "Firewall blocking UDP traffic to STUN/TURN servers", "Incorrect TURN server configuration or credentials", "Restrictive corporate network or VPN"], solutions: ["Verify STUN/TURN server URLs and credentials", "Ensure UDP traffic to STUN/TURN ports is not blocked", "Check firewall or VPN settings", "Try using TCP-based TURN as a fallback"] }, 34001: { name: "TOKEN_EXPIRING_SOON", message: "Authentication token expiring soon", description: "The authentication token is approaching its expiration time. If the token expires the connection will be lost and calls will fail. A new token should be generated before expiration.", causes: ["Token was issued with a limited lifetime"], solutions: ["Generate a new authentication token", "Reconnect with fresh credentials before the token expires"] }, 35001: { name: "SESSION_NOT_REATTACHED", message: "Active call lost after reconnect", description: "The WebSocket reconnected successfully but the server returned an empty reattached_sessions list while the SDK still has an active call. The server no longer knows about the call, so any subsequent call-control operation (hangup, hold, etc.) will fail with CALL_DOES_NOT_EXIST.", causes: ["Server-side session expired during the disconnection window", "Reconnect token was invalidated", "Backend restarted or lost in-memory call state"], solutions: ["Terminate the local call and notify the user", "Start a new call", "Investigate why the session was not preserved on the server"] } };
|
|
58
|
-
function
|
|
59
|
-
const t =
|
|
57
|
+
const Di = { 40001: { name: "SDP_CREATE_OFFER_FAILED", message: "Failed to create call offer", description: "The browser was unable to generate a local SDP offer. This typically indicates a WebRTC API error or invalid media constraints.", causes: ["Browser WebRTC API error", "Missing or invalid media constraints"], solutions: ["Check getUserMedia permissions", "Verify ICE server configuration"] }, 40002: { name: "SDP_CREATE_ANSWER_FAILED", message: "Failed to answer the call", description: "The browser was unable to generate a local SDP answer. The remote offer may be invalid or the browser state inconsistent.", causes: ["Browser WebRTC API error", "Invalid remote SDP offer"], solutions: ["Retry the call", "Check browser WebRTC compatibility"] }, 40003: { name: "SDP_SET_LOCAL_DESCRIPTION_FAILED", message: "Failed to apply local call settings", description: "setLocalDescription() was rejected by the browser. The generated SDP may be malformed or the browser state may be inconsistent.", causes: ["Malformed SDP", "Browser state inconsistency"], solutions: ["Retry the call"] }, 40004: { name: "SDP_SET_REMOTE_DESCRIPTION_FAILED", message: "Failed to apply remote call settings", description: "setRemoteDescription() was rejected by the browser. The remote SDP may be malformed or contain unsupported codecs.", causes: ["Malformed remote SDP", "Browser codec mismatch"], solutions: ["Retry the call", "Check codec configuration"] }, 40005: { name: "SDP_SEND_FAILED", message: "Failed to send call data to server", description: "The Invite or Answer message could not be delivered via the signaling WebSocket. The connection may have been lost.", causes: ["WebSocket connection lost", "Server error"], solutions: ["Check network connectivity", "Retry the call"] }, 42001: { name: "MEDIA_MICROPHONE_PERMISSION_DENIED", message: "Microphone access denied", description: "The user or operating system denied microphone permission. The browser permission prompt was dismissed or OS-level access is disabled.", causes: ["User denied browser permission prompt", "OS-level microphone access disabled"], solutions: ["Ask user to grant microphone permission in browser settings"] }, 42002: { name: "MEDIA_DEVICE_NOT_FOUND", message: "No microphone found", description: "The requested audio input device is not available. No microphone is connected, the device was disconnected, or an invalid deviceId was specified.", causes: ["No microphone connected", "Device was disconnected", "Invalid deviceId"], solutions: ["Check that a microphone is connected", "Select a valid audio input device"] }, 42003: { name: "MEDIA_GET_USER_MEDIA_FAILED", message: "Failed to access microphone", description: "getUserMedia() was rejected for an unexpected reason. The device may be in use by another application or the browser encountered an internal error.", causes: ["Browser error", "Device in use by another application"], solutions: ["Close other applications using the microphone", "Retry"] }, 44005: { name: "PEER_CLOSED_DURING_INIT", message: "Call was closed during setup", description: "The PeerConnection was closed (e.g. by hangup()) while peer.init() was still running. This is a race condition: an async operation such as setRemoteDescription, getUserMedia, or the media recovery flow yielded control, and close() ran during that gap. The init() cannot continue because the underlying RTCPeerConnection has been destroyed.", causes: ["call.hangup() or call.close() was called while the call was still setting up", "A WebSocket Bye message arrived during getUserMedia prompt or SDP negotiation", "User clicked hangup/decline before media permissions were granted"], solutions: ["This is expected if the user intentionally hung up during setup — no action needed", "If this happens frequently without user action, check for automatic hangup triggers that may fire too early"] }, 44001: { name: "HOLD_FAILED", message: "Failed to hold the call", description: "The server rejected or did not respond to the hold request. The WebSocket connection may have been lost during the operation.", causes: ["Server error", "WebSocket connection lost during hold"], solutions: ["Retry the hold operation", "Check network connectivity"] }, 44002: { name: "INVALID_CALL_PARAMETERS", message: "Invalid call parameters", description: "The call could not be initiated because required parameters are missing or invalid. For example, no destination number was provided to newCall().", causes: ["Missing destinationNumber in call options", "Invalid or empty call parameters"], solutions: ["Provide a valid destinationNumber when calling newCall()", "Check the call options object for required fields"] }, 44003: { name: "BYE_SEND_FAILED", message: "Failed to hang up cleanly", description: "The hangup signal could not be delivered to the server. The call was terminated locally but the server may not be aware.", causes: ["WebSocket connection lost before BYE sent"], solutions: ["No action needed — call is terminated locally", "Check network connectivity"] }, 44004: { name: "SUBSCRIBE_FAILED", message: "Failed to subscribe to call events", description: "The Verto subscribe request for the call channel failed. This may prevent receiving call state updates from the server.", causes: ["WebSocket connection lost during subscribe", "Server rejected the subscription request"], solutions: ["Check network connectivity", "Retry the call"] }, 45001: { name: "WEBSOCKET_CONNECTION_FAILED", message: "Unable to connect to server", description: "The WebSocket connection to the signaling server could not be established. The server may be unreachable, the URL may be incorrect, or a firewall may be blocking the connection.", causes: ["Server unreachable", "Incorrect WebSocket URL", "Firewall blocking WebSocket connections", "Network interruption"], solutions: ["Check network connectivity", "Verify the signaling server URL", "Ensure WebSocket connections are not blocked by a firewall"] }, 45002: { name: "WEBSOCKET_ERROR", message: "Connection to server lost", description: "An error occurred on the WebSocket connection after it was established. The connection may have been dropped due to network issues or server-side closure.", causes: ["Network interruption", "Server closed the connection", "Idle timeout"], solutions: ["Check network connectivity", "SDK will attempt automatic reconnection if configured"] }, 45003: { name: "RECONNECTION_EXHAUSTED", message: "Unable to reconnect to server", description: "All automatic reconnection attempts have been exhausted. The SDK tried to re-establish the WebSocket connection multiple times but failed on every attempt.", causes: ["Prolonged network outage", "Server unreachable", "Firewall or proxy blocking reconnection"], solutions: ["Check network connectivity", "Call client.disconnect() and client.connect() to manually retry", "Notify the user that the connection was lost"] }, 45004: { name: "GATEWAY_FAILED", message: "Gateway connection failed", description: "The upstream gateway reported a FAILED or FAIL_WAIT state. The signaling server could not establish or maintain a connection to the gateway. When autoReconnect is disabled, this is immediately fatal. When enabled, the SDK will retry until RECONNECTION_EXHAUSTED.", causes: ["Gateway down or unreachable", "Server-side infrastructure issue", "Network partition between signaling server and gateway"], solutions: ["Wait for automatic reconnection (if autoReconnect is enabled)", "Call client.disconnect() and client.connect() to manually retry", "Check Telnyx service status"] }, 46001: { name: "LOGIN_FAILED", message: "Authentication failed", description: "The login request was rejected by the server. The credentials may be invalid, expired, or the account may be suspended.", causes: ["Invalid credentials (username/password or token)", "Expired authentication token", "Account suspended or disabled"], solutions: ["Verify credentials", "Generate a new authentication token", "Check account status"] }, 46002: { name: "INVALID_CREDENTIALS", message: "Invalid credential parameters", description: "The SDK rejected the login options before sending any request to the server. This is an internal client-side validation guard — the credentials object is missing required fields or has an invalid structure. No network request was made.", causes: ["Missing login and password fields", "Missing or malformed authentication token", "Invalid combination of credential fields in the options object"], solutions: ["Provide valid login/password or a valid authentication token", "Check the TelnyxRTC constructor options against the documentation", "Ensure the credential object matches one of the supported auth modes (credentials, token, or anonymous)"] }, 46003: { name: "AUTHENTICATION_REQUIRED", message: "Authentication required", description: "The server rejected a request because the session is not authenticated. This can happen when the client sends a message (e.g. Invite, Subscribe, or Ping) before login completes, after a token expires mid-session, or after the server drops the authenticated state for any reason.", causes: ["Message sent before login completed", "Authentication token expired during the session", "Server-side session was invalidated", "WebSocket reconnected but re-authentication did not complete"], solutions: ["Ensure the client is fully logged in before sending messages", "Re-authenticate using client.login() with fresh credentials", "Listen for telnyx.ready before making calls or sending requests"] }, 48001: { name: "NETWORK_OFFLINE", message: "Device is offline", description: "The browser reported that the device has lost network connectivity (navigator.onLine === false). All WebSocket and media connections will fail until the network is restored.", causes: ["Wi-Fi or ethernet disconnected", "Airplane mode enabled", "Network interface went down"], solutions: ["Check network connectivity", "Reconnect to Wi-Fi or ethernet", "Disable airplane mode"] }, 49001: { name: "UNEXPECTED_ERROR", message: "An unexpected error occurred", description: "An error was thrown that does not match any known SDK error category. This is a catch-all for unclassified failures.", causes: ["Unknown or unhandled error condition"], solutions: ["Check the originalError property for the underlying cause", "Report the issue if it persists"] } }, Pi = { 31001: { name: "HIGH_RTT", message: "High network latency detected", description: "Round-trip time (RTT) exceeded the threshold for multiple consecutive samples. High latency causes perceptible audio delays.", causes: ["Poor network connection", "Geographic distance to media server", "Network congestion"], solutions: ["Check network connectivity", "Use a wired connection instead of Wi-Fi", "Close bandwidth-heavy applications"] }, 31002: { name: "HIGH_JITTER", message: "High jitter detected", description: "Jitter (variability in packet arrival time) exceeded the threshold for multiple consecutive samples. High jitter causes crackling and choppy audio.", causes: ["Network congestion", "Unstable Wi-Fi connection", "Overloaded network equipment"], solutions: ["Use a wired connection instead of Wi-Fi", "Close bandwidth-heavy applications", "Check network equipment"] }, 31003: { name: "HIGH_PACKET_LOSS", message: "High packet loss detected", description: "Packet loss exceeded the threshold for multiple consecutive samples. High packet loss causes choppy audio or dropped calls.", causes: ["Network congestion", "Unstable connection", "Firewall or QoS misconfiguration"], solutions: ["Check network connectivity", "Use a wired connection", "Contact network administrator"] }, 31004: { name: "LOW_MOS", message: "Low call quality score", description: "Mean Opinion Score (MOS) dropped below the acceptable threshold for multiple consecutive samples. This is a composite indicator of overall call quality.", causes: ["Combination of high latency, jitter, and/or packet loss", "Poor network conditions"], solutions: ["Check network connectivity", "Use a wired connection", "Close bandwidth-heavy applications"] }, 32001: { name: "LOW_BYTES_RECEIVED", message: "No audio data received", description: "No bytes have been received from the remote party for multiple consecutive seconds. This may indicate a network interruption or remote-side issue.", causes: ["Network interruption", "Remote party microphone issue", "Firewall blocking inbound media"], solutions: ["Check network connectivity", "Ask remote party to check their microphone", "Check firewall rules for media ports"] }, 32002: { name: "LOW_BYTES_SENT", message: "No audio data being sent", description: "No bytes have been sent for multiple consecutive seconds. This may indicate a local microphone issue or network interruption.", causes: ["Microphone muted or disconnected", "Network interruption", "Local media track ended"], solutions: ["Check that the microphone is not muted", "Verify the microphone is still connected", "Check network connectivity"] }, 33001: { name: "ICE_CONNECTIVITY_LOST", message: "Connection interrupted", description: "The ICE connection transitioned to the disconnected state. The previously selected connection path was lost and renegotiation may be required. The connection may recover automatically.", causes: ["Temporary network interruption", "Network interface change (e.g. Wi-Fi to cellular)", "NAT rebinding"], solutions: ["Wait for automatic recovery", "Check network connectivity"] }, 33002: { name: "ICE_GATHERING_TIMEOUT", message: "ICE gathering timed out", description: "ICE candidate gathering did not complete within the safety timeout. This is typically caused by network restrictions blocking STUN/TURN. The call may still succeed if candidates arrive late.", causes: ["Firewall blocking STUN/TURN", "Network unreachable", "STUN/TURN server not responding"], solutions: ["Check STUN/TURN server reachability", "Ensure UDP traffic is not blocked", "Try forceRelayCandidate option"] }, 33003: { name: "ICE_GATHERING_EMPTY", message: "No ICE candidates gathered", description: "No ICE candidates were gathered after sending the initial SDP. This may indicate a firewall blocking all STUN/TURN traffic or no available network interface.", causes: ["Firewall blocking all STUN/TURN traffic", "No network interface available", "VPN blocking UDP"], solutions: ["Check STUN/TURN server reachability", "Ensure UDP traffic is not blocked", "Use forceRelayCandidate option"] }, 33004: { name: "PEER_CONNECTION_FAILED", message: "Connection failed", description: "RTCPeerConnection entered the failed state. This is a recoverable condition — the SDK may attempt ICE restart or the connection may recover. If it does not recover, the call will eventually be terminated.", causes: ["ICE failure", "DTLS handshake failure", "Prolonged network interruption"], solutions: ["Wait for automatic recovery", "Check network connectivity", "Verify TURN server credentials"] }, 33005: { name: "ONLY_HOST_ICE_CANDIDATES", message: "Only local network candidates available", description: "ICE gathering completed but only host (local network) candidates were collected — no server-reflexive (srflx) or relay (turn) candidates were found. This typically means the STUN/TURN servers are unreachable, which will prevent connections outside the local network.", causes: ["STUN/TURN servers unreachable", "Firewall blocking UDP traffic to STUN/TURN servers", "Incorrect TURN server configuration or credentials", "Restrictive corporate network or VPN"], solutions: ["Verify STUN/TURN server URLs and credentials", "Ensure UDP traffic to STUN/TURN ports is not blocked", "Check firewall or VPN settings", "Try using TCP-based TURN as a fallback"] }, 33006: { name: "ANSWER_WHILE_PEER_ACTIVE", message: "Call answer ignored because a peer connection is already active", description: "answer() was called on a call that already has an active or connecting peer connection. Creating a second peer connection for the same call would duplicate media negotiation, confuse the remote party, and break call reporting. This is typically caused by application code invoking answer() multiple times (e.g. from multiple event handlers).", causes: ["Application called answer() twice on the same call object", "Multiple click handlers or event listeners triggering answer()"], solutions: ["Ensure answer() is called only once per call", "Disable the answer button after the first click", "Check that answer() is not invoked from multiple event handlers"] }, 34001: { name: "TOKEN_EXPIRING_SOON", message: "Authentication token expiring soon", description: "The authentication token is approaching its expiration time. If the token expires the connection will be lost and calls will fail. A new token should be generated before expiration.", causes: ["Token was issued with a limited lifetime"], solutions: ["Generate a new authentication token", "Reconnect with fresh credentials before the token expires"] }, 35001: { name: "SESSION_NOT_REATTACHED", message: "Active call lost after reconnect", description: "The WebSocket reconnected successfully but the server returned an empty reattached_sessions list while the SDK still has an active call. The server no longer knows about the call, so any subsequent call-control operation (hangup, hold, etc.) will fail with CALL_DOES_NOT_EXIST.", causes: ["Server-side session expired during the disconnection window", "Reconnect token was invalidated", "Backend restarted or lost in-memory call state"], solutions: ["Terminate the local call and notify the user", "Start a new call", "Investigate why the session was not preserved on the server"] } };
|
|
58
|
+
function de(n, e) {
|
|
59
|
+
const t = Pi[n];
|
|
60
60
|
return { code: n, name: t.name, message: t.message, description: t.description, causes: [...t.causes], solutions: [...t.solutions] };
|
|
61
61
|
}
|
|
62
|
-
class
|
|
62
|
+
class Oe extends Error {
|
|
63
63
|
constructor(e) {
|
|
64
|
-
super(e.message || `[${e.code}] ${e.name}`), this.name = e.name, this.code = e.code, this.description = e.description, this.causes = e.causes, this.solutions = e.solutions, this.originalError = e.originalError, Object.setPrototypeOf(this,
|
|
64
|
+
super(e.message || `[${e.code}] ${e.name}`), this.name = e.name, this.code = e.code, this.description = e.description, this.causes = e.causes, this.solutions = e.solutions, this.originalError = e.originalError, Object.setPrototypeOf(this, Oe.prototype);
|
|
65
65
|
}
|
|
66
66
|
toJSON() {
|
|
67
67
|
return { code: this.code, name: this.name, description: this.description, message: this.message, causes: this.causes, solutions: this.solutions, originalError: this.originalError };
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function Le(n) {
|
|
71
71
|
if (n instanceof DOMException) {
|
|
72
|
-
if (n.name === "NotAllowedError") return
|
|
73
|
-
if (n.name === "NotFoundError" || n.name === "OverconstrainedError") return
|
|
72
|
+
if (n.name === "NotAllowedError") return si;
|
|
73
|
+
if (n.name === "NotFoundError" || n.name === "OverconstrainedError") return oi;
|
|
74
74
|
}
|
|
75
|
-
return
|
|
75
|
+
return hn;
|
|
76
76
|
}
|
|
77
77
|
function W(n, e, t) {
|
|
78
|
-
const i =
|
|
79
|
-
return new
|
|
78
|
+
const i = Di[n], s = e instanceof Error ? e : e !== void 0 ? new Error(String(e)) : void 0;
|
|
79
|
+
return new Oe({ code: n, name: i.name, description: i.description, message: t || i.message, causes: [...i.causes], solutions: [...i.solutions], originalError: s });
|
|
80
80
|
}
|
|
81
|
-
var
|
|
82
|
-
function
|
|
81
|
+
var Mi = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
82
|
+
function gn(n, e) {
|
|
83
83
|
return n(e = { exports: {} }, e.exports), e.exports;
|
|
84
84
|
}
|
|
85
|
-
var
|
|
85
|
+
var Ui = gn((function(n) {
|
|
86
86
|
var e, t;
|
|
87
|
-
e =
|
|
87
|
+
e = Mi, t = function() {
|
|
88
88
|
var i = function() {
|
|
89
89
|
}, s = "undefined", o = typeof window !== s && typeof window.navigator !== s && /Trident\/|MSIE /.test(window.navigator.userAgent), r = ["trace", "debug", "info", "warn", "error"];
|
|
90
90
|
function c(m, w) {
|
|
91
|
-
var
|
|
92
|
-
if (typeof
|
|
91
|
+
var x = m[w];
|
|
92
|
+
if (typeof x.bind == "function") return x.bind(m);
|
|
93
93
|
try {
|
|
94
|
-
return Function.prototype.bind.call(
|
|
94
|
+
return Function.prototype.bind.call(x, m);
|
|
95
95
|
} catch {
|
|
96
96
|
return function() {
|
|
97
|
-
return Function.prototype.apply.apply(
|
|
97
|
+
return Function.prototype.apply.apply(x, [m, arguments]);
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function d() {
|
|
102
102
|
console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
|
|
103
103
|
}
|
|
104
104
|
function l(m, w) {
|
|
105
|
-
for (var
|
|
106
|
-
var A = r[
|
|
107
|
-
this[A] =
|
|
105
|
+
for (var x = 0; x < r.length; x++) {
|
|
106
|
+
var A = r[x];
|
|
107
|
+
this[A] = x < m ? i : this.methodFactory(A, m, w);
|
|
108
108
|
}
|
|
109
109
|
this.log = this.debug;
|
|
110
110
|
}
|
|
111
|
-
function f(m, w,
|
|
111
|
+
function f(m, w, x) {
|
|
112
112
|
return function() {
|
|
113
|
-
typeof console !== s && (l.call(this, w,
|
|
113
|
+
typeof console !== s && (l.call(this, w, x), this[m].apply(this, arguments));
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
-
function h(m, w,
|
|
116
|
+
function h(m, w, x) {
|
|
117
117
|
return (function(A) {
|
|
118
|
-
return A === "debug" && (A = "log"), typeof console !== s && (A === "trace" && o ?
|
|
118
|
+
return A === "debug" && (A = "log"), typeof console !== s && (A === "trace" && o ? d : console[A] !== void 0 ? c(console, A) : console.log !== void 0 ? c(console, "log") : i);
|
|
119
119
|
})(m) || f.apply(this, arguments);
|
|
120
120
|
}
|
|
121
|
-
function S(m, w,
|
|
121
|
+
function S(m, w, x) {
|
|
122
122
|
var A, P = this;
|
|
123
123
|
w = w ?? "WARN";
|
|
124
124
|
var M = "loglevel";
|
|
@@ -130,19 +130,19 @@ var xi = hn((function(n) {
|
|
|
130
130
|
} catch {
|
|
131
131
|
}
|
|
132
132
|
if (typeof R === s) try {
|
|
133
|
-
var a = window.document.cookie,
|
|
134
|
-
|
|
133
|
+
var a = window.document.cookie, u = a.indexOf(encodeURIComponent(M) + "=");
|
|
134
|
+
u !== -1 && (R = /^([^;]+)/.exec(a.slice(u))[1]);
|
|
135
135
|
} catch {
|
|
136
136
|
}
|
|
137
137
|
return P.levels[R] === void 0 && (R = void 0), R;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
typeof m == "string" ? M += ":" + m : typeof m == "symbol" && (M = void 0), P.name = m, P.levels = { TRACE: 0, DEBUG: 1, INFO: 2, WARN: 3, ERROR: 4, SILENT: 5 }, P.methodFactory =
|
|
140
|
+
typeof m == "string" ? M += ":" + m : typeof m == "symbol" && (M = void 0), P.name = m, P.levels = { TRACE: 0, DEBUG: 1, INFO: 2, WARN: 3, ERROR: 4, SILENT: 5 }, P.methodFactory = x || h, P.getLevel = function() {
|
|
141
141
|
return A;
|
|
142
142
|
}, P.setLevel = function(R, a) {
|
|
143
143
|
if (typeof R == "string" && P.levels[R.toUpperCase()] !== void 0 && (R = P.levels[R.toUpperCase()]), !(typeof R == "number" && R >= 0 && R <= P.levels.SILENT)) throw "log.setLevel() called with invalid level: " + R;
|
|
144
|
-
if (A = R, a !== !1 && (function(
|
|
145
|
-
var p = (r[
|
|
144
|
+
if (A = R, a !== !1 && (function(u) {
|
|
145
|
+
var p = (r[u] || "silent").toUpperCase();
|
|
146
146
|
if (typeof window !== s && M) {
|
|
147
147
|
try {
|
|
148
148
|
return void (window.localStorage[M] = p);
|
|
@@ -191,8 +191,8 @@ var xi = hn((function(n) {
|
|
|
191
191
|
}, y.default = y, y;
|
|
192
192
|
}, n.exports ? n.exports = t() : e.log = t();
|
|
193
193
|
}));
|
|
194
|
-
const
|
|
195
|
-
class
|
|
194
|
+
const Ot = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
195
|
+
class Fi {
|
|
196
196
|
constructor(e = {}) {
|
|
197
197
|
var t, i, s;
|
|
198
198
|
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,7 +204,7 @@ class Di {
|
|
|
204
204
|
this.isCapturing = !1;
|
|
205
205
|
}
|
|
206
206
|
addEntry(e, t, i) {
|
|
207
|
-
if (!this.isCapturing || !this.options.enabled ||
|
|
207
|
+
if (!this.isCapturing || !this.options.enabled || Ot[e] < Ot[this.options.level]) return;
|
|
208
208
|
const s = Object.assign({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), level: e, message: t }, i && Object.keys(i).length > 0 ? { context: i } : {});
|
|
209
209
|
this.buffer.push(s), this.buffer.length > this.options.maxEntries && this.buffer.shift();
|
|
210
210
|
}
|
|
@@ -228,10 +228,10 @@ class Di {
|
|
|
228
228
|
return this.options.enabled;
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
let
|
|
232
|
-
const g =
|
|
233
|
-
let
|
|
234
|
-
function
|
|
231
|
+
let vn = null;
|
|
232
|
+
const g = Ui.getLogger("telnyx"), Ge = { trace: 0, debug: 1, info: 2, warn: 3, error: 4 };
|
|
233
|
+
let mn = Ge.info;
|
|
234
|
+
function Lt(n) {
|
|
235
235
|
if (n == null || typeof n != "object") return n;
|
|
236
236
|
try {
|
|
237
237
|
const t = JSON.stringify(n), i = JSON.parse(t);
|
|
@@ -252,24 +252,24 @@ function At(n) {
|
|
|
252
252
|
}
|
|
253
253
|
return Object.keys(e).length > 0 ? e : { value: String(n) };
|
|
254
254
|
}
|
|
255
|
-
const
|
|
255
|
+
const ji = g.methodFactory;
|
|
256
256
|
g.methodFactory = (n, e, t) => {
|
|
257
|
-
const i =
|
|
257
|
+
const i = ji(n, e, t);
|
|
258
258
|
return function(...s) {
|
|
259
|
-
if (
|
|
259
|
+
if (Ge[n] >= mn) {
|
|
260
260
|
const r = [(/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), "-"];
|
|
261
261
|
for (const c of s) r.push(c);
|
|
262
262
|
i(...r);
|
|
263
263
|
}
|
|
264
|
-
const o =
|
|
264
|
+
const o = vn;
|
|
265
265
|
if (o?.isActive()) {
|
|
266
|
-
const [r, ...c] = s,
|
|
266
|
+
const [r, ...c] = s, d = typeof r == "string" ? r : JSON.stringify(r);
|
|
267
267
|
let l;
|
|
268
|
-
c.length > 0 && (l = c.length === 1 && typeof c[0] == "object" && c[0] !== null ?
|
|
268
|
+
c.length > 0 && (l = c.length === 1 && typeof c[0] == "object" && c[0] !== null ? Lt(c[0]) : { args: c.map(Lt) }), o.addEntry(n, d, l);
|
|
269
269
|
}
|
|
270
270
|
};
|
|
271
271
|
}, g.setLevel("debug", !1);
|
|
272
|
-
const
|
|
272
|
+
const Fe = (n) => {
|
|
273
273
|
const [e, t, i, s, o, r] = n;
|
|
274
274
|
let c = {};
|
|
275
275
|
try {
|
|
@@ -278,79 +278,79 @@ const Ue = (n) => {
|
|
|
278
278
|
g.warn("Verto LA invalid media JSON string:", o);
|
|
279
279
|
}
|
|
280
280
|
return { participantId: Number(e), participantNumber: t, participantName: i, codec: s, media: c, participantData: r };
|
|
281
|
-
},
|
|
281
|
+
}, _n = (n) => {
|
|
282
282
|
if (typeof n != "string") return n;
|
|
283
283
|
try {
|
|
284
284
|
return JSON.parse(n);
|
|
285
285
|
} catch {
|
|
286
286
|
return n;
|
|
287
287
|
}
|
|
288
|
-
}, Se = (n) => n instanceof Function || typeof n == "function",
|
|
288
|
+
}, Se = (n) => n instanceof Function || typeof n == "function", Ve = (n) => typeof document == "object" && "getElementById" in document ? typeof n == "string" ? document.getElementById(n) || null : typeof n == "function" ? n() : n instanceof HTMLMediaElement ? n : null : null, Bi = /^(ws|wss):\/\//, yn = (n, e = null) => {
|
|
289
289
|
const { result: t = {}, error: i } = n;
|
|
290
290
|
if (i) return { error: i };
|
|
291
291
|
const { result: s = null } = t;
|
|
292
292
|
if (s === null) return e !== null && (t.node_id = e), { result: t };
|
|
293
293
|
const { code: o = null, node_id: r = null, result: c = null } = s;
|
|
294
|
-
return o && o !== "200" ? { error: s } : c ?
|
|
295
|
-
},
|
|
294
|
+
return o && o !== "200" ? { error: s } : c ? yn(c, r) : { result: s };
|
|
295
|
+
}, Sn = (n, e) => Math.floor(Math.random() * (e - n + 1) + n), qe = ({ login: n, passwd: e, password: t, login_token: i }) => !!(n && (e || t) || i), ke = ({ anonymous_login: n }) => !!n && !!n.target_id && !!n.target_type, bt = (n) => {
|
|
296
296
|
var e, t, i, s, o, r;
|
|
297
|
-
let c = "",
|
|
298
|
-
return !((t = (e = n?.result) === null || e === void 0 ? void 0 : e.params) === null || t === void 0) && t.state && (c = (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 && (
|
|
297
|
+
let c = "", d = "";
|
|
298
|
+
return !((t = (e = n?.result) === null || e === void 0 ? void 0 : e.params) === null || t === void 0) && t.state && (c = (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 && (d = (r = n?.params) === null || r === void 0 ? void 0 : r.state), c || d;
|
|
299
299
|
};
|
|
300
|
-
function
|
|
300
|
+
function xt({ debounceTime: n }) {
|
|
301
301
|
let e, t;
|
|
302
302
|
return { promise: new Promise(((i, s) => {
|
|
303
|
-
e = n ?
|
|
303
|
+
e = n ? Hi(i, n) : i, t = s;
|
|
304
304
|
})), resolve: e, reject: t };
|
|
305
305
|
}
|
|
306
|
-
const
|
|
306
|
+
const Hi = (n, e) => {
|
|
307
307
|
let t;
|
|
308
308
|
return (...i) => {
|
|
309
309
|
clearTimeout(t), t = window.setTimeout((() => {
|
|
310
310
|
n(...i);
|
|
311
311
|
}), e);
|
|
312
312
|
};
|
|
313
|
-
},
|
|
313
|
+
}, Ct = "telnyx-voice-sdk-id";
|
|
314
314
|
function fe() {
|
|
315
|
-
return sessionStorage.getItem(
|
|
315
|
+
return sessionStorage.getItem(Ct);
|
|
316
316
|
}
|
|
317
|
-
function
|
|
318
|
-
sessionStorage.removeItem(
|
|
317
|
+
function bn() {
|
|
318
|
+
sessionStorage.removeItem(Ct);
|
|
319
319
|
}
|
|
320
|
-
var
|
|
320
|
+
var z, ce, H;
|
|
321
321
|
typeof window < "u" && window.addEventListener("beforeunload", (() => {
|
|
322
|
-
|
|
322
|
+
bn();
|
|
323
323
|
})), (function(n) {
|
|
324
324
|
n.Offer = "offer", n.Answer = "answer";
|
|
325
|
-
})(
|
|
325
|
+
})(z || (z = {})), (function(n) {
|
|
326
326
|
n.Inbound = "inbound", n.Outbound = "outbound";
|
|
327
327
|
})(ce || (ce = {})), (function(n) {
|
|
328
328
|
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";
|
|
329
|
-
})(
|
|
330
|
-
const re = { generic: "event", [
|
|
331
|
-
var U,
|
|
329
|
+
})(H || (H = {}));
|
|
330
|
+
const re = { generic: "event", [H.Display]: "participantData", [H.Attach]: "participantData", conferenceUpdate: "conferenceUpdate", callUpdate: "callUpdate", vertoClientReady: "vertoClientReady", userMediaError: "userMediaError", peerConnectionFailureError: "peerConnectionFailureError", signalingStateClosed: "signalingStateClosed" }, $i = { invalidCredentialsOptions: "InvalidCredentialsOptions" }, Wi = { 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 };
|
|
331
|
+
var U, ut, oe, le, ne;
|
|
332
332
|
(function(n) {
|
|
333
333
|
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";
|
|
334
334
|
})(U || (U = {})), (function(n) {
|
|
335
335
|
n.Participant = "participant", n.Moderator = "moderator";
|
|
336
|
-
})(
|
|
336
|
+
})(ut || (ut = {})), (function(n) {
|
|
337
337
|
n.Join = "join", n.Leave = "leave", n.Bootstrap = "bootstrap", n.Add = "add", n.Modify = "modify", n.Delete = "delete", n.Clear = "clear", n.ChatMessage = "chatMessage", n.LayerInfo = "layerInfo", n.LogoInfo = "logoInfo", n.LayoutInfo = "layoutInfo", n.LayoutList = "layoutList", n.ModCmdResponse = "modCommandResponse";
|
|
338
338
|
})(oe || (oe = {})), (function(n) {
|
|
339
339
|
n.Video = "videoinput", n.AudioIn = "audioinput", n.AudioOut = "audiooutput";
|
|
340
340
|
})(le || (le = {})), (function(n) {
|
|
341
341
|
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";
|
|
342
342
|
})(ne || (ne = {}));
|
|
343
|
-
const be = "GLOBAL", se = {},
|
|
344
|
-
const i =
|
|
343
|
+
const be = "GLOBAL", se = {}, Pe = (n, e) => `${n}|${e}`, Cn = (n, e = be) => Pe(n, e) in se, he = (n, e, t = be) => {
|
|
344
|
+
const i = Pe(n, t);
|
|
345
345
|
i in se || (se[i] = []), se[i].push(e);
|
|
346
|
-
},
|
|
346
|
+
}, wn = (n, e, t = be) => {
|
|
347
347
|
const i = function(s) {
|
|
348
348
|
pe(n, i, t), e(s);
|
|
349
349
|
};
|
|
350
350
|
return i.prototype.targetRef = e, he(n, i, t);
|
|
351
351
|
}, pe = (n, e, t = be) => {
|
|
352
|
-
if (!
|
|
353
|
-
const i =
|
|
352
|
+
if (!Cn(n, t)) return !1;
|
|
353
|
+
const i = Pe(n, t);
|
|
354
354
|
if (Se(e))
|
|
355
355
|
for (let s = se[i].length - 1; s >= 0; s--) {
|
|
356
356
|
const o = se[i][s];
|
|
@@ -360,34 +360,34 @@ const be = "GLOBAL", se = {}, De = (n, e) => `${n}|${e}`, yn = (n, e = be) => De
|
|
|
360
360
|
return se[i].length === 0 && delete se[i], !0;
|
|
361
361
|
}, L = (n, e, t = be, i = !0) => {
|
|
362
362
|
const s = i && t !== be;
|
|
363
|
-
if (!
|
|
364
|
-
const o =
|
|
363
|
+
if (!Cn(n, t)) return s && L(n, e), !1;
|
|
364
|
+
const o = Pe(n, t), r = se[o].length;
|
|
365
365
|
if (!r) return s && L(n, e), !1;
|
|
366
366
|
for (let c = r - 1; c >= 0; c--) se[o][c](e);
|
|
367
367
|
return s && L(n, e), !0;
|
|
368
|
-
},
|
|
369
|
-
const e =
|
|
368
|
+
}, at = (n) => {
|
|
369
|
+
const e = Pe(n, "");
|
|
370
370
|
Object.keys(se).filter(((t) => t.indexOf(e) === 0)).forEach(((t) => delete se[t]));
|
|
371
371
|
};
|
|
372
|
-
let
|
|
373
|
-
const
|
|
374
|
-
class
|
|
372
|
+
let Gi = typeof WebSocket < "u" ? WebSocket : null;
|
|
373
|
+
const Vi = 0, qi = 1, Yi = 2, Nt = 3;
|
|
374
|
+
class Dt {
|
|
375
375
|
constructor(e) {
|
|
376
|
-
this.session = e, this.previousGatewayState = "", this._wsClient = null, this._host =
|
|
376
|
+
this.session = e, this.previousGatewayState = "", this._wsClient = null, this._host = At, this._timers = {}, this._useCanaryRtcServer = !1, this._hasCanaryBeenUsed = !1, this._safetyTimeoutId = null, this.upDur = null, this.downDur = null;
|
|
377
377
|
const { host: t, env: i, region: s, useCanaryRtcServer: o } = e.options;
|
|
378
|
-
i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" :
|
|
378
|
+
i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : At), t && (this._host = ((r) => `${Bi.test(r) ? "" : "wss://"}${r}`)(t)), s && (this._host = this._host.replace(/rtc(dev)?/, `${s}.rtc$1`)), o && (this._useCanaryRtcServer = !0);
|
|
379
379
|
}
|
|
380
380
|
get connected() {
|
|
381
|
-
return !!this._wsClient && this._wsClient.readyState ===
|
|
381
|
+
return !!this._wsClient && this._wsClient.readyState === qi;
|
|
382
382
|
}
|
|
383
383
|
get connecting() {
|
|
384
|
-
return !!this._wsClient && this._wsClient.readyState ===
|
|
384
|
+
return !!this._wsClient && this._wsClient.readyState === Vi;
|
|
385
385
|
}
|
|
386
386
|
get closing() {
|
|
387
|
-
return !!this._wsClient && this._wsClient.readyState ===
|
|
387
|
+
return !!this._wsClient && this._wsClient.readyState === Yi;
|
|
388
388
|
}
|
|
389
389
|
get closed() {
|
|
390
|
-
return !!this._wsClient && this._wsClient.readyState ===
|
|
390
|
+
return !!this._wsClient && this._wsClient.readyState === Nt;
|
|
391
391
|
}
|
|
392
392
|
get isAlive() {
|
|
393
393
|
return this.connecting || this.connected;
|
|
@@ -401,12 +401,12 @@ class Nt {
|
|
|
401
401
|
connect() {
|
|
402
402
|
const e = new URL(this._host);
|
|
403
403
|
let t = fe();
|
|
404
|
-
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);
|
|
404
|
+
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), this.session.options.skipLastVoiceSdkId && e.searchParams.has("voice_sdk_id") && e.searchParams.set("skip_last_voice_sdk_id", "true");
|
|
405
405
|
try {
|
|
406
|
-
this._wsClient = new
|
|
406
|
+
this._wsClient = new Gi(e.toString()), this._registerSocketEvents(this._wsClient);
|
|
407
407
|
} catch (i) {
|
|
408
408
|
g.error("WebSocket connection failed:", i);
|
|
409
|
-
const s = W(
|
|
409
|
+
const s = W(di, i);
|
|
410
410
|
L(T.Error, { error: s, sessionId: this.session.sessionid }, this.session.uuid);
|
|
411
411
|
}
|
|
412
412
|
}
|
|
@@ -418,9 +418,9 @@ class Nt {
|
|
|
418
418
|
var t;
|
|
419
419
|
const { request: i } = e, s = new Promise(((o, r) => {
|
|
420
420
|
if (i.hasOwnProperty("result")) return o();
|
|
421
|
-
|
|
422
|
-
const { result:
|
|
423
|
-
return l ? r(l) : o(
|
|
421
|
+
wn(i.id, ((c) => {
|
|
422
|
+
const { result: d, error: l } = yn(c);
|
|
423
|
+
return l ? r(l) : o(d);
|
|
424
424
|
}));
|
|
425
425
|
}));
|
|
426
426
|
return g.debug(`SEND:
|
|
@@ -435,17 +435,17 @@ class Nt {
|
|
|
435
435
|
_registerSocketEvents(e) {
|
|
436
436
|
e.onopen = (t) => L(T.SocketOpen, t, this.session.uuid), e.onclose = (t) => (this._clearSafetyTimeout(), this._safetyCleanupSocket(e, "close"), L(T.SocketClose, t, this.session.uuid)), e.onerror = (t) => {
|
|
437
437
|
this._clearSafetyTimeout(), this._safetyCleanupSocket(e, "error");
|
|
438
|
-
const i = W(
|
|
438
|
+
const i = W(ui);
|
|
439
439
|
return L(T.Error, { error: i, sessionId: this.session.sessionid }, this.session.uuid), L(T.SocketError, { error: t, sessionId: this.session.sessionid }, this.session.uuid);
|
|
440
440
|
}, e.onmessage = (t) => {
|
|
441
441
|
var i, s;
|
|
442
|
-
const o =
|
|
442
|
+
const o = _n(t.data);
|
|
443
443
|
var r;
|
|
444
444
|
if (typeof o != "string") {
|
|
445
|
-
if (o.voice_sdk_id && (r = o.voice_sdk_id, sessionStorage.setItem(
|
|
445
|
+
if (o.voice_sdk_id && (r = o.voice_sdk_id, sessionStorage.setItem(Ct, r)), this._unsetTimer(o.id), g.debug(`RECV:
|
|
446
446
|
`, JSON.stringify(o, null, 2), `
|
|
447
447
|
`), ne[`${(s = (i = o?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state}`] || !L(o.id, o)) {
|
|
448
|
-
const c =
|
|
448
|
+
const c = bt(o);
|
|
449
449
|
L(T.SocketMessage, o, this.session.uuid), c && (this.previousGatewayState = c);
|
|
450
450
|
}
|
|
451
451
|
} else this._handleStringResponse(o);
|
|
@@ -455,7 +455,7 @@ class Nt {
|
|
|
455
455
|
e.onopen = null, e.onclose = null, e.onerror = null, e.onmessage = null;
|
|
456
456
|
}
|
|
457
457
|
_handleCloseTimeout(e) {
|
|
458
|
-
this._safetyTimeoutId = null, e && e.readyState !==
|
|
458
|
+
this._safetyTimeoutId = null, e && e.readyState !== Nt ? (g.warn("Socket stuck in CLOSING after 5s — forcefully cleaning up"), this._deregisterSocketEvents(e), this._safetyCleanupSocket(e, "timeout"), this._wsClient && this._wsClient !== e || L(T.SocketClose, { code: Li, 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");
|
|
459
459
|
}
|
|
460
460
|
_clearSafetyTimeout() {
|
|
461
461
|
this._safetyTimeoutId && (g.debug("Clearing safety timeout"), clearTimeout(this._safetyTimeoutId), this._safetyTimeoutId = null);
|
|
@@ -477,124 +477,124 @@ class Nt {
|
|
|
477
477
|
else g.warn("Unknown message from socket", e);
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
|
-
class
|
|
480
|
+
class Me {
|
|
481
481
|
buildRequest(e) {
|
|
482
482
|
this.request = Object.assign({ jsonrpc: "2.0", id: ye() }, e);
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
|
-
const
|
|
486
|
-
class ee extends
|
|
485
|
+
const Pt = { id: "callID", destinationNumber: "destination_number", remoteCallerName: "remote_caller_id_name", remoteCallerNumber: "remote_caller_id_number", callerName: "caller_id_name", callerNumber: "caller_id_number", customHeaders: "custom_headers" };
|
|
486
|
+
class ee extends Me {
|
|
487
487
|
constructor(e = {}) {
|
|
488
488
|
if (super(), e.hasOwnProperty("dialogParams")) {
|
|
489
|
-
const t =
|
|
490
|
-
for (const i in
|
|
489
|
+
const t = We(e.dialogParams, ["remoteSdp", "localStream", "remoteStream", "localElement", "remoteElement", "onNotification", "camId", "micId", "speakerId"]);
|
|
490
|
+
for (const i in Pt) i && t.hasOwnProperty(i) && (t[Pt[i]] = t[i], delete t[i]);
|
|
491
491
|
e.dialogParams = t;
|
|
492
492
|
}
|
|
493
493
|
this.buildRequest({ method: this.toString(), params: e });
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
class
|
|
496
|
+
class En extends ee {
|
|
497
497
|
constructor(e) {
|
|
498
|
-
super(), this.method =
|
|
498
|
+
super(), this.method = H.GatewayState, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
|
-
class
|
|
501
|
+
class Ji {
|
|
502
502
|
constructor(e) {
|
|
503
503
|
this.pendingRequestId = null, this.onSocketMessage = (t) => O(this, void 0, void 0, (function* () {
|
|
504
|
-
t.id === this.pendingRequestId && this.gatewayStateTask.resolve(
|
|
504
|
+
t.id === this.pendingRequestId && this.gatewayStateTask.resolve(bt(t));
|
|
505
505
|
})), this.getIsRegistered = () => O(this, void 0, void 0, (function* () {
|
|
506
|
-
const t = new
|
|
507
|
-
this.pendingRequestId = t.request.id, this.gatewayStateTask =
|
|
506
|
+
const t = new En(fe());
|
|
507
|
+
this.pendingRequestId = t.request.id, this.gatewayStateTask = xt({}), this.session.execute(t);
|
|
508
508
|
const i = yield this.gatewayStateTask.promise;
|
|
509
509
|
return !!i && [ne.REGISTER, ne.REGED].includes(i);
|
|
510
|
-
})), this.session = e, this.gatewayStateTask =
|
|
510
|
+
})), this.session = e, this.gatewayStateTask = xt({}), this.session.on("telnyx.socket.message", this.onSocketMessage);
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
|
-
class
|
|
513
|
+
class In extends ee {
|
|
514
514
|
constructor(e) {
|
|
515
|
-
super(), this.method =
|
|
515
|
+
super(), this.method = H.Ping, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
|
-
var
|
|
519
|
-
class
|
|
518
|
+
var Tn = "2.26.4", wt = Tn;
|
|
519
|
+
class Ki extends ee {
|
|
520
520
|
constructor(e, t, i, s, o = {}, r) {
|
|
521
521
|
super(), this.method = "login";
|
|
522
|
-
const c = { login: e, passwd: t, login_token: i, userVariables: o, reconnection: r, loginParams: {}, "User-Agent": { sdkVersion:
|
|
522
|
+
const c = { login: e, passwd: t, login_token: i, userVariables: o, reconnection: r, loginParams: {}, "User-Agent": { sdkVersion: wt, data: navigator.userAgent } };
|
|
523
523
|
s && (c.sessid = s), this.buildRequest({ method: this.method, params: c });
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
-
class
|
|
526
|
+
class Xi extends ee {
|
|
527
527
|
constructor(e, t) {
|
|
528
528
|
super(), this.buildRequest({ id: e, result: { method: t } });
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
|
-
class
|
|
531
|
+
class Mt extends ee {
|
|
532
532
|
toString() {
|
|
533
|
-
return
|
|
533
|
+
return H.Invite;
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
|
-
class
|
|
536
|
+
class Ut extends ee {
|
|
537
537
|
toString() {
|
|
538
|
-
return
|
|
538
|
+
return H.Answer;
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
|
-
class
|
|
541
|
+
class Ft extends ee {
|
|
542
542
|
toString() {
|
|
543
|
-
return
|
|
543
|
+
return H.Attach;
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
|
-
class
|
|
546
|
+
class zi extends ee {
|
|
547
547
|
toString() {
|
|
548
|
-
return
|
|
548
|
+
return H.Bye;
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
|
-
class
|
|
551
|
+
class Qi extends ee {
|
|
552
552
|
toString() {
|
|
553
|
-
return
|
|
553
|
+
return H.Candidate;
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
|
-
class
|
|
556
|
+
class Zi extends ee {
|
|
557
557
|
toString() {
|
|
558
|
-
return
|
|
558
|
+
return H.EndOfCandidates;
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
|
-
class
|
|
561
|
+
class ct extends ee {
|
|
562
562
|
toString() {
|
|
563
|
-
return
|
|
563
|
+
return H.Modify;
|
|
564
564
|
}
|
|
565
565
|
}
|
|
566
|
-
class
|
|
566
|
+
class jt extends ee {
|
|
567
567
|
toString() {
|
|
568
|
-
return
|
|
568
|
+
return H.Info;
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
|
-
class
|
|
571
|
+
class es extends ee {
|
|
572
572
|
toString() {
|
|
573
|
-
return
|
|
573
|
+
return H.Broadcast;
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
|
-
class
|
|
576
|
+
class ts extends ee {
|
|
577
577
|
toString() {
|
|
578
|
-
return
|
|
578
|
+
return H.Subscribe;
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
|
-
class
|
|
581
|
+
class ns extends ee {
|
|
582
582
|
toString() {
|
|
583
|
-
return
|
|
583
|
+
return H.Unsubscribe;
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
|
-
class
|
|
586
|
+
class is extends ee {
|
|
587
587
|
constructor(e) {
|
|
588
588
|
super(), this.method = "anonymous_login";
|
|
589
|
-
const { target_type: t, target_id: i, target_version_id: s, target_params: o, userVariables: r, sessionId: c, reconnection:
|
|
589
|
+
const { target_type: t, target_id: i, target_version_id: s, target_params: o, userVariables: r, sessionId: c, reconnection: d } = e, l = { target_type: t, target_id: i, userVariables: r, reconnection: d, "User-Agent": { sdkVersion: wt, data: navigator.userAgent } };
|
|
590
590
|
c && (l.sessid = c), s && (l.target_version_id = s), o && (l.target_params = o), this.buildRequest({ method: this.method, params: l });
|
|
591
591
|
}
|
|
592
592
|
}
|
|
593
|
-
class
|
|
593
|
+
class xe {
|
|
594
594
|
constructor(e) {
|
|
595
595
|
if (this.options = e, this.uuid = ye(), 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.dc = null, this.region = null, this.connection = null, this._jwtAuth = !1, this._autoReconnect = !0, this._idle = !1, this._tokenExpiryTimeout = null, this._executeQueue = [], !this.validateOptions()) throw new Error("Invalid init options");
|
|
596
596
|
var t, i;
|
|
597
|
-
t = e.debug ? "debug" : "info",
|
|
597
|
+
t = e.debug ? "debug" : "info", mn = (i = Ge[t]) !== null && i !== void 0 ? i : Ge.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 Dt(this), this.registerAgent = new Ji(this);
|
|
598
598
|
}
|
|
599
599
|
get __logger() {
|
|
600
600
|
return g;
|
|
@@ -608,13 +608,13 @@ class Le {
|
|
|
608
608
|
}));
|
|
609
609
|
}
|
|
610
610
|
get reconnectDelay() {
|
|
611
|
-
return 1e3 *
|
|
611
|
+
return 1e3 * Sn(2, 6);
|
|
612
612
|
}
|
|
613
613
|
execute(e) {
|
|
614
614
|
return this._idle ? new Promise(((t) => this._executeQueue.push({ resolve: t, msg: e }))) : this.connected ? this.connection.send(e).catch(((t) => O(this, void 0, void 0, (function* () {
|
|
615
615
|
if (t?.code === this.authenticationRequiredErrorCode) {
|
|
616
616
|
if (!this._autoReconnect) {
|
|
617
|
-
const i = W(
|
|
617
|
+
const i = W(gi, t);
|
|
618
618
|
L(T.Error, { error: i, sessionId: this.sessionid }, this.uuid);
|
|
619
619
|
}
|
|
620
620
|
yield this.login();
|
|
@@ -628,7 +628,7 @@ class Le {
|
|
|
628
628
|
this._idle ? this._executeQueue.push({ msg: e }) : this.connection.sendRawText(e);
|
|
629
629
|
}
|
|
630
630
|
validateOptions() {
|
|
631
|
-
return
|
|
631
|
+
return qe(this.options) || ke(this.options);
|
|
632
632
|
}
|
|
633
633
|
broadcast(e) {
|
|
634
634
|
}
|
|
@@ -645,15 +645,15 @@ class Le {
|
|
|
645
645
|
}
|
|
646
646
|
connect() {
|
|
647
647
|
return O(this, void 0, void 0, (function* () {
|
|
648
|
-
this.connection || (g.debug("No existing connection found, creating a new one."), this.connection = new
|
|
648
|
+
this.connection || (g.debug("No existing connection found, creating a new one."), this.connection = new Dt(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.");
|
|
649
649
|
}));
|
|
650
650
|
}
|
|
651
651
|
_handleLoginError(e) {
|
|
652
|
-
const t = W(
|
|
652
|
+
const t = W(pn, e);
|
|
653
653
|
L(T.Error, { error: t, sessionId: this.sessionid }, this.uuid);
|
|
654
654
|
}
|
|
655
655
|
clearReconnectToken() {
|
|
656
|
-
|
|
656
|
+
bn();
|
|
657
657
|
}
|
|
658
658
|
_checkTokenExpiry() {
|
|
659
659
|
this._clearTokenExpiryTimeout();
|
|
@@ -665,9 +665,9 @@ class Le {
|
|
|
665
665
|
if (typeof i != "number") return;
|
|
666
666
|
const s = i - Math.floor(Date.now() / 1e3);
|
|
667
667
|
if (s <= 0) return;
|
|
668
|
-
if (s <=
|
|
668
|
+
if (s <= xe.TOKEN_EXPIRY_WARNING_SECONDS) this._emitTokenExpiryWarning();
|
|
669
669
|
else {
|
|
670
|
-
const o = 1e3 * (s -
|
|
670
|
+
const o = 1e3 * (s - xe.TOKEN_EXPIRY_WARNING_SECONDS);
|
|
671
671
|
this._tokenExpiryTimeout = setTimeout((() => {
|
|
672
672
|
this._emitTokenExpiryWarning();
|
|
673
673
|
}), o);
|
|
@@ -677,7 +677,7 @@ class Le {
|
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
679
|
_emitTokenExpiryWarning() {
|
|
680
|
-
const e =
|
|
680
|
+
const e = de(Ri);
|
|
681
681
|
L(T.Warning, { warning: e, sessionId: this.sessionid }, this.uuid);
|
|
682
682
|
}
|
|
683
683
|
_clearTokenExpiryTimeout() {
|
|
@@ -686,13 +686,13 @@ class Le {
|
|
|
686
686
|
login({ creds: e, onSuccess: t, onError: i } = {}) {
|
|
687
687
|
return O(this, void 0, void 0, (function* () {
|
|
688
688
|
if (this.connection && this.connection.isAlive) {
|
|
689
|
-
if (e && (e.login !== void 0 && (this.options.login = e.login), e.password !== void 0 && (this.options.password = e.password), e.passwd !== void 0 && (this.options.passwd = e.passwd), e.login_token !== void 0 && (this.options.login_token = e.login_token), e.userVariables !== void 0 && (this.options.userVariables = e.userVariables), e.anonymous_login !== void 0 && (this.options.anonymous_login = e.anonymous_login)),
|
|
689
|
+
if (e && (e.login !== void 0 && (this.options.login = e.login), e.password !== void 0 && (this.options.password = e.password), e.passwd !== void 0 && (this.options.passwd = e.passwd), e.login_token !== void 0 && (this.options.login_token = e.login_token), e.userVariables !== void 0 && (this.options.userVariables = e.userVariables), e.anonymous_login !== void 0 && (this.options.anonymous_login = e.anonymous_login)), qe(this.options)) return this._login({ type: "login", onSuccess: t, onError: i });
|
|
690
690
|
if (ke(this.options)) return this._login({ type: "anonymous_login", onSuccess: t, onError: i });
|
|
691
691
|
{
|
|
692
692
|
const s = "Invalid login options provided for authentication.";
|
|
693
693
|
g.error(s);
|
|
694
|
-
const o = W(
|
|
695
|
-
return void L(T.Error, { error: o, type:
|
|
694
|
+
const o = W(fi, void 0, s);
|
|
695
|
+
return void L(T.Error, { error: o, type: $i.invalidCredentialsOptions, sessionId: this.sessionid }, this.uuid);
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
698
|
}));
|
|
@@ -700,7 +700,7 @@ class Le {
|
|
|
700
700
|
_login({ type: e, onSuccess: t, onError: i }) {
|
|
701
701
|
return O(this, void 0, void 0, (function* () {
|
|
702
702
|
let s;
|
|
703
|
-
s = e === "login" ? new
|
|
703
|
+
s = e === "login" ? new Ki(this.options.login, this.options.password || this.options.passwd, this.options.login_token, this.sessionid, this.options.userVariables, !!fe()) : new is({ 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: !!fe() });
|
|
704
704
|
const o = yield this.execute(s).catch(((r) => {
|
|
705
705
|
this._handleLoginError(r), i && i(r);
|
|
706
706
|
}));
|
|
@@ -712,8 +712,8 @@ class Le {
|
|
|
712
712
|
}));
|
|
713
713
|
}
|
|
714
714
|
onNetworkClose() {
|
|
715
|
-
this.relayProtocol &&
|
|
716
|
-
for (const e in this.subscriptions)
|
|
715
|
+
this.relayProtocol && at(this.relayProtocol);
|
|
716
|
+
for (const e in this.subscriptions) at(e);
|
|
717
717
|
this.subscriptions = {}, this.contexts = [], clearTimeout(this._keepAliveTimeout), clearTimeout(this._reconnectTimeout), this.connection && (this.connection.previousGatewayState = ""), this._autoReconnect && (this._reconnectTimeout = setTimeout((() => {
|
|
718
718
|
g.debug("Calling connect due to network close and auto-reconnect enabled."), this.connect();
|
|
719
719
|
}), this.reconnectDelay));
|
|
@@ -721,7 +721,7 @@ class Le {
|
|
|
721
721
|
_onSocketMessage(e) {
|
|
722
722
|
}
|
|
723
723
|
_removeSubscription(e, t) {
|
|
724
|
-
this._existsSubscription(e, t) && (t ? (delete this.subscriptions[e][t], pe(e, null, t)) : (delete this.subscriptions[e],
|
|
724
|
+
this._existsSubscription(e, t) && (t ? (delete this.subscriptions[e][t], pe(e, null, t)) : (delete this.subscriptions[e], at(e)));
|
|
725
725
|
}
|
|
726
726
|
_addSubscription(e, t = null, i) {
|
|
727
727
|
this._existsSubscription(e, i) || (this._existsSubscription(e) || (this.subscriptions[e] = {}), this.subscriptions[e][i] = {}, Se(t) && he(e, t, i));
|
|
@@ -744,7 +744,7 @@ class Le {
|
|
|
744
744
|
this._idle = !0, clearTimeout(this._keepAliveTimeout), this.connection && this.connection.close();
|
|
745
745
|
}
|
|
746
746
|
_resetKeepAlive() {
|
|
747
|
-
this._pong === !1 && (g.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new
|
|
747
|
+
this._pong === !1 && (g.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new In(fe()))), clearTimeout(this._keepAliveTimeout), this._triggerKeepAliveTimeoutCheck();
|
|
748
748
|
}
|
|
749
749
|
_triggerKeepAliveTimeoutCheck() {
|
|
750
750
|
this._pong = !1, this._keepAliveTimeout = setTimeout((() => this._resetKeepAlive()), 35e3);
|
|
@@ -768,12 +768,12 @@ class Le {
|
|
|
768
768
|
return this._autoReconnect;
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
|
-
|
|
772
|
-
const
|
|
773
|
-
const t =
|
|
771
|
+
xe.TOKEN_EXPIRY_WARNING_SECONDS = 120;
|
|
772
|
+
const Ye = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n instanceof MediaStream, Re = (n, e) => {
|
|
773
|
+
const t = Ve(n);
|
|
774
774
|
t !== null && (t.getAttribute("autoplay") || t.setAttribute("autoplay", "autoplay"), t.getAttribute("playsinline") || t.setAttribute("playsinline", "playsinline"), t.srcObject = e);
|
|
775
|
-
},
|
|
776
|
-
const t =
|
|
775
|
+
}, kn = (n, e) => O(void 0, void 0, void 0, (function* () {
|
|
776
|
+
const t = Ve(n);
|
|
777
777
|
if (t === null) return g.info("No HTMLMediaElement to attach the speakerId"), !1;
|
|
778
778
|
if (typeof e != "string") return g.info(`Invalid speaker deviceId: '${e}'`), !1;
|
|
779
779
|
try {
|
|
@@ -781,37 +781,37 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
|
|
|
781
781
|
} catch {
|
|
782
782
|
return !1;
|
|
783
783
|
}
|
|
784
|
-
})),
|
|
784
|
+
})), ss = (n) => {
|
|
785
785
|
n && n.readyState === "live" && n.stop();
|
|
786
786
|
}, Ne = (n) => {
|
|
787
|
-
me(n) && n.getTracks().forEach(
|
|
788
|
-
},
|
|
787
|
+
me(n) && n.getTracks().forEach(ss), n = null;
|
|
788
|
+
}, Je = (n) => O(void 0, void 0, void 0, (function* () {
|
|
789
789
|
g.info("RTCService.getUserMedia", n);
|
|
790
790
|
const { audio: e, video: t } = n;
|
|
791
791
|
if (!e && !t) return null;
|
|
792
792
|
try {
|
|
793
|
-
return yield
|
|
793
|
+
return yield Ye(n);
|
|
794
794
|
} catch (i) {
|
|
795
795
|
if (g.error("getUserMedia error: ", i), ((s) => s.name === "NotReadableError" || s.name === "NotFoundError" || s.name === "OverconstrainedError")(i)) {
|
|
796
796
|
const s = ((o) => {
|
|
797
797
|
const { audio: r, video: c } = o;
|
|
798
|
-
let
|
|
798
|
+
let d = !1, l = r, f = c;
|
|
799
799
|
if (typeof r == "object" && r !== null && "deviceId" in r) {
|
|
800
|
-
|
|
801
|
-
const h =
|
|
800
|
+
d = !0;
|
|
801
|
+
const h = We(r, ["deviceId"]);
|
|
802
802
|
l = Object.keys(h).length === 0 || h;
|
|
803
803
|
}
|
|
804
804
|
if (typeof c == "object" && c !== null && "deviceId" in c) {
|
|
805
|
-
|
|
806
|
-
const h =
|
|
805
|
+
d = !0;
|
|
806
|
+
const h = We(c, ["deviceId"]);
|
|
807
807
|
f = Object.keys(h).length === 0 || h;
|
|
808
808
|
}
|
|
809
|
-
return
|
|
809
|
+
return d ? { audio: l, video: f } : null;
|
|
810
810
|
})(n);
|
|
811
811
|
if (s) {
|
|
812
812
|
g.warn("Device not found or not readable, falling back to default device");
|
|
813
813
|
try {
|
|
814
|
-
return yield
|
|
814
|
+
return yield Ye(s);
|
|
815
815
|
} catch (o) {
|
|
816
816
|
throw g.error("Fallback getUserMedia also failed: ", o), i;
|
|
817
817
|
}
|
|
@@ -832,23 +832,23 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
|
|
|
832
832
|
}));
|
|
833
833
|
}
|
|
834
834
|
return t;
|
|
835
|
-
})),
|
|
835
|
+
})), Bt = [[320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]], Ke = (n, e, t) => O(void 0, void 0, void 0, (function* () {
|
|
836
836
|
const i = yield Te(t, !0);
|
|
837
837
|
for (let s = 0; s < i.length; s++) {
|
|
838
838
|
const { deviceId: o, label: r } = i[s];
|
|
839
839
|
if (n === o || e === r) return o;
|
|
840
840
|
}
|
|
841
841
|
return null;
|
|
842
|
-
})),
|
|
842
|
+
})), os = (n) => {
|
|
843
843
|
const e = navigator.mediaDevices.getSupportedConstraints();
|
|
844
844
|
Object.keys(n).map(((t) => {
|
|
845
845
|
e.hasOwnProperty(t) && n[t] !== null && n[t] !== void 0 || delete n[t];
|
|
846
846
|
}));
|
|
847
|
-
},
|
|
847
|
+
}, ht = (n, e) => {
|
|
848
848
|
if (!n) return !1;
|
|
849
|
-
const { subscribed: t, alreadySubscribed: i } =
|
|
849
|
+
const { subscribed: t, alreadySubscribed: i } = pt(n);
|
|
850
850
|
return t.includes(e) || i.includes(e);
|
|
851
|
-
},
|
|
851
|
+
}, pt = (n) => {
|
|
852
852
|
const e = { subscribed: [], alreadySubscribed: [], unauthorized: [], unsubscribed: [], notSubscribed: [] };
|
|
853
853
|
return Object.keys(e).forEach(((t) => {
|
|
854
854
|
e[t] = n[`${t}Channels`] || [];
|
|
@@ -880,13 +880,13 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
|
|
|
880
880
|
s.enabled = !s.enabled;
|
|
881
881
|
}
|
|
882
882
|
}));
|
|
883
|
-
},
|
|
883
|
+
}, Ht = (n) => {
|
|
884
884
|
_e(n, "audio", !0);
|
|
885
|
-
},
|
|
885
|
+
}, ft = (n) => {
|
|
886
886
|
_e(n, "audio", !1);
|
|
887
|
-
},
|
|
887
|
+
}, $t = (n) => {
|
|
888
888
|
_e(n, "audio", null);
|
|
889
|
-
},
|
|
889
|
+
}, rs = (n) => ((e, t = null) => {
|
|
890
890
|
if (!me(e)) return null;
|
|
891
891
|
let i = [];
|
|
892
892
|
switch (t) {
|
|
@@ -901,7 +901,7 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
|
|
|
901
901
|
}
|
|
902
902
|
return i.some(((s) => s.enabled));
|
|
903
903
|
})(n, "audio");
|
|
904
|
-
function
|
|
904
|
+
function as() {
|
|
905
905
|
try {
|
|
906
906
|
const { browserInfo: n, name: e, version: t, supportAudio: i, supportVideo: s } = (function() {
|
|
907
907
|
if (!window || !window.navigator || !window.navigator.userAgent) throw new Error("You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari");
|
|
@@ -922,14 +922,14 @@ function is() {
|
|
|
922
922
|
return { browserInfo: navigator.userAgent, name: h, version: S, supportAudio: !0, supportVideo: !0 };
|
|
923
923
|
}
|
|
924
924
|
throw new Error("This browser does not support @telnyx/webrtc. To see browser support list: `TelnyxRTC.webRTCSupportedBrowserList()`");
|
|
925
|
-
})(), o = window.RTCPeerConnection, r = window.RTCSessionDescription, c = window.RTCIceCandidate,
|
|
926
|
-
return { browserInfo: n, browserName: e, browserVersion: t, supportWebRTC: !!(o && r && c &&
|
|
925
|
+
})(), o = window.RTCPeerConnection, r = window.RTCSessionDescription, c = window.RTCIceCandidate, d = window.navigator && window.navigator.mediaDevices, l = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia || navigator.mozGetUserMedia;
|
|
926
|
+
return { browserInfo: n, browserName: e, browserVersion: t, supportWebRTC: !!(o && r && c && d && l), supportWebRTCAudio: i, supportWebRTCVideo: s, supportRTCPeerConnection: !!o, supportSessionDescription: !!r, supportIceCandidate: !!c, supportMediaDevices: !!d, supportGetUserMedia: !!Je };
|
|
927
927
|
} catch (n) {
|
|
928
928
|
return n.message;
|
|
929
929
|
}
|
|
930
930
|
}
|
|
931
931
|
var Y;
|
|
932
|
-
function
|
|
932
|
+
function Wt(n, e) {
|
|
933
933
|
const t = document.getElementById(e);
|
|
934
934
|
if (t) return t;
|
|
935
935
|
if (n && e) {
|
|
@@ -938,14 +938,14 @@ function $t(n, e) {
|
|
|
938
938
|
}
|
|
939
939
|
return null;
|
|
940
940
|
}
|
|
941
|
-
function
|
|
941
|
+
function Gt(n) {
|
|
942
942
|
n && (n._playFulfilled = !1, n._promise = n.play(), n._promise.then((() => {
|
|
943
943
|
n._playFulfilled = !0;
|
|
944
944
|
})).catch(((e) => {
|
|
945
945
|
g.error("playAudio", e), n._playFulfilled = !0;
|
|
946
946
|
})));
|
|
947
947
|
}
|
|
948
|
-
function
|
|
948
|
+
function Vt(n) {
|
|
949
949
|
n && (n._playFulfilled ? (n.pause(), n.currentTime = 0) : n._promise && n._promise.then ? n._promise.then((() => {
|
|
950
950
|
n.pause(), n.currentTime = 0;
|
|
951
951
|
})) : setTimeout((() => {
|
|
@@ -955,14 +955,14 @@ function Wt(n) {
|
|
|
955
955
|
(function(n) {
|
|
956
956
|
n.not_supported = "not supported", n.full = "full", n.partial = "partial";
|
|
957
957
|
})(Y || (Y = {}));
|
|
958
|
-
const
|
|
958
|
+
const qt = (n) => {
|
|
959
959
|
const e = [], t = [];
|
|
960
960
|
return n && n.length !== 0 ? (n.forEach(((i) => {
|
|
961
961
|
const s = i.mimeType.toLocaleLowerCase();
|
|
962
962
|
s.startsWith("audio/") ? e.push(i) : s.startsWith("video/") && t.push(i);
|
|
963
963
|
})), { audioCodecs: e, videoCodecs: t }) : { audioCodecs: e, videoCodecs: t };
|
|
964
964
|
};
|
|
965
|
-
class
|
|
965
|
+
class cs extends Me {
|
|
966
966
|
constructor(e, t) {
|
|
967
967
|
super(), this.method = "ai_conversation", this.buildRequest({ method: this.method, params: { type: "conversation.item.create", previous_item_id: null, item: { id: ye(), type: "message", role: "user", content: [{ type: "input_text", text: e }, ...t?.map(((i) => ({ type: "image_url", image_url: { url: i } })))] } } });
|
|
968
968
|
}
|
|
@@ -971,8 +971,8 @@ class J {
|
|
|
971
971
|
constructor(e, t) {
|
|
972
972
|
var i;
|
|
973
973
|
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.onWarning = null, this._breachCounters = {}, this._activeWarnings = /* @__PURE__ */ new Set(), this._lastWarningEmitted = {}, this._prevPacketsReceived = null, this._prevPacketsLost = 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(s) {
|
|
974
|
-
return new
|
|
975
|
-
})(this.logCollectorOptions), this.logCollector.start(), i = this.logCollector,
|
|
974
|
+
return new Fi(s);
|
|
975
|
+
})(this.logCollectorOptions), this.logCollector.start(), i = this.logCollector, vn = i);
|
|
976
976
|
}
|
|
977
977
|
start(e) {
|
|
978
978
|
var t, i;
|
|
@@ -995,8 +995,8 @@ class J {
|
|
|
995
995
|
try {
|
|
996
996
|
const s = this._segmentIndex++, o = this.statsBuffer;
|
|
997
997
|
this.statsBuffer = [];
|
|
998
|
-
const r = (i = (t = this.logCollector) === null || t === void 0 ? void 0 : t.drain()) !== null && i !== void 0 ? i : [], c = /* @__PURE__ */ new Date(),
|
|
999
|
-
return g.info("CallReportCollector: Flushed intermediate segment", { segment: s, intervals: o.length, logEntries: r.length, callId: e.callId }),
|
|
998
|
+
const r = (i = (t = this.logCollector) === null || t === void 0 ? void 0 : t.drain()) !== null && i !== void 0 ? i : [], c = /* @__PURE__ */ new Date(), d = Object.assign(Object.assign({ summary: Object.assign(Object.assign({}, e), { durationSeconds: (c.getTime() - this.callStartTime.getTime()) / 1e3, startTimestamp: this.callStartTime.toISOString(), endTimestamp: c.toISOString() }), stats: o }, r.length > 0 ? { logs: r } : {}), { segment: s });
|
|
999
|
+
return g.info("CallReportCollector: Flushed intermediate segment", { segment: s, intervals: o.length, logEntries: r.length, callId: e.callId }), d;
|
|
1000
1000
|
} finally {
|
|
1001
1001
|
this._flushing = !1;
|
|
1002
1002
|
}
|
|
@@ -1004,9 +1004,9 @@ class J {
|
|
|
1004
1004
|
postReport(e, t, i, s) {
|
|
1005
1005
|
var o, r;
|
|
1006
1006
|
return O(this, void 0, void 0, (function* () {
|
|
1007
|
-
const c = (o = this.logCollector) === null || o === void 0 ? void 0 : o.getLogs(),
|
|
1007
|
+
const c = (o = this.logCollector) === null || o === void 0 ? void 0 : o.getLogs(), d = c && c.length > 0;
|
|
1008
1008
|
if (!this.options.enabled) return void g.info("CallReportCollector: Skipping report — call reports disabled");
|
|
1009
|
-
if (this.statsBuffer.length === 0 && !
|
|
1009
|
+
if (this.statsBuffer.length === 0 && !d) return void g.info("CallReportCollector: Skipping report — no stats or logs collected");
|
|
1010
1010
|
const l = this._segmentIndex > 0, f = this._segmentIndex, h = 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 }, c && c.length > 0 ? { logs: c } : {}), l ? { segment: f } : {});
|
|
1011
1011
|
yield this._sendPayload(h, t, i, s);
|
|
1012
1012
|
}));
|
|
@@ -1020,20 +1020,20 @@ class J {
|
|
|
1020
1020
|
var o, r;
|
|
1021
1021
|
return O(this, void 0, void 0, (function* () {
|
|
1022
1022
|
try {
|
|
1023
|
-
const c = new URL(i),
|
|
1024
|
-
g.info(`CallReportCollector: Posting ${l}`, { endpoint:
|
|
1023
|
+
const c = new URL(i), d = `${c.protocol.replace(/^ws/, "http")}//${c.host}/call_report`, l = e.segment !== void 0 && !e.summary.endTimestamp ? `intermediate segment ${e.segment}` : "final report";
|
|
1024
|
+
g.info(`CallReportCollector: Posting ${l}`, { endpoint: d, 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 });
|
|
1025
1025
|
const f = { "Content-Type": "application/json", "x-call-report-id": t, "x-call-id": e.summary.callId };
|
|
1026
1026
|
s && (f["x-voice-sdk-id"] = s);
|
|
1027
|
-
const h = JSON.stringify(e), S = () => fetch(
|
|
1027
|
+
const h = JSON.stringify(e), S = () => fetch(d, { method: "POST", headers: f, body: h }), y = yield S();
|
|
1028
1028
|
if (y.ok) g.info(`CallReportCollector: Successfully posted ${l}`);
|
|
1029
1029
|
else {
|
|
1030
1030
|
const v = yield y.text();
|
|
1031
1031
|
g.error(`CallReportCollector: Failed to post ${l}`, { status: y.status, error: v });
|
|
1032
1032
|
}
|
|
1033
1033
|
} catch (c) {
|
|
1034
|
-
g.warn(`CallReportCollector: Network error posting call report, retrying in ${J.RETRY_DELAY_MS}ms`, { error: c }), yield new Promise(((
|
|
1034
|
+
g.warn(`CallReportCollector: Network error posting call report, retrying in ${J.RETRY_DELAY_MS}ms`, { error: c }), yield new Promise(((d) => setTimeout(d, J.RETRY_DELAY_MS)));
|
|
1035
1035
|
try {
|
|
1036
|
-
const
|
|
1036
|
+
const d = new URL(i), l = `${d.protocol.replace(/^ws/, "http")}//${d.host}/call_report`, f = { "Content-Type": "application/json", "x-call-report-id": t, "x-call-id": e.summary.callId };
|
|
1037
1037
|
s && (f["x-voice-sdk-id"] = s);
|
|
1038
1038
|
const h = yield fetch(l, { method: "POST", headers: f, body: JSON.stringify(e) });
|
|
1039
1039
|
if (h.ok) g.info("CallReportCollector: Successfully posted call report on retry");
|
|
@@ -1041,8 +1041,8 @@ class J {
|
|
|
1041
1041
|
const S = yield h.text();
|
|
1042
1042
|
g.error("CallReportCollector: Failed to post call report on retry", { status: h.status, error: S });
|
|
1043
1043
|
}
|
|
1044
|
-
} catch (
|
|
1045
|
-
g.error("CallReportCollector: Retry also failed, giving up", { error:
|
|
1044
|
+
} catch (d) {
|
|
1045
|
+
g.error("CallReportCollector: Retry also failed, giving up", { error: d });
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
1048
|
}));
|
|
@@ -1062,7 +1062,7 @@ class J {
|
|
|
1062
1062
|
return O(this, void 0, void 0, (function* () {
|
|
1063
1063
|
if (this.peerConnection && this.intervalStartTime) try {
|
|
1064
1064
|
const o = yield this.peerConnection.getStats(), r = /* @__PURE__ */ new Date();
|
|
1065
|
-
let c,
|
|
1065
|
+
let c, d, l = null, f = null, h = null, S = null;
|
|
1066
1066
|
if (o.forEach(((v) => {
|
|
1067
1067
|
switch (v.type) {
|
|
1068
1068
|
case "outbound-rtp":
|
|
@@ -1099,10 +1099,10 @@ class J {
|
|
|
1099
1099
|
}
|
|
1100
1100
|
this.previousStats.inboundBytes = f.bytesReceived;
|
|
1101
1101
|
}
|
|
1102
|
-
h && (h.currentRoundTripTime !== void 0 && this.intervalRTTs.push(h.currentRoundTripTime), this.previousCandidatePairId !== null && h.id !== this.previousCandidatePairId && g.debug("CallReportCollector: ICE candidate pair changed mid-call", { previous: this.previousCandidatePairId, current: h.id }), this.previousCandidatePairId = (t = h.id) !== null && t !== void 0 ? t : null), h && (c = this._resolveCandidate(o, h.localCandidateId),
|
|
1102
|
+
h && (h.currentRoundTripTime !== void 0 && this.intervalRTTs.push(h.currentRoundTripTime), this.previousCandidatePairId !== null && h.id !== this.previousCandidatePairId && g.debug("CallReportCollector: ICE candidate pair changed mid-call", { previous: this.previousCandidatePairId, current: h.id }), this.previousCandidatePairId = (t = h.id) !== null && t !== void 0 ? t : null), h && (c = this._resolveCandidate(o, h.localCandidateId), d = this._resolveCandidate(o, h.remoteCandidateId)), this.previousStats.timestamp = r.getTime();
|
|
1103
1103
|
const y = r.getTime() - this.intervalStartTime.getTime();
|
|
1104
1104
|
if (e || y >= this.options.interval) {
|
|
1105
|
-
const v = this._createStatsEntry(this.intervalStartTime, r, l, f, h, c,
|
|
1105
|
+
const v = this._createStatsEntry(this.intervalStartTime, r, l, f, h, c, d, S);
|
|
1106
1106
|
if (this.statsBuffer.push(v), this.statsBuffer.length > this.MAX_BUFFER_SIZE && (this.statsBuffer.shift(), g.warn("CallReportCollector: Buffer size limit reached, removing oldest entry")), this.onFlushNeeded && !this._flushing) {
|
|
1107
1107
|
const E = this.statsBuffer.length, m = (s = (i = this.logCollector) === null || i === void 0 ? void 0 : i.getLogCount()) !== null && s !== void 0 ? s : 0;
|
|
1108
1108
|
if (E >= J.STATS_FLUSH_THRESHOLD || m >= J.LOGS_FLUSH_THRESHOLD) {
|
|
@@ -1122,29 +1122,29 @@ class J {
|
|
|
1122
1122
|
}));
|
|
1123
1123
|
}
|
|
1124
1124
|
_checkQualityWarnings(e, t) {
|
|
1125
|
-
var i, s, o, r, c,
|
|
1125
|
+
var i, s, o, r, c, d, l, f, h, S, y, v, E, m, w, x, A;
|
|
1126
1126
|
if (!this.onWarning) return;
|
|
1127
1127
|
const P = (i = e.connection) === null || i === void 0 ? void 0 : i.roundTripTimeAvg, M = (o = (s = e.audio) === null || s === void 0 ? void 0 : s.inbound) === null || o === void 0 ? void 0 : o.jitterAvg;
|
|
1128
1128
|
let q;
|
|
1129
1129
|
if (t) {
|
|
1130
1130
|
const F = (r = t.packetsReceived) !== null && r !== void 0 ? r : 0, R = (c = t.packetsLost) !== null && c !== void 0 ? c : 0;
|
|
1131
1131
|
if (this._prevPacketsReceived !== null && this._prevPacketsLost !== null) {
|
|
1132
|
-
const a = F - this._prevPacketsReceived,
|
|
1133
|
-
p > 0 && (q =
|
|
1132
|
+
const a = F - this._prevPacketsReceived, u = R - this._prevPacketsLost, p = a + u;
|
|
1133
|
+
p > 0 && (q = u / p * 100);
|
|
1134
1134
|
}
|
|
1135
1135
|
this._prevPacketsReceived = F, this._prevPacketsLost = R;
|
|
1136
1136
|
}
|
|
1137
|
-
if (this._trackBreach(
|
|
1137
|
+
if (this._trackBreach(mi, P !== void 0 && P > J.THRESHOLD_RTT_MS), this._trackBreach(_i, M !== void 0 && M > J.THRESHOLD_JITTER_MS), this._trackBreach(yi, q !== void 0 && q > J.THRESHOLD_PACKET_LOSS_PCT), P !== void 0 && M !== void 0 && q !== void 0) {
|
|
1138
1138
|
const F = 93.2 - 0.11 * M - 2.5 * q - 0.01 * (1e3 * P), R = Math.max(1, Math.min(4.5, 1 + 0.035 * F + F * (F - 60) * (100 - F) * 7e-6));
|
|
1139
|
-
this._trackBreach(
|
|
1140
|
-
} else this._trackBreach(
|
|
1141
|
-
if (((l = (
|
|
1139
|
+
this._trackBreach(Rt, R < J.THRESHOLD_MOS);
|
|
1140
|
+
} else this._trackBreach(Rt, !1);
|
|
1141
|
+
if (((l = (d = e.audio) === null || d === void 0 ? void 0 : d.inbound) === null || l === void 0 ? void 0 : l.bytesReceived) !== void 0 && this.statsBuffer.length > 1) {
|
|
1142
1142
|
const F = this.statsBuffer[this.statsBuffer.length - 2], R = (S = (h = (f = F?.audio) === null || f === void 0 ? void 0 : f.inbound) === null || h === void 0 ? void 0 : h.bytesReceived) !== null && S !== void 0 ? S : 0, a = (y = e.audio.inbound.bytesReceived) !== null && y !== void 0 ? y : 0;
|
|
1143
|
-
this._trackBreach(
|
|
1143
|
+
this._trackBreach(Si, a - R == 0);
|
|
1144
1144
|
}
|
|
1145
1145
|
if (((E = (v = e.audio) === null || v === void 0 ? void 0 : v.outbound) === null || E === void 0 ? void 0 : E.bytesSent) !== void 0 && this.statsBuffer.length > 1) {
|
|
1146
|
-
const F = this.statsBuffer[this.statsBuffer.length - 2], R = (
|
|
1147
|
-
this._trackBreach(
|
|
1146
|
+
const F = this.statsBuffer[this.statsBuffer.length - 2], R = (x = (w = (m = F?.audio) === null || m === void 0 ? void 0 : m.outbound) === null || w === void 0 ? void 0 : w.bytesSent) !== null && x !== void 0 ? x : 0, a = (A = e.audio.outbound.bytesSent) !== null && A !== void 0 ? A : 0;
|
|
1147
|
+
this._trackBreach(bi, a - R == 0);
|
|
1148
1148
|
}
|
|
1149
1149
|
}
|
|
1150
1150
|
_trackBreach(e, t) {
|
|
@@ -1156,7 +1156,7 @@ class J {
|
|
|
1156
1156
|
if (r - ((s = this._lastWarningEmitted[e]) !== null && s !== void 0 ? s : 0) >= J.WARNING_THROTTLE_MS) {
|
|
1157
1157
|
this._lastWarningEmitted[e] = r;
|
|
1158
1158
|
try {
|
|
1159
|
-
const c =
|
|
1159
|
+
const c = de(e);
|
|
1160
1160
|
g.warn(`CallReportCollector: warning ${c.code}: ${c.message}`), (o = this.onWarning) === null || o === void 0 || o.call(this, c);
|
|
1161
1161
|
} catch (c) {
|
|
1162
1162
|
g.error(`CallReportCollector: Failed to emit warning ${e}`, { error: c });
|
|
@@ -1165,9 +1165,9 @@ class J {
|
|
|
1165
1165
|
}
|
|
1166
1166
|
} else this._breachCounters[e] = 0, this._activeWarnings.delete(e), delete this._lastWarningEmitted[e];
|
|
1167
1167
|
}
|
|
1168
|
-
_createStatsEntry(e, t, i, s, o, r, c,
|
|
1168
|
+
_createStatsEntry(e, t, i, s, o, r, c, d) {
|
|
1169
1169
|
const l = { intervalStartUtc: e.toISOString(), intervalEndUtc: t.toISOString(), audio: {} };
|
|
1170
|
-
return i && (l.audio.outbound = { packetsSent: i.packetsSent, bytesSent: i.bytesSent, audioLevelAvg: this._average(this.intervalAudioLevels.outbound), bitrateAvg: this._average(this.intervalBitrates.outbound) }), s && (l.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 && (l.connection = { roundTripTimeAvg: this._average(this.intervalRTTs), packetsSent: o.packetsSent, packetsReceived: o.packetsReceived, bytesSent: o.bytesSent, bytesReceived: o.bytesReceived }, l.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 } : {}), c ? { remote: c } : {})),
|
|
1170
|
+
return i && (l.audio.outbound = { packetsSent: i.packetsSent, bytesSent: i.bytesSent, audioLevelAvg: this._average(this.intervalAudioLevels.outbound), bitrateAvg: this._average(this.intervalBitrates.outbound) }), s && (l.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 && (l.connection = { roundTripTimeAvg: this._average(this.intervalRTTs), packetsSent: o.packetsSent, packetsReceived: o.packetsReceived, bytesSent: o.bytesSent, bytesReceived: o.bytesReceived }, l.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 } : {}), c ? { remote: c } : {})), d && (l.transport = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, d.iceState !== void 0 ? { iceState: d.iceState } : {}), d.dtlsState !== void 0 ? { dtlsState: d.dtlsState } : {}), d.srtpCipher !== void 0 ? { srtpCipher: d.srtpCipher } : {}), d.tlsVersion !== void 0 ? { tlsVersion: d.tlsVersion } : {}), d.selectedCandidatePairChanges !== void 0 ? { selectedCandidatePairChanges: d.selectedCandidatePairChanges } : {})), l;
|
|
1171
1171
|
}
|
|
1172
1172
|
_resolveCandidate(e, t) {
|
|
1173
1173
|
if (!t) return void g.debug("CallReportCollector: candidateId is empty, skipping resolve");
|
|
@@ -1197,9 +1197,9 @@ class J {
|
|
|
1197
1197
|
if (e === void 0 || t === void 0) return null;
|
|
1198
1198
|
const s = i === "inbound" ? "inboundAudioEnergy" : "outboundAudioEnergy", o = i === "inbound" ? "inboundSamplesDuration" : "outboundSamplesDuration", r = this.previousStats[s], c = this.previousStats[o];
|
|
1199
1199
|
if (this.previousStats[s] = e, this.previousStats[o] = t, r === void 0 || c === void 0) return null;
|
|
1200
|
-
const
|
|
1200
|
+
const d = e - r, l = t - c;
|
|
1201
1201
|
if (l <= 0) return null;
|
|
1202
|
-
const f = Math.sqrt(
|
|
1202
|
+
const f = Math.sqrt(d / l);
|
|
1203
1203
|
return Math.min(1, Math.max(0, f));
|
|
1204
1204
|
}
|
|
1205
1205
|
_getTrackAudioLevel(e, t) {
|
|
@@ -1218,7 +1218,7 @@ class J {
|
|
|
1218
1218
|
}
|
|
1219
1219
|
}
|
|
1220
1220
|
J.STATS_FLUSH_THRESHOLD = 300, J.LOGS_FLUSH_THRESHOLD = 800, J.CONSECUTIVE_BREACHES_REQUIRED = 3, J.THRESHOLD_RTT_MS = 0.4, J.THRESHOLD_JITTER_MS = 30, J.THRESHOLD_PACKET_LOSS_PCT = 1, J.THRESHOLD_MOS = 3.5, J.WARNING_THROTTLE_MS = 15e3, J.RETRY_DELAY_MS = 500;
|
|
1221
|
-
var
|
|
1221
|
+
var je, Rn = gn((function(n, e) {
|
|
1222
1222
|
var t;
|
|
1223
1223
|
function i() {
|
|
1224
1224
|
}
|
|
@@ -1228,38 +1228,38 @@ var Fe, In = hn((function(n, e) {
|
|
|
1228
1228
|
function o(a) {
|
|
1229
1229
|
return a._maxListeners === void 0 ? s.defaultMaxListeners : a._maxListeners;
|
|
1230
1230
|
}
|
|
1231
|
-
function r(a,
|
|
1231
|
+
function r(a, u, p, _) {
|
|
1232
1232
|
var b, k, I;
|
|
1233
1233
|
if (typeof p != "function") throw new TypeError('"listener" argument must be a function');
|
|
1234
|
-
if ((k = a._events) ? (k.newListener && (a.emit("newListener",
|
|
1235
|
-
if (typeof I == "function" ? I = k[
|
|
1234
|
+
if ((k = a._events) ? (k.newListener && (a.emit("newListener", u, p.listener ? p.listener : p), k = a._events), I = k[u]) : (k = a._events = new i(), a._eventsCount = 0), I) {
|
|
1235
|
+
if (typeof I == "function" ? I = k[u] = _ ? [p, I] : [I, p] : _ ? I.unshift(p) : I.push(p), !I.warned && (b = o(a)) && 0 < b && I.length > b) {
|
|
1236
1236
|
I.warned = !0;
|
|
1237
|
-
var
|
|
1238
|
-
|
|
1237
|
+
var N = new Error("Possible EventEmitter memory leak detected. " + I.length + " " + u + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
1238
|
+
N.name = "MaxListenersExceededWarning", N.emitter = a, N.type = u, N.count = I.length, (function(B) {
|
|
1239
1239
|
typeof console.warn == "function" ? console.warn(B) : console.log(B);
|
|
1240
|
-
})(
|
|
1240
|
+
})(N);
|
|
1241
1241
|
}
|
|
1242
|
-
} else I = k[
|
|
1242
|
+
} else I = k[u] = p, ++a._eventsCount;
|
|
1243
1243
|
return a;
|
|
1244
1244
|
}
|
|
1245
|
-
function c(a,
|
|
1245
|
+
function c(a, u, p) {
|
|
1246
1246
|
function _() {
|
|
1247
|
-
a.removeListener(
|
|
1247
|
+
a.removeListener(u, _), b || (b = !0, p.apply(a, arguments));
|
|
1248
1248
|
}
|
|
1249
1249
|
var b = !1;
|
|
1250
1250
|
return _.listener = p, _;
|
|
1251
1251
|
}
|
|
1252
|
-
function
|
|
1253
|
-
var
|
|
1254
|
-
if (
|
|
1255
|
-
var p =
|
|
1252
|
+
function d(a) {
|
|
1253
|
+
var u = this._events;
|
|
1254
|
+
if (u) {
|
|
1255
|
+
var p = u[a];
|
|
1256
1256
|
if (typeof p == "function") return 1;
|
|
1257
1257
|
if (p) return p.length;
|
|
1258
1258
|
}
|
|
1259
1259
|
return 0;
|
|
1260
1260
|
}
|
|
1261
|
-
function l(a,
|
|
1262
|
-
for (var p = Array(
|
|
1261
|
+
function l(a, u) {
|
|
1262
|
+
for (var p = Array(u); u--; ) p[u] = a[u];
|
|
1263
1263
|
return p;
|
|
1264
1264
|
}
|
|
1265
1265
|
Object.defineProperty(e, "__esModule", { value: !0 }), i.prototype = /* @__PURE__ */ Object.create(null), s.EventEmitter = s, s.usingDomains = !1, s.prototype.domain = void 0, s.prototype._events = void 0, s.prototype._maxListeners = void 0, s.defaultMaxListeners = 10, s.init = function() {
|
|
@@ -1270,16 +1270,16 @@ var Fe, In = hn((function(n, e) {
|
|
|
1270
1270
|
}, s.prototype.getMaxListeners = function() {
|
|
1271
1271
|
return o(this);
|
|
1272
1272
|
}, s.prototype.emit = function(a) {
|
|
1273
|
-
var
|
|
1273
|
+
var u, p, _, b, k, I, N, B = a === "error";
|
|
1274
1274
|
if (I = this._events) B = B && I.error == null;
|
|
1275
1275
|
else if (!B) return !1;
|
|
1276
|
-
if (
|
|
1277
|
-
if (
|
|
1278
|
-
if (
|
|
1279
|
-
var te = new Error('Uncaught, unspecified "error" event. (' +
|
|
1280
|
-
throw te.context =
|
|
1276
|
+
if (N = this.domain, B) {
|
|
1277
|
+
if (u = arguments[1], !N) {
|
|
1278
|
+
if (u instanceof Error) throw u;
|
|
1279
|
+
var te = new Error('Uncaught, unspecified "error" event. (' + u + ")");
|
|
1280
|
+
throw te.context = u, te;
|
|
1281
1281
|
}
|
|
1282
|
-
return
|
|
1282
|
+
return u || (u = new Error('Uncaught, unspecified "error" event')), u.domainEmitter = this, u.domain = N, u.domainThrown = !1, N.emit("error", u), !1;
|
|
1283
1283
|
}
|
|
1284
1284
|
if (!(p = I[a])) return !1;
|
|
1285
1285
|
var ie = typeof p == "function";
|
|
@@ -1287,53 +1287,53 @@ var Fe, In = hn((function(n, e) {
|
|
|
1287
1287
|
case 1:
|
|
1288
1288
|
(function(G, C, D) {
|
|
1289
1289
|
if (C) G.call(D);
|
|
1290
|
-
else for (var j = G.length,
|
|
1290
|
+
else for (var j = G.length, $ = l(G, j), K = 0; K < j; ++K) $[K].call(D);
|
|
1291
1291
|
})(p, ie, this);
|
|
1292
1292
|
break;
|
|
1293
1293
|
case 2:
|
|
1294
1294
|
(function(G, C, D, j) {
|
|
1295
1295
|
if (C) G.call(D, j);
|
|
1296
|
-
else for (var
|
|
1296
|
+
else for (var $ = G.length, K = l(G, $), Q = 0; Q < $; ++Q) K[Q].call(D, j);
|
|
1297
1297
|
})(p, ie, this, arguments[1]);
|
|
1298
1298
|
break;
|
|
1299
1299
|
case 3:
|
|
1300
|
-
(function(G, C, D, j,
|
|
1301
|
-
if (C) G.call(D, j,
|
|
1302
|
-
else for (var K = G.length,
|
|
1300
|
+
(function(G, C, D, j, $) {
|
|
1301
|
+
if (C) G.call(D, j, $);
|
|
1302
|
+
else for (var K = G.length, Q = l(G, K), V = 0; V < K; ++V) Q[V].call(D, j, $);
|
|
1303
1303
|
})(p, ie, this, arguments[1], arguments[2]);
|
|
1304
1304
|
break;
|
|
1305
1305
|
case 4:
|
|
1306
|
-
(function(G, C, D, j,
|
|
1307
|
-
if (C) G.call(D, j,
|
|
1308
|
-
else for (var
|
|
1306
|
+
(function(G, C, D, j, $, K) {
|
|
1307
|
+
if (C) G.call(D, j, $, K);
|
|
1308
|
+
else for (var Q = G.length, V = l(G, Q), ae = 0; ae < Q; ++ae) V[ae].call(D, j, $, K);
|
|
1309
1309
|
})(p, ie, this, arguments[1], arguments[2], arguments[3]);
|
|
1310
1310
|
break;
|
|
1311
1311
|
default:
|
|
1312
1312
|
for (b = Array(_ - 1), k = 1; k < _; k++) b[k - 1] = arguments[k];
|
|
1313
1313
|
(function(G, C, D, j) {
|
|
1314
1314
|
if (C) G.apply(D, j);
|
|
1315
|
-
else for (var
|
|
1315
|
+
else for (var $ = G.length, K = l(G, $), Q = 0; Q < $; ++Q) K[Q].apply(D, j);
|
|
1316
1316
|
})(p, ie, this, b);
|
|
1317
1317
|
}
|
|
1318
1318
|
return !0;
|
|
1319
|
-
}, s.prototype.addListener = function(a,
|
|
1320
|
-
return r(this, a,
|
|
1321
|
-
}, s.prototype.on = s.prototype.addListener, s.prototype.prependListener = function(a,
|
|
1322
|
-
return r(this, a,
|
|
1323
|
-
}, s.prototype.once = function(a,
|
|
1324
|
-
if (typeof
|
|
1325
|
-
return this.on(a, c(this, a,
|
|
1326
|
-
}, s.prototype.prependOnceListener = function(a,
|
|
1327
|
-
if (typeof
|
|
1328
|
-
return this.prependListener(a, c(this, a,
|
|
1329
|
-
}, s.prototype.removeListener = function(a,
|
|
1319
|
+
}, s.prototype.addListener = function(a, u) {
|
|
1320
|
+
return r(this, a, u, !1);
|
|
1321
|
+
}, s.prototype.on = s.prototype.addListener, s.prototype.prependListener = function(a, u) {
|
|
1322
|
+
return r(this, a, u, !0);
|
|
1323
|
+
}, s.prototype.once = function(a, u) {
|
|
1324
|
+
if (typeof u != "function") throw new TypeError('"listener" argument must be a function');
|
|
1325
|
+
return this.on(a, c(this, a, u)), this;
|
|
1326
|
+
}, s.prototype.prependOnceListener = function(a, u) {
|
|
1327
|
+
if (typeof u != "function") throw new TypeError('"listener" argument must be a function');
|
|
1328
|
+
return this.prependListener(a, c(this, a, u)), this;
|
|
1329
|
+
}, s.prototype.removeListener = function(a, u) {
|
|
1330
1330
|
var p, _, b, k, I;
|
|
1331
|
-
if (typeof
|
|
1331
|
+
if (typeof u != "function") throw new TypeError('"listener" argument must be a function');
|
|
1332
1332
|
if (!(_ = this._events)) return this;
|
|
1333
1333
|
if (!(p = _[a])) return this;
|
|
1334
|
-
if (p ===
|
|
1334
|
+
if (p === u || p.listener && p.listener === u) --this._eventsCount == 0 ? this._events = new i() : (delete _[a], _.removeListener && this.emit("removeListener", a, p.listener || u));
|
|
1335
1335
|
else if (typeof p != "function") {
|
|
1336
|
-
for (b = -1, k = p.length; 0 < k--; ) if (p[k] ===
|
|
1336
|
+
for (b = -1, k = p.length; 0 < k--; ) if (p[k] === u || p[k].listener && p[k].listener === u) {
|
|
1337
1337
|
I = p[k].listener, b = k;
|
|
1338
1338
|
break;
|
|
1339
1339
|
}
|
|
@@ -1341,35 +1341,35 @@ var Fe, In = hn((function(n, e) {
|
|
|
1341
1341
|
if (p.length === 1) {
|
|
1342
1342
|
if (p[0] = void 0, --this._eventsCount == 0) return this._events = new i(), this;
|
|
1343
1343
|
delete _[a];
|
|
1344
|
-
} else (function(
|
|
1345
|
-
for (var te = B, ie = te + 1, G =
|
|
1346
|
-
|
|
1344
|
+
} else (function(N, B) {
|
|
1345
|
+
for (var te = B, ie = te + 1, G = N.length; ie < G; te += 1, ie += 1) N[te] = N[ie];
|
|
1346
|
+
N.pop();
|
|
1347
1347
|
})(p, b);
|
|
1348
|
-
_.removeListener && this.emit("removeListener", a, I ||
|
|
1348
|
+
_.removeListener && this.emit("removeListener", a, I || u);
|
|
1349
1349
|
}
|
|
1350
1350
|
return this;
|
|
1351
1351
|
}, s.prototype.removeAllListeners = function(a) {
|
|
1352
|
-
var
|
|
1352
|
+
var u, p;
|
|
1353
1353
|
if (!(p = this._events)) return this;
|
|
1354
1354
|
if (!p.removeListener) return arguments.length === 0 ? (this._events = new i(), this._eventsCount = 0) : p[a] && (--this._eventsCount == 0 ? this._events = new i() : delete p[a]), this;
|
|
1355
1355
|
if (arguments.length === 0) {
|
|
1356
1356
|
for (var _, b = Object.keys(p), k = 0; k < b.length; ++k) (_ = b[k]) !== "removeListener" && this.removeAllListeners(_);
|
|
1357
1357
|
return this.removeAllListeners("removeListener"), this._events = new i(), this._eventsCount = 0, this;
|
|
1358
1358
|
}
|
|
1359
|
-
if (typeof (
|
|
1360
|
-
else if (
|
|
1361
|
-
this.removeListener(a,
|
|
1362
|
-
while (
|
|
1359
|
+
if (typeof (u = p[a]) == "function") this.removeListener(a, u);
|
|
1360
|
+
else if (u) do
|
|
1361
|
+
this.removeListener(a, u[u.length - 1]);
|
|
1362
|
+
while (u[0]);
|
|
1363
1363
|
return this;
|
|
1364
1364
|
}, s.prototype.listeners = function(a) {
|
|
1365
|
-
var
|
|
1366
|
-
return _ ? p = (
|
|
1365
|
+
var u, p, _ = this._events;
|
|
1366
|
+
return _ ? p = (u = _[a]) ? typeof u == "function" ? [u.listener || u] : (function(b) {
|
|
1367
1367
|
for (var k = Array(b.length), I = 0; I < k.length; ++I) k[I] = b[I].listener || b[I];
|
|
1368
1368
|
return k;
|
|
1369
|
-
})(
|
|
1370
|
-
}, s.listenerCount = function(a,
|
|
1371
|
-
return typeof a.listenerCount == "function" ? a.listenerCount(
|
|
1372
|
-
}, s.prototype.listenerCount =
|
|
1369
|
+
})(u) : [] : p = [], p;
|
|
1370
|
+
}, s.listenerCount = function(a, u) {
|
|
1371
|
+
return typeof a.listenerCount == "function" ? a.listenerCount(u) : d.call(a, u);
|
|
1372
|
+
}, s.prototype.listenerCount = d, s.prototype.eventNames = function() {
|
|
1373
1373
|
return 0 < this._eventsCount ? Reflect.ownKeys(this._events) : [];
|
|
1374
1374
|
};
|
|
1375
1375
|
var f, h = new Uint8Array(16);
|
|
@@ -1379,61 +1379,61 @@ var Fe, In = hn((function(n, e) {
|
|
|
1379
1379
|
}
|
|
1380
1380
|
for (var y = /^(?:[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, v = [], E = 0; 256 > E; ++E) v.push((E + 256).toString(16).substr(1));
|
|
1381
1381
|
function m(a) {
|
|
1382
|
-
var
|
|
1382
|
+
var u = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0, p = (v[a[u + 0]] + v[a[u + 1]] + v[a[u + 2]] + v[a[u + 3]] + "-" + v[a[u + 4]] + v[a[u + 5]] + "-" + v[a[u + 6]] + v[a[u + 7]] + "-" + v[a[u + 8]] + v[a[u + 9]] + "-" + v[a[u + 10]] + v[a[u + 11]] + v[a[u + 12]] + v[a[u + 13]] + v[a[u + 14]] + v[a[u + 15]]).toLowerCase();
|
|
1383
1383
|
if (!(function(_) {
|
|
1384
1384
|
return typeof _ == "string" && y.test(_);
|
|
1385
1385
|
})(p)) throw TypeError("Stringified UUID is invalid");
|
|
1386
1386
|
return p;
|
|
1387
1387
|
}
|
|
1388
|
-
function w(a,
|
|
1388
|
+
function w(a, u, p) {
|
|
1389
1389
|
var _ = (a = a || {}).random || (a.rng || S)();
|
|
1390
1390
|
return _[6] = 64 | 15 & _[6], _[8] = 128 | 63 & _[8], m(_);
|
|
1391
1391
|
}
|
|
1392
|
-
function
|
|
1393
|
-
if (!a || !
|
|
1392
|
+
function x(a, u) {
|
|
1393
|
+
if (!a || !u) return {};
|
|
1394
1394
|
const p = { ...a };
|
|
1395
1395
|
if (p.localCandidateId) {
|
|
1396
|
-
const _ =
|
|
1396
|
+
const _ = u.get(p.localCandidateId);
|
|
1397
1397
|
p.local = { ..._ };
|
|
1398
1398
|
}
|
|
1399
1399
|
if (p.remoteCandidateId) {
|
|
1400
|
-
const _ =
|
|
1400
|
+
const _ = u.get(p.remoteCandidateId);
|
|
1401
1401
|
p.remote = { ..._ };
|
|
1402
1402
|
}
|
|
1403
1403
|
return p;
|
|
1404
1404
|
}
|
|
1405
|
-
function A(a,
|
|
1405
|
+
function A(a, u, p) {
|
|
1406
1406
|
return 8 * (function(_, b, k) {
|
|
1407
|
-
const I = _[k],
|
|
1408
|
-
return I === null ||
|
|
1409
|
-
})(a,
|
|
1407
|
+
const I = _[k], N = b ? b[k] : null;
|
|
1408
|
+
return I === null || N === null ? null : (I - N) / (_.timestamp - b.timestamp) * 1e3;
|
|
1409
|
+
})(a, u, p);
|
|
1410
1410
|
}
|
|
1411
1411
|
function P(a) {
|
|
1412
1412
|
if (!a.entries) return a;
|
|
1413
|
-
const
|
|
1413
|
+
const u = {};
|
|
1414
1414
|
return a.forEach((function(p, _) {
|
|
1415
|
-
|
|
1416
|
-
})),
|
|
1415
|
+
u[_] = p;
|
|
1416
|
+
})), u;
|
|
1417
1417
|
}
|
|
1418
|
-
function M(a,
|
|
1418
|
+
function M(a, u, p = {}) {
|
|
1419
1419
|
if (!a) return null;
|
|
1420
1420
|
let _ = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] }, connection: { inbound: [], outbound: [] } };
|
|
1421
1421
|
p.remote && (_.remote = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] } });
|
|
1422
1422
|
for (const b of a.values()) switch (b.type) {
|
|
1423
1423
|
case "outbound-rtp": {
|
|
1424
1424
|
const k = b.mediaType || b.kind, I = {};
|
|
1425
|
-
let
|
|
1425
|
+
let N = {};
|
|
1426
1426
|
if (!["audio", "video"].includes(k)) continue;
|
|
1427
1427
|
if (b.codecId) {
|
|
1428
1428
|
const B = a.get(b.codecId);
|
|
1429
1429
|
B && (I.clockRate = B.clockRate, I.mimeType = B.mimeType, I.payloadType = B.payloadType);
|
|
1430
1430
|
}
|
|
1431
|
-
|
|
1431
|
+
N = a.get(b.mediaSourceId) || a.get(b.trackId) || {}, _[k].outbound.push({ ...b, ...I, track: { ...N } });
|
|
1432
1432
|
break;
|
|
1433
1433
|
}
|
|
1434
1434
|
case "inbound-rtp": {
|
|
1435
1435
|
let k = b.mediaType || b.kind, I = {};
|
|
1436
|
-
const
|
|
1436
|
+
const N = {};
|
|
1437
1437
|
if (!["audio", "video"].includes(k)) if (b.id.includes("Video")) k = "video";
|
|
1438
1438
|
else {
|
|
1439
1439
|
if (!b.id.includes("Audio")) continue;
|
|
@@ -1441,16 +1441,16 @@ var Fe, In = hn((function(n, e) {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
if (b.codecId) {
|
|
1443
1443
|
const B = a.get(b.codecId);
|
|
1444
|
-
B && (
|
|
1444
|
+
B && (N.clockRate = B.clockRate, N.mimeType = B.mimeType, N.payloadType = B.payloadType);
|
|
1445
1445
|
}
|
|
1446
1446
|
if (!_.connection.id && b.transportId) {
|
|
1447
1447
|
const B = a.get(b.transportId);
|
|
1448
1448
|
if (B && B.selectedCandidatePairId) {
|
|
1449
1449
|
const te = a.get(B.selectedCandidatePairId);
|
|
1450
|
-
_.connection =
|
|
1450
|
+
_.connection = x(te, a);
|
|
1451
1451
|
}
|
|
1452
1452
|
}
|
|
1453
|
-
I = a.get(b.mediaSourceId) || a.get(b.trackId) || {}, _[k].inbound.push({ ...b, ...
|
|
1453
|
+
I = a.get(b.mediaSourceId) || a.get(b.trackId) || {}, _[k].inbound.push({ ...b, ...N, track: { ...I } });
|
|
1454
1454
|
break;
|
|
1455
1455
|
}
|
|
1456
1456
|
case "peer-connection":
|
|
@@ -1466,14 +1466,14 @@ var Fe, In = hn((function(n, e) {
|
|
|
1466
1466
|
k = "audio";
|
|
1467
1467
|
}
|
|
1468
1468
|
if (b.codecId) {
|
|
1469
|
-
const
|
|
1470
|
-
|
|
1469
|
+
const N = a.get(b.codecId);
|
|
1470
|
+
N && (I.clockRate = N.clockRate, I.mimeType = N.mimeType, I.payloadType = N.payloadType);
|
|
1471
1471
|
}
|
|
1472
1472
|
if (!_.connection.id && b.transportId) {
|
|
1473
|
-
const
|
|
1474
|
-
if (
|
|
1475
|
-
const B = a.get(
|
|
1476
|
-
_.connection =
|
|
1473
|
+
const N = a.get(b.transportId);
|
|
1474
|
+
if (N && N.selectedCandidatePairId) {
|
|
1475
|
+
const B = a.get(N.selectedCandidatePairId);
|
|
1476
|
+
_.connection = x(B, a);
|
|
1477
1477
|
}
|
|
1478
1478
|
}
|
|
1479
1479
|
_.remote[k].inbound.push({ ...b, ...I });
|
|
@@ -1484,98 +1484,98 @@ var Fe, In = hn((function(n, e) {
|
|
|
1484
1484
|
const k = b.mediaType || b.kind, I = {};
|
|
1485
1485
|
if (!["audio", "video"].includes(k)) continue;
|
|
1486
1486
|
if (b.codecId) {
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1487
|
+
const N = a.get(b.codecId);
|
|
1488
|
+
N && (I.clockRate = N.clockRate, I.mimeType = N.mimeType, I.payloadType = N.payloadType);
|
|
1489
1489
|
}
|
|
1490
1490
|
_.remote[k].outbound.push({ ...b, ...I });
|
|
1491
1491
|
break;
|
|
1492
1492
|
}
|
|
1493
1493
|
}
|
|
1494
|
-
if (!_.connection.id) for (const b of a.values()) b.type === "candidate-pair" && b.nominated && b.state === "succeeded" && (_.connection =
|
|
1494
|
+
if (!_.connection.id) for (const b of a.values()) b.type === "candidate-pair" && b.nominated && b.state === "succeeded" && (_.connection = x(b, a));
|
|
1495
1495
|
return _ = (function(b, k) {
|
|
1496
1496
|
return k && (b.audio.inbound.map(((I) => {
|
|
1497
|
-
let
|
|
1498
|
-
I.bitrate = A(I,
|
|
1497
|
+
let N = k.audio.inbound.find(((B) => B.id === I.id));
|
|
1498
|
+
I.bitrate = A(I, N, "bytesReceived"), I.packetRate = A(I, N, "packetsReceived");
|
|
1499
1499
|
})), b.audio.outbound.map(((I) => {
|
|
1500
|
-
let
|
|
1501
|
-
I.bitrate = A(I,
|
|
1500
|
+
let N = k.audio.outbound.find(((B) => B.id === I.id));
|
|
1501
|
+
I.bitrate = A(I, N, "bytesSent"), I.packetRate = A(I, N, "packetsSent");
|
|
1502
1502
|
})), b.video.inbound.map(((I) => {
|
|
1503
|
-
let
|
|
1504
|
-
I.bitrate = A(I,
|
|
1503
|
+
let N = k.video.inbound.find(((B) => B.id === I.id));
|
|
1504
|
+
I.bitrate = A(I, N, "bytesReceived"), I.packetRate = A(I, N, "packetsReceived");
|
|
1505
1505
|
})), b.video.outbound.map(((I) => {
|
|
1506
|
-
let
|
|
1507
|
-
I.bitrate = A(I,
|
|
1506
|
+
let N = k.video.outbound.find(((B) => B.id === I.id));
|
|
1507
|
+
I.bitrate = A(I, N, "bytesSent"), I.packetRate = A(I, N, "packetsSent");
|
|
1508
1508
|
}))), b;
|
|
1509
|
-
})(_,
|
|
1509
|
+
})(_, u), _;
|
|
1510
1510
|
}
|
|
1511
1511
|
let q, F = {}, R = [];
|
|
1512
1512
|
e.WebRTCStats = class extends s {
|
|
1513
1513
|
constructor(a) {
|
|
1514
1514
|
if (super(), this.monitoringSetInterval = 0, this.connectionMonitoringSetInterval = 0, this.connectionMonitoringInterval = 1e3, this.remote = !0, this.peersToMonitor = {}, this.timeline = [], this.statsToMonitor = ["inbound-rtp", "outbound-rtp", "remote-inbound-rtp", "remote-outbound-rtp", "peer-connection", "data-channel", "stream", "track", "sender", "receiver", "transport", "candidate-pair", "local-candidate", "remote-candidate"], typeof window > "u") throw new Error("WebRTCStats only works in browser");
|
|
1515
|
-
const
|
|
1516
|
-
this.isEdge = !!window.RTCIceGatherer, this.getStatsInterval =
|
|
1515
|
+
const u = { ...a };
|
|
1516
|
+
this.isEdge = !!window.RTCIceGatherer, this.getStatsInterval = u.getStatsInterval || 1e3, this.rawStats = !!u.rawStats, this.statsObject = !!u.statsObject, this.filteredStats = !!u.filteredStats, this.shouldWrapGetUserMedia = !!u.wrapGetUserMedia, typeof u.remote == "boolean" && (this.remote = u.remote), this.debug = !!u.debug, this.logLevel = u.logLevel || "none", this.shouldWrapGetUserMedia && this.wrapGetUserMedia();
|
|
1517
1517
|
}
|
|
1518
|
-
async addPeer(a,
|
|
1519
|
-
return console.warn("The addPeer() method has been deprecated, please use addConnection()"), this.addConnection({ peerId: a, pc:
|
|
1518
|
+
async addPeer(a, u) {
|
|
1519
|
+
return console.warn("The addPeer() method has been deprecated, please use addConnection()"), this.addConnection({ peerId: a, pc: u });
|
|
1520
1520
|
}
|
|
1521
1521
|
async addConnection(a) {
|
|
1522
|
-
const { pc:
|
|
1522
|
+
const { pc: u, peerId: p } = a;
|
|
1523
1523
|
let { connectionId: _, remote: b } = a;
|
|
1524
|
-
if (b = typeof b == "boolean" ? b : this.remote, !(
|
|
1524
|
+
if (b = typeof b == "boolean" ? b : this.remote, !(u && u instanceof RTCPeerConnection)) throw new Error("Missing argument 'pc' or is not of instance RTCPeerConnection");
|
|
1525
1525
|
if (!p) throw new Error("Missing argument peerId");
|
|
1526
1526
|
if (this.isEdge) throw new Error("Can't monitor peers in Edge at this time.");
|
|
1527
1527
|
if (this.peersToMonitor[p]) {
|
|
1528
1528
|
if (_ && _ in this.peersToMonitor[p]) throw new Error(`We are already monitoring connection with id ${_}.`);
|
|
1529
1529
|
for (let I in this.peersToMonitor[p]) {
|
|
1530
|
-
const
|
|
1531
|
-
if (
|
|
1532
|
-
|
|
1530
|
+
const N = this.peersToMonitor[p][I];
|
|
1531
|
+
if (N.pc === u) throw new Error(`We are already monitoring peer with id ${p}.`);
|
|
1532
|
+
N.pc.connectionState === "closed" && this.removeConnection({ pc: N.pc });
|
|
1533
1533
|
}
|
|
1534
1534
|
}
|
|
1535
|
-
const k =
|
|
1535
|
+
const k = u.getConfiguration();
|
|
1536
1536
|
return k.iceServers && k.iceServers.forEach((function(I) {
|
|
1537
1537
|
delete I.credential;
|
|
1538
|
-
})), _ || (_ = w()), this.emitEvent({ event: "addConnection", tag: "peer", peerId: p, connectionId: _, data: { options: a, peerConfiguration: k } }), this.monitorPeer({ peerId: p, connectionId: _, pc:
|
|
1538
|
+
})), _ || (_ = w()), this.emitEvent({ event: "addConnection", tag: "peer", peerId: p, connectionId: _, data: { options: a, peerConfiguration: k } }), this.monitorPeer({ peerId: p, connectionId: _, pc: u, remote: b }), { connectionId: _ };
|
|
1539
1539
|
}
|
|
1540
1540
|
getTimeline(a) {
|
|
1541
|
-
return this.timeline = this.timeline.sort(((
|
|
1541
|
+
return this.timeline = this.timeline.sort(((u, p) => u.timestamp.getTime() - p.timestamp.getTime())), a ? this.timeline.filter(((u) => u.tag === a)) : this.timeline;
|
|
1542
1542
|
}
|
|
1543
1543
|
get logger() {
|
|
1544
|
-
const a = (
|
|
1544
|
+
const a = (u) => {
|
|
1545
1545
|
const p = ["none", "error", "warn", "info", "debug"];
|
|
1546
|
-
return p.slice(0, p.indexOf(this.logLevel) + 1).indexOf(
|
|
1546
|
+
return p.slice(0, p.indexOf(this.logLevel) + 1).indexOf(u) > -1;
|
|
1547
1547
|
};
|
|
1548
|
-
return { error(...
|
|
1549
|
-
this.debug && a("error") && console.error("[webrtc-stats][error] ", ...
|
|
1550
|
-
}, warn(...
|
|
1551
|
-
this.debug && a("warn") && console.warn("[webrtc-stats][warn] ", ...
|
|
1552
|
-
}, info(...
|
|
1553
|
-
this.debug && a("info") && console.log("[webrtc-stats][info] ", ...
|
|
1554
|
-
}, debug(...
|
|
1555
|
-
this.debug && a("debug") && console.debug("[webrtc-stats][debug] ", ...
|
|
1548
|
+
return { error(...u) {
|
|
1549
|
+
this.debug && a("error") && console.error("[webrtc-stats][error] ", ...u);
|
|
1550
|
+
}, warn(...u) {
|
|
1551
|
+
this.debug && a("warn") && console.warn("[webrtc-stats][warn] ", ...u);
|
|
1552
|
+
}, info(...u) {
|
|
1553
|
+
this.debug && a("info") && console.log("[webrtc-stats][info] ", ...u);
|
|
1554
|
+
}, debug(...u) {
|
|
1555
|
+
this.debug && a("debug") && console.debug("[webrtc-stats][debug] ", ...u);
|
|
1556
1556
|
} };
|
|
1557
1557
|
}
|
|
1558
1558
|
removeConnection(a) {
|
|
1559
|
-
let
|
|
1559
|
+
let u, { connectionId: p, pc: _ } = a;
|
|
1560
1560
|
if (!_ && !p) throw new Error("Missing arguments. You need to either send pc or a connectionId.");
|
|
1561
1561
|
if (p) {
|
|
1562
1562
|
if (typeof p != "string") throw new Error("connectionId must be a string.");
|
|
1563
|
-
for (let b in this.peersToMonitor) p in this.peersToMonitor[b] && (_ = this.peersToMonitor[b][p].pc,
|
|
1563
|
+
for (let b in this.peersToMonitor) p in this.peersToMonitor[b] && (_ = this.peersToMonitor[b][p].pc, u = b);
|
|
1564
1564
|
} else if (_) {
|
|
1565
1565
|
if (!(_ instanceof RTCPeerConnection)) throw new Error("pc must be an instance of RTCPeerConnection.");
|
|
1566
|
-
for (let b in this.peersToMonitor) for (let k in this.peersToMonitor[b]) this.peersToMonitor[b][k].pc === _ && (p = k,
|
|
1566
|
+
for (let b in this.peersToMonitor) for (let k in this.peersToMonitor[b]) this.peersToMonitor[b][k].pc === _ && (p = k, u = b);
|
|
1567
1567
|
}
|
|
1568
1568
|
if (!_ || !p) throw new Error("Could not find the desired connection.");
|
|
1569
|
-
return this.removePeerConnectionEventListeners(p, _), delete this.peersToMonitor[
|
|
1569
|
+
return this.removePeerConnectionEventListeners(p, _), delete this.peersToMonitor[u][p], Object.values(this.peersToMonitor[u]).length === 0 && delete this.peersToMonitor[u], { connectionId: p };
|
|
1570
1570
|
}
|
|
1571
1571
|
removeAllPeers() {
|
|
1572
1572
|
for (let a in this.peersToMonitor) this.removePeer(a);
|
|
1573
1573
|
}
|
|
1574
1574
|
removePeer(a) {
|
|
1575
1575
|
if (this.logger.info(`Removing PeerConnection with id ${a}.`), this.peersToMonitor[a]) {
|
|
1576
|
-
for (let
|
|
1577
|
-
let p = this.peersToMonitor[a][
|
|
1578
|
-
this.removePeerConnectionEventListeners(
|
|
1576
|
+
for (let u in this.peersToMonitor[a]) {
|
|
1577
|
+
let p = this.peersToMonitor[a][u].pc;
|
|
1578
|
+
this.removePeerConnectionEventListeners(u, p);
|
|
1579
1579
|
}
|
|
1580
1580
|
delete this.peersToMonitor[a];
|
|
1581
1581
|
}
|
|
@@ -1586,20 +1586,20 @@ var Fe, In = hn((function(n, e) {
|
|
|
1586
1586
|
})), R = [], this.shouldWrapGetUserMedia && q && (navigator.mediaDevices.getUserMedia = q);
|
|
1587
1587
|
}
|
|
1588
1588
|
monitorPeer(a) {
|
|
1589
|
-
let { peerId:
|
|
1589
|
+
let { peerId: u, connectionId: p, pc: _, remote: b } = a;
|
|
1590
1590
|
if (!_) return void this.logger.warn("Did not receive pc argument when calling monitorPeer()");
|
|
1591
1591
|
const k = { pc: _, connectionId: p, stream: null, stats: { parsed: null, raw: null }, options: { remote: b } };
|
|
1592
|
-
if (this.peersToMonitor[
|
|
1593
|
-
if (p in this.peersToMonitor[
|
|
1594
|
-
this.peersToMonitor[
|
|
1595
|
-
} else this.peersToMonitor[
|
|
1596
|
-
this.addPeerConnectionEventListeners(
|
|
1592
|
+
if (this.peersToMonitor[u]) {
|
|
1593
|
+
if (p in this.peersToMonitor[u]) return void this.logger.warn(`Already watching connection with ID ${p}`);
|
|
1594
|
+
this.peersToMonitor[u][p] = k;
|
|
1595
|
+
} else this.peersToMonitor[u] = { [p]: k };
|
|
1596
|
+
this.addPeerConnectionEventListeners(u, p, _), this.numberOfMonitoredPeers === 1 && (this.startStatsMonitoring(), this.startConnectionStateMonitoring());
|
|
1597
1597
|
}
|
|
1598
1598
|
startStatsMonitoring() {
|
|
1599
1599
|
this.monitoringSetInterval || (this.monitoringSetInterval = window.setInterval((() => {
|
|
1600
1600
|
this.numberOfMonitoredPeers || this.stopStatsMonitoring(), this.getStats().then(((a) => {
|
|
1601
|
-
a.forEach(((
|
|
1602
|
-
this.emitEvent(
|
|
1601
|
+
a.forEach(((u) => {
|
|
1602
|
+
this.emitEvent(u);
|
|
1603
1603
|
}));
|
|
1604
1604
|
}));
|
|
1605
1605
|
}), this._getStatsInterval));
|
|
@@ -1609,22 +1609,22 @@ var Fe, In = hn((function(n, e) {
|
|
|
1609
1609
|
}
|
|
1610
1610
|
async getStats(a = null) {
|
|
1611
1611
|
this.logger.info(a ? `Getting stats from peer ${a}` : "Getting stats from all peers");
|
|
1612
|
-
let
|
|
1612
|
+
let u = {};
|
|
1613
1613
|
if (a) {
|
|
1614
1614
|
if (!this.peersToMonitor[a]) throw new Error(`Cannot get stats. Peer with id ${a} does not exist`);
|
|
1615
|
-
|
|
1616
|
-
} else
|
|
1615
|
+
u[a] = this.peersToMonitor[a];
|
|
1616
|
+
} else u = this.peersToMonitor;
|
|
1617
1617
|
let p = [];
|
|
1618
|
-
for (const _ in
|
|
1619
|
-
const k =
|
|
1618
|
+
for (const _ in u) for (const b in u[_]) {
|
|
1619
|
+
const k = u[_][b], I = k.pc;
|
|
1620
1620
|
if (I && !this.checkIfConnectionIsClosed(_, b, I)) try {
|
|
1621
|
-
const
|
|
1621
|
+
const N = this.getTimestamp(), B = I.getStats(null);
|
|
1622
1622
|
if (B) {
|
|
1623
|
-
const te = await B, ie = this.getTimestamp(), G = P(te), C = { remote: k.options.remote }, D = M(te, k.stats.parsed, C), j = { event: "stats", tag: "stats", peerId: _, connectionId: b, timeTaken: ie -
|
|
1623
|
+
const te = await B, ie = this.getTimestamp(), G = P(te), C = { remote: k.options.remote }, D = M(te, k.stats.parsed, C), j = { event: "stats", tag: "stats", peerId: _, connectionId: b, timeTaken: ie - N, data: D };
|
|
1624
1624
|
this.rawStats === !0 && (j.rawStats = te), this.statsObject === !0 && (j.statsObject = G), this.filteredStats === !0 && (j.filteredStats = this.filteroutStats(G)), p.push(j), k.stats.parsed = D;
|
|
1625
1625
|
} else this.logger.error(`PeerConnection from peer ${_} did not return any stats data`);
|
|
1626
|
-
} catch (
|
|
1627
|
-
this.logger.error(
|
|
1626
|
+
} catch (N) {
|
|
1627
|
+
this.logger.error(N);
|
|
1628
1628
|
}
|
|
1629
1629
|
}
|
|
1630
1630
|
return p;
|
|
@@ -1632,18 +1632,18 @@ var Fe, In = hn((function(n, e) {
|
|
|
1632
1632
|
startConnectionStateMonitoring() {
|
|
1633
1633
|
this.connectionMonitoringSetInterval = window.setInterval((() => {
|
|
1634
1634
|
this.numberOfMonitoredPeers || this.stopConnectionStateMonitoring();
|
|
1635
|
-
for (const a in this.peersToMonitor) for (const
|
|
1636
|
-
const p = this.peersToMonitor[a][
|
|
1637
|
-
this.checkIfConnectionIsClosed(a,
|
|
1635
|
+
for (const a in this.peersToMonitor) for (const u in this.peersToMonitor[a]) {
|
|
1636
|
+
const p = this.peersToMonitor[a][u].pc;
|
|
1637
|
+
this.checkIfConnectionIsClosed(a, u, p);
|
|
1638
1638
|
}
|
|
1639
1639
|
}), this.connectionMonitoringInterval);
|
|
1640
1640
|
}
|
|
1641
|
-
checkIfConnectionIsClosed(a,
|
|
1641
|
+
checkIfConnectionIsClosed(a, u, p) {
|
|
1642
1642
|
const _ = this.isConnectionClosed(p);
|
|
1643
1643
|
if (_) {
|
|
1644
1644
|
this.removeConnection({ pc: p });
|
|
1645
1645
|
let b = p.connectionState === "closed" ? "onconnectionstatechange" : "oniceconnectionstatechange";
|
|
1646
|
-
this.emitEvent({ event: b, peerId: a, connectionId:
|
|
1646
|
+
this.emitEvent({ event: b, peerId: a, connectionId: u, tag: "connection", data: "closed" });
|
|
1647
1647
|
}
|
|
1648
1648
|
return _;
|
|
1649
1649
|
}
|
|
@@ -1658,61 +1658,61 @@ var Fe, In = hn((function(n, e) {
|
|
|
1658
1658
|
this.logger.info("Wrapping getUsermedia functions."), q = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
|
|
1659
1659
|
const a = this.parseGetUserMedia.bind(this);
|
|
1660
1660
|
navigator.mediaDevices.getUserMedia = (function() {
|
|
1661
|
-
return a({ constraints: arguments[0] }), q.apply(navigator.mediaDevices, arguments).then(((
|
|
1661
|
+
return a({ constraints: arguments[0] }), q.apply(navigator.mediaDevices, arguments).then(((u) => (a({ stream: u }), u)), ((u) => (a({ error: u }), Promise.reject(u))));
|
|
1662
1662
|
}).bind(navigator.mediaDevices);
|
|
1663
1663
|
}
|
|
1664
1664
|
filteroutStats(a = {}) {
|
|
1665
|
-
const
|
|
1666
|
-
for (const _ in
|
|
1667
|
-
var p =
|
|
1668
|
-
this.statsToMonitor.includes(p.type) || delete
|
|
1665
|
+
const u = { ...a };
|
|
1666
|
+
for (const _ in u) {
|
|
1667
|
+
var p = u[_];
|
|
1668
|
+
this.statsToMonitor.includes(p.type) || delete u[_];
|
|
1669
1669
|
}
|
|
1670
|
-
return
|
|
1670
|
+
return u;
|
|
1671
1671
|
}
|
|
1672
1672
|
get peerConnectionListeners() {
|
|
1673
|
-
return { icecandidate: (a,
|
|
1674
|
-
this.logger.debug("[pc-event] icecandidate | peerId: ${peerId}", _), this.emitEvent({ event: "onicecandidate", tag: "connection", peerId: a, connectionId:
|
|
1675
|
-
}, track: (a,
|
|
1673
|
+
return { icecandidate: (a, u, p, _) => {
|
|
1674
|
+
this.logger.debug("[pc-event] icecandidate | peerId: ${peerId}", _), this.emitEvent({ event: "onicecandidate", tag: "connection", peerId: a, connectionId: u, data: _.candidate });
|
|
1675
|
+
}, track: (a, u, p, _) => {
|
|
1676
1676
|
this.logger.debug(`[pc-event] track | peerId: ${a}`, _);
|
|
1677
1677
|
const b = _.track, k = _.streams[0];
|
|
1678
|
-
a in this.peersToMonitor &&
|
|
1678
|
+
a in this.peersToMonitor && u in this.peersToMonitor[a] && (this.peersToMonitor[a][u].stream = k), this.addTrackEventListeners(b, u), this.emitEvent({ event: "ontrack", tag: "track", peerId: a, connectionId: u, data: { stream: k ? this.getStreamDetails(k) : null, track: b ? this.getMediaTrackDetails(b) : null, title: _.track.kind + ":" + _.track.id + " " + _.streams.map((function(I) {
|
|
1679
1679
|
return "stream:" + I.id;
|
|
1680
1680
|
})) } });
|
|
1681
|
-
}, signalingstatechange: (a,
|
|
1682
|
-
this.logger.debug(`[pc-event] signalingstatechange | peerId: ${a}`), this.emitEvent({ event: "onsignalingstatechange", tag: "connection", peerId: a, connectionId:
|
|
1683
|
-
}, iceconnectionstatechange: (a,
|
|
1684
|
-
this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${a}`), this.emitEvent({ event: "oniceconnectionstatechange", tag: "connection", peerId: a, connectionId:
|
|
1685
|
-
}, icegatheringstatechange: (a,
|
|
1686
|
-
this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${a}`), this.emitEvent({ event: "onicegatheringstatechange", tag: "connection", peerId: a, connectionId:
|
|
1687
|
-
}, icecandidateerror: (a,
|
|
1688
|
-
this.logger.debug(`[pc-event] icecandidateerror | peerId: ${a}`), this.emitEvent({ event: "onicecandidateerror", tag: "connection", peerId: a, connectionId:
|
|
1689
|
-
}, connectionstatechange: (a,
|
|
1690
|
-
this.logger.debug(`[pc-event] connectionstatechange | peerId: ${a}`), this.emitEvent({ event: "onconnectionstatechange", tag: "connection", peerId: a, connectionId:
|
|
1691
|
-
}, negotiationneeded: (a,
|
|
1692
|
-
this.logger.debug(`[pc-event] negotiationneeded | peerId: ${a}`), this.emitEvent({ event: "onnegotiationneeded", tag: "connection", peerId: a, connectionId:
|
|
1693
|
-
}, datachannel: (a,
|
|
1694
|
-
this.logger.debug(`[pc-event] datachannel | peerId: ${a}`, _), this.emitEvent({ event: "ondatachannel", tag: "datachannel", peerId: a, connectionId:
|
|
1681
|
+
}, signalingstatechange: (a, u, p) => {
|
|
1682
|
+
this.logger.debug(`[pc-event] signalingstatechange | peerId: ${a}`), this.emitEvent({ event: "onsignalingstatechange", tag: "connection", peerId: a, connectionId: u, data: { signalingState: p.signalingState, localDescription: p.localDescription, remoteDescription: p.remoteDescription } });
|
|
1683
|
+
}, iceconnectionstatechange: (a, u, p) => {
|
|
1684
|
+
this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${a}`), this.emitEvent({ event: "oniceconnectionstatechange", tag: "connection", peerId: a, connectionId: u, data: p.iceConnectionState });
|
|
1685
|
+
}, icegatheringstatechange: (a, u, p) => {
|
|
1686
|
+
this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${a}`), this.emitEvent({ event: "onicegatheringstatechange", tag: "connection", peerId: a, connectionId: u, data: p.iceGatheringState });
|
|
1687
|
+
}, icecandidateerror: (a, u, p, _) => {
|
|
1688
|
+
this.logger.debug(`[pc-event] icecandidateerror | peerId: ${a}`), this.emitEvent({ event: "onicecandidateerror", tag: "connection", peerId: a, connectionId: u, error: { errorCode: _.errorCode } });
|
|
1689
|
+
}, connectionstatechange: (a, u, p) => {
|
|
1690
|
+
this.logger.debug(`[pc-event] connectionstatechange | peerId: ${a}`), this.emitEvent({ event: "onconnectionstatechange", tag: "connection", peerId: a, connectionId: u, data: p.connectionState });
|
|
1691
|
+
}, negotiationneeded: (a, u, p) => {
|
|
1692
|
+
this.logger.debug(`[pc-event] negotiationneeded | peerId: ${a}`), this.emitEvent({ event: "onnegotiationneeded", tag: "connection", peerId: a, connectionId: u });
|
|
1693
|
+
}, datachannel: (a, u, p, _) => {
|
|
1694
|
+
this.logger.debug(`[pc-event] datachannel | peerId: ${a}`, _), this.emitEvent({ event: "ondatachannel", tag: "datachannel", peerId: a, connectionId: u, data: _.channel });
|
|
1695
1695
|
} };
|
|
1696
1696
|
}
|
|
1697
|
-
addPeerConnectionEventListeners(a,
|
|
1698
|
-
this.logger.debug(`Adding event listeners for peer ${a} and connection ${
|
|
1699
|
-
F[
|
|
1697
|
+
addPeerConnectionEventListeners(a, u, p) {
|
|
1698
|
+
this.logger.debug(`Adding event listeners for peer ${a} and connection ${u}.`), F[u] = {}, Object.keys(this.peerConnectionListeners).forEach(((_) => {
|
|
1699
|
+
F[u][_] = this.peerConnectionListeners[_].bind(this, a, u, p), p.addEventListener(_, F[u][_], !1);
|
|
1700
1700
|
}));
|
|
1701
1701
|
}
|
|
1702
1702
|
parseGetUserMedia(a) {
|
|
1703
1703
|
try {
|
|
1704
|
-
const
|
|
1705
|
-
a.stream && (
|
|
1704
|
+
const u = { event: "getUserMedia", tag: "getUserMedia", data: { ...a } };
|
|
1705
|
+
a.stream && (u.data.details = this.parseStream(a.stream), a.stream.getTracks().map(((p) => {
|
|
1706
1706
|
this.addTrackEventListeners(p), R.push(p);
|
|
1707
|
-
}))), this.emitEvent(
|
|
1707
|
+
}))), this.emitEvent(u);
|
|
1708
1708
|
} catch {
|
|
1709
1709
|
}
|
|
1710
1710
|
}
|
|
1711
1711
|
parseStream(a) {
|
|
1712
|
-
const
|
|
1712
|
+
const u = { audio: [], video: [] };
|
|
1713
1713
|
return a.getTracks().forEach(((p) => {
|
|
1714
|
-
|
|
1715
|
-
})),
|
|
1714
|
+
u[p.kind].push(this.getMediaTrackDetails(p));
|
|
1715
|
+
})), u;
|
|
1716
1716
|
}
|
|
1717
1717
|
getMediaTrackDetails(a) {
|
|
1718
1718
|
return { enabled: a.enabled, id: a.id, contentHint: a.contentHint, kind: a.kind, label: a.label, muted: a.muted, readyState: a.readyState, constructorName: a.constructor.name, capabilities: a.getCapabilities ? a.getCapabilities() : {}, constraints: a.getConstraints ? a.getConstraints() : {}, settings: a.getSettings ? a.getSettings() : {}, _track: a };
|
|
@@ -1721,19 +1721,19 @@ var Fe, In = hn((function(n, e) {
|
|
|
1721
1721
|
return { active: a.active, id: a.id, _stream: a };
|
|
1722
1722
|
}
|
|
1723
1723
|
getTrackEventObject(a) {
|
|
1724
|
-
return { mute: (
|
|
1725
|
-
this.emitEvent({ event: "mute", tag: "track", connectionId: a, data: { event:
|
|
1726
|
-
}, unmute: (
|
|
1727
|
-
this.emitEvent({ event: "unmute", tag: "track", connectionId: a, data: { event:
|
|
1728
|
-
}, overconstrained: (
|
|
1729
|
-
this.emitEvent({ event: "overconstrained", tag: "track", connectionId: a, data: { event:
|
|
1730
|
-
}, ended: (
|
|
1731
|
-
this.emitEvent({ event: "ended", tag: "track", connectionId: a, data: { event:
|
|
1724
|
+
return { mute: (u) => {
|
|
1725
|
+
this.emitEvent({ event: "mute", tag: "track", connectionId: a, data: { event: u } });
|
|
1726
|
+
}, unmute: (u) => {
|
|
1727
|
+
this.emitEvent({ event: "unmute", tag: "track", connectionId: a, data: { event: u } });
|
|
1728
|
+
}, overconstrained: (u) => {
|
|
1729
|
+
this.emitEvent({ event: "overconstrained", tag: "track", connectionId: a, data: { event: u } });
|
|
1730
|
+
}, ended: (u) => {
|
|
1731
|
+
this.emitEvent({ event: "ended", tag: "track", connectionId: a, data: { event: u } }), this.removeTrackEventListeners(u.target);
|
|
1732
1732
|
} };
|
|
1733
1733
|
}
|
|
1734
|
-
addTrackEventListeners(a,
|
|
1734
|
+
addTrackEventListeners(a, u) {
|
|
1735
1735
|
F[a.id] = {};
|
|
1736
|
-
const p = this.getTrackEventObject(
|
|
1736
|
+
const p = this.getTrackEventObject(u);
|
|
1737
1737
|
Object.keys(p).forEach(((_) => {
|
|
1738
1738
|
F[a.id][_] = p[_].bind(this), a.addEventListener(_, F[a.id][_]);
|
|
1739
1739
|
})), F[a.id].readyState = setInterval((() => {
|
|
@@ -1745,8 +1745,8 @@ var Fe, In = hn((function(n, e) {
|
|
|
1745
1745
|
}
|
|
1746
1746
|
removeTrackEventListeners(a) {
|
|
1747
1747
|
if (a.id in F) {
|
|
1748
|
-
const
|
|
1749
|
-
Object.keys(
|
|
1748
|
+
const u = this.getTrackEventObject();
|
|
1749
|
+
Object.keys(u).forEach(((p) => {
|
|
1750
1750
|
a.removeEventListener(p, F[a.id][p]);
|
|
1751
1751
|
})), clearInterval(F[a.id].readyState), delete F[a.id];
|
|
1752
1752
|
}
|
|
@@ -1755,8 +1755,8 @@ var Fe, In = hn((function(n, e) {
|
|
|
1755
1755
|
this.timeline.push(a), this.emit("timeline", a);
|
|
1756
1756
|
}
|
|
1757
1757
|
emitEvent(a) {
|
|
1758
|
-
const
|
|
1759
|
-
this.addToTimeline(
|
|
1758
|
+
const u = { ...a, timestamp: /* @__PURE__ */ new Date() };
|
|
1759
|
+
this.addToTimeline(u), u.tag && this.emit(u.tag, u);
|
|
1760
1760
|
}
|
|
1761
1761
|
set getStatsInterval(a) {
|
|
1762
1762
|
if (!Number.isInteger(a)) throw new Error(`getStatsInterval should be an integer, got: ${a}`);
|
|
@@ -1765,12 +1765,12 @@ var Fe, In = hn((function(n, e) {
|
|
|
1765
1765
|
get numberOfMonitoredPeers() {
|
|
1766
1766
|
return Object.keys(this.peersToMonitor).length;
|
|
1767
1767
|
}
|
|
1768
|
-
removePeerConnectionEventListeners(a,
|
|
1768
|
+
removePeerConnectionEventListeners(a, u) {
|
|
1769
1769
|
a in F && (Object.keys(this.peerConnectionListeners).forEach(((p) => {
|
|
1770
|
-
|
|
1771
|
-
})), delete F[a]),
|
|
1770
|
+
u.removeEventListener(p, F[a][p], !1);
|
|
1771
|
+
})), delete F[a]), u.getSenders().forEach(((p) => {
|
|
1772
1772
|
p.track && this.removeTrackEventListeners(p.track);
|
|
1773
|
-
})),
|
|
1773
|
+
})), u.getReceivers().forEach(((p) => {
|
|
1774
1774
|
p.track && this.removeTrackEventListeners(p.track);
|
|
1775
1775
|
}));
|
|
1776
1776
|
}
|
|
@@ -1780,8 +1780,8 @@ var Fe, In = hn((function(n, e) {
|
|
|
1780
1780
|
wrapGetDisplayMedia() {
|
|
1781
1781
|
const a = this;
|
|
1782
1782
|
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
|
|
1783
|
-
const
|
|
1784
|
-
return a.debug("navigator.mediaDevices.getDisplayMedia", null, arguments[0]),
|
|
1783
|
+
const u = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices), p = function() {
|
|
1784
|
+
return a.debug("navigator.mediaDevices.getDisplayMedia", null, arguments[0]), u.apply(navigator.mediaDevices, arguments).then((function(_) {
|
|
1785
1785
|
return _;
|
|
1786
1786
|
}), (function(_) {
|
|
1787
1787
|
return a.debug("navigator.mediaDevices.getDisplayMediaOnFailure", null, _.name), Promise.reject(_);
|
|
@@ -1792,68 +1792,68 @@ var Fe, In = hn((function(n, e) {
|
|
|
1792
1792
|
}
|
|
1793
1793
|
};
|
|
1794
1794
|
}));
|
|
1795
|
-
(
|
|
1796
|
-
var
|
|
1797
|
-
function
|
|
1795
|
+
(je = Rn) && je.__esModule && Object.prototype.hasOwnProperty.call(je, "default") && je.default;
|
|
1796
|
+
var ls = Rn.WebRTCStats;
|
|
1797
|
+
function ds(n) {
|
|
1798
1798
|
const { packetsLost: e, packetsReceived: t, jitter: i, rtt: s } = n, o = (function(l) {
|
|
1799
1799
|
const { jitter: f, rtt: h } = l, S = f + h / 2;
|
|
1800
1800
|
return 0.024 * S + 0.11 * (S - 177.3) * (S > 177.3 ? 1 : 0);
|
|
1801
1801
|
})({ rtt: s, jitter: i }), r = (function(l) {
|
|
1802
1802
|
const { packetsLost: f, packetsReceived: h } = l, S = f / (h + f) * 100;
|
|
1803
1803
|
return 20 * Math.log(1 + S);
|
|
1804
|
-
})({ packetsLost: e, packetsReceived: t }), c = 93.2 - o - r + 0,
|
|
1805
|
-
return Math.min(Math.max(
|
|
1804
|
+
})({ packetsLost: e, packetsReceived: t }), c = 93.2 - o - r + 0, d = 1 + 0.035 * c + 7e-6 * c * (c - 60) * (100 - c);
|
|
1805
|
+
return Math.min(Math.max(d, 1), 5);
|
|
1806
1806
|
}
|
|
1807
|
-
function
|
|
1807
|
+
function us(n) {
|
|
1808
1808
|
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";
|
|
1809
1809
|
}
|
|
1810
|
-
class
|
|
1810
|
+
class hs extends Me {
|
|
1811
1811
|
constructor(e, t) {
|
|
1812
1812
|
super(), this.buildRequest({ type: "debug_report_start", debug_report_id: e, debug_report_version: 1, call_id: t });
|
|
1813
1813
|
}
|
|
1814
1814
|
}
|
|
1815
|
-
class
|
|
1815
|
+
class ps extends Me {
|
|
1816
1816
|
constructor(e, t) {
|
|
1817
1817
|
super(), this.buildRequest({ type: "debug_report_stop", debug_report_id: e, debug_report_version: 1, call_id: t });
|
|
1818
1818
|
}
|
|
1819
1819
|
}
|
|
1820
|
-
class
|
|
1820
|
+
class fs extends Me {
|
|
1821
1821
|
constructor(e, t) {
|
|
1822
1822
|
super(), this.buildRequest({ type: "debug_report_data", debug_report_id: e, debug_report_version: 1, debug_report_data: t });
|
|
1823
1823
|
}
|
|
1824
1824
|
}
|
|
1825
|
-
function
|
|
1825
|
+
function Yt(n, e) {
|
|
1826
1826
|
var t, i;
|
|
1827
1827
|
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 };
|
|
1828
1828
|
}
|
|
1829
|
-
function
|
|
1829
|
+
function gs(n, e) {
|
|
1830
1830
|
const t = ye();
|
|
1831
1831
|
let i = !1;
|
|
1832
|
-
const s = new
|
|
1832
|
+
const s = new ls({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), o = (r) => O(this, void 0, void 0, (function* () {
|
|
1833
1833
|
r.event === "stats" && L(T.StatsFrame, (function({ data: c }) {
|
|
1834
|
-
var
|
|
1835
|
-
const { audio: m, remote: w } = c, { audio:
|
|
1836
|
-
return { jitter: A, rtt: P, mos: F, quality:
|
|
1837
|
-
})(r), n.uuid), yield n.execute(new
|
|
1834
|
+
var d, l, f, h, S, y, v, E;
|
|
1835
|
+
const { audio: m, remote: w } = c, { audio: x } = w, A = (l = (d = x.inbound[0]) === null || d === void 0 ? void 0 : d.jitter) !== null && l !== void 0 ? l : 1 / 0, P = (h = (f = x.inbound[0]) === null || f === void 0 ? void 0 : f.roundTripTime) !== null && h !== void 0 ? h : 1 / 0, M = (y = (S = m.inbound[0]) === null || S === void 0 ? void 0 : S.packetsReceived) !== null && y !== void 0 ? y : -1, q = (E = (v = m.inbound[0]) === null || v === void 0 ? void 0 : v.packetsLost) !== null && E !== void 0 ? E : -1, F = ds({ jitter: 1e3 * A, rtt: 1e3 * P, packetsLost: q, packetsReceived: M });
|
|
1836
|
+
return { jitter: A, rtt: P, mos: F, quality: us(F), inboundAudio: m.inbound[0], outboundAudio: m.outbound[0], remoteInboundAudio: x.inbound[0], remoteOutboundAudio: x.outbound[0] };
|
|
1837
|
+
})(r), n.uuid), yield n.execute(new fs(t, r));
|
|
1838
1838
|
}));
|
|
1839
1839
|
return { get isRunning() {
|
|
1840
1840
|
return i;
|
|
1841
|
-
}, start: (r, c,
|
|
1841
|
+
}, start: (r, c, d) => O(this, void 0, void 0, (function* () {
|
|
1842
1842
|
if (i) g.debug(`[${e}] Stats reporter already running, skipping start`);
|
|
1843
1843
|
else {
|
|
1844
|
-
yield n.execute(new
|
|
1844
|
+
yield n.execute(new hs(t, e)), s.on("timeline", o);
|
|
1845
1845
|
try {
|
|
1846
|
-
yield s.addConnection({ pc: r, peerId: c, connectionId:
|
|
1846
|
+
yield s.addConnection({ pc: r, peerId: c, connectionId: d }), i = !0;
|
|
1847
1847
|
} catch (l) {
|
|
1848
1848
|
g.error(`[${e}] Failed to start stats reporter:`, l), s.removeAllPeers(), s.destroy();
|
|
1849
1849
|
}
|
|
1850
1850
|
}
|
|
1851
1851
|
})), stop: (r) => O(this, void 0, void 0, (function* () {
|
|
1852
1852
|
const c = s.getTimeline();
|
|
1853
|
-
L(T.StatsReport, c, n.uuid), r === "file" && (function(
|
|
1854
|
-
const f = new Blob([JSON.stringify(
|
|
1853
|
+
L(T.StatsReport, c, n.uuid), r === "file" && (function(d, l) {
|
|
1854
|
+
const f = new Blob([JSON.stringify(d)], { type: "application/json" }), h = URL.createObjectURL(f), S = document.createElement("a");
|
|
1855
1855
|
S.href = h, S.download = `${l}.json`, S.click(), URL.revokeObjectURL(h);
|
|
1856
|
-
})(c, `webrtc-stats-${t}-${Date.now()}`), yield n.execute(new
|
|
1856
|
+
})(c, `webrtc-stats-${t}-${Date.now()}`), yield n.execute(new ps(t, e)), s.removeAllPeers(), s.destroy(), i = !1;
|
|
1857
1857
|
})), reportConnectionStateChange: (r) => {
|
|
1858
1858
|
const c = { event: "connectionstatechange-detailed", tag: "connection", timestamp: (/* @__PURE__ */ new Date()).toISOString(), data: r };
|
|
1859
1859
|
o(c);
|
|
@@ -1862,27 +1862,27 @@ function us(n, e) {
|
|
|
1862
1862
|
o(c);
|
|
1863
1863
|
} };
|
|
1864
1864
|
}
|
|
1865
|
-
const
|
|
1865
|
+
const An = (n, e) => {
|
|
1866
1866
|
const { contentType: t, canvasType: i, callID: s, canvasInfo: o = null, currentLayerIdx: r = -1 } = e;
|
|
1867
1867
|
o && i !== "mcu-personal-canvas" && delete o.memberID;
|
|
1868
|
-
const c = { type: re.conferenceUpdate, call: n.calls[s], canvasInfo:
|
|
1868
|
+
const c = { type: re.conferenceUpdate, call: n.calls[s], canvasInfo: vs(o), currentLayerIdx: r };
|
|
1869
1869
|
switch (t) {
|
|
1870
1870
|
case "layer-info": {
|
|
1871
|
-
const
|
|
1872
|
-
L(T.Notification,
|
|
1871
|
+
const d = Object.assign({ action: oe.LayerInfo }, c);
|
|
1872
|
+
L(T.Notification, d, n.uuid);
|
|
1873
1873
|
break;
|
|
1874
1874
|
}
|
|
1875
1875
|
case "layout-info": {
|
|
1876
|
-
const
|
|
1877
|
-
L(T.Notification,
|
|
1876
|
+
const d = Object.assign({ action: oe.LayoutInfo }, c);
|
|
1877
|
+
L(T.Notification, d, n.uuid);
|
|
1878
1878
|
break;
|
|
1879
1879
|
}
|
|
1880
1880
|
}
|
|
1881
|
-
},
|
|
1881
|
+
}, vs = (n) => {
|
|
1882
1882
|
const e = JSON.stringify(n).replace(/memberID/g, "participantId").replace(/ID"/g, 'Id"').replace(/POS"/g, 'Pos"');
|
|
1883
|
-
return
|
|
1884
|
-
},
|
|
1885
|
-
function
|
|
1883
|
+
return _n(e);
|
|
1884
|
+
}, Jt = ["new-call-start", "new-peer", "get-user-media", "peer-creation-end", "start-negotiation", "create-offer", "create-answer", "set-local-description", "ice-gathering-started", "first-candidate", "first-non-host-candidate", "send-sdp", "ice-gathering-completed", "ringing", "telnyx-rtc-media", "first-remote-media-track", "set-remote-description", "telnyx-rtc-answer", "ice-connected", "dtls-connected", "call-active", "answer-called"], ms = { "new-call-start": "Call Start", "new-peer": "Peer object created", "get-user-media": "Media devices acquired", "peer-creation-end": "Peer setup complete", "start-negotiation": "SDP negotiation started", "create-offer": "SDP offer generated", "create-answer": "SDP answer generated", "set-local-description": "Local description applied", "ice-gathering-started": "ICE candidate gathering started", "first-candidate": "First ICE candidate found", "first-non-host-candidate": "First server-reflexive/relay candidate found", "send-sdp": "SDP sent to server", "ice-gathering-completed": "All ICE candidates gathered", ringing: "Remote side ringing", "telnyx-rtc-media": "Early media received from server", "first-remote-media-track": "First remote audio/video track received", "set-remote-description": "Remote description applied", "telnyx-rtc-answer": "Call answered by remote side", "ice-connected": "ICE connection established", "dtls-connected": "Secure media channel established (DTLS)", "call-active": "Call is active", "answer-called": "Answer delay (invite → call.answer)" };
|
|
1885
|
+
function Kt(n) {
|
|
1886
1886
|
try {
|
|
1887
1887
|
const e = performance.getEntriesByName(n, "mark");
|
|
1888
1888
|
return e.length > 0 ? e[0].startTime : void 0;
|
|
@@ -1890,14 +1890,14 @@ function Yt(n) {
|
|
|
1890
1890
|
return;
|
|
1891
1891
|
}
|
|
1892
1892
|
}
|
|
1893
|
-
class
|
|
1893
|
+
class De {
|
|
1894
1894
|
constructor(e, t, i, s, o) {
|
|
1895
1895
|
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._iceGatheringSafetyTimeout = null, this._gatheredCandidatesCount = 0, this._firstMediaTrackMarked = !1, this._timingsCollected = !1, this.handleConnectionStateChange = () => O(this, void 0, void 0, (function* () {
|
|
1896
1896
|
const { connectionState: r } = this.instance;
|
|
1897
1897
|
if (g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}] Connection State changed: ${this._prevConnectionState} -> ${r}`), r === "failed" || r === "disconnected") {
|
|
1898
1898
|
const c = () => O(this, void 0, void 0, (function* () {
|
|
1899
1899
|
if (this.isDebugEnabled && this.statsReporter) {
|
|
1900
|
-
const
|
|
1900
|
+
const d = yield (function(l, f) {
|
|
1901
1901
|
return O(this, void 0, void 0, (function* () {
|
|
1902
1902
|
const h = { connectionState: l.connectionState, previousConnectionState: f, iceConnectionState: l.iceConnectionState, iceGatheringState: l.iceGatheringState, signalingState: l.signalingState }, S = l.getTransceivers();
|
|
1903
1903
|
if (S.length > 0) {
|
|
@@ -1918,18 +1918,18 @@ class xe {
|
|
|
1918
1918
|
return h;
|
|
1919
1919
|
}));
|
|
1920
1920
|
})(this.instance, this._prevConnectionState);
|
|
1921
|
-
this.statsReporter.reportConnectionStateChange(
|
|
1921
|
+
this.statsReporter.reportConnectionStateChange(d);
|
|
1922
1922
|
}
|
|
1923
1923
|
window.removeEventListener("online", c);
|
|
1924
1924
|
}));
|
|
1925
1925
|
navigator.onLine ? c() : window.addEventListener("online", c);
|
|
1926
1926
|
}
|
|
1927
1927
|
if (r === "disconnected") {
|
|
1928
|
-
const c =
|
|
1928
|
+
const c = de(Ci);
|
|
1929
1929
|
L(T.Warning, { warning: c, callId: this.options.id, sessionId: this._session.sessionid }, this.options.id);
|
|
1930
1930
|
}
|
|
1931
1931
|
if (r === "failed") {
|
|
1932
|
-
const c =
|
|
1932
|
+
const c = de(Ii);
|
|
1933
1933
|
L(T.PeerConnectionFailureError, { warning: c, error: new Error(`Peer Connection failed. previous state: ${this._prevConnectionState}, current state: ${r}`), sessionId: this._session.sessionid }, this.options.id);
|
|
1934
1934
|
}
|
|
1935
1935
|
this._prevConnectionState = r, r === "connected" && (performance.mark("dtls-connected"), this.tryCollectTimings()), this._isTrickleIce() && (r === "connecting" && performance.mark("peer-connection-connecting"), r === "connected" && (this._clearIceGatheringSafetyTimeout(), performance.mark("peer-connection-connected")));
|
|
@@ -1944,10 +1944,10 @@ class xe {
|
|
|
1944
1944
|
}, 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;
|
|
1945
1945
|
}
|
|
1946
1946
|
get isOffer() {
|
|
1947
|
-
return this.type ===
|
|
1947
|
+
return this.type === z.Offer;
|
|
1948
1948
|
}
|
|
1949
1949
|
get isAnswer() {
|
|
1950
|
-
return this.type ===
|
|
1950
|
+
return this.type === z.Answer;
|
|
1951
1951
|
}
|
|
1952
1952
|
get isDebugEnabled() {
|
|
1953
1953
|
return this.options.debug || this._session.options.debug;
|
|
@@ -1998,40 +1998,40 @@ class xe {
|
|
|
1998
1998
|
if (this._timingsCollected || !(performance.getEntriesByName("call-active", "mark").length > 0) || this.instance.connectionState !== "connected") return;
|
|
1999
1999
|
this._timingsCollected = !0;
|
|
2000
2000
|
const e = (function(t, i) {
|
|
2001
|
-
const s =
|
|
2001
|
+
const s = Kt("new-call-start");
|
|
2002
2002
|
if (s === void 0) return { mode: t, direction: i, steps: [] };
|
|
2003
2003
|
const o = [];
|
|
2004
|
-
for (const
|
|
2005
|
-
if (
|
|
2006
|
-
const l =
|
|
2007
|
-
l !== void 0 && o.push({ label:
|
|
2004
|
+
for (const d of Jt) {
|
|
2005
|
+
if (d === "new-call-start") continue;
|
|
2006
|
+
const l = Kt(d);
|
|
2007
|
+
l !== void 0 && o.push({ label: ms[d] || d, fromStart: l - s });
|
|
2008
2008
|
}
|
|
2009
|
-
o.sort(((
|
|
2009
|
+
o.sort(((d, l) => d.fromStart - l.fromStart));
|
|
2010
2010
|
const r = [];
|
|
2011
2011
|
let c = 0;
|
|
2012
|
-
for (const
|
|
2012
|
+
for (const d of o) r.push({ label: d.label, fromStart: d.fromStart, delta: d.fromStart - c }), c = d.fromStart;
|
|
2013
2013
|
return { mode: t, direction: i, steps: r };
|
|
2014
2014
|
})(this._isTrickleIce() ? "trickle" : "non-trickle", this.isOffer ? "outbound" : "inbound");
|
|
2015
2015
|
(function(t) {
|
|
2016
2016
|
const { mode: i, direction: s, steps: o } = t, r = `[CallTimings][${s}][${i}]`;
|
|
2017
2017
|
if (o.length === 0) return void g.info(`${r} No timing data collected`);
|
|
2018
|
-
const c = Math.max(...o.map(((S) => S.label.length)), 4) + 2,
|
|
2018
|
+
const c = Math.max(...o.map(((S) => S.label.length)), 4) + 2, d = (S, y) => {
|
|
2019
2019
|
for (; S.length < y; ) S += " ";
|
|
2020
2020
|
return S;
|
|
2021
2021
|
}, l = (S, y) => {
|
|
2022
2022
|
for (; S.length < y; ) S = " " + S;
|
|
2023
2023
|
return S;
|
|
2024
|
-
}, f =
|
|
2024
|
+
}, f = d("Step", c) + l("Delta", 14) + l("From Start", 14);
|
|
2025
2025
|
let h = "";
|
|
2026
2026
|
for (let S = 0; S < f.length; S++) h += "-";
|
|
2027
|
-
g.info(`${r} Call establishment timing breakdown:`), g.info(`${r} ${f}`), g.info(`${r} ${h}`), g.info(`${r} ${
|
|
2027
|
+
g.info(`${r} Call establishment timing breakdown:`), g.info(`${r} ${f}`), g.info(`${r} ${h}`), g.info(`${r} ${d("Call Start", c)}${l("-", 14)}${l("0.00ms", 14)}`);
|
|
2028
2028
|
for (const S of o) {
|
|
2029
2029
|
const y = S.delta.toFixed(2) + "ms", v = S.fromStart.toFixed(2) + "ms";
|
|
2030
|
-
g.info(`${r} ${
|
|
2030
|
+
g.info(`${r} ${d(S.label, c)}${l(y, 14)}${l(v, 14)}`);
|
|
2031
2031
|
}
|
|
2032
2032
|
g.info(`${r} ${h}`);
|
|
2033
2033
|
})(e), (function() {
|
|
2034
|
-
for (const t of
|
|
2034
|
+
for (const t of Jt) try {
|
|
2035
2035
|
performance.clearMarks(t);
|
|
2036
2036
|
} catch {
|
|
2037
2037
|
g.warn("Clearing performance marks is failed");
|
|
@@ -2041,33 +2041,34 @@ class xe {
|
|
|
2041
2041
|
createPeerConnection() {
|
|
2042
2042
|
return O(this, void 0, void 0, (function* () {
|
|
2043
2043
|
var e;
|
|
2044
|
-
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", ((s) => {
|
|
2044
|
+
if (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", ((s) => {
|
|
2045
2045
|
this.options.remoteStream = s.stream;
|
|
2046
|
-
})), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type:
|
|
2046
|
+
})), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: z.Offer }), performance.mark("set-remote-description"), !this.instance)) throw W(rt);
|
|
2047
2047
|
const t = !!this.options.receiveOnlyAudio && !this.options.audio;
|
|
2048
2048
|
let i = null;
|
|
2049
2049
|
if (this.options.localStream = yield this._retrieveLocalStream().catch(((s) => O(this, void 0, void 0, (function* () {
|
|
2050
2050
|
const o = this._session.options.mediaPermissionsRecovery;
|
|
2051
2051
|
if (o?.enabled && this._isAnswer()) {
|
|
2052
2052
|
let r = null, c = null;
|
|
2053
|
-
return yield new Promise(((
|
|
2054
|
-
c = setTimeout((() => l(new Error("Media recovery flow timed out!"))), o.timeout), L(T.Error, { error: W(
|
|
2055
|
-
|
|
2053
|
+
return yield new Promise(((d, l) => {
|
|
2054
|
+
c = setTimeout((() => l(new Error("Media recovery flow timed out!"))), o.timeout), L(T.Error, { error: W(Le(s), s), callId: this.options.id, sessionId: this._session.sessionid, recoverable: !0, retryDeadline: Date.now() + o.timeout, resume: () => {
|
|
2055
|
+
d();
|
|
2056
2056
|
}, reject: () => {
|
|
2057
2057
|
l(new Error("Call was rejected during media recovery flow!"));
|
|
2058
2058
|
} }, this._session.uuid);
|
|
2059
2059
|
})).then((() => O(this, void 0, void 0, (function* () {
|
|
2060
|
-
var
|
|
2061
|
-
c && (clearTimeout(c), c = null), r = yield this._retrieveLocalStream(), (
|
|
2062
|
-
})))).catch(((
|
|
2060
|
+
var d;
|
|
2061
|
+
c && (clearTimeout(c), c = null), r = yield this._retrieveLocalStream(), (d = o.onSuccess) === null || d === void 0 || d.call(o);
|
|
2062
|
+
})))).catch(((d) => {
|
|
2063
2063
|
var l;
|
|
2064
|
-
c && (clearTimeout(c), c = null), i =
|
|
2064
|
+
c && (clearTimeout(c), c = null), i = d, (l = o.onError) === null || l === void 0 || l.call(o, d);
|
|
2065
2065
|
})), r;
|
|
2066
2066
|
}
|
|
2067
2067
|
return i = s, null;
|
|
2068
|
-
})))), !this.
|
|
2069
|
-
|
|
2070
|
-
|
|
2068
|
+
})))), !this.instance) throw W(rt);
|
|
2069
|
+
if (!this.options.localStream && !t)
|
|
2070
|
+
throw W(i ? Le(i) : hn, i ?? void 0);
|
|
2071
|
+
performance.mark("get-user-media"), this.options.mutedMicOnStart && me(this.options.localStream) && (g.info("Muting local audio tracks on start"), ft(this.options.localStream)), performance.mark("peer-creation-end");
|
|
2071
2072
|
}));
|
|
2072
2073
|
}
|
|
2073
2074
|
incrementGatheredCandidates() {
|
|
@@ -2077,14 +2078,14 @@ class xe {
|
|
|
2077
2078
|
this._clearIceGatheringSafetyTimeout(), this._iceGatheringSafetyTimeout = setTimeout((() => {
|
|
2078
2079
|
if (this.instance) {
|
|
2079
2080
|
if (this._gatheredCandidatesCount === 0) {
|
|
2080
|
-
const e =
|
|
2081
|
+
const e = de(Ei);
|
|
2081
2082
|
L(T.Warning, { warning: e, callId: this.options.id, sessionId: this._session.sessionid }, this.options.id);
|
|
2082
2083
|
} else if (this.instance.iceGatheringState !== "complete") {
|
|
2083
|
-
const e =
|
|
2084
|
+
const e = de(wi);
|
|
2084
2085
|
L(T.Warning, { warning: e, callId: this.options.id, sessionId: this._session.sessionid }, this.options.id);
|
|
2085
2086
|
}
|
|
2086
2087
|
}
|
|
2087
|
-
}),
|
|
2088
|
+
}), De.ICE_GATHERING_SAFETY_TIMEOUT_MS);
|
|
2088
2089
|
}
|
|
2089
2090
|
_clearIceGatheringSafetyTimeout() {
|
|
2090
2091
|
this._iceGatheringSafetyTimeout !== null && (clearTimeout(this._iceGatheringSafetyTimeout), this._iceGatheringSafetyTimeout = null);
|
|
@@ -2092,7 +2093,8 @@ class xe {
|
|
|
2092
2093
|
init() {
|
|
2093
2094
|
var e;
|
|
2094
2095
|
return O(this, void 0, void 0, (function* () {
|
|
2095
|
-
yield this.createPeerConnection(), this.
|
|
2096
|
+
if (yield this.createPeerConnection(), !this.instance) throw W(rt);
|
|
2097
|
+
this.isDebugEnabled && (this.statsReporter = gs(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));
|
|
2096
2098
|
const { localElement: t, localStream: i = null, screenShare: s = !1 } = this.options;
|
|
2097
2099
|
if (me(i)) {
|
|
2098
2100
|
const o = i.getAudioTracks();
|
|
@@ -2105,24 +2107,24 @@ class xe {
|
|
|
2105
2107
|
g.info("Local video tracks constraints: ", f.getConstraints());
|
|
2106
2108
|
}));
|
|
2107
2109
|
}
|
|
2108
|
-
const { audioCodecs: c, videoCodecs:
|
|
2110
|
+
const { audioCodecs: c, videoCodecs: d } = qt(this.options.preferred_codecs);
|
|
2109
2111
|
if (this.isOffer && typeof this.instance.addTransceiver == "function") {
|
|
2110
2112
|
const l = { direction: "sendrecv", streams: [i] };
|
|
2111
2113
|
r.forEach(((f) => {
|
|
2112
2114
|
f.kind === "audio" && (this.options.userVariables.microphoneLabel = f.label), f.kind === "video" && (this.options.userVariables.cameraLabel = f.label);
|
|
2113
2115
|
const h = this.instance.addTransceiver(f, l);
|
|
2114
|
-
f.kind === "audio" && c.length > 0 && this._setCodecs(h, c), f.kind === "video" &&
|
|
2116
|
+
f.kind === "audio" && c.length > 0 && this._setCodecs(h, c), f.kind === "video" && d.length > 0 && this._setCodecs(h, d);
|
|
2115
2117
|
}));
|
|
2116
2118
|
} else typeof this.instance.addTrack == "function" ? (r.forEach(((l) => {
|
|
2117
2119
|
l.kind === "audio" && (this.options.userVariables.microphoneLabel = l.label), l.kind === "video" && (this.options.userVariables.cameraLabel = l.label), this.instance.addTrack(l, i);
|
|
2118
2120
|
})), this.instance.getTransceivers().forEach(((l) => {
|
|
2119
|
-
l.receiver.track.kind === "audio" && c.length > 0 && this._setCodecs(l, c), l.receiver.track.kind === "video" &&
|
|
2121
|
+
l.receiver.track.kind === "audio" && c.length > 0 && this._setCodecs(l, c), l.receiver.track.kind === "video" && d.length > 0 && this._setCodecs(l, d);
|
|
2120
2122
|
}))) : this.instance.addStream(i);
|
|
2121
2123
|
s === !1 && Re(t, i);
|
|
2122
2124
|
} else if (this.options.receiveOnlyAudio && typeof this.instance.addTransceiver == "function") {
|
|
2123
2125
|
const o = this.instance.addTransceiver("audio", { direction: "recvonly" });
|
|
2124
2126
|
g.info("Added recvonly audio transceiver for receive-only mode", o);
|
|
2125
|
-
const { audioCodecs: r } =
|
|
2127
|
+
const { audioCodecs: r } = qt(this.options.preferred_codecs);
|
|
2126
2128
|
r.length > 0 && this._setCodecs(o, r);
|
|
2127
2129
|
}
|
|
2128
2130
|
this.isOffer ? (this.options.negotiateAudio && this._checkMediaToNegotiate("audio"), this.options.negotiateVideo && this._checkMediaToNegotiate("video")) : this._isTrickleIce() || this.startNegotiation(), this._isTrickleIce() && this.startTrickleIceNegotiation(), this._logTransceivers();
|
|
@@ -2146,7 +2148,7 @@ class xe {
|
|
|
2146
2148
|
return performance.mark("create-offer"), yield this._setLocalDescription(e), performance.mark("set-local-description"), performance.mark("ice-gathering-started"), this._isTrickleIce() || this._sdpReady(), e;
|
|
2147
2149
|
} catch (e) {
|
|
2148
2150
|
g.error("Peer _createOffer error:", e);
|
|
2149
|
-
const t = W(
|
|
2151
|
+
const t = W(ti, e);
|
|
2150
2152
|
L(T.Error, { error: t, sessionId: this._session.sessionid }, this.options.id);
|
|
2151
2153
|
}
|
|
2152
2154
|
}
|
|
@@ -2159,7 +2161,7 @@ class xe {
|
|
|
2159
2161
|
yield this.instance.setRemoteDescription(e);
|
|
2160
2162
|
} catch (t) {
|
|
2161
2163
|
g.error("Peer _setRemoteDescription error:", t);
|
|
2162
|
-
const i = W(
|
|
2164
|
+
const i = W(un, t);
|
|
2163
2165
|
throw L(T.Error, { error: i, sessionId: this._session.sessionid }, this.options.id), t;
|
|
2164
2166
|
}
|
|
2165
2167
|
}));
|
|
@@ -2167,14 +2169,14 @@ class xe {
|
|
|
2167
2169
|
_createAnswer() {
|
|
2168
2170
|
return O(this, void 0, void 0, (function* () {
|
|
2169
2171
|
if (this._isAnswer()) {
|
|
2170
|
-
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:
|
|
2172
|
+
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 })]));
|
|
2171
2173
|
this._logTransceivers();
|
|
2172
2174
|
try {
|
|
2173
2175
|
const e = yield this.instance.createAnswer();
|
|
2174
2176
|
return performance.mark("create-answer"), yield this._setLocalDescription(e), performance.mark("set-local-description"), performance.mark("ice-gathering-started"), e;
|
|
2175
2177
|
} catch (e) {
|
|
2176
2178
|
g.error("Peer _createAnswer error:", e);
|
|
2177
|
-
const t = W(
|
|
2179
|
+
const t = W(ni, e);
|
|
2178
2180
|
L(T.Error, { error: t, sessionId: this._session.sessionid }, this.options.id);
|
|
2179
2181
|
}
|
|
2180
2182
|
}
|
|
@@ -2186,7 +2188,7 @@ class xe {
|
|
|
2186
2188
|
yield this.instance.setLocalDescription(e);
|
|
2187
2189
|
} catch (t) {
|
|
2188
2190
|
g.error("Peer _setLocalDescription error:", t);
|
|
2189
|
-
const i = W(
|
|
2191
|
+
const i = W(ii, t);
|
|
2190
2192
|
throw L(T.Error, { error: i, sessionId: this._session.sessionid }, this.options.id), t;
|
|
2191
2193
|
}
|
|
2192
2194
|
}));
|
|
@@ -2199,18 +2201,18 @@ class xe {
|
|
|
2199
2201
|
if (me(this.options.localStream)) return this.options.localStream;
|
|
2200
2202
|
const e = yield (t = this.options, O(void 0, void 0, void 0, (function* () {
|
|
2201
2203
|
let { audio: i = !0, micId: s, video: o = !1, camId: r } = t;
|
|
2202
|
-
const { micLabel: c = "", camLabel:
|
|
2203
|
-
return s && (s = yield
|
|
2204
|
+
const { micLabel: c = "", camLabel: d = "" } = t;
|
|
2205
|
+
return s && (s = yield Ke(s, c, le.AudioIn).catch(((l) => null)), s && (typeof i == "boolean" && (i = {}), i.deviceId = { exact: s })), r && (r = yield Ke(r, d, le.Video).catch(((l) => null)), r && (typeof o == "boolean" && (o = {}), o.deviceId = { exact: r })), { audio: i, video: o };
|
|
2204
2206
|
})));
|
|
2205
2207
|
var t;
|
|
2206
|
-
return
|
|
2208
|
+
return Je(e);
|
|
2207
2209
|
}));
|
|
2208
2210
|
}
|
|
2209
2211
|
_isOffer() {
|
|
2210
|
-
return this.type ===
|
|
2212
|
+
return this.type === z.Offer;
|
|
2211
2213
|
}
|
|
2212
2214
|
_isAnswer() {
|
|
2213
|
-
return this.type ===
|
|
2215
|
+
return this.type === z.Answer;
|
|
2214
2216
|
}
|
|
2215
2217
|
_isTrickleIce() {
|
|
2216
2218
|
return this.options.trickleIce === !0;
|
|
@@ -2230,29 +2232,29 @@ class xe {
|
|
|
2230
2232
|
}));
|
|
2231
2233
|
}
|
|
2232
2234
|
}
|
|
2233
|
-
|
|
2234
|
-
const
|
|
2235
|
-
class
|
|
2235
|
+
De.ICE_GATHERING_SAFETY_TIMEOUT_MS = 15e3;
|
|
2236
|
+
const Be = wt;
|
|
2237
|
+
class On {
|
|
2236
2238
|
constructor(e, t) {
|
|
2237
|
-
this.session = e, this._callReportCollector = null, this.id = "", this.recoveredCallId = "", this.state = U[U.New], this.prevState = "", this.channels = [], this.role =
|
|
2239
|
+
this.session = e, this._callReportCollector = null, this.id = "", this.recoveredCallId = "", this.state = U[U.New], this.prevState = "", this.channels = [], this.role = ut.Participant, this.extension = null, this._state = U.New, this._prevState = U.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._firstCandidateSent = !1, this._firstNonHostCandidateSent = !1, this._isRecovering = !1, this._checkConferenceSerno = (m) => {
|
|
2238
2240
|
const w = m < 0 || !this._lastSerno || this._lastSerno && m === this._lastSerno + 1;
|
|
2239
2241
|
return w && m >= 0 && (this._lastSerno = m), w;
|
|
2240
2242
|
}, this._doStats = () => {
|
|
2241
2243
|
this.peer && this.peer.instance && this._statsBindings.length !== 0 && this.peer.instance.getStats().then(((m) => {
|
|
2242
2244
|
m.forEach(((w) => {
|
|
2243
|
-
this._statsBindings.forEach(((
|
|
2244
|
-
if (
|
|
2245
|
-
if (
|
|
2246
|
-
for (const A in
|
|
2245
|
+
this._statsBindings.forEach(((x) => {
|
|
2246
|
+
if (x.callback) {
|
|
2247
|
+
if (x.constraints) {
|
|
2248
|
+
for (const A in x.constraints) if (x.constraints.hasOwnProperty(A) && x.constraints[A] !== w[A]) return;
|
|
2247
2249
|
}
|
|
2248
|
-
|
|
2250
|
+
x.callback(w);
|
|
2249
2251
|
}
|
|
2250
2252
|
}));
|
|
2251
2253
|
}));
|
|
2252
2254
|
}));
|
|
2253
2255
|
};
|
|
2254
|
-
const { iceServers: i, speaker: s, micId: o, micLabel: r, camId: c, camLabel:
|
|
2255
|
-
this.options = Object.assign({},
|
|
2256
|
+
const { iceServers: i, speaker: s, micId: o, micLabel: r, camId: c, camLabel: d, localElement: l, remoteElement: f, options: h, mediaConstraints: { audio: S, video: y }, ringtoneFile: v, ringbackFile: E } = e;
|
|
2257
|
+
this.options = Object.assign({}, Wi, { audio: S, video: y, iceServers: t?.iceServers && Array.isArray(t.iceServers) ? t.iceServers : i, localElement: l, remoteElement: f, micId: o, micLabel: r, camId: c, camLabel: d, speakerId: s, ringtoneFile: v, ringbackFile: E, debug: h.debug, debugOutput: h.debugOutput, trickleIce: h.trickleIce, prefetchIceCandidates: h.prefetchIceCandidates, forceRelayCandidate: h.forceRelayCandidate, keepConnectionAliveOnSocketClose: h.keepConnectionAliveOnSocketClose, mutedMicOnStart: h.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 = Wt(this.options.ringtoneFile, "_ringtone"), this._ringback = Wt(this.options.ringbackFile, "_ringback"));
|
|
2256
2258
|
}
|
|
2257
2259
|
get creatingPeer() {
|
|
2258
2260
|
return this._creatingPeer;
|
|
@@ -2282,59 +2284,63 @@ class kn {
|
|
|
2282
2284
|
return `conference-member.${this.id}`;
|
|
2283
2285
|
}
|
|
2284
2286
|
get isAudioMuted() {
|
|
2285
|
-
return !
|
|
2287
|
+
return !rs(this.options.localStream);
|
|
2286
2288
|
}
|
|
2287
2289
|
invite() {
|
|
2288
2290
|
return O(this, void 0, void 0, (function* () {
|
|
2289
|
-
this._creatingPeer = !0, this.direction = ce.Outbound, this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("new-peer"), this.peer = new
|
|
2291
|
+
this._creatingPeer = !0, this.direction = ce.Outbound, this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("new-peer"), this.peer = new De(z.Offer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents);
|
|
2290
2292
|
try {
|
|
2291
2293
|
yield this.peer.init();
|
|
2292
2294
|
} catch (e) {
|
|
2293
2295
|
g.error("Peer init failed, aborting call", e), this._creatingPeer = !1;
|
|
2294
|
-
const t = e instanceof
|
|
2296
|
+
const t = e instanceof Oe ? e : W(kt, e instanceof Error ? e : void 0);
|
|
2295
2297
|
return L(T.Error, { error: t, callId: this.id, sessionId: this.session.sessionid, recoverable: !1 }, this.session.uuid), void this.hangup({}, !1);
|
|
2296
2298
|
}
|
|
2297
2299
|
this._creatingPeer = !1;
|
|
2298
2300
|
}));
|
|
2299
2301
|
}
|
|
2300
2302
|
answer(e = {}) {
|
|
2301
|
-
var t;
|
|
2303
|
+
var t, i;
|
|
2302
2304
|
return O(this, void 0, void 0, (function* () {
|
|
2303
|
-
|
|
2305
|
+
if (!((t = this.peer) === null || t === void 0) && t.instance && this.peer.instance.signalingState !== "closed") {
|
|
2306
|
+
const s = de(ki);
|
|
2307
|
+
return L(T.Warning, { warning: s, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid), void g.warn(`[${this.id}] answer() ignored: peer connection already exists (signalingState: ${this.peer.instance.signalingState})`);
|
|
2308
|
+
}
|
|
2309
|
+
performance.mark("answer-called"), this._creatingPeer = !0, this.stopRingtone(), this.direction = ce.Inbound, ((i = e?.customHeaders) === null || i === void 0 ? void 0 : i.length) > 0 && (this.options = Object.assign(Object.assign({}, this.options), { customHeaders: e.customHeaders })), this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("new-peer"), this.peer = new De(z.Answer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents);
|
|
2304
2310
|
try {
|
|
2305
2311
|
yield this.peer.init();
|
|
2306
|
-
} catch (
|
|
2307
|
-
g.error("Peer init failed, aborting call",
|
|
2308
|
-
const
|
|
2309
|
-
return L(T.Error, { error:
|
|
2312
|
+
} catch (s) {
|
|
2313
|
+
g.error("Peer init failed, aborting call", s), this._creatingPeer = !1;
|
|
2314
|
+
const o = s instanceof Oe ? s : W(kt, s instanceof Error ? s : void 0);
|
|
2315
|
+
return L(T.Error, { error: o, callId: this.id, sessionId: this.session.sessionid, recoverable: !1 }, this.session.uuid), void (yield this.hangup());
|
|
2310
2316
|
}
|
|
2311
2317
|
this._creatingPeer = !1;
|
|
2312
2318
|
}));
|
|
2313
2319
|
}
|
|
2314
2320
|
playRingtone() {
|
|
2315
|
-
|
|
2321
|
+
Gt(this._ringtone);
|
|
2316
2322
|
}
|
|
2317
2323
|
stopRingtone() {
|
|
2318
|
-
|
|
2324
|
+
Vt(this._ringtone);
|
|
2319
2325
|
}
|
|
2320
2326
|
playRingback() {
|
|
2321
|
-
|
|
2327
|
+
Gt(this._ringback);
|
|
2322
2328
|
}
|
|
2323
2329
|
stopRingback() {
|
|
2324
|
-
|
|
2330
|
+
Vt(this._ringback);
|
|
2325
2331
|
}
|
|
2326
2332
|
hangup(e, t) {
|
|
2327
2333
|
var i, s, o, r;
|
|
2328
2334
|
return O(this, void 0, void 0, (function* () {
|
|
2329
|
-
const c = e || {},
|
|
2335
|
+
const c = e || {}, d = t !== !1, l = this._state < U.Active ? { cause: "USER_BUSY", causeCode: 17 } : { cause: "NORMAL_CLEARING", causeCode: 16 };
|
|
2330
2336
|
if (this.cause = c.cause || l.cause, this.causeCode = c.causeCode || l.causeCode, this.sipCode = c.sipCode || null, this.sipReason = c.sipReason || null, this.sipCallId = c.sip_call_id || null, this.options.customHeaders = [...(i = this.options.customHeaders) !== null && i !== void 0 ? i : [], ...(o = (s = c?.dialogParams) === null || s === void 0 ? void 0 : s.customHeaders) !== null && o !== void 0 ? o : []], c.isRecovering) return this._isRecovering = !0, this.setState(U.Recovering), void this._finalize();
|
|
2331
|
-
if (this.setState(U.Hangup), this.stopRingtone(), this.stopRingback(),
|
|
2332
|
-
const f = new
|
|
2337
|
+
if (this.setState(U.Hangup), this.stopRingtone(), this.stopRingback(), d) {
|
|
2338
|
+
const f = new zi({ sipCode: this.sipCode, sip_call_id: this.sipCallId, sessid: this.session.sessionid, dialogParams: this.options, cause: this.cause, causeCode: this.causeCode });
|
|
2333
2339
|
try {
|
|
2334
2340
|
yield this._execute(f);
|
|
2335
2341
|
} catch (h) {
|
|
2336
2342
|
g.error("telnyx_rtc.bye failed!", h);
|
|
2337
|
-
const S = W(
|
|
2343
|
+
const S = W(ci, h);
|
|
2338
2344
|
L(T.Error, { error: S, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
2339
2345
|
}
|
|
2340
2346
|
}
|
|
@@ -2342,33 +2348,33 @@ class kn {
|
|
|
2342
2348
|
}));
|
|
2343
2349
|
}
|
|
2344
2350
|
hold() {
|
|
2345
|
-
const e = new
|
|
2351
|
+
const e = new ct({ sessid: this.session.sessionid, action: "hold", dialogParams: this.options });
|
|
2346
2352
|
return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
|
|
2347
2353
|
}
|
|
2348
2354
|
unhold() {
|
|
2349
|
-
const e = new
|
|
2355
|
+
const e = new ct({ sessid: this.session.sessionid, action: "unhold", dialogParams: this.options });
|
|
2350
2356
|
return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
|
|
2351
2357
|
}
|
|
2352
2358
|
toggleHold() {
|
|
2353
|
-
const e = new
|
|
2359
|
+
const e = new ct({ sessid: this.session.sessionid, action: "toggleHold", dialogParams: this.options });
|
|
2354
2360
|
return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
|
|
2355
2361
|
}
|
|
2356
2362
|
dtmf(e) {
|
|
2357
|
-
const t = new
|
|
2363
|
+
const t = new jt({ sessid: this.session.sessionid, dtmf: e, dialogParams: this.options });
|
|
2358
2364
|
this._execute(t);
|
|
2359
2365
|
}
|
|
2360
2366
|
message(e, t) {
|
|
2361
|
-
const i = { from: this.session.options.login, to: e, body: t }, s = new
|
|
2367
|
+
const i = { from: this.session.options.login, to: e, body: t }, s = new jt({ sessid: this.session.sessionid, msg: i, dialogParams: this.options });
|
|
2362
2368
|
this._execute(s);
|
|
2363
2369
|
}
|
|
2364
2370
|
muteAudio() {
|
|
2365
|
-
|
|
2371
|
+
ft(this.options.localStream);
|
|
2366
2372
|
}
|
|
2367
2373
|
unmuteAudio() {
|
|
2368
|
-
|
|
2374
|
+
Ht(this.options.localStream);
|
|
2369
2375
|
}
|
|
2370
2376
|
toggleAudioMute() {
|
|
2371
|
-
|
|
2377
|
+
$t(this.options.localStream);
|
|
2372
2378
|
}
|
|
2373
2379
|
setAudioInDevice(e, t = this.options.mutedMicOnStart) {
|
|
2374
2380
|
var i;
|
|
@@ -2377,15 +2383,15 @@ class kn {
|
|
|
2377
2383
|
if (o) {
|
|
2378
2384
|
let r;
|
|
2379
2385
|
try {
|
|
2380
|
-
r = yield
|
|
2386
|
+
r = yield Ye({ audio: { deviceId: { exact: e } } });
|
|
2381
2387
|
} catch (l) {
|
|
2382
|
-
const f = W(
|
|
2388
|
+
const f = W(Le(l), l);
|
|
2383
2389
|
return void L(T.MediaError, f, ((i = this.options) === null || i === void 0 ? void 0 : i.id) || this.id);
|
|
2384
2390
|
}
|
|
2385
2391
|
const c = r.getAudioTracks()[0];
|
|
2386
2392
|
c.enabled = !t, o.replaceTrack(c), this.options.micId = e;
|
|
2387
|
-
const { localStream:
|
|
2388
|
-
|
|
2393
|
+
const { localStream: d } = this.options;
|
|
2394
|
+
d.getAudioTracks().forEach(((l) => l.stop())), d.getVideoTracks().forEach(((l) => r.addTrack(l))), this.options.localStream = r;
|
|
2389
2395
|
}
|
|
2390
2396
|
}));
|
|
2391
2397
|
}
|
|
@@ -2405,21 +2411,21 @@ class kn {
|
|
|
2405
2411
|
return O(this, void 0, void 0, (function* () {
|
|
2406
2412
|
const { instance: t } = this.peer, i = t.getSenders().find((({ track: { kind: s } }) => s === "video"));
|
|
2407
2413
|
if (i) {
|
|
2408
|
-
const s = yield
|
|
2414
|
+
const s = yield Ye({ video: { deviceId: { exact: e } } }), o = s.getVideoTracks()[0];
|
|
2409
2415
|
i.replaceTrack(o);
|
|
2410
2416
|
const { localElement: r, localStream: c } = this.options;
|
|
2411
|
-
Re(r, s), this.options.camId = e, c.getAudioTracks().forEach(((
|
|
2417
|
+
Re(r, s), this.options.camId = e, c.getAudioTracks().forEach(((d) => s.addTrack(d))), c.getVideoTracks().forEach(((d) => d.stop())), this.options.localStream = s;
|
|
2412
2418
|
}
|
|
2413
2419
|
}));
|
|
2414
2420
|
}
|
|
2415
2421
|
deaf() {
|
|
2416
|
-
|
|
2422
|
+
ft(this.options.remoteStream);
|
|
2417
2423
|
}
|
|
2418
2424
|
undeaf() {
|
|
2419
|
-
|
|
2425
|
+
Ht(this.options.remoteStream);
|
|
2420
2426
|
}
|
|
2421
2427
|
toggleDeaf() {
|
|
2422
|
-
|
|
2428
|
+
$t(this.options.remoteStream);
|
|
2423
2429
|
}
|
|
2424
2430
|
setBandwidthEncodingsMaxBps(e, t) {
|
|
2425
2431
|
return O(this, void 0, void 0, (function* () {
|
|
@@ -2455,7 +2461,7 @@ class kn {
|
|
|
2455
2461
|
case U.Active:
|
|
2456
2462
|
performance.mark("call-active"), (t = this.peer) === null || t === void 0 || t.tryCollectTimings(), this._isRecovering && (this._isRecovering = !1, g.debug(`[${this.id}] Recovery complete, call is active`)), setTimeout((() => {
|
|
2457
2463
|
const { remoteElement: s, speakerId: o } = this.options;
|
|
2458
|
-
s && o &&
|
|
2464
|
+
s && o && kn(s, o);
|
|
2459
2465
|
}), 0), this._callReportCollector && (!((i = this.peer) === null || i === void 0) && i.instance) && this.session.callReportId && this._callReportCollector.start(this.peer.instance);
|
|
2460
2466
|
break;
|
|
2461
2467
|
case U.Destroy:
|
|
@@ -2465,34 +2471,34 @@ class kn {
|
|
|
2465
2471
|
handleMessage(e) {
|
|
2466
2472
|
const { method: t, params: i } = e;
|
|
2467
2473
|
switch (t) {
|
|
2468
|
-
case
|
|
2474
|
+
case H.Answer:
|
|
2469
2475
|
if (performance.mark("telnyx-rtc-answer"), 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 >= U.Active) return;
|
|
2470
2476
|
this._state >= U.Early && this.setState(U.Active), this.gotEarly || this._onRemoteSdp(i.sdp), this.stopRingback(), this.stopRingtone();
|
|
2471
2477
|
break;
|
|
2472
|
-
case
|
|
2478
|
+
case H.Media:
|
|
2473
2479
|
if (performance.mark("telnyx-rtc-media"), this._state >= U.Early) return;
|
|
2474
2480
|
this.gotEarly = !0, this._onRemoteSdp(i.sdp);
|
|
2475
2481
|
break;
|
|
2476
|
-
case
|
|
2482
|
+
case H.Display: {
|
|
2477
2483
|
const { display_name: o, display_number: r, display_direction: c } = i;
|
|
2478
2484
|
this.extension = r;
|
|
2479
|
-
const
|
|
2485
|
+
const d = c === ce.Inbound ? ce.Outbound : ce.Inbound, l = { type: re[t], call: this, displayName: o, displayNumber: r, displayDirection: d };
|
|
2480
2486
|
L(T.Notification, l, this.id) || L(T.Notification, l, this.session.uuid);
|
|
2481
2487
|
break;
|
|
2482
2488
|
}
|
|
2483
|
-
case
|
|
2489
|
+
case H.Candidate:
|
|
2484
2490
|
this._addIceCandidate(i);
|
|
2485
2491
|
break;
|
|
2486
|
-
case
|
|
2487
|
-
case
|
|
2492
|
+
case H.Info:
|
|
2493
|
+
case H.Event: {
|
|
2488
2494
|
const o = Object.assign(Object.assign({}, i), { type: re.generic, call: this });
|
|
2489
2495
|
L(T.Notification, o, this.id) || L(T.Notification, o, this.session.uuid);
|
|
2490
2496
|
break;
|
|
2491
2497
|
}
|
|
2492
|
-
case
|
|
2498
|
+
case H.Ringing:
|
|
2493
2499
|
performance.mark("ringing"), 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);
|
|
2494
2500
|
break;
|
|
2495
|
-
case
|
|
2501
|
+
case H.Bye:
|
|
2496
2502
|
const s = i.client_state || i.clientState;
|
|
2497
2503
|
s && (this.options.clientState = s), this.stopRingback(), this.stopRingtone(), this.hangup(i, !1);
|
|
2498
2504
|
}
|
|
@@ -2504,21 +2510,21 @@ class kn {
|
|
|
2504
2510
|
switch (i) {
|
|
2505
2511
|
case "bootObj": {
|
|
2506
2512
|
this._lastSerno = 0;
|
|
2507
|
-
const { chatChannel: c, infoChannel:
|
|
2508
|
-
this._dispatchConferenceUpdate({ action: oe.Join, conferenceName: f, participantId: Number(h), role: S }), c && (yield this._subscribeConferenceChat(c)),
|
|
2513
|
+
const { chatChannel: c, infoChannel: d, modChannel: l, laName: f, conferenceMemberID: h, role: S } = t;
|
|
2514
|
+
this._dispatchConferenceUpdate({ action: oe.Join, conferenceName: f, participantId: Number(h), role: S }), c && (yield this._subscribeConferenceChat(c)), d && (yield this._subscribeConferenceInfo(d));
|
|
2509
2515
|
const y = [];
|
|
2510
|
-
for (const v in s) y.push(Object.assign({ callId: s[v][0], index: Number(v) },
|
|
2516
|
+
for (const v in s) y.push(Object.assign({ callId: s[v][0], index: Number(v) }, Fe(s[v][1])));
|
|
2511
2517
|
this._dispatchConferenceUpdate({ action: oe.Bootstrap, participants: y });
|
|
2512
2518
|
break;
|
|
2513
2519
|
}
|
|
2514
2520
|
case "add":
|
|
2515
|
-
this._dispatchConferenceUpdate(Object.assign({ action: oe.Add, callId: o, index: r },
|
|
2521
|
+
this._dispatchConferenceUpdate(Object.assign({ action: oe.Add, callId: o, index: r }, Fe(s)));
|
|
2516
2522
|
break;
|
|
2517
2523
|
case "modify":
|
|
2518
|
-
this._dispatchConferenceUpdate(Object.assign({ action: oe.Modify, callId: o, index: r },
|
|
2524
|
+
this._dispatchConferenceUpdate(Object.assign({ action: oe.Modify, callId: o, index: r }, Fe(s)));
|
|
2519
2525
|
break;
|
|
2520
2526
|
case "del":
|
|
2521
|
-
this._dispatchConferenceUpdate(Object.assign({ action: oe.Delete, callId: o, index: r },
|
|
2527
|
+
this._dispatchConferenceUpdate(Object.assign({ action: oe.Delete, callId: o, index: r }, Fe(s)));
|
|
2522
2528
|
break;
|
|
2523
2529
|
case "clear":
|
|
2524
2530
|
this._dispatchConferenceUpdate({ action: oe.Clear });
|
|
@@ -2536,12 +2542,12 @@ class kn {
|
|
|
2536
2542
|
_subscribeConferenceChat(e) {
|
|
2537
2543
|
return O(this, void 0, void 0, (function* () {
|
|
2538
2544
|
const t = { nodeId: this.nodeId, channels: [e], handler: (s) => {
|
|
2539
|
-
const { direction: o, from: r, fromDisplay: c, message:
|
|
2540
|
-
this._dispatchConferenceUpdate({ action: oe.ChatMessage, direction: o, participantNumber: r, participantName: c, messageText:
|
|
2545
|
+
const { direction: o, from: r, fromDisplay: c, message: d, type: l } = s.data;
|
|
2546
|
+
this._dispatchConferenceUpdate({ action: oe.ChatMessage, direction: o, participantNumber: r, participantName: c, messageText: d, messageType: l, messageId: s.eventSerno });
|
|
2541
2547
|
} }, i = yield this.session.vertoSubscribe(t).catch(((s) => {
|
|
2542
2548
|
g.error("ConfChat subscription error:", s);
|
|
2543
2549
|
}));
|
|
2544
|
-
|
|
2550
|
+
ht(i, e) && (this._addChannel(e), Object.defineProperties(this, { sendChatMessage: { configurable: !0, value: (s, o) => {
|
|
2545
2551
|
this.session.vertoBroadcast({ nodeId: this.nodeId, channel: e, data: { action: "send", message: s, type: o } });
|
|
2546
2552
|
} } }));
|
|
2547
2553
|
}));
|
|
@@ -2550,11 +2556,11 @@ class kn {
|
|
|
2550
2556
|
return O(this, void 0, void 0, (function* () {
|
|
2551
2557
|
const t = { nodeId: this.nodeId, channels: [e], handler: (s) => {
|
|
2552
2558
|
const { eventData: o } = s;
|
|
2553
|
-
o.contentType === "layout-info" ? (o.callID = this.id,
|
|
2559
|
+
o.contentType === "layout-info" ? (o.callID = this.id, An(this.session, o)) : g.error("Conference-Info unknown contentType", s);
|
|
2554
2560
|
} }, i = yield this.session.vertoSubscribe(t).catch(((s) => {
|
|
2555
2561
|
g.error("ConfInfo subscription error:", s);
|
|
2556
2562
|
}));
|
|
2557
|
-
|
|
2563
|
+
ht(i, e) && this._addChannel(e);
|
|
2558
2564
|
}));
|
|
2559
2565
|
}
|
|
2560
2566
|
_confControl(e, t = {}) {
|
|
@@ -2566,17 +2572,17 @@ class kn {
|
|
|
2566
2572
|
}
|
|
2567
2573
|
_handleChangeHoldStateError(e) {
|
|
2568
2574
|
g.error(`Failed to ${e.action} on call ${this.id}`);
|
|
2569
|
-
const t = W(
|
|
2575
|
+
const t = W(ri, e);
|
|
2570
2576
|
return L(T.Error, { error: t, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid), !1;
|
|
2571
2577
|
}
|
|
2572
2578
|
_onRemoteSdp(e) {
|
|
2573
2579
|
return O(this, void 0, void 0, (function* () {
|
|
2574
|
-
const t = new RTCSessionDescription({ sdp: e, type:
|
|
2580
|
+
const t = new RTCSessionDescription({ sdp: e, type: z.Answer });
|
|
2575
2581
|
yield this.peer.instance.setRemoteDescription(t).then((() => {
|
|
2576
2582
|
performance.mark("set-remote-description"), this.options.trickleIce && (this._isRemoteDescriptionSet = !0, this._flushPendingTrickleIceCandidates()), this.gotEarly && this.setState(U.Early), this.gotAnswer && this.setState(U.Active);
|
|
2577
2583
|
})).catch(((i) => O(this, void 0, void 0, (function* () {
|
|
2578
2584
|
g.error("Call setRemoteDescription Error: ", i);
|
|
2579
|
-
const s = W(
|
|
2585
|
+
const s = W(un, i);
|
|
2580
2586
|
L(T.Error, { error: s, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
2581
2587
|
try {
|
|
2582
2588
|
yield this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
|
|
@@ -2595,29 +2601,29 @@ class kn {
|
|
|
2595
2601
|
const { sdp: s, type: o } = e;
|
|
2596
2602
|
if (s.indexOf("candidate") === -1) return g.info(`No candidate - retry
|
|
2597
2603
|
`), void this._requestAnotherLocalDescription();
|
|
2598
|
-
if ((i = (t = this.peer) === null || t === void 0 ? void 0 : t.instance) === null || i === void 0 || i.removeEventListener("icecandidate", this._onIce), !
|
|
2599
|
-
const
|
|
2600
|
-
g.warn(`[${this.id}] Warning ${
|
|
2604
|
+
if ((i = (t = this.peer) === null || t === void 0 ? void 0 : t.instance) === null || i === void 0 || i.removeEventListener("icecandidate", this._onIce), !Oi.test(s)) {
|
|
2605
|
+
const d = de(Ti);
|
|
2606
|
+
g.warn(`[${this.id}] Warning ${d.code}: ${d.message}`), L(T.Warning, { warning: d, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
2601
2607
|
}
|
|
2602
2608
|
performance.mark("ice-gathering-end");
|
|
2603
2609
|
let r = null;
|
|
2604
|
-
const c = { sessid: this.session.sessionid, sdp: s, dialogParams: this.options, "User-Agent": `Web-${
|
|
2610
|
+
const c = { sessid: this.session.sessionid, sdp: s, dialogParams: this.options, "User-Agent": `Web-${Be}` };
|
|
2605
2611
|
switch (o) {
|
|
2606
|
-
case
|
|
2607
|
-
this.setState(U.Requesting), r = new
|
|
2612
|
+
case z.Offer:
|
|
2613
|
+
this.setState(U.Requesting), r = new Mt(c);
|
|
2608
2614
|
break;
|
|
2609
|
-
case
|
|
2610
|
-
this._isRecovering || this.setState(U.Answering), r = this.options.attach === !0 ? new
|
|
2615
|
+
case z.Answer:
|
|
2616
|
+
this._isRecovering || this.setState(U.Answering), r = this.options.attach === !0 ? new Ft(c) : new Ut(c);
|
|
2611
2617
|
break;
|
|
2612
2618
|
default:
|
|
2613
2619
|
return g.error(`${this.id} - Unknown local SDP type:`, e), void this.hangup({}, !1);
|
|
2614
2620
|
}
|
|
2615
|
-
performance.mark("send-sdp"), this._execute(r).then(((
|
|
2616
|
-
const { node_id: l = null } =
|
|
2617
|
-
this._targetNodeId = l, o ===
|
|
2618
|
-
})).catch(((
|
|
2619
|
-
g.error(`${this.id} - Sending ${o} error:`,
|
|
2620
|
-
const l = W(
|
|
2621
|
+
performance.mark("send-sdp"), this._execute(r).then(((d) => {
|
|
2622
|
+
const { node_id: l = null } = d;
|
|
2623
|
+
this._targetNodeId = l, o === z.Offer ? this.setState(U.Trying) : this.setState(U.Active);
|
|
2624
|
+
})).catch(((d) => O(this, void 0, void 0, (function* () {
|
|
2625
|
+
g.error(`${this.id} - Sending ${o} error:`, d);
|
|
2626
|
+
const l = W(Tt, d);
|
|
2621
2627
|
L(T.Error, { error: l, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
2622
2628
|
try {
|
|
2623
2629
|
yield this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
|
|
@@ -2630,28 +2636,28 @@ class kn {
|
|
|
2630
2636
|
if (!e) return g.error("No SDP data provided"), void this.hangup({}, !1);
|
|
2631
2637
|
const { sdp: t, type: i } = e;
|
|
2632
2638
|
let s = null;
|
|
2633
|
-
const o = { sessid: this.session.sessionid, sdp: t, dialogParams: this.options, trickle: !0, "User-Agent": `Web-${
|
|
2639
|
+
const o = { sessid: this.session.sessionid, sdp: t, dialogParams: this.options, trickle: !0, "User-Agent": `Web-${Be}` };
|
|
2634
2640
|
switch (i) {
|
|
2635
|
-
case
|
|
2636
|
-
this.setState(U.Requesting), s = new
|
|
2641
|
+
case z.Offer:
|
|
2642
|
+
this.setState(U.Requesting), s = new Mt(o);
|
|
2637
2643
|
break;
|
|
2638
|
-
case
|
|
2639
|
-
this._isRecovering || this.setState(U.Answering), s = this.options.attach === !0 ? new
|
|
2644
|
+
case z.Answer:
|
|
2645
|
+
this._isRecovering || this.setState(U.Answering), s = this.options.attach === !0 ? new Ft(o) : new Ut(o);
|
|
2640
2646
|
break;
|
|
2641
2647
|
default:
|
|
2642
2648
|
return g.error(`${this.id} - Unknown local SDP type:`, e), void this.hangup({}, !1);
|
|
2643
2649
|
}
|
|
2644
2650
|
performance.mark("send-sdp"), this._execute(s).then(((r) => {
|
|
2645
2651
|
const { node_id: c = null } = r;
|
|
2646
|
-
this._targetNodeId = c, i ===
|
|
2652
|
+
this._targetNodeId = c, i === z.Offer ? this.setState(U.Trying) : this.setState(U.Active);
|
|
2647
2653
|
})).catch(((r) => O(this, void 0, void 0, (function* () {
|
|
2648
2654
|
g.error(`${this.id} - Sending ${i} error:`, r);
|
|
2649
|
-
const c = W(
|
|
2655
|
+
const c = W(Tt, r);
|
|
2650
2656
|
L(T.Error, { error: c, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
2651
2657
|
try {
|
|
2652
2658
|
yield this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
|
|
2653
|
-
} catch (
|
|
2654
|
-
g.error("Error during hangup after SDP send failure:",
|
|
2659
|
+
} catch (d) {
|
|
2660
|
+
g.error("Error during hangup after SDP send failure:", d);
|
|
2655
2661
|
}
|
|
2656
2662
|
}))));
|
|
2657
2663
|
}
|
|
@@ -2669,7 +2675,7 @@ class kn {
|
|
|
2669
2675
|
e.candidate && e.candidate.candidate ? (g.debug("RTCPeer Candidate:", e.candidate), (t = this.peer) === null || t === void 0 || t.incrementGatheredCandidates(), this._trackCandidateMarks(e.candidate), this._sendIceCandidate(e.candidate)) : this._sendEndOfCandidates();
|
|
2670
2676
|
}
|
|
2671
2677
|
_sendIceCandidate(e) {
|
|
2672
|
-
const t = new
|
|
2678
|
+
const t = new Qi({ sessid: this.session.sessionid, candidate: e.candidate, sdpMLineIndex: e.sdpMLineIndex, sdpMid: e.sdpMid, dialogParams: this.options });
|
|
2673
2679
|
this._execute(t);
|
|
2674
2680
|
}
|
|
2675
2681
|
_addIceCandidate(e) {
|
|
@@ -2685,7 +2691,7 @@ class kn {
|
|
|
2685
2691
|
}));
|
|
2686
2692
|
}
|
|
2687
2693
|
_sendEndOfCandidates() {
|
|
2688
|
-
const e = new
|
|
2694
|
+
const e = new Zi({ sessid: this.session.sessionid, endOfCandidates: !0, dialogParams: this.options });
|
|
2689
2695
|
this._execute(e);
|
|
2690
2696
|
}
|
|
2691
2697
|
_trackCandidateMarks(e) {
|
|
@@ -2713,7 +2719,7 @@ class kn {
|
|
|
2713
2719
|
}, e.onicecandidateerror = (t) => {
|
|
2714
2720
|
var i;
|
|
2715
2721
|
if (g.debug("ICE candidate error:", t), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
|
|
2716
|
-
const s =
|
|
2722
|
+
const s = Yt(t, e);
|
|
2717
2723
|
this.peer.statsReporter.reportIceCandidateError(s);
|
|
2718
2724
|
}
|
|
2719
2725
|
}, e.addEventListener("addstream", ((t) => {
|
|
@@ -2732,7 +2738,7 @@ class kn {
|
|
|
2732
2738
|
}, e.onicecandidateerror = (t) => {
|
|
2733
2739
|
var i;
|
|
2734
2740
|
if (g.debug("ICE candidate error:", t), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
|
|
2735
|
-
const s =
|
|
2741
|
+
const s = Yt(t, e);
|
|
2736
2742
|
this.peer.statsReporter.reportIceCandidateError(s);
|
|
2737
2743
|
}
|
|
2738
2744
|
}, e.addEventListener("addstream", ((t) => {
|
|
@@ -2765,8 +2771,8 @@ class kn {
|
|
|
2765
2771
|
_init() {
|
|
2766
2772
|
var e, t;
|
|
2767
2773
|
const { id: i, userVariables: s, remoteCallerNumber: o, onNotification: r, recoveredCallId: c } = this.options;
|
|
2768
|
-
var
|
|
2769
|
-
this.options.id = i ? i.toString() : ye(), this.id = this.options.id, c && (this.recoveredCallId = c, this._isRecovering = !0), s && (
|
|
2774
|
+
var d;
|
|
2775
|
+
this.options.id = i ? i.toString() : ye(), this.id = this.options.id, c && (this.recoveredCallId = c, this._isRecovering = !0), s && (d = s, Object.keys(d).length !== 0) || (this.options.userVariables = this.session.options.userVariables || {}), o || (this.options.remoteCallerNumber = this.options.destinationNumber), this.session.calls[this.id] = this, he(T.MediaError, this._onMediaError, this.id), he(T.PeerConnectionFailureError, this._onPeerConnectionFailureError, this.id), he(T.PeerConnectionSignalingStateClosed, this._onPeerConnectionSignalingStateClosed, this.id), Se(r) && he(T.Notification, r.bind(this), this.id);
|
|
2770
2776
|
const l = this.session.options.enableCallReports !== !1, f = this.session.options.callReportInterval || 5e3, h = this.session.options.debugLogLevel || "debug", S = this.session.options.debugLogMaxEntries || 1e3;
|
|
2771
2777
|
l && (this._callReportCollector = new J({ enabled: !0, interval: f }, { enabled: !0, level: h, maxEntries: S }), this._callReportCollector.onFlushNeeded = () => {
|
|
2772
2778
|
this._flushIntermediateReport();
|
|
@@ -2789,7 +2795,7 @@ class kn {
|
|
|
2789
2795
|
if (!t) return void g.debug("Cannot flush intermediate report: call_report_id not available");
|
|
2790
2796
|
const i = (e = this.session.connection) === null || e === void 0 ? void 0 : e.host;
|
|
2791
2797
|
if (!i) return void g.debug("Cannot flush intermediate report: connection host not available");
|
|
2792
|
-
const s = { callId: this.id, destinationNumber: this.options.destinationNumber, callerNumber: this.options.callerNumber, direction: this.direction === ce.Inbound ? "inbound" : "outbound", state: this.state, telnyxSessionId: this.options.telnyxSessionId, telnyxLegId: this.options.telnyxLegId, sdkVersion:
|
|
2798
|
+
const s = { callId: this.id, destinationNumber: this.options.destinationNumber, callerNumber: this.options.callerNumber, direction: this.direction === ce.Inbound ? "inbound" : "outbound", state: this.state, telnyxSessionId: this.options.telnyxSessionId, telnyxLegId: this.options.telnyxLegId, sdkVersion: Be }, o = this._callReportCollector.flush(s);
|
|
2793
2799
|
if (!o) return;
|
|
2794
2800
|
const r = fe() || void 0;
|
|
2795
2801
|
this._callReportCollector.sendPayload(o, t, i, r).catch(((c) => {
|
|
@@ -2803,7 +2809,7 @@ class kn {
|
|
|
2803
2809
|
yield this._callReportCollector.stop();
|
|
2804
2810
|
const t = this.session.callReportId;
|
|
2805
2811
|
if (!t) return g.debug("Cannot post call report: call_report_id not available"), void this._callReportCollector.cleanup();
|
|
2806
|
-
const i = { callId: this.id, destinationNumber: this.options.destinationNumber, callerNumber: this.options.callerNumber, direction: this.direction === ce.Inbound ? "inbound" : "outbound", state: this.state, telnyxSessionId: this.options.telnyxSessionId, telnyxLegId: this.options.telnyxLegId, sdkVersion:
|
|
2812
|
+
const i = { callId: this.id, destinationNumber: this.options.destinationNumber, callerNumber: this.options.callerNumber, direction: this.direction === ce.Inbound ? "inbound" : "outbound", state: this.state, telnyxSessionId: this.options.telnyxSessionId, telnyxLegId: this.options.telnyxLegId, sdkVersion: Be }, s = (e = this.session.connection) === null || e === void 0 ? void 0 : e.host;
|
|
2807
2813
|
if (!s) return void g.error("Cannot post call report: connection host not available");
|
|
2808
2814
|
const o = fe() || void 0;
|
|
2809
2815
|
this._callReportCollector.postReport(i, t, s, o).catch(((r) => {
|
|
@@ -2821,7 +2827,7 @@ class kn {
|
|
|
2821
2827
|
this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null), g.debug("Stats stopped");
|
|
2822
2828
|
}
|
|
2823
2829
|
}
|
|
2824
|
-
|
|
2830
|
+
On.setStateTelnyx = (n) => {
|
|
2825
2831
|
if (n) {
|
|
2826
2832
|
switch (n._state) {
|
|
2827
2833
|
case U.Recovering:
|
|
@@ -2851,9 +2857,9 @@ kn.setStateTelnyx = (n) => {
|
|
|
2851
2857
|
return n;
|
|
2852
2858
|
}
|
|
2853
2859
|
};
|
|
2854
|
-
class ge extends
|
|
2860
|
+
class ge extends On {
|
|
2855
2861
|
constructor() {
|
|
2856
|
-
super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, t) => this.session.execute(new
|
|
2862
|
+
super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, t) => this.session.execute(new cs(e, t));
|
|
2857
2863
|
}
|
|
2858
2864
|
hangup(e = {}, t = !0) {
|
|
2859
2865
|
const i = Object.create(null, { hangup: { get: () => super.hangup } });
|
|
@@ -2870,8 +2876,8 @@ class ge extends kn {
|
|
|
2870
2876
|
this.screenShare && (yield this.screenShare.hangup());
|
|
2871
2877
|
}))));
|
|
2872
2878
|
}));
|
|
2873
|
-
const { remoteCallerName: s, remoteCallerNumber: o, callerName: r, callerNumber: c } = this.options,
|
|
2874
|
-
return this.screenShare = new ge(this.session,
|
|
2879
|
+
const { remoteCallerName: s, remoteCallerNumber: o, callerName: r, callerNumber: c } = this.options, d = Object.assign({ screenShare: !0, localStream: t, destinationNumber: `${this.extension}-screen`, remoteCallerName: s, remoteCallerNumber: `${o}-screen`, callerName: `${r} (Screen)`, callerNumber: `${c} (Screen)` }, e);
|
|
2880
|
+
return this.screenShare = new ge(this.session, d), this.screenShare.invite(), this.screenShare;
|
|
2875
2881
|
}));
|
|
2876
2882
|
}
|
|
2877
2883
|
stopScreenShare() {
|
|
@@ -2883,7 +2889,7 @@ class ge extends kn {
|
|
|
2883
2889
|
return O(this, void 0, void 0, (function* () {
|
|
2884
2890
|
this.options.speakerId = e;
|
|
2885
2891
|
const { remoteElement: t, speakerId: i } = this.options;
|
|
2886
|
-
return !(!t || !i) &&
|
|
2892
|
+
return !(!t || !i) && kn(t, i);
|
|
2887
2893
|
}));
|
|
2888
2894
|
}
|
|
2889
2895
|
_finalize() {
|
|
@@ -2906,7 +2912,7 @@ ${r.type}
|
|
|
2906
2912
|
}))), 2e3);
|
|
2907
2913
|
}
|
|
2908
2914
|
}
|
|
2909
|
-
class
|
|
2915
|
+
class _s extends xe {
|
|
2910
2916
|
constructor(e) {
|
|
2911
2917
|
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();
|
|
2912
2918
|
}
|
|
@@ -2928,7 +2934,7 @@ class fs extends Le {
|
|
|
2928
2934
|
checkPermissions(e = !0, t = !0) {
|
|
2929
2935
|
return O(this, void 0, void 0, (function* () {
|
|
2930
2936
|
try {
|
|
2931
|
-
const i = yield
|
|
2937
|
+
const i = yield Je({ audio: e, video: t });
|
|
2932
2938
|
return Ne(i), !0;
|
|
2933
2939
|
} catch {
|
|
2934
2940
|
return !1;
|
|
@@ -2968,9 +2974,9 @@ class fs extends Le {
|
|
|
2968
2974
|
}
|
|
2969
2975
|
speedTest(e) {
|
|
2970
2976
|
return new Promise(((t, i) => {
|
|
2971
|
-
if (
|
|
2972
|
-
const { upDur: c, downDur:
|
|
2973
|
-
t({ upDur: c, downDur:
|
|
2977
|
+
if (wn(T.SpeedTest, ((r) => {
|
|
2978
|
+
const { upDur: c, downDur: d } = r, l = d ? 8 * e / (d / 1e3) / 1024 : 0;
|
|
2979
|
+
t({ upDur: c, downDur: d, upKps: (c ? 8 * e / (c / 1e3) / 1024 : 0).toFixed(0), downKps: l.toFixed(0) });
|
|
2974
2980
|
}), this.uuid), !(e = Number(e))) return i(`Invalid parameter 'bytes': ${e}`);
|
|
2975
2981
|
this.executeRaw(`#SPU ${e}`);
|
|
2976
2982
|
let s = e / 1024;
|
|
@@ -2982,7 +2988,7 @@ class fs extends Le {
|
|
|
2982
2988
|
}
|
|
2983
2989
|
getDevices() {
|
|
2984
2990
|
return Te().catch(((e) => {
|
|
2985
|
-
const t = W(
|
|
2991
|
+
const t = W(Le(e), e);
|
|
2986
2992
|
return L(T.MediaError, t, this.uuid), [];
|
|
2987
2993
|
}));
|
|
2988
2994
|
}
|
|
@@ -2991,7 +2997,7 @@ class fs extends Le {
|
|
|
2991
2997
|
}
|
|
2992
2998
|
getAudioInDevices() {
|
|
2993
2999
|
return Te(le.AudioIn).catch(((e) => {
|
|
2994
|
-
const t = W(
|
|
3000
|
+
const t = W(Le(e), e);
|
|
2995
3001
|
return L(T.MediaError, t, this.uuid), [];
|
|
2996
3002
|
}));
|
|
2997
3003
|
}
|
|
@@ -2999,16 +3005,16 @@ class fs extends Le {
|
|
|
2999
3005
|
return Te(le.AudioOut).catch(((e) => (g.error("getAudioOutDevices", e), L(T.MediaError, e, this.uuid), [])));
|
|
3000
3006
|
}
|
|
3001
3007
|
validateDeviceId(e, t, i) {
|
|
3002
|
-
return
|
|
3008
|
+
return Ke(e, t, i);
|
|
3003
3009
|
}
|
|
3004
3010
|
getDeviceResolutions(e) {
|
|
3005
3011
|
return O(this, void 0, void 0, (function* () {
|
|
3006
3012
|
try {
|
|
3007
3013
|
return yield ((t) => O(void 0, void 0, void 0, (function* () {
|
|
3008
|
-
const i = [], s = yield
|
|
3009
|
-
for (let r = 0; r <
|
|
3010
|
-
const [c,
|
|
3011
|
-
(yield o.applyConstraints({ width: { exact: c }, height: { exact:
|
|
3014
|
+
const i = [], s = yield Je({ video: { deviceId: { exact: t } } }), o = s.getVideoTracks()[0];
|
|
3015
|
+
for (let r = 0; r < Bt.length; r++) {
|
|
3016
|
+
const [c, d] = Bt[r];
|
|
3017
|
+
(yield o.applyConstraints({ width: { exact: c }, height: { exact: d } }).then((() => !0)).catch((() => !1))) && i.push({ resolution: `${c}x${d}`, width: c, height: d });
|
|
3012
3018
|
}
|
|
3013
3019
|
return Ne(s), i;
|
|
3014
3020
|
})))(e);
|
|
@@ -3023,14 +3029,14 @@ class fs extends Le {
|
|
|
3023
3029
|
setAudioSettings(e) {
|
|
3024
3030
|
return O(this, void 0, void 0, (function* () {
|
|
3025
3031
|
if (!e) throw new Error("You need to provide the settings object");
|
|
3026
|
-
const { micId: t, micLabel: i } = e, s =
|
|
3027
|
-
return
|
|
3028
|
-
const { deviceId: l } =
|
|
3032
|
+
const { micId: t, micLabel: i } = e, s = We(e, ["micId", "micLabel"]);
|
|
3033
|
+
return os(s), this._audioConstraints = yield ((o, r, c, d) => O(void 0, void 0, void 0, (function* () {
|
|
3034
|
+
const { deviceId: l } = d;
|
|
3029
3035
|
if (l === void 0 && (o || r)) {
|
|
3030
|
-
const f = yield
|
|
3031
|
-
f && (
|
|
3036
|
+
const f = yield Ke(o, r, c).catch(((h) => null));
|
|
3037
|
+
f && (d.deviceId = { exact: f });
|
|
3032
3038
|
}
|
|
3033
|
-
return
|
|
3039
|
+
return d;
|
|
3034
3040
|
})))(t, i, "audioinput", s), this.micId = t, this.micLabel = i, this._audioConstraints;
|
|
3035
3041
|
}));
|
|
3036
3042
|
}
|
|
@@ -3044,7 +3050,7 @@ class fs extends Le {
|
|
|
3044
3050
|
if (e && Array.isArray(e)) this._iceServers = e;
|
|
3045
3051
|
else {
|
|
3046
3052
|
const t = this.options.env === "development";
|
|
3047
|
-
this._iceServers = t ?
|
|
3053
|
+
this._iceServers = t ? Ni : xi;
|
|
3048
3054
|
}
|
|
3049
3055
|
}
|
|
3050
3056
|
get iceServers() {
|
|
@@ -3057,37 +3063,37 @@ class fs extends Le {
|
|
|
3057
3063
|
return this._speaker;
|
|
3058
3064
|
}
|
|
3059
3065
|
set localElement(e) {
|
|
3060
|
-
this._localElement =
|
|
3066
|
+
this._localElement = Ve(e);
|
|
3061
3067
|
}
|
|
3062
3068
|
get localElement() {
|
|
3063
3069
|
return this._localElement;
|
|
3064
3070
|
}
|
|
3065
3071
|
set remoteElement(e) {
|
|
3066
|
-
this._remoteElement =
|
|
3072
|
+
this._remoteElement = Ve(e);
|
|
3067
3073
|
}
|
|
3068
3074
|
get remoteElement() {
|
|
3069
3075
|
return this._remoteElement;
|
|
3070
3076
|
}
|
|
3071
3077
|
vertoBroadcast({ nodeId: e, channel: t = "", data: i }) {
|
|
3072
3078
|
if (!t) throw new Error(`Invalid channel for broadcast: ${t}`);
|
|
3073
|
-
const s = new
|
|
3079
|
+
const s = new es({ sessid: this.sessionid, eventChannel: t, data: i });
|
|
3074
3080
|
e && (s.targetNodeId = e), this.execute(s).catch(((o) => o));
|
|
3075
3081
|
}
|
|
3076
3082
|
vertoSubscribe({ nodeId: e, channels: t = [], handler: i }) {
|
|
3077
3083
|
return O(this, void 0, void 0, (function* () {
|
|
3078
|
-
if (!(t = t.filter(((
|
|
3079
|
-
const s = new
|
|
3084
|
+
if (!(t = t.filter(((d) => d && !this._existsSubscription(this.relayProtocol, d)))).length) return {};
|
|
3085
|
+
const s = new ts({ sessid: this.sessionid, eventChannel: t });
|
|
3080
3086
|
e && (s.targetNodeId = e);
|
|
3081
|
-
const o = yield this.execute(s), { unauthorized: r = [], subscribed: c = [] } =
|
|
3082
|
-
return r.length && r.forEach(((
|
|
3087
|
+
const o = yield this.execute(s), { unauthorized: r = [], subscribed: c = [] } = pt(o);
|
|
3088
|
+
return r.length && r.forEach(((d) => this._removeSubscription(this.relayProtocol, d))), c.forEach(((d) => this._addSubscription(this.relayProtocol, i, d))), o;
|
|
3083
3089
|
}));
|
|
3084
3090
|
}
|
|
3085
3091
|
vertoUnsubscribe({ nodeId: e, channels: t = [] }) {
|
|
3086
3092
|
return O(this, void 0, void 0, (function* () {
|
|
3087
3093
|
if (!(t = t.filter(((c) => c && this._existsSubscription(this.relayProtocol, c)))).length) return {};
|
|
3088
|
-
const i = new
|
|
3094
|
+
const i = new ns({ sessid: this.sessionid, eventChannel: t });
|
|
3089
3095
|
e && (i.targetNodeId = e);
|
|
3090
|
-
const s = yield this.execute(i), { unsubscribed: o = [], notSubscribed: r = [] } =
|
|
3096
|
+
const s = yield this.execute(i), { unsubscribed: o = [], notSubscribed: r = [] } = pt(s);
|
|
3091
3097
|
return o.forEach(((c) => this._removeSubscription(this.relayProtocol, c))), r.forEach(((c) => this._removeSubscription(this.relayProtocol, c))), s;
|
|
3092
3098
|
}));
|
|
3093
3099
|
}
|
|
@@ -3096,7 +3102,7 @@ class fs extends Le {
|
|
|
3096
3102
|
this._wasOffline && (g.debug(`Network connectivity restored for session ${this.sessionid}. Reconnecting...`), this._wasOffline = !1, this._autoReconnect = !0, this.socketDisconnect());
|
|
3097
3103
|
}, this._offlineHandler = () => {
|
|
3098
3104
|
this._wasOffline = !0, g.debug(`Network connectivity lost for session ${this.sessionid}`);
|
|
3099
|
-
const e = W(
|
|
3105
|
+
const e = W(vi);
|
|
3100
3106
|
L(T.Error, { error: e, sessionId: this.sessionid }, this.uuid);
|
|
3101
3107
|
}, window.addEventListener("online", this._onlineHandler), window.addEventListener("offline", this._offlineHandler));
|
|
3102
3108
|
}
|
|
@@ -3107,83 +3113,83 @@ class fs extends Le {
|
|
|
3107
3113
|
return ge.setStateTelnyx(e);
|
|
3108
3114
|
}
|
|
3109
3115
|
}
|
|
3110
|
-
class
|
|
3116
|
+
class Xt {
|
|
3111
3117
|
constructor(e, t) {
|
|
3112
3118
|
this.code = t, this.message = e;
|
|
3113
3119
|
}
|
|
3114
3120
|
}
|
|
3115
|
-
class
|
|
3121
|
+
class ys {
|
|
3116
3122
|
constructor(e) {
|
|
3117
3123
|
this.session = e, this.retriedConnect = 0, this.retriedRegister = 0;
|
|
3118
3124
|
}
|
|
3119
3125
|
_ack(e, t) {
|
|
3120
|
-
const i = new
|
|
3126
|
+
const i = new Xi(e, t);
|
|
3121
3127
|
this.nodeId && (i.targetNodeId = this.nodeId), this.session.execute(i);
|
|
3122
3128
|
}
|
|
3123
3129
|
reconnectDelay() {
|
|
3124
|
-
return 1e3 *
|
|
3130
|
+
return 1e3 * Sn(2, 6);
|
|
3125
3131
|
}
|
|
3126
3132
|
handleMessage(e) {
|
|
3127
|
-
var t, i, s, o, r, c,
|
|
3133
|
+
var t, i, s, o, r, c, d, l, f;
|
|
3128
3134
|
const { session: h } = this;
|
|
3129
3135
|
h.setPingReceived();
|
|
3130
|
-
const { id: S, method: y, params: v = {}, voice_sdk_id: E } = e, m = v?.callID, w = v?.eventChannel,
|
|
3136
|
+
const { id: S, method: y, params: v = {}, voice_sdk_id: E } = e, m = v?.callID, w = v?.eventChannel, x = v?.eventType, A = h.calls[m], P = (t = A?.peer) === null || t === void 0 ? void 0 : t.isConnectionHealthy();
|
|
3131
3137
|
if (Array.isArray(v?.reattached_sessions) && v.reattached_sessions.length === 0 && Object.keys(h.calls).length > 0) {
|
|
3132
|
-
const R =
|
|
3138
|
+
const R = de(Ai);
|
|
3133
3139
|
L(T.Warning, { warning: R, sessionId: h.sessionid }, h.uuid);
|
|
3134
3140
|
}
|
|
3135
|
-
if (
|
|
3141
|
+
if (x === "channelPvtData") return this._handlePvtEvent(v.pvtData);
|
|
3136
3142
|
const M = (R) => {
|
|
3137
|
-
var a,
|
|
3138
|
-
const I = { audio: !0, video: h.options.video, remoteSdp: v.sdp, destinationNumber: v.callee_id_number, remoteCallerName: v.caller_id_name, remoteCallerNumber: v.caller_id_number, callerName: v.callee_id_name, callerNumber: v.callee_id_number, attach: y ===
|
|
3143
|
+
var a, u, p, _, b, k;
|
|
3144
|
+
const I = { audio: !0, video: h.options.video, remoteSdp: v.sdp, destinationNumber: v.callee_id_number, remoteCallerName: v.caller_id_name, remoteCallerNumber: v.caller_id_number, callerName: v.callee_id_name, callerNumber: v.callee_id_number, attach: y === H.Attach, mediaSettings: v.mediaSettings, debug: (a = h.options.debug) !== null && a !== void 0 && a, debugOutput: (u = h.options.debugOutput) !== null && u !== void 0 ? u : "socket", trickleIce: (p = h.options.trickleIce) !== null && p !== void 0 && p, prefetchIceCandidates: (_ = h.options.prefetchIceCandidates) === null || _ === void 0 || _, forceRelayCandidate: (b = h.options.forceRelayCandidate) !== null && b !== void 0 && b, keepConnectionAliveOnSocketClose: (k = h.options.keepConnectionAliveOnSocketClose) !== null && k !== void 0 && k };
|
|
3139
3145
|
m && (I.id = m), v.telnyx_call_control_id && (I.telnyxCallControlId = v.telnyx_call_control_id), v.telnyx_session_id && (I.telnyxSessionId = v.telnyx_session_id), v.telnyx_leg_id && (I.telnyxLegId = v.telnyx_leg_id), v.client_state && (I.clientState = v.client_state), v.dialogParams && v.dialogParams.custom_headers && v.dialogParams.custom_headers.length && (I.customHeaders = v.dialogParams.custom_headers), R && (I.recoveredCallId = R), performance.mark("new-call-start");
|
|
3140
|
-
const
|
|
3141
|
-
return
|
|
3142
|
-
}, q = new
|
|
3146
|
+
const N = new ge(h, I);
|
|
3147
|
+
return N.nodeId = this.nodeId, N;
|
|
3148
|
+
}, q = new En(E), F = new In(E);
|
|
3143
3149
|
switch (y) {
|
|
3144
|
-
case
|
|
3145
|
-
case
|
|
3146
|
-
case
|
|
3147
|
-
case
|
|
3148
|
-
case
|
|
3149
|
-
case
|
|
3150
|
+
case H.Answer:
|
|
3151
|
+
case H.Display:
|
|
3152
|
+
case H.Candidate:
|
|
3153
|
+
case H.Ringing:
|
|
3154
|
+
case H.Bye:
|
|
3155
|
+
case H.Media:
|
|
3150
3156
|
if (!m || !A) return void g.error(`Received ${y} for non existing call:`, v);
|
|
3151
3157
|
A.handleMessage(e), this._ack(S, y);
|
|
3152
3158
|
break;
|
|
3153
|
-
case
|
|
3159
|
+
case H.Ping:
|
|
3154
3160
|
this.session.setPingReceived(), this.session.execute(F);
|
|
3155
3161
|
break;
|
|
3156
|
-
case
|
|
3162
|
+
case H.Punt:
|
|
3157
3163
|
h.options.keepConnectionAliveOnSocketClose && P ? (g.info("[punt] Received PUNT from server. keepConnectionAliveOnSocketClose=true — disconnecting socket only, keeping calls alive."), h.socketDisconnect(), this._ack(S, y)) : (g.info("[punt] Received PUNT from server — calling serverDisconnect() to purge all calls without BYE."), h.serverDisconnect());
|
|
3158
3164
|
break;
|
|
3159
|
-
case
|
|
3160
|
-
const
|
|
3161
|
-
|
|
3165
|
+
case H.Invite: {
|
|
3166
|
+
const u = M();
|
|
3167
|
+
u.direction = ce.Inbound, u.playRingtone(), u.setState(U.Ringing), this._ack(S, y);
|
|
3162
3168
|
break;
|
|
3163
3169
|
}
|
|
3164
|
-
case
|
|
3170
|
+
case H.Attach: {
|
|
3165
3171
|
if (!A)
|
|
3166
3172
|
return M().answer(), void this._ack(S, y);
|
|
3167
|
-
const
|
|
3168
|
-
g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${m}] closing existing call on ATTACH.`), A.hangup({ isRecovering: !0 }, !1), g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${m}] Attach: Creating new call for recovery (recoveredCallId: ${
|
|
3173
|
+
const u = A.id;
|
|
3174
|
+
g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${m}] closing existing call on ATTACH.`), A.hangup({ isRecovering: !0 }, !1), g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${m}] Attach: Creating new call for recovery (recoveredCallId: ${u})`), M(u).answer(), this._ack(S, y);
|
|
3169
3175
|
break;
|
|
3170
3176
|
}
|
|
3171
|
-
case
|
|
3177
|
+
case H.Event:
|
|
3172
3178
|
case "webrtc.event":
|
|
3173
3179
|
if (!w) return void g.error("Verto received an unknown event:", v);
|
|
3174
3180
|
const R = h.relayProtocol, a = w.split(".")[0];
|
|
3175
3181
|
h._existsSubscription(R, w) ? L(R, v, w) : w === h.sessionid ? this._handleSessionEvent(v.eventData) : h._existsSubscription(R, a) ? L(R, v, a) : h.calls.hasOwnProperty(w) ? h.calls[w].handleMessage(e) : L(T.Notification, v, h.uuid);
|
|
3176
3182
|
break;
|
|
3177
|
-
case
|
|
3183
|
+
case H.Info:
|
|
3178
3184
|
v.type = re.generic, L(T.Notification, v, h.uuid);
|
|
3179
3185
|
break;
|
|
3180
|
-
case
|
|
3186
|
+
case H.ClientReady:
|
|
3181
3187
|
this.session.execute(q);
|
|
3182
3188
|
break;
|
|
3183
3189
|
default: {
|
|
3184
|
-
const
|
|
3185
|
-
if (
|
|
3186
|
-
switch (
|
|
3190
|
+
const u = bt(e);
|
|
3191
|
+
if (u) {
|
|
3192
|
+
switch (u) {
|
|
3187
3193
|
case ne.REGISTER:
|
|
3188
3194
|
case ne.REGED:
|
|
3189
3195
|
if (h.connection.previousGatewayState !== ne.REGED && h.connection.previousGatewayState !== ne.REGISTER) {
|
|
@@ -3192,7 +3198,7 @@ class gs {
|
|
|
3192
3198
|
p && (h.callReportId = p, g.debug("Captured call_report_id from REGED:", p));
|
|
3193
3199
|
const _ = (r = (o = e?.result) === null || o === void 0 ? void 0 : o.params) === null || r === void 0 ? void 0 : r.dc;
|
|
3194
3200
|
_ && (h.dc = _);
|
|
3195
|
-
const b = (
|
|
3201
|
+
const b = (d = (c = e?.result) === null || c === void 0 ? void 0 : c.params) === null || d === void 0 ? void 0 : d.region;
|
|
3196
3202
|
b && (h.region = b), g.info(`Connected to Telnyx — region: ${(l = h.region) !== null && l !== void 0 ? l : "unknown"}, dc: ${(f = h.dc) !== null && f !== void 0 ? f : "unknown"}`), v.type = re.vertoClientReady, L(T.Ready, v, h.uuid);
|
|
3197
3203
|
}
|
|
3198
3204
|
break;
|
|
@@ -3200,7 +3206,7 @@ class gs {
|
|
|
3200
3206
|
case ne.NOREG:
|
|
3201
3207
|
if (this.retriedRegister += 1, this.retriedRegister === 5) {
|
|
3202
3208
|
this.retriedRegister = 0;
|
|
3203
|
-
const p = new
|
|
3209
|
+
const p = new Xt("Fail to register the user, the server tried 5 times", "UNREGED|NOREG"), _ = W(pn, p);
|
|
3204
3210
|
L(T.Error, { error: _, sessionId: h.sessionid }, h.uuid);
|
|
3205
3211
|
break;
|
|
3206
3212
|
}
|
|
@@ -3211,10 +3217,10 @@ class gs {
|
|
|
3211
3217
|
case ne.FAILED:
|
|
3212
3218
|
case ne.FAIL_WAIT:
|
|
3213
3219
|
if (h.connection.previousGatewayState !== ne.FAILED && h.connection.previousGatewayState !== ne.FAIL_WAIT) {
|
|
3214
|
-
const p = W(
|
|
3220
|
+
const p = W(pi, new Error(`Gateway state: ${u}`));
|
|
3215
3221
|
if (L(T.Error, { error: p, sessionId: h.sessionid }, h.uuid), !this.session.hasAutoReconnect()) {
|
|
3216
3222
|
this.retriedConnect = 0;
|
|
3217
|
-
const _ = new
|
|
3223
|
+
const _ = new Xt("Fail to connect the server, the server tried 5 times", "FAILED|FAIL_WAIT"), b = W(hi, _);
|
|
3218
3224
|
L(T.Error, { error: b, sessionId: h.sessionid }, h.uuid);
|
|
3219
3225
|
break;
|
|
3220
3226
|
}
|
|
@@ -3258,7 +3264,7 @@ class gs {
|
|
|
3258
3264
|
}
|
|
3259
3265
|
_handlePvtEvent(e) {
|
|
3260
3266
|
return O(this, void 0, void 0, (function* () {
|
|
3261
|
-
const { session: t } = this, i = t.relayProtocol, { action: s, laChannel: o, laName: r, chatChannel: c, infoChannel:
|
|
3267
|
+
const { session: t } = this, i = t.relayProtocol, { action: s, laChannel: o, laName: r, chatChannel: c, infoChannel: d, modChannel: l, conferenceMemberID: f, role: h, callID: S } = e;
|
|
3262
3268
|
switch (s) {
|
|
3263
3269
|
case "conference-liveArray-join": {
|
|
3264
3270
|
const y = () => {
|
|
@@ -3266,17 +3272,17 @@ class gs {
|
|
|
3266
3272
|
}, v = { nodeId: this.nodeId, channels: [o], handler: ({ data: m }) => {
|
|
3267
3273
|
const w = S || this._retrieveCallId(m, o);
|
|
3268
3274
|
if (w && t.calls.hasOwnProperty(w)) {
|
|
3269
|
-
const
|
|
3270
|
-
|
|
3275
|
+
const x = t.calls[w];
|
|
3276
|
+
x._addChannel(o), x.extension = r, x.handleConferenceUpdate(m, e).then(((A) => {
|
|
3271
3277
|
A === "INVALID_PACKET" && y();
|
|
3272
3278
|
}));
|
|
3273
3279
|
}
|
|
3274
3280
|
} }, E = yield t.vertoSubscribe(v).catch(((m) => {
|
|
3275
3281
|
g.error("liveArray subscription error:", m);
|
|
3276
|
-
const w = W(
|
|
3282
|
+
const w = W(li, m);
|
|
3277
3283
|
L(T.Error, { error: w, sessionId: t.sessionid }, t.uuid);
|
|
3278
3284
|
}));
|
|
3279
|
-
|
|
3285
|
+
ht(E, o) && y();
|
|
3280
3286
|
break;
|
|
3281
3287
|
}
|
|
3282
3288
|
case "conference-liveArray-part": {
|
|
@@ -3288,7 +3294,7 @@ class gs {
|
|
|
3288
3294
|
L(T.Notification, m, E, !1) || L(T.Notification, m, t.uuid), y === null && pe(T.Notification, null, E);
|
|
3289
3295
|
}
|
|
3290
3296
|
}
|
|
3291
|
-
const v = [o, c,
|
|
3297
|
+
const v = [o, c, d, l];
|
|
3292
3298
|
t.vertoUnsubscribe({ nodeId: this.nodeId, channels: v }).then((({ unsubscribedChannels: E = [] }) => {
|
|
3293
3299
|
y && (y.channels = y.channels.filter(((m) => !E.includes(m))));
|
|
3294
3300
|
})).catch(((E) => {
|
|
@@ -3303,7 +3309,7 @@ class gs {
|
|
|
3303
3309
|
switch (e.contentType) {
|
|
3304
3310
|
case "layout-info":
|
|
3305
3311
|
case "layer-info":
|
|
3306
|
-
|
|
3312
|
+
An(this.session, e);
|
|
3307
3313
|
break;
|
|
3308
3314
|
case "logo-info": {
|
|
3309
3315
|
const t = { type: re.conferenceUpdate, action: oe.LogoInfo, logo: e.logoURL };
|
|
@@ -3313,7 +3319,7 @@ class gs {
|
|
|
3313
3319
|
}
|
|
3314
3320
|
}
|
|
3315
3321
|
}
|
|
3316
|
-
class
|
|
3322
|
+
class Ss extends _s {
|
|
3317
3323
|
constructor(e) {
|
|
3318
3324
|
super(e), this.relayProtocol = "verto-protocol", this.timeoutErrorCode = -329990, this.handleLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
|
|
3319
3325
|
this._idle = !1;
|
|
@@ -3323,18 +3329,18 @@ class vs extends fs {
|
|
|
3323
3329
|
} });
|
|
3324
3330
|
})), this.handleAnonymousLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
|
|
3325
3331
|
this._idle = !1, yield this.login();
|
|
3326
|
-
})), this._vertoHandler = new
|
|
3332
|
+
})), this._vertoHandler = new ys(this), window.addEventListener("beforeunload", ((t) => {
|
|
3327
3333
|
this.calls && Object.keys(this.calls).forEach(((i) => {
|
|
3328
3334
|
this.calls[i] && (g.info(`Hanging up call due to window unload: ${i}`), this.calls[i].hangup({}, !0));
|
|
3329
3335
|
}));
|
|
3330
3336
|
}));
|
|
3331
3337
|
}
|
|
3332
3338
|
validateOptions() {
|
|
3333
|
-
return
|
|
3339
|
+
return qe(this.options) || ke(this.options);
|
|
3334
3340
|
}
|
|
3335
3341
|
newCall(e) {
|
|
3336
3342
|
if (!this.validateCallOptions(e))
|
|
3337
|
-
throw W(
|
|
3343
|
+
throw W(ai, void 0, "Error: destinationNumber is required");
|
|
3338
3344
|
const t = new ge(this, e);
|
|
3339
3345
|
return performance.mark("new-call-start"), t.invite(), t;
|
|
3340
3346
|
}
|
|
@@ -3352,48 +3358,48 @@ class vs extends fs {
|
|
|
3352
3358
|
}
|
|
3353
3359
|
_onSocketOpen() {
|
|
3354
3360
|
return O(this, void 0, void 0, (function* () {
|
|
3355
|
-
return
|
|
3361
|
+
return qe(this.options) ? this.handleLoginOnSocketOpen() : ke(this.options) ? this.handleAnonymousLoginOnSocketOpen() : void 0;
|
|
3356
3362
|
}));
|
|
3357
3363
|
}
|
|
3358
3364
|
_onSocketMessage(e) {
|
|
3359
3365
|
this._vertoHandler.handleMessage(e);
|
|
3360
3366
|
}
|
|
3361
3367
|
}
|
|
3362
|
-
class
|
|
3368
|
+
class bs extends Ss {
|
|
3363
3369
|
constructor(e) {
|
|
3364
|
-
super(e), g.info(`SDK version: ${
|
|
3370
|
+
super(e), g.info(`SDK version: ${Tn}`);
|
|
3365
3371
|
}
|
|
3366
3372
|
newCall(e) {
|
|
3367
3373
|
return super.newCall(e);
|
|
3368
3374
|
}
|
|
3369
3375
|
static webRTCInfo() {
|
|
3370
|
-
return
|
|
3376
|
+
return as();
|
|
3371
3377
|
}
|
|
3372
3378
|
static webRTCSupportedBrowserList() {
|
|
3373
3379
|
return [{ operationSystem: "Android", supported: [{ browserName: "Chrome", features: ["audio"], supported: Y.full }, { browserName: "Firefox", features: ["audio"], supported: Y.partial }, { browserName: "Safari", supported: Y.not_supported }, { browserName: "Edge", supported: Y.not_supported }] }, { operationSystem: "iOS", supported: [{ browserName: "Chrome", supported: Y.not_supported }, { browserName: "Firefox", supported: Y.not_supported }, { browserName: "Safari", features: ["video", "audio"], supported: Y.full }, { browserName: "Edge", supported: Y.not_supported }] }, { operationSystem: "Linux", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: Y.full }, { browserName: "Firefox", features: ["audio"], supported: Y.partial }, { browserName: "Safari", supported: Y.not_supported }, { browserName: "Edge", supported: Y.not_supported }] }, { operationSystem: "MacOS", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: Y.full }, { browserName: "Firefox", features: ["audio"], supported: Y.partial }, { browserName: "Safari", features: ["video", "audio"], supported: Y.full }, { browserName: "Edge", features: ["audio"], supported: Y.partial }] }, { operationSystem: "Windows", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: Y.full }, { browserName: "Firefox", features: ["audio"], supported: Y.partial }, { browserName: "Safari", supported: Y.not_supported }, { browserName: "Edge", features: ["audio"], supported: Y.partial }] }];
|
|
3374
3380
|
}
|
|
3375
3381
|
}
|
|
3376
|
-
function
|
|
3382
|
+
function Ln(n) {
|
|
3377
3383
|
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
3378
3384
|
}
|
|
3379
|
-
var
|
|
3380
|
-
function
|
|
3381
|
-
return
|
|
3385
|
+
var lt = { exports: {} }, zt;
|
|
3386
|
+
function Cs() {
|
|
3387
|
+
return zt || (zt = 1, (function(n) {
|
|
3382
3388
|
var e = Object.prototype.hasOwnProperty, t = "~";
|
|
3383
3389
|
function i() {
|
|
3384
3390
|
}
|
|
3385
3391
|
Object.create && (i.prototype = /* @__PURE__ */ Object.create(null), new i().__proto__ || (t = !1));
|
|
3386
|
-
function s(
|
|
3387
|
-
this.fn =
|
|
3392
|
+
function s(d, l, f) {
|
|
3393
|
+
this.fn = d, this.context = l, this.once = f || !1;
|
|
3388
3394
|
}
|
|
3389
|
-
function o(
|
|
3395
|
+
function o(d, l, f, h, S) {
|
|
3390
3396
|
if (typeof f != "function")
|
|
3391
3397
|
throw new TypeError("The listener must be a function");
|
|
3392
|
-
var y = new s(f, h ||
|
|
3393
|
-
return
|
|
3398
|
+
var y = new s(f, h || d, S), v = t ? t + l : l;
|
|
3399
|
+
return d._events[v] ? d._events[v].fn ? d._events[v] = [d._events[v], y] : d._events[v].push(y) : (d._events[v] = y, d._eventsCount++), d;
|
|
3394
3400
|
}
|
|
3395
|
-
function r(
|
|
3396
|
-
--
|
|
3401
|
+
function r(d, l) {
|
|
3402
|
+
--d._eventsCount === 0 ? d._events = new i() : delete d._events[l];
|
|
3397
3403
|
}
|
|
3398
3404
|
function c() {
|
|
3399
3405
|
this._events = new i(), this._eventsCount = 0;
|
|
@@ -3417,7 +3423,7 @@ function _s() {
|
|
|
3417
3423
|
}, c.prototype.emit = function(l, f, h, S, y, v) {
|
|
3418
3424
|
var E = t ? t + l : l;
|
|
3419
3425
|
if (!this._events[E]) return !1;
|
|
3420
|
-
var m = this._events[E], w = arguments.length,
|
|
3426
|
+
var m = this._events[E], w = arguments.length, x, A;
|
|
3421
3427
|
if (m.fn) {
|
|
3422
3428
|
switch (m.once && this.removeListener(l, m.fn, void 0, !0), w) {
|
|
3423
3429
|
case 1:
|
|
@@ -3433,9 +3439,9 @@ function _s() {
|
|
|
3433
3439
|
case 6:
|
|
3434
3440
|
return m.fn.call(m.context, f, h, S, y, v), !0;
|
|
3435
3441
|
}
|
|
3436
|
-
for (A = 1,
|
|
3437
|
-
|
|
3438
|
-
m.fn.apply(m.context,
|
|
3442
|
+
for (A = 1, x = new Array(w - 1); A < w; A++)
|
|
3443
|
+
x[A - 1] = arguments[A];
|
|
3444
|
+
m.fn.apply(m.context, x);
|
|
3439
3445
|
} else {
|
|
3440
3446
|
var P = m.length, M;
|
|
3441
3447
|
for (A = 0; A < P; A++)
|
|
@@ -3453,9 +3459,9 @@ function _s() {
|
|
|
3453
3459
|
m[A].fn.call(m[A].context, f, h, S);
|
|
3454
3460
|
break;
|
|
3455
3461
|
default:
|
|
3456
|
-
if (!
|
|
3457
|
-
|
|
3458
|
-
m[A].fn.apply(m[A].context,
|
|
3462
|
+
if (!x) for (M = 1, x = new Array(w - 1); M < w; M++)
|
|
3463
|
+
x[M - 1] = arguments[M];
|
|
3464
|
+
m[A].fn.apply(m[A].context, x);
|
|
3459
3465
|
}
|
|
3460
3466
|
}
|
|
3461
3467
|
return !0;
|
|
@@ -3481,16 +3487,16 @@ function _s() {
|
|
|
3481
3487
|
var f;
|
|
3482
3488
|
return l ? (f = t ? t + l : l, this._events[f] && r(this, f)) : (this._events = new i(), this._eventsCount = 0), this;
|
|
3483
3489
|
}, c.prototype.off = c.prototype.removeListener, c.prototype.addListener = c.prototype.on, c.prefixed = t, c.EventEmitter = c, n.exports = c;
|
|
3484
|
-
})(
|
|
3490
|
+
})(lt)), lt.exports;
|
|
3485
3491
|
}
|
|
3486
|
-
var
|
|
3487
|
-
const
|
|
3488
|
-
var $e = { exports: {} },
|
|
3489
|
-
function
|
|
3490
|
-
return
|
|
3492
|
+
var ws = Cs();
|
|
3493
|
+
const Et = /* @__PURE__ */ Ln(ws), Xe = new Et();
|
|
3494
|
+
var $e = { exports: {} }, Es = $e.exports, Qt;
|
|
3495
|
+
function Is() {
|
|
3496
|
+
return Qt || (Qt = 1, (function(n) {
|
|
3491
3497
|
(function(e, t) {
|
|
3492
3498
|
n.exports ? n.exports = t() : e.log = t();
|
|
3493
|
-
})(
|
|
3499
|
+
})(Es, function() {
|
|
3494
3500
|
var e = function() {
|
|
3495
3501
|
}, t = "undefined", i = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), s = [
|
|
3496
3502
|
"trace",
|
|
@@ -3511,11 +3517,11 @@ function bs() {
|
|
|
3511
3517
|
};
|
|
3512
3518
|
}
|
|
3513
3519
|
}
|
|
3514
|
-
function
|
|
3520
|
+
function d() {
|
|
3515
3521
|
console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
|
|
3516
3522
|
}
|
|
3517
3523
|
function l(E) {
|
|
3518
|
-
return E === "debug" && (E = "log"), typeof console === t ? !1 : E === "trace" && i ?
|
|
3524
|
+
return E === "debug" && (E = "log"), typeof console === t ? !1 : E === "trace" && i ? d : console[E] !== void 0 ? c(console, E) : console.log !== void 0 ? c(console, "log") : e;
|
|
3519
3525
|
}
|
|
3520
3526
|
function f() {
|
|
3521
3527
|
for (var E = this.getLevel(), m = 0; m < s.length; m++) {
|
|
@@ -3534,7 +3540,7 @@ function bs() {
|
|
|
3534
3540
|
return l(E) || h.apply(this, arguments);
|
|
3535
3541
|
}
|
|
3536
3542
|
function y(E, m) {
|
|
3537
|
-
var w = this,
|
|
3543
|
+
var w = this, x, A, P, M = "loglevel";
|
|
3538
3544
|
typeof E == "string" ? M += ":" + E : typeof E == "symbol" && (M = void 0);
|
|
3539
3545
|
function q(p) {
|
|
3540
3546
|
var _ = (s[p] || "silent").toUpperCase();
|
|
@@ -3594,7 +3600,7 @@ function bs() {
|
|
|
3594
3600
|
ERROR: 4,
|
|
3595
3601
|
SILENT: 5
|
|
3596
3602
|
}, w.methodFactory = m || S, w.getLevel = function() {
|
|
3597
|
-
return P ?? A ??
|
|
3603
|
+
return P ?? A ?? x;
|
|
3598
3604
|
}, w.setLevel = function(p, _) {
|
|
3599
3605
|
return P = a(p), _ !== !1 && q(P), f.call(w);
|
|
3600
3606
|
}, w.setDefaultLevel = function(p) {
|
|
@@ -3606,14 +3612,14 @@ function bs() {
|
|
|
3606
3612
|
}, w.disableAll = function(p) {
|
|
3607
3613
|
w.setLevel(w.levels.SILENT, p);
|
|
3608
3614
|
}, w.rebuild = function() {
|
|
3609
|
-
if (r !== w && (
|
|
3615
|
+
if (r !== w && (x = a(r.getLevel())), f.call(w), r === w)
|
|
3610
3616
|
for (var p in o)
|
|
3611
3617
|
o[p].rebuild();
|
|
3612
|
-
},
|
|
3618
|
+
}, x = a(
|
|
3613
3619
|
r ? r.getLevel() : "WARN"
|
|
3614
3620
|
);
|
|
3615
|
-
var
|
|
3616
|
-
|
|
3621
|
+
var u = F();
|
|
3622
|
+
u != null && (P = a(u)), f.call(w);
|
|
3617
3623
|
}
|
|
3618
3624
|
r = new y(), r.getLogger = function(m) {
|
|
3619
3625
|
if (typeof m != "symbol" && typeof m != "string" || m === "")
|
|
@@ -3633,24 +3639,24 @@ function bs() {
|
|
|
3633
3639
|
});
|
|
3634
3640
|
})($e)), $e.exports;
|
|
3635
3641
|
}
|
|
3636
|
-
var
|
|
3637
|
-
const
|
|
3638
|
-
|
|
3639
|
-
const i =
|
|
3642
|
+
var Ts = Is();
|
|
3643
|
+
const ks = /* @__PURE__ */ Ln(Ts), Rs = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), X = ks.getLogger("telnyx-ai-agent"), As = X.methodFactory;
|
|
3644
|
+
X.methodFactory = (n, e, t) => {
|
|
3645
|
+
const i = As(n, e, t);
|
|
3640
3646
|
return function(...s) {
|
|
3641
|
-
i(
|
|
3647
|
+
i(Rs(), "-", ...s);
|
|
3642
3648
|
};
|
|
3643
3649
|
};
|
|
3644
|
-
|
|
3645
|
-
function
|
|
3650
|
+
X.setLevel("info");
|
|
3651
|
+
function Os(n, e) {
|
|
3646
3652
|
let t = 0;
|
|
3647
3653
|
return (...i) => {
|
|
3648
3654
|
const s = Date.now();
|
|
3649
3655
|
s - t >= e && (t = s, n(...i));
|
|
3650
3656
|
};
|
|
3651
3657
|
}
|
|
3652
|
-
const
|
|
3653
|
-
class
|
|
3658
|
+
const Ls = 10, xs = 500, Ns = 100, Zt = 20;
|
|
3659
|
+
class Ds {
|
|
3654
3660
|
remoteIntervalId = null;
|
|
3655
3661
|
localIntervalId = null;
|
|
3656
3662
|
remoteStream = null;
|
|
@@ -3677,10 +3683,10 @@ class Os {
|
|
|
3677
3683
|
minSpeechDurationMs;
|
|
3678
3684
|
maxLatencyMs;
|
|
3679
3685
|
constructor(e) {
|
|
3680
|
-
this.volumeThreshold = e?.volumeThreshold ??
|
|
3686
|
+
this.volumeThreshold = e?.volumeThreshold ?? Ls, this.silenceDurationMs = e?.silenceDurationMs ?? xs, this.minSpeechDurationMs = e?.minSpeechDurationMs ?? Ns, this.maxLatencyMs = e?.maxLatencyMs;
|
|
3681
3687
|
}
|
|
3682
|
-
updateAgentState =
|
|
3683
|
-
|
|
3688
|
+
updateAgentState = Os((e) => {
|
|
3689
|
+
X.debug("AudioStreamMonitor updateAgentState", e), X.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state, Xe.emit("conversation.agent.state", e));
|
|
3684
3690
|
}, 100);
|
|
3685
3691
|
/**
|
|
3686
3692
|
* Set the remote audio stream (agent's voice) to monitor for speech detection
|
|
@@ -3720,11 +3726,11 @@ class Os {
|
|
|
3720
3726
|
*/
|
|
3721
3727
|
startRemoteMonitor() {
|
|
3722
3728
|
if (!this.remoteStream) {
|
|
3723
|
-
|
|
3729
|
+
X.debug("Remote monitor: no stream, skipping");
|
|
3724
3730
|
return;
|
|
3725
3731
|
}
|
|
3726
|
-
this.monitorStartTime = performance.now(), this.remoteAudioContext = new AudioContext(),
|
|
3727
|
-
|
|
3732
|
+
this.monitorStartTime = performance.now(), this.remoteAudioContext = new AudioContext(), X.debug("Remote AudioContext state:", this.remoteAudioContext.state), this.remoteAudioContext.state === "suspended" && (X.debug("Resuming suspended AudioContext..."), this.remoteAudioContext.resume().then(() => {
|
|
3733
|
+
X.debug("AudioContext resumed, state:", this.remoteAudioContext?.state);
|
|
3728
3734
|
})), this.remoteSource = this.remoteAudioContext.createMediaStreamSource(
|
|
3729
3735
|
this.remoteStream
|
|
3730
3736
|
), this.remoteAnalyser = this.remoteAudioContext.createAnalyser(), this.remoteSource.connect(this.remoteAnalyser);
|
|
@@ -3734,8 +3740,8 @@ class Os {
|
|
|
3734
3740
|
let i = !1;
|
|
3735
3741
|
const s = () => {
|
|
3736
3742
|
this.remoteAnalyser?.getByteFrequencyData(t);
|
|
3737
|
-
const o = t.reduce((c,
|
|
3738
|
-
if (Math.random() < 0.01 &&
|
|
3743
|
+
const o = t.reduce((c, d) => c + d, 0) / t.length, r = o >= this.volumeThreshold;
|
|
3744
|
+
if (Math.random() < 0.01 && X.debug("Remote audio volume:", o, "threshold:", this.volumeThreshold, "above:", r), r)
|
|
3739
3745
|
if (i)
|
|
3740
3746
|
this.updateAgentState({ state: "speaking" });
|
|
3741
3747
|
else if (this.isFirstAgentSpeech && this.monitorStartTime !== null) {
|
|
@@ -3750,7 +3756,7 @@ class Os {
|
|
|
3750
3756
|
this.thinkingStartTime === null && this.updateAgentState({ state: "listening" });
|
|
3751
3757
|
i = r;
|
|
3752
3758
|
};
|
|
3753
|
-
this.remoteIntervalId = window.setInterval(s,
|
|
3759
|
+
this.remoteIntervalId = window.setInterval(s, Zt);
|
|
3754
3760
|
}
|
|
3755
3761
|
/**
|
|
3756
3762
|
* Monitor local stream (user's microphone) for VAD
|
|
@@ -3758,16 +3764,16 @@ class Os {
|
|
|
3758
3764
|
*/
|
|
3759
3765
|
startLocalMonitor() {
|
|
3760
3766
|
if (!this.localStream) {
|
|
3761
|
-
|
|
3767
|
+
X.debug("Local monitor: no stream, skipping");
|
|
3762
3768
|
return;
|
|
3763
3769
|
}
|
|
3764
|
-
this.localAudioContext = new AudioContext(),
|
|
3770
|
+
this.localAudioContext = new AudioContext(), X.debug("Local AudioContext state:", this.localAudioContext.state), this.localAudioContext.state === "suspended" && (X.debug("Resuming suspended local AudioContext..."), this.localAudioContext.resume()), this.localSource = this.localAudioContext.createMediaStreamSource(
|
|
3765
3771
|
this.localStream
|
|
3766
3772
|
), this.localAnalyser = this.localAudioContext.createAnalyser(), this.localSource.connect(this.localAnalyser), this.localAnalyser.fftSize = 512;
|
|
3767
3773
|
const e = new Uint8Array(this.localAnalyser.frequencyBinCount), t = () => {
|
|
3768
3774
|
this.localAnalyser?.getByteFrequencyData(e);
|
|
3769
3775
|
const i = e.reduce((o, r) => o + r, 0) / e.length;
|
|
3770
|
-
if (Math.random() < 0.02 &&
|
|
3776
|
+
if (Math.random() < 0.02 && X.debug("Local audio volume:", i), i >= this.volumeThreshold)
|
|
3771
3777
|
this.userIsSpeaking || (this.userIsSpeaking = !0, this.userSpeechStartTime = performance.now(), this.userSilenceStartTime = null), this.lastUserAudioTime = performance.now();
|
|
3772
3778
|
else if (this.userIsSpeaking && this.lastUserAudioTime !== null && (this.lastUserAudioTime - (this.userSpeechStartTime || this.lastUserAudioTime) >= this.minSpeechDurationMs && this.userSilenceStartTime === null && (this.userSilenceStartTime = this.lastUserAudioTime), performance.now() - this.lastUserAudioTime > this.silenceDurationMs)) {
|
|
3773
3779
|
this.userIsSpeaking = !1, this.userSpeechStartTime = null, this.thinkingStartTime = performance.now();
|
|
@@ -3775,46 +3781,46 @@ class Os {
|
|
|
3775
3781
|
this.updateAgentState({ state: "thinking", thinkingStartedAt: c });
|
|
3776
3782
|
}
|
|
3777
3783
|
};
|
|
3778
|
-
this.localIntervalId = window.setInterval(t,
|
|
3784
|
+
this.localIntervalId = window.setInterval(t, Zt);
|
|
3779
3785
|
}
|
|
3780
3786
|
destroy() {
|
|
3781
3787
|
this.stopAudioStreamMonitor();
|
|
3782
3788
|
}
|
|
3783
3789
|
}
|
|
3784
|
-
function
|
|
3790
|
+
function Ps(n) {
|
|
3785
3791
|
if (!n || typeof n != "object")
|
|
3786
3792
|
return !1;
|
|
3787
3793
|
const e = n;
|
|
3788
3794
|
return e.method === "ai_conversation" && typeof e.params == "object";
|
|
3789
3795
|
}
|
|
3790
|
-
function
|
|
3796
|
+
function Ms(n) {
|
|
3791
3797
|
if (!n || typeof n != "object")
|
|
3792
3798
|
return !1;
|
|
3793
3799
|
const e = n;
|
|
3794
3800
|
return e.params.type !== "response.text.delta" ? !1 : !!e.params.delta;
|
|
3795
3801
|
}
|
|
3796
|
-
function
|
|
3802
|
+
function Us(n) {
|
|
3797
3803
|
if (!n || typeof n != "object")
|
|
3798
3804
|
return !1;
|
|
3799
3805
|
const e = n;
|
|
3800
3806
|
return e.params.type !== "conversation.item.created" ? !1 : !!e.params.item.content;
|
|
3801
3807
|
}
|
|
3802
|
-
function
|
|
3808
|
+
function Fs(n) {
|
|
3803
3809
|
if (!n || typeof n != "object")
|
|
3804
3810
|
return !1;
|
|
3805
3811
|
const e = n;
|
|
3806
3812
|
return e.params?.type !== "conversation.item.deleted" ? !1 : !!e.params.item_id;
|
|
3807
3813
|
}
|
|
3808
|
-
function
|
|
3809
|
-
return
|
|
3814
|
+
function js(n) {
|
|
3815
|
+
return Ms(n) ? {
|
|
3810
3816
|
id: `${n.params.item_id}-${Date.now()}`,
|
|
3811
3817
|
role: "assistant",
|
|
3812
3818
|
content: n.params.delta,
|
|
3813
3819
|
timestamp: /* @__PURE__ */ new Date()
|
|
3814
3820
|
} : null;
|
|
3815
3821
|
}
|
|
3816
|
-
function
|
|
3817
|
-
if (!
|
|
3822
|
+
function Bs(n) {
|
|
3823
|
+
if (!Us(n) || n.params.item.role !== "user" || n.params.item.status !== "completed")
|
|
3818
3824
|
return null;
|
|
3819
3825
|
let e = "", t = [];
|
|
3820
3826
|
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, {
|
|
@@ -3825,29 +3831,29 @@ function Ms(n) {
|
|
|
3825
3831
|
attachments: t
|
|
3826
3832
|
};
|
|
3827
3833
|
}
|
|
3828
|
-
class
|
|
3834
|
+
class Hs extends Et {
|
|
3829
3835
|
telnyxRTC;
|
|
3830
3836
|
transcript = [];
|
|
3831
3837
|
constructor(e) {
|
|
3832
3838
|
super(), this.telnyxRTC = e, this.telnyxRTC.on(T.SocketMessage, this.onSocketMessage);
|
|
3833
3839
|
}
|
|
3834
3840
|
onSocketMessage = (e) => {
|
|
3835
|
-
if (
|
|
3841
|
+
if (Ps(e))
|
|
3836
3842
|
switch (e.params.type) {
|
|
3837
3843
|
case "response.text.delta": {
|
|
3838
|
-
const t =
|
|
3839
|
-
t && (this.transcript.push(t), this.emit("transcript.item", t),
|
|
3844
|
+
const t = js(e);
|
|
3845
|
+
t && (this.transcript.push(t), this.emit("transcript.item", t), Xe.emit("conversation.agent.state", { state: "listening" }));
|
|
3840
3846
|
return;
|
|
3841
3847
|
}
|
|
3842
3848
|
case "conversation.item.deleted": {
|
|
3843
|
-
if (
|
|
3849
|
+
if (Fs(e)) {
|
|
3844
3850
|
const t = e.params.item_id, i = this.transcript.findIndex((s) => s.id === t);
|
|
3845
3851
|
i !== -1 && this.transcript.splice(i, 1);
|
|
3846
3852
|
}
|
|
3847
3853
|
return;
|
|
3848
3854
|
}
|
|
3849
3855
|
case "conversation.item.created": {
|
|
3850
|
-
const t =
|
|
3856
|
+
const t = Bs(e);
|
|
3851
3857
|
if (t) {
|
|
3852
3858
|
const i = this.transcript.findIndex(
|
|
3853
3859
|
(s) => s.id === t.id
|
|
@@ -3859,9 +3865,17 @@ class Us extends Ct {
|
|
|
3859
3865
|
}
|
|
3860
3866
|
};
|
|
3861
3867
|
}
|
|
3862
|
-
|
|
3868
|
+
const Ae = (n) => typeof n == "object" && n !== null, en = (n) => {
|
|
3869
|
+
const e = Ae(n) && Ae(n.result) ? n.result : n;
|
|
3870
|
+
if (!(!Ae(e) || e.message !== "logged in"))
|
|
3871
|
+
return typeof e.sessid == "string" ? e.sessid : null;
|
|
3872
|
+
}, $s = (n) => Ae(n) && Ae(n.request) && (n.request.method === "login" || n.request.method === "anonymous_login");
|
|
3873
|
+
class tn extends Et {
|
|
3863
3874
|
telnyxRTC;
|
|
3864
3875
|
transcription;
|
|
3876
|
+
removeLoginSuccessHook = null;
|
|
3877
|
+
authenticated = !1;
|
|
3878
|
+
authenticating = !1;
|
|
3865
3879
|
agentId;
|
|
3866
3880
|
versionId;
|
|
3867
3881
|
conversationId;
|
|
@@ -3894,7 +3908,7 @@ class Xt extends Ct {
|
|
|
3894
3908
|
*/
|
|
3895
3909
|
callReportId = null;
|
|
3896
3910
|
constructor(e) {
|
|
3897
|
-
super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.conversationId = e.conversationId, this.debug = e.debug || !1, this.chatMode = e.chatMode || !1, this.activeCall = null,
|
|
3911
|
+
super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.conversationId = e.conversationId, this.debug = e.debug || !1, this.chatMode = e.chatMode || !1, this.activeCall = null, X.setLevel(this.debug ? "debug" : "info");
|
|
3898
3912
|
const t = {
|
|
3899
3913
|
target_id: e.agentId,
|
|
3900
3914
|
target_type: "ai_assistant",
|
|
@@ -3902,16 +3916,17 @@ class Xt extends Ct {
|
|
|
3902
3916
|
};
|
|
3903
3917
|
e.conversationId && (t.target_params = {
|
|
3904
3918
|
conversation_id: e.conversationId
|
|
3905
|
-
}), this.telnyxRTC = new
|
|
3919
|
+
}), this.telnyxRTC = new bs({
|
|
3906
3920
|
env: e.environment || "production",
|
|
3907
3921
|
anonymous_login: t,
|
|
3908
3922
|
debug: e.debug || !1,
|
|
3909
3923
|
trickleIce: e.trickleIce,
|
|
3910
|
-
region: e.region
|
|
3911
|
-
|
|
3924
|
+
region: e.region,
|
|
3925
|
+
skipLastVoiceSdkId: e.skipLastVoiceSdkId ?? !0
|
|
3926
|
+
}), this.removeLoginSuccessHook = this.installLoginSuccessHook(), this.telnyxRTC.on(T.Ready, this.onClientReady), this.telnyxRTC.on(T.Error, this.onClientOrSocketError), this.telnyxRTC.on(T.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(T.SocketClose, this.onSocketClose), this.telnyxRTC.on(T.SocketMessage, this.onSocketMessage), this.telnyxRTC.on(T.Notification, this.onNotification), this.transcription = new Hs(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem), Xe.addListener(
|
|
3912
3927
|
"conversation.agent.state",
|
|
3913
3928
|
this.onAgentStateChange
|
|
3914
|
-
), this.audioStreamMonitor = new
|
|
3929
|
+
), this.audioStreamMonitor = new Ds(e.vad);
|
|
3915
3930
|
}
|
|
3916
3931
|
/**
|
|
3917
3932
|
* Connects to the Telnyx WebRTC service and establishes a session with the AI agent.
|
|
@@ -3921,6 +3936,25 @@ class Xt extends Ct {
|
|
|
3921
3936
|
async connect() {
|
|
3922
3937
|
return this.telnyxRTC.connect();
|
|
3923
3938
|
}
|
|
3939
|
+
/**
|
|
3940
|
+
* True once the underlying WebRTC login request has succeeded. This can be
|
|
3941
|
+
* true before `agent.connected`, which waits for REGED / client-ready.
|
|
3942
|
+
*/
|
|
3943
|
+
get isAuthenticated() {
|
|
3944
|
+
return this.authenticated;
|
|
3945
|
+
}
|
|
3946
|
+
/**
|
|
3947
|
+
* True while the underlying WebRTC login request is waiting for a response.
|
|
3948
|
+
*/
|
|
3949
|
+
get isAuthenticating() {
|
|
3950
|
+
return this.authenticating;
|
|
3951
|
+
}
|
|
3952
|
+
/**
|
|
3953
|
+
* Current Telnyx WebRTC session id, populated by successful login.
|
|
3954
|
+
*/
|
|
3955
|
+
get sessionId() {
|
|
3956
|
+
return this.telnyxRTC.sessionid || null;
|
|
3957
|
+
}
|
|
3924
3958
|
/**
|
|
3925
3959
|
* Clears the reconnect token stored by the underlying WebRTC SDK.
|
|
3926
3960
|
*
|
|
@@ -3936,7 +3970,7 @@ class Xt extends Ct {
|
|
|
3936
3970
|
* Emits an 'agent.disconnected' event before completing cleanup.
|
|
3937
3971
|
*/
|
|
3938
3972
|
async disconnect() {
|
|
3939
|
-
this.audioStreamMonitor.destroy(), this.telnyxRTC.disconnect(), this.telnyxRTC.off(T.Ready, this.onClientReady), this.telnyxRTC.off(T.Error, this.onClientOrSocketError), this.telnyxRTC.off(T.SocketError, this.onClientOrSocketError), this.telnyxRTC.off(T.Notification, this.onNotification), this.dc = null, this.region = null, this.callReportId = null, this.emit("agent.disconnected"), this.transcription.removeAllListeners(),
|
|
3973
|
+
this.audioStreamMonitor.destroy(), this.removeLoginSuccessHook?.(), this.removeLoginSuccessHook = null, this.telnyxRTC.disconnect(), this.telnyxRTC.off(T.Ready, this.onClientReady), this.telnyxRTC.off(T.Error, this.onClientOrSocketError), this.telnyxRTC.off(T.SocketError, this.onClientOrSocketError), this.telnyxRTC.off(T.SocketClose, this.onSocketClose), this.telnyxRTC.off(T.SocketMessage, this.onSocketMessage), this.telnyxRTC.off(T.Notification, this.onNotification), this.dc = null, this.region = null, this.callReportId = null, this.authenticated = !1, this.authenticating = !1, this.emit("agent.disconnected"), this.transcription.removeAllListeners(), Xe.removeAllListeners(), this.removeAllListeners();
|
|
3940
3974
|
}
|
|
3941
3975
|
/**
|
|
3942
3976
|
* Sends a text message to the AI agent during an active conversation.
|
|
@@ -3954,7 +3988,7 @@ class Xt extends Ct {
|
|
|
3954
3988
|
*/
|
|
3955
3989
|
sendConversationMessage(e, t = []) {
|
|
3956
3990
|
if (!this.activeCall) {
|
|
3957
|
-
|
|
3991
|
+
X.error("No active call to send message.");
|
|
3958
3992
|
return;
|
|
3959
3993
|
}
|
|
3960
3994
|
this.activeCall.sendConversationMessage(e, t);
|
|
@@ -3993,7 +4027,7 @@ class Xt extends Ct {
|
|
|
3993
4027
|
*/
|
|
3994
4028
|
async startConversation(e) {
|
|
3995
4029
|
if (!this.telnyxRTC) {
|
|
3996
|
-
|
|
4030
|
+
X.error("Client is not initialized.");
|
|
3997
4031
|
return;
|
|
3998
4032
|
}
|
|
3999
4033
|
const i = RTCRtpReceiver.getCapabilities("audio")?.codecs?.find(
|
|
@@ -4010,7 +4044,7 @@ class Xt extends Ct {
|
|
|
4010
4044
|
name: "X-AI-Assistant-Conversation-ID",
|
|
4011
4045
|
value: this.conversationId
|
|
4012
4046
|
});
|
|
4013
|
-
const
|
|
4047
|
+
const d = this.telnyxRTC.newCall({
|
|
4014
4048
|
destinationNumber: "xxx",
|
|
4015
4049
|
...r,
|
|
4016
4050
|
audio: this.chatMode ? !1 : o ?? !0,
|
|
@@ -4018,7 +4052,7 @@ class Xt extends Ct {
|
|
|
4018
4052
|
preferred_codecs: [i],
|
|
4019
4053
|
customHeaders: c.length > 0 ? c : void 0
|
|
4020
4054
|
});
|
|
4021
|
-
this.emit("conversation.update", { call:
|
|
4055
|
+
this.emit("conversation.update", { call: d, type: "callUpdate" });
|
|
4022
4056
|
}
|
|
4023
4057
|
/**
|
|
4024
4058
|
* Ends the current active conversation with the AI agent.
|
|
@@ -4047,9 +4081,52 @@ class Xt extends Ct {
|
|
|
4047
4081
|
};
|
|
4048
4082
|
this.emit("agent.connected", e);
|
|
4049
4083
|
};
|
|
4084
|
+
installLoginSuccessHook() {
|
|
4085
|
+
const e = this.telnyxRTC, t = e.execute, i = e.login, s = this.emitLoginStarted.bind(this), o = this.emitLoginSuccess.bind(this);
|
|
4086
|
+
let r = !0, c = 0;
|
|
4087
|
+
const d = (h) => {
|
|
4088
|
+
c === h && (this.authenticating = !1);
|
|
4089
|
+
}, l = function(h) {
|
|
4090
|
+
const S = $s(h), y = c;
|
|
4091
|
+
return t.call(this, h).then((v) => {
|
|
4092
|
+
const E = S ? en(v) : void 0;
|
|
4093
|
+
return r && E !== void 0 && (d(y), o({ sessionId: E })), v;
|
|
4094
|
+
});
|
|
4095
|
+
}, f = function(h) {
|
|
4096
|
+
const S = ++c;
|
|
4097
|
+
if (r) {
|
|
4098
|
+
const y = {
|
|
4099
|
+
sessionId: e.sessionid || null
|
|
4100
|
+
};
|
|
4101
|
+
s(y);
|
|
4102
|
+
}
|
|
4103
|
+
return i.call(this, h).finally(() => {
|
|
4104
|
+
r && e.login === f && d(S);
|
|
4105
|
+
});
|
|
4106
|
+
};
|
|
4107
|
+
return e.execute = l, e.login = f, () => {
|
|
4108
|
+
r = !1, e.execute === l && (e.execute = t), e.login === f && (e.login = i);
|
|
4109
|
+
};
|
|
4110
|
+
}
|
|
4111
|
+
emitLoginStarted(e) {
|
|
4112
|
+
this.authenticating = !0, this.authenticated = !1, this.emit("agent.login.started", e);
|
|
4113
|
+
}
|
|
4114
|
+
emitLoginSuccess(e) {
|
|
4115
|
+
const t = this.telnyxRTC, i = t.sessionid || null;
|
|
4116
|
+
e.sessionId && (t.sessionid = e.sessionId);
|
|
4117
|
+
const s = e.sessionId || t.sessionid || null;
|
|
4118
|
+
this.authenticated && s === i || (this.authenticated = !0, this.authenticating = !1, this.emit("agent.login.success", { sessionId: s }));
|
|
4119
|
+
}
|
|
4050
4120
|
onClientOrSocketError = (e) => {
|
|
4051
4121
|
this.emit("agent.error", e.error);
|
|
4052
4122
|
};
|
|
4123
|
+
onSocketClose = () => {
|
|
4124
|
+
this.authenticated = !1, this.authenticating = !1;
|
|
4125
|
+
};
|
|
4126
|
+
onSocketMessage = (e) => {
|
|
4127
|
+
const t = en(e);
|
|
4128
|
+
t !== void 0 && this.emitLoginSuccess({ sessionId: t });
|
|
4129
|
+
};
|
|
4053
4130
|
onNotification = (e) => {
|
|
4054
4131
|
e.type !== "callUpdate" || !e.call || (this.emit("conversation.update", e), e.call.state === "active" ? (this.activeCall = e.call, e.call.remoteStream && this.audioStreamMonitor.setRemoteStream(e.call.remoteStream), e.call.localStream && this.audioStreamMonitor.setLocalStream(e.call.localStream)) : (this.activeCall = null, this.audioStreamMonitor.stopAudioStreamMonitor()));
|
|
4055
4132
|
};
|
|
@@ -4060,11 +4137,11 @@ class Xt extends Ct {
|
|
|
4060
4137
|
this.emit("conversation.agent.state", e);
|
|
4061
4138
|
};
|
|
4062
4139
|
}
|
|
4063
|
-
var
|
|
4064
|
-
var
|
|
4065
|
-
function
|
|
4066
|
-
if (
|
|
4067
|
-
|
|
4140
|
+
var He = { exports: {} }, Ce = {};
|
|
4141
|
+
var nn;
|
|
4142
|
+
function Ws() {
|
|
4143
|
+
if (nn) return Ce;
|
|
4144
|
+
nn = 1;
|
|
4068
4145
|
var n = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
4069
4146
|
function t(i, s, o) {
|
|
4070
4147
|
var r = null;
|
|
@@ -4084,9 +4161,9 @@ function Fs() {
|
|
|
4084
4161
|
return Ce.Fragment = e, Ce.jsx = t, Ce.jsxs = t, Ce;
|
|
4085
4162
|
}
|
|
4086
4163
|
var we = {};
|
|
4087
|
-
var
|
|
4088
|
-
function
|
|
4089
|
-
return
|
|
4164
|
+
var sn;
|
|
4165
|
+
function Gs() {
|
|
4166
|
+
return sn || (sn = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
4090
4167
|
function n(C) {
|
|
4091
4168
|
if (C == null) return null;
|
|
4092
4169
|
if (typeof C == "function")
|
|
@@ -4095,7 +4172,7 @@ function js() {
|
|
|
4095
4172
|
switch (C) {
|
|
4096
4173
|
case m:
|
|
4097
4174
|
return "Fragment";
|
|
4098
|
-
case
|
|
4175
|
+
case x:
|
|
4099
4176
|
return "Profiler";
|
|
4100
4177
|
case w:
|
|
4101
4178
|
return "StrictMode";
|
|
@@ -4103,7 +4180,7 @@ function js() {
|
|
|
4103
4180
|
return "Suspense";
|
|
4104
4181
|
case F:
|
|
4105
4182
|
return "SuspenseList";
|
|
4106
|
-
case
|
|
4183
|
+
case u:
|
|
4107
4184
|
return "Activity";
|
|
4108
4185
|
}
|
|
4109
4186
|
if (typeof C == "object")
|
|
@@ -4142,11 +4219,11 @@ function js() {
|
|
|
4142
4219
|
}
|
|
4143
4220
|
if (D) {
|
|
4144
4221
|
D = console;
|
|
4145
|
-
var j = D.error,
|
|
4222
|
+
var j = D.error, $ = typeof Symbol == "function" && Symbol.toStringTag && C[Symbol.toStringTag] || C.constructor.name || "Object";
|
|
4146
4223
|
return j.call(
|
|
4147
4224
|
D,
|
|
4148
4225
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
4149
|
-
|
|
4226
|
+
$
|
|
4150
4227
|
), e(C);
|
|
4151
4228
|
}
|
|
4152
4229
|
}
|
|
@@ -4177,7 +4254,7 @@ function js() {
|
|
|
4177
4254
|
}
|
|
4178
4255
|
function c(C, D) {
|
|
4179
4256
|
function j() {
|
|
4180
|
-
|
|
4257
|
+
N || (N = !0, console.error(
|
|
4181
4258
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
4182
4259
|
D
|
|
4183
4260
|
));
|
|
@@ -4187,23 +4264,23 @@ function js() {
|
|
|
4187
4264
|
configurable: !0
|
|
4188
4265
|
});
|
|
4189
4266
|
}
|
|
4190
|
-
function
|
|
4267
|
+
function d() {
|
|
4191
4268
|
var C = n(this.type);
|
|
4192
4269
|
return B[C] || (B[C] = !0, console.error(
|
|
4193
4270
|
"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."
|
|
4194
4271
|
)), C = this.props.ref, C !== void 0 ? C : null;
|
|
4195
4272
|
}
|
|
4196
|
-
function l(C, D, j,
|
|
4273
|
+
function l(C, D, j, $, K, Q) {
|
|
4197
4274
|
var V = j.ref;
|
|
4198
4275
|
return C = {
|
|
4199
4276
|
$$typeof: v,
|
|
4200
4277
|
type: C,
|
|
4201
4278
|
key: D,
|
|
4202
4279
|
props: j,
|
|
4203
|
-
_owner:
|
|
4280
|
+
_owner: $
|
|
4204
4281
|
}, (V !== void 0 ? V : null) !== null ? Object.defineProperty(C, "ref", {
|
|
4205
4282
|
enumerable: !1,
|
|
4206
|
-
get:
|
|
4283
|
+
get: d
|
|
4207
4284
|
}) : Object.defineProperty(C, "ref", { enumerable: !1, value: null }), C._store = {}, Object.defineProperty(C._store, "validated", {
|
|
4208
4285
|
configurable: !1,
|
|
4209
4286
|
enumerable: !1,
|
|
@@ -4223,16 +4300,16 @@ function js() {
|
|
|
4223
4300
|
configurable: !1,
|
|
4224
4301
|
enumerable: !1,
|
|
4225
4302
|
writable: !0,
|
|
4226
|
-
value:
|
|
4303
|
+
value: Q
|
|
4227
4304
|
}), Object.freeze && (Object.freeze(C.props), Object.freeze(C)), C;
|
|
4228
4305
|
}
|
|
4229
|
-
function f(C, D, j,
|
|
4306
|
+
function f(C, D, j, $, K, Q) {
|
|
4230
4307
|
var V = D.children;
|
|
4231
4308
|
if (V !== void 0)
|
|
4232
|
-
if (
|
|
4309
|
+
if ($)
|
|
4233
4310
|
if (k(V)) {
|
|
4234
|
-
for (
|
|
4235
|
-
h(V[
|
|
4311
|
+
for ($ = 0; $ < V.length; $++)
|
|
4312
|
+
h(V[$]);
|
|
4236
4313
|
Object.freeze && Object.freeze(V);
|
|
4237
4314
|
} else
|
|
4238
4315
|
console.error(
|
|
@@ -4241,26 +4318,26 @@ function js() {
|
|
|
4241
4318
|
else h(V);
|
|
4242
4319
|
if (b.call(D, "key")) {
|
|
4243
4320
|
V = n(C);
|
|
4244
|
-
var ae = Object.keys(D).filter(function(
|
|
4245
|
-
return
|
|
4321
|
+
var ae = Object.keys(D).filter(function(qn) {
|
|
4322
|
+
return qn !== "key";
|
|
4246
4323
|
});
|
|
4247
|
-
|
|
4324
|
+
$ = 0 < ae.length ? "{key: someKey, " + ae.join(": ..., ") + ": ...}" : "{key: someKey}", G[V + $] || (ae = 0 < ae.length ? "{" + ae.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
4248
4325
|
`A props object containing a "key" prop is being spread into JSX:
|
|
4249
4326
|
let props = %s;
|
|
4250
4327
|
<%s {...props} />
|
|
4251
4328
|
React keys must be passed directly to JSX without using spread:
|
|
4252
4329
|
let props = %s;
|
|
4253
4330
|
<%s key={someKey} {...props} />`,
|
|
4254
|
-
|
|
4331
|
+
$,
|
|
4255
4332
|
V,
|
|
4256
4333
|
ae,
|
|
4257
4334
|
V
|
|
4258
|
-
), G[V +
|
|
4335
|
+
), G[V + $] = !0);
|
|
4259
4336
|
}
|
|
4260
4337
|
if (V = null, j !== void 0 && (t(j), V = "" + j), r(D) && (t(D.key), V = "" + D.key), "key" in D) {
|
|
4261
4338
|
j = {};
|
|
4262
|
-
for (var
|
|
4263
|
-
|
|
4339
|
+
for (var ot in D)
|
|
4340
|
+
ot !== "key" && (j[ot] = D[ot]);
|
|
4264
4341
|
} else j = D;
|
|
4265
4342
|
return V && c(
|
|
4266
4343
|
j,
|
|
@@ -4271,7 +4348,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
4271
4348
|
j,
|
|
4272
4349
|
s(),
|
|
4273
4350
|
K,
|
|
4274
|
-
|
|
4351
|
+
Q
|
|
4275
4352
|
);
|
|
4276
4353
|
}
|
|
4277
4354
|
function h(C) {
|
|
@@ -4280,7 +4357,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
4280
4357
|
function S(C) {
|
|
4281
4358
|
return typeof C == "object" && C !== null && C.$$typeof === v;
|
|
4282
4359
|
}
|
|
4283
|
-
var y =
|
|
4360
|
+
var y = St, v = Symbol.for("react.transitional.element"), E = Symbol.for("react.portal"), m = Symbol.for("react.fragment"), w = Symbol.for("react.strict_mode"), x = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), P = Symbol.for("react.context"), M = Symbol.for("react.forward_ref"), q = Symbol.for("react.suspense"), F = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), a = Symbol.for("react.lazy"), u = Symbol.for("react.activity"), p = Symbol.for("react.client.reference"), _ = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, b = Object.prototype.hasOwnProperty, k = Array.isArray, I = console.createTask ? console.createTask : function() {
|
|
4284
4361
|
return null;
|
|
4285
4362
|
};
|
|
4286
4363
|
y = {
|
|
@@ -4288,65 +4365,65 @@ React keys must be passed directly to JSX without using spread:
|
|
|
4288
4365
|
return C();
|
|
4289
4366
|
}
|
|
4290
4367
|
};
|
|
4291
|
-
var
|
|
4368
|
+
var N, B = {}, te = y.react_stack_bottom_frame.bind(
|
|
4292
4369
|
y,
|
|
4293
4370
|
o
|
|
4294
4371
|
)(), ie = I(i(o)), G = {};
|
|
4295
4372
|
we.Fragment = m, we.jsx = function(C, D, j) {
|
|
4296
|
-
var
|
|
4373
|
+
var $ = 1e4 > _.recentlyCreatedOwnerStacks++;
|
|
4297
4374
|
return f(
|
|
4298
4375
|
C,
|
|
4299
4376
|
D,
|
|
4300
4377
|
j,
|
|
4301
4378
|
!1,
|
|
4302
|
-
|
|
4303
|
-
|
|
4379
|
+
$ ? Error("react-stack-top-frame") : te,
|
|
4380
|
+
$ ? I(i(C)) : ie
|
|
4304
4381
|
);
|
|
4305
4382
|
}, we.jsxs = function(C, D, j) {
|
|
4306
|
-
var
|
|
4383
|
+
var $ = 1e4 > _.recentlyCreatedOwnerStacks++;
|
|
4307
4384
|
return f(
|
|
4308
4385
|
C,
|
|
4309
4386
|
D,
|
|
4310
4387
|
j,
|
|
4311
4388
|
!0,
|
|
4312
|
-
|
|
4313
|
-
|
|
4389
|
+
$ ? Error("react-stack-top-frame") : te,
|
|
4390
|
+
$ ? I(i(C)) : ie
|
|
4314
4391
|
);
|
|
4315
4392
|
};
|
|
4316
4393
|
})()), we;
|
|
4317
4394
|
}
|
|
4318
|
-
var
|
|
4319
|
-
function
|
|
4320
|
-
return
|
|
4395
|
+
var on;
|
|
4396
|
+
function Vs() {
|
|
4397
|
+
return on || (on = 1, process.env.NODE_ENV === "production" ? He.exports = Ws() : He.exports = Gs()), He.exports;
|
|
4321
4398
|
}
|
|
4322
|
-
var Ee =
|
|
4323
|
-
const
|
|
4324
|
-
function
|
|
4399
|
+
var Ee = Vs();
|
|
4400
|
+
const ue = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
|
|
4401
|
+
function xn(n) {
|
|
4325
4402
|
return "init" in n;
|
|
4326
4403
|
}
|
|
4327
|
-
function
|
|
4404
|
+
function gt(n) {
|
|
4328
4405
|
return !!n.write;
|
|
4329
4406
|
}
|
|
4330
|
-
function
|
|
4407
|
+
function rn(n) {
|
|
4331
4408
|
return "v" in n || "e" in n;
|
|
4332
4409
|
}
|
|
4333
4410
|
function ze(n) {
|
|
4334
4411
|
if ("e" in n)
|
|
4335
4412
|
throw n.e;
|
|
4336
|
-
if ((
|
|
4413
|
+
if ((ue ? "production" : void 0) !== "production" && !("v" in n))
|
|
4337
4414
|
throw new Error("[Bug] atom state is not initialized");
|
|
4338
4415
|
return n.v;
|
|
4339
4416
|
}
|
|
4340
4417
|
const Qe = /* @__PURE__ */ new WeakMap();
|
|
4341
|
-
function
|
|
4418
|
+
function Nn(n) {
|
|
4342
4419
|
var e;
|
|
4343
|
-
return
|
|
4420
|
+
return Ze(n) && !!((e = Qe.get(n)) != null && e[0]);
|
|
4344
4421
|
}
|
|
4345
|
-
function
|
|
4422
|
+
function qs(n) {
|
|
4346
4423
|
const e = Qe.get(n);
|
|
4347
4424
|
e?.[0] && (e[0] = !1, e[1].forEach((t) => t()));
|
|
4348
4425
|
}
|
|
4349
|
-
function
|
|
4426
|
+
function vt(n, e) {
|
|
4350
4427
|
let t = Qe.get(n);
|
|
4351
4428
|
if (!t) {
|
|
4352
4429
|
t = [!0, /* @__PURE__ */ new Set()], Qe.set(n, t);
|
|
@@ -4357,17 +4434,17 @@ function ft(n, e) {
|
|
|
4357
4434
|
}
|
|
4358
4435
|
t[1].add(e);
|
|
4359
4436
|
}
|
|
4360
|
-
function
|
|
4437
|
+
function Ze(n) {
|
|
4361
4438
|
return typeof n?.then == "function";
|
|
4362
4439
|
}
|
|
4363
|
-
function
|
|
4440
|
+
function Dn(n, e, t) {
|
|
4364
4441
|
if (!t.p.has(n)) {
|
|
4365
4442
|
t.p.add(n);
|
|
4366
4443
|
const i = () => t.p.delete(n);
|
|
4367
4444
|
e.then(i, i);
|
|
4368
4445
|
}
|
|
4369
4446
|
}
|
|
4370
|
-
function
|
|
4447
|
+
function Pn(n, e, t) {
|
|
4371
4448
|
var i;
|
|
4372
4449
|
const s = /* @__PURE__ */ new Set();
|
|
4373
4450
|
for (const o of ((i = t.get(n)) == null ? void 0 : i.t) || [])
|
|
@@ -4376,29 +4453,29 @@ function Nn(n, e, t) {
|
|
|
4376
4453
|
s.add(o);
|
|
4377
4454
|
return s;
|
|
4378
4455
|
}
|
|
4379
|
-
const
|
|
4456
|
+
const Ys = (n, e, ...t) => e.read(...t), Js = (n, e, ...t) => e.write(...t), Ks = (n, e) => {
|
|
4380
4457
|
if (e.INTERNAL_onInit)
|
|
4381
4458
|
return e.INTERNAL_onInit(n);
|
|
4382
4459
|
if (e.unstable_onInit)
|
|
4383
4460
|
return console.warn(
|
|
4384
4461
|
"[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."
|
|
4385
4462
|
), e.unstable_onInit(n);
|
|
4386
|
-
},
|
|
4463
|
+
}, Xs = (n, e, t) => {
|
|
4387
4464
|
var i;
|
|
4388
4465
|
return (i = e.onMount) == null ? void 0 : i.call(e, t);
|
|
4389
|
-
},
|
|
4466
|
+
}, zs = (n, e) => {
|
|
4390
4467
|
var t;
|
|
4391
4468
|
const i = Z(n), s = i[0], o = i[6], r = i[9];
|
|
4392
|
-
if ((
|
|
4469
|
+
if ((ue ? "production" : void 0) !== "production" && !e)
|
|
4393
4470
|
throw new Error("Atom is undefined or null");
|
|
4394
4471
|
let c = s.get(e);
|
|
4395
4472
|
return c || (c = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, s.set(e, c), (t = o.i) == null || t.call(o, e), r?.(n, e)), c;
|
|
4396
|
-
},
|
|
4397
|
-
const e = Z(n), t = e[1], i = e[3], s = e[4], o = e[5], r = e[6], c = e[13],
|
|
4473
|
+
}, Qs = (n) => {
|
|
4474
|
+
const e = Z(n), t = e[1], i = e[3], s = e[4], o = e[5], r = e[6], c = e[13], d = [], l = (f) => {
|
|
4398
4475
|
try {
|
|
4399
4476
|
f();
|
|
4400
4477
|
} catch (h) {
|
|
4401
|
-
|
|
4478
|
+
d.push(h);
|
|
4402
4479
|
}
|
|
4403
4480
|
};
|
|
4404
4481
|
do {
|
|
@@ -4409,10 +4486,10 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
|
|
|
4409
4486
|
return (y = t.get(S)) == null ? void 0 : y.l.forEach(h);
|
|
4410
4487
|
}), i.clear(), o.forEach(h), o.clear(), s.forEach(h), s.clear(), f.forEach(l), i.size && c(n);
|
|
4411
4488
|
} while (i.size || o.size || s.size);
|
|
4412
|
-
if (
|
|
4413
|
-
throw new AggregateError(
|
|
4414
|
-
},
|
|
4415
|
-
const e = Z(n), t = e[1], i = e[2], s = e[3], o = e[11], r = e[14], c = e[17],
|
|
4489
|
+
if (d.length)
|
|
4490
|
+
throw new AggregateError(d);
|
|
4491
|
+
}, Zs = (n) => {
|
|
4492
|
+
const e = Z(n), t = e[1], i = e[2], s = e[3], o = e[11], r = e[14], c = e[17], d = [], l = /* @__PURE__ */ new WeakSet(), f = /* @__PURE__ */ new WeakSet(), h = Array.from(s);
|
|
4416
4493
|
for (; h.length; ) {
|
|
4417
4494
|
const S = h[h.length - 1], y = o(n, S);
|
|
4418
4495
|
if (f.has(S)) {
|
|
@@ -4421,18 +4498,18 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
|
|
|
4421
4498
|
}
|
|
4422
4499
|
if (l.has(S)) {
|
|
4423
4500
|
if (i.get(S) === y.n)
|
|
4424
|
-
|
|
4425
|
-
else if ((
|
|
4501
|
+
d.push([S, y]);
|
|
4502
|
+
else if ((ue ? "production" : void 0) !== "production" && i.has(S))
|
|
4426
4503
|
throw new Error("[Bug] invalidated atom exists");
|
|
4427
4504
|
f.add(S), h.pop();
|
|
4428
4505
|
continue;
|
|
4429
4506
|
}
|
|
4430
4507
|
l.add(S);
|
|
4431
|
-
for (const v of
|
|
4508
|
+
for (const v of Pn(S, y, t))
|
|
4432
4509
|
l.has(v) || h.push(v);
|
|
4433
4510
|
}
|
|
4434
|
-
for (let S =
|
|
4435
|
-
const [y, v] =
|
|
4511
|
+
for (let S = d.length - 1; S >= 0; --S) {
|
|
4512
|
+
const [y, v] = d[S];
|
|
4436
4513
|
let E = !1;
|
|
4437
4514
|
for (const m of v.d.keys())
|
|
4438
4515
|
if (m !== y && s.has(m)) {
|
|
@@ -4441,15 +4518,15 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
|
|
|
4441
4518
|
}
|
|
4442
4519
|
E && (r(n, y), c(n, y)), i.delete(y);
|
|
4443
4520
|
}
|
|
4444
|
-
},
|
|
4521
|
+
}, mt = /* @__PURE__ */ new WeakSet(), eo = (n, e) => {
|
|
4445
4522
|
var t, i;
|
|
4446
|
-
const s = Z(n), o = s[1], r = s[2], c = s[3],
|
|
4447
|
-
if (
|
|
4523
|
+
const s = Z(n), o = s[1], r = s[2], c = s[3], d = s[6], l = s[7], f = s[11], h = s[12], S = s[13], y = s[14], v = s[16], E = s[17], m = f(n, e);
|
|
4524
|
+
if (rn(m)) {
|
|
4448
4525
|
if (o.has(e) && r.get(e) !== m.n)
|
|
4449
4526
|
return m;
|
|
4450
4527
|
let R = !1;
|
|
4451
|
-
for (const [a,
|
|
4452
|
-
if (y(n, a).n !==
|
|
4528
|
+
for (const [a, u] of m.d)
|
|
4529
|
+
if (y(n, a).n !== u) {
|
|
4453
4530
|
R = !0;
|
|
4454
4531
|
break;
|
|
4455
4532
|
}
|
|
@@ -4458,25 +4535,25 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
|
|
|
4458
4535
|
}
|
|
4459
4536
|
m.d.clear();
|
|
4460
4537
|
let w = !0;
|
|
4461
|
-
function
|
|
4538
|
+
function x() {
|
|
4462
4539
|
o.has(e) && (E(n, e), S(n), h(n));
|
|
4463
4540
|
}
|
|
4464
4541
|
function A(R) {
|
|
4465
4542
|
var a;
|
|
4466
4543
|
if (R === e) {
|
|
4467
4544
|
const p = f(n, R);
|
|
4468
|
-
if (!
|
|
4469
|
-
if (
|
|
4470
|
-
|
|
4545
|
+
if (!rn(p))
|
|
4546
|
+
if (xn(R))
|
|
4547
|
+
et(n, R, R.init);
|
|
4471
4548
|
else
|
|
4472
4549
|
throw new Error("no atom init");
|
|
4473
4550
|
return ze(p);
|
|
4474
4551
|
}
|
|
4475
|
-
const
|
|
4552
|
+
const u = y(n, R);
|
|
4476
4553
|
try {
|
|
4477
|
-
return ze(
|
|
4554
|
+
return ze(u);
|
|
4478
4555
|
} finally {
|
|
4479
|
-
m.d.set(R,
|
|
4556
|
+
m.d.set(R, u.n), Nn(m.v) && Dn(e, m.v, u), o.has(e) && ((a = o.get(R)) == null || a.t.add(e)), w || x();
|
|
4480
4557
|
}
|
|
4481
4558
|
}
|
|
4482
4559
|
let P, M;
|
|
@@ -4485,8 +4562,8 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
|
|
|
4485
4562
|
return P || (P = new AbortController()), P.signal;
|
|
4486
4563
|
},
|
|
4487
4564
|
get setSelf() {
|
|
4488
|
-
return (
|
|
4489
|
-
if ((
|
|
4565
|
+
return (ue ? "production" : void 0) !== "production" && !gt(e) && console.warn("setSelf function cannot be used with read-only atom"), !M && gt(e) && (M = (...R) => {
|
|
4566
|
+
if ((ue ? "production" : void 0) !== "production" && w && console.warn("setSelf function cannot be called in sync"), !w)
|
|
4490
4567
|
try {
|
|
4491
4568
|
return v(n, e, ...R);
|
|
4492
4569
|
} finally {
|
|
@@ -4496,43 +4573,43 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
|
|
|
4496
4573
|
}
|
|
4497
4574
|
}, F = m.n;
|
|
4498
4575
|
try {
|
|
4499
|
-
(
|
|
4576
|
+
(ue ? "production" : void 0) !== "production" && mt.delete(n);
|
|
4500
4577
|
const R = l(n, e, A, q);
|
|
4501
|
-
return (
|
|
4578
|
+
return (ue ? "production" : void 0) !== "production" && mt.has(n) && console.warn(
|
|
4502
4579
|
"Detected store mutation during atom read. This is not supported."
|
|
4503
|
-
),
|
|
4580
|
+
), et(n, e, R), Ze(R) && (vt(R, () => P?.abort()), R.then(x, x)), (t = d.r) == null || t.call(d, e), m;
|
|
4504
4581
|
} catch (R) {
|
|
4505
4582
|
return delete m.v, m.e = R, ++m.n, m;
|
|
4506
4583
|
} finally {
|
|
4507
|
-
w = !1, F !== m.n && r.get(e) === F && (r.set(e, m.n), c.add(e), (i =
|
|
4584
|
+
w = !1, F !== m.n && r.get(e) === F && (r.set(e, m.n), c.add(e), (i = d.c) == null || i.call(d, e));
|
|
4508
4585
|
}
|
|
4509
|
-
},
|
|
4586
|
+
}, to = (n, e) => {
|
|
4510
4587
|
const t = Z(n), i = t[1], s = t[2], o = t[11], r = [e];
|
|
4511
4588
|
for (; r.length; ) {
|
|
4512
|
-
const c = r.pop(),
|
|
4513
|
-
for (const l of
|
|
4589
|
+
const c = r.pop(), d = o(n, c);
|
|
4590
|
+
for (const l of Pn(c, d, i)) {
|
|
4514
4591
|
const f = o(n, l);
|
|
4515
4592
|
s.set(l, f.n), r.push(l);
|
|
4516
4593
|
}
|
|
4517
4594
|
}
|
|
4518
|
-
},
|
|
4519
|
-
const i = Z(n), s = i[3], o = i[6], r = i[8], c = i[11],
|
|
4595
|
+
}, Mn = (n, e, ...t) => {
|
|
4596
|
+
const i = Z(n), s = i[3], o = i[6], r = i[8], c = i[11], d = i[12], l = i[13], f = i[14], h = i[15], S = i[17];
|
|
4520
4597
|
let y = !0;
|
|
4521
4598
|
const v = (m) => ze(f(n, m)), E = (m, ...w) => {
|
|
4522
|
-
var
|
|
4599
|
+
var x;
|
|
4523
4600
|
const A = c(n, m);
|
|
4524
4601
|
try {
|
|
4525
4602
|
if (m === e) {
|
|
4526
|
-
if (!
|
|
4603
|
+
if (!xn(m))
|
|
4527
4604
|
throw new Error("atom not writable");
|
|
4528
|
-
(
|
|
4605
|
+
(ue ? "production" : void 0) !== "production" && mt.add(n);
|
|
4529
4606
|
const P = A.n, M = w[0];
|
|
4530
|
-
|
|
4607
|
+
et(n, m, M), S(n, m), P !== A.n && (s.add(m), h(n, m), (x = o.c) == null || x.call(o, m));
|
|
4531
4608
|
return;
|
|
4532
4609
|
} else
|
|
4533
|
-
return
|
|
4610
|
+
return Mn(n, m, ...w);
|
|
4534
4611
|
} finally {
|
|
4535
|
-
y || (l(n),
|
|
4612
|
+
y || (l(n), d(n));
|
|
4536
4613
|
}
|
|
4537
4614
|
};
|
|
4538
4615
|
try {
|
|
@@ -4540,14 +4617,14 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
|
|
|
4540
4617
|
} finally {
|
|
4541
4618
|
y = !1;
|
|
4542
4619
|
}
|
|
4543
|
-
},
|
|
4620
|
+
}, no = (n, e) => {
|
|
4544
4621
|
var t;
|
|
4545
|
-
const i = Z(n), s = i[1], o = i[3], r = i[6], c = i[11],
|
|
4546
|
-
if (S && !
|
|
4622
|
+
const i = Z(n), s = i[1], o = i[3], r = i[6], c = i[11], d = i[15], l = i[18], f = i[19], h = c(n, e), S = s.get(e);
|
|
4623
|
+
if (S && !Nn(h.v)) {
|
|
4547
4624
|
for (const [y, v] of h.d)
|
|
4548
4625
|
if (!S.d.has(y)) {
|
|
4549
4626
|
const E = c(n, y);
|
|
4550
|
-
l(n, y).t.add(e), S.d.add(y), v !== E.n && (o.add(y),
|
|
4627
|
+
l(n, y).t.add(e), S.d.add(y), v !== E.n && (o.add(y), d(n, y), (t = r.c) == null || t.call(r, y));
|
|
4551
4628
|
}
|
|
4552
4629
|
for (const y of S.d)
|
|
4553
4630
|
if (!h.d.has(y)) {
|
|
@@ -4556,34 +4633,34 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
|
|
|
4556
4633
|
v?.t.delete(e);
|
|
4557
4634
|
}
|
|
4558
4635
|
}
|
|
4559
|
-
},
|
|
4636
|
+
}, Un = (n, e) => {
|
|
4560
4637
|
var t;
|
|
4561
|
-
const i = Z(n), s = i[1], o = i[4], r = i[6], c = i[10],
|
|
4638
|
+
const i = Z(n), s = i[1], o = i[4], r = i[6], c = i[10], d = i[11], l = i[12], f = i[13], h = i[14], S = i[16], y = d(n, e);
|
|
4562
4639
|
let v = s.get(e);
|
|
4563
4640
|
if (!v) {
|
|
4564
4641
|
h(n, e);
|
|
4565
4642
|
for (const E of y.d.keys())
|
|
4566
|
-
|
|
4643
|
+
Un(n, E).t.add(e);
|
|
4567
4644
|
if (v = {
|
|
4568
4645
|
l: /* @__PURE__ */ new Set(),
|
|
4569
4646
|
d: new Set(y.d.keys()),
|
|
4570
4647
|
t: /* @__PURE__ */ new Set()
|
|
4571
|
-
}, s.set(e, v),
|
|
4648
|
+
}, s.set(e, v), gt(e)) {
|
|
4572
4649
|
const E = () => {
|
|
4573
4650
|
let m = !0;
|
|
4574
|
-
const w = (...
|
|
4651
|
+
const w = (...x) => {
|
|
4575
4652
|
try {
|
|
4576
|
-
return S(n, e, ...
|
|
4653
|
+
return S(n, e, ...x);
|
|
4577
4654
|
} finally {
|
|
4578
4655
|
m || (f(n), l(n));
|
|
4579
4656
|
}
|
|
4580
4657
|
};
|
|
4581
4658
|
try {
|
|
4582
|
-
const
|
|
4583
|
-
|
|
4659
|
+
const x = c(n, e, w);
|
|
4660
|
+
x && (v.u = () => {
|
|
4584
4661
|
m = !0;
|
|
4585
4662
|
try {
|
|
4586
|
-
|
|
4663
|
+
x();
|
|
4587
4664
|
} finally {
|
|
4588
4665
|
m = !1;
|
|
4589
4666
|
}
|
|
@@ -4597,9 +4674,9 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
|
|
|
4597
4674
|
(t = r.m) == null || t.call(r, e);
|
|
4598
4675
|
}
|
|
4599
4676
|
return v;
|
|
4600
|
-
},
|
|
4677
|
+
}, io = (n, e) => {
|
|
4601
4678
|
var t, i;
|
|
4602
|
-
const s = Z(n), o = s[1], r = s[5], c = s[6],
|
|
4679
|
+
const s = Z(n), o = s[1], r = s[5], c = s[6], d = s[11], l = s[19], f = d(n, e);
|
|
4603
4680
|
let h = o.get(e);
|
|
4604
4681
|
if (!h || h.l.size)
|
|
4605
4682
|
return h;
|
|
@@ -4619,40 +4696,40 @@ const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs
|
|
|
4619
4696
|
return;
|
|
4620
4697
|
}
|
|
4621
4698
|
return h;
|
|
4622
|
-
},
|
|
4699
|
+
}, et = (n, e, t) => {
|
|
4623
4700
|
const i = Z(n)[11], s = i(n, e), o = "v" in s, r = s.v;
|
|
4624
|
-
if (
|
|
4701
|
+
if (Ze(t))
|
|
4625
4702
|
for (const c of s.d.keys())
|
|
4626
|
-
|
|
4703
|
+
Dn(
|
|
4627
4704
|
e,
|
|
4628
4705
|
t,
|
|
4629
4706
|
i(n, c)
|
|
4630
4707
|
);
|
|
4631
|
-
s.v = t, delete s.e, (!o || !Object.is(r, s.v)) && (++s.n,
|
|
4632
|
-
},
|
|
4708
|
+
s.v = t, delete s.e, (!o || !Object.is(r, s.v)) && (++s.n, Ze(r) && qs(r));
|
|
4709
|
+
}, so = (n, e) => {
|
|
4633
4710
|
const t = Z(n)[14];
|
|
4634
4711
|
return ze(t(n, e));
|
|
4635
|
-
},
|
|
4712
|
+
}, oo = (n, e, ...t) => {
|
|
4636
4713
|
const i = Z(n), s = i[12], o = i[13], r = i[16];
|
|
4637
4714
|
try {
|
|
4638
4715
|
return r(n, e, ...t);
|
|
4639
4716
|
} finally {
|
|
4640
4717
|
o(n), s(n);
|
|
4641
4718
|
}
|
|
4642
|
-
},
|
|
4643
|
-
const i = Z(n), s = i[12], o = i[18], r = i[19],
|
|
4644
|
-
return
|
|
4645
|
-
|
|
4719
|
+
}, ro = (n, e, t) => {
|
|
4720
|
+
const i = Z(n), s = i[12], o = i[18], r = i[19], d = o(n, e).l;
|
|
4721
|
+
return d.add(t), s(n), () => {
|
|
4722
|
+
d.delete(t), r(n, e), s(n);
|
|
4646
4723
|
};
|
|
4647
|
-
},
|
|
4648
|
-
const e =
|
|
4649
|
-
if ((
|
|
4724
|
+
}, Fn = /* @__PURE__ */ new WeakMap(), Z = (n) => {
|
|
4725
|
+
const e = Fn.get(n);
|
|
4726
|
+
if ((ue ? "production" : void 0) !== "production" && !e)
|
|
4650
4727
|
throw new Error(
|
|
4651
4728
|
"Store must be created by buildStore to read its building blocks"
|
|
4652
4729
|
);
|
|
4653
4730
|
return e;
|
|
4654
4731
|
};
|
|
4655
|
-
function
|
|
4732
|
+
function ao(...n) {
|
|
4656
4733
|
const e = {
|
|
4657
4734
|
get(i) {
|
|
4658
4735
|
const s = Z(e)[21];
|
|
@@ -4683,63 +4760,63 @@ function no(...n) {
|
|
|
4683
4760
|
{},
|
|
4684
4761
|
// storeHooks
|
|
4685
4762
|
// atom interceptors
|
|
4686
|
-
Hs,
|
|
4687
|
-
Ws,
|
|
4688
|
-
Gs,
|
|
4689
|
-
Vs,
|
|
4690
|
-
// building-block functions
|
|
4691
|
-
qs,
|
|
4692
4763
|
Ys,
|
|
4693
4764
|
Js,
|
|
4694
4765
|
Ks,
|
|
4766
|
+
Xs,
|
|
4767
|
+
// building-block functions
|
|
4695
4768
|
zs,
|
|
4696
|
-
xn,
|
|
4697
4769
|
Qs,
|
|
4698
|
-
Dn,
|
|
4699
|
-
Xs,
|
|
4700
|
-
Ze,
|
|
4701
4770
|
Zs,
|
|
4702
4771
|
eo,
|
|
4703
4772
|
to,
|
|
4773
|
+
Mn,
|
|
4774
|
+
no,
|
|
4775
|
+
Un,
|
|
4776
|
+
io,
|
|
4777
|
+
et,
|
|
4778
|
+
so,
|
|
4779
|
+
oo,
|
|
4780
|
+
ro,
|
|
4704
4781
|
void 0
|
|
4705
4782
|
].map((i, s) => n[s] || i);
|
|
4706
|
-
return
|
|
4783
|
+
return Fn.set(e, Object.freeze(t)), e;
|
|
4707
4784
|
}
|
|
4708
|
-
const
|
|
4709
|
-
let
|
|
4710
|
-
function
|
|
4711
|
-
const t = `atom${++
|
|
4785
|
+
const jn = {};
|
|
4786
|
+
let co = 0;
|
|
4787
|
+
function tt(n, e) {
|
|
4788
|
+
const t = `atom${++co}`, i = {
|
|
4712
4789
|
toString() {
|
|
4713
|
-
return (
|
|
4790
|
+
return (jn ? "production" : void 0) !== "production" && this.debugLabel ? t + ":" + this.debugLabel : t;
|
|
4714
4791
|
}
|
|
4715
4792
|
};
|
|
4716
|
-
return typeof n == "function" ? i.read = n : (i.init = n, i.read =
|
|
4793
|
+
return typeof n == "function" ? i.read = n : (i.init = n, i.read = lo, i.write = uo), i;
|
|
4717
4794
|
}
|
|
4718
|
-
function
|
|
4795
|
+
function lo(n) {
|
|
4719
4796
|
return n(this);
|
|
4720
4797
|
}
|
|
4721
|
-
function
|
|
4798
|
+
function uo(n, e, t) {
|
|
4722
4799
|
return e(
|
|
4723
4800
|
this,
|
|
4724
4801
|
typeof t == "function" ? t(n(this)) : t
|
|
4725
4802
|
);
|
|
4726
4803
|
}
|
|
4727
|
-
function
|
|
4728
|
-
return
|
|
4804
|
+
function ho() {
|
|
4805
|
+
return ao();
|
|
4729
4806
|
}
|
|
4730
4807
|
let Ie;
|
|
4731
|
-
function
|
|
4732
|
-
return Ie || (Ie =
|
|
4808
|
+
function po() {
|
|
4809
|
+
return Ie || (Ie = ho(), (jn ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = Ie), globalThis.__JOTAI_DEFAULT_STORE__ !== Ie && console.warn(
|
|
4733
4810
|
"Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
|
|
4734
4811
|
))), Ie;
|
|
4735
4812
|
}
|
|
4736
|
-
const
|
|
4813
|
+
const fo = {}, go = ln(
|
|
4737
4814
|
void 0
|
|
4738
4815
|
);
|
|
4739
|
-
function
|
|
4740
|
-
return
|
|
4816
|
+
function Bn(n) {
|
|
4817
|
+
return cn(go) || po();
|
|
4741
4818
|
}
|
|
4742
|
-
const
|
|
4819
|
+
const _t = (n) => typeof n?.then == "function", yt = (n) => {
|
|
4743
4820
|
n.status || (n.status = "pending", n.then(
|
|
4744
4821
|
(e) => {
|
|
4745
4822
|
n.status = "fulfilled", n.value = e;
|
|
@@ -4748,34 +4825,34 @@ const vt = (n) => typeof n?.then == "function", mt = (n) => {
|
|
|
4748
4825
|
n.status = "rejected", n.reason = e;
|
|
4749
4826
|
}
|
|
4750
4827
|
));
|
|
4751
|
-
},
|
|
4828
|
+
}, vo = St.use || // A shim for older React versions
|
|
4752
4829
|
((n) => {
|
|
4753
4830
|
if (n.status === "pending")
|
|
4754
4831
|
throw n;
|
|
4755
4832
|
if (n.status === "fulfilled")
|
|
4756
4833
|
return n.value;
|
|
4757
|
-
throw n.status === "rejected" ? n.reason : (
|
|
4758
|
-
}),
|
|
4759
|
-
let t =
|
|
4834
|
+
throw n.status === "rejected" ? n.reason : (yt(n), n);
|
|
4835
|
+
}), dt = /* @__PURE__ */ new WeakMap(), an = (n, e) => {
|
|
4836
|
+
let t = dt.get(n);
|
|
4760
4837
|
return t || (t = new Promise((i, s) => {
|
|
4761
4838
|
let o = n;
|
|
4762
4839
|
const r = (l) => (f) => {
|
|
4763
4840
|
o === l && i(f);
|
|
4764
4841
|
}, c = (l) => (f) => {
|
|
4765
4842
|
o === l && s(f);
|
|
4766
|
-
},
|
|
4843
|
+
}, d = () => {
|
|
4767
4844
|
try {
|
|
4768
4845
|
const l = e();
|
|
4769
|
-
|
|
4846
|
+
_t(l) ? (dt.set(l, t), o = l, l.then(r(l), c(l)), vt(l, d)) : i(l);
|
|
4770
4847
|
} catch (l) {
|
|
4771
4848
|
s(l);
|
|
4772
4849
|
}
|
|
4773
4850
|
};
|
|
4774
|
-
n.then(r(n), c(n)),
|
|
4775
|
-
}),
|
|
4851
|
+
n.then(r(n), c(n)), vt(n, d);
|
|
4852
|
+
}), dt.set(n, t)), t;
|
|
4776
4853
|
};
|
|
4777
|
-
function
|
|
4778
|
-
const { delay: t, unstable_promiseStatus: i = !
|
|
4854
|
+
function nt(n, e) {
|
|
4855
|
+
const { delay: t, unstable_promiseStatus: i = !St.use } = {}, s = Bn(), [[o, r, c], d] = Yn(
|
|
4779
4856
|
(f) => {
|
|
4780
4857
|
const h = s.get(n);
|
|
4781
4858
|
return Object.is(f[0], h) && f[1] === s && f[2] === n ? f : [h, s, n];
|
|
@@ -4784,55 +4861,55 @@ function tt(n, e) {
|
|
|
4784
4861
|
() => [s.get(n), s, n]
|
|
4785
4862
|
);
|
|
4786
4863
|
let l = o;
|
|
4787
|
-
if ((r !== s || c !== n) && (
|
|
4864
|
+
if ((r !== s || c !== n) && (d(), l = s.get(n)), ve(() => {
|
|
4788
4865
|
const f = s.sub(n, () => {
|
|
4789
4866
|
if (i)
|
|
4790
4867
|
try {
|
|
4791
4868
|
const h = s.get(n);
|
|
4792
|
-
|
|
4793
|
-
|
|
4869
|
+
_t(h) && yt(
|
|
4870
|
+
an(h, () => s.get(n))
|
|
4794
4871
|
);
|
|
4795
4872
|
} catch {
|
|
4796
4873
|
}
|
|
4797
4874
|
if (typeof t == "number") {
|
|
4798
|
-
setTimeout(
|
|
4875
|
+
setTimeout(d, t);
|
|
4799
4876
|
return;
|
|
4800
4877
|
}
|
|
4801
|
-
|
|
4878
|
+
d();
|
|
4802
4879
|
});
|
|
4803
|
-
return
|
|
4804
|
-
}, [s, n, t, i]),
|
|
4805
|
-
const f =
|
|
4806
|
-
return i &&
|
|
4880
|
+
return d(), f;
|
|
4881
|
+
}, [s, n, t, i]), Jn(l), _t(l)) {
|
|
4882
|
+
const f = an(l, () => s.get(n));
|
|
4883
|
+
return i && yt(f), vo(f);
|
|
4807
4884
|
}
|
|
4808
4885
|
return l;
|
|
4809
4886
|
}
|
|
4810
|
-
function
|
|
4811
|
-
const t =
|
|
4812
|
-
return
|
|
4887
|
+
function it(n, e) {
|
|
4888
|
+
const t = Bn();
|
|
4889
|
+
return Kn(
|
|
4813
4890
|
(...s) => {
|
|
4814
|
-
if ((
|
|
4891
|
+
if ((fo ? "production" : void 0) !== "production" && !("write" in n))
|
|
4815
4892
|
throw new Error("not writable atom");
|
|
4816
4893
|
return t.set(n, ...s);
|
|
4817
4894
|
},
|
|
4818
4895
|
[t, n]
|
|
4819
4896
|
);
|
|
4820
4897
|
}
|
|
4821
|
-
const
|
|
4822
|
-
function
|
|
4823
|
-
return
|
|
4898
|
+
const Hn = tt([]);
|
|
4899
|
+
function To() {
|
|
4900
|
+
return nt(Hn);
|
|
4824
4901
|
}
|
|
4825
|
-
function
|
|
4826
|
-
return
|
|
4902
|
+
function mo() {
|
|
4903
|
+
return it(Hn);
|
|
4827
4904
|
}
|
|
4828
|
-
const
|
|
4829
|
-
const n =
|
|
4905
|
+
const st = () => {
|
|
4906
|
+
const n = cn(Vn);
|
|
4830
4907
|
if (!n)
|
|
4831
4908
|
throw new Error("useClient must be used within a TelnyxAIAgentProvider");
|
|
4832
4909
|
return n;
|
|
4833
4910
|
};
|
|
4834
|
-
function
|
|
4835
|
-
const n =
|
|
4911
|
+
function _o() {
|
|
4912
|
+
const n = st(), e = mo();
|
|
4836
4913
|
return ve(() => {
|
|
4837
4914
|
const t = (i) => e((s) => [...s, i]);
|
|
4838
4915
|
return n.addListener("transcript.item", t), () => {
|
|
@@ -4840,15 +4917,15 @@ function po() {
|
|
|
4840
4917
|
};
|
|
4841
4918
|
}, [n, e]), null;
|
|
4842
4919
|
}
|
|
4843
|
-
const
|
|
4844
|
-
function
|
|
4845
|
-
return
|
|
4920
|
+
const $n = tt("connecting");
|
|
4921
|
+
function ko() {
|
|
4922
|
+
return nt($n);
|
|
4846
4923
|
}
|
|
4847
|
-
function
|
|
4848
|
-
return
|
|
4924
|
+
function yo() {
|
|
4925
|
+
return it($n);
|
|
4849
4926
|
}
|
|
4850
|
-
function
|
|
4851
|
-
const n =
|
|
4927
|
+
function So() {
|
|
4928
|
+
const n = st(), e = yo();
|
|
4852
4929
|
return ve(() => {
|
|
4853
4930
|
const t = () => e("connected"), i = () => e("disconnected"), s = () => e("error");
|
|
4854
4931
|
return n.addListener("agent.connected", t), n.addListener("agent.disconnected", i), n.addListener("agent.error", s), () => {
|
|
@@ -4856,15 +4933,15 @@ function go() {
|
|
|
4856
4933
|
};
|
|
4857
4934
|
}, [n, e]), null;
|
|
4858
4935
|
}
|
|
4859
|
-
const
|
|
4860
|
-
function
|
|
4861
|
-
return
|
|
4936
|
+
const Wn = tt(null);
|
|
4937
|
+
function Ro() {
|
|
4938
|
+
return nt(Wn);
|
|
4862
4939
|
}
|
|
4863
|
-
function
|
|
4864
|
-
return
|
|
4940
|
+
function bo() {
|
|
4941
|
+
return it(Wn);
|
|
4865
4942
|
}
|
|
4866
|
-
const
|
|
4867
|
-
const n =
|
|
4943
|
+
const Co = () => {
|
|
4944
|
+
const n = st(), e = bo();
|
|
4868
4945
|
return ve(() => {
|
|
4869
4946
|
const t = (i) => {
|
|
4870
4947
|
e(i);
|
|
@@ -4873,15 +4950,15 @@ const mo = () => {
|
|
|
4873
4950
|
n.removeListener("conversation.update", t);
|
|
4874
4951
|
};
|
|
4875
4952
|
}, [n, e]), null;
|
|
4876
|
-
},
|
|
4877
|
-
function
|
|
4878
|
-
return
|
|
4953
|
+
}, Gn = tt({ state: "listening" });
|
|
4954
|
+
function Ao() {
|
|
4955
|
+
return nt(Gn);
|
|
4879
4956
|
}
|
|
4880
|
-
function
|
|
4881
|
-
return
|
|
4957
|
+
function wo() {
|
|
4958
|
+
return it(Gn);
|
|
4882
4959
|
}
|
|
4883
|
-
function
|
|
4884
|
-
const n =
|
|
4960
|
+
function Eo() {
|
|
4961
|
+
const n = st(), e = wo();
|
|
4885
4962
|
return ve(() => {
|
|
4886
4963
|
const t = (i) => {
|
|
4887
4964
|
e(i);
|
|
@@ -4891,7 +4968,7 @@ function yo() {
|
|
|
4891
4968
|
};
|
|
4892
4969
|
}, [n, e]), null;
|
|
4893
4970
|
}
|
|
4894
|
-
const
|
|
4971
|
+
const Vn = ln(null), Oo = ({
|
|
4895
4972
|
children: n,
|
|
4896
4973
|
agentId: e,
|
|
4897
4974
|
environment: t,
|
|
@@ -4899,36 +4976,36 @@ const Hn = rn(null), Io = ({
|
|
|
4899
4976
|
debug: s,
|
|
4900
4977
|
vad: o
|
|
4901
4978
|
}) => {
|
|
4902
|
-
const [r, c] =
|
|
4979
|
+
const [r, c] = Xn(() => new tn({ agentId: e, environment: t, versionId: i, debug: s, vad: o }));
|
|
4903
4980
|
return ve(() => {
|
|
4904
4981
|
if (!r) {
|
|
4905
|
-
const
|
|
4906
|
-
return c(
|
|
4907
|
-
|
|
4982
|
+
const d = new tn({ agentId: e, environment: t, versionId: i, vad: o });
|
|
4983
|
+
return c(d), () => {
|
|
4984
|
+
d.disconnect();
|
|
4908
4985
|
};
|
|
4909
4986
|
}
|
|
4910
4987
|
}, [e, r, t, i, o]), ve(() => {
|
|
4911
4988
|
r?.connect();
|
|
4912
|
-
}, [r]), /* @__PURE__ */ Ee.jsxs(
|
|
4913
|
-
/* @__PURE__ */ Ee.jsx(
|
|
4914
|
-
/* @__PURE__ */ Ee.jsx(
|
|
4915
|
-
/* @__PURE__ */ Ee.jsx(
|
|
4916
|
-
/* @__PURE__ */ Ee.jsx(
|
|
4989
|
+
}, [r]), /* @__PURE__ */ Ee.jsxs(Vn.Provider, { value: r, children: [
|
|
4990
|
+
/* @__PURE__ */ Ee.jsx(_o, {}),
|
|
4991
|
+
/* @__PURE__ */ Ee.jsx(So, {}),
|
|
4992
|
+
/* @__PURE__ */ Ee.jsx(Co, {}),
|
|
4993
|
+
/* @__PURE__ */ Ee.jsx(Eo, {}),
|
|
4917
4994
|
n
|
|
4918
4995
|
] });
|
|
4919
4996
|
};
|
|
4920
4997
|
export {
|
|
4921
|
-
|
|
4998
|
+
Vn as ClientContext,
|
|
4922
4999
|
T as SwEvent,
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
5000
|
+
tn as TelnyxAIAgent,
|
|
5001
|
+
Oo as TelnyxAIAgentProvider,
|
|
5002
|
+
Ao as useAgentState,
|
|
5003
|
+
st as useClient,
|
|
5004
|
+
ko as useConnectionState,
|
|
5005
|
+
Ro as useConversation,
|
|
5006
|
+
wo as useSetAgentState,
|
|
5007
|
+
yo as useSetConnectionState,
|
|
5008
|
+
bo as useSetConversation,
|
|
5009
|
+
mo as useSetTranscript,
|
|
5010
|
+
To as useTranscript
|
|
4934
5011
|
};
|