@elevenlabs/client 1.6.0 → 1.7.1
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/BaseConversation.d.ts +5 -4
- package/dist/BaseConversation.d.ts.map +1 -1
- package/dist/BaseConversation.js +16 -1
- package/dist/BaseConversation.js.map +1 -1
- package/dist/lib.iife.js +610 -581
- package/dist/lib.iife.js.map +1 -1
- package/dist/types.d.ts +83 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +29 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/BaseConnection.d.ts +4 -2
- package/dist/utils/BaseConnection.d.ts.map +1 -1
- package/dist/utils/WebRTCConnection.d.ts.map +1 -1
- package/dist/utils/WebRTCConnection.js +6 -1
- package/dist/utils/WebRTCConnection.js.map +1 -1
- package/dist/utils/events.d.ts +4 -2
- package/dist/utils/events.d.ts.map +1 -1
- package/dist/utils/events.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
package/dist/lib.iife.js
CHANGED
|
@@ -193,6 +193,13 @@ var ElevenLabsClient = (function(exports) {
|
|
|
193
193
|
});
|
|
194
194
|
if (this.options.onAgentToolResponse) this.options.onAgentToolResponse(event.agent_tool_response);
|
|
195
195
|
}
|
|
196
|
+
handleAgentToolResponseFullPayload(event) {
|
|
197
|
+
if (event.agent_tool_response_full_payload.tool_name === "end_call") this.endSessionWithDetails({
|
|
198
|
+
reason: "agent",
|
|
199
|
+
context: new CloseEvent("end_call", { reason: "Agent ended the call" })
|
|
200
|
+
});
|
|
201
|
+
if (this.options.onAgentToolResponse) this.options.onAgentToolResponse(event.agent_tool_response_full_payload);
|
|
202
|
+
}
|
|
196
203
|
handleConversationMetadata(event) {
|
|
197
204
|
if (this.options.onConversationMetadata) this.options.onConversationMetadata(event.conversation_initiation_metadata_event);
|
|
198
205
|
}
|
|
@@ -274,6 +281,9 @@ var ElevenLabsClient = (function(exports) {
|
|
|
274
281
|
case "agent_tool_response":
|
|
275
282
|
this.handleAgentToolResponse(parsedEvent);
|
|
276
283
|
return;
|
|
284
|
+
case "agent_tool_response_full_payload":
|
|
285
|
+
this.handleAgentToolResponseFullPayload(parsedEvent);
|
|
286
|
+
return;
|
|
277
287
|
case "conversation_initiation_metadata":
|
|
278
288
|
this.handleConversationMetadata(parsedEvent);
|
|
279
289
|
return;
|
|
@@ -432,7 +442,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
432
442
|
//#region src/sourceInfo.ts
|
|
433
443
|
let sourceInfo = Object.freeze({
|
|
434
444
|
name: "js_sdk",
|
|
435
|
-
version: "1.
|
|
445
|
+
version: "1.7.1"
|
|
436
446
|
});
|
|
437
447
|
//#endregion
|
|
438
448
|
//#region src/utils/events.ts
|
|
@@ -595,7 +605,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
595
605
|
}
|
|
596
606
|
};
|
|
597
607
|
//#endregion
|
|
598
|
-
//#region ../../node_modules/.pnpm/livekit-client@2.16.
|
|
608
|
+
//#region ../../node_modules/.pnpm/livekit-client@2.16.1_patch_hash=d922ae1654b16c2729a80163c34eb23e5844912948547243600e8c_d1ce20d6e8ed22c8e8eab81412419be8/node_modules/livekit-client/dist/livekit-client.esm.mjs
|
|
599
609
|
function _mergeNamespaces(n, m) {
|
|
600
610
|
m.forEach(function(e) {
|
|
601
611
|
e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
|
|
@@ -6817,20 +6827,6 @@ var ElevenLabsClient = (function(exports) {
|
|
|
6817
6827
|
return retryDelay + Math.random() * 1e3;
|
|
6818
6828
|
}
|
|
6819
6829
|
};
|
|
6820
|
-
/******************************************************************************
|
|
6821
|
-
Copyright (c) Microsoft Corporation.
|
|
6822
|
-
|
|
6823
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6824
|
-
purpose with or without fee is hereby granted.
|
|
6825
|
-
|
|
6826
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
6827
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
6828
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
6829
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
6830
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
6831
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
6832
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
6833
|
-
***************************************************************************** */
|
|
6834
6830
|
function __rest(s, e) {
|
|
6835
6831
|
var t = {};
|
|
6836
6832
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -9176,44 +9172,68 @@ var ElevenLabsClient = (function(exports) {
|
|
|
9176
9172
|
return adapter;
|
|
9177
9173
|
}
|
|
9178
9174
|
adapterFactory({ window: typeof window === "undefined" ? void 0 : window });
|
|
9179
|
-
const
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
(function(EncryptionEvent) {
|
|
9197
|
-
EncryptionEvent["ParticipantEncryptionStatusChanged"] = "participantEncryptionStatusChanged";
|
|
9198
|
-
EncryptionEvent["EncryptionError"] = "encryptionError";
|
|
9199
|
-
})(EncryptionEvent || (EncryptionEvent = {}));
|
|
9200
|
-
var CryptorEvent;
|
|
9201
|
-
(function(CryptorEvent) {
|
|
9202
|
-
CryptorEvent["Error"] = "cryptorError";
|
|
9203
|
-
})(CryptorEvent || (CryptorEvent = {}));
|
|
9204
|
-
function isE2EESupported() {
|
|
9205
|
-
return isInsertableStreamSupported() || isScriptTransformSupported();
|
|
9206
|
-
}
|
|
9207
|
-
function isScriptTransformSupported() {
|
|
9208
|
-
return typeof window.RTCRtpScriptTransform !== "undefined";
|
|
9175
|
+
const commonVersionIdentifier = /version\/(\d+(\.?_?\d+)+)/i;
|
|
9176
|
+
let browserDetails;
|
|
9177
|
+
/**
|
|
9178
|
+
* @internal
|
|
9179
|
+
*/
|
|
9180
|
+
function getBrowser(userAgent) {
|
|
9181
|
+
let force = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
9182
|
+
if (typeof userAgent === "undefined" && typeof navigator === "undefined") return;
|
|
9183
|
+
const ua = (userAgent !== null && userAgent !== void 0 ? userAgent : navigator.userAgent).toLowerCase();
|
|
9184
|
+
if (browserDetails === void 0 || force) {
|
|
9185
|
+
const browser = browsersList.find((_ref) => {
|
|
9186
|
+
let { test } = _ref;
|
|
9187
|
+
return test.test(ua);
|
|
9188
|
+
});
|
|
9189
|
+
browserDetails = browser === null || browser === void 0 ? void 0 : browser.describe(ua);
|
|
9190
|
+
}
|
|
9191
|
+
return browserDetails;
|
|
9209
9192
|
}
|
|
9210
|
-
|
|
9211
|
-
|
|
9193
|
+
const browsersList = [
|
|
9194
|
+
{
|
|
9195
|
+
test: /firefox|iceweasel|fxios/i,
|
|
9196
|
+
describe(ua) {
|
|
9197
|
+
return {
|
|
9198
|
+
name: "Firefox",
|
|
9199
|
+
version: getMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i, ua),
|
|
9200
|
+
os: ua.toLowerCase().includes("fxios") ? "iOS" : void 0,
|
|
9201
|
+
osVersion: getOSVersion(ua)
|
|
9202
|
+
};
|
|
9203
|
+
}
|
|
9204
|
+
},
|
|
9205
|
+
{
|
|
9206
|
+
test: /chrom|crios|crmo/i,
|
|
9207
|
+
describe(ua) {
|
|
9208
|
+
return {
|
|
9209
|
+
name: "Chrome",
|
|
9210
|
+
version: getMatch(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua),
|
|
9211
|
+
os: ua.toLowerCase().includes("crios") ? "iOS" : void 0,
|
|
9212
|
+
osVersion: getOSVersion(ua)
|
|
9213
|
+
};
|
|
9214
|
+
}
|
|
9215
|
+
},
|
|
9216
|
+
{
|
|
9217
|
+
test: /safari|applewebkit/i,
|
|
9218
|
+
describe(ua) {
|
|
9219
|
+
return {
|
|
9220
|
+
name: "Safari",
|
|
9221
|
+
version: getMatch(commonVersionIdentifier, ua),
|
|
9222
|
+
os: ua.includes("mobile/") ? "iOS" : "macOS",
|
|
9223
|
+
osVersion: getOSVersion(ua)
|
|
9224
|
+
};
|
|
9225
|
+
}
|
|
9226
|
+
}
|
|
9227
|
+
];
|
|
9228
|
+
function getMatch(exp, ua) {
|
|
9229
|
+
let id = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
|
|
9230
|
+
const match = ua.match(exp);
|
|
9231
|
+
return match && match.length >= id && match[id] || "";
|
|
9212
9232
|
}
|
|
9213
|
-
function
|
|
9214
|
-
|
|
9215
|
-
if (((_a = packet.value) === null || _a === void 0 ? void 0 : _a.case) !== "sipDtmf" && ((_b = packet.value) === null || _b === void 0 ? void 0 : _b.case) !== "metrics" && ((_c = packet.value) === null || _c === void 0 ? void 0 : _c.case) !== "speaker" && ((_d = packet.value) === null || _d === void 0 ? void 0 : _d.case) !== "transcription" && ((_e = packet.value) === null || _e === void 0 ? void 0 : _e.case) !== "encryptedPacket") return new EncryptedPacketPayload({ value: packet.value });
|
|
9233
|
+
function getOSVersion(ua) {
|
|
9234
|
+
return ua.includes("mac os") ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, ".") : void 0;
|
|
9216
9235
|
}
|
|
9236
|
+
const version = "2.16.1";
|
|
9217
9237
|
var LivekitError = class extends Error {
|
|
9218
9238
|
constructor(code, message) {
|
|
9219
9239
|
super(message || "an error has occured");
|
|
@@ -9229,8 +9249,9 @@ var ElevenLabsClient = (function(exports) {
|
|
|
9229
9249
|
ConnectionErrorReason[ConnectionErrorReason["Cancelled"] = 3] = "Cancelled";
|
|
9230
9250
|
ConnectionErrorReason[ConnectionErrorReason["LeaveRequest"] = 4] = "LeaveRequest";
|
|
9231
9251
|
ConnectionErrorReason[ConnectionErrorReason["Timeout"] = 5] = "Timeout";
|
|
9252
|
+
ConnectionErrorReason[ConnectionErrorReason["WebSocket"] = 6] = "WebSocket";
|
|
9232
9253
|
})(ConnectionErrorReason || (ConnectionErrorReason = {}));
|
|
9233
|
-
var ConnectionError = class extends LivekitError {
|
|
9254
|
+
var ConnectionError = class ConnectionError extends LivekitError {
|
|
9234
9255
|
constructor(message, reason, status, context) {
|
|
9235
9256
|
super(1, message);
|
|
9236
9257
|
this.name = "ConnectionError";
|
|
@@ -9239,6 +9260,27 @@ var ElevenLabsClient = (function(exports) {
|
|
|
9239
9260
|
this.context = context;
|
|
9240
9261
|
this.reasonName = ConnectionErrorReason[reason];
|
|
9241
9262
|
}
|
|
9263
|
+
static notAllowed(message, status, context) {
|
|
9264
|
+
return new ConnectionError(message, ConnectionErrorReason.NotAllowed, status, context);
|
|
9265
|
+
}
|
|
9266
|
+
static timeout(message) {
|
|
9267
|
+
return new ConnectionError(message, ConnectionErrorReason.Timeout);
|
|
9268
|
+
}
|
|
9269
|
+
static leaveRequest(message, context) {
|
|
9270
|
+
return new ConnectionError(message, ConnectionErrorReason.LeaveRequest, void 0, context);
|
|
9271
|
+
}
|
|
9272
|
+
static internal(message, context) {
|
|
9273
|
+
return new ConnectionError(message, ConnectionErrorReason.InternalError, void 0, context);
|
|
9274
|
+
}
|
|
9275
|
+
static cancelled(message) {
|
|
9276
|
+
return new ConnectionError(message, ConnectionErrorReason.Cancelled);
|
|
9277
|
+
}
|
|
9278
|
+
static serverUnreachable(message, status) {
|
|
9279
|
+
return new ConnectionError(message, ConnectionErrorReason.ServerUnreachable, status);
|
|
9280
|
+
}
|
|
9281
|
+
static websocket(message, status, reason) {
|
|
9282
|
+
return new ConnectionError(message, ConnectionErrorReason.WebSocket, status, reason);
|
|
9283
|
+
}
|
|
9242
9284
|
};
|
|
9243
9285
|
var DeviceUnsupportedError = class extends LivekitError {
|
|
9244
9286
|
constructor(message) {
|
|
@@ -9280,6 +9322,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
9280
9322
|
var SignalRequestError = class extends LivekitError {
|
|
9281
9323
|
constructor(message, reason) {
|
|
9282
9324
|
super(15, message);
|
|
9325
|
+
this.name = "SignalRequestError";
|
|
9283
9326
|
this.reason = reason;
|
|
9284
9327
|
this.reasonName = typeof reason === "string" ? reason : RequestResponse_Reason[reason];
|
|
9285
9328
|
}
|
|
@@ -9302,6 +9345,12 @@ var ElevenLabsClient = (function(exports) {
|
|
|
9302
9345
|
this.reasonName = DataStreamErrorReason[reason];
|
|
9303
9346
|
}
|
|
9304
9347
|
};
|
|
9348
|
+
var SignalReconnectError = class extends LivekitError {
|
|
9349
|
+
constructor(message) {
|
|
9350
|
+
super(18, message);
|
|
9351
|
+
this.name = "SignalReconnectError";
|
|
9352
|
+
}
|
|
9353
|
+
};
|
|
9305
9354
|
var MediaDeviceFailure;
|
|
9306
9355
|
(function(MediaDeviceFailure) {
|
|
9307
9356
|
MediaDeviceFailure["PermissionDenied"] = "PermissionDenied";
|
|
@@ -9320,21 +9369,19 @@ var ElevenLabsClient = (function(exports) {
|
|
|
9320
9369
|
}
|
|
9321
9370
|
MediaDeviceFailure.getFailure = getFailure;
|
|
9322
9371
|
})(MediaDeviceFailure || (MediaDeviceFailure = {}));
|
|
9323
|
-
var
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
|
|
9335
|
-
|
|
9336
|
-
* ```
|
|
9337
|
-
*/
|
|
9372
|
+
var CriticalTimers = class {};
|
|
9373
|
+
CriticalTimers.setTimeout = function() {
|
|
9374
|
+
return setTimeout(...arguments);
|
|
9375
|
+
};
|
|
9376
|
+
CriticalTimers.setInterval = function() {
|
|
9377
|
+
return setInterval(...arguments);
|
|
9378
|
+
};
|
|
9379
|
+
CriticalTimers.clearTimeout = function() {
|
|
9380
|
+
return clearTimeout(...arguments);
|
|
9381
|
+
};
|
|
9382
|
+
CriticalTimers.clearInterval = function() {
|
|
9383
|
+
return clearInterval(...arguments);
|
|
9384
|
+
};
|
|
9338
9385
|
var RoomEvent;
|
|
9339
9386
|
(function(RoomEvent) {
|
|
9340
9387
|
/**
|
|
@@ -9950,86 +9997,338 @@ var ElevenLabsClient = (function(exports) {
|
|
|
9950
9997
|
return structuredClone(value);
|
|
9951
9998
|
} else return JSON.parse(JSON.stringify(value));
|
|
9952
9999
|
}
|
|
9953
|
-
|
|
9954
|
-
|
|
9955
|
-
|
|
9956
|
-
|
|
9957
|
-
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
9961
|
-
|
|
9962
|
-
|
|
9963
|
-
const browser = browsersList.find((_ref) => {
|
|
9964
|
-
let { test } = _ref;
|
|
9965
|
-
return test.test(ua);
|
|
9966
|
-
});
|
|
9967
|
-
browserDetails = browser === null || browser === void 0 ? void 0 : browser.describe(ua);
|
|
9968
|
-
}
|
|
9969
|
-
return browserDetails;
|
|
9970
|
-
}
|
|
9971
|
-
const browsersList = [
|
|
9972
|
-
{
|
|
9973
|
-
test: /firefox|iceweasel|fxios/i,
|
|
9974
|
-
describe(ua) {
|
|
9975
|
-
return {
|
|
9976
|
-
name: "Firefox",
|
|
9977
|
-
version: getMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i, ua),
|
|
9978
|
-
os: ua.toLowerCase().includes("fxios") ? "iOS" : void 0,
|
|
9979
|
-
osVersion: getOSVersion(ua)
|
|
9980
|
-
};
|
|
9981
|
-
}
|
|
9982
|
-
},
|
|
9983
|
-
{
|
|
9984
|
-
test: /chrom|crios|crmo/i,
|
|
9985
|
-
describe(ua) {
|
|
9986
|
-
return {
|
|
9987
|
-
name: "Chrome",
|
|
9988
|
-
version: getMatch(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua),
|
|
9989
|
-
os: ua.toLowerCase().includes("crios") ? "iOS" : void 0,
|
|
9990
|
-
osVersion: getOSVersion(ua)
|
|
10000
|
+
var VideoPreset = class {
|
|
10001
|
+
constructor(widthOrOptions, height, maxBitrate, maxFramerate, priority) {
|
|
10002
|
+
if (typeof widthOrOptions === "object") {
|
|
10003
|
+
this.width = widthOrOptions.width;
|
|
10004
|
+
this.height = widthOrOptions.height;
|
|
10005
|
+
this.aspectRatio = widthOrOptions.aspectRatio;
|
|
10006
|
+
this.encoding = {
|
|
10007
|
+
maxBitrate: widthOrOptions.maxBitrate,
|
|
10008
|
+
maxFramerate: widthOrOptions.maxFramerate,
|
|
10009
|
+
priority: widthOrOptions.priority
|
|
9991
10010
|
};
|
|
9992
|
-
}
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
|
|
9998
|
-
|
|
9999
|
-
|
|
10000
|
-
os: ua.includes("mobile/") ? "iOS" : "macOS",
|
|
10001
|
-
osVersion: getOSVersion(ua)
|
|
10011
|
+
} else if (height !== void 0 && maxBitrate !== void 0) {
|
|
10012
|
+
this.width = widthOrOptions;
|
|
10013
|
+
this.height = height;
|
|
10014
|
+
this.aspectRatio = widthOrOptions / height;
|
|
10015
|
+
this.encoding = {
|
|
10016
|
+
maxBitrate,
|
|
10017
|
+
maxFramerate,
|
|
10018
|
+
priority
|
|
10002
10019
|
};
|
|
10003
|
-
}
|
|
10020
|
+
} else throw new TypeError("Unsupported options: provide at least width, height and maxBitrate");
|
|
10021
|
+
}
|
|
10022
|
+
get resolution() {
|
|
10023
|
+
return {
|
|
10024
|
+
width: this.width,
|
|
10025
|
+
height: this.height,
|
|
10026
|
+
frameRate: this.encoding.maxFramerate,
|
|
10027
|
+
aspectRatio: this.aspectRatio
|
|
10028
|
+
};
|
|
10004
10029
|
}
|
|
10030
|
+
};
|
|
10031
|
+
const backupVideoCodecs = ["vp8", "h264"];
|
|
10032
|
+
const videoCodecs = [
|
|
10033
|
+
"vp8",
|
|
10034
|
+
"h264",
|
|
10035
|
+
"vp9",
|
|
10036
|
+
"av1",
|
|
10037
|
+
"h265"
|
|
10005
10038
|
];
|
|
10006
|
-
function
|
|
10007
|
-
|
|
10008
|
-
const match = ua.match(exp);
|
|
10009
|
-
return match && match.length >= id && match[id] || "";
|
|
10010
|
-
}
|
|
10011
|
-
function getOSVersion(ua) {
|
|
10012
|
-
return ua.includes("mac os") ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, ".") : void 0;
|
|
10039
|
+
function isBackupVideoCodec(codec) {
|
|
10040
|
+
return !!backupVideoCodecs.find((backup) => backup === codec);
|
|
10013
10041
|
}
|
|
10014
|
-
|
|
10042
|
+
/** @deprecated Use {@link isBackupVideoCodec} instead */
|
|
10043
|
+
const isBackupCodec = isBackupVideoCodec;
|
|
10044
|
+
var BackupCodecPolicy;
|
|
10045
|
+
(function(BackupCodecPolicy) {
|
|
10046
|
+
BackupCodecPolicy[BackupCodecPolicy["PREFER_REGRESSION"] = 0] = "PREFER_REGRESSION";
|
|
10047
|
+
BackupCodecPolicy[BackupCodecPolicy["SIMULCAST"] = 1] = "SIMULCAST";
|
|
10048
|
+
BackupCodecPolicy[BackupCodecPolicy["REGRESSION"] = 2] = "REGRESSION";
|
|
10049
|
+
})(BackupCodecPolicy || (BackupCodecPolicy = {}));
|
|
10050
|
+
var AudioPresets;
|
|
10051
|
+
(function(AudioPresets) {
|
|
10052
|
+
AudioPresets.telephone = { maxBitrate: 12e3 };
|
|
10053
|
+
AudioPresets.speech = { maxBitrate: 24e3 };
|
|
10054
|
+
AudioPresets.music = { maxBitrate: 48e3 };
|
|
10055
|
+
AudioPresets.musicStereo = { maxBitrate: 64e3 };
|
|
10056
|
+
AudioPresets.musicHighQuality = { maxBitrate: 96e3 };
|
|
10057
|
+
AudioPresets.musicHighQualityStereo = { maxBitrate: 128e3 };
|
|
10058
|
+
})(AudioPresets || (AudioPresets = {}));
|
|
10015
10059
|
/**
|
|
10016
|
-
*
|
|
10017
|
-
* that ensure that they are fired. These should be used when it is critical
|
|
10018
|
-
* that the timer fires on time.
|
|
10060
|
+
* Sane presets for video resolution/encoding
|
|
10019
10061
|
*/
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
|
|
10025
|
-
|
|
10026
|
-
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
CriticalTimers.clearInterval = function() {
|
|
10031
|
-
return clearInterval(...arguments);
|
|
10062
|
+
const VideoPresets = {
|
|
10063
|
+
h90: new VideoPreset(160, 90, 9e4, 20),
|
|
10064
|
+
h180: new VideoPreset(320, 180, 16e4, 20),
|
|
10065
|
+
h216: new VideoPreset(384, 216, 18e4, 20),
|
|
10066
|
+
h360: new VideoPreset(640, 360, 45e4, 20),
|
|
10067
|
+
h540: new VideoPreset(960, 540, 8e5, 25),
|
|
10068
|
+
h720: new VideoPreset(1280, 720, 17e5, 30),
|
|
10069
|
+
h1080: new VideoPreset(1920, 1080, 3e6, 30),
|
|
10070
|
+
h1440: new VideoPreset(2560, 1440, 5e6, 30),
|
|
10071
|
+
h2160: new VideoPreset(3840, 2160, 8e6, 30)
|
|
10032
10072
|
};
|
|
10073
|
+
/**
|
|
10074
|
+
* Four by three presets
|
|
10075
|
+
*/
|
|
10076
|
+
const VideoPresets43 = {
|
|
10077
|
+
h120: new VideoPreset(160, 120, 7e4, 20),
|
|
10078
|
+
h180: new VideoPreset(240, 180, 125e3, 20),
|
|
10079
|
+
h240: new VideoPreset(320, 240, 14e4, 20),
|
|
10080
|
+
h360: new VideoPreset(480, 360, 33e4, 20),
|
|
10081
|
+
h480: new VideoPreset(640, 480, 5e5, 20),
|
|
10082
|
+
h540: new VideoPreset(720, 540, 6e5, 25),
|
|
10083
|
+
h720: new VideoPreset(960, 720, 13e5, 30),
|
|
10084
|
+
h1080: new VideoPreset(1440, 1080, 23e5, 30),
|
|
10085
|
+
h1440: new VideoPreset(1920, 1440, 38e5, 30)
|
|
10086
|
+
};
|
|
10087
|
+
const ScreenSharePresets = {
|
|
10088
|
+
h360fps3: new VideoPreset(640, 360, 2e5, 3, "medium"),
|
|
10089
|
+
h360fps15: new VideoPreset(640, 360, 4e5, 15, "medium"),
|
|
10090
|
+
h720fps5: new VideoPreset(1280, 720, 8e5, 5, "medium"),
|
|
10091
|
+
h720fps15: new VideoPreset(1280, 720, 15e5, 15, "medium"),
|
|
10092
|
+
h720fps30: new VideoPreset(1280, 720, 2e6, 30, "medium"),
|
|
10093
|
+
h1080fps15: new VideoPreset(1920, 1080, 25e5, 15, "medium"),
|
|
10094
|
+
h1080fps30: new VideoPreset(1920, 1080, 5e6, 30, "medium"),
|
|
10095
|
+
original: new VideoPreset(0, 0, 7e6, 30, "medium")
|
|
10096
|
+
};
|
|
10097
|
+
function mergeDefaultOptions(options, audioDefaults, videoDefaults) {
|
|
10098
|
+
var _a, _b;
|
|
10099
|
+
var _c, _d;
|
|
10100
|
+
const { optionsWithoutProcessor, audioProcessor, videoProcessor } = extractProcessorsFromOptions(options !== null && options !== void 0 ? options : {});
|
|
10101
|
+
const defaultAudioProcessor = audioDefaults === null || audioDefaults === void 0 ? void 0 : audioDefaults.processor;
|
|
10102
|
+
const defaultVideoProcessor = videoDefaults === null || videoDefaults === void 0 ? void 0 : videoDefaults.processor;
|
|
10103
|
+
const clonedOptions = optionsWithoutProcessor !== null && optionsWithoutProcessor !== void 0 ? optionsWithoutProcessor : {};
|
|
10104
|
+
if (clonedOptions.audio === true) clonedOptions.audio = {};
|
|
10105
|
+
if (clonedOptions.video === true) clonedOptions.video = {};
|
|
10106
|
+
if (clonedOptions.audio) {
|
|
10107
|
+
mergeObjectWithoutOverwriting(clonedOptions.audio, audioDefaults);
|
|
10108
|
+
(_a = (_c = clonedOptions.audio).deviceId) !== null && _a !== void 0 || (_c.deviceId = { ideal: "default" });
|
|
10109
|
+
if (audioProcessor || defaultAudioProcessor) clonedOptions.audio.processor = audioProcessor !== null && audioProcessor !== void 0 ? audioProcessor : defaultAudioProcessor;
|
|
10110
|
+
}
|
|
10111
|
+
if (clonedOptions.video) {
|
|
10112
|
+
mergeObjectWithoutOverwriting(clonedOptions.video, videoDefaults);
|
|
10113
|
+
(_b = (_d = clonedOptions.video).deviceId) !== null && _b !== void 0 || (_d.deviceId = { ideal: "default" });
|
|
10114
|
+
if (videoProcessor || defaultVideoProcessor) clonedOptions.video.processor = videoProcessor !== null && videoProcessor !== void 0 ? videoProcessor : defaultVideoProcessor;
|
|
10115
|
+
}
|
|
10116
|
+
return clonedOptions;
|
|
10117
|
+
}
|
|
10118
|
+
function mergeObjectWithoutOverwriting(mainObject, objectToMerge) {
|
|
10119
|
+
Object.keys(objectToMerge).forEach((key) => {
|
|
10120
|
+
if (mainObject[key] === void 0) mainObject[key] = objectToMerge[key];
|
|
10121
|
+
});
|
|
10122
|
+
return mainObject;
|
|
10123
|
+
}
|
|
10124
|
+
function constraintsForOptions(options) {
|
|
10125
|
+
var _a, _b;
|
|
10126
|
+
var _c, _d;
|
|
10127
|
+
const constraints = {};
|
|
10128
|
+
if (options.video) if (typeof options.video === "object") {
|
|
10129
|
+
const videoOptions = {};
|
|
10130
|
+
const target = videoOptions;
|
|
10131
|
+
const source = options.video;
|
|
10132
|
+
Object.keys(source).forEach((key) => {
|
|
10133
|
+
switch (key) {
|
|
10134
|
+
case "resolution":
|
|
10135
|
+
mergeObjectWithoutOverwriting(target, source.resolution);
|
|
10136
|
+
break;
|
|
10137
|
+
default: target[key] = source[key];
|
|
10138
|
+
}
|
|
10139
|
+
});
|
|
10140
|
+
constraints.video = videoOptions;
|
|
10141
|
+
(_a = (_c = constraints.video).deviceId) !== null && _a !== void 0 || (_c.deviceId = { ideal: "default" });
|
|
10142
|
+
} else constraints.video = options.video ? { deviceId: { ideal: "default" } } : false;
|
|
10143
|
+
else constraints.video = false;
|
|
10144
|
+
if (options.audio) if (typeof options.audio === "object") {
|
|
10145
|
+
constraints.audio = options.audio;
|
|
10146
|
+
(_b = (_d = constraints.audio).deviceId) !== null && _b !== void 0 || (_d.deviceId = { ideal: "default" });
|
|
10147
|
+
} else constraints.audio = { deviceId: { ideal: "default" } };
|
|
10148
|
+
else constraints.audio = false;
|
|
10149
|
+
return constraints;
|
|
10150
|
+
}
|
|
10151
|
+
/**
|
|
10152
|
+
* This function detects silence on a given [[Track]] instance.
|
|
10153
|
+
* Returns true if the track seems to be entirely silent.
|
|
10154
|
+
*/
|
|
10155
|
+
function detectSilence(track_1) {
|
|
10156
|
+
return __awaiter(this, arguments, void 0, function(track) {
|
|
10157
|
+
let timeOffset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 200;
|
|
10158
|
+
return function* () {
|
|
10159
|
+
const ctx = getNewAudioContext();
|
|
10160
|
+
if (ctx) {
|
|
10161
|
+
const analyser = ctx.createAnalyser();
|
|
10162
|
+
analyser.fftSize = 2048;
|
|
10163
|
+
const bufferLength = analyser.frequencyBinCount;
|
|
10164
|
+
const dataArray = new Uint8Array(bufferLength);
|
|
10165
|
+
ctx.createMediaStreamSource(new MediaStream([track.mediaStreamTrack])).connect(analyser);
|
|
10166
|
+
yield sleep(timeOffset);
|
|
10167
|
+
analyser.getByteTimeDomainData(dataArray);
|
|
10168
|
+
const someNoise = dataArray.some((sample) => sample !== 128 && sample !== 0);
|
|
10169
|
+
ctx.close();
|
|
10170
|
+
return !someNoise;
|
|
10171
|
+
}
|
|
10172
|
+
return false;
|
|
10173
|
+
}();
|
|
10174
|
+
});
|
|
10175
|
+
}
|
|
10176
|
+
/**
|
|
10177
|
+
* @internal
|
|
10178
|
+
*/
|
|
10179
|
+
function getNewAudioContext() {
|
|
10180
|
+
var _a;
|
|
10181
|
+
const AudioContext = typeof window !== "undefined" && (window.AudioContext || window.webkitAudioContext);
|
|
10182
|
+
if (AudioContext) {
|
|
10183
|
+
const audioContext = new AudioContext({ latencyHint: "interactive" });
|
|
10184
|
+
if (audioContext.state === "suspended" && typeof window !== "undefined" && ((_a = window.document) === null || _a === void 0 ? void 0 : _a.body)) {
|
|
10185
|
+
const handleResume = () => __awaiter(this, void 0, void 0, function* () {
|
|
10186
|
+
var _a;
|
|
10187
|
+
try {
|
|
10188
|
+
if (audioContext.state === "suspended") yield audioContext.resume();
|
|
10189
|
+
} catch (e) {
|
|
10190
|
+
console.warn("Error trying to auto-resume audio context", e);
|
|
10191
|
+
} finally {
|
|
10192
|
+
(_a = window.document.body) === null || _a === void 0 || _a.removeEventListener("click", handleResume);
|
|
10193
|
+
}
|
|
10194
|
+
});
|
|
10195
|
+
audioContext.addEventListener("statechange", () => {
|
|
10196
|
+
var _a;
|
|
10197
|
+
if (audioContext.state === "closed") (_a = window.document.body) === null || _a === void 0 || _a.removeEventListener("click", handleResume);
|
|
10198
|
+
});
|
|
10199
|
+
window.document.body.addEventListener("click", handleResume);
|
|
10200
|
+
}
|
|
10201
|
+
return audioContext;
|
|
10202
|
+
}
|
|
10203
|
+
}
|
|
10204
|
+
/**
|
|
10205
|
+
* @internal
|
|
10206
|
+
*/
|
|
10207
|
+
function kindToSource(kind) {
|
|
10208
|
+
if (kind === "audioinput") return Track.Source.Microphone;
|
|
10209
|
+
else if (kind === "videoinput") return Track.Source.Camera;
|
|
10210
|
+
else return Track.Source.Unknown;
|
|
10211
|
+
}
|
|
10212
|
+
/**
|
|
10213
|
+
* @internal
|
|
10214
|
+
*/
|
|
10215
|
+
function sourceToKind(source) {
|
|
10216
|
+
if (source === Track.Source.Microphone) return "audioinput";
|
|
10217
|
+
else if (source === Track.Source.Camera) return "videoinput";
|
|
10218
|
+
else return;
|
|
10219
|
+
}
|
|
10220
|
+
/**
|
|
10221
|
+
* @internal
|
|
10222
|
+
*/
|
|
10223
|
+
function screenCaptureToDisplayMediaStreamOptions(options) {
|
|
10224
|
+
var _a, _b;
|
|
10225
|
+
let videoConstraints = (_a = options.video) !== null && _a !== void 0 ? _a : true;
|
|
10226
|
+
if (options.resolution && options.resolution.width > 0 && options.resolution.height > 0) {
|
|
10227
|
+
videoConstraints = typeof videoConstraints === "boolean" ? {} : videoConstraints;
|
|
10228
|
+
if (isSafari()) videoConstraints = Object.assign(Object.assign({}, videoConstraints), {
|
|
10229
|
+
width: { max: options.resolution.width },
|
|
10230
|
+
height: { max: options.resolution.height },
|
|
10231
|
+
frameRate: options.resolution.frameRate
|
|
10232
|
+
});
|
|
10233
|
+
else videoConstraints = Object.assign(Object.assign({}, videoConstraints), {
|
|
10234
|
+
width: { ideal: options.resolution.width },
|
|
10235
|
+
height: { ideal: options.resolution.height },
|
|
10236
|
+
frameRate: options.resolution.frameRate
|
|
10237
|
+
});
|
|
10238
|
+
}
|
|
10239
|
+
return {
|
|
10240
|
+
audio: (_b = options.audio) !== null && _b !== void 0 ? _b : false,
|
|
10241
|
+
video: videoConstraints,
|
|
10242
|
+
controller: options.controller,
|
|
10243
|
+
selfBrowserSurface: options.selfBrowserSurface,
|
|
10244
|
+
surfaceSwitching: options.surfaceSwitching,
|
|
10245
|
+
systemAudio: options.systemAudio,
|
|
10246
|
+
preferCurrentTab: options.preferCurrentTab
|
|
10247
|
+
};
|
|
10248
|
+
}
|
|
10249
|
+
function mimeTypeToVideoCodecString(mimeType) {
|
|
10250
|
+
return mimeType.split("/")[1].toLowerCase();
|
|
10251
|
+
}
|
|
10252
|
+
function getTrackPublicationInfo(tracks) {
|
|
10253
|
+
const infos = [];
|
|
10254
|
+
tracks.forEach((track) => {
|
|
10255
|
+
if (track.track !== void 0) infos.push(new TrackPublishedResponse({
|
|
10256
|
+
cid: track.track.mediaStreamID,
|
|
10257
|
+
track: track.trackInfo
|
|
10258
|
+
}));
|
|
10259
|
+
});
|
|
10260
|
+
return infos;
|
|
10261
|
+
}
|
|
10262
|
+
function getLogContextFromTrack(track) {
|
|
10263
|
+
if ("mediaStreamTrack" in track) return {
|
|
10264
|
+
trackID: track.sid,
|
|
10265
|
+
source: track.source,
|
|
10266
|
+
muted: track.isMuted,
|
|
10267
|
+
enabled: track.mediaStreamTrack.enabled,
|
|
10268
|
+
kind: track.kind,
|
|
10269
|
+
streamID: track.mediaStreamID,
|
|
10270
|
+
streamTrackID: track.mediaStreamTrack.id
|
|
10271
|
+
};
|
|
10272
|
+
else return {
|
|
10273
|
+
trackID: track.trackSid,
|
|
10274
|
+
enabled: track.isEnabled,
|
|
10275
|
+
muted: track.isMuted,
|
|
10276
|
+
trackInfo: Object.assign({
|
|
10277
|
+
mimeType: track.mimeType,
|
|
10278
|
+
name: track.trackName,
|
|
10279
|
+
encrypted: track.isEncrypted,
|
|
10280
|
+
kind: track.kind,
|
|
10281
|
+
source: track.source
|
|
10282
|
+
}, track.track ? getLogContextFromTrack(track.track) : {})
|
|
10283
|
+
};
|
|
10284
|
+
}
|
|
10285
|
+
function supportsSynchronizationSources() {
|
|
10286
|
+
return typeof RTCRtpReceiver !== "undefined" && "getSynchronizationSources" in RTCRtpReceiver;
|
|
10287
|
+
}
|
|
10288
|
+
function diffAttributes(oldValues, newValues) {
|
|
10289
|
+
var _a;
|
|
10290
|
+
if (oldValues === void 0) oldValues = {};
|
|
10291
|
+
if (newValues === void 0) newValues = {};
|
|
10292
|
+
const allKeys = [...Object.keys(newValues), ...Object.keys(oldValues)];
|
|
10293
|
+
const diff = {};
|
|
10294
|
+
for (const key of allKeys) if (oldValues[key] !== newValues[key]) diff[key] = (_a = newValues[key]) !== null && _a !== void 0 ? _a : "";
|
|
10295
|
+
return diff;
|
|
10296
|
+
}
|
|
10297
|
+
/** @internal */
|
|
10298
|
+
function extractProcessorsFromOptions(options) {
|
|
10299
|
+
const newOptions = Object.assign({}, options);
|
|
10300
|
+
let audioProcessor;
|
|
10301
|
+
let videoProcessor;
|
|
10302
|
+
if (typeof newOptions.audio === "object" && newOptions.audio.processor) {
|
|
10303
|
+
audioProcessor = newOptions.audio.processor;
|
|
10304
|
+
newOptions.audio = Object.assign(Object.assign({}, newOptions.audio), { processor: void 0 });
|
|
10305
|
+
}
|
|
10306
|
+
if (typeof newOptions.video === "object" && newOptions.video.processor) {
|
|
10307
|
+
videoProcessor = newOptions.video.processor;
|
|
10308
|
+
newOptions.video = Object.assign(Object.assign({}, newOptions.video), { processor: void 0 });
|
|
10309
|
+
}
|
|
10310
|
+
return {
|
|
10311
|
+
audioProcessor,
|
|
10312
|
+
videoProcessor,
|
|
10313
|
+
optionsWithoutProcessor: cloneDeep(newOptions)
|
|
10314
|
+
};
|
|
10315
|
+
}
|
|
10316
|
+
function getTrackSourceFromProto(source) {
|
|
10317
|
+
switch (source) {
|
|
10318
|
+
case TrackSource.CAMERA: return Track.Source.Camera;
|
|
10319
|
+
case TrackSource.MICROPHONE: return Track.Source.Microphone;
|
|
10320
|
+
case TrackSource.SCREEN_SHARE: return Track.Source.ScreenShare;
|
|
10321
|
+
case TrackSource.SCREEN_SHARE_AUDIO: return Track.Source.ScreenShareAudio;
|
|
10322
|
+
default: return Track.Source.Unknown;
|
|
10323
|
+
}
|
|
10324
|
+
}
|
|
10325
|
+
function areDimensionsSmaller(a, b) {
|
|
10326
|
+
return a.width * a.height < b.width * b.height;
|
|
10327
|
+
}
|
|
10328
|
+
function layerDimensionsFor(trackInfo, quality) {
|
|
10329
|
+
var _a;
|
|
10330
|
+
return (_a = trackInfo.layers) === null || _a === void 0 ? void 0 : _a.find((l) => l.quality === quality);
|
|
10331
|
+
}
|
|
10033
10332
|
const BACKGROUND_REACTION_DELAY = 5e3;
|
|
10034
10333
|
const recycledElements = [];
|
|
10035
10334
|
var VideoQuality;
|
|
@@ -10301,103 +10600,6 @@ var ElevenLabsClient = (function(exports) {
|
|
|
10301
10600
|
}
|
|
10302
10601
|
Track.streamStateFromProto = streamStateFromProto;
|
|
10303
10602
|
})(Track || (Track = {}));
|
|
10304
|
-
var VideoPreset = class {
|
|
10305
|
-
constructor(widthOrOptions, height, maxBitrate, maxFramerate, priority) {
|
|
10306
|
-
if (typeof widthOrOptions === "object") {
|
|
10307
|
-
this.width = widthOrOptions.width;
|
|
10308
|
-
this.height = widthOrOptions.height;
|
|
10309
|
-
this.aspectRatio = widthOrOptions.aspectRatio;
|
|
10310
|
-
this.encoding = {
|
|
10311
|
-
maxBitrate: widthOrOptions.maxBitrate,
|
|
10312
|
-
maxFramerate: widthOrOptions.maxFramerate,
|
|
10313
|
-
priority: widthOrOptions.priority
|
|
10314
|
-
};
|
|
10315
|
-
} else if (height !== void 0 && maxBitrate !== void 0) {
|
|
10316
|
-
this.width = widthOrOptions;
|
|
10317
|
-
this.height = height;
|
|
10318
|
-
this.aspectRatio = widthOrOptions / height;
|
|
10319
|
-
this.encoding = {
|
|
10320
|
-
maxBitrate,
|
|
10321
|
-
maxFramerate,
|
|
10322
|
-
priority
|
|
10323
|
-
};
|
|
10324
|
-
} else throw new TypeError("Unsupported options: provide at least width, height and maxBitrate");
|
|
10325
|
-
}
|
|
10326
|
-
get resolution() {
|
|
10327
|
-
return {
|
|
10328
|
-
width: this.width,
|
|
10329
|
-
height: this.height,
|
|
10330
|
-
frameRate: this.encoding.maxFramerate,
|
|
10331
|
-
aspectRatio: this.aspectRatio
|
|
10332
|
-
};
|
|
10333
|
-
}
|
|
10334
|
-
};
|
|
10335
|
-
const backupVideoCodecs = ["vp8", "h264"];
|
|
10336
|
-
const videoCodecs = [
|
|
10337
|
-
"vp8",
|
|
10338
|
-
"h264",
|
|
10339
|
-
"vp9",
|
|
10340
|
-
"av1",
|
|
10341
|
-
"h265"
|
|
10342
|
-
];
|
|
10343
|
-
function isBackupVideoCodec(codec) {
|
|
10344
|
-
return !!backupVideoCodecs.find((backup) => backup === codec);
|
|
10345
|
-
}
|
|
10346
|
-
/** @deprecated Use {@link isBackupVideoCodec} instead */
|
|
10347
|
-
const isBackupCodec = isBackupVideoCodec;
|
|
10348
|
-
var BackupCodecPolicy;
|
|
10349
|
-
(function(BackupCodecPolicy) {
|
|
10350
|
-
BackupCodecPolicy[BackupCodecPolicy["PREFER_REGRESSION"] = 0] = "PREFER_REGRESSION";
|
|
10351
|
-
BackupCodecPolicy[BackupCodecPolicy["SIMULCAST"] = 1] = "SIMULCAST";
|
|
10352
|
-
BackupCodecPolicy[BackupCodecPolicy["REGRESSION"] = 2] = "REGRESSION";
|
|
10353
|
-
})(BackupCodecPolicy || (BackupCodecPolicy = {}));
|
|
10354
|
-
var AudioPresets;
|
|
10355
|
-
(function(AudioPresets) {
|
|
10356
|
-
AudioPresets.telephone = { maxBitrate: 12e3 };
|
|
10357
|
-
AudioPresets.speech = { maxBitrate: 24e3 };
|
|
10358
|
-
AudioPresets.music = { maxBitrate: 48e3 };
|
|
10359
|
-
AudioPresets.musicStereo = { maxBitrate: 64e3 };
|
|
10360
|
-
AudioPresets.musicHighQuality = { maxBitrate: 96e3 };
|
|
10361
|
-
AudioPresets.musicHighQualityStereo = { maxBitrate: 128e3 };
|
|
10362
|
-
})(AudioPresets || (AudioPresets = {}));
|
|
10363
|
-
/**
|
|
10364
|
-
* Sane presets for video resolution/encoding
|
|
10365
|
-
*/
|
|
10366
|
-
const VideoPresets = {
|
|
10367
|
-
h90: new VideoPreset(160, 90, 9e4, 20),
|
|
10368
|
-
h180: new VideoPreset(320, 180, 16e4, 20),
|
|
10369
|
-
h216: new VideoPreset(384, 216, 18e4, 20),
|
|
10370
|
-
h360: new VideoPreset(640, 360, 45e4, 20),
|
|
10371
|
-
h540: new VideoPreset(960, 540, 8e5, 25),
|
|
10372
|
-
h720: new VideoPreset(1280, 720, 17e5, 30),
|
|
10373
|
-
h1080: new VideoPreset(1920, 1080, 3e6, 30),
|
|
10374
|
-
h1440: new VideoPreset(2560, 1440, 5e6, 30),
|
|
10375
|
-
h2160: new VideoPreset(3840, 2160, 8e6, 30)
|
|
10376
|
-
};
|
|
10377
|
-
/**
|
|
10378
|
-
* Four by three presets
|
|
10379
|
-
*/
|
|
10380
|
-
const VideoPresets43 = {
|
|
10381
|
-
h120: new VideoPreset(160, 120, 7e4, 20),
|
|
10382
|
-
h180: new VideoPreset(240, 180, 125e3, 20),
|
|
10383
|
-
h240: new VideoPreset(320, 240, 14e4, 20),
|
|
10384
|
-
h360: new VideoPreset(480, 360, 33e4, 20),
|
|
10385
|
-
h480: new VideoPreset(640, 480, 5e5, 20),
|
|
10386
|
-
h540: new VideoPreset(720, 540, 6e5, 25),
|
|
10387
|
-
h720: new VideoPreset(960, 720, 13e5, 30),
|
|
10388
|
-
h1080: new VideoPreset(1440, 1080, 23e5, 30),
|
|
10389
|
-
h1440: new VideoPreset(1920, 1440, 38e5, 30)
|
|
10390
|
-
};
|
|
10391
|
-
const ScreenSharePresets = {
|
|
10392
|
-
h360fps3: new VideoPreset(640, 360, 2e5, 3, "medium"),
|
|
10393
|
-
h360fps15: new VideoPreset(640, 360, 4e5, 15, "medium"),
|
|
10394
|
-
h720fps5: new VideoPreset(1280, 720, 8e5, 5, "medium"),
|
|
10395
|
-
h720fps15: new VideoPreset(1280, 720, 15e5, 15, "medium"),
|
|
10396
|
-
h720fps30: new VideoPreset(1280, 720, 2e6, 30, "medium"),
|
|
10397
|
-
h1080fps15: new VideoPreset(1920, 1080, 25e5, 15, "medium"),
|
|
10398
|
-
h1080fps30: new VideoPreset(1920, 1080, 5e6, 30, "medium"),
|
|
10399
|
-
original: new VideoPreset(0, 0, 7e6, 30, "medium")
|
|
10400
|
-
};
|
|
10401
10603
|
const separator = "|";
|
|
10402
10604
|
const ddExtensionURI = "https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";
|
|
10403
10605
|
function unpackStreamId(packed) {
|
|
@@ -10724,277 +10926,115 @@ var ElevenLabsClient = (function(exports) {
|
|
|
10724
10926
|
function isRemoteTrack(track) {
|
|
10725
10927
|
return !!track && !track.isLocal;
|
|
10726
10928
|
}
|
|
10727
|
-
function isRemotePub(pub) {
|
|
10728
|
-
return !!pub && !pub.isLocal;
|
|
10729
|
-
}
|
|
10730
|
-
function isRemoteVideoTrack(track) {
|
|
10731
|
-
return isRemoteTrack(track) && isVideoTrack(track);
|
|
10732
|
-
}
|
|
10733
|
-
function isLocalParticipant(p) {
|
|
10734
|
-
return p.isLocal;
|
|
10735
|
-
}
|
|
10736
|
-
function splitUtf8(s, n) {
|
|
10737
|
-
const result = [];
|
|
10738
|
-
let encoded = new TextEncoder().encode(s);
|
|
10739
|
-
while (encoded.length > n) {
|
|
10740
|
-
let k = n;
|
|
10741
|
-
while (k > 0) {
|
|
10742
|
-
const byte = encoded[k];
|
|
10743
|
-
if (byte !== void 0 && (byte & 192) !== 128) break;
|
|
10744
|
-
k--;
|
|
10745
|
-
}
|
|
10746
|
-
result.push(encoded.slice(0, k));
|
|
10747
|
-
encoded = encoded.slice(k);
|
|
10748
|
-
}
|
|
10749
|
-
if (encoded.length > 0) result.push(encoded);
|
|
10750
|
-
return result;
|
|
10751
|
-
}
|
|
10752
|
-
function extractMaxAgeFromRequestHeaders(headers) {
|
|
10753
|
-
var _a;
|
|
10754
|
-
const cacheControl = headers.get("Cache-Control");
|
|
10755
|
-
if (cacheControl) {
|
|
10756
|
-
const maxAge = (_a = cacheControl.match(/(?:^|[,\s])max-age=(\d+)/)) === null || _a === void 0 ? void 0 : _a[1];
|
|
10757
|
-
if (maxAge) return parseInt(maxAge, 10);
|
|
10758
|
-
}
|
|
10759
|
-
}
|
|
10760
|
-
function mergeDefaultOptions(options, audioDefaults, videoDefaults) {
|
|
10761
|
-
var _a, _b;
|
|
10762
|
-
var _c, _d;
|
|
10763
|
-
const { optionsWithoutProcessor, audioProcessor, videoProcessor } = extractProcessorsFromOptions(options !== null && options !== void 0 ? options : {});
|
|
10764
|
-
const defaultAudioProcessor = audioDefaults === null || audioDefaults === void 0 ? void 0 : audioDefaults.processor;
|
|
10765
|
-
const defaultVideoProcessor = videoDefaults === null || videoDefaults === void 0 ? void 0 : videoDefaults.processor;
|
|
10766
|
-
const clonedOptions = optionsWithoutProcessor !== null && optionsWithoutProcessor !== void 0 ? optionsWithoutProcessor : {};
|
|
10767
|
-
if (clonedOptions.audio === true) clonedOptions.audio = {};
|
|
10768
|
-
if (clonedOptions.video === true) clonedOptions.video = {};
|
|
10769
|
-
if (clonedOptions.audio) {
|
|
10770
|
-
mergeObjectWithoutOverwriting(clonedOptions.audio, audioDefaults);
|
|
10771
|
-
(_a = (_c = clonedOptions.audio).deviceId) !== null && _a !== void 0 || (_c.deviceId = { ideal: "default" });
|
|
10772
|
-
if (audioProcessor || defaultAudioProcessor) clonedOptions.audio.processor = audioProcessor !== null && audioProcessor !== void 0 ? audioProcessor : defaultAudioProcessor;
|
|
10773
|
-
}
|
|
10774
|
-
if (clonedOptions.video) {
|
|
10775
|
-
mergeObjectWithoutOverwriting(clonedOptions.video, videoDefaults);
|
|
10776
|
-
(_b = (_d = clonedOptions.video).deviceId) !== null && _b !== void 0 || (_d.deviceId = { ideal: "default" });
|
|
10777
|
-
if (videoProcessor || defaultVideoProcessor) clonedOptions.video.processor = videoProcessor !== null && videoProcessor !== void 0 ? videoProcessor : defaultVideoProcessor;
|
|
10778
|
-
}
|
|
10779
|
-
return clonedOptions;
|
|
10780
|
-
}
|
|
10781
|
-
function mergeObjectWithoutOverwriting(mainObject, objectToMerge) {
|
|
10782
|
-
Object.keys(objectToMerge).forEach((key) => {
|
|
10783
|
-
if (mainObject[key] === void 0) mainObject[key] = objectToMerge[key];
|
|
10784
|
-
});
|
|
10785
|
-
return mainObject;
|
|
10786
|
-
}
|
|
10787
|
-
function constraintsForOptions(options) {
|
|
10788
|
-
var _a, _b;
|
|
10789
|
-
var _c, _d;
|
|
10790
|
-
const constraints = {};
|
|
10791
|
-
if (options.video) if (typeof options.video === "object") {
|
|
10792
|
-
const videoOptions = {};
|
|
10793
|
-
const target = videoOptions;
|
|
10794
|
-
const source = options.video;
|
|
10795
|
-
Object.keys(source).forEach((key) => {
|
|
10796
|
-
switch (key) {
|
|
10797
|
-
case "resolution":
|
|
10798
|
-
mergeObjectWithoutOverwriting(target, source.resolution);
|
|
10799
|
-
break;
|
|
10800
|
-
default: target[key] = source[key];
|
|
10801
|
-
}
|
|
10802
|
-
});
|
|
10803
|
-
constraints.video = videoOptions;
|
|
10804
|
-
(_a = (_c = constraints.video).deviceId) !== null && _a !== void 0 || (_c.deviceId = { ideal: "default" });
|
|
10805
|
-
} else constraints.video = options.video ? { deviceId: { ideal: "default" } } : false;
|
|
10806
|
-
else constraints.video = false;
|
|
10807
|
-
if (options.audio) if (typeof options.audio === "object") {
|
|
10808
|
-
constraints.audio = options.audio;
|
|
10809
|
-
(_b = (_d = constraints.audio).deviceId) !== null && _b !== void 0 || (_d.deviceId = { ideal: "default" });
|
|
10810
|
-
} else constraints.audio = { deviceId: { ideal: "default" } };
|
|
10811
|
-
else constraints.audio = false;
|
|
10812
|
-
return constraints;
|
|
10813
|
-
}
|
|
10814
|
-
/**
|
|
10815
|
-
* This function detects silence on a given [[Track]] instance.
|
|
10816
|
-
* Returns true if the track seems to be entirely silent.
|
|
10817
|
-
*/
|
|
10818
|
-
function detectSilence(track_1) {
|
|
10819
|
-
return __awaiter(this, arguments, void 0, function(track) {
|
|
10820
|
-
let timeOffset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 200;
|
|
10821
|
-
return function* () {
|
|
10822
|
-
const ctx = getNewAudioContext();
|
|
10823
|
-
if (ctx) {
|
|
10824
|
-
const analyser = ctx.createAnalyser();
|
|
10825
|
-
analyser.fftSize = 2048;
|
|
10826
|
-
const bufferLength = analyser.frequencyBinCount;
|
|
10827
|
-
const dataArray = new Uint8Array(bufferLength);
|
|
10828
|
-
ctx.createMediaStreamSource(new MediaStream([track.mediaStreamTrack])).connect(analyser);
|
|
10829
|
-
yield sleep(timeOffset);
|
|
10830
|
-
analyser.getByteTimeDomainData(dataArray);
|
|
10831
|
-
const someNoise = dataArray.some((sample) => sample !== 128 && sample !== 0);
|
|
10832
|
-
ctx.close();
|
|
10833
|
-
return !someNoise;
|
|
10834
|
-
}
|
|
10835
|
-
return false;
|
|
10836
|
-
}();
|
|
10837
|
-
});
|
|
10838
|
-
}
|
|
10839
|
-
/**
|
|
10840
|
-
* @internal
|
|
10841
|
-
*/
|
|
10842
|
-
function getNewAudioContext() {
|
|
10843
|
-
var _a;
|
|
10844
|
-
const AudioContext = typeof window !== "undefined" && (window.AudioContext || window.webkitAudioContext);
|
|
10845
|
-
if (AudioContext) {
|
|
10846
|
-
const audioContext = new AudioContext({ latencyHint: "interactive" });
|
|
10847
|
-
if (audioContext.state === "suspended" && typeof window !== "undefined" && ((_a = window.document) === null || _a === void 0 ? void 0 : _a.body)) {
|
|
10848
|
-
const handleResume = () => __awaiter(this, void 0, void 0, function* () {
|
|
10849
|
-
var _a;
|
|
10850
|
-
try {
|
|
10851
|
-
if (audioContext.state === "suspended") yield audioContext.resume();
|
|
10852
|
-
} catch (e) {
|
|
10853
|
-
console.warn("Error trying to auto-resume audio context", e);
|
|
10854
|
-
} finally {
|
|
10855
|
-
(_a = window.document.body) === null || _a === void 0 || _a.removeEventListener("click", handleResume);
|
|
10856
|
-
}
|
|
10857
|
-
});
|
|
10858
|
-
audioContext.addEventListener("statechange", () => {
|
|
10859
|
-
var _a;
|
|
10860
|
-
if (audioContext.state === "closed") (_a = window.document.body) === null || _a === void 0 || _a.removeEventListener("click", handleResume);
|
|
10861
|
-
});
|
|
10862
|
-
window.document.body.addEventListener("click", handleResume);
|
|
10863
|
-
}
|
|
10864
|
-
return audioContext;
|
|
10865
|
-
}
|
|
10866
|
-
}
|
|
10867
|
-
/**
|
|
10868
|
-
* @internal
|
|
10869
|
-
*/
|
|
10870
|
-
function kindToSource(kind) {
|
|
10871
|
-
if (kind === "audioinput") return Track.Source.Microphone;
|
|
10872
|
-
else if (kind === "videoinput") return Track.Source.Camera;
|
|
10873
|
-
else return Track.Source.Unknown;
|
|
10929
|
+
function isRemotePub(pub) {
|
|
10930
|
+
return !!pub && !pub.isLocal;
|
|
10874
10931
|
}
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
*/
|
|
10878
|
-
function sourceToKind(source) {
|
|
10879
|
-
if (source === Track.Source.Microphone) return "audioinput";
|
|
10880
|
-
else if (source === Track.Source.Camera) return "videoinput";
|
|
10881
|
-
else return;
|
|
10932
|
+
function isRemoteVideoTrack(track) {
|
|
10933
|
+
return isRemoteTrack(track) && isVideoTrack(track);
|
|
10882
10934
|
}
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
function
|
|
10887
|
-
|
|
10888
|
-
let
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
|
|
10894
|
-
|
|
10895
|
-
}
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
height: { ideal: options.resolution.height },
|
|
10899
|
-
frameRate: options.resolution.frameRate
|
|
10900
|
-
});
|
|
10935
|
+
function isLocalParticipant(p) {
|
|
10936
|
+
return p.isLocal;
|
|
10937
|
+
}
|
|
10938
|
+
function splitUtf8(s, n) {
|
|
10939
|
+
const result = [];
|
|
10940
|
+
let encoded = new TextEncoder().encode(s);
|
|
10941
|
+
while (encoded.length > n) {
|
|
10942
|
+
let k = n;
|
|
10943
|
+
while (k > 0) {
|
|
10944
|
+
const byte = encoded[k];
|
|
10945
|
+
if (byte !== void 0 && (byte & 192) !== 128) break;
|
|
10946
|
+
k--;
|
|
10947
|
+
}
|
|
10948
|
+
result.push(encoded.slice(0, k));
|
|
10949
|
+
encoded = encoded.slice(k);
|
|
10901
10950
|
}
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
video: videoConstraints,
|
|
10905
|
-
controller: options.controller,
|
|
10906
|
-
selfBrowserSurface: options.selfBrowserSurface,
|
|
10907
|
-
surfaceSwitching: options.surfaceSwitching,
|
|
10908
|
-
systemAudio: options.systemAudio,
|
|
10909
|
-
preferCurrentTab: options.preferCurrentTab
|
|
10910
|
-
};
|
|
10951
|
+
if (encoded.length > 0) result.push(encoded);
|
|
10952
|
+
return result;
|
|
10911
10953
|
}
|
|
10912
|
-
function
|
|
10913
|
-
|
|
10954
|
+
function extractMaxAgeFromRequestHeaders(headers) {
|
|
10955
|
+
var _a;
|
|
10956
|
+
const cacheControl = headers.get("Cache-Control");
|
|
10957
|
+
if (cacheControl) {
|
|
10958
|
+
const maxAge = (_a = cacheControl.match(/(?:^|[,\s])max-age=(\d+)/)) === null || _a === void 0 ? void 0 : _a[1];
|
|
10959
|
+
if (maxAge) return parseInt(maxAge, 10);
|
|
10960
|
+
}
|
|
10914
10961
|
}
|
|
10915
|
-
function
|
|
10916
|
-
const
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
cid: track.track.mediaStreamID,
|
|
10920
|
-
track: track.trackInfo
|
|
10921
|
-
}));
|
|
10962
|
+
function createRtcUrl(url, searchParams) {
|
|
10963
|
+
const urlObj = new URL(toWebsocketUrl(url));
|
|
10964
|
+
searchParams.forEach((value, key) => {
|
|
10965
|
+
urlObj.searchParams.set(key, value);
|
|
10922
10966
|
});
|
|
10923
|
-
return
|
|
10967
|
+
return appendUrlPath(urlObj, "rtc");
|
|
10924
10968
|
}
|
|
10925
|
-
function
|
|
10926
|
-
|
|
10927
|
-
trackID: track.sid,
|
|
10928
|
-
source: track.source,
|
|
10929
|
-
muted: track.isMuted,
|
|
10930
|
-
enabled: track.mediaStreamTrack.enabled,
|
|
10931
|
-
kind: track.kind,
|
|
10932
|
-
streamID: track.mediaStreamID,
|
|
10933
|
-
streamTrackID: track.mediaStreamTrack.id
|
|
10934
|
-
};
|
|
10935
|
-
else return {
|
|
10936
|
-
trackID: track.trackSid,
|
|
10937
|
-
enabled: track.isEnabled,
|
|
10938
|
-
muted: track.isMuted,
|
|
10939
|
-
trackInfo: Object.assign({
|
|
10940
|
-
mimeType: track.mimeType,
|
|
10941
|
-
name: track.trackName,
|
|
10942
|
-
encrypted: track.isEncrypted,
|
|
10943
|
-
kind: track.kind,
|
|
10944
|
-
source: track.source
|
|
10945
|
-
}, track.track ? getLogContextFromTrack(track.track) : {})
|
|
10946
|
-
};
|
|
10969
|
+
function createValidateUrl(rtcWsUrl) {
|
|
10970
|
+
return appendUrlPath(new URL(toHttpUrl(rtcWsUrl)), "validate");
|
|
10947
10971
|
}
|
|
10948
|
-
function
|
|
10949
|
-
return
|
|
10972
|
+
function ensureTrailingSlash(path) {
|
|
10973
|
+
return path.endsWith("/") ? path : "".concat(path, "/");
|
|
10950
10974
|
}
|
|
10951
|
-
function
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
if (newValues === void 0) newValues = {};
|
|
10955
|
-
const allKeys = [...Object.keys(newValues), ...Object.keys(oldValues)];
|
|
10956
|
-
const diff = {};
|
|
10957
|
-
for (const key of allKeys) if (oldValues[key] !== newValues[key]) diff[key] = (_a = newValues[key]) !== null && _a !== void 0 ? _a : "";
|
|
10958
|
-
return diff;
|
|
10975
|
+
function appendUrlPath(urlObj, path) {
|
|
10976
|
+
urlObj.pathname = "".concat(ensureTrailingSlash(urlObj.pathname)).concat(path);
|
|
10977
|
+
return urlObj.toString();
|
|
10959
10978
|
}
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
|
|
10963
|
-
|
|
10964
|
-
let videoProcessor;
|
|
10965
|
-
if (typeof newOptions.audio === "object" && newOptions.audio.processor) {
|
|
10966
|
-
audioProcessor = newOptions.audio.processor;
|
|
10967
|
-
newOptions.audio = Object.assign(Object.assign({}, newOptions.audio), { processor: void 0 });
|
|
10968
|
-
}
|
|
10969
|
-
if (typeof newOptions.video === "object" && newOptions.video.processor) {
|
|
10970
|
-
videoProcessor = newOptions.video.processor;
|
|
10971
|
-
newOptions.video = Object.assign(Object.assign({}, newOptions.video), { processor: void 0 });
|
|
10972
|
-
}
|
|
10973
|
-
return {
|
|
10974
|
-
audioProcessor,
|
|
10975
|
-
videoProcessor,
|
|
10976
|
-
optionsWithoutProcessor: cloneDeep(newOptions)
|
|
10977
|
-
};
|
|
10979
|
+
function parseSignalResponse(value) {
|
|
10980
|
+
if (typeof value === "string") return SignalResponse.fromJson(JSON.parse(value), { ignoreUnknownFields: true });
|
|
10981
|
+
else if (value instanceof ArrayBuffer) return SignalResponse.fromBinary(new Uint8Array(value));
|
|
10982
|
+
throw new Error("could not decode websocket message: ".concat(typeof value));
|
|
10978
10983
|
}
|
|
10979
|
-
function
|
|
10980
|
-
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
case
|
|
10985
|
-
|
|
10984
|
+
function getAbortReasonAsString(signal) {
|
|
10985
|
+
let defaultMessage = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "Unknown reason";
|
|
10986
|
+
if (!(signal instanceof AbortSignal)) return defaultMessage;
|
|
10987
|
+
const reason = signal.reason;
|
|
10988
|
+
switch (typeof reason) {
|
|
10989
|
+
case "string": return reason;
|
|
10990
|
+
case "object": return reason instanceof Error ? reason.message : defaultMessage;
|
|
10991
|
+
default: return "toString" in reason ? reason.toString() : defaultMessage;
|
|
10986
10992
|
}
|
|
10987
10993
|
}
|
|
10988
|
-
|
|
10989
|
-
|
|
10994
|
+
const E2EE_FLAG = "lk_e2ee";
|
|
10995
|
+
var KeyProviderEvent;
|
|
10996
|
+
(function(KeyProviderEvent) {
|
|
10997
|
+
KeyProviderEvent["SetKey"] = "setKey";
|
|
10998
|
+
/** Event for requesting to ratchet the key used to encrypt the stream */
|
|
10999
|
+
KeyProviderEvent["RatchetRequest"] = "ratchetRequest";
|
|
11000
|
+
/** Emitted when a key is ratcheted. Could be after auto-ratcheting on decryption failure or
|
|
11001
|
+
* following a `RatchetRequest`, will contain the ratcheted key material */
|
|
11002
|
+
KeyProviderEvent["KeyRatcheted"] = "keyRatcheted";
|
|
11003
|
+
})(KeyProviderEvent || (KeyProviderEvent = {}));
|
|
11004
|
+
var KeyHandlerEvent;
|
|
11005
|
+
(function(KeyHandlerEvent) {
|
|
11006
|
+
/** Emitted when a key has been ratcheted. Is emitted when any key has been ratcheted
|
|
11007
|
+
* i.e. when the FrameCryptor tried to ratchet when decryption is failing */
|
|
11008
|
+
KeyHandlerEvent["KeyRatcheted"] = "keyRatcheted";
|
|
11009
|
+
})(KeyHandlerEvent || (KeyHandlerEvent = {}));
|
|
11010
|
+
var EncryptionEvent;
|
|
11011
|
+
(function(EncryptionEvent) {
|
|
11012
|
+
EncryptionEvent["ParticipantEncryptionStatusChanged"] = "participantEncryptionStatusChanged";
|
|
11013
|
+
EncryptionEvent["EncryptionError"] = "encryptionError";
|
|
11014
|
+
})(EncryptionEvent || (EncryptionEvent = {}));
|
|
11015
|
+
var CryptorEvent;
|
|
11016
|
+
(function(CryptorEvent) {
|
|
11017
|
+
CryptorEvent["Error"] = "cryptorError";
|
|
11018
|
+
})(CryptorEvent || (CryptorEvent = {}));
|
|
11019
|
+
function isE2EESupported() {
|
|
11020
|
+
return isInsertableStreamSupported() || isScriptTransformSupported();
|
|
10990
11021
|
}
|
|
10991
|
-
function
|
|
10992
|
-
|
|
10993
|
-
return (_a = trackInfo.layers) === null || _a === void 0 ? void 0 : _a.find((l) => l.quality === quality);
|
|
11022
|
+
function isScriptTransformSupported() {
|
|
11023
|
+
return typeof window.RTCRtpScriptTransform !== "undefined";
|
|
10994
11024
|
}
|
|
10995
|
-
|
|
10996
|
-
|
|
10997
|
-
|
|
11025
|
+
function isInsertableStreamSupported() {
|
|
11026
|
+
return typeof window.RTCRtpSender !== "undefined" && typeof window.RTCRtpSender.prototype.createEncodedStreams !== "undefined";
|
|
11027
|
+
}
|
|
11028
|
+
function asEncryptablePacket(packet) {
|
|
11029
|
+
var _a, _b, _c, _d, _e;
|
|
11030
|
+
if (((_a = packet.value) === null || _a === void 0 ? void 0 : _a.case) !== "sipDtmf" && ((_b = packet.value) === null || _b === void 0 ? void 0 : _b.case) !== "metrics" && ((_c = packet.value) === null || _c === void 0 ? void 0 : _c.case) !== "speaker" && ((_d = packet.value) === null || _d === void 0 ? void 0 : _d.case) !== "transcription" && ((_e = packet.value) === null || _e === void 0 ? void 0 : _e.case) !== "encryptedPacket") return new EncryptedPacketPayload({ value: packet.value });
|
|
11031
|
+
}
|
|
11032
|
+
var CryptorErrorReason;
|
|
11033
|
+
(function(CryptorErrorReason) {
|
|
11034
|
+
CryptorErrorReason[CryptorErrorReason["InvalidKey"] = 0] = "InvalidKey";
|
|
11035
|
+
CryptorErrorReason[CryptorErrorReason["MissingKey"] = 1] = "MissingKey";
|
|
11036
|
+
CryptorErrorReason[CryptorErrorReason["InternalError"] = 2] = "InternalError";
|
|
11037
|
+
})(CryptorErrorReason || (CryptorErrorReason = {}));
|
|
10998
11038
|
var E2EEManager = class extends eventsExports.EventEmitter {
|
|
10999
11039
|
constructor(options, dcEncryptionEnabled) {
|
|
11000
11040
|
super();
|
|
@@ -11529,11 +11569,6 @@ var ElevenLabsClient = (function(exports) {
|
|
|
11529
11569
|
return Array.from(this.pendingTasks.values());
|
|
11530
11570
|
}
|
|
11531
11571
|
};
|
|
11532
|
-
/**
|
|
11533
|
-
* [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) with [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
|
|
11534
|
-
*
|
|
11535
|
-
* @see https://web.dev/websocketstream/
|
|
11536
|
-
*/
|
|
11537
11572
|
var WebSocketStream = class {
|
|
11538
11573
|
get readyState() {
|
|
11539
11574
|
return this.ws.readyState;
|
|
@@ -11605,38 +11640,6 @@ var ElevenLabsClient = (function(exports) {
|
|
|
11605
11640
|
this.close = closeWithInfo;
|
|
11606
11641
|
}
|
|
11607
11642
|
};
|
|
11608
|
-
function createRtcUrl(url, searchParams) {
|
|
11609
|
-
const urlObj = new URL(toWebsocketUrl(url));
|
|
11610
|
-
searchParams.forEach((value, key) => {
|
|
11611
|
-
urlObj.searchParams.set(key, value);
|
|
11612
|
-
});
|
|
11613
|
-
return appendUrlPath(urlObj, "rtc");
|
|
11614
|
-
}
|
|
11615
|
-
function createValidateUrl(rtcWsUrl) {
|
|
11616
|
-
return appendUrlPath(new URL(toHttpUrl(rtcWsUrl)), "validate");
|
|
11617
|
-
}
|
|
11618
|
-
function ensureTrailingSlash(path) {
|
|
11619
|
-
return path.endsWith("/") ? path : "".concat(path, "/");
|
|
11620
|
-
}
|
|
11621
|
-
function appendUrlPath(urlObj, path) {
|
|
11622
|
-
urlObj.pathname = "".concat(ensureTrailingSlash(urlObj.pathname)).concat(path);
|
|
11623
|
-
return urlObj.toString();
|
|
11624
|
-
}
|
|
11625
|
-
function parseSignalResponse(value) {
|
|
11626
|
-
if (typeof value === "string") return SignalResponse.fromJson(JSON.parse(value), { ignoreUnknownFields: true });
|
|
11627
|
-
else if (value instanceof ArrayBuffer) return SignalResponse.fromBinary(new Uint8Array(value));
|
|
11628
|
-
throw new Error("could not decode websocket message: ".concat(typeof value));
|
|
11629
|
-
}
|
|
11630
|
-
function getAbortReasonAsString(signal) {
|
|
11631
|
-
let defaultMessage = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "Unknown reason";
|
|
11632
|
-
if (!(signal instanceof AbortSignal)) return defaultMessage;
|
|
11633
|
-
const reason = signal.reason;
|
|
11634
|
-
switch (typeof reason) {
|
|
11635
|
-
case "string": return reason;
|
|
11636
|
-
case "object": return reason instanceof Error ? reason.message : defaultMessage;
|
|
11637
|
-
default: return "toString" in reason ? reason.toString() : defaultMessage;
|
|
11638
|
-
}
|
|
11639
|
-
}
|
|
11640
11643
|
const passThroughQueueSignals = [
|
|
11641
11644
|
"syncState",
|
|
11642
11645
|
"trickle",
|
|
@@ -11751,15 +11754,14 @@ var ElevenLabsClient = (function(exports) {
|
|
|
11751
11754
|
const abortHandler = (eventOrError) => __awaiter(this, void 0, void 0, function* () {
|
|
11752
11755
|
if (alreadyAborted) return;
|
|
11753
11756
|
alreadyAborted = true;
|
|
11754
|
-
const
|
|
11755
|
-
const reason = getAbortReasonAsString(target, "Abort handler called");
|
|
11757
|
+
const reason = getAbortReasonAsString(eventOrError instanceof Event ? eventOrError.currentTarget : eventOrError, "Abort handler called");
|
|
11756
11758
|
if (this.streamWriter && !this.isDisconnected) this.sendLeave().then(() => this.close(reason)).catch((e) => {
|
|
11757
11759
|
this.log.error(e);
|
|
11758
11760
|
this.close();
|
|
11759
11761
|
});
|
|
11760
11762
|
else this.close();
|
|
11761
11763
|
cleanupAbortHandlers();
|
|
11762
|
-
reject(
|
|
11764
|
+
reject(ConnectionError.cancelled(reason));
|
|
11763
11765
|
});
|
|
11764
11766
|
abortSignal === null || abortSignal === void 0 || abortSignal.addEventListener("abort", abortHandler);
|
|
11765
11767
|
const cleanupAbortHandlers = () => {
|
|
@@ -11767,7 +11769,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
11767
11769
|
abortSignal === null || abortSignal === void 0 || abortSignal.removeEventListener("abort", abortHandler);
|
|
11768
11770
|
};
|
|
11769
11771
|
const wsTimeout = setTimeout(() => {
|
|
11770
|
-
abortHandler(
|
|
11772
|
+
abortHandler(ConnectionError.timeout("room connection has timed out (signal)"));
|
|
11771
11773
|
}, opts.websocketTimeout);
|
|
11772
11774
|
const handleSignalConnected = (connection, firstMessage) => {
|
|
11773
11775
|
this.handleSignalConnected(connection, wsTimeout, firstMessage);
|
|
@@ -11783,7 +11785,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
11783
11785
|
try {
|
|
11784
11786
|
this.ws.closed.then((closeInfo) => {
|
|
11785
11787
|
var _a;
|
|
11786
|
-
if (this.isEstablishingConnection) reject(
|
|
11788
|
+
if (this.isEstablishingConnection) reject(ConnectionError.internal("Websocket got closed during a (re)connection attempt: ".concat(closeInfo.reason)));
|
|
11787
11789
|
if (closeInfo.closeCode !== 1e3) {
|
|
11788
11790
|
this.log.warn("websocket closed", Object.assign(Object.assign({}, this.logContext), {
|
|
11789
11791
|
reason: closeInfo.reason,
|
|
@@ -11794,7 +11796,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
11794
11796
|
if (this.state === SignalConnectionState.CONNECTED) this.handleOnClose((_a = closeInfo.reason) !== null && _a !== void 0 ? _a : "Unexpected WS error");
|
|
11795
11797
|
}
|
|
11796
11798
|
}).catch((reason) => {
|
|
11797
|
-
if (this.isEstablishingConnection) reject(
|
|
11799
|
+
if (this.isEstablishingConnection) reject(ConnectionError.internal("Websocket error during a (re)connection attempt: ".concat(reason)));
|
|
11798
11800
|
});
|
|
11799
11801
|
const connection = yield this.ws.opened.catch((reason) => __awaiter(this, void 0, void 0, function* () {
|
|
11800
11802
|
if (this.state !== SignalConnectionState.CONNECTED) {
|
|
@@ -11812,7 +11814,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
11812
11814
|
this.streamWriter = connection.writable.getWriter();
|
|
11813
11815
|
const firstMessage = yield signalReader.read();
|
|
11814
11816
|
signalReader.releaseLock();
|
|
11815
|
-
if (!firstMessage.value) throw
|
|
11817
|
+
if (!firstMessage.value) throw ConnectionError.internal("no message received as first message");
|
|
11816
11818
|
const firstSignalResponse = parseSignalResponse(firstMessage.value);
|
|
11817
11819
|
const validation = this.validateFirstMessage(firstSignalResponse, (_a = opts.reconnect) !== null && _a !== void 0 ? _a : false);
|
|
11818
11820
|
if (!validation.isValid) {
|
|
@@ -12203,15 +12205,15 @@ var ElevenLabsClient = (function(exports) {
|
|
|
12203
12205
|
}
|
|
12204
12206
|
else if (this.isEstablishingConnection && ((_d = firstSignalResponse.message) === null || _d === void 0 ? void 0 : _d.case) === "leave") return {
|
|
12205
12207
|
isValid: false,
|
|
12206
|
-
error:
|
|
12208
|
+
error: ConnectionError.leaveRequest("Received leave request while trying to (re)connect", firstSignalResponse.message.value.reason)
|
|
12207
12209
|
};
|
|
12208
12210
|
else if (!isReconnect) return {
|
|
12209
12211
|
isValid: false,
|
|
12210
|
-
error:
|
|
12212
|
+
error: ConnectionError.internal("did not receive join response, got ".concat((_e = firstSignalResponse.message) === null || _e === void 0 ? void 0 : _e.case, " instead"))
|
|
12211
12213
|
};
|
|
12212
12214
|
return {
|
|
12213
12215
|
isValid: false,
|
|
12214
|
-
error:
|
|
12216
|
+
error: ConnectionError.internal("Unexpected first message")
|
|
12215
12217
|
};
|
|
12216
12218
|
}
|
|
12217
12219
|
/**
|
|
@@ -12225,11 +12227,16 @@ var ElevenLabsClient = (function(exports) {
|
|
|
12225
12227
|
return __awaiter(this, void 0, void 0, function* () {
|
|
12226
12228
|
try {
|
|
12227
12229
|
const resp = yield fetch(validateUrl);
|
|
12228
|
-
if (resp.status.toFixed(0).startsWith("4"))
|
|
12229
|
-
|
|
12230
|
-
|
|
12230
|
+
if (resp.status.toFixed(0).startsWith("4")) {
|
|
12231
|
+
const msg = yield resp.text();
|
|
12232
|
+
return ConnectionError.notAllowed(msg, resp.status);
|
|
12233
|
+
} else if (reason instanceof ConnectionError) return reason;
|
|
12234
|
+
else return ConnectionError.internal("Encountered unknown websocket error during connection: ".concat(reason), {
|
|
12235
|
+
status: resp.status,
|
|
12236
|
+
statusText: resp.statusText
|
|
12237
|
+
});
|
|
12231
12238
|
} catch (e) {
|
|
12232
|
-
return e instanceof ConnectionError ? e :
|
|
12239
|
+
return e instanceof ConnectionError ? e : ConnectionError.serverUnreachable(e instanceof Error ? e.message : "server was not reachable");
|
|
12233
12240
|
}
|
|
12234
12241
|
});
|
|
12235
12242
|
}
|
|
@@ -13814,18 +13821,18 @@ var ElevenLabsClient = (function(exports) {
|
|
|
13814
13821
|
const abortHandler = () => {
|
|
13815
13822
|
this.log.warn("abort transport connection", this.logContext);
|
|
13816
13823
|
CriticalTimers.clearTimeout(connectTimeout);
|
|
13817
|
-
reject(
|
|
13824
|
+
reject(ConnectionError.cancelled("room connection has been cancelled"));
|
|
13818
13825
|
};
|
|
13819
13826
|
if (abortController === null || abortController === void 0 ? void 0 : abortController.signal.aborted) abortHandler();
|
|
13820
13827
|
abortController === null || abortController === void 0 || abortController.signal.addEventListener("abort", abortHandler);
|
|
13821
13828
|
const connectTimeout = CriticalTimers.setTimeout(() => {
|
|
13822
13829
|
abortController === null || abortController === void 0 || abortController.signal.removeEventListener("abort", abortHandler);
|
|
13823
|
-
reject(
|
|
13830
|
+
reject(ConnectionError.internal("could not establish pc connection"));
|
|
13824
13831
|
}, timeout);
|
|
13825
13832
|
while (this.state !== PCTransportState.CONNECTED) {
|
|
13826
13833
|
yield sleep(50);
|
|
13827
13834
|
if (abortController === null || abortController === void 0 ? void 0 : abortController.signal.aborted) {
|
|
13828
|
-
reject(
|
|
13835
|
+
reject(ConnectionError.cancelled("room connection has been cancelled"));
|
|
13829
13836
|
return;
|
|
13830
13837
|
}
|
|
13831
13838
|
}
|
|
@@ -13856,11 +13863,12 @@ var ElevenLabsClient = (function(exports) {
|
|
|
13856
13863
|
updatedAtInMs: Date.now(),
|
|
13857
13864
|
maxAgeInMs
|
|
13858
13865
|
};
|
|
13859
|
-
} else throw
|
|
13866
|
+
} else if (regionSettingsResponse.status === 401) throw ConnectionError.notAllowed("Could not fetch region settings: ".concat(regionSettingsResponse.statusText), regionSettingsResponse.status);
|
|
13867
|
+
else throw ConnectionError.internal("Could not fetch region settings: ".concat(regionSettingsResponse.statusText));
|
|
13860
13868
|
} catch (e) {
|
|
13861
13869
|
if (e instanceof ConnectionError) throw e;
|
|
13862
|
-
else if (signal === null || signal === void 0 ? void 0 : signal.aborted) throw
|
|
13863
|
-
else throw
|
|
13870
|
+
else if (signal === null || signal === void 0 ? void 0 : signal.aborted) throw ConnectionError.cancelled("Region fetching was aborted");
|
|
13871
|
+
else throw ConnectionError.serverUnreachable("Could not fetch region settings, ".concat(e instanceof Error ? "".concat(e.name, ": ").concat(e.message) : e));
|
|
13864
13872
|
} finally {
|
|
13865
13873
|
unlock();
|
|
13866
13874
|
}
|
|
@@ -14499,8 +14507,6 @@ var ElevenLabsClient = (function(exports) {
|
|
|
14499
14507
|
* Sets a processor on this track.
|
|
14500
14508
|
* See https://github.com/livekit/track-processors-js for example usage
|
|
14501
14509
|
*
|
|
14502
|
-
* @experimental
|
|
14503
|
-
*
|
|
14504
14510
|
* @param processor
|
|
14505
14511
|
* @param showProcessedStreamLocally
|
|
14506
14512
|
* @returns
|
|
@@ -14560,8 +14566,6 @@ var ElevenLabsClient = (function(exports) {
|
|
|
14560
14566
|
* Stops the track processor
|
|
14561
14567
|
* See https://github.com/livekit/track-processors-js for example usage
|
|
14562
14568
|
*
|
|
14563
|
-
* @experimental
|
|
14564
|
-
* @returns
|
|
14565
14569
|
*/
|
|
14566
14570
|
stopProcessor() {
|
|
14567
14571
|
return __awaiter(this, arguments, void 0, function() {
|
|
@@ -14822,7 +14826,6 @@ var ElevenLabsClient = (function(exports) {
|
|
|
14822
14826
|
});
|
|
14823
14827
|
}
|
|
14824
14828
|
};
|
|
14825
|
-
/** @internal */
|
|
14826
14829
|
function mediaTrackToLocalTrack(mediaStreamTrack, constraints, loggerOptions) {
|
|
14827
14830
|
switch (mediaStreamTrack.kind) {
|
|
14828
14831
|
case "audio": return new LocalAudioTrack(mediaStreamTrack, constraints, false, void 0, loggerOptions);
|
|
@@ -15557,6 +15560,8 @@ var ElevenLabsClient = (function(exports) {
|
|
|
15557
15560
|
const minReconnectWait = 2 * 1e3;
|
|
15558
15561
|
const leaveReconnect = "leave-reconnect";
|
|
15559
15562
|
const reliabeReceiveStateTTL = 3e4;
|
|
15563
|
+
const lossyDataChannelBufferThresholdMin = 8 * 1024;
|
|
15564
|
+
const lossyDataChannelBufferThresholdMax = 256 * 1024;
|
|
15560
15565
|
var PCState;
|
|
15561
15566
|
(function(PCState) {
|
|
15562
15567
|
PCState[PCState["New"] = 0] = "New";
|
|
@@ -15600,6 +15605,9 @@ var ElevenLabsClient = (function(exports) {
|
|
|
15600
15605
|
this.reliableDataSequence = 1;
|
|
15601
15606
|
this.reliableMessageBuffer = new DataPacketBuffer();
|
|
15602
15607
|
this.reliableReceivedState = new TTLMap(reliabeReceiveStateTTL);
|
|
15608
|
+
this.lossyDataStatCurrentBytes = 0;
|
|
15609
|
+
this.lossyDataStatByterate = 0;
|
|
15610
|
+
this.lossyDataDropCount = 0;
|
|
15603
15611
|
this.midToTrackId = {};
|
|
15604
15612
|
/** used to indicate whether the browser is currently waiting to reconnect */
|
|
15605
15613
|
this.isWaitingForNetworkReconnect = false;
|
|
@@ -15816,6 +15824,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
15816
15824
|
this.removeAllListeners();
|
|
15817
15825
|
this.deregisterOnLineListener();
|
|
15818
15826
|
this.clearPendingReconnect();
|
|
15827
|
+
this.cleanupLossyDataStats();
|
|
15819
15828
|
yield this.cleanupPeerConnections();
|
|
15820
15829
|
yield this.cleanupClient();
|
|
15821
15830
|
} finally {
|
|
@@ -15851,6 +15860,15 @@ var ElevenLabsClient = (function(exports) {
|
|
|
15851
15860
|
this.reliableReceivedState.clear();
|
|
15852
15861
|
});
|
|
15853
15862
|
}
|
|
15863
|
+
cleanupLossyDataStats() {
|
|
15864
|
+
this.lossyDataStatByterate = 0;
|
|
15865
|
+
this.lossyDataStatCurrentBytes = 0;
|
|
15866
|
+
if (this.lossyDataStatInterval) {
|
|
15867
|
+
clearInterval(this.lossyDataStatInterval);
|
|
15868
|
+
this.lossyDataStatInterval = void 0;
|
|
15869
|
+
}
|
|
15870
|
+
this.lossyDataDropCount = 0;
|
|
15871
|
+
}
|
|
15854
15872
|
cleanupClient() {
|
|
15855
15873
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15856
15874
|
yield this.client.close();
|
|
@@ -15862,7 +15880,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
15862
15880
|
return new Promise((resolve, reject) => {
|
|
15863
15881
|
const publicationTimeout = setTimeout(() => {
|
|
15864
15882
|
delete this.pendingTrackResolvers[req.cid];
|
|
15865
|
-
reject(
|
|
15883
|
+
reject(ConnectionError.timeout("publication of local track timed out, no response from server"));
|
|
15866
15884
|
}, 1e4);
|
|
15867
15885
|
this.pendingTrackResolvers[req.cid] = {
|
|
15868
15886
|
resolve: (info) => {
|
|
@@ -16100,6 +16118,16 @@ var ElevenLabsClient = (function(exports) {
|
|
|
16100
16118
|
this.reliableDC.bufferedAmountLowThreshold = 65535;
|
|
16101
16119
|
this.lossyDC.onbufferedamountlow = this.handleBufferedAmountLow;
|
|
16102
16120
|
this.reliableDC.onbufferedamountlow = this.handleBufferedAmountLow;
|
|
16121
|
+
this.cleanupLossyDataStats();
|
|
16122
|
+
this.lossyDataStatInterval = setInterval(() => {
|
|
16123
|
+
this.lossyDataStatByterate = this.lossyDataStatCurrentBytes;
|
|
16124
|
+
this.lossyDataStatCurrentBytes = 0;
|
|
16125
|
+
const dc = this.dataChannelForKind(DataPacket_Kind.LOSSY);
|
|
16126
|
+
if (dc) {
|
|
16127
|
+
const threshold = this.lossyDataStatByterate / 10;
|
|
16128
|
+
dc.bufferedAmountLowThreshold = Math.min(Math.max(threshold, lossyDataChannelBufferThresholdMin), lossyDataChannelBufferThresholdMax);
|
|
16129
|
+
}
|
|
16130
|
+
}, 1e3);
|
|
16103
16131
|
}
|
|
16104
16132
|
createSender(track, opts, encodings) {
|
|
16105
16133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -16293,7 +16321,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
16293
16321
|
this.pcState = PCState.Connected;
|
|
16294
16322
|
} catch (e) {
|
|
16295
16323
|
this.pcState = PCState.Disconnected;
|
|
16296
|
-
throw
|
|
16324
|
+
throw ConnectionError.internal("could not establish PC connection, ".concat(e.message));
|
|
16297
16325
|
}
|
|
16298
16326
|
});
|
|
16299
16327
|
}
|
|
@@ -16356,13 +16384,22 @@ var ElevenLabsClient = (function(exports) {
|
|
|
16356
16384
|
this.reliableDataSequence += 1;
|
|
16357
16385
|
}
|
|
16358
16386
|
const msg = packet.toBinary();
|
|
16359
|
-
yield this.waitForBufferStatusLow(kind);
|
|
16360
16387
|
const dc = this.dataChannelForKind(kind);
|
|
16361
16388
|
if (dc) {
|
|
16362
|
-
if (kind === DataPacket_Kind.RELIABLE)
|
|
16363
|
-
|
|
16364
|
-
|
|
16365
|
-
|
|
16389
|
+
if (kind === DataPacket_Kind.RELIABLE) {
|
|
16390
|
+
yield this.waitForBufferStatusLow(kind);
|
|
16391
|
+
this.reliableMessageBuffer.push({
|
|
16392
|
+
data: msg,
|
|
16393
|
+
sequence: packet.sequence
|
|
16394
|
+
});
|
|
16395
|
+
} else {
|
|
16396
|
+
if (!this.isBufferStatusLow(kind)) {
|
|
16397
|
+
this.lossyDataDropCount += 1;
|
|
16398
|
+
if (this.lossyDataDropCount % 100 === 0) this.log.warn("dropping lossy data channel messages, total dropped: ".concat(this.lossyDataDropCount), this.logContext);
|
|
16399
|
+
return;
|
|
16400
|
+
}
|
|
16401
|
+
this.lossyDataStatCurrentBytes += msg.byteLength;
|
|
16402
|
+
}
|
|
16366
16403
|
if (this.attemptingReconnect) return;
|
|
16367
16404
|
dc.send(msg);
|
|
16368
16405
|
}
|
|
@@ -16406,7 +16443,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
16406
16443
|
if (!_this2.pcManager) throw new UnexpectedConnectionState("PC manager is closed");
|
|
16407
16444
|
const transport = subscriber ? _this2.pcManager.subscriber : _this2.pcManager.publisher;
|
|
16408
16445
|
const transportName = subscriber ? "Subscriber" : "Publisher";
|
|
16409
|
-
if (!transport) throw
|
|
16446
|
+
if (!transport) throw ConnectionError.internal("".concat(transportName, " connection not set"));
|
|
16410
16447
|
let needNegotiation = false;
|
|
16411
16448
|
if (!subscriber && !_this2.dataChannelForKind(kind, subscriber)) {
|
|
16412
16449
|
_this2.createDataChannels();
|
|
@@ -16423,7 +16460,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
16423
16460
|
if (transport.isICEConnected && ((_a = _this2.dataChannelForKind(kind, subscriber)) === null || _a === void 0 ? void 0 : _a.readyState) === "open") return;
|
|
16424
16461
|
yield sleep(50);
|
|
16425
16462
|
}
|
|
16426
|
-
throw
|
|
16463
|
+
throw ConnectionError.internal("could not establish ".concat(transportName, " connection, state: ").concat(transport.getICEConnectionState()));
|
|
16427
16464
|
}();
|
|
16428
16465
|
});
|
|
16429
16466
|
}
|
|
@@ -16585,7 +16622,6 @@ var ElevenLabsClient = (function(exports) {
|
|
|
16585
16622
|
}
|
|
16586
16623
|
}
|
|
16587
16624
|
};
|
|
16588
|
-
var SignalReconnectError = class extends Error {};
|
|
16589
16625
|
function supportOptionalDatachannel(protocol) {
|
|
16590
16626
|
return protocol !== void 0 && protocol > 13;
|
|
16591
16627
|
}
|
|
@@ -17081,7 +17117,6 @@ var ElevenLabsClient = (function(exports) {
|
|
|
17081
17117
|
}
|
|
17082
17118
|
/**
|
|
17083
17119
|
* @internal
|
|
17084
|
-
* @experimental CAUTION, might get removed in a minor release
|
|
17085
17120
|
*/
|
|
17086
17121
|
streamText(options) {
|
|
17087
17122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -17984,12 +18019,6 @@ var ElevenLabsClient = (function(exports) {
|
|
|
17984
18019
|
} else return [];
|
|
17985
18020
|
}
|
|
17986
18021
|
};
|
|
17987
|
-
/**
|
|
17988
|
-
* Creates a local video and audio track at the same time. When acquiring both
|
|
17989
|
-
* audio and video tracks together, it'll display a single permission prompt to
|
|
17990
|
-
* the user instead of two separate ones.
|
|
17991
|
-
* @param options
|
|
17992
|
-
*/
|
|
17993
18022
|
function createLocalTracks(options, loggerOptions) {
|
|
17994
18023
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17995
18024
|
options !== null && options !== void 0 || (options = {});
|
|
@@ -19483,7 +19512,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
19483
19512
|
resolve: (responsePayload, responseError) => {
|
|
19484
19513
|
clearTimeout(responseTimeoutId);
|
|
19485
19514
|
if (this.pendingAcks.has(id)) {
|
|
19486
|
-
|
|
19515
|
+
this.log.warn("RPC response received before ack", id);
|
|
19487
19516
|
this.pendingAcks.delete(id);
|
|
19488
19517
|
clearTimeout(ackTimeoutId);
|
|
19489
19518
|
}
|
|
@@ -20120,7 +20149,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
20120
20149
|
return this.connectFuture.promise;
|
|
20121
20150
|
}
|
|
20122
20151
|
this.setAndEmitConnectionState(ConnectionState.Connecting);
|
|
20123
|
-
if (((_a = this.regionUrlProvider) === null || _a === void 0 ? void 0 : _a.getServerUrl().toString()) !== url) {
|
|
20152
|
+
if (((_a = this.regionUrlProvider) === null || _a === void 0 ? void 0 : _a.getServerUrl().toString()) !== ensureTrailingSlash(url)) {
|
|
20124
20153
|
this.regionUrl = void 0;
|
|
20125
20154
|
this.regionUrlProvider = void 0;
|
|
20126
20155
|
}
|
|
@@ -20142,7 +20171,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
20142
20171
|
unlockDisconnect === null || unlockDisconnect === void 0 || unlockDisconnect();
|
|
20143
20172
|
try {
|
|
20144
20173
|
yield BackOffStrategy.getInstance().getBackOffPromise(url);
|
|
20145
|
-
if (abortController.signal.aborted) throw
|
|
20174
|
+
if (abortController.signal.aborted) throw ConnectionError.cancelled("Connection attempt aborted");
|
|
20146
20175
|
yield this.attemptConnection(regionUrl !== null && regionUrl !== void 0 ? regionUrl : url, token, opts, abortController);
|
|
20147
20176
|
this.abortController = void 0;
|
|
20148
20177
|
resolve();
|
|
@@ -20255,7 +20284,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
20255
20284
|
} catch (err) {
|
|
20256
20285
|
yield this.engine.close();
|
|
20257
20286
|
this.recreateEngine();
|
|
20258
|
-
const resultingError =
|
|
20287
|
+
const resultingError = abortController.signal.aborted ? ConnectionError.cancelled("Signal connection aborted") : ConnectionError.serverUnreachable("could not establish signal connection");
|
|
20259
20288
|
if (err instanceof Error) resultingError.message = "".concat(resultingError.message, ": ").concat(err.message);
|
|
20260
20289
|
if (err instanceof ConnectionError) {
|
|
20261
20290
|
resultingError.reason = err.reason;
|
|
@@ -20267,7 +20296,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
20267
20296
|
if (abortController.signal.aborted) {
|
|
20268
20297
|
yield this.engine.close();
|
|
20269
20298
|
this.recreateEngine();
|
|
20270
|
-
throw
|
|
20299
|
+
throw ConnectionError.cancelled("Connection attempt aborted");
|
|
20271
20300
|
}
|
|
20272
20301
|
try {
|
|
20273
20302
|
yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout, abortController);
|
|
@@ -20280,7 +20309,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
20280
20309
|
window.addEventListener("pagehide", this.onPageLeave);
|
|
20281
20310
|
window.addEventListener("beforeunload", this.onPageLeave);
|
|
20282
20311
|
}
|
|
20283
|
-
if (isWeb())
|
|
20312
|
+
if (isWeb()) window.addEventListener("freeze", this.onPageLeave);
|
|
20284
20313
|
this.setAndEmitConnectionState(ConnectionState.Connected);
|
|
20285
20314
|
this.emit(RoomEvent.Connected);
|
|
20286
20315
|
BackOffStrategy.getInstance().resetFailedConnectionAttempts(url);
|
|
@@ -20308,7 +20337,7 @@ var ElevenLabsClient = (function(exports) {
|
|
|
20308
20337
|
const msg = "Abort connection attempt due to user initiated disconnect";
|
|
20309
20338
|
_this2.log.warn(msg, _this2.logContext);
|
|
20310
20339
|
(_a = _this2.abortController) === null || _a === void 0 || _a.abort(msg);
|
|
20311
|
-
(_c = (_b = _this2.connectFuture) === null || _b === void 0 ? void 0 : _b.reject) === null || _c === void 0 || _c.call(_b,
|
|
20340
|
+
(_c = (_b = _this2.connectFuture) === null || _b === void 0 ? void 0 : _b.reject) === null || _c === void 0 || _c.call(_b, ConnectionError.cancelled("Client initiated disconnect"));
|
|
20312
20341
|
_this2.connectFuture = void 0;
|
|
20313
20342
|
}
|
|
20314
20343
|
if (_this2.engine) {
|
|
@@ -21286,12 +21315,12 @@ var ElevenLabsClient = (function(exports) {
|
|
|
21286
21315
|
});
|
|
21287
21316
|
if (byteLength(response) > MAX_PAYLOAD_BYTES) {
|
|
21288
21317
|
responseError = RpcError.builtIn("RESPONSE_PAYLOAD_TOO_LARGE");
|
|
21289
|
-
|
|
21318
|
+
this.log.warn("RPC Response payload too large for ".concat(method));
|
|
21290
21319
|
} else responsePayload = response;
|
|
21291
21320
|
} catch (error) {
|
|
21292
21321
|
if (error instanceof RpcError) responseError = error;
|
|
21293
21322
|
else {
|
|
21294
|
-
|
|
21323
|
+
this.log.warn("Uncaught error returned by RPC handler for ".concat(method, ". Returning APPLICATION_ERROR instead."), error);
|
|
21295
21324
|
responseError = RpcError.builtIn("APPLICATION_ERROR");
|
|
21296
21325
|
}
|
|
21297
21326
|
}
|
|
@@ -22144,7 +22173,7 @@ registerProcessor("rawAudioProcessor", RawAudioProcessor);
|
|
|
22144
22173
|
throw new Error(`Failed to fetch conversation token for agent ${config.agentId}: ${msg}`);
|
|
22145
22174
|
}
|
|
22146
22175
|
else throw new Error("Either conversationToken or agentId is required for WebRTC connection");
|
|
22147
|
-
const room = new Room();
|
|
22176
|
+
const room = new Room({ singlePeerConnection: false });
|
|
22148
22177
|
try {
|
|
22149
22178
|
const connection = new WebRTCConnection(room, `room_${Date.now()}`, parseFormat("pcm_48000"), parseFormat("pcm_48000"), config);
|
|
22150
22179
|
const livekitUrl = config.livekitUrl || DEFAULT_LIVEKIT_WS_URL;
|