@koi-design/callkit 2.1.0-beta.1 → 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 +143 -50
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +143 -50
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -50
- 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",
|
|
@@ -4099,15 +4107,9 @@ ${log}` : log;
|
|
|
4099
4107
|
if (currentChunk.length > 0) {
|
|
4100
4108
|
chunks.push(currentChunk.join("\n"));
|
|
4101
4109
|
}
|
|
4102
|
-
|
|
4103
|
-
await previousPromise;
|
|
4104
|
-
if (index > 0) {
|
|
4105
|
-
await new Promise((resolve) => {
|
|
4106
|
-
setTimeout(resolve, 1e3);
|
|
4107
|
-
});
|
|
4108
|
-
}
|
|
4110
|
+
for (const chunk of chunks) {
|
|
4109
4111
|
await this.callKit.api.trackLogs(chunk);
|
|
4110
|
-
}
|
|
4112
|
+
}
|
|
4111
4113
|
this.pendingTrackLogs = [];
|
|
4112
4114
|
} catch (error) {
|
|
4113
4115
|
console.error(error);
|
|
@@ -18663,7 +18665,11 @@ ${log}` : log;
|
|
|
18663
18665
|
/**
|
|
18664
18666
|
*@description Whether it's a referring
|
|
18665
18667
|
*/
|
|
18666
|
-
|
|
18668
|
+
_isRefering = false;
|
|
18669
|
+
/**
|
|
18670
|
+
*@description Whether it's in call refering dealwith disconnect recovery
|
|
18671
|
+
*/
|
|
18672
|
+
_isInCallRefering = false;
|
|
18667
18673
|
// sipConnected = false;
|
|
18668
18674
|
/**
|
|
18669
18675
|
*@description Whether it's an outgoing call
|
|
@@ -18688,8 +18694,30 @@ ${log}` : log;
|
|
|
18688
18694
|
getCurrentCallId() {
|
|
18689
18695
|
return this.currentCallId;
|
|
18690
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
|
+
}
|
|
18691
18719
|
setRefering(refering) {
|
|
18692
|
-
if (this.
|
|
18720
|
+
if (this._isRefering === refering)
|
|
18693
18721
|
return;
|
|
18694
18722
|
this.callKit.logger.info("setRefering", {
|
|
18695
18723
|
caller: "Connect.setRefering",
|
|
@@ -18697,7 +18725,8 @@ ${log}` : log;
|
|
|
18697
18725
|
refering
|
|
18698
18726
|
}
|
|
18699
18727
|
});
|
|
18700
|
-
this.
|
|
18728
|
+
this._isRefering = refering;
|
|
18729
|
+
this.callKit.trigger(KitEvent.KIT_REFERING_CHANGE);
|
|
18701
18730
|
}
|
|
18702
18731
|
setIsReConnected(isReConnected) {
|
|
18703
18732
|
if (this.isReConnected === isReConnected)
|
|
@@ -18731,13 +18760,19 @@ ${log}` : log;
|
|
|
18731
18760
|
this.currentCallId = callId;
|
|
18732
18761
|
this.callKit.trigger(KitEvent.KIT_CALL_ID_CHANGE, callId);
|
|
18733
18762
|
}
|
|
18734
|
-
async reset() {
|
|
18763
|
+
async reset({ force = false } = { force: false }) {
|
|
18735
18764
|
this.setOutgoing(false);
|
|
18736
18765
|
this.isUnprompted = false;
|
|
18737
18766
|
this.hasInvite = false;
|
|
18738
|
-
if (
|
|
18767
|
+
if (force) {
|
|
18768
|
+
this._isError = false;
|
|
18769
|
+
}
|
|
18770
|
+
if (this._isRefering) {
|
|
18739
18771
|
this.setRefering(false);
|
|
18740
18772
|
}
|
|
18773
|
+
if (this._isInCallRefering) {
|
|
18774
|
+
this.setInCallRefering(false);
|
|
18775
|
+
}
|
|
18741
18776
|
if (this.isReConnected) {
|
|
18742
18777
|
this.setIsReConnected(false);
|
|
18743
18778
|
}
|
|
@@ -18833,6 +18868,18 @@ ${log}` : log;
|
|
|
18833
18868
|
isMuted() {
|
|
18834
18869
|
return this.isMute;
|
|
18835
18870
|
}
|
|
18871
|
+
/**
|
|
18872
|
+
* isRefering
|
|
18873
|
+
*/
|
|
18874
|
+
isRefering() {
|
|
18875
|
+
return this._isRefering;
|
|
18876
|
+
}
|
|
18877
|
+
/**
|
|
18878
|
+
* isInCallRefering
|
|
18879
|
+
*/
|
|
18880
|
+
isInCallRefering() {
|
|
18881
|
+
return this._isInCallRefering;
|
|
18882
|
+
}
|
|
18836
18883
|
/**
|
|
18837
18884
|
* Call ended, call not started
|
|
18838
18885
|
* @returns
|
|
@@ -18882,7 +18929,9 @@ ${log}` : log;
|
|
|
18882
18929
|
}
|
|
18883
18930
|
});
|
|
18884
18931
|
this.setRegister(false);
|
|
18885
|
-
this.
|
|
18932
|
+
if (!this.isInCallRefering()) {
|
|
18933
|
+
this.setConnectStatus(CallStatus.init);
|
|
18934
|
+
}
|
|
18886
18935
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
18887
18936
|
registererState: state,
|
|
18888
18937
|
isRegistered: this.isRegistered()
|
|
@@ -18913,7 +18962,7 @@ ${log}` : log;
|
|
|
18913
18962
|
}
|
|
18914
18963
|
}
|
|
18915
18964
|
);
|
|
18916
|
-
this.
|
|
18965
|
+
this.referInCall(selfUri).catch((err) => {
|
|
18917
18966
|
this.callKit.logger.error(err, {
|
|
18918
18967
|
caller: "Connect.setupRegisterer.registererStateChange",
|
|
18919
18968
|
type: "SIP",
|
|
@@ -18951,14 +19000,18 @@ ${log}` : log;
|
|
|
18951
19000
|
type: "SIP",
|
|
18952
19001
|
content: {
|
|
18953
19002
|
registererState: state,
|
|
18954
|
-
isRegistered: this.isRegistered()
|
|
19003
|
+
isRegistered: this.isRegistered(),
|
|
19004
|
+
isInCallRefering: this.isInCallRefering()
|
|
18955
19005
|
}
|
|
18956
19006
|
});
|
|
18957
19007
|
this.setRegister(false);
|
|
18958
|
-
this.
|
|
19008
|
+
if (!this.isInCallRefering()) {
|
|
19009
|
+
this.setConnectStatus(CallStatus.init);
|
|
19010
|
+
}
|
|
18959
19011
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
18960
19012
|
registererState: state,
|
|
18961
|
-
isRegistered: this.isRegistered()
|
|
19013
|
+
isRegistered: this.isRegistered(),
|
|
19014
|
+
isInCallRefering: this.isInCallRefering()
|
|
18962
19015
|
});
|
|
18963
19016
|
break;
|
|
18964
19017
|
case RegistererState.Unregistered:
|
|
@@ -18967,14 +19020,18 @@ ${log}` : log;
|
|
|
18967
19020
|
type: "SIP",
|
|
18968
19021
|
content: {
|
|
18969
19022
|
isRegistered: this.isRegistered(),
|
|
18970
|
-
registererState: state
|
|
19023
|
+
registererState: state,
|
|
19024
|
+
isInCallRefering: this.isInCallRefering()
|
|
18971
19025
|
}
|
|
18972
19026
|
});
|
|
18973
19027
|
this.setRegister(false);
|
|
18974
|
-
this.
|
|
19028
|
+
if (!this.isInCallRefering()) {
|
|
19029
|
+
this.setConnectStatus(CallStatus.init);
|
|
19030
|
+
}
|
|
18975
19031
|
this.callKit.trigger(KitEvent.SIP_REGISTERER_EVENT, {
|
|
18976
19032
|
registererState: state,
|
|
18977
|
-
isRegistered: this.isRegistered()
|
|
19033
|
+
isRegistered: this.isRegistered(),
|
|
19034
|
+
isInCallRefering: this.isInCallRefering()
|
|
18978
19035
|
});
|
|
18979
19036
|
break;
|
|
18980
19037
|
default:
|
|
@@ -19141,14 +19198,17 @@ ${log}` : log;
|
|
|
19141
19198
|
caller: "Connect.register.onInvite",
|
|
19142
19199
|
type: "SIP",
|
|
19143
19200
|
content: {
|
|
19144
|
-
sessionState: state
|
|
19201
|
+
sessionState: state,
|
|
19202
|
+
isInCallRefering: this.isInCallRefering()
|
|
19145
19203
|
}
|
|
19146
19204
|
});
|
|
19147
|
-
this.
|
|
19148
|
-
|
|
19149
|
-
|
|
19150
|
-
|
|
19151
|
-
|
|
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
|
+
}
|
|
19152
19212
|
break;
|
|
19153
19213
|
case SessionState2.Established:
|
|
19154
19214
|
this.callKit.logger.info("connect Established", {
|
|
@@ -19158,17 +19218,20 @@ ${log}` : log;
|
|
|
19158
19218
|
sessionState: state
|
|
19159
19219
|
}
|
|
19160
19220
|
});
|
|
19161
|
-
this.
|
|
19162
|
-
|
|
19163
|
-
|
|
19164
|
-
|
|
19165
|
-
|
|
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
|
+
}
|
|
19166
19228
|
setupRemoteMedia(this.currentSession);
|
|
19167
19229
|
break;
|
|
19168
19230
|
case SessionState2.Terminating:
|
|
19169
19231
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
19170
19232
|
sessionState: state,
|
|
19171
|
-
isRegistered: this.isRegistered()
|
|
19233
|
+
isRegistered: this.isRegistered(),
|
|
19234
|
+
isInCallRefering: this.isInCallRefering()
|
|
19172
19235
|
});
|
|
19173
19236
|
break;
|
|
19174
19237
|
case SessionState2.Terminated:
|
|
@@ -19176,7 +19239,8 @@ ${log}` : log;
|
|
|
19176
19239
|
caller: "Connect.register.onInvite",
|
|
19177
19240
|
type: "SIP",
|
|
19178
19241
|
content: {
|
|
19179
|
-
sessionState: state
|
|
19242
|
+
sessionState: state,
|
|
19243
|
+
isInCallRefering: this.isInCallRefering()
|
|
19180
19244
|
}
|
|
19181
19245
|
});
|
|
19182
19246
|
this.hasInvite = false;
|
|
@@ -19186,7 +19250,8 @@ ${log}` : log;
|
|
|
19186
19250
|
this.isUnprompted = false;
|
|
19187
19251
|
this.callKit.trigger(KitEvent.SIP_SESSION_EVENT, {
|
|
19188
19252
|
sessionState: state,
|
|
19189
|
-
isRegistered: this.isRegistered()
|
|
19253
|
+
isRegistered: this.isRegistered(),
|
|
19254
|
+
isInCallRefering: this.isInCallRefering()
|
|
19190
19255
|
});
|
|
19191
19256
|
break;
|
|
19192
19257
|
default:
|
|
@@ -19236,9 +19301,9 @@ ${log}` : log;
|
|
|
19236
19301
|
}
|
|
19237
19302
|
});
|
|
19238
19303
|
}
|
|
19239
|
-
if (this.
|
|
19304
|
+
if (this.isInCallRefering()) {
|
|
19240
19305
|
this.currentSession.accept(options);
|
|
19241
|
-
this.
|
|
19306
|
+
this.setInCallRefering(false);
|
|
19242
19307
|
return;
|
|
19243
19308
|
}
|
|
19244
19309
|
if (this.isOutgoing) {
|
|
@@ -19325,7 +19390,10 @@ ${log}` : log;
|
|
|
19325
19390
|
reconnectTimer;
|
|
19326
19391
|
reconnectAttempts = 0;
|
|
19327
19392
|
startReconnectTimer() {
|
|
19393
|
+
if (this._isError)
|
|
19394
|
+
return;
|
|
19328
19395
|
if (this.reconnectAttempts >= this.reconnectConfig.maxAttempts && this.callKit.config.isLogin()) {
|
|
19396
|
+
this._isError = true;
|
|
19329
19397
|
this.callKit.reset();
|
|
19330
19398
|
this.callKit.logger.error("Reconnect failed max attempts", {
|
|
19331
19399
|
caller: "Connect.startReconnectTimer",
|
|
@@ -19348,10 +19416,10 @@ ${log}` : log;
|
|
|
19348
19416
|
}
|
|
19349
19417
|
});
|
|
19350
19418
|
this.reconnectAttempts += 1;
|
|
19419
|
+
this.setIsReConnected(true);
|
|
19351
19420
|
this.reconnectTimer = setTimeout(() => {
|
|
19352
19421
|
if (this.reconnectTimer && this.callKit.config.isLogin()) {
|
|
19353
19422
|
this.userAgent?.reconnect();
|
|
19354
|
-
this.setIsReConnected(true);
|
|
19355
19423
|
this.callKit.logger.info("Reconnect attempt", {
|
|
19356
19424
|
caller: "Connect.startReconnectTimer",
|
|
19357
19425
|
type: "SIP",
|
|
@@ -19664,6 +19732,35 @@ ${log}` : log;
|
|
|
19664
19732
|
}
|
|
19665
19733
|
this.currentSession.refer(target, extra?.sessionReferOptions);
|
|
19666
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
|
+
}
|
|
19667
19764
|
};
|
|
19668
19765
|
|
|
19669
19766
|
// core/socket.ts
|
|
@@ -19971,14 +20068,10 @@ ${log}` : log;
|
|
|
19971
20068
|
this.callKit.connect.socketTriggerHangup(callUuid);
|
|
19972
20069
|
}
|
|
19973
20070
|
}
|
|
19974
|
-
this.callKit.trigger(
|
|
19975
|
-
|
|
19976
|
-
|
|
19977
|
-
|
|
19978
|
-
callUuid
|
|
19979
|
-
},
|
|
19980
|
-
true
|
|
19981
|
-
);
|
|
20071
|
+
this.callKit.trigger(KitEvent.SERVER_SOCKET_EVENT, {
|
|
20072
|
+
...data,
|
|
20073
|
+
callUuid
|
|
20074
|
+
});
|
|
19982
20075
|
}
|
|
19983
20076
|
send(event, message) {
|
|
19984
20077
|
if (!this.connectAuthState.isConnected) {
|
|
@@ -20213,7 +20306,7 @@ ${log}` : log;
|
|
|
20213
20306
|
encryptionPassword
|
|
20214
20307
|
}
|
|
20215
20308
|
});
|
|
20216
|
-
if (this.socket.isError) {
|
|
20309
|
+
if (this.socket.isError || this.connect.isError) {
|
|
20217
20310
|
this.logger.warn("socket is error", {
|
|
20218
20311
|
caller: "CallKit.login",
|
|
20219
20312
|
content: { username, password, extra, socketError: this.socket.isError }
|
|
@@ -20451,7 +20544,7 @@ ${log}` : log;
|
|
|
20451
20544
|
if (this.connect.isCalling()) {
|
|
20452
20545
|
await this.hangup();
|
|
20453
20546
|
}
|
|
20454
|
-
await this.connect.reset();
|
|
20547
|
+
await this.connect.reset({ force });
|
|
20455
20548
|
if (this.config.isLogin()) {
|
|
20456
20549
|
await this.logout({ isReset: false });
|
|
20457
20550
|
} else {
|