@tarojs/taro 3.3.16 → 3.3.20

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/package.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "@tarojs/taro",
3
- "version": "3.3.16",
3
+ "version": "3.3.20",
4
4
  "description": "Taro framework",
5
5
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
6
6
  "main": "index.js",
7
- "main:h5": "h5.js",
8
7
  "typings": "types/index.d.ts",
9
8
  "files": [
10
9
  "index.js",
11
- "h5.js",
12
10
  "types",
13
11
  "html.css",
14
12
  "html5.css"
@@ -26,9 +24,9 @@
26
24
  "author": "O2Team",
27
25
  "license": "MIT",
28
26
  "dependencies": {
29
- "@tarojs/api": "3.3.16",
30
- "@tarojs/runtime": "3.3.16",
31
- "@tarojs/taro-h5": "3.3.16"
27
+ "@tarojs/api": "3.3.20",
28
+ "@tarojs/runtime": "3.3.20",
29
+ "@tarojs/taro-h5": "3.3.20"
32
30
  },
33
- "gitHead": "75d3de695c98fab79998612ef87567a68ea981a7"
31
+ "gitHead": "f98ceefaa3e419db5a6c3bcd3bf123ce5a0a0124"
34
32
  }
@@ -69,7 +69,7 @@ declare module '../../../index' {
69
69
  * - 开发者可以在回调中进行页面重定向,但必须在回调中**同步**处理,异步处理(例如 `setTimeout` 异步执行)无效。
70
70
  * - 若开发者没有调用 [Taro.onPageNotFound](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onPageNotFound.html) 绑定监听,也没有声明 `App.onPageNotFound`,当跳转页面不存在时,将推入微信客户端原生的页面不存在提示页面。
71
71
  * - 如果回调中又重定向到另一个不存在的页面,将推入微信客户端原生的页面不存在提示页面,并且不再第二次回调。
72
- * @supported weapp
72
+ * @supported weapp, h5
73
73
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onPageNotFound.html
74
74
  */
75
75
  onPageNotFound(callback: onPageNotFound.Callback): void
@@ -130,7 +130,7 @@ declare module '../../../index' {
130
130
  */
131
131
  onAppHide(
132
132
  /** 小程序切后台事件的回调函数 */
133
- callback: (res: TaroGeneral.CallbackResult) => void,
133
+ callback: (res: onAppShow.CallbackResult) => void,
134
134
  ): void
135
135
 
136
136
  /** 取消监听小程序要打开的页面不存在事件
@@ -139,7 +139,7 @@ declare module '../../../index' {
139
139
  */
140
140
  offPageNotFound(
141
141
  /** 小程序要打开的页面不存在事件的回调函数 */
142
- callback: (res: TaroGeneral.CallbackResult) => void,
142
+ callback: (res: onPageNotFound.Callback) => void,
143
143
  ): void
144
144
 
145
145
  /** 取消监听音频播放错误事件
@@ -149,7 +149,7 @@ declare module '../../../index' {
149
149
 
150
150
  offError(
151
151
  /** 音频播放错误事件的回调函数 */
152
- callback: (res: TaroGeneral.CallbackResult) => void,
152
+ callback: (res: onError.Callback) => void,
153
153
  ): void
154
154
 
155
155
  /** 取消监听音频中断结束事件
@@ -1374,7 +1374,7 @@ declare module '../../index' {
1374
1374
  /** 阴影的模糊级别 */
1375
1375
  shadowBlur: number
1376
1376
  /** 阴影的颜色 */
1377
- shadowColor: number
1377
+ shadowColor: string
1378
1378
  /** 阴影相对于形状在水平方向的偏移 */
1379
1379
  shadowOffsetX: number
1380
1380
  /** 阴影相对于形状在竖直方向的偏移 */
@@ -1698,6 +1698,27 @@ declare module '../../index' {
1698
1698
  *
1699
1699
  * **Tip**: 需要指定 canvasId,该绘图上下文只作用于对应的 `<canvas/>`
1700
1700
  * @supported weapp, h5
1701
+ * @example
1702
+ * ```tsx
1703
+ * const context = Taro.createCanvasContext('canvas')
1704
+ *
1705
+ * context.setStrokeStyle("#00ff00")
1706
+ * context.setLineWidth(5)
1707
+ * context.rect(0, 0, 200, 200)
1708
+ * context.stroke()
1709
+ * context.setStrokeStyle("#ff0000")
1710
+ * context.setLineWidth(2)
1711
+ * context.moveTo(160, 100)
1712
+ * context.arc(100, 100, 60, 0, 2 * Math.PI, true)
1713
+ * context.moveTo(140, 100)
1714
+ * context.arc(100, 100, 40, 0, Math.PI, false)
1715
+ * context.moveTo(85, 80)
1716
+ * context.arc(80, 80, 5, 0, 2 * Math.PI, true)
1717
+ * context.moveTo(125, 80)
1718
+ * context.arc(120, 80, 5, 0, 2 * Math.PI, true)
1719
+ * context.stroke()
1720
+ * context.draw()
1721
+ * ```
1701
1722
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createCanvasContext.html
1702
1723
  */
1703
1724
  createCanvasContext(
@@ -94,7 +94,7 @@ declare module '../../index' {
94
94
  ): void
95
95
 
96
96
  /** 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。
97
- * @supported weapp
97
+ * @supported weapp, h5
98
98
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/compass/wx.offCompassChange.html
99
99
  */
100
100
  offCompassChange(
@@ -122,6 +122,8 @@ declare module '../../index' {
122
122
  sourceType?: Array<keyof sourceType>
123
123
  /** 接口调用成功的回调函数 */
124
124
  success?: (result: SuccessCallbackResult) => void
125
+ /** 用来上传的input元素ID(仅h5端)@supported h5 */
126
+ imageId?: string
125
127
  }
126
128
  /** 图片的尺寸 */
127
129
  interface sizeType {
@@ -241,66 +243,6 @@ declare module '../../index' {
241
243
  }
242
244
  }
243
245
 
244
- namespace chooseMedia {
245
- interface Option {
246
- /** 最多可以选择的文件个数 */
247
- count?: number
248
- /** 文件类型 */
249
- mediaType?: Array<keyof mediaType>
250
- /** 图片和视频选择的来源 */
251
- sourceType?: Array<keyof sourceType>
252
- /** 拍摄视频最长拍摄时间,单位秒。时间范围为 3s 至 30s 之间 */
253
- maxDuration?: number
254
- /** 仅对 mediaType 为 image 时有效,是否压缩所选文件 */
255
- sizeType?: Array<'original' | 'compressed'>
256
- /** 仅在 sourceType 为 camera 时生效,使用前置或后置摄像头 */
257
- camera?: string
258
- /** 接口调用失败的回调函数 */
259
- fail?: (res: TaroGeneral.CallbackResult) => void
260
- /** 接口调用成功的回调函数 */
261
- success?: (result: SuccessCallbackResult) => void
262
- }
263
- interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
264
- /** 本地临时文件列表 */
265
- tempFiles: ChooseMedia[]
266
- /** 文件类型,有效值有 image 、video */
267
- type: string
268
- }
269
- /** 本地临时文件列表 */
270
- interface ChooseMedia {
271
- /** 本地临时文件路径 (本地路径) */
272
- tempFilePath: string
273
- /** 本地临时文件大小,单位 B */
274
- size: number
275
- /** 视频的时间长度 */
276
- duration: number
277
- /** 视频的高度 */
278
- height: number
279
- /** 视频的宽度 */
280
- width: number
281
- /** 视频缩略图临时文件路径 */
282
- thumbTempFilePath: string
283
- }
284
- interface mediaType {
285
- /** 只能拍摄视频或从相册选择视频 */
286
- video
287
- /** 只能拍摄图片或从相册选择图片 */
288
- image
289
- }
290
- interface sourceType {
291
- /** 从相册选择 */
292
- album
293
- /** 使用相机拍摄 */
294
- camera
295
- }
296
- interface camera {
297
- /** 使用后置摄像头 */
298
- back
299
- /** 使用前置摄像头 */
300
- front
301
- }
302
- }
303
-
304
246
  interface TaroStatic {
305
247
  /** 保存图片到系统相册。需要[用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.writePhotosAlbum
306
248
  * @supported weapp, rn, alipay, swan
@@ -414,25 +356,5 @@ declare module '../../index' {
414
356
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html
415
357
  */
416
358
  chooseMessageFile(option: chooseMessageFile.Option): Promise<chooseMessageFile.SuccessCallbackResult>
417
-
418
- /** 拍摄或从手机相册中选择图片或视频。
419
- * @supported weapp, rn
420
- * @example
421
- * ```tsx
422
- * Taro.chooseMedia({
423
- * count: 9,
424
- * mediaType: ['image','video'],
425
- * sourceType: ['album', 'camera'],
426
- * maxDuration: 30,
427
- * camera: 'back',
428
- * success: (res) => {
429
- * console.log(res.tempFiles)
430
- * console.log(res.type)
431
- * }
432
- * })
433
- * ```
434
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html
435
- */
436
- chooseMedia(option: chooseMedia.Option): Promise<chooseMedia.SuccessCallbackResult>
437
359
  }
438
360
  }
@@ -14,48 +14,75 @@ declare module '../../index' {
14
14
  }
15
15
  }
16
16
 
17
- namespace chooseVideo {
17
+ namespace openVideoEditor {
18
18
  interface Option {
19
- /** 默认拉起的是前置或者后置摄像头。部分 Android 手机下由于系统 ROM 不支持无法生效 */
20
- camera?: keyof camera
21
- /** 接口调用结束的回调函数(调用成功、失败都会执行) */
22
- complete?: (res: TaroGeneral.CallbackResult) => void
23
- /** 是否压缩所选择的视频文件 */
24
- compressed?: boolean
19
+ /** 视频源的路径,只支持本地路径 */
20
+ filePath: string
21
+ /** 接口调用成功的回调函数 */
22
+ success?: (result: SuccessCallbackResult) => void
25
23
  /** 接口调用失败的回调函数 */
26
24
  fail?: (res: TaroGeneral.CallbackResult) => void
27
- /** 拍摄视频最长拍摄时间,单位秒 */
28
- maxDuration?: number
29
- /** 视频选择的来源 */
30
- sourceType?: Array<keyof sourceType>
25
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
26
+ complete?: (res: TaroGeneral.CallbackResult) => void
27
+ }
28
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
29
+ /** 剪辑后生成的视频文件的时长,单位毫秒(ms) */
30
+ duration: number
31
+ /** 剪辑后生成的视频文件大小,单位字节数(byte) */
32
+ size: number
33
+ /** 编辑后生成的视频文件的临时路径 */
34
+ tempFilePath: string
35
+ /** 编辑后生成的缩略图文件的临时路径 */
36
+ tempThumbPath: string
37
+ }
38
+ }
39
+
40
+ namespace getVideoInfo {
41
+ interface Option {
42
+ /** 视频文件路径,可以是临时文件路径也可以是永久文件路径 */
43
+ src: string
31
44
  /** 接口调用成功的回调函数 */
32
45
  success?: (result: SuccessCallbackResult) => void
46
+ /** 接口调用失败的回调函数 */
47
+ fail?: (res: TaroGeneral.CallbackResult) => void
48
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
49
+ complete?: (res: TaroGeneral.CallbackResult) => void
33
50
  }
34
51
  interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
35
- /** 选定视频的时间长度 */
52
+ /** 画面方向 */
53
+ orientation: keyof orientation
54
+ /** 视频格式 */
55
+ type: string
56
+ /** 视频长度 */
36
57
  duration: number
37
- /** 返回选定视频的高度 */
38
- height: number
39
- /** 选定视频的数据量大小 */
58
+ /** 视频大小,单位 kB */
40
59
  size: number
41
- /** 选定视频的临时文件路径 */
42
- tempFilePath: string
43
- /** 返回选定视频的宽度 */
60
+ /** 视频的长,单位 px */
61
+ height: number
62
+ /** 视频的宽,单位 px */
44
63
  width: number
45
- /** 调用结果 */
46
- errMsg: string
47
- }
48
- interface camera {
49
- /** 默认拉起后置摄像头 */
50
- back
51
- /** 默认拉起前置摄像头 */
52
- front
64
+ /** 视频帧率 */
65
+ fps: number
66
+ /** 视频码率,单位 kbps */
67
+ bitrate: number
53
68
  }
54
- interface sourceType {
55
- /** 从相册选择视频 */
56
- album
57
- /** 使用相机拍摄视频 */
58
- camera
69
+ interface orientation {
70
+ /** 默认 */
71
+ up
72
+ /** 180 度旋转 */
73
+ down
74
+ /** 逆时针旋转 90 度 */
75
+ left
76
+ /** 顺时针旋转 90 度 */
77
+ right
78
+ /** 同 up,但水平翻转 */
79
+ 'up-mirrored'
80
+ /** 同 down,但水平翻转 */
81
+ 'down-mirrored'
82
+ /** 同 left,但垂直翻转 */
83
+ 'left-mirrored'
84
+ /** 同 right,但垂直翻转 */
85
+ 'right-mirrored'
59
86
  }
60
87
  }
61
88
 
@@ -140,6 +167,147 @@ declare module '../../index' {
140
167
  }
141
168
  }
