@realsee/live 0.7.3-alpha.0 → 0.7.4

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 (143) hide show
  1. package/dist/index.cjs.js +3 -3
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.es.js +687 -130
  5. package/dist/index.es.js.map +1 -1
  6. package/dist/live/controller.d.ts +163 -42
  7. package/dist/live/createLive.d.ts +35 -3
  8. package/dist/live/createLiveReact.d.ts +51 -3
  9. package/dist/live/live.d.ts +501 -50
  10. package/dist/rtc/BrowserRTC.d.ts +63 -0
  11. package/dist/rtc/BrowserRTC4Chime.d.ts +38 -2
  12. package/dist/rtc/CoreRTC.d.ts +65 -1
  13. package/dist/rtc/VRWebViewRTC.d.ts +56 -6
  14. package/dist/typings/live/EventType.d.ts +58 -10
  15. package/dist/typings/live/GetVoiceSign.d.ts +27 -7
  16. package/dist/typings/live/UserInfo.d.ts +70 -0
  17. package/dist/typings/rtc/eventType.d.ts +55 -8
  18. package/dist/utils/appendUri.d.ts +17 -0
  19. package/dist/utils/uuid.d.ts +11 -1
  20. package/docs/.nojekyll +1 -0
  21. package/docs/assets/highlight.css +127 -0
  22. package/docs/assets/icons.js +18 -0
  23. package/docs/assets/icons.svg +1 -0
  24. package/docs/assets/main.js +60 -0
  25. package/docs/assets/navigation.js +1 -0
  26. package/docs/assets/search.js +1 -0
  27. package/docs/assets/style.css +1493 -0
  28. package/docs/classes/BrowserRTC.html +88 -0
  29. package/docs/classes/BrowserRTC4Chime.html +100 -0
  30. package/docs/classes/CoreRTC.html +65 -0
  31. package/docs/classes/Live.html +249 -0
  32. package/docs/classes/Subscribe.html +36 -0
  33. package/docs/classes/VRWebViewRTC.html +72 -0
  34. package/docs/enums/BuiltInRTCType.html +3 -0
  35. package/docs/enums/BuiltinActionType.html +14 -0
  36. package/docs/enums/BuiltinEventType.html +6 -0
  37. package/docs/enums/Command.html +22 -0
  38. package/docs/enums/LiveState.html +8 -0
  39. package/docs/enums/MemUserStatus.html +15 -0
  40. package/docs/enums/MicroStatus.html +6 -0
  41. package/docs/enums/RTCJoinedInfoCodeEnum.html +12 -0
  42. package/docs/enums/RTCType.html +5 -0
  43. package/docs/enums/UserStatus.html +8 -0
  44. package/docs/enums/WebSocketCloseError.html +20 -0
  45. package/docs/enums/WebSocketErrorType.html +8 -0
  46. package/docs/enums/WebSocketState.html +12 -0
  47. package/docs/functions/GetVoiceSignFn.html +20 -0
  48. package/docs/functions/_clearLiveInstanceIfNeed.html +1 -0
  49. package/docs/functions/createLive.html +9 -0
  50. package/docs/functions/createLiveReact.html +110 -0
  51. package/docs/functions/parseLiveMsg.html +4 -0
  52. package/docs/functions/parseWSClsErr.html +1 -0
  53. package/docs/hierarchy.html +1 -0
  54. package/docs/index.html +336 -0
  55. package/docs/interfaces/AttendeeResponse.html +4 -0
  56. package/docs/interfaces/LiveOptions.html +56 -0
  57. package/docs/interfaces/MeetingResponse.html +3 -0
  58. package/docs/interfaces/MeetingSessionConfigurationOptions.html +8 -0
  59. package/docs/interfaces/Permission.html +31 -0
  60. package/docs/interfaces/RTCJoinedInfo.html +7 -0
  61. package/docs/interfaces/RTCProtocol.html +65 -0
  62. package/docs/interfaces/SubscribeMixinType.emit.html +1 -0
  63. package/docs/interfaces/SubscribeMixinType.hasListener.html +1 -0
  64. package/docs/interfaces/SubscribeMixinType.off.html +1 -0
  65. package/docs/interfaces/SubscribeMixinType.on.html +1 -0
  66. package/docs/interfaces/SubscribeMixinType.once.html +1 -0
  67. package/docs/interfaces/VRWebViewRTCOptions.html +22 -0
  68. package/docs/modules/SubscribeMixinType.html +6 -0
  69. package/docs/modules.html +55 -0
  70. package/docs/types/BuiltinMsg.html +2 -0
  71. package/docs/types/EventMap.html +1 -0
  72. package/docs/types/EventType.html +2 -0
  73. package/docs/types/GetVoiceSign.html +3 -0
  74. package/docs/types/GetVoiceSignParams.html +5 -0
  75. package/docs/types/GetVoiceSignReturnType.html +6 -0
  76. package/docs/types/KeyframeEventType.html +2 -0
  77. package/docs/types/LiveBuiltInData.html +1 -0
  78. package/docs/types/LiveConnectOptions.html +8 -0
  79. package/docs/types/LiveEventType.html +41 -0
  80. package/docs/types/LiveMsg.html +2 -0
  81. package/docs/types/LiveProviderPropTypes.html +5 -0
  82. package/docs/types/RTCActionReactCallback.html +1 -0
  83. package/docs/types/RTCEventType.html +29 -0
  84. package/docs/types/ReqLiveMsg.html +6 -0
  85. package/docs/types/RoomInfo.html +1 -0
  86. package/docs/types/UserInfo.html +12 -0
  87. package/docs/types/UserInfoExt.html +5 -0
  88. package/docs/types/UserVolume.html +2 -0
  89. package/docs/types/WebSocketError.html +1 -0
  90. package/package.json +1 -2
  91. package/docs/README.md +0 -437
  92. package/docs/classes/BrowserRTC.md +0 -436
  93. package/docs/classes/BrowserRTC4Chime.md +0 -558
  94. package/docs/classes/CoreRTC.md +0 -448
  95. package/docs/classes/Live.md +0 -770
  96. package/docs/classes/VRWebViewRTC.md +0 -436
  97. package/docs/enumerations/BuiltInRTCType.md +0 -27
  98. package/docs/enumerations/BuiltinActionType.md +0 -81
  99. package/docs/enumerations/BuiltinEventType.md +0 -33
  100. package/docs/enumerations/Command.md +0 -107
  101. package/docs/enumerations/LiveState.md +0 -53
  102. package/docs/enumerations/MemUserStatus.md +0 -67
  103. package/docs/enumerations/MicroStatus.md +0 -33
  104. package/docs/enumerations/RTCJoinedInfoCodeEnum.md +0 -69
  105. package/docs/enumerations/RTCType.md +0 -39
  106. package/docs/enumerations/UserStatus.md +0 -45
  107. package/docs/enumerations/WebSocketCloseError.md +0 -117
  108. package/docs/enumerations/WebSocketErrorType.md +0 -77
  109. package/docs/enumerations/WebSocketState.md +0 -69
  110. package/docs/functions/GetVoiceSignFn.md +0 -27
  111. package/docs/functions/clearLiveInstanceIfNeed.md +0 -17
  112. package/docs/functions/createLive.md +0 -27
  113. package/docs/functions/createLiveReact.md +0 -449
  114. package/docs/functions/parseLiveMsg.md +0 -27
  115. package/docs/functions/parseWSClsErr.md +0 -21
  116. package/docs/globals.md +0 -71
  117. package/docs/interfaces/AttendeeResponse.md +0 -37
  118. package/docs/interfaces/LiveOptions.md +0 -246
  119. package/docs/interfaces/MeetingResponse.md +0 -55
  120. package/docs/interfaces/MeetingSessionConfigurationOptions.md +0 -93
  121. package/docs/interfaces/Permission.md +0 -147
  122. package/docs/interfaces/RTCJoinedInfo.md +0 -67
  123. package/docs/interfaces/RTCProtocol.md +0 -404
  124. package/docs/interfaces/VRWebViewRTCOptions.md +0 -41
  125. package/docs/type-aliases/BuiltinMsg.md +0 -41
  126. package/docs/type-aliases/EventType.md +0 -19
  127. package/docs/type-aliases/GetVoiceSign.md +0 -15
  128. package/docs/type-aliases/GetVoiceSignParams.md +0 -35
  129. package/docs/type-aliases/GetVoiceSignReturnType.md +0 -41
  130. package/docs/type-aliases/KeyframeEventType.md +0 -19
  131. package/docs/type-aliases/LiveBuiltInData.md +0 -47
  132. package/docs/type-aliases/LiveConnectOptions.md +0 -47
  133. package/docs/type-aliases/LiveEventType.md +0 -165
  134. package/docs/type-aliases/LiveMsg.md +0 -53
  135. package/docs/type-aliases/LiveProviderPropTypes.md +0 -27
  136. package/docs/type-aliases/RTCActionReactCallback.md +0 -13
  137. package/docs/type-aliases/RTCEventType.md +0 -65
  138. package/docs/type-aliases/ReqLiveMsg.md +0 -45
  139. package/docs/type-aliases/RoomInfo.md +0 -55
  140. package/docs/type-aliases/UserInfo.md +0 -77
  141. package/docs/type-aliases/UserInfoExt.md +0 -33
  142. package/docs/type-aliases/UserVolume.md +0 -25
  143. package/docs/type-aliases/WebSocketError.md +0 -31
