@tencentcloud/tuiroom-engine-js 3.4.3-beta.3 → 3.4.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.
package/index.d.ts CHANGED
@@ -297,6 +297,11 @@ type TUISeatInfo = {
297
297
  isVideoLocked: boolean;
298
298
  isAudioLocked: boolean;
299
299
  };
300
+ declare enum TUIMoveSeatPolicy {
301
+ kAbortWhenOccupied = 0,
302
+ kForceReplace = 1,
303
+ kSwapPosition = 2
304
+ }
300
305
  type TUIRequest = {
301
306
  requestAction: TUIRequestAction;
302
307
  timestamp: number;
@@ -1226,6 +1231,25 @@ type TUILiveInfo = {
1226
1231
  readonly lebEncrypted?: string;
1227
1232
  readonly lebSignature?: string;
1228
1233
  };
1234
+ type StartLiveOptions = {
1235
+ roomId: string;
1236
+ roomType?: TUIRoomType;
1237
+ name: string;
1238
+ notice?: string;
1239
+ isMessageDisableForAllUser?: boolean;
1240
+ isGiftEnabled?: boolean;
1241
+ isLikeEnabled?: boolean;
1242
+ isPublicVisible?: boolean;
1243
+ isSeatEnabled?: boolean;
1244
+ keepOwnerOnSeat?: boolean;
1245
+ seatLayoutTemplateId?: number;
1246
+ maxSeatCount?: number;
1247
+ seatMode?: TUISeatMode;
1248
+ coverUrl?: string;
1249
+ backgroundUrl?: string;
1250
+ categoryList?: Array<number>;
1251
+ activityStatus?: number;
1252
+ };
1229
1253
  /**
1230
1254
  * 直播连线用户信息
1231
1255
  */
@@ -1714,6 +1738,84 @@ declare enum TUILiveBattleManagerEvents {
1714
1738
  * });
1715
1739
  */
1716
1740
  onBattleRequestReject = "onBattleRequestReject"
1741
+ }
1742
+ /**
1743
+ * 礼物信息
1744
+ */
1745
+ type GiftInfo = {
1746
+ giftID: string;
1747
+ name: string;
1748
+ desc: string;
1749
+ iconUrl: string;
1750
+ resourceUrl: string;
1751
+ level: number;
1752
+ coins: number;
1753
+ extensionInfo: Record<string, string>;
1754
+ };
1755
+ /**
1756
+ * 礼物分类信息
1757
+ */
1758
+ type GiftCategory = {
1759
+ categoryID: string;
1760
+ name: string;
1761
+ desc: string;
1762
+ extensionInfo: Record<string, string>;
1763
+ giftList: GiftInfo[];
1764
+ };
1765
+ declare enum TUILiveGiftManagerEvents {
1766
+ /**
1767
+ * @description 接收到礼物数量发送变化监听事件
1768
+ * @default 'onGiftCountChanged'
1769
+ * @event TUILiveGiftManagerEvents#onGiftCountChanged
1770
+ * @param {object} options
1771
+ * @param {String} roomId 房间Id
1772
+ * @param {Number} totalGiftsSent 总礼物数
1773
+ * @param {Number} totalGiftCoins 总礼物价值
1774
+ * @param {Number} totalUniqueGiftSenders 总礼物发送者数量
1775
+ *
1776
+ * @example
1777
+ * const roomEngine = new TUIRoomEngine();
1778
+ * const liveGiftManager = roomEngine.TUILiveGiftManager();
1779
+ * liveGiftManager.on(TUILiveGiftManagerEvents.onGiftCountChanged, ({ roomId, totalGiftsSent, totalGiftCoins, totalUniqueGiftSenders }) => {
1780
+ * console.log('liveGiftManager.onGiftCountChanged', roomId, totalGiftsSent, totalGiftCoins, totalUniqueGiftSenders);
1781
+ * });
1782
+ */
1783
+ onGiftCountChanged = "onGiftCountChanged",
1784
+ /**
1785
+ * @description 接收到礼物消息的监听事件
1786
+ * @default 'onReceiveGiftMessage'
1787
+ * @event TUILiveGiftManagerEvents#onReceiveGiftMessage
1788
+ * @param {object} options
1789
+ * @param {String} roomId 房间Id
1790
+ * @param {GiftInfo} giftInfo 礼物信息
1791
+ * @param {number} count 礼物数量
1792
+ * @param {TUIUserInfo} sender 发送者信息
1793
+ *
1794
+ * @example
1795
+ * const roomEngine = new TUIRoomEngine();
1796
+ * const liveGiftManager = roomEngine.TUILiveGiftManager();
1797
+ * liveGiftManager.on(TUILiveGiftManagerEvents.onReceiveGiftMessage, ({ roomId, giftInfo, count, sender }) => {
1798
+ * console.log('liveGiftManager.onReceiveGiftMessage', roomId, giftInfo, count, sender);
1799
+ * });
1800
+ */
1801
+ onReceiveGiftMessage = "onReceiveGiftMessage",
1802
+ /**
1803
+ * @description 接收到点赞消息的监听事件
1804
+ * @default 'onReceiveLikesMessage'
1805
+ * @event TUILiveGiftManagerEvents#onReceiveLikesMessage
1806
+ * @param {object} options
1807
+ * @param {String} roomId 房间Id
1808
+ * @param {number} totalLikesReceived 总点赞数
1809
+ * @param {TUIUserInfo} sender 发送者信息
1810
+ *
1811
+ * @example
1812
+ * const roomEngine = new TUIRoomEngine();
1813
+ * const liveGiftManager = roomEngine.TUILiveGiftManager();
1814
+ * liveGiftManager.on(TUILiveGiftManagerEvents.onReceiveLikesMessage, ({ roomId, totalLikesReceived, sender }) => {
1815
+ * console.log('liveGiftManager.onReceiveLikesMessage', roomId, totalLikesReceived, sender);
1816
+ * });
1817
+ */
1818
+ onReceiveLikesMessage = "onReceiveLikesMessage"
1717
1819
  }