142
169
 
170
+ namespace compressVideo {
171
+ interface Option {
172
+ /** 视频文件路径,可以是临时文件路径也可以是永久文件路径 */
173
+ src: string
174
+ /** 压缩质量 */
175
+ quality: keyof quality
176
+ /** 码率,单位 kbps */
177
+ bitrate: number
178
+ /** 帧率 */
179
+ fps: number
180
+ /** 相对于原视频的分辨率比例,取值范围(0, 1] */
181
+ resolution: number
182
+ /** 接口调用成功的回调函数 */
183
+ success?: (result: SuccessCallbackResult) => void
184
+ /** 接口调用失败的回调函数 */
185
+ fail?: (res: TaroGeneral.CallbackResult) => void
186
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
187
+ complete?: (res: TaroGeneral.CallbackResult) => void
188
+ }
189
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
190
+ /** 压缩后的临时文件地址 */
191
+ tempFilePath: string
192
+ /** 压缩后的大小,单位 kB */
193
+ size: number
194
+ }
195
+ interface quality {
196
+ /** 低 */
197
+ low
198
+ /** 中 */
199
+ medium
200
+ /** 高 */
201
+ high
202
+ }
203
+ }
204
+
205
+ namespace chooseVideo {
206
+ interface Option {
207
+ /** 默认拉起的是前置或者后置摄像头。部分 Android 手机下由于系统 ROM 不支持无法生效 */
208
+ camera?: keyof camera
209
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
210
+ complete?: (res: TaroGeneral.CallbackResult) => void
211
+ /** 是否压缩所选择的视频文件 */
212
+ compressed?: boolean
213
+ /** 接口调用失败的回调函数 */
214
+ fail?: (res: TaroGeneral.CallbackResult) => void
215
+ /** 拍摄视频最长拍摄时间,单位秒 */
216
+ maxDuration?: number
217
+ /** 视频选择的来源 */
218
+ sourceType?: Array<keyof sourceType>
219
+ /** 接口调用成功的回调函数 */
220
+ success?: (result: SuccessCallbackResult) => void
221
+ }
222
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
223
+ /** 选定视频的时间长度 */
224
+ duration: number
225
+ /** 返回选定视频的高度 */
226
+ height: number
227
+ /** 选定视频的数据量大小 */
228
+ size: number
229
+ /** 选定视频的临时文件路径 */
230
+ tempFilePath: string
231
+ /** 返回选定视频的宽度 */
232
+ width: number
233
+ /** 调用结果 */
234
+ errMsg: string
235
+ }
236
+ interface camera {
237
+ /** 默认拉起后置摄像头 */
238
+ back
239
+ /** 默认拉起前置摄像头 */
240
+ front
241
+ }
242
+ interface sourceType {
243
+ /** 从相册选择视频 */
244
+ album
245
+ /** 使用相机拍摄视频 */
246
+ camera
247
+ }
248
+ }
249
+
250
+
251
+ namespace chooseMedia {
252
+ interface Option {
253
+ /** 最多可以选择的文件个数 */
254
+ count?: number
255
+ /** 文件类型 */
256
+ mediaType?: Array<keyof mediaType>
257
+ /** 图片和视频选择的来源 */
258
+ sourceType?: Array<keyof sourceType>
259
+ /** 拍摄视频最长拍摄时间,单位秒。时间范围为 3s 至 30s 之间 */
260
+ maxDuration?: number
261
+ /** 仅对 mediaType 为 image 时有效,是否压缩所选文件 */
262
+ sizeType?: Array<'original' | 'compressed'>
263
+ /** 仅在 sourceType 为 camera 时生效,使用前置或后置摄像头 */
264
+ camera?: string
265
+ /** 接口调用失败的回调函数 */
266
+ fail?: (res: TaroGeneral.CallbackResult) => void
267
+ /** 接口调用成功的回调函数 */
268
+ success?: (result: SuccessCallbackResult) => void
269
+ }
270
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
271
+ /** 本地临时文件列表 */
272
+ tempFiles: ChooseMedia[]
273
+ /** 文件类型,有效值有 image 、video */
274
+ type: string
275
+ }
276
+ /** 本地临时文件列表 */
277
+ interface ChooseMedia {
278
+ /** 本地临时文件路径 (本地路径) */
279
+ tempFilePath: string
280
+ /** 本地临时文件大小,单位 B */
281
+ size: number
282
+ /** 视频的时间长度 */
283
+ duration: number
284
+ /** 视频的高度 */
285
+ height: number
286
+ /** 视频的宽度 */
287
+ width: number
288
+ /** 视频缩略图临时文件路径 */
289
+ thumbTempFilePath: string
290
+ }
291
+ interface mediaType {
292
+ /** 只能拍摄视频或从相册选择视频 */
293
+ video
294
+ /** 只能拍摄图片或从相册选择图片 */
295
+ image
296
+ }
297
+ interface sourceType {
298
+ /** 从相册选择 */
299
+ album
300
+ /** 使用相机拍摄 */
301
+ camera
302
+ }
303
+ interface camera {
304
+ /** 使用后置摄像头 */
305
+ back
306
+ /** 使用前置摄像头 */
307
+ front
308
+ }
309
+ }
310
+
143
311
  interface TaroStatic {
144
312
  /**
145
313
  * 保存视频到系统相册。支持mp4视频格式。需要[用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.writePhotosAlbum
@@ -161,6 +329,46 @@ declare module '../../index' {
161
329
  */
162
330
  saveVideoToPhotosAlbum(option: saveVideoToPhotosAlbum.Option): Promise<TaroGeneral.CallbackResult>
163
331
 
332
+ /** 打开视频编辑器
333
+ * @supported weapp
334
+ * @example
335
+ * ```tsx
336
+ * Taro.openVideoEditor({
337
+ * filePath: ''
338
+ * })
339
+ * ```
340
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.openVideoEditor.html
341
+ */
342
+ openVideoEditor(option: openVideoEditor.Option): Promise<openVideoEditor.SuccessCallbackResult>
343
+
344
+ /** 获取视频详细信息
345
+ * @supported weapp
346
+ * @example
347
+ * ```tsx
348
+ * Taro.downloadFile({
349
+ * url: 'https://mock.taro.org/mock_video.mp4',
350
+ * success(res) {
351
+ * Taro.getVideoInfo({
352
+ * src: res.tempFilePath,
353
+ * success (res) {
354
+ * console.log('获取文件地址成功')
355
+ * console.log(res)
356
+ * },
357
+ * fail (res) {
358
+ * console.log('获取文件地址失败')
359
+ * console.log(res)
360
+ * },
361
+ * complete (res) {
362
+ * console.log('获取文件地址')
363
+ * }
364
+ * })
365
+ * }
366
+ * })
367
+ * ```
368
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.getVideoInfo.html
369
+ */
370
+ getVideoInfo(option: getVideoInfo.Option): Promise<getVideoInfo.SuccessCallbackResult>
371
+
164
372
  /** 创建 video 上下文 VideoContext 对象。
165
373
  * @supported weapp, h5
166
374
  * @example
@@ -176,6 +384,37 @@ declare module '../../index' {
176
384
  component?: TaroGeneral.IAnyObject,
177
385
  ): VideoContext
178
386
 
387
+ /** 压缩视频接口。
388
+ * 开发者可指定压缩质量 `quality` 进行压缩。当需要更精细的控制时,可指定 `bitrate`、`fps`、和 `resolution`,当 `quality` 传入时,这三个参数将被忽略。原视频的相关信息可通过 [getVideoInfo](https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.getVideoInfo.html) 获取。
389
+ * @supported weapp
390
+ * @example
391
+ * ```tsx
392
+ * Taro.chooseVideo({
393
+ * sourceType: ['album', 'camera'],
394
+ * maxDuration: 60,
395
+ * camera: 'back',
396
+ * compressed: false,
397
+ * success (res) {
398
+ * Taro.compressVideo({
399
+ * src: res.tempFilePath,
400
+ * quality: quality,
401
+ * bitrate: 1032,
402
+ * fps: 24,
403
+ * resolution:0.5,
404
+ * success (res) {
405
+ * console.log("压缩成功")
406
+ * },
407
+ * fail (err) {
408
+ * console.log("压缩失败")
409
+ * }
410
+ * })
411
+ * }
412
+ * })
413
+ * ```
414
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.compressVideo.html
415
+ */
416
+ compressVideo(option: compressVideo.Option): Promise<compressVideo.SuccessCallbackResult>
417
+
179
418
  /** 拍摄视频或从手机相册中选视频。
180
419
  * @supported weapp, rn
181
420
  * @example
@@ -191,6 +430,26 @@ declare module '../../index' {
191
430
  * ```
192
431
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseVideo.html
193
432
  */
194
- chooseVideo(option: chooseVideo.Option): Promise<void>
433
+ chooseVideo(option: chooseVideo.Option): Promise<chooseVideo.SuccessCallbackResult>
434
+
435
+ /** 拍摄或从手机相册中选择图片或视频。
436
+ * @supported weapp, rn
437
+ * @example
438
+ * ```tsx
439
+ * Taro.chooseMedia({
440
+ * count: 9,
441
+ * mediaType: ['image','video'],
442
+ * sourceType: ['album', 'camera'],
443
+ * maxDuration: 30,
444
+ * camera: 'back',
445
+ * success: (res) => {
446
+ * console.log(res.tempFiles)
447
+ * console.log(res.type)
448
+ * }
449
+ * })
450
+ * ```
451
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html
452
+ */
453
+ chooseMedia(option: chooseMedia.Option): Promise<chooseMedia.SuccessCallbackResult>
195
454
  }
