@16x/webphone-sdk 3.1.17 → 3.1.18
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 +9 -0
- package/dist/{CCBarClient-C2sC86Xi.js → CCBarClient-5z2ZCceq.js} +121 -96
- package/dist/CCBarClient-UAJK9WcJ.cjs +1 -0
- package/dist/{Diagnostics-CK0ai_sy.cjs → Diagnostics-DhX9Uc67.cjs} +1 -1
- package/dist/{Diagnostics-B6xGNl8M.js → Diagnostics-qnipur6s.js} +1 -1
- package/dist/diagnostics/index.cjs +1 -1
- package/dist/diagnostics/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/index.umd.js +10 -10
- package/dist/legacy/index.cjs +1 -1
- package/dist/legacy/index.js +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/CCBarClient-GQ3yxDur.cjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.1.18 - 2026-10-08
|
|
4
|
+
|
|
5
|
+
修复通话失败原因被统一包装成「当前通话状态不支持此操作」的误导文案(与主线 3.2.9 同源修复):
|
|
6
|
+
|
|
7
|
+
- `CallManager.failureError` 新增 SIP 拒绝载荷映射:对方挂断/平台拒绝(480/488/4xx-6xx 家族)→ `CALL_REJECTED`("对方或呼叫平台拒绝了本次呼叫"),486/BUSY → `CALL_BUSY`,408/Request Timeout → `NETWORK_TIMEOUT`。
|
|
8
|
+
- 此前 JsSIP 原始失败载荷一律落入 `CALL_OPERATION_NOT_ALLOWED` 兜底,文案指向状态机,严重误导排障方向(实测复现:对方直接挂断显示 480、平台资源竞争返回 488 时均显示"当前通话状态不支持此操作")。原始载荷完整保留在 `error.cause`。
|
|
9
|
+
- 无 SIP 信息的未知载荷行为不变;`CALL_REJECTED`/`CALL_BUSY` 错误码自此真正被 SIP 层触发。
|
|
10
|
+
- 保持 3.1.x 客户服务端 `getToken`、`getAccount` 和会话组装契约不变。
|
|
11
|
+
|
|
3
12
|
## 3.1.17
|
|
4
13
|
|
|
5
14
|
修复平台抖动后 dial 永久不可自愈(CALL_NOT_CONNECTED)——与主线 3.2.8 同源修复:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as e, t } from "./SharedWorkerProtocol-CffZrUXg.js";
|
|
2
|
-
import { r as n, t as r } from "./Diagnostics-
|
|
2
|
+
import { r as n, t as r } from "./Diagnostics-qnipur6s.js";
|
|
3
3
|
//#region src/events/TypedEventBus.ts
|
|
4
4
|
var i = class {
|
|
5
5
|
handlers = /* @__PURE__ */ new Map();
|
|
@@ -673,7 +673,7 @@ var v = class {
|
|
|
673
673
|
reason: b(n)
|
|
674
674
|
}) : this.events.emit("call.failed", {
|
|
675
675
|
callId: e.id,
|
|
676
|
-
error:
|
|
676
|
+
error: ie(n, e.id)
|
|
677
677
|
}));
|
|
678
678
|
}
|
|
679
679
|
async switchAutomaticActiveCall(e, t, n) {
|
|
@@ -913,7 +913,22 @@ function b(e) {
|
|
|
913
913
|
let t = e.reason;
|
|
914
914
|
return typeof t == "string" && t !== "" ? t : "ended";
|
|
915
915
|
}
|
|
916
|
-
function re(
|
|
916
|
+
function re(e) {
|
|
917
|
+
if (typeof e != "object" || !e) return;
|
|
918
|
+
let { cause: t, cause_code: n, message: r } = e, i = typeof n == "number" ? n : void 0, a = typeof t == "string" ? t : void 0;
|
|
919
|
+
if (i === void 0 && typeof r == "object" && r) {
|
|
920
|
+
let e = r.data;
|
|
921
|
+
if (typeof e == "string") {
|
|
922
|
+
let t = /^SIP\/2\.0\s+(\d{3})/m.exec(e);
|
|
923
|
+
if (t) return { code: Number(t[1]) };
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
return i === void 0 && a === void 0 ? void 0 : {
|
|
927
|
+
code: i,
|
|
928
|
+
cause: a
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
function ie(t, n) {
|
|
917
932
|
if (t instanceof e) return new e(t.code, t.category, t.retryable, {
|
|
918
933
|
requestId: t.requestId,
|
|
919
934
|
callId: n,
|
|
@@ -937,15 +952,25 @@ function re(t, n) {
|
|
|
937
952
|
cause: r
|
|
938
953
|
});
|
|
939
954
|
}
|
|
940
|
-
|
|
955
|
+
let r = re(t);
|
|
956
|
+
return r === void 0 ? new e("CALL_OPERATION_NOT_ALLOWED", "call", !1, {
|
|
957
|
+
callId: n,
|
|
958
|
+
cause: t
|
|
959
|
+
}) : r.code === 486 || r.cause === "Busy" ? new e("CALL_BUSY", "call", !1, {
|
|
960
|
+
callId: n,
|
|
961
|
+
cause: t
|
|
962
|
+
}) : r.code === 408 || r.cause === "Request Timeout" ? new e("NETWORK_TIMEOUT", "call", !0, {
|
|
963
|
+
callId: n,
|
|
964
|
+
cause: t
|
|
965
|
+
}) : new e("CALL_REJECTED", "call", !1, {
|
|
941
966
|
callId: n,
|
|
942
967
|
cause: t
|
|
943
968
|
});
|
|
944
969
|
}
|
|
945
970
|
//#endregion
|
|
946
971
|
//#region src/crypto/legacySipTicket.ts
|
|
947
|
-
var
|
|
948
|
-
function
|
|
972
|
+
var ae = "q7X4p6MvK1z8Lb3A", oe = "W9e2T4mN0aQ7Ru6C", se = 16, ce = "�";
|
|
973
|
+
function le(e) {
|
|
949
974
|
for (let t of e) {
|
|
950
975
|
let e = t.codePointAt(0) ?? 0;
|
|
951
976
|
if (e === 127 || e < 32 && e !== 9) return !0;
|
|
@@ -959,32 +984,32 @@ async function x(t, n = {}) {
|
|
|
959
984
|
if (i === void 0) throw new e("CONFIG_INVALID", "configuration", !1, { cause: "需要 WebCrypto 才能解 SIP 密码:请在安全上下文(https / localhost)或 Node 18+ 里运行" });
|
|
960
985
|
let a = S(r);
|
|
961
986
|
if (a === void 0) throw new e("LEGACY_PLATFORM_REJECTED", "auth", !1, { cause: "密文不是合法的 Base64:确认取的是 password/registerPassword 原值,没有被截断或转义" });
|
|
962
|
-
let o = await i.importKey("raw", C(n.key ??
|
|
987
|
+
let o = await i.importKey("raw", C(n.key ?? ae), "AES-CBC", !1, ["decrypt"]);
|
|
963
988
|
try {
|
|
964
989
|
let e = await i.decrypt({
|
|
965
990
|
name: "AES-CBC",
|
|
966
|
-
iv: C(n.iv ??
|
|
991
|
+
iv: C(n.iv ?? oe)
|
|
967
992
|
}, o, a);
|
|
968
993
|
return new TextDecoder("utf-8").decode(e).trim();
|
|
969
994
|
} catch (t) {
|
|
970
995
|
throw new e("LEGACY_PLATFORM_REJECTED", "auth", !1, { cause: `SIP 密码解密失败(检查 key/iv 与该环境是否一致):${t instanceof Error ? t.message : String(t)}` });
|
|
971
996
|
}
|
|
972
997
|
}
|
|
973
|
-
async function
|
|
998
|
+
async function ue(e, t = {}) {
|
|
974
999
|
let n = String(e ?? "").replace(/\s+/g, "");
|
|
975
|
-
if (
|
|
1000
|
+
if (de(n)) try {
|
|
976
1001
|
let e = await x(n, t);
|
|
977
|
-
return
|
|
1002
|
+
return fe(e) ? e : void 0;
|
|
978
1003
|
} catch {
|
|
979
1004
|
return;
|
|
980
1005
|
}
|
|
981
1006
|
}
|
|
982
|
-
function
|
|
1007
|
+
function de(e) {
|
|
983
1008
|
let t = S(e);
|
|
984
|
-
return t !== void 0 && t.byteLength > 0 && t.byteLength %
|
|
1009
|
+
return t !== void 0 && t.byteLength > 0 && t.byteLength % se === 0;
|
|
985
1010
|
}
|
|
986
|
-
function
|
|
987
|
-
return e.length === 0 || e.includes(
|
|
1011
|
+
function fe(e) {
|
|
1012
|
+
return e.length === 0 || e.includes(ce) ? !1 : !le(e);
|
|
988
1013
|
}
|
|
989
1014
|
function S(e) {
|
|
990
1015
|
if (e.length !== 0 && e.length % 4 == 0 && /^[A-Za-z0-9+/]+={0,2}$/.test(e)) try {
|
|
@@ -1001,7 +1026,7 @@ function C(e) {
|
|
|
1001
1026
|
}
|
|
1002
1027
|
//#endregion
|
|
1003
1028
|
//#region src/shared/SharedWorkerClient.ts
|
|
1004
|
-
var
|
|
1029
|
+
var pe = class {
|
|
1005
1030
|
port;
|
|
1006
1031
|
timeoutMs;
|
|
1007
1032
|
pending = /* @__PURE__ */ new Map();
|
|
@@ -1038,13 +1063,13 @@ var fe = class {
|
|
|
1038
1063
|
try {
|
|
1039
1064
|
let n = t(e);
|
|
1040
1065
|
if (n.type === "event") {
|
|
1041
|
-
n.event === "connection.stateChanged" &&
|
|
1066
|
+
n.event === "connection.stateChanged" && me(n.payload) && (this.lifecycleState = n.payload.state), this.eventHandlers.forEach((e) => e(n));
|
|
1042
1067
|
return;
|
|
1043
1068
|
}
|
|
1044
1069
|
if (n.type !== "response") return;
|
|
1045
1070
|
let r = this.pending.get(n.requestId);
|
|
1046
1071
|
if (r === void 0) return;
|
|
1047
|
-
this.pending.delete(n.requestId), clearTimeout(r.timer), n.ok ? r.resolve(n.result) : r.reject(
|
|
1072
|
+
this.pending.delete(n.requestId), clearTimeout(r.timer), n.ok ? r.resolve(n.result) : r.reject(w(n));
|
|
1048
1073
|
} catch (e) {
|
|
1049
1074
|
this.pending.forEach((t) => {
|
|
1050
1075
|
clearTimeout(t.timer), t.reject(e);
|
|
@@ -1052,10 +1077,10 @@ var fe = class {
|
|
|
1052
1077
|
}
|
|
1053
1078
|
}
|
|
1054
1079
|
};
|
|
1055
|
-
function
|
|
1080
|
+
function me(e) {
|
|
1056
1081
|
return typeof e == "object" && !!e && "state" in e && (e.state === "connected" || e.state === "reconnecting");
|
|
1057
1082
|
}
|
|
1058
|
-
function
|
|
1083
|
+
function w(t) {
|
|
1059
1084
|
let n = t.error;
|
|
1060
1085
|
return new e(n?.code ?? "SDK_INTERNAL_ERROR", n?.category ?? "internal", n?.retryable ?? !1, {
|
|
1061
1086
|
requestId: t.requestId,
|
|
@@ -1067,12 +1092,12 @@ function me(t) {
|
|
|
1067
1092
|
}
|
|
1068
1093
|
//#endregion
|
|
1069
1094
|
//#region src/shared/SharedWorkerFactory.ts
|
|
1070
|
-
function
|
|
1095
|
+
function T(t = {}) {
|
|
1071
1096
|
if ((t.enabled ?? "auto") === !1) return {
|
|
1072
1097
|
mode: "single-tab",
|
|
1073
1098
|
reason: "disabled"
|
|
1074
1099
|
};
|
|
1075
|
-
let n = t.locationHref ??
|
|
1100
|
+
let n = t.locationHref ?? D(), r = E(t.url, n), i = (n) => {
|
|
1076
1101
|
if (t.fallback === "error") throw new e("CONFIG_INVALID", "configuration", !1, { cause: n });
|
|
1077
1102
|
return {
|
|
1078
1103
|
mode: "single-tab",
|
|
@@ -1080,8 +1105,8 @@ function w(t = {}) {
|
|
|
1080
1105
|
};
|
|
1081
1106
|
};
|
|
1082
1107
|
if (r === void 0) return i("SharedWorker URL is unavailable");
|
|
1083
|
-
if (!
|
|
1084
|
-
let a = t.workerCtor ??
|
|
1108
|
+
if (!k(r, n)) return i("SharedWorker URL must be same-origin");
|
|
1109
|
+
let a = t.workerCtor ?? O();
|
|
1085
1110
|
if (a === void 0) return i("SharedWorker is not supported");
|
|
1086
1111
|
let o;
|
|
1087
1112
|
try {
|
|
@@ -1089,10 +1114,10 @@ function w(t = {}) {
|
|
|
1089
1114
|
} catch (e) {
|
|
1090
1115
|
return i(`SharedWorker construction failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
1091
1116
|
}
|
|
1092
|
-
let s = t.tabId ??
|
|
1117
|
+
let s = t.tabId ?? A(), c = new pe(o.port), l = {
|
|
1093
1118
|
version: 1,
|
|
1094
1119
|
type: "attach",
|
|
1095
|
-
requestId:
|
|
1120
|
+
requestId: j(),
|
|
1096
1121
|
tabId: s
|
|
1097
1122
|
}, u = c.request(l).then(() => void 0).catch((e) => {
|
|
1098
1123
|
throw c.close(), e;
|
|
@@ -1106,20 +1131,20 @@ function w(t = {}) {
|
|
|
1106
1131
|
ready: u
|
|
1107
1132
|
};
|
|
1108
1133
|
}
|
|
1109
|
-
function
|
|
1134
|
+
function E(e, t = D()) {
|
|
1110
1135
|
try {
|
|
1111
1136
|
return t === void 0 ? void 0 : new URL(e ?? "./shared-worker.js", t).toString();
|
|
1112
1137
|
} catch {
|
|
1113
1138
|
return;
|
|
1114
1139
|
}
|
|
1115
1140
|
}
|
|
1116
|
-
function
|
|
1141
|
+
function D() {
|
|
1117
1142
|
return typeof location > "u" ? void 0 : location.href;
|
|
1118
1143
|
}
|
|
1119
|
-
function
|
|
1144
|
+
function O() {
|
|
1120
1145
|
if (typeof SharedWorker == "function") return SharedWorker;
|
|
1121
1146
|
}
|
|
1122
|
-
function
|
|
1147
|
+
function k(e, t) {
|
|
1123
1148
|
if (t === void 0) return !0;
|
|
1124
1149
|
try {
|
|
1125
1150
|
return new URL(e, t).origin === new URL(t).origin;
|
|
@@ -1127,15 +1152,15 @@ function O(e, t) {
|
|
|
1127
1152
|
return !1;
|
|
1128
1153
|
}
|
|
1129
1154
|
}
|
|
1130
|
-
function
|
|
1155
|
+
function A() {
|
|
1131
1156
|
return `tab-${typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).slice(2)}`;
|
|
1132
1157
|
}
|
|
1133
|
-
function
|
|
1158
|
+
function j() {
|
|
1134
1159
|
return `attach-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
1135
1160
|
}
|
|
1136
1161
|
//#endregion
|
|
1137
1162
|
//#region src/media/DeviceManager.ts
|
|
1138
|
-
var
|
|
1163
|
+
var M = class {
|
|
1139
1164
|
mediaDevices;
|
|
1140
1165
|
createAudioElement;
|
|
1141
1166
|
outputCapability;
|
|
@@ -1143,23 +1168,23 @@ var j = class {
|
|
|
1143
1168
|
outputGeneration = 0;
|
|
1144
1169
|
outputTail;
|
|
1145
1170
|
constructor(e = {}) {
|
|
1146
|
-
this.mediaDevices = e.mediaDevices === null ? void 0 : e.mediaDevices ??
|
|
1171
|
+
this.mediaDevices = e.mediaDevices === null ? void 0 : e.mediaDevices ?? N(), this.createAudioElement = e.createAudioElement;
|
|
1147
1172
|
}
|
|
1148
1173
|
async requestPermission(e = {}) {
|
|
1149
1174
|
let t = this.requireMediaDevices(), n;
|
|
1150
1175
|
try {
|
|
1151
1176
|
n = await t.getUserMedia({ audio: e });
|
|
1152
1177
|
} catch (e) {
|
|
1153
|
-
throw
|
|
1178
|
+
throw I(e);
|
|
1154
1179
|
}
|
|
1155
|
-
|
|
1180
|
+
P(n);
|
|
1156
1181
|
}
|
|
1157
1182
|
async getDevices() {
|
|
1158
1183
|
if (this.mediaDevices === void 0) return [];
|
|
1159
1184
|
try {
|
|
1160
1185
|
return (await this.mediaDevices.enumerateDevices()).filter((e) => e.kind === "audioinput" || e.kind === "audiooutput" && this.supportsOutputSelection());
|
|
1161
1186
|
} catch (e) {
|
|
1162
|
-
throw
|
|
1187
|
+
throw L(e);
|
|
1163
1188
|
}
|
|
1164
1189
|
}
|
|
1165
1190
|
getCapabilities() {
|
|
@@ -1197,7 +1222,7 @@ var j = class {
|
|
|
1197
1222
|
try {
|
|
1198
1223
|
await r.setSinkId(t);
|
|
1199
1224
|
} catch (e) {
|
|
1200
|
-
throw
|
|
1225
|
+
throw R(e);
|
|
1201
1226
|
}
|
|
1202
1227
|
}
|
|
1203
1228
|
enqueueOutput(e) {
|
|
@@ -1211,7 +1236,7 @@ var j = class {
|
|
|
1211
1236
|
try {
|
|
1212
1237
|
return await t.getUserMedia({ audio: { deviceId: { exact: e } } });
|
|
1213
1238
|
} catch (e) {
|
|
1214
|
-
throw
|
|
1239
|
+
throw F(e);
|
|
1215
1240
|
}
|
|
1216
1241
|
}
|
|
1217
1242
|
requireMediaDevices() {
|
|
@@ -1231,10 +1256,10 @@ var j = class {
|
|
|
1231
1256
|
}
|
|
1232
1257
|
}
|
|
1233
1258
|
};
|
|
1234
|
-
function
|
|
1259
|
+
function N() {
|
|
1235
1260
|
return globalThis.navigator?.mediaDevices;
|
|
1236
1261
|
}
|
|
1237
|
-
function
|
|
1262
|
+
function P(e) {
|
|
1238
1263
|
let t;
|
|
1239
1264
|
try {
|
|
1240
1265
|
t = e.getTracks();
|
|
@@ -1247,43 +1272,43 @@ function N(e) {
|
|
|
1247
1272
|
} catch {}
|
|
1248
1273
|
});
|
|
1249
1274
|
}
|
|
1250
|
-
function P(t) {
|
|
1251
|
-
let n = R(t);
|
|
1252
|
-
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 });
|
|
1253
|
-
}
|
|
1254
1275
|
function F(t) {
|
|
1255
|
-
let n =
|
|
1276
|
+
let n = z(t);
|
|
1256
1277
|
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 });
|
|
1257
1278
|
}
|
|
1258
1279
|
function I(t) {
|
|
1259
|
-
let n =
|
|
1260
|
-
return n === "NotFoundError" ? new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { cause: t }) : n === "
|
|
1280
|
+
let n = z(t);
|
|
1281
|
+
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 });
|
|
1261
1282
|
}
|
|
1262
1283
|
function L(t) {
|
|
1263
|
-
let n =
|
|
1284
|
+
let n = z(t);
|
|
1264
1285
|
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 });
|
|
1265
1286
|
}
|
|
1266
|
-
function R(
|
|
1287
|
+
function R(t) {
|
|
1288
|
+
let n = z(t);
|
|
1289
|
+
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 });
|
|
1290
|
+
}
|
|
1291
|
+
function z(e) {
|
|
1267
1292
|
if (typeof e != "object" || !e || !("name" in e)) return;
|
|
1268
1293
|
let t = e.name;
|
|
1269
1294
|
return typeof t == "string" ? t : void 0;
|
|
1270
1295
|
}
|
|
1271
1296
|
//#endregion
|
|
1272
1297
|
//#region src/media/RemoteAudio.ts
|
|
1273
|
-
var
|
|
1298
|
+
var he = class {
|
|
1274
1299
|
createAudioElement;
|
|
1275
1300
|
bindings = /* @__PURE__ */ new Map();
|
|
1276
1301
|
audioOwners = /* @__PURE__ */ new Map();
|
|
1277
1302
|
trackOwners = /* @__PURE__ */ new Map();
|
|
1278
1303
|
generations = /* @__PURE__ */ new Map();
|
|
1279
1304
|
pendingPlays = /* @__PURE__ */ new Map();
|
|
1280
|
-
constructor(e =
|
|
1305
|
+
constructor(e = ge) {
|
|
1281
1306
|
this.createAudioElement = e;
|
|
1282
1307
|
}
|
|
1283
1308
|
async bind(t, n) {
|
|
1284
1309
|
let r = this.bindings.get(t);
|
|
1285
1310
|
if (r?.stream === n) return;
|
|
1286
|
-
let i =
|
|
1311
|
+
let i = _e(t, n), a;
|
|
1287
1312
|
try {
|
|
1288
1313
|
a = this.createAudioElement();
|
|
1289
1314
|
} catch (n) {
|
|
@@ -1404,18 +1429,18 @@ var z = class {
|
|
|
1404
1429
|
return this.generations.get(e) === t && this.bindings.get(e)?.generation === t;
|
|
1405
1430
|
}
|
|
1406
1431
|
};
|
|
1407
|
-
function
|
|
1432
|
+
function ge() {
|
|
1408
1433
|
if (typeof document > "u") throw new e("CAPABILITY_NOT_SUPPORTED", "capability", !1);
|
|
1409
1434
|
return document.createElement("audio");
|
|
1410
1435
|
}
|
|
1411
|
-
function
|
|
1436
|
+
function _e(t, n) {
|
|
1412
1437
|
try {
|
|
1413
1438
|
return [...new Set(n.getAudioTracks())].filter((e) => e.kind === "audio");
|
|
1414
1439
|
} catch (r) {
|
|
1415
1440
|
try {
|
|
1416
1441
|
return [...new Set(n.getTracks())].filter((e) => e.kind === "audio");
|
|
1417
1442
|
} catch (i) {
|
|
1418
|
-
throw
|
|
1443
|
+
throw ve(n), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1419
1444
|
callId: t,
|
|
1420
1445
|
cause: r ?? i
|
|
1421
1446
|
});
|
|
@@ -1427,7 +1452,7 @@ function B(e, t) {
|
|
|
1427
1452
|
(t.get(e) ?? 0) === 0 && V(e);
|
|
1428
1453
|
});
|
|
1429
1454
|
}
|
|
1430
|
-
function
|
|
1455
|
+
function ve(e) {
|
|
1431
1456
|
try {
|
|
1432
1457
|
[...new Set(e.getTracks())].filter((e) => e.kind === "audio").forEach(V);
|
|
1433
1458
|
} catch {}
|
|
@@ -1439,7 +1464,7 @@ function V(e) {
|
|
|
1439
1464
|
}
|
|
1440
1465
|
//#endregion
|
|
1441
1466
|
//#region src/media/MediaManager.ts
|
|
1442
|
-
var
|
|
1467
|
+
var ye = class {
|
|
1443
1468
|
deviceManager;
|
|
1444
1469
|
remoteAudio;
|
|
1445
1470
|
getActiveCall;
|
|
@@ -1460,7 +1485,7 @@ var ve = class {
|
|
|
1460
1485
|
mediaDevices: e.mediaDevices,
|
|
1461
1486
|
createAudioElement: e.createAudioElement
|
|
1462
1487
|
};
|
|
1463
|
-
this.deviceManager = new
|
|
1488
|
+
this.deviceManager = new M(t), this.remoteAudio = new he(e.createAudioElement), this.getActiveCall = e.getActiveCall, this.createRemoteStream = e.createRemoteStream ?? Se;
|
|
1464
1489
|
}
|
|
1465
1490
|
requestPermission(e) {
|
|
1466
1491
|
return this.assertNotDisposed(), this.deviceManager.requestPermission(e);
|
|
@@ -1480,7 +1505,7 @@ var ve = class {
|
|
|
1480
1505
|
n !== void 0 && this.releaseResource(n).catch((e) => {
|
|
1481
1506
|
this.releaseErrors.set(n, e);
|
|
1482
1507
|
});
|
|
1483
|
-
let r =
|
|
1508
|
+
let r = be(t) ? t : { peerConnection: t }, i = {
|
|
1484
1509
|
callId: e,
|
|
1485
1510
|
peerConnection: r.peerConnection,
|
|
1486
1511
|
senders: /* @__PURE__ */ new Map(),
|
|
@@ -1667,7 +1692,7 @@ var ve = class {
|
|
|
1667
1692
|
try {
|
|
1668
1693
|
c = s.getTracks();
|
|
1669
1694
|
} catch (t) {
|
|
1670
|
-
throw
|
|
1695
|
+
throw xe(s), new e("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
1671
1696
|
callId: n.callId,
|
|
1672
1697
|
cause: t
|
|
1673
1698
|
});
|
|
@@ -1817,7 +1842,7 @@ var ve = class {
|
|
|
1817
1842
|
if (this.disposed || this.disposing) throw new e("SDK_ALREADY_DISPOSED", "internal", !1);
|
|
1818
1843
|
}
|
|
1819
1844
|
};
|
|
1820
|
-
function
|
|
1845
|
+
function be(e) {
|
|
1821
1846
|
return "peerConnection" in e;
|
|
1822
1847
|
}
|
|
1823
1848
|
function H(e) {
|
|
@@ -1839,7 +1864,7 @@ function W(e) {
|
|
|
1839
1864
|
return U(e) ? Promise.resolve() : Promise.reject(e);
|
|
1840
1865
|
}
|
|
1841
1866
|
}
|
|
1842
|
-
function
|
|
1867
|
+
function xe(e) {
|
|
1843
1868
|
try {
|
|
1844
1869
|
G(e.getTracks());
|
|
1845
1870
|
} catch {}
|
|
@@ -1852,7 +1877,7 @@ function K(e) {
|
|
|
1852
1877
|
e.stop();
|
|
1853
1878
|
} catch {}
|
|
1854
1879
|
}
|
|
1855
|
-
function
|
|
1880
|
+
function Se(e) {
|
|
1856
1881
|
if (typeof MediaStream < "u") try {
|
|
1857
1882
|
return new MediaStream([e]);
|
|
1858
1883
|
} catch {
|
|
@@ -1861,8 +1886,8 @@ function xe(e) {
|
|
|
1861
1886
|
}
|
|
1862
1887
|
//#endregion
|
|
1863
1888
|
//#region src/core/mediaBridge.ts
|
|
1864
|
-
function
|
|
1865
|
-
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
|
|
1889
|
+
function Ce(t, n = {}) {
|
|
1890
|
+
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 ye({ getActiveCall: u });
|
|
1866
1891
|
return {
|
|
1867
1892
|
publicMedia: {
|
|
1868
1893
|
requestPermission: () => (f(), d.requestPermission()),
|
|
@@ -1920,7 +1945,7 @@ function Se(t, n = {}) {
|
|
|
1920
1945
|
function p(e, t) {
|
|
1921
1946
|
if (!q(t) || typeof t.getMediaRegistration != "function") return;
|
|
1922
1947
|
let n = t.getMediaRegistration();
|
|
1923
|
-
if (
|
|
1948
|
+
if (we(n) && r.get(e)?.peerConnection !== n.peerConnection) {
|
|
1924
1949
|
r.set(e, n);
|
|
1925
1950
|
try {
|
|
1926
1951
|
d.registerCallMedia(e, n);
|
|
@@ -1933,19 +1958,19 @@ function Se(t, n = {}) {
|
|
|
1933
1958
|
function q(e) {
|
|
1934
1959
|
return typeof e == "object" && !!e;
|
|
1935
1960
|
}
|
|
1936
|
-
function
|
|
1961
|
+
function we(e) {
|
|
1937
1962
|
return typeof e == "object" && !!e && "peerConnection" in e && typeof e.peerConnection == "object" && e.peerConnection !== null;
|
|
1938
1963
|
}
|
|
1939
1964
|
//#endregion
|
|
1940
1965
|
//#region src/reconnect/backoff.ts
|
|
1941
|
-
var
|
|
1942
|
-
function
|
|
1943
|
-
let n = Math.min(
|
|
1966
|
+
var Te = 1e3, Ee = 3e4;
|
|
1967
|
+
function De(e, t = Math.random) {
|
|
1968
|
+
let n = Math.min(Ee, Te * 2 ** Math.max(0, Math.floor(e))), r = Math.min(1, Math.max(0, t()));
|
|
1944
1969
|
return Math.round(n * (1 + r * .2));
|
|
1945
1970
|
}
|
|
1946
1971
|
//#endregion
|
|
1947
1972
|
//#region src/reconnect/ReconnectManager.ts
|
|
1948
|
-
var
|
|
1973
|
+
var Oe = class {
|
|
1949
1974
|
recover;
|
|
1950
1975
|
isRecovered;
|
|
1951
1976
|
random;
|
|
@@ -1963,7 +1988,7 @@ var De = class {
|
|
|
1963
1988
|
}
|
|
1964
1989
|
start() {
|
|
1965
1990
|
if (this.disposed || !this.online || !this.isOnline() || this.pendingTimer !== void 0 || this.running) return;
|
|
1966
|
-
let e = this.generation, t =
|
|
1991
|
+
let e = this.generation, t = De(this.attempt, this.random);
|
|
1967
1992
|
this.pendingTimer = setTimeout(() => {
|
|
1968
1993
|
this.pendingTimer = void 0, this.run(e);
|
|
1969
1994
|
}, t);
|
|
@@ -2005,7 +2030,7 @@ var De = class {
|
|
|
2005
2030
|
clearPendingTimer() {
|
|
2006
2031
|
this.pendingTimer !== void 0 && (clearTimeout(this.pendingTimer), this.pendingTimer = void 0);
|
|
2007
2032
|
}
|
|
2008
|
-
},
|
|
2033
|
+
}, ke = 12e4, Ae = 5e3, je = class t {
|
|
2009
2034
|
media;
|
|
2010
2035
|
options;
|
|
2011
2036
|
api;
|
|
@@ -2044,7 +2069,7 @@ var De = class {
|
|
|
2044
2069
|
sharedWorkerSelection;
|
|
2045
2070
|
constructor(t) {
|
|
2046
2071
|
if (this.options = t, t.api === void 0 && t.sessionProvider === void 0) throw new e("CONFIG_INVALID", "configuration", !1, { cause: "CCBarClient 需要 sessionProvider" });
|
|
2047
|
-
this.api = t.api === void 0 ?
|
|
2072
|
+
this.api = t.api === void 0 ? Y(Ne(t.sessionProvider)) : Y(t.api), this.suppliedSip = t.sip === void 0 ? void 0 : Pe(t.sip), this.mediaBridge = Ce(() => this.getActiveMediaContext()), this.media = this.mediaBridge.publicMedia, this.reconnect = new Oe({
|
|
2048
2073
|
recover: () => this.recoverConnection(),
|
|
2049
2074
|
isRecovered: () => this.state === "connected",
|
|
2050
2075
|
onAttempt: (e) => {
|
|
@@ -2057,13 +2082,13 @@ var De = class {
|
|
|
2057
2082
|
}), this.sharedWorkerSelection = t.sharedWorker === void 0 ? {
|
|
2058
2083
|
mode: "single-tab",
|
|
2059
2084
|
reason: "disabled"
|
|
2060
|
-
} :
|
|
2085
|
+
} : T({
|
|
2061
2086
|
...t.sharedWorker,
|
|
2062
2087
|
...t.sharedWorkerHost ?? {}
|
|
2063
2088
|
});
|
|
2064
2089
|
}
|
|
2065
2090
|
static async checkSupport() {
|
|
2066
|
-
let e = typeof navigator < "u" && navigator.mediaDevices !== void 0, t = typeof WebSocket < "u", n =
|
|
2091
|
+
let e = typeof navigator < "u" && navigator.mediaDevices !== void 0, t = typeof WebSocket < "u", n = J(typeof navigator < "u" ? navigator.userAgent : "");
|
|
2067
2092
|
return {
|
|
2068
2093
|
supported: e && t,
|
|
2069
2094
|
platform: n,
|
|
@@ -2171,7 +2196,7 @@ var De = class {
|
|
|
2171
2196
|
sdkVersion: n,
|
|
2172
2197
|
platform: a === "mobile-web" ? "mobile_web" : "web",
|
|
2173
2198
|
...this.options.locale === void 0 ? {} : { locale: this.options.locale },
|
|
2174
|
-
requestedCapabilities: [...this.options.requestedCapabilities ??
|
|
2199
|
+
requestedCapabilities: [...this.options.requestedCapabilities ?? Re(a)]
|
|
2175
2200
|
}), this.ownedSessionIds.add(t.sessionId), this.assertGeneration(e), r = await this.getSip(), this.assertGeneration(e), this.session = t;
|
|
2176
2201
|
let o = this.callManager ?? this.createCallManager(r, t, a);
|
|
2177
2202
|
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);
|
|
@@ -2277,7 +2302,7 @@ var De = class {
|
|
|
2277
2302
|
try {
|
|
2278
2303
|
await this.media.releaseAll();
|
|
2279
2304
|
} catch (t) {
|
|
2280
|
-
|
|
2305
|
+
Fe(t) || (e ??= t);
|
|
2281
2306
|
}
|
|
2282
2307
|
try {
|
|
2283
2308
|
await this.mediaBridge.dispose();
|
|
@@ -2309,7 +2334,7 @@ var De = class {
|
|
|
2309
2334
|
}
|
|
2310
2335
|
if (e !== void 0) throw e;
|
|
2311
2336
|
}
|
|
2312
|
-
withBarrierTimeout(t, n, r =
|
|
2337
|
+
withBarrierTimeout(t, n, r = Ae) {
|
|
2313
2338
|
return new Promise((i, a) => {
|
|
2314
2339
|
let o = setTimeout(() => {
|
|
2315
2340
|
a(new e("SDK_INTERNAL_ERROR", "internal", !0, {
|
|
@@ -2448,7 +2473,7 @@ var De = class {
|
|
|
2448
2473
|
if (!(this.disposed || this.intentionalDisconnect)) {
|
|
2449
2474
|
if (this.hasNonTerminalCalls()) {
|
|
2450
2475
|
let e = Date.now();
|
|
2451
|
-
if (this.stuckCallsSince === void 0 && (this.stuckCallsSince = e), e - this.stuckCallsSince <
|
|
2476
|
+
if (this.stuckCallsSince === void 0 && (this.stuckCallsSince = e), e - this.stuckCallsSince < ke) return;
|
|
2452
2477
|
this.stuckCallsSince = void 0, await this.callManager?.forceTerminateCalls();
|
|
2453
2478
|
} else this.stuckCallsSince = void 0;
|
|
2454
2479
|
if (await this.awaitMediaReleaseBarriers(), this.session === void 0) {
|
|
@@ -2516,7 +2541,7 @@ var De = class {
|
|
|
2516
2541
|
destination: e.destination
|
|
2517
2542
|
})),
|
|
2518
2543
|
permission: this.support?.hasMediaDevices === !1 ? "unsupported" : "unknown",
|
|
2519
|
-
ice:
|
|
2544
|
+
ice: Me(e, this.sip?.iceQualitySnapshot?.()),
|
|
2520
2545
|
wss: {
|
|
2521
2546
|
configured: e !== void 0,
|
|
2522
2547
|
secure: e?.transport.wssUrl.toLowerCase().startsWith("wss://") ?? !1,
|
|
@@ -2633,7 +2658,7 @@ var De = class {
|
|
|
2633
2658
|
return new e("SDK_ALREADY_DISPOSED", "internal", !1);
|
|
2634
2659
|
}
|
|
2635
2660
|
};
|
|
2636
|
-
function
|
|
2661
|
+
function Me(e, t) {
|
|
2637
2662
|
if (e === void 0) return {
|
|
2638
2663
|
configured: !1,
|
|
2639
2664
|
serverCount: 0,
|
|
@@ -2653,17 +2678,17 @@ function je(e, t) {
|
|
|
2653
2678
|
turnServerCount: r
|
|
2654
2679
|
};
|
|
2655
2680
|
}
|
|
2656
|
-
function
|
|
2681
|
+
function J(e) {
|
|
2657
2682
|
return e === "" ? "unknown" : /iPhone|iPad|Android/i.test(e) ? "mobile-web" : "web";
|
|
2658
2683
|
}
|
|
2659
|
-
function
|
|
2684
|
+
function Y(t) {
|
|
2660
2685
|
if (typeof t != "object" || !t) throw new e("CONFIG_INVALID", "configuration", !1);
|
|
2661
2686
|
return t;
|
|
2662
2687
|
}
|
|
2663
|
-
async function
|
|
2688
|
+
async function X(e) {
|
|
2664
2689
|
let t = e.sip?.registerTicket;
|
|
2665
2690
|
if (typeof t != "string" || t === "") return e;
|
|
2666
|
-
let n = await
|
|
2691
|
+
let n = await ue(t);
|
|
2667
2692
|
return n === void 0 || n === t ? e : {
|
|
2668
2693
|
...e,
|
|
2669
2694
|
sip: {
|
|
@@ -2674,8 +2699,8 @@ async function Y(e) {
|
|
|
2674
2699
|
}
|
|
2675
2700
|
function Ne(t) {
|
|
2676
2701
|
let r = {
|
|
2677
|
-
createSession: async (e) =>
|
|
2678
|
-
refreshSession: async (e) =>
|
|
2702
|
+
createSession: async (e) => X(await t.createSession(e)),
|
|
2703
|
+
refreshSession: async (e) => X(t.refreshSession === void 0 ? await t.createSession({
|
|
2679
2704
|
sdkVersion: n,
|
|
2680
2705
|
platform: "web"
|
|
2681
2706
|
}) : await t.refreshSession(e)),
|
|
@@ -2686,7 +2711,7 @@ function Ne(t) {
|
|
|
2686
2711
|
}, i = t.invalidateToken;
|
|
2687
2712
|
return i !== void 0 && (r.invalidateToken = () => i()), r;
|
|
2688
2713
|
}
|
|
2689
|
-
function
|
|
2714
|
+
function Pe(t) {
|
|
2690
2715
|
if (typeof t != "object" || !t) throw new e("CONFIG_INVALID", "configuration", !1);
|
|
2691
2716
|
return t;
|
|
2692
2717
|
}
|
|
@@ -2706,13 +2731,13 @@ function Z(t, n, r, i, a) {
|
|
|
2706
2731
|
function Q(t) {
|
|
2707
2732
|
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" || t.code === "AUTH_TOKEN_REJECTED" : !1;
|
|
2708
2733
|
}
|
|
2709
|
-
function
|
|
2734
|
+
function Fe(t) {
|
|
2710
2735
|
return t instanceof e && t.code === "SDK_ALREADY_DISPOSED";
|
|
2711
2736
|
}
|
|
2712
2737
|
function $(t) {
|
|
2713
2738
|
return t instanceof e && (t.code === "SDK_ALREADY_DISPOSED" || t.code === "CALL_NOT_CONNECTED");
|
|
2714
2739
|
}
|
|
2715
|
-
var
|
|
2740
|
+
var Ie = [
|
|
2716
2741
|
"outbound",
|
|
2717
2742
|
"inbound",
|
|
2718
2743
|
"mute",
|
|
@@ -2720,13 +2745,13 @@ var Fe = [
|
|
|
2720
2745
|
"dtmf",
|
|
2721
2746
|
"blind_transfer",
|
|
2722
2747
|
"device_selection"
|
|
2723
|
-
],
|
|
2748
|
+
], Le = [
|
|
2724
2749
|
"outbound",
|
|
2725
2750
|
"mute",
|
|
2726
2751
|
"dtmf"
|
|
2727
2752
|
];
|
|
2728
|
-
function
|
|
2729
|
-
return e === "mobile-web" ?
|
|
2753
|
+
function Re(e) {
|
|
2754
|
+
return e === "mobile-web" ? Le : Ie;
|
|
2730
2755
|
}
|
|
2731
2756
|
//#endregion
|
|
2732
|
-
export { v as a, s as c, a as d, i as f, x as i, o as l,
|
|
2757
|
+
export { v as a, s as c, a as d, i as f, x as i, o as l, T as n, f as o, E as r, c as s, je as t, l as u };
|