@tarojs/taro 3.4.1 → 3.4.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.
Files changed (88) hide show
  1. package/package.json +5 -5
  2. package/types/api/ai/face.d.ts +133 -0
  3. package/types/api/ai/visionkit.d.ts +303 -0
  4. package/types/api/base/crypto.d.ts +90 -0
  5. package/types/api/base/debug.d.ts +152 -13
  6. package/types/api/base/env.d.ts +2 -1
  7. package/types/api/base/index.d.ts +10 -2
  8. package/types/api/base/performance.d.ts +195 -0
  9. package/types/api/base/system.d.ts +539 -101
  10. package/types/api/base/update.d.ts +59 -7
  11. package/types/api/base/weapp/app-event.d.ts +46 -23
  12. package/types/api/base/weapp/life-cycle.d.ts +141 -1
  13. package/types/api/canvas/index.d.ts +150 -136
  14. package/types/api/cloud/index.d.ts +2 -2
  15. package/types/api/device/accelerometer.d.ts +3 -3
  16. package/types/api/device/accessibility.d.ts +26 -0
  17. package/types/api/device/battery.d.ts +2 -2
  18. package/types/api/device/{ble.d.ts → bluetooth-ble.d.ts} +228 -62
  19. package/types/api/device/bluetooth-peripheral.d.ts +430 -0
  20. package/types/api/device/bluetooth.d.ts +67 -2
  21. package/types/api/device/calendar.d.ts +88 -0
  22. package/types/api/device/contact.d.ts +74 -50
  23. package/types/api/device/gyroscope.d.ts +5 -5
  24. package/types/api/device/iBeacon.d.ts +33 -19
  25. package/types/api/{ui → device}/keyboard.d.ts +0 -0
  26. package/types/api/device/{performance.d.ts → memory.d.ts} +4 -4
  27. package/types/api/device/motion.d.ts +3 -3
  28. package/types/api/device/network.d.ts +53 -12
  29. package/types/api/device/nfc.d.ts +1089 -13
  30. package/types/api/device/scan.d.ts +1 -1
  31. package/types/api/device/screen.d.ts +40 -12
  32. package/types/api/device/wifi.d.ts +41 -6
  33. package/types/api/files/index.d.ts +371 -184
  34. package/types/api/location/index.d.ts +116 -55
  35. package/types/api/media/audio.d.ts +629 -38
  36. package/types/api/media/background-audio.d.ts +8 -8
  37. package/types/api/media/camera.d.ts +38 -19
  38. package/types/api/media/editor.d.ts +22 -2
  39. package/types/api/media/image.d.ts +61 -32
  40. package/types/api/media/live.d.ts +66 -6
  41. package/types/api/media/map.d.ts +469 -49
  42. package/types/api/media/media-recorder.d.ts +92 -0
  43. package/types/api/media/recorder.d.ts +20 -20
  44. package/types/api/media/video-decoder.d.ts +117 -0
  45. package/types/api/media/video-processing.d.ts +11 -7
  46. package/types/api/media/video.d.ts +45 -16
  47. package/types/api/media/voip.d.ts +290 -0
  48. package/types/api/{open-api/navigate.d.ts → navigate/index.d.ts} +63 -25
  49. package/types/api/network/download.d.ts +39 -16
  50. package/types/api/network/request.d.ts +125 -37
  51. package/types/api/network/tcp.d.ts +181 -0
  52. package/types/api/network/udp.d.ts +154 -83
  53. package/types/api/network/upload.d.ts +41 -25
  54. package/types/api/network/websocket.d.ts +16 -15
  55. package/types/api/open-api/authorize.d.ts +41 -2
  56. package/types/api/open-api/channels.d.ts +178 -0
  57. package/types/api/open-api/facial.d.ts +3 -0
  58. package/types/api/open-api/favorites.d.ts +100 -0
  59. package/types/api/open-api/group.d.ts +59 -0
  60. package/types/api/open-api/invoice.d.ts +2 -2
  61. package/types/api/open-api/license-plate.d.ts +27 -0
  62. package/types/api/open-api/login.d.ts +21 -0
  63. package/types/api/open-api/redpackage.d.ts +24 -0
  64. package/types/api/open-api/settings.d.ts +76 -14
  65. package/types/api/open-api/soter.d.ts +2 -2
  66. package/types/api/open-api/subscribe-message.d.ts +88 -3
  67. package/types/api/open-api/user-info.d.ts +55 -18
  68. package/types/api/open-api/werun.d.ts +33 -6
  69. package/types/api/payment/index.d.ts +119 -0
  70. package/types/api/route/index.d.ts +13 -9
  71. package/types/api/share/index.d.ts +192 -9
  72. package/types/api/storage/index.d.ts +29 -83
  73. package/types/api/swan/index.d.ts +1 -1
  74. package/types/api/ui/animation.d.ts +84 -70
  75. package/types/api/ui/background.d.ts +4 -2
  76. package/types/api/ui/custom-component.d.ts +1 -1
  77. package/types/api/ui/fonts.d.ts +27 -31
  78. package/types/api/ui/navigation-bar.d.ts +1 -0
  79. package/types/api/ui/scroll.d.ts +73 -7
  80. package/types/api/ui/sticky.d.ts +4 -4
  81. package/types/api/ui/tab-bar.d.ts +7 -7
  82. package/types/api/ui/window.d.ts +22 -2
  83. package/types/api/worker/index.d.ts +9 -1
  84. package/types/api/wxml/index.d.ts +111 -107
  85. package/types/compile.d.ts +5 -0
  86. package/types/global.d.ts +142 -111
  87. package/types/taro.api.d.ts +79 -62
  88. package/types/api/open-api/payment.d.ts +0 -61
