@tarojs/taro 3.5.0-canary.0 → 3.5.0-canary.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/taro",
3
- "version": "3.5.0-canary.0",
3
+ "version": "3.5.0-canary.1",
4
4
  "description": "Taro framework",
5
5
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
6
6
  "main": "index.js",
@@ -26,9 +26,9 @@
26
26
  "author": "O2Team",
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@tarojs/api": "3.5.0-canary.0",
30
- "@tarojs/runtime": "3.5.0-canary.0",
31
- "@tarojs/taro-h5": "3.5.0-canary.0"
29
+ "@tarojs/api": "3.5.0-canary.1",
30
+ "@tarojs/runtime": "3.5.0-canary.1",
31
+ "@tarojs/taro-h5": "3.5.0-canary.1"
32
32
  },
33
- "gitHead": "a0222bc41bc05b0e34413d6db3de963d777a5015"
33
+ "gitHead": "c61624d2f763e6d31e67d6cf9c564efc8b0d0887"
34
34
  }
@@ -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(
@@ -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 {
@@ -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
@@ -328,7 +270,7 @@ declare module '../../index' {
328
270
  previewImage(option: previewImage.Option): Promise<TaroGeneral.CallbackResult>
329
271
 
330
272
  /** 预览图片和视频。
331
- * @supported weapp 基础库 2.12.0 开始支持,低版本需做兼容处理。
273
+ * @supported weapp
332
274
  * @example
333
275
  * ```tsx
334
276
  * Taro.previewMedia({
@@ -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
  }