UNPKG

minigame-api-typings

Version:
1,380 lines (1,373 loc) 992 kB
/*! ***************************************************************************** Copyright (c) 2024 Tencent, Inc. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************** */ declare namespace WechatMinigame { interface AccessOption { /** 要判断是否存在的文件/目录路径 (本地路径) */ path: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: AccessCompleteCallback /** 接口调用失败的回调函数 */ fail?: AccessFailCallback /** 接口调用成功的回调函数 */ success?: AccessSuccessCallback } /** 账号信息 */ interface AccountInfo { /** 小程序账号信息 */ miniProgram: MiniProgram /** 插件账号信息(仅在插件中调用时包含这一项) */ plugin: Plugin } interface AddCardOption { /** 需要添加的卡券列表 */ cardList: AddCardRequestInfo[] /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: AddCardCompleteCallback /** 接口调用失败的回调函数 */ fail?: AddCardFailCallback /** 接口调用成功的回调函数 */ success?: AddCardSuccessCallback } /** 需要添加的卡券列表 */ interface AddCardRequestInfo { /** 卡券的扩展参数。需将 CardExt 对象 JSON 序列化为**字符串**传入 */ cardExt: string /** 卡券 ID */ cardId: string } /** 卡券添加结果列表 */ interface AddCardResponseInfo { /** 卡券的扩展参数,结构请参考下文 */ cardExt: string /** 用户领取到卡券的 ID */ cardId: string /** 加密 code,为用户领取到卡券的code加密后的字符串,解密请参照:[code 解码接口](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1499332673_Unm7V) */ code: string /** 是否成功 */ isSuccess: boolean } interface AddCardSuccessCallbackResult { /** 卡券添加结果列表 */ cardList: AddCardResponseInfo[] errMsg: string } interface AddServiceOption { /** 描述service的Object */ service: BLEPeripheralService /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: AddServiceCompleteCallback /** 接口调用失败的回调函数 */ fail?: AddServiceFailCallback /** 接口调用成功的回调函数 */ success?: AddServiceSuccessCallback } /** 广播自定义参数 */ interface AdvertiseReqObj { /** 需要基础库: `2.20.1` * * 以 beacon 设备形式广播的参数。 */ beacon?: BeaconInfoObj /** 当前设备是否可连接 */ connectable?: boolean /** 广播中 deviceName 字段,默认为空 */ deviceName?: string /** 广播的制造商信息。仅安卓支持,iOS 因系统限制无法定制。 */ manufacturerData?: ManufacturerData[] /** 要广播的服务 UUID 列表。使用 16/32 位 UUID 时请参考注意事项。 */ serviceUuids?: string[] } interface AppAuthorizeSetting { /** 允许微信使用相册的开关(仅 iOS 有效) */ albumAuthorized: 'authorized' | 'denied' | 'not determined' /** 允许微信使用蓝牙的开关(安卓基础库 3.5.0 以上有效) */ bluetoothAuthorized: 'authorized' | 'denied' | 'not determined' /** 允许微信使用摄像头的开关 */ cameraAuthorized: 'authorized' | 'denied' | 'not determined' /** 允许微信使用定位的开关 */ locationAuthorized: 'authorized' | 'denied' | 'not determined' /** 定位准确度。true 表示模糊定位,false 表示精确定位(仅 iOS 有效) */ locationReducedAccuracy: boolean /** 允许微信使用麦克风的开关 */ microphoneAuthorized: 'authorized' | 'denied' | 'not determined' /** 允许微信通知带有提醒的开关(仅 iOS 有效) */ notificationAlertAuthorized: 'authorized' | 'denied' | 'not determined' /** 允许微信通知的开关 */ notificationAuthorized: 'authorized' | 'denied' | 'not determined' /** 允许微信通知带有标记的开关(仅 iOS 有效) */ notificationBadgeAuthorized: 'authorized' | 'denied' | 'not determined' /** 允许微信通知带有声音的开关(仅 iOS 有效) */ notificationSoundAuthorized: 'authorized' | 'denied' | 'not determined' /** 允许微信读写日历的开关 */ phoneCalendarAuthorized: 'authorized' | 'denied' | 'not determined' } interface AppBaseInfo { /** 客户端基础库版本 */ SDKVersion: string /** 是否已打开调试。可通过右上角菜单或 [wx.setEnableDebug](https://developers.weixin.qq.com/minigame/dev/api/base/debug/wx.setEnableDebug.html) 打开调试。 */ enableDebug: boolean /** 微信字体大小缩放比例 */ fontSizeScaleFactor: number /** 需要基础库: `2.23.4` * * 微信字体大小,单位px */ fontSizeSetting: number /** 当前小程序运行的宿主环境 */ host: AppBaseInfoHost /** 微信设置的语言 */ language: string /** 微信版本号 */ version: string /** 系统当前主题,取值为`light`或`dark`,全局配置`"darkmode":true`时才能获取,否则为 undefined (不支持小游戏) * * 可选值: * - 'dark': 深色主题; * - 'light': 浅色主题; */ theme?: 'dark' | 'light' } /** 当前小程序运行的宿主环境 */ interface AppBaseInfoHost { /** 宿主 app(第三方App) 对应的 appId (当小程序运行在第三方App环境时才返回) */ appId: string } interface AppendFileOption { /** 要追加的文本或二进制数据 */ data: string | ArrayBuffer /** 要追加内容的文件路径 (本地路径) */ filePath: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: AppendFileCompleteCallback /** 指定写入文件的字符编码 * * 可选值: * - 'ascii': ; * - 'base64': ; * - 'binary': ; * - 'hex': ; * - 'ucs2': 以小端序读取; * - 'ucs-2': 以小端序读取; * - 'utf16le': 以小端序读取; * - 'utf-16le': 以小端序读取; * - 'utf-8': ; * - 'utf8': ; * - 'latin1': ; */ encoding?: | 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le' | 'utf-8' | 'utf8' | 'latin1' /** 接口调用失败的回调函数 */ fail?: AppendFileFailCallback /** 接口调用成功的回调函数 */ success?: AppendFileSuccessCallback } /** 需要基础库: `2.19.0` * * AudioBuffer接口表示存在内存里的一段短小的音频资源,利用[WebAudioContext.decodeAudioData](https://developers.weixin.qq.com/minigame/dev/api/media/audio/WebAudioContext.decodeAudioData.html)方法从一个音频文件构建,或者利用 [WebAudioContext.createBuffer](https://developers.weixin.qq.com/minigame/dev/api/media/audio/WebAudioContext.createBuffer.html)从原始数据构建。把音频放入AudioBuffer后,可以传入到一个 AudioBufferSourceNode进行播放。 */ interface AudioBuffer { /** 返回存储在缓存区的PCM数据的时长(单位为秒) */ duration: number /** 返回存储在缓存区的PCM数据的采样帧率 */ length: number /** 储存在缓存区的PCM数据的通道数 */ numberOfChannels: number /** 存储在缓存区的PCM数据的采样率(单位为sample/s) */ sampleRate: number /** [AudioBuffer.copyFromChannel()](https://developers.weixin.qq.com/minigame/dev/api/media/audio/AudioBuffer.copyFromChannel.html) * * 从AudioBuffer的指定频道复制到数组终端。 */ copyFromChannel(): void /** [AudioBuffer.copyToChannel(Float32Array source, number channelNumber, number startInChannel)](https://developers.weixin.qq.com/minigame/dev/api/media/audio/AudioBuffer.copyToChannel.html) * * 从指定数组复制样本到audioBuffer的特定通道 * * **示例代码** * * 示例代码参考AudioBuffer.copyFromChannel */ copyToChannel( /** 需要复制的源数组 */ source: Float32Array, /** 需要复制到的目的通道号 */ channelNumber: number, /** 复制偏移数据量 */ startInChannel: number ): void /** [Float32Array AudioBuffer.getChannelData(number channel)](https://developers.weixin.qq.com/minigame/dev/api/media/audio/AudioBuffer.getChannelData.html) * * 返回一个 Float32Array,包含了带有频道的PCM数据,由频道参数定义(有0代表第一个频道) */ getChannelData( /** 要获取特定通道数据的索引 */ channel: number ): Float32Array } /** 空间音频监听器,代表在一个音频场景内唯一的位置和方向信息。 */ interface AudioListener { /** 表示监听器的前向系统在同一笛卡尔坐标系中的水平位置,作为位置(位置x,位置和位置和位置)值。 */ forwardX: number /** 表示听众的前向方向在同一笛卡尔坐标系中作为位置(位置x,位置和位置和位置)值的垂直位置。 */ forwardY: number /** 表示与position (positionX、positionY和positionZ)值在同一笛卡尔坐标系下的听者前进方向的纵向(前后)位置。 */ forwardZ: number /** 右手笛卡尔坐标系中X轴的位置。 */ positionX: number /** 右手笛卡尔坐标系中Y轴的位置。 */ positionY: number /** 右手笛卡尔坐标系中Z轴的位置。 */ positionZ: number /** 设置监听器的方向 */ setOrientation: (...args: any[]) => any /** 设置监听器的位置 */ setPosition: (...args: any[]) => any /** 表示在与position (positionX、positionY和positionZ)值相同的笛卡尔坐标系中侦听器向前方向的水平位置。 */ upX: number /** 表示在与position (positionX、positionY和positionZ)值相同的笛卡尔坐标系中侦听器向上方向的水平位置。 */ upY: number /** 表示在与position (positionX、positionY和positionZ)值相同的笛卡尔坐标系中侦听器向后方向的水平位置。 */ upZ: number } /** 需要基础库: `2.19.0` * * AudioParam 接口代表音频相关的参数,通常是 AudioNode(例如 GainNode.gain)的参数 */ interface AudioParam { /** 代表被具体的 AudioNode 创建的 AudioParam 的属性的初始值(只读) */ defaultValue: number /** 代表参数有效范围的最大可能值(只读) */ maxValue: number /** 代表参数有效范围的最小可能值(只读) */ minValue: number /** 当前属性的值(比如音量值或播放倍速值)(可读可写) */ value: number } interface AuthPrivateMessageOption { /** shareTicket。可以从 wx.getEnterOptionsSync 中获取。详情 [shareTicket](#) */ shareTicket: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: AuthPrivateMessageCompleteCallback /** 接口调用失败的回调函数 */ fail?: AuthPrivateMessageFailCallback /** 接口调用成功的回调函数 */ success?: AuthPrivateMessageSuccessCallback } interface AuthPrivateMessageSuccessCallbackResult { /** 经过加密的activityId,解密后可得到原始的activityId。若解密后得到的activityId可以与开发者后台的活动id对应上则验证通过,否则表明valid字段不可靠(被篡改) 详细见[加密数据解密算法](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html) */ encryptedData: string /** 错误信息 */ errMsg: string /** 加密算法的初始向量,详细见[加密数据解密算法](https://developers.weixin.qq.com/minigame/dev/guide/open-ability/signature.html) */ iv: string /** 验证是否通过 */ valid: boolean } /** 用户授权设置信息,详情参考[权限](#) */ interface AuthSetting { /** 是否授权使用你的微信朋友信息,对应开放数据域内的 [wx.getFriendCloudStorage](https://developers.weixin.qq.com/minigame/dev/api/open-api/data/wx.getFriendCloudStorage.html) 、[wx.getGroupCloudStorage](https://developers.weixin.qq.com/minigame/dev/api/open-api/data/wx.getGroupCloudStorage.html) 、[wx.getGroupInfo](https://developers.weixin.qq.com/minigame/dev/api/open-api/data/wx.getGroupInfo.html) 、[wx.getPotentialFriendList](https://developers.weixin.qq.com/minigame/dev/api/open-api/data/wx.getPotentialFriendList.html) 、[wx.getUserCloudStorageKeys](https://developers.weixin.qq.com/minigame/dev/api/open-api/data/wx.getUserCloudStorageKeys.html) 、[wx.getUserInfo](https://developers.weixin.qq.com/minigame/dev/api/open-api/data/OpenDataContext-wx.getUserInfo.html) 、[GameServerManager.getFriendsStateData](https://developers.weixin.qq.com/minigame/dev/api/game-server-manager/GameServerManager.getFriendsStateData.html) 接口,以及主域内的 [wx.getUserInteractiveStorage](https://developers.weixin.qq.com/minigame/dev/api/open-api/data/wx.getUserInteractiveStorage.html) 接口。 */ 'scope.WxFriendInteraction'?: boolean /** 是否授权模糊地理位置,对应接口 [wx.getFuzzyLocation](https://developers.weixin.qq.com/minigame/dev/api/location/wx.getFuzzyLocation.html) */ 'scope.userFuzzyLocation'?: boolean /** 是否授权用户信息,对应接口 [wx.getUserInfo](https://developers.weixin.qq.com/minigame/dev/api/open-api/user-info/wx.getUserInfo.html) */ 'scope.userInfo'?: boolean /** 是否授权精确地理位置,对应接口 [wx.getLocation](https://developers.weixin.qq.com/minigame/dev/api/location/wx.getLocation.html)。将废弃,请使用 scope.userFuzzyLocation 代替 */ 'scope.userLocation'?: boolean /** 是否授权微信运动步数,对应接口 [wx.getWeRunData](https://developers.weixin.qq.com/minigame/dev/api/open-api/werun/wx.getWeRunData.html) */ 'scope.werun'?: boolean /** 是否授权保存到相册,对应接口 [wx.saveImageToPhotosAlbum](https://developers.weixin.qq.com/minigame/dev/api/media/image/wx.saveImageToPhotosAlbum.html) */ 'scope.writePhotosAlbum'?: boolean } interface AuthorizeOption { /** 需要获取权限的 scope,详见 [scope 列表](https://developers.weixin.qq.com/minigame/dev/guide/base-ability/authorize.html#scope-列表) */ scope: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: AuthorizeCompleteCallback /** 接口调用失败的回调函数 */ fail?: AuthorizeFailCallback /** 接口调用成功的回调函数 */ success?: AuthorizeSuccessCallback } /** 设备特征列表 */ interface BLECharacteristic { /** 该特征支持的操作类型 */ properties: BLECharacteristicProperties /** 蓝牙设备特征的 UUID */ uuid: string } /** 该特征支持的操作类型 */ interface BLECharacteristicProperties { /** 该特征是否支持 indicate 操作 */ indicate: boolean /** 该特征是否支持 notify 操作 */ notify: boolean /** 该特征是否支持 read 操作 */ read: boolean /** 该特征是否支持 write 操作 */ write: boolean /** 该特征是否支持有回复写操作 */ writeDefault: boolean /** 该特征是否支持无回复写操作 */ writeNoResponse: boolean } /** 描述service的Object */ interface BLEPeripheralService { /** characteristics列表 */ characteristics: Characteristic[] /** 蓝牙服务的 UUID */ uuid: string } /** 设备服务列表 */ interface BLEService { /** 该服务是否为主服务 */ isPrimary: boolean /** 蓝牙设备服务的 UUID */ uuid: string } /** banner 广告组件。banner 广告组件是一个原生组件,层级比普通组件高。banner 广告组件默认是隐藏的,需要调用 BannerAd.show() 将其显示。banner 广告会根据开发者设置的宽度进行等比缩放,缩放后的尺寸将通过 BannerAd.onResize() 事件中提供。 */ interface BannerAd { /** banner 广告组件的样式。style 上的属性的值仅为开发者设置的值,banner 广告会根据开发者设置的宽度进行等比缩放,缩放后的真实尺寸需要通过 BannerAd.onResize() 事件获得。 */ style: BannerAdStyle /** [BannerAd.destroy()](https://developers.weixin.qq.com/minigame/dev/api/ad/BannerAd.destroy.html) * * 销毁 banner 广告。 */ destroy(): void /** [BannerAd.hide()](https://developers.weixin.qq.com/minigame/dev/api/ad/BannerAd.hide.html) * * 隐藏 banner 广告。 */ hide(): void /** [BannerAd.offError(function listener)](https://developers.weixin.qq.com/minigame/dev/api/ad/BannerAd.offError.html) * * 移除 banner 广告错误事件的监听函数 * * **示例代码** * * ```js const listener = function (res) { console.log(res) } BannerAd.onError(listener) BannerAd.offError(listener) // 需传入与监听时同一个的函数对象 ``` */ offError( /** onError 传入的监听函数。不传此参数则移除所有监听函数。 */ listener?: GridAdOffErrorCallback ): void /** [BannerAd.offLoad(function listener)](https://developers.weixin.qq.com/minigame/dev/api/ad/BannerAd.offLoad.html) * * 移除 banner 广告加载事件的监听函数 * * **示例代码** * * ```js const listener = function (res) { console.log(res) } BannerAd.onLoad(listener) BannerAd.offLoad(listener) // 需传入与监听时同一个的函数对象 ``` */ offLoad( /** onLoad 传入的监听函数。不传此参数则移除所有监听函数。 */ listener?: OffLoadCallback ): void /** [BannerAd.offResize(function listener)](https://developers.weixin.qq.com/minigame/dev/api/ad/BannerAd.offResize.html) * * 移除 banner 广告尺寸变化事件的监听函数 * * **示例代码** * * ```js const listener = function (res) { console.log(res) } BannerAd.onResize(listener) BannerAd.offResize(listener) // 需传入与监听时同一个的函数对象 ``` */ offResize( /** onResize 传入的监听函数。不传此参数则移除所有监听函数。 */ listener?: OffResizeCallback ): void /** [BannerAd.onError(function listener)](https://developers.weixin.qq.com/minigame/dev/api/ad/BannerAd.onError.html) * * 监听 banner 广告错误事件。 * * **错误码信息与解决方案表** * * 错误码是通过onError获取到的错误信息。调试期间,可以通过异常返回来捕获信息。 * 在小程序发布上线之后,如果遇到异常问题,可以在[“运维中心“](https://mp.weixin.qq.com/)里面搜寻错误日志,还可以针对异常返回加上适当的监控信息。 * * | 代码 | 异常情况 | 理由 | 解决方案 | * | ------ | -------------- | --------------- | -------------------------- | * | 1000 | 后端错误调用失败 | 该项错误不是开发者的异常情况 | 一般情况下忽略一段时间即可恢复。 | * | 1001 | 参数错误 | 使用方法错误 | 可以前往developers.weixin.qq.com确认具体教程(小程序和小游戏分别有各自的教程,可以在顶部选项中,“设计”一栏的右侧进行切换。| * | 1002 | 广告单元无效 | 可能是拼写错误、或者误用了其他APP的广告ID | 请重新前往mp.weixin.qq.com确认广告位ID。 | * | 1003 | 内部错误 | 该项错误不是开发者的异常情况 | 一般情况下忽略一段时间即可恢复。| * | 1004 | 无适合的广告 | 广告不是每一次都会出现,这次没有出现可能是由于该用户不适合浏览广告 | 属于正常情况,且开发者需要针对这种情况做形态上的兼容。 | * | 1005 | 广告组件审核中 | 你的广告正在被审核,无法展现广告 | 请前往mp.weixin.qq.com确认审核状态,且开发者需要针对这种情况做形态上的兼容。| * | 1006 | 广告组件被驳回 | 你的广告审核失败,无法展现广告 | 请前往mp.weixin.qq.com确认审核状态,且开发者需要针对这种情况做形态上的兼容。| * | 1007 | 广告组件被封禁 | 你的广告能力已经被封禁,封禁期间无法展现广告 | 请前往mp.weixin.qq.com确认小程序广告封禁状态。 | * | 1008 | 广告单元已关闭 | 该广告位的广告能力已经被关闭 | 请前往mp.weixin.qq.com重新打开对应广告位的展现。| */ onError( /** banner 广告错误事件的监听函数 */ listener: GridAdOnErrorCallback ): void /** [BannerAd.onLoad(function listener)](https://developers.weixin.qq.com/minigame/dev/api/ad/BannerAd.onLoad.html) * * 监听 banner 广告加载事件。 */ onLoad( /** banner 广告加载事件的监听函数 */ listener: OnLoadCallback ): void /** [BannerAd.onResize(function listener)](https://developers.weixin.qq.com/minigame/dev/api/ad/BannerAd.onResize.html) * * 监听 banner 广告尺寸变化事件。 */ onResize( /** banner 广告尺寸变化事件的监听函数 */ listener: OnResizeCallback ): void /** [Promise BannerAd.show()](https://developers.weixin.qq.com/minigame/dev/api/ad/BannerAd.show.html) * * 显示 banner 广告。 */ show(): Promise<any> } /** banner 广告组件的样式。style 上的属性的值仅为开发者设置的值,banner 广告会根据开发者设置的宽度进行等比缩放,缩放后的真实尺寸需要通过 BannerAd.onResize() 事件获得。 */ interface BannerAdStyle { /** banner 广告组件的高度 */ height: number /** banner 广告组件的左上角横坐标 */ left: number /** banner 广告组件经过缩放后真实的高度 */ realHeight: number /** banner 广告组件经过缩放后真实的宽度 */ realWidth: number /** banner 广告组件的左上角纵坐标 */ top: number /** banner 广告组件的宽度。最小 300,最大至 `屏幕宽度`(屏幕宽度可以通过 wx.getSystemInfoSync() 获取)。 */ width: number } /** Beacon 设备 */ interface BeaconInfo { /** Beacon 设备的距离,单位 m。iOS 上,proximity 为 0 时,accuracy 为 -1。 */ accuracy: number /** Beacon 设备的主 ID */ major: number /** Beacon 设备的次 ID */ minor: number /** 表示设备距离的枚举值(仅iOS) * * 可选值: * - 0: 信号太弱不足以计算距离,或非 iOS 设备; * - 1: 十分近; * - 2: 比较近; * - 3: 远; */ proximity: 0 | 1 | 2 | 3 /** 表示设备的信号强度,单位 dBm */ rssi: number /** Beacon 设备广播的 UUID */ uuid: string } /** 需要基础库: `2.20.1` * * 以 beacon 设备形式广播的参数。 */ interface BeaconInfoObj { /** Beacon 设备的主 ID */ major: number /** Beacon 设备的次 ID */ minor: number /** Beacon 设备广播的 UUID */ uuid: string /** 用于判断距离设备 1 米时 RSSI 大小的参考值 */ measuredPower?: number } interface BindWifiOption { /** 当前 wifi 网络的 BSSID ,可通过 wx.getConnectedWifi 获取 */ BSSID: string } interface BlueToothDevice { /** 当前蓝牙设备的信号强度,单位 dBm */ RSSI: number /** 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 */ advertisData: ArrayBuffer /** 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 */ advertisServiceUUIDs: string[] /** 当前蓝牙设备是否可连接( Android 8.0 以下不支持返回该值 ) */ connectable: boolean /** 蓝牙设备 id */ deviceId: string /** 当前蓝牙设备的广播数据段中的 LocalName 数据段 */ localName: string /** 蓝牙设备名称,某些设备可能没有 */ name: string /** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */ serviceData: IAnyObject } /** 搜索到的设备列表 */ interface BluetoothDeviceInfo { /** 用于区分设备的 id */ deviceId: string /** 蓝牙设备名称,某些设备可能没有 */ name: string } /** 需要基础库: `2.28.0` * * 人体检测配置。用法详情[指南文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/visionkit/body.html)。 */ interface BodyTrack { /** 需要基础库: `2.28.0` * * 人体检测模式 * * 可选值: * - 1: 通过摄像头实时检测; * - 2: 静态图片检测; */ mode: 1 | 2 } interface BroadcastInRoomOption { /** 广播内容 */ msg: string /** 给座位号为哪些的玩家发送信息,不填代表给房间所有人发送 */ toPosNumList: number[] /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: BroadcastInRoomCompleteCallback /** 接口调用失败的回调函数 */ fail?: BroadcastInRoomFailCallback /** 接口调用成功的回调函数 */ success?: BroadcastInRoomSuccessCallback } /** 音频源节点,通过 [WebAudioContext.createBufferSource](https://developers.weixin.qq.com/minigame/dev/api/media/audio/WebAudioContext.createBufferSource.html)方法获得。 * * **示例代码** * * ```js const source = audioCtx.createBufferSource() source.buffer = AudioBuffer source.connect(audioCtx.destination) source.start() ``` */ interface BufferSourceNode { /** [AudioBuffer](https://developers.weixin.qq.com/minigame/dev/api/media/audio/AudioBuffer.html) * * 是一个 AudioBuffer, 它定义了要播放的音频,当设置它的值为 0 时,它会定义一个静默的单通道。(可读可写) */ buffer: AudioBuffer /** 定义音频是否循环播放(可读可写) */ loop?: boolean /** 定义音频循环播放时,结束播放的位置。单位是秒,默认值是0(可读可写) */ loopEnd?: number /** 定义音频循环播放时,开始播放的位置。单位是秒,默认值是0(可读可写) */ loopStart?: number /** 定义音频播放结束事件回调函数(可读可写) */ onended?: (...args: any[]) => any /** [AudioParam](https://developers.weixin.qq.com/minigame/dev/api/media/audio/AudioParam.html) * * 定义音频的播放倍速,数值越大速度越快,默认速度1.0,有效范围为 0 < playbackRate <= 2.0(可读可写) */ playbackRate?: AudioParam /** [BufferSourceNode.connect(AudioNode|[AudioParam](https://developers.weixin.qq.com/minigame/dev/api/media/audio/AudioParam.html) destination)](https://developers.weixin.qq.com/minigame/dev/api/media/audio/BufferSourceNode.connect.html) * * 连接到一个指定目标。这个指定的目标可能是另一个 AudioNode(从而将音频数据引导到下一个指定节点)或一个AudioParam, 以便上一个节点的输出数据随着时间流逝能自动地对下一个参数值进行改变 */ connect( /** 要建立连接的目标节点 */ destination: AudioNode | AudioParam ): void /** [BufferSourceNode.disconnect()](https://developers.weixin.qq.com/minigame/dev/api/media/audio/BufferSourceNode.disconnect.html) * * 与已连接的目标节点断开连接 */ disconnect(): void /** [BufferSourceNode.start(number when, number offset, number duration)](https://developers.weixin.qq.com/minigame/dev/api/media/audio/BufferSourceNode.start.html) * * 音频源开始播放 */ start( /** 延迟播放的时间,单位是秒。与 AudioContext 使用相同的时间坐标系统。如果 when 小于 AudioContext.currentTime, 或者是 0,声音立即被播放。 默认值是 0 */ when?: number, /** 音频开始播放的位置,单位是秒。默认值是 0 */ offset?: number, /** 音频播放的持续时间,单位是秒。如果这个参数没有被指定,声音播放到自然结束或者使用stop() 方法结束。使用这个参数的功能与调用 start(when, offset) 和调用 stop(when+duration)效果完全相同 */ duration?: number ): void /** [BufferSourceNode.stop(number when)](https://developers.weixin.qq.com/minigame/dev/api/media/audio/BufferSourceNode.stop.html) * * 停止播放 */ stop( /** 延迟停止播放的时间,单位是秒。与 AudioContext 使用相同的时间坐标系统。省略此参数、指定值 0 或传递负值会使声音立即停止播放。 */ when?: number ): void } /** 相机对象 */ interface Camera { /** 摄像头朝向 */ devicePosition: string /** 闪光灯,值为 auto, on, off */ flash: string /** 相机的高度 */ height: number /** 帧数据图像尺寸,值为 small, medium, large */ size: string /** 相机的宽度 */ width: number /** 相机的左上角横坐标 */ x: number /** 相机的左上角纵坐标 */ y: number /** [Camera.closeFrameChange()](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.closeFrameChange.html) * * 需要基础库: `2.9.0` * * 关闭监听帧数据 */ closeFrameChange(): void /** [Camera.destroy()](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.destroy.html) * * 需要基础库: `2.9.0` * * 销毁相机 */ destroy(): void /** [Camera.listenFrameChange([Worker](https://developers.weixin.qq.com/minigame/dev/api/worker/Worker.html) worker)](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.listenFrameChange.html) * * 需要基础库: `2.9.0` * * 开启监听帧数据 */ listenFrameChange( /** [Worker](https://developers.weixin.qq.com/minigame/dev/api/worker/Worker.html) * * 需要基础库: `2.17.0` * * 可选参数。如果需要在 iOS ExperimentalWorker 内监听摄像头帧数据,则需要传入对应 Worker 对象,否则不需要传入任何参数。详情 [Worker.getCameraFrameData](https://developers.weixin.qq.com/minigame/dev/api/worker/Worker.getCameraFrameData.html) */ worker?: Worker ): void /** [Camera.onAuthCancel(function callback)](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.onAuthCancel.html) * * 需要基础库: `2.9.0` * * 监听用户不允许授权使用摄像头的情况 */ onAuthCancel( /** 事件发生时的回调函数 */ callback: (...args: any[]) => any ): void /** [Camera.onCameraFrame(function callback)](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.onCameraFrame.html) * * 需要基础库: `2.9.0` * * 监听摄像头实时帧数据 */ onCameraFrame( /** 摄像头返回实时帧数据的回调函数 */ callback: OnCameraFrameCallback ): void /** [Camera.onStop(function callback)](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.onStop.html) * * 需要基础库: `2.9.0` * * 监听摄像头非正常终止事件,如退出后台等情况 */ onStop( /** 事件发生时的回调函数 */ callback: (...args: any[]) => any ): void /** [Promise Camera.startRecord()](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.startRecord.html) * * 需要基础库: `2.9.0` * * 开始录像 */ startRecord(): Promise<any> /** [Promise Camera.stopRecord(boolean compressed)](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.stopRecord.html) * * 需要基础库: `2.9.0` * * 结束录像,成功则返回封面与视频 */ stopRecord( /** 是否压缩录制视频 */ compressed?: boolean ): Promise<any> /** [Promise Camera.takePhoto(string quality)](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.takePhoto.html) * * 需要基础库: `2.9.0` * * 拍照,可指定质量,成功则返回图片 */ takePhoto( /** 拍照质量,值为 high, normal, low */ quality?: string ): Promise<any> } interface CancelMatchOption { /** 需要取消匹配的matchId */ matchId: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CancelMatchCompleteCallback /** 接口调用失败的回调函数 */ fail?: CancelMatchFailCallback /** 接口调用成功的回调函数 */ success?: CancelMatchSuccessCallback } /** 画布对象 */ interface Canvas { /** 画布的高度 */ height: number /** 画布的宽度 */ width: number /** [Canvas.toTempFilePath(Object object)](https://developers.weixin.qq.com/minigame/dev/api/render/canvas/Canvas.toTempFilePath.html) * * 将当前 Canvas 保存为一个临时文件。**如果使用了开放数据域,则生成后的文件仅能被用于以下接口:`wx.saveImageToPhotosAlbum`、`wx.shareAppMessage`、`wx.onShareAppMessage`、`wx.previewImage`、`wx.previewMedia`、`wx.onShareTimeline`、`wx.showShareImageMenu`** */ toTempFilePath(option: ToTempFilePathOption): void /** [[RenderingContext](https://developers.weixin.qq.com/minigame/dev/api/render/canvas/RenderingContext.html) Canvas.getContext(string contextType, Object contextAttributes)](https://developers.weixin.qq.com/minigame/dev/api/render/canvas/Canvas.getContext.html) * * 获取画布对象的绘图上下文 */ getContext( /** 上下文类型 * * 参数 contextType 可选值: * - '2d': 2d 绘图上下文; * - 'webgl': webgl 绘图上下文; * - 'webgl2': webgl2 绘图上下文; */ contextType: '2d' | 'webgl' | 'webgl2', /** webgl 上下文属性,仅当 contextType 为 webgl 时有效 */ contextAttributes?: ContextAttributes ): any /** [string Canvas.toDataURL()](https://developers.weixin.qq.com/minigame/dev/api/render/canvas/Canvas.toDataURL.html) * * 把画布上的绘制内容以一个 data URI 的格式返回 */ toDataURL(): string /** [string Canvas.toTempFilePathSync(Object object)](https://developers.weixin.qq.com/minigame/dev/api/render/canvas/Canvas.toTempFilePathSync.html) * * [Canvas.toTempFilePath](https://developers.weixin.qq.com/minigame/dev/api/render/canvas/Canvas.toTempFilePath.html) 的同步版本 */ toTempFilePathSync(option: ToTempFilePathSyncOption): string } interface ChangeSeatOption { /** 座位号,从 0 开始 */ posNum: number /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: ChangeSeatCompleteCallback /** 接口调用失败的回调函数 */ fail?: ChangeSeatFailCallback /** 接口调用成功的回调函数 */ success?: ChangeSeatSuccessCallback } /** characteristics列表 */ interface Characteristic { /** characteristic 的 UUID */ uuid: string /** 描述符数据 */ descriptors?: Descriptor[] /** 特征权限 */ permission?: CharacteristicPermission /** 特征支持的操作 */ properties?: CharacteristicProperties /** 特征对应的二进制值 */ value?: ArrayBuffer } /** 特征权限 */ interface CharacteristicPermission { /** 加密读请求 */ readEncryptionRequired?: boolean /** 可读 */ readable?: boolean /** 加密写请求 */ writeEncryptionRequired?: boolean /** 可写 */ writeable?: boolean } /** 特征支持的操作 */ interface CharacteristicProperties { /** 回包 */ indicate?: boolean /** 订阅 */ notify?: boolean /** 读 */ read?: boolean /** 写 */ write?: boolean /** 无回复写 */ writeNoResponse?: boolean } interface CheckHandoffEnabledOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CheckHandoffEnabledCompleteCallback /** 接口调用失败的回调函数 */ fail?: CheckHandoffEnabledFailCallback /** 接口调用成功的回调函数 */ success?: CheckHandoffEnabledSuccessCallback } interface CheckHandoffEnabledSuccessCallbackResult { /** 错误码,0未知,1用户取消,2电脑未登录,3电脑版本过低,4暂未支持 */ errCode: number /** 是否可以进行接力 */ isEnabled: boolean errMsg: string } interface CheckIsAddedToMyMiniProgramOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CheckIsAddedToMyMiniProgramCompleteCallback /** 接口调用失败的回调函数 */ fail?: CheckIsAddedToMyMiniProgramFailCallback /** 接口调用成功的回调函数 */ success?: CheckIsAddedToMyMiniProgramSuccessCallback } interface CheckIsAddedToMyMiniProgramSuccessCallbackResult { /** 是否被添加至 「我的小程序」 */ added: boolean errMsg: string } interface CheckSessionOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CheckSessionCompleteCallback /** 接口调用失败的回调函数 */ fail?: CheckSessionFailCallback /** 接口调用成功的回调函数 */ success?: CheckSessionSuccessCallback } /** 返回选择的文件的本地临时文件对象数组 */ interface ChooseFile { /** 选择的文件名称 */ name: string /** 本地临时文件路径 (本地路径) */ path: string /** 本地临时文件大小,单位 B */ size: number /** 选择的文件的会话发送时间,Unix时间戳,工具暂不支持此属性 */ time: number /** 选择的文件类型 * * 可选值: * - 'video': 选择了视频文件; * - 'image': 选择了图片文件; * - 'file': 选择了除图片和视频的文件; */ type: 'video' | 'image' | 'file' } interface ChooseImageOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: ChooseImageCompleteCallback /** 最多可以选择的图片张数 */ count?: number /** 接口调用失败的回调函数 */ fail?: ChooseImageFailCallback /** 所选的图片的尺寸 * * 可选值: * - 'original': 原图; * - 'compressed': 压缩图; */ sizeType?: Array<'original' | 'compressed'> /** 选择图片的来源 * * 可选值: * - 'album': 从相册选图; * - 'camera': 使用相机; */ sourceType?: Array<'album' | 'camera'> /** 接口调用成功的回调函数 */ success?: ChooseImageSuccessCallback } interface ChooseImageSuccessCallbackResult { /** 图片的本地临时文件路径列表 (本地路径) */ tempFilePaths: string[] /** 需要基础库: `1.2.0` * * 图片的本地临时文件列表 */ tempFiles: ImageFile[] errMsg: string } interface ChooseMediaOption { /** 仅在 sourceType 为 camera 时生效,使用前置或后置摄像头 * * 可选值: * - 'back': 使用后置摄像头; * - 'front': 使用前置摄像头; */ camera?: 'back' | 'front' /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: ChooseMediaCompleteCallback /** 最多可以选择的文件个数,基础库2.25.0前,最多可支持9个文件,2.25.0及以后最多可支持20个文件 */ count?: number /** 接口调用失败的回调函数 */ fail?: ChooseMediaFailCallback /** 拍摄视频最长拍摄时间,单位秒。时间范围为 3s 至 60s 之间。不限制相册。 */ maxDuration?: number /** 文件类型 * * 可选值: * - 'image': 只能拍摄图片或从相册选择图片; * - 'video': 只能拍摄视频或从相册选择视频; * - 'mix': 可同时选择图片和视频; */ mediaType?: Array<'image' | 'video' | 'mix'> /** 是否压缩所选文件,基础库2.25.0前仅对 mediaType 为 image 时有效,2.25.0及以后对全量 mediaType 有效 */ sizeType?: string[] /** 图片和视频选择的来源 * * 可选值: * - 'album': 从相册选择; * - 'camera': 使用相机拍摄; */ sourceType?: Array<'album' | 'camera'> /** 接口调用成功的回调函数 */ success?: ChooseMediaSuccessCallback } interface ChooseMediaSuccessCallbackResult { /** 本地临时文件列表 */ tempFiles: MediaFile[] /** 文件类型,有效值有 image 、video、mix */ type: string errMsg: string } interface ChooseMessageFileOption { /** 最多可以选择的文件个数,可以 0~100 */ count: number /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: ChooseMessageFileCompleteCallback /** 需要基础库: `2.6.0` * * 根据文件拓展名过滤,仅 type==file 时有效。每一项都不能是空字符串。默认不过滤。 */ extension?: string[] /** 接口调用失败的回调函数 */ fail?: ChooseMessageFileFailCallback /** 接口调用成功的回调函数 */ success?: ChooseMessageFileSuccessCallback /** 所选的文件的类型 * * 可选值: * - 'all': 从所有文件选择; * - 'video': 只能选择视频文件; * - 'image': 只能选择图片文件; * - 'file': 可以选择除了图片和视频之外的其它的文件; */ type?: 'all' | 'video' | 'image' | 'file' } interface ChooseMessageFileSuccessCallbackResult { /** 返回选择的文件的本地临时文件对象数组 */ tempFiles: ChooseFile[] errMsg: string } interface ClearStorageOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: ClearStorageCompleteCallback /** 接口调用失败的回调函数 */ fail?: ClearStorageFailCallback /** 接口调用成功的回调函数 */ success?: ClearStorageSuccessCallback } /** 菜单按钮的布局位置信息 */ interface ClientRect { /** 下边界坐标,单位:px */ bottom: number /** 高度,单位:px */ height: number /** 左边界坐标,单位:px */ left: number /** 右边界坐标,单位:px */ right: number /** 上边界坐标,单位:px */ top: number /** 宽度,单位:px */ width: number } interface CloseBLEConnectionOption { /** 蓝牙设备 id */ deviceId: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CloseBLEConnectionCompleteCallback /** 接口调用失败的回调函数 */ fail?: CloseBLEConnectionFailCallback /** 接口调用成功的回调函数 */ success?: CloseBLEConnectionSuccessCallback } interface CloseBluetoothAdapterOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CloseBluetoothAdapterCompleteCallback /** 接口调用失败的回调函数 */ fail?: CloseBluetoothAdapterFailCallback /** 接口调用成功的回调函数 */ success?: CloseBluetoothAdapterSuccessCallback } interface CloseSocketOption { /** 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。 */ code?: number /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CloseSocketCompleteCallback /** 接口调用失败的回调函数 */ fail?: CloseSocketFailCallback /** 一个可读的字符串,表示连接被关闭的原因。这个字符串必须是不长于 123 字节的 UTF-8 文本(不是字符)。 */ reason?: string /** 接口调用成功的回调函数 */ success?: CloseSocketSuccessCallback } interface CloseSyncOption { /** 需要被关闭的文件描述符。fd 通过 [FileSystemManager.open](https://developers.weixin.qq.com/minigame/dev/api/file/FileSystemManager.open.html) 或 [FileSystemManager.openSync](https://developers.weixin.qq.com/minigame/dev/api/file/FileSystemManager.openSync.html) 接口获得 */ fd: string } interface CompressImageOption { /** 图片路径,图片的路径,支持本地路径、代码包路径 */ src: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CompressImageCompleteCallback /** 需要基础库: `2.26.0` * * 压缩后图片的高度,单位为px,若不填写则默认以compressedWidth为准等比缩放 */ compressedHeight?: number /** 需要基础库: `2.26.0` * * 压缩后图片的宽度,单位为px,若不填写则默认以compressedHeight为准等比缩放。 */ compressedWidth?: number /** 接口调用失败的回调函数 */ fail?: CompressImageFailCallback /** 压缩质量,范围0~100,数值越小,质量越低,压缩率越高(仅对jpg有效)。 */ quality?: number /** 接口调用成功的回调函数 */ success?: CompressImageSuccessCallback } interface CompressImageSuccessCallbackResult { /** 压缩后图片的临时文件路径 (本地路径) */ tempFilePath: string errMsg: string } interface ConnectSocketOption { /** 开发者服务器 wss 接口地址 */ url: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: ConnectSocketCompleteCallback /** 接口调用失败的回调函数 */ fail?: ConnectSocketFailCallback /** 需要基础库: `2.29.0` * * 强制使用蜂窝网络发送请求 */ forceCellularNetwork?: boolean /** HTTP Header,Header 中不能设置 Referer */ header?: IAnyObject /** 需要基础库: `2.8.0` * * 是否开启压缩扩展 */ perMessageDeflate?: boolean /** 需要基础库: `1.4.0` * * 子协议数组 */ protocols?: string[] /** 接口调用成功的回调函数 */ success?: ConnectSocketSuccessCallback /** 需要基础库: `2.4.0` * * 建立 TCP 连接的时候的 TCP_NODELAY 设置 */ tcpNoDelay?: boolean /** 需要基础库: `2.10.0` * * 超时时间,单位为毫秒 */ timeout?: number } /** 一个字典对象,用于指定是否禁用规范化(默认启用规范化) */ interface Constraints { /** 如果指定为true则禁用标准化,默认为false */ disableNormalization?: boolean } /** webgl 上下文属性,仅当 contextType 为 webgl 时有效 */ interface ContextAttributes { /** 需要基础库: `2.11.0` * * 是否开启透明通道,仅当 contextType 为 webgl 时有效。(开启后,配合wx.createVideo({underGameView: true}) 即可在video组件之上渲染主屏画布) */ alpha?: number /** 表示是否抗锯齿 */ antialias?: boolean /** 抗锯齿样本数。最小值为 2,最大不超过系统限制数量,仅 iOS 支持 */ antialiasSamples?: number /** 表示是否绘图完成后是否保留绘图缓冲区 */ preserveDrawingBuffer?: boolean } interface CopyFileOption { /** 目标文件路径,支持本地路径 */ destPath: string /** 源文件路径,支持本地路径 */ srcPath: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CopyFileCompleteCallback /** 接口调用失败的回调函数 */ fail?: CopyFileFailCallback /** 接口调用成功的回调函数 */ success?: CopyFileSuccessCallback } interface CreateBLEConnectionOption { /** 蓝牙设备 id */ deviceId: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CreateBLEConnectionCompleteCallback /** 接口调用失败的回调函数 */ fail?: CreateBLEConnectionFailCallback /** 接口调用成功的回调函数 */ success?: CreateBLEConnectionSuccessCallback /** 超时时间,单位 ms,不填表示不会超时 */ timeout?: number } interface CreateBLEPeripheralServerOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CreateBLEPeripheralServerCompleteCallback /** 接口调用失败的回调函数 */ fail?: CreateBLEPeripheralServerFailCallback /** 接口调用成功的回调函数 */ success?: CreateBLEPeripheralServerSuccessCallback } interface CreateBLEPeripheralServerSuccessCallbackResult { /** [BLEPeripheralServer](https://developers.weixin.qq.com/minigame/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.html) * * 外围设备的服务端。 */ server: BLEPeripheralServer errMsg: string } interface CreateBannerAdOption { /** 广告单元 id */ adUnitId: string /** banner 广告组件的样式 */ style: CreateBannerAdStyleOption /** 广告自动刷新的间隔时间,单位为秒,参数值必须大于等于30(该参数不传入时 Banner 广告不会自动刷新) */ adIntervals?: number } /** banner 广告组件的样式 */ interface CreateBannerAdStyleOption { /** banner 广告组件的高度 */ height: number /** banner 广告组件的左上角横坐标 */ left: number /** banner 广告组件的左上角纵坐标 */ top: number /** banner 广告组件的宽度 */ width: number } interface CreateCameraOption { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CreateCameraCompleteCallback /** 摄像头朝向,值为 front, back */ devicePosition?: string /** 接口调用失败的回调函数 */ fail?: CreateCameraFailCallback /** 闪光灯,值为 auto, on, off */ flash?: string /** 相机的高度 */ height?: number /** 帧数据图像尺寸,值为 small, medium, large */ size?: string /** 接口调用成功的回调函数 */ success?: CreateCameraSuccessCallback /** 相机的宽度 */ width?: number /** 相机的左上角横坐标 */ x?: number /** 相机的左上角纵坐标 */ y?: number } interface CreateCustomAdOption { /** 广告自动刷新的间隔时间,单位为秒,参数值必须大于等于30(仅对支持自动刷新的模板生效) */ adIntervals: number /** 广告单元 id */ adUnitId: string /** 原生模板广告组件的样式 */ style: CreateCustomAdStyleOption } /** 原生模板广告组件的样式 */ interface CreateCustomAdStyleOption { /** (只对小程序适用) 原生模板广告组件是否固定屏幕位置(不跟随屏幕滚动) */ fixed: boolean /** 原生模板广告组件的左上角横坐标 */ left: number /** 原生模板广告组件的左上角纵坐标 */ top: number /** 原生模板广告组件的宽度(仅在某些模板生效,如矩阵格子) */ width: number } interface CreateGameClubButtonOption { /** 游戏圈按钮的图标,仅当 object.type 参数为 image 时有效。 * * 可选值: * - 'green': 绿色的图标; * - 'white': 白色的图标; * - 'dark': 有黑色圆角背景的白色图标; * - 'light': 有白色圆角背景的绿色图标; */ icon: 'green' | 'white' | 'dark' | 'light' /** 按钮的样式 */ style: OptionStyle /** 按钮的类型。 * * 可选值: * - 'text': 可以设置背景色和文本的按钮; * - 'image': 只能设置背景贴图的按钮,背景贴图会直接拉伸到按钮的宽高; */ type: 'text' | 'image' /** 按钮的背景图片,仅当 type 为 `image` 时有效 */ image?: string /** 需要基础库: `2.30.3` * * 当传递了openlink值时,此字段生效,决定创建的按钮是否需要拥有红点,默认为true */ hasRedDot?: boolean /** 需要基础库: `2.30.3` * * 设置后可以跳到对应的活动页面,具体进入「MP后台-能力地图-游戏圈」-由帖子的"游戏内跳转ID"生成 */ openlink?: string /** 按钮上的文本,仅当 type 为 `text` 时有效 */ text?: string } interface CreateGameRecorderShareButtonOption { /** 对局回放的分享参数。 */ share: ShareOption /** 按钮的样式 */ style: CreateGameRecorderShareButtonStyleOption /** 图标的 url。支持 http/https 开头的网络资源和 wxfile:// 开头的本地资源。如果不设置则使用默认图标。 */ icon?: string /** 按钮的背景图片的 url。支持 http/https 开头的网络资源和 wxfile:// 开头的本地资源。如果不设置则使用默认图标。 */ image?: string /** 按钮的文本。 */ text?: string } /** 按钮的样式 */ interface CreateGameRecorderShareButtonStyleOption { /** 文本的颜色。 */ color?: string /** 文本的字体大小。最小 17,最大 22。 */ fontSize?: number /** 按钮的高度,最小 40 逻辑像素 */ height?: number /** 图标和文本之间的距离,最小 8 逻辑像素 */ iconMarginRight?: number /** 左上角横坐标,单位 逻辑像素 */ left?: number /** 按钮的左内边距,最小 16 逻辑像素。 */ paddingLeft?: number /** 按钮的右内边距,最小 16 逻辑像素。 */ paddingRight?: number /** 左上角纵坐标,单位 逻辑像素 */ top?: number } interface CreateGridAdOption { /** grid(格子) 广告广告组件的主题,提供 `white` `black` 两种主题选择。 */ adTheme: string /** 广告单元 id */ adUnitId: string /** grid(格子) 广告组件的格子个数,可设置爱5,8两种格子个数样式,默认值为5 */ gridCount: number /** grid(格子) 广告组件的样式 */ style: CreateGridAdStyleOption /** 广告自动刷新的间隔时间,单位为秒,参数值必须大于等于30(该参数不传入时 grid(格子) 广告不会自动刷新) */ adIntervals?: number } /** grid(格子) 广告组件的样式 */ interface CreateGridAdStyleOption { /** grid(格子) 广告组件的高度 */ height: number /** grid(格子) 广告组件的左上角横坐标 */ left: number /** grid(格子) 广告组件的左上角纵坐标 */ top: number /** grid(格子) 广告组件的宽度 */ width: number } interface CreateInferenceSessionOption { /** 模型文件路径,目前只执行后缀为.onnx格式(支持代码包路径,和本地文件系统路径) */ model: string /** 是否使用NPU推理,仅对IOS有效 */ allowNPU?: boolean /** 是否生成量化模型推理 */ allowQuantize?: boolean /** 推理精度,有效值为 0 - 4。一般来说,使用的precesionLevel等级越低,推理速度越快,但可能会损失精度。推荐开发者在开发时,在效果满足需求时优先使用更低精度以提高推理速度,节约能耗。 * * 可选值: * - 0: 使用fp16 存储浮点,fp16计算,Winograd 算法也采取fp16 计算,开启近似math计算; * - 1: 使用fp16 存储浮点,fp16计算,禁用 Winograd 算法,开启近似math计算; * - 2: 使用fp16 存储浮点,fp32计算,开启 Winograd,开启近似math计算; * - 3: 使用fp32 存储浮点,fp32计算,开启 Winograd,开启近似math计算; * - 4: 使用fp32 存储浮点,fp32计算,开启 Winograd,关闭近似math计算; */ precesionLevel?: 0 | 1 | 2 | 3 | 4 /** 输入典型分辨率 */ typicalShape?: IAnyObject } interface CreateInnerAudioContextOption { /** 需要基础库: `2.19.0` * * 是否使用 WebAudio 作为底层音频驱动,默认关闭。对于短音频、播放频繁的音频建议开启此选项,开启后将获得更优的性能表现。由于开启此选项后也会带来一定的内存增长,因此对于长音频建议关闭此选项。 */ useWebAudioImplement?: boolean } interface CreateInterstitialAdOption { /** 广告单元 id */ adUnitId: string } interface CreateOpenSettingButtonOption { /** 按钮的样式 */ style: OptionStyle /** 按钮的类型。 * * 可选值: * - 'text': 可以设置背景色和文本的按钮; * - 'image': 只能设置背景贴图的按钮,背景贴图会直接拉伸到按钮的宽高; */ type: 'text' | 'image' /** 按钮的背景图片,仅当 type 为 `image` 时有效 */ image?: string /** 按钮上的文本,仅当 type 为 `text` 时有效 */ text?: string } interface CreateRewardedVideoAdOption { /** 广告单元 id */ adUnitId: string /** 需要基础库: `2.8.0` * * 是否启用多例模式,默认为false */ multiton?: boolean } interface CreateRoomOption { /** 房间最大人数 */ maxMemberNum: number /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: CreateRoomCompleteCallback /** 接口调用失败的回调函数 */ fail?: CreateRoomFailCallback /** 游戏对局时长,到达指定时长时游戏会结束,最大值 3600。 */ gameLastTime?: number /** 游戏自定义的关于个人的扩展信息,其他人可在 `MemberInfo` 中读取到,最多 32 个字节 */ memberExtInfo?: string /** 是否需要生成游戏随机种子,设置为 true,房间信息会携带 gameSeed 属性 */ needGameSeed?: boolean /** 是否需要用户头像和昵称 * * 可选值: * - 'true': 需要用户头像和昵称,则每个加入房间的人必须授权过用户信息,MemberInfo 中会有 headimage 和 nickname; * - 'false': 不需要用户头像和昵称,MemberInfo 中不会有 headimage 和 nickname; */ needUserInfo?: 'true' | 'false' /** 游戏自定义的关于房间扩展信息,其他人可在 `RoomInfo` 中读取到最多 32 个字节 */ roomExtInfo?: string /** 需要满足百分比的玩家都发送了开始指令才能启动游戏。有效范围 0~100,0 表示只要有一个人调用开始就启动,100 表示要求所有人都开始才能启动。 */ startPercent?: number /** 接口调用成功的回调函数 */ success?: CreateRoomSuccessCallback } interface CreateRoomSuccessCallbackDataResult { /** 房间唯一标识 */ accessInfo: string /** 用户在房间内的唯一标识 */ clientId: number } interface CreateRoomSuccessCallbackResult { data: CreateRoomSuccessCallbackDataResult /** 错误码 */ errCode: number /** 错误信息 */ errMsg: string } interface CreateUserInfoButtonOption { /** 按钮的样式 */ style: OptionStyle /** 按钮的类型。 * * 可选值: * - 'text': 可以设置背景色和文本的按钮; * - 'image': 只能设置背景贴图的按钮,背景贴图会直接拉伸到按钮的宽高; */ type: 'text' | 'image' /** 按钮的背景图片,仅当 type 为 `image` 时有效 */ image?: string /** 描述用户信息的语言 * * 可选值: * - 'en': 英文; * - 'zh_CN': 简体中文; * - 'zh_TW': 繁体中文; */ lang?: 'en' | 'zh_CN' | 'zh_TW' /** 是否带上登录态信息。当 withCredentials 为 true 时,要求此前有调用过 wx.login 且登录态尚未过期,此时返回的数据会包含 encryptedData, iv 等敏感信息;当 withCredentials 为 false 时,不要求有登录态,返回的数据不包含 encryptedData, iv 等敏感信息。 */ withCredentials?: boolean /** 按钮上的文本,仅当 type 为 `text` 时有效 */ text?: string } interface CreateVideoOption { /** 视频的资源地址 */ src: string /** 视频跳转后自动暂停播放 */ autoPauseIfNavigate?: boolean /** 视频跳转原生页后自动暂停播放 */ autoPauseIfOpenNative?: