@realsee/live 0.4.0-beta.8 → 0.5.0-alpha.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.
Files changed (33) hide show
  1. package/dist/live/controller.d.ts +75 -38
  2. package/dist/live/createLive.d.ts +5 -3
  3. package/dist/live/createLiveReact.d.ts +49 -3
  4. package/dist/live/live.d.ts +162 -0
  5. package/dist/realsee-live.cjs.development.js +1561 -1447
  6. package/dist/realsee-live.cjs.development.js.map +1 -1
  7. package/dist/realsee-live.cjs.production.js +1 -1
  8. package/dist/realsee-live.cjs.production.js.map +1 -1
  9. package/dist/realsee-live.esm.js +1564 -1450
  10. package/dist/realsee-live.esm.js.map +1 -1
  11. package/dist/realsee-live.umd.development.js +51492 -51332
  12. package/dist/realsee-live.umd.development.js.map +1 -1
  13. package/dist/realsee-live.umd.production.js +1 -1
  14. package/dist/realsee-live.umd.production.js.map +1 -1
  15. package/dist/typings/live/EventType.d.ts +17 -33
  16. package/dist/typings/live/LiveConnectOptions.d.ts +7 -0
  17. package/dist/typings/live/LiveErrorType.d.ts +9 -0
  18. package/dist/typings/live/LiveOptions.d.ts +5 -12
  19. package/dist/typings/live/LiveState.d.ts +15 -0
  20. package/dist/typings/live/index.d.ts +2 -1
  21. package/dist/typings/react/index.d.ts +0 -1
  22. package/dist/utils/RobustWebSocket.d.ts +130 -0
  23. package/dist/utils/logger.d.ts +16 -0
  24. package/docs/assets/search.js +1 -1
  25. package/docs/enums/LiveState.html +7 -0
  26. package/docs/index.html +1 -1
  27. package/docs/interfaces/LiveOptions.html +16 -19
  28. package/docs/modules.html +34 -40
  29. package/package.json +2 -2
  30. package/dist/typings/live/Live.d.ts +0 -128
  31. package/dist/typings/react/LiveReact.d.ts +0 -164
  32. package/docs/interfaces/Live.html +0 -116
  33. package/docs/interfaces/LiveReact.html +0 -52
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realsee/live",
3
- "version": "0.4.0-beta.8",
3
+ "version": "0.5.0-alpha.3",
4
4
  "description": "如视 Live SDK:基于如视 WebSocket 长链双工通信能力的前端封装,借助此 SDK 您可以快捷地实现具备同屏连线、实时语音的 VR 带看业务能力。",
5
5
  "main": "dist/realsee-live.cjs.js",
6
6
  "module": "dist/realsee-live.esm.js",
@@ -20,7 +20,7 @@
20
20
  "typescript": "^4.7.2"
21
21
  },
