@koi-design/callkit 2.0.0-beta.1 → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +12 -4
- package/dist/index.global.js +50 -282
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +38 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -36,7 +36,6 @@ var import_blueimp_md5 = __toESM(require("blueimp-md5"));
|
|
|
36
36
|
|
|
37
37
|
// package/axios.ts
|
|
38
38
|
var import_axios = __toESM(require("axios"));
|
|
39
|
-
var import_axios_retry = __toESM(require("axios-retry"));
|
|
40
39
|
var instance = import_axios.default.create({
|
|
41
40
|
headers: {
|
|
42
41
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -47,23 +46,6 @@ instance.interceptors.response.use(
|
|
|
47
46
|
(response) => response.data,
|
|
48
47
|
(error) => Promise.reject(error)
|
|
49
48
|
);
|
|
50
|
-
(0, import_axios_retry.default)(instance, {
|
|
51
|
-
retries: 3,
|
|
52
|
-
// Maximum number of retries, default is 3
|
|
53
|
-
retryDelay: (retryCount, error) => {
|
|
54
|
-
console.log(
|
|
55
|
-
`AJAX Retrying attempt ${retryCount}, error: ${error?.message}`
|
|
56
|
-
);
|
|
57
|
-
return retryCount * 1e3;
|
|
58
|
-
},
|
|
59
|
-
retryCondition: (error) => {
|
|
60
|
-
if (!error.response)
|
|
61
|
-
return true;
|
|
62
|
-
return error.response.status < 200 || error.response.status >= 300;
|
|
63
|
-
},
|
|
64
|
-
shouldResetTimeout: true
|
|
65
|
-
// Whether to reset axios timeout on retry
|
|
66
|
-
});
|
|
67
49
|
var request = (config) => instance.request(config);
|
|
68
50
|
var axios_default = request;
|
|
69
51
|
|
|
@@ -885,7 +867,7 @@ var Connect = class {
|
|
|
885
867
|
/**
|
|
886
868
|
* Whether registered
|
|
887
869
|
*/
|
|
888
|
-
|
|
870
|
+
isRegister = false;
|
|
889
871
|
constructor(callKit) {
|
|
890
872
|
this.callKit = callKit;
|
|
891
873
|
const { reconnect = {} } = this.callKit.config.getConfig();
|
|
@@ -925,6 +907,7 @@ var Connect = class {
|
|
|
925
907
|
});
|
|
926
908
|
}
|
|
927
909
|
}
|
|
910
|
+
this.callKit.config.reset();
|
|
928
911
|
this.setConnectStatus(CallStatus.init);
|
|
929
912
|
this.clearObserveOptionsHeartbeatInterval();
|
|
930
913
|
}
|
|
@@ -967,11 +950,23 @@ var Connect = class {
|
|
|
967
950
|
return this.connectStatus === CallStatus.ringing;
|
|
968
951
|
}
|
|
969
952
|
/**
|
|
970
|
-
*
|
|
953
|
+
* isHolding
|
|
971
954
|
*/
|
|
972
955
|
isHolding() {
|
|
973
956
|
return this.connectStatus === CallStatus.holding;
|
|
974
957
|
}
|
|
958
|
+
/**
|
|
959
|
+
* isRegistered
|
|
960
|
+
*/
|
|
961
|
+
isRegistered() {
|
|
962
|
+
return this.isRegister;
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* isMute
|
|
966
|
+
*/
|
|
967
|
+
isMuted() {
|
|
968
|
+
return this.isMute;
|
|
969
|
+
}
|
|
975
970
|
/**
|
|
976
971
|
* Call ended, call not started
|
|
977
972
|
* @returns
|
|
@@ -1000,7 +995,7 @@ var Connect = class {
|
|
|
1000
995
|
}
|
|
1001
996
|
async register() {
|
|
1002
997
|
if (this.connectStatus !== CallStatus.init) {
|
|
1003
|
-
if (this.isRegistered) {
|
|
998
|
+
if (this.isRegistered()) {
|
|
1004
999
|
this.callKit.logger.warn("connectStatus is registered", {
|
|
1005
1000
|
caller: "Connect.register",
|
|
1006
1001
|
content: {
|
|
@@ -1136,14 +1131,14 @@ var Connect = class {
|
|
|
1136
1131
|
type: "SIP",
|
|
1137
1132
|
content: {
|
|
1138
1133
|
registererState: state,
|
|
1139
|
-
isRegistered: this.isRegistered
|
|
1134
|
+
isRegistered: this.isRegistered()
|
|
1140
1135
|
}
|
|
1141
1136
|
});
|
|
1142
1137
|
this.setRegister(false);
|
|
1143
1138
|
this.setConnectStatus(CallStatus.init);
|
|
1144
1139
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
1145
1140
|
registererState: state,
|
|
1146
|
-
isRegistered: this.isRegistered
|
|
1141
|
+
isRegistered: this.isRegistered()
|
|
1147
1142
|
});
|
|
1148
1143
|
break;
|
|
1149
1144
|
case import_sip.RegistererState.Registered:
|
|
@@ -1152,13 +1147,13 @@ var Connect = class {
|
|
|
1152
1147
|
type: "SIP",
|
|
1153
1148
|
content: {
|
|
1154
1149
|
registererState: state,
|
|
1155
|
-
isRegistered: this.isRegistered
|
|
1150
|
+
isRegistered: this.isRegistered()
|
|
1156
1151
|
}
|
|
1157
1152
|
});
|
|
1158
1153
|
this.setRegister(true);
|
|
1159
1154
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
1160
1155
|
registererState: state,
|
|
1161
|
-
isRegistered: this.isRegistered
|
|
1156
|
+
isRegistered: this.isRegistered()
|
|
1162
1157
|
});
|
|
1163
1158
|
break;
|
|
1164
1159
|
case import_sip.RegistererState.Terminated:
|
|
@@ -1167,13 +1162,13 @@ var Connect = class {
|
|
|
1167
1162
|
type: "SIP",
|
|
1168
1163
|
content: {
|
|
1169
1164
|
registererState: state,
|
|
1170
|
-
isRegistered: this.isRegistered
|
|
1165
|
+
isRegistered: this.isRegistered()
|
|
1171
1166
|
}
|
|
1172
1167
|
});
|
|
1173
1168
|
this.setRegister(false);
|
|
1174
1169
|
this.setConnectStatus(CallStatus.init);
|
|
1175
1170
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
1176
|
-
isRegistered: this.isRegistered,
|
|
1171
|
+
isRegistered: this.isRegistered(),
|
|
1177
1172
|
registererState: state
|
|
1178
1173
|
});
|
|
1179
1174
|
break;
|
|
@@ -1182,14 +1177,14 @@ var Connect = class {
|
|
|
1182
1177
|
caller: "Connect.register.registererStateChange",
|
|
1183
1178
|
type: "SIP",
|
|
1184
1179
|
content: {
|
|
1185
|
-
isRegistered: this.isRegistered,
|
|
1180
|
+
isRegistered: this.isRegistered(),
|
|
1186
1181
|
registererState: state
|
|
1187
1182
|
}
|
|
1188
1183
|
});
|
|
1189
1184
|
this.setRegister(false);
|
|
1190
1185
|
this.setConnectStatus(CallStatus.init);
|
|
1191
1186
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
1192
|
-
isRegistered: this.isRegistered,
|
|
1187
|
+
isRegistered: this.isRegistered(),
|
|
1193
1188
|
registererState: state
|
|
1194
1189
|
});
|
|
1195
1190
|
break;
|
|
@@ -1204,7 +1199,7 @@ var Connect = class {
|
|
|
1204
1199
|
caller: "Connect.register.onInvite",
|
|
1205
1200
|
content: {
|
|
1206
1201
|
invite,
|
|
1207
|
-
isRegistered: this.isRegistered
|
|
1202
|
+
isRegistered: this.isRegistered()
|
|
1208
1203
|
}
|
|
1209
1204
|
});
|
|
1210
1205
|
this.currentSession = invite;
|
|
@@ -1224,7 +1219,7 @@ var Connect = class {
|
|
|
1224
1219
|
this.setConnectStatus(CallStatus.ringing);
|
|
1225
1220
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
1226
1221
|
sessionState: state,
|
|
1227
|
-
isRegistered: this.isRegistered
|
|
1222
|
+
isRegistered: this.isRegistered()
|
|
1228
1223
|
});
|
|
1229
1224
|
break;
|
|
1230
1225
|
case import_sip.SessionState.Established:
|
|
@@ -1238,14 +1233,14 @@ var Connect = class {
|
|
|
1238
1233
|
this.callKit.connect.setConnectStatus(CallStatus.calling);
|
|
1239
1234
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
1240
1235
|
sessionState: state,
|
|
1241
|
-
isRegistered: this.isRegistered
|
|
1236
|
+
isRegistered: this.isRegistered()
|
|
1242
1237
|
});
|
|
1243
1238
|
setupRemoteMedia(this.currentSession);
|
|
1244
1239
|
break;
|
|
1245
1240
|
case import_sip.SessionState.Terminating:
|
|
1246
1241
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
1247
1242
|
sessionState: state,
|
|
1248
|
-
isRegistered: this.isRegistered
|
|
1243
|
+
isRegistered: this.isRegistered()
|
|
1249
1244
|
});
|
|
1250
1245
|
break;
|
|
1251
1246
|
case import_sip.SessionState.Terminated:
|
|
@@ -1266,7 +1261,7 @@ var Connect = class {
|
|
|
1266
1261
|
this.isUnprompted = false;
|
|
1267
1262
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
1268
1263
|
sessionState: state,
|
|
1269
|
-
isRegistered: this.isRegistered
|
|
1264
|
+
isRegistered: this.isRegistered()
|
|
1270
1265
|
});
|
|
1271
1266
|
break;
|
|
1272
1267
|
default:
|
|
@@ -1453,11 +1448,10 @@ var Connect = class {
|
|
|
1453
1448
|
caller: "Connect.unregister",
|
|
1454
1449
|
type: "SIP",
|
|
1455
1450
|
content: {
|
|
1456
|
-
isRegistered: this.isRegistered
|
|
1457
|
-
registerer: this.registerer
|
|
1451
|
+
isRegistered: this.isRegistered()
|
|
1458
1452
|
}
|
|
1459
1453
|
});
|
|
1460
|
-
if (!this.isRegistered || !this.registerer) {
|
|
1454
|
+
if (!this.isRegistered() || !this.registerer) {
|
|
1461
1455
|
this.callKit.logger.warn("No registerer to unregister.", {
|
|
1462
1456
|
caller: "Connect.unregister",
|
|
1463
1457
|
type: "SIP",
|
|
@@ -1487,7 +1481,7 @@ var Connect = class {
|
|
|
1487
1481
|
}
|
|
1488
1482
|
});
|
|
1489
1483
|
this.isOutgoing = true;
|
|
1490
|
-
if (!this.isRegistered) {
|
|
1484
|
+
if (!this.isRegistered()) {
|
|
1491
1485
|
await this.register();
|
|
1492
1486
|
}
|
|
1493
1487
|
this.setConnectStatus(CallStatus.connecting);
|
|
@@ -1507,7 +1501,7 @@ var Connect = class {
|
|
|
1507
1501
|
register
|
|
1508
1502
|
}
|
|
1509
1503
|
});
|
|
1510
|
-
this.
|
|
1504
|
+
this.isRegister = register;
|
|
1511
1505
|
this.callKit.trigger(KitEvent.KIT_REGISTER_CHANGE, register);
|
|
1512
1506
|
}
|
|
1513
1507
|
/**
|
|
@@ -2069,7 +2063,6 @@ var Socket = class {
|
|
|
2069
2063
|
errCode: ErrorCode.SOCKET_CONNECT_ERROR
|
|
2070
2064
|
}
|
|
2071
2065
|
});
|
|
2072
|
-
this.callKit.config.reset();
|
|
2073
2066
|
this.callKit.reset();
|
|
2074
2067
|
return;
|
|
2075
2068
|
}
|
|
@@ -2176,7 +2169,7 @@ var Socket = class {
|
|
|
2176
2169
|
* 重置 socket 连接和所有状态
|
|
2177
2170
|
* @param isWaitConfirm Whether need to wait for close confirmation
|
|
2178
2171
|
*/
|
|
2179
|
-
async reset(
|
|
2172
|
+
async reset() {
|
|
2180
2173
|
if (this.pingTimer) {
|
|
2181
2174
|
clearInterval(this.pingTimer);
|
|
2182
2175
|
this.pingTimer = void 0;
|
|
@@ -2188,9 +2181,7 @@ var Socket = class {
|
|
|
2188
2181
|
this.callKit.logger.info("Closing socket connection", {
|
|
2189
2182
|
caller: "Socket.reset",
|
|
2190
2183
|
type: "INCALL",
|
|
2191
|
-
content: {
|
|
2192
|
-
isWaitConfirm
|
|
2193
|
-
}
|
|
2184
|
+
content: {}
|
|
2194
2185
|
});
|
|
2195
2186
|
this.ws.close();
|
|
2196
2187
|
this.isConnected = false;
|
|
@@ -2362,8 +2353,8 @@ var CallKit = class {
|
|
|
2362
2353
|
}
|
|
2363
2354
|
}
|
|
2364
2355
|
await this.hangup();
|
|
2365
|
-
this.socket.reset(false);
|
|
2366
2356
|
this.connect.reset();
|
|
2357
|
+
this.socket.reset();
|
|
2367
2358
|
this.config.reset();
|
|
2368
2359
|
this.trigger(KitEvent.KIT_LOGIN_CHANGE, false);
|
|
2369
2360
|
}
|
|
@@ -2479,9 +2470,9 @@ var CallKit = class {
|
|
|
2479
2470
|
* set userstatus
|
|
2480
2471
|
* @param status
|
|
2481
2472
|
*/
|
|
2482
|
-
setUserStatus(status) {
|
|
2473
|
+
async setUserStatus(status) {
|
|
2483
2474
|
const { agentId } = this.config.getConfig().userInfo;
|
|
2484
|
-
this.api.updateUserStatus({
|
|
2475
|
+
await this.api.updateUserStatus({
|
|
2485
2476
|
agentId,
|
|
2486
2477
|
status
|
|
2487
2478
|
});
|