@tarojs/taro 3.7.0-canary.6 → 4.0.0-alpha.0

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.7.0-canary.6",
3
+ "version": "4.0.0-alpha.0",
4
4
  "description": "Taro framework",
5
5
  "homepage": "https://github.com/nervjs/taro/tree/master/packages/taro#readme",
6
6
  "main": "index.js",
@@ -21,12 +21,12 @@
21
21
  "author": "O2Team",
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@tarojs/api": "3.7.0-canary.6",
25
- "@tarojs/runtime": "3.7.0-canary.6"
24
+ "@tarojs/api": "4.0.0-alpha.0",
25
+ "@tarojs/runtime": "4.0.0-alpha.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@tarojs/shared": "3.7.0-canary.6",
29
- "@tarojs/helper": "3.7.0-canary.6"
28
+ "@tarojs/shared": "4.0.0-alpha.0",
29
+ "@tarojs/helper": "4.0.0-alpha.0"
30
30
  },
31
31
  "peerDependenciesMeta": {
32
32
  "@types/react": {
@@ -546,7 +546,7 @@ declare module '../../index' {
546
546
  getSystemSetting(): getSystemSetting.Result
547
547
 
548
548
  /** [Taro.getSystemInfo](./getSystemInfo) 的同步版本
549
- * @supported weapp, h5, rn, tt
549
+ * @supported weapp, h5, rn, tt, harmony
550
550
  * @h5 不支持 version、statusBarHeight、fontSizeSetting、SDKVersion
551
551
  * @weapp 小程序可以在微信和企业微信中调用此接口,但是在企业微信中调用此接口时,会额外返回一个 environment 字段(微信中不返回),如此字段值为 wxwork,则表示当前小程序运行在企业微信环境中。
552
552
  * @example
@@ -591,7 +591,7 @@ declare module '../../index' {
591
591
  getSystemInfoAsync(res?: getSystemInfoAsync.Option): Promise<getSystemInfo.Result>
592
592
 
593
593
  /** 获取系统信息,支持 `Promise` 化使用。
594
- * @supported weapp, h5, rn, tt
594
+ * @supported weapp, h5, rn, tt, harmony
595
595
  * @h5 不支持 version、statusBarHeight、fontSizeSetting、SDKVersion
596
596
  * @weapp 小程序可以在微信和企业微信中调用此接口,但是在企业微信中调用此接口时,会额外返回一个 environment 字段(微信中不返回),如此字段值为 wxwork,则表示当前小程序运行在企业微信环境中。
597
597
  * @example
@@ -113,7 +113,7 @@ declare module '../../../index' {
113
113
  *
114
114
  * **注意**
115
115
  * - 所有的 unhandledRejection 都可以被这一监听捕获,但只有 Error 类型的才会在小程序后台触发报警。
116
- * @supported weapp, tt, h5
116
+ * @supported weapp, tt, h5, harmony
117
117
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onUnhandledRejection.html
118
118
  */
119
119
  onUnhandledRejection<T = any>(callback: onUnhandledRejection.Callback<T>): void
@@ -137,7 +137,7 @@ declare module '../../../index' {
137
137
  onPageNotFound(callback: onPageNotFound.Callback): void
138
138
 
139
139
  /** 监听小程序错误事件。如脚本错误或 API 调用报错等。该事件与 [`App.onError`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onerrorstring-error) 的回调时机与参数一致。
140
- * @supported weapp, tt, h5
140
+ * @supported weapp, tt, h5, harmony
141
141
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onError.html
142
142
  */
143
143
  onError(callback: onError.Callback): void
@@ -196,7 +196,7 @@ declare module '../../../index' {
196
196
  ): void
197
197
 
198
198
  /** 取消监听未处理的 Promise 拒绝事件
199
- * @supported weapp, tt, h5
199
+ * @supported weapp, tt, h5, harmony
200
200
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offUnhandledRejection.html
201
201
  */
202
202
  offUnhandledRejection<T = any>(callback: onUnhandledRejection.Callback<T>): void
@@ -217,7 +217,7 @@ declare module '../../../index' {
217
217
  ): void
218
218
 
219
219
  /** 取消监听音频播放错误事件
220
- * @supported weapp, tt, h5
220
+ * @supported weapp, tt, h5, harmony
221
221
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offError.html
222
222
  */
223
223
 
@@ -56,7 +56,7 @@ declare module '../../index' {
56
56
  * ```tsx
57
57
  * Taro.startAccelerometer({ interval: 'game' })
58
58
  * ```
59
- * @supported weapp, alipay, swan, jd, qq, tt, h5, rn
59
+ * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony
60
60
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.startAccelerometer.html
61
61
  */
62
62
  startAccelerometer (res?: startAccelerometer.Option): Promise<TaroGeneral.CallbackResult>
@@ -67,14 +67,14 @@ declare module '../../index' {
67
67
  * ```tsx
68
68
  * Taro.stopAccelerometer()
69
69
  * ```
70
- * @supported weapp, alipay, swan, jd, qq, tt, h5, rn
70
+ * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony
71
71
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.stopAccelerometer.html
72
72
  */
73
73
  stopAccelerometer (res?: stopAccelerometer.Option): Promise<TaroGeneral.CallbackResult>
74
74
 
75
75
  /**
76
76
  * 监听加速度数据,频率:5次/秒,接口调用后会自动开始监听,可使用 `Taro.stopAccelerometer` 停止监听。
77
- * @supported weapp, alipay, swan, jd, qq, tt, h5, rn
77
+ * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony
78
78
  * @example
79
79
  * ```tsx
80
80
  * Taro.onAccelerometerChange(res => {
@@ -91,7 +91,7 @@ declare module '../../index' {
91
91
 
92
92
  /**
93
93
  * 取消监听加速度数据事件,参数为空,则取消所有的事件监听。
94
- * @supported weapp, alipay, swan, jd, tt, h5, rn
94
+ * @supported weapp, alipay, swan, jd, tt, h5, rn, harmony
95
95
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.offAccelerometerChange.html
96
96
  */
97
97
  offAccelerometerChange(
@@ -32,13 +32,13 @@ declare module '../../index' {
32
32
 
33
33
  interface TaroStatic {
34
34
  /** Taro.getBatteryInfo 的同步版本
35
- * @supported weapp, alipay, swan, jd, qq
35
+ * @supported weapp, alipay, swan, jd, qq, harmony
36
36
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/battery/wx.getBatteryInfoSync.html
37
37
  */
38
38
  getBatteryInfoSync(): getBatteryInfoSync.Result
39
39
 
40
40
  /** 获取设备电量。同步 API Taro.getBatteryInfoSync 在 iOS 上不可用。
41
- * @supported weapp, alipay, swan, jd, qq, h5
41
+ * @supported weapp, alipay, swan, jd, qq, h5, harmony
42
42
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/battery/wx.getBatteryInfo.html
43
43
  */
44
44
  getBatteryInfo(option?: getBatteryInfo.Option): Promise<getBatteryInfo.SuccessCallbackResult>
@@ -43,7 +43,7 @@ declare module '../../index' {
43
43
 
44
44
  interface TaroStatic {
45
45
  /** 设置系统剪贴板的内容。调用成功后,会弹出 toast 提示"内容已复制",持续 1.5s
46
- * @supported weapp, swan, jd, qq, tt, h5, rn
46
+ * @supported weapp, swan, jd, qq, tt, h5, rn, harmony
47
47
  * @h5 部分实现
48
48
  * @example
49
49
  * ```tsx
@@ -64,7 +64,7 @@ declare module '../../index' {
64
64
 
65
65
  /**
66
66
  * 获取系统剪贴板内容
67
- * @supported weapp, swan, jd, qq, tt, h5, rn
67
+ * @supported weapp, swan, jd, qq, tt, h5, rn, harmony
68
68
  * @h5 部分实现
69
69
  * @example
70
70
  * ```tsx
@@ -71,7 +71,7 @@ declare module '../../index' {
71
71
  getSelectedTextRange(option?: getSelectedTextRange.Option): Promise<getSelectedTextRange.SuccessCallbackResult>
72
72
 
73
73
  /** 监听键盘高度变化
74
- * @supported weapp, swan, jd, qq, rn
74
+ * @supported weapp, swan, jd, qq, rn, harmony
75
75
  * @example
76
76
  * ```tsx
77
77
  * Taro.onKeyboardHeightChange(res => {
@@ -86,7 +86,7 @@ declare module '../../index' {
86
86
 
87
87
  /**
88
88
  * 取消监听键盘高度变化事件。
89
- * @supported weapp, swan, jd, rn
89
+ * @supported weapp, swan, jd, rn, harmony
90
90
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.offKeyboardHeightChange.html
91
91
  */
92
92
  offKeyboardHeightChange(
@@ -107,7 +107,7 @@ declare module '../../index' {
107
107
  ): void
108
108
 
109
109
  /** 监听网络状态变化。
110
- * @supported weapp, swan, h5, rn, tt
110
+ * @supported weapp, swan, h5, rn, tt, harmony
111
111
  * @example
112
112
  * ```tsx
113
113
  * Taro.onNetworkStatusChange(function (res) {
@@ -132,7 +132,7 @@ declare module '../../index' {
132
132
  ): void
133
133
 
134
134
  /** 取消监听网络状态变化事件,参数为空,则取消所有的事件监听。
135
- * @supported weapp, swan, h5, rn
135
+ * @supported weapp, swan, h5, rn, harmony
136
136
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/network/wx.offNetworkStatusChange.html
137
137
  */
138
138
  offNetworkStatusChange(
@@ -141,7 +141,7 @@ declare module '../../index' {
141
141
  ): void
142
142
 
143
143
  /** 获取网络类型。
144
- * @supported weapp, swan, qq, h5, rn, tt
144
+ * @supported weapp, swan, qq, h5, rn, tt, harmony
145
145
  * @example
146
146
  * ```tsx
147
147
  * Taro.getNetworkType({
@@ -16,7 +16,7 @@ declare module '../../index' {
16
16
 
17
17
  interface TaroStatic {
18
18
  /** 拨打电话
19
- * @supported weapp, swan, jd, qq, tt, h5, rn
19
+ * @supported weapp, swan, jd, qq, tt, h5, rn, harmony
20
20
  * @example
21
21
  * ```tsx
22
22
  * Taro.makePhoneCall({
@@ -207,7 +207,7 @@ declare module '../../index' {
207
207
  *
208
208
  * **说明**
209
209
  * - 若安卓系统设置中开启了自动调节亮度功能,则屏幕亮度会根据光线自动调整,该接口仅能获取自动调节亮度之前的值,而非实时的亮度值。
210
- * @supported weapp, alipay, swan, jd, qq, rn
210
+ * @supported weapp, alipay, swan, jd, qq, rn, harmony
211
211
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.getScreenBrightness.html
212
212
  */
213
213
  getScreenBrightness(
@@ -29,7 +29,7 @@ declare module '../../index' {
29
29
  /** 使手机发生较短时间的振动(15 ms)。仅在 iPhone `7 / 7 Plus` 以上及 Android 机型生效
30
30
  *
31
31
  * 仅微信小程序平台支持 type 参数
32
- * @supported weapp, alipay, swan, jd, qq, tt, h5, rn
32
+ * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony
33
33
  * @example
34
34
  * ```tsx
35
35
  * Taro.vibrateShort(params).then(...)
@@ -39,7 +39,7 @@ declare module '../../index' {
39
39
  vibrateShort(option?: vibrateShort.Option): Promise<TaroGeneral.CallbackResult>
40
40
 
41
41
  /** 使手机发生较长时间的振动(400ms)
42
- * @supported weapp, alipay, swan, jd, qq, tt, h5, rn
42
+ * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony
43
43
  * @example
44
44
  * ```tsx
45
45
  * Taro.vibrateLong(params).then(...)
@@ -361,7 +361,7 @@ declare module '../../index' {
361
361
  previewImage(option: previewImage.Option): Promise<TaroGeneral.CallbackResult>
362
362
 
363
363
  /** 获取图片信息。网络图片需先配置download域名才能生效。
364
- * @supported weapp, alipay, swan, tt, h5, rn
364
+ * @supported weapp, alipay, swan, tt, h5, rn, harmony
365
365
  * @example
366
366
  * ```tsx
367
367
  * Taro.getImageInfo({
@@ -400,7 +400,7 @@ declare module '../../index' {
400
400
  * - 对于 `GET` 方法的数据,会将数据转换成 query string(`encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...`)
401
401
  * - 对于 `POST` 方法且 `header['content-type']` 为 `application/json` 的数据,会对数据进行 JSON 序列化
402
402
  * - 对于 `POST` 方法且 `header['content-type']` 为 `application/x-www-form-urlencoded` 的数据,会将数据转换成 query string `(encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...)`
403
- * @supported weapp, h5, rn, alipay, swan, tt, qq
403
+ * @supported weapp, h5, rn, alipay, swan, tt, qq, harmony
404
404
  * @example
405
405
  * ```tsx
406
406
  * Taro.request({
@@ -117,7 +117,7 @@ declare module '../../index' {
117
117
 
118
118
  interface TaroStatic {
119
119
  /** 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面
120
- * @supported weapp, h5, rn, tt
120
+ * @supported weapp, h5, rn, tt, harmony
121
121
  * @example
122
122
  * ```json
123
123
  * {
@@ -143,7 +143,7 @@ declare module '../../index' {
143
143
  switchTab(option: switchTab.Option): Promise<TaroGeneral.CallbackResult>
144
144
 
145
145
  /** 关闭所有页面,打开到应用内的某个页面
146
- * @supported weapp, h5, rn, tt
146
+ * @supported weapp, h5, rn, tt, harmony
147
147
  * @example
148
148
  * ```tsx
149
149
  * Taro.reLaunch({
@@ -155,7 +155,7 @@ declare module '../../index' {
155
155
  reLaunch(option: reLaunch.Option): Promise<TaroGeneral.CallbackResult>
156
156
 
157
157
  /** 关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面。
158
- * @supported weapp, h5, rn, tt
158
+ * @supported weapp, h5, rn, tt, harmony
159
159
  * @h5 未针对 tabbar 页面做限制处理
160
160
  * @example
161
161
  * ```tsx
@@ -168,7 +168,7 @@ declare module '../../index' {
168
168
  redirectTo(option: redirectTo.Option): Promise<TaroGeneral.CallbackResult>
169
169
 
170
170
  /** 保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 Taro.navigateBack 可以返回到原页面。小程序中页面栈最多十层。
171
- * @supported weapp, h5, rn, tt
171
+ * @supported weapp, h5, rn, tt, harmony
172
172
  * @h5 未针对 tabbar 页面做限制处理
173
173
  * @example
174
174
  * ```tsx
@@ -195,7 +195,7 @@ declare module '../../index' {
195
195
  navigateTo(option: navigateTo.Option): Promise<TaroGeneral.CallbackResult>
196
196
 
197
197
  /** 关闭当前页面,返回上一页面或多级页面。可通过 getCurrentPages 获取当前的页面栈,决定需要返回几层。
198
- * @supported weapp, h5, rn, tt
198
+ * @supported weapp, h5, rn, tt, harmony
199
199
  * @h5 若入参 delta 大于现有页面数时,返回应用打开的第一个页面(如果想要返回首页请使用 reLaunch 方法)。
200
200
  * @example
201
201
  * ```tsx
@@ -177,7 +177,7 @@ declare module '../../index' {
177
177
  ): void
178
178
 
179
179
  /** 将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。
180
- * @supported weapp, alipay, swan, jd, qq, tt, h5, rn
180
+ * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony
181
181
  * @example
182
182
  * ```tsx
183
183
  * Taro.setStorage({
@@ -221,7 +221,7 @@ declare module '../../index' {
221
221
  ): void
222
222
 
223
223
  /** 从本地缓存中移除指定 key
224
- * @supported weapp, alipay, swan, jd, qq, tt, h5, rn
224
+ * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony
225
225
  * @example
226
226
  * ```tsx
227
227
  * Taro.removeStorage({
@@ -289,7 +289,7 @@ declare module '../../index' {
289
289
  getStorageInfo(option?: getStorageInfo.Option): Promise<TaroGeneral.CallbackResult>
290
290
 
291
291
  /** 从本地缓存中异步获取指定 key 的内容
292
- * @supported weapp, alipay, swan, jd, qq, tt, h5, rn
292
+ * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony
293
293
  * @example
294
294
  * ```tsx
295
295
  * Taro.getStorage({
@@ -327,7 +327,7 @@ declare module '../../index' {
327
327
  clearStorageSync(): void
328
328
 
329
329
  /** 清理本地数据缓存
330
- * @supported weapp, alipay, swan, jd, qq, tt, h5, rn
330
+ * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony
331
331
  * @example
332
332
  * ```tsx
333
333
  * Taro.clearStorage()
@@ -97,7 +97,7 @@ declare module '../index' {
97
97
  }): void
98
98
 
99
99
  /** 小程序获取和 Taro 相关的 App 信息
100
- * @supported weapp, alipay, jd, qq, swan, tt, h5
100
+ * @supported weapp, alipay, jd, qq, swan, tt, h5, harmony
101
101
  */
102
102
  getAppInfo(): getAppInfo.AppInfo
103
103
 
@@ -127,7 +127,13 @@ declare module '../index' {
127
127
  /** 小程序引用插件 JS 接口
128
128
  * @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
129
129
  */
130
- requirePlugin(pluginName: string): any
130
+ requirePlugin: {
131
+ (pluginName: string): any
132
+ /** @supported weapp */
133
+ (pluginName: string, success?: (mod: any) => any, error?: (e: { mod: any; errMsg: string }) => any): any;
134
+ /** @supported weapp */
135
+ async?: (pluginName: string) => Promise<any>
136
+ }
131
137
 
132
138
  /** 获取当前页面实例
133
139
  * @supported global
@@ -410,7 +410,7 @@ declare module '../../index' {
410
410
 
411
411
  interface TaroStatic {
412
412
  /** 创建一个动画实例 [animation](../Animation)。调用实例的方法来描述动画。最后通过动画实例的 export 方法导出动画数据传递给组件的 animation 属性。
413
- * @supported weapp, h5, tt
413
+ * @supported weapp, tt, h5, harmony
414
414
  * @example
415
415
  * ```tsx
416
416
  * var animation = Taro.createAnimation({
@@ -160,7 +160,7 @@ declare module '../../index' {
160
160
  * **注意**
161
161
  * - Taro.showLoading 和 Taro.showToast 同时只能显示一个
162
162
  * - Taro.showToast 应与 Taro.hideToast 配对使用
163
- * @supported weapp, h5, rn, tt
163
+ * @supported weapp, h5, rn, tt, harmony
164
164
  * @example
165
165
  * ```tsx
166
166
  * Taro.showToast({
@@ -177,7 +177,7 @@ declare module '../../index' {
177
177
  * **注意**
178
178
  * - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
179
179
  * - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
180
- * @supported weapp, h5, rn, tt
180
+ * @supported weapp, h5, rn, tt, harmony
181
181
  * @example
182
182
  * ```tsx
183
183
  * Taro.showModal({
@@ -220,7 +220,7 @@ declare module '../../index' {
220
220
  * **注意**
221
221
  * - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
222
222
  * - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
223
- * @supported weapp, h5, rn, tt
223
+ * @supported weapp, h5, rn, tt, harmony
224
224
  * @example
225
225
  * ```tsx
226
226
  * Taro.showActionSheet({
@@ -238,7 +238,7 @@ declare module '../../index' {
238
238
  showActionSheet(option: showActionSheet.Option): Promise<showActionSheet.SuccessCallbackResult>
239
239
 
240
240
  /** 隐藏消息提示框
241
- * @supported weapp, h5, rn, tt
241
+ * @supported weapp, h5, rn, tt, harmony
242
242
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideToast.html
243
243
  */
244
244
  hideToast(option?: hideToast.Option): void
@@ -79,13 +79,13 @@ declare module '../../index' {
79
79
 
80
80
  interface TaroStatic {
81
81
  /** 在当前页面显示导航条加载动画
82
- * @supported weapp, rn, tt
82
+ * @supported weapp, rn, tt, harmony
83
83
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/navigation-bar/wx.showNavigationBarLoading.html
84
84
  */
85
85
  showNavigationBarLoading(option?: showNavigationBarLoading.Option): void
86
86
 
87
87
  /** 动态设置当前页面的标题
88
- * @supported weapp, alipay, h5, rn, tt
88
+ * @supported weapp, alipay, tt, h5, rn, harmony
89
89
  * @example
90
90
  * ```tsx
91
91
  * Taro.setNavigationBarTitle({
@@ -97,7 +97,7 @@ declare module '../../index' {
97
97
  setNavigationBarTitle(option: setNavigationBarTitle.Option): Promise<TaroGeneral.CallbackResult>
98
98
 
99
99
  /** 设置页面导航条颜色
100
- * @supported weapp, h5, rn, tt
100
+ * @supported weapp, tt, h5, rn, harmony
101
101
  * @h5 不支持 animation 参数
102
102
  * @rn 不支持 animation 参数
103
103
  * @example
@@ -116,13 +116,13 @@ declare module '../../index' {
116
116
  setNavigationBarColor(option: setNavigationBarColor.Option): Promise<TaroGeneral.CallbackResult>
117
117
 
118
118
  /** 在当前页面隐藏导航条加载动画
119
- * @supported weapp, rn, tt
119
+ * @supported weapp, rn, tt, harmony
120
120
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/navigation-bar/wx.hideNavigationBarLoading.html
121
121
  */
122
122
  hideNavigationBarLoading(option?: hideNavigationBarLoading.Option): void
123
123
 
124
124
  /** 隐藏返回首页按钮。微信7.0.7版本起,当用户打开的小程序最底层页面是非首页时,默认展示“返回首页”按钮,开发者可在页面 onShow 中调用 hideHomeButton 进行隐藏。
125
- * @supported weapp, tt
125
+ * @supported weapp, tt, harmony
126
126
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/navigation-bar/wx.hideHomeButton.html
127
127
  */
128
128
  hideHomeButton(option?: hideHomeButton.Option): Promise<TaroGeneral.CallbackResult>
@@ -25,7 +25,7 @@ declare module '../../index' {
25
25
 
26
26
  interface TaroStatic {
27
27
  /** 停止当前页面下拉刷新。
28
- * @supported weapp, h5, rn, tt
28
+ * @supported weapp, h5, rn, tt, harmony
29
29
  * @example
30
30
  * ```tsx
31
31
  * onPullDownRefresh: function (){
@@ -37,7 +37,7 @@ declare module '../../index' {
37
37
  stopPullDownRefresh(option?: stopPullDownRefresh.Option): void
38
38
 
39
39
  /** 开始下拉刷新。调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
40
- * @supported weapp, h5, rn, tt
40
+ * @supported weapp, h5, rn, tt, harmony
41
41
  * @rn 无动画效果
42
42
  * @example
43
43
  * ```tsx
@@ -99,7 +99,7 @@ declare module '../../index' {
99
99
  * - 后代选择器:.the-ancestor .the-descendant
100
100
  * - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
101
101
  * - 多选择器的并集:#a-node, .some-other-nodes
102
- * @supported weapp, h5, rn, tt
102
+ * @supported weapp, h5, rn, tt, harmony
103
103
  * @example
104
104
  * ```tsx
105
105
  * Taro.pageScrollTo({
@@ -121,13 +121,13 @@ declare module '../../index' {
121
121
 
122
122
  interface TaroStatic {
123
123
  /** 显示 tabBar 某一项的右上角的红点
124
- * @supported weapp, h5, rn, tt
124
+ * @supported weapp, h5, rn, tt, harmony
125
125
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.showTabBarRedDot.html
126
126
  */
127
127
  showTabBarRedDot(option: showTabBarRedDot.Option): Promise<TaroGeneral.CallbackResult>
128
128
 
129
129
  /** 显示 tabBar
130
- * @supported weapp, h5, rn, tt
130
+ * @supported weapp, h5, rn, tt, harmony
131
131
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.showTabBar.html
132
132
  */
133
133
  showTabBar(option?: showTabBar.Option): Promise<TaroGeneral.CallbackResult>
@@ -148,7 +148,7 @@ declare module '../../index' {
148
148
  setTabBarStyle(option?: setTabBarStyle.Option): Promise<TaroGeneral.CallbackResult>
149
149
 
150
150
  /** 动态设置 tabBar 某一项的内容,`2.7.0` 起图片支持临时文件和网络文件。
151
- * @supported weapp, h5, rn, tt
151
+ * @supported weapp, h5, rn, tt, harmony
152
152
  * @example
153
153
  * ```tsx
154
154
  * Taro.setTabBarItem({
@@ -163,7 +163,7 @@ declare module '../../index' {
163
163
  setTabBarItem(option: setTabBarItem.Option): Promise<TaroGeneral.CallbackResult>
164
164
 
165
165
  /** 为 tabBar 某一项的右上角添加文本
166
- * @supported weapp, h5, rn, tt
166
+ * @supported weapp, h5, rn, tt, harmony
167
167
  * @example
168
168
  * ```tsx
169
169
  * Taro.setTabBarBadge({
@@ -176,19 +176,19 @@ declare module '../../index' {
176
176
  setTabBarBadge(option: setTabBarBadge.Option): Promise<TaroGeneral.CallbackResult>
177
177
 
178
178
  /** 移除 tabBar 某一项右上角的文本
179
- * @supported weapp, h5, rn, tt
179
+ * @supported weapp, h5, rn, tt, harmony
180
180
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.removeTabBarBadge.html
181
181
  */
182
182
  removeTabBarBadge(option: removeTabBarBadge.Option): Promise<TaroGeneral.CallbackResult>
183
183
 
184
184
  /** 隐藏 tabBar 某一项的右上角的红点
185
- * @supported weapp, h5, rn, tt
185
+ * @supported weapp, h5, rn, tt, harmony
186
186
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.hideTabBarRedDot.html
187
187
  */
188
188
  hideTabBarRedDot(option: hideTabBarRedDot.Option): Promise<TaroGeneral.CallbackResult>
189
189
 
190
190
  /** 隐藏 tabBar
191
- * @supported weapp, h5, rn, tt
191
+ * @supported weapp, h5, rn, tt, harmony
192
192
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.hideTabBar.html
193
193
  */
194
194
  hideTabBar(option?: hideTabBar.Option): Promise<TaroGeneral.CallbackResult>
@@ -484,7 +484,7 @@ declare module '../../index' {
484
484
 
485
485
  interface TaroStatic {
486
486
  /** 返回一个 SelectorQuery 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createSelectorQuery()` 来代替。
487
- * @supported weapp, h5, tt
487
+ * @supported weapp, h5, tt, harmony
488
488
  * @example
489
489
  * ```tsx
490
490
  * const query = Taro.createSelectorQuery()
@@ -500,7 +500,7 @@ declare module '../../index' {
500
500
  createSelectorQuery(): SelectorQuery
501
501
 
502
502
  /** 创建并返回一个 IntersectionObserver 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createIntersectionObserver([options])` 来代替。
503
- * @supported weapp, h5, tt
503
+ * @supported weapp, h5, tt, harmony
504
504
  * @example
505
505
  * ```tsx
506
506
  * const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true })
@@ -0,0 +1,77 @@
1
+ import type Chain from 'webpack-chain'
2
+ import type { IOption, IPostcssOption, IUrlLoaderOption } from './util'
3
+
4
+ export interface IHarmonyConfig<T extends CompilerTypes = CompilerWebpackTypes> {
5
+ /** Harmony 项目地址 */
6
+ projectPath: string
7
+
8
+ /** hap 名
9
+ * @default "entry"
10
+ */
11
+ hapName?: string
12
+
13
+ /** 应用名称
14
+ * @default "default"
15
+ */
16
+ name?: string
17
+
18
+ /** 用于告诉 Taro 编译器需要抽取的公共文件 */
19
+ commonChunks?: string[] | ((commonChunks: string[]) => string[])
20
+
21
+ /** Harmony 编译过程的相关配置 */
22
+ compile?: {
23
+ exclude?: any[]
24
+ include?: any[]
25
+ filter?: (filename: string) => boolean
26
+ }
27
+
28
+ /** 用于控制是否生成 js、css 对应的 sourceMap (默认值:watch 模式下为 true,否则为 false) */
29
+ enableSourceMap?: boolean
30
+
31
+ /** 默认值:'cheap-module-source-map', 具体参考[Webpack devtool 配置](https://webpack.js.org/configuration/devtool/#devtool) */
32
+ sourceMapType?: string
33
+
34
+ /** 指定 React 框架相关的代码是否使用开发环境(未压缩)代码,默认使用生产环境(压缩后)代码 */
35
+ debugReact?: boolean
36
+
37
+ /**
38
+ * 自定义 Webpack 配置
39
+ * @param chain [webpackChain](https://github.com/neutrinojs/webpack-chain) 对象
40
+ * @param webpack webpack 实例
41
+ */
42
+ webpackChain?: (chain: Chain, webpack: typeof Webpack) => void
43
+
44
+ /** webpack 编译模式下,可用于修改、拓展 Webpack 的 output 选项,配置项参考[官方文档](https://webpack.js.org/configuration/output/)
45
+ * vite 编译模式下,用于修改、扩展 rollup 的 output,目前仅适配 chunkFileNames 和 assetFileNames 两个配置,修改其他配置请使用 vite 插件进行修改。配置想参考[官方文档](https://rollupjs.org/configuration-options/)
46
+ */
47
+ output?: T extends 'vite'
48
+ ? Pick<RollupOutputOptions, 'chunkFileNames'> & OutputExt
49
+ : Webpack.Configuration['output'] & OutputExt
50
+
51
+ /** 配置 postcss 相关插件 */
52
+ postcss?: IPostcssOption<'harmony'>
53
+
54
+ /** [css-loader](https://github.com/webpack-contrib/css-loader) 的附加配置 */
55
+ cssLoaderOption?: IOption
56
+
57
+ /** [sass-loader](https://github.com/webpack-contrib/sass-loader) 的附加配置 */
58
+ sassLoaderOption?: IOption
59
+
60
+ /** [less-loader](https://github.com/webpack-contrib/less-loader) 的附加配置 */
61
+ lessLoaderOption?: IOption
62
+
63
+ /** [stylus-loader](https://github.com/shama/stylus-loader) 的附加配置 */
64
+ stylusLoaderOption?: IOption
65
+
66
+ /** 针对 mp4 | webm | ogg | mp3 | wav | flac | aac 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
67
+ mediaUrlLoaderOption?: IUrlLoaderOption
68
+
69
+ /** 针对 woff | woff2 | eot | ttf | otf 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
70
+ fontUrlLoaderOption?: IUrlLoaderOption
71
+
72
+ /** 针对 png | jpg | jpeg | gif | bpm | svg 文件的 [url-loader](https://github.com/webpack-contrib/url-loader) 配置 */
73
+ imageUrlLoaderOption?: IUrlLoaderOption
74
+
75
+ /** [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) 的附加配置 */
76
+ miniCssExtractPluginOption?: IOption
77
+ }
@@ -1,4 +1,5 @@
1
1
  export * from './h5'
2
+ export * from './harmony'
2
3
  export * from './mini'
3
4
 
4
5
  export * from './manifest'
@@ -115,6 +115,12 @@ export interface IMiniAppConfig<T extends CompilerTypes = CompilerWebpackTypes>
115
115
 
116
116
  /** 使用的编译工具。可选值:webpack4、webpack5、vite */
117
117
  compiler?: Compiler<T>
118
+
119
+ /** 体验式功能 */
120
+ experimental?: {
121
+ /** 是否开启编译模式 */
122
+ compileMode?: boolean
123
+ }
118
124
  }
119
125
 
120
126
  export interface IMiniFilesConfig {
@@ -1,10 +1,11 @@
1
1
  import type Webpack from 'webpack'
2
2
  import type Chain from 'webpack-chain'
3
- import { type Input } from 'postcss'
3
+ import type { Input } from 'postcss'
4
4
  import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
5
5
  import type { IModifyChainData } from '../hooks'
6
6
  import type { ICopyOptions, IOption, ISassOptions, TogglableOptions } from './util'
7
7
  import type { IH5Config } from './h5'
8
+ import type { IHarmonyConfig } from './harmony'
8
9
  import type { IMiniAppConfig, IMiniFilesConfig } from './mini'
9
10
  import type { IRNConfig } from './rn'
10
11
 
@@ -313,5 +314,7 @@ export interface IProjectConfig<T extends CompilerTypes = CompilerWebpackTypes>
313
314
  /** 专属于 RN 的配置 */
314
315
  rn?: IRNConfig
315
316
 
317
+ harmony?: IHarmonyConfig<T>
318
+
316
319
  [key: string]: any
317
320
  }
@@ -77,6 +77,8 @@ export interface IPxTransformOption {
77
77
  deviceRatio?: TaroGeneral.TDeviceRatio
78
78
  /** 平台 */
79
79
  platform?: 'weapp' | 'h5' | string
80
+ /** 启用的能力 Scope 默认为 ['platform', 'size'] */
81
+ methods?: string[]
80
82
  /** filter 回调函数,可 exclude 不处理的文件 */
81
83
  exclude?: (fileName: string) => boolean
82
84
  }
@@ -90,7 +92,7 @@ interface IBasePostcssOption {
90
92
  [key: string]: any
91
93
  }
92
94
 
93
- export type IPostcssOption<T = 'h5' | 'mini'> = T extends 'h5'
95
+ export type IPostcssOption<T = 'h5' | 'harmony' | 'mini'> = T extends 'h5'
94
96
  ? IBasePostcssOption & { url?: PostcssOption.url }
95
97
  : IBasePostcssOption
96
98
 
@@ -1,7 +1,7 @@
1
1
  import type { RecursiveTemplate, UnRecursiveTemplate } from '@tarojs/shared/dist/template'
2
2
  import type { PluginContext } from 'rollup'
3
3
  import type { AppConfig, PageConfig } from '../index'
4
- import type { IMiniFilesConfig, IH5Config, IMiniAppConfig } from './config'
4
+ import type { IMiniFilesConfig, IH5Config, IHarmonyConfig, IMiniAppConfig } from './config'
5
5
  import type { IProjectConfig } from './config/project'
6
6
  import type { IComponentConfig } from './hooks'
7
7
 
@@ -47,6 +47,14 @@ export interface ViteH5BuildConfig extends CommonBuildConfig, IH5Config<'vite'>
47
47
  runtimePath?: string | string[]
48
48
  }
49
49
 
50
+ export interface ViteHarmonyBuildConfig extends CommonBuildConfig, IHarmonyConfig {
51
+ fileType: IFileType
52
+ useETS?: boolean
53
+ useJSON5?: boolean
54
+ runtimePath?: string | string[]
55
+ taroComponentsPath: string
56
+ }
57
+
50
58
  export interface CommonBuildConfig extends IProjectConfig<'vite'> {
51
59
  entry: {
52
60
  app: string | string[]
@@ -117,6 +125,17 @@ export interface ViteH5CompilerContext extends ViteCompilerContext<ViteH5BuildCo
117
125
  browserslist: string[]
118
126
  }
119
127
 
128
+ export interface ViteHarmonyCompilerContext extends ViteCompilerContext<ViteHarmonyBuildConfig> {
129
+ fileType: ViteFileType
130
+ commonChunks: string[]
131
+ getCommonChunks: () => string[]
132
+ modifyHarmonyConfig: (config: Partial<AppConfig>) => void
133
+ modifyHostPackageDep: (outDir: string, deps?: Record<string, string>, devDeps?: Record<string, string>) => void
134
+ getScriptPath: (filePath: string) => string
135
+ getStylePath: (filePath: string) => string
136
+ getConfigPath: (filePath: string) => string
137
+ }
138
+
120
139
  export interface ViteMiniCompilerContext extends ViteCompilerContext<ViteMiniBuildConfig> {
121
140
  fileType: ViteFileType
122
141
  commonChunks: string[]