@tarojs/taro 3.4.0-beta.2 → 3.4.0-beta.3

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.4.0-beta.2",
3
+ "version": "3.4.0-beta.3",
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.4.0-beta.2",
30
- "@tarojs/runtime": "3.4.0-beta.2",
31
- "@tarojs/taro-h5": "3.4.0-beta.2"
27
+ "@tarojs/api": "3.4.0-beta.3",
28
+ "@tarojs/runtime": "3.4.0-beta.3",
29
+ "@tarojs/taro-h5": "3.4.0-beta.3"
32
30
  },
33
- "gitHead": "ac3eb29f11aec15d25e061775d9e970efabc2c98"
31
+ "gitHead": "2ef7e8c10c9e5784e98bb1ad3a803d5fd6a46c8b"
34
32
  }
@@ -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
  /** 取消监听音频中断结束事件
@@ -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(
@@ -243,66 +243,6 @@ declare module '../../index' {
243
243
  }
244
244
  }
245
245
 
246
- namespace chooseMedia {
247
- interface Option {
248
- /** 最多可以选择的文件个数 */
249
- count?: number
250
- /** 文件类型 */
251
- mediaType?: Array<keyof mediaType>
252
- /** 图片和视频选择的来源 */
253
- sourceType?: Array<keyof sourceType>
254
- /** 拍摄视频最长拍摄时间,单位秒。时间范围为 3s 至 30s 之间 */
255
- maxDuration?: number
256
- /** 仅对 mediaType 为 image 时有效,是否压缩所选文件 */
257
- sizeType?: Array<'original' | 'compressed'>
258
- /** 仅在 sourceType 为 camera 时生效,使用前置或后置摄像头 */
259
- camera?: string
260
- /** 接口调用失败的回调函数 */
261
- fail?: (res: TaroGeneral.CallbackResult) => void
262
- /** 接口调用成功的回调函数 */
263
- success?: (result: SuccessCallbackResult) => void
264
- }
265
- interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
266
- /** 本地临时文件列表 */
267
- tempFiles: ChooseMedia[]
268
- /** 文件类型,有效值有 image 、video */
269
- type: string
270
- }
271
- /** 本地临时文件列表 */
272
- interface ChooseMedia {
273
- /** 本地临时文件路径 (本地路径) */
274
- tempFilePath: string
275
- /** 本地临时文件大小,单位 B */
276
- size: number
277
- /** 视频的时间长度 */
278
- duration: number
279
- /** 视频的高度 */
280
- height: number
281
- /** 视频的宽度 */
282
- width: number
283
- /** 视频缩略图临时文件路径 */
284
- thumbTempFilePath: string
285
- }
286
- interface mediaType {
287
- /** 只能拍摄视频或从相册选择视频 */
288
- video
289
- /** 只能拍摄图片或从相册选择图片 */
290
- image
291
- }
292
- interface sourceType {
293
- /** 从相册选择 */
294
- album
295
- /** 使用相机拍摄 */
296
- camera
297
- }
298
- interface camera {
299
- /** 使用后置摄像头 */
300
- back
301
- /** 使用前置摄像头 */
302
- front
303
- }
304
- }
305
-
306
246
  interface TaroStatic {
307
247
  /** 保存图片到系统相册。需要[用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.writePhotosAlbum
308
248
  * @supported weapp, rn, alipay, swan
@@ -416,25 +356,5 @@ declare module '../../index' {
416
356
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html
417
357
  */
418
358
  chooseMessageFile(option: chooseMessageFile.Option): Promise<chooseMessageFile.SuccessCallbackResult>
419
-
420
- /** 拍摄或从手机相册中选择图片或视频。
421
- * @supported weapp, rn
422
- * @example
423
- * ```tsx
424
- * Taro.chooseMedia({
425
- * count: 9,
426
- * mediaType: ['image','video'],
427
- * sourceType: ['album', 'camera'],
428
- * maxDuration: 30,
429
- * camera: 'back',
430
- * success: (res) => {
431
- * console.log(res.tempFiles)
432
- * console.log(res.type)
433
- * }
434
- * })
435
- * ```
436
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html
437
- */
438
- chooseMedia(option: chooseMedia.Option): Promise<chooseMedia.SuccessCallbackResult>
439
359
  }
440
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
@@ -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
  }
