@tarojs/taro 3.3.12 → 3.4.0-beta.0

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 (97) hide show
  1. package/package.json +5 -5
  2. package/types/api/ad/index.d.ts +34 -28
  3. package/types/api/alipay/index.d.ts +11 -7
  4. package/types/api/base/debug.d.ts +60 -54
  5. package/types/api/base/env.d.ts +12 -8
  6. package/types/api/base/index.d.ts +87 -83
  7. package/types/api/base/system.d.ts +59 -54
  8. package/types/api/base/update.d.ts +37 -33
  9. package/types/api/base/weapp/app-event.d.ts +147 -131
  10. package/types/api/base/weapp/life-cycle.d.ts +14 -10
  11. package/types/api/canvas/index.d.ts +115 -110
  12. package/types/api/cloud/index.d.ts +99 -94
  13. package/types/api/data-analysis/index.d.ts +68 -64
  14. package/types/api/device/accelerometer.d.ts +57 -50
  15. package/types/api/device/battery.d.ts +19 -15
  16. package/types/api/device/ble.d.ts +241 -228
  17. package/types/api/device/bluetooth.d.ts +207 -194
  18. package/types/api/device/clipboard.d.ts +48 -43
  19. package/types/api/device/compass.d.ts +55 -48
  20. package/types/api/device/contact.d.ts +13 -9
  21. package/types/api/device/gyroscope.d.ts +41 -35
  22. package/types/api/device/iBeacon.d.ts +79 -73
  23. package/types/api/device/motion.d.ts +42 -37
  24. package/types/api/device/network.d.ts +80 -42
  25. package/types/api/device/nfc.d.ts +105 -96
  26. package/types/api/device/performance.d.ts +32 -18
  27. package/types/api/device/phone.d.ts +20 -15
  28. package/types/api/device/scan.d.ts +31 -26
  29. package/types/api/device/screen.d.ts +74 -67
  30. package/types/api/device/vibrate.d.ts +31 -25
  31. package/types/api/device/wifi.d.ts +151 -140
  32. package/types/api/ext/index.d.ts +44 -39
  33. package/types/api/files/index.d.ts +219 -209
  34. package/types/api/framework/index.d.ts +25 -20
  35. package/types/api/location/index.d.ts +140 -136
  36. package/types/api/media/audio.d.ts +135 -127
  37. package/types/api/media/background-audio.d.ts +135 -126
  38. package/types/api/media/camera.d.ts +30 -26
  39. package/types/api/media/editor.d.ts +35 -33
  40. package/types/api/media/image.d.ts +161 -150
  41. package/types/api/media/live.d.ts +88 -82
  42. package/types/api/media/map.d.ts +47 -43
  43. package/types/api/media/recorder.d.ts +90 -84
  44. package/types/api/media/video-processing.d.ts +10 -6
  45. package/types/api/media/video.d.ts +63 -58
  46. package/types/api/network/download.d.ts +34 -30
  47. package/types/api/network/mdns.d.ts +104 -91
  48. package/types/api/network/request.d.ts +83 -79
  49. package/types/api/network/udp.d.ts +20 -16
  50. package/types/api/network/upload.d.ts +60 -56
  51. package/types/api/network/websocket.d.ts +201 -194
  52. package/types/api/open-api/account.d.ts +18 -14
  53. package/types/api/open-api/address.d.ts +27 -23
  54. package/types/api/open-api/authorize.d.ts +30 -26
  55. package/types/api/open-api/card.d.ts +55 -51
  56. package/types/api/open-api/customer-service.d.ts +21 -17
  57. package/types/api/open-api/facial.d.ts +28 -24
  58. package/types/api/open-api/invoice.d.ts +38 -34
  59. package/types/api/open-api/login.d.ts +56 -52
  60. package/types/api/open-api/navigate.d.ts +79 -75
  61. package/types/api/open-api/payment.d.ts +34 -30
  62. package/types/api/open-api/settings.d.ts +49 -45
  63. package/types/api/open-api/soter.d.ts +92 -86
  64. package/types/api/open-api/subscribe-message.d.ts +24 -20
  65. package/types/api/open-api/user-info.d.ts +60 -57
  66. package/types/api/open-api/werun.d.ts +50 -46
  67. package/types/api/route/index.d.ts +122 -118
  68. package/types/api/share/index.d.ts +68 -64
  69. package/types/api/storage/background-fetch.d.ts +40 -35
  70. package/types/api/storage/index.d.ts +267 -262
  71. package/types/api/swan/index.d.ts +47 -42
  72. package/types/api/ui/animation.d.ts +21 -17
  73. package/types/api/ui/background.d.ts +38 -34
  74. package/types/api/ui/custom-component.d.ts +22 -18
  75. package/types/api/ui/fonts.d.ts +26 -21
  76. package/types/api/ui/interaction.d.ts +167 -121
  77. package/types/api/ui/keyboard.d.ts +59 -55
  78. package/types/api/ui/menu.d.ts +10 -6
  79. package/types/api/ui/navigation-bar.d.ts +67 -63
  80. package/types/api/ui/pull-down-refresh.d.ts +33 -29
  81. package/types/api/ui/scroll.d.ts +30 -26
  82. package/types/api/ui/sticky.d.ts +22 -19
  83. package/types/api/ui/tab-bar.d.ts +101 -97
  84. package/types/api/ui/window.d.ts +24 -18
  85. package/types/api/worker/index.d.ts +28 -24
  86. package/types/api/wxml/index.d.ts +42 -38
  87. package/types/global.d.ts +390 -0
  88. package/types/index.d.ts +12 -98
  89. package/types/taro.api.d.ts +94 -0
  90. package/types/taro.component.d.ts +10 -57
  91. package/types/taro.config.d.ts +24 -6
  92. package/types/taro.extend.d.ts +52 -75
  93. package/types/taro.hooks.d.ts +68 -67
  94. package/types/taro.lifecycle.d.ts +47 -28
  95. package/types/api/ad/index.ts +0 -6
  96. package/types/api/alipay/index.ts +0 -7
  97. package/types/api/index.d.ts +0 -352
