@koi-design/callkit 2.1.4 → 2.1.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 +16 -31
- package/dist/index.global.js +93 -47
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +93 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Invitation, UserAgent, Registerer } from 'sip.js';
|
|
1
|
+
import { RegistererOptions, Invitation, UserAgent, Registerer } from 'sip.js';
|
|
2
2
|
|
|
3
3
|
declare class Api {
|
|
4
4
|
private callKit;
|
|
@@ -53,7 +53,7 @@ declare class Logger {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
type SocketSendEventType = (typeof SocketSendEvent)[keyof typeof SocketSendEvent];
|
|
56
|
-
interface
|
|
56
|
+
interface IncallConfig {
|
|
57
57
|
enabled: boolean;
|
|
58
58
|
maxAttempts: number;
|
|
59
59
|
delay: number;
|
|
@@ -61,6 +61,12 @@ interface SocketConfig {
|
|
|
61
61
|
pingTimeout: number;
|
|
62
62
|
excludeLogEvents: string[];
|
|
63
63
|
}
|
|
64
|
+
interface SipConfig {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
maxAttempts: number;
|
|
67
|
+
delay: number;
|
|
68
|
+
registererOptions: RegistererOptions;
|
|
69
|
+
}
|
|
64
70
|
declare class Socket {
|
|
65
71
|
private callKit;
|
|
66
72
|
private ws?;
|
|
@@ -88,14 +94,7 @@ declare class Socket {
|
|
|
88
94
|
get startConfirm(): boolean;
|
|
89
95
|
get isError(): boolean;
|
|
90
96
|
constructor(callKit: CallKit);
|
|
91
|
-
get reconnectConfig():
|
|
92
|
-
enabled?: boolean;
|
|
93
|
-
maxAttempts?: number;
|
|
94
|
-
delay?: number;
|
|
95
|
-
pingInterval?: number;
|
|
96
|
-
pingTimeout?: number;
|
|
97
|
-
excludeLogEvents?: string[];
|
|
98
|
-
};
|
|
97
|
+
get reconnectConfig(): IncallConfig;
|
|
99
98
|
isConnected(): boolean;
|
|
100
99
|
init(): void;
|
|
101
100
|
private setConnectAuthState;
|
|
@@ -138,8 +137,8 @@ interface IConfig {
|
|
|
138
137
|
constrains: WebrtcConstranis;
|
|
139
138
|
socket: string;
|
|
140
139
|
reconnect?: {
|
|
141
|
-
sip?: Partial<
|
|
142
|
-
incall?: Partial<
|
|
140
|
+
sip?: Partial<SipConfig>;
|
|
141
|
+
incall?: Partial<IncallConfig>;
|
|
143
142
|
};
|
|
144
143
|
userInfo: {
|
|
145
144
|
wsUrl: string;
|
|
@@ -178,14 +177,7 @@ declare class Config {
|
|
|
178
177
|
interval: number;
|
|
179
178
|
maxSize: number;
|
|
180
179
|
};
|
|
181
|
-
getReconnectConfig
|
|
182
|
-
enabled?: boolean;
|
|
183
|
-
maxAttempts?: number;
|
|
184
|
-
delay?: number;
|
|
185
|
-
pingInterval?: number;
|
|
186
|
-
pingTimeout?: number;
|
|
187
|
-
excludeLogEvents?: string[];
|
|
188
|
-
};
|
|
180
|
+
getReconnectConfig<T extends 'sip' | 'incall'>(type: T): T extends "sip" ? SipConfig : IncallConfig;
|
|
189
181
|
enableTrackLogs(enabled: boolean): void;
|
|
190
182
|
}
|
|
191
183
|
|
|
@@ -449,14 +441,7 @@ declare class Connect {
|
|
|
449
441
|
*/
|
|
450
442
|
hasInvite: boolean;
|
|
451
443
|
constructor(callKit: CallKit);
|
|
452
|
-
get reconnectConfig():
|
|
453
|
-
enabled?: boolean;
|
|
454
|
-
maxAttempts?: number;
|
|
455
|
-
delay?: number;
|
|
456
|
-
pingInterval?: number;
|
|
457
|
-
pingTimeout?: number;
|
|
458
|
-
excludeLogEvents?: string[];
|
|
459
|
-
};
|
|
444
|
+
get reconnectConfig(): SipConfig;
|
|
460
445
|
private currentCallId;
|
|
461
446
|
getCurrentCallId(): string | null;
|
|
462
447
|
/**
|
|
@@ -476,7 +461,7 @@ declare class Connect {
|
|
|
476
461
|
force?: boolean;
|
|
477
462
|
}): Promise<void>;
|
|
478
463
|
private getAduioReference;
|
|
479
|
-
permission(): Promise<
|
|
464
|
+
permission(): Promise<boolean>;
|
|
480
465
|
/**
|
|
481
466
|
* Making connection
|
|
482
467
|
* @returns
|
|
@@ -569,8 +554,8 @@ interface CallKitConfig {
|
|
|
569
554
|
constrains?: WebrtcConstranis;
|
|
570
555
|
log?: LoggerLevel;
|
|
571
556
|
reconnect?: {
|
|
572
|
-
sip?: Partial<
|
|
573
|
-
incall?: Partial<
|
|
557
|
+
sip?: Partial<SipConfig>;
|
|
558
|
+
incall?: Partial<IncallConfig>;
|
|
574
559
|
};
|
|
575
560
|
}
|
|
576
561
|
type ConfigEntity = Partial<IConfig> & CallKitConfig;
|
package/dist/index.global.js
CHANGED
|
@@ -3736,7 +3736,10 @@ var WebCall = (() => {
|
|
|
3736
3736
|
var SIP_RECONNECT_CONFIG = {
|
|
3737
3737
|
enabled: true,
|
|
3738
3738
|
maxAttempts: 3,
|
|
3739
|
-
delay: 1e3
|
|
3739
|
+
delay: 1e3,
|
|
3740
|
+
registererOptions: {
|
|
3741
|
+
refreshFrequency: 90
|
|
3742
|
+
}
|
|
3740
3743
|
};
|
|
3741
3744
|
|
|
3742
3745
|
// core/call.ts
|
|
@@ -3880,13 +3883,13 @@ var WebCall = (() => {
|
|
|
3880
3883
|
// package.json
|
|
3881
3884
|
var package_default = {
|
|
3882
3885
|
name: "@koi-design/callkit",
|
|
3883
|
-
version: "2.1.
|
|
3886
|
+
version: "2.1.5-beta.2",
|
|
3884
3887
|
description: "callkit",
|
|
3885
3888
|
author: "koi",
|
|
3886
3889
|
license: "ISC",
|
|
3887
3890
|
scripts: {
|
|
3888
3891
|
build: "tsup",
|
|
3889
|
-
start: "vite",
|
|
3892
|
+
start: "vite --host 0.0.0.0",
|
|
3890
3893
|
dev: "tsup --watch",
|
|
3891
3894
|
lint: "eslint -c ../../.eslintrc.js --ext .jsx,.js,.tsx,.ts ./package --fix",
|
|
3892
3895
|
release: "tsup && node scripts/pkg.js"
|
|
@@ -4043,10 +4046,7 @@ var WebCall = (() => {
|
|
|
4043
4046
|
};
|
|
4044
4047
|
}
|
|
4045
4048
|
getReconnectConfig(type) {
|
|
4046
|
-
|
|
4047
|
-
return {
|
|
4048
|
-
...config
|
|
4049
|
-
};
|
|
4049
|
+
return this.config?.reconnect?.[type] ?? (type === "sip" ? SIP_RECONNECT_CONFIG : SOCKET_RECONNECT_CONFIG);
|
|
4050
4050
|
}
|
|
4051
4051
|
enableTrackLogs(enabled) {
|
|
4052
4052
|
this.config.trackLogs.enabled = enabled;
|
|
@@ -18608,36 +18608,71 @@ ${log}` : log;
|
|
|
18608
18608
|
return {};
|
|
18609
18609
|
}
|
|
18610
18610
|
};
|
|
18611
|
-
|
|
18612
|
-
// core/connect.ts
|
|
18613
|
-
function convertObjectStringToJSON(input) {
|
|
18614
|
-
const corrected = input.replace(/(\w+):\s*'(.*?)'/g, '"$1": "$2"').replace(/'/g, '"');
|
|
18615
|
-
return corrected;
|
|
18616
|
-
}
|
|
18617
18611
|
var closeStream = (stream) => {
|
|
18618
18612
|
if (stream)
|
|
18619
18613
|
stream.getTracks().forEach((track) => track.stop());
|
|
18620
18614
|
};
|
|
18621
|
-
|
|
18622
|
-
if (
|
|
18615
|
+
async function checkPermission() {
|
|
18616
|
+
if (!navigator.mediaDevices) {
|
|
18623
18617
|
navigator.mediaDevices = {};
|
|
18624
18618
|
}
|
|
18625
|
-
if (
|
|
18626
|
-
navigator.mediaDevices.getUserMedia
|
|
18627
|
-
|
|
18628
|
-
|
|
18629
|
-
|
|
18630
|
-
|
|
18631
|
-
|
|
18632
|
-
|
|
18633
|
-
|
|
18619
|
+
if (navigator.mediaDevices.getUserMedia) {
|
|
18620
|
+
return navigator.mediaDevices.getUserMedia({ audio: true });
|
|
18621
|
+
}
|
|
18622
|
+
const legacyGetUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
|
|
18623
|
+
if (!legacyGetUserMedia) {
|
|
18624
|
+
const err = Object.assign(
|
|
18625
|
+
new Error(
|
|
18626
|
+
"Unable to obtain device permissions. Please check your browser settings or device permissions."
|
|
18627
|
+
),
|
|
18628
|
+
{
|
|
18629
|
+
name: "NotSupportedError"
|
|
18634
18630
|
}
|
|
18635
|
-
|
|
18636
|
-
|
|
18637
|
-
|
|
18638
|
-
|
|
18631
|
+
);
|
|
18632
|
+
return Promise.reject(err);
|
|
18633
|
+
}
|
|
18634
|
+
return new Promise((resolve, reject) => {
|
|
18635
|
+
legacyGetUserMedia.call(navigator, { audio: true }, resolve, reject);
|
|
18636
|
+
});
|
|
18637
|
+
}
|
|
18638
|
+
var permissionError = (err) => {
|
|
18639
|
+
const errorName = err?.name || "UnknownError";
|
|
18640
|
+
const errorMessage = err?.message;
|
|
18641
|
+
switch (errorName) {
|
|
18642
|
+
case "NotAllowedError":
|
|
18643
|
+
return {
|
|
18644
|
+
type: "permission-denied",
|
|
18645
|
+
reason: "Microphone permission denied. Please check browser microphone permission settings"
|
|
18646
|
+
};
|
|
18647
|
+
case "NotFoundError":
|
|
18648
|
+
return {
|
|
18649
|
+
type: "no-device",
|
|
18650
|
+
reason: "Microphone device not found. Please check if microphone is properly connected"
|
|
18651
|
+
};
|
|
18652
|
+
case "SecurityError":
|
|
18653
|
+
return {
|
|
18654
|
+
type: "security-error",
|
|
18655
|
+
reason: "Microphone access blocked. Please use HTTPS or contact technical support"
|
|
18656
|
+
};
|
|
18657
|
+
case "NotReadableError":
|
|
18658
|
+
return {
|
|
18659
|
+
type: "device-busy",
|
|
18660
|
+
reason: "Microphone is being used by another application. Please close other apps using the microphone"
|
|
18661
|
+
};
|
|
18662
|
+
default:
|
|
18663
|
+
return {
|
|
18664
|
+
name: errorName,
|
|
18665
|
+
type: errorName,
|
|
18666
|
+
reason: errorMessage || "Microphone error. Please check device and browser settings or contact technical support"
|
|
18667
|
+
};
|
|
18639
18668
|
}
|
|
18640
18669
|
};
|
|
18670
|
+
|
|
18671
|
+
// core/connect.ts
|
|
18672
|
+
function convertObjectStringToJSON(input) {
|
|
18673
|
+
const corrected = input.replace(/(\w+):\s*'(.*?)'/g, '"$1": "$2"').replace(/'/g, '"');
|
|
18674
|
+
return corrected;
|
|
18675
|
+
}
|
|
18641
18676
|
var Connect = class {
|
|
18642
18677
|
callKit;
|
|
18643
18678
|
/**
|
|
@@ -18822,15 +18857,31 @@ ${log}` : log;
|
|
|
18822
18857
|
return audioRef;
|
|
18823
18858
|
}
|
|
18824
18859
|
async permission() {
|
|
18825
|
-
|
|
18826
|
-
|
|
18827
|
-
|
|
18828
|
-
|
|
18829
|
-
|
|
18830
|
-
|
|
18831
|
-
|
|
18832
|
-
|
|
18833
|
-
|
|
18860
|
+
try {
|
|
18861
|
+
this.callKit.logger.info("permission", {
|
|
18862
|
+
caller: "Connect.permission",
|
|
18863
|
+
content: {
|
|
18864
|
+
permission: true
|
|
18865
|
+
}
|
|
18866
|
+
});
|
|
18867
|
+
await checkPermission();
|
|
18868
|
+
return true;
|
|
18869
|
+
} catch (err) {
|
|
18870
|
+
this.callKit.reset();
|
|
18871
|
+
const error = permissionError(err);
|
|
18872
|
+
this.callKit.logger.error(err, {
|
|
18873
|
+
caller: "Connect.permission",
|
|
18874
|
+
content: {
|
|
18875
|
+
permission: false,
|
|
18876
|
+
errCode: ErrorCode.WEBRTC_USER_MEDIA_ERROR,
|
|
18877
|
+
errName: error.name,
|
|
18878
|
+
type: error.type,
|
|
18879
|
+
reason: error.reason,
|
|
18880
|
+
errRaw: err
|
|
18881
|
+
}
|
|
18882
|
+
});
|
|
18883
|
+
return false;
|
|
18884
|
+
}
|
|
18834
18885
|
}
|
|
18835
18886
|
/**
|
|
18836
18887
|
* Making connection
|
|
@@ -18934,7 +18985,7 @@ ${log}` : log;
|
|
|
18934
18985
|
}
|
|
18935
18986
|
const { userInfo } = this.callKit.config.getConfig();
|
|
18936
18987
|
const { userPart, fsIp, fsPort } = userInfo;
|
|
18937
|
-
const registererOptions = {};
|
|
18988
|
+
const { registererOptions = {} } = this.reconnectConfig;
|
|
18938
18989
|
this.registerer = new Registerer(this.userAgent, registererOptions);
|
|
18939
18990
|
this.registerer.stateChange.addListener((state) => {
|
|
18940
18991
|
switch (state) {
|
|
@@ -19084,15 +19135,10 @@ ${log}` : log;
|
|
|
19084
19135
|
connectStatus: this.connectStatus
|
|
19085
19136
|
}
|
|
19086
19137
|
});
|
|
19087
|
-
await this.permission()
|
|
19088
|
-
|
|
19089
|
-
|
|
19090
|
-
|
|
19091
|
-
content: {
|
|
19092
|
-
errCode: ErrorCode.WEBRTC_USER_MEDIA_ERROR
|
|
19093
|
-
}
|
|
19094
|
-
});
|
|
19095
|
-
});
|
|
19138
|
+
const permissionResult = await this.permission();
|
|
19139
|
+
if (!permissionResult) {
|
|
19140
|
+
return;
|
|
19141
|
+
}
|
|
19096
19142
|
const { userInfo, constrains } = this.callKit.config.getConfig();
|
|
19097
19143
|
const localStreamFactory = async () => {
|
|
19098
19144
|
this.mediaStream = await navigator.mediaDevices.getUserMedia(constrains);
|