@16x/webphone-sdk 3.1.5 → 3.1.7
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/CHANGELOG.md +32 -0
- package/dist/{CCBarClient-DLA6xiYH.js → CCBarClient-7XHcgg4k.js} +148 -137
- package/dist/CCBarClient-DuutkCu3.cjs +1 -0
- package/dist/{Diagnostics-DJeeM2q8.cjs → Diagnostics-C-PkbqQx.cjs} +1 -1
- package/dist/{Diagnostics-DdxaOkkw.js → Diagnostics-ChKsZB6s.js} +1 -1
- package/dist/{JsSipAdapter-oIJe-1OX.js → JsSipAdapter-C2NmmtWt.js} +32 -1
- package/dist/{JsSipAdapter-BHNVNkCS.cjs → JsSipAdapter-Dy5-I08P.cjs} +1 -1
- package/dist/api/contracts.d.ts +1 -1
- package/dist/diagnostics/index.cjs +1 -1
- package/dist/diagnostics/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/index.umd.js +11 -11
- package/dist/legacy/index.cjs +1 -1
- package/dist/legacy/index.js +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/CCBarClient-DVhqE08O.cjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as e, t } from "./SharedWorkerProtocol-DKVQ5-po.js";
|
|
2
|
-
import { r as n, t as r } from "./Diagnostics-
|
|
2
|
+
import { r as n, t as r } from "./Diagnostics-ChKsZB6s.js";
|
|
3
3
|
//#region src/events/TypedEventBus.ts
|
|
4
4
|
var i = class {
|
|
5
5
|
handlers = /* @__PURE__ */ new Map();
|
|
@@ -289,8 +289,9 @@ var c = class extends e {
|
|
|
289
289
|
"ended",
|
|
290
290
|
"failed",
|
|
291
291
|
"hold",
|
|
292
|
-
"unhold"
|
|
293
|
-
|
|
292
|
+
"unhold",
|
|
293
|
+
"mediaConnected"
|
|
294
|
+
], te = 3e4, m = class {
|
|
294
295
|
options;
|
|
295
296
|
currentState = "new";
|
|
296
297
|
sessionUnsubscribers = [];
|
|
@@ -342,6 +343,7 @@ var c = class extends e {
|
|
|
342
343
|
} catch (e) {
|
|
343
344
|
throw this.incomingOperation = void 0, this.finishFailedIncomingOperation(e), this.operationError(e);
|
|
344
345
|
}
|
|
346
|
+
this.transitionIfAllowed("connecting", void 0, "accepted");
|
|
345
347
|
}
|
|
346
348
|
async reject(e = {}, t) {
|
|
347
349
|
this.assertNotDisposed(), this.assertOwner(t), this.assertIncomingCall(), this.assertIncomingOperationAvailable(), this.incomingOperation = "reject";
|
|
@@ -366,13 +368,13 @@ var c = class extends e {
|
|
|
366
368
|
this.assertState("active"), this.assertCapability("dtmf"), this.invoke(() => this.options.session.sendDtmf(e));
|
|
367
369
|
}
|
|
368
370
|
async transfer(e, t) {
|
|
369
|
-
if (this.assertNotDisposed(), this.assertOwner(t), this.assertTransferCapability(), this.assertState("active"), this.assertCapability("blind_transfer"), !
|
|
371
|
+
if (this.assertNotDisposed(), this.assertOwner(t), this.assertTransferCapability(), this.assertState("active"), this.assertCapability("blind_transfer"), !ne(e) || e.target.trim() === "") throw this.operationError();
|
|
370
372
|
this.invoke(() => this.options.session.refer(e.target.trim()));
|
|
371
373
|
}
|
|
372
374
|
async hangup(e) {
|
|
373
|
-
if (this.assertNotDisposed(), this.assertOwner(e),
|
|
375
|
+
if (this.assertNotDisposed(), this.assertOwner(e), h(this.currentState)) throw this.operationError();
|
|
374
376
|
try {
|
|
375
|
-
this.options.session.terminate(), this.transitionTo("ended");
|
|
377
|
+
this.options.session.terminate(), h(this.currentState) || this.transitionTo("ended");
|
|
376
378
|
} catch (e) {
|
|
377
379
|
throw this.operationError(e);
|
|
378
380
|
}
|
|
@@ -400,7 +402,7 @@ var c = class extends e {
|
|
|
400
402
|
}
|
|
401
403
|
dispose() {
|
|
402
404
|
if (!this.disposed) {
|
|
403
|
-
if (this.rejectPendingOperation(), this.incomingOperation = void 0, this.disposed = !0, !
|
|
405
|
+
if (this.rejectPendingOperation(), this.incomingOperation = void 0, this.disposed = !0, !h(this.currentState)) try {
|
|
404
406
|
this.options.session.terminate();
|
|
405
407
|
} catch (e) {
|
|
406
408
|
this.reportOperationError(e);
|
|
@@ -412,7 +414,7 @@ var c = class extends e {
|
|
|
412
414
|
}
|
|
413
415
|
}
|
|
414
416
|
handleSessionEvent(e, t) {
|
|
415
|
-
if ((e === "accepted" || e === "confirmed" || e === "ended" || e === "failed") && (this.incomingOperation = void 0), !(this.disposed ||
|
|
417
|
+
if ((e === "accepted" || e === "confirmed" || e === "ended" || e === "failed") && (this.incomingOperation = void 0), !(this.disposed || h(this.currentState))) switch (e) {
|
|
416
418
|
case "progress":
|
|
417
419
|
this.transitionIfAllowed("ringing", t, e);
|
|
418
420
|
break;
|
|
@@ -422,6 +424,9 @@ var c = class extends e {
|
|
|
422
424
|
case "confirmed":
|
|
423
425
|
this.transitionToActive(t);
|
|
424
426
|
break;
|
|
427
|
+
case "mediaConnected":
|
|
428
|
+
this.currentState === "connecting" && this.transitionTo("active", t);
|
|
429
|
+
break;
|
|
425
430
|
case "hold":
|
|
426
431
|
this.transitionIfAllowed("held", t, e);
|
|
427
432
|
break;
|
|
@@ -447,7 +452,7 @@ var c = class extends e {
|
|
|
447
452
|
if (this.currentState === e) return;
|
|
448
453
|
if (!o(this.currentState, e)) throw this.operationError();
|
|
449
454
|
let n = this.currentState;
|
|
450
|
-
this.currentState = e,
|
|
455
|
+
this.currentState = e, h(e) && this.rejectPendingOperation();
|
|
451
456
|
try {
|
|
452
457
|
this.options.onStateChanged?.({
|
|
453
458
|
callId: this.id,
|
|
@@ -455,7 +460,7 @@ var c = class extends e {
|
|
|
455
460
|
to: e
|
|
456
461
|
}, t);
|
|
457
462
|
} catch {} finally {
|
|
458
|
-
|
|
463
|
+
h(e) && this.dispose();
|
|
459
464
|
}
|
|
460
465
|
}
|
|
461
466
|
startPendingOperation(e, t, n) {
|
|
@@ -467,7 +472,7 @@ var c = class extends e {
|
|
|
467
472
|
resolve: r,
|
|
468
473
|
reject: i
|
|
469
474
|
};
|
|
470
|
-
this.pendingOperation = a, a.timer = setTimeout(() => this.timeoutPendingOperation(a),
|
|
475
|
+
this.pendingOperation = a, a.timer = setTimeout(() => this.timeoutPendingOperation(a), te);
|
|
471
476
|
let o;
|
|
472
477
|
try {
|
|
473
478
|
o = n();
|
|
@@ -480,7 +485,7 @@ var c = class extends e {
|
|
|
480
485
|
}
|
|
481
486
|
resolvePendingOperation(e) {
|
|
482
487
|
if (this.pendingOperation === e) {
|
|
483
|
-
if (this.clearPendingTimer(e), this.pendingOperation = void 0, this.disposed ||
|
|
488
|
+
if (this.clearPendingTimer(e), this.pendingOperation = void 0, this.disposed || h(this.currentState)) {
|
|
484
489
|
e.reject(this.operationError());
|
|
485
490
|
return;
|
|
486
491
|
}
|
|
@@ -515,6 +520,7 @@ var c = class extends e {
|
|
|
515
520
|
} catch {}
|
|
516
521
|
}
|
|
517
522
|
finishFailedIncomingOperation(e) {
|
|
523
|
+
this.reportOperationError(e);
|
|
518
524
|
try {
|
|
519
525
|
this.options.session.terminate();
|
|
520
526
|
} catch (t) {
|
|
@@ -579,27 +585,27 @@ var c = class extends e {
|
|
|
579
585
|
});
|
|
580
586
|
}
|
|
581
587
|
};
|
|
582
|
-
function
|
|
588
|
+
function h(e) {
|
|
583
589
|
return e === "ended" || e === "failed";
|
|
584
590
|
}
|
|
585
|
-
function
|
|
591
|
+
function ne(e) {
|
|
586
592
|
return typeof e == "object" && !!e && e.type === "blind" && typeof e.target == "string";
|
|
587
593
|
}
|
|
588
594
|
//#endregion
|
|
589
595
|
//#region src/core/callId.ts
|
|
590
|
-
var
|
|
591
|
-
function
|
|
592
|
-
return
|
|
596
|
+
var g = 0;
|
|
597
|
+
function _() {
|
|
598
|
+
return g += 1, `call_${Date.now().toString(36)}_${g.toString(36)}`;
|
|
593
599
|
}
|
|
594
600
|
//#endregion
|
|
595
601
|
//#region src/core/userData.ts
|
|
596
|
-
var
|
|
602
|
+
var re = "X-User-Data", v = /[^\x20-\x7E]/, y = "userdata 只能是可见 ASCII(不能有换行/制表/中文):换行会构成 SIP 头注入;要传中文或 JSON 请调用方先 encodeURIComponent / base64,再在平台侧解回来";
|
|
597
603
|
function b(t) {
|
|
598
604
|
if (typeof t != "string") return [];
|
|
599
605
|
let n = t.trim();
|
|
600
606
|
if (n === "") return [];
|
|
601
|
-
if (
|
|
602
|
-
return [`${
|
|
607
|
+
if (v.test(n)) throw new e("CALL_INVALID_USERDATA", "call", !1, { cause: y });
|
|
608
|
+
return [`${re}: ${n}`];
|
|
603
609
|
}
|
|
604
610
|
//#endregion
|
|
605
611
|
//#region src/core/CallManager.ts
|
|
@@ -643,7 +649,7 @@ var x = class {
|
|
|
643
649
|
if (this.options.platform === "mobile-web" && this.calls.size + this.pendingDialCount >= o) throw this.capabilityError();
|
|
644
650
|
if (this.calls.size + this.pendingDialCount >= o || this.pendingDestinations.has(i) || [...this.calls.values()].some((e) => e.destination === i)) throw new e("CALL_ALREADY_EXISTS", "call", !1);
|
|
645
651
|
this.pendingDialCount += 1, this.pendingDestinations.add(i);
|
|
646
|
-
let s =
|
|
652
|
+
let s = _(), c;
|
|
647
653
|
try {
|
|
648
654
|
c = await this.holdActiveCallForNewCall(), this.assertGeneration(r, s);
|
|
649
655
|
let e;
|
|
@@ -655,7 +661,7 @@ var x = class {
|
|
|
655
661
|
this.assertGeneration(r, s);
|
|
656
662
|
let o;
|
|
657
663
|
try {
|
|
658
|
-
o = new
|
|
664
|
+
o = new m({
|
|
659
665
|
id: s,
|
|
660
666
|
destination: i,
|
|
661
667
|
platform: this.options.platform,
|
|
@@ -906,7 +912,7 @@ var x = class {
|
|
|
906
912
|
}
|
|
907
913
|
handleIncoming(t) {
|
|
908
914
|
if (this.disposed) return;
|
|
909
|
-
let n =
|
|
915
|
+
let n = _(), r = this.incomingSessionSnapshot;
|
|
910
916
|
if (r === void 0 || !r.policy.incomingEnabled || !this.effectiveCapabilities(r).has("inbound")) {
|
|
911
917
|
this.terminateUnsupportedIncoming(t), this.events.emit("error", { error: this.capabilityError(n) });
|
|
912
918
|
return;
|
|
@@ -918,7 +924,7 @@ var x = class {
|
|
|
918
924
|
}
|
|
919
925
|
let a;
|
|
920
926
|
try {
|
|
921
|
-
a = new
|
|
927
|
+
a = new m({
|
|
922
928
|
id: n,
|
|
923
929
|
destination: i,
|
|
924
930
|
platform: this.options.platform,
|
|
@@ -1139,13 +1145,13 @@ var se = class {
|
|
|
1139
1145
|
try {
|
|
1140
1146
|
let n = t(e);
|
|
1141
1147
|
if (n.type === "event") {
|
|
1142
|
-
n.event === "connection.stateChanged" &&
|
|
1148
|
+
n.event === "connection.stateChanged" && ce(n.payload) && (this.lifecycleState = n.payload.state), this.eventHandlers.forEach((e) => e(n));
|
|
1143
1149
|
return;
|
|
1144
1150
|
}
|
|
1145
1151
|
if (n.type !== "response") return;
|
|
1146
1152
|
let r = this.pending.get(n.requestId);
|
|
1147
1153
|
if (r === void 0) return;
|
|
1148
|
-
this.pending.delete(n.requestId), clearTimeout(r.timer), n.ok ? r.resolve(n.result) : r.reject(
|
|
1154
|
+
this.pending.delete(n.requestId), clearTimeout(r.timer), n.ok ? r.resolve(n.result) : r.reject(le(n));
|
|
1149
1155
|
} catch (e) {
|
|
1150
1156
|
this.pending.forEach((t) => {
|
|
1151
1157
|
clearTimeout(t.timer), t.reject(e);
|
|
@@ -1153,10 +1159,10 @@ var se = class {
|
|
|
1153
1159
|
}
|
|
1154
1160
|
}
|
|
1155
1161
|
};
|
|
1156
|
-
function
|
|
1162
|
+
function ce(e) {
|
|
1157
1163
|
return typeof e == "object" && !!e && "state" in e && (e.state === "connected" || e.state === "reconnecting");
|
|
1158
1164
|
}
|
|
1159
|
-
function
|
|
1165
|
+
function le(t) {
|
|
1160
1166
|
let n = t.error;
|
|
1161
1167
|
return new e(n?.code ?? "SDK_INTERNAL_ERROR", n?.category ?? "internal", n?.retryable ?? !1, {
|
|
1162
1168
|
requestId: t.requestId,
|
|
@@ -1167,12 +1173,12 @@ function ce(t) {
|
|
|
1167
1173
|
}
|
|
1168
1174
|
//#endregion
|
|
1169
1175
|
//#region src/shared/SharedWorkerFactory.ts
|
|
1170
|
-
function
|
|
1176
|
+
function S(t = {}) {
|
|
1171
1177
|
if ((t.enabled ?? "auto") === !1) return {
|
|
1172
1178
|
mode: "single-tab",
|
|
1173
1179
|
reason: "disabled"
|
|
1174
1180
|
};
|
|
1175
|
-
let n = t.locationHref ??
|
|
1181
|
+
let n = t.locationHref ?? w(), r = C(t.url, n), i = (n) => {
|
|
1176
1182
|
if (t.fallback === "error") throw new e("CONFIG_INVALID", "configuration", !1, { cause: n });
|
|
1177
1183
|
return {
|
|
1178
1184
|
mode: "single-tab",
|
|
@@ -1180,8 +1186,8 @@ function C(t = {}) {
|
|
|
1180
1186
|
};
|
|
1181
1187
|
};
|
|
1182
1188
|
if (r === void 0) return i("SharedWorker URL is unavailable");
|
|
1183
|
-
if (!
|
|
1184
|
-
let a = t.workerCtor ??
|
|
1189
|
+
if (!de(r, n)) return i("SharedWorker URL must be same-origin");
|
|
1190
|
+
let a = t.workerCtor ?? ue();
|
|
1185
1191
|
if (a === void 0) return i("SharedWorker is not supported");
|
|
1186
1192
|
let o;
|
|
1187
1193
|
try {
|
|
@@ -1189,10 +1195,10 @@ function C(t = {}) {
|
|
|
1189
1195
|
} catch (e) {
|
|
1190
1196
|
return i(`SharedWorker construction failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
1191
1197
|
}
|
|
1192
|
-
let s = t.tabId ??
|
|
1198
|
+
let s = t.tabId ?? T(), c = new se(o.port), l = {
|
|
1193
1199
|
version: 1,
|
|
1194
1200
|
type: "attach",
|
|
1195
|
-
requestId:
|
|
1201
|
+
requestId: E(),
|
|
1196
1202
|
tabId: s
|
|
1197
1203
|
}, u = c.request(l).then(() => void 0).catch((e) => {
|
|
1198
1204
|
throw c.close(), e;
|
|
@@ -1206,20 +1212,20 @@ function C(t = {}) {
|
|
|
1206
1212
|
ready: u
|
|
1207
1213
|
};
|
|
1208
1214
|
}
|
|
1209
|
-
function
|
|
1215
|
+
function C(e, t = w()) {
|
|
1210
1216
|
try {
|
|
1211
1217
|
return t === void 0 ? void 0 : new URL(e ?? "./shared-worker.js", t).toString();
|
|
1212
1218
|
} catch {
|
|
1213
1219
|
return;
|
|
1214
1220
|
}
|
|
1215
1221
|
}
|
|
1216
|
-
function
|
|
1222
|
+
function w() {
|
|
1217
1223
|
return typeof location > "u" ? void 0 : location.href;
|
|
1218
1224
|
}
|
|
1219
|
-
function
|
|
1225
|
+
function ue() {
|
|
1220
1226
|
if (typeof SharedWorker == "function") return SharedWorker;
|
|
1221
1227
|
}
|
|
1222
|
-
function
|
|
1228
|
+
function de(e, t) {
|
|
1223
1229
|
if (t === void 0) return !0;
|
|
1224
1230
|
try {
|
|
1225
1231
|
return new URL(e, t).origin === new URL(t).origin;
|
|
@@ -1227,15 +1233,15 @@ function E(e, t) {
|
|
|
1227
1233
|
return !1;
|
|
1228
1234
|
}
|
|
1229
1235
|
}
|
|
1230
|
-
function
|
|
1236
|
+
function T() {
|
|
1231
1237
|
return `tab-${typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).slice(2)}`;
|
|
1232
1238
|
}
|
|
1233
|
-
function
|
|
1239
|
+
function E() {
|
|
1234
1240
|
return `attach-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
1235
1241
|
}
|
|
1236
1242
|
//#endregion
|
|
1237
1243
|
//#region src/media/DeviceManager.ts
|
|
1238
|
-
var
|
|
1244
|
+
var D = class {
|
|
1239
1245
|
mediaDevices;
|
|
1240
1246
|
createAudioElement;
|
|
1241
1247
|
outputCapability;
|
|
@@ -1243,23 +1249,23 @@ var k = class {
|
|
|
1243
1249
|
outputGeneration = 0;
|
|
1244
1250
|
outputTail;
|
|
1245
1251
|
constructor(e = {}) {
|
|
1246
|
-
this.mediaDevices = e.mediaDevices === null ? void 0 : e.mediaDevices ??
|
|
1252
|
+
this.mediaDevices = e.mediaDevices === null ? void 0 : e.mediaDevices ?? O(), this.createAudioElement = e.createAudioElement;
|
|
1247
1253
|
}
|
|
1248
1254
|
async requestPermission(e = {}) {
|
|
1249
1255
|
let t = this.requireMediaDevices(), n;
|
|
1250
1256
|
try {
|
|
1251
1257
|
n = await t.getUserMedia({ audio: e });
|
|
1252
1258
|
} catch (e) {
|
|
1253
|
-
throw
|
|
1259
|
+
throw j(e);
|
|
1254
1260
|
}
|
|
1255
|
-
|
|
1261
|
+
k(n);
|
|
1256
1262
|
}
|
|
1257
1263
|
async getDevices() {
|
|
1258
1264
|
if (this.mediaDevices === void 0) return [];
|
|
1259
1265
|
try {
|
|
1260
1266
|
return (await this.mediaDevices.enumerateDevices()).filter((e) => e.kind === "audioinput" || e.kind === "audiooutput" && this.supportsOutputSelection());
|
|
1261
1267
|
} catch (e) {
|
|
1262
|
-
throw
|
|
1268
|
+
throw M(e);
|
|
1263
1269
|
}
|
|
1264
1270
|
}
|
|
1265
1271
|
getCapabilities() {
|
|
@@ -1297,7 +1303,7 @@ var k = class {
|
|
|
1297
1303
|
try {
|
|
1298
1304
|
await r.setSinkId(t);
|
|
1299
1305
|
} catch (e) {
|
|
1300
|
-
throw
|
|
1306
|
+
throw N(e);
|
|
1301
1307
|
}
|
|
1302
1308
|
}
|
|
1303
1309
|
enqueueOutput(e) {
|
|
@@ -1311,7 +1317,7 @@ var k = class {
|
|
|
1311
1317
|
try {
|
|
1312
1318
|
return await t.getUserMedia({ audio: { deviceId: { exact: e } } });
|
|
1313
1319
|
} catch (e) {
|
|
1314
|
-
throw
|
|
1320
|
+
throw A(e);
|
|
1315
1321
|
}
|
|
1316
1322
|
}
|
|
1317
1323
|
requireMediaDevices() {
|
|
@@ -1331,10 +1337,10 @@ var k = class {
|
|
|
1331
1337
|
}
|
|
1332
1338
|
}
|
|
1333
1339
|
};
|
|
1334
|
-
function
|
|
1340
|
+
function O() {
|
|
1335
1341
|
return globalThis.navigator?.mediaDevices;
|
|
1336
1342
|
}
|
|
1337
|
-
function
|
|
1343
|
+
function k(e) {
|
|
1338
1344
|
let t;
|
|
1339
1345
|
try {
|
|
1340
1346
|
t = e.getTracks();
|
|
@@ -1347,57 +1353,57 @@ function j(e) {
|
|
|
1347
1353
|
} catch {}
|
|
1348
1354
|
});
|
|
1349
1355
|
}
|
|
1350
|
-
function
|
|
1351
|
-
let n =
|
|
1356
|
+
function A(t) {
|
|
1357
|
+
let n = P(t);
|
|
1352
1358
|
return n === "NotFoundError" || n === "OverconstrainedError" ? new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { cause: t }) : n === "NotReadableError" || n === "AbortError" ? new e("MEDIA_DEVICE_IN_USE", "media", !0, { cause: t }) : n === "NotAllowedError" || n === "SecurityError" ? new e("MEDIA_PERMISSION_DENIED", "media", !1, { cause: t }) : new e("SDK_INTERNAL_ERROR", "internal", !1, { cause: t });
|
|
1353
1359
|
}
|
|
1354
|
-
function
|
|
1355
|
-
let n =
|
|
1360
|
+
function j(t) {
|
|
1361
|
+
let n = P(t);
|
|
1356
1362
|
return n === "NotFoundError" || n === "OverconstrainedError" ? new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { cause: t }) : n === "NotReadableError" || n === "AbortError" ? new e("MEDIA_DEVICE_IN_USE", "media", !0, { cause: t }) : n === "NotAllowedError" || n === "SecurityError" ? new e("MEDIA_PERMISSION_DENIED", "media", !1, { cause: t }) : new e("SDK_INTERNAL_ERROR", "internal", !1, { cause: t });
|
|
1357
1363
|
}
|
|
1358
|
-
function
|
|
1359
|
-
let n =
|
|
1364
|
+
function M(t) {
|
|
1365
|
+
let n = P(t);
|
|
1360
1366
|
return n === "NotFoundError" ? new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { cause: t }) : n === "NotAllowedError" || n === "SecurityError" ? new e("MEDIA_PERMISSION_DENIED", "media", !1, { cause: t }) : n === "AbortError" || n === "NotReadableError" ? new e("MEDIA_DEVICE_IN_USE", "media", !0, { cause: t }) : new e("SDK_INTERNAL_ERROR", "internal", !1, { cause: t });
|
|
1361
1367
|
}
|
|
1362
|
-
function
|
|
1363
|
-
let n =
|
|
1368
|
+
function N(t) {
|
|
1369
|
+
let n = P(t);
|
|
1364
1370
|
return n === "NotFoundError" ? new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { cause: t }) : n === "NotAllowedError" || n === "SecurityError" ? new e("MEDIA_PERMISSION_DENIED", "media", !1, { cause: t }) : n === "AbortError" || n === "NotReadableError" ? new e("MEDIA_DEVICE_IN_USE", "media", !0, { cause: t }) : new e("SDK_INTERNAL_ERROR", "internal", !1, { cause: t });
|
|
1365
1371
|
}
|
|
1366
|
-
function
|
|
1372
|
+
function P(e) {
|
|
1367
1373
|
if (typeof e != "object" || !e || !("name" in e)) return;
|
|
1368
1374
|
let t = e.name;
|
|
1369
1375
|
return typeof t == "string" ? t : void 0;
|
|
1370
1376
|
}
|
|
1371
1377
|
//#endregion
|
|
1372
1378
|
//#region src/media/RemoteAudio.ts
|
|
1373
|
-
var
|
|
1379
|
+
var F = class {
|
|
1374
1380
|
createAudioElement;
|
|
1375
1381
|
bindings = /* @__PURE__ */ new Map();
|
|
1376
1382
|
audioOwners = /* @__PURE__ */ new Map();
|
|
1377
1383
|
trackOwners = /* @__PURE__ */ new Map();
|
|
1378
1384
|
generations = /* @__PURE__ */ new Map();
|
|
1379
1385
|
pendingPlays = /* @__PURE__ */ new Map();
|
|
1380
|
-
constructor(e =
|
|
1386
|
+
constructor(e = I) {
|
|
1381
1387
|
this.createAudioElement = e;
|
|
1382
1388
|
}
|
|
1383
1389
|
async bind(t, n) {
|
|
1384
1390
|
let r = this.bindings.get(t);
|
|
1385
1391
|
if (r?.stream === n) return;
|
|
1386
|
-
let i =
|
|
1392
|
+
let i = L(t, n), a;
|
|
1387
1393
|
try {
|
|
1388
1394
|
a = this.createAudioElement();
|
|
1389
1395
|
} catch (n) {
|
|
1390
|
-
throw
|
|
1396
|
+
throw R(i, this.trackOwners), new e("CAPABILITY_NOT_SUPPORTED", "capability", !1, {
|
|
1391
1397
|
callId: t,
|
|
1392
1398
|
cause: n
|
|
1393
1399
|
});
|
|
1394
1400
|
}
|
|
1395
1401
|
let o = this.audioOwners.get(a);
|
|
1396
|
-
if (o !== void 0 && o !== t) throw
|
|
1402
|
+
if (o !== void 0 && o !== t) throw R(i, this.trackOwners), new e("CALL_OPERATION_NOT_ALLOWED", "call", !1, { callId: t });
|
|
1397
1403
|
try {
|
|
1398
1404
|
a.autoplay = !0, a.playsInline = !0;
|
|
1399
1405
|
} catch (n) {
|
|
1400
|
-
throw
|
|
1406
|
+
throw R(i, this.trackOwners), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1401
1407
|
callId: t,
|
|
1402
1408
|
cause: n
|
|
1403
1409
|
});
|
|
@@ -1405,7 +1411,7 @@ var L = class {
|
|
|
1405
1411
|
try {
|
|
1406
1412
|
a.srcObject = n;
|
|
1407
1413
|
} catch (n) {
|
|
1408
|
-
throw
|
|
1414
|
+
throw R(i, this.trackOwners), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1409
1415
|
callId: t,
|
|
1410
1416
|
cause: n
|
|
1411
1417
|
});
|
|
@@ -1481,7 +1487,7 @@ var L = class {
|
|
|
1481
1487
|
releaseTrack(e) {
|
|
1482
1488
|
let t = this.trackOwners.get(e);
|
|
1483
1489
|
if (t === void 0 || t <= 1) {
|
|
1484
|
-
this.trackOwners.delete(e),
|
|
1490
|
+
this.trackOwners.delete(e), B(e);
|
|
1485
1491
|
return;
|
|
1486
1492
|
}
|
|
1487
1493
|
this.trackOwners.set(e, t - 1);
|
|
@@ -1504,42 +1510,42 @@ var L = class {
|
|
|
1504
1510
|
return this.generations.get(e) === t && this.bindings.get(e)?.generation === t;
|
|
1505
1511
|
}
|
|
1506
1512
|
};
|
|
1507
|
-
function
|
|
1513
|
+
function I() {
|
|
1508
1514
|
if (typeof document > "u") throw new e("CAPABILITY_NOT_SUPPORTED", "capability", !1);
|
|
1509
1515
|
return document.createElement("audio");
|
|
1510
1516
|
}
|
|
1511
|
-
function
|
|
1517
|
+
function L(t, n) {
|
|
1512
1518
|
try {
|
|
1513
1519
|
return [...new Set(n.getAudioTracks())].filter((e) => e.kind === "audio");
|
|
1514
1520
|
} catch (r) {
|
|
1515
1521
|
try {
|
|
1516
1522
|
return [...new Set(n.getTracks())].filter((e) => e.kind === "audio");
|
|
1517
1523
|
} catch (i) {
|
|
1518
|
-
throw
|
|
1524
|
+
throw z(n), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1519
1525
|
callId: t,
|
|
1520
1526
|
cause: r ?? i
|
|
1521
1527
|
});
|
|
1522
1528
|
}
|
|
1523
1529
|
}
|
|
1524
1530
|
}
|
|
1525
|
-
function
|
|
1531
|
+
function R(e, t) {
|
|
1526
1532
|
e.forEach((e) => {
|
|
1527
|
-
(t.get(e) ?? 0) === 0 &&
|
|
1533
|
+
(t.get(e) ?? 0) === 0 && B(e);
|
|
1528
1534
|
});
|
|
1529
1535
|
}
|
|
1530
|
-
function
|
|
1536
|
+
function z(e) {
|
|
1531
1537
|
try {
|
|
1532
|
-
[...new Set(e.getTracks())].filter((e) => e.kind === "audio").forEach(
|
|
1538
|
+
[...new Set(e.getTracks())].filter((e) => e.kind === "audio").forEach(B);
|
|
1533
1539
|
} catch {}
|
|
1534
1540
|
}
|
|
1535
|
-
function
|
|
1541
|
+
function B(e) {
|
|
1536
1542
|
try {
|
|
1537
1543
|
e.stop();
|
|
1538
1544
|
} catch {}
|
|
1539
1545
|
}
|
|
1540
1546
|
//#endregion
|
|
1541
1547
|
//#region src/media/MediaManager.ts
|
|
1542
|
-
var
|
|
1548
|
+
var V = class {
|
|
1543
1549
|
deviceManager;
|
|
1544
1550
|
remoteAudio;
|
|
1545
1551
|
getActiveCall;
|
|
@@ -1560,7 +1566,7 @@ var U = class {
|
|
|
1560
1566
|
mediaDevices: e.mediaDevices,
|
|
1561
1567
|
createAudioElement: e.createAudioElement
|
|
1562
1568
|
};
|
|
1563
|
-
this.deviceManager = new
|
|
1569
|
+
this.deviceManager = new D(t), this.remoteAudio = new F(e.createAudioElement), this.getActiveCall = e.getActiveCall, this.createRemoteStream = e.createRemoteStream ?? pe;
|
|
1564
1570
|
}
|
|
1565
1571
|
requestPermission(e) {
|
|
1566
1572
|
return this.assertNotDisposed(), this.deviceManager.requestPermission(e);
|
|
@@ -1580,7 +1586,7 @@ var U = class {
|
|
|
1580
1586
|
n !== void 0 && this.releaseResource(n).catch((e) => {
|
|
1581
1587
|
this.releaseErrors.set(n, e);
|
|
1582
1588
|
});
|
|
1583
|
-
let r =
|
|
1589
|
+
let r = H(t) ? t : { peerConnection: t }, i = {
|
|
1584
1590
|
callId: e,
|
|
1585
1591
|
peerConnection: r.peerConnection,
|
|
1586
1592
|
senders: /* @__PURE__ */ new Map(),
|
|
@@ -1662,7 +1668,7 @@ var U = class {
|
|
|
1662
1668
|
this.remoteAudio.release(r), this.releaseErrors.delete(t), this.calls.get(r) === t && this.calls.delete(r), t.generation += 1, t.released = !0, this.unsubscribeTrackSource(t);
|
|
1663
1669
|
let i = /* @__PURE__ */ new Set([...t.localTracks, ...t.pendingTracks]), a = [...t.senders.values()].filter((e) => e.audio).map((e) => ({
|
|
1664
1670
|
senderResource: e,
|
|
1665
|
-
promise: this.enqueueSender(t, e, () =>
|
|
1671
|
+
promise: this.enqueueSender(t, e, () => G(e.sender), !0)
|
|
1666
1672
|
})), o = Promise.all(a.map(async (e) => {
|
|
1667
1673
|
try {
|
|
1668
1674
|
return await e.promise, {
|
|
@@ -1680,14 +1686,14 @@ var U = class {
|
|
|
1680
1686
|
if (n.forEach((e) => {
|
|
1681
1687
|
if (e.cause !== void 0) {
|
|
1682
1688
|
o.push(e.cause);
|
|
1683
|
-
let t =
|
|
1689
|
+
let t = U(e.senderResource.sender);
|
|
1684
1690
|
t?.kind === "audio" && a.add(t);
|
|
1685
1691
|
return;
|
|
1686
1692
|
}
|
|
1687
|
-
let t =
|
|
1693
|
+
let t = U(e.senderResource.sender);
|
|
1688
1694
|
t?.kind === "audio" && i.add(t);
|
|
1689
1695
|
}), i.forEach((e) => {
|
|
1690
|
-
a.has(e) ||
|
|
1696
|
+
a.has(e) || q(e);
|
|
1691
1697
|
}), o.length > 0) throw t.localTracks.clear(), t.pendingTracks.clear(), a.forEach((e) => t.localTracks.add(e)), new e("SDK_INTERNAL_ERROR", "internal", !0, {
|
|
1692
1698
|
callId: r,
|
|
1693
1699
|
cause: o[0]
|
|
@@ -1695,7 +1701,7 @@ var U = class {
|
|
|
1695
1701
|
if (!t.peerClosed && t.peerConnection.close !== void 0) try {
|
|
1696
1702
|
await t.peerConnection.close(), t.peerClosed = !0;
|
|
1697
1703
|
} catch (n) {
|
|
1698
|
-
let i = [...t.senders.values()].map((e) =>
|
|
1704
|
+
let i = [...t.senders.values()].map((e) => U(e.sender)).find((e) => e?.kind === "audio");
|
|
1699
1705
|
throw t.localTracks.clear(), t.pendingTracks.clear(), i != null && t.localTracks.add(i), new e("SDK_INTERNAL_ERROR", "internal", !0, {
|
|
1700
1706
|
callId: r,
|
|
1701
1707
|
cause: n
|
|
@@ -1763,11 +1769,11 @@ var U = class {
|
|
|
1763
1769
|
}
|
|
1764
1770
|
async performInputSwitch(t, n, r) {
|
|
1765
1771
|
if (this.assertActiveCall(n), this.assertDeviceSelectionCapability(n), !this.isCurrentResource(r) || n.peerConnection !== r.peerConnection) throw this.callOperationError(n.callId);
|
|
1766
|
-
let i = this.findAudioSender(r), a =
|
|
1772
|
+
let i = this.findAudioSender(r), a = U(i.sender), o = r.generation, s = await this.deviceManager.openInputStream(t), c;
|
|
1767
1773
|
try {
|
|
1768
1774
|
c = s.getTracks();
|
|
1769
1775
|
} catch (t) {
|
|
1770
|
-
throw
|
|
1776
|
+
throw fe(s), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1771
1777
|
callId: n.callId,
|
|
1772
1778
|
cause: t
|
|
1773
1779
|
});
|
|
@@ -1776,26 +1782,26 @@ var U = class {
|
|
|
1776
1782
|
try {
|
|
1777
1783
|
l = s.getAudioTracks();
|
|
1778
1784
|
} catch (t) {
|
|
1779
|
-
throw
|
|
1785
|
+
throw K(c), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1780
1786
|
callId: n.callId,
|
|
1781
1787
|
cause: t
|
|
1782
1788
|
});
|
|
1783
1789
|
}
|
|
1784
1790
|
let u = l[0];
|
|
1785
|
-
if (u === void 0) throw
|
|
1786
|
-
if (!this.canCommitInputSwitch(n, r, i, a, o)) throw
|
|
1791
|
+
if (u === void 0) throw K(c), new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { callId: n.callId });
|
|
1792
|
+
if (!this.canCommitInputSwitch(n, r, i, a, o)) throw K(c), this.callOperationError(n.callId);
|
|
1787
1793
|
c.forEach((e) => r.pendingTracks.add(e)), r.pendingTracks.add(u);
|
|
1788
1794
|
try {
|
|
1789
1795
|
await this.enqueueSender(r, i, () => i.sender.replaceTrack(u));
|
|
1790
1796
|
} catch (t) {
|
|
1791
|
-
throw r.released ? this.callOperationError(n.callId) : (r.released || (c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), await this.rollbackSender(r, i, a, u),
|
|
1797
|
+
throw r.released ? this.callOperationError(n.callId) : (r.released || (c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), await this.rollbackSender(r, i, a, u), K(c)), new e("MEDIA_DEVICE_IN_USE", "media", !0, {
|
|
1792
1798
|
callId: n.callId,
|
|
1793
1799
|
cause: t
|
|
1794
1800
|
}));
|
|
1795
1801
|
}
|
|
1796
1802
|
if (!this.canCommitInputSwitch(n, r, i, u, o)) {
|
|
1797
1803
|
if (!r.released) try {
|
|
1798
|
-
await this.enqueueSender(r, i, () =>
|
|
1804
|
+
await this.enqueueSender(r, i, () => U(i.sender) === u ? G(i.sender) : Promise.resolve()), c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), K(c);
|
|
1799
1805
|
} catch (t) {
|
|
1800
1806
|
throw new e("SDK_INTERNAL_ERROR", "internal", !0, {
|
|
1801
1807
|
callId: n.callId,
|
|
@@ -1804,8 +1810,8 @@ var U = class {
|
|
|
1804
1810
|
}
|
|
1805
1811
|
throw this.callOperationError(n.callId);
|
|
1806
1812
|
}
|
|
1807
|
-
c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), r.localTracks.add(u), a !== null && a !== u && (r.localTracks.delete(a),
|
|
1808
|
-
e !== u &&
|
|
1813
|
+
c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), r.localTracks.add(u), a !== null && a !== u && (r.localTracks.delete(a), q(a)), c.forEach((e) => {
|
|
1814
|
+
e !== u && q(e);
|
|
1809
1815
|
});
|
|
1810
1816
|
}
|
|
1811
1817
|
ensureCallMedia(e) {
|
|
@@ -1828,7 +1834,7 @@ var U = class {
|
|
|
1828
1834
|
});
|
|
1829
1835
|
}
|
|
1830
1836
|
r.forEach((r) => {
|
|
1831
|
-
let i =
|
|
1837
|
+
let i = U(r), a;
|
|
1832
1838
|
try {
|
|
1833
1839
|
a = n?.(r) ?? r.senderKind ?? r.kind;
|
|
1834
1840
|
} catch (n) {
|
|
@@ -1845,7 +1851,7 @@ var U = class {
|
|
|
1845
1851
|
});
|
|
1846
1852
|
}
|
|
1847
1853
|
findAudioSender(e) {
|
|
1848
|
-
let t = [...e.senders.values()].find((e) => e.audio && (
|
|
1854
|
+
let t = [...e.senders.values()].find((e) => e.audio && (U(e.sender)?.kind === "audio" || U(e.sender) === null));
|
|
1849
1855
|
if (t === void 0) throw this.capabilityError(e.callId);
|
|
1850
1856
|
return t;
|
|
1851
1857
|
}
|
|
@@ -1861,7 +1867,7 @@ var U = class {
|
|
|
1861
1867
|
} catch {
|
|
1862
1868
|
return !1;
|
|
1863
1869
|
}
|
|
1864
|
-
return
|
|
1870
|
+
return U(n.sender) === r;
|
|
1865
1871
|
}
|
|
1866
1872
|
enqueueSender(e, t, n, r = !1) {
|
|
1867
1873
|
t.queue.pending += 1;
|
|
@@ -1890,7 +1896,7 @@ var U = class {
|
|
|
1890
1896
|
});
|
|
1891
1897
|
}
|
|
1892
1898
|
async rollbackSender(e, t, n, r) {
|
|
1893
|
-
e.released ||
|
|
1899
|
+
e.released || U(t.sender) !== r || await this.enqueueSender(e, t, () => t.sender.replaceTrack(n)).catch(() => void 0);
|
|
1894
1900
|
}
|
|
1895
1901
|
isCurrentResource(e, t = e.generation) {
|
|
1896
1902
|
return !this.disposed && this.calls.get(e.callId) === e && e.generation === t;
|
|
@@ -1917,37 +1923,42 @@ var U = class {
|
|
|
1917
1923
|
if (this.disposed || this.disposing) throw new e("SDK_ALREADY_DISPOSED", "internal", !1);
|
|
1918
1924
|
}
|
|
1919
1925
|
};
|
|
1920
|
-
function
|
|
1926
|
+
function H(e) {
|
|
1921
1927
|
return "peerConnection" in e;
|
|
1922
1928
|
}
|
|
1923
|
-
function
|
|
1929
|
+
function U(e) {
|
|
1924
1930
|
try {
|
|
1925
1931
|
return e.track;
|
|
1926
1932
|
} catch {
|
|
1927
1933
|
return null;
|
|
1928
1934
|
}
|
|
1929
1935
|
}
|
|
1930
|
-
function
|
|
1936
|
+
function W(e) {
|
|
1937
|
+
return typeof e == "object" && !!e && e.name === "InvalidStateError";
|
|
1938
|
+
}
|
|
1939
|
+
function G(e) {
|
|
1931
1940
|
try {
|
|
1932
|
-
return e.replaceTrack(null)
|
|
1941
|
+
return e.replaceTrack(null).catch((e) => {
|
|
1942
|
+
if (!W(e)) throw e;
|
|
1943
|
+
});
|
|
1933
1944
|
} catch (e) {
|
|
1934
|
-
return Promise.reject(e);
|
|
1945
|
+
return W(e) ? Promise.resolve() : Promise.reject(e);
|
|
1935
1946
|
}
|
|
1936
1947
|
}
|
|
1937
|
-
function
|
|
1948
|
+
function fe(e) {
|
|
1938
1949
|
try {
|
|
1939
|
-
|
|
1950
|
+
K(e.getTracks());
|
|
1940
1951
|
} catch {}
|
|
1941
1952
|
}
|
|
1942
|
-
function
|
|
1943
|
-
e.forEach(
|
|
1953
|
+
function K(e) {
|
|
1954
|
+
e.forEach(q);
|
|
1944
1955
|
}
|
|
1945
|
-
function
|
|
1956
|
+
function q(e) {
|
|
1946
1957
|
try {
|
|
1947
1958
|
e.stop();
|
|
1948
1959
|
} catch {}
|
|
1949
1960
|
}
|
|
1950
|
-
function
|
|
1961
|
+
function pe(e) {
|
|
1951
1962
|
if (typeof MediaStream < "u") try {
|
|
1952
1963
|
return new MediaStream([e]);
|
|
1953
1964
|
} catch {
|
|
@@ -1956,8 +1967,8 @@ function de(e) {
|
|
|
1956
1967
|
}
|
|
1957
1968
|
//#endregion
|
|
1958
1969
|
//#region src/core/mediaBridge.ts
|
|
1959
|
-
function
|
|
1960
|
-
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = n.ownershipRequired === !0, s = !1, c = !1, l, u = () => t(), d = new
|
|
1970
|
+
function me(t, n = {}) {
|
|
1971
|
+
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = n.ownershipRequired === !0, s = !1, c = !1, l, u = () => t(), d = new V({ getActiveCall: u });
|
|
1961
1972
|
return {
|
|
1962
1973
|
publicMedia: {
|
|
1963
1974
|
requestPermission: () => (f(), d.requestPermission()),
|
|
@@ -1970,7 +1981,7 @@ function fe(t, n = {}) {
|
|
|
1970
1981
|
releaseAll: () => (f(), d.releaseAll())
|
|
1971
1982
|
},
|
|
1972
1983
|
registerCall(e, t) {
|
|
1973
|
-
s || c || !
|
|
1984
|
+
s || c || !J(t) || (i.set(e, t), (!o || a.has(e)) && p(e, t));
|
|
1974
1985
|
},
|
|
1975
1986
|
async setCallOwnership(e, t) {
|
|
1976
1987
|
if (s) return;
|
|
@@ -2013,9 +2024,9 @@ function fe(t, n = {}) {
|
|
|
2013
2024
|
if (s) throw new e("SDK_ALREADY_DISPOSED", "internal", !1);
|
|
2014
2025
|
}
|
|
2015
2026
|
function p(e, t) {
|
|
2016
|
-
if (!
|
|
2027
|
+
if (!J(t) || typeof t.getMediaRegistration != "function") return;
|
|
2017
2028
|
let n = t.getMediaRegistration();
|
|
2018
|
-
if (
|
|
2029
|
+
if (he(n) && r.get(e)?.peerConnection !== n.peerConnection) {
|
|
2019
2030
|
r.set(e, n);
|
|
2020
2031
|
try {
|
|
2021
2032
|
d.registerCallMedia(e, n);
|
|
@@ -2025,22 +2036,22 @@ function fe(t, n = {}) {
|
|
|
2025
2036
|
}
|
|
2026
2037
|
}
|
|
2027
2038
|
}
|
|
2028
|
-
function
|
|
2039
|
+
function J(e) {
|
|
2029
2040
|
return typeof e == "object" && !!e;
|
|
2030
2041
|
}
|
|
2031
|
-
function
|
|
2042
|
+
function he(e) {
|
|
2032
2043
|
return typeof e == "object" && !!e && "peerConnection" in e && typeof e.peerConnection == "object" && e.peerConnection !== null;
|
|
2033
2044
|
}
|
|
2034
2045
|
//#endregion
|
|
2035
2046
|
//#region src/reconnect/backoff.ts
|
|
2036
|
-
var
|
|
2037
|
-
function
|
|
2038
|
-
let n = Math.min(
|
|
2047
|
+
var ge = 1e3, _e = 3e4;
|
|
2048
|
+
function ve(e, t = Math.random) {
|
|
2049
|
+
let n = Math.min(_e, ge * 2 ** Math.max(0, Math.floor(e))), r = Math.min(1, Math.max(0, t()));
|
|
2039
2050
|
return Math.round(n * (1 + r * .2));
|
|
2040
2051
|
}
|
|
2041
2052
|
//#endregion
|
|
2042
2053
|
//#region src/reconnect/ReconnectManager.ts
|
|
2043
|
-
var
|
|
2054
|
+
var ye = class {
|
|
2044
2055
|
recover;
|
|
2045
2056
|
random;
|
|
2046
2057
|
isOnline;
|
|
@@ -2057,7 +2068,7 @@ var _e = class {
|
|
|
2057
2068
|
}
|
|
2058
2069
|
start() {
|
|
2059
2070
|
if (this.disposed || !this.online || !this.isOnline() || this.pendingTimer !== void 0 || this.running) return;
|
|
2060
|
-
let e = this.generation, t =
|
|
2071
|
+
let e = this.generation, t = ve(this.attempt, this.random);
|
|
2061
2072
|
this.pendingTimer = setTimeout(() => {
|
|
2062
2073
|
this.pendingTimer = void 0, this.run(e);
|
|
2063
2074
|
}, t);
|
|
@@ -2099,7 +2110,7 @@ var _e = class {
|
|
|
2099
2110
|
clearPendingTimer() {
|
|
2100
2111
|
this.pendingTimer !== void 0 && (clearTimeout(this.pendingTimer), this.pendingTimer = void 0);
|
|
2101
2112
|
}
|
|
2102
|
-
},
|
|
2113
|
+
}, be = class t {
|
|
2103
2114
|
media;
|
|
2104
2115
|
options;
|
|
2105
2116
|
api;
|
|
@@ -2144,7 +2155,7 @@ var _e = class {
|
|
|
2144
2155
|
this.api = t.api === void 0 ? t.sessionProvider === void 0 ? new p({
|
|
2145
2156
|
baseUrl: t.baseUrl ?? "",
|
|
2146
2157
|
tokenProvider: i
|
|
2147
|
-
}) :
|
|
2158
|
+
}) : Y(Ce(t.sessionProvider)) : Y(t.api), this.suppliedSip = t.sip === void 0 ? void 0 : X(t.sip), this.mediaBridge = me(() => this.getActiveMediaContext()), this.media = this.mediaBridge.publicMedia, this.reconnect = new ye({
|
|
2148
2159
|
recover: () => this.recoverConnection(),
|
|
2149
2160
|
onAttempt: (e) => {
|
|
2150
2161
|
this.disposed || this.events.emit("connection.reconnecting", { attempt: e });
|
|
@@ -2156,13 +2167,13 @@ var _e = class {
|
|
|
2156
2167
|
}), this.sharedWorkerSelection = t.sharedWorker === void 0 ? {
|
|
2157
2168
|
mode: "single-tab",
|
|
2158
2169
|
reason: "disabled"
|
|
2159
|
-
} :
|
|
2170
|
+
} : S({
|
|
2160
2171
|
...t.sharedWorker,
|
|
2161
2172
|
...t.sharedWorkerHost ?? {}
|
|
2162
2173
|
});
|
|
2163
2174
|
}
|
|
2164
2175
|
static async checkSupport() {
|
|
2165
|
-
let e = typeof navigator < "u" && navigator.mediaDevices !== void 0, t = typeof WebSocket < "u", n =
|
|
2176
|
+
let e = typeof navigator < "u" && navigator.mediaDevices !== void 0, t = typeof WebSocket < "u", n = Se(typeof navigator < "u" ? navigator.userAgent : "");
|
|
2166
2177
|
return {
|
|
2167
2178
|
supported: e && t,
|
|
2168
2179
|
platform: n,
|
|
@@ -2269,7 +2280,7 @@ var _e = class {
|
|
|
2269
2280
|
sdkVersion: n,
|
|
2270
2281
|
platform: a === "mobile-web" ? "mobile_web" : "web",
|
|
2271
2282
|
...this.options.locale === void 0 ? {} : { locale: this.options.locale },
|
|
2272
|
-
requestedCapabilities: [...this.options.requestedCapabilities ??
|
|
2283
|
+
requestedCapabilities: [...this.options.requestedCapabilities ?? De(a)]
|
|
2273
2284
|
}), this.ownedSessionIds.add(t.sessionId), this.assertGeneration(e), r = await this.getSip(), this.assertGeneration(e), this.session = t;
|
|
2274
2285
|
let o = this.callManager ?? this.createCallManager(r, t, a);
|
|
2275
2286
|
this.callManager === void 0 && (i = o), o.updateSession(t), this.callManager = o, this.attachSipListener(r), this.attachNetworkListeners(), await r.connect(t), this.assertGeneration(e), this.setConnectionState("connected"), this.events.emit("connection.registered", { registered: !0 }), this.scheduleRefresh(t);
|
|
@@ -2375,7 +2386,7 @@ var _e = class {
|
|
|
2375
2386
|
try {
|
|
2376
2387
|
await this.media.releaseAll();
|
|
2377
2388
|
} catch (t) {
|
|
2378
|
-
|
|
2389
|
+
we(t) || (e ??= t);
|
|
2379
2390
|
}
|
|
2380
2391
|
try {
|
|
2381
2392
|
await this.mediaBridge.dispose();
|
|
@@ -2533,7 +2544,7 @@ var _e = class {
|
|
|
2533
2544
|
async getSip() {
|
|
2534
2545
|
if (this.sip !== void 0) return this.sip;
|
|
2535
2546
|
if (this.suppliedSip !== void 0) return this.sip = this.suppliedSip, this.sip;
|
|
2536
|
-
let [e, t] = await Promise.all([import("./createJsSipFactory-9CPsweDR.js"), import("./JsSipAdapter-
|
|
2547
|
+
let [e, t] = await Promise.all([import("./createJsSipFactory-9CPsweDR.js"), import("./JsSipAdapter-C2NmmtWt.js")]);
|
|
2537
2548
|
return this.sip = new t.JsSipAdapter(e.createJsSipFactory(), this.options.baseUrl, this.options.sipKeepaliveSeconds, this.options.agentTerminal, this.options.sipSessionTimers ?? !1), this.sip;
|
|
2538
2549
|
}
|
|
2539
2550
|
attachSipListener(e) {
|
|
@@ -2575,7 +2586,7 @@ var _e = class {
|
|
|
2575
2586
|
destination: e.destination
|
|
2576
2587
|
})),
|
|
2577
2588
|
permission: this.support?.hasMediaDevices === !1 ? "unsupported" : "unknown",
|
|
2578
|
-
ice:
|
|
2589
|
+
ice: xe(e),
|
|
2579
2590
|
wss: {
|
|
2580
2591
|
configured: e !== void 0,
|
|
2581
2592
|
secure: e?.transport.wssUrl.toLowerCase().startsWith("wss://") ?? !1,
|
|
@@ -2692,7 +2703,7 @@ var _e = class {
|
|
|
2692
2703
|
return new e("SDK_ALREADY_DISPOSED", "internal", !1);
|
|
2693
2704
|
}
|
|
2694
2705
|
};
|
|
2695
|
-
function
|
|
2706
|
+
function xe(e) {
|
|
2696
2707
|
if (e === void 0) return {
|
|
2697
2708
|
configured: !1,
|
|
2698
2709
|
serverCount: 0,
|
|
@@ -2710,14 +2721,14 @@ function ye(e) {
|
|
|
2710
2721
|
turnServerCount: n
|
|
2711
2722
|
};
|
|
2712
2723
|
}
|
|
2713
|
-
function
|
|
2724
|
+
function Se(e) {
|
|
2714
2725
|
return e === "" ? "unknown" : /iPhone|iPad|Android/i.test(e) ? "mobile-web" : "web";
|
|
2715
2726
|
}
|
|
2716
|
-
function
|
|
2727
|
+
function Y(t) {
|
|
2717
2728
|
if (typeof t != "object" || !t) throw new e("CONFIG_INVALID", "configuration", !1);
|
|
2718
2729
|
return t;
|
|
2719
2730
|
}
|
|
2720
|
-
function
|
|
2731
|
+
function Ce(t) {
|
|
2721
2732
|
let r = {
|
|
2722
2733
|
createSession: (e) => t.createSession(e),
|
|
2723
2734
|
refreshSession: (e) => t.refreshSession === void 0 ? t.createSession({
|
|
@@ -2731,7 +2742,7 @@ function xe(t) {
|
|
|
2731
2742
|
}, i = t.invalidateToken;
|
|
2732
2743
|
return i !== void 0 && (r.invalidateToken = () => i()), r;
|
|
2733
2744
|
}
|
|
2734
|
-
function
|
|
2745
|
+
function X(t) {
|
|
2735
2746
|
if (typeof t != "object" || !t) throw new e("CONFIG_INVALID", "configuration", !1);
|
|
2736
2747
|
return t;
|
|
2737
2748
|
}
|
|
@@ -2750,13 +2761,13 @@ function Z(t, n, r, i, a) {
|
|
|
2750
2761
|
function Q(t) {
|
|
2751
2762
|
return t instanceof e ? t.status !== void 0 && t.status >= 400 && t.status < 500 || t.serverCode === "SESSION_NOT_FOUND" || t.serverCode === "SESSION_EXPIRED" || t.serverCode === "TOKEN_INVALID" || t.serverCode === "TOKEN_EXPIRED" || t.code === "AUTH_TOKEN_UNAVAILABLE" || t.code === "AUTH_TOKEN_EXPIRED" : !1;
|
|
2752
2763
|
}
|
|
2753
|
-
function
|
|
2764
|
+
function we(t) {
|
|
2754
2765
|
return t instanceof e && t.code === "SDK_ALREADY_DISPOSED";
|
|
2755
2766
|
}
|
|
2756
2767
|
function $(t) {
|
|
2757
2768
|
return t instanceof e && (t.code === "SDK_ALREADY_DISPOSED" || t.code === "CALL_NOT_CONNECTED");
|
|
2758
2769
|
}
|
|
2759
|
-
var
|
|
2770
|
+
var Te = [
|
|
2760
2771
|
"outbound",
|
|
2761
2772
|
"inbound",
|
|
2762
2773
|
"mute",
|
|
@@ -2764,13 +2775,13 @@ var we = [
|
|
|
2764
2775
|
"dtmf",
|
|
2765
2776
|
"blind_transfer",
|
|
2766
2777
|
"device_selection"
|
|
2767
|
-
],
|
|
2778
|
+
], Ee = [
|
|
2768
2779
|
"outbound",
|
|
2769
2780
|
"mute",
|
|
2770
2781
|
"dtmf"
|
|
2771
2782
|
];
|
|
2772
|
-
function
|
|
2773
|
-
return e === "mobile-web" ?
|
|
2783
|
+
function De(e) {
|
|
2784
|
+
return e === "mobile-web" ? Ee : Te;
|
|
2774
2785
|
}
|
|
2775
2786
|
//#endregion
|
|
2776
|
-
export {
|
|
2787
|
+
export { m as a, c, l as d, a as f, x as i, s as l, S as n, p as o, i as p, C as r, d as s, be as t, o as u };
|