@@ -53,12 +53,12 @@ export type IOption = Record<string, any>
53
53
 
54
54
  export interface ICopyOptions {
55
55
  patterns: {
56
- from: string,
57
- to: string,
58
- ignore?: string[],
59
- transform?: Function,
56
+ from: string
57
+ to: string
58
+ ignore?: string[]
59
+ transform?: Function
60
60
  watch?: boolean
61
- }[],
61
+ }[]
62
62
  options: {
63
63
  ignore?: string[]
64
64
  }
@@ -68,11 +68,11 @@ export interface ISassOptions {
68
68
  /**
69
69
  * 引入的全局 sass 文件,如果要引入多个文件,支持数组形式传入
70
70
  */
71
- resource?: string | string[],
71
+ resource?: string | string[]
72
72
  /**
73
73
  * 项目根目录的绝对地址(若为小程序云开发模板,则应该是client目录)
74
74
  */
75
- projectDirectory?: string,
75
+ projectDirectory?: string
76
76
  /**
77
77
  * 全局 scss 变量,若 data 与 resource 中设置了同样的变量,则 data 的优先级高于 resource
78
78
  */
@@ -89,21 +89,21 @@ export namespace PostcssOption {
89
89
  generateScopedName: string | ((localName: string, absoluteFilePath: string) => string)
90
90
  }>
91
91
  export type url = TogglableOptions<{
92
- limit: number,
92
+ limit: number
93
93
  basePath?: string | string[]
94
94
  }>
95
95
  }
96
96
 
97
97
  export interface IPostcssOption {
98
- autoprefixer?: TogglableOptions,
99
- pxtransform?: TogglableOptions,
100
- cssModules?: PostcssOption.cssModules,
101
- url?: PostcssOption.url,
98
+ autoprefixer?: TogglableOptions
99
+ pxtransform?: TogglableOptions
100
+ cssModules?: PostcssOption.cssModules
101
+ url?: PostcssOption.url
102
102
  [key: string]: any
103
103
  }
104
104
 
105
105
  export interface ICompileOption {
106
- exclude?: string[],
106
+ exclude?: string[]
107
107
  include?: string[]
108
108
  }
109
109
 
@@ -113,85 +113,85 @@ interface Runtime {
113
113
  }
114
114
 
115
115
  export interface IMiniAppConfig {
116
- appOutput?: boolean,
117
- enableSourceMap?: boolean,
118
- sourceMapType?: string,
119
- debugReact?: boolean,
116
+ appOutput?: boolean
117
+ enableSourceMap?: boolean
118
+ sourceMapType?: string
119
+ debugReact?: boolean
120
120
  minifyXML?: {
121
121
  collapseWhitespace?: boolean
122
- },
123
-
124
- webpackChain?: (chain: any, webpack: any, PARSE_AST_TYPE: any) => void,
125
- entry?: webpack.Entry,
126
- output?: webpack.Output,
127
- postcss?: IPostcssOption,
128
- cssLoaderOption?: IOption,
129
- sassLoaderOption?: IOption,
130
- lessLoaderOption?: IOption,
131
- stylusLoaderOption?: IOption,
132
- mediaUrlLoaderOption?: IOption,
133
- fontUrlLoaderOption?: IOption,
134
- imageUrlLoaderOption?: IOption,
135
- miniCssExtractPluginOption?: IOption,
136
-
137
- customFilesTypes?: IMINI_APP_FILE_TYPE,
138
- commonChunks?: string[] | ((commonChunks: string[]) => string[]),
139
- addChunkPages?: ((pages: Map<string, string[]>, pagesNames?: string[]) => void),
122
+ }
123
+
124
+ webpackChain?: (chain: any, webpack: any, PARSE_AST_TYPE: any) => void
125
+ entry?: webpack.Entry
126
+ output?: webpack.Output
127
+ postcss?: IPostcssOption
128
+ cssLoaderOption?: IOption
129
+ sassLoaderOption?: IOption
130
+ lessLoaderOption?: IOption
131
+ stylusLoaderOption?: IOption
132
+ mediaUrlLoaderOption?: IOption
133
+ fontUrlLoaderOption?: IOption
134
+ imageUrlLoaderOption?: IOption
135
+ miniCssExtractPluginOption?: IOption
136
+
137
+ customFilesTypes?: IMINI_APP_FILE_TYPE
138
+ commonChunks?: string[] | ((commonChunks: string[]) => string[])
139
+ addChunkPages?: ((pages: Map<string, string[]>, pagesNames?: string[]) => void)
140
140
  optimizeMainPackage?: {
141
- enable?: boolean,
141
+ enable?: boolean
142
142
  exclude?: any[]
143
- },
143
+ }
144
144
 
