@koi-design/callkit 2.1.0-beta.2 → 2.1.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 +34 -2
- package/dist/index.global.js +141 -42
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +141 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +141 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -292,6 +292,14 @@ declare const KitEvent: {
|
|
|
292
292
|
SIP_CONNECT_EVENT: string;
|
|
293
293
|
SIP_REGISTERER_EVENT: string;
|
|
294
294
|
SIP_SESSION_EVENT: string;
|
|
295
|
+
/**
|
|
296
|
+
* Refering change
|
|
297
|
+
*/
|
|
298
|
+
KIT_REFERING_CHANGE: string;
|
|
299
|
+
/**
|
|
300
|
+
* In call refering change
|
|
301
|
+
*/
|
|
302
|
+
KIT_IN_CALL_REFERING_CHANGE: string;
|
|
295
303
|
};
|
|
296
304
|
declare const SocketSendEvent: {
|
|
297
305
|
/**
|
|
@@ -419,7 +427,11 @@ declare class Connect {
|
|
|
419
427
|
/**
|
|
420
428
|
*@description Whether it's a referring
|
|
421
429
|
*/
|
|
422
|
-
|
|
430
|
+
private _isRefering;
|
|
431
|
+
/**
|
|
432
|
+
*@description Whether it's in call refering dealwith disconnect recovery
|
|
433
|
+
*/
|
|
434
|
+
private _isInCallRefering;
|
|
423
435
|
/**
|
|
424
436
|
*@description Whether it's an outgoing call
|
|
425
437
|
*/
|
|
@@ -442,11 +454,22 @@ declare class Connect {
|
|
|
442
454
|
};
|
|
443
455
|
private currentCallId;
|
|
444
456
|
getCurrentCallId(): string | null;
|
|
457
|
+
/**
|
|
458
|
+
*@description Whether the SIP socket is error
|
|
459
|
+
*/
|
|
460
|
+
private _isError;
|
|
461
|
+
get isError(): boolean;
|
|
462
|
+
/**
|
|
463
|
+
*@description Set whether it's in call refering dealwith disconnect recovery
|
|
464
|
+
*/
|
|
465
|
+
private setInCallRefering;
|
|
445
466
|
setRefering(refering: boolean): void;
|
|
446
467
|
private setIsReConnected;
|
|
447
468
|
setOutgoing(outgoing: boolean): void;
|
|
448
469
|
setCallId(callId: string | null): void;
|
|
449
|
-
reset(
|
|
470
|
+
reset({ force }?: {
|
|
471
|
+
force?: boolean;
|
|
472
|
+
}): Promise<void>;
|
|
450
473
|
private getAduioReference;
|
|
451
474
|
permission(): Promise<void>;
|
|
452
475
|
/**
|
|
@@ -475,6 +498,14 @@ declare class Connect {
|
|
|
475
498
|
* isMute
|
|
476
499
|
*/
|
|
477
500
|
isMuted(): boolean;
|
|
501
|
+
/**
|
|
502
|
+
* isRefering
|
|
503
|
+
*/
|
|
504
|
+
isRefering(): boolean;
|
|
505
|
+
/**
|
|
506
|
+
* isInCallRefering
|
|
507
|
+
*/
|
|
508
|
+
isInCallRefering(): boolean;
|
|
478
509
|
/**
|
|
479
510
|
* Call ended, call not started
|
|
480
511
|
* @returns
|
|
@@ -519,6 +550,7 @@ declare class Connect {
|
|
|
519
550
|
setHold(hold: boolean): Promise<void>;
|
|
520
551
|
setMute(mute: boolean): Promise<void>;
|
|
521
552
|
refer(referTo: string, extra?: any): Promise<void>;
|
|
553
|
+
private referInCall;
|
|
522
554
|
}
|
|
523
555
|
|
|
524
556
|
interface CallKitConfig {
|
package/dist/index.global.js
CHANGED
|
@@ -3483,7 +3483,15 @@ var WebCall = (() => {
|
|
|
3483
3483
|
INCALL_CONNECT_EVENT: "IncallConnectEvent",
|
|
3484
3484
|
SIP_CONNECT_EVENT: "sipConnectEvent",
|
|
3485
3485
|
SIP_REGISTERER_EVENT: "sipRegistererEvent",
|
|
3486
|
-
SIP_SESSION_EVENT: "sipSessionEvent"
|
|
3486
|
+
SIP_SESSION_EVENT: "sipSessionEvent",
|
|
3487
|
+
/**
|
|
3488
|
+
* Refering change
|
|
3489
|
+
*/
|
|
3490
|
+
KIT_REFERING_CHANGE: "referingChange",
|
|
3491
|
+
/**
|
|
3492
|
+
* In call refering change
|
|
3493
|
+
*/
|
|
3494
|
+
KIT_IN_CALL_REFERING_CHANGE: "inCallReferingChange"
|
|
3487
3495
|
};
|
|
3488
3496
|
var ErrorCode = {
|
|
3489
3497
|
/**
|
|
@@ -3870,7 +3878,7 @@ var WebCall = (() => {
|
|
|
3870
3878
|
// package.json
|
|
3871
3879
|
var package_default = {
|
|
3872
3880
|
name: "@koi-design/callkit",
|
|
3873
|
-
version: "2.1.0-beta.
|
|
3881
|
+
version: "2.1.0-beta.3",
|
|
3874
3882
|
description: "callkit",
|
|
3875
3883
|
author: "koi",
|
|
3876
3884
|
license: "ISC",
|
|
@@ -18657,7 +18665,11 @@ ${log}` : log;
|
|
|
18657
18665
|
/**
|
|
18658
18666
|
*@description Whether it's a referring
|
|
18659
18667
|
*/
|
|
18660
|
-
|
|
18668
|
+
_isRefering = false;
|
|
18669
|
+
/**
|
|
18670
|
+
*@description Whether it's in call refering dealwith disconnect recovery
|
|
18671
|
+
*/
|
|
18672
|
+
_isInCallRefering = false;
|
|
18661
18673
|
// sipConnected = false;
|
|
18662
18674
|
/**
|
|
18663
18675
|
*@description Whether it's an outgoing call
|
|
@@ -18682,8 +18694,30 @@ ${log}` : log;
|
|
|
18682
18694
|
getCurrentCallId() {
|
|
18683
18695
|
return this.currentCallId;
|
|
18684
18696
|
}
|
|
18697
|
+
/**
|
|
18698
|
+
*@description Whether the SIP socket is error
|
|
18699
|
+
*/
|
|
18700
|
+
_isError = false;
|
|
18701
|
+
get isError() {
|
|
18702
|
+
return this._isError;
|
|
18703
|
+
}
|
|
18704
|
+
/**
|
|
18705
|
+
*@description Set whether it's in call refering dealwith disconnect recovery
|
|
18706
|
+
*/
|
|
18707
|
+
setInCallRefering(refering) {
|
|
18708
|
+
if (this._isInCallRefering === refering)
|
|
18709
|
+
return;
|
|
18710
|
+
this.callKit.logger.info("setIsInCallRefering", {
|
|
18711
|
+
caller: "Connect.setIsInCallRefering",
|
|
18712
|
+
content: {
|
|
18713
|
+
refering
|
|
18714
|
+
}
|
|
18715
|
+
});
|
|
18716
|
+
this._isInCallRefering = refering;
|
|
18717
|
+
this.callKit.trigger(KitEvent.KIT_IN_CALL_REFERING_CHANGE);
|
|
18718
|
+
}
|
|
18685
18719
|
setRefering(refering) {
|
|
18686
|
-
if (this.
|
|
18720
|
+
if (this._isRefering === refering)
|
|
18687
18721
|
return;
|
|
18688
18722
|
this.callKit.logger.info("setRefering", {
|
|
18689
18723
|
caller: "Connect.setRefering",
|
|
@@ -18691,7 +18725,8 @@ ${log}` : log;
|
|
|
18691
18725
|
refering
|
|
18692
18726
|
}
|
|
18693
18727
|
});
|
|
18694
|
-
this.
|
|
18728
|
+
this._isRefering = refering;
|
|
18729
|
+
this.callKit.trigger(KitEvent.KIT_REFERING_CHANGE);
|
|
18695
18730
|
}
|
|
18696
18731
|
setIsReConnected(isReConnected) {
|
|
18697
18732
|
if (this.isReConnected === isReConnected)
|
|
@@ -18725,13 +18760,19 @@ ${log}` : log;
|
|
|
18725
18760
|
this.currentCallId = callId;
|
|
18726
18761
|
this.callKit.trigger(KitEvent.KIT_CALL_ID_CHANGE, callId);
|
|
18727
18762
|
}
|
|
18728
|
-
async reset() {
|
|
18763
|
+
async reset({ force = false } = { force: false }) {
|
|
18729
18764
|
this.setOutgoing(false);
|
|
18730
18765
|
this.isUnprompted = false;
|
|
18731
18766
|
this.hasInvite = false;
|
|
18732
|
-
if (
|
|
18767
|
+
if (force) {
|
|
18768
|
+
this._isError = false;
|
|
18769
|
+
}
|
|
18770
|
+
if (this._isRefering) {
|
|
18733
18771
|
this.setRefering(false);
|
|
18734
18772
|
}
|
|
18773
|
+
if (this._isInCallRefering) {
|
|
18774
|
+
this.setInCallRefering(false);
|
|
18775
|
+
}
|
|
18735
18776
|
if (this.isReConnected) {
|
|
18736
18777
|
this.setIsReConnected(false);
|
|
18737
18778
|
}
|
|
@@ -18827,6 +18868,18 @@ ${log}` : log;
|
|
|
18827
18868
|
isMuted() {
|
|
18828
18869
|
return this.isMute;
|
|
18829
18870
|
}
|
|
18871
|
+
/**
|
|
18872
|
+
* isRefering
|
|
18873
|
+
*/
|
|
18874
|
+
isRefering() {
|
|
18875
|
+
return this._isRefering;
|
|
18876
|
+
}
|
|
18877
|
+
/**
|
|
18878
|
+
* isInCallRefering
|
|
18879
|
+
*/
|
|
18880
|
+
isInCallRefering() {
|
|
18881
|
+
return this._isInCallRefering;
|
|
18882
|
+
}
|
|
18830
18883
|
/**
|
|
18831
18884
|
* Call ended, call not started
|
|
18832
18885
|
* @returns
|
|
@@ -18876,7 +18929,9 @@ ${log}` : log;
|
|
|
18876
18929
|
}
|
|
18877
18930
|
});
|
|
18878
18931
|
this.setRegister(false);
|
|
18879
|
-
this.
|
|
18932
|
+
if (!this.isInCallRefering()) {
|
|
18933
|
+
this.setConnectStatus(CallStatus.init);
|
|
18934
|
+
}
|
|
18880
18935
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
18881
18936
|
registererState: state,
|
|
18882
18937
|
isRegistered: this.isRegistered()
|
|
@@ -18907,7 +18962,7 @@ ${log}` : log;
|
|
|
18907
18962
|
}
|
|
18908
18963
|
}
|
|
18909
18964
|
);
|
|
18910
|
-
this.
|
|
18965
|
+
this.referInCall(selfUri).catch((err) => {
|
|
18911
18966
|
this.callKit.logger.error(err, {
|
|
18912
18967
|
caller: "Connect.setupRegisterer.registererStateChange",
|
|
18913
18968
|
type: "SIP",
|
|
@@ -18945,14 +19000,18 @@ ${log}` : log;
|
|
|
18945
19000
|
type: "SIP",
|
|
18946
19001
|
content: {
|
|
18947
19002
|
registererState: state,
|
|
18948
|
-
isRegistered: this.isRegistered()
|
|
19003
|
+
isRegistered: this.isRegistered(),
|
|
19004
|
+
isInCallRefering: this.isInCallRefering()
|
|
18949
19005
|
}
|
|
18950
19006
|
});
|
|
18951
19007
|
this.setRegister(false);
|
|
18952
|
-
this.
|
|
19008
|
+
if (!this.isInCallRefering()) {
|
|
19009
|
+
this.setConnectStatus(CallStatus.init);
|
|
19010
|
+
}
|
|
18953
19011
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
18954
19012
|
registererState: state,
|
|
18955
|
-
isRegistered: this.isRegistered()
|
|
19013
|
+
isRegistered: this.isRegistered(),
|
|
19014
|
+
isInCallRefering: this.isInCallRefering()
|
|
18956
19015
|
});
|
|
18957
19016
|
break;
|
|
18958
19017
|
case RegistererState.Unregistered:
|
|
@@ -18961,14 +19020,18 @@ ${log}` : log;
|
|
|
18961
19020
|
type: "SIP",
|
|
18962
19021
|
content: {
|
|
18963
19022
|
isRegistered: this.isRegistered(),
|
|
18964
|
-
registererState: state
|
|
19023
|
+
registererState: state,
|
|
19024
|
+
isInCallRefering: this.isInCallRefering()
|
|
18965
19025
|
}
|
|
18966
19026
|
});
|
|
18967
19027
|
this.setRegister(false);
|
|
18968
|
-
this.
|
|
19028
|
+
if (!this.isInCallRefering()) {
|
|
19029
|
+
this.setConnectStatus(CallStatus.init);
|
|
19030
|
+
}
|
|
18969
19031
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
18970
19032
|
registererState: state,
|
|
18971
|
-
isRegistered: this.isRegistered()
|
|
19033
|
+
isRegistered: this.isRegistered(),
|
|
19034
|
+
isInCallRefering: this.isInCallRefering()
|
|
18972
19035
|
});
|
|
18973
19036
|
break;
|
|
18974
19037
|
default:
|
|
@@ -19135,14 +19198,17 @@ ${log}` : log;
|
|
|
19135
19198
|
caller: "Connect.register.onInvite",
|
|
19136
19199
|
type: "SIP",
|
|
19137
19200
|
content: {
|
|
19138
|
-
sessionState: state
|
|
19201
|
+
sessionState: state,
|
|
19202
|
+
isInCallRefering: this.isInCallRefering()
|
|
19139
19203
|
}
|
|
19140
19204
|
});
|
|
19141
|
-
this.
|
|
19142
|
-
|
|
19143
|
-
|
|
19144
|
-
|
|
19145
|
-
|
|
19205
|
+
if (!this.isInCallRefering()) {
|
|
19206
|
+
this.setConnectStatus(CallStatus.ringing);
|
|
19207
|
+
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
19208
|
+
sessionState: state,
|
|
19209
|
+
isRegistered: this.isRegistered()
|
|
19210
|
+
});
|
|
19211
|
+
}
|
|
19146
19212
|
break;
|
|
19147
19213
|
case SessionState2.Established:
|
|
19148
19214
|
this.callKit.logger.info("connect Established", {
|
|
@@ -19152,17 +19218,20 @@ ${log}` : log;
|
|
|
19152
19218
|
sessionState: state
|
|
19153
19219
|
}
|
|
19154
19220
|
});
|
|
19155
|
-
this.
|
|
19156
|
-
|
|
19157
|
-
|
|
19158
|
-
|
|
19159
|
-
|
|
19221
|
+
if (!this.isInCallRefering()) {
|
|
19222
|
+
this.callKit.connect.setConnectStatus(CallStatus.calling);
|
|
19223
|
+
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
19224
|
+
sessionState: state,
|
|
19225
|
+
isRegistered: this.isRegistered()
|
|
19226
|
+
});
|
|
19227
|
+
}
|
|
19160
19228
|
setupRemoteMedia(this.currentSession);
|
|
19161
19229
|
break;
|
|
19162
19230
|
case SessionState2.Terminating:
|
|
19163
19231
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
19164
19232
|
sessionState: state,
|
|
19165
|
-
isRegistered: this.isRegistered()
|
|
19233
|
+
isRegistered: this.isRegistered(),
|
|
19234
|
+
isInCallRefering: this.isInCallRefering()
|
|
19166
19235
|
});
|
|
19167
19236
|
break;
|
|
19168
19237
|
case SessionState2.Terminated:
|
|
@@ -19170,7 +19239,8 @@ ${log}` : log;
|
|
|
19170
19239
|
caller: "Connect.register.onInvite",
|
|
19171
19240
|
type: "SIP",
|
|
19172
19241
|
content: {
|
|
19173
|
-
sessionState: state
|
|
19242
|
+
sessionState: state,
|
|
19243
|
+
isInCallRefering: this.isInCallRefering()
|
|
19174
19244
|
}
|
|
19175
19245
|
});
|
|
19176
19246
|
this.hasInvite = false;
|
|
@@ -19180,7 +19250,8 @@ ${log}` : log;
|
|
|
19180
19250
|
this.isUnprompted = false;
|
|
19181
19251
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
19182
19252
|
sessionState: state,
|
|
19183
|
-
isRegistered: this.isRegistered()
|
|
19253
|
+
isRegistered: this.isRegistered(),
|
|
19254
|
+
isInCallRefering: this.isInCallRefering()
|
|
19184
19255
|
});
|
|
19185
19256
|
break;
|
|
19186
19257
|
default:
|
|
@@ -19230,9 +19301,9 @@ ${log}` : log;
|
|
|
19230
19301
|
}
|
|
19231
19302
|
});
|
|
19232
19303
|
}
|
|
19233
|
-
if (this.
|
|
19304
|
+
if (this.isInCallRefering()) {
|
|
19234
19305
|
this.currentSession.accept(options);
|
|
19235
|
-
this.
|
|
19306
|
+
this.setInCallRefering(false);
|
|
19236
19307
|
return;
|
|
19237
19308
|
}
|
|
19238
19309
|
if (this.isOutgoing) {
|
|
@@ -19319,7 +19390,10 @@ ${log}` : log;
|
|
|
19319
19390
|
reconnectTimer;
|
|
19320
19391
|
reconnectAttempts = 0;
|
|
19321
19392
|
startReconnectTimer() {
|
|
19393
|
+
if (this._isError)
|
|
19394
|
+
return;
|
|
19322
19395
|
if (this.reconnectAttempts >= this.reconnectConfig.maxAttempts && this.callKit.config.isLogin()) {
|
|
19396
|
+
this._isError = true;
|
|
19323
19397
|
this.callKit.reset();
|
|
19324
19398
|
this.callKit.logger.error("Reconnect failed max attempts", {
|
|
19325
19399
|
caller: "Connect.startReconnectTimer",
|
|
@@ -19342,10 +19416,10 @@ ${log}` : log;
|
|
|
19342
19416
|
}
|
|
19343
19417
|
});
|
|
19344
19418
|
this.reconnectAttempts += 1;
|
|
19419
|
+
this.setIsReConnected(true);
|
|
19345
19420
|
this.reconnectTimer = setTimeout(() => {
|
|
19346
19421
|
if (this.reconnectTimer && this.callKit.config.isLogin()) {
|
|
19347
19422
|
this.userAgent?.reconnect();
|
|
19348
|
-
this.setIsReConnected(true);
|
|
19349
19423
|
this.callKit.logger.info("Reconnect attempt", {
|
|
19350
19424
|
caller: "Connect.startReconnectTimer",
|
|
19351
19425
|
type: "SIP",
|
|
@@ -19658,6 +19732,35 @@ ${log}` : log;
|
|
|
19658
19732
|
}
|
|
19659
19733
|
this.currentSession.refer(target, extra?.sessionReferOptions);
|
|
19660
19734
|
}
|
|
19735
|
+
async referInCall(referTo, extra) {
|
|
19736
|
+
if (!this.currentSession) {
|
|
19737
|
+
const errorMsg = "Cannot refer in call: currentSession is not available";
|
|
19738
|
+
this.callKit.logger.warn(errorMsg, {
|
|
19739
|
+
caller: "Connect.referInCall",
|
|
19740
|
+
type: "SIP",
|
|
19741
|
+
content: {
|
|
19742
|
+
errCode: ErrorCode.WEBRTC_CALL_INVITE_ERROR,
|
|
19743
|
+
referTo
|
|
19744
|
+
}
|
|
19745
|
+
});
|
|
19746
|
+
return;
|
|
19747
|
+
}
|
|
19748
|
+
this.setInCallRefering(true);
|
|
19749
|
+
this.callKit.logger.info("connect referInCall", {
|
|
19750
|
+
caller: "Connect.referInCall",
|
|
19751
|
+
type: "SIP",
|
|
19752
|
+
content: {
|
|
19753
|
+
referTo,
|
|
19754
|
+
extra,
|
|
19755
|
+
sessionState: this.currentSession.state
|
|
19756
|
+
}
|
|
19757
|
+
});
|
|
19758
|
+
let target;
|
|
19759
|
+
if (referTo) {
|
|
19760
|
+
target = UserAgent.makeURI(referTo);
|
|
19761
|
+
}
|
|
19762
|
+
this.currentSession.refer(target, extra?.sessionReferOptions);
|
|
19763
|
+
}
|
|
19661
19764
|
};
|
|
19662
19765
|
|
|
19663
19766
|
// core/socket.ts
|
|
@@ -19965,14 +20068,10 @@ ${log}` : log;
|
|
|
19965
20068
|
this.callKit.connect.socketTriggerHangup(callUuid);
|
|
19966
20069
|
}
|
|
19967
20070
|
}
|
|
19968
|
-
this.callKit.trigger(
|
|
19969
|
-
|
|
19970
|
-
|
|
19971
|
-
|
|
19972
|
-
callUuid
|
|
19973
|
-
},
|
|
19974
|
-
true
|
|
19975
|
-
);
|
|
20071
|
+
this.callKit.trigger(KitEvent.SERVER_SOCKET_EVENT, {
|
|
20072
|
+
...data,
|
|
20073
|
+
callUuid
|
|
20074
|
+
});
|
|
19976
20075
|
}
|
|
19977
20076
|
send(event, message) {
|
|
19978
20077
|
if (!this.connectAuthState.isConnected) {
|
|
@@ -20207,7 +20306,7 @@ ${log}` : log;
|
|
|
20207
20306
|
encryptionPassword
|
|
20208
20307
|
}
|
|
20209
20308
|
});
|
|
20210
|
-
if (this.socket.isError) {
|
|
20309
|
+
if (this.socket.isError || this.connect.isError) {
|
|
20211
20310
|
this.logger.warn("socket is error", {
|
|
20212
20311
|
caller: "CallKit.login",
|
|
20213
20312
|
content: { username, password, extra, socketError: this.socket.isError }
|
|
@@ -20445,7 +20544,7 @@ ${log}` : log;
|
|
|
20445
20544
|
if (this.connect.isCalling()) {
|
|
20446
20545
|
await this.hangup();
|
|
20447
20546
|
}
|
|
20448
|
-
await this.connect.reset();
|
|
20547
|
+
await this.connect.reset({ force });
|
|
20449
20548
|
if (this.config.isLogin()) {
|
|
20450
20549
|
await this.logout({ isReset: false });
|
|
20451
20550
|
} else {
|