@tarojs/taro 3.4.0-beta.1 → 3.4.1
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 +5 -7
- package/types/api/base/weapp/app-event.d.ts +3 -3
- package/types/api/canvas/index.d.ts +21 -0
- package/types/api/media/audio.d.ts +24 -22
- package/types/api/media/background-audio.d.ts +39 -33
- package/types/api/media/image.d.ts +1 -81
- package/types/api/media/video.d.ts +290 -31
- package/types/api/network/request.d.ts +18 -1
- package/types/api/open-api/customer-service.d.ts +1 -1
- package/types/api/open-api/navigate.d.ts +1 -3
- package/types/api/wxml/index.d.ts +34 -0
- package/types/compile.d.ts +106 -106
- package/types/taro.component.d.ts +82 -60
- package/types/taro.config.d.ts +174 -170
- package/types/taro.extend.d.ts +0 -17
- package/types/taro.hooks.d.ts +12 -12
- package/types/taro.lifecycle.d.ts +7 -0
- package/h5.js +0 -4
|
@@ -14,48 +14,75 @@ declare module '../../index' {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
namespace
|
|
17
|
+
namespace openVideoEditor {
|
|
18
18
|
interface Option {
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
43
|
-
/**
|
|
60
|
+
/** 视频的长,单位 px */
|
|
61
|
+
height: number
|
|
62
|
+
/** 视频的宽,单位 px */
|
|
44
63
|
width: number
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/** 默认拉起后置摄像头 */
|
|
50
|
-
back
|
|
51
|
-
/** 默认拉起前置摄像头 */
|
|
52
|
-
front
|
|
64
|
+
/** 视频帧率 */
|
|
65
|
+
fps: number
|
|
66
|
+
/** 视频码率,单位 kbps */
|
|
67
|
+
bitrate: number
|
|
53
68
|
}
|
|
54
|
-
interface
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
|
|
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
|
|
@@ -192,5 +431,25 @@ declare module '../../index' {
|
|
|
192
431
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseVideo.html
|
|
193
432
|
*/
|
|
194
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
|
}
|
|
@@ -231,6 +231,21 @@ declare module '../../index' {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
type interceptor = (chain: Chain) => any
|
|
235
|
+
|
|
236
|
+
interface Chain {
|
|
237
|
+
index: number
|
|
238
|
+
requestParams: RequestParams
|
|
239
|
+
interceptors: interceptor[]
|
|
240
|
+
proceed(requestParams: RequestParams): any
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
interface interceptors {
|
|
244
|
+
logInterceptor(chain: Chain): Promise<any>
|
|
245
|
+
|
|
246
|
+
timeoutInterceptor(chain: Chain): Promise<any>
|
|
247
|
+
}
|
|
248
|
+
|
|
234
249
|
interface TaroStatic {
|
|
235
250
|
/** 发起 HTTPS 网络请求。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。
|
|
236
251
|
*
|
|
@@ -298,6 +313,8 @@ declare module '../../index' {
|
|
|
298
313
|
* ```
|
|
299
314
|
* @since 1.2.16
|
|
300
315
|
*/
|
|
301
|
-
addInterceptor
|
|
316
|
+
addInterceptor(interceptor: interceptor): any
|
|
317
|
+
|
|
318
|
+
interceptors: interceptors
|
|
302
319
|
}
|
|
303
320
|
}
|
|
@@ -141,6 +141,40 @@ declare module '../../index' {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
/** `MediaQueryObserver` 对象,用于监听页面 media query 状态的变化,如界面的长宽是不是在某个指定的范围内。 */
|
|
145
|
+
interface MediaQueryObserver {
|
|
146
|
+
/** 开始监听页面 media query 变化情况 */
|
|
147
|
+
observe(descriptor: MediaQueryObserver.descriptor, callback: MediaQueryObserver.observeCallback): void
|
|
148
|
+
/** 停止监听。回调函数将不再触发 */
|
|
149
|
+
disconnect(): void
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
namespace MediaQueryObserver {
|
|
153
|
+
/** media query 描述符 */
|
|
154
|
+
interface descriptor {
|
|
155
|
+
/** 页面最小宽度 (单位: px) */
|
|
156
|
+
minWidth: number
|
|
157
|
+
/** 页面最大宽度 (单位: px) */
|
|
158
|
+
maxWidth: number
|
|
159
|
+
/** 页面宽度 (单位: px) */
|
|
160
|
+
width: number
|
|
161
|
+
/** 页面最小高度 (单位: px) */
|
|
162
|
+
minHeight: number
|
|
163
|
+
/** 页面最大高度(px 为单位) */
|
|
164
|
+
maxHeight: number
|
|
165
|
+
/** 页面高度(px 为单位) */
|
|
166
|
+
height: number
|
|
167
|
+
/** 屏幕方向 */
|
|
168
|
+
orientation: 'landscape' | 'portrait'
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** 监听 media query 状态变化的回调函数 */
|
|
172
|
+
type observeCallback = (res: {
|
|
173
|
+
/** 页面的当前状态是否满足所指定的 media query */
|
|
174
|
+
matches: boolean
|
|
175
|
+
}) => void
|
|
176
|
+
}
|
|
177
|
+
|
|
144
178
|
/** 查询节点信息的对象
|
|
145
179
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.html
|
|
146
180
|
*/
|