@tarojs/taro 3.3.13 → 3.3.14
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/package.json +5 -5
- package/types/api/ad/index.d.ts +34 -28
- package/types/api/alipay/index.d.ts +11 -7
- package/types/api/base/debug.d.ts +60 -54
- package/types/api/base/env.d.ts +12 -8
- package/types/api/base/index.d.ts +87 -83
- package/types/api/base/system.d.ts +59 -54
- package/types/api/base/update.d.ts +37 -33
- package/types/api/base/weapp/app-event.d.ts +147 -131
- package/types/api/base/weapp/life-cycle.d.ts +14 -10
- package/types/api/canvas/index.d.ts +115 -110
- package/types/api/cloud/index.d.ts +99 -94
- package/types/api/data-analysis/index.d.ts +68 -64
- package/types/api/device/accelerometer.d.ts +57 -50
- package/types/api/device/battery.d.ts +19 -15
- package/types/api/device/ble.d.ts +241 -228
- package/types/api/device/bluetooth.d.ts +207 -194
- package/types/api/device/clipboard.d.ts +48 -43
- package/types/api/device/compass.d.ts +55 -48
- package/types/api/device/contact.d.ts +13 -9
- package/types/api/device/gyroscope.d.ts +41 -35
- package/types/api/device/iBeacon.d.ts +79 -73
- package/types/api/device/motion.d.ts +42 -37
- package/types/api/device/network.d.ts +48 -42
- package/types/api/device/nfc.d.ts +105 -96
- package/types/api/device/performance.d.ts +22 -18
- package/types/api/device/phone.d.ts +20 -15
- package/types/api/device/scan.d.ts +31 -26
- package/types/api/device/screen.d.ts +74 -67
- package/types/api/device/vibrate.d.ts +31 -25
- package/types/api/device/wifi.d.ts +151 -140
- package/types/api/ext/index.d.ts +44 -39
- package/types/api/files/index.d.ts +219 -209
- package/types/api/framework/index.d.ts +25 -20
- package/types/api/location/index.d.ts +140 -136
- package/types/api/media/audio.d.ts +135 -127
- package/types/api/media/background-audio.d.ts +135 -126
- package/types/api/media/camera.d.ts +30 -26
- package/types/api/media/editor.d.ts +35 -33
- package/types/api/media/image.d.ts +161 -150
- package/types/api/media/live.d.ts +88 -82
- package/types/api/media/map.d.ts +47 -43
- package/types/api/media/recorder.d.ts +90 -84
- package/types/api/media/video-processing.d.ts +10 -6
- package/types/api/media/video.d.ts +63 -58
- package/types/api/network/download.d.ts +34 -30
- package/types/api/network/mdns.d.ts +104 -91
- package/types/api/network/request.d.ts +83 -79
- package/types/api/network/udp.d.ts +20 -16
- package/types/api/network/upload.d.ts +60 -56
- package/types/api/network/websocket.d.ts +201 -194
- package/types/api/open-api/account.d.ts +18 -14
- package/types/api/open-api/address.d.ts +27 -23
- package/types/api/open-api/authorize.d.ts +30 -26
- package/types/api/open-api/card.d.ts +55 -51
- package/types/api/open-api/customer-service.d.ts +21 -17
- package/types/api/open-api/facial.d.ts +28 -24
- package/types/api/open-api/invoice.d.ts +38 -34
- package/types/api/open-api/login.d.ts +56 -52
- package/types/api/open-api/navigate.d.ts +79 -75
- package/types/api/open-api/payment.d.ts +34 -30
- package/types/api/open-api/settings.d.ts +49 -45
- package/types/api/open-api/soter.d.ts +92 -86
- package/types/api/open-api/subscribe-message.d.ts +24 -20
- package/types/api/open-api/user-info.d.ts +60 -57
- package/types/api/open-api/werun.d.ts +50 -46
- package/types/api/route/index.d.ts +122 -118
- package/types/api/share/index.d.ts +68 -64
- package/types/api/storage/background-fetch.d.ts +40 -35
- package/types/api/storage/index.d.ts +267 -262
- package/types/api/swan/index.d.ts +47 -42
- package/types/api/ui/animation.d.ts +21 -17
- package/types/api/ui/background.d.ts +38 -34
- package/types/api/ui/custom-component.d.ts +22 -18
- package/types/api/ui/fonts.d.ts +26 -21
- package/types/api/ui/interaction.d.ts +153 -149
- package/types/api/ui/keyboard.d.ts +59 -55
- package/types/api/ui/menu.d.ts +10 -6
- package/types/api/ui/navigation-bar.d.ts +67 -63
- package/types/api/ui/pull-down-refresh.d.ts +33 -29
- package/types/api/ui/scroll.d.ts +30 -26
- package/types/api/ui/sticky.d.ts +22 -19
- package/types/api/ui/tab-bar.d.ts +101 -97
- package/types/api/ui/window.d.ts +24 -18
- package/types/api/worker/index.d.ts +28 -24
- package/types/api/wxml/index.d.ts +42 -38
- package/types/global.d.ts +350 -0
- package/types/index.d.ts +12 -98
- package/types/taro.api.d.ts +94 -0
- package/types/taro.component.d.ts +10 -57
- package/types/taro.config.d.ts +24 -6
- package/types/taro.extend.d.ts +70 -67
- package/types/taro.hooks.d.ts +68 -67
- package/types/taro.lifecycle.d.ts +47 -28
- package/types/api/ad/index.ts +0 -6
- package/types/api/alipay/index.ts +0 -7
- package/types/api/index.d.ts +0 -352
|
@@ -1,36 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace stopBluetoothDevicesDiscovery {
|
|
3
|
-
interface Promised extends
|
|
5
|
+
interface Promised extends TaroGeneral.CallbackResult {
|
|
4
6
|
/** 成功:ok,错误:详细信息 */
|
|
5
7
|
errMsg: string
|
|
6
8
|
}
|
|
7
9
|
interface Option {
|
|
8
10
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
9
|
-
complete?: (res:
|
|
11
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
10
12
|
/** 接口调用失败的回调函数 */
|
|
11
|
-
fail?: (res:
|
|
13
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
12
14
|
/** 接口调用成功的回调函数 */
|
|
13
|
-
success?: (res:
|
|
15
|
+
success?: (res: TaroGeneral.BluetoothError) => void
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
|
-
/** 停止搜寻附近的蓝牙外围设备。若已经找到需要的蓝牙设备并不需要继续搜索时,建议调用该接口停止蓝牙搜索。
|
|
17
|
-
* @supported weapp
|
|
18
|
-
* @example
|
|
19
|
-
* ```tsx
|
|
20
|
-
* Taro.stopBluetoothDevicesDiscovery({
|
|
21
|
-
* success: function (res) {
|
|
22
|
-
* console.log(res)
|
|
23
|
-
* }
|
|
24
|
-
* })
|
|
25
|
-
* ```
|
|
26
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.stopBluetoothDevicesDiscovery.html
|
|
27
|
-
*/
|
|
28
|
-
function stopBluetoothDevicesDiscovery(
|
|
29
|
-
option?: stopBluetoothDevicesDiscovery.Option,
|
|
30
|
-
): Promise<stopBluetoothDevicesDiscovery.Promised>
|
|
31
18
|
|
|
32
19
|
namespace startBluetoothDevicesDiscovery {
|
|
33
|
-
interface Promised extends
|
|
20
|
+
interface Promised extends TaroGeneral.CallbackResult {
|
|
34
21
|
/** 成功:ok,错误:详细信息 */
|
|
35
22
|
errMsg: string
|
|
36
23
|
}
|
|
@@ -38,43 +25,26 @@ declare namespace Taro {
|
|
|
38
25
|
/** 是否允许重复上报同一设备。如果允许重复上报,则 Taro.onBlueToothDeviceFound 方法会多次上报同一设备,但是 RSSI 值会有不同。 */
|
|
39
26
|
allowDuplicatesKey?: boolean
|
|
40
27
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
41
|
-
complete?: (res:
|
|
28
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
42
29
|
/** 接口调用失败的回调函数 */
|
|
43
|
-
fail?: (res:
|
|
30
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
44
31
|
/** 上报设备的间隔。0 表示找到新设备立即上报,其他数值根据传入的间隔上报。 */
|
|
45
32
|
interval?: number
|
|
46
33
|
/** 要搜索的蓝牙设备主 service 的 uuid 列表。某些蓝牙设备会广播自己的主 service 的 uuid。如果设置此参数,则只搜索广播包有对应 uuid 的主服务的蓝牙设备。建议主要通过该参数过滤掉周边不需要处理的其他蓝牙设备。 */
|
|
47
34
|
services?: string[]
|
|
48
35
|
/** 接口调用成功的回调函数 */
|
|
49
|
-
success?: (res:
|
|
36
|
+
success?: (res: TaroGeneral.BluetoothError) => void
|
|
50
37
|
}
|
|
51
38
|
}
|
|
52
|
-
/** 开始搜寻附近的蓝牙外围设备。**此操作比较耗费系统资源,请在搜索并连接到设备后调用 Taro.stopBluetoothDevicesDiscovery 方法停止搜索。**
|
|
53
|
-
* @supported weapp
|
|
54
|
-
* @example
|
|
55
|
-
* ```tsx
|
|
56
|
-
* // 以微信硬件平台的蓝牙智能灯为例,主服务的 UUID 是 FEE7。传入这个参数,只搜索主服务 UUID 为 FEE7 的设备
|
|
57
|
-
* Taro.startBluetoothDevicesDiscovery({
|
|
58
|
-
* services: ['FEE7'],
|
|
59
|
-
* success: function (res) {
|
|
60
|
-
* console.log(res)
|
|
61
|
-
* }
|
|
62
|
-
* })
|
|
63
|
-
* ```
|
|
64
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.startBluetoothDevicesDiscovery.html
|
|
65
|
-
*/
|
|
66
|
-
function startBluetoothDevicesDiscovery(
|
|
67
|
-
option: startBluetoothDevicesDiscovery.Option,
|
|
68
|
-
): Promise<startBluetoothDevicesDiscovery.Promised>
|
|
69
39
|
|
|
70
40
|
namespace openBluetoothAdapter {
|
|
71
41
|
interface Option {
|
|
72
42
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
73
|
-
complete?: (res:
|
|
43
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
74
44
|
/** 接口调用失败的回调函数 */
|
|
75
|
-
fail?: (res:
|
|
45
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
76
46
|
/** 接口调用成功的回调函数 */
|
|
77
|
-
success?: (res:
|
|
47
|
+
success?: (res: TaroGeneral.BluetoothError) => void
|
|
78
48
|
}
|
|
79
49
|
|
|
80
50
|
/** object.fail 回调函数返回的 state 参数(仅 iOS) */
|
|
@@ -91,23 +61,6 @@ declare namespace Taro {
|
|
|
91
61
|
4
|
|
92
62
|
}
|
|
93
63
|
}
|
|
94
|
-
/** 初始化蓝牙模块
|
|
95
|
-
*
|
|
96
|
-
* **注意**
|
|
97
|
-
* - 其他蓝牙相关 API 必须在 Taro.openBluetoothAdapter 调用之后使用。否则 API 会返回错误(errCode=10000)。
|
|
98
|
-
* - 在用户蓝牙开关未开启或者手机不支持蓝牙功能的情况下,调用 Taro.openBluetoothAdapter 监听手机蓝牙状态的改变,也可以调用蓝牙模块的所有API。
|
|
99
|
-
* @supported weapp
|
|
100
|
-
* @example
|
|
101
|
-
* ```tsx
|
|
102
|
-
* Taro.openBluetoothAdapter({
|
|
103
|
-
* success: function (res) {
|
|
104
|
-
* console.log(res)
|
|
105
|
-
* }
|
|
106
|
-
* })
|
|
107
|
-
* ```
|
|
108
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.openBluetoothAdapter.html
|
|
109
|
-
*/
|
|
110
|
-
function openBluetoothAdapter(option?: openBluetoothAdapter.Option): Promise<General.CallbackResult>
|
|
111
64
|
|
|
112
65
|
namespace onBluetoothDeviceFound {
|
|
113
66
|
/** 寻找到新设备的事件的回调函数 */
|
|
@@ -133,40 +86,9 @@ declare namespace Taro {
|
|
|
133
86
|
/** 蓝牙设备名称,某些设备可能没有 */
|
|
134
87
|
name: string
|
|
135
88
|
/** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */
|
|
136
|
-
serviceData:
|
|
89
|
+
serviceData: TaroGeneral.IAnyObject
|
|
137
90
|
}
|
|
138
91
|
}
|
|
139
|
-
/** 监听寻找到新设备的事件
|
|
140
|
-
*
|
|
141
|
-
* **注意**
|
|
142
|
-
* - 若在 Taro.onBluetoothDeviceFound 回调了某个设备,则此设备会添加到 Taro.getBluetoothDevices 接口获取到的数组中。
|
|
143
|
-
* - 安卓下部分机型需要有位置权限才能搜索到设备,需留意是否开启了位置权限
|
|
144
|
-
* @supported weapp
|
|
145
|
-
* @example
|
|
146
|
-
* ```tsx
|
|
147
|
-
* // ArrayBuffer转16进度字符串示例
|
|
148
|
-
* function ab2hex(buffer) {
|
|
149
|
-
* var hexArr = Array.prototype.map.call(
|
|
150
|
-
* new Uint8Array(buffer),
|
|
151
|
-
* function(bit) {
|
|
152
|
-
* return ('00' + bit.toString(16)).slice(-2)
|
|
153
|
-
* }
|
|
154
|
-
* )
|
|
155
|
-
* return hexArr.join('');
|
|
156
|
-
* }
|
|
157
|
-
* Taro.onBluetoothDeviceFound(function (res) {
|
|
158
|
-
* var devices = res.devices;
|
|
159
|
-
* console.log('new device list has founded')
|
|
160
|
-
* console.dir(devices)
|
|
161
|
-
* console.log(ab2hex(devices[0].advertisData))
|
|
162
|
-
* })
|
|
163
|
-
* ```
|
|
164
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.onBluetoothDeviceFound.html
|
|
165
|
-
*/
|
|
166
|
-
function onBluetoothDeviceFound(
|
|
167
|
-
/** 寻找到新设备的事件的回调函数 */
|
|
168
|
-
callback: onBluetoothDeviceFound.Callback,
|
|
169
|
-
): void
|
|
170
92
|
|
|
171
93
|
namespace onBluetoothAdapterStateChange {
|
|
172
94
|
/** 蓝牙适配器状态变化事件的回调函数 */
|
|
@@ -180,33 +102,19 @@ declare namespace Taro {
|
|
|
180
102
|
discovering: boolean
|
|
181
103
|
}
|
|
182
104
|
}
|
|
183
|
-
/** 监听蓝牙适配器状态变化事件
|
|
184
|
-
* @supported weapp
|
|
185
|
-
* @example
|
|
186
|
-
* ```tsx
|
|
187
|
-
* Taro.onBluetoothAdapterStateChange(function (res) {
|
|
188
|
-
* console.log('adapterState changed, now is', res)
|
|
189
|
-
* })
|
|
190
|
-
* ```
|
|
191
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.onBluetoothAdapterStateChange.html
|
|
192
|
-
*/
|
|
193
|
-
function onBluetoothAdapterStateChange(
|
|
194
|
-
/** 蓝牙适配器状态变化事件的回调函数 */
|
|
195
|
-
callback: onBluetoothAdapterStateChange.Callback,
|
|
196
|
-
): void
|
|
197
105
|
|
|
198
106
|
namespace getConnectedBluetoothDevices {
|
|
199
107
|
interface Option {
|
|
200
108
|
/** 蓝牙设备主 service 的 uuid 列表 */
|
|
201
109
|
services: string[]
|
|
202
110
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
203
|
-
complete?: (res:
|
|
111
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
204
112
|
/** 接口调用失败的回调函数 */
|
|
205
|
-
fail?: (res:
|
|
113
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
206
114
|
/** 接口调用成功的回调函数 */
|
|
207
115
|
success?: (result: SuccessCallbackResult) => void
|
|
208
116
|
}
|
|
209
|
-
interface SuccessCallbackResult extends
|
|
117
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
210
118
|
/** 搜索到的设备列表 */
|
|
211
119
|
devices: BluetoothDeviceInfo[]
|
|
212
120
|
/** 成功:ok,错误:详细信息 */
|
|
@@ -220,39 +128,24 @@ declare namespace Taro {
|
|
|
220
128
|
name: string
|
|
221
129
|
}
|
|
222
130
|
}
|
|
223
|
-
/** 根据 uuid 获取处于已连接状态的设备。
|
|
224
|
-
* @supported weapp
|
|
225
|
-
* @example
|
|
226
|
-
* ```tsx
|
|
227
|
-
* Taro.getConnectedBluetoothDevices({
|
|
228
|
-
* success: function (res) {
|
|
229
|
-
* console.log(res)
|
|
230
|
-
* }
|
|
231
|
-
* })
|
|
232
|
-
* ```
|
|
233
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getConnectedBluetoothDevices.html
|
|
234
|
-
*/
|
|
235
|
-
function getConnectedBluetoothDevices(
|
|
236
|
-
option: getConnectedBluetoothDevices.Option,
|
|
237
|
-
): void
|
|
238
131
|
|
|
239
132
|
namespace getBluetoothDevices {
|
|
240
133
|
interface Option {
|
|
241
134
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
242
|
-
complete?: (res:
|
|
135
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
243
136
|
/** 接口调用失败的回调函数 */
|
|
244
|
-
fail?: (res:
|
|
137
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
245
138
|
/** 接口调用成功的回调函数 */
|
|
246
139
|
success?: (res: SuccessCallbackResult) => void
|
|
247
140
|
}
|
|
248
|
-
interface SuccessCallbackResult extends
|
|
141
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
249
142
|
/** uuid 对应的的已连接设备列表 */
|
|
250
143
|
devices: SuccessCallbackResultBlueToothDevice[]
|
|
251
144
|
/** 成功:ok,错误:详细信息 */
|
|
252
145
|
errMsg: string
|
|
253
146
|
}
|
|
254
147
|
/** uuid 对应的的已连接设备列表 */
|
|
255
|
-
interface SuccessCallbackResultBlueToothDevice extends
|
|
148
|
+
interface SuccessCallbackResultBlueToothDevice extends TaroGeneral.CallbackResult {
|
|
256
149
|
/** 当前蓝牙设备的信号强度 */
|
|
257
150
|
RSSI: number
|
|
258
151
|
/** 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 */
|
|
@@ -266,51 +159,21 @@ declare namespace Taro {
|
|
|
266
159
|
/** 蓝牙设备名称,某些设备可能没有 */
|
|
267
160
|
name: string
|
|
268
161
|
/** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */
|
|
269
|
-
serviceData:
|
|
162
|
+
serviceData: TaroGeneral.IAnyObject
|
|
270
163
|
}
|
|
271
164
|
}
|
|
272
|
-
/** 获取在蓝牙模块生效期间所有已发现的蓝牙设备。包括已经和本机处于连接状态的设备。
|
|
273
|
-
*
|
|
274
|
-
* **注意事项**
|
|
275
|
-
* - 该接口获取到的设备列表为**蓝牙模块生效期间所有搜索到的蓝牙设备**,若在蓝牙模块使用流程结束后未及时调用 Taro.closeBluetoothAdapter 释放资源,会存在调用该接口会返回之前的蓝牙使用流程中搜索到的蓝牙设备,可能设备已经不在用户身边,无法连接。
|
|
276
|
-
* - 蓝牙设备在被搜索到时,系统返回的 name 字段一般为广播包中的 LocalName 字段中的设备名称,而如果与蓝牙设备建立连接,系统返回的 name 字段会改为从蓝牙设备上获取到的 `GattName`。若需要动态改变设备名称并展示,建议使用 `localName` 字段。
|
|
277
|
-
* @supported weapp
|
|
278
|
-
* @example
|
|
279
|
-
* ```tsx
|
|
280
|
-
* // ArrayBuffer转16进度字符串示例
|
|
281
|
-
* function ab2hex(buffer) {
|
|
282
|
-
* var hexArr = Array.prototype.map.call(
|
|
283
|
-
* new Uint8Array(buffer),
|
|
284
|
-
* function(bit) {
|
|
285
|
-
* return ('00' + bit.toString(16)).slice(-2)
|
|
286
|
-
* }
|
|
287
|
-
* )
|
|
288
|
-
* return hexArr.join('');
|
|
289
|
-
* }
|
|
290
|
-
* Taro.getBluetoothDevices({
|
|
291
|
-
* success: function (res) {
|
|
292
|
-
* console.log(res)
|
|
293
|
-
* if (res.devices[0]) {
|
|
294
|
-
* console.log(ab2hex(res.devices[0].advertisData))
|
|
295
|
-
* }
|
|
296
|
-
* }
|
|
297
|
-
* })
|
|
298
|
-
* ```
|
|
299
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getBluetoothDevices.html
|
|
300
|
-
*/
|
|
301
|
-
function getBluetoothDevices(option?: getBluetoothDevices.Option): Promise<getBluetoothDevices.SuccessCallbackResult>
|
|
302
165
|
|
|
303
166
|
namespace getBluetoothAdapterState {
|
|
304
167
|
interface Option {
|
|
305
168
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
306
|
-
complete?: (res:
|
|
169
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
307
170
|
/** 接口调用失败的回调函数 */
|
|
308
|
-
fail?: (res:
|
|
171
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
309
172
|
/** 接口调用成功的回调函数 */
|
|
310
173
|
success?: (result: SuccessCallbackResult) => void
|
|
311
174
|
}
|
|
312
175
|
|
|
313
|
-
interface SuccessCallbackResult extends
|
|
176
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
314
177
|
/** 蓝牙适配器是否可用 */
|
|
315
178
|
available: boolean
|
|
316
179
|
/** 是否正在搜索设备 */
|
|
@@ -319,43 +182,193 @@ declare namespace Taro {
|
|
|
319
182
|
errMsg: string
|
|
320
183
|
}
|
|
321
184
|
}
|
|
322
|
-
/** 获取本机蓝牙适配器状态。
|
|
323
|
-
* @supported weapp
|
|
324
|
-
* @example
|
|
325
|
-
* ```tsx
|
|
326
|
-
* Taro.getBluetoothAdapterState({
|
|
327
|
-
* success: function (res) {
|
|
328
|
-
* console.log(res)
|
|
329
|
-
* }
|
|
330
|
-
* })
|
|
331
|
-
* ```
|
|
332
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getBluetoothAdapterState.html
|
|
333
|
-
*/
|
|
334
|
-
function getBluetoothAdapterState(
|
|
335
|
-
option?: getBluetoothAdapterState.Option,
|
|
336
|
-
): Promise<getBluetoothAdapterState.SuccessCallbackResult>
|
|
337
185
|
|
|
338
186
|
namespace closeBluetoothAdapter {
|
|
339
187
|
interface Option {
|
|
340
188
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
341
|
-
complete?: (res:
|
|
189
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
342
190
|
/** 接口调用失败的回调函数 */
|
|
343
|
-
fail?: (res:
|
|
191
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
344
192
|
/** 接口调用成功的回调函数 */
|
|
345
|
-
success?: (res:
|
|
193
|
+
success?: (res: TaroGeneral.BluetoothError) => void
|
|
346
194
|
}
|
|
347
195
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
196
|
+
|
|
197
|
+
interface TaroStatic {
|
|
198
|
+
/** 停止搜寻附近的蓝牙外围设备。若已经找到需要的蓝牙设备并不需要继续搜索时,建议调用该接口停止蓝牙搜索。
|
|
199
|
+
* @supported weapp
|
|
200
|
+
* @example
|
|
201
|
+
* ```tsx
|
|
202
|
+
* Taro.stopBluetoothDevicesDiscovery({
|
|
203
|
+
* success: function (res) {
|
|
204
|
+
* console.log(res)
|
|
205
|
+
* }
|
|
206
|
+
* })
|
|
207
|
+
* ```
|
|
208
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.stopBluetoothDevicesDiscovery.html
|
|
209
|
+
*/
|
|
210
|
+
stopBluetoothDevicesDiscovery(
|
|
211
|
+
option?: stopBluetoothDevicesDiscovery.Option,
|
|
212
|
+
): Promise<stopBluetoothDevicesDiscovery.Promised>
|
|
213
|
+
|
|
214
|
+
/** 开始搜寻附近的蓝牙外围设备。**此操作比较耗费系统资源,请在搜索并连接到设备后调用 Taro.stopBluetoothDevicesDiscovery 方法停止搜索。**
|
|
215
|
+
* @supported weapp
|
|
216
|
+
* @example
|
|
217
|
+
* ```tsx
|
|
218
|
+
* // 以微信硬件平台的蓝牙智能灯为例,主服务的 UUID 是 FEE7。传入这个参数,只搜索主服务 UUID 为 FEE7 的设备
|
|
219
|
+
* Taro.startBluetoothDevicesDiscovery({
|
|
220
|
+
* services: ['FEE7'],
|
|
221
|
+
* success: function (res) {
|
|
222
|
+
* console.log(res)
|
|
223
|
+
* }
|
|
224
|
+
* })
|
|
225
|
+
* ```
|
|
226
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.startBluetoothDevicesDiscovery.html
|
|
227
|
+
*/
|
|
228
|
+
startBluetoothDevicesDiscovery(
|
|
229
|
+
option: startBluetoothDevicesDiscovery.Option,
|
|
230
|
+
): Promise<startBluetoothDevicesDiscovery.Promised>
|
|
231
|
+
|
|
232
|
+
/** 初始化蓝牙模块
|
|
233
|
+
*
|
|
234
|
+
* **注意**
|
|
235
|
+
* - 其他蓝牙相关 API 必须在 Taro.openBluetoothAdapter 调用之后使用。否则 API 会返回错误(errCode=10000)。
|
|
236
|
+
* - 在用户蓝牙开关未开启或者手机不支持蓝牙功能的情况下,调用 Taro.openBluetoothAdapter 监听手机蓝牙状态的改变,也可以调用蓝牙模块的所有API。
|
|
237
|
+
* @supported weapp
|
|
238
|
+
* @example
|
|
239
|
+
* ```tsx
|
|
240
|
+
* Taro.openBluetoothAdapter({
|
|
241
|
+
* success: function (res) {
|
|
242
|
+
* console.log(res)
|
|
243
|
+
* }
|
|
244
|
+
* })
|
|
245
|
+
* ```
|
|
246
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.openBluetoothAdapter.html
|
|
247
|
+
*/
|
|
248
|
+
openBluetoothAdapter(option?: openBluetoothAdapter.Option): Promise<TaroGeneral.CallbackResult>
|
|
249
|
+
|
|
250
|
+
/** 监听寻找到新设备的事件
|
|
251
|
+
*
|
|
252
|
+
* **注意**
|
|
253
|
+
* - 若在 Taro.onBluetoothDeviceFound 回调了某个设备,则此设备会添加到 Taro.getBluetoothDevices 接口获取到的数组中。
|
|
254
|
+
* - 安卓下部分机型需要有位置权限才能搜索到设备,需留意是否开启了位置权限
|
|
255
|
+
* @supported weapp
|
|
256
|
+
* @example
|
|
257
|
+
* ```tsx
|
|
258
|
+
* // ArrayBuffer转16进度字符串示例
|
|
259
|
+
* function ab2hex(buffer) {
|
|
260
|
+
* var hexArr = Array.prototype.map.call(
|
|
261
|
+
* new Uint8Array(buffer),
|
|
262
|
+
* function(bit) {
|
|
263
|
+
* return ('00' + bit.toString(16)).slice(-2)
|
|
264
|
+
* }
|
|
265
|
+
* )
|
|
266
|
+
* return hexArr.join('');
|
|
267
|
+
* }
|
|
268
|
+
* Taro.onBluetoothDeviceFound(function (res) {
|
|
269
|
+
* var devices = res.devices;
|
|
270
|
+
* console.log('new device list has founded')
|
|
271
|
+
* console.dir(devices)
|
|
272
|
+
* console.log(ab2hex(devices[0].advertisData))
|
|
273
|
+
* })
|
|
274
|
+
* ```
|
|
275
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.onBluetoothDeviceFound.html
|
|
276
|
+
*/
|
|
277
|
+
onBluetoothDeviceFound(
|
|
278
|
+
/** 寻找到新设备的事件的回调函数 */
|
|
279
|
+
callback: onBluetoothDeviceFound.Callback,
|
|
280
|
+
): void
|
|
281
|
+
|
|
282
|
+
/** 监听蓝牙适配器状态变化事件
|
|
283
|
+
* @supported weapp
|
|
284
|
+
* @example
|
|
285
|
+
* ```tsx
|
|
286
|
+
* Taro.onBluetoothAdapterStateChange(function (res) {
|
|
287
|
+
* console.log('adapterState changed, now is', res)
|
|
288
|
+
* })
|
|
289
|
+
* ```
|
|
290
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.onBluetoothAdapterStateChange.html
|
|
291
|
+
*/
|
|
292
|
+
onBluetoothAdapterStateChange(
|
|
293
|
+
/** 蓝牙适配器状态变化事件的回调函数 */
|
|
294
|
+
callback: onBluetoothAdapterStateChange.Callback,
|
|
295
|
+
): void
|
|
296
|
+
|
|
297
|
+
/** 根据 uuid 获取处于已连接状态的设备。
|
|
298
|
+
* @supported weapp
|
|
299
|
+
* @example
|
|
300
|
+
* ```tsx
|
|
301
|
+
* Taro.getConnectedBluetoothDevices({
|
|
302
|
+
* success: function (res) {
|
|
303
|
+
* console.log(res)
|
|
304
|
+
* }
|
|
305
|
+
* })
|
|
306
|
+
* ```
|
|
307
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getConnectedBluetoothDevices.html
|
|
308
|
+
*/
|
|
309
|
+
getConnectedBluetoothDevices(
|
|
310
|
+
option: getConnectedBluetoothDevices.Option,
|
|
311
|
+
): void
|
|
312
|
+
|
|
313
|
+
/** 获取在蓝牙模块生效期间所有已发现的蓝牙设备。包括已经和本机处于连接状态的设备。
|
|
314
|
+
*
|
|
315
|
+
* **注意事项**
|
|
316
|
+
* - 该接口获取到的设备列表为**蓝牙模块生效期间所有搜索到的蓝牙设备**,若在蓝牙模块使用流程结束后未及时调用 Taro.closeBluetoothAdapter 释放资源,会存在调用该接口会返回之前的蓝牙使用流程中搜索到的蓝牙设备,可能设备已经不在用户身边,无法连接。
|
|
317
|
+
* - 蓝牙设备在被搜索到时,系统返回的 name 字段一般为广播包中的 LocalName 字段中的设备名称,而如果与蓝牙设备建立连接,系统返回的 name 字段会改为从蓝牙设备上获取到的 `GattName`。若需要动态改变设备名称并展示,建议使用 `localName` 字段。
|
|
318
|
+
* @supported weapp
|
|
319
|
+
* @example
|
|
320
|
+
* ```tsx
|
|
321
|
+
* // ArrayBuffer转16进度字符串示例
|
|
322
|
+
* function ab2hex(buffer) {
|
|
323
|
+
* var hexArr = Array.prototype.map.call(
|
|
324
|
+
* new Uint8Array(buffer),
|
|
325
|
+
* function(bit) {
|
|
326
|
+
* return ('00' + bit.toString(16)).slice(-2)
|
|
327
|
+
* }
|
|
328
|
+
* )
|
|
329
|
+
* return hexArr.join('');
|
|
330
|
+
* }
|
|
331
|
+
* Taro.getBluetoothDevices({
|
|
332
|
+
* success: function (res) {
|
|
333
|
+
* console.log(res)
|
|
334
|
+
* if (res.devices[0]) {
|
|
335
|
+
* console.log(ab2hex(res.devices[0].advertisData))
|
|
336
|
+
* }
|
|
337
|
+
* }
|
|
338
|
+
* })
|
|
339
|
+
* ```
|
|
340
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getBluetoothDevices.html
|
|
341
|
+
*/
|
|
342
|
+
getBluetoothDevices(option?: getBluetoothDevices.Option): Promise<getBluetoothDevices.SuccessCallbackResult>
|
|
343
|
+
|
|
344
|
+
/** 获取本机蓝牙适配器状态。
|
|
345
|
+
* @supported weapp
|
|
346
|
+
* @example
|
|
347
|
+
* ```tsx
|
|
348
|
+
* Taro.getBluetoothAdapterState({
|
|
349
|
+
* success: function (res) {
|
|
350
|
+
* console.log(res)
|
|
351
|
+
* }
|
|
352
|
+
* })
|
|
353
|
+
* ```
|
|
354
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getBluetoothAdapterState.html
|
|
355
|
+
*/
|
|
356
|
+
getBluetoothAdapterState(
|
|
357
|
+
option?: getBluetoothAdapterState.Option,
|
|
358
|
+
): Promise<getBluetoothAdapterState.SuccessCallbackResult>
|
|
359
|
+
|
|
360
|
+
/** 关闭蓝牙模块。调用该方法将断开所有已建立的连接并释放系统资源。建议在使用蓝牙流程后,与 Taro.openBluetoothAdapter 成对调用。
|
|
361
|
+
* @supported weapp
|
|
362
|
+
* @example
|
|
363
|
+
* ```tsx
|
|
364
|
+
* Taro.closeBluetoothAdapter({
|
|
365
|
+
* success: function (res) {
|
|
366
|
+
* console.log(res)
|
|
367
|
+
* }
|
|
368
|
+
* })
|
|
369
|
+
* ```
|
|
370
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.closeBluetoothAdapter.html
|
|
371
|
+
*/
|
|
372
|
+
closeBluetoothAdapter(option?: closeBluetoothAdapter.Option): Promise<TaroGeneral.CallbackResult>
|
|
373
|
+
}
|
|
361
374
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace setClipboardData {
|
|
3
|
-
interface Promised extends
|
|
5
|
+
interface Promised extends TaroGeneral.CallbackResult {
|
|
4
6
|
/** 调用信息 */
|
|
5
7
|
errMsg: string
|
|
6
8
|
/** 剪贴板的内容 */
|
|
@@ -10,36 +12,16 @@ declare namespace Taro {
|
|
|
10
12
|
/** 剪贴板的内容 */
|
|
11
13
|
data: string
|
|
12
14
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
13
|
-
complete?: (res:
|
|
15
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
14
16
|
/** 接口调用失败的回调函数 */
|
|
15
|
-
fail?: (res:
|
|
17
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
16
18
|
/** 接口调用成功的回调函数 */
|
|
17
|
-
success?: (res:
|
|
19
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
/** 设置系统剪贴板的内容。调用成功后,会弹出 toast 提示"内容已复制",持续 1.5s
|
|
22
|
-
* @supported weapp, h5, rn
|
|
23
|
-
* @h5 部分实现
|
|
24
|
-
* @example
|
|
25
|
-
* ```tsx
|
|
26
|
-
* Taro.setClipboardData({
|
|
27
|
-
* data: 'data',
|
|
28
|
-
* success: function (res) {
|
|
29
|
-
* Taro.getClipboardData({
|
|
30
|
-
* success: function (res) {
|
|
31
|
-
* console.log(res.data) // data
|
|
32
|
-
* }
|
|
33
|
-
* })
|
|
34
|
-
* }
|
|
35
|
-
* })
|
|
36
|
-
* ```
|
|
37
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/clipboard/wx.setClipboardData.html
|
|
38
|
-
*/
|
|
39
|
-
function setClipboardData(option: setClipboardData.Option): Promise<setClipboardData.Promised>
|
|
40
|
-
|
|
41
23
|
namespace getClipboardData {
|
|
42
|
-
interface Promised extends
|
|
24
|
+
interface Promised extends TaroGeneral.CallbackResult {
|
|
43
25
|
/** 调用信息 */
|
|
44
26
|
errMsg: string
|
|
45
27
|
/** 剪贴板的内容 */
|
|
@@ -47,9 +29,9 @@ declare namespace Taro {
|
|
|
47
29
|
}
|
|
48
30
|
interface Option {
|
|
49
31
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
50
|
-
complete?: (res:
|
|
32
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
51
33
|
/** 接口调用失败的回调函数 */
|
|
52
|
-
fail?: (res:
|
|
34
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
53
35
|
/** 接口调用成功的回调函数 */
|
|
54
36
|
success?: (res: SuccessCallbackOption) => void
|
|
55
37
|
}
|
|
@@ -58,19 +40,42 @@ declare namespace Taro {
|
|
|
58
40
|
data: string
|
|
59
41
|
}
|
|
60
42
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
43
|
+
|
|
44
|
+
interface TaroStatic {
|
|
45
|
+
/** 设置系统剪贴板的内容。调用成功后,会弹出 toast 提示"内容已复制",持续 1.5s
|
|
46
|
+
* @supported weapp, h5, rn
|
|
47
|
+
* @h5 部分实现
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* Taro.setClipboardData({
|
|
51
|
+
* data: 'data',
|
|
52
|
+
* success: function (res) {
|
|
53
|
+
* Taro.getClipboardData({
|
|
54
|
+
* success: function (res) {
|
|
55
|
+
* console.log(res.data) // data
|
|
56
|
+
* }
|
|
57
|
+
* })
|
|
58
|
+
* }
|
|
59
|
+
* })
|
|
60
|
+
* ```
|
|
61
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/clipboard/wx.setClipboardData.html
|
|
62
|
+
*/
|
|
63
|
+
setClipboardData(option: setClipboardData.Option): Promise<setClipboardData.Promised>
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 获取系统剪贴板内容
|
|
67
|
+
* @supported weapp, h5, rn
|
|
68
|
+
* @h5 部分实现
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* Taro.getClipboardData({
|
|
72
|
+
* success: function (res){
|
|
73
|
+
* console.log(res.data)
|
|
74
|
+
* }
|
|
75
|
+
* })
|
|
76
|
+
* ```
|
|
77
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/clipboard/wx.getClipboardData.html
|
|
78
|
+
*/
|
|
79
|
+
getClipboardData(res?: getClipboardData.Option): Promise<getClipboardData.Promised>
|
|
80
|
+
}
|
|
76
81
|
}
|