@tarojs/taro 3.5.0-canary.1 → 3.5.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/html.css +50 -14
- package/html5.css +167 -64
- package/index.js +3 -4
- package/package.json +21 -11
- package/types/api/ad/index.d.ts +2 -2
- package/types/api/ai/face.d.ts +133 -0
- package/types/api/ai/visionkit.d.ts +303 -0
- package/types/api/base/crypto.d.ts +90 -0
- package/types/api/base/debug.d.ts +152 -13
- package/types/api/base/env.d.ts +2 -1
- package/types/api/base/index.d.ts +11 -3
- package/types/api/base/performance.d.ts +195 -0
- package/types/api/base/system.d.ts +541 -103
- package/types/api/base/update.d.ts +60 -8
- package/types/api/base/weapp/app-event.d.ts +99 -37
- package/types/api/base/weapp/life-cycle.d.ts +142 -2
- package/types/api/canvas/index.d.ts +151 -137
- package/types/api/cloud/index.d.ts +17 -2
- package/types/api/data-analysis/index.d.ts +1 -1
- package/types/api/device/accelerometer.d.ts +6 -6
- package/types/api/device/accessibility.d.ts +26 -0
- package/types/api/device/battery.d.ts +2 -2
- package/types/api/device/{ble.d.ts → bluetooth-ble.d.ts} +228 -62
- package/types/api/device/bluetooth-peripheral.d.ts +430 -0
- package/types/api/device/bluetooth.d.ts +67 -2
- package/types/api/device/calendar.d.ts +88 -0
- package/types/api/device/clipboard.d.ts +2 -2
- package/types/api/device/compass.d.ts +3 -3
- package/types/api/device/contact.d.ts +74 -50
- package/types/api/device/gyroscope.d.ts +6 -6
- package/types/api/device/iBeacon.d.ts +33 -19
- package/types/api/{ui → device}/keyboard.d.ts +1 -1
- package/types/api/device/{performance.d.ts → memory.d.ts} +5 -5
- package/types/api/device/motion.d.ts +3 -3
- package/types/api/device/network.d.ts +56 -15
- package/types/api/device/nfc.d.ts +1089 -13
- package/types/api/device/phone.d.ts +1 -1
- package/types/api/device/scan.d.ts +1 -1
- package/types/api/device/screen.d.ts +42 -14
- package/types/api/device/vibrate.d.ts +6 -2
- package/types/api/device/wifi.d.ts +44 -9
- package/types/api/ext/index.d.ts +2 -2
- package/types/api/files/index.d.ts +392 -205
- package/types/api/framework/index.d.ts +5 -4
- package/types/api/location/index.d.ts +156 -53
- package/types/api/media/audio.d.ts +629 -38
- package/types/api/media/background-audio.d.ts +9 -9
- package/types/api/media/camera.d.ts +41 -22
- package/types/api/media/editor.d.ts +22 -2
- package/types/api/media/image.d.ts +64 -35
- package/types/api/media/live.d.ts +66 -6
- package/types/api/media/map.d.ts +474 -54
- package/types/api/media/media-recorder.d.ts +92 -0
- package/types/api/media/recorder.d.ts +21 -21
- package/types/api/media/video-decoder.d.ts +117 -0
- package/types/api/media/video-processing.d.ts +11 -7
- package/types/api/media/video.d.ts +47 -18
- package/types/api/media/voip.d.ts +290 -0
- package/types/api/{open-api/navigate.d.ts → navigate/index.d.ts} +65 -27
- package/types/api/network/download.d.ts +61 -19
- package/types/api/network/request.d.ts +129 -41
- package/types/api/network/tcp.d.ts +181 -0
- package/types/api/network/udp.d.ts +154 -83
- package/types/api/network/upload.d.ts +55 -28
- package/types/api/network/websocket.d.ts +20 -19
- package/types/api/open-api/address.d.ts +1 -1
- package/types/api/open-api/authorize.d.ts +42 -3
- package/types/api/open-api/channels.d.ts +178 -0
- package/types/api/open-api/facial.d.ts +3 -0
- package/types/api/open-api/favorites.d.ts +100 -0
- package/types/api/open-api/group.d.ts +59 -0
- package/types/api/open-api/invoice.d.ts +2 -2
- package/types/api/open-api/license-plate.d.ts +27 -0
- package/types/api/open-api/login.d.ts +21 -0
- package/types/api/open-api/redpackage.d.ts +24 -0
- package/types/api/open-api/settings.d.ts +82 -17
- package/types/api/open-api/soter.d.ts +2 -2
- package/types/api/open-api/subscribe-message.d.ts +89 -4
- package/types/api/open-api/user-info.d.ts +56 -19
- package/types/api/open-api/werun.d.ts +33 -6
- package/types/api/payment/index.d.ts +119 -0
- package/types/api/route/index.d.ts +18 -14
- package/types/api/share/index.d.ts +192 -9
- package/types/api/storage/index.d.ts +38 -92
- package/types/api/swan/index.d.ts +1 -1
- package/types/api/ui/animation.d.ts +105 -155
- package/types/api/ui/background.d.ts +4 -2
- package/types/api/ui/custom-component.d.ts +1 -1
- package/types/api/ui/fonts.d.ts +27 -31
- package/types/api/ui/interaction.d.ts +6 -6
- package/types/api/ui/menu.d.ts +1 -1
- package/types/api/ui/navigation-bar.d.ts +6 -5
- package/types/api/ui/pull-down-refresh.d.ts +2 -2
- package/types/api/ui/scroll.d.ts +75 -7
- package/types/api/ui/sticky.d.ts +4 -4
- package/types/api/ui/tab-bar.d.ts +8 -8
- package/types/api/ui/window.d.ts +22 -2
- package/types/api/worker/index.d.ts +9 -1
- package/types/api/wxml/index.d.ts +116 -112
- package/types/compile.d.ts +57 -6
- package/types/global.d.ts +142 -111
- package/types/taro.api.d.ts +79 -62
- package/types/taro.component.d.ts +21 -65
- package/types/taro.config.d.ts +31 -0
- package/types/taro.extend.d.ts +31 -18
- package/types/taro.hooks.d.ts +55 -3
- package/types/taro.lifecycle.d.ts +21 -14
- package/LICENSE +0 -21
- package/types/api/open-api/payment.d.ts +0 -61
|
@@ -23,10 +23,10 @@ declare module '../../index' {
|
|
|
23
23
|
/**
|
|
24
24
|
* @default 0
|
|
25
25
|
*/
|
|
26
|
-
level?: keyof
|
|
26
|
+
level?: keyof Level
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
type
|
|
29
|
+
type Level = {
|
|
30
30
|
/** 表示会把 App、Page 的生命周期函数和 wx 命名空间下的函数调用写入日志 */
|
|
31
31
|
0
|
|
32
32
|
/** 表示不会把 App、Page 的生命周期函数和 wx 命名空间下的函数调用写入日志 */
|
|
@@ -34,6 +34,76 @@ declare module '../../index' {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/** 向调试面板中打印日志。console 是一个全局对象,可以直接访问。在微信客户端中,向 vConsole 中输出日志。
|
|
38
|
+
*
|
|
39
|
+
* **注意**
|
|
40
|
+
* - 由于 vConsole 功能有限,以及不同客户端对 console 方法的支持情况有差异,建议开发者在小程序中只使用本文档中提供的方法。
|
|
41
|
+
* - 部分内容展示的限制请参见调试
|
|
42
|
+
* @supported weapp
|
|
43
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.html
|
|
44
|
+
*/
|
|
45
|
+
interface console {
|
|
46
|
+
/** 向调试面板中打印 debug 日志
|
|
47
|
+
* @supported weapp
|
|
48
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.debug.html
|
|
49
|
+
*/
|
|
50
|
+
debug(
|
|
51
|
+
/** 日志内容,可以有任意多个。 */
|
|
52
|
+
...args: any[]
|
|
53
|
+
): void
|
|
54
|
+
/** 向调试面板中打印 error 日志
|
|
55
|
+
* @supported weapp
|
|
56
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.error.html
|
|
57
|
+
*/
|
|
58
|
+
error(
|
|
59
|
+
/** 日志内容,可以有任意多个。 */
|
|
60
|
+
...args: any[]
|
|
61
|
+
): void
|
|
62
|
+
/** 在调试面板中创建一个新的分组
|
|
63
|
+
*
|
|
64
|
+
* **注意**
|
|
65
|
+
* 仅在工具中有效,在 vConsole 中为空函数实现。
|
|
66
|
+
* @supported weapp
|
|
67
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.group.html
|
|
68
|
+
*/
|
|
69
|
+
group(
|
|
70
|
+
/** 分组标记 */
|
|
71
|
+
label?: string,
|
|
72
|
+
): void
|
|
73
|
+
/** 结束由 [console.group](#group) 创建的分组
|
|
74
|
+
*
|
|
75
|
+
* **注意**
|
|
76
|
+
* 仅在工具中有效,在 vConsole 中为空函数实现。
|
|
77
|
+
* @supported weapp
|
|
78
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.groupEnd.html
|
|
79
|
+
*/
|
|
80
|
+
groupEnd(): void
|
|
81
|
+
/** 向调试面板中打印 info 日志
|
|
82
|
+
* @supported weapp
|
|
83
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.info.html
|
|
84
|
+
*/
|
|
85
|
+
info(
|
|
86
|
+
/** 日志内容,可以有任意多个。 */
|
|
87
|
+
...args: any[]
|
|
88
|
+
): void
|
|
89
|
+
/** 向调试面板中打印 log 日志
|
|
90
|
+
* @supported weapp, tt
|
|
91
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.log.html
|
|
92
|
+
*/
|
|
93
|
+
log(
|
|
94
|
+
/** 日志内容,可以有任意多个。 */
|
|
95
|
+
...args: any[]
|
|
96
|
+
): void
|
|
97
|
+
/** 向调试面板中打印 warn 日志
|
|
98
|
+
* @supported weapp
|
|
99
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.warn.html
|
|
100
|
+
*/
|
|
101
|
+
warn(
|
|
102
|
+
/** 日志内容,可以有任意多个。 */
|
|
103
|
+
...args: any[]
|
|
104
|
+
): void
|
|
105
|
+
}
|
|
106
|
+
|
|
37
107
|
/**
|
|
38
108
|
* 日志管理器实例,可以通过 Taro.getLogManager 获取。
|
|
39
109
|
*
|
|
@@ -44,6 +114,8 @@ declare module '../../index' {
|
|
|
44
114
|
* 开发者可以通过小程序管理后台左侧菜单“反馈管理”页面查看相关打印日志。
|
|
45
115
|
*
|
|
46
116
|
* 基础库默认会把 App、Page 的生命周期函数和 wx 命名空间下的函数调用写入日志。
|
|
117
|
+
* @supported weapp
|
|
118
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/LogManager.html
|
|
47
119
|
*/
|
|
48
120
|
interface LogManager {
|
|
49
121
|
/** 写 debug 日志
|
|
@@ -86,6 +158,8 @@ declare module '../../index' {
|
|
|
86
158
|
* 使用说明
|
|
87
159
|
* 为帮助小程序开发者快捷地排查小程序漏洞、定位问题,我们推出了实时日志功能。从基础库2.7.1开始,开发者可通过提供的接口打印日志,日志汇聚并实时上报到小程序后台。
|
|
88
160
|
* 开发者可从小程序管理后台“开发->运维中心->实时日志”进入日志查询页面,查看开发者打印的日志信息。
|
|
161
|
+
* @supported weapp
|
|
162
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/RealtimeLogManager.html
|
|
89
163
|
*/
|
|
90
164
|
|
|
91
165
|
interface RealtimeLogManager {
|
|
@@ -129,6 +203,14 @@ declare module '../../index' {
|
|
|
129
203
|
/** 过滤关键字,最多不超过1Kb,可以在小程序管理后台根据设置的内容搜索得到对应的日志。 */
|
|
130
204
|
msg: string
|
|
131
205
|
): void
|
|
206
|
+
/** 获取给定标签的日志管理器实例,目前只支持在插件使用
|
|
207
|
+
* @supported weapp
|
|
208
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/RealtimeLogManager.tag.html
|
|
209
|
+
*/
|
|
210
|
+
tag(
|
|
211
|
+
/** 标签名 */
|
|
212
|
+
tagName: string
|
|
213
|
+
): RealtimeTagLogManager
|
|
132
214
|
/** 写 warn 日志
|
|
133
215
|
* @supported weapp
|
|
134
216
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/RealtimeLogManager.warn.html
|
|
@@ -139,6 +221,63 @@ declare module '../../index' {
|
|
|
139
221
|
): void
|
|
140
222
|
}
|
|
141
223
|
|
|
224
|
+
/** 给定标签的实时日志管理器实例,可以通过 给定标签的实时日志管理器实例,可以通过 [RealtimeLogManager.tag](./RealtimeLogManager#tag) 接口获取,目前只支持在插件使用。 接口获取,目前只支持在插件使用。
|
|
225
|
+
*
|
|
226
|
+
* **使用说明**
|
|
227
|
+
* RealtimeTagLogManager 功能和 [RealtimeLogManager](./RealtimeLogManager) 相似,但是为了让输出的实时日志更易于分析,其具有更严格的格式要求。
|
|
228
|
+
* RealtimeTagLogManager 使用时需要传入标签,调用该实例所输出的日志均会被汇集到对应标签下,同时该实例的日志只支持 key-value 格式进行输出。
|
|
229
|
+
* @supported weapp
|
|
230
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/RealtimeTagLogManager.html
|
|
231
|
+
*/
|
|
232
|
+
interface RealtimeTagLogManager {
|
|
233
|
+
/** 添加过滤关键字
|
|
234
|
+
* @supported weapp
|
|
235
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/RealtimeTagLogManager.addFilterMsg.html
|
|
236
|
+
*/
|
|
237
|
+
addFilterMsg(
|
|
238
|
+
/** 是 setFilterMsg 的添加接口。用于设置多个过滤关键字。 */
|
|
239
|
+
msg: string
|
|
240
|
+
): void
|
|
241
|
+
/** 写 error 日志
|
|
242
|
+
* @supported weapp
|
|
243
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/RealtimeTagLogManager.error.html
|
|
244
|
+
*/
|
|
245
|
+
error(
|
|
246
|
+
/** 日志的 key */
|
|
247
|
+
key: string,
|
|
248
|
+
/** 日志的 key */
|
|
249
|
+
value: Object | any[] | number | string,
|
|
250
|
+
): void
|
|
251
|
+
/** 写 info 日志
|
|
252
|
+
* @supported weapp
|
|
253
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/RealtimeTagLogManager.info.html
|
|
254
|
+
*/
|
|
255
|
+
info(
|
|
256
|
+
/** 日志的 key */
|
|
257
|
+
key: string,
|
|
258
|
+
/** 日志的 key */
|
|
259
|
+
value: Object | any[] | number | string,
|
|
260
|
+
): void
|
|
261
|
+
/** 设置过滤关键字
|
|
262
|
+
* @supported weapp
|
|
263
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/RealtimeTagLogManager.setFilterMsg.html
|
|
264
|
+
*/
|
|
265
|
+
setFilterMsg(
|
|
266
|
+
/** 过滤关键字,最多不超过1Kb,可以在小程序管理后台根据设置的内容搜索得到对应的日志。 */
|
|
267
|
+
msg: string
|
|
268
|
+
): void
|
|
269
|
+
/** 写 warn 日志
|
|
270
|
+
* @supported weapp
|
|
271
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/RealtimeTagLogManager.warn.html
|
|
272
|
+
*/
|
|
273
|
+
warn(
|
|
274
|
+
/** 日志的 key */
|
|
275
|
+
key: string,
|
|
276
|
+
/** 日志的 key */
|
|
277
|
+
value: Object | any[] | number | string,
|
|
278
|
+
): void
|
|
279
|
+
}
|
|
280
|
+
|
|
142
281
|
interface TaroStatic {
|
|
143
282
|
/**
|
|
144
283
|
* 设置是否打开调试开关,此开关对正式版也能生效。
|
|
@@ -159,32 +298,32 @@ declare module '../../index' {
|
|
|
159
298
|
setEnableDebug(res: setEnableDebug.Option): Promise<setEnableDebug.Promised>
|
|
160
299
|
|
|
161
300
|
/**
|
|
162
|
-
*
|
|
301
|
+
* 获取实时日志管理器对象。
|
|
163
302
|
* @supported weapp
|
|
164
303
|
* @example
|
|
165
304
|
* ```tsx
|
|
166
|
-
* const logger = Taro.
|
|
167
|
-
*
|
|
168
|
-
* logger.log({str: 'hello world'}, 'basic log', 100, [1, 2, 3])
|
|
305
|
+
* const logger = Taro.getRealtimeLogManager()
|
|
169
306
|
* logger.info({str: 'hello world'}, 'info log', 100, [1, 2, 3])
|
|
170
|
-
* logger.
|
|
307
|
+
* logger.error({str: 'hello world'}, 'error log', 100, [1, 2, 3])
|
|
171
308
|
* logger.warn({str: 'hello world'}, 'warn log', 100, [1, 2, 3])
|
|
172
309
|
* ```
|
|
173
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/wx.getLogManager.html
|
|
174
310
|
*/
|
|
175
|
-
|
|
311
|
+
getRealtimeLogManager(): RealtimeLogManager
|
|
176
312
|
|
|
177
313
|
/**
|
|
178
|
-
*
|
|
314
|
+
* 获取日志管理器对象。
|
|
179
315
|
* @supported weapp
|
|
180
316
|
* @example
|
|
181
317
|
* ```tsx
|
|
182
|
-
* const logger = Taro.
|
|
318
|
+
* const logger = Taro.getLogManager({level: 1})
|
|
319
|
+
*
|
|
320
|
+
* logger.log({str: 'hello world'}, 'basic log', 100, [1, 2, 3])
|
|
183
321
|
* logger.info({str: 'hello world'}, 'info log', 100, [1, 2, 3])
|
|
184
|
-
* logger.
|
|
322
|
+
* logger.debug({str: 'hello world'}, 'debug log', 100, [1, 2, 3])
|
|
185
323
|
* logger.warn({str: 'hello world'}, 'warn log', 100, [1, 2, 3])
|
|
186
324
|
* ```
|
|
325
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/wx.getLogManager.html
|
|
187
326
|
*/
|
|
188
|
-
|
|
327
|
+
getLogManager(res?: getLogManager.Option): LogManager
|
|
189
328
|
}
|
|
190
329
|
}
|
package/types/api/base/env.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import Taro from '../../index'
|
|
|
3
3
|
declare module '../../index' {
|
|
4
4
|
interface TaroStatic {
|
|
5
5
|
/**
|
|
6
|
-
* @supported weapp
|
|
6
|
+
* @supported weapp, h5, rn
|
|
7
7
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/env/envObj.html
|
|
8
8
|
*/
|
|
9
9
|
env: {
|
|
10
|
+
[key: string]: string | undefined
|
|
10
11
|
/** 文件系统中的用户目录路径 (本地路径) */
|
|
11
12
|
USER_DATA_PATH: string
|
|
12
13
|
}
|
|
@@ -3,7 +3,7 @@ import Taro from '../../index'
|
|
|
3
3
|
declare module '../../index' {
|
|
4
4
|
interface TaroStatic {
|
|
5
5
|
/** 判断小程序的 API,回调,参数,组件等是否在当前版本可用。
|
|
6
|
-
* @supported weapp
|
|
6
|
+
* @supported weapp, tt
|
|
7
7
|
* @example
|
|
8
8
|
* ```tsx
|
|
9
9
|
* Taro.canIUse('openBluetoothAdapter')
|
|
@@ -35,9 +35,16 @@ declare module '../../index' {
|
|
|
35
35
|
schema: string
|
|
36
36
|
): boolean
|
|
37
37
|
|
|
38
|
+
/** 判断能否使用 WebP 格式
|
|
39
|
+
*
|
|
40
|
+
* > 在小程序平台中仅在 android 和 devtools 设备时可用
|
|
41
|
+
* @supported global
|
|
42
|
+
*/
|
|
43
|
+
canIUseWebp(): boolean
|
|
44
|
+
|
|
38
45
|
/**
|
|
39
46
|
* 将 Base64 字符串转成 ArrayBuffer 数据。
|
|
40
|
-
* @supported weapp, h5
|
|
47
|
+
* @supported weapp, h5, rn, tt
|
|
41
48
|
* @example
|
|
42
49
|
* ```tsx
|
|
43
50
|
* const base64 = 'CxYh'
|
|
@@ -52,7 +59,7 @@ declare module '../../index' {
|
|
|
52
59
|
|
|
53
60
|
/**
|
|
54
61
|
* 将 ArrayBuffer 数据转成 Base64 字符串。
|
|
55
|
-
* @supported weapp, h5
|
|
62
|
+
* @supported weapp, h5, rn, tt
|
|
56
63
|
* @example
|
|
57
64
|
* ```tsx
|
|
58
65
|
* const arrayBuffer = new Uint8Array([11, 22, 33])
|
|
@@ -88,6 +95,7 @@ declare module '../../index' {
|
|
|
88
95
|
|
|
89
96
|
/**
|
|
90
97
|
* 预加载的数据
|
|
98
|
+
* @ignore
|
|
91
99
|
*/
|
|
92
100
|
preloadData: Record<string, any>
|
|
93
101
|
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
4
|
+
/** EntryList 对象
|
|
5
|
+
* @supported weapp
|
|
6
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.html
|
|
7
|
+
*/
|
|
8
|
+
interface EntryList {
|
|
9
|
+
/** 该方法返回当前列表中的所有性能数据
|
|
10
|
+
* @supported weapp
|
|
11
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.getEntries.html
|
|
12
|
+
*/
|
|
13
|
+
getEntries(): PerformanceEntry[]
|
|
14
|
+
/** 获取当前列表中所有名称为 [name] 且类型为 [entryType] 的性能数据
|
|
15
|
+
* @supported weapp
|
|
16
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.getEntriesByName.html
|
|
17
|
+
*/
|
|
18
|
+
getEntriesByName(name: string, entryType: string): PerformanceEntry[]
|
|
19
|
+
/** 获取当前列表中所有类型为 [entryType] 的性能数据
|
|
20
|
+
* @supported weapp
|
|
21
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/EntryList.getEntriesByType.html
|
|
22
|
+
*/
|
|
23
|
+
getEntriesByType(entryType: string): PerformanceEntry[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Performance 对象,用于获取性能数据及创建性能监听器
|
|
27
|
+
* @supported weapp, tt
|
|
28
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.html
|
|
29
|
+
*/
|
|
30
|
+
interface Performance {
|
|
31
|
+
/** 创建全局性能事件监听器
|
|
32
|
+
* @supported weapp
|
|
33
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.createObserver.html
|
|
34
|
+
*/
|
|
35
|
+
createObserver(callback: Function): PerformanceObserver
|
|
36
|
+
/** 该方法返回当前缓冲区中的所有性能数据
|
|
37
|
+
* @supported weapp, tt
|
|
38
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntries.html
|
|
39
|
+
*/
|
|
40
|
+
getEntries(): PerformanceEntry[]
|
|
41
|
+
/** 获取当前缓冲区中所有名称为 [name] 且类型为 [entryType] 的性能数据
|
|
42
|
+
* @supported weapp, tt
|
|
43
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntriesByName.html
|
|
44
|
+
*/
|
|
45
|
+
getEntriesByName(name: string, entryType: string): PerformanceEntry[]
|
|
46
|
+
/** 获取当前缓冲区中所有类型为 [entryType] 的性能数据
|
|
47
|
+
* @supported weapp, tt
|
|
48
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntriesByType.html
|
|
49
|
+
*/
|
|
50
|
+
getEntriesByType(entryType: string): PerformanceEntry[]
|
|
51
|
+
/** 设置缓冲区大小,默认缓冲 30 条性能数据
|
|
52
|
+
* @supported weapp
|
|
53
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.setBufferSize.html
|
|
54
|
+
*/
|
|
55
|
+
setBufferSize(size: number): void
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** 单条性能数据
|
|
59
|
+
* @supported weapp
|
|
60
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceEntry.html
|
|
61
|
+
*/
|
|
62
|
+
interface PerformanceEntry {
|
|
63
|
+
/** 指标类型 */
|
|
64
|
+
entryType: keyof PerformanceEntry.EntryType
|
|
65
|
+
/** 指标名称 */
|
|
66
|
+
name: keyof PerformanceEntry.EntryName
|
|
67
|
+
/** 开始时间,不同指标的具体含义会有差异 */
|
|
68
|
+
startTime: number
|
|
69
|
+
/** 耗时 ms。仅对于表示阶段的指标有效。 */
|
|
70
|
+
duration: number
|
|
71
|
+
/** 页面路径。仅 render 和 navigation 类型指标有效。 */
|
|
72
|
+
path: string
|
|
73
|
+
/** 路由真正响应开始时间。仅 navigation 类型指标有效。 */
|
|
74
|
+
navigationStart: number
|
|
75
|
+
/** 路由详细类型,与小程序路由方法对应。仅 navigation 类型指标有效。 */
|
|
76
|
+
navigationType: string
|
|
77
|
+
/** 分包名,主包表示为 APP。仅 evaluateScript 指标有效。 */
|
|
78
|
+
moduleName: string
|
|
79
|
+
/** 注入文件列表。仅 evaluateScript 指标有效。 */
|
|
80
|
+
fileList: string[]
|
|
81
|
+
/** 渲染层代码注入完成时间。仅 firstRender 指标有效。 */
|
|
82
|
+
viewLayerReadyTime: number
|
|
83
|
+
/** 首次渲染参数从逻辑层发出的时间。仅 firstRender 指标有效。 */
|
|
84
|
+
initDataSendTime: number
|
|
85
|
+
/** 首次渲染参数在渲染层收到的时间。仅 firstRender 指标有效。 */
|
|
86
|
+
initDataRecvTime: number
|
|
87
|
+
/** 渲染层执行渲染开始时间。仅 firstRender 指标有效。 */
|
|
88
|
+
viewLayerRenderStartTime: number
|
|
89
|
+
/** 渲染层执行渲染结束时间。仅 firstRender 指标有效。 */
|
|
90
|
+
viewLayerRenderEndTime: number
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** PerformanceObserver 对象,用于监听性能相关事件
|
|
94
|
+
* @supported weapp
|
|
95
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceObserver.html
|
|
96
|
+
*/
|
|
97
|
+
interface PerformanceObserver {
|
|
98
|
+
/** 获取当前支持的所有性能指标类型 */
|
|
99
|
+
supportedEntryTypes: PerformanceEntry[]
|
|
100
|
+
/** 停止监听
|
|
101
|
+
* @supported weapp
|
|
102
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceObserver.disconnect.html
|
|
103
|
+
*/
|
|
104
|
+
disconnect(): void
|
|
105
|
+
/** 开始监听
|
|
106
|
+
* @supported weapp
|
|
107
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceObserver.observe.html
|
|
108
|
+
*/
|
|
109
|
+
observe(option: PerformanceObserver.observe.Option): void
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
namespace PerformanceEntry {
|
|
113
|
+
/** entryType 的合法值 */
|
|
114
|
+
interface EntryType {
|
|
115
|
+
/** 路由 */
|
|
116
|
+
navigation
|
|
117
|
+
/** 渲染 */
|
|
118
|
+
render
|
|
119
|
+
/** 脚本 */
|
|
120
|
+
script
|
|
121
|
+
}
|
|
122
|
+
/** name 的合法值 */
|
|
123
|
+
interface EntryName {
|
|
124
|
+
/** 小程序启动耗时。起点为用户点击小程序图标,或小程序被拉起的时间;终点为首页 onReady。(entryType: navigation) */
|
|
125
|
+
appLaunch
|
|
126
|
+
/** 路由处理耗时。(entryType: navigation) */
|
|
127
|
+
route
|
|
128
|
+
/** 页面首次渲染耗时。起点为逻辑层收到路由事件,包括逻辑层页面与组件初始化、VD 同步、渲染层执行渲染的时间;终点为首页 onReady。(entryType: render) */
|
|
129
|
+
firstRender
|
|
130
|
+
/** [页面首次绘制](https://developer.mozilla.org/en-US/docs/Glossary/First_paint)。第一个像素渲染到屏幕上所用的时间。(entryType: render) */
|
|
131
|
+
firstPaint
|
|
132
|
+
/** [页面首次内容绘制](https://developer.mozilla.org/en-US/docs/Glossary/First_contentful_paint)。第一块内容渲染到屏幕上所用的时间。(entryType: render) */
|
|
133
|
+
firstContentfulPaint
|
|
134
|
+
/** 逻辑层 JS 代码注入耗时。(entryType: script) */
|
|
135
|
+
evaluateScript
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
namespace PerformanceObserver {
|
|
140
|
+
namespace observe {
|
|
141
|
+
interface Option {
|
|
142
|
+
/** 指标类型。不能和 entryTypes 同时使用 */
|
|
143
|
+
type: keyof EntryType
|
|
144
|
+
/** 指标类型列表。不能和 type 同时使用。 */
|
|
145
|
+
entryTypes: (keyof EntryType)[]
|
|
146
|
+
}
|
|
147
|
+
interface EntryType {
|
|
148
|
+
/** 路由 */
|
|
149
|
+
navigation
|
|
150
|
+
/** 渲染 */
|
|
151
|
+
render
|
|
152
|
+
/** 脚本 */
|
|
153
|
+
script
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface TaroStatic {
|
|
159
|
+
/** 小程序测速上报。使用前,需要在小程序管理后台配置。 详情参见[小程序测速](https://developers.weixin.qq.com/miniprogram/dev/framework/performanceReport/index.html)指南。
|
|
160
|
+
* @supported weapp
|
|
161
|
+
* @example
|
|
162
|
+
* ```tsx
|
|
163
|
+
* Taro.reportPerformance(1101, 680)
|
|
164
|
+
* Taro.reportPerformance(1101, 680, 'custom')
|
|
165
|
+
* ```
|
|
166
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.reportPerformance.html
|
|
167
|
+
*/
|
|
168
|
+
reportPerformance(
|
|
169
|
+
/** 指标 id */
|
|
170
|
+
id: number,
|
|
171
|
+
/** 需要上报的数值 */
|
|
172
|
+
value: number,
|
|
173
|
+
/** 自定义维度 */
|
|
174
|
+
dimensions?: string | string[],
|
|
175
|
+
): void
|
|
176
|
+
|
|
177
|
+
/** 小程序测速上报。使用前,需要在小程序管理后台配置。 详情参见[小程序测速](https://developers.weixin.qq.com/miniprogram/dev/framework/performanceReport/index.html)指南。
|
|
178
|
+
*
|
|
179
|
+
* **注意**
|
|
180
|
+
* - 目前,当开启代码 [按需注入](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/lazyload.html) `时,evaluateScript` 将仅包含公有部分代码,页面和组件的代码注入的时间会包含在 `firstRender` 中(因为页面和组件的代码注入过程成为了首次渲染过程的一部分)。因此开启按需注入后,脚本耗时降低,渲染时间提高属于正常现象,优化效果可以关注整体启动耗时(`appLaunch`)来评估。
|
|
181
|
+
* - `firstPaint` 和 `firstContentfulPaint` 指标在开启 `vconsole` 的情况下,由于绘制 `vconsoel` 的面板,会导致数据提前。
|
|
182
|
+
* @supported weapp, tt
|
|
183
|
+
* @example
|
|
184
|
+
* ```tsx
|
|
185
|
+
* const performance = Taro.getPerformance()
|
|
186
|
+
* const observer = performance.createObserver((entryList) => {
|
|
187
|
+
* console.log(entryList.getEntries())
|
|
188
|
+
* })
|
|
189
|
+
* observer.observe({ entryTypes: ['render', 'script', 'navigation'] })
|
|
190
|
+
* ```
|
|
191
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.getPerformance.html
|
|
192
|
+
*/
|
|
193
|
+
getPerformance(): Performance
|
|
194
|
+
}
|
|
195
|
+
}
|