@tarojs/taro 3.6.0-canary.1 → 3.6.0-canary.10

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.6.0-canary.1",
3
+ "version": "3.6.0-canary.10",
4
4
  "description": "Taro framework",
5
5
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
6
6
  "main": "index.js",
@@ -21,8 +21,8 @@
21
21
  "author": "O2Team",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@tarojs/api": "3.6.0-canary.1",
25
- "@tarojs/runtime": "3.6.0-canary.1"
24
+ "@tarojs/api": "3.6.0-canary.10",
25
+ "@tarojs/runtime": "3.6.0-canary.10"
26
26
  },
27
27
  "peerDependenciesMeta": {
28
28
  "@types/react": {
@@ -3,12 +3,20 @@ import Taro from '../../index'
3
3
  declare module '../../index' {
4
4
  namespace createRewardedVideoAd {
5
5
  interface Option {
6
- /** 广告单元 id */
6
+ /** 小程序广告位 ID
7
+ * @supported weapp, tt, swan
8
+ */
7
9
  adUnitId: string
8
10
  /** 是否启用多例模式
9
11
  * @default false
12
+ * @supported weapp
10
13
  */
11
14
  multiton?: boolean
15
+ /** 小程序应用 ID
16
+ * @supported swan
17
+ * @swan 必填
18
+ */
19
+ appSid?: string
12
20
  }
13
21
  }
14
22
 
@@ -186,7 +194,7 @@ declare module '../../index' {
186
194
 
187
195
  interface TaroStatic {
188
196
  /** 创建激励视频广告组件。
189
- * @supported weapp
197
+ * @supported weapp, tt, swan
190
198
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ad/wx.createRewardedVideoAd.html
191
199
  */
192
200
  createRewardedVideoAd (option: createRewardedVideoAd.Option): RewardedVideoAd
@@ -1,12 +1,26 @@
1
1
  import Taro from '../../index'
2
2
 
3
3
  declare module '../../index' {
4
+ namespace getOpenUserInfo {
5
+ interface Option {
6
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
7
+ complete?:(res: TaroGeneral.CallbackResult) => void
8
+ /** 接口调用失败的回调函数 */
9
+ fail?: (res: TaroGeneral.CallbackResult) => void
10
+ /** 接口调用成功的回调函数 */
11
+ success?: (res: SuccessCallbackResult) => void
12
+ }
13
+ interface SuccessCallbackResult {
14
+ /** 返回一个 Object 类型的对象 res。使用 JSON.parse(res.response).response 解析 */
15
+ response: string
16
+ }
17
+ }
4
18
  interface TaroStatic {
5
19
  /**
6
20
  * 此接口可获取支付宝会员的基础信息(头像图片地址、昵称、性别、国家码、省份、所在市区),接入方法请参考 获取会员基础信息介绍。如需获取支付宝会员标识(user_id),请调用 my.getAuthCode 和 alipay.system.oauth.token 接口。
7
21
  * @supported alipay
8
22
  * @see https://docs.alipay.com/mini/api/ch8chh
9
23
  */
10
- getOpenUserInfo(): Promise<string>
24
+ getOpenUserInfo(Option: getOpenUserInfo.Option): Promise<getOpenUserInfo.SuccessCallbackResult>
11
25
  }
12
26
  }
@@ -100,7 +100,7 @@ declare module '../../index' {
100
100
  * @supported weapp
101
101
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/contact/wx.chooseContact.html
102
102
  */
103
- chooseContact(option: chooseContact.Option): Promise<TaroGeneral.CallbackResult>
103
+ chooseContact(option: chooseContact.Option): Promise<chooseContact.SuccessCallbackResult>
104
104
  /** 添加手机通讯录联系人。用户可以选择将该表单以「新增联系人」或「添加到已有联系人」的方式,写入手机系统通讯录。
105
105
  * @supported weapp
106
106
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/contact/wx.addPhoneContact.html
@@ -62,7 +62,8 @@ declare module '../../index' {
62
62
  /** 实际设置的缩放级别。由于系统限制,某些机型可能无法设置成指定值,会改用最接近的可设值。 */
63
63
  zoom: number
64
64
  /**
65
- * @supported alipay on android
65
+ * @supported alipay
66
+ * @alipay on android
66
67
  */
67
68
  setZoom:number
68
69
  }
@@ -86,19 +87,19 @@ declare module '../../index' {
86
87
  /** 视频的文件的临时路径 */
87
88
  tempVideoPath: string
88
89
  /** 视频文件的高度。
89
- * @supported alipay
90
+ * @supported alipay
90
91
  */
91
92
  height: string
92
93
  /** 视频文件的宽度。
93
- * @supported alipay
94
+ * @supported alipay
94
95
  */
95
96
  width: string
96
97
  /** 视频文件的尺寸。
97
- * @supported alipay
98
+ * @supported alipay
98
99
  */
99
100
  size: string
100
101
  /** 录制的持续时间。
101
- * @supported alipay
102
+ * @supported alipay
102
103
  */
103
104
  duration: string
104
105
  }
@@ -198,7 +199,6 @@ declare module '../../index' {
198
199
  * ```
199
200
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/wx.createCameraContext.html
200
201
  */
201
- createCameraContext(): CameraContext
202
- createCameraContext(id: string): CameraContext
202
+ createCameraContext(id?: string): CameraContext
203
203
  }
204
204
  }
@@ -9,10 +9,14 @@ declare module '../../index' {
9
9
  path?: string
10
10
  /** 需要传递给目标小程序的数据,目标小程序可在 `App.onLaunch`,`App.onShow` 中获取到这份数据。如果跳转的是小游戏,可以在 [Taro.onShow](#)、[Taro.getLaunchOptionsSync](/docs/apis/base/weapp/life-cycle/getLaunchOptionsSync) 中可以获取到这份数据数据。 */
11
11
  extraData?: TaroGeneral.IAnyObject
12
- /** 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版。*/
12
+ /** 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版。 */
13
13
  envVersion?: keyof EnvVersion
14
14
  /** 小程序链接,当传递该参数后,可以不传 appId 和 path。链接可以通过【小程序菜单】->【复制链接】获取。 */
15
15
  shortLink?: string
16
+ /** 校验方式 。默认为binding */
17
+ verify?: keyof Verify
18
+ /** 不 reLaunch 目标小程序,直接打开目标跳转的小程序退后台时的页面,需满足以下条件:1. 目标跳转的小程序生命周期未被销毁;2. 且目标当次启动的path、query、apiCategory与上次启动相同。默认值为 false 。 */
19
+ noRelaunchIfPathUnchanged?: boolean
16
20
  /** 接口调用成功的回调函数 */
17
21
  success?: (res: TaroGeneral.CallbackResult) => void
18
22
  /** 接口调用失败的回调函数 */
@@ -21,6 +25,13 @@ declare module '../../index' {
21
25
  complete?: (res: TaroGeneral.CallbackResult) => void
22
26
  }
23
27
 
28
+ interface Verify {
29
+ /** 校验小程序管理后台的绑定关系 */
30
+ binding
31
+ /** 校验目标打开链接是否为小程序联盟商品。 */
32
+ unionProduct
33
+ }
34
+
24
35
  interface EnvVersion {
25
36
  /** 开发版 */
26
37
  develop
@@ -39,7 +50,7 @@ declare module '../../index' {
39
50
  path?: string
40
51
  /** 需要传递给目标小程序的数据,目标小程序可在 `App.onLaunch`,`App.onShow` 中获取到这份数据。如果跳转的是小游戏,可以在 [Taro.onShow](#)、[Taro.getLaunchOptionsSync](/docs/apis/base/weapp/life-cycle/getLaunchOptionsSync) 中可以获取到这份数据数据。 */
41
52
  extraData?: TaroGeneral.IAnyObject
42
- /** 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版。*/
53
+ /** 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版。 */
43
54
  envVersion?: keyof EnvVersion
44
55
  /** 小程序链接,当传递该参数后,可以不传 appId 和 path。链接可以通过【小程序菜单】->【复制链接】获取。 */
45
56
  shortLink?: string
@@ -9,6 +9,8 @@ declare module '../../index' {
9
9
  filePath?: string
10
10
  /** HTTP 请求的 Header,Header 中不能设置 Referer */
11
11
  header?: TaroGeneral.IAnyObject
12
+ /** 超时时间,单位为毫秒 */
13
+ timeout?: number
12
14
  /** 是否应使用传出凭据 (cookie) 发送此请求
13
15
  * @default true
14
16
  * @supported h5
@@ -505,7 +505,7 @@ declare module '../../index' {
505
505
  * ```tsx
506
506
  * const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true })
507
507
  * ```
508
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createSelectorQuery.html
508
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createIntersectionObserver.html
509
509
  */
510
510
  createIntersectionObserver(
511
511
  /** 自定义组件实例 */
@@ -20,6 +20,12 @@ declare module './index' {
20
20
  * - custom 自定义导航栏
21
21
  */
22
22
  navigationStyle?: 'default' | 'custom'
23
+ /**
24
+ * 在非首页、非页面栈最底层页面或非 tabbar 内页面中的导航栏展示 home 键
25
+ * @default false
26
+ * @supported weapp
27
+ */
28
+ homeButton?: boolean
23
29
  /** 窗口的背景色, HexColor
24
30
  * @default: "#ffffff"
25
31
  */
@@ -44,11 +50,11 @@ declare module './index' {
44
50
  * @default: 50
45
51
  */
46
52
  onReachBottomDistance?: number
47
- /** 屏幕旋转设置
53
+ /** 屏幕旋转设置,支持 auto / portrait / landscape
48
54
  * @see https://developers.weixin.qq.com/miniprogram/dev/framework/view/resizable.html
49
55
  */
50
56
  pageOrientation?: 'auto' | 'portrait' | 'landscape'
51
- /** 页面初始渲染缓存配置,支持 static / dynamic */
57
+ /** 页面[初始渲染缓存](https://developers.weixin.qq.com/miniprogram/dev/framework/view/initial-rendering-cache.html)配置,支持 static / dynamic */
52
58
  initialRenderingCache?: 'static' | 'dynamic'
53
59
  /** 重新启动策略配置
54
60
  * - homePage: 如果从这个页面退出小程序,下次将从首页冷启动
@@ -56,6 +62,90 @@ declare module './index' {
56
62
  * @default "homePage"
57
63
  */
58
64
  restartStrategy?: 'homePage' | 'homePageAndLatestPage'
65
+ /**
66
+ * 切入系统后台时,隐藏页面内容,保护用户隐私。支持 hidden / none
67
+ * @default "none"
68
+ */
69
+ visualEffectInBackground?: 'hidden' | 'none'
70
+ /**
71
+ * 控制[预加载下个页面的时机](https://developers.weixin.qq.com/miniprogram/dev/framework/performance/tips/runtime_nav.html#_2-4-%E6%8E%A7%E5%88%B6%E9%A2%84%E5%8A%A0%E8%BD%BD%E4%B8%8B%E4%B8%AA%E9%A1%B5%E9%9D%A2%E7%9A%84%E6%97%B6%E6%9C%BA)。
72
+ * 支持 static / manual / auto
73
+ */
74
+ handleWebviewPreload?: string
75
+ /** 是否允许向下拉拽。
76
+ * @default: "YES"
77
+ * @supported alipay
78
+ */
79
+ allowsBounceVertical?: 'YES' | 'NO'
80
+ /**
81
+ * 下拉露出显示背景图的底色。例:白色 "#FFFFFF"。**仅安卓下有效,iOS 下页面背景图底色会使用 backgroundColor 的值**
82
+ * @supported alipay
83
+ * @type {HexColor}
84
+ */
85
+ backgroundImageColor?: string
86
+ /**
87
+ * 下拉露出显示背景图的链接
88
+ * @supported alipay
89
+ */
90
+ backgroundImageUrl?: string
91
+ /**
92
+ * 页面默认标题
93
+ * @supported alipay
94
+ */
95
+ defaultTitle?: string
96
+ /**
97
+ * 仅支持 Android,是否显示 WebView 滚动条。默认 YES,支持 YES / NO。
98
+ * @default "YES"
99
+ * @supported alipay
100
+ */
101
+ enableScrollBar?: string
102
+ /**
103
+ * 仅支持 iOS,是否支持手势返回。默认 YES,支持 YES / NO。
104
+ * @supported alipay
105
+ */
106
+ gestureBack?: string
107
+ /** 是否允许下拉刷新
108
+ * @desc
109
+ * 1. 下拉刷新生效的前提是 allowsBounceVertical 值为 true
110
+ * 2. window 全局配置后全局生效,但是如果单个页面配置了该参数,以页面的配置为准。
111
+ * @default true
112
+ * @supported alipay
113
+ */
114
+ pullRefresh?: boolean
115
+ /**
116
+ * rpx 单位是否宽度自适应 ,默认 true,当设置为 false 时,2 rpx 将恒等于 1 px,不再根据屏幕宽度进行自适应,注意,此时 750 rpx 将不再等于 100% 宽度。
117
+ * @supported alipay
118
+ */
119
+ responsive?: boolean
120
+ /**
121
+ * 是否进入时显示导航栏的 loading。默认 NO,支持 YES / NO。
122
+ * @default "NO"
123
+ * @supported alipay
124
+ */
125
+ showTitleLoading?: string
126
+ /**
127
+ * 导航栏透明设置。默认 none,支持 always 一直透明 / auto 滑动自适应 / none 不透明。
128
+ * @default "none"
129
+ * @supported alipay
130
+ */
131
+ transparentTitle?: string
132
+ /**
133
+ * 是否允许导航栏点击穿透。默认 NO,支持 YES / NO。
134
+ * @default "NO"
135
+ * @supported alipay
136
+ */
137
+ titlePenetrate?: string
138
+ /**
139
+ * 导航栏图片地址。
140
+ * @supported alipay
141
+ */
142
+ titleImage?: string
143
+ /**
144
+ * 导航栏背景色。例:白色 "#FFFFFF"。
145
+ * @supported alipay
146
+ * @type {HexColor}
147
+ */
148
+ titleBarColor?: string
59
149
  }
60
150
 
61
151
  interface PageConfig extends CommonConfig {
@@ -91,24 +181,51 @@ declare module './index' {
91
181
  style?: string
92
182
  /** 单页模式相关配置 */
93
183
  singlePage?: SinglePage
94
- }
95
-
96
- interface WindowConfig extends CommonConfig {
97
- /** 切入系统后台时,隐藏页面内容,保护用户隐私。支持 hidden / none
98
- * @default none
184
+ /**
185
+ * 事件监听是否为 passive
186
+ * @default false
187
+ * @see https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#enablePassiveEvent
188
+ */
189
+ enablePassiveEvent?:
190
+ | boolean
191
+ | {
192
+ /**
193
+ * 是否设置 touchstart 事件为 passive
194
+ * @default false
195
+ */
196
+ touchstart?: boolean
197
+ /**
198
+ * 是否设置 touchmove 事件为 passive
199
+ * @default false
200
+ */
201
+ touchmove?: boolean
202
+ /**
203
+ * 是否设置 wheel 事件为 passive
204
+ * @default false
205
+ */
206
+ wheel?: boolean
207
+ }
208
+ /**
209
+ * 渲染后端
210
+ * @default "webview"
99
211
  */
100
- visualEffectInBackground?: 'hidden' | 'none'
101
- /** 是否允许下拉刷新
102
- * 备注:下拉刷新生效的前提是 allowsBounceVertical 值为 YES
103
- * @default: "NO"
212
+ renderer?: 'webview' | 'skyline'
213
+ /**
214
+ * 设置导航栏额外图标,目前支持设置属性 icon,值为图标 url(以 https/http 开头)或 base64 字符串,大小建议 30*30 px
215
+ *
216
+ * 点击后触发 onOptionMenuClick(**注意**:该配置即将废弃。)。
217
+ * @supported alipay
104
218
  */
105
- pullRefresh?: 'YES' | 'NO' | boolean
106
- /** 是否允许向下拉拽
107
- * @default: "YES"
219
+ optionMenu?: Record<string, string>
220
+ /**
221
+ * 设置导航栏图标主题,仅支持真机预览。"default" 为蓝色图标,"light" 为白色图标。
222
+ * @supported alipay
108
223
  */
109
- allowsBounceVertical?: 'YES' | 'NO'
224
+ barButtonTheme?: string
110
225
  }
111
226
 
227
+ interface WindowConfig extends CommonConfig {}
228
+
112
229
  interface TabBarItem {
113
230
  /** 页面路径,必须在 pages 中先定义 */
114
231
  pagePath: string
@@ -283,7 +400,16 @@ declare module './index' {
283
400
  * - chooseAddress: 获取用户地址信息
284
401
  * @see https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#requiredPrivateInfos
285
402
  */
286
- requiredPrivateInfos?: ('getFuzzyLocation' | 'getLocation' | 'onLocationChange' | 'startLocationUpdate' | 'startLocationUpdateBackground' | 'chooseLocation' | 'choosePoi' | 'chooseAddress')[]
403
+ requiredPrivateInfos?: (
404
+ | 'getFuzzyLocation'
405
+ | 'getLocation'
406
+ | 'onLocationChange'
407
+ | 'startLocationUpdate'
408
+ | 'startLocationUpdateBackground'
409
+ | 'chooseLocation'
410
+ | 'choosePoi'
411
+ | 'chooseAddress'
412
+ )[]
287
413
  /** 使用到的插件
288
414
  * @since 1.9.6
289
415
  */
@@ -377,15 +503,32 @@ declare module './index' {
377
503
  /** 是否开启 FPS 面板,默认false */
378
504
  enableFPSPanel?: boolean
379
505
  }
380
- /** touch 事件监听是否为 passive,默认false */
381
- enablePassiveEvent?: boolean | {
382
- /** 是否设置 touchstart 事件为 passive,默认false */
383
- touchstart?: boolean
384
- /** 是否设置 touchmove 事件为 passive,默认false */
385
- touchmove?: boolean
386
- /** 是否设置 wheel 事件为 passive,默认false */
387
- wheel?: boolean
388
- }
506
+ /**
507
+ * touch 相关事件默认的 passive 为 false。如果小程序不使用 catchtouch 事件时,可以通过这个选项将 passive 置为 true,以提高滚动性能。
508
+ * 具体原理可参考[MDN](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners)
509
+ *
510
+ * 可以直接设置这个选项为 true,也可以分别控制某个事件。
511
+ * @default false
512
+ */
513
+ enablePassiveEvent?:
514
+ | boolean
515
+ | {
516
+ /**
517
+ * 是否设置 touchstart 事件为 passive
518
+ * @default false
519
+ */
520
+ touchstart?: boolean
521
+ /**
522
+ * 是否设置 touchmove 事件为 passive
523
+ * @default false
524
+ */
525
+ touchmove?: boolean
526
+ /**
527
+ * 是否设置 wheel 事件为 passive
528
+ * @default false
529
+ */
530
+ wheel?: boolean
531
+ }
389
532
  /** 自定义模块映射规则 */
390
533
  resolveAlias?: Record<string, string>
391
534
  /** 接受一个数组,每一项都是字符串,来指定编译为原生小程序组件的组件入口 */
@@ -400,6 +543,11 @@ declare module './index' {
400
543
  * @since 3.3.18
401
544
  */
402
545
  animation?: RouterAnimate | boolean
546
+ /**
547
+ * 指定小程序全局的默认渲染后端。
548
+ * @default "webview"
549
+ */
550
+ renderer?: 'webview' | 'skyline'
403
551
  }
404
552
 
405
553
  interface Config extends PageConfig, AppConfig {
@@ -422,4 +570,3 @@ declare module './index' {
422
570
  Config: Config
423
571
  }
424
572
  }
425
-
@@ -6,7 +6,7 @@ declare module './index' {
6
6
  * 页面展示时的回调。
7
7
  * @supported global
8
8
  */
9
- useDidShow(callback: () => void): void
9
+ useDidShow(callback: (options?: getLaunchOptionsSync.LaunchOptions) => void): void
10
10
 
11
11
  /**
12
12
  * 页面隐藏时的回调。
@@ -83,6 +83,12 @@ declare module './index' {
83
83
  */
84
84
  useError(callback: (error: string) => void): void
85
85
 
86
+ /**
87
+ * 小程序有未处理的 Promise reject 时触发。也可以使用 Taro.onUnhandledRejection 绑定监听。
88
+ * @supported weapp, alipay
89
+ */
90
+ useUnhandledRejection(callback: (error: { reason: Error, promise: Promise<Error> }) => void): void
91
+
86
92
  /**
87
93
  * 小程序要打开的页面不存在时触发的回调。
88
94
  * @supported weapp, h5
@@ -94,7 +100,7 @@ declare module './index' {
94
100
  * 页面加载完成时的回调。
95
101
  * @supported weapp, h5
96
102
  */
97
- useLoad(callback: () => void): void
103
+ useLoad<T extends {} = Record<string, any>>(callback: (param: T) => void): void
98
104
 
99
105
  /**
100
106
  * 页面卸载时的回调。