@@ -1,51 +1,6 @@
1
- declare namespace Taro {
2
- /** 创建离屏 canvas 实例
3
- * @supported weapp
4
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createOffscreenCanvas.html
5
- */
6
- function createOffscreenCanvas(): OffscreenCanvas
7
-
8
- /** 创建 canvas 的绘图上下文 [CanvasContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html) 对象
9
- *
10
- * **Tip**: 需要指定 canvasId,该绘图上下文只作用于对应的 `<canvas/>`
11
- * @supported weapp, h5
12
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createCanvasContext.html
13
- */
14
- function createCanvasContext(
15
- /** 要获取上下文的 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件 canvas-id 属性 */
16
- canvasId: string,
17
- /** 在自定义组件下,当前组件实例的this,表示在这个自定义组件下查找拥有 canvas-id 的 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) ,如果省略则不在任何自定义组件内查找 */
18
- component?: General.IAnyObject,
19
- ): CanvasContext
1
+ import Taro from '../../index'
20
2
 
21
- /** 把当前画布指定区域的内容导出生成指定大小的图片。在 `draw()` 回调里调用该方法才能保证图片导出成功。
22
- *
23
- * **Bug & Tip:**
24
- *
25
- * 1. `tip`: 在 `draw` 回调里调用该方法才能保证图片导出成功。
26
- * @example
27
- * ```tsx
28
- * Taro.canvasToTempFilePath({
29
- * x: 100,
30
- * y: 200,
31
- * width: 50,
32
- * height: 50,
33
- * destWidth: 100,
34
- * destHeight: 100,
35
- * canvasId: 'myCanvas',
36
- * success: function (res) {
37
- * console.log(res.tempFilePath)
38
- * }
39
- * })
40
- * ```
41
- * @supported weapp, h5
42
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasToTempFilePath.html
43
- */
44
- function canvasToTempFilePath(
45
- option: canvasToTempFilePath.Option,
46
- /** 在自定义组件下,当前组件实例的this,以操作组件内 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件 */
47
- component?: General.IAnyObject,
48
- ): Promise<canvasToTempFilePath.SuccessCallbackResult>
3
+ declare module '../../index' {
49
4
  namespace canvasToTempFilePath {
50
5
  interface Option {
51
6
  /** 画布标识,传入 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件实例 (canvas type="2d" 时使用该属性)。 */
@@ -55,13 +10,13 @@ declare namespace Taro {
55
10
  /** 图片的质量,目前仅对 jpg 有效。取值范围为 (0, 1],不在范围内时当作 1.0 处理。 */
56
11
  quality?: number
57
12
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
58
- complete?: (res: General.CallbackResult) => void
13
+ complete?: (res: TaroGeneral.CallbackResult) => void
59
14
  /** 输出的图片的高度 */
60
15
  destHeight?: number
61
16
  /** 输出的图片的宽度 */
62
17
  destWidth?: number
63
18
  /** 接口调用失败的回调函数 */
64
- fail?: (res: General.CallbackResult) => void
19
+ fail?: (res: TaroGeneral.CallbackResult) => void
65
20
  /** 目标文件的类型
66
21
  * @default "png"
67
22
  */
@@ -77,7 +32,7 @@ declare namespace Taro {
77
32
  /** 指定的画布区域的左上角纵坐标 */
78
33
  y?: number
79
34
  }
80
- interface SuccessCallbackResult extends General.CallbackResult {
35
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
81
36
  /** 生成文件的临时路径 */
82
37
  tempFilePath: string
83
38
  /** 调用结果 */
@@ -99,17 +54,17 @@ declare namespace Taro {
99
54
  */
100
55
  disableScroll?: boolean
101
56
  /** 手指触摸动作开始 */
102
- onTouchStart?: General.CommonEventFunction
57
+ onTouchStart?: TaroGeneral.CommonEventFunction
103
58
  /** 手指触摸后移动 */
104
- onTouchMove?: General.CommonEventFunction
59
+ onTouchMove?: TaroGeneral.CommonEventFunction
105
60
  /** 手指触摸动作结束 */
106
- onTouchEnd?: General.CommonEventFunction
61
+ onTouchEnd?: TaroGeneral.CommonEventFunction
107
62
  /** 手指触摸动作被打断,如来电提醒,弹窗 */
108
- onTouchCancel?: General.CommonEventFunction
63
+ onTouchCancel?: TaroGeneral.CommonEventFunction
109
64
  /** 手指长按 500ms 之后触发,触发了长按事件后进行移动不会触发屏幕的滚动 */
110
- onLongTap?: General.CommonEventFunction
65
+ onLongTap?: TaroGeneral.CommonEventFunction
111
66
  /** 当发生错误时触发 error 事件,detail = {errMsg: 'something wrong'} */
112
- onError?: General.CommonEventFunction<CanvasProps.onErrorEventDetail>
67
+ onError?: TaroGeneral.CommonEventFunction<CanvasProps.onErrorEventDetail>
113
68
  }
114
69
 
115
70
  namespace CanvasProps {
@@ -118,28 +73,6 @@ declare namespace Taro {
118
73
  }
119
74
  }
120
75
  }
121
-
122
- /** 将像素数据绘制到画布。在自定义组件下,第二个参数传入自定义组件实例 this,以操作组件内 <canvas> 组件
123
- * @supported weapp, h5
124
- * @example
125
- * ```tsx
126
- * const data = new Uint8ClampedArray([255, 0, 0, 1])
127
- * Taro.canvasPutImageData({
128
- * canvasId: 'myCanvas',
129
- * x: 0,
130
- * y: 0,
131
- * width: 1,
132
- * data: data,
133
- * success: function (res) {}
134
- * })
135
- * ```
136
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasPutImageData.html
137
- */
138
- function canvasPutImageData(
139
- option: canvasPutImageData.Option,
140
- /** 在自定义组件下,当前组件实例的this,以操作组件内 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件 */
141
- component?: General.IAnyObject,
142
- ): Promise<General.CallbackResult>
143
76
  namespace canvasPutImageData {
144
77
  interface Option {
145
78
  /** 画布标识,传入 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件的 canvas-id 属性。 */
@@ -155,39 +88,13 @@ declare namespace Taro {
155
88
  /** 源图像数据在目标画布中的位置偏移量(y 轴方向的偏移量) */
156
89
  y: number
157
90
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
158
- complete?: (res: General.CallbackResult) => void
91
+ complete?: (res: TaroGeneral.CallbackResult) => void
159
92
  /** 接口调用失败的回调函数 */
160
- fail?: (res: General.CallbackResult) => void
93
+ fail?: (res: TaroGeneral.CallbackResult) => void
161
94
  /** 接口调用成功的回调函数 */
162
- success?: (res: General.CallbackResult) => void
95
+ success?: (res: TaroGeneral.CallbackResult) => void
163
96
  }
164
97
  }
165
-
166
- /** 获取 canvas 区域隐含的像素数据。
167
- * @supported weapp, h5
168
- * @example
169
- * ```tsx
170
- * Taro.canvasGetImageData({
171
- * canvasId: 'myCanvas',
172
- * x: 0,
173
- * y: 0,
174
- * width: 100,
175
- * height: 100,
176
- * success: function (res) {
177
- * console.log(res.width) // 100
178
- * console.log(res.height) // 100
179
- * console.log(res.data instanceof Uint8ClampedArray) // true
180
- * console.log(res.data.length) // 100 * 100 * 4
181
- * }
182
- * })
183
- * ```
184
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasGetImageData.html
185
- */
186
- function canvasGetImageData(
187
- option: canvasGetImageData.Option,
188
- /** 在自定义组件下,当前组件实例的this,以操作组件内 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件 */
189
- component?: General.IAnyObject,
190
- ): Promise<canvasGetImageData.SuccessCallbackResult>
191
98
  namespace canvasGetImageData {
192
99
  interface Option {
193
100
  /** 画布标识,传入 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件的 `canvas-id` 属性。 */
@@ -201,13 +108,13 @@ declare namespace Taro {
201
108
  /** 将要被提取的图像数据矩形区域的左上角纵坐标 */
202
109
  y: number
203
110
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
204
- complete?: (res: General.CallbackResult) => void
111
+ complete?: (res: TaroGeneral.CallbackResult) => void
205
112
  /** 接口调用失败的回调函数 */
206
- fail?: (res: General.CallbackResult) => void
113
+ fail?: (res: TaroGeneral.CallbackResult) => void
207
114
  /** 接口调用成功的回调函数 */
208
115
  success?: (result: SuccessCallbackResult) => void
209
116
  }
210
- interface SuccessCallbackResult extends General.CallbackResult {
117
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
211
118
  /** 图像像素点数据,一维数组,每四项表示一个像素点的 rgba */
212
119
  data: Uint8ClampedArray
213
120
  /** 图像数据矩形的高度 */
@@ -1779,4 +1686,102 @@ declare namespace Taro {
1779
1686
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html
1780
1687
  */
1781
1688
  interface RenderingContext {}
1689
+
1690
+ interface TaroStatic {
1691
+ /** 创建离屏 canvas 实例
1692
+ * @supported weapp
1693
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createOffscreenCanvas.html
1694
+ */
1695
+ createOffscreenCanvas(): OffscreenCanvas
1696
+
1697
+ /** 创建 canvas 的绘图上下文 [CanvasContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html) 对象
1698
+ *
1699
+ * **Tip**: 需要指定 canvasId,该绘图上下文只作用于对应的 `<canvas/>`
1700
+ * @supported weapp, h5
1701
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createCanvasContext.html
1702
+ */
1703
+ createCanvasContext(
1704
+ /** 要获取上下文的 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件 canvas-id 属性 */
1705
+ canvasId: string,
1706
+ /** 在自定义组件下,当前组件实例的this,表示在这个自定义组件下查找拥有 canvas-id 的 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) ,如果省略则不在任何自定义组件内查找 */
1707
+ component?: TaroGeneral.IAnyObject,
1708
+ ): CanvasContext
1709
+
1710
+ /** 把当前画布指定区域的内容导出生成指定大小的图片。在 `draw()` 回调里调用该方法才能保证图片导出成功。
1711
+ *
1712
+ * **Bug & Tip:**
1713
+ *
1714
+ * 1. `tip`: 在 `draw` 回调里调用该方法才能保证图片导出成功。
1715
+ * @example
1716
+ * ```tsx
1717
+ * Taro.canvasToTempFilePath({
1718
+ * x: 100,
1719
+ * y: 200,
1720
+ * width: 50,
1721
+ * height: 50,
1722
+ * destWidth: 100,
1723
+ * destHeight: 100,
1724
+ * canvasId: 'myCanvas',
1725
+ * success: function (res) {
1726
+ * console.log(res.tempFilePath)
1727
+ * }
1728
+ * })
1729
+ * ```
1730
+ * @supported weapp, h5
1731
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasToTempFilePath.html
1732
+ */
1733
+ canvasToTempFilePath(
1734
+ option: canvasToTempFilePath.Option,
1735
+ /** 在自定义组件下,当前组件实例的this,以操作组件内 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件 */
1736
+ component?: TaroGeneral.IAnyObject,
1737
+ ): Promise<canvasToTempFilePath.SuccessCallbackResult>
1738
+
1739
+ /** 将像素数据绘制到画布。在自定义组件下,第二个参数传入自定义组件实例 this,以操作组件内 <canvas> 组件
1740
+ * @supported weapp, h5
1741
+ * @example
1742
+ * ```tsx
1743
+ * const data = new Uint8ClampedArray([255, 0, 0, 1])
1744
+ * Taro.canvasPutImageData({
1745
+ * canvasId: 'myCanvas',
1746
+ * x: 0,
1747
+ * y: 0,
1748
+ * width: 1,
1749
+ * data: data,
1750
+ * success: function (res) {}
1751
+ * })
1752
+ * ```
1753
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasPutImageData.html
1754
+ */
1755
+ canvasPutImageData(
1756
+ option: canvasPutImageData.Option,
1757
+ /** 在自定义组件下,当前组件实例的this,以操作组件内 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件 */
1758
+ component?: TaroGeneral.IAnyObject,
1759
+ ): Promise<TaroGeneral.CallbackResult>
1760
+
1761
+ /** 获取 canvas 区域隐含的像素数据。
1762
+ * @supported weapp, h5
1763
+ * @example
1764
+ * ```tsx
1765
+ * Taro.canvasGetImageData({
1766
+ * canvasId: 'myCanvas',
1767
+ * x: 0,
1768
+ * y: 0,
1769
+ * width: 100,
1770
+ * height: 100,
1771
+ * success: function (res) {
1772
+ * console.log(res.width) // 100
1773
+ * console.log(res.height) // 100
1774
+ * console.log(res.data instanceof Uint8ClampedArray) // true
1775
+ * console.log(res.data.length) // 100 * 100 * 4
1776
+ * }
1777
+ * })
1778
+ * ```
1779
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasGetImageData.html
1780
+ */
1781
+ canvasGetImageData(
1782
+ option: canvasGetImageData.Option,
1783
+ /** 在自定义组件下,当前组件实例的this,以操作组件内 [canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 组件 */
1784
+ component?: TaroGeneral.IAnyObject,
1785
+ ): Promise<canvasGetImageData.SuccessCallbackResult>
1786
+ }
1782
1787
  }