@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 CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "@tarojs/taro",
3
- "version": "3.4.0-beta.1",
3
+ "version": "3.4.1",
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.1",
30
- "@tarojs/runtime": "3.4.0-beta.1",
31
- "@tarojs/taro-h5": "3.4.0-beta.1"
27
+ "@tarojs/api": "3.4.1",
28
+ "@tarojs/runtime": "3.4.1",
29
+ "@tarojs/taro-h5": "3.4.1"
32
30
  },
33
- "gitHead": "bd7b3674278d22f71e2658b530cc0be24bf9964e"
31
+ "gitHead": "a2437215b1966fd0b6dd09311bcb4fd894a871d0"
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(
@@ -153,22 +153,16 @@ declare module '../../index' {
153
153
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.html
154
154
  */
155
155
  interface InnerAudioContext {
156
+ /** 音频资源的地址,用于直接播放。 */
157
+ src: string
158
+ /** 开始播放的位置(单位:s)
159
+ * @default 0
160
+ */
161
+ startTime: number
156
162
  /** 是否自动开始播放
157
163
  * @default false
158
164
  */
159
165
  autoplay: boolean
160
- /** 音频缓冲的时间点,仅保证当前播放时间点到此时间点内容已缓冲
161
- * @readonly
162
- */
163
- buffered: number
164
- /** 当前音频的播放位置(单位 s)。只有在当前有合法的 src 时返回,时间保留小数点后 6 位
165
- * @readonly
166
- */
167
- currentTime: number
168
- /** 当前音频的长度(单位 s)。只有在当前有合法的 src 时返回
169
- * @readonly
170
- */
171
- duration: number
172
166
  /** 是否循环播放
173
167
  * @default false
174
168
  */
@@ -177,16 +171,6 @@ declare module '../../index' {
177
171
  * @default true
178
172
  */
179
173
  obeyMuteSwitch: boolean
180
- /** 当前是是否暂停或停止状态
181
- * @readonly
182
- */
183
- paused: boolean
184
- /** 音频资源的地址,用于直接播放。 */
185
- src: string
186
- /** 开始播放的位置(单位:s)
187
- * @default 0
188
- */
189
- startTime: number
190
174
  /** 音量。范围 0~1。
191
175
  * @default 1
192
176
  */
@@ -195,6 +179,24 @@ declare module '../../index' {
195
179
  * @default 1
196
180
  */
197
181
  playbackRate: number
182
+ /** 当前音频的长度(单位 s)。只有在当前有合法的 src 时返回
183
+ * @readonly
184
+ */
185
+ duration: number
186
+ /** 当前音频的播放位置(单位 s)。只有在当前有合法的 src 时返回,时间保留小数点后 6 位
187
+ * @readonly
188
+ */
189
+ currentTime: number
190
+ /** 当前是是否暂停或停止状态
191
+ * @readonly
192
+ */
193
+ paused: boolean
194
+ /** 音频缓冲的时间点,仅保证当前播放时间点到此时间点内容已缓冲
195
+ * @readonly
196
+ */
197
+ buffered: number
198
+ /** origin: 发送完整的 referrer; no-referrer: 不发送 */
199
+ referrerPolicy?: 'origin' | 'no-referrer' | string
198
200
  /** 播放 */
199
201
  play(): void
200
202
  /** 暂停 */
@@ -100,70 +100,76 @@ declare module '../../index' {
100
100
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/background-audio/BackgroundAudioManager.html
101
101
  */
102
102
  interface BackgroundAudioManager {
103
- /** 音频已缓冲的时间,仅保证当前播放时间点到此时间点内容已缓冲。
104
- * @readonly
105
- */
106
- buffered: number
103
+ /** 音频的数据源([2.2.3](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 开始支持云文件ID)。默认为空字符串,**当设置了新的 src 时,会自动开始播放**,目前支持的格式有 m4a, aac, mp3, wav。 */
104
+ src: string
105
+ /** 音频开始播放的位置(单位:s)。 */
106
+ startTime: number
107
+ /** 音频标题,用于原生音频播放器音频标题(必填)。原生音频播放器中的分享功能,分享出去的卡片标题,也将使用该值。 */
108
+ title: string
109
+ /** 专辑名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
110
+ epname: string
111
+ /** 歌手名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
112
+ singer: string
107
113
  /** 封面图 URL,用于做原生音频播放器背景图。原生音频播放器中的分享功能,分享出去的卡片配图及背景也将使用该图。 */
108
114
  coverImgUrl: string
109
- /** 当前音频的播放位置(单位:s),只有在有合法 src 时返回。
110
- * @readonly
115
+ /** 页面链接,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
116
+ webUrl: string
117
+ /** 音频协议。默认值为 'http',设置 'hls' 可以支持播放 HLS 协议的直播音频。 */
118
+ protocol: string
119
+ /** 播放速度。范围 0.5-2.0。
120
+ * @default 1
111
121
  */
112
- currentTime: number
122
+ playbackRate?: number
113
123
  /** 当前音频的长度(单位:s),只有在有合法 src 时返回。
114
124
  * @readonly
115
125
  */
116
126
  duration: number
117
- /** 专辑名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
118
- epname: string
127
+ /** 当前音频的播放位置(单位:s),只有在有合法 src 时返回。
128
+ * @readonly
129
+ */
130
+ currentTime: number
119
131
  /** 当前是否暂停或停止。
120
132
  * @readonly
121
133
  */
122
134
  paused: boolean
123
- /** 音频协议。默认值为 'http',设置 'hls' 可以支持播放 HLS 协议的直播音频。 */
124
- protocol: string
125
- /** 歌手名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
126
- singer: string
127
- /** 音频的数据源([2.2.3](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 开始支持云文件ID)。默认为空字符串,**当设置了新的 src 时,会自动开始播放**,目前支持的格式有 m4a, aac, mp3, wav。 */
128
- src: string
129
- /** 音频开始播放的位置(单位:s)。 */
130
- startTime: number
131
- /** 音频标题,用于原生音频播放器音频标题(必填)。原生音频播放器中的分享功能,分享出去的卡片标题,也将使用该值。 */
132
- title: string
133
- /** 页面链接,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */
134
- webUrl: string
135
+ /** 音频已缓冲的时间,仅保证当前播放时间点到此时间点内容已缓冲。
136
+ * @readonly
137
+ */
138
+ buffered: number
139
+ /** origin: 发送完整的 referrer; no-referrer: 不发送 */
140
+ referrerPolicy?: 'origin' | 'no-referrer' | string
135
141
  /** 播放 */
136
142
  play(): void
137
143
  /** 暂停 */
138
144
  pause(): void
139
- /** 停止 */
140
- stop(): void
141
145
  /** 跳转到指定位置,单位 s */
142
146
  seek(position: any): void
147
+ /** 停止 */
148
+ stop(): void
143
149
  /** 背景音频进入可以播放状态,但不保证后面可以流畅播放 */
144
150
  onCanplay(callback?: () => void): void
151
+ /** 音频加载中事件,当音频因为数据不足,需要停下来加载时会触发 */
152
+ onWaiting(callback?: () => void): void
153
+ /** 背景音频播放错误事件 */
154
+ onError(callback?: () => void): void
145
155
  /** 背景音频播放事件 */
146
156
  onPlay(callback?: () => void): void
147
157
  /** 背景音频暂停事件 */
148
158
  onPause(callback?: () => void): void
149
- /** 背景音频停止事件 */
150
- onStop(callback?: () => void): void
159
+ /** 背景音频开始跳转操作事件 */
160
+ onSeeking(callback?: () => void): void
161
+ /** 背景音频完成跳转操作事件 */
162
+ onSeeked(callback?: () => void): void
151
163
  /** 背景音频自然播放结束事件 */
152
164
  onEnded(callback?: () => void): void
165
+ /** 背景音频停止事件 */
166
+ onStop(callback?: () => void): void
153
167
  /** 背景音频播放进度更新事件 */
154
168
  onTimeUpdate(callback?: () => void): void
155
169
  /** 用户在系统音乐播放面板点击上一曲事件(iOS only) */
156
170
  onPrev(callback?: () => void): void
157
171
  /** 用户在系统音乐播放面板点击下一曲事件(iOS only) */
158
172
  onNext(callback?: () => void): void
159
- /** 背景音频播放错误事件 */
160
- onError(callback?: () => void): void
161
- /** 音频加载中事件,当音频因为数据不足,需要停下来加载时会触发 */
162
- onWaiting(callback?: () => void): void
163
- /** 背景音频开始跳转操作事件 */
164
- onSeeking(callback?: () => void): void
165
- /** 背景音频完成跳转操作事件 */
166
- onSeeked(callback?: () => void): void
167
173
  }
168
174
 
169
175
  interface TaroStatic {
@@ -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
@@ -330,7 +270,7 @@ declare module '../../index' {
330
270
  previewImage(option: previewImage.Option): Promise<TaroGeneral.CallbackResult>
331
271
 
332
272
  /** 预览图片和视频。
333
- * @supported weapp 基础库 2.12.0 开始支持,低版本需做兼容处理。
273
+ * @supported weapp
334
274
  * @example
335
275
  * ```tsx
336
276
  * Taro.previewMedia({
@@ -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
  }