@realsee/live 0.6.13 → 0.6.15
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.cjs.js +9 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +776 -622
- package/dist/index.es.js.map +1 -1
- package/dist/live/controller.d.ts +28 -0
- package/dist/live/createLiveReact.d.ts +1 -1
- package/dist/live/live.d.ts +6 -1
- package/dist/rtc/VRWebViewRTC.d.ts +84 -9
- package/dist/typings/live/GetVoiceSign.d.ts +33 -5
- package/dist/typings/live/LiveConnectOptions.d.ts +17 -0
- package/dist/typings/live/LiveMsg.d.ts +14 -0
- package/dist/typings/rtc/eventType.d.ts +22 -7
- package/dist/typings/rtc/joinedInfo.d.ts +5 -1
- package/dist/typings/rtc/protocol.d.ts +4 -0
- package/dist/utils/RobustWebSocket.d.ts +3 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/Live.html +812 -0
- package/docs/classes/VRWebViewRTC.html +212 -21
- package/docs/enums/Command.html +24 -8
- package/docs/enums/MicroStatus.html +8 -4
- package/docs/enums/RTCJoinedInfoCodeEnum.html +11 -2
- package/docs/functions/_clearLiveInstanceIfNeed.html +98 -0
- package/docs/functions/createLive.html +8 -4
- package/docs/functions/createLiveReact.html +18 -14
- package/docs/functions/parseLiveMsg.html +7 -3
- package/docs/functions/parseWSClsErr.html +6 -2
- package/docs/index.html +6 -2
- package/docs/interfaces/RTCJoinedInfo.html +6 -6
- package/docs/interfaces/RTCProtocol.html +16 -4
- package/docs/modules.html +11 -3
- package/docs/types/BuiltinMsg.html +6 -2
- package/docs/types/EventType.html +6 -2
- package/docs/types/GetVoiceSign.html +12 -27
- package/docs/types/GetVoiceSignParams.html +111 -0
- package/docs/types/GetVoiceSignReturnType.html +115 -0
- package/docs/types/KeyframeTypes.html +6 -2
- package/docs/types/LiveBuiltInData.html +117 -0
- package/docs/types/LiveConnectOptions.html +22 -6
- package/docs/types/LiveEventType.html +6 -2
- package/docs/types/LiveMsg.html +7 -3
- package/docs/types/LiveProviderPropTypes.html +8 -4
- package/docs/types/RTCActionReactCallback.html +6 -2
- package/docs/types/RTCEventType.html +58 -3
- package/docs/types/ReqLiveMsg.html +6 -2
- package/docs/types/RoomInfo.html +6 -2
- package/docs/types/UserInfo.html +6 -2
- package/docs/types/UserInfoExt.html +6 -2
- package/docs/types/UserVolume.html +6 -2
- package/docs/types/WebSocketError.html +6 -2
- package/package.json +1 -1
- package/docs/interfaces/GetVoiceSignReturnType.html +0 -90
|
@@ -2,11 +2,39 @@ import { LiveMsg } from '../typings';
|
|
|
2
2
|
import { LiveState } from '../typings/live/LiveState';
|
|
3
3
|
import { RobustWebSocketEventDetail } from '../utils/RobustWebSocket';
|
|
4
4
|
import { Subscribe } from '../utils/subscribe';
|
|
5
|
+
/**
|
|
6
|
+
* 带看控制器事件映射
|
|
7
|
+
*/
|
|
5
8
|
export type LiveControllerEventMap = {
|
|
9
|
+
/**
|
|
10
|
+
* 带看状态变更
|
|
11
|
+
* @param state
|
|
12
|
+
* @param prevState
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
6
15
|
stateChange: (state: LiveState, prevState: LiveState) => void;
|
|
16
|
+
/**
|
|
17
|
+
* 接收到带看消息
|
|
18
|
+
* @param message
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
7
21
|
message: (message: LiveMsg) => void;
|
|
22
|
+
/**
|
|
23
|
+
* 带看重连中
|
|
24
|
+
* @param detail
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
reconnecting: (detail: RobustWebSocketEventDetail) => void;
|
|
28
|
+
/**
|
|
29
|
+
* 带看重连成功
|
|
30
|
+
* @param detail
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
8
33
|
reconnected: (detail: RobustWebSocketEventDetail) => void;
|
|
9
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* 带看控制器
|
|
37
|
+
*/
|
|
10
38
|
export declare class LiveController extends Subscribe<LiveControllerEventMap> {
|
|
11
39
|
/**
|
|
12
40
|
* ws代理器
|
|
@@ -21,7 +21,7 @@ export declare function createLiveReact<KeyframesSnapshot extends Record<string,
|
|
|
21
21
|
useLiveAction: () => {
|
|
22
22
|
connect: (options: LiveConnectOptions) => Promise<boolean | Error>;
|
|
23
23
|
broadcast: (data: Record<string, any>, toUserIds: string | string[], timeout?: number) => Promise<unknown>;
|
|
24
|
-
exit: () => Promise<
|
|
24
|
+
exit: () => Promise<void>;
|
|
25
25
|
kick: (toUserIds: string | string[]) => Promise<boolean>;
|
|
26
26
|
toggleMicro: (microStatus: boolean) => Promise<boolean>;
|
|
27
27
|
forbidMicro: (micro: MicroStatus, toUserIds?: string | string[]) => Promise<boolean>;
|
package/dist/live/live.d.ts
CHANGED
|
@@ -117,7 +117,12 @@ export declare class Live<KeyframesSnapshot extends Record<string, any>> extends
|
|
|
117
117
|
* 退出带看
|
|
118
118
|
* @returns
|
|
119
119
|
*/
|
|
120
|
-
|
|
120
|
+
_exit: () => Promise<boolean>;
|
|
121
|
+
/**
|
|
122
|
+
* 退出带看
|
|
123
|
+
* @returns
|
|
124
|
+
*/
|
|
125
|
+
exit: () => Promise<void>;
|
|
121
126
|
/**
|
|
122
127
|
* 关闭带看房间
|
|
123
128
|
* @param code
|
|
@@ -1,22 +1,97 @@
|
|
|
1
|
-
import { RTCType } from
|
|
2
|
-
import { VRWebViewRTCOptions } from
|
|
3
|
-
import { CoreRTC } from
|
|
1
|
+
import { RTCType } from "../typings/rtc/type";
|
|
2
|
+
import { VRWebViewRTCOptions } from "../typings/rtc/VRWebViewRTCOptions";
|
|
3
|
+
import { CoreRTC } from "./CoreRTC";
|
|
4
4
|
export declare class VRWebViewRTC extends CoreRTC {
|
|
5
5
|
type: RTCType;
|
|
6
6
|
joined: boolean;
|
|
7
7
|
micro: boolean;
|
|
8
8
|
voiceId: string;
|
|
9
|
+
/**
|
|
10
|
+
* 保留加入房间参数,用于重连
|
|
11
|
+
*/
|
|
12
|
+
private _joinOptions;
|
|
9
13
|
private options;
|
|
10
14
|
get jsBridge(): import("@realsee/jsbridge-x").JSBridgeProtocol;
|
|
11
15
|
constructor({ jsBridge, getVoiceSign }: VRWebViewRTCOptions);
|
|
12
|
-
|
|
16
|
+
/**
|
|
17
|
+
* 处理用户音量
|
|
18
|
+
* @param userVolumes
|
|
19
|
+
*/
|
|
20
|
+
private handleUserVolumes;
|
|
21
|
+
/**
|
|
22
|
+
* 处理弱网络情况
|
|
23
|
+
* @param weakNetwork
|
|
24
|
+
*/
|
|
25
|
+
private handleWeakNetwork;
|
|
26
|
+
/**
|
|
27
|
+
* 加入语音房间
|
|
28
|
+
* @param options
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
join: (options: {
|
|
13
32
|
voiceId: string;
|
|
14
33
|
userId: string;
|
|
15
34
|
roomId: string;
|
|
16
35
|
type: RTCType;
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
36
|
+
}) => Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* 重连
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
reJoin: () => Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* 获取 rtc 签名
|
|
44
|
+
* @param params
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
private getVoiceSignOrEmitError;
|
|
48
|
+
/**
|
|
49
|
+
* 处理小程序的加入房间
|
|
50
|
+
* @param options
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
private handleWxMiniProgramWebViewJoin;
|
|
54
|
+
/**
|
|
55
|
+
* 处理App WebView的加入房间
|
|
56
|
+
* @param options
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
private handleAppWebViewJoin;
|
|
60
|
+
/**
|
|
61
|
+
* 加入语音房间,给小程序使用
|
|
62
|
+
* @param param0
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
private joinRoomOrEmitError;
|
|
66
|
+
/**
|
|
67
|
+
* 处理加入语音房间结果
|
|
68
|
+
* @param res
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
private handleJoinResult;
|
|
72
|
+
/**
|
|
73
|
+
* 将错误信息发送出去,并将 joined 置为 false
|
|
74
|
+
* @param message
|
|
75
|
+
*/
|
|
76
|
+
private emitErrorAndSetJoinedFalse;
|
|
77
|
+
/**
|
|
78
|
+
* 退出房间
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
quit: () => Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* 监测麦克风权限
|
|
84
|
+
* @returns
|
|
85
|
+
*/
|
|
86
|
+
detectMicro: () => Promise<boolean>;
|
|
87
|
+
/**
|
|
88
|
+
* 修改麦克风状态
|
|
89
|
+
* @param flag
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
toggleMicro: (flag?: boolean) => Promise<boolean>;
|
|
93
|
+
/**
|
|
94
|
+
* 震动
|
|
95
|
+
*/
|
|
96
|
+
shock: () => void;
|
|
22
97
|
}
|
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 语音签名的返回值
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type GetVoiceSignReturnType = {
|
|
5
|
+
/**
|
|
6
|
+
* rtc 的 sdkAppId
|
|
7
|
+
*/
|
|
5
8
|
sdkAppId: number;
|
|
9
|
+
/**
|
|
10
|
+
* rtc 的 用户 id
|
|
11
|
+
*/
|
|
6
12
|
userId: string;
|
|
13
|
+
/**
|
|
14
|
+
* rtc 的 语音房间号
|
|
15
|
+
*/
|
|
7
16
|
roomId: string | number;
|
|
17
|
+
/**
|
|
18
|
+
* rtc 的 用户签名
|
|
19
|
+
*/
|
|
8
20
|
userSig: string;
|
|
9
|
-
}
|
|
21
|
+
};
|
|
10
22
|
/**
|
|
11
|
-
*
|
|
23
|
+
* 获取用户语音签名的参数
|
|
12
24
|
*/
|
|
13
|
-
export type
|
|
25
|
+
export type GetVoiceSignParams = {
|
|
26
|
+
/**
|
|
27
|
+
* 语音房间号
|
|
28
|
+
*/
|
|
14
29
|
voiceId: string;
|
|
30
|
+
/**
|
|
31
|
+
* 用户 id
|
|
32
|
+
*/
|
|
15
33
|
userId: string;
|
|
34
|
+
/**
|
|
35
|
+
* 房间 id
|
|
36
|
+
*/
|
|
16
37
|
roomId: string | number;
|
|
17
|
-
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 获取用户语音签名的方法
|
|
41
|
+
* @param voiceId 语音房间号
|
|
42
|
+
* @param userId 用户 id
|
|
43
|
+
* @param roomId 房间 id
|
|
44
|
+
*/
|
|
45
|
+
export type GetVoiceSign = (params: GetVoiceSignParams) => Promise<GetVoiceSignReturnType>;
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import { MicroStatus } from "./LiveMsg";
|
|
2
|
+
/**
|
|
3
|
+
* 带看连接配置项
|
|
4
|
+
*/
|
|
2
5
|
export type LiveConnectOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* 这个是带看房间的 ws 地址
|
|
8
|
+
*/
|
|
3
9
|
url?: string;
|
|
10
|
+
/**
|
|
11
|
+
* 是否强制加入
|
|
12
|
+
* 如果为 true,会强制加入房间,不管之前是否已经加入,会把之前的连接断开
|
|
13
|
+
* 如果为 false,会检查是否已经加入房间,如果已经加入,不会再次加入
|
|
14
|
+
*/
|
|
4
15
|
force?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 获取带看房间 ticket 的方法
|
|
18
|
+
*/
|
|
5
19
|
getTicket?: () => Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* 初始的麦克风状态
|
|
22
|
+
*/
|
|
6
23
|
rtcMicStatus?: MicroStatus;
|
|
7
24
|
};
|
|
@@ -4,13 +4,21 @@
|
|
|
4
4
|
* - 上行:客户端上报数据
|
|
5
5
|
*/
|
|
6
6
|
export declare enum Command {
|
|
7
|
+
/** 当前用户信息:下行 */
|
|
7
8
|
SelfUserInfo = "SELF_USER_INFO",
|
|
9
|
+
/** 房间信息:下行 */
|
|
8
10
|
RoomInfo = "ROOM_INFO",
|
|
11
|
+
/** RTC信息:下行 */
|
|
9
12
|
RTCInfo = "RTC_INFO",
|
|
13
|
+
/** 用户列表:下行 */
|
|
10
14
|
UserList = "USER_LIST",
|
|
15
|
+
/** 内置消息:下行、上行 */
|
|
11
16
|
BuiltinMsg = "BUILTIN_MSG",
|
|
17
|
+
/** 自定义广播事件消息:下行、上行 */
|
|
12
18
|
CustomEvent = "CUSTOM_EVENT",
|
|
19
|
+
/** 帧数据同步:下行、上行 */
|
|
13
20
|
KeyframeSync = "KEYFRAME_SYNC",
|
|
21
|
+
/** 被踢出房间:下行 */
|
|
14
22
|
UserKickOut = "USER_KICK_OUT"
|
|
15
23
|
}
|
|
16
24
|
/**
|
|
@@ -94,7 +102,13 @@ export type BuiltinMsg = {
|
|
|
94
102
|
* 麦克风状态。
|
|
95
103
|
*/
|
|
96
104
|
export declare enum MicroStatus {
|
|
105
|
+
/**
|
|
106
|
+
* 打开
|
|
107
|
+
*/
|
|
97
108
|
OPEN = "OPEN",
|
|
109
|
+
/**
|
|
110
|
+
* 关闭
|
|
111
|
+
*/
|
|
98
112
|
CLOSE = "CLOSE"
|
|
99
113
|
}
|
|
100
114
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UserVolume } from
|
|
2
|
-
import { RTCJoinedInfo } from
|
|
1
|
+
import { UserVolume } from "../live/UserVolume";
|
|
2
|
+
import { RTCJoinedInfo } from "./joinedInfo";
|
|
3
3
|
/**
|
|
4
4
|
* RTC 异步事件类型。
|
|
5
5
|
*/
|
|
@@ -8,22 +8,37 @@ export type RTCEventType = {
|
|
|
8
8
|
* 错误\异常
|
|
9
9
|
* @param error
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
"error"(error: Error | RTCJoinedInfo): void;
|
|
12
12
|
/**
|
|
13
13
|
* 即将加入房间。
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
"joinWillStart"(): void;
|
|
16
16
|
/**
|
|
17
17
|
* 成功加入语音房间。
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
"joined"(): void;
|
|
20
20
|
/**
|
|
21
21
|
* 弱网提醒事件。
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
"weakNetwork"(): void;
|
|
24
24
|
/**
|
|
25
25
|
* 每个用户的音量。
|
|
26
26
|
* @param userVolumes
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
"userVolumes"(userVolumes: UserVolume[]): void;
|
|
29
|
+
/**
|
|
30
|
+
* rtc 成功
|
|
31
|
+
* @inner 内置事件,行为会随版本变更,请勿通过外部注册监听
|
|
32
|
+
*/
|
|
33
|
+
"inner.rtc.success"(result: RTCJoinedInfo | boolean): void;
|
|
34
|
+
/**
|
|
35
|
+
* rtc 失败
|
|
36
|
+
* @inner 内置事件,行为会随版本变更,请勿通过外部注册监听
|
|
37
|
+
*/
|
|
38
|
+
"inner.rtc.fail"(result: RTCJoinedInfo | boolean): void;
|
|
39
|
+
/**
|
|
40
|
+
* rtc 错误
|
|
41
|
+
* @inner 内置事件,行为会随版本变更,请勿通过外部注册监听
|
|
42
|
+
*/
|
|
43
|
+
"inner.rtc.error"(error: Error): void;
|
|
29
44
|
};
|