@realsee/live 0.6.15 → 0.7.1

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 (167) hide show
  1. package/README.md +50 -55
  2. package/dist/index.cjs.js +38 -24
  3. package/dist/index.d.cts +1336 -0
  4. package/dist/index.d.ts +1336 -5
  5. package/dist/index.esm.js +10 -0
  6. package/docs/README.md +435 -0
  7. package/docs/classes/BrowserRTC.md +436 -0
  8. package/docs/classes/BrowserRTC4Chime.md +558 -0
  9. package/docs/classes/CoreRTC.md +448 -0
  10. package/docs/classes/Live.md +797 -0
  11. package/docs/classes/Subscribe.md +211 -0
  12. package/docs/classes/VRWebViewRTC.md +436 -0
  13. package/docs/enumerations/BuiltInRTCType.md +27 -0
  14. package/docs/enumerations/BuiltinActionType.md +81 -0
  15. package/docs/enumerations/BuiltinEventType.md +33 -0
  16. package/docs/enumerations/Command.md +107 -0
  17. package/docs/enumerations/LiveState.md +53 -0
  18. package/docs/enumerations/MemUserStatus.md +67 -0
  19. package/docs/enumerations/MicroStatus.md +33 -0
  20. package/docs/enumerations/RTCJoinedInfoCodeEnum.md +69 -0
  21. package/docs/enumerations/RTCType.md +39 -0
  22. package/docs/enumerations/UserStatus.md +45 -0
  23. package/docs/enumerations/WebSocketCloseError.md +117 -0
  24. package/docs/enumerations/WebSocketErrorType.md +77 -0
  25. package/docs/enumerations/WebSocketState.md +69 -0
  26. package/docs/functions/GetVoiceSignFn.md +27 -0
  27. package/docs/functions/clearLiveInstanceIfNeed.md +17 -0
  28. package/docs/functions/createLive.md +27 -0
  29. package/docs/functions/createLiveReact.md +449 -0
  30. package/docs/functions/parseLiveMsg.md +27 -0
  31. package/docs/functions/parseWSClsErr.md +21 -0
  32. package/docs/globals.md +77 -0
  33. package/docs/interfaces/AttendeeResponse.md +37 -0
  34. package/docs/interfaces/LiveOptions.md +246 -0
  35. package/docs/interfaces/MeetingResponse.md +55 -0
  36. package/docs/interfaces/MeetingSessionConfigurationOptions.md +93 -0
  37. package/docs/interfaces/Permission.md +147 -0
  38. package/docs/interfaces/RTCJoinedInfo.md +67 -0
  39. package/docs/interfaces/RTCProtocol.md +404 -0
  40. package/docs/interfaces/VRWebViewRTCOptions.md +41 -0
  41. package/docs/namespaces/SubscribeMixinType/README.md +17 -0
  42. package/docs/namespaces/SubscribeMixinType/interfaces/emit.md +31 -0
  43. package/docs/namespaces/SubscribeMixinType/interfaces/hasListener.md +25 -0
  44. package/docs/namespaces/SubscribeMixinType/interfaces/off.md +31 -0
  45. package/docs/namespaces/SubscribeMixinType/interfaces/on.md +37 -0
  46. package/docs/namespaces/SubscribeMixinType/interfaces/once.md +35 -0
  47. package/docs/type-aliases/BuiltinMsg.md +41 -0
  48. package/docs/type-aliases/EventMap.md +17 -0
  49. package/docs/type-aliases/EventType.md +19 -0
  50. package/docs/type-aliases/GetVoiceSign.md +15 -0
  51. package/docs/type-aliases/GetVoiceSignParams.md +35 -0
  52. package/docs/type-aliases/GetVoiceSignReturnType.md +41 -0
  53. package/docs/type-aliases/KeyframeEventType.md +19 -0
  54. package/docs/type-aliases/LiveBuiltInData.md +47 -0
  55. package/docs/type-aliases/LiveConnectOptions.md +47 -0
  56. package/docs/type-aliases/LiveEventType.md +165 -0
  57. package/docs/type-aliases/LiveMsg.md +53 -0
  58. package/docs/type-aliases/LiveProviderPropTypes.md +27 -0
  59. package/docs/type-aliases/RTCActionReactCallback.md +13 -0
  60. package/docs/type-aliases/RTCEventType.md +65 -0
  61. package/docs/type-aliases/ReqLiveMsg.md +45 -0
  62. package/docs/type-aliases/RoomInfo.md +55 -0
  63. package/docs/type-aliases/UserInfo.md +77 -0
  64. package/docs/type-aliases/UserInfoExt.md +33 -0
  65. package/docs/type-aliases/UserVolume.md +25 -0
  66. package/docs/type-aliases/WebSocketError.md +31 -0
  67. package/package.json +39 -32
  68. package/dist/index.cjs.js.map +0 -1
  69. package/dist/index.es.js +0 -2328
  70. package/dist/index.es.js.map +0 -1
  71. package/dist/live/controller.d.ts +0 -118
  72. package/dist/live/createLive.d.ts +0 -8
  73. package/dist/live/createLiveReact.d.ts +0 -52
  74. package/dist/live/live.d.ts +0 -182
  75. package/dist/rtc/BrowserRTC.d.ts +0 -39
  76. package/dist/rtc/BrowserRTC4Chime.d.ts +0 -60
  77. package/dist/rtc/CoreRTC.d.ts +0 -23
  78. package/dist/rtc/VRWebViewRTC.d.ts +0 -97
  79. package/dist/rtc/index.d.ts +0 -5
  80. package/dist/typings/chime/AttendeeResponse.d.ts +0 -5
  81. package/dist/typings/chime/MeetingResponse.d.ts +0 -12
  82. package/dist/typings/chime/MeetingSessionConfigurationOptions.d.ts +0 -16
  83. package/dist/typings/chime/index.d.ts +0 -3
  84. package/dist/typings/index.d.ts +0 -4
  85. package/dist/typings/live/EventType.d.ts +0 -74
  86. package/dist/typings/live/GetVoiceSign.d.ts +0 -45
  87. package/dist/typings/live/LiveConnectOptions.d.ts +0 -24
  88. package/dist/typings/live/LiveMsg.d.ts +0 -133
  89. package/dist/typings/live/LiveOptions.d.ts +0 -79
  90. package/dist/typings/live/LiveState.d.ts +0 -15
  91. package/dist/typings/live/RoomInfo.d.ts +0 -13
  92. package/dist/typings/live/UserInfo.d.ts +0 -103
  93. package/dist/typings/live/UserVolume.d.ts +0 -7
  94. package/dist/typings/live/WebSocket.d.ts +0 -82
  95. package/dist/typings/live/index.d.ts +0 -10
  96. package/dist/typings/react/RTCActionReactCallback.d.ts +0 -2
  97. package/dist/typings/react/index.d.ts +0 -1
  98. package/dist/typings/rtc/VRWebViewRTCOptions.d.ts +0 -6
  99. package/dist/typings/rtc/eventType.d.ts +0 -44
  100. package/dist/typings/rtc/index.d.ts +0 -5
  101. package/dist/typings/rtc/joinedInfo.d.ts +0 -38
  102. package/dist/typings/rtc/protocol.d.ts +0 -62
  103. package/dist/typings/rtc/type.d.ts +0 -12
  104. package/dist/utils/RobustWebSocket.d.ts +0 -160
  105. package/dist/utils/appendUri.d.ts +0 -1
  106. package/dist/utils/clientDetector.d.ts +0 -4
  107. package/dist/utils/equal.d.ts +0 -10
  108. package/dist/utils/logger.d.ts +0 -16
  109. package/dist/utils/subscribe.d.ts +0 -75
  110. package/dist/utils/uuid.d.ts +0 -4
  111. package/docs/.nojekyll +0 -1
  112. package/docs/assets/highlight.css +0 -120
  113. package/docs/assets/main.js +0 -58
  114. package/docs/assets/search.js +0 -1
  115. package/docs/assets/style.css +0 -1280
  116. package/docs/classes/BrowserRTC.html +0 -561
  117. package/docs/classes/BrowserRTC4Chime.html +0 -602
  118. package/docs/classes/CoreRTC.html +0 -432
  119. package/docs/classes/Live.html +0 -812
  120. package/docs/classes/VRWebViewRTC.html +0 -639
  121. package/docs/enums/BuiltInRTCType.html +0 -69
  122. package/docs/enums/BuiltinActionType.html +0 -112
  123. package/docs/enums/BuiltinEventType.html +0 -76
  124. package/docs/enums/Command.html +0 -134
  125. package/docs/enums/LiveState.html +0 -89
  126. package/docs/enums/MemUserStatus.html +0 -97
  127. package/docs/enums/MicroStatus.html +0 -76
  128. package/docs/enums/RTCJoinedInfoCodeEnum.html +0 -103
  129. package/docs/enums/RTCType.html +0 -79
  130. package/docs/enums/UserStatus.html +0 -85
  131. package/docs/enums/WebSocketCloseError.html +0 -139
  132. package/docs/enums/WebSocketErrorType.html +0 -104
  133. package/docs/enums/WebSocketState.html +0 -103
  134. package/docs/functions/_clearLiveInstanceIfNeed.html +0 -98
  135. package/docs/functions/createLive.html +0 -111
  136. package/docs/functions/createLiveReact.html +0 -579
  137. package/docs/functions/parseLiveMsg.html +0 -109
  138. package/docs/functions/parseWSClsErr.html +0 -103
  139. package/docs/index.html +0 -474
  140. package/docs/interfaces/AttendeeResponse.html +0 -80
  141. package/docs/interfaces/LiveOptions.html +0 -272
  142. package/docs/interfaces/MeetingResponse.html +0 -90
  143. package/docs/interfaces/MeetingSessionConfigurationOptions.html +0 -119
  144. package/docs/interfaces/Permission.html +0 -157
  145. package/docs/interfaces/RTCJoinedInfo.html +0 -104
  146. package/docs/interfaces/RTCProtocol.html +0 -424
  147. package/docs/interfaces/VRWebViewRTCOptions.html +0 -73
  148. package/docs/modules.html +0 -156
  149. package/docs/types/BuiltinMsg.html +0 -112
  150. package/docs/types/EventType.html +0 -101
  151. package/docs/types/GetVoiceSign.html +0 -109
  152. package/docs/types/GetVoiceSignParams.html +0 -111
  153. package/docs/types/GetVoiceSignReturnType.html +0 -115
  154. package/docs/types/KeyframeTypes.html +0 -101
  155. package/docs/types/LiveBuiltInData.html +0 -117
  156. package/docs/types/LiveConnectOptions.html +0 -123
  157. package/docs/types/LiveEventType.html +0 -276
  158. package/docs/types/LiveMsg.html +0 -117
  159. package/docs/types/LiveProviderPropTypes.html +0 -106
  160. package/docs/types/RTCActionReactCallback.html +0 -94
  161. package/docs/types/RTCEventType.html +0 -210
  162. package/docs/types/ReqLiveMsg.html +0 -118
  163. package/docs/types/RoomInfo.html +0 -118
  164. package/docs/types/UserInfo.html +0 -139
  165. package/docs/types/UserInfoExt.html +0 -109
  166. package/docs/types/UserVolume.html +0 -103
  167. package/docs/types/WebSocketError.html +0 -105
