@16x/webphone-sdk 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -4
- package/LICENSE +0 -1
- package/README.md +1 -1
- package/dist/CCBarClient-DdLM2NKm.cjs +1 -0
- package/dist/{CCBarClient-BdbynNBi.js → CCBarClient-xC63i3Qd.js} +345 -156
- package/dist/{Diagnostics-Cw2HVrCD.js → Diagnostics-BhsVHELt.js} +9 -9
- package/dist/{Diagnostics-BYVvmxil.cjs → Diagnostics-CvH6cjih.cjs} +1 -1
- package/dist/JsSipAdapter-BM7I95Xb.cjs +1 -0
- package/dist/{JsSipAdapter-GHzVSCDh.js → JsSipAdapter-CV6q6UUY.js} +20 -13
- package/dist/SharedWorkerProtocol-V_x8Erjv.cjs +1 -0
- package/dist/{SharedWorkerProtocol-BqUafs8d.js → SharedWorkerProtocol-jfo9N5wa.js} +27 -17
- package/dist/core/CCBarClient.d.ts +14 -2
- package/dist/core/CallManager.d.ts +2 -0
- package/dist/diagnostics/Diagnostics.d.ts +1 -0
- package/dist/diagnostics/index.cjs +1 -1
- package/dist/diagnostics/index.d.ts +1 -1
- package/dist/diagnostics/index.js +3 -6
- package/dist/index.cjs +1 -1
- package/dist/index.js +9 -139
- package/dist/index.umd.js +17 -17
- package/dist/legacy/index.cjs +1 -1
- package/dist/legacy/index.js +2 -2
- package/dist/shared-worker.cjs +1 -1
- package/dist/shared-worker.js +13 -6
- package/dist/types.d.ts +5 -0
- package/dist/ui/XCallCCBarElement.d.ts +2 -0
- package/dist/ui/index.cjs +1 -1
- package/dist/ui/index.js +138 -130
- package/package.json +3 -1
- package/dist/CCBarClient-DKWdvgf5.cjs +0 -1
- package/dist/CCBarError-CIqJE8zK.cjs +0 -1
- package/dist/CCBarError-DSbPw2dA.js +0 -14
- package/dist/JsSipAdapter-jtGdoXrm.cjs +0 -1
- package/dist/SharedWorkerProtocol-CYN0AprP.cjs +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "./Diagnostics-
|
|
1
|
+
import { i as e, t } from "./SharedWorkerProtocol-jfo9N5wa.js";
|
|
2
|
+
import { r as n, t as r } from "./Diagnostics-BhsVHELt.js";
|
|
3
3
|
//#region src/events/TypedEventBus.ts
|
|
4
|
-
var
|
|
4
|
+
var i = class {
|
|
5
5
|
handlers = /* @__PURE__ */ new Map();
|
|
6
6
|
on(e, t) {
|
|
7
7
|
let n = this.handlers.get(e) ?? /* @__PURE__ */ new Set();
|
|
@@ -27,7 +27,7 @@ var n = class {
|
|
|
27
27
|
clear() {
|
|
28
28
|
this.handlers.clear();
|
|
29
29
|
}
|
|
30
|
-
},
|
|
30
|
+
}, a = {
|
|
31
31
|
new: /* @__PURE__ */ new Set([
|
|
32
32
|
"dialing",
|
|
33
33
|
"ringing",
|
|
@@ -61,19 +61,19 @@ var n = class {
|
|
|
61
61
|
]),
|
|
62
62
|
ended: /* @__PURE__ */ new Set(),
|
|
63
63
|
failed: /* @__PURE__ */ new Set()
|
|
64
|
-
},
|
|
65
|
-
function
|
|
66
|
-
if (!
|
|
64
|
+
}, o = (e, t) => a[e].has(t);
|
|
65
|
+
function s(e, t) {
|
|
66
|
+
if (!o(e, t)) throw new c(e, t);
|
|
67
67
|
return t;
|
|
68
68
|
}
|
|
69
|
-
var
|
|
69
|
+
var c = class extends e {
|
|
70
70
|
constructor(e, t) {
|
|
71
71
|
super("CALL_OPERATION_NOT_ALLOWED", "call", !1, { cause: {
|
|
72
72
|
from: e,
|
|
73
73
|
to: t
|
|
74
74
|
} });
|
|
75
75
|
}
|
|
76
|
-
},
|
|
76
|
+
}, l = s, u = 60, d = class {
|
|
77
77
|
tokenProvider;
|
|
78
78
|
cachedToken;
|
|
79
79
|
cachedRequestKey = "";
|
|
@@ -95,7 +95,7 @@ var o = class extends e {
|
|
|
95
95
|
this.generation += 1, this.cachedToken = void 0, this.cachedRequestKey = "", this.refreshing = void 0;
|
|
96
96
|
}
|
|
97
97
|
needsRefresh(e) {
|
|
98
|
-
return e.expiresAt !== void 0 && e.expiresAt <= Math.floor(Date.now() / 1e3) +
|
|
98
|
+
return e.expiresAt !== void 0 && e.expiresAt <= Math.floor(Date.now() / 1e3) + u;
|
|
99
99
|
}
|
|
100
100
|
async refresh(e, t, n) {
|
|
101
101
|
let r = await this.tokenProvider(e), i = typeof r == "string" ? { accessToken: r } : r;
|
|
@@ -104,7 +104,7 @@ var o = class extends e {
|
|
|
104
104
|
clearRefresh(e) {
|
|
105
105
|
this.refreshing === e && (this.refreshing = void 0);
|
|
106
106
|
}
|
|
107
|
-
},
|
|
107
|
+
}, f = {
|
|
108
108
|
ORIGIN_NOT_ALLOWED: {
|
|
109
109
|
code: "CONFIG_ORIGIN_NOT_ALLOWED",
|
|
110
110
|
category: "configuration",
|
|
@@ -185,13 +185,13 @@ var o = class extends e {
|
|
|
185
185
|
category: "internal",
|
|
186
186
|
retryable: !0
|
|
187
187
|
}
|
|
188
|
-
},
|
|
188
|
+
}, p = class {
|
|
189
189
|
tokenManager;
|
|
190
190
|
fetcher;
|
|
191
191
|
baseUrl;
|
|
192
192
|
timeoutMs;
|
|
193
193
|
constructor(e) {
|
|
194
|
-
this.tokenManager = new
|
|
194
|
+
this.tokenManager = new d(e.tokenProvider), this.fetcher = e.fetcher ?? fetch.bind(globalThis), this.baseUrl = e.baseUrl.replace(/\/$/, ""), this.timeoutMs = e.timeoutMs ?? 1e4;
|
|
195
195
|
}
|
|
196
196
|
invalidateToken() {
|
|
197
197
|
this.tokenManager.invalidate();
|
|
@@ -220,6 +220,7 @@ var o = class extends e {
|
|
|
220
220
|
try {
|
|
221
221
|
let e = await this.tokenManager.getValidToken(), a = await this.fetcher(`${this.baseUrl}${n}`, {
|
|
222
222
|
method: t,
|
|
223
|
+
credentials: "omit",
|
|
223
224
|
headers: {
|
|
224
225
|
Authorization: `Bearer ${e}`,
|
|
225
226
|
...r === void 0 ? {} : { "Content-Type": "application/json" }
|
|
@@ -250,7 +251,7 @@ var o = class extends e {
|
|
|
250
251
|
}
|
|
251
252
|
}
|
|
252
253
|
toCCBarError(t, n) {
|
|
253
|
-
let r =
|
|
254
|
+
let r = f[n.code ?? ""] ?? this.mapStatus(t);
|
|
254
255
|
return new e(r.code, r.category, r.retryable, { requestId: n.requestId });
|
|
255
256
|
}
|
|
256
257
|
mapStatus(e) {
|
|
@@ -272,7 +273,7 @@ var o = class extends e {
|
|
|
272
273
|
retryable: !1
|
|
273
274
|
};
|
|
274
275
|
}
|
|
275
|
-
},
|
|
276
|
+
}, ee = [
|
|
276
277
|
"progress",
|
|
277
278
|
"accepted",
|
|
278
279
|
"confirmed",
|
|
@@ -280,7 +281,7 @@ var o = class extends e {
|
|
|
280
281
|
"failed",
|
|
281
282
|
"hold",
|
|
282
283
|
"unhold"
|
|
283
|
-
],
|
|
284
|
+
], te = 3e4, m = class {
|
|
284
285
|
options;
|
|
285
286
|
currentState = "new";
|
|
286
287
|
sessionUnsubscribers = [];
|
|
@@ -296,7 +297,7 @@ var o = class extends e {
|
|
|
296
297
|
constructor(t) {
|
|
297
298
|
this.options = t, this.id = t.id, this.destination = t.destination, this.platform = t.platform, this.capabilities = t.capabilities ?? /* @__PURE__ */ new Set();
|
|
298
299
|
try {
|
|
299
|
-
|
|
300
|
+
ee.forEach((e) => {
|
|
300
301
|
this.sessionUnsubscribers.push(t.session.on(e, (t) => this.handleSessionEvent(e, t)));
|
|
301
302
|
});
|
|
302
303
|
} catch (n) {
|
|
@@ -357,7 +358,7 @@ var o = class extends e {
|
|
|
357
358
|
this.assertState("active"), this.assertCapability("dtmf"), this.invoke(() => this.options.session.sendDtmf(e));
|
|
358
359
|
}
|
|
359
360
|
async transfer(e, t) {
|
|
360
|
-
if (this.assertNotDisposed(), this.assertOwner(t), this.assertTransferCapability(), this.assertState("active"), this.assertCapability("blind_transfer"), !
|
|
361
|
+
if (this.assertNotDisposed(), this.assertOwner(t), this.assertTransferCapability(), this.assertState("active"), this.assertCapability("blind_transfer"), !ne(e) || e.target.trim() === "") throw this.operationError();
|
|
361
362
|
this.invoke(() => this.options.session.refer(e.target.trim()));
|
|
362
363
|
}
|
|
363
364
|
async hangup(e) {
|
|
@@ -429,14 +430,14 @@ var o = class extends e {
|
|
|
429
430
|
this.currentState !== "active" && ((this.currentState === "dialing" || this.currentState === "ringing") && this.transitionTo("connecting", e), this.transitionIfAllowed("active", e, "confirmed"));
|
|
430
431
|
}
|
|
431
432
|
transitionIfAllowed(e, t, n) {
|
|
432
|
-
this.currentState !== e && (
|
|
433
|
+
this.currentState !== e && (o(this.currentState, e) ? this.transitionTo(e, t) : this.reportIllegalTransition(e, n));
|
|
433
434
|
}
|
|
434
435
|
transitionIfStillRinging(e, t) {
|
|
435
436
|
this.currentState === "ringing" && this.transitionTo(e, t);
|
|
436
437
|
}
|
|
437
438
|
transitionTo(e, t) {
|
|
438
439
|
if (this.currentState === e) return;
|
|
439
|
-
if (!
|
|
440
|
+
if (!o(this.currentState, e)) throw this.operationError();
|
|
440
441
|
let n = this.currentState;
|
|
441
442
|
this.currentState = e, h(e) && this.rejectPendingOperation();
|
|
442
443
|
try {
|
|
@@ -458,7 +459,7 @@ var o = class extends e {
|
|
|
458
459
|
resolve: r,
|
|
459
460
|
reject: i
|
|
460
461
|
};
|
|
461
|
-
this.pendingOperation = a, a.timer = setTimeout(() => this.timeoutPendingOperation(a),
|
|
462
|
+
this.pendingOperation = a, a.timer = setTimeout(() => this.timeoutPendingOperation(a), te);
|
|
462
463
|
let o;
|
|
463
464
|
try {
|
|
464
465
|
o = n();
|
|
@@ -573,19 +574,19 @@ var o = class extends e {
|
|
|
573
574
|
function h(e) {
|
|
574
575
|
return e === "ended" || e === "failed";
|
|
575
576
|
}
|
|
576
|
-
function
|
|
577
|
+
function ne(e) {
|
|
577
578
|
return typeof e == "object" && !!e && e.type === "blind" && typeof e.target == "string";
|
|
578
579
|
}
|
|
579
580
|
//#endregion
|
|
580
581
|
//#region src/core/callId.ts
|
|
581
|
-
var
|
|
582
|
-
function
|
|
583
|
-
return
|
|
582
|
+
var g = 0;
|
|
583
|
+
function _() {
|
|
584
|
+
return g += 1, `call_${Date.now().toString(36)}_${g.toString(36)}`;
|
|
584
585
|
}
|
|
585
586
|
//#endregion
|
|
586
587
|
//#region src/core/CallManager.ts
|
|
587
|
-
var
|
|
588
|
-
events = new
|
|
588
|
+
var v = class {
|
|
589
|
+
events = new y();
|
|
589
590
|
calls = /* @__PURE__ */ new Map();
|
|
590
591
|
options;
|
|
591
592
|
incomingUnsubscribe;
|
|
@@ -623,7 +624,7 @@ var y = class {
|
|
|
623
624
|
if (this.options.platform === "mobile-web" && this.calls.size + this.pendingDialCount >= a) throw this.capabilityError();
|
|
624
625
|
if (this.calls.size + this.pendingDialCount >= a || this.pendingDestinations.has(i) || [...this.calls.values()].some((e) => e.destination === i)) throw new e("CALL_ALREADY_EXISTS", "call", !1);
|
|
625
626
|
this.pendingDialCount += 1, this.pendingDestinations.add(i);
|
|
626
|
-
let o =
|
|
627
|
+
let o = _(), s;
|
|
627
628
|
try {
|
|
628
629
|
s = await this.holdActiveCallForNewCall(), this.assertGeneration(r, o);
|
|
629
630
|
let e;
|
|
@@ -695,7 +696,8 @@ var y = class {
|
|
|
695
696
|
let e = [...this.calls.values()].map((e) => e.getResourceCounts());
|
|
696
697
|
return {
|
|
697
698
|
timers: e.reduce((e, t) => e + t.timers, 0),
|
|
698
|
-
listeners: this.events.listenerCount() + e.reduce((e, t) => e + t.listeners, 0)
|
|
699
|
+
listeners: this.events.listenerCount() + e.reduce((e, t) => e + t.listeners, 0),
|
|
700
|
+
terminalRecords: this.terminalNotified.size + this.terminalOperations.size
|
|
699
701
|
};
|
|
700
702
|
}
|
|
701
703
|
getActiveCall() {
|
|
@@ -770,7 +772,9 @@ var y = class {
|
|
|
770
772
|
n ??= e;
|
|
771
773
|
}
|
|
772
774
|
if (n !== void 0) throw n;
|
|
773
|
-
})).
|
|
775
|
+
})).finally(() => {
|
|
776
|
+
this.terminalNotified.clear(), this.terminalOperations.clear();
|
|
777
|
+
}).then(() => void 0);
|
|
774
778
|
return this.disposeOperation = n, n;
|
|
775
779
|
}
|
|
776
780
|
updateSession(e) {
|
|
@@ -814,10 +818,10 @@ var y = class {
|
|
|
814
818
|
}
|
|
815
819
|
t.to === "held" && this.activeCallId === e.id && this.automaticActiveTransition?.previous.id !== e.id && (this.activeCallId = null, this.events.emit("call.activeChanged", { callId: null })), (t.to === "ended" || t.to === "failed") && (this.calls.delete(e.id), this.callSessions.delete(e.id), this.callOwners.delete(e.id), this.ownerLostCalls.delete(e.id), this.activeCallId === e.id && this.automaticActiveTransition?.previous.id !== e.id && (this.activeCallId = null, this.events.emit("call.activeChanged", { callId: null })), this.notifyCallTerminal(e.id), t.to === "ended" ? this.events.emit("call.ended", {
|
|
816
820
|
callId: e.id,
|
|
817
|
-
reason:
|
|
821
|
+
reason: b(n)
|
|
818
822
|
}) : this.events.emit("call.failed", {
|
|
819
823
|
callId: e.id,
|
|
820
|
-
error:
|
|
824
|
+
error: x(n, e.id)
|
|
821
825
|
}));
|
|
822
826
|
}
|
|
823
827
|
async switchAutomaticActiveCall(e, t, n) {
|
|
@@ -883,7 +887,7 @@ var y = class {
|
|
|
883
887
|
}
|
|
884
888
|
handleIncoming(t) {
|
|
885
889
|
if (this.disposed) return;
|
|
886
|
-
let n =
|
|
890
|
+
let n = _();
|
|
887
891
|
if (this.options.platform === "mobile-web") {
|
|
888
892
|
this.terminateUnsupportedIncoming(t), this.events.emit("error", { error: this.capabilityError(n) });
|
|
889
893
|
return;
|
|
@@ -974,12 +978,15 @@ var y = class {
|
|
|
974
978
|
} catch (t) {
|
|
975
979
|
this.events.emit("error", { error: this.callOperationError(e, t) });
|
|
976
980
|
let n = Promise.reject(this.callOperationError(e, t));
|
|
977
|
-
return this.terminalOperations.set(e, n), n.catch(() => void 0), n;
|
|
981
|
+
return this.terminalOperations.set(e, n), n.catch(() => void 0).finally(() => this.pruneTerminalRecord(e, n)), n;
|
|
978
982
|
}
|
|
979
983
|
let r = Promise.resolve(n).catch((t) => {
|
|
980
984
|
throw this.events.emit("error", { error: this.callOperationError(e, t) }), t;
|
|
981
985
|
});
|
|
982
|
-
return this.terminalOperations.set(e, r), r.catch(() => void 0), r;
|
|
986
|
+
return this.terminalOperations.set(e, r), r.catch(() => void 0).finally(() => this.pruneTerminalRecord(e, r)), r;
|
|
987
|
+
}
|
|
988
|
+
pruneTerminalRecord(e, t) {
|
|
989
|
+
this.terminalOperations.get(e) === t && this.terminalOperations.delete(e), this.calls.has(e) || this.terminalNotified.delete(e);
|
|
983
990
|
}
|
|
984
991
|
assertNotDisposed() {
|
|
985
992
|
if (this.disposed) throw new e("SDK_ALREADY_DISPOSED", "internal", !1);
|
|
@@ -1022,7 +1029,7 @@ var y = class {
|
|
|
1022
1029
|
cause: t
|
|
1023
1030
|
});
|
|
1024
1031
|
}
|
|
1025
|
-
},
|
|
1032
|
+
}, y = class {
|
|
1026
1033
|
handlers = /* @__PURE__ */ new Map();
|
|
1027
1034
|
on(e, t) {
|
|
1028
1035
|
let n = this.handlers.get(e) ?? /* @__PURE__ */ new Set(), r = t;
|
|
@@ -1047,12 +1054,12 @@ var y = class {
|
|
|
1047
1054
|
this.handlers.clear();
|
|
1048
1055
|
}
|
|
1049
1056
|
};
|
|
1050
|
-
function
|
|
1057
|
+
function b(e) {
|
|
1051
1058
|
if (typeof e != "object" || !e || !("reason" in e)) return "ended";
|
|
1052
1059
|
let t = e.reason;
|
|
1053
1060
|
return typeof t == "string" && t !== "" ? t : "ended";
|
|
1054
1061
|
}
|
|
1055
|
-
function
|
|
1062
|
+
function x(t, n) {
|
|
1056
1063
|
if (t instanceof e) return new e(t.code, t.category, t.retryable, {
|
|
1057
1064
|
requestId: t.requestId,
|
|
1058
1065
|
callId: n,
|
|
@@ -1076,8 +1083,139 @@ function S(t, n) {
|
|
|
1076
1083
|
});
|
|
1077
1084
|
}
|
|
1078
1085
|
//#endregion
|
|
1086
|
+
//#region src/shared/SharedWorkerClient.ts
|
|
1087
|
+
var S = class {
|
|
1088
|
+
port;
|
|
1089
|
+
timeoutMs;
|
|
1090
|
+
pending = /* @__PURE__ */ new Map();
|
|
1091
|
+
eventHandlers = /* @__PURE__ */ new Set();
|
|
1092
|
+
closed = !1;
|
|
1093
|
+
lifecycleState = "connected";
|
|
1094
|
+
constructor(e, t = {}) {
|
|
1095
|
+
this.port = e, this.timeoutMs = t.timeoutMs ?? 15e3, this.port.onmessage = (e) => this.handleMessage(e.data), this.port.start();
|
|
1096
|
+
}
|
|
1097
|
+
request(t) {
|
|
1098
|
+
return this.closed ? Promise.reject(new e("SDK_ALREADY_DISPOSED", "internal", !1)) : this.pending.has(t.requestId) ? Promise.reject(new e("SDK_INTERNAL_ERROR", "internal", !1, { requestId: t.requestId })) : this.lifecycleState === "reconnecting" && t.type === "command" && (t.command === "dial" || t.command === "answer") ? Promise.reject(new e("CALL_OPERATION_NOT_ALLOWED", "call", !0, { callId: t.payload?.callId })) : new Promise((n, r) => {
|
|
1099
|
+
let i = setTimeout(() => {
|
|
1100
|
+
this.pending.delete(t.requestId), r(new e("NETWORK_TIMEOUT", "network", !0, { requestId: t.requestId }));
|
|
1101
|
+
}, this.timeoutMs);
|
|
1102
|
+
this.pending.set(t.requestId, {
|
|
1103
|
+
resolve: (e) => n(e),
|
|
1104
|
+
reject: r,
|
|
1105
|
+
timer: i
|
|
1106
|
+
}), this.port.postMessage(t);
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
onEvent(e) {
|
|
1110
|
+
return this.closed ? () => void 0 : (this.eventHandlers.add(e), () => this.eventHandlers.delete(e));
|
|
1111
|
+
}
|
|
1112
|
+
getLifecycleState() {
|
|
1113
|
+
return this.lifecycleState;
|
|
1114
|
+
}
|
|
1115
|
+
close() {
|
|
1116
|
+
this.closed || (this.closed = !0, this.pending.forEach((t) => {
|
|
1117
|
+
clearTimeout(t.timer), t.reject(new e("SDK_ALREADY_DISPOSED", "internal", !1));
|
|
1118
|
+
}), this.pending.clear(), this.eventHandlers.clear(), this.port.close());
|
|
1119
|
+
}
|
|
1120
|
+
handleMessage(e) {
|
|
1121
|
+
try {
|
|
1122
|
+
let n = t(e);
|
|
1123
|
+
if (n.type === "event") {
|
|
1124
|
+
n.event === "connection.stateChanged" && C(n.payload) && (this.lifecycleState = n.payload.state), this.eventHandlers.forEach((e) => e(n));
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
if (n.type !== "response") return;
|
|
1128
|
+
let r = this.pending.get(n.requestId);
|
|
1129
|
+
if (r === void 0) return;
|
|
1130
|
+
this.pending.delete(n.requestId), clearTimeout(r.timer), n.ok ? r.resolve(n.result) : r.reject(w(n));
|
|
1131
|
+
} catch (e) {
|
|
1132
|
+
this.pending.forEach((t) => {
|
|
1133
|
+
clearTimeout(t.timer), t.reject(e);
|
|
1134
|
+
}), this.pending.clear();
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
function C(e) {
|
|
1139
|
+
return typeof e == "object" && !!e && "state" in e && (e.state === "connected" || e.state === "reconnecting");
|
|
1140
|
+
}
|
|
1141
|
+
function w(t) {
|
|
1142
|
+
let n = t.error;
|
|
1143
|
+
return new e(n?.code ?? "SDK_INTERNAL_ERROR", n?.category ?? "internal", n?.retryable ?? !1, {
|
|
1144
|
+
requestId: t.requestId,
|
|
1145
|
+
...n?.message === void 0 ? {} : { cause: n.message }
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
//#endregion
|
|
1149
|
+
//#region src/shared/SharedWorkerFactory.ts
|
|
1150
|
+
function T(t = {}) {
|
|
1151
|
+
if ((t.enabled ?? "auto") === !1) return {
|
|
1152
|
+
mode: "single-tab",
|
|
1153
|
+
reason: "disabled"
|
|
1154
|
+
};
|
|
1155
|
+
let n = t.locationHref ?? D(), r = E(t.url, n), i = (n) => {
|
|
1156
|
+
if (t.fallback === "error") throw new e("CONFIG_INVALID", "configuration", !1, { cause: n });
|
|
1157
|
+
return {
|
|
1158
|
+
mode: "single-tab",
|
|
1159
|
+
reason: n
|
|
1160
|
+
};
|
|
1161
|
+
};
|
|
1162
|
+
if (r === void 0) return i("SharedWorker URL is unavailable");
|
|
1163
|
+
if (!ie(r, n)) return i("SharedWorker URL must be same-origin");
|
|
1164
|
+
let a = t.workerCtor ?? re();
|
|
1165
|
+
if (a === void 0) return i("SharedWorker is not supported");
|
|
1166
|
+
let o;
|
|
1167
|
+
try {
|
|
1168
|
+
o = new a(r, t.name === void 0 ? void 0 : { name: t.name });
|
|
1169
|
+
} catch (e) {
|
|
1170
|
+
return i(`SharedWorker construction failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
1171
|
+
}
|
|
1172
|
+
let s = t.tabId ?? O(), c = new S(o.port), l = {
|
|
1173
|
+
version: 1,
|
|
1174
|
+
type: "attach",
|
|
1175
|
+
requestId: k(),
|
|
1176
|
+
tabId: s
|
|
1177
|
+
}, u = c.request(l).then(() => void 0).catch((e) => {
|
|
1178
|
+
throw c.close(), e;
|
|
1179
|
+
});
|
|
1180
|
+
return {
|
|
1181
|
+
mode: "shared",
|
|
1182
|
+
worker: o,
|
|
1183
|
+
client: c,
|
|
1184
|
+
tabId: s,
|
|
1185
|
+
workerUrl: r,
|
|
1186
|
+
ready: u
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
function E(e, t = D()) {
|
|
1190
|
+
try {
|
|
1191
|
+
return t === void 0 ? void 0 : new URL(e ?? "./shared-worker.js", t).toString();
|
|
1192
|
+
} catch {
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
function D() {
|
|
1197
|
+
return typeof location > "u" ? void 0 : location.href;
|
|
1198
|
+
}
|
|
1199
|
+
function re() {
|
|
1200
|
+
if (typeof SharedWorker == "function") return SharedWorker;
|
|
1201
|
+
}
|
|
1202
|
+
function ie(e, t) {
|
|
1203
|
+
if (t === void 0) return !0;
|
|
1204
|
+
try {
|
|
1205
|
+
return new URL(e, t).origin === new URL(t).origin;
|
|
1206
|
+
} catch {
|
|
1207
|
+
return !1;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
function O() {
|
|
1211
|
+
return `tab-${typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).slice(2)}`;
|
|
1212
|
+
}
|
|
1213
|
+
function k() {
|
|
1214
|
+
return `attach-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
1215
|
+
}
|
|
1216
|
+
//#endregion
|
|
1079
1217
|
//#region src/media/DeviceManager.ts
|
|
1080
|
-
var
|
|
1218
|
+
var A = class {
|
|
1081
1219
|
mediaDevices;
|
|
1082
1220
|
createAudioElement;
|
|
1083
1221
|
outputCapability;
|
|
@@ -1085,23 +1223,23 @@ var C = class {
|
|
|
1085
1223
|
outputGeneration = 0;
|
|
1086
1224
|
outputTail;
|
|
1087
1225
|
constructor(e = {}) {
|
|
1088
|
-
this.mediaDevices = e.mediaDevices === null ? void 0 : e.mediaDevices ??
|
|
1226
|
+
this.mediaDevices = e.mediaDevices === null ? void 0 : e.mediaDevices ?? j(), this.createAudioElement = e.createAudioElement;
|
|
1089
1227
|
}
|
|
1090
1228
|
async requestPermission(e = {}) {
|
|
1091
1229
|
let t = this.requireMediaDevices(), n;
|
|
1092
1230
|
try {
|
|
1093
1231
|
n = await t.getUserMedia({ audio: e });
|
|
1094
1232
|
} catch (e) {
|
|
1095
|
-
throw
|
|
1233
|
+
throw P(e);
|
|
1096
1234
|
}
|
|
1097
|
-
|
|
1235
|
+
M(n);
|
|
1098
1236
|
}
|
|
1099
1237
|
async getDevices() {
|
|
1100
1238
|
if (this.mediaDevices === void 0) return [];
|
|
1101
1239
|
try {
|
|
1102
1240
|
return (await this.mediaDevices.enumerateDevices()).filter((e) => e.kind === "audioinput" || e.kind === "audiooutput" && this.supportsOutputSelection());
|
|
1103
1241
|
} catch (e) {
|
|
1104
|
-
throw
|
|
1242
|
+
throw F(e);
|
|
1105
1243
|
}
|
|
1106
1244
|
}
|
|
1107
1245
|
getCapabilities() {
|
|
@@ -1139,7 +1277,7 @@ var C = class {
|
|
|
1139
1277
|
try {
|
|
1140
1278
|
await r.setSinkId(t);
|
|
1141
1279
|
} catch (e) {
|
|
1142
|
-
throw
|
|
1280
|
+
throw I(e);
|
|
1143
1281
|
}
|
|
1144
1282
|
}
|
|
1145
1283
|
enqueueOutput(e) {
|
|
@@ -1153,7 +1291,7 @@ var C = class {
|
|
|
1153
1291
|
try {
|
|
1154
1292
|
return await t.getUserMedia({ audio: { deviceId: { exact: e } } });
|
|
1155
1293
|
} catch (e) {
|
|
1156
|
-
throw
|
|
1294
|
+
throw N(e);
|
|
1157
1295
|
}
|
|
1158
1296
|
}
|
|
1159
1297
|
requireMediaDevices() {
|
|
@@ -1173,10 +1311,10 @@ var C = class {
|
|
|
1173
1311
|
}
|
|
1174
1312
|
}
|
|
1175
1313
|
};
|
|
1176
|
-
function
|
|
1314
|
+
function j() {
|
|
1177
1315
|
return globalThis.navigator?.mediaDevices;
|
|
1178
1316
|
}
|
|
1179
|
-
function
|
|
1317
|
+
function M(e) {
|
|
1180
1318
|
let t;
|
|
1181
1319
|
try {
|
|
1182
1320
|
t = e.getTracks();
|
|
@@ -1189,57 +1327,57 @@ function T(e) {
|
|
|
1189
1327
|
} catch {}
|
|
1190
1328
|
});
|
|
1191
1329
|
}
|
|
1192
|
-
function
|
|
1193
|
-
let n =
|
|
1330
|
+
function N(t) {
|
|
1331
|
+
let n = L(t);
|
|
1194
1332
|
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 });
|
|
1195
1333
|
}
|
|
1196
|
-
function
|
|
1197
|
-
let n =
|
|
1334
|
+
function P(t) {
|
|
1335
|
+
let n = L(t);
|
|
1198
1336
|
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 });
|
|
1199
1337
|
}
|
|
1200
|
-
function
|
|
1201
|
-
let n =
|
|
1338
|
+
function F(t) {
|
|
1339
|
+
let n = L(t);
|
|
1202
1340
|
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 });
|
|
1203
1341
|
}
|
|
1204
|
-
function
|
|
1205
|
-
let n =
|
|
1342
|
+
function I(t) {
|
|
1343
|
+
let n = L(t);
|
|
1206
1344
|
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 });
|
|
1207
1345
|
}
|
|
1208
|
-
function
|
|
1346
|
+
function L(e) {
|
|
1209
1347
|
if (typeof e != "object" || !e || !("name" in e)) return;
|
|
1210
1348
|
let t = e.name;
|
|
1211
1349
|
return typeof t == "string" ? t : void 0;
|
|
1212
1350
|
}
|
|
1213
1351
|
//#endregion
|
|
1214
1352
|
//#region src/media/RemoteAudio.ts
|
|
1215
|
-
var
|
|
1353
|
+
var R = class {
|
|
1216
1354
|
createAudioElement;
|
|
1217
1355
|
bindings = /* @__PURE__ */ new Map();
|
|
1218
1356
|
audioOwners = /* @__PURE__ */ new Map();
|
|
1219
1357
|
trackOwners = /* @__PURE__ */ new Map();
|
|
1220
1358
|
generations = /* @__PURE__ */ new Map();
|
|
1221
1359
|
pendingPlays = /* @__PURE__ */ new Map();
|
|
1222
|
-
constructor(e =
|
|
1360
|
+
constructor(e = z) {
|
|
1223
1361
|
this.createAudioElement = e;
|
|
1224
1362
|
}
|
|
1225
1363
|
async bind(t, n) {
|
|
1226
1364
|
let r = this.bindings.get(t);
|
|
1227
1365
|
if (r?.stream === n) return;
|
|
1228
|
-
let i =
|
|
1366
|
+
let i = B(t, n), a;
|
|
1229
1367
|
try {
|
|
1230
1368
|
a = this.createAudioElement();
|
|
1231
1369
|
} catch (n) {
|
|
1232
|
-
throw
|
|
1370
|
+
throw V(i, this.trackOwners), new e("CAPABILITY_NOT_SUPPORTED", "capability", !1, {
|
|
1233
1371
|
callId: t,
|
|
1234
1372
|
cause: n
|
|
1235
1373
|
});
|
|
1236
1374
|
}
|
|
1237
1375
|
let o = this.audioOwners.get(a);
|
|
1238
|
-
if (o !== void 0 && o !== t) throw
|
|
1376
|
+
if (o !== void 0 && o !== t) throw V(i, this.trackOwners), new e("CALL_OPERATION_NOT_ALLOWED", "call", !1, { callId: t });
|
|
1239
1377
|
try {
|
|
1240
1378
|
a.autoplay = !0, a.playsInline = !0;
|
|
1241
1379
|
} catch (n) {
|
|
1242
|
-
throw
|
|
1380
|
+
throw V(i, this.trackOwners), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1243
1381
|
callId: t,
|
|
1244
1382
|
cause: n
|
|
1245
1383
|
});
|
|
@@ -1247,7 +1385,7 @@ var O = class {
|
|
|
1247
1385
|
try {
|
|
1248
1386
|
a.srcObject = n;
|
|
1249
1387
|
} catch (n) {
|
|
1250
|
-
throw
|
|
1388
|
+
throw V(i, this.trackOwners), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1251
1389
|
callId: t,
|
|
1252
1390
|
cause: n
|
|
1253
1391
|
});
|
|
@@ -1323,7 +1461,7 @@ var O = class {
|
|
|
1323
1461
|
releaseTrack(e) {
|
|
1324
1462
|
let t = this.trackOwners.get(e);
|
|
1325
1463
|
if (t === void 0 || t <= 1) {
|
|
1326
|
-
this.trackOwners.delete(e),
|
|
1464
|
+
this.trackOwners.delete(e), U(e);
|
|
1327
1465
|
return;
|
|
1328
1466
|
}
|
|
1329
1467
|
this.trackOwners.set(e, t - 1);
|
|
@@ -1346,42 +1484,42 @@ var O = class {
|
|
|
1346
1484
|
return this.generations.get(e) === t && this.bindings.get(e)?.generation === t;
|
|
1347
1485
|
}
|
|
1348
1486
|
};
|
|
1349
|
-
function
|
|
1487
|
+
function z() {
|
|
1350
1488
|
if (typeof document > "u") throw new e("CAPABILITY_NOT_SUPPORTED", "capability", !1);
|
|
1351
1489
|
return document.createElement("audio");
|
|
1352
1490
|
}
|
|
1353
|
-
function
|
|
1491
|
+
function B(t, n) {
|
|
1354
1492
|
try {
|
|
1355
1493
|
return [...new Set(n.getAudioTracks())].filter((e) => e.kind === "audio");
|
|
1356
1494
|
} catch (r) {
|
|
1357
1495
|
try {
|
|
1358
1496
|
return [...new Set(n.getTracks())].filter((e) => e.kind === "audio");
|
|
1359
1497
|
} catch (i) {
|
|
1360
|
-
throw
|
|
1498
|
+
throw H(n), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1361
1499
|
callId: t,
|
|
1362
1500
|
cause: r ?? i
|
|
1363
1501
|
});
|
|
1364
1502
|
}
|
|
1365
1503
|
}
|
|
1366
1504
|
}
|
|
1367
|
-
function
|
|
1505
|
+
function V(e, t) {
|
|
1368
1506
|
e.forEach((e) => {
|
|
1369
|
-
(t.get(e) ?? 0) === 0 &&
|
|
1507
|
+
(t.get(e) ?? 0) === 0 && U(e);
|
|
1370
1508
|
});
|
|
1371
1509
|
}
|
|
1372
|
-
function
|
|
1510
|
+
function H(e) {
|
|
1373
1511
|
try {
|
|
1374
|
-
[...new Set(e.getTracks())].filter((e) => e.kind === "audio").forEach(
|
|
1512
|
+
[...new Set(e.getTracks())].filter((e) => e.kind === "audio").forEach(U);
|
|
1375
1513
|
} catch {}
|
|
1376
1514
|
}
|
|
1377
|
-
function
|
|
1515
|
+
function U(e) {
|
|
1378
1516
|
try {
|
|
1379
1517
|
e.stop();
|
|
1380
1518
|
} catch {}
|
|
1381
1519
|
}
|
|
1382
1520
|
//#endregion
|
|
1383
1521
|
//#region src/media/MediaManager.ts
|
|
1384
|
-
var
|
|
1522
|
+
var W = class {
|
|
1385
1523
|
deviceManager;
|
|
1386
1524
|
remoteAudio;
|
|
1387
1525
|
getActiveCall;
|
|
@@ -1402,7 +1540,7 @@ var P = class {
|
|
|
1402
1540
|
mediaDevices: e.mediaDevices,
|
|
1403
1541
|
createAudioElement: e.createAudioElement
|
|
1404
1542
|
};
|
|
1405
|
-
this.deviceManager = new
|
|
1543
|
+
this.deviceManager = new A(t), this.remoteAudio = new R(e.createAudioElement), this.getActiveCall = e.getActiveCall, this.createRemoteStream = e.createRemoteStream ?? oe;
|
|
1406
1544
|
}
|
|
1407
1545
|
requestPermission(e) {
|
|
1408
1546
|
return this.assertNotDisposed(), this.deviceManager.requestPermission(e);
|
|
@@ -1422,7 +1560,7 @@ var P = class {
|
|
|
1422
1560
|
n !== void 0 && this.releaseResource(n).catch((e) => {
|
|
1423
1561
|
this.releaseErrors.set(n, e);
|
|
1424
1562
|
});
|
|
1425
|
-
let r =
|
|
1563
|
+
let r = G(t) ? t : { peerConnection: t }, i = {
|
|
1426
1564
|
callId: e,
|
|
1427
1565
|
peerConnection: r.peerConnection,
|
|
1428
1566
|
senders: /* @__PURE__ */ new Map(),
|
|
@@ -1504,7 +1642,7 @@ var P = class {
|
|
|
1504
1642
|
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);
|
|
1505
1643
|
let i = /* @__PURE__ */ new Set([...t.localTracks, ...t.pendingTracks]), a = [...t.senders.values()].filter((e) => e.audio).map((e) => ({
|
|
1506
1644
|
senderResource: e,
|
|
1507
|
-
promise: this.enqueueSender(t, e, () =>
|
|
1645
|
+
promise: this.enqueueSender(t, e, () => q(e.sender), !0)
|
|
1508
1646
|
})), o = Promise.all(a.map(async (e) => {
|
|
1509
1647
|
try {
|
|
1510
1648
|
return await e.promise, {
|
|
@@ -1522,14 +1660,14 @@ var P = class {
|
|
|
1522
1660
|
if (n.forEach((e) => {
|
|
1523
1661
|
if (e.cause !== void 0) {
|
|
1524
1662
|
o.push(e.cause);
|
|
1525
|
-
let t =
|
|
1663
|
+
let t = K(e.senderResource.sender);
|
|
1526
1664
|
t?.kind === "audio" && a.add(t);
|
|
1527
1665
|
return;
|
|
1528
1666
|
}
|
|
1529
|
-
let t =
|
|
1667
|
+
let t = K(e.senderResource.sender);
|
|
1530
1668
|
t?.kind === "audio" && i.add(t);
|
|
1531
1669
|
}), i.forEach((e) => {
|
|
1532
|
-
a.has(e) ||
|
|
1670
|
+
a.has(e) || Y(e);
|
|
1533
1671
|
}), o.length > 0) throw t.localTracks.clear(), t.pendingTracks.clear(), a.forEach((e) => t.localTracks.add(e)), new e("SDK_INTERNAL_ERROR", "internal", !0, {
|
|
1534
1672
|
callId: r,
|
|
1535
1673
|
cause: o[0]
|
|
@@ -1537,7 +1675,7 @@ var P = class {
|
|
|
1537
1675
|
if (!t.peerClosed && t.peerConnection.close !== void 0) try {
|
|
1538
1676
|
await t.peerConnection.close(), t.peerClosed = !0;
|
|
1539
1677
|
} catch (n) {
|
|
1540
|
-
let i = [...t.senders.values()].map((e) =>
|
|
1678
|
+
let i = [...t.senders.values()].map((e) => K(e.sender)).find((e) => e?.kind === "audio");
|
|
1541
1679
|
throw t.localTracks.clear(), t.pendingTracks.clear(), i != null && t.localTracks.add(i), new e("SDK_INTERNAL_ERROR", "internal", !0, {
|
|
1542
1680
|
callId: r,
|
|
1543
1681
|
cause: n
|
|
@@ -1605,11 +1743,11 @@ var P = class {
|
|
|
1605
1743
|
}
|
|
1606
1744
|
async performInputSwitch(t, n, r) {
|
|
1607
1745
|
if (this.assertActiveCall(n), this.assertDeviceSelectionCapability(n), !this.isCurrentResource(r) || n.peerConnection !== r.peerConnection) throw this.callOperationError(n.callId);
|
|
1608
|
-
let i = this.findAudioSender(r), a =
|
|
1746
|
+
let i = this.findAudioSender(r), a = K(i.sender), o = r.generation, s = await this.deviceManager.openInputStream(t), c;
|
|
1609
1747
|
try {
|
|
1610
1748
|
c = s.getTracks();
|
|
1611
1749
|
} catch (t) {
|
|
1612
|
-
throw
|
|
1750
|
+
throw ae(s), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1613
1751
|
callId: n.callId,
|
|
1614
1752
|
cause: t
|
|
1615
1753
|
});
|
|
@@ -1618,26 +1756,26 @@ var P = class {
|
|
|
1618
1756
|
try {
|
|
1619
1757
|
l = s.getAudioTracks();
|
|
1620
1758
|
} catch (t) {
|
|
1621
|
-
throw
|
|
1759
|
+
throw J(c), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1622
1760
|
callId: n.callId,
|
|
1623
1761
|
cause: t
|
|
1624
1762
|
});
|
|
1625
1763
|
}
|
|
1626
1764
|
let u = l[0];
|
|
1627
|
-
if (u === void 0) throw
|
|
1628
|
-
if (!this.canCommitInputSwitch(n, r, i, a, o)) throw
|
|
1765
|
+
if (u === void 0) throw J(c), new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { callId: n.callId });
|
|
1766
|
+
if (!this.canCommitInputSwitch(n, r, i, a, o)) throw J(c), this.callOperationError(n.callId);
|
|
1629
1767
|
c.forEach((e) => r.pendingTracks.add(e)), r.pendingTracks.add(u);
|
|
1630
1768
|
try {
|
|
1631
1769
|
await this.enqueueSender(r, i, () => i.sender.replaceTrack(u));
|
|
1632
1770
|
} catch (t) {
|
|
1633
|
-
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),
|
|
1771
|
+
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), J(c)), new e("MEDIA_DEVICE_IN_USE", "media", !0, {
|
|
1634
1772
|
callId: n.callId,
|
|
1635
1773
|
cause: t
|
|
1636
1774
|
}));
|
|
1637
1775
|
}
|
|
1638
1776
|
if (!this.canCommitInputSwitch(n, r, i, u, o)) {
|
|
1639
1777
|
if (!r.released) try {
|
|
1640
|
-
await this.enqueueSender(r, i, () =>
|
|
1778
|
+
await this.enqueueSender(r, i, () => K(i.sender) === u ? q(i.sender) : Promise.resolve()), c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), J(c);
|
|
1641
1779
|
} catch (t) {
|
|
1642
1780
|
throw new e("SDK_INTERNAL_ERROR", "internal", !0, {
|
|
1643
1781
|
callId: n.callId,
|
|
@@ -1646,8 +1784,8 @@ var P = class {
|
|
|
1646
1784
|
}
|
|
1647
1785
|
throw this.callOperationError(n.callId);
|
|
1648
1786
|
}
|
|
1649
|
-
c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), r.localTracks.add(u), a !== null && a !== u && (r.localTracks.delete(a),
|
|
1650
|
-
e !== u &&
|
|
1787
|
+
c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), r.localTracks.add(u), a !== null && a !== u && (r.localTracks.delete(a), Y(a)), c.forEach((e) => {
|
|
1788
|
+
e !== u && Y(e);
|
|
1651
1789
|
});
|
|
1652
1790
|
}
|
|
1653
1791
|
ensureCallMedia(e) {
|
|
@@ -1670,7 +1808,7 @@ var P = class {
|
|
|
1670
1808
|
});
|
|
1671
1809
|
}
|
|
1672
1810
|
r.forEach((r) => {
|
|
1673
|
-
let i =
|
|
1811
|
+
let i = K(r), a;
|
|
1674
1812
|
try {
|
|
1675
1813
|
a = n?.(r) ?? r.senderKind ?? r.kind;
|
|
1676
1814
|
} catch (n) {
|
|
@@ -1687,7 +1825,7 @@ var P = class {
|
|
|
1687
1825
|
});
|
|
1688
1826
|
}
|
|
1689
1827
|
findAudioSender(e) {
|
|
1690
|
-
let t = [...e.senders.values()].find((e) => e.audio && (
|
|
1828
|
+
let t = [...e.senders.values()].find((e) => e.audio && (K(e.sender)?.kind === "audio" || K(e.sender) === null));
|
|
1691
1829
|
if (t === void 0) throw this.capabilityError(e.callId);
|
|
1692
1830
|
return t;
|
|
1693
1831
|
}
|
|
@@ -1703,7 +1841,7 @@ var P = class {
|
|
|
1703
1841
|
} catch {
|
|
1704
1842
|
return !1;
|
|
1705
1843
|
}
|
|
1706
|
-
return
|
|
1844
|
+
return K(n.sender) === r;
|
|
1707
1845
|
}
|
|
1708
1846
|
enqueueSender(e, t, n, r = !1) {
|
|
1709
1847
|
t.queue.pending += 1;
|
|
@@ -1732,7 +1870,7 @@ var P = class {
|
|
|
1732
1870
|
});
|
|
1733
1871
|
}
|
|
1734
1872
|
async rollbackSender(e, t, n, r) {
|
|
1735
|
-
e.released ||
|
|
1873
|
+
e.released || K(t.sender) !== r || await this.enqueueSender(e, t, () => t.sender.replaceTrack(n)).catch(() => void 0);
|
|
1736
1874
|
}
|
|
1737
1875
|
isCurrentResource(e, t = e.generation) {
|
|
1738
1876
|
return !this.disposed && this.calls.get(e.callId) === e && e.generation === t;
|
|
@@ -1759,37 +1897,37 @@ var P = class {
|
|
|
1759
1897
|
if (this.disposed || this.disposing) throw new e("SDK_ALREADY_DISPOSED", "internal", !1);
|
|
1760
1898
|
}
|
|
1761
1899
|
};
|
|
1762
|
-
function
|
|
1900
|
+
function G(e) {
|
|
1763
1901
|
return "peerConnection" in e;
|
|
1764
1902
|
}
|
|
1765
|
-
function
|
|
1903
|
+
function K(e) {
|
|
1766
1904
|
try {
|
|
1767
1905
|
return e.track;
|
|
1768
1906
|
} catch {
|
|
1769
1907
|
return null;
|
|
1770
1908
|
}
|
|
1771
1909
|
}
|
|
1772
|
-
function
|
|
1910
|
+
function q(e) {
|
|
1773
1911
|
try {
|
|
1774
1912
|
return e.replaceTrack(null);
|
|
1775
1913
|
} catch (e) {
|
|
1776
1914
|
return Promise.reject(e);
|
|
1777
1915
|
}
|
|
1778
1916
|
}
|
|
1779
|
-
function
|
|
1917
|
+
function ae(e) {
|
|
1780
1918
|
try {
|
|
1781
|
-
|
|
1919
|
+
J(e.getTracks());
|
|
1782
1920
|
} catch {}
|
|
1783
1921
|
}
|
|
1784
|
-
function
|
|
1785
|
-
e.forEach(
|
|
1922
|
+
function J(e) {
|
|
1923
|
+
e.forEach(Y);
|
|
1786
1924
|
}
|
|
1787
|
-
function
|
|
1925
|
+
function Y(e) {
|
|
1788
1926
|
try {
|
|
1789
1927
|
e.stop();
|
|
1790
1928
|
} catch {}
|
|
1791
1929
|
}
|
|
1792
|
-
function
|
|
1930
|
+
function oe(e) {
|
|
1793
1931
|
if (typeof MediaStream < "u") try {
|
|
1794
1932
|
return new MediaStream([e]);
|
|
1795
1933
|
} catch {
|
|
@@ -1798,8 +1936,8 @@ function V(e) {
|
|
|
1798
1936
|
}
|
|
1799
1937
|
//#endregion
|
|
1800
1938
|
//#region src/core/mediaBridge.ts
|
|
1801
|
-
function
|
|
1802
|
-
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
|
|
1939
|
+
function se(t, n = {}) {
|
|
1940
|
+
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 W({ getActiveCall: u });
|
|
1803
1941
|
return {
|
|
1804
1942
|
publicMedia: {
|
|
1805
1943
|
requestPermission: () => (f(), d.requestPermission()),
|
|
@@ -1812,7 +1950,7 @@ function H(t, n = {}) {
|
|
|
1812
1950
|
releaseAll: () => (f(), d.releaseAll())
|
|
1813
1951
|
},
|
|
1814
1952
|
registerCall(e, t) {
|
|
1815
|
-
s || c || !
|
|
1953
|
+
s || c || !X(t) || (i.set(e, t), (!o || a.has(e)) && p(e, t));
|
|
1816
1954
|
},
|
|
1817
1955
|
async setCallOwnership(e, t) {
|
|
1818
1956
|
if (s) return;
|
|
@@ -1855,9 +1993,9 @@ function H(t, n = {}) {
|
|
|
1855
1993
|
if (s) throw new e("SDK_ALREADY_DISPOSED", "internal", !1);
|
|
1856
1994
|
}
|
|
1857
1995
|
function p(e, t) {
|
|
1858
|
-
if (!
|
|
1996
|
+
if (!X(t) || typeof t.getMediaRegistration != "function") return;
|
|
1859
1997
|
let n = t.getMediaRegistration();
|
|
1860
|
-
if (
|
|
1998
|
+
if (ce(n) && r.get(e)?.peerConnection !== n.peerConnection) {
|
|
1861
1999
|
r.set(e, n);
|
|
1862
2000
|
try {
|
|
1863
2001
|
d.registerCallMedia(e, n);
|
|
@@ -1867,22 +2005,22 @@ function H(t, n = {}) {
|
|
|
1867
2005
|
}
|
|
1868
2006
|
}
|
|
1869
2007
|
}
|
|
1870
|
-
function
|
|
2008
|
+
function X(e) {
|
|
1871
2009
|
return typeof e == "object" && !!e;
|
|
1872
2010
|
}
|
|
1873
|
-
function
|
|
2011
|
+
function ce(e) {
|
|
1874
2012
|
return typeof e == "object" && !!e && "peerConnection" in e && typeof e.peerConnection == "object" && e.peerConnection !== null;
|
|
1875
2013
|
}
|
|
1876
2014
|
//#endregion
|
|
1877
2015
|
//#region src/reconnect/backoff.ts
|
|
1878
|
-
var
|
|
1879
|
-
function
|
|
1880
|
-
let n = Math.min(
|
|
2016
|
+
var le = 1e3, ue = 3e4;
|
|
2017
|
+
function de(e, t = Math.random) {
|
|
2018
|
+
let n = Math.min(ue, le * 2 ** Math.max(0, Math.floor(e))), r = Math.min(1, Math.max(0, t()));
|
|
1881
2019
|
return Math.round(n * (1 + r * .2));
|
|
1882
2020
|
}
|
|
1883
2021
|
//#endregion
|
|
1884
2022
|
//#region src/reconnect/ReconnectManager.ts
|
|
1885
|
-
var
|
|
2023
|
+
var fe = class {
|
|
1886
2024
|
recover;
|
|
1887
2025
|
random;
|
|
1888
2026
|
isOnline;
|
|
@@ -1899,7 +2037,7 @@ var J = class {
|
|
|
1899
2037
|
}
|
|
1900
2038
|
start() {
|
|
1901
2039
|
if (this.disposed || !this.online || !this.isOnline() || this.pendingTimer !== void 0 || this.running) return;
|
|
1902
|
-
let e = this.generation, t =
|
|
2040
|
+
let e = this.generation, t = de(this.attempt, this.random);
|
|
1903
2041
|
this.pendingTimer = setTimeout(() => {
|
|
1904
2042
|
this.pendingTimer = void 0, this.run(e);
|
|
1905
2043
|
}, t);
|
|
@@ -1941,13 +2079,13 @@ var J = class {
|
|
|
1941
2079
|
clearPendingTimer() {
|
|
1942
2080
|
this.pendingTimer !== void 0 && (clearTimeout(this.pendingTimer), this.pendingTimer = void 0);
|
|
1943
2081
|
}
|
|
1944
|
-
},
|
|
2082
|
+
}, pe = class t {
|
|
1945
2083
|
media;
|
|
1946
2084
|
options;
|
|
1947
2085
|
api;
|
|
1948
2086
|
suppliedSip;
|
|
1949
2087
|
sip;
|
|
1950
|
-
events = new
|
|
2088
|
+
events = new i();
|
|
1951
2089
|
mediaBridge;
|
|
1952
2090
|
reconnect;
|
|
1953
2091
|
diagnostics;
|
|
@@ -1975,28 +2113,35 @@ var J = class {
|
|
|
1975
2113
|
ownedSessionIds = /* @__PURE__ */ new Set();
|
|
1976
2114
|
terminalReleaseOperations = /* @__PURE__ */ new Map();
|
|
1977
2115
|
tokenRequest = {};
|
|
2116
|
+
sharedWorkerSelection;
|
|
1978
2117
|
constructor(e) {
|
|
1979
2118
|
this.options = e;
|
|
1980
|
-
let
|
|
2119
|
+
let t = (e) => this.options.tokenProvider({
|
|
1981
2120
|
...e,
|
|
1982
2121
|
...this.tokenRequest
|
|
1983
2122
|
});
|
|
1984
|
-
this.api = e.api === void 0 ? new
|
|
2123
|
+
this.api = e.api === void 0 ? new p({
|
|
1985
2124
|
baseUrl: e.baseUrl ?? "",
|
|
1986
|
-
tokenProvider:
|
|
1987
|
-
}) :
|
|
2125
|
+
tokenProvider: t
|
|
2126
|
+
}) : Z(e.api), this.suppliedSip = e.sip === void 0 ? void 0 : ge(e.sip), this.mediaBridge = se(() => this.getActiveMediaContext()), this.media = this.mediaBridge.publicMedia, this.reconnect = new fe({
|
|
1988
2127
|
recover: () => this.recoverConnection(),
|
|
1989
2128
|
onAttempt: (e) => {
|
|
1990
2129
|
this.disposed || this.events.emit("connection.reconnecting", { attempt: e });
|
|
1991
2130
|
}
|
|
1992
|
-
}), this.diagnostics = new
|
|
2131
|
+
}), this.diagnostics = new r({
|
|
1993
2132
|
getSnapshot: () => this.createDiagnosticsSnapshot(),
|
|
1994
2133
|
getPermission: () => this.readMicrophonePermission(),
|
|
1995
2134
|
getDeviceNames: async () => (await this.media.getDevices()).map((e) => e.label).filter((e) => e !== "")
|
|
2135
|
+
}), this.sharedWorkerSelection = e.sharedWorker === void 0 ? {
|
|
2136
|
+
mode: "single-tab",
|
|
2137
|
+
reason: "disabled"
|
|
2138
|
+
} : T({
|
|
2139
|
+
...e.sharedWorker,
|
|
2140
|
+
...e.sharedWorkerHost ?? {}
|
|
1996
2141
|
});
|
|
1997
2142
|
}
|
|
1998
2143
|
static async checkSupport() {
|
|
1999
|
-
let e = typeof navigator < "u" && navigator.mediaDevices !== void 0, t = typeof WebSocket < "u", n =
|
|
2144
|
+
let e = typeof navigator < "u" && navigator.mediaDevices !== void 0, t = typeof WebSocket < "u", n = he(typeof navigator < "u" ? navigator.userAgent : "");
|
|
2000
2145
|
return {
|
|
2001
2146
|
supported: e && t,
|
|
2002
2147
|
platform: n,
|
|
@@ -2007,8 +2152,8 @@ var J = class {
|
|
|
2007
2152
|
}
|
|
2008
2153
|
async initialize() {
|
|
2009
2154
|
if (this.assertNotDisposed(), this.initialized) return;
|
|
2010
|
-
let e = await
|
|
2011
|
-
this.support = e, this.options.platform === void 0 && (e.platform === "web" || e.platform === "mobile-web") && (this.detectedPlatform = e.platform), this.assertNotDisposed(), this.initialized = !0;
|
|
2155
|
+
let e = await t.checkSupport();
|
|
2156
|
+
this.support = e, this.options.platform === void 0 && (e.platform === "web" || e.platform === "mobile-web") && (this.detectedPlatform = e.platform), await this.awaitSharedWorkerReady(), this.assertNotDisposed(), this.initialized = !0;
|
|
2012
2157
|
}
|
|
2013
2158
|
connect(e) {
|
|
2014
2159
|
this.assertNotDisposed();
|
|
@@ -2031,7 +2176,7 @@ var J = class {
|
|
|
2031
2176
|
}
|
|
2032
2177
|
dispose() {
|
|
2033
2178
|
if (this.disposeOperation !== void 0) return this.disposeOperation;
|
|
2034
|
-
this.disposed = !0, this.lifecycleGeneration += 1, this.intentionalDisconnect = !0, this.acceptingEvents = !1, this.reconnect.dispose(), this.clearRefreshTimer(), this.detachNetworkListeners(), this.state = "disconnected", this.diagnostics.log("info", "connection.stateChanged", { state: "disconnected" }), this.detachSipListener(), this.detachManagerListeners();
|
|
2179
|
+
this.disposed = !0, this.lifecycleGeneration += 1, this.intentionalDisconnect = !0, this.acceptingEvents = !1, this.reconnect.dispose(), this.clearRefreshTimer(), this.detachNetworkListeners(), this.releaseSharedWorker(), this.state = "disconnected", this.diagnostics.log("info", "connection.stateChanged", { state: "disconnected" }), this.detachSipListener(), this.detachManagerListeners();
|
|
2035
2180
|
let e = !1, t = this.performDispose().then(() => {
|
|
2036
2181
|
e = !0;
|
|
2037
2182
|
}).finally(() => {
|
|
@@ -2069,6 +2214,16 @@ var J = class {
|
|
|
2069
2214
|
getAgent() {
|
|
2070
2215
|
return this.session?.agent;
|
|
2071
2216
|
}
|
|
2217
|
+
getSharedWorkerState() {
|
|
2218
|
+
let e = this.sharedWorkerSelection;
|
|
2219
|
+
return e.mode === "shared" ? {
|
|
2220
|
+
mode: "shared",
|
|
2221
|
+
tabId: e.tabId
|
|
2222
|
+
} : {
|
|
2223
|
+
mode: "single-tab",
|
|
2224
|
+
reason: e.reason
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2072
2227
|
getDiagnostics(e = {}) {
|
|
2073
2228
|
return this.diagnostics.getReport(e);
|
|
2074
2229
|
}
|
|
@@ -2085,22 +2240,22 @@ var J = class {
|
|
|
2085
2240
|
this.events.off(e, t);
|
|
2086
2241
|
}
|
|
2087
2242
|
async performConnect(e) {
|
|
2088
|
-
let t,
|
|
2243
|
+
let t, r, i;
|
|
2089
2244
|
try {
|
|
2090
2245
|
await this.initialize(), this.assertGeneration(e);
|
|
2091
|
-
let
|
|
2246
|
+
let a = this.resolvePlatform();
|
|
2092
2247
|
this.intentionalDisconnect = !1, this.acceptingEvents = !0, this.setConnectionState("connecting"), t = await this.api.createSession({
|
|
2093
|
-
sdkVersion:
|
|
2094
|
-
platform:
|
|
2248
|
+
sdkVersion: n,
|
|
2249
|
+
platform: a === "mobile-web" ? "mobile_web" : "web",
|
|
2095
2250
|
...this.options.locale === void 0 ? {} : { locale: this.options.locale },
|
|
2096
|
-
requestedCapabilities: [...this.options.requestedCapabilities ??
|
|
2097
|
-
}), this.ownedSessionIds.add(t.sessionId), this.assertGeneration(e),
|
|
2098
|
-
let
|
|
2099
|
-
this.callManager === void 0 && (
|
|
2100
|
-
} catch (
|
|
2101
|
-
if (await this.rollbackConnect(t,
|
|
2102
|
-
if (e !== this.lifecycleGeneration) throw
|
|
2103
|
-
let a = Q(
|
|
2251
|
+
requestedCapabilities: [...this.options.requestedCapabilities ?? be(a)]
|
|
2252
|
+
}), this.ownedSessionIds.add(t.sessionId), this.assertGeneration(e), r = await this.getSip(), this.assertGeneration(e), this.session = t;
|
|
2253
|
+
let o = this.callManager ?? this.createCallManager(r, t, a);
|
|
2254
|
+
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);
|
|
2255
|
+
} catch (n) {
|
|
2256
|
+
if (await this.rollbackConnect(t, r, i), this.disposed) throw this.disposedError();
|
|
2257
|
+
if (e !== this.lifecycleGeneration) throw n;
|
|
2258
|
+
let a = Q(n, "REGISTRATION_FAILED", "registration", !0);
|
|
2104
2259
|
throw this.setConnectionState("failed"), this.events.emit("connection.failed", { error: a }), a;
|
|
2105
2260
|
}
|
|
2106
2261
|
}
|
|
@@ -2117,7 +2272,7 @@ var J = class {
|
|
|
2117
2272
|
} catch (t) {
|
|
2118
2273
|
$(t) || (e ??= t);
|
|
2119
2274
|
}
|
|
2120
|
-
this.reconnect.cancel(), this.clearRefreshTimer(), this.intentionalDisconnect = !0, this.detachSipListener(), this.detachManagerListeners();
|
|
2275
|
+
this.reconnect.cancel(), this.clearRefreshTimer(), this.intentionalDisconnect = !0, this.detachNetworkListeners(), this.detachSipListener(), this.detachManagerListeners();
|
|
2121
2276
|
let r = this.callManager, i = this.sip;
|
|
2122
2277
|
this.callManager = void 0;
|
|
2123
2278
|
try {
|
|
@@ -2141,10 +2296,10 @@ var J = class {
|
|
|
2141
2296
|
} catch (t) {
|
|
2142
2297
|
e ??= t;
|
|
2143
2298
|
}
|
|
2144
|
-
if (this.disposed || (this.acceptingEvents = !0, this.setConnectionState("disconnected")), e !== void 0) throw e;
|
|
2299
|
+
if (this.pruneDeletedSessionTombstones(), this.disposed || (this.acceptingEvents = !0, this.setConnectionState("disconnected")), e !== void 0) throw e;
|
|
2145
2300
|
}
|
|
2146
2301
|
createCallManager(e, t, n) {
|
|
2147
|
-
let r = new
|
|
2302
|
+
let r = new v({
|
|
2148
2303
|
sip: e,
|
|
2149
2304
|
platform: n,
|
|
2150
2305
|
session: t,
|
|
@@ -2199,7 +2354,7 @@ var J = class {
|
|
|
2199
2354
|
try {
|
|
2200
2355
|
await this.media.releaseAll();
|
|
2201
2356
|
} catch (t) {
|
|
2202
|
-
|
|
2357
|
+
_e(t) || (e ??= t);
|
|
2203
2358
|
}
|
|
2204
2359
|
try {
|
|
2205
2360
|
await this.mediaBridge.dispose();
|
|
@@ -2216,7 +2371,7 @@ var J = class {
|
|
|
2216
2371
|
} catch (t) {
|
|
2217
2372
|
e ??= t;
|
|
2218
2373
|
}
|
|
2219
|
-
if (this.session = void 0, this.sipUnsubscribe = void 0, this.events.clear(), e !== void 0) throw e;
|
|
2374
|
+
if (this.pruneDeletedSessionTombstones(), this.session = void 0, this.sipUnsubscribe = void 0, this.events.clear(), e !== void 0) throw e;
|
|
2220
2375
|
}
|
|
2221
2376
|
async awaitMediaReleaseBarriers() {
|
|
2222
2377
|
let e;
|
|
@@ -2326,12 +2481,12 @@ var J = class {
|
|
|
2326
2481
|
}, n);
|
|
2327
2482
|
}
|
|
2328
2483
|
async recoverConnection() {
|
|
2329
|
-
this.disposed || this.hasNonTerminalCalls() || (await this.awaitMediaReleaseBarriers(), await this.refreshAndRebuild());
|
|
2484
|
+
this.disposed || this.intentionalDisconnect || this.hasNonTerminalCalls() || (await this.awaitMediaReleaseBarriers(), await this.refreshAndRebuild());
|
|
2330
2485
|
}
|
|
2331
2486
|
async getSip() {
|
|
2332
2487
|
if (this.sip !== void 0) return this.sip;
|
|
2333
2488
|
if (this.suppliedSip !== void 0) return this.sip = this.suppliedSip, this.sip;
|
|
2334
|
-
let [e, t] = await Promise.all([import("./createJsSipFactory-yttVU3d6.js"), import("./JsSipAdapter-
|
|
2489
|
+
let [e, t] = await Promise.all([import("./createJsSipFactory-yttVU3d6.js"), import("./JsSipAdapter-CV6q6UUY.js")]);
|
|
2335
2490
|
return this.sip = new t.JsSipAdapter(e.createJsSipFactory(), this.options.baseUrl), this.sip;
|
|
2336
2491
|
}
|
|
2337
2492
|
attachSipListener(e) {
|
|
@@ -2373,7 +2528,7 @@ var J = class {
|
|
|
2373
2528
|
destination: e.destination
|
|
2374
2529
|
})),
|
|
2375
2530
|
permission: this.support?.hasMediaDevices === !1 ? "unsupported" : "unknown",
|
|
2376
|
-
ice:
|
|
2531
|
+
ice: me(e),
|
|
2377
2532
|
wss: {
|
|
2378
2533
|
configured: e !== void 0,
|
|
2379
2534
|
secure: e?.transport.wssUrl.toLowerCase().startsWith("wss://") ?? !1,
|
|
@@ -2393,7 +2548,8 @@ var J = class {
|
|
|
2393
2548
|
tracks: e.tracks,
|
|
2394
2549
|
peerConnections: e.peerConnections,
|
|
2395
2550
|
audioElements: e.audioElements,
|
|
2396
|
-
webSockets: n?.webSockets ?? +!!i
|
|
2551
|
+
webSockets: n?.webSockets ?? +!!i,
|
|
2552
|
+
deletedSessions: this.deletedSessions.size
|
|
2397
2553
|
};
|
|
2398
2554
|
}
|
|
2399
2555
|
async readMicrophonePermission() {
|
|
@@ -2416,6 +2572,9 @@ var J = class {
|
|
|
2416
2572
|
});
|
|
2417
2573
|
return this.sessionDeleteOperations.set(e, n), n;
|
|
2418
2574
|
}
|
|
2575
|
+
pruneDeletedSessionTombstones() {
|
|
2576
|
+
for (let e of [...this.deletedSessions]) !this.ownedSessionIds.has(e) && !this.sessionDeleteOperations.has(e) && this.deletedSessions.delete(e);
|
|
2577
|
+
}
|
|
2419
2578
|
async deleteOwnedSessions() {
|
|
2420
2579
|
let e;
|
|
2421
2580
|
for (let t of [...this.ownedSessionIds]) try {
|
|
@@ -2443,6 +2602,36 @@ var J = class {
|
|
|
2443
2602
|
isCurrentGeneration(e) {
|
|
2444
2603
|
return !this.disposed && e === this.lifecycleGeneration;
|
|
2445
2604
|
}
|
|
2605
|
+
async awaitSharedWorkerReady() {
|
|
2606
|
+
let e = this.sharedWorkerSelection;
|
|
2607
|
+
if (e.mode === "shared") try {
|
|
2608
|
+
await e.ready;
|
|
2609
|
+
} catch (e) {
|
|
2610
|
+
if (this.disposed) return;
|
|
2611
|
+
if (this.options.sharedWorker?.fallback === "error") throw e;
|
|
2612
|
+
this.sharedWorkerSelection = {
|
|
2613
|
+
mode: "single-tab",
|
|
2614
|
+
reason: e instanceof Error ? e.message : "SharedWorker attach failed"
|
|
2615
|
+
};
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
releaseSharedWorker() {
|
|
2619
|
+
let e = this.sharedWorkerSelection;
|
|
2620
|
+
if (this.sharedWorkerSelection = {
|
|
2621
|
+
mode: "single-tab",
|
|
2622
|
+
reason: "disposed"
|
|
2623
|
+
}, e.mode === "shared") {
|
|
2624
|
+
try {
|
|
2625
|
+
e.client.request({
|
|
2626
|
+
version: 1,
|
|
2627
|
+
type: "detach",
|
|
2628
|
+
requestId: `detach-${e.tabId}`,
|
|
2629
|
+
tabId: e.tabId
|
|
2630
|
+
}).catch(() => void 0);
|
|
2631
|
+
} catch {}
|
|
2632
|
+
e.client.close();
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2446
2635
|
assertNotDisposed() {
|
|
2447
2636
|
if (this.disposed) throw this.disposedError();
|
|
2448
2637
|
}
|
|
@@ -2450,7 +2639,7 @@ var J = class {
|
|
|
2450
2639
|
return new e("SDK_ALREADY_DISPOSED", "internal", !1);
|
|
2451
2640
|
}
|
|
2452
2641
|
};
|
|
2453
|
-
function
|
|
2642
|
+
function me(e) {
|
|
2454
2643
|
if (e === void 0) return {
|
|
2455
2644
|
configured: !1,
|
|
2456
2645
|
serverCount: 0,
|
|
@@ -2468,14 +2657,14 @@ function X(e) {
|
|
|
2468
2657
|
turnServerCount: n
|
|
2469
2658
|
};
|
|
2470
2659
|
}
|
|
2471
|
-
function
|
|
2660
|
+
function he(e) {
|
|
2472
2661
|
return e === "" ? "unknown" : /iPhone|iPad|Android/i.test(e) ? "mobile-web" : "web";
|
|
2473
2662
|
}
|
|
2474
|
-
function
|
|
2663
|
+
function Z(t) {
|
|
2475
2664
|
if (typeof t != "object" || !t) throw new e("CONFIG_INVALID", "configuration", !1);
|
|
2476
2665
|
return t;
|
|
2477
2666
|
}
|
|
2478
|
-
function
|
|
2667
|
+
function ge(t) {
|
|
2479
2668
|
if (typeof t != "object" || !t) throw new e("CONFIG_INVALID", "configuration", !1);
|
|
2480
2669
|
return t;
|
|
2481
2670
|
}
|
|
@@ -2489,13 +2678,13 @@ function Q(t, n, r, i, a) {
|
|
|
2489
2678
|
cause: t
|
|
2490
2679
|
});
|
|
2491
2680
|
}
|
|
2492
|
-
function
|
|
2681
|
+
function _e(t) {
|
|
2493
2682
|
return t instanceof e && t.code === "SDK_ALREADY_DISPOSED";
|
|
2494
2683
|
}
|
|
2495
2684
|
function $(t) {
|
|
2496
2685
|
return t instanceof e && (t.code === "SDK_ALREADY_DISPOSED" || t.code === "CALL_NOT_CONNECTED");
|
|
2497
2686
|
}
|
|
2498
|
-
var
|
|
2687
|
+
var ve = [
|
|
2499
2688
|
"outbound",
|
|
2500
2689
|
"inbound",
|
|
2501
2690
|
"mute",
|
|
@@ -2503,13 +2692,13 @@ var oe = [
|
|
|
2503
2692
|
"dtmf",
|
|
2504
2693
|
"blind_transfer",
|
|
2505
2694
|
"device_selection"
|
|
2506
|
-
],
|
|
2695
|
+
], ye = [
|
|
2507
2696
|
"outbound",
|
|
2508
2697
|
"mute",
|
|
2509
2698
|
"dtmf"
|
|
2510
2699
|
];
|
|
2511
|
-
function
|
|
2512
|
-
return e === "mobile-web" ?
|
|
2700
|
+
function be(e) {
|
|
2701
|
+
return e === "mobile-web" ? ye : ve;
|
|
2513
2702
|
}
|
|
2514
2703
|
//#endregion
|
|
2515
|
-
export {
|
|
2704
|
+
export { m as a, c, l as d, a as f, v as i, s as l, T as n, p as o, i as p, E as r, d as s, pe as t, o as u };
|