@spcsn/taro 0.1.2 → 1.0.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.
- package/README.md +13 -6
- package/dist/index.js +223 -1
- package/dist/index.js.map +1 -1
- package/package.json +25 -56
- package/types/api/ad/index.d.ts +3 -6
- package/types/api/base/debug.d.ts +8 -8
- package/types/api/base/env.d.ts +3 -3
- package/types/api/base/index.d.ts +3 -3
- package/types/api/base/performance.d.ts +5 -5
- package/types/api/base/system.d.ts +8 -16
- package/types/api/base/update.d.ts +6 -6
- package/types/api/base/weapp/app-event.d.ts +12 -12
- package/types/api/base/weapp/life-cycle.d.ts +1 -1
- package/types/api/canvas/index.d.ts +71 -72
- package/types/api/data-analysis/index.d.ts +1 -1
- package/types/api/device/accelerometer.d.ts +4 -4
- package/types/api/device/accessibility.d.ts +1 -1
- package/types/api/device/battery.d.ts +2 -2
- package/types/api/device/bluetooth-ble.d.ts +14 -14
- package/types/api/device/bluetooth-peripheral.d.ts +15 -15
- package/types/api/device/bluetooth.d.ts +11 -11
- package/types/api/device/calendar.d.ts +2 -2
- package/types/api/device/clipboard.d.ts +2 -4
- package/types/api/device/compass.d.ts +4 -4
- package/types/api/device/gyroscope.d.ts +4 -4
- package/types/api/device/iBeacon.d.ts +7 -7
- package/types/api/device/keyboard.d.ts +3 -3
- package/types/api/device/memory.d.ts +2 -2
- package/types/api/device/motion.d.ts +4 -4
- package/types/api/device/network.d.ts +5 -20
- package/types/api/device/nfc.d.ts +17 -17
- package/types/api/device/phone.d.ts +1 -1
- package/types/api/device/scan.d.ts +1 -1
- package/types/api/device/screen.d.ts +6 -6
- package/types/api/device/sms.d.ts +1 -1
- package/types/api/device/vibrate.d.ts +2 -2
- package/types/api/device/wifi.d.ts +10 -10
- package/types/api/ext/index.d.ts +2 -2
- package/types/api/files/index.d.ts +46 -46
- package/types/api/framework/index.d.ts +2 -2
- package/types/api/location/index.d.ts +38 -45
- package/types/api/media/audio.d.ts +30 -30
- package/types/api/media/background-audio.d.ts +1 -1
- package/types/api/media/camera.d.ts +12 -25
- package/types/api/media/image.d.ts +8 -13
- package/types/api/media/map.d.ts +15 -15
- package/types/api/media/recorder.d.ts +11 -11
- package/types/api/media/video.d.ts +19 -21
- package/types/api/navigate/index.d.ts +2 -2
- package/types/api/network/download.d.ts +7 -8
- package/types/api/network/request.d.ts +14 -33
- package/types/api/network/upload.d.ts +7 -9
- package/types/api/network/websocket.d.ts +14 -14
- package/types/api/open-api/account.d.ts +1 -1
- package/types/api/open-api/address.d.ts +5 -5
- package/types/api/open-api/authorize.d.ts +1 -1
- package/types/api/open-api/login.d.ts +5 -5
- package/types/api/open-api/settings.d.ts +2 -2
- package/types/api/open-api/subscribe-message.d.ts +15 -15
- package/types/api/open-api/user-info.d.ts +2 -3
- package/types/api/payment/index.d.ts +1 -1
- package/types/api/route/index.d.ts +5 -8
- package/types/api/share/index.d.ts +3 -3
- package/types/api/storage/background-fetch.d.ts +6 -9
- package/types/api/storage/index.d.ts +11 -11
- package/types/api/taro.extend.d.ts +7 -24
- package/types/api/taro.hooks.d.ts +8 -33
- package/types/api/ui/animation.d.ts +33 -36
- package/types/api/ui/background.d.ts +2 -4
- package/types/api/ui/custom-component.d.ts +1 -1
- package/types/api/ui/fonts.d.ts +1 -10
- package/types/api/ui/interaction.d.ts +6 -6
- package/types/api/ui/menu.d.ts +1 -1
- package/types/api/ui/navigation-bar.d.ts +5 -7
- package/types/api/ui/pull-down-refresh.d.ts +2 -3
- package/types/api/ui/scroll.d.ts +3 -4
- package/types/api/ui/tab-bar.d.ts +8 -8
- package/types/api/ui/window.d.ts +2 -2
- package/types/api/wxml/index.d.ts +19 -23
- package/types/compile/compiler.d.ts +4 -10
- package/types/compile/config/index.d.ts +0 -3
- package/types/compile/config/mini.d.ts +17 -39
- package/types/compile/config/plugin.d.ts +14 -4
- package/types/compile/config/project.d.ts +23 -61
- package/types/compile/config/util.d.ts +18 -73
- package/types/compile/index.d.ts +16 -1
- package/types/compile/viteCompilerContext.d.ts +18 -52
- package/types/global.d.ts +1 -12
- package/types/index.d.ts +0 -11
- package/types/taro.api.d.ts +0 -9
- package/types/taro.component.d.ts +0 -2
- package/types/taro.config.d.ts +0 -120
- package/types/taro.runtime.d.ts +7 -3
- package/types/api/alipay/index.d.ts +0 -69
- package/types/api/qq/index.d.ts +0 -354
- package/types/api/swan/bookshelf.d.ts +0 -307
- package/types/api/swan/download-package.d.ts +0 -80
- package/types/api/swan/index.d.ts +0 -251
- package/types/api/swan/pay.d.ts +0 -139
- package/types/compile/config/h5.d.ts +0 -134
- package/types/compile/config/harmony.d.ts +0 -118
- package/types/compile/config/rn.d.ts +0 -85
|
@@ -89,7 +89,7 @@ declare module '../../index' {
|
|
|
89
89
|
/** VideoContext 实例,可通过 [Taro.createVideoContext](./createVideoContext) 获取。
|
|
90
90
|
*
|
|
91
91
|
* VideoContext 通过 id 跟一个 video 组件绑定,操作对应的 video 组件。
|
|
92
|
-
* @supported weapp
|
|
92
|
+
* @supported weapp
|
|
93
93
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.html
|
|
94
94
|
*/
|
|
95
95
|
interface VideoContext {
|
|
@@ -99,7 +99,7 @@ declare module '../../index' {
|
|
|
99
99
|
*/
|
|
100
100
|
exitBackgroundPlayback(): void
|
|
101
101
|
/** 退出全屏
|
|
102
|
-
* @supported weapp
|
|
102
|
+
* @supported weapp
|
|
103
103
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.exitFullScreen.html
|
|
104
104
|
*/
|
|
105
105
|
exitFullScreen(): void
|
|
@@ -114,17 +114,17 @@ declare module '../../index' {
|
|
|
114
114
|
*/
|
|
115
115
|
hideStatusBar(): void
|
|
116
116
|
/** 暂停视频
|
|
117
|
-
* @supported weapp
|
|
117
|
+
* @supported weapp
|
|
118
118
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.pause.html
|
|
119
119
|
*/
|
|
120
120
|
pause(): void
|
|
121
121
|
/** 播放视频
|
|
122
|
-
* @supported weapp
|
|
122
|
+
* @supported weapp
|
|
123
123
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.play.html
|
|
124
124
|
*/
|
|
125
125
|
play(): void
|
|
126
126
|
/** 设置倍速播放
|
|
127
|
-
* @supported weapp
|
|
127
|
+
* @supported weapp
|
|
128
128
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.playbackRate.html
|
|
129
129
|
*/
|
|
130
130
|
playbackRate(
|
|
@@ -137,12 +137,12 @@ declare module '../../index' {
|
|
|
137
137
|
*/
|
|
138
138
|
requestBackgroundPlayback(): void
|
|
139
139
|
/** 进入全屏
|
|
140
|
-
* @supported weapp
|
|
140
|
+
* @supported weapp
|
|
141
141
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.requestFullScreen.html
|
|
142
142
|
*/
|
|
143
143
|
requestFullScreen(option: VideoContext.RequestFullScreenOption): void
|
|
144
144
|
/** 跳转到指定位置
|
|
145
|
-
* @supported weapp
|
|
145
|
+
* @supported weapp
|
|
146
146
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.seek.html
|
|
147
147
|
*/
|
|
148
148
|
seek(
|
|
@@ -163,7 +163,7 @@ declare module '../../index' {
|
|
|
163
163
|
*/
|
|
164
164
|
showStatusBar(): void
|
|
165
165
|
/** 停止视频
|
|
166
|
-
* @supported weapp
|
|
166
|
+
* @supported weapp
|
|
167
167
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.stop.html
|
|
168
168
|
*/
|
|
169
169
|
stop(): void
|
|
@@ -235,7 +235,7 @@ declare module '../../index' {
|
|
|
235
235
|
interface Option {
|
|
236
236
|
/** 默认拉起的是前置或者后置摄像头。部分 Android 手机下由于系统 ROM 不支持无法生效
|
|
237
237
|
* @default "back"
|
|
238
|
-
* @supported weapp
|
|
238
|
+
* @supported weapp
|
|
239
239
|
*/
|
|
240
240
|
camera?: keyof Camera
|
|
241
241
|
/** 是否压缩所选择的视频文件
|
|
@@ -250,7 +250,7 @@ declare module '../../index' {
|
|
|
250
250
|
maxDuration?: number
|
|
251
251
|
/** 视频选择的来源
|
|
252
252
|
* @default ['album', 'camera']
|
|
253
|
-
* @supported weapp
|
|
253
|
+
* @supported weapp
|
|
254
254
|
*/
|
|
255
255
|
sourceType?: Array<keyof sourceType>
|
|
256
256
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
@@ -292,17 +292,17 @@ declare module '../../index' {
|
|
|
292
292
|
interface Option {
|
|
293
293
|
/** 最多可以选择的文件个数
|
|
294
294
|
* @default 9
|
|
295
|
-
* @supported weapp
|
|
295
|
+
* @supported weapp
|
|
296
296
|
*/
|
|
297
297
|
count?: number
|
|
298
298
|
/** 文件类型
|
|
299
299
|
* @default ['image', 'video']
|
|
300
|
-
* @supported weapp
|
|
300
|
+
* @supported weapp
|
|
301
301
|
*/
|
|
302
302
|
mediaType?: Array<keyof mediaType>
|
|
303
303
|
/** 图片和视频选择的来源
|
|
304
304
|
* @default ['album', 'camera']
|
|
305
|
-
* @supported weapp
|
|
305
|
+
* @supported weapp
|
|
306
306
|
*/
|
|
307
307
|
sourceType?: Array<keyof sourceType>
|
|
308
308
|
/** 拍摄视频最长拍摄时间,单位秒。时间范围为 3s 至 60s 之间
|
|
@@ -317,7 +317,7 @@ declare module '../../index' {
|
|
|
317
317
|
sizeType?: Array<'original' | 'compressed'>
|
|
318
318
|
/** 仅在 sourceType 为 camera 时生效,使用前置或后置摄像头
|
|
319
319
|
* @default "back"
|
|
320
|
-
* @supported weapp
|
|
320
|
+
* @supported weapp
|
|
321
321
|
*/
|
|
322
322
|
camera?: string
|
|
323
323
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
@@ -327,7 +327,6 @@ declare module '../../index' {
|
|
|
327
327
|
/** 接口调用成功的回调函数 */
|
|
328
328
|
success?: (result: SuccessCallbackResult) => void
|
|
329
329
|
/** 用来上传的input元素ID
|
|
330
|
-
* @supported h5
|
|
331
330
|
*/
|
|
332
331
|
mediaId?: string
|
|
333
332
|
}
|
|
@@ -354,7 +353,6 @@ declare module '../../index' {
|
|
|
354
353
|
/** 选择的文件的类型 */
|
|
355
354
|
fileType: string
|
|
356
355
|
/** 原始的浏览器 File 对象
|
|
357
|
-
* @supported h5
|
|
358
356
|
*/
|
|
359
357
|
originalFileObj?: File
|
|
360
358
|
}
|
|
@@ -387,7 +385,7 @@ declare module '../../index' {
|
|
|
387
385
|
* **Bug & Tip:**
|
|
388
386
|
*
|
|
389
387
|
* 1. `tip`: camera 参数在部分 Android 手机下由于系统 ROM 不支持无法生效
|
|
390
|
-
* @supported weapp
|
|
388
|
+
* @supported weapp
|
|
391
389
|
* @example
|
|
392
390
|
```tsx
|
|
393
391
|
* Taro.saveVideoToPhotosAlbum({
|
|
@@ -414,7 +412,7 @@ declare module '../../index' {
|
|
|
414
412
|
openVideoEditor(option: openVideoEditor.Option): Promise<openVideoEditor.SuccessCallbackResult>
|
|
415
413
|
|
|
416
414
|
/** 获取视频详细信息
|
|
417
|
-
* @supported weapp
|
|
415
|
+
* @supported weapp
|
|
418
416
|
* @example
|
|
419
417
|
* ```tsx
|
|
420
418
|
* Taro.downloadFile({
|
|
@@ -442,7 +440,7 @@ declare module '../../index' {
|
|
|
442
440
|
getVideoInfo(option: getVideoInfo.Option): Promise<getVideoInfo.SuccessCallbackResult>
|
|
443
441
|
|
|
444
442
|
/** 创建 video 上下文 VideoContext 对象。
|
|
445
|
-
* @supported weapp
|
|
443
|
+
* @supported weapp
|
|
446
444
|
* @example
|
|
447
445
|
* ```tsx
|
|
448
446
|
* videoContext = Taro.createVideoContext('myVideo')
|
|
@@ -488,7 +486,7 @@ declare module '../../index' {
|
|
|
488
486
|
compressVideo(option: compressVideo.Option): Promise<compressVideo.SuccessCallbackResult>
|
|
489
487
|
|
|
490
488
|
/** 拍摄视频或从手机相册中选视频。
|
|
491
|
-
* @supported weapp
|
|
489
|
+
* @supported weapp
|
|
492
490
|
* @example
|
|
493
491
|
* ```tsx
|
|
494
492
|
* Taro.chooseVideo({
|
|
@@ -505,7 +503,7 @@ declare module '../../index' {
|
|
|
505
503
|
chooseVideo(option: chooseVideo.Option): Promise<chooseVideo.SuccessCallbackResult>
|
|
506
504
|
|
|
507
505
|
/** 拍摄或从手机相册中选择图片或视频。
|
|
508
|
-
* @supported weapp
|
|
506
|
+
* @supported weapp
|
|
509
507
|
* @example
|
|
510
508
|
* ```tsx
|
|
511
509
|
* Taro.chooseMedia({
|
|
@@ -241,7 +241,7 @@ declare module '../../index' {
|
|
|
241
241
|
* **关于调试**
|
|
242
242
|
* - 在开发者工具上调用此 API 并不会真实的跳转到另外的小程序,但是开发者工具会校验本次调用跳转是否成功。[详情](https://developers.weixin.qq.com/miniprogram/dev/devtools/different.html#跳转小程序调试支持)
|
|
243
243
|
* - 开发者工具上支持被跳转的小程序处理接收参数的调试。[详情](https://developers.weixin.qq.com/miniprogram/dev/devtools/different.html#跳转小程序调试支持)
|
|
244
|
-
* @supported weapp
|
|
244
|
+
* @supported weapp
|
|
245
245
|
* @example
|
|
246
246
|
* ```tsx
|
|
247
247
|
* Taro.navigateToMiniProgram({
|
|
@@ -263,7 +263,7 @@ declare module '../../index' {
|
|
|
263
263
|
/** 返回到上一个小程序。只有在当前小程序是被其他小程序打开时可以调用成功
|
|
264
264
|
*
|
|
265
265
|
* 注意:**微信客户端 iOS 6.5.9,Android 6.5.10 及以上版本支持**
|
|
266
|
-
* @supported weapp
|
|
266
|
+
* @supported weapp
|
|
267
267
|
* @example
|
|
268
268
|
* ```tsx
|
|
269
269
|
* Taro.navigateBackMiniProgram({
|
|
@@ -13,7 +13,6 @@ declare module '../../index' {
|
|
|
13
13
|
timeout?: number
|
|
14
14
|
/** 是否应使用传出凭据 (cookie) 发送此请求
|
|
15
15
|
* @default true
|
|
16
|
-
* @supported h5
|
|
17
16
|
*/
|
|
18
17
|
withCredentials?: boolean
|
|
19
18
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
@@ -85,7 +84,7 @@ declare module '../../index' {
|
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
/** 一个可以监听下载进度变化事件,以及取消下载任务的对象
|
|
88
|
-
* @supported weapp
|
|
87
|
+
* @supported weapp
|
|
89
88
|
* @example
|
|
90
89
|
* ```tsx
|
|
91
90
|
* const downloadTask = Taro.downloadFile({
|
|
@@ -109,12 +108,12 @@ declare module '../../index' {
|
|
|
109
108
|
*/
|
|
110
109
|
interface DownloadTask {
|
|
111
110
|
/** 中断下载任务
|
|
112
|
-
* @supported weapp
|
|
111
|
+
* @supported weapp
|
|
113
112
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.abort.html
|
|
114
113
|
*/
|
|
115
114
|
abort(): void
|
|
116
115
|
/** 监听下载进度变化事件
|
|
117
|
-
* @supported weapp
|
|
116
|
+
* @supported weapp
|
|
118
117
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.onProgressUpdate.html
|
|
119
118
|
*/
|
|
120
119
|
onProgressUpdate(
|
|
@@ -122,7 +121,7 @@ declare module '../../index' {
|
|
|
122
121
|
callback: DownloadTask.OnProgressUpdateCallback,
|
|
123
122
|
): void
|
|
124
123
|
/** 取消监听下载进度变化事件
|
|
125
|
-
* @supported weapp
|
|
124
|
+
* @supported weapp
|
|
126
125
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.offProgressUpdate.html
|
|
127
126
|
*/
|
|
128
127
|
offProgressUpdate(
|
|
@@ -130,7 +129,7 @@ declare module '../../index' {
|
|
|
130
129
|
callback: DownloadTask.OnProgressUpdateCallback,
|
|
131
130
|
): void
|
|
132
131
|
/** 监听 HTTP Response Header 事件。会比请求完成事件更早
|
|
133
|
-
* @supported weapp
|
|
132
|
+
* @supported weapp
|
|
134
133
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.onHeadersReceived.html
|
|
135
134
|
*/
|
|
136
135
|
onHeadersReceived(
|
|
@@ -138,7 +137,7 @@ declare module '../../index' {
|
|
|
138
137
|
callback: DownloadTask.OnHeadersReceivedCallback,
|
|
139
138
|
): void
|
|
140
139
|
/** 取消监听 HTTP Response Header 事件
|
|
141
|
-
* @supported weapp
|
|
140
|
+
* @supported weapp
|
|
142
141
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.offHeadersReceived.html
|
|
143
142
|
*/
|
|
144
143
|
offHeadersReceived(
|
|
@@ -151,7 +150,7 @@ declare module '../../index' {
|
|
|
151
150
|
/** 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径,单次下载允许的最大文件为 50MB。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。
|
|
152
151
|
*
|
|
153
152
|
* 注意:请在服务端响应的 header 中指定合理的 `Content-Type` 字段,以保证客户端正确处理文件类型。
|
|
154
|
-
* @supported weapp
|
|
153
|
+
* @supported weapp
|
|
155
154
|
* @example
|
|
156
155
|
* ```tsx
|
|
157
156
|
* Taro.downloadFile({
|
|
@@ -14,7 +14,7 @@ declare module '../../index' {
|
|
|
14
14
|
header?: TaroGeneral.IAnyObject
|
|
15
15
|
/** 超时时间,单位为毫秒
|
|
16
16
|
* @default 60000
|
|
17
|
-
* @supported weapp
|
|
17
|
+
* @supported weapp
|
|
18
18
|
*/
|
|
19
19
|
timeout?: number
|
|
20
20
|
/** HTTP 请求方法
|
|
@@ -42,7 +42,7 @@ declare module '../../index' {
|
|
|
42
42
|
enableQuic?: boolean
|
|
43
43
|
/** 开启 cache
|
|
44
44
|
* @default false
|
|
45
|
-
* @supported weapp
|
|
45
|
+
* @supported weapp
|
|
46
46
|
*/
|
|
47
47
|
enableCache?: boolean
|
|
48
48
|
/** 是否开启 HttpDNS 服务。如开启,需要同时填入 httpDNSServiceId 。 HttpDNS 用法详见 移动解析HttpDNS
|
|
@@ -68,13 +68,13 @@ declare module '../../index' {
|
|
|
68
68
|
/**
|
|
69
69
|
* headers 中设置 cookie 字段是否生效。如果为 false,则 headers 中的 cookie 字段将被忽略,请求头中将包含服务端上一次返回的 cookie(如果有)。
|
|
70
70
|
* @default false
|
|
71
|
-
* @supported
|
|
71
|
+
* @supported weapp
|
|
72
72
|
*/
|
|
73
73
|
enableCookie?: boolean
|
|
74
74
|
/**
|
|
75
75
|
* referer 策略,用于控制当前请求 header 对象中 referer 字段格式。该参数默认值可通过 app.json 中的配置进行修改。
|
|
76
76
|
* @default "querystring"
|
|
77
|
-
* @supported
|
|
77
|
+
* @supported weapp
|
|
78
78
|
* @see https://opendocs.alipay.com/mini/api/owycmh#referrerStrategy%20%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E
|
|
79
79
|
*/
|
|
80
80
|
referrerStrategy?: keyof ReferrerStrategy
|
|
@@ -86,66 +86,47 @@ declare module '../../index' {
|
|
|
86
86
|
complete?: (res: Partial<SuccessCallbackResult> & TaroGeneral.CallbackResult) => void
|
|
87
87
|
/** 设置是否使用 jsonp 方式获取数据
|
|
88
88
|
* @default false
|
|
89
|
-
* @supported h5
|
|
90
89
|
*/
|
|
91
90
|
jsonp?: boolean | string
|
|
92
91
|
/** 设置 jsonp 请求 url 是否需要被缓存
|
|
93
|
-
* @supported h5
|
|
94
92
|
*/
|
|
95
93
|
jsonpCache?: RequestCache
|
|
96
94
|
/** 设置是否允许跨域请求
|
|
97
95
|
* @default "same-origin"
|
|
98
|
-
* @supported h5
|
|
99
96
|
*/
|
|
100
97
|
mode?: keyof CorsMode
|
|
101
98
|
/** 设置是否携带 Cookie
|
|
102
99
|
* @default "omit"
|
|
103
|
-
* @supported h5
|
|
104
100
|
*/
|
|
105
101
|
credentials?: keyof Credentials
|
|
106
102
|
/** 设置缓存模式
|
|
107
103
|
* @default "default"
|
|
108
|
-
* @supported h5
|
|
109
104
|
*/
|
|
110
105
|
cache?: keyof Cache
|
|
111
106
|
/** 设置请求重试次数
|
|
112
107
|
* @default 2
|
|
113
|
-
* @supported h5
|
|
114
|
-
* @h5 仅在 jsonp 模式下生效
|
|
115
108
|
*/
|
|
116
109
|
retryTimes?: number
|
|
117
110
|
/** 设置请求的兜底接口
|
|
118
|
-
* @supported h5
|
|
119
|
-
* @h5 仅在 jsonp 模式下生效
|
|
120
111
|
*/
|
|
121
112
|
backup?: string | string[]
|
|
122
113
|
/** 设置请求中止信号
|
|
123
|
-
* @supported h5
|
|
124
114
|
*/
|
|
125
115
|
signal?: AbortSignal
|
|
126
116
|
/** 设置请求响应的数据校验函数,若返回 false,则请求兜底接口,若无兜底接口,则报请求失败
|
|
127
|
-
* @supported h5
|
|
128
|
-
* @h5 仅在 jsonp 模式下生效
|
|
129
117
|
*/
|
|
130
118
|
dataCheck?(): boolean
|
|
131
119
|
/** 设置请求是否使用缓存
|
|
132
120
|
* @default false
|
|
133
|
-
* @supported h5
|
|
134
|
-
* @h5 仅在 jsonp 模式下生效
|
|
135
121
|
*/
|
|
136
122
|
useStore?: boolean
|
|
137
123
|
/** 设置请求缓存校验的 key
|
|
138
|
-
* @supported h5
|
|
139
|
-
* @h5 仅在 jsonp 模式下生效
|
|
140
124
|
*/
|
|
141
125
|
storeCheckKey?: string
|
|
142
126
|
/** 设置请求缓存签名
|
|
143
|
-
* @supported h5
|
|
144
|
-
* @h5 仅在 jsonp 模式下生效
|
|
145
127
|
*/
|
|
146
128
|
storeSign?: string
|
|
147
129
|
/** 设置请求校验函数,一般不需要设置
|
|
148
|
-
* @supported h5
|
|
149
130
|
*/
|
|
150
131
|
storeCheck?(): boolean
|
|
151
132
|
}
|
|
@@ -173,17 +154,17 @@ declare module '../../index' {
|
|
|
173
154
|
json
|
|
174
155
|
/**
|
|
175
156
|
* 返回的数据为文本字符串
|
|
176
|
-
* @supported
|
|
157
|
+
* @supported weapp
|
|
177
158
|
*/
|
|
178
159
|
text
|
|
179
160
|
/**
|
|
180
161
|
* 返回的数据将转换为 base64 格式字符串
|
|
181
|
-
* @supported
|
|
162
|
+
* @supported weapp
|
|
182
163
|
*/
|
|
183
164
|
base64
|
|
184
165
|
/**
|
|
185
166
|
* 返回的数据将保持 ArrayBuffer 数据
|
|
186
|
-
* @supported
|
|
167
|
+
* @supported weapp
|
|
187
168
|
*/
|
|
188
169
|
arraybuffer
|
|
189
170
|
}
|
|
@@ -267,7 +248,7 @@ declare module '../../index' {
|
|
|
267
248
|
}
|
|
268
249
|
|
|
269
250
|
/** 网络请求任务对象
|
|
270
|
-
* @supported weapp
|
|
251
|
+
* @supported weapp
|
|
271
252
|
* @example
|
|
272
253
|
* 回调函数(Callback)用法:
|
|
273
254
|
*
|
|
@@ -321,12 +302,12 @@ declare module '../../index' {
|
|
|
321
302
|
*/
|
|
322
303
|
interface RequestTask<T> extends Promise<request.SuccessCallbackResult<T>> {
|
|
323
304
|
/** 中断请求任务
|
|
324
|
-
* @supported weapp
|
|
305
|
+
* @supported weapp
|
|
325
306
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/request/RequestTask.abort.html
|
|
326
307
|
*/
|
|
327
308
|
abort(): void
|
|
328
309
|
/** 监听 HTTP Response Header 事件。会比请求完成事件更早
|
|
329
|
-
* @supported weapp
|
|
310
|
+
* @supported weapp
|
|
330
311
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/request/RequestTask.onHeadersReceived.html
|
|
331
312
|
*/
|
|
332
313
|
onHeadersReceived(
|
|
@@ -334,7 +315,7 @@ declare module '../../index' {
|
|
|
334
315
|
callback: RequestTask.onHeadersReceived.Callback
|
|
335
316
|
): void
|
|
336
317
|
/** 取消监听 HTTP Response Header 事件
|
|
337
|
-
* @supported weapp
|
|
318
|
+
* @supported weapp
|
|
338
319
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/request/RequestTask.offHeadersReceived.html
|
|
339
320
|
*/
|
|
340
321
|
offHeadersReceived(
|
|
@@ -405,7 +386,7 @@ declare module '../../index' {
|
|
|
405
386
|
* - 对于 `GET` 方法的数据,会将数据转换成 query string(`encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...`)
|
|
406
387
|
* - 对于 `POST` 方法且 `header['content-type']` 为 `application/json` 的数据,会对数据进行 JSON 序列化
|
|
407
388
|
* - 对于 `POST` 方法且 `header['content-type']` 为 `application/x-www-form-urlencoded` 的数据,会将数据转换成 query string `(encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...)`
|
|
408
|
-
* @supported weapp
|
|
389
|
+
* @supported weapp
|
|
409
390
|
* @example
|
|
410
391
|
* ```tsx
|
|
411
392
|
* Taro.request({
|
|
@@ -438,7 +419,7 @@ declare module '../../index' {
|
|
|
438
419
|
* 拦截器是一个函数,接受 chain 对象作为参数。chain 对象中含有 **requestParmas** 属性,代表请求参数。拦截器内最后需要调用 `chain.proceed(requestParams)` 以调用下一个拦截器或发起请求。
|
|
439
420
|
*
|
|
440
421
|
* Taro 提供了两个内置拦截器 `logInterceptor` 与 `timeoutInterceptor`,分别用于打印请求的相关信息和在请求超时时抛出错误。
|
|
441
|
-
* @supported weapp
|
|
422
|
+
* @supported weapp
|
|
442
423
|
* @example
|
|
443
424
|
* ```tsx
|
|
444
425
|
* const interceptor = function (chain) {
|
|
@@ -471,7 +452,7 @@ declare module '../../index' {
|
|
|
471
452
|
* ```tsx
|
|
472
453
|
* Taro.cleanInterceptors()
|
|
473
454
|
* ```
|
|
474
|
-
* @supported weapp
|
|
455
|
+
* @supported weapp
|
|
475
456
|
*/
|
|
476
457
|
cleanInterceptors(): void
|
|
477
458
|
|
|
@@ -16,12 +16,10 @@ declare module '../../index' {
|
|
|
16
16
|
/** 超时时间,单位为毫秒 */
|
|
17
17
|
timeout?: number
|
|
18
18
|
/** 上传的文件名
|
|
19
|
-
* @supported h5
|
|
20
19
|
*/
|
|
21
20
|
fileName?: string
|
|
22
21
|
/** 是否应使用传出凭据 (cookie) 发送此请求
|
|
23
22
|
* @default true
|
|
24
|
-
* @supported h5
|
|
25
23
|
*/
|
|
26
24
|
withCredentials?: boolean
|
|
27
25
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
@@ -84,7 +82,7 @@ declare module '../../index' {
|
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
/** 一个可以监听上传进度变化事件,以及取消上传任务的对象
|
|
87
|
-
* @supported weapp
|
|
85
|
+
* @supported weapp
|
|
88
86
|
* @example
|
|
89
87
|
* ```tsx
|
|
90
88
|
* const uploadTask = Taro.uploadFile({
|
|
@@ -112,12 +110,12 @@ declare module '../../index' {
|
|
|
112
110
|
*/
|
|
113
111
|
interface UploadTask {
|
|
114
112
|
/** 中断上传任务
|
|
115
|
-
* @supported weapp
|
|
113
|
+
* @supported weapp
|
|
116
114
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.abort.html
|
|
117
115
|
*/
|
|
118
116
|
abort(): void
|
|
119
117
|
/** 监听上传进度变化事件
|
|
120
|
-
* @supported weapp
|
|
118
|
+
* @supported weapp
|
|
121
119
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.onProgressUpdate.html
|
|
122
120
|
*/
|
|
123
121
|
onProgressUpdate(
|
|
@@ -125,7 +123,7 @@ declare module '../../index' {
|
|
|
125
123
|
callback: UploadTask.OnProgressUpdateCallback,
|
|
126
124
|
): void
|
|
127
125
|
/** 取消监听上传进度变化事件
|
|
128
|
-
* @supported weapp
|
|
126
|
+
* @supported weapp
|
|
129
127
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.offProgressUpdate.html
|
|
130
128
|
*/
|
|
131
129
|
offProgressUpdate(
|
|
@@ -133,7 +131,7 @@ declare module '../../index' {
|
|
|
133
131
|
callback: UploadTask.OnProgressUpdateCallback,
|
|
134
132
|
): void
|
|
135
133
|
/** 监听 HTTP Response Header 事件。会比请求完成事件更早
|
|
136
|
-
* @supported weapp
|
|
134
|
+
* @supported weapp
|
|
137
135
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.onHeadersReceived.html
|
|
138
136
|
*/
|
|
139
137
|
onHeadersReceived(
|
|
@@ -141,7 +139,7 @@ declare module '../../index' {
|
|
|
141
139
|
callback: UploadTask.OnHeadersReceivedCallback,
|
|
142
140
|
): void
|
|
143
141
|
/** 取消监听 HTTP Response Header 事件
|
|
144
|
-
* @supported weapp
|
|
142
|
+
* @supported weapp
|
|
145
143
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.offHeadersReceived.html
|
|
146
144
|
*/
|
|
147
145
|
offHeadersReceived(
|
|
@@ -152,7 +150,7 @@ declare module '../../index' {
|
|
|
152
150
|
|
|
153
151
|
interface TaroStatic {
|
|
154
152
|
/** 将本地资源上传到服务器。客户端发起一个 HTTPS POST 请求,其中 `content-type` 为 `multipart/form-data`。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。
|
|
155
|
-
* @supported weapp
|
|
153
|
+
* @supported weapp
|
|
156
154
|
* @example
|
|
157
155
|
* ```tsx
|
|
158
156
|
* Taro.chooseImage({
|
|
@@ -138,22 +138,22 @@ declare module '../../index' {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
/** WebSocket 任务,可通过 [Taro.connectSocket()](/docs/apis/network/websocket/SocketTask) 接口创建返回。
|
|
141
|
-
* @supported weapp
|
|
141
|
+
* @supported weapp
|
|
142
142
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.html
|
|
143
143
|
*/
|
|
144
144
|
interface SocketTask {
|
|
145
145
|
/** 通过 WebSocket 连接发送数据
|
|
146
|
-
* @supported weapp
|
|
146
|
+
* @supported weapp
|
|
147
147
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.send.html
|
|
148
148
|
*/
|
|
149
149
|
send(option: SocketTask.SendOption): void
|
|
150
150
|
/** 关闭 WebSocket 连接
|
|
151
|
-
* @supported weapp
|
|
151
|
+
* @supported weapp
|
|
152
152
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.close.html
|
|
153
153
|
*/
|
|
154
154
|
close(option: SocketTask.CloseOption): void
|
|
155
155
|
/** 监听 WebSocket 连接打开事件
|
|
156
|
-
* @supported weapp
|
|
156
|
+
* @supported weapp
|
|
157
157
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.onOpen.html
|
|
158
158
|
*/
|
|
159
159
|
onOpen(
|
|
@@ -161,7 +161,7 @@ declare module '../../index' {
|
|
|
161
161
|
callback: SocketTask.OnOpenCallback
|
|
162
162
|
): void
|
|
163
163
|
/** 监听 WebSocket 连接关闭事件
|
|
164
|
-
* @supported weapp
|
|
164
|
+
* @supported weapp
|
|
165
165
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.onClose.html
|
|
166
166
|
*/
|
|
167
167
|
onClose(
|
|
@@ -169,7 +169,7 @@ declare module '../../index' {
|
|
|
169
169
|
callback: SocketTask.OnCloseCallback
|
|
170
170
|
): void
|
|
171
171
|
/** 监听 WebSocket 错误事件
|
|
172
|
-
* @supported weapp
|
|
172
|
+
* @supported weapp
|
|
173
173
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.onError.html
|
|
174
174
|
*/
|
|
175
175
|
onError(
|
|
@@ -177,7 +177,7 @@ declare module '../../index' {
|
|
|
177
177
|
callback: SocketTask.OnErrorCallback
|
|
178
178
|
): void
|
|
179
179
|
/** 监听 WebSocket 接受到服务器的消息事件
|
|
180
|
-
* @supported weapp
|
|
180
|
+
* @supported weapp
|
|
181
181
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.onMessage.html
|
|
182
182
|
*/
|
|
183
183
|
onMessage<T = any>(
|
|
@@ -205,7 +205,7 @@ declare module '../../index' {
|
|
|
205
205
|
|
|
206
206
|
interface TaroStatic {
|
|
207
207
|
/** 通过 WebSocket 连接发送数据。需要先 Taro.connectSocket,并在 Taro.onSocketOpen 回调之后才能发送。
|
|
208
|
-
* @supported weapp
|
|
208
|
+
* @supported weapp
|
|
209
209
|
* @example
|
|
210
210
|
* ```tsx
|
|
211
211
|
* let socketOpen = false
|
|
@@ -235,7 +235,7 @@ declare module '../../index' {
|
|
|
235
235
|
sendSocketMessage(option: sendSocketMessage.Option): Promise<TaroGeneral.CallbackResult>
|
|
236
236
|
|
|
237
237
|
/** 监听 WebSocket 连接打开事件
|
|
238
|
-
* @supported weapp
|
|
238
|
+
* @supported weapp
|
|
239
239
|
* @example
|
|
240
240
|
* ```tsx
|
|
241
241
|
* Taro.connectSocket({
|
|
@@ -253,7 +253,7 @@ declare module '../../index' {
|
|
|
253
253
|
): void
|
|
254
254
|
|
|
255
255
|
/** 监听 WebSocket 接受到服务器的消息事件
|
|
256
|
-
* @supported weapp
|
|
256
|
+
* @supported weapp
|
|
257
257
|
* @example
|
|
258
258
|
* ```tsx
|
|
259
259
|
* Taro.connectSocket({
|
|
@@ -271,7 +271,7 @@ declare module '../../index' {
|
|
|
271
271
|
): void
|
|
272
272
|
|
|
273
273
|
/** 监听 WebSocket 错误事件
|
|
274
|
-
* @supported weapp
|
|
274
|
+
* @supported weapp
|
|
275
275
|
* @example
|
|
276
276
|
* ```tsx
|
|
277
277
|
* Taro.connectSocket({
|
|
@@ -292,7 +292,7 @@ declare module '../../index' {
|
|
|
292
292
|
): void
|
|
293
293
|
|
|
294
294
|
/** 监听 WebSocket 连接关闭事件
|
|
295
|
-
* @supported weapp
|
|
295
|
+
* @supported weapp
|
|
296
296
|
* @example
|
|
297
297
|
* ```tsx
|
|
298
298
|
* Taro.connectSocket({
|
|
@@ -320,7 +320,7 @@ declare module '../../index' {
|
|
|
320
320
|
* **并发数**
|
|
321
321
|
* - 1.7.0 及以上版本,最多可以同时存在 5 个 WebSocket 连接。
|
|
322
322
|
* - 1.7.0 以下版本,一个小程序同时只能有一个 WebSocket 连接,如果当前已存在一个 WebSocket 连接,会自动关闭该连接,并重新创建一个 WebSocket 连接。
|
|
323
|
-
* @supported weapp
|
|
323
|
+
* @supported weapp
|
|
324
324
|
* @example
|
|
325
325
|
* ```tsx
|
|
326
326
|
* Taro.connectSocket({
|
|
@@ -360,7 +360,7 @@ declare module '../../index' {
|
|
|
360
360
|
connectSocket(option: connectSocket.Option): Promise<SocketTask>
|
|
361
361
|
|
|
362
362
|
/** 关闭 WebSocket 连接
|
|
363
|
-
* @supported weapp
|
|
363
|
+
* @supported weapp
|
|
364
364
|
* @example
|
|
365
365
|
* ```tsx
|
|
366
366
|
* Taro.connectSocket({
|
|
@@ -15,7 +15,7 @@ declare module '../../index' {
|
|
|
15
15
|
/** 收货人姓名 */
|
|
16
16
|
userName: string
|
|
17
17
|
/** 邮编
|
|
18
|
-
* @supported weapp
|
|
18
|
+
* @supported weapp
|
|
19
19
|
*/
|
|
20
20
|
postalCode: string
|
|
21
21
|
/** 国标收货地址第一级地址 */
|
|
@@ -25,17 +25,17 @@ declare module '../../index' {
|
|
|
25
25
|
/** 国标收货地址第三级地址 */
|
|
26
26
|
countyName: string
|
|
27
27
|
/** 国标收货地址第四级地址
|
|
28
|
-
* @supported weapp
|
|
28
|
+
* @supported weapp
|
|
29
29
|
*/
|
|
30
30
|
streetName: string
|
|
31
31
|
/** 详细收货地址信息 */
|
|
32
32
|
detailInfo: string
|
|
33
33
|
/** 新选择器详细收货地址信息
|
|
34
|
-
* @supported weapp
|
|
34
|
+
* @supported weapp
|
|
35
35
|
*/
|
|
36
36
|
detailInfoNew: string
|
|
37
37
|
/** 收货地址国家码
|
|
38
|
-
* @supported weapp
|
|
38
|
+
* @supported weapp
|
|
39
39
|
*/
|
|
40
40
|
nationalCode: string
|
|
41
41
|
/** 收货人手机号码 */
|
|
@@ -45,7 +45,7 @@ declare module '../../index' {
|
|
|
45
45
|
|
|
46
46
|
interface TaroStatic {
|
|
47
47
|
/** 获取用户收货地址。调起用户编辑收货地址原生界面,并在编辑完成后返回用户选择的地址。
|
|
48
|
-
* @supported weapp
|
|
48
|
+
* @supported weapp
|
|
49
49
|
* @example
|
|
50
50
|
* ```tsx
|
|
51
51
|
* Taro.chooseAddress({
|
|
@@ -55,7 +55,7 @@ declare module '../../index' {
|
|
|
55
55
|
authorizeForMiniProgram(option: authorizeForMiniProgram.Option): Promise<TaroGeneral.CallbackResult>
|
|
56
56
|
|
|
57
57
|
/** 提前向用户发起授权请求。调用后会立刻弹窗询问用户是否同意授权小程序使用某项功能或获取用户的某些数据,但不会实际调用对应接口。如果用户之前已经同意授权,则不会出现弹窗,直接返回成功。更多用法详见 [用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html)。
|
|
58
|
-
* @supported weapp
|
|
58
|
+
* @supported weapp
|
|
59
59
|
* @example
|
|
60
60
|
* ```tsx
|
|
61
61
|
* // 可以通过 Taro.getSetting 先查询一下用户是否授权了 "scope.record" 这个 scope
|