196
455
  }
@@ -58,6 +58,12 @@ declare module '../../index' {
58
58
  /** 已经下载的数据长度,单位 Bytes */
59
59
  totalBytesWritten: number
60
60
  }
61
+
62
+ type DownloadTaskPromise = Promise<DownloadTask> & {
63
+ headersReceive: DownloadTask['onHeadersReceived'],
64
+ progress: DownloadTask['onProgressUpdate'],
65
+ abort: DownloadTask['abort']
66
+ }
61
67
  }
62
68
 
63
69
  interface DownloadTask {
@@ -121,6 +127,6 @@ declare module '../../index' {
121
127
  * ```
122
128
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/wx.downloadFile.html
123
129
  */
124
- downloadFile(option: downloadFile.Option): DownloadTask
130
+ downloadFile(option: downloadFile.Option): DownloadTask.DownloadTaskPromise
125
131
  }
126
132
  }
@@ -67,6 +67,12 @@ declare module '../../index' {
67
67
  /** 已经上传的数据长度,单位 Bytes */
68
68
  totalBytesSent: number
69
69
  }
70
+
71
+ type UploadTaskPromise = Promise<UploadTask> & {
72
+ headersReceive: UploadTask['onHeadersReceived'],
73
+ progress: UploadTask['onProgressUpdate'],
74
+ abort: UploadTask['abort']
75
+ }
70
76
  }
71
77
 
72
78
  /** 一个可以监听上传进度变化事件,以及取消上传任务的对象
@@ -166,6 +172,6 @@ declare module '../../index' {
166
172
  * ```
167
173
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/wx.uploadFile.html
168
174
  */
169
- uploadFile(option: uploadFile.Option): Promise<uploadFile.SuccessCallbackResult & UploadTask> & UploadTask
175
+ uploadFile(option: uploadFile.Option): UploadTask.UploadTaskPromise
170
176
  }
171
177
  }
