@telnyx/ai-agent-lib 0.4.3 → 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 +21 -0
- package/dist/index.js +1044 -974
- package/dist/types.d.ts +21 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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
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]);
|
|
@@ -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 Ni = { 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"] } }, xi = { 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"] } };
|
|
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
58
|
function de(n, e) {
|
|
59
|
-
const t =
|
|
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
|
-
function
|
|
78
|
-
const i =
|
|
79
|
-
return new
|
|
77
|
+
function W(n, e, t) {
|
|
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 Pi = pn((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 Pi = pn((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 Mi {
|
|
|
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 Mi {
|
|
|
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 Ot(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 z, ce,
|
|
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,31 +360,31 @@ const be = "GLOBAL", se = {}, De = (n, e) => `${n}|${e}`, Sn = (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
390
|
return !!this._wsClient && this._wsClient.readyState === Nt;
|
|
@@ -403,10 +403,10 @@ class xt {
|
|
|
403
403
|
let t = fe();
|
|
404
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 =
|
|
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 xt {
|
|
|
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 xt {
|
|
|
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 =
|
|
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 xt {
|
|
|
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 !== 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:
|
|
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 xt {
|
|
|
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
489
|
const t = We(e.dialogParams, ["remoteSdp", "localStream", "remoteStream", "localElement", "remoteElement", "onNotification", "camId", "micId", "speakerId"]);
|
|
490
|
-
for (const i in
|
|
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 =
|
|
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 =
|
|
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 = de(
|
|
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 =
|
|
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
|
-
|
|
800
|
+
d = !0;
|
|
801
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
|
-
|
|
805
|
+
d = !0;
|
|
806
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,8 +922,8 @@ function os() {
|
|
|
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
|
}
|
|
@@ -938,14 +938,14 @@ function Wt(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 Gt(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) {
|
|
@@ -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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Q = l(G, K), V = 0; V < K; ++V) Q[V].call(D, j,
|
|
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 Q = G.length, V = l(G, Q), ae = 0; ae < Q; ++ae) V[ae].call(D, j,
|
|
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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Tn = pn((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, Tn = pn((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 ps(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 Jt(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 = de(
|
|
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 = de(
|
|
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")));
|
|
@@ -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");
|
|
@@ -2043,32 +2043,32 @@ class xe {
|
|
|
2043
2043
|
var e;
|
|
2044
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: z.Offer }), performance.mark("set-remote-description"), !this.instance)) throw
|
|
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:
|
|
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.instance) throw
|
|
2068
|
+
})))), !this.instance) throw W(rt);
|
|
2069
2069
|
if (!this.options.localStream && !t)
|
|
2070
|
-
throw
|
|
2071
|
-
performance.mark("get-user-media"), this.options.mutedMicOnStart && me(this.options.localStream) && (g.info("Muting local audio tracks on start"),
|
|
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");
|
|
2072
2072
|
}));
|
|
2073
2073
|
}
|
|
2074
2074
|
incrementGatheredCandidates() {
|
|
@@ -2078,14 +2078,14 @@ class xe {
|
|
|
2078
2078
|
this._clearIceGatheringSafetyTimeout(), this._iceGatheringSafetyTimeout = setTimeout((() => {
|
|
2079
2079
|
if (this.instance) {
|
|
2080
2080
|
if (this._gatheredCandidatesCount === 0) {
|
|
2081
|
-
const e = de(
|
|
2081
|
+
const e = de(Ei);
|
|
2082
2082
|
L(T.Warning, { warning: e, callId: this.options.id, sessionId: this._session.sessionid }, this.options.id);
|
|
2083
2083
|
} else if (this.instance.iceGatheringState !== "complete") {
|
|
2084
|
-
const e = de(
|
|
2084
|
+
const e = de(wi);
|
|
2085
2085
|
L(T.Warning, { warning: e, callId: this.options.id, sessionId: this._session.sessionid }, this.options.id);
|
|
2086
2086
|
}
|
|
2087
2087
|
}
|
|
2088
|
-
}),
|
|
2088
|
+
}), De.ICE_GATHERING_SAFETY_TIMEOUT_MS);
|
|
2089
2089
|
}
|
|
2090
2090
|
_clearIceGatheringSafetyTimeout() {
|
|
2091
2091
|
this._iceGatheringSafetyTimeout !== null && (clearTimeout(this._iceGatheringSafetyTimeout), this._iceGatheringSafetyTimeout = null);
|
|
@@ -2093,8 +2093,8 @@ class xe {
|
|
|
2093
2093
|
init() {
|
|
2094
2094
|
var e;
|
|
2095
2095
|
return O(this, void 0, void 0, (function* () {
|
|
2096
|
-
if (yield this.createPeerConnection(), !this.instance) throw
|
|
2097
|
-
this.isDebugEnabled && (this.statsReporter =
|
|
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));
|
|
2098
2098
|
const { localElement: t, localStream: i = null, screenShare: s = !1 } = this.options;
|
|
2099
2099
|
if (me(i)) {
|
|
2100
2100
|
const o = i.getAudioTracks();
|
|
@@ -2107,24 +2107,24 @@ class xe {
|
|
|
2107
2107
|
g.info("Local video tracks constraints: ", f.getConstraints());
|
|
2108
2108
|
}));
|
|
2109
2109
|
}
|
|
2110
|
-
const { audioCodecs: c, videoCodecs:
|
|
2110
|
+
const { audioCodecs: c, videoCodecs: d } = qt(this.options.preferred_codecs);
|
|
2111
2111
|
if (this.isOffer && typeof this.instance.addTransceiver == "function") {
|
|
2112
2112
|
const l = { direction: "sendrecv", streams: [i] };
|
|
2113
2113
|
r.forEach(((f) => {
|
|
2114
2114
|
f.kind === "audio" && (this.options.userVariables.microphoneLabel = f.label), f.kind === "video" && (this.options.userVariables.cameraLabel = f.label);
|
|
2115
2115
|
const h = this.instance.addTransceiver(f, l);
|
|
2116
|
-
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);
|
|
2117
2117
|
}));
|
|
2118
2118
|
} else typeof this.instance.addTrack == "function" ? (r.forEach(((l) => {
|
|
2119
2119
|
l.kind === "audio" && (this.options.userVariables.microphoneLabel = l.label), l.kind === "video" && (this.options.userVariables.cameraLabel = l.label), this.instance.addTrack(l, i);
|
|
2120
2120
|
})), this.instance.getTransceivers().forEach(((l) => {
|
|
2121
|
-
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);
|
|
2122
2122
|
}))) : this.instance.addStream(i);
|
|
2123
2123
|
s === !1 && Re(t, i);
|
|
2124
2124
|
} else if (this.options.receiveOnlyAudio && typeof this.instance.addTransceiver == "function") {
|
|
2125
2125
|
const o = this.instance.addTransceiver("audio", { direction: "recvonly" });
|
|
2126
2126
|
g.info("Added recvonly audio transceiver for receive-only mode", o);
|
|
2127
|
-
const { audioCodecs: r } =
|
|
2127
|
+
const { audioCodecs: r } = qt(this.options.preferred_codecs);
|
|
2128
2128
|
r.length > 0 && this._setCodecs(o, r);
|
|
2129
2129
|
}
|
|
2130
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();
|
|
@@ -2148,7 +2148,7 @@ class xe {
|
|
|
2148
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;
|
|
2149
2149
|
} catch (e) {
|
|
2150
2150
|
g.error("Peer _createOffer error:", e);
|
|
2151
|
-
const t =
|
|
2151
|
+
const t = W(ti, e);
|
|
2152
2152
|
L(T.Error, { error: t, sessionId: this._session.sessionid }, this.options.id);
|
|
2153
2153
|
}
|
|
2154
2154
|
}
|
|
@@ -2161,7 +2161,7 @@ class xe {
|
|
|
2161
2161
|
yield this.instance.setRemoteDescription(e);
|
|
2162
2162
|
} catch (t) {
|
|
2163
2163
|
g.error("Peer _setRemoteDescription error:", t);
|
|
2164
|
-
const i =
|
|
2164
|
+
const i = W(un, t);
|
|
2165
2165
|
throw L(T.Error, { error: i, sessionId: this._session.sessionid }, this.options.id), t;
|
|
2166
2166
|
}
|
|
2167
2167
|
}));
|
|
@@ -2176,7 +2176,7 @@ class xe {
|
|
|
2176
2176
|
return performance.mark("create-answer"), yield this._setLocalDescription(e), performance.mark("set-local-description"), performance.mark("ice-gathering-started"), e;
|
|
2177
2177
|
} catch (e) {
|
|
2178
2178
|
g.error("Peer _createAnswer error:", e);
|
|
2179
|
-
const t =
|
|
2179
|
+
const t = W(ni, e);
|
|
2180
2180
|
L(T.Error, { error: t, sessionId: this._session.sessionid }, this.options.id);
|
|
2181
2181
|
}
|
|
2182
2182
|
}
|
|
@@ -2188,7 +2188,7 @@ class xe {
|
|
|
2188
2188
|
yield this.instance.setLocalDescription(e);
|
|
2189
2189
|
} catch (t) {
|
|
2190
2190
|
g.error("Peer _setLocalDescription error:", t);
|
|
2191
|
-
const i =
|
|
2191
|
+
const i = W(ii, t);
|
|
2192
2192
|
throw L(T.Error, { error: i, sessionId: this._session.sessionid }, this.options.id), t;
|
|
2193
2193
|
}
|
|
2194
2194
|
}));
|
|
@@ -2201,11 +2201,11 @@ class xe {
|
|
|
2201
2201
|
if (me(this.options.localStream)) return this.options.localStream;
|
|
2202
2202
|
const e = yield (t = this.options, O(void 0, void 0, void 0, (function* () {
|
|
2203
2203
|
let { audio: i = !0, micId: s, video: o = !1, camId: r } = t;
|
|
2204
|
-
const { micLabel: c = "", camLabel:
|
|
2205
|
-
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 };
|
|
2206
2206
|
})));
|
|
2207
2207
|
var t;
|
|
2208
|
-
return
|
|
2208
|
+
return Je(e);
|
|
2209
2209
|
}));
|
|
2210
2210
|
}
|
|
2211
2211
|
_isOffer() {
|
|
@@ -2232,29 +2232,29 @@ class xe {
|
|
|
2232
2232
|
}));
|
|
2233
2233
|
}
|
|
2234
2234
|
}
|
|
2235
|
-
|
|
2236
|
-
const
|
|
2237
|
-
class
|
|
2235
|
+
De.ICE_GATHERING_SAFETY_TIMEOUT_MS = 15e3;
|
|
2236
|
+
const Be = wt;
|
|
2237
|
+
class On {
|
|
2238
2238
|
constructor(e, t) {
|
|
2239
|
-
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) => {
|
|
2240
2240
|
const w = m < 0 || !this._lastSerno || this._lastSerno && m === this._lastSerno + 1;
|
|
2241
2241
|
return w && m >= 0 && (this._lastSerno = m), w;
|
|
2242
2242
|
}, this._doStats = () => {
|
|
2243
2243
|
this.peer && this.peer.instance && this._statsBindings.length !== 0 && this.peer.instance.getStats().then(((m) => {
|
|
2244
2244
|
m.forEach(((w) => {
|
|
2245
|
-
this._statsBindings.forEach(((
|
|
2246
|
-
if (
|
|
2247
|
-
if (
|
|
2248
|
-
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;
|
|
2249
2249
|
}
|
|
2250
|
-
|
|
2250
|
+
x.callback(w);
|
|
2251
2251
|
}
|
|
2252
2252
|
}));
|
|
2253
2253
|
}));
|
|
2254
2254
|
}));
|
|
2255
2255
|
};
|
|
2256
|
-
const { iceServers: i, speaker: s, micId: o, micLabel: r, camId: c, camLabel:
|
|
2257
|
-
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"));
|
|
2258
2258
|
}
|
|
2259
2259
|
get creatingPeer() {
|
|
2260
2260
|
return this._creatingPeer;
|
|
@@ -2284,16 +2284,16 @@ class Rn {
|
|
|
2284
2284
|
return `conference-member.${this.id}`;
|
|
2285
2285
|
}
|
|
2286
2286
|
get isAudioMuted() {
|
|
2287
|
-
return !
|
|
2287
|
+
return !rs(this.options.localStream);
|
|
2288
2288
|
}
|
|
2289
2289
|
invite() {
|
|
2290
2290
|
return O(this, void 0, void 0, (function* () {
|
|
2291
|
-
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);
|
|
2292
2292
|
try {
|
|
2293
2293
|
yield this.peer.init();
|
|
2294
2294
|
} catch (e) {
|
|
2295
2295
|
g.error("Peer init failed, aborting call", e), this._creatingPeer = !1;
|
|
2296
|
-
const t = e instanceof
|
|
2296
|
+
const t = e instanceof Oe ? e : W(kt, e instanceof Error ? e : void 0);
|
|
2297
2297
|
return L(T.Error, { error: t, callId: this.id, sessionId: this.session.sessionid, recoverable: !1 }, this.session.uuid), void this.hangup({}, !1);
|
|
2298
2298
|
}
|
|
2299
2299
|
this._creatingPeer = !1;
|
|
@@ -2303,44 +2303,44 @@ class Rn {
|
|
|
2303
2303
|
var t, i;
|
|
2304
2304
|
return O(this, void 0, void 0, (function* () {
|
|
2305
2305
|
if (!((t = this.peer) === null || t === void 0) && t.instance && this.peer.instance.signalingState !== "closed") {
|
|
2306
|
-
const s = de(
|
|
2306
|
+
const s = de(ki);
|
|
2307
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
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
|
|
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);
|
|
2310
2310
|
try {
|
|
2311
2311
|
yield this.peer.init();
|
|
2312
2312
|
} catch (s) {
|
|
2313
2313
|
g.error("Peer init failed, aborting call", s), this._creatingPeer = !1;
|
|
2314
|
-
const o = s instanceof
|
|
2314
|
+
const o = s instanceof Oe ? s : W(kt, s instanceof Error ? s : void 0);
|
|
2315
2315
|
return L(T.Error, { error: o, callId: this.id, sessionId: this.session.sessionid, recoverable: !1 }, this.session.uuid), void (yield this.hangup());
|
|
2316
2316
|
}
|
|
2317
2317
|
this._creatingPeer = !1;
|
|
2318
2318
|
}));
|
|
2319
2319
|
}
|
|
2320
2320
|
playRingtone() {
|
|
2321
|
-
|
|
2321
|
+
Gt(this._ringtone);
|
|
2322
2322
|
}
|
|
2323
2323
|
stopRingtone() {
|
|
2324
|
-
|
|
2324
|
+
Vt(this._ringtone);
|
|
2325
2325
|
}
|
|
2326
2326
|
playRingback() {
|
|
2327
|
-
|
|
2327
|
+
Gt(this._ringback);
|
|
2328
2328
|
}
|
|
2329
2329
|
stopRingback() {
|
|
2330
|
-
|
|
2330
|
+
Vt(this._ringback);
|
|
2331
2331
|
}
|
|
2332
2332
|
hangup(e, t) {
|
|
2333
2333
|
var i, s, o, r;
|
|
2334
2334
|
return O(this, void 0, void 0, (function* () {
|
|
2335
|
-
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 };
|
|
2336
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();
|
|
2337
|
-
if (this.setState(U.Hangup), this.stopRingtone(), this.stopRingback(),
|
|
2338
|
-
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 });
|
|
2339
2339
|
try {
|
|
2340
2340
|
yield this._execute(f);
|
|
2341
2341
|
} catch (h) {
|
|
2342
2342
|
g.error("telnyx_rtc.bye failed!", h);
|
|
2343
|
-
const S =
|
|
2343
|
+
const S = W(ci, h);
|
|
2344
2344
|
L(T.Error, { error: S, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
2345
2345
|
}
|
|
2346
2346
|
}
|
|
@@ -2348,30 +2348,30 @@ class Rn {
|
|
|
2348
2348
|
}));
|
|
2349
2349
|
}
|
|
2350
2350
|
hold() {
|
|
2351
|
-
const e = new
|
|
2351
|
+
const e = new ct({ sessid: this.session.sessionid, action: "hold", dialogParams: this.options });
|
|
2352
2352
|
return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
|
|
2353
2353
|
}
|
|
2354
2354
|
unhold() {
|
|
2355
|
-
const e = new
|
|
2355
|
+
const e = new ct({ sessid: this.session.sessionid, action: "unhold", dialogParams: this.options });
|
|
2356
2356
|
return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
|
|
2357
2357
|
}
|
|
2358
2358
|
toggleHold() {
|
|
2359
|
-
const e = new
|
|
2359
|
+
const e = new ct({ sessid: this.session.sessionid, action: "toggleHold", dialogParams: this.options });
|
|
2360
2360
|
return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
|
|
2361
2361
|
}
|
|
2362
2362
|
dtmf(e) {
|
|
2363
|
-
const t = new
|
|
2363
|
+
const t = new jt({ sessid: this.session.sessionid, dtmf: e, dialogParams: this.options });
|
|
2364
2364
|
this._execute(t);
|
|
2365
2365
|
}
|
|
2366
2366
|
message(e, t) {
|
|
2367
|
-
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 });
|
|
2368
2368
|
this._execute(s);
|
|
2369
2369
|
}
|
|
2370
2370
|
muteAudio() {
|
|
2371
|
-
|
|
2371
|
+
ft(this.options.localStream);
|
|
2372
2372
|
}
|
|
2373
2373
|
unmuteAudio() {
|
|
2374
|
-
|
|
2374
|
+
Ht(this.options.localStream);
|
|
2375
2375
|
}
|
|
2376
2376
|
toggleAudioMute() {
|
|
2377
2377
|
$t(this.options.localStream);
|
|
@@ -2383,15 +2383,15 @@ class Rn {
|
|
|
2383
2383
|
if (o) {
|
|
2384
2384
|
let r;
|
|
2385
2385
|
try {
|
|
2386
|
-
r = yield
|
|
2386
|
+
r = yield Ye({ audio: { deviceId: { exact: e } } });
|
|
2387
2387
|
} catch (l) {
|
|
2388
|
-
const f =
|
|
2388
|
+
const f = W(Le(l), l);
|
|
2389
2389
|
return void L(T.MediaError, f, ((i = this.options) === null || i === void 0 ? void 0 : i.id) || this.id);
|
|
2390
2390
|
}
|
|
2391
2391
|
const c = r.getAudioTracks()[0];
|
|
2392
2392
|
c.enabled = !t, o.replaceTrack(c), this.options.micId = e;
|
|
2393
|
-
const { localStream:
|
|
2394
|
-
|
|
2393
|
+
const { localStream: d } = this.options;
|
|
2394
|
+
d.getAudioTracks().forEach(((l) => l.stop())), d.getVideoTracks().forEach(((l) => r.addTrack(l))), this.options.localStream = r;
|
|
2395
2395
|
}
|
|
2396
2396
|
}));
|
|
2397
2397
|
}
|
|
@@ -2411,18 +2411,18 @@ class Rn {
|
|
|
2411
2411
|
return O(this, void 0, void 0, (function* () {
|
|
2412
2412
|
const { instance: t } = this.peer, i = t.getSenders().find((({ track: { kind: s } }) => s === "video"));
|
|
2413
2413
|
if (i) {
|
|
2414
|
-
const s = yield
|
|
2414
|
+
const s = yield Ye({ video: { deviceId: { exact: e } } }), o = s.getVideoTracks()[0];
|
|
2415
2415
|
i.replaceTrack(o);
|
|
2416
2416
|
const { localElement: r, localStream: c } = this.options;
|
|
2417
|
-
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;
|
|
2418
2418
|
}
|
|
2419
2419
|
}));
|
|
2420
2420
|
}
|
|
2421
2421
|
deaf() {
|
|
2422
|
-
|
|
2422
|
+
ft(this.options.remoteStream);
|
|
2423
2423
|
}
|
|
2424
2424
|
undeaf() {
|
|
2425
|
-
|
|
2425
|
+
Ht(this.options.remoteStream);
|
|
2426
2426
|
}
|
|
2427
2427
|
toggleDeaf() {
|
|
2428
2428
|
$t(this.options.remoteStream);
|
|
@@ -2461,7 +2461,7 @@ class Rn {
|
|
|
2461
2461
|
case U.Active:
|
|
2462
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((() => {
|
|
2463
2463
|
const { remoteElement: s, speakerId: o } = this.options;
|
|
2464
|
-
s && o &&
|
|
2464
|
+
s && o && kn(s, o);
|
|
2465
2465
|
}), 0), this._callReportCollector && (!((i = this.peer) === null || i === void 0) && i.instance) && this.session.callReportId && this._callReportCollector.start(this.peer.instance);
|
|
2466
2466
|
break;
|
|
2467
2467
|
case U.Destroy:
|
|
@@ -2471,34 +2471,34 @@ class Rn {
|
|
|
2471
2471
|
handleMessage(e) {
|
|
2472
2472
|
const { method: t, params: i } = e;
|
|
2473
2473
|
switch (t) {
|
|
2474
|
-
case
|
|
2474
|
+
case H.Answer:
|
|
2475
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;
|
|
2476
2476
|
this._state >= U.Early && this.setState(U.Active), this.gotEarly || this._onRemoteSdp(i.sdp), this.stopRingback(), this.stopRingtone();
|
|
2477
2477
|
break;
|
|
2478
|
-
case
|
|
2478
|
+
case H.Media:
|
|
2479
2479
|
if (performance.mark("telnyx-rtc-media"), this._state >= U.Early) return;
|
|
2480
2480
|
this.gotEarly = !0, this._onRemoteSdp(i.sdp);
|
|
2481
2481
|
break;
|
|
2482
|
-
case
|
|
2482
|
+
case H.Display: {
|
|
2483
2483
|
const { display_name: o, display_number: r, display_direction: c } = i;
|
|
2484
2484
|
this.extension = r;
|
|
2485
|
-
const
|
|
2485
|
+
const d = c === ce.Inbound ? ce.Outbound : ce.Inbound, l = { type: re[t], call: this, displayName: o, displayNumber: r, displayDirection: d };
|
|
2486
2486
|
L(T.Notification, l, this.id) || L(T.Notification, l, this.session.uuid);
|
|
2487
2487
|
break;
|
|
2488
2488
|
}
|
|
2489
|
-
case
|
|
2489
|
+
case H.Candidate:
|
|
2490
2490
|
this._addIceCandidate(i);
|
|
2491
2491
|
break;
|
|
2492
|
-
case
|
|
2493
|
-
case
|
|
2492
|
+
case H.Info:
|
|
2493
|
+
case H.Event: {
|
|
2494
2494
|
const o = Object.assign(Object.assign({}, i), { type: re.generic, call: this });
|
|
2495
2495
|
L(T.Notification, o, this.id) || L(T.Notification, o, this.session.uuid);
|
|
2496
2496
|
break;
|
|
2497
2497
|
}
|
|
2498
|
-
case
|
|
2498
|
+
case H.Ringing:
|
|
2499
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);
|
|
2500
2500
|
break;
|
|
2501
|
-
case
|
|
2501
|
+
case H.Bye:
|
|
2502
2502
|
const s = i.client_state || i.clientState;
|
|
2503
2503
|
s && (this.options.clientState = s), this.stopRingback(), this.stopRingtone(), this.hangup(i, !1);
|
|
2504
2504
|
}
|
|
@@ -2510,21 +2510,21 @@ class Rn {
|
|
|
2510
2510
|
switch (i) {
|
|
2511
2511
|
case "bootObj": {
|
|
2512
2512
|
this._lastSerno = 0;
|
|
2513
|
-
const { chatChannel: c, infoChannel:
|
|
2514
|
-
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));
|
|
2515
2515
|
const y = [];
|
|
2516
|
-
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])));
|
|
2517
2517
|
this._dispatchConferenceUpdate({ action: oe.Bootstrap, participants: y });
|
|
2518
2518
|
break;
|
|
2519
2519
|
}
|
|
2520
2520
|
case "add":
|
|
2521
|
-
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)));
|
|
2522
2522
|
break;
|
|
2523
2523
|
case "modify":
|
|
2524
|
-
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)));
|
|
2525
2525
|
break;
|
|
2526
2526
|
case "del":
|
|
2527
|
-
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)));
|
|
2528
2528
|
break;
|
|
2529
2529
|
case "clear":
|
|
2530
2530
|
this._dispatchConferenceUpdate({ action: oe.Clear });
|
|
@@ -2542,12 +2542,12 @@ class Rn {
|
|
|
2542
2542
|
_subscribeConferenceChat(e) {
|
|
2543
2543
|
return O(this, void 0, void 0, (function* () {
|
|
2544
2544
|
const t = { nodeId: this.nodeId, channels: [e], handler: (s) => {
|
|
2545
|
-
const { direction: o, from: r, fromDisplay: c, message:
|
|
2546
|
-
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 });
|
|
2547
2547
|
} }, i = yield this.session.vertoSubscribe(t).catch(((s) => {
|
|
2548
2548
|
g.error("ConfChat subscription error:", s);
|
|
2549
2549
|
}));
|
|
2550
|
-
|
|
2550
|
+
ht(i, e) && (this._addChannel(e), Object.defineProperties(this, { sendChatMessage: { configurable: !0, value: (s, o) => {
|
|
2551
2551
|
this.session.vertoBroadcast({ nodeId: this.nodeId, channel: e, data: { action: "send", message: s, type: o } });
|
|
2552
2552
|
} } }));
|
|
2553
2553
|
}));
|
|
@@ -2556,11 +2556,11 @@ class Rn {
|
|
|
2556
2556
|
return O(this, void 0, void 0, (function* () {
|
|
2557
2557
|
const t = { nodeId: this.nodeId, channels: [e], handler: (s) => {
|
|
2558
2558
|
const { eventData: o } = s;
|
|
2559
|
-
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);
|
|
2560
2560
|
} }, i = yield this.session.vertoSubscribe(t).catch(((s) => {
|
|
2561
2561
|
g.error("ConfInfo subscription error:", s);
|
|
2562
2562
|
}));
|
|
2563
|
-
|
|
2563
|
+
ht(i, e) && this._addChannel(e);
|
|
2564
2564
|
}));
|
|
2565
2565
|
}
|
|
2566
2566
|
_confControl(e, t = {}) {
|
|
@@ -2572,7 +2572,7 @@ class Rn {
|
|
|
2572
2572
|
}
|
|
2573
2573
|
_handleChangeHoldStateError(e) {
|
|
2574
2574
|
g.error(`Failed to ${e.action} on call ${this.id}`);
|
|
2575
|
-
const t =
|
|
2575
|
+
const t = W(ri, e);
|
|
2576
2576
|
return L(T.Error, { error: t, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid), !1;
|
|
2577
2577
|
}
|
|
2578
2578
|
_onRemoteSdp(e) {
|
|
@@ -2582,7 +2582,7 @@ class Rn {
|
|
|
2582
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);
|
|
2583
2583
|
})).catch(((i) => O(this, void 0, void 0, (function* () {
|
|
2584
2584
|
g.error("Call setRemoteDescription Error: ", i);
|
|
2585
|
-
const s =
|
|
2585
|
+
const s = W(un, i);
|
|
2586
2586
|
L(T.Error, { error: s, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
2587
2587
|
try {
|
|
2588
2588
|
yield this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
|
|
@@ -2601,29 +2601,29 @@ class Rn {
|
|
|
2601
2601
|
const { sdp: s, type: o } = e;
|
|
2602
2602
|
if (s.indexOf("candidate") === -1) return g.info(`No candidate - retry
|
|
2603
2603
|
`), void this._requestAnotherLocalDescription();
|
|
2604
|
-
if ((i = (t = this.peer) === null || t === void 0 ? void 0 : t.instance) === null || i === void 0 || i.removeEventListener("icecandidate", this._onIce), !
|
|
2605
|
-
const
|
|
2606
|
-
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);
|
|
2607
2607
|
}
|
|
2608
2608
|
performance.mark("ice-gathering-end");
|
|
2609
2609
|
let r = null;
|
|
2610
|
-
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}` };
|
|
2611
2611
|
switch (o) {
|
|
2612
2612
|
case z.Offer:
|
|
2613
|
-
this.setState(U.Requesting), r = new
|
|
2613
|
+
this.setState(U.Requesting), r = new Mt(c);
|
|
2614
2614
|
break;
|
|
2615
2615
|
case z.Answer:
|
|
2616
|
-
this._isRecovering || this.setState(U.Answering), r = this.options.attach === !0 ? new
|
|
2616
|
+
this._isRecovering || this.setState(U.Answering), r = this.options.attach === !0 ? new Ft(c) : new Ut(c);
|
|
2617
2617
|
break;
|
|
2618
2618
|
default:
|
|
2619
2619
|
return g.error(`${this.id} - Unknown local SDP type:`, e), void this.hangup({}, !1);
|
|
2620
2620
|
}
|
|
2621
|
-
performance.mark("send-sdp"), this._execute(r).then(((
|
|
2622
|
-
const { node_id: l = null } =
|
|
2621
|
+
performance.mark("send-sdp"), this._execute(r).then(((d) => {
|
|
2622
|
+
const { node_id: l = null } = d;
|
|
2623
2623
|
this._targetNodeId = l, o === z.Offer ? this.setState(U.Trying) : this.setState(U.Active);
|
|
2624
|
-
})).catch(((
|
|
2625
|
-
g.error(`${this.id} - Sending ${o} error:`,
|
|
2626
|
-
const l =
|
|
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);
|
|
2627
2627
|
L(T.Error, { error: l, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
2628
2628
|
try {
|
|
2629
2629
|
yield this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
|
|
@@ -2636,13 +2636,13 @@ class Rn {
|
|
|
2636
2636
|
if (!e) return g.error("No SDP data provided"), void this.hangup({}, !1);
|
|
2637
2637
|
const { sdp: t, type: i } = e;
|
|
2638
2638
|
let s = null;
|
|
2639
|
-
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}` };
|
|
2640
2640
|
switch (i) {
|
|
2641
2641
|
case z.Offer:
|
|
2642
|
-
this.setState(U.Requesting), s = new
|
|
2642
|
+
this.setState(U.Requesting), s = new Mt(o);
|
|
2643
2643
|
break;
|
|
2644
2644
|
case z.Answer:
|
|
2645
|
-
this._isRecovering || this.setState(U.Answering), s = this.options.attach === !0 ? new
|
|
2645
|
+
this._isRecovering || this.setState(U.Answering), s = this.options.attach === !0 ? new Ft(o) : new Ut(o);
|
|
2646
2646
|
break;
|
|
2647
2647
|
default:
|
|
2648
2648
|
return g.error(`${this.id} - Unknown local SDP type:`, e), void this.hangup({}, !1);
|
|
@@ -2652,12 +2652,12 @@ class Rn {
|
|
|
2652
2652
|
this._targetNodeId = c, i === z.Offer ? this.setState(U.Trying) : this.setState(U.Active);
|
|
2653
2653
|
})).catch(((r) => O(this, void 0, void 0, (function* () {
|
|
2654
2654
|
g.error(`${this.id} - Sending ${i} error:`, r);
|
|
2655
|
-
const c =
|
|
2655
|
+
const c = W(Tt, r);
|
|
2656
2656
|
L(T.Error, { error: c, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
2657
2657
|
try {
|
|
2658
2658
|
yield this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
|
|
2659
|
-
} catch (
|
|
2660
|
-
g.error("Error during hangup after SDP send failure:",
|
|
2659
|
+
} catch (d) {
|
|
2660
|
+
g.error("Error during hangup after SDP send failure:", d);
|
|
2661
2661
|
}
|
|
2662
2662
|
}))));
|
|
2663
2663
|
}
|
|
@@ -2675,7 +2675,7 @@ class Rn {
|
|
|
2675
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();
|
|
2676
2676
|
}
|
|
2677
2677
|
_sendIceCandidate(e) {
|
|
2678
|
-
const t = new
|
|
2678
|
+
const t = new Qi({ sessid: this.session.sessionid, candidate: e.candidate, sdpMLineIndex: e.sdpMLineIndex, sdpMid: e.sdpMid, dialogParams: this.options });
|
|
2679
2679
|
this._execute(t);
|
|
2680
2680
|
}
|
|
2681
2681
|
_addIceCandidate(e) {
|
|
@@ -2691,7 +2691,7 @@ class Rn {
|
|
|
2691
2691
|
}));
|
|
2692
2692
|
}
|
|
2693
2693
|
_sendEndOfCandidates() {
|
|
2694
|
-
const e = new
|
|
2694
|
+
const e = new Zi({ sessid: this.session.sessionid, endOfCandidates: !0, dialogParams: this.options });
|
|
2695
2695
|
this._execute(e);
|
|
2696
2696
|
}
|
|
2697
2697
|
_trackCandidateMarks(e) {
|
|
@@ -2719,7 +2719,7 @@ class Rn {
|
|
|
2719
2719
|
}, e.onicecandidateerror = (t) => {
|
|
2720
2720
|
var i;
|
|
2721
2721
|
if (g.debug("ICE candidate error:", t), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
|
|
2722
|
-
const s =
|
|
2722
|
+
const s = Yt(t, e);
|
|
2723
2723
|
this.peer.statsReporter.reportIceCandidateError(s);
|
|
2724
2724
|
}
|
|
2725
2725
|
}, e.addEventListener("addstream", ((t) => {
|
|
@@ -2738,7 +2738,7 @@ class Rn {
|
|
|
2738
2738
|
}, e.onicecandidateerror = (t) => {
|
|
2739
2739
|
var i;
|
|
2740
2740
|
if (g.debug("ICE candidate error:", t), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
|
|
2741
|
-
const s =
|
|
2741
|
+
const s = Yt(t, e);
|
|
2742
2742
|
this.peer.statsReporter.reportIceCandidateError(s);
|
|
2743
2743
|
}
|
|
2744
2744
|
}, e.addEventListener("addstream", ((t) => {
|
|
@@ -2771,8 +2771,8 @@ class Rn {
|
|
|
2771
2771
|
_init() {
|
|
2772
2772
|
var e, t;
|
|
2773
2773
|
const { id: i, userVariables: s, remoteCallerNumber: o, onNotification: r, recoveredCallId: c } = this.options;
|
|
2774
|
-
var
|
|
2775
|
-
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);
|
|
2776
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;
|
|
2777
2777
|
l && (this._callReportCollector = new J({ enabled: !0, interval: f }, { enabled: !0, level: h, maxEntries: S }), this._callReportCollector.onFlushNeeded = () => {
|
|
2778
2778
|
this._flushIntermediateReport();
|
|
@@ -2795,7 +2795,7 @@ class Rn {
|
|
|
2795
2795
|
if (!t) return void g.debug("Cannot flush intermediate report: call_report_id not available");
|
|
2796
2796
|
const i = (e = this.session.connection) === null || e === void 0 ? void 0 : e.host;
|
|
2797
2797
|
if (!i) return void g.debug("Cannot flush intermediate report: connection host not available");
|
|
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:
|
|
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);
|
|
2799
2799
|
if (!o) return;
|
|
2800
2800
|
const r = fe() || void 0;
|
|
2801
2801
|
this._callReportCollector.sendPayload(o, t, i, r).catch(((c) => {
|
|
@@ -2809,7 +2809,7 @@ class Rn {
|
|
|
2809
2809
|
yield this._callReportCollector.stop();
|
|
2810
2810
|
const t = this.session.callReportId;
|
|
2811
2811
|
if (!t) return g.debug("Cannot post call report: call_report_id not available"), void this._callReportCollector.cleanup();
|
|
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:
|
|
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;
|
|
2813
2813
|
if (!s) return void g.error("Cannot post call report: connection host not available");
|
|
2814
2814
|
const o = fe() || void 0;
|
|
2815
2815
|
this._callReportCollector.postReport(i, t, s, o).catch(((r) => {
|
|
@@ -2827,7 +2827,7 @@ class Rn {
|
|
|
2827
2827
|
this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null), g.debug("Stats stopped");
|
|
2828
2828
|
}
|
|
2829
2829
|
}
|
|
2830
|
-
|
|
2830
|
+
On.setStateTelnyx = (n) => {
|
|
2831
2831
|
if (n) {
|
|
2832
2832
|
switch (n._state) {
|
|
2833
2833
|
case U.Recovering:
|
|
@@ -2857,9 +2857,9 @@ Rn.setStateTelnyx = (n) => {
|
|
|
2857
2857
|
return n;
|
|
2858
2858
|
}
|
|
2859
2859
|
};
|
|
2860
|
-
class ge extends
|
|
2860
|
+
class ge extends On {
|
|
2861
2861
|
constructor() {
|
|
2862
|
-
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));
|
|
2863
2863
|
}
|
|
2864
2864
|
hangup(e = {}, t = !0) {
|
|
2865
2865
|
const i = Object.create(null, { hangup: { get: () => super.hangup } });
|
|
@@ -2876,8 +2876,8 @@ class ge extends Rn {
|
|
|
2876
2876
|
this.screenShare && (yield this.screenShare.hangup());
|
|
2877
2877
|
}))));
|
|
2878
2878
|
}));
|
|
2879
|
-
const { remoteCallerName: s, remoteCallerNumber: o, callerName: r, callerNumber: c } = this.options,
|
|
2880
|
-
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;
|
|
2881
2881
|
}));
|
|
2882
2882
|
}
|
|
2883
2883
|
stopScreenShare() {
|
|
@@ -2889,7 +2889,7 @@ class ge extends Rn {
|
|
|
2889
2889
|
return O(this, void 0, void 0, (function* () {
|
|
2890
2890
|
this.options.speakerId = e;
|
|
2891
2891
|
const { remoteElement: t, speakerId: i } = this.options;
|
|
2892
|
-
return !(!t || !i) &&
|
|
2892
|
+
return !(!t || !i) && kn(t, i);
|
|
2893
2893
|
}));
|
|
2894
2894
|
}
|
|
2895
2895
|
_finalize() {
|
|
@@ -2912,7 +2912,7 @@ ${r.type}
|
|
|
2912
2912
|
}))), 2e3);
|
|
2913
2913
|
}
|
|
2914
2914
|
}
|
|
2915
|
-
class
|
|
2915
|
+
class _s extends xe {
|
|
2916
2916
|
constructor(e) {
|
|
2917
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();
|
|
2918
2918
|
}
|
|
@@ -2934,7 +2934,7 @@ class vs extends Le {
|
|
|
2934
2934
|
checkPermissions(e = !0, t = !0) {
|
|
2935
2935
|
return O(this, void 0, void 0, (function* () {
|
|
2936
2936
|
try {
|
|
2937
|
-
const i = yield
|
|
2937
|
+
const i = yield Je({ audio: e, video: t });
|
|
2938
2938
|
return Ne(i), !0;
|
|
2939
2939
|
} catch {
|
|
2940
2940
|
return !1;
|
|
@@ -2974,9 +2974,9 @@ class vs extends Le {
|
|
|
2974
2974
|
}
|
|
2975
2975
|
speedTest(e) {
|
|
2976
2976
|
return new Promise(((t, i) => {
|
|
2977
|
-
if (
|
|
2978
|
-
const { upDur: c, downDur:
|
|
2979
|
-
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) });
|
|
2980
2980
|
}), this.uuid), !(e = Number(e))) return i(`Invalid parameter 'bytes': ${e}`);
|
|
2981
2981
|
this.executeRaw(`#SPU ${e}`);
|
|
2982
2982
|
let s = e / 1024;
|
|
@@ -2988,7 +2988,7 @@ class vs extends Le {
|
|
|
2988
2988
|
}
|
|
2989
2989
|
getDevices() {
|
|
2990
2990
|
return Te().catch(((e) => {
|
|
2991
|
-
const t =
|
|
2991
|
+
const t = W(Le(e), e);
|
|
2992
2992
|
return L(T.MediaError, t, this.uuid), [];
|
|
2993
2993
|
}));
|
|
2994
2994
|
}
|
|
@@ -2997,7 +2997,7 @@ class vs extends Le {
|
|
|
2997
2997
|
}
|
|
2998
2998
|
getAudioInDevices() {
|
|
2999
2999
|
return Te(le.AudioIn).catch(((e) => {
|
|
3000
|
-
const t =
|
|
3000
|
+
const t = W(Le(e), e);
|
|
3001
3001
|
return L(T.MediaError, t, this.uuid), [];
|
|
3002
3002
|
}));
|
|
3003
3003
|
}
|
|
@@ -3005,16 +3005,16 @@ class vs extends Le {
|
|
|
3005
3005
|
return Te(le.AudioOut).catch(((e) => (g.error("getAudioOutDevices", e), L(T.MediaError, e, this.uuid), [])));
|
|
3006
3006
|
}
|
|
3007
3007
|
validateDeviceId(e, t, i) {
|
|
3008
|
-
return
|
|
3008
|
+
return Ke(e, t, i);
|
|
3009
3009
|
}
|
|
3010
3010
|
getDeviceResolutions(e) {
|
|
3011
3011
|
return O(this, void 0, void 0, (function* () {
|
|
3012
3012
|
try {
|
|
3013
3013
|
return yield ((t) => O(void 0, void 0, void 0, (function* () {
|
|
3014
|
-
const i = [], s = yield
|
|
3015
|
-
for (let r = 0; r <
|
|
3016
|
-
const [c,
|
|
3017
|
-
(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 });
|
|
3018
3018
|
}
|
|
3019
3019
|
return Ne(s), i;
|
|
3020
3020
|
})))(e);
|
|
@@ -3030,13 +3030,13 @@ class vs extends Le {
|
|
|
3030
3030
|
return O(this, void 0, void 0, (function* () {
|
|
3031
3031
|
if (!e) throw new Error("You need to provide the settings object");
|
|
3032
3032
|
const { micId: t, micLabel: i } = e, s = We(e, ["micId", "micLabel"]);
|
|
3033
|
-
return
|
|
3034
|
-
const { deviceId: l } =
|
|
3033
|
+
return os(s), this._audioConstraints = yield ((o, r, c, d) => O(void 0, void 0, void 0, (function* () {
|
|
3034
|
+
const { deviceId: l } = d;
|
|
3035
3035
|
if (l === void 0 && (o || r)) {
|
|
3036
|
-
const f = yield
|
|
3037
|
-
f && (
|
|
3036
|
+
const f = yield Ke(o, r, c).catch(((h) => null));
|
|
3037
|
+
f && (d.deviceId = { exact: f });
|
|
3038
3038
|
}
|
|
3039
|
-
return
|
|
3039
|
+
return d;
|
|
3040
3040
|
})))(t, i, "audioinput", s), this.micId = t, this.micLabel = i, this._audioConstraints;
|
|
3041
3041
|
}));
|
|
3042
3042
|
}
|
|
@@ -3050,7 +3050,7 @@ class vs extends Le {
|
|
|
3050
3050
|
if (e && Array.isArray(e)) this._iceServers = e;
|
|
3051
3051
|
else {
|
|
3052
3052
|
const t = this.options.env === "development";
|
|
3053
|
-
this._iceServers = t ?
|
|
3053
|
+
this._iceServers = t ? Ni : xi;
|
|
3054
3054
|
}
|
|
3055
3055
|
}
|
|
3056
3056
|
get iceServers() {
|
|
@@ -3063,37 +3063,37 @@ class vs extends Le {
|
|
|
3063
3063
|
return this._speaker;
|
|
3064
3064
|
}
|
|
3065
3065
|
set localElement(e) {
|
|
3066
|
-
this._localElement =
|
|
3066
|
+
this._localElement = Ve(e);
|
|
3067
3067
|
}
|
|
3068
3068
|
get localElement() {
|
|
3069
3069
|
return this._localElement;
|
|
3070
3070
|
}
|
|
3071
3071
|
set remoteElement(e) {
|
|
3072
|
-
this._remoteElement =
|
|
3072
|
+
this._remoteElement = Ve(e);
|
|
3073
3073
|
}
|
|
3074
3074
|
get remoteElement() {
|
|
3075
3075
|
return this._remoteElement;
|
|
3076
3076
|
}
|
|
3077
3077
|
vertoBroadcast({ nodeId: e, channel: t = "", data: i }) {
|
|
3078
3078
|
if (!t) throw new Error(`Invalid channel for broadcast: ${t}`);
|
|
3079
|
-
const s = new
|
|
3079
|
+
const s = new es({ sessid: this.sessionid, eventChannel: t, data: i });
|
|
3080
3080
|
e && (s.targetNodeId = e), this.execute(s).catch(((o) => o));
|
|
3081
3081
|
}
|
|
3082
3082
|
vertoSubscribe({ nodeId: e, channels: t = [], handler: i }) {
|
|
3083
3083
|
return O(this, void 0, void 0, (function* () {
|
|
3084
|
-
if (!(t = t.filter(((
|
|
3085
|
-
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 });
|
|
3086
3086
|
e && (s.targetNodeId = e);
|
|
3087
|
-
const o = yield this.execute(s), { unauthorized: r = [], subscribed: c = [] } =
|
|
3088
|
-
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;
|
|
3089
3089
|
}));
|
|
3090
3090
|
}
|
|
3091
3091
|
vertoUnsubscribe({ nodeId: e, channels: t = [] }) {
|
|
3092
3092
|
return O(this, void 0, void 0, (function* () {
|
|
3093
3093
|
if (!(t = t.filter(((c) => c && this._existsSubscription(this.relayProtocol, c)))).length) return {};
|
|
3094
|
-
const i = new
|
|
3094
|
+
const i = new ns({ sessid: this.sessionid, eventChannel: t });
|
|
3095
3095
|
e && (i.targetNodeId = e);
|
|
3096
|
-
const s = yield this.execute(i), { unsubscribed: o = [], notSubscribed: r = [] } =
|
|
3096
|
+
const s = yield this.execute(i), { unsubscribed: o = [], notSubscribed: r = [] } = pt(s);
|
|
3097
3097
|
return o.forEach(((c) => this._removeSubscription(this.relayProtocol, c))), r.forEach(((c) => this._removeSubscription(this.relayProtocol, c))), s;
|
|
3098
3098
|
}));
|
|
3099
3099
|
}
|
|
@@ -3102,7 +3102,7 @@ class vs extends Le {
|
|
|
3102
3102
|
this._wasOffline && (g.debug(`Network connectivity restored for session ${this.sessionid}. Reconnecting...`), this._wasOffline = !1, this._autoReconnect = !0, this.socketDisconnect());
|
|
3103
3103
|
}, this._offlineHandler = () => {
|
|
3104
3104
|
this._wasOffline = !0, g.debug(`Network connectivity lost for session ${this.sessionid}`);
|
|
3105
|
-
const e =
|
|
3105
|
+
const e = W(vi);
|
|
3106
3106
|
L(T.Error, { error: e, sessionId: this.sessionid }, this.uuid);
|
|
3107
3107
|
}, window.addEventListener("online", this._onlineHandler), window.addEventListener("offline", this._offlineHandler));
|
|
3108
3108
|
}
|
|
@@ -3113,83 +3113,83 @@ class vs extends Le {
|
|
|
3113
3113
|
return ge.setStateTelnyx(e);
|
|
3114
3114
|
}
|
|
3115
3115
|
}
|
|
3116
|
-
class
|
|
3116
|
+
class Xt {
|
|
3117
3117
|
constructor(e, t) {
|
|
3118
3118
|
this.code = t, this.message = e;
|
|
3119
3119
|
}
|
|
3120
3120
|
}
|
|
3121
|
-
class
|
|
3121
|
+
class ys {
|
|
3122
3122
|
constructor(e) {
|
|
3123
3123
|
this.session = e, this.retriedConnect = 0, this.retriedRegister = 0;
|
|
3124
3124
|
}
|
|
3125
3125
|
_ack(e, t) {
|
|
3126
|
-
const i = new
|
|
3126
|
+
const i = new Xi(e, t);
|
|
3127
3127
|
this.nodeId && (i.targetNodeId = this.nodeId), this.session.execute(i);
|
|
3128
3128
|
}
|
|
3129
3129
|
reconnectDelay() {
|
|
3130
|
-
return 1e3 *
|
|
3130
|
+
return 1e3 * Sn(2, 6);
|
|
3131
3131
|
}
|
|
3132
3132
|
handleMessage(e) {
|
|
3133
|
-
var t, i, s, o, r, c,
|
|
3133
|
+
var t, i, s, o, r, c, d, l, f;
|
|
3134
3134
|
const { session: h } = this;
|
|
3135
3135
|
h.setPingReceived();
|
|
3136
|
-
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();
|
|
3137
3137
|
if (Array.isArray(v?.reattached_sessions) && v.reattached_sessions.length === 0 && Object.keys(h.calls).length > 0) {
|
|
3138
|
-
const R = de(
|
|
3138
|
+
const R = de(Ai);
|
|
3139
3139
|
L(T.Warning, { warning: R, sessionId: h.sessionid }, h.uuid);
|
|
3140
3140
|
}
|
|
3141
|
-
if (
|
|
3141
|
+
if (x === "channelPvtData") return this._handlePvtEvent(v.pvtData);
|
|
3142
3142
|
const M = (R) => {
|
|
3143
|
-
var a,
|
|
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 ===
|
|
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 };
|
|
3145
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");
|
|
3146
|
-
const
|
|
3147
|
-
return
|
|
3148
|
-
}, 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);
|
|
3149
3149
|
switch (y) {
|
|
3150
|
-
case
|
|
3151
|
-
case
|
|
3152
|
-
case
|
|
3153
|
-
case
|
|
3154
|
-
case
|
|
3155
|
-
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:
|
|
3156
3156
|
if (!m || !A) return void g.error(`Received ${y} for non existing call:`, v);
|
|
3157
3157
|
A.handleMessage(e), this._ack(S, y);
|
|
3158
3158
|
break;
|
|
3159
|
-
case
|
|
3159
|
+
case H.Ping:
|
|
3160
3160
|
this.session.setPingReceived(), this.session.execute(F);
|
|
3161
3161
|
break;
|
|
3162
|
-
case
|
|
3162
|
+
case H.Punt:
|
|
3163
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());
|
|
3164
3164
|
break;
|
|
3165
|
-
case
|
|
3166
|
-
const
|
|
3167
|
-
|
|
3165
|
+
case H.Invite: {
|
|
3166
|
+
const u = M();
|
|
3167
|
+
u.direction = ce.Inbound, u.playRingtone(), u.setState(U.Ringing), this._ack(S, y);
|
|
3168
3168
|
break;
|
|
3169
3169
|
}
|
|
3170
|
-
case
|
|
3170
|
+
case H.Attach: {
|
|
3171
3171
|
if (!A)
|
|
3172
3172
|
return M().answer(), void this._ack(S, y);
|
|
3173
|
-
const
|
|
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: ${
|
|
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);
|
|
3175
3175
|
break;
|
|
3176
3176
|
}
|
|
3177
|
-
case
|
|
3177
|
+
case H.Event:
|
|
3178
3178
|
case "webrtc.event":
|
|
3179
3179
|
if (!w) return void g.error("Verto received an unknown event:", v);
|
|
3180
3180
|
const R = h.relayProtocol, a = w.split(".")[0];
|
|
3181
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);
|
|
3182
3182
|
break;
|
|
3183
|
-
case
|
|
3183
|
+
case H.Info:
|
|
3184
3184
|
v.type = re.generic, L(T.Notification, v, h.uuid);
|
|
3185
3185
|
break;
|
|
3186
|
-
case
|
|
3186
|
+
case H.ClientReady:
|
|
3187
3187
|
this.session.execute(q);
|
|
3188
3188
|
break;
|
|
3189
3189
|
default: {
|
|
3190
|
-
const
|
|
3191
|
-
if (
|
|
3192
|
-
switch (
|
|
3190
|
+
const u = bt(e);
|
|
3191
|
+
if (u) {
|
|
3192
|
+
switch (u) {
|
|
3193
3193
|
case ne.REGISTER:
|
|
3194
3194
|
case ne.REGED:
|
|
3195
3195
|
if (h.connection.previousGatewayState !== ne.REGED && h.connection.previousGatewayState !== ne.REGISTER) {
|
|
@@ -3198,7 +3198,7 @@ class ms {
|
|
|
3198
3198
|
p && (h.callReportId = p, g.debug("Captured call_report_id from REGED:", p));
|
|
3199
3199
|
const _ = (r = (o = e?.result) === null || o === void 0 ? void 0 : o.params) === null || r === void 0 ? void 0 : r.dc;
|
|
3200
3200
|
_ && (h.dc = _);
|
|
3201
|
-
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;
|
|
3202
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);
|
|
3203
3203
|
}
|
|
3204
3204
|
break;
|
|
@@ -3206,7 +3206,7 @@ class ms {
|
|
|
3206
3206
|
case ne.NOREG:
|
|
3207
3207
|
if (this.retriedRegister += 1, this.retriedRegister === 5) {
|
|
3208
3208
|
this.retriedRegister = 0;
|
|
3209
|
-
const p = new
|
|
3209
|
+
const p = new Xt("Fail to register the user, the server tried 5 times", "UNREGED|NOREG"), _ = W(pn, p);
|
|
3210
3210
|
L(T.Error, { error: _, sessionId: h.sessionid }, h.uuid);
|
|
3211
3211
|
break;
|
|
3212
3212
|
}
|
|
@@ -3217,16 +3217,16 @@ class ms {
|
|
|
3217
3217
|
case ne.FAILED:
|
|
3218
3218
|
case ne.FAIL_WAIT:
|
|
3219
3219
|
if (h.connection.previousGatewayState !== ne.FAILED && h.connection.previousGatewayState !== ne.FAIL_WAIT) {
|
|
3220
|
-
const p =
|
|
3220
|
+
const p = W(pi, new Error(`Gateway state: ${u}`));
|
|
3221
3221
|
if (L(T.Error, { error: p, sessionId: h.sessionid }, h.uuid), !this.session.hasAutoReconnect()) {
|
|
3222
3222
|
this.retriedConnect = 0;
|
|
3223
|
-
const _ = new
|
|
3223
|
+
const _ = new Xt("Fail to connect the server, the server tried 5 times", "FAILED|FAIL_WAIT"), b = W(hi, _);
|
|
3224
3224
|
L(T.Error, { error: b, sessionId: h.sessionid }, h.uuid);
|
|
3225
3225
|
break;
|
|
3226
3226
|
}
|
|
3227
3227
|
if (this.retriedConnect += 1, this.retriedConnect === 5) {
|
|
3228
3228
|
this.retriedConnect = 0;
|
|
3229
|
-
const _ =
|
|
3229
|
+
const _ = W(45003, new Error("Connection Retry Failed"));
|
|
3230
3230
|
L(T.Error, { error: _, sessionId: h.sessionid }, h.uuid);
|
|
3231
3231
|
break;
|
|
3232
3232
|
}
|
|
@@ -3264,7 +3264,7 @@ class ms {
|
|
|
3264
3264
|
}
|
|
3265
3265
|
_handlePvtEvent(e) {
|
|
3266
3266
|
return O(this, void 0, void 0, (function* () {
|
|
3267
|
-
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;
|
|
3268
3268
|
switch (s) {
|
|
3269
3269
|
case "conference-liveArray-join": {
|
|
3270
3270
|
const y = () => {
|
|
@@ -3272,17 +3272,17 @@ class ms {
|
|
|
3272
3272
|
}, v = { nodeId: this.nodeId, channels: [o], handler: ({ data: m }) => {
|
|
3273
3273
|
const w = S || this._retrieveCallId(m, o);
|
|
3274
3274
|
if (w && t.calls.hasOwnProperty(w)) {
|
|
3275
|
-
const
|
|
3276
|
-
|
|
3275
|
+
const x = t.calls[w];
|
|
3276
|
+
x._addChannel(o), x.extension = r, x.handleConferenceUpdate(m, e).then(((A) => {
|
|
3277
3277
|
A === "INVALID_PACKET" && y();
|
|
3278
3278
|
}));
|
|
3279
3279
|
}
|
|
3280
3280
|
} }, E = yield t.vertoSubscribe(v).catch(((m) => {
|
|
3281
3281
|
g.error("liveArray subscription error:", m);
|
|
3282
|
-
const w =
|
|
3282
|
+
const w = W(li, m);
|
|
3283
3283
|
L(T.Error, { error: w, sessionId: t.sessionid }, t.uuid);
|
|
3284
3284
|
}));
|
|
3285
|
-
|
|
3285
|
+
ht(E, o) && y();
|
|
3286
3286
|
break;
|
|
3287
3287
|
}
|
|
3288
3288
|
case "conference-liveArray-part": {
|
|
@@ -3294,7 +3294,7 @@ class ms {
|
|
|
3294
3294
|
L(T.Notification, m, E, !1) || L(T.Notification, m, t.uuid), y === null && pe(T.Notification, null, E);
|
|
3295
3295
|
}
|
|
3296
3296
|
}
|
|
3297
|
-
const v = [o, c,
|
|
3297
|
+
const v = [o, c, d, l];
|
|
3298
3298
|
t.vertoUnsubscribe({ nodeId: this.nodeId, channels: v }).then((({ unsubscribedChannels: E = [] }) => {
|
|
3299
3299
|
y && (y.channels = y.channels.filter(((m) => !E.includes(m))));
|
|
3300
3300
|
})).catch(((E) => {
|
|
@@ -3309,7 +3309,7 @@ class ms {
|
|
|
3309
3309
|
switch (e.contentType) {
|
|
3310
3310
|
case "layout-info":
|
|
3311
3311
|
case "layer-info":
|
|
3312
|
-
|
|
3312
|
+
An(this.session, e);
|
|
3313
3313
|
break;
|
|
3314
3314
|
case "logo-info": {
|
|
3315
3315
|
const t = { type: re.conferenceUpdate, action: oe.LogoInfo, logo: e.logoURL };
|
|
@@ -3319,7 +3319,7 @@ class ms {
|
|
|
3319
3319
|
}
|
|
3320
3320
|
}
|
|
3321
3321
|
}
|
|
3322
|
-
class
|
|
3322
|
+
class Ss extends _s {
|
|
3323
3323
|
constructor(e) {
|
|
3324
3324
|
super(e), this.relayProtocol = "verto-protocol", this.timeoutErrorCode = -329990, this.handleLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
|
|
3325
3325
|
this._idle = !1;
|
|
@@ -3329,18 +3329,18 @@ class _s extends vs {
|
|
|
3329
3329
|
} });
|
|
3330
3330
|
})), this.handleAnonymousLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
|
|
3331
3331
|
this._idle = !1, yield this.login();
|
|
3332
|
-
})), this._vertoHandler = new
|
|
3332
|
+
})), this._vertoHandler = new ys(this), window.addEventListener("beforeunload", ((t) => {
|
|
3333
3333
|
this.calls && Object.keys(this.calls).forEach(((i) => {
|
|
3334
3334
|
this.calls[i] && (g.info(`Hanging up call due to window unload: ${i}`), this.calls[i].hangup({}, !0));
|
|
3335
3335
|
}));
|
|
3336
3336
|
}));
|
|
3337
3337
|
}
|
|
3338
3338
|
validateOptions() {
|
|
3339
|
-
return
|
|
3339
|
+
return qe(this.options) || ke(this.options);
|
|
3340
3340
|
}
|
|
3341
3341
|
newCall(e) {
|
|
3342
3342
|
if (!this.validateCallOptions(e))
|
|
3343
|
-
throw
|
|
3343
|
+
throw W(ai, void 0, "Error: destinationNumber is required");
|
|
3344
3344
|
const t = new ge(this, e);
|
|
3345
3345
|
return performance.mark("new-call-start"), t.invite(), t;
|
|
3346
3346
|
}
|
|
@@ -3358,48 +3358,48 @@ class _s extends vs {
|
|
|
3358
3358
|
}
|
|
3359
3359
|
_onSocketOpen() {
|
|
3360
3360
|
return O(this, void 0, void 0, (function* () {
|
|
3361
|
-
return
|
|
3361
|
+
return qe(this.options) ? this.handleLoginOnSocketOpen() : ke(this.options) ? this.handleAnonymousLoginOnSocketOpen() : void 0;
|
|
3362
3362
|
}));
|
|
3363
3363
|
}
|
|
3364
3364
|
_onSocketMessage(e) {
|
|
3365
3365
|
this._vertoHandler.handleMessage(e);
|
|
3366
3366
|
}
|
|
3367
3367
|
}
|
|
3368
|
-
class
|
|
3368
|
+
class bs extends Ss {
|
|
3369
3369
|
constructor(e) {
|
|
3370
|
-
super(e), g.info(`SDK version: ${
|
|
3370
|
+
super(e), g.info(`SDK version: ${Tn}`);
|
|
3371
3371
|
}
|
|
3372
3372
|
newCall(e) {
|
|
3373
3373
|
return super.newCall(e);
|
|
3374
3374
|
}
|
|
3375
3375
|
static webRTCInfo() {
|
|
3376
|
-
return
|
|
3376
|
+
return as();
|
|
3377
3377
|
}
|
|
3378
3378
|
static webRTCSupportedBrowserList() {
|
|
3379
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 }] }];
|
|
3380
3380
|
}
|
|
3381
3381
|
}
|
|
3382
|
-
function
|
|
3382
|
+
function Ln(n) {
|
|
3383
3383
|
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
3384
3384
|
}
|
|
3385
|
-
var
|
|
3386
|
-
function
|
|
3387
|
-
return
|
|
3385
|
+
var lt = { exports: {} }, zt;
|
|
3386
|
+
function Cs() {
|
|
3387
|
+
return zt || (zt = 1, (function(n) {
|
|
3388
3388
|
var e = Object.prototype.hasOwnProperty, t = "~";
|
|
3389
3389
|
function i() {
|
|
3390
3390
|
}
|
|
3391
3391
|
Object.create && (i.prototype = /* @__PURE__ */ Object.create(null), new i().__proto__ || (t = !1));
|
|
3392
|
-
function s(
|
|
3393
|
-
this.fn =
|
|
3392
|
+
function s(d, l, f) {
|
|
3393
|
+
this.fn = d, this.context = l, this.once = f || !1;
|
|
3394
3394
|
}
|
|
3395
|
-
function o(
|
|
3395
|
+
function o(d, l, f, h, S) {
|
|
3396
3396
|
if (typeof f != "function")
|
|
3397
3397
|
throw new TypeError("The listener must be a function");
|
|
3398
|
-
var y = new s(f, h ||
|
|
3399
|
-
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;
|
|
3400
3400
|
}
|
|
3401
|
-
function r(
|
|
3402
|
-
--
|
|
3401
|
+
function r(d, l) {
|
|
3402
|
+
--d._eventsCount === 0 ? d._events = new i() : delete d._events[l];
|
|
3403
3403
|
}
|
|
3404
3404
|
function c() {
|
|
3405
3405
|
this._events = new i(), this._eventsCount = 0;
|
|
@@ -3423,7 +3423,7 @@ function Ss() {
|
|
|
3423
3423
|
}, c.prototype.emit = function(l, f, h, S, y, v) {
|
|
3424
3424
|
var E = t ? t + l : l;
|
|
3425
3425
|
if (!this._events[E]) return !1;
|
|
3426
|
-
var m = this._events[E], w = arguments.length,
|
|
3426
|
+
var m = this._events[E], w = arguments.length, x, A;
|
|
3427
3427
|
if (m.fn) {
|
|
3428
3428
|
switch (m.once && this.removeListener(l, m.fn, void 0, !0), w) {
|
|
3429
3429
|
case 1:
|
|
@@ -3439,9 +3439,9 @@ function Ss() {
|
|
|
3439
3439
|
case 6:
|
|
3440
3440
|
return m.fn.call(m.context, f, h, S, y, v), !0;
|
|
3441
3441
|
}
|
|
3442
|
-
for (A = 1,
|
|
3443
|
-
|
|
3444
|
-
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);
|
|
3445
3445
|
} else {
|
|
3446
3446
|
var P = m.length, M;
|
|
3447
3447
|
for (A = 0; A < P; A++)
|
|
@@ -3459,9 +3459,9 @@ function Ss() {
|
|
|
3459
3459
|
m[A].fn.call(m[A].context, f, h, S);
|
|
3460
3460
|
break;
|
|
3461
3461
|
default:
|
|
3462
|
-
if (!
|
|
3463
|
-
|
|
3464
|
-
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);
|
|
3465
3465
|
}
|
|
3466
3466
|
}
|
|
3467
3467
|
return !0;
|
|
@@ -3487,16 +3487,16 @@ function Ss() {
|
|
|
3487
3487
|
var f;
|
|
3488
3488
|
return l ? (f = t ? t + l : l, this._events[f] && r(this, f)) : (this._events = new i(), this._eventsCount = 0), this;
|
|
3489
3489
|
}, c.prototype.off = c.prototype.removeListener, c.prototype.addListener = c.prototype.on, c.prefixed = t, c.EventEmitter = c, n.exports = c;
|
|
3490
|
-
})(
|
|
3490
|
+
})(lt)), lt.exports;
|
|
3491
3491
|
}
|
|
3492
|
-
var
|
|
3493
|
-
const
|
|
3494
|
-
var $e = { exports: {} },
|
|
3495
|
-
function
|
|
3496
|
-
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) {
|
|
3497
3497
|
(function(e, t) {
|
|
3498
3498
|
n.exports ? n.exports = t() : e.log = t();
|
|
3499
|
-
})(
|
|
3499
|
+
})(Es, function() {
|
|
3500
3500
|
var e = function() {
|
|
3501
3501
|
}, t = "undefined", i = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), s = [
|
|
3502
3502
|
"trace",
|
|
@@ -3517,11 +3517,11 @@ function ws() {
|
|
|
3517
3517
|
};
|
|
3518
3518
|
}
|
|
3519
3519
|
}
|
|
3520
|
-
function
|
|
3520
|
+
function d() {
|
|
3521
3521
|
console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
|
|
3522
3522
|
}
|
|
3523
3523
|
function l(E) {
|
|
3524
|
-
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;
|
|
3525
3525
|
}
|
|
3526
3526
|
function f() {
|
|
3527
3527
|
for (var E = this.getLevel(), m = 0; m < s.length; m++) {
|
|
@@ -3540,7 +3540,7 @@ function ws() {
|
|
|
3540
3540
|
return l(E) || h.apply(this, arguments);
|
|
3541
3541
|
}
|
|
3542
3542
|
function y(E, m) {
|
|
3543
|
-
var w = this,
|
|
3543
|
+
var w = this, x, A, P, M = "loglevel";
|
|
3544
3544
|
typeof E == "string" ? M += ":" + E : typeof E == "symbol" && (M = void 0);
|
|
3545
3545
|
function q(p) {
|
|
3546
3546
|
var _ = (s[p] || "silent").toUpperCase();
|
|
@@ -3600,7 +3600,7 @@ function ws() {
|
|
|
3600
3600
|
ERROR: 4,
|
|
3601
3601
|
SILENT: 5
|
|
3602
3602
|
}, w.methodFactory = m || S, w.getLevel = function() {
|
|
3603
|
-
return P ?? A ??
|
|
3603
|
+
return P ?? A ?? x;
|
|
3604
3604
|
}, w.setLevel = function(p, _) {
|
|
3605
3605
|
return P = a(p), _ !== !1 && q(P), f.call(w);
|
|
3606
3606
|
}, w.setDefaultLevel = function(p) {
|
|
@@ -3612,14 +3612,14 @@ function ws() {
|
|
|
3612
3612
|
}, w.disableAll = function(p) {
|
|
3613
3613
|
w.setLevel(w.levels.SILENT, p);
|
|
3614
3614
|
}, w.rebuild = function() {
|
|
3615
|
-
if (r !== w && (
|
|
3615
|
+
if (r !== w && (x = a(r.getLevel())), f.call(w), r === w)
|
|
3616
3616
|
for (var p in o)
|
|
3617
3617
|
o[p].rebuild();
|
|
3618
|
-
},
|
|
3618
|
+
}, x = a(
|
|
3619
3619
|
r ? r.getLevel() : "WARN"
|
|
3620
3620
|
);
|
|
3621
|
-
var
|
|
3622
|
-
|
|
3621
|
+
var u = F();
|
|
3622
|
+
u != null && (P = a(u)), f.call(w);
|
|
3623
3623
|
}
|
|
3624
3624
|
r = new y(), r.getLogger = function(m) {
|
|
3625
3625
|
if (typeof m != "symbol" && typeof m != "string" || m === "")
|
|
@@ -3639,24 +3639,24 @@ function ws() {
|
|
|
3639
3639
|
});
|
|
3640
3640
|
})($e)), $e.exports;
|
|
3641
3641
|
}
|
|
3642
|
-
var
|
|
3643
|
-
const
|
|
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
3644
|
X.methodFactory = (n, e, t) => {
|
|
3645
|
-
const i =
|
|
3645
|
+
const i = As(n, e, t);
|
|
3646
3646
|
return function(...s) {
|
|
3647
|
-
i(
|
|
3647
|
+
i(Rs(), "-", ...s);
|
|
3648
3648
|
};
|
|
3649
3649
|
};
|
|
3650
3650
|
X.setLevel("info");
|
|
3651
|
-
function
|
|
3651
|
+
function Os(n, e) {
|
|
3652
3652
|
let t = 0;
|
|
3653
3653
|
return (...i) => {
|
|
3654
3654
|
const s = Date.now();
|
|
3655
3655
|
s - t >= e && (t = s, n(...i));
|
|
3656
3656
|
};
|
|
3657
3657
|
}
|
|
3658
|
-
const
|
|
3659
|
-
class
|
|
3658
|
+
const Ls = 10, xs = 500, Ns = 100, Zt = 20;
|
|
3659
|
+
class Ds {
|
|
3660
3660
|
remoteIntervalId = null;
|
|
3661
3661
|
localIntervalId = null;
|
|
3662
3662
|
remoteStream = null;
|
|
@@ -3683,10 +3683,10 @@ class Ns {
|
|
|
3683
3683
|
minSpeechDurationMs;
|
|
3684
3684
|
maxLatencyMs;
|
|
3685
3685
|
constructor(e) {
|
|
3686
|
-
this.volumeThreshold = e?.volumeThreshold ??
|
|
3686
|
+
this.volumeThreshold = e?.volumeThreshold ?? Ls, this.silenceDurationMs = e?.silenceDurationMs ?? xs, this.minSpeechDurationMs = e?.minSpeechDurationMs ?? Ns, this.maxLatencyMs = e?.maxLatencyMs;
|
|
3687
3687
|
}
|
|
3688
|
-
updateAgentState =
|
|
3689
|
-
X.debug("AudioStreamMonitor updateAgentState", e), X.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state,
|
|
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));
|
|
3690
3690
|
}, 100);
|
|
3691
3691
|
/**
|
|
3692
3692
|
* Set the remote audio stream (agent's voice) to monitor for speech detection
|
|
@@ -3740,7 +3740,7 @@ class Ns {
|
|
|
3740
3740
|
let i = !1;
|
|
3741
3741
|
const s = () => {
|
|
3742
3742
|
this.remoteAnalyser?.getByteFrequencyData(t);
|
|
3743
|
-
const o = t.reduce((c,
|
|
3743
|
+
const o = t.reduce((c, d) => c + d, 0) / t.length, r = o >= this.volumeThreshold;
|
|
3744
3744
|
if (Math.random() < 0.01 && X.debug("Remote audio volume:", o, "threshold:", this.volumeThreshold, "above:", r), r)
|
|
3745
3745
|
if (i)
|
|
3746
3746
|
this.updateAgentState({ state: "speaking" });
|
|
@@ -3756,7 +3756,7 @@ class Ns {
|
|
|
3756
3756
|
this.thinkingStartTime === null && this.updateAgentState({ state: "listening" });
|
|
3757
3757
|
i = r;
|
|
3758
3758
|
};
|
|
3759
|
-
this.remoteIntervalId = window.setInterval(s,
|
|
3759
|
+
this.remoteIntervalId = window.setInterval(s, Zt);
|
|
3760
3760
|
}
|
|
3761
3761
|
/**
|
|
3762
3762
|
* Monitor local stream (user's microphone) for VAD
|
|
@@ -3781,46 +3781,46 @@ class Ns {
|
|
|
3781
3781
|
this.updateAgentState({ state: "thinking", thinkingStartedAt: c });
|
|
3782
3782
|
}
|
|
3783
3783
|
};
|
|
3784
|
-
this.localIntervalId = window.setInterval(t,
|
|
3784
|
+
this.localIntervalId = window.setInterval(t, Zt);
|
|
3785
3785
|
}
|
|
3786
3786
|
destroy() {
|
|
3787
3787
|
this.stopAudioStreamMonitor();
|
|
3788
3788
|
}
|
|
3789
3789
|
}
|
|
3790
|
-
function
|
|
3790
|
+
function Ps(n) {
|
|
3791
3791
|
if (!n || typeof n != "object")
|
|
3792
3792
|
return !1;
|
|
3793
3793
|
const e = n;
|
|
3794
3794
|
return e.method === "ai_conversation" && typeof e.params == "object";
|
|
3795
3795
|
}
|
|
3796
|
-
function
|
|
3796
|
+
function Ms(n) {
|
|
3797
3797
|
if (!n || typeof n != "object")
|
|
3798
3798
|
return !1;
|
|
3799
3799
|
const e = n;
|
|
3800
3800
|
return e.params.type !== "response.text.delta" ? !1 : !!e.params.delta;
|
|
3801
3801
|
}
|
|
3802
|
-
function
|
|
3802
|
+
function Us(n) {
|
|
3803
3803
|
if (!n || typeof n != "object")
|
|
3804
3804
|
return !1;
|
|
3805
3805
|
const e = n;
|
|
3806
3806
|
return e.params.type !== "conversation.item.created" ? !1 : !!e.params.item.content;
|
|
3807
3807
|
}
|
|
3808
|
-
function
|
|
3808
|
+
function Fs(n) {
|
|
3809
3809
|
if (!n || typeof n != "object")
|
|
3810
3810
|
return !1;
|
|
3811
3811
|
const e = n;
|
|
3812
3812
|
return e.params?.type !== "conversation.item.deleted" ? !1 : !!e.params.item_id;
|
|
3813
3813
|
}
|
|
3814
|
-
function
|
|
3815
|
-
return
|
|
3814
|
+
function js(n) {
|
|
3815
|
+
return Ms(n) ? {
|
|
3816
3816
|
id: `${n.params.item_id}-${Date.now()}`,
|
|
3817
3817
|
role: "assistant",
|
|
3818
3818
|
content: n.params.delta,
|
|
3819
3819
|
timestamp: /* @__PURE__ */ new Date()
|
|
3820
3820
|
} : null;
|
|
3821
3821
|
}
|
|
3822
|
-
function
|
|
3823
|
-
if (!
|
|
3822
|
+
function Bs(n) {
|
|
3823
|
+
if (!Us(n) || n.params.item.role !== "user" || n.params.item.status !== "completed")
|
|
3824
3824
|
return null;
|
|
3825
3825
|
let e = "", t = [];
|
|
3826
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, {
|
|
@@ -3831,29 +3831,29 @@ function Fs(n) {
|
|
|
3831
3831
|
attachments: t
|
|
3832
3832
|
};
|
|
3833
3833
|
}
|
|
3834
|
-
class
|
|
3834
|
+
class Hs extends Et {
|
|
3835
3835
|
telnyxRTC;
|
|
3836
3836
|
transcript = [];
|
|
3837
3837
|
constructor(e) {
|
|
3838
3838
|
super(), this.telnyxRTC = e, this.telnyxRTC.on(T.SocketMessage, this.onSocketMessage);
|
|
3839
3839
|
}
|
|
3840
3840
|
onSocketMessage = (e) => {
|
|
3841
|
-
if (
|
|
3841
|
+
if (Ps(e))
|
|
3842
3842
|
switch (e.params.type) {
|
|
3843
3843
|
case "response.text.delta": {
|
|
3844
|
-
const t =
|
|
3845
|
-
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" }));
|
|
3846
3846
|
return;
|
|
3847
3847
|
}
|
|
3848
3848
|
case "conversation.item.deleted": {
|
|
3849
|
-
if (
|
|
3849
|
+
if (Fs(e)) {
|
|
3850
3850
|
const t = e.params.item_id, i = this.transcript.findIndex((s) => s.id === t);
|
|
3851
3851
|
i !== -1 && this.transcript.splice(i, 1);
|
|
3852
3852
|
}
|
|
3853
3853
|
return;
|
|
3854
3854
|
}
|
|
3855
3855
|
case "conversation.item.created": {
|
|
3856
|
-
const t =
|
|
3856
|
+
const t = Bs(e);
|
|
3857
3857
|
if (t) {
|
|
3858
3858
|
const i = this.transcript.findIndex(
|
|
3859
3859
|
(s) => s.id === t.id
|
|
@@ -3865,9 +3865,17 @@ class js extends wt {
|
|
|
3865
3865
|
}
|
|
3866
3866
|
};
|
|
3867
3867
|
}
|
|
3868
|
-
|
|
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 {
|
|
3869
3874
|
telnyxRTC;
|
|
3870
3875
|
transcription;
|
|
3876
|
+
removeLoginSuccessHook = null;
|
|
3877
|
+
authenticated = !1;
|
|
3878
|
+
authenticating = !1;
|
|
3871
3879
|
agentId;
|
|
3872
3880
|
versionId;
|
|
3873
3881
|
conversationId;
|
|
@@ -3908,17 +3916,17 @@ class Zt extends wt {
|
|
|
3908
3916
|
};
|
|
3909
3917
|
e.conversationId && (t.target_params = {
|
|
3910
3918
|
conversation_id: e.conversationId
|
|
3911
|
-
}), this.telnyxRTC = new
|
|
3919
|
+
}), this.telnyxRTC = new bs({
|
|
3912
3920
|
env: e.environment || "production",
|
|
3913
3921
|
anonymous_login: t,
|
|
3914
3922
|
debug: e.debug || !1,
|
|
3915
3923
|
trickleIce: e.trickleIce,
|
|
3916
3924
|
region: e.region,
|
|
3917
3925
|
skipLastVoiceSdkId: e.skipLastVoiceSdkId ?? !0
|
|
3918
|
-
}), 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.Notification, this.onNotification), this.transcription = new
|
|
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(
|
|
3919
3927
|
"conversation.agent.state",
|
|
3920
3928
|
this.onAgentStateChange
|
|
3921
|
-
), this.audioStreamMonitor = new
|
|
3929
|
+
), this.audioStreamMonitor = new Ds(e.vad);
|
|
3922
3930
|
}
|
|
3923
3931
|
/**
|
|
3924
3932
|
* Connects to the Telnyx WebRTC service and establishes a session with the AI agent.
|
|
@@ -3928,6 +3936,25 @@ class Zt extends wt {
|
|
|
3928
3936
|
async connect() {
|
|
3929
3937
|
return this.telnyxRTC.connect();
|
|
3930
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
|
+
}
|
|
3931
3958
|
/**
|
|
3932
3959
|
* Clears the reconnect token stored by the underlying WebRTC SDK.
|
|
3933
3960
|
*
|
|
@@ -3943,7 +3970,7 @@ class Zt extends wt {
|
|
|
3943
3970
|
* Emits an 'agent.disconnected' event before completing cleanup.
|
|
3944
3971
|
*/
|
|
3945
3972
|
async disconnect() {
|
|
3946
|
-
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();
|
|
3947
3974
|
}
|
|
3948
3975
|
/**
|
|
3949
3976
|
* Sends a text message to the AI agent during an active conversation.
|
|
@@ -4017,7 +4044,7 @@ class Zt extends wt {
|
|
|
4017
4044
|
name: "X-AI-Assistant-Conversation-ID",
|
|
4018
4045
|
value: this.conversationId
|
|
4019
4046
|
});
|
|
4020
|
-
const
|
|
4047
|
+
const d = this.telnyxRTC.newCall({
|
|
4021
4048
|
destinationNumber: "xxx",
|
|
4022
4049
|
...r,
|
|
4023
4050
|
audio: this.chatMode ? !1 : o ?? !0,
|
|
@@ -4025,7 +4052,7 @@ class Zt extends wt {
|
|
|
4025
4052
|
preferred_codecs: [i],
|
|
4026
4053
|
customHeaders: c.length > 0 ? c : void 0
|
|
4027
4054
|
});
|
|
4028
|
-
this.emit("conversation.update", { call:
|
|
4055
|
+
this.emit("conversation.update", { call: d, type: "callUpdate" });
|
|
4029
4056
|
}
|
|
4030
4057
|
/**
|
|
4031
4058
|
* Ends the current active conversation with the AI agent.
|
|
@@ -4054,9 +4081,52 @@ class Zt extends wt {
|
|
|
4054
4081
|
};
|
|
4055
4082
|
this.emit("agent.connected", e);
|
|
4056
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
|
+
}
|
|
4057
4120
|
onClientOrSocketError = (e) => {
|
|
4058
4121
|
this.emit("agent.error", e.error);
|
|
4059
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
|
+
};
|
|
4060
4130
|
onNotification = (e) => {
|
|
4061
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()));
|
|
4062
4132
|
};
|
|
@@ -4067,11 +4137,11 @@ class Zt extends wt {
|
|
|
4067
4137
|
this.emit("conversation.agent.state", e);
|
|
4068
4138
|
};
|
|
4069
4139
|
}
|
|
4070
|
-
var
|
|
4071
|
-
var
|
|
4072
|
-
function
|
|
4073
|
-
if (
|
|
4074
|
-
|
|
4140
|
+
var He = { exports: {} }, Ce = {};
|
|
4141
|
+
var nn;
|
|
4142
|
+
function Ws() {
|
|
4143
|
+
if (nn) return Ce;
|
|
4144
|
+
nn = 1;
|
|
4075
4145
|
var n = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
4076
4146
|
function t(i, s, o) {
|
|
4077
4147
|
var r = null;
|
|
@@ -4091,9 +4161,9 @@ function Bs() {
|
|
|
4091
4161
|
return Ce.Fragment = e, Ce.jsx = t, Ce.jsxs = t, Ce;
|
|
4092
4162
|
}
|
|
4093
4163
|
var we = {};
|
|
4094
|
-
var
|
|
4095
|
-
function
|
|
4096
|
-
return
|
|
4164
|
+
var sn;
|
|
4165
|
+
function Gs() {
|
|
4166
|
+
return sn || (sn = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
4097
4167
|
function n(C) {
|
|
4098
4168
|
if (C == null) return null;
|
|
4099
4169
|
if (typeof C == "function")
|
|
@@ -4102,7 +4172,7 @@ function $s() {
|
|
|
4102
4172
|
switch (C) {
|
|
4103
4173
|
case m:
|
|
4104
4174
|
return "Fragment";
|
|
4105
|
-
case
|
|
4175
|
+
case x:
|
|
4106
4176
|
return "Profiler";
|
|
4107
4177
|
case w:
|
|
4108
4178
|
return "StrictMode";
|
|
@@ -4110,7 +4180,7 @@ function $s() {
|
|
|
4110
4180
|
return "Suspense";
|
|
4111
4181
|
case F:
|
|
4112
4182
|
return "SuspenseList";
|
|
4113
|
-
case
|
|
4183
|
+
case u:
|
|
4114
4184
|
return "Activity";
|
|
4115
4185
|
}
|
|
4116
4186
|
if (typeof C == "object")
|
|
@@ -4149,11 +4219,11 @@ function $s() {
|
|
|
4149
4219
|
}
|
|
4150
4220
|
if (D) {
|
|
4151
4221
|
D = console;
|
|
4152
|
-
var j = D.error,
|
|
4222
|
+
var j = D.error, $ = typeof Symbol == "function" && Symbol.toStringTag && C[Symbol.toStringTag] || C.constructor.name || "Object";
|
|
4153
4223
|
return j.call(
|
|
4154
4224
|
D,
|
|
4155
4225
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
4156
|
-
|
|
4226
|
+
$
|
|
4157
4227
|
), e(C);
|
|
4158
4228
|
}
|
|
4159
4229
|
}
|
|
@@ -4184,7 +4254,7 @@ function $s() {
|
|
|
4184
4254
|
}
|
|
4185
4255
|
function c(C, D) {
|
|
4186
4256
|
function j() {
|
|
4187
|
-
|
|
4257
|
+
N || (N = !0, console.error(
|
|
4188
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)",
|
|
4189
4259
|
D
|
|
4190
4260
|
));
|
|
@@ -4194,23 +4264,23 @@ function $s() {
|
|
|
4194
4264
|
configurable: !0
|
|
4195
4265
|
});
|
|
4196
4266
|
}
|
|
4197
|
-
function
|
|
4267
|
+
function d() {
|
|
4198
4268
|
var C = n(this.type);
|
|
4199
4269
|
return B[C] || (B[C] = !0, console.error(
|
|
4200
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."
|
|
4201
4271
|
)), C = this.props.ref, C !== void 0 ? C : null;
|
|
4202
4272
|
}
|
|
4203
|
-
function l(C, D, j,
|
|
4273
|
+
function l(C, D, j, $, K, Q) {
|
|
4204
4274
|
var V = j.ref;
|
|
4205
4275
|
return C = {
|
|
4206
4276
|
$$typeof: v,
|
|
4207
4277
|
type: C,
|
|
4208
4278
|
key: D,
|
|
4209
4279
|
props: j,
|
|
4210
|
-
_owner:
|
|
4280
|
+
_owner: $
|
|
4211
4281
|
}, (V !== void 0 ? V : null) !== null ? Object.defineProperty(C, "ref", {
|
|
4212
4282
|
enumerable: !1,
|
|
4213
|
-
get:
|
|
4283
|
+
get: d
|
|
4214
4284
|
}) : Object.defineProperty(C, "ref", { enumerable: !1, value: null }), C._store = {}, Object.defineProperty(C._store, "validated", {
|
|
4215
4285
|
configurable: !1,
|
|
4216
4286
|
enumerable: !1,
|
|
@@ -4233,13 +4303,13 @@ function $s() {
|
|
|
4233
4303
|
value: Q
|
|
4234
4304
|
}), Object.freeze && (Object.freeze(C.props), Object.freeze(C)), C;
|
|
4235
4305
|
}
|
|
4236
|
-
function f(C, D, j,
|
|
4306
|
+
function f(C, D, j, $, K, Q) {
|
|
4237
4307
|
var V = D.children;
|
|
4238
4308
|
if (V !== void 0)
|
|
4239
|
-
if (
|
|
4309
|
+
if ($)
|
|
4240
4310
|
if (k(V)) {
|
|
4241
|
-
for (
|
|
4242
|
-
h(V[
|
|
4311
|
+
for ($ = 0; $ < V.length; $++)
|
|
4312
|
+
h(V[$]);
|
|
4243
4313
|
Object.freeze && Object.freeze(V);
|
|
4244
4314
|
} else
|
|
4245
4315
|
console.error(
|
|
@@ -4248,26 +4318,26 @@ function $s() {
|
|
|
4248
4318
|
else h(V);
|
|
4249
4319
|
if (b.call(D, "key")) {
|
|
4250
4320
|
V = n(C);
|
|
4251
|
-
var ae = Object.keys(D).filter(function(
|
|
4252
|
-
return
|
|
4321
|
+
var ae = Object.keys(D).filter(function(qn) {
|
|
4322
|
+
return qn !== "key";
|
|
4253
4323
|
});
|
|
4254
|
-
|
|
4324
|
+
$ = 0 < ae.length ? "{key: someKey, " + ae.join(": ..., ") + ": ...}" : "{key: someKey}", G[V + $] || (ae = 0 < ae.length ? "{" + ae.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
4255
4325
|
`A props object containing a "key" prop is being spread into JSX:
|
|
4256
4326
|
let props = %s;
|
|
4257
4327
|
<%s {...props} />
|
|
4258
4328
|
React keys must be passed directly to JSX without using spread:
|
|
4259
4329
|
let props = %s;
|
|
4260
4330
|
<%s key={someKey} {...props} />`,
|
|
4261
|
-
|
|
4331
|
+
$,
|
|
4262
4332
|
V,
|
|
4263
4333
|
ae,
|
|
4264
4334
|
V
|
|
4265
|
-
), G[V +
|
|
4335
|
+
), G[V + $] = !0);
|
|
4266
4336
|
}
|
|
4267
4337
|
if (V = null, j !== void 0 && (t(j), V = "" + j), r(D) && (t(D.key), V = "" + D.key), "key" in D) {
|
|
4268
4338
|
j = {};
|
|
4269
|
-
for (var
|
|
4270
|
-
|
|
4339
|
+
for (var ot in D)
|
|
4340
|
+
ot !== "key" && (j[ot] = D[ot]);
|
|
4271
4341
|
} else j = D;
|
|
4272
4342
|
return V && c(
|
|
4273
4343
|
j,
|
|
@@ -4287,7 +4357,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
4287
4357
|
function S(C) {
|
|
4288
4358
|
return typeof C == "object" && C !== null && C.$$typeof === v;
|
|
4289
4359
|
}
|
|
4290
|
-
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() {
|
|
4291
4361
|
return null;
|
|
4292
4362
|
};
|
|
4293
4363
|
y = {
|
|
@@ -4295,68 +4365,68 @@ React keys must be passed directly to JSX without using spread:
|
|
|
4295
4365
|
return C();
|
|
4296
4366
|
}
|
|
4297
4367
|
};
|
|
4298
|
-
var
|
|
4368
|
+
var N, B = {}, te = y.react_stack_bottom_frame.bind(
|
|
4299
4369
|
y,
|
|
4300
4370
|
o
|
|
4301
4371
|
)(), ie = I(i(o)), G = {};
|
|
4302
4372
|
we.Fragment = m, we.jsx = function(C, D, j) {
|
|
4303
|
-
var
|
|
4373
|
+
var $ = 1e4 > _.recentlyCreatedOwnerStacks++;
|
|
4304
4374
|
return f(
|
|
4305
4375
|
C,
|
|
4306
4376
|
D,
|
|
4307
4377
|
j,
|
|
4308
4378
|
!1,
|
|
4309
|
-
|
|
4310
|
-
|
|
4379
|
+
$ ? Error("react-stack-top-frame") : te,
|
|
4380
|
+
$ ? I(i(C)) : ie
|
|
4311
4381
|
);
|
|
4312
4382
|
}, we.jsxs = function(C, D, j) {
|
|
4313
|
-
var
|
|
4383
|
+
var $ = 1e4 > _.recentlyCreatedOwnerStacks++;
|
|
4314
4384
|
return f(
|
|
4315
4385
|
C,
|
|
4316
4386
|
D,
|
|
4317
4387
|
j,
|
|
4318
4388
|
!0,
|
|
4319
|
-
|
|
4320
|
-
|
|
4389
|
+
$ ? Error("react-stack-top-frame") : te,
|
|
4390
|
+
$ ? I(i(C)) : ie
|
|
4321
4391
|
);
|
|
4322
4392
|
};
|
|
4323
4393
|
})()), we;
|
|
4324
4394
|
}
|
|
4325
|
-
var
|
|
4326
|
-
function
|
|
4327
|
-
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;
|
|
4328
4398
|
}
|
|
4329
|
-
var Ee =
|
|
4399
|
+
var Ee = Vs();
|
|
4330
4400
|
const ue = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
|
|
4331
|
-
function
|
|
4401
|
+
function xn(n) {
|
|
4332
4402
|
return "init" in n;
|
|
4333
4403
|
}
|
|
4334
|
-
function
|
|
4404
|
+
function gt(n) {
|
|
4335
4405
|
return !!n.write;
|
|
4336
4406
|
}
|
|
4337
|
-
function
|
|
4407
|
+
function rn(n) {
|
|
4338
4408
|
return "v" in n || "e" in n;
|
|
4339
4409
|
}
|
|
4340
|
-
function
|
|
4410
|
+
function ze(n) {
|
|
4341
4411
|
if ("e" in n)
|
|
4342
4412
|
throw n.e;
|
|
4343
4413
|
if ((ue ? "production" : void 0) !== "production" && !("v" in n))
|
|
4344
4414
|
throw new Error("[Bug] atom state is not initialized");
|
|
4345
4415
|
return n.v;
|
|
4346
4416
|
}
|
|
4347
|
-
const
|
|
4348
|
-
function
|
|
4417
|
+
const Qe = /* @__PURE__ */ new WeakMap();
|
|
4418
|
+
function Nn(n) {
|
|
4349
4419
|
var e;
|
|
4350
|
-
return
|
|
4420
|
+
return Ze(n) && !!((e = Qe.get(n)) != null && e[0]);
|
|
4351
4421
|
}
|
|
4352
|
-
function
|
|
4353
|
-
const e =
|
|
4422
|
+
function qs(n) {
|
|
4423
|
+
const e = Qe.get(n);
|
|
4354
4424
|
e?.[0] && (e[0] = !1, e[1].forEach((t) => t()));
|
|
4355
4425
|
}
|
|
4356
|
-
function
|
|
4357
|
-
let t =
|
|
4426
|
+
function vt(n, e) {
|
|
4427
|
+
let t = Qe.get(n);
|
|
4358
4428
|
if (!t) {
|
|
4359
|
-
t = [!0, /* @__PURE__ */ new Set()],
|
|
4429
|
+
t = [!0, /* @__PURE__ */ new Set()], Qe.set(n, t);
|
|
4360
4430
|
const i = () => {
|
|
4361
4431
|
t[0] = !1;
|
|
4362
4432
|
};
|
|
@@ -4364,17 +4434,17 @@ function gt(n, e) {
|
|
|
4364
4434
|
}
|
|
4365
4435
|
t[1].add(e);
|
|
4366
4436
|
}
|
|
4367
|
-
function
|
|
4437
|
+
function Ze(n) {
|
|
4368
4438
|
return typeof n?.then == "function";
|
|
4369
4439
|
}
|
|
4370
|
-
function
|
|
4440
|
+
function Dn(n, e, t) {
|
|
4371
4441
|
if (!t.p.has(n)) {
|
|
4372
4442
|
t.p.add(n);
|
|
4373
4443
|
const i = () => t.p.delete(n);
|
|
4374
4444
|
e.then(i, i);
|
|
4375
4445
|
}
|
|
4376
4446
|
}
|
|
4377
|
-
function
|
|
4447
|
+
function Pn(n, e, t) {
|
|
4378
4448
|
var i;
|
|
4379
4449
|
const s = /* @__PURE__ */ new Set();
|
|
4380
4450
|
for (const o of ((i = t.get(n)) == null ? void 0 : i.t) || [])
|
|
@@ -4383,29 +4453,29 @@ function xn(n, e, t) {
|
|
|
4383
4453
|
s.add(o);
|
|
4384
4454
|
return s;
|
|
4385
4455
|
}
|
|
4386
|
-
const
|
|
4456
|
+
const Ys = (n, e, ...t) => e.read(...t), Js = (n, e, ...t) => e.write(...t), Ks = (n, e) => {
|
|
4387
4457
|
if (e.INTERNAL_onInit)
|
|
4388
4458
|
return e.INTERNAL_onInit(n);
|
|
4389
4459
|
if (e.unstable_onInit)
|
|
4390
4460
|
return console.warn(
|
|
4391
4461
|
"[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."
|
|
4392
4462
|
), e.unstable_onInit(n);
|
|
4393
|
-
},
|
|
4463
|
+
}, Xs = (n, e, t) => {
|
|
4394
4464
|
var i;
|
|
4395
4465
|
return (i = e.onMount) == null ? void 0 : i.call(e, t);
|
|
4396
|
-
},
|
|
4466
|
+
}, zs = (n, e) => {
|
|
4397
4467
|
var t;
|
|
4398
4468
|
const i = Z(n), s = i[0], o = i[6], r = i[9];
|
|
4399
4469
|
if ((ue ? "production" : void 0) !== "production" && !e)
|
|
4400
4470
|
throw new Error("Atom is undefined or null");
|
|
4401
4471
|
let c = s.get(e);
|
|
4402
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;
|
|
4403
|
-
},
|
|
4404
|
-
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) => {
|
|
4405
4475
|
try {
|
|
4406
4476
|
f();
|
|
4407
4477
|
} catch (h) {
|
|
4408
|
-
|
|
4478
|
+
d.push(h);
|
|
4409
4479
|
}
|
|
4410
4480
|
};
|
|
4411
4481
|
do {
|
|
@@ -4416,10 +4486,10 @@ const Gs = (n, e, ...t) => e.read(...t), Vs = (n, e, ...t) => e.write(...t), qs
|
|
|
4416
4486
|
return (y = t.get(S)) == null ? void 0 : y.l.forEach(h);
|
|
4417
4487
|
}), i.clear(), o.forEach(h), o.clear(), s.forEach(h), s.clear(), f.forEach(l), i.size && c(n);
|
|
4418
4488
|
} while (i.size || o.size || s.size);
|
|
4419
|
-
if (
|
|
4420
|
-
throw new AggregateError(
|
|
4421
|
-
},
|
|
4422
|
-
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);
|
|
4423
4493
|
for (; h.length; ) {
|
|
4424
4494
|
const S = h[h.length - 1], y = o(n, S);
|
|
4425
4495
|
if (f.has(S)) {
|
|
@@ -4428,18 +4498,18 @@ const Gs = (n, e, ...t) => e.read(...t), Vs = (n, e, ...t) => e.write(...t), qs
|
|
|
4428
4498
|
}
|
|
4429
4499
|
if (l.has(S)) {
|
|
4430
4500
|
if (i.get(S) === y.n)
|
|
4431
|
-
|
|
4501
|
+
d.push([S, y]);
|
|
4432
4502
|
else if ((ue ? "production" : void 0) !== "production" && i.has(S))
|
|
4433
4503
|
throw new Error("[Bug] invalidated atom exists");
|
|
4434
4504
|
f.add(S), h.pop();
|
|
4435
4505
|
continue;
|
|
4436
4506
|
}
|
|
4437
4507
|
l.add(S);
|
|
4438
|
-
for (const v of
|
|
4508
|
+
for (const v of Pn(S, y, t))
|
|
4439
4509
|
l.has(v) || h.push(v);
|
|
4440
4510
|
}
|
|
4441
|
-
for (let S =
|
|
4442
|
-
const [y, v] =
|
|
4511
|
+
for (let S = d.length - 1; S >= 0; --S) {
|
|
4512
|
+
const [y, v] = d[S];
|
|
4443
4513
|
let E = !1;
|
|
4444
4514
|
for (const m of v.d.keys())
|
|
4445
4515
|
if (m !== y && s.has(m)) {
|
|
@@ -4448,15 +4518,15 @@ const Gs = (n, e, ...t) => e.read(...t), Vs = (n, e, ...t) => e.write(...t), qs
|
|
|
4448
4518
|
}
|
|
4449
4519
|
E && (r(n, y), c(n, y)), i.delete(y);
|
|
4450
4520
|
}
|
|
4451
|
-
},
|
|
4521
|
+
}, mt = /* @__PURE__ */ new WeakSet(), eo = (n, e) => {
|
|
4452
4522
|
var t, i;
|
|
4453
|
-
const s = Z(n), o = s[1], r = s[2], c = s[3],
|
|
4454
|
-
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)) {
|
|
4455
4525
|
if (o.has(e) && r.get(e) !== m.n)
|
|
4456
4526
|
return m;
|
|
4457
4527
|
let R = !1;
|
|
4458
|
-
for (const [a,
|
|
4459
|
-
if (y(n, a).n !==
|
|
4528
|
+
for (const [a, u] of m.d)
|
|
4529
|
+
if (y(n, a).n !== u) {
|
|
4460
4530
|
R = !0;
|
|
4461
4531
|
break;
|
|
4462
4532
|
}
|
|
@@ -4465,25 +4535,25 @@ const Gs = (n, e, ...t) => e.read(...t), Vs = (n, e, ...t) => e.write(...t), qs
|
|
|
4465
4535
|
}
|
|
4466
4536
|
m.d.clear();
|
|
4467
4537
|
let w = !0;
|
|
4468
|
-
function
|
|
4538
|
+
function x() {
|
|
4469
4539
|
o.has(e) && (E(n, e), S(n), h(n));
|
|
4470
4540
|
}
|
|
4471
4541
|
function A(R) {
|
|
4472
4542
|
var a;
|
|
4473
4543
|
if (R === e) {
|
|
4474
4544
|
const p = f(n, R);
|
|
4475
|
-
if (!
|
|
4476
|
-
if (
|
|
4477
|
-
|
|
4545
|
+
if (!rn(p))
|
|
4546
|
+
if (xn(R))
|
|
4547
|
+
et(n, R, R.init);
|
|
4478
4548
|
else
|
|
4479
4549
|
throw new Error("no atom init");
|
|
4480
|
-
return
|
|
4550
|
+
return ze(p);
|
|
4481
4551
|
}
|
|
4482
|
-
const
|
|
4552
|
+
const u = y(n, R);
|
|
4483
4553
|
try {
|
|
4484
|
-
return
|
|
4554
|
+
return ze(u);
|
|
4485
4555
|
} finally {
|
|
4486
|
-
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();
|
|
4487
4557
|
}
|
|
4488
4558
|
}
|
|
4489
4559
|
let P, M;
|
|
@@ -4492,7 +4562,7 @@ const Gs = (n, e, ...t) => e.read(...t), Vs = (n, e, ...t) => e.write(...t), qs
|
|
|
4492
4562
|
return P || (P = new AbortController()), P.signal;
|
|
4493
4563
|
},
|
|
4494
4564
|
get setSelf() {
|
|
4495
|
-
return (ue ? "production" : void 0) !== "production" && !
|
|
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) => {
|
|
4496
4566
|
if ((ue ? "production" : void 0) !== "production" && w && console.warn("setSelf function cannot be called in sync"), !w)
|
|
4497
4567
|
try {
|
|
4498
4568
|
return v(n, e, ...R);
|
|
@@ -4503,43 +4573,43 @@ const Gs = (n, e, ...t) => e.read(...t), Vs = (n, e, ...t) => e.write(...t), qs
|
|
|
4503
4573
|
}
|
|
4504
4574
|
}, F = m.n;
|
|
4505
4575
|
try {
|
|
4506
|
-
(ue ? "production" : void 0) !== "production" &&
|
|
4576
|
+
(ue ? "production" : void 0) !== "production" && mt.delete(n);
|
|
4507
4577
|
const R = l(n, e, A, q);
|
|
4508
|
-
return (ue ? "production" : void 0) !== "production" &&
|
|
4578
|
+
return (ue ? "production" : void 0) !== "production" && mt.has(n) && console.warn(
|
|
4509
4579
|
"Detected store mutation during atom read. This is not supported."
|
|
4510
|
-
),
|
|
4580
|
+
), et(n, e, R), Ze(R) && (vt(R, () => P?.abort()), R.then(x, x)), (t = d.r) == null || t.call(d, e), m;
|
|
4511
4581
|
} catch (R) {
|
|
4512
4582
|
return delete m.v, m.e = R, ++m.n, m;
|
|
4513
4583
|
} finally {
|
|
4514
|
-
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));
|
|
4515
4585
|
}
|
|
4516
|
-
},
|
|
4586
|
+
}, to = (n, e) => {
|
|
4517
4587
|
const t = Z(n), i = t[1], s = t[2], o = t[11], r = [e];
|
|
4518
4588
|
for (; r.length; ) {
|
|
4519
|
-
const c = r.pop(),
|
|
4520
|
-
for (const l of
|
|
4589
|
+
const c = r.pop(), d = o(n, c);
|
|
4590
|
+
for (const l of Pn(c, d, i)) {
|
|
4521
4591
|
const f = o(n, l);
|
|
4522
4592
|
s.set(l, f.n), r.push(l);
|
|
4523
4593
|
}
|
|
4524
4594
|
}
|
|
4525
|
-
},
|
|
4526
|
-
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];
|
|
4527
4597
|
let y = !0;
|
|
4528
|
-
const v = (m) =>
|
|
4529
|
-
var
|
|
4598
|
+
const v = (m) => ze(f(n, m)), E = (m, ...w) => {
|
|
4599
|
+
var x;
|
|
4530
4600
|
const A = c(n, m);
|
|
4531
4601
|
try {
|
|
4532
4602
|
if (m === e) {
|
|
4533
|
-
if (!
|
|
4603
|
+
if (!xn(m))
|
|
4534
4604
|
throw new Error("atom not writable");
|
|
4535
|
-
(ue ? "production" : void 0) !== "production" &&
|
|
4605
|
+
(ue ? "production" : void 0) !== "production" && mt.add(n);
|
|
4536
4606
|
const P = A.n, M = w[0];
|
|
4537
|
-
|
|
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));
|
|
4538
4608
|
return;
|
|
4539
4609
|
} else
|
|
4540
|
-
return
|
|
4610
|
+
return Mn(n, m, ...w);
|
|
4541
4611
|
} finally {
|
|
4542
|
-
y || (l(n),
|
|
4612
|
+
y || (l(n), d(n));
|
|
4543
4613
|
}
|
|
4544
4614
|
};
|
|
4545
4615
|
try {
|
|
@@ -4547,14 +4617,14 @@ const Gs = (n, e, ...t) => e.read(...t), Vs = (n, e, ...t) => e.write(...t), qs
|
|
|
4547
4617
|
} finally {
|
|
4548
4618
|
y = !1;
|
|
4549
4619
|
}
|
|
4550
|
-
},
|
|
4620
|
+
}, no = (n, e) => {
|
|
4551
4621
|
var t;
|
|
4552
|
-
const i = Z(n), s = i[1], o = i[3], r = i[6], c = i[11],
|
|
4553
|
-
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)) {
|
|
4554
4624
|
for (const [y, v] of h.d)
|
|
4555
4625
|
if (!S.d.has(y)) {
|
|
4556
4626
|
const E = c(n, y);
|
|
4557
|
-
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));
|
|
4558
4628
|
}
|
|
4559
4629
|
for (const y of S.d)
|
|
4560
4630
|
if (!h.d.has(y)) {
|
|
@@ -4563,34 +4633,34 @@ const Gs = (n, e, ...t) => e.read(...t), Vs = (n, e, ...t) => e.write(...t), qs
|
|
|
4563
4633
|
v?.t.delete(e);
|
|
4564
4634
|
}
|
|
4565
4635
|
}
|
|
4566
|
-
},
|
|
4636
|
+
}, Un = (n, e) => {
|
|
4567
4637
|
var t;
|
|
4568
|
-
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);
|
|
4569
4639
|
let v = s.get(e);
|
|
4570
4640
|
if (!v) {
|
|
4571
4641
|
h(n, e);
|
|
4572
4642
|
for (const E of y.d.keys())
|
|
4573
|
-
|
|
4643
|
+
Un(n, E).t.add(e);
|
|
4574
4644
|
if (v = {
|
|
4575
4645
|
l: /* @__PURE__ */ new Set(),
|
|
4576
4646
|
d: new Set(y.d.keys()),
|
|
4577
4647
|
t: /* @__PURE__ */ new Set()
|
|
4578
|
-
}, s.set(e, v),
|
|
4648
|
+
}, s.set(e, v), gt(e)) {
|
|
4579
4649
|
const E = () => {
|
|
4580
4650
|
let m = !0;
|
|
4581
|
-
const w = (...
|
|
4651
|
+
const w = (...x) => {
|
|
4582
4652
|
try {
|
|
4583
|
-
return S(n, e, ...
|
|
4653
|
+
return S(n, e, ...x);
|
|
4584
4654
|
} finally {
|
|
4585
4655
|
m || (f(n), l(n));
|
|
4586
4656
|
}
|
|
4587
4657
|
};
|
|
4588
4658
|
try {
|
|
4589
|
-
const
|
|
4590
|
-
|
|
4659
|
+
const x = c(n, e, w);
|
|
4660
|
+
x && (v.u = () => {
|
|
4591
4661
|
m = !0;
|
|
4592
4662
|
try {
|
|
4593
|
-
|
|
4663
|
+
x();
|
|
4594
4664
|
} finally {
|
|
4595
4665
|
m = !1;
|
|
4596
4666
|
}
|
|
@@ -4604,9 +4674,9 @@ const Gs = (n, e, ...t) => e.read(...t), Vs = (n, e, ...t) => e.write(...t), qs
|
|
|
4604
4674
|
(t = r.m) == null || t.call(r, e);
|
|
4605
4675
|
}
|
|
4606
4676
|
return v;
|
|
4607
|
-
},
|
|
4677
|
+
}, io = (n, e) => {
|
|
4608
4678
|
var t, i;
|
|
4609
|
-
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);
|
|
4610
4680
|
let h = o.get(e);
|
|
4611
4681
|
if (!h || h.l.size)
|
|
4612
4682
|
return h;
|
|
@@ -4626,40 +4696,40 @@ const Gs = (n, e, ...t) => e.read(...t), Vs = (n, e, ...t) => e.write(...t), qs
|
|
|
4626
4696
|
return;
|
|
4627
4697
|
}
|
|
4628
4698
|
return h;
|
|
4629
|
-
},
|
|
4699
|
+
}, et = (n, e, t) => {
|
|
4630
4700
|
const i = Z(n)[11], s = i(n, e), o = "v" in s, r = s.v;
|
|
4631
|
-
if (
|
|
4701
|
+
if (Ze(t))
|
|
4632
4702
|
for (const c of s.d.keys())
|
|
4633
|
-
|
|
4703
|
+
Dn(
|
|
4634
4704
|
e,
|
|
4635
4705
|
t,
|
|
4636
4706
|
i(n, c)
|
|
4637
4707
|
);
|
|
4638
|
-
s.v = t, delete s.e, (!o || !Object.is(r, s.v)) && (++s.n,
|
|
4639
|
-
},
|
|
4708
|
+
s.v = t, delete s.e, (!o || !Object.is(r, s.v)) && (++s.n, Ze(r) && qs(r));
|
|
4709
|
+
}, so = (n, e) => {
|
|
4640
4710
|
const t = Z(n)[14];
|
|
4641
|
-
return
|
|
4642
|
-
},
|
|
4711
|
+
return ze(t(n, e));
|
|
4712
|
+
}, oo = (n, e, ...t) => {
|
|
4643
4713
|
const i = Z(n), s = i[12], o = i[13], r = i[16];
|
|
4644
4714
|
try {
|
|
4645
4715
|
return r(n, e, ...t);
|
|
4646
4716
|
} finally {
|
|
4647
4717
|
o(n), s(n);
|
|
4648
4718
|
}
|
|
4649
|
-
},
|
|
4650
|
-
const i = Z(n), s = i[12], o = i[18], r = i[19],
|
|
4651
|
-
return
|
|
4652
|
-
|
|
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);
|
|
4653
4723
|
};
|
|
4654
|
-
},
|
|
4655
|
-
const e =
|
|
4724
|
+
}, Fn = /* @__PURE__ */ new WeakMap(), Z = (n) => {
|
|
4725
|
+
const e = Fn.get(n);
|
|
4656
4726
|
if ((ue ? "production" : void 0) !== "production" && !e)
|
|
4657
4727
|
throw new Error(
|
|
4658
4728
|
"Store must be created by buildStore to read its building blocks"
|
|
4659
4729
|
);
|
|
4660
4730
|
return e;
|
|
4661
4731
|
};
|
|
4662
|
-
function
|
|
4732
|
+
function ao(...n) {
|
|
4663
4733
|
const e = {
|
|
4664
4734
|
get(i) {
|
|
4665
4735
|
const s = Z(e)[21];
|
|
@@ -4690,63 +4760,63 @@ function so(...n) {
|
|
|
4690
4760
|
{},
|
|
4691
4761
|
// storeHooks
|
|
4692
4762
|
// atom interceptors
|
|
4693
|
-
Gs,
|
|
4694
|
-
Vs,
|
|
4695
|
-
qs,
|
|
4696
4763
|
Ys,
|
|
4697
|
-
// building-block functions
|
|
4698
4764
|
Js,
|
|
4699
4765
|
Ks,
|
|
4700
4766
|
Xs,
|
|
4767
|
+
// building-block functions
|
|
4701
4768
|
zs,
|
|
4702
4769
|
Qs,
|
|
4703
|
-
Dn,
|
|
4704
4770
|
Zs,
|
|
4705
|
-
Pn,
|
|
4706
4771
|
eo,
|
|
4707
|
-
Ze,
|
|
4708
4772
|
to,
|
|
4773
|
+
Mn,
|
|
4709
4774
|
no,
|
|
4775
|
+
Un,
|
|
4710
4776
|
io,
|
|
4777
|
+
et,
|
|
4778
|
+
so,
|
|
4779
|
+
oo,
|
|
4780
|
+
ro,
|
|
4711
4781
|
void 0
|
|
4712
4782
|
].map((i, s) => n[s] || i);
|
|
4713
|
-
return
|
|
4783
|
+
return Fn.set(e, Object.freeze(t)), e;
|
|
4714
4784
|
}
|
|
4715
|
-
const
|
|
4716
|
-
let
|
|
4717
|
-
function
|
|
4718
|
-
const t = `atom${++
|
|
4785
|
+
const jn = {};
|
|
4786
|
+
let co = 0;
|
|
4787
|
+
function tt(n, e) {
|
|
4788
|
+
const t = `atom${++co}`, i = {
|
|
4719
4789
|
toString() {
|
|
4720
|
-
return (
|
|
4790
|
+
return (jn ? "production" : void 0) !== "production" && this.debugLabel ? t + ":" + this.debugLabel : t;
|
|
4721
4791
|
}
|
|
4722
4792
|
};
|
|
4723
|
-
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;
|
|
4724
4794
|
}
|
|
4725
|
-
function
|
|
4795
|
+
function lo(n) {
|
|
4726
4796
|
return n(this);
|
|
4727
4797
|
}
|
|
4728
|
-
function
|
|
4798
|
+
function uo(n, e, t) {
|
|
4729
4799
|
return e(
|
|
4730
4800
|
this,
|
|
4731
4801
|
typeof t == "function" ? t(n(this)) : t
|
|
4732
4802
|
);
|
|
4733
4803
|
}
|
|
4734
|
-
function
|
|
4735
|
-
return
|
|
4804
|
+
function ho() {
|
|
4805
|
+
return ao();
|
|
4736
4806
|
}
|
|
4737
4807
|
let Ie;
|
|
4738
|
-
function
|
|
4739
|
-
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(
|
|
4740
4810
|
"Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
|
|
4741
4811
|
))), Ie;
|
|
4742
4812
|
}
|
|
4743
|
-
const
|
|
4813
|
+
const fo = {}, go = ln(
|
|
4744
4814
|
void 0
|
|
4745
4815
|
);
|
|
4746
|
-
function
|
|
4747
|
-
return
|
|
4816
|
+
function Bn(n) {
|
|
4817
|
+
return cn(go) || po();
|
|
4748
4818
|
}
|
|
4749
|
-
const
|
|
4819
|
+
const _t = (n) => typeof n?.then == "function", yt = (n) => {
|
|
4750
4820
|
n.status || (n.status = "pending", n.then(
|
|
4751
4821
|
(e) => {
|
|
4752
4822
|
n.status = "fulfilled", n.value = e;
|
|
@@ -4755,34 +4825,34 @@ const mt = (n) => typeof n?.then == "function", _t = (n) => {
|
|
|
4755
4825
|
n.status = "rejected", n.reason = e;
|
|
4756
4826
|
}
|
|
4757
4827
|
));
|
|
4758
|
-
},
|
|
4828
|
+
}, vo = St.use || // A shim for older React versions
|
|
4759
4829
|
((n) => {
|
|
4760
4830
|
if (n.status === "pending")
|
|
4761
4831
|
throw n;
|
|
4762
4832
|
if (n.status === "fulfilled")
|
|
4763
4833
|
return n.value;
|
|
4764
|
-
throw n.status === "rejected" ? n.reason : (
|
|
4765
|
-
}),
|
|
4766
|
-
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);
|
|
4767
4837
|
return t || (t = new Promise((i, s) => {
|
|
4768
4838
|
let o = n;
|
|
4769
4839
|
const r = (l) => (f) => {
|
|
4770
4840
|
o === l && i(f);
|
|
4771
4841
|
}, c = (l) => (f) => {
|
|
4772
4842
|
o === l && s(f);
|
|
4773
|
-
},
|
|
4843
|
+
}, d = () => {
|
|
4774
4844
|
try {
|
|
4775
4845
|
const l = e();
|
|
4776
|
-
|
|
4846
|
+
_t(l) ? (dt.set(l, t), o = l, l.then(r(l), c(l)), vt(l, d)) : i(l);
|
|
4777
4847
|
} catch (l) {
|
|
4778
4848
|
s(l);
|
|
4779
4849
|
}
|
|
4780
4850
|
};
|
|
4781
|
-
n.then(r(n), c(n)),
|
|
4782
|
-
}),
|
|
4851
|
+
n.then(r(n), c(n)), vt(n, d);
|
|
4852
|
+
}), dt.set(n, t)), t;
|
|
4783
4853
|
};
|
|
4784
|
-
function
|
|
4785
|
-
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(
|
|
4786
4856
|
(f) => {
|
|
4787
4857
|
const h = s.get(n);
|
|
4788
4858
|
return Object.is(f[0], h) && f[1] === s && f[2] === n ? f : [h, s, n];
|
|
@@ -4791,55 +4861,55 @@ function tt(n, e) {
|
|
|
4791
4861
|
() => [s.get(n), s, n]
|
|
4792
4862
|
);
|
|
4793
4863
|
let l = o;
|
|
4794
|
-
if ((r !== s || c !== n) && (
|
|
4864
|
+
if ((r !== s || c !== n) && (d(), l = s.get(n)), ve(() => {
|
|
4795
4865
|
const f = s.sub(n, () => {
|
|
4796
4866
|
if (i)
|
|
4797
4867
|
try {
|
|
4798
4868
|
const h = s.get(n);
|
|
4799
|
-
|
|
4800
|
-
|
|
4869
|
+
_t(h) && yt(
|
|
4870
|
+
an(h, () => s.get(n))
|
|
4801
4871
|
);
|
|
4802
4872
|
} catch {
|
|
4803
4873
|
}
|
|
4804
4874
|
if (typeof t == "number") {
|
|
4805
|
-
setTimeout(
|
|
4875
|
+
setTimeout(d, t);
|
|
4806
4876
|
return;
|
|
4807
4877
|
}
|
|
4808
|
-
|
|
4878
|
+
d();
|
|
4809
4879
|
});
|
|
4810
|
-
return
|
|
4811
|
-
}, [s, n, t, i]),
|
|
4812
|
-
const f =
|
|
4813
|
-
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);
|
|
4814
4884
|
}
|
|
4815
4885
|
return l;
|
|
4816
4886
|
}
|
|
4817
|
-
function
|
|
4818
|
-
const t =
|
|
4819
|
-
return
|
|
4887
|
+
function it(n, e) {
|
|
4888
|
+
const t = Bn();
|
|
4889
|
+
return Kn(
|
|
4820
4890
|
(...s) => {
|
|
4821
|
-
if ((
|
|
4891
|
+
if ((fo ? "production" : void 0) !== "production" && !("write" in n))
|
|
4822
4892
|
throw new Error("not writable atom");
|
|
4823
4893
|
return t.set(n, ...s);
|
|
4824
4894
|
},
|
|
4825
4895
|
[t, n]
|
|
4826
4896
|
);
|
|
4827
4897
|
}
|
|
4828
|
-
const
|
|
4829
|
-
function
|
|
4830
|
-
return
|
|
4898
|
+
const Hn = tt([]);
|
|
4899
|
+
function To() {
|
|
4900
|
+
return nt(Hn);
|
|
4831
4901
|
}
|
|
4832
|
-
function
|
|
4833
|
-
return
|
|
4902
|
+
function mo() {
|
|
4903
|
+
return it(Hn);
|
|
4834
4904
|
}
|
|
4835
|
-
const
|
|
4836
|
-
const n =
|
|
4905
|
+
const st = () => {
|
|
4906
|
+
const n = cn(Vn);
|
|
4837
4907
|
if (!n)
|
|
4838
4908
|
throw new Error("useClient must be used within a TelnyxAIAgentProvider");
|
|
4839
4909
|
return n;
|
|
4840
4910
|
};
|
|
4841
|
-
function
|
|
4842
|
-
const n =
|
|
4911
|
+
function _o() {
|
|
4912
|
+
const n = st(), e = mo();
|
|
4843
4913
|
return ve(() => {
|
|
4844
4914
|
const t = (i) => e((s) => [...s, i]);
|
|
4845
4915
|
return n.addListener("transcript.item", t), () => {
|
|
@@ -4847,15 +4917,15 @@ function go() {
|
|
|
4847
4917
|
};
|
|
4848
4918
|
}, [n, e]), null;
|
|
4849
4919
|
}
|
|
4850
|
-
const
|
|
4851
|
-
function
|
|
4852
|
-
return
|
|
4920
|
+
const $n = tt("connecting");
|
|
4921
|
+
function ko() {
|
|
4922
|
+
return nt($n);
|
|
4853
4923
|
}
|
|
4854
|
-
function
|
|
4855
|
-
return
|
|
4924
|
+
function yo() {
|
|
4925
|
+
return it($n);
|
|
4856
4926
|
}
|
|
4857
|
-
function
|
|
4858
|
-
const n =
|
|
4927
|
+
function So() {
|
|
4928
|
+
const n = st(), e = yo();
|
|
4859
4929
|
return ve(() => {
|
|
4860
4930
|
const t = () => e("connected"), i = () => e("disconnected"), s = () => e("error");
|
|
4861
4931
|
return n.addListener("agent.connected", t), n.addListener("agent.disconnected", i), n.addListener("agent.error", s), () => {
|
|
@@ -4863,15 +4933,15 @@ function mo() {
|
|
|
4863
4933
|
};
|
|
4864
4934
|
}, [n, e]), null;
|
|
4865
4935
|
}
|
|
4866
|
-
const
|
|
4867
|
-
function
|
|
4868
|
-
return
|
|
4936
|
+
const Wn = tt(null);
|
|
4937
|
+
function Ro() {
|
|
4938
|
+
return nt(Wn);
|
|
4869
4939
|
}
|
|
4870
|
-
function
|
|
4871
|
-
return
|
|
4940
|
+
function bo() {
|
|
4941
|
+
return it(Wn);
|
|
4872
4942
|
}
|
|
4873
|
-
const
|
|
4874
|
-
const n =
|
|
4943
|
+
const Co = () => {
|
|
4944
|
+
const n = st(), e = bo();
|
|
4875
4945
|
return ve(() => {
|
|
4876
4946
|
const t = (i) => {
|
|
4877
4947
|
e(i);
|
|
@@ -4880,15 +4950,15 @@ const yo = () => {
|
|
|
4880
4950
|
n.removeListener("conversation.update", t);
|
|
4881
4951
|
};
|
|
4882
4952
|
}, [n, e]), null;
|
|
4883
|
-
},
|
|
4884
|
-
function
|
|
4885
|
-
return
|
|
4953
|
+
}, Gn = tt({ state: "listening" });
|
|
4954
|
+
function Ao() {
|
|
4955
|
+
return nt(Gn);
|
|
4886
4956
|
}
|
|
4887
|
-
function
|
|
4888
|
-
return
|
|
4957
|
+
function wo() {
|
|
4958
|
+
return it(Gn);
|
|
4889
4959
|
}
|
|
4890
|
-
function
|
|
4891
|
-
const n =
|
|
4960
|
+
function Eo() {
|
|
4961
|
+
const n = st(), e = wo();
|
|
4892
4962
|
return ve(() => {
|
|
4893
4963
|
const t = (i) => {
|
|
4894
4964
|
e(i);
|
|
@@ -4898,7 +4968,7 @@ function bo() {
|
|
|
4898
4968
|
};
|
|
4899
4969
|
}, [n, e]), null;
|
|
4900
4970
|
}
|
|
4901
|
-
const
|
|
4971
|
+
const Vn = ln(null), Oo = ({
|
|
4902
4972
|
children: n,
|
|
4903
4973
|
agentId: e,
|
|
4904
4974
|
environment: t,
|
|
@@ -4906,36 +4976,36 @@ const Hn = an(null), ko = ({
|
|
|
4906
4976
|
debug: s,
|
|
4907
4977
|
vad: o
|
|
4908
4978
|
}) => {
|
|
4909
|
-
const [r, c] =
|
|
4979
|
+
const [r, c] = Xn(() => new tn({ agentId: e, environment: t, versionId: i, debug: s, vad: o }));
|
|
4910
4980
|
return ve(() => {
|
|
4911
4981
|
if (!r) {
|
|
4912
|
-
const
|
|
4913
|
-
return c(
|
|
4914
|
-
|
|
4982
|
+
const d = new tn({ agentId: e, environment: t, versionId: i, vad: o });
|
|
4983
|
+
return c(d), () => {
|
|
4984
|
+
d.disconnect();
|
|
4915
4985
|
};
|
|
4916
4986
|
}
|
|
4917
4987
|
}, [e, r, t, i, o]), ve(() => {
|
|
4918
4988
|
r?.connect();
|
|
4919
|
-
}, [r]), /* @__PURE__ */ Ee.jsxs(
|
|
4920
|
-
/* @__PURE__ */ Ee.jsx(
|
|
4921
|
-
/* @__PURE__ */ Ee.jsx(
|
|
4922
|
-
/* @__PURE__ */ Ee.jsx(
|
|
4923
|
-
/* @__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, {}),
|
|
4924
4994
|
n
|
|
4925
4995
|
] });
|
|
4926
4996
|
};
|
|
4927
4997
|
export {
|
|
4928
|
-
|
|
4998
|
+
Vn as ClientContext,
|
|
4929
4999
|
T as SwEvent,
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
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
|
|
4941
5011
|
};
|