@16x/webphone-sdk 3.1.4 → 3.1.5
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 +13 -0
- package/dist/{CCBarClient-DY7QjXib.js → CCBarClient-DLA6xiYH.js} +163 -148
- package/dist/CCBarClient-DVhqE08O.cjs +1 -0
- package/dist/{Diagnostics-DD_y4_ah.cjs → Diagnostics-DJeeM2q8.cjs} +1 -1
- package/dist/{Diagnostics-BlstRMt3.js → Diagnostics-DdxaOkkw.js} +1 -1
- package/dist/core/CallManager.d.ts +8 -0
- package/dist/core/userData.d.ts +13 -0
- 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 +14 -14
- package/dist/legacy/index.cjs +1 -1
- package/dist/legacy/index.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/CCBarClient-D9PCJoZj.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-DdxaOkkw.js";
|
|
3
3
|
//#region src/events/TypedEventBus.ts
|
|
4
4
|
var i = class {
|
|
5
5
|
handlers = /* @__PURE__ */ new Map();
|
|
@@ -282,7 +282,7 @@ var c = class extends e {
|
|
|
282
282
|
retryable: !1
|
|
283
283
|
};
|
|
284
284
|
}
|
|
285
|
-
},
|
|
285
|
+
}, ee = [
|
|
286
286
|
"progress",
|
|
287
287
|
"accepted",
|
|
288
288
|
"confirmed",
|
|
@@ -290,7 +290,7 @@ var c = class extends e {
|
|
|
290
290
|
"failed",
|
|
291
291
|
"hold",
|
|
292
292
|
"unhold"
|
|
293
|
-
],
|
|
293
|
+
], m = 3e4, h = class {
|
|
294
294
|
options;
|
|
295
295
|
currentState = "new";
|
|
296
296
|
sessionUnsubscribers = [];
|
|
@@ -306,7 +306,7 @@ var c = class extends e {
|
|
|
306
306
|
constructor(t) {
|
|
307
307
|
this.options = t, this.id = t.id, this.destination = t.destination, this.platform = t.platform, this.capabilities = t.capabilities ?? /* @__PURE__ */ new Set();
|
|
308
308
|
try {
|
|
309
|
-
|
|
309
|
+
ee.forEach((e) => {
|
|
310
310
|
this.sessionUnsubscribers.push(t.session.on(e, (t) => this.handleSessionEvent(e, t)));
|
|
311
311
|
});
|
|
312
312
|
} catch (n) {
|
|
@@ -366,11 +366,11 @@ var c = class extends e {
|
|
|
366
366
|
this.assertState("active"), this.assertCapability("dtmf"), this.invoke(() => this.options.session.sendDtmf(e));
|
|
367
367
|
}
|
|
368
368
|
async transfer(e, t) {
|
|
369
|
-
if (this.assertNotDisposed(), this.assertOwner(t), this.assertTransferCapability(), this.assertState("active"), this.assertCapability("blind_transfer"), !
|
|
369
|
+
if (this.assertNotDisposed(), this.assertOwner(t), this.assertTransferCapability(), this.assertState("active"), this.assertCapability("blind_transfer"), !te(e) || e.target.trim() === "") throw this.operationError();
|
|
370
370
|
this.invoke(() => this.options.session.refer(e.target.trim()));
|
|
371
371
|
}
|
|
372
372
|
async hangup(e) {
|
|
373
|
-
if (this.assertNotDisposed(), this.assertOwner(e),
|
|
373
|
+
if (this.assertNotDisposed(), this.assertOwner(e), g(this.currentState)) throw this.operationError();
|
|
374
374
|
try {
|
|
375
375
|
this.options.session.terminate(), this.transitionTo("ended");
|
|
376
376
|
} catch (e) {
|
|
@@ -400,7 +400,7 @@ var c = class extends e {
|
|
|
400
400
|
}
|
|
401
401
|
dispose() {
|
|
402
402
|
if (!this.disposed) {
|
|
403
|
-
if (this.rejectPendingOperation(), this.incomingOperation = void 0, this.disposed = !0, !
|
|
403
|
+
if (this.rejectPendingOperation(), this.incomingOperation = void 0, this.disposed = !0, !g(this.currentState)) try {
|
|
404
404
|
this.options.session.terminate();
|
|
405
405
|
} catch (e) {
|
|
406
406
|
this.reportOperationError(e);
|
|
@@ -412,7 +412,7 @@ var c = class extends e {
|
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
handleSessionEvent(e, t) {
|
|
415
|
-
if ((e === "accepted" || e === "confirmed" || e === "ended" || e === "failed") && (this.incomingOperation = void 0), !(this.disposed ||
|
|
415
|
+
if ((e === "accepted" || e === "confirmed" || e === "ended" || e === "failed") && (this.incomingOperation = void 0), !(this.disposed || g(this.currentState))) switch (e) {
|
|
416
416
|
case "progress":
|
|
417
417
|
this.transitionIfAllowed("ringing", t, e);
|
|
418
418
|
break;
|
|
@@ -447,7 +447,7 @@ var c = class extends e {
|
|
|
447
447
|
if (this.currentState === e) return;
|
|
448
448
|
if (!o(this.currentState, e)) throw this.operationError();
|
|
449
449
|
let n = this.currentState;
|
|
450
|
-
this.currentState = e,
|
|
450
|
+
this.currentState = e, g(e) && this.rejectPendingOperation();
|
|
451
451
|
try {
|
|
452
452
|
this.options.onStateChanged?.({
|
|
453
453
|
callId: this.id,
|
|
@@ -455,7 +455,7 @@ var c = class extends e {
|
|
|
455
455
|
to: e
|
|
456
456
|
}, t);
|
|
457
457
|
} catch {} finally {
|
|
458
|
-
|
|
458
|
+
g(e) && this.dispose();
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
461
|
startPendingOperation(e, t, n) {
|
|
@@ -467,7 +467,7 @@ var c = class extends e {
|
|
|
467
467
|
resolve: r,
|
|
468
468
|
reject: i
|
|
469
469
|
};
|
|
470
|
-
this.pendingOperation = a, a.timer = setTimeout(() => this.timeoutPendingOperation(a),
|
|
470
|
+
this.pendingOperation = a, a.timer = setTimeout(() => this.timeoutPendingOperation(a), m);
|
|
471
471
|
let o;
|
|
472
472
|
try {
|
|
473
473
|
o = n();
|
|
@@ -480,7 +480,7 @@ var c = class extends e {
|
|
|
480
480
|
}
|
|
481
481
|
resolvePendingOperation(e) {
|
|
482
482
|
if (this.pendingOperation === e) {
|
|
483
|
-
if (this.clearPendingTimer(e), this.pendingOperation = void 0, this.disposed ||
|
|
483
|
+
if (this.clearPendingTimer(e), this.pendingOperation = void 0, this.disposed || g(this.currentState)) {
|
|
484
484
|
e.reject(this.operationError());
|
|
485
485
|
return;
|
|
486
486
|
}
|
|
@@ -579,22 +579,32 @@ var c = class extends e {
|
|
|
579
579
|
});
|
|
580
580
|
}
|
|
581
581
|
};
|
|
582
|
-
function
|
|
582
|
+
function g(e) {
|
|
583
583
|
return e === "ended" || e === "failed";
|
|
584
584
|
}
|
|
585
|
-
function
|
|
585
|
+
function te(e) {
|
|
586
586
|
return typeof e == "object" && !!e && e.type === "blind" && typeof e.target == "string";
|
|
587
587
|
}
|
|
588
588
|
//#endregion
|
|
589
589
|
//#region src/core/callId.ts
|
|
590
|
-
var
|
|
591
|
-
function
|
|
592
|
-
return
|
|
590
|
+
var _ = 0;
|
|
591
|
+
function v() {
|
|
592
|
+
return _ += 1, `call_${Date.now().toString(36)}_${_.toString(36)}`;
|
|
593
|
+
}
|
|
594
|
+
//#endregion
|
|
595
|
+
//#region src/core/userData.ts
|
|
596
|
+
var ne = "X-User-Data", re = /[^\x20-\x7E]/, y = "userdata 只能是可见 ASCII(不能有换行/制表/中文):换行会构成 SIP 头注入;要传中文或 JSON 请调用方先 encodeURIComponent / base64,再在平台侧解回来";
|
|
597
|
+
function b(t) {
|
|
598
|
+
if (typeof t != "string") return [];
|
|
599
|
+
let n = t.trim();
|
|
600
|
+
if (n === "") return [];
|
|
601
|
+
if (re.test(n)) throw new e("CALL_INVALID_USERDATA", "call", !1, { cause: y });
|
|
602
|
+
return [`${ne}: ${n}`];
|
|
593
603
|
}
|
|
594
604
|
//#endregion
|
|
595
605
|
//#region src/core/CallManager.ts
|
|
596
606
|
var x = class {
|
|
597
|
-
events = new
|
|
607
|
+
events = new ie();
|
|
598
608
|
calls = /* @__PURE__ */ new Map();
|
|
599
609
|
options;
|
|
600
610
|
incomingUnsubscribe;
|
|
@@ -627,53 +637,54 @@ var x = class {
|
|
|
627
637
|
this.assertNotDisposed();
|
|
628
638
|
let r = this.operationGeneration, i = t.destination.trim();
|
|
629
639
|
if (i === "") throw new e("CALL_INVALID_DESTINATION", "call", !1);
|
|
640
|
+
let a = b(t.userdata);
|
|
630
641
|
this.requireCapability(n, "outbound");
|
|
631
|
-
let
|
|
632
|
-
if (this.options.platform === "mobile-web" && this.calls.size + this.pendingDialCount >=
|
|
633
|
-
if (this.calls.size + this.pendingDialCount >=
|
|
642
|
+
let o = this.callLimit(n);
|
|
643
|
+
if (this.options.platform === "mobile-web" && this.calls.size + this.pendingDialCount >= o) throw this.capabilityError();
|
|
644
|
+
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);
|
|
634
645
|
this.pendingDialCount += 1, this.pendingDestinations.add(i);
|
|
635
|
-
let
|
|
646
|
+
let s = v(), c;
|
|
636
647
|
try {
|
|
637
|
-
|
|
648
|
+
c = await this.holdActiveCallForNewCall(), this.assertGeneration(r, s);
|
|
638
649
|
let e;
|
|
639
650
|
try {
|
|
640
|
-
e = this.options.sip.dial(i, this.dialOptions(
|
|
651
|
+
e = this.options.sip.dial(i, this.dialOptions(s, n, t.type, a));
|
|
641
652
|
} catch (e) {
|
|
642
|
-
throw this.dialError(e,
|
|
653
|
+
throw this.dialError(e, s);
|
|
643
654
|
}
|
|
644
|
-
this.assertGeneration(r,
|
|
645
|
-
let
|
|
655
|
+
this.assertGeneration(r, s);
|
|
656
|
+
let o;
|
|
646
657
|
try {
|
|
647
|
-
|
|
648
|
-
id:
|
|
658
|
+
o = new h({
|
|
659
|
+
id: s,
|
|
649
660
|
destination: i,
|
|
650
661
|
platform: this.options.platform,
|
|
651
662
|
capabilities: this.effectiveCapabilities(n),
|
|
652
663
|
session: e,
|
|
653
|
-
onStateChanged: (e, t) => this.handleStateChanged(
|
|
664
|
+
onStateChanged: (e, t) => this.handleStateChanged(o, e, t),
|
|
654
665
|
onError: (e) => this.events.emit("error", { error: e }),
|
|
655
|
-
onDisposed: () => this.handleDisposed(
|
|
666
|
+
onDisposed: () => this.handleDisposed(o)
|
|
656
667
|
});
|
|
657
668
|
} catch (e) {
|
|
658
|
-
throw this.dialError(e,
|
|
669
|
+
throw this.dialError(e, s);
|
|
659
670
|
}
|
|
660
|
-
if (!this.isCurrentGeneration(r)) throw
|
|
661
|
-
this.calls.set(
|
|
671
|
+
if (!this.isCurrentGeneration(r)) throw o.dispose(), this.callOperationError(o.id);
|
|
672
|
+
this.calls.set(o.id, o), this.callSessions.set(o.id, e), this.options.onCallCreated?.(o.id, e);
|
|
662
673
|
try {
|
|
663
|
-
|
|
674
|
+
o.beginOutbound();
|
|
664
675
|
} catch (e) {
|
|
665
|
-
throw
|
|
676
|
+
throw o.dispose(), this.calls.delete(o.id), this.callSessions.delete(o.id), this.dialError(e, o.id);
|
|
666
677
|
}
|
|
667
|
-
if (!this.isCurrentGeneration(r)) throw
|
|
678
|
+
if (!this.isCurrentGeneration(r)) throw o.dispose(), this.calls.delete(o.id), this.callSessions.delete(o.id), this.callOperationError(o.id);
|
|
668
679
|
return this.events.emit("call.created", {
|
|
669
|
-
callId:
|
|
670
|
-
state:
|
|
671
|
-
}),
|
|
680
|
+
callId: o.id,
|
|
681
|
+
state: o.state
|
|
682
|
+
}), o;
|
|
672
683
|
} catch (e) {
|
|
673
|
-
if (this.isCurrentGeneration(r) &&
|
|
674
|
-
await
|
|
684
|
+
if (this.isCurrentGeneration(r) && c !== void 0 && this.isManagedCall(c) && c.state === "held") try {
|
|
685
|
+
await c.resume();
|
|
675
686
|
} catch (t) {
|
|
676
|
-
throw this.compensationError(
|
|
687
|
+
throw this.compensationError(c.id, void 0, e, t);
|
|
677
688
|
}
|
|
678
689
|
throw e;
|
|
679
690
|
} finally {
|
|
@@ -826,10 +837,10 @@ var x = class {
|
|
|
826
837
|
}
|
|
827
838
|
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", {
|
|
828
839
|
callId: e.id,
|
|
829
|
-
reason:
|
|
840
|
+
reason: ae(n)
|
|
830
841
|
}) : this.events.emit("call.failed", {
|
|
831
842
|
callId: e.id,
|
|
832
|
-
error:
|
|
843
|
+
error: oe(n, e.id)
|
|
833
844
|
}));
|
|
834
845
|
}
|
|
835
846
|
async switchAutomaticActiveCall(e, t, n) {
|
|
@@ -895,7 +906,7 @@ var x = class {
|
|
|
895
906
|
}
|
|
896
907
|
handleIncoming(t) {
|
|
897
908
|
if (this.disposed) return;
|
|
898
|
-
let n =
|
|
909
|
+
let n = v(), r = this.incomingSessionSnapshot;
|
|
899
910
|
if (r === void 0 || !r.policy.incomingEnabled || !this.effectiveCapabilities(r).has("inbound")) {
|
|
900
911
|
this.terminateUnsupportedIncoming(t), this.events.emit("error", { error: this.capabilityError(n) });
|
|
901
912
|
return;
|
|
@@ -907,7 +918,7 @@ var x = class {
|
|
|
907
918
|
}
|
|
908
919
|
let a;
|
|
909
920
|
try {
|
|
910
|
-
a = new
|
|
921
|
+
a = new h({
|
|
911
922
|
id: n,
|
|
912
923
|
destination: i,
|
|
913
924
|
platform: this.options.platform,
|
|
@@ -1015,10 +1026,14 @@ var x = class {
|
|
|
1015
1026
|
let t = this.options.platform === "mobile-web" ? 1 : 2, n = this.options.maxConcurrentCalls ?? t;
|
|
1016
1027
|
return Math.min(t, Math.max(1, n), Math.max(1, e.policy.maxConcurrentCalls));
|
|
1017
1028
|
}
|
|
1018
|
-
dialOptions(e, t, n) {
|
|
1029
|
+
dialOptions(e, t, n, r = []) {
|
|
1019
1030
|
return {
|
|
1020
1031
|
iceServers: t.iceServers,
|
|
1021
|
-
extraHeaders: [
|
|
1032
|
+
extraHeaders: [
|
|
1033
|
+
`X-XCall-Call-ID: ${e}`,
|
|
1034
|
+
`X-XCall-Session-ID: ${t.sessionId}`,
|
|
1035
|
+
...r
|
|
1036
|
+
],
|
|
1022
1037
|
...n === void 0 ? {} : { type: n }
|
|
1023
1038
|
};
|
|
1024
1039
|
}
|
|
@@ -1032,7 +1047,7 @@ var x = class {
|
|
|
1032
1047
|
cause: t
|
|
1033
1048
|
});
|
|
1034
1049
|
}
|
|
1035
|
-
},
|
|
1050
|
+
}, ie = class {
|
|
1036
1051
|
handlers = /* @__PURE__ */ new Map();
|
|
1037
1052
|
on(e, t) {
|
|
1038
1053
|
let n = this.handlers.get(e) ?? /* @__PURE__ */ new Set(), r = t;
|
|
@@ -1057,12 +1072,12 @@ var x = class {
|
|
|
1057
1072
|
this.handlers.clear();
|
|
1058
1073
|
}
|
|
1059
1074
|
};
|
|
1060
|
-
function
|
|
1075
|
+
function ae(e) {
|
|
1061
1076
|
if (typeof e != "object" || !e || !("reason" in e)) return "ended";
|
|
1062
1077
|
let t = e.reason;
|
|
1063
1078
|
return typeof t == "string" && t !== "" ? t : "ended";
|
|
1064
1079
|
}
|
|
1065
|
-
function
|
|
1080
|
+
function oe(t, n) {
|
|
1066
1081
|
if (t instanceof e) return new e(t.code, t.category, t.retryable, {
|
|
1067
1082
|
requestId: t.requestId,
|
|
1068
1083
|
callId: n,
|
|
@@ -1087,7 +1102,7 @@ function ne(t, n) {
|
|
|
1087
1102
|
}
|
|
1088
1103
|
//#endregion
|
|
1089
1104
|
//#region src/shared/SharedWorkerClient.ts
|
|
1090
|
-
var
|
|
1105
|
+
var se = class {
|
|
1091
1106
|
port;
|
|
1092
1107
|
timeoutMs;
|
|
1093
1108
|
pending = /* @__PURE__ */ new Map();
|
|
@@ -1124,13 +1139,13 @@ var S = class {
|
|
|
1124
1139
|
try {
|
|
1125
1140
|
let n = t(e);
|
|
1126
1141
|
if (n.type === "event") {
|
|
1127
|
-
n.event === "connection.stateChanged" &&
|
|
1142
|
+
n.event === "connection.stateChanged" && S(n.payload) && (this.lifecycleState = n.payload.state), this.eventHandlers.forEach((e) => e(n));
|
|
1128
1143
|
return;
|
|
1129
1144
|
}
|
|
1130
1145
|
if (n.type !== "response") return;
|
|
1131
1146
|
let r = this.pending.get(n.requestId);
|
|
1132
1147
|
if (r === void 0) return;
|
|
1133
|
-
this.pending.delete(n.requestId), clearTimeout(r.timer), n.ok ? r.resolve(n.result) : r.reject(
|
|
1148
|
+
this.pending.delete(n.requestId), clearTimeout(r.timer), n.ok ? r.resolve(n.result) : r.reject(ce(n));
|
|
1134
1149
|
} catch (e) {
|
|
1135
1150
|
this.pending.forEach((t) => {
|
|
1136
1151
|
clearTimeout(t.timer), t.reject(e);
|
|
@@ -1138,10 +1153,10 @@ var S = class {
|
|
|
1138
1153
|
}
|
|
1139
1154
|
}
|
|
1140
1155
|
};
|
|
1141
|
-
function
|
|
1156
|
+
function S(e) {
|
|
1142
1157
|
return typeof e == "object" && !!e && "state" in e && (e.state === "connected" || e.state === "reconnecting");
|
|
1143
1158
|
}
|
|
1144
|
-
function
|
|
1159
|
+
function ce(t) {
|
|
1145
1160
|
let n = t.error;
|
|
1146
1161
|
return new e(n?.code ?? "SDK_INTERNAL_ERROR", n?.category ?? "internal", n?.retryable ?? !1, {
|
|
1147
1162
|
requestId: t.requestId,
|
|
@@ -1152,12 +1167,12 @@ function C(t) {
|
|
|
1152
1167
|
}
|
|
1153
1168
|
//#endregion
|
|
1154
1169
|
//#region src/shared/SharedWorkerFactory.ts
|
|
1155
|
-
function
|
|
1170
|
+
function C(t = {}) {
|
|
1156
1171
|
if ((t.enabled ?? "auto") === !1) return {
|
|
1157
1172
|
mode: "single-tab",
|
|
1158
1173
|
reason: "disabled"
|
|
1159
1174
|
};
|
|
1160
|
-
let n = t.locationHref ??
|
|
1175
|
+
let n = t.locationHref ?? T(), r = w(t.url, n), i = (n) => {
|
|
1161
1176
|
if (t.fallback === "error") throw new e("CONFIG_INVALID", "configuration", !1, { cause: n });
|
|
1162
1177
|
return {
|
|
1163
1178
|
mode: "single-tab",
|
|
@@ -1165,8 +1180,8 @@ function w(t = {}) {
|
|
|
1165
1180
|
};
|
|
1166
1181
|
};
|
|
1167
1182
|
if (r === void 0) return i("SharedWorker URL is unavailable");
|
|
1168
|
-
if (!
|
|
1169
|
-
let a = t.workerCtor ??
|
|
1183
|
+
if (!E(r, n)) return i("SharedWorker URL must be same-origin");
|
|
1184
|
+
let a = t.workerCtor ?? le();
|
|
1170
1185
|
if (a === void 0) return i("SharedWorker is not supported");
|
|
1171
1186
|
let o;
|
|
1172
1187
|
try {
|
|
@@ -1174,10 +1189,10 @@ function w(t = {}) {
|
|
|
1174
1189
|
} catch (e) {
|
|
1175
1190
|
return i(`SharedWorker construction failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
1176
1191
|
}
|
|
1177
|
-
let s = t.tabId ??
|
|
1192
|
+
let s = t.tabId ?? D(), c = new se(o.port), l = {
|
|
1178
1193
|
version: 1,
|
|
1179
1194
|
type: "attach",
|
|
1180
|
-
requestId:
|
|
1195
|
+
requestId: O(),
|
|
1181
1196
|
tabId: s
|
|
1182
1197
|
}, u = c.request(l).then(() => void 0).catch((e) => {
|
|
1183
1198
|
throw c.close(), e;
|
|
@@ -1191,20 +1206,20 @@ function w(t = {}) {
|
|
|
1191
1206
|
ready: u
|
|
1192
1207
|
};
|
|
1193
1208
|
}
|
|
1194
|
-
function
|
|
1209
|
+
function w(e, t = T()) {
|
|
1195
1210
|
try {
|
|
1196
1211
|
return t === void 0 ? void 0 : new URL(e ?? "./shared-worker.js", t).toString();
|
|
1197
1212
|
} catch {
|
|
1198
1213
|
return;
|
|
1199
1214
|
}
|
|
1200
1215
|
}
|
|
1201
|
-
function
|
|
1216
|
+
function T() {
|
|
1202
1217
|
return typeof location > "u" ? void 0 : location.href;
|
|
1203
1218
|
}
|
|
1204
|
-
function
|
|
1219
|
+
function le() {
|
|
1205
1220
|
if (typeof SharedWorker == "function") return SharedWorker;
|
|
1206
1221
|
}
|
|
1207
|
-
function
|
|
1222
|
+
function E(e, t) {
|
|
1208
1223
|
if (t === void 0) return !0;
|
|
1209
1224
|
try {
|
|
1210
1225
|
return new URL(e, t).origin === new URL(t).origin;
|
|
@@ -1212,15 +1227,15 @@ function O(e, t) {
|
|
|
1212
1227
|
return !1;
|
|
1213
1228
|
}
|
|
1214
1229
|
}
|
|
1215
|
-
function
|
|
1230
|
+
function D() {
|
|
1216
1231
|
return `tab-${typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).slice(2)}`;
|
|
1217
1232
|
}
|
|
1218
|
-
function
|
|
1233
|
+
function O() {
|
|
1219
1234
|
return `attach-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
1220
1235
|
}
|
|
1221
1236
|
//#endregion
|
|
1222
1237
|
//#region src/media/DeviceManager.ts
|
|
1223
|
-
var
|
|
1238
|
+
var k = class {
|
|
1224
1239
|
mediaDevices;
|
|
1225
1240
|
createAudioElement;
|
|
1226
1241
|
outputCapability;
|
|
@@ -1228,23 +1243,23 @@ var oe = class {
|
|
|
1228
1243
|
outputGeneration = 0;
|
|
1229
1244
|
outputTail;
|
|
1230
1245
|
constructor(e = {}) {
|
|
1231
|
-
this.mediaDevices = e.mediaDevices === null ? void 0 : e.mediaDevices ??
|
|
1246
|
+
this.mediaDevices = e.mediaDevices === null ? void 0 : e.mediaDevices ?? A(), this.createAudioElement = e.createAudioElement;
|
|
1232
1247
|
}
|
|
1233
1248
|
async requestPermission(e = {}) {
|
|
1234
1249
|
let t = this.requireMediaDevices(), n;
|
|
1235
1250
|
try {
|
|
1236
1251
|
n = await t.getUserMedia({ audio: e });
|
|
1237
1252
|
} catch (e) {
|
|
1238
|
-
throw
|
|
1253
|
+
throw N(e);
|
|
1239
1254
|
}
|
|
1240
|
-
|
|
1255
|
+
j(n);
|
|
1241
1256
|
}
|
|
1242
1257
|
async getDevices() {
|
|
1243
1258
|
if (this.mediaDevices === void 0) return [];
|
|
1244
1259
|
try {
|
|
1245
1260
|
return (await this.mediaDevices.enumerateDevices()).filter((e) => e.kind === "audioinput" || e.kind === "audiooutput" && this.supportsOutputSelection());
|
|
1246
1261
|
} catch (e) {
|
|
1247
|
-
throw
|
|
1262
|
+
throw P(e);
|
|
1248
1263
|
}
|
|
1249
1264
|
}
|
|
1250
1265
|
getCapabilities() {
|
|
@@ -1282,7 +1297,7 @@ var oe = class {
|
|
|
1282
1297
|
try {
|
|
1283
1298
|
await r.setSinkId(t);
|
|
1284
1299
|
} catch (e) {
|
|
1285
|
-
throw
|
|
1300
|
+
throw F(e);
|
|
1286
1301
|
}
|
|
1287
1302
|
}
|
|
1288
1303
|
enqueueOutput(e) {
|
|
@@ -1296,7 +1311,7 @@ var oe = class {
|
|
|
1296
1311
|
try {
|
|
1297
1312
|
return await t.getUserMedia({ audio: { deviceId: { exact: e } } });
|
|
1298
1313
|
} catch (e) {
|
|
1299
|
-
throw
|
|
1314
|
+
throw M(e);
|
|
1300
1315
|
}
|
|
1301
1316
|
}
|
|
1302
1317
|
requireMediaDevices() {
|
|
@@ -1316,10 +1331,10 @@ var oe = class {
|
|
|
1316
1331
|
}
|
|
1317
1332
|
}
|
|
1318
1333
|
};
|
|
1319
|
-
function
|
|
1334
|
+
function A() {
|
|
1320
1335
|
return globalThis.navigator?.mediaDevices;
|
|
1321
1336
|
}
|
|
1322
|
-
function
|
|
1337
|
+
function j(e) {
|
|
1323
1338
|
let t;
|
|
1324
1339
|
try {
|
|
1325
1340
|
t = e.getTracks();
|
|
@@ -1332,57 +1347,57 @@ function A(e) {
|
|
|
1332
1347
|
} catch {}
|
|
1333
1348
|
});
|
|
1334
1349
|
}
|
|
1335
|
-
function j(t) {
|
|
1336
|
-
let n = F(t);
|
|
1337
|
-
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 });
|
|
1338
|
-
}
|
|
1339
1350
|
function M(t) {
|
|
1340
|
-
let n =
|
|
1351
|
+
let n = I(t);
|
|
1341
1352
|
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 });
|
|
1342
1353
|
}
|
|
1343
1354
|
function N(t) {
|
|
1344
|
-
let n =
|
|
1345
|
-
return n === "NotFoundError" ? new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { cause: t }) : n === "
|
|
1355
|
+
let n = I(t);
|
|
1356
|
+
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 });
|
|
1346
1357
|
}
|
|
1347
1358
|
function P(t) {
|
|
1348
|
-
let n =
|
|
1359
|
+
let n = I(t);
|
|
1349
1360
|
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 });
|
|
1350
1361
|
}
|
|
1351
|
-
function F(
|
|
1362
|
+
function F(t) {
|
|
1363
|
+
let n = I(t);
|
|
1364
|
+
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
|
+
}
|
|
1366
|
+
function I(e) {
|
|
1352
1367
|
if (typeof e != "object" || !e || !("name" in e)) return;
|
|
1353
1368
|
let t = e.name;
|
|
1354
1369
|
return typeof t == "string" ? t : void 0;
|
|
1355
1370
|
}
|
|
1356
1371
|
//#endregion
|
|
1357
1372
|
//#region src/media/RemoteAudio.ts
|
|
1358
|
-
var
|
|
1373
|
+
var L = class {
|
|
1359
1374
|
createAudioElement;
|
|
1360
1375
|
bindings = /* @__PURE__ */ new Map();
|
|
1361
1376
|
audioOwners = /* @__PURE__ */ new Map();
|
|
1362
1377
|
trackOwners = /* @__PURE__ */ new Map();
|
|
1363
1378
|
generations = /* @__PURE__ */ new Map();
|
|
1364
1379
|
pendingPlays = /* @__PURE__ */ new Map();
|
|
1365
|
-
constructor(e =
|
|
1380
|
+
constructor(e = R) {
|
|
1366
1381
|
this.createAudioElement = e;
|
|
1367
1382
|
}
|
|
1368
1383
|
async bind(t, n) {
|
|
1369
1384
|
let r = this.bindings.get(t);
|
|
1370
1385
|
if (r?.stream === n) return;
|
|
1371
|
-
let i =
|
|
1386
|
+
let i = z(t, n), a;
|
|
1372
1387
|
try {
|
|
1373
1388
|
a = this.createAudioElement();
|
|
1374
1389
|
} catch (n) {
|
|
1375
|
-
throw
|
|
1390
|
+
throw B(i, this.trackOwners), new e("CAPABILITY_NOT_SUPPORTED", "capability", !1, {
|
|
1376
1391
|
callId: t,
|
|
1377
1392
|
cause: n
|
|
1378
1393
|
});
|
|
1379
1394
|
}
|
|
1380
1395
|
let o = this.audioOwners.get(a);
|
|
1381
|
-
if (o !== void 0 && o !== t) throw
|
|
1396
|
+
if (o !== void 0 && o !== t) throw B(i, this.trackOwners), new e("CALL_OPERATION_NOT_ALLOWED", "call", !1, { callId: t });
|
|
1382
1397
|
try {
|
|
1383
1398
|
a.autoplay = !0, a.playsInline = !0;
|
|
1384
1399
|
} catch (n) {
|
|
1385
|
-
throw
|
|
1400
|
+
throw B(i, this.trackOwners), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1386
1401
|
callId: t,
|
|
1387
1402
|
cause: n
|
|
1388
1403
|
});
|
|
@@ -1390,7 +1405,7 @@ var I = class {
|
|
|
1390
1405
|
try {
|
|
1391
1406
|
a.srcObject = n;
|
|
1392
1407
|
} catch (n) {
|
|
1393
|
-
throw
|
|
1408
|
+
throw B(i, this.trackOwners), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1394
1409
|
callId: t,
|
|
1395
1410
|
cause: n
|
|
1396
1411
|
});
|
|
@@ -1466,7 +1481,7 @@ var I = class {
|
|
|
1466
1481
|
releaseTrack(e) {
|
|
1467
1482
|
let t = this.trackOwners.get(e);
|
|
1468
1483
|
if (t === void 0 || t <= 1) {
|
|
1469
|
-
this.trackOwners.delete(e),
|
|
1484
|
+
this.trackOwners.delete(e), H(e);
|
|
1470
1485
|
return;
|
|
1471
1486
|
}
|
|
1472
1487
|
this.trackOwners.set(e, t - 1);
|
|
@@ -1489,42 +1504,42 @@ var I = class {
|
|
|
1489
1504
|
return this.generations.get(e) === t && this.bindings.get(e)?.generation === t;
|
|
1490
1505
|
}
|
|
1491
1506
|
};
|
|
1492
|
-
function
|
|
1507
|
+
function R() {
|
|
1493
1508
|
if (typeof document > "u") throw new e("CAPABILITY_NOT_SUPPORTED", "capability", !1);
|
|
1494
1509
|
return document.createElement("audio");
|
|
1495
1510
|
}
|
|
1496
|
-
function
|
|
1511
|
+
function z(t, n) {
|
|
1497
1512
|
try {
|
|
1498
1513
|
return [...new Set(n.getAudioTracks())].filter((e) => e.kind === "audio");
|
|
1499
1514
|
} catch (r) {
|
|
1500
1515
|
try {
|
|
1501
1516
|
return [...new Set(n.getTracks())].filter((e) => e.kind === "audio");
|
|
1502
1517
|
} catch (i) {
|
|
1503
|
-
throw
|
|
1518
|
+
throw V(n), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1504
1519
|
callId: t,
|
|
1505
1520
|
cause: r ?? i
|
|
1506
1521
|
});
|
|
1507
1522
|
}
|
|
1508
1523
|
}
|
|
1509
1524
|
}
|
|
1510
|
-
function
|
|
1525
|
+
function B(e, t) {
|
|
1511
1526
|
e.forEach((e) => {
|
|
1512
|
-
(t.get(e) ?? 0) === 0 &&
|
|
1527
|
+
(t.get(e) ?? 0) === 0 && H(e);
|
|
1513
1528
|
});
|
|
1514
1529
|
}
|
|
1515
|
-
function
|
|
1530
|
+
function V(e) {
|
|
1516
1531
|
try {
|
|
1517
|
-
[...new Set(e.getTracks())].filter((e) => e.kind === "audio").forEach(
|
|
1532
|
+
[...new Set(e.getTracks())].filter((e) => e.kind === "audio").forEach(H);
|
|
1518
1533
|
} catch {}
|
|
1519
1534
|
}
|
|
1520
|
-
function
|
|
1535
|
+
function H(e) {
|
|
1521
1536
|
try {
|
|
1522
1537
|
e.stop();
|
|
1523
1538
|
} catch {}
|
|
1524
1539
|
}
|
|
1525
1540
|
//#endregion
|
|
1526
1541
|
//#region src/media/MediaManager.ts
|
|
1527
|
-
var
|
|
1542
|
+
var U = class {
|
|
1528
1543
|
deviceManager;
|
|
1529
1544
|
remoteAudio;
|
|
1530
1545
|
getActiveCall;
|
|
@@ -1545,7 +1560,7 @@ var H = class {
|
|
|
1545
1560
|
mediaDevices: e.mediaDevices,
|
|
1546
1561
|
createAudioElement: e.createAudioElement
|
|
1547
1562
|
};
|
|
1548
|
-
this.deviceManager = new
|
|
1563
|
+
this.deviceManager = new k(t), this.remoteAudio = new L(e.createAudioElement), this.getActiveCall = e.getActiveCall, this.createRemoteStream = e.createRemoteStream ?? de;
|
|
1549
1564
|
}
|
|
1550
1565
|
requestPermission(e) {
|
|
1551
1566
|
return this.assertNotDisposed(), this.deviceManager.requestPermission(e);
|
|
@@ -1565,7 +1580,7 @@ var H = class {
|
|
|
1565
1580
|
n !== void 0 && this.releaseResource(n).catch((e) => {
|
|
1566
1581
|
this.releaseErrors.set(n, e);
|
|
1567
1582
|
});
|
|
1568
|
-
let r =
|
|
1583
|
+
let r = W(t) ? t : { peerConnection: t }, i = {
|
|
1569
1584
|
callId: e,
|
|
1570
1585
|
peerConnection: r.peerConnection,
|
|
1571
1586
|
senders: /* @__PURE__ */ new Map(),
|
|
@@ -1647,7 +1662,7 @@ var H = class {
|
|
|
1647
1662
|
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);
|
|
1648
1663
|
let i = /* @__PURE__ */ new Set([...t.localTracks, ...t.pendingTracks]), a = [...t.senders.values()].filter((e) => e.audio).map((e) => ({
|
|
1649
1664
|
senderResource: e,
|
|
1650
|
-
promise: this.enqueueSender(t, e, () =>
|
|
1665
|
+
promise: this.enqueueSender(t, e, () => K(e.sender), !0)
|
|
1651
1666
|
})), o = Promise.all(a.map(async (e) => {
|
|
1652
1667
|
try {
|
|
1653
1668
|
return await e.promise, {
|
|
@@ -1665,11 +1680,11 @@ var H = class {
|
|
|
1665
1680
|
if (n.forEach((e) => {
|
|
1666
1681
|
if (e.cause !== void 0) {
|
|
1667
1682
|
o.push(e.cause);
|
|
1668
|
-
let t =
|
|
1683
|
+
let t = G(e.senderResource.sender);
|
|
1669
1684
|
t?.kind === "audio" && a.add(t);
|
|
1670
1685
|
return;
|
|
1671
1686
|
}
|
|
1672
|
-
let t =
|
|
1687
|
+
let t = G(e.senderResource.sender);
|
|
1673
1688
|
t?.kind === "audio" && i.add(t);
|
|
1674
1689
|
}), i.forEach((e) => {
|
|
1675
1690
|
a.has(e) || J(e);
|
|
@@ -1680,7 +1695,7 @@ var H = class {
|
|
|
1680
1695
|
if (!t.peerClosed && t.peerConnection.close !== void 0) try {
|
|
1681
1696
|
await t.peerConnection.close(), t.peerClosed = !0;
|
|
1682
1697
|
} catch (n) {
|
|
1683
|
-
let i = [...t.senders.values()].map((e) =>
|
|
1698
|
+
let i = [...t.senders.values()].map((e) => G(e.sender)).find((e) => e?.kind === "audio");
|
|
1684
1699
|
throw t.localTracks.clear(), t.pendingTracks.clear(), i != null && t.localTracks.add(i), new e("SDK_INTERNAL_ERROR", "internal", !0, {
|
|
1685
1700
|
callId: r,
|
|
1686
1701
|
cause: n
|
|
@@ -1748,11 +1763,11 @@ var H = class {
|
|
|
1748
1763
|
}
|
|
1749
1764
|
async performInputSwitch(t, n, r) {
|
|
1750
1765
|
if (this.assertActiveCall(n), this.assertDeviceSelectionCapability(n), !this.isCurrentResource(r) || n.peerConnection !== r.peerConnection) throw this.callOperationError(n.callId);
|
|
1751
|
-
let i = this.findAudioSender(r), a =
|
|
1766
|
+
let i = this.findAudioSender(r), a = G(i.sender), o = r.generation, s = await this.deviceManager.openInputStream(t), c;
|
|
1752
1767
|
try {
|
|
1753
1768
|
c = s.getTracks();
|
|
1754
1769
|
} catch (t) {
|
|
1755
|
-
throw
|
|
1770
|
+
throw ue(s), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1756
1771
|
callId: n.callId,
|
|
1757
1772
|
cause: t
|
|
1758
1773
|
});
|
|
@@ -1780,7 +1795,7 @@ var H = class {
|
|
|
1780
1795
|
}
|
|
1781
1796
|
if (!this.canCommitInputSwitch(n, r, i, u, o)) {
|
|
1782
1797
|
if (!r.released) try {
|
|
1783
|
-
await this.enqueueSender(r, i, () =>
|
|
1798
|
+
await this.enqueueSender(r, i, () => G(i.sender) === u ? K(i.sender) : Promise.resolve()), c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), q(c);
|
|
1784
1799
|
} catch (t) {
|
|
1785
1800
|
throw new e("SDK_INTERNAL_ERROR", "internal", !0, {
|
|
1786
1801
|
callId: n.callId,
|
|
@@ -1813,7 +1828,7 @@ var H = class {
|
|
|
1813
1828
|
});
|
|
1814
1829
|
}
|
|
1815
1830
|
r.forEach((r) => {
|
|
1816
|
-
let i =
|
|
1831
|
+
let i = G(r), a;
|
|
1817
1832
|
try {
|
|
1818
1833
|
a = n?.(r) ?? r.senderKind ?? r.kind;
|
|
1819
1834
|
} catch (n) {
|
|
@@ -1830,7 +1845,7 @@ var H = class {
|
|
|
1830
1845
|
});
|
|
1831
1846
|
}
|
|
1832
1847
|
findAudioSender(e) {
|
|
1833
|
-
let t = [...e.senders.values()].find((e) => e.audio && (
|
|
1848
|
+
let t = [...e.senders.values()].find((e) => e.audio && (G(e.sender)?.kind === "audio" || G(e.sender) === null));
|
|
1834
1849
|
if (t === void 0) throw this.capabilityError(e.callId);
|
|
1835
1850
|
return t;
|
|
1836
1851
|
}
|
|
@@ -1846,7 +1861,7 @@ var H = class {
|
|
|
1846
1861
|
} catch {
|
|
1847
1862
|
return !1;
|
|
1848
1863
|
}
|
|
1849
|
-
return
|
|
1864
|
+
return G(n.sender) === r;
|
|
1850
1865
|
}
|
|
1851
1866
|
enqueueSender(e, t, n, r = !1) {
|
|
1852
1867
|
t.queue.pending += 1;
|
|
@@ -1875,7 +1890,7 @@ var H = class {
|
|
|
1875
1890
|
});
|
|
1876
1891
|
}
|
|
1877
1892
|
async rollbackSender(e, t, n, r) {
|
|
1878
|
-
e.released ||
|
|
1893
|
+
e.released || G(t.sender) !== r || await this.enqueueSender(e, t, () => t.sender.replaceTrack(n)).catch(() => void 0);
|
|
1879
1894
|
}
|
|
1880
1895
|
isCurrentResource(e, t = e.generation) {
|
|
1881
1896
|
return !this.disposed && this.calls.get(e.callId) === e && e.generation === t;
|
|
@@ -1902,24 +1917,24 @@ var H = class {
|
|
|
1902
1917
|
if (this.disposed || this.disposing) throw new e("SDK_ALREADY_DISPOSED", "internal", !1);
|
|
1903
1918
|
}
|
|
1904
1919
|
};
|
|
1905
|
-
function
|
|
1920
|
+
function W(e) {
|
|
1906
1921
|
return "peerConnection" in e;
|
|
1907
1922
|
}
|
|
1908
|
-
function
|
|
1923
|
+
function G(e) {
|
|
1909
1924
|
try {
|
|
1910
1925
|
return e.track;
|
|
1911
1926
|
} catch {
|
|
1912
1927
|
return null;
|
|
1913
1928
|
}
|
|
1914
1929
|
}
|
|
1915
|
-
function
|
|
1930
|
+
function K(e) {
|
|
1916
1931
|
try {
|
|
1917
1932
|
return e.replaceTrack(null);
|
|
1918
1933
|
} catch (e) {
|
|
1919
1934
|
return Promise.reject(e);
|
|
1920
1935
|
}
|
|
1921
1936
|
}
|
|
1922
|
-
function
|
|
1937
|
+
function ue(e) {
|
|
1923
1938
|
try {
|
|
1924
1939
|
q(e.getTracks());
|
|
1925
1940
|
} catch {}
|
|
@@ -1932,7 +1947,7 @@ function J(e) {
|
|
|
1932
1947
|
e.stop();
|
|
1933
1948
|
} catch {}
|
|
1934
1949
|
}
|
|
1935
|
-
function
|
|
1950
|
+
function de(e) {
|
|
1936
1951
|
if (typeof MediaStream < "u") try {
|
|
1937
1952
|
return new MediaStream([e]);
|
|
1938
1953
|
} catch {
|
|
@@ -1941,8 +1956,8 @@ function se(e) {
|
|
|
1941
1956
|
}
|
|
1942
1957
|
//#endregion
|
|
1943
1958
|
//#region src/core/mediaBridge.ts
|
|
1944
|
-
function
|
|
1945
|
-
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
|
|
1959
|
+
function fe(t, n = {}) {
|
|
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 U({ getActiveCall: u });
|
|
1946
1961
|
return {
|
|
1947
1962
|
publicMedia: {
|
|
1948
1963
|
requestPermission: () => (f(), d.requestPermission()),
|
|
@@ -2000,7 +2015,7 @@ function ce(t, n = {}) {
|
|
|
2000
2015
|
function p(e, t) {
|
|
2001
2016
|
if (!Y(t) || typeof t.getMediaRegistration != "function") return;
|
|
2002
2017
|
let n = t.getMediaRegistration();
|
|
2003
|
-
if (
|
|
2018
|
+
if (pe(n) && r.get(e)?.peerConnection !== n.peerConnection) {
|
|
2004
2019
|
r.set(e, n);
|
|
2005
2020
|
try {
|
|
2006
2021
|
d.registerCallMedia(e, n);
|
|
@@ -2013,19 +2028,19 @@ function ce(t, n = {}) {
|
|
|
2013
2028
|
function Y(e) {
|
|
2014
2029
|
return typeof e == "object" && !!e;
|
|
2015
2030
|
}
|
|
2016
|
-
function
|
|
2031
|
+
function pe(e) {
|
|
2017
2032
|
return typeof e == "object" && !!e && "peerConnection" in e && typeof e.peerConnection == "object" && e.peerConnection !== null;
|
|
2018
2033
|
}
|
|
2019
2034
|
//#endregion
|
|
2020
2035
|
//#region src/reconnect/backoff.ts
|
|
2021
|
-
var
|
|
2022
|
-
function
|
|
2023
|
-
let n = Math.min(
|
|
2036
|
+
var me = 1e3, he = 3e4;
|
|
2037
|
+
function ge(e, t = Math.random) {
|
|
2038
|
+
let n = Math.min(he, me * 2 ** Math.max(0, Math.floor(e))), r = Math.min(1, Math.max(0, t()));
|
|
2024
2039
|
return Math.round(n * (1 + r * .2));
|
|
2025
2040
|
}
|
|
2026
2041
|
//#endregion
|
|
2027
2042
|
//#region src/reconnect/ReconnectManager.ts
|
|
2028
|
-
var
|
|
2043
|
+
var _e = class {
|
|
2029
2044
|
recover;
|
|
2030
2045
|
random;
|
|
2031
2046
|
isOnline;
|
|
@@ -2042,7 +2057,7 @@ var pe = class {
|
|
|
2042
2057
|
}
|
|
2043
2058
|
start() {
|
|
2044
2059
|
if (this.disposed || !this.online || !this.isOnline() || this.pendingTimer !== void 0 || this.running) return;
|
|
2045
|
-
let e = this.generation, t =
|
|
2060
|
+
let e = this.generation, t = ge(this.attempt, this.random);
|
|
2046
2061
|
this.pendingTimer = setTimeout(() => {
|
|
2047
2062
|
this.pendingTimer = void 0, this.run(e);
|
|
2048
2063
|
}, t);
|
|
@@ -2084,7 +2099,7 @@ var pe = class {
|
|
|
2084
2099
|
clearPendingTimer() {
|
|
2085
2100
|
this.pendingTimer !== void 0 && (clearTimeout(this.pendingTimer), this.pendingTimer = void 0);
|
|
2086
2101
|
}
|
|
2087
|
-
},
|
|
2102
|
+
}, ve = class t {
|
|
2088
2103
|
media;
|
|
2089
2104
|
options;
|
|
2090
2105
|
api;
|
|
@@ -2129,7 +2144,7 @@ var pe = class {
|
|
|
2129
2144
|
this.api = t.api === void 0 ? t.sessionProvider === void 0 ? new p({
|
|
2130
2145
|
baseUrl: t.baseUrl ?? "",
|
|
2131
2146
|
tokenProvider: i
|
|
2132
|
-
}) : X(
|
|
2147
|
+
}) : X(xe(t.sessionProvider)) : X(t.api), this.suppliedSip = t.sip === void 0 ? void 0 : Se(t.sip), this.mediaBridge = fe(() => this.getActiveMediaContext()), this.media = this.mediaBridge.publicMedia, this.reconnect = new _e({
|
|
2133
2148
|
recover: () => this.recoverConnection(),
|
|
2134
2149
|
onAttempt: (e) => {
|
|
2135
2150
|
this.disposed || this.events.emit("connection.reconnecting", { attempt: e });
|
|
@@ -2141,13 +2156,13 @@ var pe = class {
|
|
|
2141
2156
|
}), this.sharedWorkerSelection = t.sharedWorker === void 0 ? {
|
|
2142
2157
|
mode: "single-tab",
|
|
2143
2158
|
reason: "disabled"
|
|
2144
|
-
} :
|
|
2159
|
+
} : C({
|
|
2145
2160
|
...t.sharedWorker,
|
|
2146
2161
|
...t.sharedWorkerHost ?? {}
|
|
2147
2162
|
});
|
|
2148
2163
|
}
|
|
2149
2164
|
static async checkSupport() {
|
|
2150
|
-
let e = typeof navigator < "u" && navigator.mediaDevices !== void 0, t = typeof WebSocket < "u", n =
|
|
2165
|
+
let e = typeof navigator < "u" && navigator.mediaDevices !== void 0, t = typeof WebSocket < "u", n = be(typeof navigator < "u" ? navigator.userAgent : "");
|
|
2151
2166
|
return {
|
|
2152
2167
|
supported: e && t,
|
|
2153
2168
|
platform: n,
|
|
@@ -2254,7 +2269,7 @@ var pe = class {
|
|
|
2254
2269
|
sdkVersion: n,
|
|
2255
2270
|
platform: a === "mobile-web" ? "mobile_web" : "web",
|
|
2256
2271
|
...this.options.locale === void 0 ? {} : { locale: this.options.locale },
|
|
2257
|
-
requestedCapabilities: [...this.options.requestedCapabilities ??
|
|
2272
|
+
requestedCapabilities: [...this.options.requestedCapabilities ?? Ee(a)]
|
|
2258
2273
|
}), this.ownedSessionIds.add(t.sessionId), this.assertGeneration(e), r = await this.getSip(), this.assertGeneration(e), this.session = t;
|
|
2259
2274
|
let o = this.callManager ?? this.createCallManager(r, t, a);
|
|
2260
2275
|
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);
|
|
@@ -2360,7 +2375,7 @@ var pe = class {
|
|
|
2360
2375
|
try {
|
|
2361
2376
|
await this.media.releaseAll();
|
|
2362
2377
|
} catch (t) {
|
|
2363
|
-
|
|
2378
|
+
Ce(t) || (e ??= t);
|
|
2364
2379
|
}
|
|
2365
2380
|
try {
|
|
2366
2381
|
await this.mediaBridge.dispose();
|
|
@@ -2560,7 +2575,7 @@ var pe = class {
|
|
|
2560
2575
|
destination: e.destination
|
|
2561
2576
|
})),
|
|
2562
2577
|
permission: this.support?.hasMediaDevices === !1 ? "unsupported" : "unknown",
|
|
2563
|
-
ice:
|
|
2578
|
+
ice: ye(e),
|
|
2564
2579
|
wss: {
|
|
2565
2580
|
configured: e !== void 0,
|
|
2566
2581
|
secure: e?.transport.wssUrl.toLowerCase().startsWith("wss://") ?? !1,
|
|
@@ -2677,7 +2692,7 @@ var pe = class {
|
|
|
2677
2692
|
return new e("SDK_ALREADY_DISPOSED", "internal", !1);
|
|
2678
2693
|
}
|
|
2679
2694
|
};
|
|
2680
|
-
function
|
|
2695
|
+
function ye(e) {
|
|
2681
2696
|
if (e === void 0) return {
|
|
2682
2697
|
configured: !1,
|
|
2683
2698
|
serverCount: 0,
|
|
@@ -2695,14 +2710,14 @@ function he(e) {
|
|
|
2695
2710
|
turnServerCount: n
|
|
2696
2711
|
};
|
|
2697
2712
|
}
|
|
2698
|
-
function
|
|
2713
|
+
function be(e) {
|
|
2699
2714
|
return e === "" ? "unknown" : /iPhone|iPad|Android/i.test(e) ? "mobile-web" : "web";
|
|
2700
2715
|
}
|
|
2701
2716
|
function X(t) {
|
|
2702
2717
|
if (typeof t != "object" || !t) throw new e("CONFIG_INVALID", "configuration", !1);
|
|
2703
2718
|
return t;
|
|
2704
2719
|
}
|
|
2705
|
-
function
|
|
2720
|
+
function xe(t) {
|
|
2706
2721
|
let r = {
|
|
2707
2722
|
createSession: (e) => t.createSession(e),
|
|
2708
2723
|
refreshSession: (e) => t.refreshSession === void 0 ? t.createSession({
|
|
@@ -2716,7 +2731,7 @@ function _e(t) {
|
|
|
2716
2731
|
}, i = t.invalidateToken;
|
|
2717
2732
|
return i !== void 0 && (r.invalidateToken = () => i()), r;
|
|
2718
2733
|
}
|
|
2719
|
-
function
|
|
2734
|
+
function Se(t) {
|
|
2720
2735
|
if (typeof t != "object" || !t) throw new e("CONFIG_INVALID", "configuration", !1);
|
|
2721
2736
|
return t;
|
|
2722
2737
|
}
|
|
@@ -2735,13 +2750,13 @@ function Z(t, n, r, i, a) {
|
|
|
2735
2750
|
function Q(t) {
|
|
2736
2751
|
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;
|
|
2737
2752
|
}
|
|
2738
|
-
function
|
|
2753
|
+
function Ce(t) {
|
|
2739
2754
|
return t instanceof e && t.code === "SDK_ALREADY_DISPOSED";
|
|
2740
2755
|
}
|
|
2741
2756
|
function $(t) {
|
|
2742
2757
|
return t instanceof e && (t.code === "SDK_ALREADY_DISPOSED" || t.code === "CALL_NOT_CONNECTED");
|
|
2743
2758
|
}
|
|
2744
|
-
var
|
|
2759
|
+
var we = [
|
|
2745
2760
|
"outbound",
|
|
2746
2761
|
"inbound",
|
|
2747
2762
|
"mute",
|
|
@@ -2749,13 +2764,13 @@ var be = [
|
|
|
2749
2764
|
"dtmf",
|
|
2750
2765
|
"blind_transfer",
|
|
2751
2766
|
"device_selection"
|
|
2752
|
-
],
|
|
2767
|
+
], Te = [
|
|
2753
2768
|
"outbound",
|
|
2754
2769
|
"mute",
|
|
2755
2770
|
"dtmf"
|
|
2756
2771
|
];
|
|
2757
|
-
function
|
|
2758
|
-
return e === "mobile-web" ?
|
|
2772
|
+
function Ee(e) {
|
|
2773
|
+
return e === "mobile-web" ? Te : we;
|
|
2759
2774
|
}
|
|
2760
2775
|
//#endregion
|
|
2761
|
-
export {
|
|
2776
|
+
export { h as a, c, l as d, a as f, x as i, s as l, C as n, p as o, i as p, w as r, d as s, ve as t, o as u };
|