@tarojs/taro 3.3.13 → 3.3.17

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 (98) 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 +116 -111
  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 +163 -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 +40 -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 +66 -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 +159 -150
  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/compile.d.ts +1 -5
  88. package/types/global.d.ts +392 -0
  89. package/types/index.d.ts +12 -98
  90. package/types/taro.api.d.ts +94 -0
  91. package/types/taro.component.d.ts +10 -57
  92. package/types/taro.config.d.ts +28 -6
  93. package/types/taro.extend.d.ts +50 -75
  94. package/types/taro.hooks.d.ts +68 -67
  95. package/types/taro.lifecycle.d.ts +47 -28
  96. package/types/api/ad/index.ts +0 -6
  97. package/types/api/alipay/index.ts +0 -7
  98. package/types/api/index.d.ts +0 -352
@@ -1,48 +1,33 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace showToast {
3
5
  interface Option {
4
6
  /** 提示的内容 */
5
7
  title: string
6
8
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
7
- complete?: (res: General.CallbackResult) => void
9
+ complete?: (res: TaroGeneral.CallbackResult) => void
8
10
  /** 提示的延迟时间 */
9
11
  duration?: number
10
12
  /** 接口调用失败的回调函数 */
11
- fail?: (res: General.CallbackResult) => void
13
+ fail?: (res: TaroGeneral.CallbackResult) => void
12
14
  /** 图标
13
15
  *
14
16
  * 可选值:
15
17
  * - 'success': 显示成功图标,此时 title 文本最多显示 7 个汉字长度;
18
+ * - 'error': 显示失败图标,此时 title 文本最多显示 7 个汉字长度;
16
19
  * - 'loading': 显示加载图标,此时 title 文本最多显示 7 个汉字长度;
17
20
  * - 'none': 不显示图标,此时 title 文本最多可显示两行 */
18
- icon?: 'success' | 'loading' | 'none'
21
+ icon?: 'success' | 'error' | 'loading' | 'none'
19
22
  /** 自定义图标的本地路径,image 的优先级高于 icon */
20
23
  image?: string
21
24
  /** 是否显示透明蒙层,防止触摸穿透 */
22
25
  mask?: boolean
23
26
  /** 接口调用成功的回调函数 */
24
- success?: (res: General.CallbackResult) => void
27
+ success?: (res: TaroGeneral.CallbackResult) => void
25
28
  }
26
29
  }
27
30
 
