@koi-design/callkit 2.0.6-beta.1 → 2.1.0-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/README.md +2 -2
- package/dist/index.d.ts +103 -83
- package/dist/index.global.js +392 -283
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +392 -283
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +393 -285
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -156
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ This package requires the following peer dependencies:
|
|
|
35
35
|
<script>
|
|
36
36
|
const callKit = new WebCall.CallKit({
|
|
37
37
|
host: 'https://example.com',
|
|
38
|
-
log: '
|
|
38
|
+
log: 'debug',
|
|
39
39
|
audioRef: () => document.querySelector('#audioRef'),
|
|
40
40
|
socket: 'wss://example.com/ws/in-call'
|
|
41
41
|
});
|
|
@@ -49,7 +49,7 @@ import { CallKit } from '@koi-design/callkit';
|
|
|
49
49
|
|
|
50
50
|
const callKit = new CallKit({
|
|
51
51
|
host: 'https://example.com',
|
|
52
|
-
log: '
|
|
52
|
+
log: 'debug',
|
|
53
53
|
audioRef: () => document.querySelector('#audioRef'),
|
|
54
54
|
socket: 'wss://example.com/ws/in-call'
|
|
55
55
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -8,11 +8,13 @@ declare class Api {
|
|
|
8
8
|
login(params: {
|
|
9
9
|
userName: string;
|
|
10
10
|
password: string;
|
|
11
|
+
timestamp: number;
|
|
11
12
|
}): Promise<any>;
|
|
12
13
|
loginOut(params: {
|
|
13
14
|
sessionId: string;
|
|
15
|
+
timestamp: number;
|
|
14
16
|
}): Promise<any>;
|
|
15
|
-
trackLogs(log: string): Promise<
|
|
17
|
+
trackLogs(log: string): Promise<void>;
|
|
16
18
|
/**
|
|
17
19
|
*
|
|
18
20
|
* @param params agentId status
|
|
@@ -50,6 +52,72 @@ declare class Logger {
|
|
|
50
52
|
private catchLog;
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
type SocketSendEventType = (typeof SocketSendEvent)[keyof typeof SocketSendEvent];
|
|
56
|
+
interface SocketConfig {
|
|
57
|
+
enabled: boolean;
|
|
58
|
+
maxAttempts: number;
|
|
59
|
+
delay: number;
|
|
60
|
+
pingInterval: number;
|
|
61
|
+
pingTimeout: number;
|
|
62
|
+
}
|
|
63
|
+
declare class Socket {
|
|
64
|
+
private callKit;
|
|
65
|
+
private ws?;
|
|
66
|
+
lastPingTime: any;
|
|
67
|
+
pingTimer?: ReturnType<typeof setInterval>;
|
|
68
|
+
/**
|
|
69
|
+
* @description reconnect timer
|
|
70
|
+
*/
|
|
71
|
+
private reconnectTimer?;
|
|
72
|
+
/**
|
|
73
|
+
* @description reconnect attempts
|
|
74
|
+
*/
|
|
75
|
+
private reconnectAttempts;
|
|
76
|
+
/**
|
|
77
|
+
* @description connect auth state
|
|
78
|
+
* @default {
|
|
79
|
+
* startConfirm: false,
|
|
80
|
+
* isConnected: false,
|
|
81
|
+
* isReconnecting: false,
|
|
82
|
+
* isAuthenticated: false,
|
|
83
|
+
* isError: false
|
|
84
|
+
* }
|
|
85
|
+
*/
|
|
86
|
+
private connectAuthState;
|
|
87
|
+
get startConfirm(): boolean;
|
|
88
|
+
get isError(): boolean;
|
|
89
|
+
constructor(callKit: CallKit);
|
|
90
|
+
get reconnectConfig(): {
|
|
91
|
+
enabled?: boolean;
|
|
92
|
+
maxAttempts?: number;
|
|
93
|
+
delay?: number;
|
|
94
|
+
pingInterval?: number;
|
|
95
|
+
pingTimeout?: number;
|
|
96
|
+
};
|
|
97
|
+
init(): void;
|
|
98
|
+
private setConnectAuthState;
|
|
99
|
+
private handleDisconnect;
|
|
100
|
+
private clearWebSocket;
|
|
101
|
+
private connect;
|
|
102
|
+
private onOpen;
|
|
103
|
+
private cleanReconnectState;
|
|
104
|
+
private resetConnectState;
|
|
105
|
+
private onClose;
|
|
106
|
+
private onError;
|
|
107
|
+
private confirmAck;
|
|
108
|
+
private onMessage;
|
|
109
|
+
send(event: SocketSendEventType, message?: any): void;
|
|
110
|
+
private ping;
|
|
111
|
+
private checkPing;
|
|
112
|
+
/**
|
|
113
|
+
* reset socket connection and all states
|
|
114
|
+
*/
|
|
115
|
+
reset(config?: {
|
|
116
|
+
force?: boolean;
|
|
117
|
+
}): Promise<void>;
|
|
118
|
+
private attemptReconnect;
|
|
119
|
+
}
|
|
120
|
+
|
|
53
121
|
interface WebrtcConstranis {
|
|
54
122
|
audio: {
|
|
55
123
|
autoGainControl?: boolean;
|
|
@@ -67,7 +135,7 @@ interface IConfig {
|
|
|
67
135
|
constrains: WebrtcConstranis;
|
|
68
136
|
socket: string;
|
|
69
137
|
reconnect?: {
|
|
70
|
-
sip?: Partial<
|
|
138
|
+
sip?: Partial<SocketConfig>;
|
|
71
139
|
incall?: Partial<SocketConfig>;
|
|
72
140
|
};
|
|
73
141
|
userInfo: {
|
|
@@ -98,7 +166,7 @@ declare class Config {
|
|
|
98
166
|
getConfig: () => IConfig;
|
|
99
167
|
setConfig: (key: string, value: any) => Promise<void>;
|
|
100
168
|
setUserInfo: (key: string, value: any) => Promise<void>;
|
|
101
|
-
reset: () => Promise<void>;
|
|
169
|
+
reset: (form: string) => Promise<void>;
|
|
102
170
|
validate: () => boolean;
|
|
103
171
|
isLogin: () => boolean;
|
|
104
172
|
check(): boolean;
|
|
@@ -107,7 +175,13 @@ declare class Config {
|
|
|
107
175
|
interval: number;
|
|
108
176
|
maxSize: number;
|
|
109
177
|
};
|
|
110
|
-
getReconnectConfig(type: 'sip' | 'incall'):
|
|
178
|
+
getReconnectConfig(type: 'sip' | 'incall'): {
|
|
179
|
+
enabled?: boolean;
|
|
180
|
+
maxAttempts?: number;
|
|
181
|
+
delay?: number;
|
|
182
|
+
pingInterval?: number;
|
|
183
|
+
pingTimeout?: number;
|
|
184
|
+
};
|
|
111
185
|
enableTrackLogs(enabled: boolean): void;
|
|
112
186
|
}
|
|
113
187
|
|
|
@@ -283,20 +357,6 @@ interface TrackLogsConfig {
|
|
|
283
357
|
enabled: boolean;
|
|
284
358
|
interval: number;
|
|
285
359
|
maxSize: number;
|
|
286
|
-
}
|
|
287
|
-
interface SocketConfig {
|
|
288
|
-
enabled: boolean;
|
|
289
|
-
maxAttempts: number;
|
|
290
|
-
delay: number;
|
|
291
|
-
pingInterval: number;
|
|
292
|
-
pingTimeout: number;
|
|
293
|
-
}
|
|
294
|
-
interface SipConfig {
|
|
295
|
-
enabled: boolean;
|
|
296
|
-
maxAttempts: number;
|
|
297
|
-
delay: number;
|
|
298
|
-
enableMessageKeepalive: boolean;
|
|
299
|
-
messageKeepaliveInterval: number;
|
|
300
360
|
}
|
|
301
361
|
|
|
302
362
|
interface CallParams {
|
|
@@ -356,6 +416,10 @@ declare class Connect {
|
|
|
356
416
|
*@description Whether it's a re-connected
|
|
357
417
|
*/
|
|
358
418
|
isReConnected: boolean;
|
|
419
|
+
/**
|
|
420
|
+
*@description Whether it's a referring
|
|
421
|
+
*/
|
|
422
|
+
isRefering: boolean;
|
|
359
423
|
/**
|
|
360
424
|
*@description Whether it's an outgoing call
|
|
361
425
|
*/
|
|
@@ -369,8 +433,18 @@ declare class Connect {
|
|
|
369
433
|
*/
|
|
370
434
|
hasInvite: boolean;
|
|
371
435
|
constructor(callKit: CallKit);
|
|
372
|
-
get reconnectConfig():
|
|
373
|
-
|
|
436
|
+
get reconnectConfig(): {
|
|
437
|
+
enabled?: boolean;
|
|
438
|
+
maxAttempts?: number;
|
|
439
|
+
delay?: number;
|
|
440
|
+
pingInterval?: number;
|
|
441
|
+
pingTimeout?: number;
|
|
442
|
+
};
|
|
443
|
+
private currentCallId;
|
|
444
|
+
getCurrentCallId(): string | null;
|
|
445
|
+
setRefering(refering: boolean): void;
|
|
446
|
+
private setIsReConnected;
|
|
447
|
+
setOutgoing(outgoing: boolean): void;
|
|
374
448
|
setCallId(callId: string | null): void;
|
|
375
449
|
reset(): Promise<void>;
|
|
376
450
|
private getAduioReference;
|
|
@@ -406,15 +480,12 @@ declare class Connect {
|
|
|
406
480
|
* @returns
|
|
407
481
|
*/
|
|
408
482
|
isInit(): boolean;
|
|
409
|
-
private heartbeatInterval?;
|
|
410
|
-
private heartbeatFlag;
|
|
411
|
-
private messageKeepaliveTimer?;
|
|
412
|
-
clearHeartbeat(): void;
|
|
413
|
-
startHeartbeat(): void;
|
|
414
|
-
private stopMessageKeepalive;
|
|
415
|
-
private startMessageKeepalive;
|
|
416
|
-
private sendKeepaliveMessage;
|
|
417
483
|
socketTriggerHangup(callId: string): void;
|
|
484
|
+
/**
|
|
485
|
+
* Setup registerer and bind stateChange listener
|
|
486
|
+
* @private
|
|
487
|
+
*/
|
|
488
|
+
private setupRegisterer;
|
|
418
489
|
register(): Promise<void>;
|
|
419
490
|
private reconnectTimer?;
|
|
420
491
|
private reconnectAttempts;
|
|
@@ -450,59 +521,6 @@ declare class Connect {
|
|
|
450
521
|
refer(referTo: string, extra?: any): Promise<void>;
|
|
451
522
|
}
|
|
452
523
|
|
|
453
|
-
type SocketSendEventType = (typeof SocketSendEvent)[keyof typeof SocketSendEvent];
|
|
454
|
-
declare class Socket {
|
|
455
|
-
private callKit;
|
|
456
|
-
private ws?;
|
|
457
|
-
lastPingTime: any;
|
|
458
|
-
pingTimer?: ReturnType<typeof setInterval>;
|
|
459
|
-
/**
|
|
460
|
-
* @description reconnect timer
|
|
461
|
-
*/
|
|
462
|
-
private reconnectTimer?;
|
|
463
|
-
/**
|
|
464
|
-
* @description reconnect attempts
|
|
465
|
-
*/
|
|
466
|
-
private reconnectAttempts;
|
|
467
|
-
/**
|
|
468
|
-
* @description connect auth state
|
|
469
|
-
* @default {
|
|
470
|
-
* startConfirm: false,
|
|
471
|
-
* isConnected: false,
|
|
472
|
-
* isReconnecting: false,
|
|
473
|
-
* isAuthenticated: false,
|
|
474
|
-
* isError: false
|
|
475
|
-
* }
|
|
476
|
-
*/
|
|
477
|
-
private connectAuthState;
|
|
478
|
-
get startConfirm(): boolean;
|
|
479
|
-
get isError(): boolean;
|
|
480
|
-
constructor(callKit: CallKit);
|
|
481
|
-
get reconnectConfig(): SocketConfig;
|
|
482
|
-
init(): void;
|
|
483
|
-
private setConnectAuthState;
|
|
484
|
-
private handleDisconnect;
|
|
485
|
-
private clearWebSocket;
|
|
486
|
-
private connect;
|
|
487
|
-
private onOpen;
|
|
488
|
-
private cleanReconnectState;
|
|
489
|
-
private resetConnectState;
|
|
490
|
-
private onClose;
|
|
491
|
-
private onError;
|
|
492
|
-
private confirmAck;
|
|
493
|
-
private onMessage;
|
|
494
|
-
send(event: SocketSendEventType, message?: any): void;
|
|
495
|
-
private ping;
|
|
496
|
-
private checkPing;
|
|
497
|
-
/**
|
|
498
|
-
* reset socket connection and all states
|
|
499
|
-
*/
|
|
500
|
-
reset(config?: {
|
|
501
|
-
force?: boolean;
|
|
502
|
-
}): Promise<void>;
|
|
503
|
-
private attemptReconnect;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
524
|
interface CallKitConfig {
|
|
507
525
|
host: string;
|
|
508
526
|
audioRef: HTMLAudioElement | (() => HTMLAudioElement);
|
|
@@ -510,7 +528,7 @@ interface CallKitConfig {
|
|
|
510
528
|
constrains?: WebrtcConstranis;
|
|
511
529
|
log?: LoggerLevel;
|
|
512
530
|
reconnect?: {
|
|
513
|
-
sip?: Partial<
|
|
531
|
+
sip?: Partial<SocketConfig>;
|
|
514
532
|
incall?: Partial<SocketConfig>;
|
|
515
533
|
};
|
|
516
534
|
}
|
|
@@ -548,7 +566,9 @@ declare class CallKit {
|
|
|
548
566
|
* set userstatus
|
|
549
567
|
* @param status
|
|
550
568
|
*/
|
|
551
|
-
setUserStatus(status: number
|
|
569
|
+
setUserStatus(status: number, extra?: {
|
|
570
|
+
[key: string]: any;
|
|
571
|
+
}): Promise<void>;
|
|
552
572
|
/**
|
|
553
573
|
* reset callkit
|
|
554
574
|
* @description recover the callkit to the initial state
|