22
22
  "dependencies": {
23
- "@realsee/jsbridge-x": "0.2.1-beta.3",
23
+ "@realsee/jsbridge-x": "0.2.2-alpha.2",
24
24
  "amazon-chime-sdk-js": "^2.26.1",
25
25
  "react": "^17.0.2",
26
26
  "trtc-js-sdk": "^4.12.5"
@@ -1,128 +0,0 @@
1
- import { UserInfo } from './UserInfo';
2
- import { LiveOptions } from './LiveOptions';
3
- import { EventType, KeyframeTypes } from './EventType';
4
- import { WebSocketState } from './WebSocket';
5
- import { BuiltinActionType, BuiltinEventType, MicroStatus } from './LiveMsg';
6
- import { Subscribe } from '../../utils/subscribe';
7
- import { RTCProtocol } from '../rtc/protocol';
8
- import { JSBridgeProtocol } from '@realsee/jsbridge-x';
9
- /**
10
- * Live 实例。
11
- */
12
- export interface Live<Snapshot extends Record<string, any>> extends Subscribe<EventType<Snapshot>> {
13
- get options(): LiveOptions;
14
- /**
15
- * 更新本地用户信息
16
- * @param userInfo
17
- */
18
- setSelfInfo(userInfo: Partial<UserInfo>): Promise<boolean | Error>;
19
- /**
20
- * 获取本地用户信息
21
- */
22
- get selfInfo(): UserInfo | undefined;
23
- /**
24
- * 获取当前WebSocket的连接状态。
25
- * @deprecated 带看不需要关注底层ws的状态,未来将移除
26
- */
27
- get readyState(): WebSocketState;
28
- /**
29
- * 获取当前会话房间内用户列表。
30
- */
31
- get userList(): UserInfo[];
32
- /**
33
- * 获取当前帧数据快照。
34
- */
35
- get snapshot(): Partial<Snapshot>;
36
- /**
37
- * 获取当前WebSocket连接的URL。(注意:这个是WebSocket连接的完整连接,附带一些query参数)。
38
- * @deprecated 带看不需要关注底层ws的相关信息,未来将移除
39
- */
40
- get url(): string;
41
- /**
42
- * 获取当前live使用的RTC实例
43
- */
44
- get $RTC(): RTCProtocol;
45
- /**
46
- * 获取当前live使用的jsBridge实例
47
- */
48
- get jsBridge(): JSBridgeProtocol;
49
- /**
50
- * 帧数据监听
51
- */
52
- keyframes: Subscribe<KeyframeTypes<Snapshot>>;
53
- /**
54
- * 根据某条 key 获取某条帧数据
55
- * @param keys
56
- * @returns 帧数据
57
- */
58
- getFramesByKey<Key extends keyof Snapshot>(key: Key): Partial<Snapshot>[Key] | undefined;
59
- /**
60
- * 发送帧数据
61
- * @param key
62
- * @param frame
63
- * @returns
64
- */
65
- sendKeyframe<Key extends keyof Snapshot>(key: Key, frame: Snapshot[Key]): boolean | Error;
66
- /**
67
- * 自定义广播事件
68
- * @param data 广播数据:这个数据需要自定义格式,此处不做任何约束。
69
- * @param toUserIds 希望收到此广播事件的用户,为空时则向所有用户广播。
70
- * @param timeout 等待广播结果的超时设置;默认为"0",表示一直等结果。
71
- * @returns
72
- */
73
- broadcast<D, R>(data: D, toUserIds: string | string[], timeout: number): Promise<R> | Error;
74
- /**
75
- * 更新用户或房间状态。
76
- * @param eventType 事件枚举
77
- * @param actionType 行为枚举
78
- * @param status 状态值
79
- * @param toUserIds 面向的用户。
80
- */
81
- updateStatus(eventType: BuiltinEventType, actionType: BuiltinActionType, status: Record<string, any>, toUserIds?: string | string[]): Promise<boolean>;
82
- /**
83
- * 执行WebSocket连接
84
- * @param force 为true时则强制重连
85
- * @returns
86
- */
87
- connect(options?: {
88
- url?: string;
89
- force?: boolean;
90
- }): Promise<boolean | Error>;
91
- /**
92
- * 开启/关闭自己的麦克风
93
- * @param microStatus true 开启麦克风;false 关闭麦克风
94
- * @return
95
- * */
96
- toggleMicro(microStatus: boolean): Promise<boolean>;
97
- /**
98
- * 关闭/开启某个或某些用户的麦克风
99
- * @param micro true 开启麦克风;false 关闭麦克风
100
- * @param toUserIds 希望关闭/开启麦克风的用户,为空时则面向所有用户。
101
- * @returns
102
- */
103
- forbidMicro(micro: MicroStatus, toUserIds?: string[] | string): Promise<boolean>;
104
- /**
105
- * 限制/开启某个或某些用户同步帧数据
106
- * @param sync true 开启同步;false 限制同步
107
- * @param toUserIds 希望限制/开启同步能力的用户,为空时则面向所有用户。
108
- * @deprecated 暂不支持
109
- * @returns
110
- *
111
- */
112
- /**
113
- * "踢人":强制让某个用户离开附近。
114
- * @param toUserIds 被"踢"的用户。
115
- * @returns
116
- */
117
- kick(toUserIds: string[] | string): Promise<boolean>;
118
- /**
119
- * 退出带看
120
- * @returns
121
- */
122
- exit(): Promise<boolean>;
123
- /**
124
- * 废弃掉当前实例依赖。
125
- */
126
- revoke(): Promise<boolean>;
127
- }
128
- export declare type LiveActionReactCallback<Snapshot extends Record<string, any>> = Pick<Live<Snapshot>, 'broadcast' | 'exit' | 'kick' | 'toggleMicro' | 'forbidMicro' | 'sendKeyframe' | 'getFramesByKey' | 'setSelfInfo' | 'updateStatus'>;
@@ -1,164 +0,0 @@
1
- import { JSBridgeProtocol } from '@realsee/jsbridge-x';
2
- import React from 'react';
3
- import { KeyframeTypes, LiveEventType, WebSocketEventType } from '../live/EventType';
4
- import { Live, LiveActionReactCallback } from '../live/Live';
5
- import { UserInfo } from '../live/UserInfo';
6
- import { WebSocketState } from '../live/WebSocket';
7
- import { RTCEventType } from '../rtc/eventType';
8
- import { RTCProtocol } from '../rtc/protocol';
9
- import { RTCActionReactCallback } from './RTCActionReactCallback';
10
- export declare type LiveProviderPropTypes<Snapshot> = {
11
- children?: React.ReactNode;
12
- live?: Live<Snapshot>;
13
- };
14
- /**
15
- * @example
16
- *
17
- * 新建文件`LiveReact.ts` 创建一个 {@link LiveReact} 实例对象:
18
- *
19
- * ```js
20
- * import { createLiveReact } from '@realsee/live'
21
- * const LiveReact = createLiveReact({ getTicket: async () => '' })
22
- * export default LiveReact
23
- * ```
24
- *
25
- *
26
- */
27
- export interface LiveReact</* 帧数据 */ Snapshot> {
28
- live: Live<Snapshot>;
29
- jsBridge: JSBridgeProtocol;
30
- /**
31
- * @description **LiveProvider** 基于 [React Context](https://reactjs.org/docs/context.html) 对 {@link Live }进行封装,你可以以 [React Hooks](https://reactjs.org/docs/hooks-intro.html) 的方式对 {@link Live } 实例进行操作、数据监听等。
32
- *
33
- * 在 `React` 环境中使用 {@link LiveReact.LiveProvider} 组件:
34
- *
35
- * ```ts
36
- * import { LiveProvider } from './LiveReact'
37
- * ReactDOM.render(<LiveProvider><App></LiveProvider>, containter)
38
- * ```
39
- */
40
- LiveProvider: (props: LiveProviderPropTypes<Snapshot>) => JSX.Element;
41
- /**
42
- * @deprecated 获取 `live` 实例,**不鼓励使用**
43
- */
44
- unsafe__useLiveInstance: () => Live<Snapshot>;
45
- /**
46
- * @deprecated 获取 `RTC` 实例,**不鼓励使用**
47
- */
48
- unsafe__useRTCInstance: () => RTCProtocol;
49
- /**
50
- *
51
- * @description 获取当前 WebSocket 连接的 URL,如果尚未创建 WebSocket 实例,则值为 `undefined`。
52
- * 如果有重连等事件发生 URL 值会发生更新。
53
- *
54
- * ```ts
55
- * import { useCurrentWebSocketUrl } from './LiveReact'
56
- * function ReactComponent() {
57
- * const url = useCurrentWebSocketUrl()
58
- * return <div>当前URL: {url}.</div>
59
- * }
60
- * ```
61
- */
62
- useCurrentWebSocketUrl: () => string | undefined;
63
- /**
64
- * @description 连接 WebSocket 服务。如果 WebSocket 已经连接则什么都不做,若提供 `{force: true}` 则会强制重连。
65
- *
66
- *
67
- * ```jsx
68
- * import { useConnect } from './LiveReact'
69
- * function ReactComponent() {
70
- * const connect = useConnect()
71
- * return <button onClick={() => connect()}>点击连接</button>
72
- * }
73
- * ```
74
- *
75
- */
76
- useConnect: () => (options?: {
77
- force?: boolean;
78
- url?: string;
79
- getTicket?: () => Promise<string>;
80
- }) => Promise<boolean | Error>;
81
- /**
82
- *
83
- * @description 帧数据状态值。如果执行 `setKeyframe()` 则会传递 WebSocket 帧同步指令;若通过 WebSocket 收到新帧数据则会更新当前状态值。
84
- *
85
- * ```typescript
86
- * function LocalFiveState() {
87
- * const [keyframe, setKeyframe] = LiveReact.useKeyframe('five')
88
- * return (<div>{JSON.stringify(keyframe)}</div>)
89
- * }
90
- * ```
91
- */
92
- useKeyframe: <K extends keyof Snapshot>(frameName: K) => [
93
- frame: Snapshot[K] | undefined,
94
- setFrame: (frame: Snapshot[K]) => boolean | Error
95
- ];
96
- /**
97
- *
98
- */
99
- useKeyframeUpdateCallback: <K extends keyof KeyframeTypes<Snapshot>>(name: K, callback: (...args: Parameters<KeyframeTypes<Snapshot>[K]>) => ReturnType<KeyframeTypes<Snapshot>[K]>, deps?: React.DependencyList) => () => void;
100
- /**
101
- *
102
- * @function broadcast 广播消息,详见 {@link Live.broadcast}。
103
- * @function exit 退出带看,详见 {@link Live.exit}。
104
- * @function kick 踢出带看,详见 {@link Live.kick}。
105
- * @function toggleMicro 打开/关闭自己的麦克风,详见 {@link Live.toggleMicro}。
106
- * @function forbidMicro 禁止麦克风,详见 {@link Live.forbidMicro}。
107
- * @function sendKeyframe 发送帧数据,详见 {@link Live.sendKeyframe}。
108
- * @function getFramesByKey 根据`key`从帧快照中获取某条帧数据,详见 {@link Live.getFramesByKey}。
109
- * @function setSelfInfo 设置当前用户信息,详见 {@link Live.setSelfInfo}。
110
- * @function updateStatus 更新用户或房间状态,详见 {@link Live.updateStatus}。
111
- *
112
- * @description 提供一些函数直接调用。
113
- *
114
- * ```ts
115
- * function ReactComponent() {
116
- * const { exit } = useLiveAction()
117
- * return (<button onClick={() => exit()}>退出带看</button>)
118
- * }
119
- * ```
120
- */
121
- useLiveAction: () => LiveActionReactCallback<Snapshot>;
122
- /**
123
- * 监听带看相关的异步 Hooks 事件。详情见 {@link LiveEventType}。
124
- */
125
- useLiveEventCallback: <K extends keyof LiveEventType<Snapshot>>(name: K, callback: (...args: Parameters<LiveEventType<Snapshot>[K]>) => ReturnType<LiveEventType<Snapshot>[K]>, deps?: React.DependencyList) => () => void;
126
- /**
127
- * 获取当前 WebSocket 状态 {@link WebSocketState}。
128
- */
129
- useReadyState: () => WebSocketState;
130
- /**
131
- * RTC 函数。
132
- */
133
- useRTCAction: () => RTCActionReactCallback;
134
- /**
135
- * RTC 事件回调监听。
136
- */
137
- useRTCEventCallback: <K extends keyof RTCEventType>(name: K, callback: (...args: Parameters<RTCEventType[K]>) => ReturnType<RTCEventType[K]>, deps?: React.DependencyList) => () => void;
138
- /**
139
- * 获取\更改 当前用户信息。
140
- * ```
141
- * const [userInfo, setUserInfo] = useSelfInfo()
142
- * ```
143
- */
144
- useSelfInfo: () => [
145
- Partial<UserInfo>,
146
- (userInfo: Partial<UserInfo>) => Promise<boolean | Error>
147
- ];
148
- /**
149
- * 当前帧数据快照。
150
- */
151
- useSnapshot: () => Partial<Snapshot> | undefined;
152
- /**
153
- * 获取房间用户列表。
154
- *
155
- * ```
156
- * const userList = useUserList()
157
- * ```
158
- */
159
- useUserList: () => UserInfo[] | undefined;
160
- /**
161
- * WebSocket 异步事件回调监听。
162
- */
163
- useWebSocketEventCallback: <K extends keyof WebSocketEventType>(name: K, callback: (...args: Parameters<WebSocketEventType[K]>) => ReturnType<WebSocketEventType[K]>, deps?: React.DependencyList) => () => void;
164
- }