145
145
  compile?: {
146
- exclude?: any[],
146
+ exclude?: any[]
147
147
  include?: any[]
148
148
  }
149
149
  runtime?: Runtime
150
150
  }
151
151
 
152
152
  export type TogglableOptions<T = IOption> = {
153
- enable?: boolean,
153
+ enable?: boolean
154
154
  config?: T
155
155
  }
156
156
 
157
157
  export interface IH5RouterConfig {
158
- mode?: 'hash' | 'browser' | 'multi',
159
- customRoutes?: IOption,
160
- basename?: string,
161
- lazyload?: boolean | ((pagename: string) => boolean),
158
+ mode?: 'hash' | 'browser' | 'multi'
159
+ customRoutes?: IOption
160
+ basename?: string
161
+ lazyload?: boolean | ((pagename: string) => boolean)
162
162
  renamePagename?: (pagename: string) => string
163
163
  forcePath?: string
164
164
  }
165
165
 
166
166
  export interface IH5Config {
167
- publicPath?: string,
168
- staticDirectory?: string,
169
- chunkDirectory?: string,
167
+ publicPath?: string
168
+ staticDirectory?: string
169
+ chunkDirectory?: string
170
170
 
171
171
  webpack?: ((webpackConfig: webpack.Configuration, webpack) => webpack.Configuration) | webpack.Configuration
172
172
 
173
- webpackChain?: (chain: any, webpack: any) => void,
174
-
175
- entry?: webpack.Entry,
176
- output?: webpack.Output,
177
- router?: IH5RouterConfig,
178
- devServer?: webpackDevServer.Configuration,
179
- enableSourceMap?: boolean,
180
- sourceMapType?: 'none' | 'eval' | 'cheap-eval-source-map' | 'cheap-module-eval-source-map' | 'eval-source-map' | 'cheap-source-map' | 'cheap-module-source-map' | 'inline-cheap-source-map' | 'inline-cheap-module-source-map' | 'source-map' | 'inline-source-map' | 'hidden-source-map' | 'nosources-source-map',
181
- enableExtract?: boolean,
182
- transformOnly?: boolean,
183
-
184
- cssLoaderOption?: IOption,
185
- styleLoaderOption?: IOption,
186
- sassLoaderOption?: IOption,
187
- lessLoaderOption?: IOption,
188
- stylusLoaderOption?: IOption,
189
- mediaUrlLoaderOption?: IOption,
190
- fontUrlLoaderOption?: IOption,
191
- imageUrlLoaderOption?: IOption,
192
- miniCssExtractPluginOption?: IOption,
193
- esnextModules?: string[],
194
- useHtmlComponents?: boolean,
173
+ webpackChain?: (chain: any, webpack: any) => void
174
+
175
+ entry?: webpack.Entry
176
+ output?: webpack.Output
177
+ router?: IH5RouterConfig
178
+ devServer?: webpackDevServer.Configuration
179
+ enableSourceMap?: boolean
180
+ sourceMapType?: 'none' | 'eval' | 'cheap-eval-source-map' | 'cheap-module-eval-source-map' | 'eval-source-map' | 'cheap-source-map' | 'cheap-module-source-map' | 'inline-cheap-source-map' | 'inline-cheap-module-source-map' | 'source-map' | 'inline-source-map' | 'hidden-source-map' | 'nosources-source-map'
181
+ enableExtract?: boolean
182
+ transformOnly?: boolean
183
+
184
+ cssLoaderOption?: IOption
185
+ styleLoaderOption?: IOption
186
+ sassLoaderOption?: IOption
187
+ lessLoaderOption?: IOption
188
+ stylusLoaderOption?: IOption
189
+ mediaUrlLoaderOption?: IOption
190
+ fontUrlLoaderOption?: IOption
191
+ imageUrlLoaderOption?: IOption
192
+ miniCssExtractPluginOption?: IOption
193
+ esnextModules?: string[]
194
+ useHtmlComponents?: boolean
195
195
 
196
196
  postcss?: IPostcssOption
197
197
  }
