@tarojs/taro 3.8.0-canary.0 → 4.0.0-alpha.2
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/html.css +9 -0
- package/package.json +16 -4
- package/types/api/ad/index.d.ts +6 -18
- package/types/api/ai/inference.d.ts +4 -8
- package/types/api/ai/visionkit.d.ts +625 -54
- package/types/api/base/debug.d.ts +8 -8
- package/types/api/base/env.d.ts +1 -1
- package/types/api/base/index.d.ts +3 -3
- package/types/api/base/performance.d.ts +5 -5
- package/types/api/base/system.d.ts +6 -6
- package/types/api/base/weapp/app-event.d.ts +10 -10
- package/types/api/base/weapp/life-cycle.d.ts +1 -1
- package/types/api/canvas/index.d.ts +389 -72
- package/types/api/data-analysis/index.d.ts +51 -1
- package/types/api/device/accelerometer.d.ts +8 -6
- package/types/api/device/accessibility.d.ts +1 -1
- package/types/api/device/battery.d.ts +3 -3
- package/types/api/device/bluetooth-ble.d.ts +40 -17
- package/types/api/device/bluetooth-peripheral.d.ts +26 -26
- package/types/api/device/bluetooth.d.ts +37 -13
- package/types/api/device/calendar.d.ts +11 -1
- package/types/api/device/clipboard.d.ts +17 -17
- package/types/api/device/compass.d.ts +5 -5
- package/types/api/device/gyroscope.d.ts +4 -4
- package/types/api/device/iBeacon.d.ts +10 -8
- package/types/api/device/keyboard.d.ts +7 -5
- package/types/api/device/memory.d.ts +3 -4
- package/types/api/device/motion.d.ts +8 -6
- package/types/api/device/network.d.ts +12 -6
- package/types/api/device/nfc.d.ts +13 -13
- package/types/api/device/phone.d.ts +1 -1
- package/types/api/device/scan.d.ts +5 -3
- package/types/api/device/screen.d.ts +28 -12
- package/types/api/device/sms.d.ts +1 -1
- package/types/api/device/vibrate.d.ts +5 -5
- package/types/api/device/wifi.d.ts +25 -13
- package/types/api/files/index.d.ts +73 -43
- package/types/api/framework/index.d.ts +2 -2
- package/types/api/location/index.d.ts +167 -19
- package/types/api/media/audio.d.ts +71 -42
- package/types/api/media/background-audio.d.ts +1 -1
- package/types/api/media/camera.d.ts +6 -3
- package/types/api/media/image.d.ts +5 -5
- package/types/api/media/video.d.ts +11 -11
- package/types/api/navigate/index.d.ts +3 -1
- package/types/api/network/download.d.ts +7 -15
- package/types/api/network/request.d.ts +7 -7
- package/types/api/network/upload.d.ts +9 -17
- package/types/api/network/websocket.d.ts +8 -8
- package/types/api/open-api/account.d.ts +1 -1
- package/types/api/open-api/address.d.ts +13 -5
- package/types/api/open-api/authorize.d.ts +1 -1
- package/types/api/open-api/channels.d.ts +16 -0
- package/types/api/open-api/device-voip.d.ts +42 -2
- package/types/api/open-api/invoice.d.ts +1 -1
- package/types/api/open-api/login.d.ts +16 -3
- package/types/api/open-api/my-miniprogram.d.ts +2 -2
- package/types/api/open-api/privacy.d.ts +107 -0
- package/types/api/open-api/settings.d.ts +3 -2
- package/types/api/open-api/sticker.d.ts +83 -0
- package/types/api/open-api/subscribe-message.d.ts +148 -6
- package/types/api/open-api/user-info.d.ts +6 -1
- package/types/api/qq/index.d.ts +306 -1
- package/types/api/route/index.d.ts +8 -5
- package/types/api/skyline/index.d.ts +59 -0
- package/types/api/storage/background-fetch.d.ts +63 -11
- package/types/api/storage/cache-manager.d.ts +61 -10
- package/types/api/storage/index.d.ts +125 -10
- package/types/api/swan/bookshelf.d.ts +307 -0
- package/types/api/swan/download-package.d.ts +80 -0
- package/types/api/swan/index.d.ts +151 -0
- package/types/api/swan/pay.d.ts +139 -0
- package/types/api/taro.extend.d.ts +15 -6
- package/types/api/taro.hooks.d.ts +9 -9
- package/types/api/ui/animation.d.ts +32 -32
- package/types/api/ui/custom-component.d.ts +1 -1
- package/types/api/ui/fonts.d.ts +4 -3
- package/types/api/ui/interaction.d.ts +6 -6
- package/types/api/ui/menu.d.ts +1 -1
- package/types/api/ui/navigation-bar.d.ts +5 -5
- package/types/api/ui/pull-down-refresh.d.ts +2 -2
- package/types/api/ui/scroll.d.ts +1 -1
- package/types/api/ui/tab-bar.d.ts +8 -8
- package/types/api/ui/window.d.ts +2 -2
- package/types/api/wxml/index.d.ts +19 -19
- package/types/compile/compiler.d.ts +9 -4
- package/types/compile/config/h5.d.ts +23 -10
- package/types/compile/config/harmony.d.ts +82 -0
- package/types/compile/config/index.d.ts +1 -0
- package/types/compile/config/mini.d.ts +58 -30
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/project.d.ts +26 -13
- package/types/compile/config/util.d.ts +22 -8
- package/types/compile/viteCompilerContext.d.ts +155 -0
- package/types/global.d.ts +3 -1
- package/types/index.d.ts +92 -44
- package/types/taro.api.d.ts +24 -13
- package/types/taro.component.d.ts +2 -1
- package/types/taro.config.d.ts +47 -6
- package/types/taro.lifecycle.d.ts +3 -0
- package/types/taro.runtime.d.ts +9 -0
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import Taro from '../../index'
|
|
2
2
|
|
|
3
3
|
declare module '../../index' {
|
|
4
|
+
namespace getCommonConfig {
|
|
5
|
+
interface Option {
|
|
6
|
+
/** 需要获取的数据指标的对象数组,每个string的格式约定:配置类型_分表key */
|
|
7
|
+
keys?: string[]
|
|
8
|
+
/** 0:通用配置模式 1:实验模式, 参数与返回结果的使用等效于接口wx.getExptInfoSync */
|
|
9
|
+
mode: 0 | 1
|
|
10
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
11
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
12
|
+
/** 接口调用失败的回调函数 */
|
|
13
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
14
|
+
/** 接口调用成功的回调函数 */
|
|
15
|
+
success?: (res: SuccessCallbackResult) => void
|
|
16
|
+
}
|
|
17
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
18
|
+
/** 错误码 */
|
|
19
|
+
errcode: number
|
|
20
|
+
/** 错误信息 */
|
|
21
|
+
errmsg: string
|
|
22
|
+
/** 配置类型, 1-表类型 2-kv类型 */
|
|
23
|
+
conf_type: number
|
|
24
|
+
/** 根据conf_type来确定conf内容, conf_type为1时conf是一个json数组, 类似"[{xxx},{xxx}]", 每一项对应表类型每一行配置内容, 其中conf_type为2时conf是一个json对象,类似"{xxxx}" */
|
|
25
|
+
conf: string
|
|
26
|
+
/** 过期时间,单位秒. 0表示当次有效 */
|
|
27
|
+
expire_sec: number
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
4
31
|
interface TaroStatic {
|
|
5
32
|
/** 自定义业务数据监控上报接口。
|
|
6
33
|
*
|
|
@@ -21,7 +48,7 @@ declare module '../../index' {
|
|
|
21
48
|
): void
|
|
22
49
|
|
|
23
50
|
/** 自定义分析数据上报接口。使用前,需要在小程序管理后台自定义分析中新建事件,配置好事件名与字段。
|
|
24
|
-
* @supported weapp, tt
|
|
51
|
+
* @supported weapp, swan, tt
|
|
25
52
|
* @example
|
|
26
53
|
* ```tsx
|
|
27
54
|
* Taro.reportAnalytics('purchase', {
|
|
@@ -68,5 +95,28 @@ declare module '../../index' {
|
|
|
68
95
|
/** 实验参数数组,不填则获取所有实验参数 */
|
|
69
96
|
keys?: Array<string>
|
|
70
97
|
): TaroGeneral.IAnyObject
|
|
98
|
+
|
|
99
|
+
/** 给定实验参数数组,获取对应的实验参数值
|
|
100
|
+
* @supported weapp
|
|
101
|
+
* @example
|
|
102
|
+
* ```tsx
|
|
103
|
+
* Taro.getCommonConfig({
|
|
104
|
+
* keys:["key1", "key2"],
|
|
105
|
+
* mode: 0,
|
|
106
|
+
* success: (res) => {
|
|
107
|
+
* console.log("success")
|
|
108
|
+
* console.log(res)
|
|
109
|
+
* },
|
|
110
|
+
* fail: (res) => {
|
|
111
|
+
* console.log("fail")
|
|
112
|
+
* console.log(res)
|
|
113
|
+
* }
|
|
114
|
+
* })
|
|
115
|
+
* ```
|
|
116
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/data-analysis/wx.getCommonConfig.html
|
|
117
|
+
*/
|
|
118
|
+
getCommonConfig(
|
|
119
|
+
option: getCommonConfig.Option
|
|
120
|
+
): Promise<getCommonConfig.SuccessCallbackResult>
|
|
71
121
|
}
|
|
72
122
|
}
|
|
@@ -56,7 +56,7 @@ declare module '../../index' {
|
|
|
56
56
|
* ```tsx
|
|
57
57
|
* Taro.startAccelerometer({ interval: 'game' })
|
|
58
58
|
* ```
|
|
59
|
-
* @supported weapp, h5, rn,
|
|
59
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony
|
|
60
60
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.startAccelerometer.html
|
|
61
61
|
*/
|
|
62
62
|
startAccelerometer (res?: startAccelerometer.Option): Promise<TaroGeneral.CallbackResult>
|
|
@@ -67,14 +67,14 @@ declare module '../../index' {
|
|
|
67
67
|
* ```tsx
|
|
68
68
|
* Taro.stopAccelerometer()
|
|
69
69
|
* ```
|
|
70
|
-
* @supported weapp, h5, rn,
|
|
70
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony
|
|
71
71
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.stopAccelerometer.html
|
|
72
72
|
*/
|
|
73
73
|
stopAccelerometer (res?: stopAccelerometer.Option): Promise<TaroGeneral.CallbackResult>
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* 监听加速度数据,频率:5次/秒,接口调用后会自动开始监听,可使用 `Taro.stopAccelerometer` 停止监听。
|
|
77
|
-
* @supported weapp, h5, rn,
|
|
77
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony
|
|
78
78
|
* @example
|
|
79
79
|
* ```tsx
|
|
80
80
|
* Taro.onAccelerometerChange(res => {
|
|
@@ -85,16 +85,18 @@ declare module '../../index' {
|
|
|
85
85
|
* ```
|
|
86
86
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.onAccelerometerChange.html
|
|
87
87
|
*/
|
|
88
|
-
onAccelerometerChange
|
|
88
|
+
onAccelerometerChange(
|
|
89
|
+
callback: onAccelerometerChange.Callback
|
|
90
|
+
): void
|
|
89
91
|
|
|
90
92
|
/**
|
|
91
93
|
* 取消监听加速度数据事件,参数为空,则取消所有的事件监听。
|
|
92
|
-
* @supported weapp, h5, rn
|
|
94
|
+
* @supported weapp, alipay, swan, jd, tt, h5, rn, harmony
|
|
93
95
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.offAccelerometerChange.html
|
|
94
96
|
*/
|
|
95
97
|
offAccelerometerChange(
|
|
96
98
|
/** 加速度数据事件的回调函数 */
|
|
97
|
-
callback?:
|
|
99
|
+
callback?: onAccelerometerChange.Callback
|
|
98
100
|
): void
|
|
99
101
|
}
|
|
100
102
|
}
|
|
@@ -18,7 +18,7 @@ declare module '../../index' {
|
|
|
18
18
|
|
|
19
19
|
interface TaroStatic {
|
|
20
20
|
/** 检测是否开启视觉无障碍功能。
|
|
21
|
-
* @supported weapp
|
|
21
|
+
* @supported weapp, jd
|
|
22
22
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accessibility/wx.checkIsOpenAccessibility.html
|
|
23
23
|
*/
|
|
24
24
|
checkIsOpenAccessibility(option: checkIsOpenAccessibility.Option): Promise<TaroGeneral.CallbackResult>
|
|
@@ -6,7 +6,7 @@ declare module '../../index' {
|
|
|
6
6
|
/** 是否正在充电中 */
|
|
7
7
|
isCharging: boolean
|
|
8
8
|
/** 设备电量,范围 1 - 100 */
|
|
9
|
-
level:
|
|
9
|
+
level: number
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -32,13 +32,13 @@ declare module '../../index' {
|
|
|
32
32
|
|
|
33
33
|
interface TaroStatic {
|
|
34
34
|
/** Taro.getBatteryInfo 的同步版本
|
|
35
|
-
* @supported weapp
|
|
35
|
+
* @supported weapp, alipay, swan, jd, qq, harmony
|
|
36
36
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/battery/wx.getBatteryInfoSync.html
|
|
37
37
|
*/
|
|
38
38
|
getBatteryInfoSync(): getBatteryInfoSync.Result
|
|
39
39
|
|
|
40
40
|
/** 获取设备电量。同步 API Taro.getBatteryInfoSync 在 iOS 上不可用。
|
|
41
|
-
* @supported weapp, h5
|
|
41
|
+
* @supported weapp, alipay, swan, jd, qq, h5, harmony, harmony_hybrid
|
|
42
42
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/battery/wx.getBatteryInfo.html
|
|
43
43
|
*/
|
|
44
44
|
getBatteryInfo(option?: getBatteryInfo.Option): Promise<getBatteryInfo.SuccessCallbackResult>
|
|
@@ -15,6 +15,8 @@ declare module '../../index' {
|
|
|
15
15
|
serviceId: string
|
|
16
16
|
/** 蓝牙设备特征值对应的二进制值 */
|
|
17
17
|
value: ArrayBuffer
|
|
18
|
+
/** 蓝牙特征值的写模式设置,有两种模式,iOS 优先 write,安卓优先 writeNoResponse 。(基础库 2.22.0 开始支持) */
|
|
19
|
+
writeType?: keyof WriteType
|
|
18
20
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
19
21
|
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
20
22
|
/** 接口调用失败的回调函数 */
|
|
@@ -22,6 +24,12 @@ declare module '../../index' {
|
|
|
22
24
|
/** 接口调用成功的回调函数 */
|
|
23
25
|
success?: (res: TaroGeneral.BluetoothError) => void
|
|
24
26
|
}
|
|
27
|
+
interface WriteType {
|
|
28
|
+
/** 强制回复写,不支持时报错 */
|
|
29
|
+
write
|
|
30
|
+
/** 强制无回复写,不支持时报错 */
|
|
31
|
+
writeNoResponse
|
|
32
|
+
}
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
namespace setBLEMTU {
|
|
@@ -122,6 +130,10 @@ declare module '../../index' {
|
|
|
122
130
|
serviceId: string
|
|
123
131
|
/** 是否启用 notify */
|
|
124
132
|
state: boolean
|
|
133
|
+
/** 设置特征订阅类型,有效值有 notification 和 indication
|
|
134
|
+
* @default "indication"
|
|
135
|
+
*/
|
|
136
|
+
type?: keyof Type
|
|
125
137
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
126
138
|
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
127
139
|
/** 接口调用失败的回调函数 */
|
|
@@ -129,6 +141,10 @@ declare module '../../index' {
|
|
|
129
141
|
/** 接口调用成功的回调函数 */
|
|
130
142
|
success?: (res: TaroGeneral.BluetoothError) => void
|
|
131
143
|
}
|
|
144
|
+
interface Type {
|
|
145
|
+
notification
|
|
146
|
+
indication
|
|
147
|
+
}
|
|
132
148
|
}
|
|
133
149
|
|
|
134
150
|
namespace getBLEMTU {
|
|
@@ -138,7 +154,7 @@ declare module '../../index' {
|
|
|
138
154
|
/** 写模式 (iOS 特有参数)
|
|
139
155
|
* @default "write"
|
|
140
156
|
*/
|
|
141
|
-
writeType
|
|
157
|
+
writeType?: keyof WriteType
|
|
142
158
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
143
159
|
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
144
160
|
/** 接口调用失败的回调函数 */
|
|
@@ -244,6 +260,10 @@ declare module '../../index' {
|
|
|
244
260
|
read: boolean
|
|
245
261
|
/** 该特征值是否支持 write 操作 */
|
|
246
262
|
write: boolean
|
|
263
|
+
/** 该特征是否支持无回复写操作 */
|
|
264
|
+
writeNoResponse: boolean
|
|
265
|
+
/** 该特征是否支持有回复写操作 */
|
|
266
|
+
writeDefault: boolean
|
|
247
267
|
}
|
|
248
268
|
}
|
|
249
269
|
|
|
@@ -291,7 +311,7 @@ declare module '../../index' {
|
|
|
291
311
|
* - 小程序不会对写入数据包大小做限制,但系统与蓝牙设备会限制蓝牙4.0单次传输的数据大小,超过最大字节数后会发生写入错误,建议每次写入不超过20字节。
|
|
292
312
|
* - 若单次写入数据过长,iOS 上存在系统不会有任何回调的情况(包括错误回调)。
|
|
293
313
|
* - 安卓平台上,在调用 `notifyBLECharacteristicValueChange` 成功后立即调用 `writeBLECharacteristicValue` 接口,在部分机型上会发生 10008 系统错误
|
|
294
|
-
* @supported weapp
|
|
314
|
+
* @supported weapp, alipay, jd
|
|
295
315
|
* @example
|
|
296
316
|
* ```tsx
|
|
297
317
|
* // 向蓝牙设备发送一个0x00的16进制数据
|
|
@@ -319,7 +339,10 @@ declare module '../../index' {
|
|
|
319
339
|
): Promise<writeBLECharacteristicValue.Promised>
|
|
320
340
|
|
|
321
341
|
/** 协商设置蓝牙低功耗的最大传输单元 (Maximum Transmission Unit, MTU)
|
|
322
|
-
*
|
|
342
|
+
*
|
|
343
|
+
* - 需在 Taro.createBLEConnection 调用成功后调用
|
|
344
|
+
* - 仅安卓系统 5.1 以上版本有效,iOS 因系统限制不支持。
|
|
345
|
+
* @supported weapp, alipay, jd
|
|
323
346
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.setBLEMTU.html
|
|
324
347
|
*/
|
|
325
348
|
setBLEMTU(
|
|
@@ -331,7 +354,7 @@ declare module '../../index' {
|
|
|
331
354
|
* **注意**
|
|
332
355
|
* - 并行调用多次会存在读失败的可能性。
|
|
333
356
|
* - 接口读取到的信息需要在 `onBLECharacteristicValueChange` 方法注册的回调中获取。
|
|
334
|
-
* @supported weapp
|
|
357
|
+
* @supported weapp, alipay, jd
|
|
335
358
|
* @example
|
|
336
359
|
* ```tsx
|
|
337
360
|
* // 必须在这里的回调才能获取
|
|
@@ -372,7 +395,7 @@ declare module '../../index' {
|
|
|
372
395
|
): void
|
|
373
396
|
|
|
374
397
|
/** 监听低功耗蓝牙连接状态的改变事件。包括开发者主动连接或断开连接,设备丢失,连接异常断开等等
|
|
375
|
-
* @supported weapp
|
|
398
|
+
* @supported weapp, alipay, jd
|
|
376
399
|
* @example
|
|
377
400
|
* ```tsx
|
|
378
401
|
* Taro.onBLEConnectionStateChange(function (res) {
|
|
@@ -388,7 +411,7 @@ declare module '../../index' {
|
|
|
388
411
|
): void
|
|
389
412
|
|
|
390
413
|
/** 监听低功耗蓝牙设备的特征值变化事件。必须先启用 `notifyBLECharacteristicValueChange` 接口才能接收到设备推送的 notification。
|
|
391
|
-
* @supported weapp
|
|
414
|
+
* @supported weapp, alipay, jd
|
|
392
415
|
* @example
|
|
393
416
|
* ```tsx
|
|
394
417
|
* // ArrayBuffer转16进制字符串示例
|
|
@@ -419,20 +442,20 @@ declare module '../../index' {
|
|
|
419
442
|
*/
|
|
420
443
|
offBLEMTUChange(
|
|
421
444
|
/** 蓝牙低功耗的最大传输单元变化事件的回调函数 */
|
|
422
|
-
callback
|
|
445
|
+
callback?: onBLEMTUChange.Callback,
|
|
423
446
|
): void
|
|
424
447
|
|
|
425
448
|
/** 取消监听蓝牙低功耗连接状态的改变事件
|
|
426
|
-
* @supported weapp
|
|
449
|
+
* @supported weapp, alipay
|
|
427
450
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLEConnectionStateChange.html
|
|
428
451
|
*/
|
|
429
452
|
offBLEConnectionStateChange(
|
|
430
453
|
/** 蓝牙低功耗连接状态的改变事件的回调函数 */
|
|
431
|
-
callback
|
|
454
|
+
callback?: onBLEConnectionStateChange.Callback,
|
|
432
455
|
): void
|
|
433
456
|
|
|
434
457
|
/** 取消监听蓝牙低功耗设备的特征值变化事件
|
|
435
|
-
* @supported weapp
|
|
458
|
+
* @supported weapp, alipay
|
|
436
459
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLECharacteristicValueChange.html
|
|
437
460
|
*/
|
|
438
461
|
offBLECharacteristicValueChange(
|
|
@@ -447,7 +470,7 @@ declare module '../../index' {
|
|
|
447
470
|
* **注意**
|
|
448
471
|
* - 订阅操作成功后需要设备主动更新特征值的 value,才会触发 Taro.onBLECharacteristicValueChange 回调。
|
|
449
472
|
* - 安卓平台上,在调用 `notifyBLECharacteristicValueChange` 成功后立即调用 `writeBLECharacteristicValue` 接口,在部分机型上会发生 10008 系统错误
|
|
450
|
-
* @supported weapp
|
|
473
|
+
* @supported weapp, alipay, jd
|
|
451
474
|
* @example
|
|
452
475
|
* ```tsx
|
|
453
476
|
* Taro.notifyBLECharacteristicValueChange({
|
|
@@ -474,7 +497,7 @@ declare module '../../index' {
|
|
|
474
497
|
* 注意:
|
|
475
498
|
* - 小程序中 MTU 为 ATT_MTU,包含 Op-Code 和 Attribute Handle 的长度,实际可以传输的数据长度为 ATT_MTU - 3
|
|
476
499
|
* - iOS 系统中 MTU 为固定值;安卓系统中,MTU 会在系统协商成功之后发生改变,建议使用 [Taro.onBLEMTUChange](/docs/apis/device/bluetooth-ble/onBLEMTUChange) 监听。
|
|
477
|
-
* @supported weapp
|
|
500
|
+
* @supported weapp, alipay, jd
|
|
478
501
|
* @example
|
|
479
502
|
* ```tsx
|
|
480
503
|
* Taro.getBLEMTU({
|
|
@@ -492,7 +515,7 @@ declare module '../../index' {
|
|
|
492
515
|
): Promise<getBLEMTU.SuccessCallbackResult>
|
|
493
516
|
|
|
494
517
|
/** 获取蓝牙设备所有服务(service)。
|
|
495
|
-
* @supported weapp
|
|
518
|
+
* @supported weapp, alipay, jd
|
|
496
519
|
* @example
|
|
497
520
|
* ```tsx
|
|
498
521
|
* Taro.getBLEDeviceServices({
|
|
@@ -510,7 +533,7 @@ declare module '../../index' {
|
|
|
510
533
|
): Promise<getBLEDeviceServices.SuccessCallbackResult>
|
|
511
534
|
|
|
512
535
|
/** 获取蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI)。
|
|
513
|
-
* @supported weapp
|
|
536
|
+
* @supported weapp, alipay, jd
|
|
514
537
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceRSSI.html
|
|
515
538
|
*/
|
|
516
539
|
getBLEDeviceRSSI(
|
|
@@ -518,7 +541,7 @@ declare module '../../index' {
|
|
|
518
541
|
): Promise<getBLEDeviceRSSI.SuccessCallbackResult>
|
|
519
542
|
|
|
520
543
|
/** 获取蓝牙设备某个服务中所有特征值(characteristic)。
|
|
521
|
-
* @supported weapp
|
|
544
|
+
* @supported weapp, alipay, jd
|
|
522
545
|
* @example
|
|
523
546
|
* ```tsx
|
|
524
547
|
* Taro.getBLEDeviceCharacteristics({
|
|
@@ -545,7 +568,7 @@ declare module '../../index' {
|
|
|
545
568
|
* - 请保证尽量成对的调用 `createBLEConnection` 和 `closeBLEConnection` 接口。安卓如果多次调用 `createBLEConnection` 创建连接,有可能导致系统持有同一设备多个连接的实例,导致调用 `closeBLEConnection` 的时候并不能真正的断开与设备的连接。
|
|
546
569
|
* - 蓝牙连接随时可能断开,建议监听 Taro.onBLEConnectionStateChange 回调事件,当蓝牙设备断开时按需执行重连操作
|
|
547
570
|
* - 若对未连接的设备或已断开连接的设备调用数据读写操作的接口,会返回 10006 错误,建议进行重连操作。
|
|
548
|
-
* @supported weapp
|
|
571
|
+
* @supported weapp, alipay, jd
|
|
549
572
|
* @example
|
|
550
573
|
* ```tsx
|
|
551
574
|
* Taro.createBLEConnection({
|
|
@@ -561,7 +584,7 @@ declare module '../../index' {
|
|
|
561
584
|
createBLEConnection(option: createBLEConnection.Option): Promise<createBLEConnection.Promised>
|
|
562
585
|
|
|
563
586
|
/** 断开与低功耗蓝牙设备的连接。
|
|
564
|
-
* @supported weapp
|
|
587
|
+
* @supported weapp, alipay, jd
|
|
565
588
|
* @example
|
|
566
589
|
* ```tsx
|
|
567
590
|
* Taro.closeBLEConnection({
|
|
@@ -13,7 +13,7 @@ declare module '../../index' {
|
|
|
13
13
|
/** server 的 UUID */
|
|
14
14
|
serverId: string
|
|
15
15
|
/** 连接目前状态 */
|
|
16
|
-
connected:
|
|
16
|
+
connected: boolean
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -38,7 +38,7 @@ declare module '../../index' {
|
|
|
38
38
|
*/
|
|
39
39
|
interface BLEPeripheralServer {
|
|
40
40
|
/** 添加服务
|
|
41
|
-
* @supported weapp
|
|
41
|
+
* @supported weapp, jd
|
|
42
42
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.addService.html
|
|
43
43
|
*/
|
|
44
44
|
addService(option: BLEPeripheralServer.addService.Option): Promise<TaroGeneral.BluetoothError>
|
|
@@ -48,20 +48,20 @@ declare module '../../index' {
|
|
|
48
48
|
*/
|
|
49
49
|
close(option: BLEPeripheralServer.close.Option): Promise<TaroGeneral.BluetoothError>
|
|
50
50
|
/** 取消监听已连接的设备请求读当前外围设备的特征值事件
|
|
51
|
-
* @supported weapp
|
|
51
|
+
* @supported weapp, jd
|
|
52
52
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicReadRequest.html
|
|
53
53
|
*/
|
|
54
54
|
offCharacteristicReadRequest(
|
|
55
55
|
/** 已连接的设备请求读当前外围设备的特征值事件的回调函数 */
|
|
56
|
-
callback
|
|
56
|
+
callback?: BLEPeripheralServer.onCharacteristicReadRequest.Callback,
|
|
57
57
|
): void
|
|
58
58
|
/** 取消监听特征订阅事件
|
|
59
|
-
* @supported weapp
|
|
59
|
+
* @supported weapp, jd
|
|
60
60
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicSubscribed.html
|
|
61
61
|
*/
|
|
62
62
|
offCharacteristicSubscribed(
|
|
63
63
|
/** 特征订阅事件的回调函数 */
|
|
64
|
-
callback
|
|
64
|
+
callback?: BLEPeripheralServer.onCharacteristicSubscribed.Callback,
|
|
65
65
|
): void
|
|
66
66
|
/** 取消监听取消特征订阅事件
|
|
67
67
|
* @supported weapp
|
|
@@ -69,20 +69,20 @@ declare module '../../index' {
|
|
|
69
69
|
*/
|
|
70
70
|
offCharacteristicUnsubscribed(
|
|
71
71
|
/** 取消特征订阅事件的回调函数 */
|
|
72
|
-
callback
|
|
72
|
+
callback?: BLEPeripheralServer.onCharacteristicUnsubscribed.Callback,
|
|
73
73
|
): void
|
|
74
74
|
/** 取消监听已连接的设备请求写当前外围设备的特征值事件
|
|
75
|
-
* @supported weapp
|
|
75
|
+
* @supported weapp, jd
|
|
76
76
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicWriteRequest.html
|
|
77
77
|
*/
|
|
78
78
|
offCharacteristicWriteRequest(
|
|
79
79
|
/** 已连接的设备请求写当前外围设备的特征值事件的回调函数 */
|
|
80
|
-
callback
|
|
80
|
+
callback?: BLEPeripheralServer.onCharacteristicWriteRequest.Callback,
|
|
81
81
|
): void
|
|
82
82
|
/** 监听已连接的设备请求读当前外围设备的特征值事件
|
|
83
83
|
*
|
|
84
84
|
* 收到该消息后需要立刻调用 [writeCharacteristicValue](/docs/apis/device/bluetooth-peripheral/BLEPeripheralServer#writecharacteristicvalue) 写回数据,否则主机不会收到响应。
|
|
85
|
-
* @supported weapp
|
|
85
|
+
* @supported weapp, jd
|
|
86
86
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicReadRequest.html
|
|
87
87
|
*/
|
|
88
88
|
onCharacteristicReadRequest(
|
|
@@ -90,7 +90,7 @@ declare module '../../index' {
|
|
|
90
90
|
callback: BLEPeripheralServer.onCharacteristicReadRequest.Callback,
|
|
91
91
|
): void
|
|
92
92
|
/** 监听特征订阅事件,仅 iOS 支持
|
|
93
|
-
* @supported weapp
|
|
93
|
+
* @supported weapp, jd
|
|
94
94
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicSubscribed.html
|
|
95
95
|
*/
|
|
96
96
|
onCharacteristicSubscribed(
|
|
@@ -98,7 +98,7 @@ declare module '../../index' {
|
|
|
98
98
|
callback: BLEPeripheralServer.onCharacteristicSubscribed.Callback,
|
|
99
99
|
): void
|
|
100
100
|
/** 监听取消特征订阅事件,仅 iOS 支持
|
|
101
|
-
* @supported weapp
|
|
101
|
+
* @supported weapp, jd
|
|
102
102
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicUnsubscribed.html
|
|
103
103
|
*/
|
|
104
104
|
onCharacteristicUnsubscribed(
|
|
@@ -106,7 +106,7 @@ declare module '../../index' {
|
|
|
106
106
|
callback: BLEPeripheralServer.onCharacteristicUnsubscribed.Callback,
|
|
107
107
|
): void
|
|
108
108
|
/** 监听已连接的设备请求写当前外围设备的特征值事件
|
|
109
|
-
* @supported weapp
|
|
109
|
+
* @supported weapp, jd
|
|
110
110
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicWriteRequest.html
|
|
111
111
|
*/
|
|
112
112
|
onCharacteristicWriteRequest(
|
|
@@ -114,22 +114,22 @@ declare module '../../index' {
|
|
|
114
114
|
callback: BLEPeripheralServer.onCharacteristicWriteRequest.Callback,
|
|
115
115
|
): void
|
|
116
116
|
/** 移除服务
|
|
117
|
-
* @supported weapp
|
|
117
|
+
* @supported weapp, jd
|
|
118
118
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.removeService.html
|
|
119
119
|
*/
|
|
120
120
|
removeService(option: BLEPeripheralServer.removeService.Option): Promise<TaroGeneral.BluetoothError>
|
|
121
121
|
/** 开始广播本地创建的外围设备
|
|
122
|
-
* @supported weapp
|
|
122
|
+
* @supported weapp, jd
|
|
123
123
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.startAdvertising.html
|
|
124
124
|
*/
|
|
125
125
|
startAdvertising(option: BLEPeripheralServer.startAdvertising.Option): Promise<TaroGeneral.BluetoothError>
|
|
126
126
|
/** 停止广播
|
|
127
|
-
* @supported weapp
|
|
127
|
+
* @supported weapp, jd
|
|
128
128
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.stopAdvertising.html
|
|
129
129
|
*/
|
|
130
130
|
stopAdvertising(option: BLEPeripheralServer.stopAdvertising.Option): Promise<TaroGeneral.BluetoothError>
|
|
131
131
|
/** 往指定特征写入二进制数据值,并通知已连接的主机,从机的特征值已发生变化,该接口会处理是走回包还是走订阅
|
|
132
|
-
* @supported weapp
|
|
132
|
+
* @supported weapp, jd
|
|
133
133
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.writeCharacteristicValue.html
|
|
134
134
|
*/
|
|
135
135
|
writeCharacteristicValue(option: BLEPeripheralServer.writeCharacteristicValue.Option): Promise<TaroGeneral.BluetoothError>
|
|
@@ -157,13 +157,13 @@ declare module '../../index' {
|
|
|
157
157
|
/** characteristic 的 UUID */
|
|
158
158
|
uuid: string
|
|
159
159
|
/** 特征支持的操作 */
|
|
160
|
-
properties
|
|
160
|
+
properties?: properties
|
|
161
161
|
/** 特征权限 */
|
|
162
|
-
permission
|
|
162
|
+
permission?: characteristicPermission
|
|
163
163
|
/** 特征对应的二进制值 */
|
|
164
|
-
value
|
|
164
|
+
value?: ArrayBuffer
|
|
165
165
|
/** 描述符数据 */
|
|
166
|
-
descriptors
|
|
166
|
+
descriptors?: descriptor[]
|
|
167
167
|
}
|
|
168
168
|
/** 特征支持的操作 */
|
|
169
169
|
interface properties {
|
|
@@ -212,7 +212,7 @@ declare module '../../index' {
|
|
|
212
212
|
/** Descriptor 的 UUID */
|
|
213
213
|
uuid: string
|
|
214
214
|
/** 描述符的权限 */
|
|
215
|
-
permission
|
|
215
|
+
permission?: descriptorPermission
|
|
216
216
|
/** 描述符数据 */
|
|
217
217
|
value: ArrayBuffer
|
|
218
218
|
}
|
|
@@ -402,7 +402,7 @@ declare module '../../index' {
|
|
|
402
402
|
|
|
403
403
|
interface TaroStatic {
|
|
404
404
|
/** 监听当前外围设备被连接或断开连接事件
|
|
405
|
-
* @supported weapp
|
|
405
|
+
* @supported weapp, jd
|
|
406
406
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.onBLEPeripheralConnectionStateChanged.html
|
|
407
407
|
*/
|
|
408
408
|
onBLEPeripheralConnectionStateChanged(
|
|
@@ -411,16 +411,16 @@ declare module '../../index' {
|
|
|
411
411
|
): void
|
|
412
412
|
|
|
413
413
|
/** 取消监听当前外围设备被连接或断开连接事件
|
|
414
|
-
* @supported weapp
|
|
414
|
+
* @supported weapp, jd
|
|
415
415
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.offBLEPeripheralConnectionStateChanged.html
|
|
416
416
|
*/
|
|
417
417
|
offBLEPeripheralConnectionStateChanged(
|
|
418
418
|
/** 当前外围设备被连接或断开连接事件的回调函数 */
|
|
419
|
-
callback
|
|
419
|
+
callback?: onBLEPeripheralConnectionStateChanged.Callback,
|
|
420
420
|
): void
|
|
421
421
|
|
|
422
422
|
/** 建立本地作为蓝牙低功耗外围设备的服务端,可创建多个
|
|
423
|
-
* @supported weapp
|
|
423
|
+
* @supported weapp, jd
|
|
424
424
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.createBLEPeripheralServer.html
|
|
425
425
|
*/
|
|
426
426
|
createBLEPeripheralServer(
|