@tarojs/taro 4.0.8-beta.0 → 4.0.8-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 +9 -10
- package/types/api/canvas/index.d.ts +1 -1
- package/types/api/cloud/index.d.ts +5 -1
- package/types/api/device/keyboard.d.ts +1 -1
- package/types/api/device/memory.d.ts +2 -2
- package/types/api/files/index.d.ts +1 -1
- package/types/api/location/index.d.ts +1 -1
- package/types/api/media/audio.d.ts +5 -1
- package/types/api/media/video.d.ts +2 -2
- package/types/api/media/voip.d.ts +2 -2
- package/types/api/network/download.d.ts +1 -1
- package/types/api/network/upload.d.ts +1 -1
- package/types/api/route/index.d.ts +107 -3
- package/types/api/skyline/index.d.ts +286 -0
- package/types/api/storage/index.d.ts +2 -2
- package/types/api/taro.extend.d.ts +9 -8
- package/types/api/taro.hooks.d.ts +9 -3
- package/types/api/ui/tab-bar.d.ts +7 -7
- package/types/compile/config/h5.d.ts +6 -3
- package/types/compile/config/mini.d.ts +3 -2
- package/types/compile/viteCompilerContext.d.ts +10 -2
- package/types/global.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/taro.component.d.ts +22 -0
- package/types/taro.config.d.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/taro",
|
|
3
|
-
"version": "4.0.8-beta.
|
|
3
|
+
"version": "4.0.8-beta.3",
|
|
4
4
|
"description": "Taro framework",
|
|
5
5
|
"author": "O2Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,20 +24,19 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@types/postcss-url": "^10.0.4",
|
|
27
|
-
"@tarojs/api": "4.0.8-beta.
|
|
28
|
-
"@tarojs/runtime": "4.0.8-beta.
|
|
27
|
+
"@tarojs/api": "4.0.8-beta.3",
|
|
28
|
+
"@tarojs/runtime": "4.0.8-beta.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/react": "^18.3.1",
|
|
32
31
|
"html-webpack-plugin": "^5.6.0",
|
|
33
32
|
"postcss": "^8.4.38",
|
|
34
33
|
"webpack": "5.91.0",
|
|
35
34
|
"webpack-chain": "^6.5.1",
|
|
36
35
|
"webpack-dev-server": "^4.15.2",
|
|
37
36
|
"rollup": "^3.29.4",
|
|
38
|
-
"@tarojs/
|
|
39
|
-
"@tarojs/
|
|
40
|
-
"@tarojs/shared": "4.0.8-beta.
|
|
37
|
+
"@tarojs/helper": "4.0.8-beta.3",
|
|
38
|
+
"@tarojs/components": "4.0.8-beta.3",
|
|
39
|
+
"@tarojs/shared": "4.0.8-beta.3"
|
|
41
40
|
},
|
|
42
41
|
"peerDependencies": {
|
|
43
42
|
"@types/react": "^18",
|
|
@@ -48,9 +47,9 @@
|
|
|
48
47
|
"webpack": "^5",
|
|
49
48
|
"webpack-chain": "^6",
|
|
50
49
|
"webpack-dev-server": "^4",
|
|
51
|
-
"@tarojs/
|
|
52
|
-
"@tarojs/shared": "4.0.8-beta.
|
|
53
|
-
"@tarojs/
|
|
50
|
+
"@tarojs/components": "4.0.8-beta.3",
|
|
51
|
+
"@tarojs/shared": "4.0.8-beta.3",
|
|
52
|
+
"@tarojs/helper": "4.0.8-beta.3"
|
|
54
53
|
},
|
|
55
54
|
"peerDependenciesMeta": {
|
|
56
55
|
"@types/react": {
|
|
@@ -2048,7 +2048,7 @@ declare module '../../index' {
|
|
|
2048
2048
|
/** 创建 canvas 的绘图上下文 [CanvasContext](/docs/apis/canvas/CanvasContext) 对象
|
|
2049
2049
|
*
|
|
2050
2050
|
* **Tip**: 需要指定 canvasId,该绘图上下文只作用于对应的 `<canvas/>`;另外,Web 端需要在 `useReady` 回调中执行它,否则会因为底层 canvas 渲染出来之前而去获取 CanvasContext,导致其底层的 context 为 `undefined`,从而不能正常绘图。
|
|
2051
|
-
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
2051
|
+
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid, harmony
|
|
2052
2052
|
* @example
|
|
2053
2053
|
* ```tsx
|
|
2054
2054
|
* import { useReady } from '@tarojs/taro'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Taro
|
|
1
|
+
import Taro from "../../index"
|
|
2
2
|
|
|
3
3
|
declare module '../../index' {
|
|
4
4
|
namespace cloud {
|
|
@@ -212,6 +212,10 @@ declare module '../../index' {
|
|
|
212
212
|
|
|
213
213
|
/** 调用云托管参数 */
|
|
214
214
|
interface CallContainerParam < P extends string | TaroGeneral.IAnyObject | ArrayBuffer = any | any > {
|
|
215
|
+
config?:{
|
|
216
|
+
/** 微信云托管的环境ID, 如果在 Taro.cloud.init 中配置了env, 则可以不配置。 */
|
|
217
|
+
env: string,
|
|
218
|
+
}
|
|
215
219
|
/** 服务路径 */
|
|
216
220
|
path: string
|
|
217
221
|
/** HTTP请求方法,默认 GET */
|
|
@@ -43,7 +43,7 @@ declare module '../../index' {
|
|
|
43
43
|
|
|
44
44
|
interface TaroStatic {
|
|
45
45
|
/** 在input、textarea等focus拉起键盘之后,手动调用此接口收起键盘
|
|
46
|
-
* @supported weapp, alipay, swan, jd, tt, rn, harmony_hybrid
|
|
46
|
+
* @supported weapp, alipay, swan, jd, tt, rn, harmony_hybrid, harmony
|
|
47
47
|
* @example
|
|
48
48
|
* ```tsx
|
|
49
49
|
* Taro.hideKeyboard({
|
|
@@ -26,7 +26,7 @@ declare module '../../index' {
|
|
|
26
26
|
/** 监听内存不足告警事件。
|
|
27
27
|
*
|
|
28
28
|
* 当 iOS/Android 向小程序进程发出内存警告时,触发该事件。触发该事件不意味小程序被杀,大部分情况下仅仅是告警,开发者可在收到通知后回收一些不必要资源避免进一步加剧内存紧张。
|
|
29
|
-
* @supported weapp, alipay, swan, jd, tt
|
|
29
|
+
* @supported weapp, alipay, swan, jd, tt, harmony
|
|
30
30
|
* @example
|
|
31
31
|
* ```tsx
|
|
32
32
|
* Taro.onMemoryWarning(function () {
|
|
@@ -41,7 +41,7 @@ declare module '../../index' {
|
|
|
41
41
|
): void
|
|
42
42
|
|
|
43
43
|
/** 取消监听内存不足告警事件。
|
|
44
|
-
* @supported weapp, alipay, swan
|
|
44
|
+
* @supported weapp, alipay, swan, harmony
|
|
45
45
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/memory/wx.offMemoryWarning.html
|
|
46
46
|
*/
|
|
47
47
|
offMemoryWarning(
|
|
@@ -1464,7 +1464,7 @@ declare module '../../index' {
|
|
|
1464
1464
|
getFileInfo(option: getFileInfo.Option): Promise<getFileInfo.SuccessCallbackResult | getFileInfo.FailCallbackResult>
|
|
1465
1465
|
|
|
1466
1466
|
/** 获取全局唯一的文件管理器
|
|
1467
|
-
* @supported weapp, alipay, swan, jd, qq, tt, harmony_hybrid
|
|
1467
|
+
* @supported weapp, alipay, swan, jd, qq, tt, harmony_hybrid, harmony
|
|
1468
1468
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/file/wx.getFileSystemManager.html
|
|
1469
1469
|
*/
|
|
1470
1470
|
getFileSystemManager(): FileSystemManager
|
|
@@ -455,7 +455,7 @@ declare module '../../index' {
|
|
|
455
455
|
* **注意**
|
|
456
456
|
* - 工具中定位模拟使用IP定位,可能会有一定误差。且工具目前仅支持 gcj02 坐标。
|
|
457
457
|
* - 使用第三方服务进行逆地址解析时,请确认第三方服务默认的坐标系,正确进行坐标转换。
|
|
458
|
-
* @supported weapp, swan, jd, qq, tt, rn, harmony_hybrid
|
|
458
|
+
* @supported weapp, swan, jd, qq, tt, rn, harmony_hybrid, harmony
|
|
459
459
|
* @example
|
|
460
460
|
* ```tsx
|
|
461
461
|
* Taro.getLocation({
|
|
@@ -740,7 +740,11 @@ declare module '../../index' {
|
|
|
740
740
|
* ```
|
|
741
741
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/WebAudioContext.decodeAudioData.html
|
|
742
742
|
*/
|
|
743
|
-
decodeAudioData(
|
|
743
|
+
decodeAudioData(
|
|
744
|
+
audioData: ArrayBuffer,
|
|
745
|
+
successCallback: (buffer: AudioBuffer) => void,
|
|
746
|
+
errorCallback: (error: any) => void
|
|
747
|
+
): Promise<AudioBuffer>
|
|
744
748
|
}
|
|
745
749
|
|
|
746
750
|
namespace WebAudioContext {
|
|
@@ -442,7 +442,7 @@ declare module '../../index' {
|
|
|
442
442
|
getVideoInfo(option: getVideoInfo.Option): Promise<getVideoInfo.SuccessCallbackResult>
|
|
443
443
|
|
|
444
444
|
/** 创建 video 上下文 VideoContext 对象。
|
|
445
|
-
* @supported weapp, h5, rn, harmony_hybrid
|
|
445
|
+
* @supported weapp, h5, rn, harmony_hybrid, harmony
|
|
446
446
|
* @example
|
|
447
447
|
* ```tsx
|
|
448
448
|
* videoContext = Taro.createVideoContext('myVideo')
|
|
@@ -505,7 +505,7 @@ declare module '../../index' {
|
|
|
505
505
|
chooseVideo(option: chooseVideo.Option): Promise<chooseVideo.SuccessCallbackResult>
|
|
506
506
|
|
|
507
507
|
/** 拍摄或从手机相册中选择图片或视频。
|
|
508
|
-
* @supported weapp, h5, harmony_hybrid
|
|
508
|
+
* @supported weapp, h5, harmony_hybrid, harmony
|
|
509
509
|
* @example
|
|
510
510
|
* ```tsx
|
|
511
511
|
* Taro.chooseMedia({
|
|
@@ -320,7 +320,7 @@ declare module '../../index' {
|
|
|
320
320
|
* @supported weapp
|
|
321
321
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/voip/wx.setEnable1v1Chat.html
|
|
322
322
|
*/
|
|
323
|
-
setEnable1v1Chat(option:
|
|
323
|
+
setEnable1v1Chat(option: setEnable1v1Chat.Option): Promise<TaroGeneral.CallbackResult>
|
|
324
324
|
/** 监听实时语音通话成员视频状态变化事件
|
|
325
325
|
* @supported weapp
|
|
326
326
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/voip/wx.onVoIPVideoMembersChanged.html
|
|
@@ -373,7 +373,7 @@ declare module '../../index' {
|
|
|
373
373
|
*/
|
|
374
374
|
offVoIPChatInterrupted(callback: onVoIPChatInterrupted.Callback): void
|
|
375
375
|
/** 加入 (创建) 实时语音通话,更多信息可见 [实时语音指南](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/voip-chat.html)
|
|
376
|
-
*
|
|
376
|
+
*
|
|
377
377
|
* 调用前需要用户授权 `scope.record`,若房间类型为视频房间需要用户授权 `scope.camera`。
|
|
378
378
|
* @supported weapp
|
|
379
379
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/media/voip/wx.joinVoIPChat.html
|
|
@@ -151,7 +151,7 @@ declare module '../../index' {
|
|
|
151
151
|
/** 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径,单次下载允许的最大文件为 50MB。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。
|
|
152
152
|
*
|
|
153
153
|
* 注意:请在服务端响应的 header 中指定合理的 `Content-Type` 字段,以保证客户端正确处理文件类型。
|
|
154
|
-
* @supported weapp, h5, alipay, swan, rn, tt, harmony_hybrid
|
|
154
|
+
* @supported weapp, h5, alipay, swan, rn, tt, harmony_hybrid, harmony
|
|
155
155
|
* @example
|
|
156
156
|
* ```tsx
|
|
157
157
|
* Taro.downloadFile({
|
|
@@ -152,7 +152,7 @@ declare module '../../index' {
|
|
|
152
152
|
|
|
153
153
|
interface TaroStatic {
|
|
154
154
|
/** 将本地资源上传到服务器。客户端发起一个 HTTPS POST 请求,其中 `content-type` 为 `multipart/form-data`。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。
|
|
155
|
-
* @supported weapp, swan, alipay, h5, rn, tt, harmony_hybrid
|
|
155
|
+
* @supported weapp, swan, alipay, h5, rn, tt, harmony_hybrid, harmony
|
|
156
156
|
* @example
|
|
157
157
|
* ```tsx
|
|
158
158
|
* Taro.chooseImage({
|
|
@@ -44,10 +44,16 @@ declare module '../../index' {
|
|
|
44
44
|
interface Option {
|
|
45
45
|
/** 需要跳转的应用内非 tabBar 的页面的路径, 路径后可以带参数。参数与路径之间使用 `?` 分隔,参数键与参数值用 `=` 相连,不同参数用 `&` 分隔;如 'path?key=value&key2=value2' */
|
|
46
46
|
url: string
|
|
47
|
-
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
48
|
-
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
49
47
|
/** 页面间通信接口,用于监听被打开页面发送到当前页面的数据。 */
|
|
50
48
|
events?: TaroGeneral.IAnyObject
|
|
49
|
+
/** 2.29.2 自定义路由类型 */
|
|
50
|
+
routeType?: string
|
|
51
|
+
/** 3.4.0 自定义路由配置 */
|
|
52
|
+
routeConfig?: TaroGeneral.IAnyObject
|
|
53
|
+
/** 3.4.0 自定义路由参数 */
|
|
54
|
+
routeOptions?: TaroGeneral.IAnyObject
|
|
55
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
56
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
51
57
|
/** 接口调用失败的回调函数 */
|
|
52
58
|
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
53
59
|
/** 接口调用成功的回调函数 */
|
|
@@ -115,9 +121,106 @@ declare module '../../index' {
|
|
|
115
121
|
): void
|
|
116
122
|
}
|
|
117
123
|
|
|
124
|
+
namespace router {
|
|
125
|
+
type CustomRouteBuilder = (routeContext: CustomRouteContext, routeOptions: Record<string, any>) => CustomRouteConfig
|
|
126
|
+
|
|
127
|
+
interface SharedValue<T> {
|
|
128
|
+
value: T
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface CustomRouteContext {
|
|
132
|
+
// 动画控制器,影响推入页面的进入和退出过渡效果
|
|
133
|
+
primaryAnimation: SharedValue<number>
|
|
134
|
+
// 动画控制器状态
|
|
135
|
+
primaryAnimationStatus: SharedValue<number>
|
|
136
|
+
// 动画控制器,影响栈顶页面的推出过渡效果
|
|
137
|
+
secondaryAnimation: SharedValue<number>
|
|
138
|
+
// 动画控制器状态
|
|
139
|
+
secondaryAnimationStatus: SharedValue<number>
|
|
140
|
+
// 当前路由进度由手势控制
|
|
141
|
+
userGestureInProgress: SharedValue<number>
|
|
142
|
+
// 手势开始控制路由
|
|
143
|
+
startUserGesture: () => void
|
|
144
|
+
// 手势不再控制路由
|
|
145
|
+
stopUserGesture: () => void
|
|
146
|
+
// 返回上一级,效果同 wx.navigateBack
|
|
147
|
+
didPop: () => void
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
interface CustomRouteConfig {
|
|
151
|
+
// 下一个页面推入后,不显示前一个页面
|
|
152
|
+
opaque?: boolean
|
|
153
|
+
// 是否保持前一个页面状态
|
|
154
|
+
maintainState?: boolean
|
|
155
|
+
// 页面推入动画时长,单位 ms
|
|
156
|
+
transitionDuration?: number
|
|
157
|
+
// 页面推出动画时长,单位 ms
|
|
158
|
+
reverseTransitionDuration?: number
|
|
159
|
+
// 遮罩层背景色,支持 rgba() 和 #RRGGBBAA 写法
|
|
160
|
+
barrierColor?: string
|
|
161
|
+
// 点击遮罩层返回上一页
|
|
162
|
+
barrierDismissible?: boolean
|
|
163
|
+
// 无障碍语义
|
|
164
|
+
barrierLabel?: string
|
|
165
|
+
// 是否与下一个页面联动,决定当前页 secondaryAnimation 是否生效
|
|
166
|
+
canTransitionTo?: boolean
|
|
167
|
+
// 是否与前一个页面联动,决定前一个页 secondaryAnimation 是否生效
|
|
168
|
+
canTransitionFrom?: boolean
|
|
169
|
+
// 处理当前页的进入/退出动画,返回 StyleObject
|
|
170
|
+
handlePrimaryAnimation?: RouteAnimationHandler
|
|
171
|
+
// 处理当前页的压入/压出动画,返回 StyleObject
|
|
172
|
+
handleSecondaryAnimation?: RouteAnimationHandler
|
|
173
|
+
// 处理上一级页面的压入/压出动画,返回 StyleObject 基础库 <3.0.0> 起支持
|
|
174
|
+
handlePreviousPageAnimation?: RouteAnimationHandler
|
|
175
|
+
// 页面进入时是否采用 snapshot 模式优化动画性能 基础库 <3.2.0> 起支持
|
|
176
|
+
allowEnterRouteSnapshotting?: boolean
|
|
177
|
+
// 页面退出时是否采用 snapshot 模式优化动画性能 基础库 <3.2.0> 起支持
|
|
178
|
+
allowExitRouteSnapshotting?: boolean
|
|
179
|
+
// 右滑返回时,可拖动范围是否撑满屏幕,基础库 <3.2.0> 起支持,常用于半屏弹窗
|
|
180
|
+
fullscreenDrag?: boolean
|
|
181
|
+
// 返回手势方向 基础库 <3.4.0> 起支持
|
|
182
|
+
popGestureDirection?: 'horizontal' | 'vertical' | 'multi'
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
type RouteAnimationHandler = () => { [key: string] : any}
|
|
186
|
+
|
|
187
|
+
/** 自定义路由
|
|
188
|
+
* @supported weapp
|
|
189
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/route/router/wx.router.html
|
|
190
|
+
*/
|
|
191
|
+
interface router {
|
|
192
|
+
/** 添加自定义路由配置
|
|
193
|
+
* @supported weapp
|
|
194
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/route/router/base/router.addRouteBuilder.html
|
|
195
|
+
*/
|
|
196
|
+
addRouteBuilder(
|
|
197
|
+
/** 路由类型 */
|
|
198
|
+
routeType: string,
|
|
199
|
+
/** 路由动画定义函数 */
|
|
200
|
+
routeBuilder: CustomRouteBuilder
|
|
201
|
+
): void
|
|
202
|
+
/** 获取页面对应的自定义路由上下文对象
|
|
203
|
+
* @supported weapp
|
|
204
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/route/router/base/router.getRouteContext.html
|
|
205
|
+
*/
|
|
206
|
+
getRouteContext(
|
|
207
|
+
/** 页面/自定义组件实例 */
|
|
208
|
+
instance: TaroGeneral.IAnyObject
|
|
209
|
+
): CustomRouteContext
|
|
210
|
+
/** 移除自定义路由配置
|
|
211
|
+
* @supported weapp
|
|
212
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/route/router/base/router.removeRouteBuilder.html
|
|
213
|
+
*/
|
|
214
|
+
removeRouteBuilder(
|
|
215
|
+
/** 路由类型 */
|
|
216
|
+
routeType: string,
|
|
217
|
+
): void
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
118
221
|
interface TaroStatic {
|
|
119
222
|
/** 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面
|
|
120
|
-
* @supported weapp, h5, rn, tt,
|
|
223
|
+
* @supported weapp, h5, rn, tt, harmony_hybrid
|
|
121
224
|
* @example
|
|
122
225
|
* ```json
|
|
123
226
|
* {
|
|
@@ -216,5 +319,6 @@ declare module '../../index' {
|
|
|
216
319
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateBack.html
|
|
217
320
|
*/
|
|
218
321
|
navigateBack(option?: navigateBack.Option): Promise<TaroGeneral.CallbackResult>
|
|
322
|
+
router: router.router
|
|
219
323
|
}
|
|
220
324
|
}
|
|
@@ -56,4 +56,290 @@ declare module '../../index' {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* DraggableSheet 实例,可通过 Taro.createSelectorQuery 的 NodesRef.node 方法获取。
|
|
62
|
+
*
|
|
63
|
+
* @supported weapp
|
|
64
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/skyline/DraggableSheetContext.html
|
|
65
|
+
*/
|
|
66
|
+
interface DraggableSheetContext {
|
|
67
|
+
/**
|
|
68
|
+
* 滚动到指定位置。size 取值 [0, 1],size = 1 时表示撑满 draggable-sheet 组件。size 和 pixels 同时传入时,仅 size 生效。
|
|
69
|
+
* @param option
|
|
70
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/skyline/DraggableSheetContext.scrollTo.html
|
|
71
|
+
*/
|
|
72
|
+
scrollTo(option: DraggableSheetContext.scrollTo.Option): void
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
namespace DraggableSheetContext {
|
|
76
|
+
namespace scrollTo {
|
|
77
|
+
interface Option {
|
|
78
|
+
/** 相对目标位置 */
|
|
79
|
+
size?: number
|
|
80
|
+
/** 绝对目标位置 */
|
|
81
|
+
pixels?: number
|
|
82
|
+
/**
|
|
83
|
+
* 是否启用滚动动画
|
|
84
|
+
* @default true
|
|
85
|
+
*/
|
|
86
|
+
animated?: boolean
|
|
87
|
+
/**
|
|
88
|
+
* 滚动动画时长(ms)
|
|
89
|
+
* @default 300
|
|
90
|
+
*/
|
|
91
|
+
duration?: number
|
|
92
|
+
/**
|
|
93
|
+
* 缓动函数
|
|
94
|
+
* @default ease
|
|
95
|
+
*/
|
|
96
|
+
easingFunction?: string
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* worklet 对象,可以通过 wx.worklet 获取
|
|
103
|
+
*
|
|
104
|
+
* @supported weapp
|
|
105
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/wx.worklet.html
|
|
106
|
+
*/
|
|
107
|
+
interface worklet {
|
|
108
|
+
/**
|
|
109
|
+
* 取消由 SharedValue 驱动的动画
|
|
110
|
+
* @param SharedValue
|
|
111
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.cancelAnimation.html
|
|
112
|
+
*/
|
|
113
|
+
cancelAnimation(SharedValue: worklet.SharedValue): void
|
|
114
|
+
/**
|
|
115
|
+
* 衍生值 DerivedValue,可基于已有的 SharedValue 生成其它共享变量。
|
|
116
|
+
* @param updaterWorklet
|
|
117
|
+
* @returns 返回 DerivedValue 类型值,可被 worklet 函数捕获。DerivedValue 也是 SharedValue 类型。
|
|
118
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.derived.html
|
|
119
|
+
*/
|
|
120
|
+
derived(updaterWorklet: worklet.WorkletFunction): worklet.DerivedValue
|
|
121
|
+
/**
|
|
122
|
+
* ScrollView 实例,可在 worklet 函数内操作 scroll-view 组件。
|
|
123
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.scrollViewContext.html
|
|
124
|
+
*/
|
|
125
|
+
scrollViewContext: {
|
|
126
|
+
/**
|
|
127
|
+
* 滚动至指定位置
|
|
128
|
+
* @param object
|
|
129
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.scrollViewContext.scrollTo.html
|
|
130
|
+
*/
|
|
131
|
+
scrollTo(NodesRef: TaroGeneral.IAnyObject, object: worklet.scrollViewContext.Option): void
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 创建共享变量 SharedValue,用于跨线程共享数据和驱动动画。
|
|
135
|
+
* @param initialValue
|
|
136
|
+
* @returns 返回 SharedValue 类型值,可被 worklet 函数捕获。
|
|
137
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/base/worklet.shared.html
|
|
138
|
+
*/
|
|
139
|
+
shared(initialValue: number | string | bool | null | undefined | Object | Array | Function): worklet.SharedValue
|
|
140
|
+
/**
|
|
141
|
+
* 基于滚动衰减的动画。
|
|
142
|
+
* @param options 动画配置
|
|
143
|
+
* @param callback 动画完成回调。动画被取消时,返回 fasle,正常完成时返回 true。
|
|
144
|
+
* @returns 返回 AnimationObject 类型值,可直接赋值给 SharedValue。
|
|
145
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.decay.html
|
|
146
|
+
*/
|
|
147
|
+
decay(options?: worklet.decay.Option, callback?: (flag: boolean) => void): worklet.AnimationObject
|
|
148
|
+
Easing: worklet.Easing
|
|
149
|
+
/**
|
|
150
|
+
* 基于物理的动画。
|
|
151
|
+
* @param toValue 目标值
|
|
152
|
+
* @param options 动画配置
|
|
153
|
+
* @param callback 动画完成回调。动画被取消时,返回 fasle,正常完成时返回 true。
|
|
154
|
+
* @returns 返回 AnimationObject 类型值,可直接赋值给 SharedValue。
|
|
155
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.spring.html
|
|
156
|
+
*/
|
|
157
|
+
spring(toValue: number | string, options?: worklet.spring.Option, callback?: (flag: boolean) => void): worklet.AnimationObject
|
|
158
|
+
/**
|
|
159
|
+
* 基于时间的动画。
|
|
160
|
+
* @param toValue 目标值
|
|
161
|
+
* @param options 动画配置
|
|
162
|
+
* @param callback 动画完成回调。动画被取消时,返回 fasle,正常完成时返回 true。
|
|
163
|
+
* @returns 返回 AnimationObject 类型值,可直接赋值给 SharedValue。
|
|
164
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.timing.html
|
|
165
|
+
*/
|
|
166
|
+
timing(toValue: number | string, options?: worklet.timing.Option, callback?: (flag: boolean) => void): worklet.AnimationObject
|
|
167
|
+
/**
|
|
168
|
+
* 延迟执行动画。
|
|
169
|
+
* @param delayMS 动画开始前等待的时间,单位:毫秒
|
|
170
|
+
* @param delayedAnimation 动画对象
|
|
171
|
+
* @returns 返回 AnimationObject 类型值,可直接赋值给 SharedValue。
|
|
172
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/combine-animation/worklet.delay.html
|
|
173
|
+
*/
|
|
174
|
+
delay(delayMS: number, delayedAnimation: worklet.AnimationObject): worklet.AnimationObject
|
|
175
|
+
/**
|
|
176
|
+
* 重复执行动画。
|
|
177
|
+
* @param animation 动画对象
|
|
178
|
+
* @param numberOfReps 重复次数。为负值时一直循环,直到被取消动画。
|
|
179
|
+
* @param reverse 反向运行动画,每周期结束动画由尾到头运行。该字段仅对 timing 和 spring 返回的动画对象生效。
|
|
180
|
+
* @param callback 动画完成回调。动画被取消时,返回 fasle,正常完成时返回 true。
|
|
181
|
+
* @returns 返回 AnimationObject 类型值,可直接赋值给 SharedValue。
|
|
182
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/combine-animation/worklet.repeat.html
|
|
183
|
+
*/
|
|
184
|
+
repeat(delayedAnimation: worklet.AnimationObject, numberOfReps: number, reverse?: boolean, callback?: (flag: boolean) => void): worklet.AnimationObject
|
|
185
|
+
/**
|
|
186
|
+
* 组合动画序列,依次执行传入的动画。
|
|
187
|
+
* @param animation 动画对象
|
|
188
|
+
* @returns 返回 AnimationObject 类型值,可直接赋值给 SharedValue。
|
|
189
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/combine-animation/worklet.sequence.html
|
|
190
|
+
*/
|
|
191
|
+
sequence(...delayedAnimation: worklet.AnimationObject): worklet.AnimationObject
|
|
192
|
+
/**
|
|
193
|
+
* worklet 函数运行在 UI 线程时,捕获的外部函数可能为 worklet 类型或普通函数,为了更明显的对其区分,要求必须使用 runOnJS 调回 JS 线程的普通函数。 有这样的要求是因为,调用其它 worklet 函数时是同步调用,但在 UI 线程执行 JS 线程的函数只能是异步,开发者容易混淆,试图同步获取 JS 线程的返回值。
|
|
194
|
+
* @param fn worklet 类型函数
|
|
195
|
+
* @returns runOnJS 为高阶函数,返回一个函数,执行时运行在 JS 线程
|
|
196
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/tool-function/worklet.runOnJS.html
|
|
197
|
+
*/
|
|
198
|
+
runOnJS(fn: TaroGeneral.TFunc): TaroGeneral.TFunc
|
|
199
|
+
/**
|
|
200
|
+
* 在 UI 线程执行 worklet 函数
|
|
201
|
+
* @param fn worklet 类型函数
|
|
202
|
+
* @returns runOnUI 为高阶函数,返回一个函数,执行时运行在 UI 线程
|
|
203
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/tool-function/worklet.runOnUI.html
|
|
204
|
+
*/
|
|
205
|
+
runOnUI(fn: TaroGeneral.TFunc): TaroGeneral.TFunc
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
namespace worklet {
|
|
209
|
+
type SharedValue = TaroGeneral.IAnyObject
|
|
210
|
+
type DerivedValue = worklet.SharedValue
|
|
211
|
+
type AnimationObject = TaroGeneral.IAnyObject
|
|
212
|
+
type WorkletFunction = TaroGeneral.TFunc
|
|
213
|
+
|
|
214
|
+
namespace scrollViewContext {
|
|
215
|
+
interface Option {
|
|
216
|
+
/** 顶部距离 */
|
|
217
|
+
top?: number
|
|
218
|
+
/** 左边界距离 */
|
|
219
|
+
left?: number
|
|
220
|
+
/** 滚动动画时长 */
|
|
221
|
+
duration?: number
|
|
222
|
+
/** 是否启用滚动动画 */
|
|
223
|
+
animated?: boolean
|
|
224
|
+
/** 动画曲线 */
|
|
225
|
+
easingFunction?: string
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
namespace decay {
|
|
230
|
+
interface Option {
|
|
231
|
+
/** 初速度 */
|
|
232
|
+
velocity?: number
|
|
233
|
+
/** 衰减速率 */
|
|
234
|
+
deceleration?: number
|
|
235
|
+
/** 边界值,长度为 2 的数组 */
|
|
236
|
+
clamp?: Array<number>
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
interface Easing {
|
|
241
|
+
/**
|
|
242
|
+
* 简单的反弹效果
|
|
243
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
244
|
+
*/
|
|
245
|
+
bounce(t: number): any;
|
|
246
|
+
/**
|
|
247
|
+
* 简单的惯性动画
|
|
248
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
249
|
+
*/
|
|
250
|
+
ease(t: number): any;
|
|
251
|
+
/**
|
|
252
|
+
* 简单的弹性动画,类似弹簧来回摆动,高阶函数。默认弹性为 1,会稍微超出一次。弹性为 0 时 不会过冲
|
|
253
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
254
|
+
*/
|
|
255
|
+
elastic(bounciness?: number): any;
|
|
256
|
+
/**
|
|
257
|
+
* 线性函数
|
|
258
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
259
|
+
*/
|
|
260
|
+
linear(t: number): any;
|
|
261
|
+
/**
|
|
262
|
+
* 二次方函数
|
|
263
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
264
|
+
*/
|
|
265
|
+
quad(t: number): any;
|
|
266
|
+
/**
|
|
267
|
+
* 立方函数
|
|
268
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
269
|
+
*/
|
|
270
|
+
cubic(t: number): any;
|
|
271
|
+
/**
|
|
272
|
+
* 高阶函数,返回幂函数
|
|
273
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
274
|
+
*/
|
|
275
|
+
poly(n: number): any;
|
|
276
|
+
/**
|
|
277
|
+
* 三次贝塞尔曲线,效果同 css transition-timing-function
|
|
278
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
279
|
+
*/
|
|
280
|
+
bezier(x1: number, y1: number, x2: number, y2: number): any;
|
|
281
|
+
/**
|
|
282
|
+
* 圆形曲线
|
|
283
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
284
|
+
*/
|
|
285
|
+
circle(t: number): any;
|
|
286
|
+
/**
|
|
287
|
+
* 正弦函数
|
|
288
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
289
|
+
*/
|
|
290
|
+
sin(t: number): any;
|
|
291
|
+
/**
|
|
292
|
+
* 指数函数
|
|
293
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
294
|
+
*/
|
|
295
|
+
exp(t: number): any;
|
|
296
|
+
/**
|
|
297
|
+
* 正向运行 easing function,高阶函数。
|
|
298
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
299
|
+
*/
|
|
300
|
+
in(easing: (t: number) => any): any;
|
|
301
|
+
/**
|
|
302
|
+
* 反向运行 easing function,高阶函数。
|
|
303
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
304
|
+
*/
|
|
305
|
+
out(easing: (t: number) => any): any;
|
|
306
|
+
/**
|
|
307
|
+
* 前半程正向,后半程反向,高阶函数。
|
|
308
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/worklet/animation/worklet.Easing.html
|
|
309
|
+
*/
|
|
310
|
+
inOut(easing: (t: number) => any): any;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
namespace spring {
|
|
314
|
+
interface Option {
|
|
315
|
+
/** 阻尼系数 */
|
|
316
|
+
damping?: number
|
|
317
|
+
/** 重量系数,值越大移动越慢 */
|
|
318
|
+
mass?: number
|
|
319
|
+
/** 弹性系数 */
|
|
320
|
+
stiffness?: number
|
|
321
|
+
/** 动画是否可以在指定值上反弹 */
|
|
322
|
+
overshootClamping?: boolean
|
|
323
|
+
/** 弹簧静止时的位移 */
|
|
324
|
+
restDisplacementThreshold?: number
|
|
325
|
+
/** 弹簧静止的速度 */
|
|
326
|
+
restSpeedThreshold?: number
|
|
327
|
+
/** 速度 */
|
|
328
|
+
velocity?: number
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
namespace timing {
|
|
333
|
+
interface Option {
|
|
334
|
+
/** 动画时长 */
|
|
335
|
+
duration?: number
|
|
336
|
+
/** 动画曲线 */
|
|
337
|
+
easing?: (t: number) => number
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
interface TaroStatic {
|
|
343
|
+
worklet: worklet
|
|
344
|
+
}
|
|
59
345
|
}
|
|
@@ -310,7 +310,7 @@ declare module '../../index' {
|
|
|
310
310
|
createBufferURL(
|
|
311
311
|
/** 需要存入内存的二进制数据 */
|
|
312
312
|
buffer: ArrayBuffer | TypedArray
|
|
313
|
-
):
|
|
313
|
+
): string
|
|
314
314
|
|
|
315
315
|
/** Taro.clearStorage 的同步版本
|
|
316
316
|
* @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid
|
|
@@ -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_hybrid
|
|
331
331
|
* @example
|
|
332
332
|
* ```tsx
|
|
333
333
|
* Taro.clearStorage()
|
|
@@ -22,7 +22,7 @@ declare module '../index' {
|
|
|
22
22
|
onShow: string
|
|
23
23
|
preloadData?: Record<any, any>
|
|
24
24
|
/**
|
|
25
|
-
* RN 私有对象navigationRef,用于使用底层接口控制路由
|
|
25
|
+
* RN 私有对象 navigationRef,用于使用底层接口控制路由
|
|
26
26
|
*/
|
|
27
27
|
rnNavigationRef?: React.RefObject<any>
|
|
28
28
|
}
|
|
@@ -48,13 +48,14 @@ declare module '../index' {
|
|
|
48
48
|
[TaroGeneral.ENV_TYPE.HARMONY]: TaroGeneral.ENV_TYPE.HARMONY
|
|
49
49
|
[TaroGeneral.ENV_TYPE.QUICKAPP]: TaroGeneral.ENV_TYPE.QUICKAPP
|
|
50
50
|
[TaroGeneral.ENV_TYPE.HARMONYHYBRID]: TaroGeneral.ENV_TYPE.HARMONYHYBRID
|
|
51
|
+
[TaroGeneral.ENV_TYPE.ASCF]: TaroGeneral.ENV_TYPE.ASCF
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
namespace interceptorify {
|
|
54
|
-
type
|
|
55
|
+
type promisifyApi<T, R> = (requestParams: T) => Promise<R>
|
|
55
56
|
interface InterceptorifyChain<T, R> {
|
|
56
57
|
requestParams: T
|
|
57
|
-
proceed:
|
|
58
|
+
proceed: promisifyApi<T, R>
|
|
58
59
|
}
|
|
59
60
|
type InterceptorifyInterceptor<T, R> = (chain: InterceptorifyChain<T, R>) => Promise<R>
|
|
60
61
|
interface Interceptorify<T, R> {
|
|
@@ -111,7 +112,7 @@ declare module '../index' {
|
|
|
111
112
|
mpVersion: string
|
|
112
113
|
/** 小程序环境 */
|
|
113
114
|
envType: string
|
|
114
|
-
/** 小程序appId */
|
|
115
|
+
/** 小程序 appId */
|
|
115
116
|
appId: string
|
|
116
117
|
}
|
|
117
118
|
/** 插件信息 */
|
|
@@ -120,7 +121,7 @@ declare module '../index' {
|
|
|
120
121
|
common: {
|
|
121
122
|
/** 用户数据存储的路径 */
|
|
122
123
|
USER_DATA_PATH: string
|
|
123
|
-
/** 校验白名单属性中的appInfoLaunchFrom后返回额外信息 */
|
|
124
|
+
/** 校验白名单属性中的 appInfoLaunchFrom 后返回额外信息 */
|
|
124
125
|
location: string | undefined
|
|
125
126
|
launchFrom: string | undefined
|
|
126
127
|
schema: string | undefined
|
|
@@ -173,9 +174,9 @@ declare module '../index' {
|
|
|
173
174
|
getRenderer(): 'webview' | 'skyline'
|
|
174
175
|
|
|
175
176
|
/**
|
|
176
|
-
* 包裹
|
|
177
|
+
* 包裹 promisify api 的洋葱圈模型
|
|
177
178
|
* @supported global
|
|
178
|
-
* @param
|
|
179
|
+
* @param promisifyApi
|
|
179
180
|
* @example
|
|
180
181
|
* ```tsx
|
|
181
182
|
* // 创建实例
|
|
@@ -227,6 +228,6 @@ declare module '../index' {
|
|
|
227
228
|
* })
|
|
228
229
|
* ```
|
|
229
230
|
*/
|
|
230
|
-
interceptorify<T, R>(
|
|
231
|
+
interceptorify<T, R>(api: interceptorify.promisifyApi<T, R>): interceptorify.Interceptorify<T, R>
|
|
231
232
|
}
|
|
232
233
|
}
|
|
@@ -98,20 +98,20 @@ declare module '../index' {
|
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* 页面加载完成时的回调。
|
|
101
|
-
* @supported weapp, h5, harmony_hybrid
|
|
101
|
+
* @supported weapp, h5, harmony_hybrid, harmony
|
|
102
102
|
*/
|
|
103
103
|
useLoad<T extends {} = Record<string, any>>(callback: (param: T) => void): void
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* 页面卸载时的回调。
|
|
107
|
-
* @supported weapp, h5, harmony_hybrid
|
|
107
|
+
* @supported weapp, h5, harmony_hybrid, harmony
|
|
108
108
|
*/
|
|
109
109
|
useUnload(callback: () => void): void
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* 页面初次渲染完成的回调。
|
|
113
113
|
* 此时页面已经准备妥当,可以和视图层进行交互。
|
|
114
|
-
* @supported weapp, h5, harmony_hybrid
|
|
114
|
+
* @supported weapp, h5, harmony_hybrid, harmony
|
|
115
115
|
*/
|
|
116
116
|
useReady(callback: () => void): void
|
|
117
117
|
|
|
@@ -133,6 +133,12 @@ declare module '../index' {
|
|
|
133
133
|
*/
|
|
134
134
|
useOptionMenuClick(callback: () => void): void
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* 键盘高度变化时的回调。
|
|
138
|
+
* @supported alipay
|
|
139
|
+
*/
|
|
140
|
+
useKeyboardHeight(callback: (payload: { height: number }) => void): void
|
|
141
|
+
|
|
136
142
|
/**
|
|
137
143
|
* 下拉中断时的回调。
|
|
138
144
|
* @supported alipay, h5, harmony_hybrid
|
|
@@ -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_hybrid
|
|
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_hybrid
|
|
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_hybrid
|
|
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_hybrid
|
|
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_hybrid
|
|
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_hybrid
|
|
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_hybrid
|
|
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>
|
|
@@ -6,6 +6,7 @@ import type { IOption, IPostcssOption, IUrlLoaderOption } from './util'
|
|
|
6
6
|
import type { OutputOptions as RollupOutputOptions } from 'rollup'
|
|
7
7
|
import type { Compiler, CompilerTypes, CompilerWebpackTypes } from '../compiler'
|
|
8
8
|
import type { OutputExt } from './project'
|
|
9
|
+
import type { ServerOptions as ViteServerOptions } from 'vite'
|
|
9
10
|
|
|
10
11
|
export interface IH5RouterConfig {
|
|
11
12
|
/** 配置路由模式 */
|
|
@@ -51,7 +52,8 @@ export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {
|
|
|
51
52
|
router?: IH5RouterConfig
|
|
52
53
|
|
|
53
54
|
/** 预览服务的配置,可以更改端口等参数。具体配置参考 [webpack-dev-server](https://webpack.js.org/configuration/dev-server) */
|
|
54
|
-
|
|
55
|
+
// 修改后:同时支持 Webpack 和 Vite
|
|
56
|
+
devServer?: T extends 'vite' ? ViteServerOptions : webpackDevServer.Configuration
|
|
55
57
|
|
|
56
58
|
/** 用于控制是否生成 js、css 对应的 sourceMap (默认值:watch 模式下为 true,否则为 false) */
|
|
57
59
|
enableSourceMap?: boolean
|
|
@@ -119,8 +121,9 @@ export interface IH5Config <T extends CompilerTypes = CompilerWebpackTypes> {
|
|
|
119
121
|
|
|
120
122
|
/** Web 编译过程的相关配置 */
|
|
121
123
|
compile?: {
|
|
122
|
-
exclude?:
|
|
123
|
-
include?:
|
|
124
|
+
exclude?: any[]
|
|
125
|
+
include?: any[]
|
|
126
|
+
/** 对应 @rollup/plugin-babel 插件的 filter 配置。只在 vite 编译模式下有效 */
|
|
124
127
|
filter?: (filename: string) => boolean
|
|
125
128
|
}
|
|
126
129
|
/** 生成的代码是否要兼容旧版浏览器,值为 true 时,会去读取 package.json 的 browserslist 字段。只在 vite 编译模式下有效 */
|
|
@@ -91,8 +91,9 @@ export interface IMiniAppConfig<T extends CompilerTypes = CompilerWebpackTypes>
|
|
|
91
91
|
|
|
92
92
|
/** 小程序编译过程的相关配置 */
|
|
93
93
|
compile?: {
|
|
94
|
-
exclude?:
|
|
95
|
-
include?:
|
|
94
|
+
exclude?: any[]
|
|
95
|
+
include?: any[]
|
|
96
|
+
/** 对应 @rollup/plugin-babel 插件的 filter 配置。只在 vite 编译模式下有效 */
|
|
96
97
|
filter?: (filename: string) => boolean
|
|
97
98
|
}
|
|
98
99
|
|
|
@@ -9,6 +9,7 @@ import type { AppConfig, PageConfig } from '../index'
|
|
|
9
9
|
|
|
10
10
|
export interface ViteNativeCompMeta {
|
|
11
11
|
name: string
|
|
12
|
+
exportName: string
|
|
12
13
|
scriptPath: string
|
|
13
14
|
configPath: string
|
|
14
15
|
config: PageConfig
|
|
@@ -16,6 +17,7 @@ export interface ViteNativeCompMeta {
|
|
|
16
17
|
templatePath: string
|
|
17
18
|
cssPath?: string
|
|
18
19
|
isPackage?: boolean
|
|
20
|
+
isGenerated?: boolean
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export interface ViteFileType {
|
|
@@ -57,6 +59,7 @@ export interface ViteHarmonyBuildConfig extends CommonBuildConfig, IHarmonyConfi
|
|
|
57
59
|
runtimePath?: string | string[]
|
|
58
60
|
isPure?: boolean
|
|
59
61
|
taroComponentsPath: string
|
|
62
|
+
cssVariables?: boolean // 是否动态解析css变量
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
export interface CommonBuildConfig extends IProjectConfig<'vite'> {
|
|
@@ -109,6 +112,7 @@ export interface ViteCompilerContext<T> {
|
|
|
109
112
|
configFileList: string[]
|
|
110
113
|
compilePage: (pageName: string) => VitePageMeta
|
|
111
114
|
watchConfigFile: (rollupCtx: PluginContext) => void
|
|
115
|
+
collectedDeps: (rollupCtx: PluginContext, id: string, filter, cache: Set<string> = new Set()) => Promise<Set<string>>
|
|
112
116
|
getAppScriptPath: () => string
|
|
113
117
|
getApp: () => ViteAppMeta
|
|
114
118
|
getPages: () => VitePageMeta[]
|
|
@@ -140,7 +144,9 @@ export interface ViteHarmonyCompilerContext extends ViteCompilerContext<ViteHarm
|
|
|
140
144
|
getCommonChunks: () => string[]
|
|
141
145
|
modifyHarmonyConfig: (config: Partial<AppConfig>) => void
|
|
142
146
|
modifyHostPackage: (deps?: Record<string, string>, devDeps?: Record<string, string>) => Exclude<IHarmonyConfig['ohPackage'], void>
|
|
143
|
-
|
|
147
|
+
resolvePageImportPath: (scriptPath: string, pageName: string) => string
|
|
148
|
+
collectNativeComponents: (meta: ViteAppMeta | VitePageMeta | ViteNativeCompMeta) => ViteNativeCompMeta[]
|
|
149
|
+
generateNativeComponent: (rollupCtx: PluginContext, meta: ViteNativeCompMeta, implicitlyLoadedAfterOneOf: string[] = []) => void
|
|
144
150
|
getScriptPath: (filePath: string) => string
|
|
145
151
|
getStylePath: (filePath: string) => string
|
|
146
152
|
getConfigPath: (filePath: string) => string
|
|
@@ -151,7 +157,9 @@ export interface ViteMiniCompilerContext extends ViteCompilerContext<ViteMiniBui
|
|
|
151
157
|
commonChunks: string[]
|
|
152
158
|
nativeComponents : Map<string, ViteNativeCompMeta>
|
|
153
159
|
getCommonChunks: () => string[]
|
|
154
|
-
|
|
160
|
+
resolvePageImportPath: (scriptPath: string, pageName: string) => string
|
|
161
|
+
collectNativeComponents: (meta: ViteAppMeta | VitePageMeta | ViteNativeCompMeta) => ViteNativeCompMeta[]
|
|
162
|
+
generateNativeComponent: (rollupCtx: PluginContext, meta: ViteNativeCompMeta, implicitlyLoadedAfterOneOf: string[] = []) => void
|
|
155
163
|
getScriptPath: (filePath: string) => string
|
|
156
164
|
getTemplatePath: (filePath: string) => string
|
|
157
165
|
getStylePath: (filePath: string) => string
|
package/types/global.d.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -192,4 +192,5 @@ declare namespace Taro {
|
|
|
192
192
|
declare global {
|
|
193
193
|
const defineAppConfig: (config: Taro.AppConfig) => Taro.AppConfig
|
|
194
194
|
const definePageConfig: (config: Taro.PageConfig) => Taro.Config
|
|
195
|
+
const importNativeComponent: <T> (path: string, name = '', exportName = 'default') => Awaited<T>
|
|
195
196
|
}
|
|
@@ -45,6 +45,8 @@ declare module './index' {
|
|
|
45
45
|
eh?(event: MpEvent): void
|
|
46
46
|
onLoad(options: Record<string, unknown>): void
|
|
47
47
|
onOptionMenuClick?(): void
|
|
48
|
+
/** 键盘高度变化时触发 @supported alipay */
|
|
49
|
+
onKeyboardHeight?(opt: { height: number; }): void
|
|
48
50
|
onPageScroll?(opt: PageScrollObject): void
|
|
49
51
|
onPopMenuClick?(): void
|
|
50
52
|
onPullDownRefresh?(): void
|
|
@@ -130,6 +132,26 @@ declare module './index' {
|
|
|
130
132
|
/** 是否返回变更的 data 字段信息 */
|
|
131
133
|
withDataPaths?: boolean
|
|
132
134
|
}, listener: () => void): void
|
|
135
|
+
/**
|
|
136
|
+
* 绑定由 worklet 驱动的样式到相应的节点
|
|
137
|
+
* @param selector 节点选择器
|
|
138
|
+
* @param updater worklet 样式更新函数
|
|
139
|
+
* @param config 配置项
|
|
140
|
+
* @param callback 完成样式绑定的回调
|
|
141
|
+
* */
|
|
142
|
+
applyAnimatedStyle?(selector: string, updater: TaroGeneral.TFunc, config?: {
|
|
143
|
+
/** 是否立即执行一次 updater 函数 */
|
|
144
|
+
immediate?: boolean
|
|
145
|
+
/** 刷新时机,枚举值 async / sync */
|
|
146
|
+
flush?: string
|
|
147
|
+
}, callback?: TaroGeneral.TFunc): void
|
|
148
|
+
/**
|
|
149
|
+
* 清除节点上 worklet 驱动样式的绑定关系
|
|
150
|
+
* @param selector 节点选择器
|
|
151
|
+
* @param styleIds 需要清除的 styleId 集合
|
|
152
|
+
* @param callback 清除样式绑定的回调
|
|
153
|
+
* */
|
|
154
|
+
clearAnimatedStyle?(selector: string, styleIds: Array<Number>, callback?: TaroGeneral.TFunc): void
|
|
133
155
|
}
|
|
134
156
|
interface PageInstance extends PageLifeCycle, ComponentInstance {
|
|
135
157
|
/** 页面配置 */
|
package/types/taro.config.d.ts
CHANGED
|
@@ -193,7 +193,7 @@ declare module './index' {
|
|
|
193
193
|
/** 页面自定义组件配置
|
|
194
194
|
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/
|
|
195
195
|
*/
|
|
196
|
-
usingComponents?: Record<string, string>
|
|
196
|
+
usingComponents?: Record<string, string | [string, string]>
|
|
197
197
|
/** 指定使用升级后的 weui 样式
|
|
198
198
|
* - v2: 可表明启用新版的组件样式
|
|
199
199
|
* @default default
|
|
@@ -581,7 +581,7 @@ declare module './index' {
|
|
|
581
581
|
desc: string
|
|
582
582
|
/** 在该场景下打开小程序时跳转页面 */
|
|
583
583
|
path: string
|
|
584
|
-
}
|
|
584
|
+
}[]
|
|
585
585
|
/** 定制化型服务商票据 */
|
|
586
586
|
serviceProviderTicket?: string
|
|
587
587
|
/** 半屏小程序 appId */
|