28
- /** 显示消息提示框
29
- *
30
- * **注意**
31
- * - Taro.showLoading 和 Taro.showToast 同时只能显示一个
32
- * - Taro.showToast 应与 Taro.hideToast 配对使用
33
- * @supported weapp, h5, rn
34
- * @example
35
- * ```tsx
36
- * Taro.showToast({
37
- * title: '成功',
38
- * icon: 'success',
39
- * duration: 2000
40
- * })
41
- * ```
42
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showToast.html
43
- */
44
- function showToast(option?: showToast.Option): Promise<General.CallbackResult>
45
-
46
31
  namespace showModal {
47
32
  interface Option {
48
33
  /** 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串 */
@@ -50,7 +35,7 @@ declare namespace Taro {
50
35
  /** 取消按钮的文字,最多 4 个字符 */
51
36
  cancelText?: string
52
37
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
53
- complete?: (res: General.CallbackResult) => void
38
+ complete?: (res: TaroGeneral.CallbackResult) => void
54
39
  /** 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串 */
55
40
  confirmColor?: string
56
41
  /** 确认按钮的文字,最多 4 个字符 */
@@ -58,7 +43,7 @@ declare namespace Taro {
58
43
  /** 提示的内容 */
59
44
  content?: string
60
45
  /** 接口调用失败的回调函数 */
61
- fail?: (res: General.CallbackResult) => void
46
+ fail?: (res: TaroGeneral.CallbackResult) => void
62
47
  /** 是否显示取消按钮 */
63
48
  showCancel?: boolean
64
49
  /** 接口调用成功的回调函数 */
@@ -67,7 +52,7 @@ declare namespace Taro {
67
52
  title?: string
68
53
  }
69
54
 
70
- interface SuccessCallbackResult extends General.CallbackResult {
55
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
71
56
  /** 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭) */
72
57
  cancel: boolean
73
58
  /** 为 true 时,表示用户点击了确定按钮 */
@@ -77,77 +62,37 @@ declare namespace Taro {
77
62
  }
78
63
  }
79
64
 
80
- /** 显示模态对话框
81
- * **注意**
82
- * - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
83
- * - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
84
- * @supported weapp, h5, rn
85
- * @example
86
- * ```tsx
87
- * Taro.showModal({
88
- * title: '提示',
89
- * content: '这是一个模态弹窗',
90
- * success: function (res) {
91
- * if (res.confirm) {
92
- * console.log('用户点击确定')
93
- * } else if (res.cancel) {
94
- * console.log('用户点击取消')
95
- * }
96
- * }
97
- * })
98
- * ```
99
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showModal.html
100
- */
101
- function showModal(option?: showModal.Option): Promise<showModal.SuccessCallbackResult>
102
-
103
65
  namespace showLoading {
104
66
  interface Option {
105
67
  /** 提示的内容 */
106
68
  title: string
107
69
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
108
- complete?: (res: General.CallbackResult) => void
70
+ complete?: (res: TaroGeneral.CallbackResult) => void
109
71
  /** 接口调用失败的回调函数 */
110
- fail?: (res: General.CallbackResult) => void
72
+ fail?: (res: TaroGeneral.CallbackResult) => void
111
73
  /** 是否显示透明蒙层,防止触摸穿透 */
112
74
  mask?: boolean
113
75
  /** 接口调用成功的回调函数 */
114
- success?: (res: General.CallbackResult) => void
76
+ success?: (res: TaroGeneral.CallbackResult) => void
115
77
  }
116
78
  }
117
79
 
118
- /** 显示 loading 提示框。需主动调用 Taro.hideLoading 才能关闭提示框
119
- *
120
- * **注意**
121
- * - Taro.showLoading 和 Taro.showToast 同时只能显示一个
122
- * - Taro.showLoading 应与 Taro.hideLoading 配对使用
123
- * @supported weapp, h5, rn
124
- * @example
125
- * ```tsx
126
- * Taro.showLoading({
127
- * title: '加载中',
128
- * })
129
- * setTimeout(function () {
130
- * Taro.hideLoading()
131
- * }, 2000)
132
- * ```
133
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showLoading.html
134
- */
135
- function showLoading(option?: showLoading.Option): Promise<General.CallbackResult>
136
-
137
80
  namespace showActionSheet {
138
81
  interface Option {
82
+ /** 警示文案 */
83
+ alertText?: string
139
84
  /** 按钮的文字数组,数组长度最大为 6 */
140
85
  itemList: string[]
141
86
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
142
- complete?: (res: General.CallbackResult) => void
87
+ complete?: (res: TaroGeneral.CallbackResult) => void
143
88
  /** 接口调用失败的回调函数 */
144
- fail?: (res: General.CallbackResult) => void
89
+ fail?: (res: TaroGeneral.CallbackResult) => void
145
90
  /** 按钮的文字颜色 */
146
91
  itemColor?: string
147
92
  /** 接口调用成功的回调函数 */
148
93
  success?: (result: SuccessCallbackResult) => void
149
94
  }
150
- interface SuccessCallbackResult extends General.CallbackResult {
95
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
151
96
  /** 用户点击的按钮序号,从上到下的顺序,从0开始 */
152
97
  tapIndex: number
153
98
  /** 调用结果 */
@@ -155,110 +100,174 @@ declare namespace Taro {
155
100
  }
156
101
  }
157
102
 
158
- /** 显示操作菜单
159
- *
160
- * **注意**
161
- * - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
162
- * - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
163
- * @supported weapp, h5, rn
164
- * @example
165
- * ```tsx
166
- * Taro.showActionSheet({
167
- * itemList: ['A', 'B', 'C'],
168
- * success: function (res) {
169
- * console.log(res.tapIndex)
170
- * },
171
- * fail: function (res) {
172
- * console.log(res.errMsg)
173
- * }
174
- * })
175
- * ```
176
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showActionSheet.html
177
- */
178
- function showActionSheet(option: showActionSheet.Option): Promise<showActionSheet.SuccessCallbackResult>
179
-
180
103
  namespace hideToast {
181
104
  interface Option {
182
105
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
183
- complete?: (res: General.CallbackResult) => void
106
+ complete?: (res: TaroGeneral.CallbackResult) => void
184
107
  /** 接口调用失败的回调函数 */
185
- fail?: (res: General.CallbackResult) => void
108
+ fail?: (res: TaroGeneral.CallbackResult) => void
186
109
  /** 接口调用成功的回调函数 */
187
- success?: (res: General.CallbackResult) => void
110
+ success?: (res: TaroGeneral.CallbackResult) => void
188
111
  }
189
112
  }
190
113
 
191
- /** 隐藏消息提示框
192
- * @supported weapp, h5, rn
193
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideToast.html
194
- */
195
- function hideToast(option?: hideToast.Option): void
196
-
197
114
  namespace hideLoading {
198
115
  interface Option {
199
116
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
200
- complete?: (res: General.CallbackResult) => void
117
+ complete?: (res: TaroGeneral.CallbackResult) => void
201
118
  /** 接口调用失败的回调函数 */
202
- fail?: (res: General.CallbackResult) => void
119
+ fail?: (res: TaroGeneral.CallbackResult) => void
203
120
  /** 接口调用成功的回调函数 */
204
- success?: (res: General.CallbackResult) => void
121
+ success?: (res: TaroGeneral.CallbackResult) => void
205
122
  }
206
123
  }
207
124
 
208
- /** 隐藏 loading 提示框
209
- * @supported weapp, h5, rn
210
- * @example
211
- * ```tsx
212
- * Taro.showLoading({
213
- * title: '加载中',
214
- * })
215
- * setTimeout(function (){
216
- * Taro.hideLoading()
217
- * },2000)
218
- * ```
219
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideLoading.html
220
- */
221
- function hideLoading(option?: hideLoading.Option): void
222
-
223
125
  namespace enableAlertBeforeUnload {
224
126
  interface Option {
127
+ /** 询问对话框内容 */
128
+ message: string
225
129
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
226
- complete?: (res: General.CallbackResult) => void
130
+ complete?: (res: TaroGeneral.CallbackResult) => void
227
131
  /** 接口调用失败的回调函数 */
228
- fail?: (res: General.CallbackResult) => void
132
+ fail?: (res: TaroGeneral.CallbackResult) => void
229
133
  /** 接口调用成功的回调函数 */
230
- success?: (res: General.CallbackResult) => void
134
+ success?: (res: TaroGeneral.CallbackResult) => void
231
135
  }
232
136
  }
233
-
234
- /** 开启小程序页面返回询问对话框
235
- * @supported weapp
236
- * @example
237
- * ```tsx
238
- * Taro.enableAlertBeforeUnload({
239
- * success: function () {
240
- * console.log('success')
241
- * },
242
- * })
243
- * ```
244
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.enableAlertBeforeUnload.html
245
- */
246
- function enableAlertBeforeUnload(option?: enableAlertBeforeUnload.Option): void
247
-
137
+
248
138
  namespace disableAlertBeforeUnload {
249
139
  interface Option {
250
140
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
251
- complete?: (res: General.CallbackResult) => void
141
+ complete?: (res: TaroGeneral.CallbackResult) => void
252
142
  /** 接口调用失败的回调函数 */
253
- fail?: (res: General.CallbackResult) => void
143
+ fail?: (res: TaroGeneral.CallbackResult) => void
254
144
  /** 接口调用成功的回调函数 */
255
- success?: (res: General.CallbackResult) => void
145
+ success?: (res: TaroGeneral.CallbackResult) => void
256
146
  }
257
147
  }
258
-
259
- /** 关闭小程序页面返回询问对话框
260
- * @supported weapp
261
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.disableAlertBeforeUnload.html
262
- */
263
- function disableAlertBeforeUnload(option?: disableAlertBeforeUnload.Option): void
148
+
149
+ interface TaroStatic {
150
+ /** 显示消息提示框
151
+ *
152
+ * **注意**
153
+ * - Taro.showLoading 和 Taro.showToast 同时只能显示一个
154
+ * - Taro.showToast 应与 Taro.hideToast 配对使用
155
+ * @supported weapp, h5, rn
156
+ * @example
157
+ * ```tsx
158
+ * Taro.showToast({
159
+ * title: '成功',
160
+ * icon: 'success',
161
+ * duration: 2000
162
+ * })
163
+ * ```
164
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showToast.html
165
+ */
166
+ showToast(option?: showToast.Option): Promise<TaroGeneral.CallbackResult>
167
+
168
+ /** 显示模态对话框
169
+ * **注意**
170
+ * - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
171
+ * - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
172
+ * @supported weapp, h5, rn
173
+ * @example
174
+ * ```tsx
175
+ * Taro.showModal({
176
+ * title: '提示',
177
+ * content: '这是一个模态弹窗',
178
+ * success: function (res) {
179
+ * if (res.confirm) {
180
+ * console.log('用户点击确定')
181
+ * } else if (res.cancel) {
182
+ * console.log('用户点击取消')
183
+ * }
184
+ * }
185
+ * })
186
+ * ```
187
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showModal.html
188
+ */
189
+ showModal(option?: showModal.Option): Promise<showModal.SuccessCallbackResult>
190
+
191
+ /** 显示 loading 提示框。需主动调用 Taro.hideLoading 才能关闭提示框
192
+ *
193
+ * **注意**
194
+ * - Taro.showLoading 和 Taro.showToast 同时只能显示一个
195
+ * - Taro.showLoading 应与 Taro.hideLoading 配对使用
196
+ * @supported weapp, h5, rn
197
+ * @example
198
+ * ```tsx
199
+ * Taro.showLoading({
200
+ * title: '加载中',
201
+ * })
202
+ * setTimeout(function () {
203
+ * Taro.hideLoading()
204
+ * }, 2000)
205
+ * ```
206
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showLoading.html
207
+ */
208
+ showLoading(option?: showLoading.Option): Promise<TaroGeneral.CallbackResult>
209
+
210
+ /** 显示操作菜单
211
+ *
212
+ * **注意**
213
+ * - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
214
+ * - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
215
+ * @supported weapp, h5, rn
216
+ * @example
217
+ * ```tsx
218
+ * Taro.showActionSheet({
219
+ * itemList: ['A', 'B', 'C'],
220
+ * success: function (res) {
221
+ * console.log(res.tapIndex)
222
+ * },
223
+ * fail: function (res) {
224
+ * console.log(res.errMsg)
225
+ * }
226
+ * })
227
+ * ```
228
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showActionSheet.html
229
+ */
230
+ showActionSheet(option: showActionSheet.Option): Promise<showActionSheet.SuccessCallbackResult>
231
+
232
+ /** 隐藏消息提示框
233
+ * @supported weapp, h5, rn
234
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideToast.html
235
+ */
236
+ hideToast(option?: hideToast.Option): void
237
+
238
+ /** 隐藏 loading 提示框
239
+ * @supported weapp, h5, rn
240
+ * @example
241
+ * ```tsx
242
+ * Taro.showLoading({
243
+ * title: '加载中',
244
+ * })
245
+ * setTimeout(function (){
246
+ * Taro.hideLoading()
247
+ * },2000)
248
+ * ```
249
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideLoading.html
250
+ */
251
+ hideLoading(option?: hideLoading.Option): void /** 隐藏 loading 提示框
252
+
253
+ /** 开启小程序页面返回询问对话框
254
+ * @supported weapp
255
+ * @example
256
+ * ```tsx
257
+ * Taro.enableAlertBeforeUnload({
258
+ * success: function () {
259
+ * console.log('success')
260
+ * },
261
+ * })
262
+ * ```
263
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.enableAlertBeforeUnload.html
264
+ */
265
+ enableAlertBeforeUnload(option: enableAlertBeforeUnload.Option): void
266
+
267
+ /** 关闭小程序页面返回询问对话框
268
+ * @supported weapp
269
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.disableAlertBeforeUnload.html
270
+ */
271
+ disableAlertBeforeUnload(option?: disableAlertBeforeUnload.Option): void
272
+ }
264
273
  }
@@ -1,39 +1,27 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace hideKeyboard {
3
5
  interface Option {
4
6
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
5
- complete?: (res: General.CallbackResult) => void
7
+ complete?: (res: TaroGeneral.CallbackResult) => void
6
8
  /** 接口调用失败的回调函数 */
7
- fail?: (res: General.CallbackResult) => void
9
+ fail?: (res: TaroGeneral.CallbackResult) => void
8
10
  /** 接口调用成功的回调函数 */
9
- success?: (res: General.CallbackResult) => void
11
+ success?: (res: TaroGeneral.CallbackResult) => void
10
12
  }
11
13
  }
12
14
 
13
- /** 在input、textarea等focus拉起键盘之后,手动调用此接口收起键盘
14
- * @supported weapp, rn
15
- * @example
16
- * ```tsx
17
- * Taro.hideKeyboard({
18
- * complete: res => {
19
- * console.log('hideKeyboard res', res)
20
- * }
21
- * })
22
- * ```
23
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.hideKeyboard.html
24
- */
25
- function hideKeyboard(option?: hideKeyboard.Option): Promise<General.CallbackResult>
26
-
27
15
  namespace getSelectedTextRange {
28
16
  interface Option {
29
17
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
30
- complete?: (res: General.CallbackResult) => void
18
+ complete?: (res: TaroGeneral.CallbackResult) => void
31
19
  /** 接口调用失败的回调函数 */
32
- fail?: (res: General.CallbackResult) => void
20
+ fail?: (res: TaroGeneral.CallbackResult) => void
33
21
  /** 接口调用成功的回调函数 */
34
22
  success?: (result: SuccessCallbackResult) => void
35
23
  }
36
- interface SuccessCallbackResult extends General.CallbackResult {
24
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
37
25
  /** 输入框光标结束位置 */
38
26
  end: number
39
27
  /** 输入框光标起始位置 */
@@ -43,20 +31,6 @@ declare namespace Taro {
43
31
  }
44
32
  }
45
33
 
46
- /** 在input、textarea等focus之后,获取输入框的光标位置。注意:只有在focus的时候调用此接口才有效。
47
- * @supported weapp
48
- * @example
49
- * ```tsx
50
- * Taro.getSelectedTextRange({
51
- * complete: res => {
52
- * console.log('getSelectedTextRange res', res.start, res.end)
53
- * }
54
- * })
55
- * ```
56
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.getSelectedTextRange.html
57
- */
58
- function getSelectedTextRange(option?: getSelectedTextRange.Option): Promise<getSelectedTextRange.SuccessCallbackResult>
59
-
60
34
  namespace onKeyboardHeightChange {
61
35
  type Callback = (
62
36
  result: CallbackResult,
@@ -67,25 +41,55 @@ declare namespace Taro {
67
41
  }
68
42
  }
69
43
 
70
- /** 监听键盘高度变化
71
- * @supported weapp, rn
72
- * @example
73
- * ```tsx
74
- * Taro.onKeyboardHeightChange(res => {
75
- * console.log(res.height)
76
- * })
77
- * ```
78
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.onKeyboardHeightChange.html
79
- */
80
- function onKeyboardHeightChange(callback: onKeyboardHeightChange.Callback): void
44
+ interface TaroStatic {
45
+ /** 在input、textarea等focus拉起键盘之后,手动调用此接口收起键盘
46
+ * @supported weapp, rn
47
+ * @example
48
+ * ```tsx
49
+ * Taro.hideKeyboard({
50
+ * complete: res => {
51
+ * console.log('hideKeyboard res', res)
52
+ * }
53
+ * })
54
+ * ```
55
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.hideKeyboard.html
56
+ */
57
+ hideKeyboard(option?: hideKeyboard.Option): Promise<TaroGeneral.CallbackResult>
81
58
 
82
- /**
83
- * 取消监听键盘高度变化事件。
84
- * @supported weapp, rn
85
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.offKeyboardHeightChange.html
86
- */
87
- function offKeyboardHeightChange(
88
- /** 键盘高度变化事件的回调函数 */
89
- callback?: (...args: any[]) => any,
90
- ): void
59
+ /** 在input、textarea等focus之后,获取输入框的光标位置。注意:只有在focus的时候调用此接口才有效。
60
+ * @supported weapp
61
+ * @example
62
+ * ```tsx
63
+ * Taro.getSelectedTextRange({
64
+ * complete: res => {
65
+ * console.log('getSelectedTextRange res', res.start, res.end)
66
+ * }
67
+ * })
68
+ * ```
69
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.getSelectedTextRange.html
70
+ */
71
+ getSelectedTextRange(option?: getSelectedTextRange.Option): Promise<getSelectedTextRange.SuccessCallbackResult>
72
+
73
+ /** 监听键盘高度变化
74
+ * @supported weapp, rn
75
+ * @example
76
+ * ```tsx
77
+ * Taro.onKeyboardHeightChange(res => {
78
+ * console.log(res.height)
79
+ * })
80
+ * ```
81
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.onKeyboardHeightChange.html
82
+ */
83
+ onKeyboardHeightChange(callback: onKeyboardHeightChange.Callback): void
84
+
85
+ /**
86
+ * 取消监听键盘高度变化事件。
87
+ * @supported weapp, rn
88
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.offKeyboardHeightChange.html
89
+ */
90
+ offKeyboardHeightChange(
91
+ /** 键盘高度变化事件的回调函数 */
92
+ callback?: (...args: any[]) => any,
93
+ ): void
94
+ }
91
95
  }
@@ -1,4 +1,6 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace getMenuButtonBoundingClientRect {
3
5
  /** 菜单按钮的布局位置信息 */
4
6
  interface Rect {
@@ -17,9 +19,11 @@ declare namespace Taro {
17
19
  }
18
20
  }
19
21
 
20
- /** 获取菜单按钮(右上角胶囊按钮)的布局位置信息。坐标信息以屏幕左上角为原点。
21
- * @supported weapp
22
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/menu/wx.getMenuButtonBoundingClientRect.html
23
- */
24
- function getMenuButtonBoundingClientRect(): getMenuButtonBoundingClientRect.Rect
22
+ interface TaroStatic {
23
+ /** 获取菜单按钮(右上角胶囊按钮)的布局位置信息。坐标信息以屏幕左上角为原点。
24
+ * @supported weapp
25
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/menu/wx.getMenuButtonBoundingClientRect.html
26
+ */
27
+ getMenuButtonBoundingClientRect(): getMenuButtonBoundingClientRect.Rect
28
+ }
25
29
  }