@tarojs/taro 3.7.0-beta.1 → 3.7.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/html.css +9 -0
- package/package.json +11 -4
- package/types/api/ai/visionkit.d.ts +625 -54
- package/types/api/base/performance.d.ts +5 -5
- package/types/api/canvas/index.d.ts +67 -54
- 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 +71 -41
- package/types/api/location/index.d.ts +166 -18
- package/types/api/media/camera.d.ts +6 -3
- package/types/api/navigate/index.d.ts +2 -0
- package/types/api/open-api/device-voip.d.ts +2 -2
- package/types/api/open-api/login.d.ts +1 -1
- package/types/api/open-api/my-miniprogram.d.ts +2 -2
- package/types/api/open-api/privacy.d.ts +99 -0
- package/types/api/route/index.d.ts +1 -0
- 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/taro.extend.d.ts +1 -1
- package/types/api/ui/fonts.d.ts +4 -3
- package/types/api/wxml/index.d.ts +2 -2
- package/types/compile/compiler.d.ts +7 -5
- package/types/compile/config/h5.d.ts +23 -10
- package/types/compile/config/mini.d.ts +46 -31
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/project.d.ts +8 -8
- package/types/compile/config/util.d.ts +20 -8
- package/types/compile/viteCompilerContext.d.ts +130 -0
- package/types/global.d.ts +1 -0
- package/types/index.d.ts +2 -0
- package/types/taro.api.d.ts +3 -0
- package/types/taro.component.d.ts +1 -1
- package/types/taro.config.d.ts +41 -4
|
@@ -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(
|
|
@@ -32,13 +32,26 @@ declare module '../../index' {
|
|
|
32
32
|
interval?: number
|
|
33
33
|
/** 要搜索的蓝牙设备主 service 的 uuid 列表。某些蓝牙设备会广播自己的主 service 的 uuid。如果设置此参数,则只搜索广播包有对应 uuid 的主服务的蓝牙设备。建议主要通过该参数过滤掉周边不需要处理的其他蓝牙设备。 */
|
|
34
34
|
services?: string[]
|
|
35
|
+
/** 扫描模式,越高扫描越快,也越耗电。仅安卓微信客户端 7.0.12 及以上支持。 */
|
|
36
|
+
powerLevel?: keyof PowerLevel
|
|
35
37
|
/** 接口调用成功的回调函数 */
|
|
36
38
|
success?: (res: TaroGeneral.BluetoothError) => void
|
|
37
39
|
}
|
|
40
|
+
|
|
41
|
+
interface PowerLevel {
|
|
42
|
+
/** 低 */
|
|
43
|
+
low,
|
|
44
|
+
/** 中 */
|
|
45
|
+
medium,
|
|
46
|
+
/** 高 */
|
|
47
|
+
high
|
|
48
|
+
}
|
|
38
49
|
}
|
|
39
50
|
|
|
40
51
|
namespace openBluetoothAdapter {
|
|
41
52
|
interface Option {
|
|
53
|
+
/** 蓝牙模式,可作为主/从设备,仅 iOS 需要。 */
|
|
54
|
+
mode?: keyof Mode;
|
|
42
55
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
43
56
|
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
44
57
|
/** 接口调用失败的回调函数 */
|
|
@@ -47,6 +60,13 @@ declare module '../../index' {
|
|
|
47
60
|
success?: (res: TaroGeneral.BluetoothError) => void
|
|
48
61
|
}
|
|
49
62
|
|
|
63
|
+
interface Mode {
|
|
64
|
+
/** 主机模式 */
|
|
65
|
+
central
|
|
66
|
+
/** 从机(外围设备)模式 */
|
|
67
|
+
peripheral
|
|
68
|
+
}
|
|
69
|
+
|
|
50
70
|
/** object.fail 回调函数返回的 state 参数(仅 iOS) */
|
|
51
71
|
interface state {
|
|
52
72
|
/** 未知 */
|
|
@@ -73,7 +93,7 @@ declare module '../../index' {
|
|
|
73
93
|
}
|
|
74
94
|
/** 新搜索到的设备 */
|
|
75
95
|
interface CallbackResultBlueToothDevice {
|
|
76
|
-
/**
|
|
96
|
+
/** 当前蓝牙设备的信号强度,单位 dBm */
|
|
77
97
|
RSSI: number
|
|
78
98
|
/** 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 */
|
|
79
99
|
advertisData: ArrayBuffer
|
|
@@ -87,6 +107,8 @@ declare module '../../index' {
|
|
|
87
107
|
name: string
|
|
88
108
|
/** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */
|
|
89
109
|
serviceData: TaroGeneral.IAnyObject
|
|
110
|
+
/** 当前蓝牙设备是否可连接( Android 8.0 以下不支持返回该值 ) */
|
|
111
|
+
connectable?: boolean
|
|
90
112
|
}
|
|
91
113
|
}
|
|
92
114
|
|
|
@@ -193,6 +215,8 @@ declare module '../../index' {
|
|
|
193
215
|
name: string
|
|
194
216
|
/** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */
|
|
195
217
|
serviceData: TaroGeneral.IAnyObject
|
|
218
|
+
/** 当前蓝牙设备是否可连接( Android 8.0 以下不支持返回该值 ) */
|
|
219
|
+
connectable?: boolean
|
|
196
220
|
}
|
|
197
221
|
}
|
|
198
222
|
|
|
@@ -229,7 +253,7 @@ declare module '../../index' {
|
|
|
229
253
|
|
|
230
254
|
interface TaroStatic {
|
|
231
255
|
/** 停止搜寻附近的蓝牙外围设备。若已经找到需要的蓝牙设备并不需要继续搜索时,建议调用该接口停止蓝牙搜索。
|
|
232
|
-
* @supported weapp
|
|
256
|
+
* @supported weapp, alipay, jd
|
|
233
257
|
* @example
|
|
234
258
|
* ```tsx
|
|
235
259
|
* Taro.stopBluetoothDevicesDiscovery({
|
|
@@ -245,7 +269,7 @@ declare module '../../index' {
|
|
|
245
269
|
): Promise<stopBluetoothDevicesDiscovery.Promised>
|
|
246
270
|
|
|
247
271
|
/** 开始搜寻附近的蓝牙外围设备。**此操作比较耗费系统资源,请在搜索并连接到设备后调用 Taro.stopBluetoothDevicesDiscovery 方法停止搜索。**
|
|
248
|
-
* @supported weapp
|
|
272
|
+
* @supported weapp, alipay, jd
|
|
249
273
|
* @example
|
|
250
274
|
* ```tsx
|
|
251
275
|
* // 以微信硬件平台的蓝牙智能灯为例,主服务的 UUID 是 FEE7。传入这个参数,只搜索主服务 UUID 为 FEE7 的设备
|
|
@@ -267,7 +291,7 @@ declare module '../../index' {
|
|
|
267
291
|
* **注意**
|
|
268
292
|
* - 其他蓝牙相关 API 必须在 Taro.openBluetoothAdapter 调用之后使用。否则 API 会返回错误(errCode=10000)。
|
|
269
293
|
* - 在用户蓝牙开关未开启或者手机不支持蓝牙功能的情况下,调用 Taro.openBluetoothAdapter 监听手机蓝牙状态的改变,也可以调用蓝牙模块的所有API。
|
|
270
|
-
* @supported weapp
|
|
294
|
+
* @supported weapp, alipay, jd
|
|
271
295
|
* @example
|
|
272
296
|
* ```tsx
|
|
273
297
|
* Taro.openBluetoothAdapter({
|
|
@@ -285,7 +309,7 @@ declare module '../../index' {
|
|
|
285
309
|
* **注意**
|
|
286
310
|
* - 若在 Taro.onBluetoothDeviceFound 回调了某个设备,则此设备会添加到 Taro.getBluetoothDevices 接口获取到的数组中。
|
|
287
311
|
* - 安卓下部分机型需要有位置权限才能搜索到设备,需留意是否开启了位置权限
|
|
288
|
-
* @supported weapp
|
|
312
|
+
* @supported weapp, alipay, jd
|
|
289
313
|
* @example
|
|
290
314
|
* ```tsx
|
|
291
315
|
* // ArrayBuffer转16进度字符串示例
|
|
@@ -313,7 +337,7 @@ declare module '../../index' {
|
|
|
313
337
|
): void
|
|
314
338
|
|
|
315
339
|
/** 监听蓝牙适配器状态变化事件
|
|
316
|
-
* @supported weapp
|
|
340
|
+
* @supported weapp, alipay, jd
|
|
317
341
|
* @example
|
|
318
342
|
* ```tsx
|
|
319
343
|
* Taro.onBluetoothAdapterStateChange(function (res) {
|
|
@@ -328,7 +352,7 @@ declare module '../../index' {
|
|
|
328
352
|
): void
|
|
329
353
|
|
|
330
354
|
/** 取消监听寻找到新设备的事件
|
|
331
|
-
* @supported weapp
|
|
355
|
+
* @supported weapp, alipay
|
|
332
356
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.offBluetoothDeviceFound.html
|
|
333
357
|
*/
|
|
334
358
|
offBluetoothDeviceFound(
|
|
@@ -337,7 +361,7 @@ declare module '../../index' {
|
|
|
337
361
|
): void
|
|
338
362
|
|
|
339
363
|
/** 取消监听蓝牙适配器状态变化事件
|
|
340
|
-
* @supported weapp
|
|
364
|
+
* @supported weapp, alipay
|
|
341
365
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.offBluetoothAdapterStateChange.html
|
|
342
366
|
*/
|
|
343
367
|
offBluetoothAdapterStateChange(
|
|
@@ -357,10 +381,10 @@ declare module '../../index' {
|
|
|
357
381
|
* @supported weapp
|
|
358
382
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.isBluetoothDevicePaired.html
|
|
359
383
|
*/
|
|
360
|
-
isBluetoothDevicePaired(option: isBluetoothDevicePaired.Option):
|
|
384
|
+
isBluetoothDevicePaired(option: isBluetoothDevicePaired.Option): Promise<TaroGeneral.CallbackResult>
|
|
361
385
|
|
|
362
386
|
/** 根据 uuid 获取处于已连接状态的设备。
|
|
363
|
-
* @supported weapp
|
|
387
|
+
* @supported weapp, alipay, jd
|
|
364
388
|
* @example
|
|
365
389
|
* ```tsx
|
|
366
390
|
* Taro.getConnectedBluetoothDevices({
|
|
@@ -380,7 +404,7 @@ declare module '../../index' {
|
|
|
380
404
|
* **注意事项**
|
|
381
405
|
* - 该接口获取到的设备列表为**蓝牙模块生效期间所有搜索到的蓝牙设备**,若在蓝牙模块使用流程结束后未及时调用 Taro.closeBluetoothAdapter 释放资源,会存在调用该接口会返回之前的蓝牙使用流程中搜索到的蓝牙设备,可能设备已经不在用户身边,无法连接。
|
|
382
406
|
* - 蓝牙设备在被搜索到时,系统返回的 name 字段一般为广播包中的 LocalName 字段中的设备名称,而如果与蓝牙设备建立连接,系统返回的 name 字段会改为从蓝牙设备上获取到的 `GattName`。若需要动态改变设备名称并展示,建议使用 `localName` 字段。
|
|
383
|
-
* @supported weapp
|
|
407
|
+
* @supported weapp, alipay, jd
|
|
384
408
|
* @example
|
|
385
409
|
* ```tsx
|
|
386
410
|
* // ArrayBuffer转16进度字符串示例
|
|
@@ -407,7 +431,7 @@ declare module '../../index' {
|
|
|
407
431
|
getBluetoothDevices(option?: getBluetoothDevices.Option): Promise<getBluetoothDevices.SuccessCallbackResult>
|
|
408
432
|
|
|
409
433
|
/** 获取本机蓝牙适配器状态。
|
|
410
|
-
* @supported weapp
|
|
434
|
+
* @supported weapp, alipay, jd
|
|
411
435
|
* @example
|
|
412
436
|
* ```tsx
|
|
413
437
|
* Taro.getBluetoothAdapterState({
|
|
@@ -423,7 +447,7 @@ declare module '../../index' {
|
|
|
423
447
|
): Promise<getBluetoothAdapterState.SuccessCallbackResult>
|
|
424
448
|
|
|
425
449
|
/** 关闭蓝牙模块。调用该方法将断开所有已建立的连接并释放系统资源。建议在使用蓝牙流程后,与 Taro.openBluetoothAdapter 成对调用。
|
|
426
|
-
* @supported weapp
|
|
450
|
+
* @supported weapp, alipay, jd
|
|
427
451
|
* @example
|
|
428
452
|
* ```tsx
|
|
429
453
|
* Taro.closeBluetoothAdapter({
|
|
@@ -28,7 +28,7 @@ declare module '../../index' {
|
|
|
28
28
|
/** 重复周期,默认 month 每月重复
|
|
29
29
|
* @default "month"
|
|
30
30
|
*/
|
|
31
|
-
repeatInterval?:
|
|
31
|
+
repeatInterval?: keyof RepeatInterval
|
|
32
32
|
/** 重复周期结束时间的 unix 时间戳,不填表示一直重复 */
|
|
33
33
|
repeatEndTime?: number
|
|
34
34
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
@@ -38,6 +38,16 @@ declare module '../../index' {
|
|
|
38
38
|
/** 接口调用成功的回调函数 */
|
|
39
39
|
success?: (result: TaroGeneral.CallbackResult) => void
|
|
40
40
|
}
|
|
41
|
+
interface RepeatInterval {
|
|
42
|
+
/** 每天重复 */
|
|
43
|
+
day
|
|
44
|
+
/** 每周重复 */
|
|
45
|
+
week
|
|
46
|
+
/** 每月重复。该模式日期不能大于 28 日 */
|
|
47
|
+
month
|
|
48
|
+
/** 每年重复 */
|
|
49
|
+
year
|
|
50
|
+
}
|
|
41
51
|
}
|
|
42
52
|
|
|
43
53
|
namespace addPhoneCalendar {
|
|
@@ -43,7 +43,7 @@ declare module '../../index' {
|
|
|
43
43
|
|
|
44
44
|
interface TaroStatic {
|
|
45
45
|
/** 设置系统剪贴板的内容。调用成功后,会弹出 toast 提示"内容已复制",持续 1.5s
|
|
46
|
-
* @supported weapp,
|
|
46
|
+
* @supported weapp, swan, jd, qq, tt, h5, rn
|
|
47
47
|
* @h5 部分实现
|
|
48
48
|
* @example
|
|
49
49
|
* ```tsx
|
|
@@ -60,22 +60,22 @@ declare module '../../index' {
|
|
|
60
60
|
* ```
|
|
61
61
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/clipboard/wx.setClipboardData.html
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
setClipboardData(option: setClipboardData.Option): Promise<setClipboardData.Promised>
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
/**
|
|
66
|
+
* 获取系统剪贴板内容
|
|
67
|
+
* @supported weapp, swan, jd, qq, tt, 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
80
|
}
|
|
81
81
|
}
|
|
@@ -59,7 +59,7 @@ declare module '../../index' {
|
|
|
59
59
|
|
|
60
60
|
interface TaroStatic {
|
|
61
61
|
/** 停止监听罗盘数据
|
|
62
|
-
* @supported weapp, h5, tt
|
|
62
|
+
* @supported weapp, swan, qq, h5, tt
|
|
63
63
|
* @example
|
|
64
64
|
* ```tsx
|
|
65
65
|
* Taro.stopCompass()
|
|
@@ -69,7 +69,7 @@ declare module '../../index' {
|
|
|
69
69
|
stopCompass(option?: stopCompass.Option): Promise<TaroGeneral.CallbackResult>
|
|
70
70
|
|
|
71
71
|
/** 开始监听罗盘数据
|
|
72
|
-
* @supported weapp, h5, tt
|
|
72
|
+
* @supported weapp, swan, qq, h5, tt
|
|
73
73
|
* @example
|
|
74
74
|
* ```js
|
|
75
75
|
* Taro.startCompass()
|
|
@@ -79,7 +79,7 @@ declare module '../../index' {
|
|
|
79
79
|
startCompass(option?: startCompass.Option): Promise<TaroGeneral.CallbackResult>
|
|
80
80
|
|
|
81
81
|
/** 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 Taro.stopCompass 停止监听。
|
|
82
|
-
* @supported weapp, h5, tt
|
|
82
|
+
* @supported weapp, swan, qq, h5, tt
|
|
83
83
|
* @example
|
|
84
84
|
* ```tsx
|
|
85
85
|
* Taro.onCompassChange(function (res) {
|
|
@@ -94,12 +94,12 @@ declare module '../../index' {
|
|
|
94
94
|
): void
|
|
95
95
|
|
|
96
96
|
/** 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。
|
|
97
|
-
* @supported weapp, h5
|
|
97
|
+
* @supported weapp, swan, qq, h5
|
|
98
98
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/compass/wx.offCompassChange.html
|
|
99
99
|
*/
|
|
100
100
|
offCompassChange(
|
|
101
101
|
/** 罗盘数据变化事件的回调函数 */
|
|
102
|
-
callback
|
|
102
|
+
callback?: onCompassChange.Callback,
|
|
103
103
|
): void
|
|
104
104
|
}
|
|
105
105
|
}
|