@@ -10,6 +10,11 @@ declare module '../../index' {
10
10
  /** 动画的效果 */
11
11
  timingFunction?: keyof timingFunction
12
12
  transformOrigin?: string
13
+ /**
14
+ * 单位
15
+ * @supported h5
16
+ */
17
+ unit?: string
13
18
  }
14
19
  interface timingFunction {
15
20
  /** 动画从头到尾的速度是相同的 */
@@ -31,14 +36,14 @@ declare module '../../index' {
31
36
 
32
37
  interface Animation {
33
38
  /** 导出动画队列。**export 方法每次调用后会清掉之前的动画操作。**
34
- * @supported weapp
39
+ * @supported weapp, h5
35
40
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.export.html
36
41
  */
37
42
  export(): {
38
43
  actions: TaroGeneral.IAnyObject[]
39
44
  }
40
45
  /** 设置背景色
41
- * @supported weapp
46
+ * @supported weapp, h5
42
47
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.backgroundColor.html
43
48
  */
44
49
  backgroundColor(
@@ -46,7 +51,7 @@ declare module '../../index' {
46
51
  value: string,
47
52
  ): Animation
48
53
  /** 设置 bottom 值
49
- * @supported weapp
54
+ * @supported weapp, h5
50
55
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.bottom.html
51
56
  */
52
57
  bottom(
@@ -54,7 +59,7 @@ declare module '../../index' {
54
59
  value: number | string,
55
60
  ): Animation
56
61
  /** 设置高度
57
- * @supported weapp
62
+ * @supported weapp, h5
58
63
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.height.html
59
64
  */
60
65
  height(
@@ -62,7 +67,7 @@ declare module '../../index' {
62
67
  value: number | string,
63
68
  ): Animation
64
69
  /** 设置 left 值
65
- * @supported weapp
70
+ * @supported weapp, h5
66
71
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.left.html
67
72
  */
68
73
  left(
@@ -70,17 +75,17 @@ declare module '../../index' {
70
75
  value: number | string,
71
76
  ): Animation
72
77
  /** 同 [transform-function matrix](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix)
73
- * @supported weapp
78
+ * @supported weapp, h5
74
79
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.matrix.html
75
80
  */
76
- matrix(): Animation
81
+ matrix(a: number, b: number, c: number, d: number, tx: number, ty: number): Animation
77
82
  /** 同 [transform-function matrix3d](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d)
78
83
  * @supported weapp
79
84
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.matrix3d.html
80
85
  */
81
- matrix3d(): Animation
86
+ matrix3d(a1: number, b1: number, c1: number, d1: number, a2: number, b2: number, c2: number, d2: number, a3: number, b3: number, c3: number, d3: number, a4: number, b4: number, c4: number, d4: number): Animation
82
87
  /** 设置透明度
83
- * @supported weapp
88
+ * @supported weapp, h5
84
89
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.opacity.html
85
90
  */
86
91
  opacity(
@@ -88,7 +93,7 @@ declare module '../../index' {
88
93
  value: number,
89
94
  ): Animation
90
95
  /** 设置 right 值
91
- * @supported weapp
96
+ * @supported weapp, h5
92
97
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.right.html
93
98
  */
94
99
  right(
@@ -96,7 +101,7 @@ declare module '../../index' {
96
101
  value: number | string,
97
102
  ): Animation
98
103
  /** 从原点顺时针旋转一个角度
99
- * @supported weapp
104
+ * @supported weapp, h5
100
105
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotate.html
101
106
  */
102
107
  rotate(
@@ -104,21 +109,21 @@ declare module '../../index' {
104
109
  angle: number,
105
110
  ): Animation
106
111
  /** 从 固定 轴顺时针旋转一个角度
107
- * @supported weapp
112
+ * @supported weapp, h5
108
113
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotate3d.html
109
114
  */
110
115
  rotate3d(
111
116
  /** 旋转轴的 x 坐标 */
112
117
  x: number,
113
118
  /** 旋转轴的 y 坐标 */
114
- y: number,
119
+ y?: number,
115
120
  /** 旋转轴的 z 坐标 */
116
- z: number,
121
+ z?: number,
117
122
  /** 旋转的角度。范围 [-180, 180] */
118
- angle: number,
123
+ angle?: number,
119
124
  ): Animation
120
125
  /** 从 X 轴顺时针旋转一个角度
121
- * @supported weapp
126
+ * @supported weapp, h5
122
127
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotateX.html
123
128
  */
124
129
  rotateX(
@@ -126,7 +131,7 @@ declare module '../../index' {
126
131
  angle: number,
127
132
  ): Animation
128
133
  /** 从 Y 轴顺时针旋转一个角度
129
- * @supported weapp
134
+ * @supported weapp, h5
130
135
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotateY.html
131
136
  */
132
137
  rotateY(
@@ -134,7 +139,7 @@ declare module '../../index' {
134
139
  angle: number,
135
140
  ): Animation
136
141
  /** 从 Z 轴顺时针旋转一个角度
137
- * @supported weapp
142
+ * @supported weapp, h5
138
143
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotateZ.html
139
144
  */
140
145
  rotateZ(
@@ -142,7 +147,7 @@ declare module '../../index' {
142
147
  angle: number,
143
148
  ): Animation
144
149
  /** 缩放
145
- * @supported weapp
150
+ * @supported weapp, h5
146
151
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scale.html
147
152
  */
148
153
  scale(
@@ -152,7 +157,7 @@ declare module '../../index' {
152
157
  sy?: number,
153
158
  ): Animation
154
159
  /** 缩放
155
- * @supported weapp
160
+ * @supported weapp, h5
156
161
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scale3d.html
157
162
  */
158
163
  scale3d(
@@ -164,7 +169,7 @@ declare module '../../index' {
164
169
  sz: number,
165
170
  ): Animation
166
171
  /** 缩放 X 轴
167
- * @supported weapp
172
+ * @supported weapp, h5
168
173
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scaleX.html
169
174
  */
170
175
  scaleX(
@@ -172,7 +177,7 @@ declare module '../../index' {
172
177
  scale: number,
173
178
  ): Animation
174
179
  /** 缩放 Y 轴
175
- * @supported weapp
180
+ * @supported weapp, h5
176
181
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scaleY.html
177
182
  */
178
183
  scaleY(
@@ -180,7 +185,7 @@ declare module '../../index' {
180
185
  scale: number,
181
186
  ): Animation
182
187
  /** 缩放 Z 轴
183
- * @supported weapp
188
+ * @supported weapp, h5
184
189
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scaleZ.html
185
190
  */
186
191
  scaleZ(
@@ -198,7 +203,7 @@ declare module '../../index' {
198
203
  ay: number,
199
204
  ): Animation
200
205
  /** 对 X 轴坐标进行倾斜
201
- * @supported weapp
206
+ * @supported weapp, h5
202
207
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.skewX.html
203
208
  */
204
209
  skewX(
@@ -214,12 +219,12 @@ declare module '../../index' {
214
219
  angle: number,
215
220
  ): Animation
216
221
  /** 表示一组动画完成。可以在一组动画中调用任意多个动画方法,一组动画中的所有动画会同时开始,一组动画完成后才会进行下一组动画。
217
- * @supported weapp
222
+ * @supported weapp, h5
218
223
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.step.html
219
224
  */
220
225
  step(option?: Animation.StepOption): Animation
221
226
  /** 设置 top 值
222
- * @supported weapp
227
+ * @supported weapp, h5
223
228
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.top.html
224
229
  */
225
230
  top(
@@ -227,7 +232,7 @@ declare module '../../index' {
227
232
  value: number | string,
228
233
  ): Animation
229
234
  /** 平移变换
230
- * @supported weapp
235
+ * @supported weapp, h5
231
236
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translate.html
232
237
  */
233
238
  translate(
@@ -237,7 +242,7 @@ declare module '../../index' {
237
242
  ty?: number,
238
243
  ): Animation
239
244
  /** 对 xyz 坐标进行平移变换
240
- * @supported weapp
245
+ * @supported weapp, h5
241
246
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translate3d.html
242
247
  */
243
248
  translate3d(
@@ -249,7 +254,7 @@ declare module '../../index' {
249
254
  tz?: number,
250
255
  ): Animation
251
256
  /** 对 X 轴平移
252
- * @supported weapp
257
+ * @supported weapp, h5
253
258
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translateX.html
254
259
  */
255
260
  translateX(
@@ -257,7 +262,7 @@ declare module '../../index' {
257
262
  translation: number,
258
263
  ): Animation
259
264
  /** 对 Y 轴平移
260
- * @supported weapp
265
+ * @supported weapp, h5
261
266
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translateY.html
262
267
  */
263
268
  translateY(
@@ -265,7 +270,7 @@ declare module '../../index' {
265
270
  translation: number,
266
271
  ): Animation
267
272
  /** 对 Z 轴平移
268
- * @supported weapp
273
+ * @supported weapp, h5
269
274
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translateZ.html
270
275
  */
271
276
  translateZ(
@@ -273,7 +278,7 @@ declare module '../../index' {
273
278
  translation: number,
274
279
  ): Animation
275
280
  /** 设置宽度
276
- * @supported weapp
281
+ * @supported weapp, h5
277
282
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.width.html
278
283
  */
279
284
  width(
@@ -79,6 +79,8 @@ declare module '../../index' {
79
79
 
80
80
  namespace showActionSheet {
81
81
  interface Option {
82
+ /** 警示文案 */
83
+ alertText?: string
82
84
  /** 按钮的文字数组,数组长度最大为 6 */
83
85
  itemList: string[]
84
86
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
@@ -80,14 +80,16 @@ declare module './index' {
80
80
  type SFC = StatelessFunctionComponent
81
81
 
82
82
  interface Show {
83
- componentDidShow?(options?: unknown): void
84
- componentDidHide?(options?: unknown): void
85
- onShow?(options?: unknown): void
86
- onHide?(options?: unknown): void
83
+ componentDidShow?(): void
84
+ componentDidHide?(): void
85
+ onShow?(): void
86
+ onHide?(): void
87
87
  }
88
88
 
89
89
  interface AppInstance extends Show {
90
90
  mount(component: React.ComponentClass | Vue.ComponentOptions<Vue>, id: string, cb: () => void): void
91
+ componentDidShow?(options?: Record<string, unknown>): void
92
+ onShow?(options?: Record<string, unknown>): void
91
93
  unmount(id: string, cb: () => void): void
92
94
  }
93
95
 
@@ -235,7 +235,24 @@ declare module './index' {
235
235
  }
236
236
  }
237
237
 
238
+ interface RouterAnimate {
239
+ /**
240
+ * 动画切换时间,单位毫秒
241
+ * @default 300
242
+ */
243
+ duration?: number
244
+ /**
245
+ * 动画切换时间,单位毫秒
246
+ * @default 50
247
+ */
248
+ delay?: number
249
+ }
250
+
238
251
  interface AppConfig {
252
+ /**
253
+ * 小程序默认启动首页,未指定 entryPagePath 时,数组的第一项代表小程序的初始页面(首页)。
254
+ */
255
+ entryPagePath?: string
239
256
  /**
240
257
  * 接受一个数组,每一项都是字符串,来指定小程序由哪些页面组成,数组的第一项代表小程序的初始页面
241
258
  */
@@ -331,6 +348,18 @@ declare module './index' {
331
348
  * 接受一个数组,每一项都是字符串,来指定编译为原生小程序组件的组件入口
332
349
  */
333
350
  components?: string[]
351
+ /**
352
+ * 渲染页面的容器 id
353
+ * @default "app"
354
+ * @since 3.3.18
355
+ */
356
+ appId?: string
357
+ /**
358
+ * 是否开启 h5 端路由动画功能,默认开启
359
+ * @supported h5
360
+ * @since 3.3.18
361
+ */
362
+ animation?: RouterAnimate | boolean
334
363
  }
335
364
 
336
365
  interface Config extends PageConfig, AppConfig {
@@ -354,6 +383,7 @@ declare module './index' {
354
383
  PreloadRule: PreloadRule
355
384
  Permission: Permission
356
385
  AppConfig: AppConfig
386
+ RouterAnimate: RouterAnimate
357
387
  Config: Config
358
388
  }
359
389
  }
@@ -54,6 +54,10 @@ declare module './index' {
54
54
  }
55
55
 
56
56
  interface TaroStatic {
57
+ Events: {
58
+ new (): TaroGeneral.Events
59
+ }
60
+
57
61
  // eventCenter
58
62
  eventCenter: TaroGeneral.Events
59
63
 
package/h5.js DELETED
@@ -1,4 +0,0 @@
1
- import Taro from '@tarojs/taro-h5'
2
- export * from '@tarojs/taro-h5'
3
-
4
- export default Taro