@koi-design/callkit 2.0.5-beta.1 → 2.0.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -6
- package/dist/index.global.js +44 -35
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +44 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ declare class Socket {
|
|
|
74
74
|
/**
|
|
75
75
|
* @description connect auth state
|
|
76
76
|
* @default {
|
|
77
|
-
*
|
|
77
|
+
* startConfirm: false,
|
|
78
78
|
* isConnected: false,
|
|
79
79
|
* isReconnecting: false,
|
|
80
80
|
* isAuthenticated: false,
|
|
@@ -82,7 +82,7 @@ declare class Socket {
|
|
|
82
82
|
* }
|
|
83
83
|
*/
|
|
84
84
|
private connectAuthState;
|
|
85
|
-
get
|
|
85
|
+
get startConfirm(): boolean;
|
|
86
86
|
get isError(): boolean;
|
|
87
87
|
constructor(callKit: CallKit);
|
|
88
88
|
get reconnectConfig(): {
|
|
@@ -98,6 +98,7 @@ declare class Socket {
|
|
|
98
98
|
private clearWebSocket;
|
|
99
99
|
private connect;
|
|
100
100
|
private onOpen;
|
|
101
|
+
private cleanReconnectState;
|
|
101
102
|
private resetConnectState;
|
|
102
103
|
private onClose;
|
|
103
104
|
private onError;
|
|
@@ -110,7 +111,7 @@ declare class Socket {
|
|
|
110
111
|
* reset socket connection and all states
|
|
111
112
|
*/
|
|
112
113
|
reset(config?: {
|
|
113
|
-
|
|
114
|
+
force?: boolean;
|
|
114
115
|
}): Promise<void>;
|
|
115
116
|
private attemptReconnect;
|
|
116
117
|
}
|
|
@@ -558,11 +559,11 @@ declare class CallKit {
|
|
|
558
559
|
/**
|
|
559
560
|
* reset callkit
|
|
560
561
|
* @description recover the callkit to the initial state
|
|
561
|
-
* @default
|
|
562
|
-
* @param config.
|
|
562
|
+
* @default force is false
|
|
563
|
+
* @param config.force is true, the callkit reset socket connection and all states
|
|
563
564
|
*/
|
|
564
565
|
reset(config?: {
|
|
565
|
-
|
|
566
|
+
force?: boolean;
|
|
566
567
|
}): Promise<void>;
|
|
567
568
|
on(event: kitEventType, callback: (...args: any[]) => void): void;
|
|
568
569
|
off(event: kitEventType, callback?: (...args: any[]) => void): void;
|
package/dist/index.global.js
CHANGED
|
@@ -3225,6 +3225,10 @@ var WebCall = (() => {
|
|
|
3225
3225
|
isLoginOuting = false;
|
|
3226
3226
|
async login(params) {
|
|
3227
3227
|
if (this.isLogining) {
|
|
3228
|
+
this.callKit.logger.info("login is already in progress cancel", {
|
|
3229
|
+
caller: "Api.login",
|
|
3230
|
+
content: { userName: params.userName }
|
|
3231
|
+
});
|
|
3228
3232
|
return;
|
|
3229
3233
|
}
|
|
3230
3234
|
this.isLogining = true;
|
|
@@ -3234,15 +3238,17 @@ var WebCall = (() => {
|
|
|
3234
3238
|
method: "post",
|
|
3235
3239
|
data: params
|
|
3236
3240
|
});
|
|
3237
|
-
this.isLogining = false;
|
|
3238
3241
|
return res;
|
|
3239
|
-
}
|
|
3242
|
+
} finally {
|
|
3240
3243
|
this.isLogining = false;
|
|
3241
|
-
throw error;
|
|
3242
3244
|
}
|
|
3243
3245
|
}
|
|
3244
3246
|
async loginOut(params) {
|
|
3245
3247
|
if (this.isLoginOuting) {
|
|
3248
|
+
this.callKit.logger.info("loginOut is already in progress cancel", {
|
|
3249
|
+
caller: "Api.loginOut",
|
|
3250
|
+
content: { sessionId: params.sessionId }
|
|
3251
|
+
});
|
|
3246
3252
|
return;
|
|
3247
3253
|
}
|
|
3248
3254
|
this.isLoginOuting = true;
|
|
@@ -3252,11 +3258,9 @@ var WebCall = (() => {
|
|
|
3252
3258
|
method: "post",
|
|
3253
3259
|
data: params
|
|
3254
3260
|
});
|
|
3255
|
-
this.isLoginOuting = false;
|
|
3256
3261
|
return res;
|
|
3257
|
-
}
|
|
3262
|
+
} finally {
|
|
3258
3263
|
this.isLoginOuting = false;
|
|
3259
|
-
throw error;
|
|
3260
3264
|
}
|
|
3261
3265
|
}
|
|
3262
3266
|
async trackLogs(log) {
|
|
@@ -3693,14 +3697,14 @@ var WebCall = (() => {
|
|
|
3693
3697
|
this.callKit.logger.info("callStart", {
|
|
3694
3698
|
caller: "Call.callStart",
|
|
3695
3699
|
content: {
|
|
3696
|
-
startConfirm: this.callKit.socket.
|
|
3700
|
+
startConfirm: this.callKit.socket.startConfirm
|
|
3697
3701
|
}
|
|
3698
3702
|
});
|
|
3699
|
-
if (!this.callKit.socket.
|
|
3703
|
+
if (!this.callKit.socket.startConfirm) {
|
|
3700
3704
|
this.callKit.logger.warn("server not confirm start", {
|
|
3701
3705
|
caller: "Call.callStart",
|
|
3702
3706
|
content: {
|
|
3703
|
-
startConfirm: this.callKit.socket.
|
|
3707
|
+
startConfirm: this.callKit.socket.startConfirm
|
|
3704
3708
|
}
|
|
3705
3709
|
});
|
|
3706
3710
|
return;
|
|
@@ -3822,7 +3826,7 @@ var WebCall = (() => {
|
|
|
3822
3826
|
// package.json
|
|
3823
3827
|
var package_default = {
|
|
3824
3828
|
name: "@koi-design/callkit",
|
|
3825
|
-
version: "2.0.5-beta.
|
|
3829
|
+
version: "2.0.5-beta.2",
|
|
3826
3830
|
description: "callkit",
|
|
3827
3831
|
author: "koi",
|
|
3828
3832
|
license: "ISC",
|
|
@@ -19111,9 +19115,7 @@ var WebCall = (() => {
|
|
|
19111
19115
|
version: `${this.callKit.config.getConfig().version}`
|
|
19112
19116
|
}
|
|
19113
19117
|
});
|
|
19114
|
-
await this.registerer.register().
|
|
19115
|
-
this.callKit.socket.send(SocketSendEvent.START);
|
|
19116
|
-
}).catch(async (err) => {
|
|
19118
|
+
await this.registerer.register().catch(async (err) => {
|
|
19117
19119
|
this.callKit.reset();
|
|
19118
19120
|
this.callKit.logger.error(err?.message, {
|
|
19119
19121
|
caller: "Connect.register",
|
|
@@ -19512,7 +19514,7 @@ var WebCall = (() => {
|
|
|
19512
19514
|
/**
|
|
19513
19515
|
* @description connect auth state
|
|
19514
19516
|
* @default {
|
|
19515
|
-
*
|
|
19517
|
+
* startConfirm: false,
|
|
19516
19518
|
* isConnected: false,
|
|
19517
19519
|
* isReconnecting: false,
|
|
19518
19520
|
* isAuthenticated: false,
|
|
@@ -19520,14 +19522,13 @@ var WebCall = (() => {
|
|
|
19520
19522
|
* }
|
|
19521
19523
|
*/
|
|
19522
19524
|
connectAuthState = {
|
|
19523
|
-
|
|
19525
|
+
startConfirm: false,
|
|
19524
19526
|
isConnected: false,
|
|
19525
19527
|
isReconnecting: false,
|
|
19526
|
-
isAuthenticated: false,
|
|
19527
19528
|
isError: false
|
|
19528
19529
|
};
|
|
19529
|
-
get
|
|
19530
|
-
return this.connectAuthState.
|
|
19530
|
+
get startConfirm() {
|
|
19531
|
+
return this.connectAuthState.startConfirm;
|
|
19531
19532
|
}
|
|
19532
19533
|
get isError() {
|
|
19533
19534
|
return this.connectAuthState.isError;
|
|
@@ -19567,6 +19568,9 @@ var WebCall = (() => {
|
|
|
19567
19568
|
if (this.connectAuthState.isReconnecting) {
|
|
19568
19569
|
return;
|
|
19569
19570
|
}
|
|
19571
|
+
if (this.connectAuthState.isError) {
|
|
19572
|
+
return;
|
|
19573
|
+
}
|
|
19570
19574
|
this.attemptReconnect();
|
|
19571
19575
|
}
|
|
19572
19576
|
clearWebSocket() {
|
|
@@ -19606,6 +19610,7 @@ var WebCall = (() => {
|
|
|
19606
19610
|
this.setConnectAuthState("isConnected", true);
|
|
19607
19611
|
this.lastPingTime = Date.now();
|
|
19608
19612
|
this.checkPing();
|
|
19613
|
+
this.send(SocketSendEvent.START);
|
|
19609
19614
|
if (this.connectAuthState.isReconnecting) {
|
|
19610
19615
|
this.setConnectAuthState("isReconnecting", false);
|
|
19611
19616
|
this.callKit.logger.info("reconnect success", {
|
|
@@ -19621,19 +19626,23 @@ var WebCall = (() => {
|
|
|
19621
19626
|
});
|
|
19622
19627
|
}
|
|
19623
19628
|
}
|
|
19629
|
+
cleanReconnectState() {
|
|
19630
|
+
this.reconnectAttempts = 0;
|
|
19631
|
+
if (this.reconnectTimer) {
|
|
19632
|
+
clearTimeout(this.reconnectTimer);
|
|
19633
|
+
this.reconnectTimer = void 0;
|
|
19634
|
+
}
|
|
19635
|
+
this.setConnectAuthState("isReconnecting", false);
|
|
19636
|
+
this.setConnectAuthState("isError", false);
|
|
19637
|
+
}
|
|
19624
19638
|
resetConnectState() {
|
|
19625
19639
|
this.connectAuthState = {
|
|
19626
|
-
|
|
19640
|
+
startConfirm: false,
|
|
19627
19641
|
isConnected: false,
|
|
19628
19642
|
isReconnecting: false,
|
|
19629
|
-
isAuthenticated: false,
|
|
19630
19643
|
isError: false
|
|
19631
19644
|
};
|
|
19632
|
-
this.
|
|
19633
|
-
if (this.reconnectTimer) {
|
|
19634
|
-
clearTimeout(this.reconnectTimer);
|
|
19635
|
-
this.reconnectTimer = void 0;
|
|
19636
|
-
}
|
|
19645
|
+
this.cleanReconnectState();
|
|
19637
19646
|
this.callKit.logger.info("reset connect state", {
|
|
19638
19647
|
caller: "Socket.resetConnectState",
|
|
19639
19648
|
type: "INCALL",
|
|
@@ -19704,7 +19713,8 @@ var WebCall = (() => {
|
|
|
19704
19713
|
return;
|
|
19705
19714
|
}
|
|
19706
19715
|
if (data.event === SocketReceiveEvent.START_CONFIRM) {
|
|
19707
|
-
this.setConnectAuthState("
|
|
19716
|
+
this.setConnectAuthState("startConfirm", true);
|
|
19717
|
+
this.cleanReconnectState();
|
|
19708
19718
|
}
|
|
19709
19719
|
if (data.event === SocketReceiveEvent.CUSTOMER_RINGING) {
|
|
19710
19720
|
this.callKit.trigger(KitEvent.CALL_RINGING, /* @__PURE__ */ new Date());
|
|
@@ -19859,20 +19869,19 @@ var WebCall = (() => {
|
|
|
19859
19869
|
* reset socket connection and all states
|
|
19860
19870
|
*/
|
|
19861
19871
|
async reset(config) {
|
|
19862
|
-
const {
|
|
19872
|
+
const { force = false } = config || {};
|
|
19863
19873
|
if (this.pingTimer) {
|
|
19864
19874
|
clearInterval(this.pingTimer);
|
|
19865
19875
|
this.pingTimer = void 0;
|
|
19866
19876
|
}
|
|
19867
|
-
if (
|
|
19877
|
+
if (force) {
|
|
19868
19878
|
this.callKit.trigger(KitEvent.INCALL_CONNECT_EVENT, {
|
|
19869
19879
|
event: "INCALL_RESET"
|
|
19870
19880
|
});
|
|
19871
19881
|
this.resetConnectState();
|
|
19872
|
-
this.setConnectAuthState("isConnected", false);
|
|
19873
19882
|
}
|
|
19874
19883
|
this.lastPingTime = void 0;
|
|
19875
|
-
this.setConnectAuthState("
|
|
19884
|
+
this.setConnectAuthState("startConfirm", false);
|
|
19876
19885
|
this.clearWebSocket();
|
|
19877
19886
|
}
|
|
19878
19887
|
attemptReconnect() {
|
|
@@ -20223,16 +20232,16 @@ var WebCall = (() => {
|
|
|
20223
20232
|
/**
|
|
20224
20233
|
* reset callkit
|
|
20225
20234
|
* @description recover the callkit to the initial state
|
|
20226
|
-
* @default
|
|
20227
|
-
* @param config.
|
|
20235
|
+
* @default force is false
|
|
20236
|
+
* @param config.force is true, the callkit reset socket connection and all states
|
|
20228
20237
|
*/
|
|
20229
20238
|
async reset(config) {
|
|
20230
|
-
const {
|
|
20239
|
+
const { force = false } = config || {};
|
|
20231
20240
|
this.logger.info("reset", {
|
|
20232
20241
|
caller: "CallKit.reset",
|
|
20233
20242
|
content: {
|
|
20234
20243
|
connectStatus: this.connect.connectStatus,
|
|
20235
|
-
|
|
20244
|
+
force
|
|
20236
20245
|
}
|
|
20237
20246
|
});
|
|
20238
20247
|
if (this.connect.isCalling()) {
|
|
@@ -20244,7 +20253,7 @@ var WebCall = (() => {
|
|
|
20244
20253
|
} else {
|
|
20245
20254
|
await this.config.reset();
|
|
20246
20255
|
}
|
|
20247
|
-
await this.socket.reset({
|
|
20256
|
+
await this.socket.reset({ force });
|
|
20248
20257
|
}
|
|
20249
20258
|
on(event, callback) {
|
|
20250
20259
|
this.listener.push({
|