@zjw-jszn/shared-imsdk 1.0.8 → 1.0.10
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 +18 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/config/index.d.ts +44 -0
- package/dist/shared-imsdk.css +137 -137
- package/dist/shared-imsdk.es.js +358 -50
- package/dist/shared-imsdk.umd.cjs +358 -50
- package/dist/types/index.d.ts +21 -0
- package/dist/utils/websocket.d.ts +17 -1
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface IMSDKConfig {
|
|
|
8
8
|
};
|
|
9
9
|
api?: {
|
|
10
10
|
baseURL?: string;
|
|
11
|
+
resourceBaseURL?: string;
|
|
11
12
|
prefix?: string;
|
|
12
13
|
uploadURL?: string;
|
|
13
14
|
signKey?: string;
|
|
@@ -18,8 +19,25 @@ export interface IMSDKConfig {
|
|
|
18
19
|
userType?: number;
|
|
19
20
|
};
|
|
20
21
|
ws?: {
|
|
22
|
+
url?: string;
|
|
21
23
|
controller?: string;
|
|
22
24
|
platform?: string;
|
|
25
|
+
reconnectInterval?: number;
|
|
26
|
+
heartbeatInterval?: number;
|
|
27
|
+
maxReconnectAttempts?: number;
|
|
28
|
+
connectTimeout?: number;
|
|
29
|
+
traceEnabled?: boolean;
|
|
30
|
+
protocol?: {
|
|
31
|
+
controller?: string;
|
|
32
|
+
action?: {
|
|
33
|
+
send?: string;
|
|
34
|
+
msgRead?: string;
|
|
35
|
+
onConnect?: string;
|
|
36
|
+
offLine?: string;
|
|
37
|
+
heartbeat?: string;
|
|
38
|
+
};
|
|
39
|
+
heartbeatSignals?: string[];
|
|
40
|
+
};
|
|
23
41
|
};
|
|
24
42
|
sound?: {
|
|
25
43
|
enabled: boolean;
|
|
@@ -28,6 +46,9 @@ export interface IMSDKConfig {
|
|
|
28
46
|
auth?: {
|
|
29
47
|
authorizationPayload?: Record<string, unknown>;
|
|
30
48
|
};
|
|
49
|
+
chat?: {
|
|
50
|
+
platformServicePhone?: string;
|
|
51
|
+
};
|
|
31
52
|
runtimeApi?: {
|
|
32
53
|
getChatConfig?: () => Promise<{
|
|
33
54
|
quick_receive?: string[] | string;
|
|
@@ -13,22 +13,35 @@ interface WebSocketMessage {
|
|
|
13
13
|
action: string;
|
|
14
14
|
param?: Record<string, unknown>;
|
|
15
15
|
}
|
|
16
|
+
type PresenceAction = 'onConnect' | 'offLine';
|
|
16
17
|
declare class WebSocketClient {
|
|
17
18
|
private ws;
|
|
18
19
|
private status;
|
|
19
20
|
private heartbeatTimer;
|
|
20
21
|
private reconnectTimer;
|
|
22
|
+
private connectTimeoutTimer;
|
|
21
23
|
private reconnectCount;
|
|
22
24
|
private messageQueue;
|
|
23
25
|
private listeners;
|
|
26
|
+
private lastToken;
|
|
27
|
+
private lastUserId;
|
|
28
|
+
private lastPhone;
|
|
24
29
|
private userId;
|
|
25
30
|
private phone;
|
|
26
31
|
private siteId;
|
|
27
32
|
private presenceAction;
|
|
28
33
|
private isConnected;
|
|
29
|
-
private
|
|
34
|
+
private wsUrlOverride;
|
|
30
35
|
private readonly logPrefix;
|
|
31
36
|
constructor(config?: WebSocketConfig);
|
|
37
|
+
private toPositiveInt;
|
|
38
|
+
private getHeartbeatInterval;
|
|
39
|
+
private getReconnectInterval;
|
|
40
|
+
private getMaxReconnectCount;
|
|
41
|
+
private getConnectTimeout;
|
|
42
|
+
private trace;
|
|
43
|
+
private resolveProtocolAction;
|
|
44
|
+
private stopConnectTimeout;
|
|
32
45
|
/**
|
|
33
46
|
* 连接 WebSocket
|
|
34
47
|
* @param {string} token - 用户token
|
|
@@ -50,6 +63,8 @@ declare class WebSocketClient {
|
|
|
50
63
|
* 使用当前配置 controller 发送业务消息
|
|
51
64
|
*/
|
|
52
65
|
sendBusinessMessage(action: string, param?: Record<string, unknown>): boolean;
|
|
66
|
+
private tryReconnectFromManualOnline;
|
|
67
|
+
private setPresenceAction;
|
|
53
68
|
/**
|
|
54
69
|
* 启动心跳
|
|
55
70
|
*/
|
|
@@ -109,6 +124,7 @@ declare class WebSocketClient {
|
|
|
109
124
|
* @returns {boolean} - 返回是否处于已连接并可用的状态
|
|
110
125
|
*/
|
|
111
126
|
checkConnected(): boolean;
|
|
127
|
+
getPresenceAction(): PresenceAction;
|
|
112
128
|
}
|
|
113
129
|
declare const wsClient: WebSocketClient;
|
|
114
130
|
export default wsClient;
|