package/README.md CHANGED
@@ -40,14 +40,14 @@ yarn add @realsee/live
40
40
  简单使用样例(先不考虑实时语音能力):
41
41
 
42
42
  ```js
43
- import { createLive } from '@realsee/live';
43
+ import { createLive } from '@realsee/live'
44
44
 
45
45
  const live = createLive({
46
46
  url: 'wss://ws-access.realsee.com/***/?=xxx' /* 连接 WebSocket 服务的 URL */,
47
47
  getTicket: async () => {
48
48
  /* 获取带看"门票"的回调函数 */
49
49
  },
50
- });
50
+ })
51
51
  ```
52
52
 
53
53
  在创建 `live` 实例时配置了两个参数:
@@ -80,12 +80,12 @@ const live = createLive({
80
80
 
81
81
  ```js
82
82
  // 发送本地 帧数据 (Five State)
83
- live.sendKeyframe('five', { panoIndex: 13 });
83
+ live.sendKeyframe('five', { panoIndex: 13 })
84
84
 
85
85
  // 接收远程 帧数据 (Five State)
86
86
  live.keyframes.on('five', (newState, prevState) => {
87
87
  // 可以拿最新的 `newState` 更新本地 UI 状态
88
- });
88
+ })
89
89
  ```
90
90
 
91
91
  您也可以通过 `live.snapshot` 属性来获取当前所有序列帧数据的"快照"。
@@ -96,19 +96,19 @@ live.keyframes.on('five', (newState, prevState) => {
96
96
 
97
97
  ```js
98
98
  // 属性:获取本地用户信息
99
- live.selfInfo;
99
+ live.selfInfo
100
100
 
101
101
  // 属性:获取当前房间内所有用户列表
102
- live.userList;
102
+ live.userList
103
103
 
104
104
  // 方法:更新本地用户信息
105
- live.setSelfInfo({});
105
+ live.setSelfInfo({})
106
106
 
107
107
  // 事件:本地用户信息发生变更
108
- live.on('selfInfoUpdate', (userInfo) => {});
108
+ live.on('selfInfoUpdate', (userInfo) => {})
109
109
 
110
110
  // 事件:房间用户列表信息发生变更
111
- live.on('userListUpdate', (userList) => {});
111
+ live.on('userListUpdate', (userList) => {})
112
112
  ```
113
113
 
114
114
  ### 广播消息
@@ -116,16 +116,13 @@ live.on('userListUpdate', (userList) => {});
116
116
  除了帧数据和房间信息之外,还可以用事件的形式向房间内的其他用户广播消息:
117
117
 
118
118
  ```js
119
- live.broadcast(
120
- data /* 广播的数据 */,
121
- ['user_id_1', 'user_id_2'] /* 收到此用户的userId */,
122
- );
119
+ live.broadcast(data /* 广播的数据 */, ['user_id_1', 'user_id_2'] /* 收到此用户的userId */)
123
120
  ```
124
121
 
125
122
  此时,房间内用户 Id 为 `user_id_1`、`user_id_2` 的用户会收到此广播消息(其他用户无感知):
126
123
 
127
124
  ```js
128
- live.on('broadcast', (data /* 广播的数据 */) => {});
125
+ live.on('broadcast', (data /* 广播的数据 */) => {})
129
126
  ```
130
127
 
131
128
  更多的例子请查看 [Live API](https://unpkg.com/@realsee/live/docs/index.html) 文档 。
@@ -140,8 +137,8 @@ live.on('broadcast', (data /* 广播的数据 */) => {});
140
137
 
141
138
  ```ts
142
139
  live.on('ws.readyStateUpdate', (readyState: WebSocketState) => {
143
- console.log(readyState); // readyState 即是最新的 WebScoket 状态
144
- });
140
+ console.log(readyState) // readyState 即是最新的 WebScoket 状态
141
+ })
145
142
  ```
146
143
 
147
144
  ### WebSocket 事件
@@ -203,8 +200,8 @@ live.on('ws.readyStateUpdate', (readyState: WebSocketState) => {
203
200
 
204
201
  ```ts
205
202
  live.$RTC.on('userVolumes', (userVolumes: UserVolume[]) => {
206
- console.log(userVolumes); // userVolumes 正在说话的用户及其音量数据。
207
- });
203
+ console.log(userVolumes) // userVolumes 正在说话的用户及其音量数据。
204
+ })
208
205
  ```
209
206
 
210
207
  ### 异常处理
@@ -257,31 +254,31 @@ live.$RTC.on('userVolumes', (userVolumes: UserVolume[]) => {
257
254
  如果是 iOS/Android App(已接入如视 VRTC 容器 SDK)
258
255
 
259
256
  ```js
260
- import JSBridge from '@realsee/jsbridge-x';
261
- import { createLive, VRWebViewRTC } from '@realsee/live';
257
+ import JSBridge from '@realsee/jsbridge-x'
258
+ import { createLive, VRWebViewRTC } from '@realsee/live'
262
259
 
263
- const jsBridgeInstance = new JSBridge();
260
+ const jsBridgeInstance = new JSBridge()
264
261
 
265
262
  const rtcInstance = new VRWebViewRTC({
266
263
  jsBridge,
267
264
  getVoiceSign: () => {},
268
- });
265
+ })
269
266
 
270
267
  const live = createLive({
271
268
  rtc: rtcInstance,
272
269
  getTicket: async () => '',
273
- });
270
+ })
274
271
  ```
275
272
 
276
273
  提供 RTC 实例配置参数之后,语音的连接、断开、重连等逻辑就托管给了 **Live** 。您可以通过 live 实例上的 `$RTC` 命名空间访问语音相关的状态和事件。
277
274
 
278
275
  ```js
279
276
  // 状态:用户是否成功加入语音房间
280
- live.$RTC.joined;
277
+ live.$RTC.joined
281
278
  // 状态:用户麦克风状态
282
- live.$RTC.micro;
279
+ live.$RTC.micro
283
280
  // 监听用户音量变化
284
- live.$RTC.on('userVolumes', (userVolumes) => {});
281
+ live.$RTC.on('userVolumes', (userVolumes) => {})
285
282
  ```
286
283
 
287
284
  ## 浏览器端支持
@@ -302,16 +299,16 @@ yarn add trtc-js-sdk
302
299
  使用方式:
303
300
 
304
301
  ```tsx
305
- import { createLive, BrowserRTC } from '@realsee/live';
302
+ import { createLive, BrowserRTC } from '@realsee/live'
306
303
 
307
304
  const rtcInstance = new VRWebViewRTC({
308
305
  getVoiceSign: () => {},
309
- });
306
+ })
310
307
 
311
308
  const live = createLive({
312
309
  rtc: rtcInstance,
313
310
  getTicket: async () => '',
314
- });
311
+ })
315
312
  ```
316
313
 
317
314
  ### Chime
@@ -326,16 +323,16 @@ yarn add amazon-chime-sdk-js
326
323
  使用方式:
327
324
 
328
325
  ```tsx
329
- import { createLive, BrowserRTC4Chime } from '@realsee/live';
326
+ import { createLive, BrowserRTC4Chime } from '@realsee/live'
330
327
 
331
328
  const rtcInstance = new BrowserRTC4Chime({
332
329
  getVoiceSign: () => {},
333
- });
330
+ })
334
331
 
335
332
  const live = createLive({
336
333
  rtc: rtcInstance,
337
334
  getTicket: async () => '',
338
- });
335
+ })
339
336
  ```
340
337
 
341
338
  ### 使用内置的 JsBridge 和 RTC 实现
@@ -343,7 +340,7 @@ const live = createLive({
343
340
  使用方式:
344
341
 
345
342
  ```tsx
346
- import { createLive } from '@realsee/live';
343
+ import { createLive } from '@realsee/live'
347
344
 
348
345
  const live = createLive({
349
346
  useBuiltInRTC: true, // 使用内置rtc
@@ -351,13 +348,11 @@ const live = createLive({
351
348
  useBuiltInJsBridge: true, // 使用内置的jsBridge
352
349
  getVoiceSign, // 内置的rtc还是要把 getVoiceSign 方法传递进去
353
350
  getTicket: async () => '' /* 必须提供 */,
354
- });
351
+ })
355
352
 
356
353
  // 可以直接使用里面的 jsBridge, 该实例由 @realsee/jsbridge-x 提供支持
357
- const jsBridge = live.jsBridge;
358
- jsBridge
359
- .ready()
360
- .then(() => console.info(`${jsBridge.webViewType} jsBridge is ready`));
354
+ const jsBridge = live.jsBridge
355
+ jsBridge.ready().then(() => console.info(`${jsBridge.webViewType} jsBridge is ready`))
361
356
  ```
362
357
 
363
358
  ## TypeScript & React 支持
@@ -370,57 +365,57 @@ jsBridge
370
365
  步骤一:新建文件 `LiveReact.ts` 并创建您自己的 `LiveReact` 实例。
371
366
 
372
367
  ```tsx
373
- import { createLiveReact } from '@realsee/live';
368
+ import { createLiveReact } from '@realsee/live'
374
369
 
375
370
  /** 定义帧数据快照结构 */
376
371
  interface Snapshot {
377
372
  /** 以 Five 状态快照为例 */
378
373
  five: {
379
- panoIndex: number;
380
- fov: number;
381
- mode: 'Panorama' | 'Model';
382
- latitude: number;
383
- longitude: number;
384
- };
374
+ panoIndex: number
375
+ fov: number
376
+ mode: 'Panorama' | 'Model'
377
+ latitude: number
378
+ longitude: number
379
+ }
385
380
  }
386
381
 
387
382
  /** 通过 `createLiveReact()` 函数创建实例*/
388
383
 
389
384
  const LiveReact = createLiveReact<Snapshot>({
390
385
  getTicket: async () => '' /* 必须提供 */,
391
- });
386
+ })
392
387
 
393
- export default LiveReact;
388
+ export default LiveReact
394
389
 
395
390
  /** 如果您不喜欢 `LiveReact.LiveProvider` 这类编程习惯,可以将需要的函数"抛"出来 */
396
- export const LiveProvider = LiveReact.LiveProvider;
397
- export const useConnect = LiveReact.useConnect;
398
- export const useKeyframe = LiveReact.useKeyframe;
391
+ export const LiveProvider = LiveReact.LiveProvider
392
+ export const useConnect = LiveReact.useConnect
393
+ export const useKeyframe = LiveReact.useKeyframe
399
394
  // export ..
400
395
  ```
401
396
 
402
397
  步骤二:通过 `LiveProvider` 将 `live` 实例集成到 `React` 的 [Context](https://reactjs.org/docs/context.html) 上下文环境中。
403
398
 
404
399
  ```jsx
405
- import { LiveProvider } from './LiveReact';
400
+ import { LiveProvider } from './LiveReact'
406
401
 
407
402
  ReactDOM.render(
408
403
  <LiveProvider>
409
404
  <RootApp />
410
405
  </LiveProvider>,
411
406
  containter,
412
- );
407
+ )
413
408
  ```
414
409
 
415
410
  步骤三:在您的 `React` 函数组件中使用相关 `Hooks` 函数。
416
411
 
417
412
  ```jsx
418
- import { useConnect } from './LiveReact';
413
+ import { useConnect } from './LiveReact'
419
414
 
420
415
  function ReconnectBtn() {
421
- const connect = useConnect();
416
+ const connect = useConnect()
422
417
 
423
- return <button onClick={() => connect()}>重新连接</button>;
418
+ return <button onClick={() => connect()}>重新连接</button>
424
419
  }
425
420
  ```
426
421