@tarojs/taro 3.3.11 → 3.3.15

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 +33 -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/taro",
3
- "version": "3.3.11",
3
+ "version": "3.3.15",
4
4
  "description": "Taro framework",
5
5
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
6
6
  "main": "index.js",
@@ -26,9 +26,9 @@
26
26
  "author": "O2Team",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@tarojs/api": "3.3.11",
30
- "@tarojs/runtime": "3.3.11",
31
- "@tarojs/taro-h5": "3.3.11"
29
+ "@tarojs/api": "3.3.15",
30
+ "@tarojs/runtime": "3.3.15",
31
+ "@tarojs/taro-h5": "3.3.15"
32
32
  },
33
- "gitHead": "dad3664e58bb1fe7ab752365d9cc0d0dd444c40a"
33
+ "gitHead": "4a11ab9a8950f6a580e1278c160f6b4aaa8ac4f2"
34
34
  }
@@ -1,9 +1,6 @@
1
- declare namespace Taro {
2
- /** 创建激励视频广告组件。
3
- * @supported weapp
4
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/wx.createRewardedVideoAd.html
5
- */
6
- function createRewardedVideoAd (option: createRewardedVideoAd.Option): RewardedVideoAd
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
7
4
  namespace createRewardedVideoAd {
8
5
  interface Option {
9
6
  /** 广告单元 id */
@@ -14,12 +11,6 @@ declare namespace Taro {
14
11
  multiton?: boolean
15
12
  }
16
13
  }
17
- /** 创建插屏广告组件。
18
- * 请通过 getSystemInfoSync 返回对象的 SDKVersion 判断基础库版本号后再使用该 API。每次调用该方法创建插屏广告都会返回一个全新的实例(小程序端的插屏广告实例不允许跨页面使用)。
19
- * @supported weapp
20
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/wx.createInterstitialAd.html
21
- */
22
- function createInterstitialAd (option: createInterstitialAd.Option): InterstitialAd
23
14
 
24
15
  namespace createInterstitialAd {
25
16
  interface Option {
@@ -27,7 +18,7 @@ declare namespace Taro {
27
18
  adUnitId: string
28
19
  }
29
20
  }
30
-
21
+
31
22
  /**
32
23
  * 插屏广告组件。插屏广告组件是一个原生组件,层级比普通组件高。插屏广告组件每次创建都会返回一个全新的实例(小程序端的插屏广告实例不允许跨页面使用),默认是隐藏的,需要调用 InterstitialAd.show() 将其显示。
33
24
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/InterstitialAd.html
@@ -74,7 +65,7 @@ declare namespace Taro {
74
65
  */
75
66
  load(): Promise<any>
76
67
  /** 显示插屏广告。
77
- *
68
+ *
78
69
  * **错误码信息表**
79
70
  *
80
71
  * 如果插屏广告显示失败,InterstitialAd.show() 方法会返回一个rejected Promise,开发者可以获取到错误码及对应的错误信息。
@@ -93,22 +84,22 @@ declare namespace Taro {
93
84
  }
94
85
  namespace InterstitialAd {
95
86
  /** 插屏广告关闭事件的回调函数 */
96
- type OffCloseCallback = (res: General.CallbackResult) => void
87
+ type OffCloseCallback = (res: TaroGeneral.CallbackResult) => void
97
88
  /** 插屏错误事件的回调函数 */
98
- type OffErrorCallback = (res: General.CallbackResult) => void
89
+ type OffErrorCallback = (res: TaroGeneral.CallbackResult) => void
99
90
  /** 插屏广告加载事件的回调函数 */
100
- type OffLoadCallback = (res: General.CallbackResult) => void
91
+ type OffLoadCallback = (res: TaroGeneral.CallbackResult) => void
101
92
  /** 插屏广告关闭事件的回调函数 */
102
- type OnCloseCallback = (res: General.CallbackResult) => void
93
+ type OnCloseCallback = (res: TaroGeneral.CallbackResult) => void
103
94
  /** 插屏错误事件的回调函数 */
104
95
  type OnErrorCallback = (result: OnErrorCallbackResult) => void
105
96
  /** 插屏广告加载事件的回调函数 */
106
- type OnLoadCallback = (res: General.CallbackResult) => void
107
- interface OnErrorCallbackResult extends General.CallbackResult {
97
+ type OnLoadCallback = (res: TaroGeneral.CallbackResult) => void
98
+ interface OnErrorCallbackResult extends TaroGeneral.CallbackResult {
108
99
  /** 错误码
109
100
  * @see https://nervjs.github.io/taro/docs/apis/General#AdErrCode
110
101
  */
111
- errCode: keyof General.AdErrCode
102
+ errCode: keyof TaroGeneral.AdErrCode
112
103
  /** 错误信息 */
113
104
  errMsg: string
114
105
  }
@@ -154,7 +145,7 @@ declare namespace Taro {
154
145
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/RewardedVideoAd.onClose.html
155
146
  */
156
147
  onClose(callback: RewardedVideoAd.OnCloseCallback): void
157
- /**
148
+ /**
158
149
  * 监听激励视频错误事件。
159
150
  * @supported weapp
160
151
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/RewardedVideoAd.onError.html
@@ -167,11 +158,11 @@ declare namespace Taro {
167
158
  onLoad(callback: RewardedVideoAd.OnLoadCallback): void
168
159
  }
169
160
  namespace RewardedVideoAd {
170
- interface OnErrorCallbackResult extends General.CallbackResult {
161
+ interface OnErrorCallbackResult extends TaroGeneral.CallbackResult {
171
162
  /** 错误码
172
163
  * @see https://nervjs.github.io/taro/docs/apis/General#AdErrCode
173
164
  */
174
- errCode: keyof General.AdErrCode
165
+ errCode: keyof TaroGeneral.AdErrCode
175
166
  /** 错误信息 */
176
167
  errMsg: string
177
168
  }
@@ -180,16 +171,31 @@ declare namespace Taro {
180
171
  isEnded: boolean
181
172
  }
182
173
  /** 用户点击 `关闭广告` 按钮的事件的回调函数 */
183
- type OffCloseCallback = (res: General.CallbackResult) => void
174
+ type OffCloseCallback = (res: TaroGeneral.CallbackResult) => void
184
175
  /** 激励视频错误事件的回调函数 */
185
- type OffErrorCallback = (res: General.CallbackResult) => void
176
+ type OffErrorCallback = (res: TaroGeneral.CallbackResult) => void
186
177
  /** 激励视频广告加载事件的回调函数 */
187
- type OffLoadCallback = (res: General.CallbackResult) => void
178
+ type OffLoadCallback = (res: TaroGeneral.CallbackResult) => void
188
179
  /** 用户点击 `关闭广告` 按钮的事件的回调函数 */
189
180
  type OnCloseCallback = (result: OnCloseCallbackResult) => void
190
181
  /** 激励视频错误事件的回调函数 */
191
182
  type OnErrorCallback = (result: OnErrorCallbackResult) => void
192
183
  /** 激励视频广告加载事件的回调函数 */
193
- type OnLoadCallback = (res: General.CallbackResult) => void
184
+ type OnLoadCallback = (res: TaroGeneral.CallbackResult) => void
185
+ }
186
+
187
+ interface TaroStatic {
188
+ /** 创建激励视频广告组件。
189
+ * @supported weapp
190
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/wx.createRewardedVideoAd.html
191
+ */
192
+ createRewardedVideoAd (option: createRewardedVideoAd.Option): RewardedVideoAd
193
+
194
+ /** 创建插屏广告组件。
195
+ * 请通过 getSystemInfoSync 返回对象的 SDKVersion 判断基础库版本号后再使用该 API。每次调用该方法创建插屏广告都会返回一个全新的实例(小程序端的插屏广告实例不允许跨页面使用)。
196
+ * @supported weapp
197
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/wx.createInterstitialAd.html
198
+ */
199
+ createInterstitialAd (option: createInterstitialAd.Option): InterstitialAd
194
200
  }
195
201
  }
@@ -1,8 +1,12 @@
1
- declare namespace Taro {
2
- /**
3
- * 此接口可获取支付宝会员的基础信息(头像图片地址、昵称、性别、国家码、省份、所在市区),接入方法请参考 获取会员基础信息介绍。如需获取支付宝会员标识(user_id),请调用 my.getAuthCode 和 alipay.system.oauth.token 接口。
4
- * @supported alipay
5
- * @see https://docs.alipay.com/mini/api/ch8chh
6
- */
7
- function getOpenUserInfo(): Promise<string>
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ interface TaroStatic {
5
+ /**
6
+ * 此接口可获取支付宝会员的基础信息(头像图片地址、昵称、性别、国家码、省份、所在市区),接入方法请参考 获取会员基础信息介绍。如需获取支付宝会员标识(user_id),请调用 my.getAuthCode 和 alipay.system.oauth.token 接口。
7
+ * @supported alipay
8
+ * @see https://docs.alipay.com/mini/api/ch8chh
9
+ */
10
+ getOpenUserInfo(): Promise<string>
11
+ }
8
12
  }
@@ -1,37 +1,22 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace setEnableDebug {
3
5
  type Option = {
4
6
  /** 是否打开调试 */
5
7
  enableDebug: boolean
6
8
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
7
- complete?: (res: General.CallbackResult) => void
9
+ complete?: (res: TaroGeneral.CallbackResult) => void
8
10
  /** 接口调用失败的回调函数 */
9
- fail?: (res: General.CallbackResult) => void
11
+ fail?: (res: TaroGeneral.CallbackResult) => void
10
12
  /** 接口调用成功的回调函数 */
11
- success?: (res: General.CallbackResult) => void
13
+ success?: (res: TaroGeneral.CallbackResult) => void
12
14
  }
13
- interface Promised extends General.CallbackResult {
15
+ interface Promised extends TaroGeneral.CallbackResult {
14
16
  /** 调用结果 */
15
17
  errMsg: string
16
18
  }
17
19
  }
18
- /**
19
- * 设置是否打开调试开关,此开关对正式版也能生效。
20
- * @supported weapp
21
- * @example
22
- * ```tsx
23
- * // 打开调试
24
- * Taro.setEnableDebug({
25
- * enableDebug: true
26
- * })
27
- * // 关闭调试
28
- * Taro.setEnableDebug({
29
- * enableDebug: false
30
- * })
31
- * ```
32
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/wx.setEnableDebug.html
33
- */
34
- function setEnableDebug(res: setEnableDebug.Option): Promise<setEnableDebug.Promised>
35
20
 
36
21
  namespace getLogManager {
37
22
  type Option = {
@@ -48,31 +33,16 @@ declare namespace Taro {
48
33
  1
49
34
  }
50
35
  }
51
- /**
52
- * 获取日志管理器对象。
53
- * @supported weapp
54
- * @example
55
- * ```tsx
56
- * const logger = Taro.getLogManager({level: 1})
57
- *
58
- * logger.log({str: 'hello world'}, 'basic log', 100, [1, 2, 3])
59
- * logger.info({str: 'hello world'}, 'info log', 100, [1, 2, 3])
60
- * logger.debug({str: 'hello world'}, 'debug log', 100, [1, 2, 3])
61
- * logger.warn({str: 'hello world'}, 'warn log', 100, [1, 2, 3])
62
- * ```
63
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/wx.getLogManager.html
64
- */
65
- function getLogManager(res?: getLogManager.Option): LogManager
66
36
 
67
37
  /**
68
38
  * 日志管理器实例,可以通过 Taro.getLogManager 获取。
69
- *
39
+ *
70
40
  * 使用说明
71
41
  * 最多保存5M的日志内容,超过5M后,旧的日志内容会被删除。
72
42
  * 对于小程序,用户可以通过使用 button 组件的 open-type="feedback" 来上传打印的日志。
73
43
  * 对于小游戏,用户可以通过使用 Taro.createFeedbackButton 来创建上传打印的日志的按钮。
74
44
  * 开发者可以通过小程序管理后台左侧菜单“反馈管理”页面查看相关打印日志。
75
- *
45
+ *
76
46
  * 基础库默认会把 App、Page 的生命周期函数和 wx 命名空间下的函数调用写入日志。
77
47
  */
78
48
  interface LogManager {
@@ -108,24 +78,11 @@ declare namespace Taro {
108
78
  /** 日志内容,可以有任意多个。每次调用的参数的总大小不超过100Kb */
109
79
  ...args: any[]
110
80
  ): void
111
- }
112
-
113
- /**
114
- * 获取实时日志管理器对象。
115
- * @supported weapp
116
- * @example
117
- * ```tsx
118
- * const logger = Taro.getRealtimeLogManager()
119
- * logger.info({str: 'hello world'}, 'info log', 100, [1, 2, 3])
120
- * logger.error({str: 'hello world'}, 'error log', 100, [1, 2, 3])
121
- * logger.warn({str: 'hello world'}, 'warn log', 100, [1, 2, 3])
122
- * ```
123
- */
124
- function getRealtimeLogManager(): RealtimeLogManager
81
+ }
125
82
 
126
83
  /**
127
84
  * 实时日志管理器实例,可以通过 Taro.getRealtimeLogManager 获取。
128
- *
85
+ *
129
86
  * 使用说明
130
87
  * 为帮助小程序开发者快捷地排查小程序漏洞、定位问题,我们推出了实时日志功能。从基础库2.7.1开始,开发者可通过提供的接口打印日志,日志汇聚并实时上报到小程序后台。
131
88
  * 开发者可从小程序管理后台“开发->运维中心->实时日志”进入日志查询页面,查看开发者打印的日志信息。
@@ -181,4 +138,53 @@ declare namespace Taro {
181
138
  ...args: any[]
182
139
  ): void
183
140
  }
141
+
142
+ interface TaroStatic {
143
+ /**
144
+ * 设置是否打开调试开关,此开关对正式版也能生效。
145
+ * @supported weapp
146
+ * @example
147
+ * ```tsx
148
+ * // 打开调试
149
+ * Taro.setEnableDebug({
150
+ * enableDebug: true
151
+ * })
152
+ * // 关闭调试
153
+ * Taro.setEnableDebug({
154
+ * enableDebug: false
155
+ * })
156
+ * ```
157
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/wx.setEnableDebug.html
158
+ */
159
+ setEnableDebug(res: setEnableDebug.Option): Promise<setEnableDebug.Promised>
160
+
161
+ /**
162
+ * 获取日志管理器对象。
163
+ * @supported weapp
164
+ * @example
165
+ * ```tsx
166
+ * const logger = Taro.getLogManager({level: 1})
167
+ *
168
+ * logger.log({str: 'hello world'}, 'basic log', 100, [1, 2, 3])
169
+ * logger.info({str: 'hello world'}, 'info log', 100, [1, 2, 3])
170
+ * logger.debug({str: 'hello world'}, 'debug log', 100, [1, 2, 3])
171
+ * logger.warn({str: 'hello world'}, 'warn log', 100, [1, 2, 3])
172
+ * ```
173
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/wx.getLogManager.html
174
+ */
175
+ getLogManager(res?: getLogManager.Option): LogManager
176
+
177
+ /**
178
+ * 获取实时日志管理器对象。
179
+ * @supported weapp
180
+ * @example
181
+ * ```tsx
182
+ * const logger = Taro.getRealtimeLogManager()
183
+ * logger.info({str: 'hello world'}, 'info log', 100, [1, 2, 3])
184
+ * logger.error({str: 'hello world'}, 'error log', 100, [1, 2, 3])
185
+ * logger.warn({str: 'hello world'}, 'warn log', 100, [1, 2, 3])
186
+ * ```
187
+ */
188
+ getRealtimeLogManager(): RealtimeLogManager
189
+ }
184
190
  }
@@ -1,10 +1,14 @@
1
- declare namespace Taro {
2
- /**
3
- * @supported weapp
4
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/env/envObj.html
5
- */
6
- abstract class env {
7
- /** 文件系统中的用户目录路径 (本地路径) */
8
- static USER_DATA_PATH: string
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ interface TaroStatic {
5
+ /**
6
+ * @supported weapp
7
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/env/envObj.html
8
+ */
9
+ env: {
10
+ /** 文件系统中的用户目录路径 (本地路径) */
11
+ USER_DATA_PATH: string
12
+ }
9
13
  }
10
14
  }
@@ -1,90 +1,94 @@
1
- declare namespace Taro {
2
- /** 判断小程序的 API,回调,参数,组件等是否在当前版本可用。
3
- * @supported weapp
4
- * @example
5
- * ```tsx
6
- * Taro.canIUse('openBluetoothAdapter')
7
- * Taro.canIUse('getSystemInfoSync.return.screenWidth')
8
- * Taro.canIUse('getSystemInfo.success.screenWidth')
9
- * Taro.canIUse('showToast.object.image')
10
- * Taro.canIUse('onCompassChange.callback.direction')
11
- * Taro.canIUse('request.object.method.GET')
12
- * Taro.canIUse('live-player')
13
- * Taro.canIUse('text.selectable')
14
- * Taro.canIUse('button.open-type.contact')
15
- * ```
16
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/wx.canIUse.html
17
- */
18
- function canIUse(
19
- /**
20
- * 使用 `${API}.${method}.${param}.${option}` 或者 `${component}.${attribute}.${option}` 方式来调用
21
- *
22
- * **参数说明**
23
- *
24
- * - `${API}` 代表 API 名字
25
- * - `${method}` 代表调用方式,有效值为return, success, object, callback
26
- * - `${param}` 代表参数或者返回值
27
- * - `${option}` 代表参数的可选值或者返回值的属性
28
- * - `${component}` 代表组件名字
29
- * - `${attribute}` 代表组件属性
30
- * - `${option}` 代表组件属性的可选值
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ interface TaroStatic {
5
+ /** 判断小程序的 API,回调,参数,组件等是否在当前版本可用。
6
+ * @supported weapp
7
+ * @example
8
+ * ```tsx
9
+ * Taro.canIUse('openBluetoothAdapter')
10
+ * Taro.canIUse('getSystemInfoSync.return.screenWidth')
11
+ * Taro.canIUse('getSystemInfo.success.screenWidth')
12
+ * Taro.canIUse('showToast.object.image')
13
+ * Taro.canIUse('onCompassChange.callback.direction')
14
+ * Taro.canIUse('request.object.method.GET')
15
+ * Taro.canIUse('live-player')
16
+ * Taro.canIUse('text.selectable')
17
+ * Taro.canIUse('button.open-type.contact')
18
+ * ```
19
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/wx.canIUse.html
31
20
  */
32
- schema: string
33
- ): boolean
21
+ canIUse(
22
+ /**
23
+ * 使用 `${API}.${method}.${param}.${option}` 或者 `${component}.${attribute}.${option}` 方式来调用
24
+ *
25
+ * **参数说明**
26
+ *
27
+ * - `${API}` 代表 API 名字
28
+ * - `${method}` 代表调用方式,有效值为return, success, object, callback
29
+ * - `${param}` 代表参数或者返回值
30
+ * - `${option}` 代表参数的可选值或者返回值的属性
31
+ * - `${component}` 代表组件名字
32
+ * - `${attribute}` 代表组件属性
33
+ * - `${option}` 代表组件属性的可选值
34
+ */
35
+ schema: string
36
+ ): boolean
34
37
 
35
- /**
36
- * 将 Base64 字符串转成 ArrayBuffer 数据。
37
- * @supported weapp, h5
38
- * @example
39
- * ```tsx
40
- * const base64 = 'CxYh'
41
- * const arrayBuffer = Taro.base64ToArrayBuffer(base64)
42
- * ```
43
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/wx.base64ToArrayBuffer.html
44
- */
45
- function base64ToArrayBuffer (
46
- /** 要转化成 ArrayBuffer 对象的 Base64 字符串 */
47
- base64: string,
48
- ): ArrayBuffer
38
+ /**
39
+ * 将 Base64 字符串转成 ArrayBuffer 数据。
40
+ * @supported weapp, h5
41
+ * @example
42
+ * ```tsx
43
+ * const base64 = 'CxYh'
44
+ * const arrayBuffer = Taro.base64ToArrayBuffer(base64)
45
+ * ```
46
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/wx.base64ToArrayBuffer.html
47
+ */
48
+ base64ToArrayBuffer (
49
+ /** 要转化成 ArrayBuffer 对象的 Base64 字符串 */
50
+ base64: string,
51
+ ): ArrayBuffer
49
52
 
50
- /**
51
- * 将 ArrayBuffer 数据转成 Base64 字符串。
52
- * @supported weapp, h5
53
- * @example
54
- * ```tsx
55
- * const arrayBuffer = new Uint8Array([11, 22, 33])
56
- * const base64 = Taro.arrayBufferToBase64(arrayBuffer)
57
- * ```
58
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/wx.arrayBufferToBase64.html
59
- */
60
- function arrayBufferToBase64 (
61
- /** 要转换成 Base64 字符串的 ArrayBuffer 对象 */
62
- buffer: ArrayBuffer,
63
- ): string
53
+ /**
54
+ * 将 ArrayBuffer 数据转成 Base64 字符串。
55
+ * @supported weapp, h5
56
+ * @example
57
+ * ```tsx
58
+ * const arrayBuffer = new Uint8Array([11, 22, 33])
59
+ * const base64 = Taro.arrayBufferToBase64(arrayBuffer)
60
+ * ```
61
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/wx.arrayBufferToBase64.html
62
+ */
63
+ arrayBufferToBase64 (
64
+ /** 要转换成 Base64 字符串的 ArrayBuffer 对象 */
65
+ buffer: ArrayBuffer,
66
+ ): string
64
67
 
65
- /**
66
- * 跳转预加载 API
67
- * @param options 预加载的数据
68
- * @example
69
- * ```tsx
70
- * Taro.preload({ key: 'value' })
71
- * ```
72
- */
73
- function preload (options: Record<string, any>)
68
+ /**
69
+ * 跳转预加载 API
70
+ * @param options 预加载的数据
71
+ * @example
72
+ * ```tsx
73
+ * Taro.preload({ key: 'value' })
74
+ * ```
75
+ */
76
+ preload (options: Record<string, any>)
74
77
 
75
- /**
76
- * 跳转预加载 API
77
- * @param key 预加载的数据 key
78
- * @param value 预加载的数据 value
79
- * @example
80
- * ```tsx
81
- * Taro.preload('key', 'value')
82
- * ```
83
- */
84
- function preload (key: string, value: any)
78
+ /**
79
+ * 跳转预加载 API
80
+ * @param key 预加载的数据 key
81
+ * @param value 预加载的数据 value
82
+ * @example
83
+ * ```tsx
84
+ * Taro.preload('key', 'value')
85
+ * ```
86
+ */
87
+ preload (key: string, value: any)
85
88
 
86
- /**
87
- * 预加载的数据
88
- */
89
- const preloadData: Record<string, any>
89
+ /**
90
+ * 预加载的数据
91
+ */
92
+ preloadData: Record<string, any>
93
+ }
90
94
  }