@@ -2,10 +2,53 @@ import { Client, LocalStream } from 'trtc-js-sdk';
2
2
  import { GetVoiceSign } from '../typings/live/GetVoiceSign';
3
3
  import { RTCType } from '../typings/rtc/type';
4
4
  import { CoreRTC } from './CoreRTC';
5
+ /**
6
+ * TRTC 实例接口(内部使用)
7
+ */
5
8
  export interface ITrtcInstance {
9
+ /**
10
+ * TRTC 客户端实例
11
+ */
6
12
  client: Client | null;
13
+ /**
14
+ * 本地音视频流
15
+ */
7
16
  stream: LocalStream | null;
8
17
  }
18
+ /**
19
+ * 浏览器端 TRTC RTC 实现
20
+ *
21
+ * 基于腾讯云 TRTC SDK 实现的浏览器端 RTC 类。
22
+ * 适用于在浏览器环境中进行实时语音通信。
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const rtc = new BrowserRTC({
27
+ * getVoiceSign: async (params) => {
28
+ * const response = await fetch('/api/get-voice-sign', {
29
+ * method: 'POST',
30
+ * body: JSON.stringify(params)
31
+ * })
32
+ * return response.json()
33
+ * },
34
+ * autoPlayConfirm: (opts) => {
35
+ * // 处理自动播放确认
36
+ * opts.onConfirm()
37
+ * }
38
+ * })
39
+ *
40
+ * // 加入房间
41
+ * await rtc.join({
42
+ * voiceId: 'voice-id',
43
+ * userId: 'user-id',
44
+ * roomId: 'room-id',
45
+ * type: RTCType.RealseeBrowserRTC
46
+ * })
47
+ *
48
+ * // 切换麦克风
49
+ * await rtc.toggleMicro(true)
50
+ * ```
51
+ */
9
52
  export declare class BrowserRTC extends CoreRTC {
10
53
  type: RTCType;
11
54
  joined: boolean;
@@ -13,9 +56,29 @@ export declare class BrowserRTC extends CoreRTC {
13
56
  voiceId: string;
14
57
  private _getVoiceSign;
15
58
  private _autoPlayConfirm;
59
+ /**
60
+ * 检查系统要求
61
+ *
62
+ * 检查浏览器是否满足 TRTC 的系统要求。
63
+ *
64
+ * @returns 系统要求检查结果
65
+ */
16
66
  checkRequirement: () => Promise<import('trtc-js-sdk').CheckResult>;
67
+ /**
68
+ * DOM 容器(内部使用)
69
+ */
17
70
  private $dom;
71
+ /**
72
+ * TRTC 实例(内部使用)
73
+ */
18
74
  private _trtc;
75
+ /**
76
+ * 创建 BrowserRTC 实例
77
+ *
78
+ * @param options 配置选项
79
+ * @param options.getVoiceSign 获取语音签名的函数,必需
80
+ * @param options.autoPlayConfirm 自动播放确认回调(可选),用于处理浏览器的自动播放策略
81
+ */
19
82
  constructor(options: {
20
83
  getVoiceSign: GetVoiceSign;
21
84
  autoPlayConfirm?: (opts: {
@@ -3,7 +3,32 @@ import { GetVoiceSign } from '../typings/live/GetVoiceSign';
3
3
  import { RTCType } from '../typings/rtc/type';
4
4
  import { CoreRTC } from './CoreRTC';
5
5
  /**
6
- * amazon-chime-sdk-js 适配的rtc实现
6
+ * 浏览器端 Amazon Chime SDK RTC 实现
7
+ *
8
+ * 基于 Amazon Chime SDK for JavaScript 实现的浏览器端 RTC 类。
9
+ * 适用于在浏览器环境中使用 Amazon Chime 进行实时语音通信。
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const rtc = new BrowserRTC4Chime({
14
+ * getVoiceSign: async (params) => {
15
+ * const response = await fetch('/api/get-voice-sign', {
16
+ * method: 'POST',
17
+ * body: JSON.stringify(params)
18
+ * })
19
+ * return response.json()
20
+ * },
21
+ * logLevel: LogLevel.INFO
22
+ * })
23
+ *
24
+ * // 加入房间
25
+ * await rtc.join({
26
+ * voiceId: 'voice-id',
27
+ * userId: 'user-id',
28
+ * roomId: 'room-id',
29
+ * type: RTCType.RealseeBrowserChimeRTC
30
+ * })
31
+ * ```
7
32
  */
8
33
  export declare class BrowserRTC4Chime extends CoreRTC {
9
34
  type: RTCType;
@@ -23,6 +48,14 @@ export declare class BrowserRTC4Chime extends CoreRTC {
23
48
  private _autoPlayConfirm;
24
49
  private $dom;
25
50
  private $audio;
51
+ /**
52
+ * 创建 BrowserRTC4Chime 实例
53
+ *
54
+ * @param options 配置选项
55
+ * @param options.getVoiceSign 获取语音签名的函数,必需
56
+ * @param options.autoPlayConfirm 自动播放确认回调(可选),用于处理浏览器的自动播放策略
57
+ * @param options.logLevel 日志级别(可选),默认为 LogLevel.INFO
58
+ */
26
59
  constructor(options: {
27
60
  getVoiceSign: GetVoiceSign;
28
61
  autoPlayConfirm?: (opts: {
@@ -31,11 +64,14 @@ export declare class BrowserRTC4Chime extends CoreRTC {
31
64
  logLevel?: LogLevel;
32
65
  });
33
66
  /**
34
- * 对audio标签初始化
67
+ * 初始化 DOM 元素(内部方法)
68
+ * 创建并挂载 audio 标签到页面
35
69
  */
36
70
  _initDom: () => void;
37
71
  /**
38
72
  * 初始化事件监听器
73
+ *
74
+ * 设置设备变化、音视频事件等监听器
39
75
  */
40
76
  initObservers: () => void;
41
77
  /**
@@ -3,21 +3,85 @@ import { RTCProtocol } from '../typings/rtc/protocol';
3
3
  import { RTCType } from '../typings/rtc/type';
4
4
  import { Subscribe } from '../utils/subscribe';
5
5
  /**
6
- * rtc 基础抽象类
6
+ * RTC 基础抽象类
7
+ *
8
+ * 所有 RTC 实现的基类,定义了 RTC 协议的基本接口。
9
+ * 子类需要实现所有抽象方法和属性。
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * class MyRTC extends CoreRTC {
14
+ * joined = false
15
+ * micro = false
16
+ * voiceId = ''
17
+ * type = RTCType.Custom
18
+ *
19
+ * async join(options) {
20
+ * // 实现加入房间逻辑
21
+ * }
22
+ *
23
+ * async quit() {
24
+ * // 实现退出房间逻辑
25
+ * }
26
+ *
27
+ * // 实现其他抽象方法...
28
+ * }
29
+ * ```
7
30
  */
8
31
  export declare abstract class CoreRTC extends Subscribe<RTCEventType> implements RTCProtocol {
32
+ /**
33
+ * 是否已加入语音房间
34
+ */
9
35
  abstract joined: boolean;
36
+ /**
37
+ * 麦克风是否开启
38
+ */
10
39
  abstract micro: boolean;
40
+ /**
41
+ * 当前语音房间ID
42
+ */
11
43
  abstract voiceId: string;
44
+ /**
45
+ * RTC 实现类型
46
+ */
12
47
  abstract type: RTCType;
48
+ /**
49
+ * 加入语音房间
50
+ *
51
+ * @param options 加入房间的选项
52
+ * @param options.voiceId 语音房间ID
53
+ * @param options.userId 用户ID
54
+ * @param options.roomId 房间ID(可选)
55
+ * @param options.type RTC类型
56
+ * @returns Promise<boolean> 是否成功加入房间
57
+ */
13
58
  abstract join(options: {
14
59
  voiceId: string;
15
60
  userId: string;
16
61
  roomId: string | number | undefined;
17
62
  type: RTCType;
18
63
  }): Promise<boolean>;
64
+ /**
65
+ * 退出语音房间
66
+ *
67
+ * @returns Promise<boolean> 是否成功退出房间
68
+ */
19
69
  abstract quit(): Promise<boolean>;
70
+ /**
71
+ * 检测麦克风权限
72
+ *
73
+ * @returns Promise<boolean> 是否有麦克风权限
74
+ */
20
75
  abstract detectMicro(): Promise<boolean>;
76
+ /**
77
+ * 切换麦克风状态
78
+ *
79
+ * @param flag 是否开启麦克风,不传则切换当前状态
80
+ * @returns Promise<boolean> 是否操作成功
81
+ */
21
82
  abstract toggleMicro(flag?: boolean): Promise<boolean>;
83
+ /**
84
+ * 震动(如果设备支持)
85
+ */
22
86
  abstract shock(): void;
23
87
  }
@@ -1,6 +1,37 @@
1
1
  import { RTCType } from '../typings/rtc/type';
2
2
  import { VRWebViewRTCOptions } from '../typings/rtc/VRWebViewRTCOptions';
3
3
  import { CoreRTC } from './CoreRTC';
4
+ /**
5
+ * VR WebView RTC 实现
6
+ *
7
+ * 适用于在如视 VR App 的 WebView 或微信小程序环境中进行实时语音通信。
8
+ * 通过 JSBridge 与原生 App 通信,实现语音功能。
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import JSBridge from '@realsee/jsbridge-x'
13
+ *
14
+ * const jsBridge = new JSBridge()
15
+ * const rtc = new VRWebViewRTC({
16
+ * jsBridge,
17
+ * getVoiceSign: async (params) => {
18
+ * const response = await fetch('/api/get-voice-sign', {
19
+ * method: 'POST',
20
+ * body: JSON.stringify(params)
21
+ * })
22
+ * return response.json()
23
+ * }
24
+ * })
25
+ *
26
+ * // 加入房间
27
+ * await rtc.join({
28
+ * voiceId: 'voice-id',
29
+ * userId: 'user-id',
30
+ * roomId: 'room-id',
31
+ * type: RTCType.RealseeVRWebViewRTC
32
+ * })
33
+ * ```
34
+ */
4
35
  export declare class VRWebViewRTC extends CoreRTC {
5
36
  type: RTCType;
6
37
  joined: boolean;
@@ -11,22 +42,41 @@ export declare class VRWebViewRTC extends CoreRTC {
11
42
  */
12
43
  private _joinOptions;
13
44
  private options;
45
+ /**
46
+ * 获取 JSBridge 实例
47
+ *
48
+ * @returns JSBridge 协议实例
49
+ */
14
50
  get jsBridge(): import('@realsee/jsbridge-x').JSBridgeProtocol;
51
+ /**
52
+ * 创建 VRWebViewRTC 实例
53
+ *
54
+ * @param options 配置选项,包含以下属性:
55
+ * - jsBridge: JSBridge 实例,必需,用于与原生 App 通信
56
+ * - getVoiceSign: 获取语音签名的函数,必需
57
+ */
15
58
  constructor({ jsBridge, getVoiceSign }: VRWebViewRTCOptions);
16
59
  /**
17
- * 处理用户音量
18
- * @param userVolumes
60
+ * 处理用户音量(内部方法)
61
+ *
62
+ * @param userVolumes 用户音量数组
19
63
  */
20
64
  private handleUserVolumes;
21
65
  /**
22
- * 处理弱网络情况
23
- * @param weakNetwork
66
+ * 处理弱网络情况(内部方法)
67
+ *
68
+ * @param weakNetwork 是否为弱网络
24
69
  */
25
70
  private handleWeakNetwork;
26
71
  /**
27
72
  * 加入语音房间
28
- * @param options
29
- * @returns
73
+ *
74
+ * @param options 加入房间的选项
75
+ * @param options.voiceId 语音房间ID
76
+ * @param options.userId 用户ID
77
+ * @param options.roomId 房间ID
78
+ * @param options.type RTC类型
79
+ * @returns Promise<boolean> 是否成功加入房间
30
80
  */
31
81
  join: (options: {
32
82
  voiceId: string;
@@ -6,29 +6,77 @@ import { UserInfo } from './UserInfo';
6
6
  */
7
7
  export type LiveEventType<KeyframesSnapshot> = {
8
8
  /**
9
- * 带看状态变化
10
- * @param state
11
- * @param prevState
9
+ * 带看连接状态变化事件
10
+ *
11
+ * @param state 当前连接状态
12
+ * @param prevState 之前的连接状态(可选)
13
+ * @example
14
+ * ```typescript
15
+ * live.on('stateChange', (state, prevState) => {
16
+ * console.log(`状态从 ${prevState} 变为 ${state}`)
17
+ * })
18
+ * ```
12
19
  */
13
20
  'stateChange'(state: LiveState, prevState?: LiveState): void;
14
21
  /**
15
22
  * 内置消息事件
16
- * @param builtinMsg
23
+ *
24
+ * 当收到任何内置消息时触发,包括用户变化和房间变化。
25
+ *
26
+ * @param builtinMsg 内置消息对象
27
+ * @example
28
+ * ```typescript
29
+ * live.on('builtinEvent', (msg) => {
30
+ * console.log('内置消息:', msg.event_type, msg.action)
31
+ * })
32
+ * ```
17
33
  */
18
34
  'builtinEvent'(builtinMsg: BuiltinMsg): void;
19
35
  /**
20
- * 内置消息事件: 用户信息改变
21
- * @param builtinMsg
36
+ * 用户信息改变事件
37
+ *
38
+ * 当用户信息发生变化时触发,是 builtinEvent 的子集。
39
+ *
40
+ * @param builtinMsg 内置消息对象,event_type 为 UserChange
41
+ * @example
42
+ * ```typescript
43
+ * live.on('userChange', (msg) => {
44
+ * if (msg.action === BuiltinActionType.UserMicroStatus) {
45
+ * console.log('麦克风状态变化:', msg.data.status)
46
+ * }
47
+ * })
48
+ * ```
22
49
  */
23
50
  'userChange'(builtinMsg: BuiltinMsg): void;
24
51
  /**
25
- * 内置消息事件:房间信息改变
26
- * @param builtinMsg
52
+ * 房间信息改变事件
53
+ *
54
+ * 当房间信息发生变化时触发,是 builtinEvent 的子集。
55
+ *
56
+ * @param builtinMsg 内置消息对象,event_type 为 RoomChange
57
+ * @example
58
+ * ```typescript
59
+ * live.on('roomChange', (msg) => {
60
+ * if (msg.action === BuiltinActionType.RoomClose) {
61
+ * console.log('房间已关闭')
62
+ * }
63
+ * })
64
+ * ```
27
65
  */
28
66
  'roomChange'(builtinMsg: BuiltinMsg): void;
29
67
  /**
30
- * 收到其他用户的广播消息。
31
- * @param evtMsg
68
+ * 收到其他用户的广播消息事件
69
+ *
70
+ * 当收到其他用户通过 broadcast 方法发送的自定义消息时触发。
71
+ *
72
+ * @param evtMsg 广播消息数据对象
73
+ * @param frontRequestId 前端请求ID,用于匹配请求和响应
74
+ * @example
75
+ * ```typescript
76
+ * live.on('broadcast', (data, requestId) => {
77
+ * console.log('收到广播:', data, '请求ID:', requestId)
78
+ * })
79
+ * ```
32
80
  */
33
81
  'broadcast'(evtMsg: Record<string, any>, frontRequestId: string): void;
34
82
  /**
@@ -37,16 +37,36 @@ export type GetVoiceSignParams = {
37
37
  roomId: string | number;
38
38
  };
39
39
  /**
40
- * 获取用户语音签名的方法
41
- * @param {GetVoiceSignParams} params - 获取语音签名所需的参数
42
- * @returns {Promise<GetVoiceSignReturnType>} 返回一个Promise,解析为语音签名的相关信息
43
- * @property {number} sdkAppId - RTC的sdkAppId
44
- * @property {string} userId - RTC的用户ID
45
- * @property {string|number} roomId - RTC的语音房间号
46
- * @property {string} userSig - RTC的用户签名
40
+ * 获取用户语音签名的函数
41
+ *
42
+ * 用于获取加入 RTC 语音房间所需的签名信息。
43
+ * 通常需要调用后端 API 来生成签名。
44
+ *
45
+ * @param params 获取语音签名所需的参数,包含以下属性:
46
+ * - voiceId: 语音房间ID
47
+ * - userId: 用户ID
48
+ * - roomId: 房间ID
49
+ * @returns Promise<GetVoiceSignReturnType> 返回包含签名信息的 Promise,包含:
50
+ * - sdkAppId: RTC的sdkAppId
51
+ * - userId: RTC的用户ID
52
+ * - roomId: RTC的语音房间号
53
+ * - userSig: RTC的用户签名
54
+ * @example
55
+ * ```typescript
56
+ * const getVoiceSign: GetVoiceSign = async (params) => {
57
+ * const response = await fetch('/api/get-voice-sign', {
58
+ * method: 'POST',
59
+ * headers: { 'Content-Type': 'application/json' },
60
+ * body: JSON.stringify(params)
61
+ * })
62
+ * return response.json()
63
+ * }
64
+ * ```
47
65
  */
48
66
  export declare function GetVoiceSignFn(params: GetVoiceSignParams): Promise<GetVoiceSignReturnType>;
49
67
  /**
50
68
  * 获取用户语音签名的方法类型
69
+ *
70
+ * 用于配置 Live 实例时提供获取语音签名的函数。
51
71
  */
52
72
  export type GetVoiceSign = typeof GetVoiceSignFn;
@@ -15,12 +15,35 @@ export declare enum UserStatus {
15
15
  */
16
16
  Replaced = 2
17
17
  }
18
+ /**
19
+ * 内存中的用户状态枚举
20
+ *
21
+ * 用于表示用户在内存中的状态,与 UserStatus 不同,这个状态更详细地描述了用户的生命周期。
22
+ */
18
23
  export declare enum MemUserStatus {
24
+ /**
25
+ * 等待进入房间
26
+ */
19
27
  WAIT_ENTER = "WAIT_ENTER",
28
+ /**
29
+ * 在线
30
+ */
20
31
  ONLINE = "ONLINE",
32
+ /**
33
+ * 已离开
34
+ */
21
35
  LEAVE = "LEAVE",
36
+ /**
37
+ * 被踢出
38
+ */
22
39
  KICK_OUT = "KICK_OUT",
40
+ /**
41
+ * 被替换
42
+ */
23
43
  BE_REPLACE = "BE_REPLACE",
44
+ /**
45
+ * 异常状态
46
+ */
24
47
  EXCEPTION = "EXCEPTION"
25
48
  }
26
49
  /**
@@ -85,19 +108,66 @@ export type UserInfo = {
85
108
  */
86
109
  extension?: UserInfoExt;
87
110
  };
111
+ /**
112
+ * 用户权限配置接口
113
+ *
114
+ * 定义了用户在带看房间中的各种权限。所有权限都是布尔值,true 表示拥有该权限。
115
+ */
88
116
  export interface Permission {
117
+ /**
118
+ * 切换更多 VR 场景的权限
119
+ */
89
120
  more_vr_scene: boolean;
121
+ /**
122
+ * 邀请其他用户进入房间的权限
123
+ */
90
124
  invite_other: boolean;
125
+ /**
126
+ * 控制自己麦克风的权限
127
+ */
91
128
  control_own_micro: boolean;
129
+ /**
130
+ * 控制其他用户麦克风的权限
131
+ */
92
132
  control_other_micro: boolean;
133
+ /**
134
+ * 查看自己麦克风状态的权限
135
+ */
93
136
  view_own_micro_status: boolean;
137
+ /**
138
+ * 查看其他用户麦克风状态的权限
139
+ */
94
140
  view_other_micro_status: boolean;
141
+ /**
142
+ * 关闭带看房间的权限
143
+ */
95
144
  close_live_room: boolean;
145
+ /**
146
+ * 申请获取其他用户电话的权限
147
+ */
96
148
  apply_other_phone: boolean;
149
+ /**
150
+ * 动态进入房间的权限
151
+ */
97
152
  dynamic_enter: boolean;
153
+ /**
154
+ * 同步帧数据的权限
155
+ */
98
156
  sync_frame: boolean;
157
+ /**
158
+ * 改变用户角色的权限
159
+ */
99
160
  transfer_role: boolean;
161
+ /**
162
+ * 改变其他用户状态的权限(如踢出用户)
163
+ */
100
164
  change_other_status: boolean;
165
+ /**
166
+ * 控制其他用户全量同步帧数据权限的权限
167
+ */
101
168
  control_other_sync: boolean;
169
+ /**
170
+ * 其他扩展权限点
171
+ */
102
172
  extension: Record<string, boolean>;
103
173
  }
@@ -1,29 +1,76 @@
1
1
  import { UserVolume } from '../live/UserVolume';
2
2
  import { RTCJoinedInfo } from './joinedInfo';
3
3
  /**
4
- * RTC 异步事件类型。
4
+ * RTC 异步事件类型
5
+ *
6
+ * 定义了 RTC 实例可以触发的所有事件类型
5
7
  */
6
8
  export type RTCEventType = {
7
9
  /**
8
- * 错误\异常
9
- * @param error
10
+ * RTC 错误或异常事件
11
+ *
12
+ * @param error 错误对象或加入房间信息
13
+ * @example
14
+ * ```typescript
15
+ * rtc.on('error', (error) => {
16
+ * console.error('RTC 错误:', error)
17
+ * })
18
+ * ```
10
19
  */
11
20
  "error"(error: Error | RTCJoinedInfo): void;
12
21
  /**
13
- * 即将加入房间。
22
+ * 即将加入房间事件
23
+ *
24
+ * 在开始加入房间流程时触发。
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * rtc.on('joinWillStart', () => {
29
+ * console.log('开始加入房间...')
30
+ * })
31
+ * ```
14
32
  */
15
33
  "joinWillStart"(): void;
16
34
  /**
17
- * 成功加入语音房间。
35
+ * 成功加入语音房间事件
36
+ *
37
+ * 当成功加入语音房间时触发。
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * rtc.on('joined', () => {
42
+ * console.log('已成功加入语音房间')
43
+ * })
44
+ * ```
18
45
  */
19
46
  "joined"(): void;
20
47
  /**
21
- * 弱网提醒事件。
48
+ * 弱网络提醒事件
49
+ *
50
+ * 当检测到网络质量较差时触发。
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * rtc.on('weakNetwork', () => {
55
+ * console.warn('网络质量较差,可能影响语音通话')
56
+ * })
57
+ * ```
22
58
  */
23
59
  "weakNetwork"(): void;
24
60
  /**
25
- * 每个用户的音量。
26
- * @param userVolumes
61
+ * 用户音量事件
62
+ *
63
+ * 当收到用户音量信息时触发,用于显示用户说话状态。
64
+ *
65
+ * @param userVolumes 用户音量数组,包含每个用户的音量信息
66
+ * @example
67
+ * ```typescript
68
+ * rtc.on('userVolumes', (volumes) => {
69
+ * volumes.forEach(volume => {
70
+ * console.log(`用户 ${volume.userId} 音量: ${volume.volume}`)
71
+ * })
72
+ * })
73
+ * ```
27
74
  */
28
75
  "userVolumes"(userVolumes: UserVolume[]): void;
29
76
  /**
@@ -1 +1,18 @@
1
+ /**
2
+ * 向 URI 追加查询参数
3
+ *
4
+ * 将查询参数追加到 URI 中,如果 URI 已有查询参数,会合并新的参数。
5
+ *
6
+ * @param uri 原始 URI 字符串
7
+ * @param query 要追加的查询参数对象
8
+ * @returns 追加查询参数后的完整 URI 字符串
9
+ * @example
10
+ * ```typescript
11
+ * appendUri('wss://example.com/live', { ticket: 'abc123', force: 1 })
12
+ * // 返回: 'wss://example.com/live?ticket=abc123&force=1'
13
+ *
14
+ * appendUri('wss://example.com/live?room=1', { ticket: 'abc123' })
15
+ * // 返回: 'wss://example.com/live?room=1&ticket=abc123'
16
+ * ```
17
+ */
1
18
  export declare function appendUri(uri: string, query?: Record<string, string | number>): string;
@@ -1,4 +1,14 @@
1
1
  /**
2
- * 基于伪随机数生成 **uuid**。
2
+ * 基于伪随机数生成 UUID
3
+ *
4
+ * 生成一个符合 UUID v4 格式的字符串(但不完全符合 RFC 4122 标准)。
5
+ * 格式:xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx
6
+ *
7
+ * @returns 生成的 UUID 字符串
8
+ * @example
9
+ * ```typescript
10
+ * const id = uuid()
11
+ * console.log(id) // 例如: 'a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d'
12
+ * ```
3
13
  */
4
14
  export declare function uuid(): string;
package/docs/.nojekyll ADDED
@@ -0,0 +1 @@
1
+ TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.