@@ -1,6 +1,53 @@
1
1
  import Taro from '../../index'
2
2
 
3
3
  declare module '../../index' {
4
+ namespace writeBLECharacteristicValue {
5
+ interface Promised extends TaroGeneral.BluetoothError {
6
+ /** 成功:ok,错误:详细信息 */
7
+ errMsg: string
8
+ }
9
+ interface Option {
10
+ /** 蓝牙特征值的 uuid */
11
+ characteristicId: string
12
+ /** 蓝牙设备 id */
13
+ deviceId: string
14
+ /** 蓝牙特征值对应服务的 uuid */
15
+ serviceId: string
16
+ /** 蓝牙设备特征值对应的二进制值 */
17
+ value: ArrayBuffer
18
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
19
+ complete?: (res: TaroGeneral.BluetoothError) => void
20
+ /** 接口调用失败的回调函数 */
21
+ fail?: (res: TaroGeneral.BluetoothError) => void
22
+ /** 接口调用成功的回调函数 */
23
+ success?: (res: TaroGeneral.BluetoothError) => void
24
+ }
25
+ }
26
+
27
+ namespace setBLEMTU {
28
+ type Promised = FailCallbackResult | SuccessCallbackResult
29
+ interface Option {
30
+ /** 蓝牙设备 id */
31
+ deviceId: string
32
+ /** 最大传输单元。设置范围为 (22,512) 区间内,单位 bytes */
33
+ mtu: number
34
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
35
+ complete?: (res: Promised) => void
36
+ /** 接口调用失败的回调函数 */
37
+ fail?: (res: FailCallbackResult) => void
38
+ /** 接口调用成功的回调函数 */
39
+ success?: (res: SuccessCallbackResult) => void
40
+ }
41
+ interface FailCallbackResult extends TaroGeneral.BluetoothError {
42
+ /** 最终协商的 MTU 值。如果协商失败则无此参数。安卓客户端 8.0.9 开始支持。 */
43
+ mtu: string
44
+ }
45
+ interface SuccessCallbackResult extends TaroGeneral.BluetoothError {
46
+ /** 最终协商的 MTU 值,与传入参数一致。安卓客户端 8.0.9 开始支持。 */
47
+ mtu: string
48
+ }
49
+ }
50
+
4
51
  namespace readBLECharacteristicValue {
5
52
  interface Option {
6
53
  /** 蓝牙特征值的 uuid */
@@ -18,6 +65,19 @@ declare module '../../index' {
18
65
  }
19
66
  }
20
67
 
68
+ namespace onBLEMTUChange {
69
+ interface CallbackResult {
70
+ /** 蓝牙设备ID */
71
+ deviceId: string
72
+ /** 最大传输单元 */
73
+ mtu: string
74
+ }
75
+ /** 蓝牙低功耗的最大传输单元变化事件的回调函数 */
76
+ type Callback = (
77
+ result: CallbackResult,
78
+ ) => void
79
+ }
80
+
21
81
  namespace onBLEConnectionStateChange {
22
82
  interface CallbackResult {
23
83
  /** 是否处于已连接状态 */
@@ -49,7 +109,7 @@ declare module '../../index' {
49
109
  }
50
110
 
51
111
  namespace notifyBLECharacteristicValueChange {
52
- interface Promised extends TaroGeneral.CallbackResult {
112
+ interface Promised extends TaroGeneral.BluetoothError {
53
113
  /** 成功:ok,错误:详细信息 */
54
114
  errMsg: string
55
115
  }
@@ -71,6 +131,36 @@ declare module '../../index' {
71
131
  }
72
132
  }
73
133
 
134
+ namespace getBLEMTU {
135
+ interface Option {
136
+ /** 蓝牙设备 id */
137
+ deviceId: string
138
+ /** 写模式 (iOS 特有参数)
139
+ * @default "write"
140
+ */
141
+ writeType: keyof WriteType
142
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
143
+ complete?: (res: TaroGeneral.BluetoothError) => void
144
+ /** 接口调用失败的回调函数 */
145
+ fail?: (res: TaroGeneral.BluetoothError) => void
146
+ /** 接口调用成功的回调函数 */
147
+ success?: (
148
+ result: SuccessCallbackResult,
149
+ ) => void
150
+ }
151
+ interface SuccessCallbackResult extends TaroGeneral.BluetoothError {
152
+ /** 最大传输单元 */
153
+ mtu: number
154
+ }
155
+ /** 写模式合法值 */
156
+ interface WriteType {
157
+ /** 有回复写 */
158
+ write
159
+ /** 无回复写 */
160
+ writeNoResponse
161
+ }
162
+ }
163
+
74
164
  namespace getBLEDeviceServices {
75
165
  interface Option {
76
166
  /** 蓝牙设备 id */
@@ -84,7 +174,7 @@ declare module '../../index' {
84
174
  result: SuccessCallbackResult,
85
175
  ) => void
86
176
  }
87
- interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
177
+ interface SuccessCallbackResult extends TaroGeneral.BluetoothError {
88
178
  /** 设备服务列表 */
89
179
  services: BLEService[]
90
180
  /** 成功:ok,错误:详细信息 */
@@ -99,6 +189,25 @@ declare module '../../index' {
99
189
  }
100
190
  }
101
191
 
192
+ namespace getBLEDeviceRSSI {
193
+ interface Option {
194
+ /** 蓝牙设备 id */
195
+ deviceId: string
196
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
197
+ complete?: (res: TaroGeneral.BluetoothError) => void
198
+ /** 接口调用失败的回调函数 */
199
+ fail?: (res: TaroGeneral.BluetoothError) => void
200
+ /** 接口调用成功的回调函数 */
201
+ success?: (
202
+ result: SuccessCallbackResult,
203
+ ) => void
204
+ }
205
+ interface SuccessCallbackResult extends TaroGeneral.BluetoothError {
206
+ /** 信号强度,单位 dBm */
207
+ RSSI: number
208
+ }
209
+ }
210
+
102
211
  namespace getBLEDeviceCharacteristics {
103
212
  interface Option {
104
213
  /** 蓝牙设备 id */
@@ -112,7 +221,7 @@ declare module '../../index' {
112
221
  /** 接口调用成功的回调函数 */
113
222
  success?: (res: SuccessCallbackResult) => void
114
223
  }
115
- interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
224
+ interface SuccessCallbackResult extends TaroGeneral.BluetoothError {
116
225
  /** 设备特征值列表 */
117
226
  characteristics: BLECharacteristic[]
118
227
  /** 成功:ok,错误:详细信息 */
@@ -139,7 +248,7 @@ declare module '../../index' {
139
248
  }
140
249
 
141
250
  namespace createBLEConnection {
142
- interface Promised extends TaroGeneral.CallbackResult {
251
+ interface Promised extends TaroGeneral.BluetoothError {
143
252
  /** 成功:ok,错误:详细信息 */
144
253
  errMsg: string
145
254
  }
@@ -158,7 +267,7 @@ declare module '../../index' {
158
267
  }
159
268
 
160
269
  namespace closeBLEConnection {
161
- interface Promised extends TaroGeneral.CallbackResult {
270
+ interface Promised extends TaroGeneral.BluetoothError {
162
271
  /** 成功:ok,错误:详细信息 */
163
272
  errMsg: string
164
273
  }
@@ -174,30 +283,49 @@ declare module '../../index' {
174
283
  }
175
284
  }
176
285
 
177
- namespace writeBLECharacteristicValue {
178
- interface Promised extends TaroGeneral.CallbackResult {
179
- /** 成功:ok,错误:详细信息 */
180
- errMsg: string
181
- }
182
- interface Option {
183
- /** 蓝牙特征值的 uuid */
184
- characteristicId: string
185
- /** 蓝牙设备 id */
186
- deviceId: string
187
- /** 蓝牙特征值对应服务的 uuid */
188
- serviceId: string
189
- /** 蓝牙设备特征值对应的二进制值 */
190
- value: ArrayBuffer
191
- /** 接口调用结束的回调函数(调用成功、失败都会执行) */
192
- complete?: (res: TaroGeneral.BluetoothError) => void
193
- /** 接口调用失败的回调函数 */
194
- fail?: (res: TaroGeneral.BluetoothError) => void
195
- /** 接口调用成功的回调函数 */
196
- success?: (res: TaroGeneral.BluetoothError) => void
197
- }
198
- }
199
-
200
286
  interface TaroStatic {
287
+ /** 向低功耗蓝牙设备特征值中写入二进制数据。注意:必须设备的特征值支持 write 才可以成功调用。
288
+ *
289
+ * **注意**
290
+ * - 并行调用多次会存在写失败的可能性。
291
+ * - 小程序不会对写入数据包大小做限制,但系统与蓝牙设备会限制蓝牙4.0单次传输的数据大小,超过最大字节数后会发生写入错误,建议每次写入不超过20字节。
292
+ * - 若单次写入数据过长,iOS 上存在系统不会有任何回调的情况(包括错误回调)。
293
+ * - 安卓平台上,在调用 `notifyBLECharacteristicValueChange` 成功后立即调用 `writeBLECharacteristicValue` 接口,在部分机型上会发生 10008 系统错误
294
+ * @supported weapp
295
+ * @example
296
+ * ```tsx
297
+ * // 向蓝牙设备发送一个0x00的16进制数据
298
+ * let buffer = new ArrayBuffer(1)
299
+ * let dataView = new DataView(buffer)
300
+ * dataView.setUint8(0, 0)
301
+ * Taro.writeBLECharacteristicValue({
302
+ * // 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
303
+ * deviceId,
304
+ * // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
305
+ * serviceId,
306
+ * // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
307
+ * characteristicId,
308
+ * // 这里的value是ArrayBuffer类型
309
+ * value: buffer,
310
+ * success: function (res) {
311
+ * console.log('writeBLECharacteristicValue success', res.errMsg)
312
+ * }
313
+ * })
314
+ * ```
315
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.writeBLECharacteristicValue.html
316
+ */
317
+ writeBLECharacteristicValue(
318
+ option: writeBLECharacteristicValue.Option,
319
+ ): Promise<writeBLECharacteristicValue.Promised>
320
+
321
+ /** 协商设置蓝牙低功耗的最大传输单元 (Maximum Transmission Unit, MTU)
322
+ * @supported weapp
323
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.setBLEMTU.html
324
+ */
325
+ setBLEMTU(
326
+ option: setBLEMTU.Option,
327
+ ): Promise<setBLEMTU.Promised>
328
+
201
329
  /** 读取低功耗蓝牙设备的特征值的二进制数据值。注意:必须设备的特征值支持 read 才可以成功调用。
202
330
  *
203
331
  * **注意**
@@ -228,6 +356,21 @@ declare module '../../index' {
228
356
  option: readBLECharacteristicValue.Option,
229
357
  ): Promise<TaroGeneral.BluetoothError>
230
358
 
359
+ /** 监听蓝牙低功耗的最大传输单元变化事件(仅安卓触发)
360
+ * @supported weapp
361
+ * @example
362
+ * ```tsx
363
+ * Taro.onBLEMTUChange(function (res) {
364
+ * console.log('bluetooth mtu is', res.mtu)
365
+ * })
366
+ * ```
367
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.onBLEMTUChange.html
368
+ */
369
+ onBLEMTUChange(
370
+ /** 蓝牙低功耗的最大传输单元变化事件的回调函数 */
371
+ callback: onBLEMTUChange.Callback,
372
+ ): void
373
+
231
374
  /** 监听低功耗蓝牙连接状态的改变事件。包括开发者主动连接或断开连接,设备丢失,连接异常断开等等
232
375
  * @supported weapp
233
376
  * @example
@@ -270,6 +413,33 @@ declare module '../../index' {
270
413
  callback: onBLECharacteristicValueChange.Callback,
271
414
  ): void
272
415
 
416
+ /** 取消监听蓝牙低功耗的最大传输单元变化事件
417
+ * @supported weapp
418
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLEMTUChange.html
419
+ */
420
+ offBLEMTUChange(
421
+ /** 蓝牙低功耗的最大传输单元变化事件的回调函数 */
422
+ callback: onBLEMTUChange.Callback,
423
+ ): void
424
+
425
+ /** 取消监听蓝牙低功耗连接状态的改变事件
426
+ * @supported weapp
427
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLEConnectionStateChange.html
428
+ */
429
+ offBLEConnectionStateChange(
430
+ /** 蓝牙低功耗连接状态的改变事件的回调函数 */
431
+ callback: onBLEMTUChange.Callback,
432
+ ): void
433
+
434
+ /** 取消监听蓝牙低功耗设备的特征值变化事件
435
+ * @supported weapp
436
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLECharacteristicValueChange.html
437
+ */
438
+ offBLECharacteristicValueChange(
439
+ /** 低功耗蓝牙设备的特征值变化事件的回调函数 */
440
+ callback: onBLEMTUChange.Callback,
441
+ ): void
442
+
273
443
  /** 启用低功耗蓝牙设备特征值变化时的 notify 功能,订阅特征值。注意:必须设备的特征值支持 notify 或者 indicate 才可以成功调用。
274
444
  *
275
445
  * 另外,必须先启用 `notifyBLECharacteristicValueChange` 才能监听到设备 `characteristicValueChange` 事件
@@ -299,6 +469,28 @@ declare module '../../index' {
299
469
  option: notifyBLECharacteristicValueChange.Option,
300
470
  ): Promise<notifyBLECharacteristicValueChange.Promised>
301
471
 
472
+ /** 获取蓝牙低功耗的最大传输单元。需在 [Taro.createBLEConnection](/docs/apis/device/bluetooth-ble/createBLEConnection) 调用成功后调用。
473
+ *
474
+ * 注意:
475
+ * - 小程序中 MTU 为 ATT_MTU,包含 Op-Code 和 Attribute Handle 的长度,实际可以传输的数据长度为 ATT_MTU - 3
476
+ * - iOS 系统中 MTU 为固定值;安卓系统中,MTU 会在系统协商成功之后发生改变,建议使用 [Taro.onBLEMTUChange](/docs/apis/device/bluetooth-ble/onBLEMTUChange) 监听。
477
+ * @supported weapp
478
+ * @example
479
+ * ```tsx
480
+ * Taro.getBLEMTU({
481
+ * deviceId: '',
482
+ * writeType: 'write',
483
+ * success (res) {
484
+ * console.log(res)
485
+ * }
486
+ * })
487
+ * ```
488
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEMTU.html
489
+ */
490
+ getBLEMTU(
491
+ option: getBLEMTU.Option,
492
+ ): Promise<getBLEMTU.SuccessCallbackResult>
493
+
302
494
  /** 获取蓝牙设备所有服务(service)。
303
495
  * @supported weapp
304
496
  * @example
@@ -317,6 +509,14 @@ declare module '../../index' {
317
509
  option: getBLEDeviceServices.Option,
318
510
  ): Promise<getBLEDeviceServices.SuccessCallbackResult>
319
511
 
512
+ /** 获取蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI)。
513
+ * @supported weapp
514
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceRSSI.html
515
+ */
516
+ getBLEDeviceRSSI(
517
+ option: getBLEDeviceRSSI.Option,
518
+ ): Promise<getBLEDeviceRSSI.SuccessCallbackResult>
519
+
320
520
  /** 获取蓝牙设备某个服务中所有特征值(characteristic)。
321
521
  * @supported weapp
322
522
  * @example
@@ -374,39 +574,5 @@ declare module '../../index' {
374
574
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.closeBLEConnection.html
375
575
  */
376
576
  closeBLEConnection(option: closeBLEConnection.Option): Promise<closeBLEConnection.Promised>
377
-
378
- /** 向低功耗蓝牙设备特征值中写入二进制数据。注意:必须设备的特征值支持 write 才可以成功调用。
379
- *
380
- * **注意**
381
- * - 并行调用多次会存在写失败的可能性。
382
- * - 小程序不会对写入数据包大小做限制,但系统与蓝牙设备会限制蓝牙4.0单次传输的数据大小,超过最大字节数后会发生写入错误,建议每次写入不超过20字节。
383
- * - 若单次写入数据过长,iOS 上存在系统不会有任何回调的情况(包括错误回调)。
384
- * - 安卓平台上,在调用 `notifyBLECharacteristicValueChange` 成功后立即调用 `writeBLECharacteristicValue` 接口,在部分机型上会发生 10008 系统错误
385
- * @supported weapp
386
- * @example
387
- * ```tsx
388
- * // 向蓝牙设备发送一个0x00的16进制数据
389
- * let buffer = new ArrayBuffer(1)
390
- * let dataView = new DataView(buffer)
391
- * dataView.setUint8(0, 0)
392
- * Taro.writeBLECharacteristicValue({
393
- * // 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
394
- * deviceId,
395
- * // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
396
- * serviceId,
397
- * // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
398
- * characteristicId,
399
- * // 这里的value是ArrayBuffer类型
400
- * value: buffer,
401
- * success: function (res) {
402
- * console.log('writeBLECharacteristicValue success', res.errMsg)
403
- * }
404
- * })
405
- * ```
406
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.writeBLECharacteristicValue.html
407
- */
408
- writeBLECharacteristicValue(
409
- option: writeBLECharacteristicValue.Option,
410
- ): Promise<writeBLECharacteristicValue.Promised>
411
577
  }
412
578
  }