1718
1820
 
1719
1821
  declare class Logger {
@@ -2318,7 +2420,7 @@ declare class TUILiveListManager {
2318
2420
  *
2319
2421
  * @description 创建并开始一个新的直播间,房主调用此接口来启动直播
2320
2422
  * @since 3.3.0
2321
- * @param {TUILiveInfo} liveInfo 直播间信息,包含房间ID、名称、公告等配置
2423
+ * @param {StartLiveOptions | TUILiveInfo} liveInfo 直播间信息,包含房间ID、名称、公告等配置
2322
2424
  * @returns {Promise<TUILiveInfo>} 返回创建成功后的直播间完整信息,包含CDN流地址等
2323
2425
  * @throws {TUIError} 可能抛出的错误:
2324
2426
  * - ERR_ALREADY_ROOM_OWNER: 用户已经是房间所有者
@@ -2350,7 +2452,7 @@ declare class TUILiveListManager {
2350
2452
  * console.log('直播开始成功,CDN流地址:', resultLiveInfo.cdnStreamUrl);
2351
2453
  * ```
2352
2454
  */
2353
- startLive(liveInfo: TUILiveInfo): Promise<TUILiveInfo>;
2455
+ startLive(liveInfo: StartLiveOptions | TUILiveInfo): Promise<TUILiveInfo>;
2354
2456
  /**
2355
2457
  * 停止直播
2356
2458
  *
@@ -2931,6 +3033,151 @@ declare class TUILiveBattleManager {
2931
3033
  private observerFunction;
2932
3034
  }
2933
3035
 
3036
+ declare class TUILiveGiftManager {
3037
+ private liveGiftManagerWASM;
3038
+ private logger;
3039
+ private static liveGiftManager;
3040
+ constructor(options: {
3041
+ Module: any;
3042
+ logger: Logger;
3043
+ roomEngineWASM: any;
3044
+ });
3045
+ /**
3046
+ * 获取礼物列表
3047
+ *
3048
+ * @param {object} options
3049
+ * @param {String} options.roomId 房间ID
3050
+ * @returns {Promise<{giftCategoryList: GiftCategory[]}>}
3051
+ *
3052
+ * @example
3053
+ * const roomEngine = new TUIRoomEngine();
3054
+ * const liveGiftManager = roomEngine.getLiveGiftManager();
3055
+ * liveGiftManager.getGiftList({
3056
+ * roomId: 'roomId'
3057
+ * });
3058
+ */
3059
+ getGiftList(options: {
3060
+ roomId: string;
3061
+ }): Promise<{
3062
+ giftCategoryList: GiftCategory[];
3063
+ }>;
3064
+ /**
3065
+ * 发送礼物
3066
+ *
3067
+ * @param {object} options
3068
+ * @param {string} options.roomId 房间ID
3069
+ * @param {string} options.giftId 礼物ID
3070
+ * @param {number} options.count 礼物数量
3071
+ * @returns {Promise<void>}
3072
+ *
3073
+ * @example
3074
+ * const roomEngine = new TUIRoomEngine();
3075
+ * const liveGiftManager = roomEngine.getLiveGiftManager();
3076
+ * liveGiftManager.sendGift({
3077
+ * roomId: 'roomId',
3078
+ * giftId: 'giftId',
3079
+ * count: 1
3080
+ * });
3081
+ */
3082
+ sendGift(options: {
3083
+ roomId: string;
3084
+ giftId: string;
3085
+ count: number;
3086
+ }): Promise<void>;
3087
+ /**
3088
+ * 发送点赞
3089
+ *
3090
+ * @param {object} options
3091
+ * @param {string} options.roomId 房间ID
3092
+ * @param {number} options.count 点赞数量
3093
+ * @returns {Promise<void>}
3094
+ *
3095
+ * @example
3096
+ * const roomEngine = new TUIRoomEngine();
3097
+ * const liveGiftManager = roomEngine.getLiveGiftManager();
3098
+ * liveGiftManager.sendLikes({
3099
+ * roomId: 'roomId',
3100
+ * count: 1
3101
+ * });
3102
+ */
3103
+ sendLikes(options: {
3104
+ roomId: string;
3105
+ count: number;
3106
+ }): Promise<void>;
3107
+ /**
3108
+ * 获取礼物数量
3109
+ *
3110
+ * @param {object} options
3111
+ * @param {string} options.roomId 房间ID
3112
+ * @returns {Promise<{totalGiftCoins:number, totalGiftsSent: number, totalUniqueGiftSenders: number}>}
3113
+ *
3114
+ * @example
3115
+ * const roomEngine = new TUIRoomEngine();
3116
+ * const liveGiftManager = roomEngine.getLiveGiftManager();
3117
+ * liveGiftManager.getGiftCountByAnchor({
3118
+ * roomId: 'roomId'
3119
+ * });
3120
+ */
3121
+ getGiftCountByAnchor(options: {
3122
+ roomId: string;
3123
+ }): Promise<{
3124
+ totalGiftCoins: number;
3125
+ totalGiftsSent: number;
3126
+ totalUniqueGiftSenders: number;
3127
+ }>;
3128
+ /**
3129
+ * 获取点赞数量
3130
+ *
3131
+ * @param {object} options
3132
+ * @param {string} options.roomId 房间ID
3133
+ * @returns {Promise<{totalLikesReceived: number}>}
3134
+ *
3135
+ * @example
3136
+ * const roomEngine = new TUIRoomEngine();
3137
+ * const liveGiftManager = roomEngine.getLiveGiftManager();
3138
+ * liveGiftManager.getLikesCount({
3139
+ * roomId: 'roomId'
3140
+ * });
3141
+ */
3142
+ getLikesCount(options: {
3143
+ roomId: string;
3144
+ }): Promise<{
3145
+ totalLikesReceived: number;
3146
+ }>;
3147
+ /**
3148
+ * 监听 TUILiveGiftManager 事件
3149
+ * @param {TUILiveGiftManagerEvents} event 事件名
3150
+ * @param func 事件回调函数
3151
+ *
3152
+ * @example
3153
+ * const roomEngine = new TUIRoomEngine();
3154
+ * const liveGiftManager = roomEngine.getLiveGiftManager();
3155
+ *
3156
+ * const callback = ({ roomId, totalGiftsSent, totalGiftCoins, totalUniqueGiftSenders }) => {
3157
+ * console.log('Demo onGiftCountChanged', { roomId, totalGiftsSent, totalGiftCoins, totalUniqueGiftSenders });
3158
+ * }
3159
+ * liveGiftManager.on(TUILiveGiftManagerEvents.onGiftCountChanged, callback);
3160
+ */
3161
+ on(event: TUILiveGiftManagerEvents, func: (...args: any[]) => void): void;
3162
+ /**
3163
+ * 取消监听 TUIliveGiftManager 事件
3164
+ * @param {TUILiveGiftManagerEvents} event 事件名
3165
+ * @param func 事件回调函数
3166
+ *
3167
+ * @example
3168
+ * const roomEngine = new TUIRoomEngine();
3169
+ * const liveGiftManager = roomEngine.getLiveGiftManager();
3170
+ *
3171
+ * const callback = ({ roomId, totalGiftsSent, totalGiftCoins, totalUniqueGiftSenders }) => {
3172
+ * console.log('Demo onGiftCountChanged', { roomId, totalGiftsSent, totalGiftCoins, totalUniqueGiftSenders });
3173
+ * }
3174
+ * liveGiftManager.off(TUILiveGiftManagerEvents.onGiftCountChanged, callback);
3175
+ */
3176
+ off(event: TUILiveGiftManagerEvents, func: (...args: any[]) => void): void;
3177
+ private JSCallNativeFunctionPromise;
3178
+ private observerFunction;
3179
+ }
3180
+
2934
3181
  /**
2935
3182
  * TUIRoomEngine 提供了音视频房间的能力
2936
3183
  *
@@ -2949,6 +3196,7 @@ declare class TUIRoomEngine {
2949
3196
  private liveLayoutManager;
2950
3197
  private liveConnectionManager;
2951
3198
  private liveBattleManager;
3199
+ private liveGiftManager;
2952
3200
  private static userId;
2953
3201
  private static sdkAppId;
2954
3202
  private static Module;
@@ -2980,10 +3228,18 @@ declare class TUIRoomEngine {
2980
3228
  /**
2981
3229
  * @private
2982
3230
  * 调用 TUIRoomEngineWASM 的 CallAPI 方法
3231
+ * 该接口废弃,后续逐步替换为 JSCallNativeCallAPIPromiseNew 方法
2983
3232
  * @param funcName
2984
3233
  * @param jsonString
2985
3234
  */
2986
3235
  private JSCallNativeCallAPIPromise;
3236
+ /**
3237
+ * 调用 roomEngineWASM 的 CallAPI 方法
3238
+ * @param funcName 函数名
3239
+ * @param args 参数
3240
+ * @returns Promise
3241
+ */
3242
+ private JSCallNativeCallAPIPromiseNew;
2987
3243
  /**
2988
3244
  * 登录 TUIRoomEngine
2989
3245
  *
@@ -3476,7 +3732,7 @@ declare class TUIRoomEngine {
3476
3732
  */
3477
3733
  stopPushLocalVideo(): Promise<void>;
3478
3734
  /**
3479
- * 开始向远端推本地音频流
3735
+ * 停止向远端推本地音频流
3480
3736
  * @returns {Promise<void>}
3481
3737
  *
3482
3738
  * @example
@@ -3486,7 +3742,7 @@ declare class TUIRoomEngine {
3486
3742
  */
3487
3743
  muteLocalAudio(): Promise<void>;
3488
3744
  /**
3489
- * 停止向远端推本地音频流
3745
+ * 开始向远端推本地音频流
3490
3746
  * @returns {Promise<void>}
3491
3747
  *
3492
3748
  * @example
@@ -3951,6 +4207,23 @@ declare class TUIRoomEngine {
3951
4207
  moveToSeat(options: {
3952
4208
  targetSeatIndex: number;
3953
4209
  }): Promise<void>;
4210
+ /**
4211
+ * 移动麦上的用户(仅支持房主或者管理员使用此接口)
4212
+ * @since v3.4.3
4213
+ * @note 当目标麦位有人时,支持三种移麦策略:
4214
+ * - 目标麦位有人时放弃移动(默认)
4215
+ * - 强制替换 - 将原麦位用户踢下麦
4216
+ * - 交换位置 - 互换两个用户的麦位
4217
+ * @param {string} options.userId 待移动的麦上用户
4218
+ * @param {number} options.targetSeatIndex 移麦目标麦位 index, 移麦成功后您将会在此麦位上。
4219
+ * @param {TUIMoveSeatPolicy} options.policy 移动麦上用户时的策略, 默认为目标麦位有人时放弃移动
4220
+ * @returns {Promise<void>}
4221
+ */
4222
+ moveUserToSeatByAdmin(options: {
4223
+ userId: string;
4224
+ targetSeatIndex: number;
4225
+ policy: TUIMoveSeatPolicy;
4226
+ }): Promise<void>;
3954
4227
  /**
3955
4228
  * 邀请其他人上麦(仅房间主持人和管理员可调用此方法)
3956
4229
  * @param {object} options 邀请其他人上麦的参数
@@ -4405,6 +4678,17 @@ declare class TUIRoomEngine {
4405
4678
  * const liveBattleManager = roomEngine.getLiveBattleManager();
4406
4679
  */
4407
4680
  getLiveBattleManager(): TUILiveBattleManager;
4681
+ /**
4682
+ * v3.4.4 版本起支持 getLiveGiftManager 获取 TUILiveGiftManager 模块
4683
+ *
4684
+ * @since v3.4.4
4685
+ * @returns {TUILiveGiftManager}
4686
+ *
4687
+ * @example
4688
+ * const roomEngine = new TUIRoomEngine();
4689
+ * const liveGiftManager = roomEngine.getLiveGiftManager();
4690
+ */
4691
+ getLiveGiftManager(): TUILiveGiftManager;
4408
4692
  /**
4409
4693
  * v2.6.0 版本起支持使用 getConferenceInvitationManager 获取 conferenceInvitation 模块
4410
4694
  * @since v2.6.0
@@ -4454,5 +4738,5 @@ declare class TUIRoomEngine {
4454
4738
  private static handleSetFramework;
4455
4739
  }
4456
4740
 
4457
- export { TRTCRole, TUIAudioQuality, TUIAudioRoute, TUIBattleCode, TUIBattleStoppedReason, TUICaptureSourceType, TUIChangeReason, TUIConferenceCancelReason, TUIConferenceInvitationManager, TUIConferenceInvitationManagerEvents, TUIConferenceListManager, TUIConferenceListManagerEvents, TUIConferenceStatus, TUIConnectionCode, TUIDeviceStatus, TUIErrorCode, TUIInvitationCode, TUIInvitationRejectedReason, TUIInvitationStatus, TUIKickedOutOfRoomReason, TUILiveBattleManagerEvents, TUILiveConnectionManagerEvents, TUILiveLayoutManager, TUILiveLayoutManagerEvents, TUILiveListManager, TUILiveListManagerEvents, TUILiveModifyFlag, TUIMediaDevice, TUIMediaDeviceState, TUIMediaDeviceType, TUINetworkQuality, TUIRenderMode, TUIRequestAction, TUIRequestCallbackType, TUIResolutionMode, TUIRole, TUIRoomDeviceManager, TUIRoomDeviceMangerEvents, TUIRoomDismissedReason, TUIRoomEvents, TUIRoomType, TUISeatMode, TUIVideoQuality, TUIVideoStreamType, TUIRoomEngine as default };
4458
- export type { TUIAutoPlayCallbackInfo, TUIBattleConfig, TUIBattleInfo, TUIBattleUser, TUIConferenceInfo, TUIConferenceModifyInfo, TUIDeviceInfo, TUIEnterRoomOptions, TUIInvitation, TUILiveConnectionUser, TUILiveInfo, TUILiveListResult, TUILiveModifyInfo, TUILiveStatisticsData, TUILoginUserInfo, TUIMessage, TUINetwork, TUIRequest, TUIRequestCallback, TUIRoomInfo, TUISeatInfo, TUISeatLayout, TUISeatLockParams, TUISeatRegion, TUIUserInfo, TUIVideoEncoderParams };
4741
+ export { TRTCRole, TUIAudioQuality, TUIAudioRoute, TUIBattleCode, TUIBattleStoppedReason, TUICaptureSourceType, TUIChangeReason, TUIConferenceCancelReason, TUIConferenceInvitationManager, TUIConferenceInvitationManagerEvents, TUIConferenceListManager, TUIConferenceListManagerEvents, TUIConferenceStatus, TUIConnectionCode, TUIDeviceStatus, TUIErrorCode, TUIInvitationCode, TUIInvitationRejectedReason, TUIInvitationStatus, TUIKickedOutOfRoomReason, TUILiveBattleManagerEvents, TUILiveConnectionManagerEvents, TUILiveGiftManagerEvents, TUILiveLayoutManager, TUILiveLayoutManagerEvents, TUILiveListManager, TUILiveListManagerEvents, TUILiveModifyFlag, TUIMediaDevice, TUIMediaDeviceState, TUIMediaDeviceType, TUIMoveSeatPolicy, TUINetworkQuality, TUIRenderMode, TUIRequestAction, TUIRequestCallbackType, TUIResolutionMode, TUIRole, TUIRoomDeviceManager, TUIRoomDeviceMangerEvents, TUIRoomDismissedReason, TUIRoomEvents, TUIRoomType, TUISeatMode, TUIVideoQuality, TUIVideoStreamType, TUIRoomEngine as default };
4742
+ export type { GiftCategory, GiftInfo, StartLiveOptions, TUIAutoPlayCallbackInfo, TUIBattleConfig, TUIBattleInfo, TUIBattleUser, TUIConferenceInfo, TUIConferenceModifyInfo, TUIDeviceInfo, TUIEnterRoomOptions, TUIInvitation, TUILiveConnectionUser, TUILiveInfo, TUILiveListResult, TUILiveModifyInfo, TUILiveStatisticsData, TUILoginUserInfo, TUIMessage, TUINetwork, TUIRequest, TUIRequestCallback, TUIRoomInfo, TUISeatInfo, TUISeatLayout, TUISeatLockParams, TUISeatRegion, TUIUserInfo, TUIVideoEncoderParams };