@realsee/live 0.4.0-beta.8 → 0.5.0-alpha.11
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/live/controller.d.ts +81 -38
- package/dist/live/createLive.d.ts +5 -3
- package/dist/live/createLiveReact.d.ts +49 -3
- package/dist/live/live.d.ts +170 -0
- package/dist/realsee-live.cjs.development.js +1654 -1445
- package/dist/realsee-live.cjs.development.js.map +1 -1
- package/dist/realsee-live.cjs.production.js +1 -1
- package/dist/realsee-live.cjs.production.js.map +1 -1
- package/dist/realsee-live.esm.js +1656 -1447
- package/dist/realsee-live.esm.js.map +1 -1
- package/dist/realsee-live.umd.development.js +51598 -51332
- package/dist/realsee-live.umd.development.js.map +1 -1
- package/dist/realsee-live.umd.production.js +1 -1
- package/dist/realsee-live.umd.production.js.map +1 -1
- package/dist/typings/live/EventType.d.ts +17 -33
- package/dist/typings/live/LiveConnectOptions.d.ts +7 -0
- package/dist/typings/live/LiveErrorType.d.ts +9 -0
- package/dist/typings/live/LiveOptions.d.ts +5 -12
- package/dist/typings/live/LiveState.d.ts +15 -0
- package/dist/typings/live/index.d.ts +2 -1
- package/dist/typings/react/index.d.ts +0 -1
- package/dist/utils/RobustWebSocket.d.ts +153 -0
- package/dist/utils/logger.d.ts +16 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/VRWebViewRTC.html +5 -5
- package/docs/enums/LiveState.html +7 -0
- package/docs/index.html +1 -1
- package/docs/interfaces/LiveOptions.html +16 -19
- package/docs/modules.html +40 -40
- package/package.json +2 -2
- package/dist/typings/live/Live.d.ts +0 -128
- package/dist/typings/react/LiveReact.d.ts +0 -164
- package/docs/interfaces/Live.html +0 -116
- package/docs/interfaces/LiveReact.html +0 -52
|
@@ -1,43 +1,86 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
import { LiveMsg } from '../typings';
|
|
2
|
+
import { LiveState } from '../typings/live/LiveState';
|
|
3
|
+
import { RobustWebSocketEventDetail } from '../utils/RobustWebSocket';
|
|
4
|
+
import { Subscribe } from '../utils/subscribe';
|
|
5
|
+
export declare type LiveControllerEventMap = {
|
|
6
|
+
stateChange: (state: LiveState, prevState: LiveState) => void;
|
|
7
|
+
message: (message: LiveMsg) => void;
|
|
8
|
+
reconnected: (detail: RobustWebSocketEventDetail) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare class LiveController extends Subscribe<LiveControllerEventMap> {
|
|
11
|
+
/**
|
|
12
|
+
* ws代理器
|
|
13
|
+
*/
|
|
14
|
+
private _ws;
|
|
15
|
+
/**
|
|
16
|
+
* 带看连接状态
|
|
17
|
+
*/
|
|
18
|
+
private _state;
|
|
19
|
+
set state(state: LiveState);
|
|
20
|
+
get state(): LiveState;
|
|
21
|
+
constructor();
|
|
22
|
+
/**
|
|
23
|
+
* 添加事件监听
|
|
24
|
+
*/
|
|
25
|
+
private _addWebSocketEventListeners;
|
|
26
|
+
/**
|
|
27
|
+
* 移除事件监听
|
|
28
|
+
*/
|
|
29
|
+
private _removeWebSocketEventListeners;
|
|
30
|
+
/**
|
|
31
|
+
* 处理房间关闭事件
|
|
32
|
+
* @param event
|
|
33
|
+
*/
|
|
34
|
+
private _handleCloseEvent;
|
|
35
|
+
/**
|
|
36
|
+
* 处理房间正在关闭事件(这个时候可能是断网了)
|
|
37
|
+
*/
|
|
38
|
+
private _handleClosingEvent;
|
|
39
|
+
/**
|
|
40
|
+
* 连接中
|
|
41
|
+
* @param event
|
|
42
|
+
*/
|
|
43
|
+
private _handleConnectingEvent;
|
|
44
|
+
/**
|
|
45
|
+
* 连接发送异常
|
|
46
|
+
* @param event
|
|
47
|
+
*/
|
|
48
|
+
private _handleErrorEvent;
|
|
49
|
+
/**
|
|
50
|
+
* 接收到消息
|
|
51
|
+
* @param event
|
|
52
|
+
*/
|
|
53
|
+
private _handleMessageEvent;
|
|
54
|
+
/**
|
|
55
|
+
* 连接建立成功
|
|
56
|
+
* @param event
|
|
57
|
+
*/
|
|
58
|
+
private _handleOpenEvent;
|
|
59
|
+
/**
|
|
60
|
+
* 处理超时
|
|
61
|
+
* @param event
|
|
62
|
+
*/
|
|
63
|
+
private _handleTimeoutEvent;
|
|
64
|
+
/**
|
|
65
|
+
* 释放资源,释放之后需要重新实例化
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
dispose: () => Promise<boolean>;
|
|
69
|
+
/**
|
|
70
|
+
* 开启房间链接
|
|
71
|
+
* @param url 房间链接
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
open: (url: string) => void;
|
|
75
|
+
/**
|
|
76
|
+
* 关闭房间
|
|
77
|
+
* @param code
|
|
78
|
+
* @param reason
|
|
79
|
+
*/
|
|
80
|
+
close: (code?: string | number | undefined, reason?: string | undefined) => Promise<boolean>;
|
|
38
81
|
/**
|
|
39
82
|
* 发送数据
|
|
40
83
|
* @param data
|
|
41
84
|
*/
|
|
42
|
-
sendMessage(data
|
|
85
|
+
sendMessage(data?: any): void | undefined;
|
|
43
86
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Live } from '../typings/live/Live';
|
|
2
1
|
import { LiveOptions } from '../typings/live/LiveOptions';
|
|
2
|
+
import { Live } from './live';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 创建`Live`实例
|
|
5
|
+
* @param opts
|
|
6
|
+
* @returns
|
|
5
7
|
*/
|
|
6
|
-
export declare
|
|
8
|
+
export declare const createLive: <KeyframesSnapshot>(opts: LiveOptions) => Live<KeyframesSnapshot>;
|
|
@@ -1,6 +1,52 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BuiltinActionType, BuiltinEventType, KeyframeTypes, LiveConnectOptions, LiveEventType, LiveOptions, MicroStatus, RTCEventType, RTCType, UserInfo } from '../typings';
|
|
3
|
+
import { LiveState } from '../typings/live/LiveState';
|
|
4
|
+
import { Live } from './live';
|
|
5
|
+
export declare type LiveProviderPropTypes<KeyframesSnapshot> = {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
live?: Live<KeyframesSnapshot>;
|
|
8
|
+
};
|
|
3
9
|
/**
|
|
4
10
|
* 创建 {@link LiveReact} 实例,并提供 `React` 技术栈相关工具链。
|
|
5
11
|
*/
|
|
6
|
-
export declare function createLiveReact<
|
|
12
|
+
export declare function createLiveReact<KeyframesSnapshot>(options: LiveOptions): {
|
|
13
|
+
live: Live<KeyframesSnapshot>;
|
|
14
|
+
jsBridge: import("@realsee/jsbridge-x").JSBridgeProtocol;
|
|
15
|
+
LiveProvider: (props: LiveProviderPropTypes<KeyframesSnapshot>) => JSX.Element;
|
|
16
|
+
unsafe__useLiveInstance: () => Live<KeyframesSnapshot>;
|
|
17
|
+
unsafe__useRTCInstance: () => import("../typings").RTCProtocol;
|
|
18
|
+
useConnect: () => (options: LiveConnectOptions) => Promise<boolean | Error>;
|
|
19
|
+
useKeyframe: <K extends keyof KeyframesSnapshot>(key: K) => [frame: KeyframesSnapshot[K] | undefined, setFrame: (frame: KeyframesSnapshot[K]) => boolean | Error];
|
|
20
|
+
useKeyframeUpdateCallback: <KeyOfKeyframe extends keyof KeyframeTypes<KeyframesSnapshot>>(key: KeyOfKeyframe, callback: (...args: Parameters<KeyframeTypes<KeyframesSnapshot>[KeyOfKeyframe]>) => ReturnType<KeyframeTypes<KeyframesSnapshot>[KeyOfKeyframe]>, deps?: React.DependencyList) => () => void;
|
|
21
|
+
useLiveAction: () => {
|
|
22
|
+
connect: (options: LiveConnectOptions) => Promise<boolean | Error>;
|
|
23
|
+
broadcast: (data: Record<string, any>, toUserIds: string | string[], timeout?: any) => Promise<unknown>;
|
|
24
|
+
exit: () => Promise<boolean>;
|
|
25
|
+
kick: (toUserIds: string | string[]) => Promise<boolean>;
|
|
26
|
+
toggleMicro: (microStatus: boolean) => Promise<boolean>;
|
|
27
|
+
forbidMicro: (micro: MicroStatus, toUserIds?: string | string[]) => Promise<boolean>;
|
|
28
|
+
forbidSync: (sync: boolean, toUserIds?: string | string[]) => Promise<boolean>;
|
|
29
|
+
sendKeyframe: (key: keyof KeyframesSnapshot, frame: KeyframesSnapshot[keyof KeyframesSnapshot]) => boolean | Error;
|
|
30
|
+
getFramesByKey: (key: keyof KeyframesSnapshot) => Partial<KeyframesSnapshot>[keyof KeyframesSnapshot] | undefined;
|
|
31
|
+
setSelfInfo: (userInfo: Partial<UserInfo>) => Promise<boolean>;
|
|
32
|
+
updateStatus: (evtType: BuiltinEventType, atnType: BuiltinActionType, status: Record<string, any>, toUserIds?: string | string[]) => Promise<boolean>;
|
|
33
|
+
};
|
|
34
|
+
useLiveEventCallback: <K_1 extends keyof LiveEventType<KeyframesSnapshot>>(name: K_1, callback: (...args: Parameters<LiveEventType<KeyframesSnapshot>[K_1]>) => ReturnType<LiveEventType<KeyframesSnapshot>[K_1]>, deps?: React.DependencyList) => () => void;
|
|
35
|
+
useLiveState: () => LiveState;
|
|
36
|
+
useRTCAction: () => {
|
|
37
|
+
join: (options: {
|
|
38
|
+
voiceId: string;
|
|
39
|
+
userId: string;
|
|
40
|
+
roomId: string;
|
|
41
|
+
type: RTCType;
|
|
42
|
+
}) => Promise<boolean>;
|
|
43
|
+
quit: () => Promise<boolean>;
|
|
44
|
+
shock: () => void | undefined;
|
|
45
|
+
toggleMicro: (flag?: boolean | undefined) => Promise<boolean>;
|
|
46
|
+
detectMicro: () => Promise<boolean>;
|
|
47
|
+
};
|
|
48
|
+
useRTCEventCallback: <K_2 extends keyof RTCEventType>(name: K_2, callback: (...args: Parameters<RTCEventType[K_2]>) => ReturnType<RTCEventType[K_2]>, deps?: React.DependencyList) => () => void;
|
|
49
|
+
useSelfInfo: () => [Partial<UserInfo>, (userInfo: Partial<UserInfo>) => Promise<boolean | Error>];
|
|
50
|
+
useKeyframesSnapshot: () => Partial<KeyframesSnapshot>;
|
|
51
|
+
useUserList: () => UserInfo[];
|
|
52
|
+
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { JSBridgeProtocol } from '@realsee/jsbridge-x';
|
|
2
|
+
import { RTCProtocol } from '../rtc';
|
|
3
|
+
import { EventType, KeyframeTypes, LiveOptions, RoomInfo, RTCType, UserInfo, BuiltinEventType, BuiltinActionType, MicroStatus, LiveConnectOptions } from '../typings';
|
|
4
|
+
import { LiveState } from '../typings/live/LiveState';
|
|
5
|
+
import { Subscribe } from '../utils/subscribe';
|
|
6
|
+
export declare type LiveBuiltInData<KeyframesSnapshot> = {
|
|
7
|
+
selfInfo?: UserInfo;
|
|
8
|
+
userList?: UserInfo[];
|
|
9
|
+
roomInfo?: RoomInfo;
|
|
10
|
+
rtcInfo?: {
|
|
11
|
+
voiceId: string;
|
|
12
|
+
type: RTCType;
|
|
13
|
+
};
|
|
14
|
+
keyframes: Partial<KeyframesSnapshot>;
|
|
15
|
+
};
|
|
16
|
+
export declare const _clearLiveInstanceIfNeed: () => void;
|
|
17
|
+
export declare class Live<KeyframesSnapshot extends Record<string, any>> extends Subscribe<EventType<KeyframesSnapshot>> {
|
|
18
|
+
/**
|
|
19
|
+
* 带看的配置
|
|
20
|
+
*/
|
|
21
|
+
private _options;
|
|
22
|
+
get options(): LiveOptions;
|
|
23
|
+
/**
|
|
24
|
+
* 带看状态
|
|
25
|
+
*/
|
|
26
|
+
get state(): LiveState;
|
|
27
|
+
/**
|
|
28
|
+
* 兼容老逻辑
|
|
29
|
+
* @deprecated 请直接读取 state 属性字段,未来将移除该属性
|
|
30
|
+
*/
|
|
31
|
+
get readyState(): LiveState;
|
|
32
|
+
/**
|
|
33
|
+
* 获取当前WebSocket连接的URL。(注意:这个是WebSocket连接的完整连接,附带一些query参数)。
|
|
34
|
+
* @deprecated 带看不需要关注底层ws的相关信息,未来将移除
|
|
35
|
+
*/
|
|
36
|
+
get url(): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* 获取当前live使用的RTC实例
|
|
39
|
+
*/
|
|
40
|
+
get $RTC(): RTCProtocol;
|
|
41
|
+
/**
|
|
42
|
+
* 获取当前live使用的jsBridge实例
|
|
43
|
+
*/
|
|
44
|
+
get jsBridge(): JSBridgeProtocol;
|
|
45
|
+
/**
|
|
46
|
+
* 帧数据监听
|
|
47
|
+
*/
|
|
48
|
+
keyframes: Subscribe<KeyframeTypes<KeyframesSnapshot>>;
|
|
49
|
+
/**
|
|
50
|
+
* 内置的一些数据
|
|
51
|
+
*/
|
|
52
|
+
private _buildInData;
|
|
53
|
+
/**
|
|
54
|
+
* 当前帧数据快照
|
|
55
|
+
*/
|
|
56
|
+
get snapshot(): Partial<KeyframesSnapshot>;
|
|
57
|
+
/**
|
|
58
|
+
* 根据键值取帧数据
|
|
59
|
+
* @param key 帧数据的键值
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
getFramesByKey: <Key extends keyof KeyframesSnapshot>(key: Key) => Partial<KeyframesSnapshot>[Key] | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* 发送帧数据(需要能够被序列化)
|
|
65
|
+
* @param key 帧数据键值
|
|
66
|
+
* @param frame 帧数据本体
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
sendKeyframe: <Key extends keyof KeyframesSnapshot>(key: Key, frame: KeyframesSnapshot[Key]) => boolean | Error;
|
|
70
|
+
/**
|
|
71
|
+
* 当前用户信息
|
|
72
|
+
*/
|
|
73
|
+
get selfInfo(): UserInfo | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* 当前用户列表
|
|
76
|
+
*/
|
|
77
|
+
get userList(): UserInfo[];
|
|
78
|
+
/**
|
|
79
|
+
* 当前带看房间信息
|
|
80
|
+
*/
|
|
81
|
+
get roomInfo(): RoomInfo | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* 带看控制器
|
|
84
|
+
*/
|
|
85
|
+
private _controller;
|
|
86
|
+
constructor(opts: LiveOptions);
|
|
87
|
+
/**
|
|
88
|
+
* 添加带看控制的事件监听
|
|
89
|
+
*/
|
|
90
|
+
private _addLiveControllerEventListeners;
|
|
91
|
+
/**
|
|
92
|
+
* 移除带看控制的事件监听
|
|
93
|
+
*/
|
|
94
|
+
private _removeLiveControllerEventListeners;
|
|
95
|
+
/**
|
|
96
|
+
* 带看状态变化
|
|
97
|
+
* @param state
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
private _handleStateChange;
|
|
101
|
+
/**
|
|
102
|
+
* 消息接收
|
|
103
|
+
* @param liveMsg
|
|
104
|
+
*/
|
|
105
|
+
private _handleMessage;
|
|
106
|
+
/**
|
|
107
|
+
* 清理带看缓存的数据
|
|
108
|
+
*/
|
|
109
|
+
private _clearLiveData;
|
|
110
|
+
/**
|
|
111
|
+
* 连接带看
|
|
112
|
+
* @param options
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
connect: (options?: LiveConnectOptions) => Promise<boolean | Error>;
|
|
116
|
+
/**
|
|
117
|
+
* 退出带看
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
exit: () => Promise<boolean>;
|
|
121
|
+
/**
|
|
122
|
+
* 销毁带看
|
|
123
|
+
* @returns
|
|
124
|
+
*/
|
|
125
|
+
dispose: () => Promise<boolean>;
|
|
126
|
+
/**
|
|
127
|
+
* 修改状态
|
|
128
|
+
* @param evtType
|
|
129
|
+
* @param atnType
|
|
130
|
+
* @param status
|
|
131
|
+
* @param toUserIds
|
|
132
|
+
* @returns
|
|
133
|
+
*/
|
|
134
|
+
updateStatus(evtType: BuiltinEventType, atnType: BuiltinActionType, status: Record<string, any>, toUserIds?: string | string[]): Promise<boolean>;
|
|
135
|
+
/**
|
|
136
|
+
* 设置自己的用户信息
|
|
137
|
+
* @param userInfo
|
|
138
|
+
* @returns
|
|
139
|
+
*/
|
|
140
|
+
setSelfInfo: (userInfo: Partial<UserInfo>) => Promise<boolean>;
|
|
141
|
+
/**
|
|
142
|
+
* 自定义广播
|
|
143
|
+
* @param request 广播请求的数据
|
|
144
|
+
* @param toUserIds
|
|
145
|
+
* @param timeout
|
|
146
|
+
* @returns
|
|
147
|
+
*/
|
|
148
|
+
broadcast<Request, Response>(request: Request, toUserIds: string | string[], timeout: number): Promise<Response> | Error | false;
|
|
149
|
+
toggleMicro: (microStatus: boolean) => Promise<boolean>;
|
|
150
|
+
/**
|
|
151
|
+
* 控制别人的麦
|
|
152
|
+
* @param microStatus
|
|
153
|
+
* @param toUserIds
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
156
|
+
forbidMicro: (microStatus: MicroStatus, toUserIds: string | string[]) => Promise<boolean>;
|
|
157
|
+
/**
|
|
158
|
+
* 控制别人的同步全量帧数据权限
|
|
159
|
+
* @param sync
|
|
160
|
+
* @param toUserIds
|
|
161
|
+
* @returns
|
|
162
|
+
*/
|
|
163
|
+
forbidSync: (sync: boolean, toUserIds: string | string[]) => Promise<boolean>;
|
|
164
|
+
/**
|
|
165
|
+
* 把用户踢出带看
|
|
166
|
+
* @param toUserIds
|
|
167
|
+
* @returns
|
|
168
|
+
*/
|
|
169
|
+
kick: (toUserIds: string | string[]) => Promise<boolean>;
|
|
170
|
+
}
|