@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.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import md5 from "blueimp-md5";
|
|
|
3
3
|
|
|
4
4
|
// package/axios.ts
|
|
5
5
|
import axios from "axios";
|
|
6
|
-
import axiosRetry from "axios-retry";
|
|
7
6
|
var instance = axios.create({
|
|
8
7
|
headers: {
|
|
9
8
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -14,23 +13,6 @@ instance.interceptors.response.use(
|
|
|
14
13
|
(response) => response.data,
|
|
15
14
|
(error) => Promise.reject(error)
|
|
16
15
|
);
|
|
17
|
-
axiosRetry(instance, {
|
|
18
|
-
retries: 3,
|
|
19
|
-
// Maximum number of retries, default is 3
|
|
20
|
-
retryDelay: (retryCount, error) => {
|
|
21
|
-
console.log(
|
|
22
|
-
`AJAX Retrying attempt ${retryCount}, error: ${error?.message}`
|
|
23
|
-
);
|
|
24
|
-
return retryCount * 1e3;
|
|
25
|
-
},
|
|
26
|
-
retryCondition: (error) => {
|
|
27
|
-
if (!error.response)
|
|
28
|
-
return true;
|
|
29
|
-
return error.response.status < 200 || error.response.status >= 300;
|
|
30
|
-
},
|
|
31
|
-
shouldResetTimeout: true
|
|
32
|
-
// Whether to reset axios timeout on retry
|
|
33
|
-
});
|
|
34
16
|
var request = (config) => instance.request(config);
|
|
35
17
|
var axios_default = request;
|
|
36
18
|
|
|
@@ -858,7 +840,7 @@ var Connect = class {
|
|
|
858
840
|
/**
|
|
859
841
|
* Whether registered
|
|
860
842
|
*/
|
|
861
|
-
|
|
843
|
+
isRegister = false;
|
|
862
844
|
constructor(callKit) {
|
|
863
845
|
this.callKit = callKit;
|
|
864
846
|
const { reconnect = {} } = this.callKit.config.getConfig();
|
|
@@ -898,6 +880,7 @@ var Connect = class {
|
|
|
898
880
|
});
|
|
899
881
|
}
|
|
900
882
|
}
|
|
883
|
+
this.callKit.config.reset();
|
|
901
884
|
this.setConnectStatus(CallStatus.init);
|
|
902
885
|
this.clearObserveOptionsHeartbeatInterval();
|
|
903
886
|
}
|
|
@@ -940,11 +923,23 @@ var Connect = class {
|
|
|
940
923
|
return this.connectStatus === CallStatus.ringing;
|
|
941
924
|
}
|
|
942
925
|
/**
|
|
943
|
-
*
|
|
926
|
+
* isHolding
|
|
944
927
|
*/
|
|
945
928
|
isHolding() {
|
|
946
929
|
return this.connectStatus === CallStatus.holding;
|
|
947
930
|
}
|
|
931
|
+
/**
|
|
932
|
+
* isRegistered
|
|
933
|
+
*/
|
|
934
|
+
isRegistered() {
|
|
935
|
+
return this.isRegister;
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* isMute
|
|
939
|
+
*/
|
|
940
|
+
isMuted() {
|
|
941
|
+
return this.isMute;
|
|
942
|
+
}
|
|
948
943
|
/**
|
|
949
944
|
* Call ended, call not started
|
|
950
945
|
* @returns
|
|
@@ -973,7 +968,7 @@ var Connect = class {
|
|
|
973
968
|
}
|
|
974
969
|
async register() {
|
|
975
970
|
if (this.connectStatus !== CallStatus.init) {
|
|
976
|
-
if (this.isRegistered) {
|
|
971
|
+
if (this.isRegistered()) {
|
|
977
972
|
this.callKit.logger.warn("connectStatus is registered", {
|
|
978
973
|
caller: "Connect.register",
|
|
979
974
|
content: {
|
|
@@ -1109,14 +1104,14 @@ var Connect = class {
|
|
|
1109
1104
|
type: "SIP",
|
|
1110
1105
|
content: {
|
|
1111
1106
|
registererState: state,
|
|
1112
|
-
isRegistered: this.isRegistered
|
|
1107
|
+
isRegistered: this.isRegistered()
|
|
1113
1108
|
}
|
|
1114
1109
|
});
|
|
1115
1110
|
this.setRegister(false);
|
|
1116
1111
|
this.setConnectStatus(CallStatus.init);
|
|
1117
1112
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
1118
1113
|
registererState: state,
|
|
1119
|
-
isRegistered: this.isRegistered
|
|
1114
|
+
isRegistered: this.isRegistered()
|
|
1120
1115
|
});
|
|
1121
1116
|
break;
|
|
1122
1117
|
case RegistererState.Registered:
|
|
@@ -1125,13 +1120,13 @@ var Connect = class {
|
|
|
1125
1120
|
type: "SIP",
|
|
1126
1121
|
content: {
|
|
1127
1122
|
registererState: state,
|
|
1128
|
-
isRegistered: this.isRegistered
|
|
1123
|
+
isRegistered: this.isRegistered()
|
|
1129
1124
|
}
|
|
1130
1125
|
});
|
|
1131
1126
|
this.setRegister(true);
|
|
1132
1127
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
1133
1128
|
registererState: state,
|
|
1134
|
-
isRegistered: this.isRegistered
|
|
1129
|
+
isRegistered: this.isRegistered()
|
|
1135
1130
|
});
|
|
1136
1131
|
break;
|
|
1137
1132
|
case RegistererState.Terminated:
|
|
@@ -1140,13 +1135,13 @@ var Connect = class {
|
|
|
1140
1135
|
type: "SIP",
|
|
1141
1136
|
content: {
|
|
1142
1137
|
registererState: state,
|
|
1143
|
-
isRegistered: this.isRegistered
|
|
1138
|
+
isRegistered: this.isRegistered()
|
|
1144
1139
|
}
|
|
1145
1140
|
});
|
|
1146
1141
|
this.setRegister(false);
|
|
1147
1142
|
this.setConnectStatus(CallStatus.init);
|
|
1148
1143
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
1149
|
-
isRegistered: this.isRegistered,
|
|
1144
|
+
isRegistered: this.isRegistered(),
|
|
1150
1145
|
registererState: state
|
|
1151
1146
|
});
|
|
1152
1147
|
break;
|
|
@@ -1155,14 +1150,14 @@ var Connect = class {
|
|
|
1155
1150
|
caller: "Connect.register.registererStateChange",
|
|
1156
1151
|
type: "SIP",
|
|
1157
1152
|
content: {
|
|
1158
|
-
isRegistered: this.isRegistered,
|
|
1153
|
+
isRegistered: this.isRegistered(),
|
|
1159
1154
|
registererState: state
|
|
1160
1155
|
}
|
|
1161
1156
|
});
|
|
1162
1157
|
this.setRegister(false);
|
|
1163
1158
|
this.setConnectStatus(CallStatus.init);
|
|
1164
1159
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
1165
|
-
isRegistered: this.isRegistered,
|
|
1160
|
+
isRegistered: this.isRegistered(),
|
|
1166
1161
|
registererState: state
|
|
1167
1162
|
});
|
|
1168
1163
|
break;
|
|
@@ -1177,7 +1172,7 @@ var Connect = class {
|
|
|
1177
1172
|
caller: "Connect.register.onInvite",
|
|
1178
1173
|
content: {
|
|
1179
1174
|
invite,
|
|
1180
|
-
isRegistered: this.isRegistered
|
|
1175
|
+
isRegistered: this.isRegistered()
|
|
1181
1176
|
}
|
|
1182
1177
|
});
|
|
1183
1178
|
this.currentSession = invite;
|
|
@@ -1197,7 +1192,7 @@ var Connect = class {
|
|
|
1197
1192
|
this.setConnectStatus(CallStatus.ringing);
|
|
1198
1193
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
1199
1194
|
sessionState: state,
|
|
1200
|
-
isRegistered: this.isRegistered
|
|
1195
|
+
isRegistered: this.isRegistered()
|
|
1201
1196
|
});
|
|
1202
1197
|
break;
|
|
1203
1198
|
case SessionState.Established:
|
|
@@ -1211,14 +1206,14 @@ var Connect = class {
|
|
|
1211
1206
|
this.callKit.connect.setConnectStatus(CallStatus.calling);
|
|
1212
1207
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
1213
1208
|
sessionState: state,
|
|
1214
|
-
isRegistered: this.isRegistered
|
|
1209
|
+
isRegistered: this.isRegistered()
|
|
1215
1210
|
});
|
|
1216
1211
|
setupRemoteMedia(this.currentSession);
|
|
1217
1212
|
break;
|
|
1218
1213
|
case SessionState.Terminating:
|
|
1219
1214
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
1220
1215
|
sessionState: state,
|
|
1221
|
-
isRegistered: this.isRegistered
|
|
1216
|
+
isRegistered: this.isRegistered()
|
|
1222
1217
|
});
|
|
1223
1218
|
break;
|
|
1224
1219
|
case SessionState.Terminated:
|
|
@@ -1239,7 +1234,7 @@ var Connect = class {
|
|
|
1239
1234
|
this.isUnprompted = false;
|
|
1240
1235
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
1241
1236
|
sessionState: state,
|
|
1242
|
-
isRegistered: this.isRegistered
|
|
1237
|
+
isRegistered: this.isRegistered()
|
|
1243
1238
|
});
|
|
1244
1239
|
break;
|
|
1245
1240
|
default:
|
|
@@ -1426,11 +1421,10 @@ var Connect = class {
|
|
|
1426
1421
|
caller: "Connect.unregister",
|
|
1427
1422
|
type: "SIP",
|
|
1428
1423
|
content: {
|
|
1429
|
-
isRegistered: this.isRegistered
|
|
1430
|
-
registerer: this.registerer
|
|
1424
|
+
isRegistered: this.isRegistered()
|
|
1431
1425
|
}
|
|
1432
1426
|
});
|
|
1433
|
-
if (!this.isRegistered || !this.registerer) {
|
|
1427
|
+
if (!this.isRegistered() || !this.registerer) {
|
|
1434
1428
|
this.callKit.logger.warn("No registerer to unregister.", {
|
|
1435
1429
|
caller: "Connect.unregister",
|
|
1436
1430
|
type: "SIP",
|
|
@@ -1460,7 +1454,7 @@ var Connect = class {
|
|
|
1460
1454
|
}
|
|
1461
1455
|
});
|
|
1462
1456
|
this.isOutgoing = true;
|
|
1463
|
-
if (!this.isRegistered) {
|
|
1457
|
+
if (!this.isRegistered()) {
|
|
1464
1458
|
await this.register();
|
|
1465
1459
|
}
|
|
1466
1460
|
this.setConnectStatus(CallStatus.connecting);
|
|
@@ -1480,7 +1474,7 @@ var Connect = class {
|
|
|
1480
1474
|
register
|
|
1481
1475
|
}
|
|
1482
1476
|
});
|
|
1483
|
-
this.
|
|
1477
|
+
this.isRegister = register;
|
|
1484
1478
|
this.callKit.trigger(KitEvent.KIT_REGISTER_CHANGE, register);
|
|
1485
1479
|
}
|
|
1486
1480
|
/**
|
|
@@ -2042,7 +2036,6 @@ var Socket = class {
|
|
|
2042
2036
|
errCode: ErrorCode.SOCKET_CONNECT_ERROR
|
|
2043
2037
|
}
|
|
2044
2038
|
});
|
|
2045
|
-
this.callKit.config.reset();
|
|
2046
2039
|
this.callKit.reset();
|
|
2047
2040
|
return;
|
|
2048
2041
|
}
|
|
@@ -2149,7 +2142,7 @@ var Socket = class {
|
|
|
2149
2142
|
* 重置 socket 连接和所有状态
|
|
2150
2143
|
* @param isWaitConfirm Whether need to wait for close confirmation
|
|
2151
2144
|
*/
|
|
2152
|
-
async reset(
|
|
2145
|
+
async reset() {
|
|
2153
2146
|
if (this.pingTimer) {
|
|
2154
2147
|
clearInterval(this.pingTimer);
|
|
2155
2148
|
this.pingTimer = void 0;
|
|
@@ -2161,9 +2154,7 @@ var Socket = class {
|
|
|
2161
2154
|
this.callKit.logger.info("Closing socket connection", {
|
|
2162
2155
|
caller: "Socket.reset",
|
|
2163
2156
|
type: "INCALL",
|
|
2164
|
-
content: {
|
|
2165
|
-
isWaitConfirm
|
|
2166
|
-
}
|
|
2157
|
+
content: {}
|
|
2167
2158
|
});
|
|
2168
2159
|
this.ws.close();
|
|
2169
2160
|
this.isConnected = false;
|
|
@@ -2335,8 +2326,8 @@ var CallKit = class {
|
|
|
2335
2326
|
}
|
|
2336
2327
|
}
|
|
2337
2328
|
await this.hangup();
|
|
2338
|
-
this.socket.reset(false);
|
|
2339
2329
|
this.connect.reset();
|
|
2330
|
+
this.socket.reset();
|
|
2340
2331
|
this.config.reset();
|
|
2341
2332
|
this.trigger(KitEvent.KIT_LOGIN_CHANGE, false);
|
|
2342
2333
|
}
|
|
@@ -2452,9 +2443,9 @@ var CallKit = class {
|
|
|
2452
2443
|
* set userstatus
|
|
2453
2444
|
* @param status
|
|
2454
2445
|
*/
|
|
2455
|
-
setUserStatus(status) {
|
|
2446
|
+
async setUserStatus(status) {
|
|
2456
2447
|
const { agentId } = this.config.getConfig().userInfo;
|
|
2457
|
-
this.api.updateUserStatus({
|
|
2448
|
+
await this.api.updateUserStatus({
|
|
2458
2449
|
agentId,
|
|
2459
2450
|
status
|
|
2460
2451
|
});
|