@@ -213,11 +213,11 @@ export type SystemConfig = {
213
213
  /**
214
214
  * 打印日志等级,分为 off,error,warn,info,log,debug
215
215
  */
216
- logLevel?: LogLevel,
216
+ logLevel?: LogLevel
217
217
  /**
218
218
  * 页面设计基准宽度,根据实际设备宽度来缩放元素大小
219
219
  */
220
- designWidth?: number,
220
+ designWidth?: number
221
221
  /**
222
222
  * 全局数据对象,属性名不能以$或_开头,在页面中可通过 this 进行访问;如果全局数据属性与页面的数据属性重名,则页面初始化时,全局数据会覆盖页面中对应的属性值
223
223
  */
@@ -228,7 +228,7 @@ type RouterConfig = {
228
228
  /**
229
229
  * 首页名称
230
230
  */
231
- entry: string,
231
+ entry: string
232
232
  /**
233
233
  * 页面配置列表,key 值为页面名称(对应页面目录名,例如 Hello 对应'Hello'目录),value 为页面详细配置 page
234
234
  */
@@ -238,14 +238,14 @@ type RouterPage = {
238
238
  /**
239
239
  * 页面对应的组件名,与 ux 文件名保持一致,例如'hello' 对应 'hello.ux'
240
240
  */
241
- component: string,
241
+ component: string
242
242
  /**
243
243
  * 页面路径,例如“/user”,不填则默认为/<页面名称>。
244
244
  * path 必须唯一,不能和其他 page 的 path 相同。
245
245
  * 下面 page 的 path 因为缺失,会被设置为“/Index”:
246
246
  * "Index": {"component": "index"}
247
247
  */
248
- path?: string,
248
+ path?: string
249
249
  /**
250
250
  * 声明页面可以处理某种请求
251
251
  */
@@ -260,31 +260,31 @@ interface IDefaultDisplayConfig {
260
260
  /**
261
261
  * 窗口背景颜色
262
262
  */
263
- backgroundColor?: string,
263
+ backgroundColor?: string
264
264
  /**
265
265
  * 是否是全屏模式,默认不会同时作用于 titleBar,titleBar 需要继续通过 titleBar 控制
266
266
  */
267
- fullScreen?: boolean,
267
+ fullScreen?: boolean
268
268
  /**
269
269
  * 是否显示 titleBar
270
270
  */
271
- titleBar?: boolean,
271
+ titleBar?: boolean
272
272
  /**
273
273
  * 标题栏背景色
274
274
  */
275
- titleBarBackgroundColor?: string,
275
+ titleBarBackgroundColor?: string
276
276
  /**
277
277
  * 标题栏文字颜色
278
278
  */
279
- titleBarTextColor?: string,
279
+ titleBarTextColor?: string
280
280
  /**
281
281
  * 标题栏文字(也可通过页面跳转传递参数(titleBarText)设置)
282
282
  */
283
- titleBarText?: string,
283
+ titleBarText?: string
284
284
  /**
285
285
  * 是否显示标题栏右上角菜单按钮,点击菜单按钮调用页面生命周期 onMenuPress 方法,如果该方法未实现则显示系统默认菜单
286
286
  */
287
- menu?: boolean,
287
+ menu?: boolean
288
288
  /**
289
289
  * 软键盘弹出时为保证输入框可见,页面的调整方式。 adjustPan:上移页面; adjustResize:压缩页面显示区域,当页面全屏时,此设置不生效
290
290
  */
@@ -304,31 +304,31 @@ export interface ITaroManifestConfig {
304
304
  /**
305
305
  * 应用包名,确认与原生应用的包名不一致,推荐采用 com.company.module 的格式,如:com.example.demo
306
306
  */
307
- package: string,
307
+ package: string
308
308
  /**
309
309
  * 应用名称,6 个汉字以内,与应用商店保存的名称一致,用于在桌面图标、弹窗等处显示应用名称
310
310
  */
311
- name: string,
311
+ name: string
312
312
  /**
313
313
  * 应用图标,提供 192x192 大小的即可
314
314
  */
315
- icon: string,
315
+ icon: string
316
316
  /**
317
317
  * 应用版本名称,如:"1.0"
318
318
  */
319
- versionName?: string,
319
+ versionName?: string
320
320
  /**
321
321
  * 应用版本号,从1自增,推荐每次重新上传包时versionCode+1
322
322
  */
323
- versionCode: number,
323
+ versionCode: number
324
324
  /**
325
325
  * 支持的最小平台版本号,兼容性检查,避免上线后在低版本平台运行并导致不兼容;如果不填按照内测版本处理
326
326
  */
327
- minPlatformVersion?: string,
327
+ minPlatformVersion?: string
328
328
  /**
329
329
  * 接口列表,绝大部分接口都需要在这里声明,否则不能调用,详见每个接口的文档说明
330
330
  */
331
- features?: FeatureItem[],
331
+ features?: FeatureItem[]
332
332
  /**
333
333
  *
334
334
  */
@@ -339,11 +339,11 @@ export interface IManifestConfig extends ITaroManifestConfig {
339
339
  /**
340
340
  * 系统配置信息
341
341
  */
342
- config: SystemConfig,
342
+ config: SystemConfig
343
343
  /**
344
344
  * 路由信息
345
345
  */
346
- router: RouterConfig,
346
+ router: RouterConfig
347
347
  /**
348
348
  * UI 显示相关配置
349
349
  */
@@ -353,24 +353,24 @@ export interface IManifestConfig extends ITaroManifestConfig {
353
353
  export type PluginItem = string | [string, object]
354
354
 
355
355
  export interface IProjectBaseConfig {
356
- projectName?: string,
357
- date?: string,
358
- designWidth?: number,
359
- watcher?: any[],
360
- deviceRatio?: TaroGeneral.TDeviceRatio,
361
- sourceRoot?: string,
362
- outputRoot?: string,
363
- env?: IOption,
364
- alias?: IOption,
365
- defineConstants?: IOption,
366
- copy?: ICopyOptions,
367
- csso?: TogglableOptions,
368
- terser?: TogglableOptions,
369
- uglify?: TogglableOptions,
370
- sass?: ISassOptions,
371
- plugins?: PluginItem[],
356
+ projectName?: string
357
+ date?: string
358
+ designWidth?: number
359
+ watcher?: any[]
360
+ deviceRatio?: TaroGeneral.TDeviceRatio
361
+ sourceRoot?: string
362
+ outputRoot?: string
363
+ env?: IOption
364
+ alias?: IOption
365
+ defineConstants?: IOption
366
+ copy?: ICopyOptions
367
+ csso?: TogglableOptions
368
+ terser?: TogglableOptions
369
+ uglify?: TogglableOptions
370
+ sass?: ISassOptions
371
+ plugins?: PluginItem[]
372
372
  presets?: PluginItem[]
373
- baseLevel?: number,
373
+ baseLevel?: number
374
374
  framework?: string
375
375
  }
376
376
 
@@ -21,7 +21,7 @@ declare module './index' {
21
21
  onPageScroll?(obj: PageScrollObject): void
22
22
  onShareAppMessage?(obj: ShareAppMessageObject): ShareAppMessageReturn
23
23
  onTabItemTap?(obj: TabItemTapObject): void
24
- onResize?(obj: any): void
24
+ onResize?(obj: PageResizeObject): void
25
25
  }
26
26
 
27
27
  interface ComponentOptions {
@@ -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
 
@@ -309,7 +309,7 @@ declare module './index' {
309
309
  * 声明分包预下载的规则。
310
310
  * preloadRule 中,key 是页面路径,value 是进入此页面的预下载配置
311
311
  * 注意: 分包预下载目前只支持通过配置方式使用,暂不支持通过调用API完成。
312
- * vConsole 里有preloadSubpackages开头的日志信息,可以用来验证预下载的情况。
312
+ * vConsole 里有 preloadSubpackages 开头的日志信息,可以用来验证预下载的情况。
313
313
  * @since 2.3.0
314
314
  */
315
315
  preloadRule?: PreloadRule
@@ -335,12 +335,12 @@ declare module './index' {
335
335
  */
336
336
  style?: 'v2'
337
337
  /**
338
- * 配置 darkmode 为 true,即表示当前小程序已适配 DarkMode
338
+ * 配置 darkMode 为 true,即表示当前小程序已适配 DarkMode
339
339
  * @since 2.11.0
340
340
  */
341
341
  darkmode?: boolean
342
342
  /**
343
- * 指定 darkmode 变量配置文件 theme.json 路径
343
+ * 指定 darkMode 变量配置文件 theme.json 路径
344
344
  * @since 2.11.0
345
345
  */
346
346
  themeLocation?: string
@@ -355,7 +355,7 @@ declare module './index' {
355
355
  */
356
356
  appId?: string
357
357
  /**
358
- * 是否开启h5端路由动画功能,默认关闭
358
+ * 是否开启 h5 端路由动画功能,默认开启
359
359
  * @supported h5
360
360
  * @since 3.3.18
361
361
  */
@@ -5,32 +5,32 @@ declare module './index' {
5
5
  /**
6
6
  * 页面展示时的回调。
7
7
  */
8
- useDidShow(callback: () => any): void
8
+ useDidShow(callback: () => void): void
9
9
 
10
10
  /**
11
11
  * 页面隐藏时的回调。
12
12
  */
13
- useDidHide(callback: () => any): void
13
+ useDidHide(callback: () => void): void
14
14
 
15
15
  /**
16
16
  * 下拉刷新时的回调。
17
17
  */
18
- usePullDownRefresh(callback: () => any): void
18
+ usePullDownRefresh(callback: () => void): void
19
19
 
20
20
  /**
21
21
  * 上拉触底时的回调。
22
22
  */
23
- useReachBottom(callback: () => any): void
23
+ useReachBottom(callback: () => void): void
24
24
 
25
25
  /**
26
26
  * 页面滚动时的回调。
27
27
  */
28
- usePageScroll(callback: (payload: PageScrollObject) => any): void
28
+ usePageScroll(callback: (payload: PageScrollObject) => void): void
29
29
 
30
30
  /**
31
31
  * 页面尺寸改变时的回调。
32
32
  */
33
- useResize(callback: () => any): void
33
+ useResize(callback: (payload: PageResizeObject) => void): void
34
34
 
35
35
  /**
36
36
  * 页面转发时的回调。
@@ -40,12 +40,12 @@ declare module './index' {
40
40
  /**
41
41
  * 当前是 tab 页时,tab 被点击时的回调。
42
42
  */
43
- useTabItemTap(callback: (payload: TabItemTapObject) => any): void
43
+ useTabItemTap(callback: (payload: TabItemTapObject) => void): void
44
44
 
45
45
  /**
46
46
  * 用户点击右上角菜单“收藏”按钮时的回调。
47
47
  */
48
- useAddToFavorites(callback: (paload: AddToFavoritesObject) => AddToFavoritesReturnObject): void
48
+ useAddToFavorites(callback: (payload: AddToFavoritesObject) => AddToFavoritesReturnObject): void
49
49
 
50
50
  /**
51
51
  * 用户点击右上角菜单“分享到朋友圈”按钮时的回调。
@@ -56,7 +56,7 @@ declare module './index' {
56
56
  * 页面初次渲染完成的回调。
57
57
  * 此时页面已经准备妥当,可以和视图层进行交互。
58
58
  */
59
- useReady(callback: () => any): void
59
+ useReady(callback: () => void): void
60
60
 
61
61
  /**
62
62
  * 获取当前路由参数。
@@ -67,18 +67,18 @@ declare module './index' {
67
67
  * 导航栏的标题被点击时的回调。
68
68
  * **仅支付宝小程序支持。**
69
69
  */
70
- useTitleClick(callback: () => any): void
70
+ useTitleClick(callback: () => void): void
71
71
 
72
72
  /**
73
73
  * 导航栏的额外图标被点击时的回调。
74
74
  * **仅支付宝小程序支持。**
75
75
  */
76
- useOptionMenuClick(callback: () => any): void
76
+ useOptionMenuClick(callback: () => void): void
77
77
 
78
78
  /**
79
79
  * 下拉中断时的回调。
80
80
  * **仅支付宝小程序支持。**
81
81
  */
82
- usePullIntercept(callback: () => any): void
82
+ usePullIntercept(callback: () => void): void
83
83
  }
84
84
  }
@@ -55,6 +55,13 @@ declare module './index' {
55
55
  scrollTop: number
56
56
  }
57
57
 
58
+ interface PageResizeObject {
59
+ size: {
60
+ windowWidth: number
61
+ windowHeight: number
62
+ }
63
+ }
64
+
58
65
  interface ShareAppMessageObject {
59
66
  /**
60
67
  * 转发事件来源
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