@tarojs/taro 3.8.0-canary.0 → 4.0.0-beta.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.
Files changed (73) hide show
  1. package/html.css +9 -0
  2. package/package.json +11 -4
  3. package/types/api/ad/index.d.ts +6 -18
  4. package/types/api/ai/inference.d.ts +4 -8
  5. package/types/api/ai/visionkit.d.ts +625 -54
  6. package/types/api/base/performance.d.ts +5 -5
  7. package/types/api/base/system.d.ts +2 -2
  8. package/types/api/base/weapp/app-event.d.ts +4 -4
  9. package/types/api/canvas/index.d.ts +67 -54
  10. package/types/api/data-analysis/index.d.ts +51 -1
  11. package/types/api/device/accelerometer.d.ts +8 -6
  12. package/types/api/device/accessibility.d.ts +1 -1
  13. package/types/api/device/battery.d.ts +3 -3
  14. package/types/api/device/bluetooth-ble.d.ts +40 -17
  15. package/types/api/device/bluetooth-peripheral.d.ts +26 -26
  16. package/types/api/device/bluetooth.d.ts +37 -13
  17. package/types/api/device/calendar.d.ts +11 -1
  18. package/types/api/device/clipboard.d.ts +17 -17
  19. package/types/api/device/compass.d.ts +5 -5
  20. package/types/api/device/gyroscope.d.ts +4 -4
  21. package/types/api/device/iBeacon.d.ts +10 -8
  22. package/types/api/device/keyboard.d.ts +7 -5
  23. package/types/api/device/memory.d.ts +3 -4
  24. package/types/api/device/motion.d.ts +8 -6
  25. package/types/api/device/network.d.ts +12 -6
  26. package/types/api/device/nfc.d.ts +13 -13
  27. package/types/api/device/phone.d.ts +1 -1
  28. package/types/api/device/scan.d.ts +5 -3
  29. package/types/api/device/screen.d.ts +28 -12
  30. package/types/api/device/sms.d.ts +1 -1
  31. package/types/api/device/vibrate.d.ts +5 -5
  32. package/types/api/device/wifi.d.ts +25 -13
  33. package/types/api/files/index.d.ts +71 -41
  34. package/types/api/location/index.d.ts +166 -18
  35. package/types/api/media/audio.d.ts +50 -30
  36. package/types/api/media/camera.d.ts +6 -3
  37. package/types/api/media/image.d.ts +1 -1
  38. package/types/api/navigate/index.d.ts +2 -0
  39. package/types/api/network/download.d.ts +2 -10
  40. package/types/api/network/request.d.ts +1 -1
  41. package/types/api/network/upload.d.ts +2 -10
  42. package/types/api/open-api/device-voip.d.ts +2 -2
  43. package/types/api/open-api/login.d.ts +1 -1
  44. package/types/api/open-api/my-miniprogram.d.ts +2 -2
  45. package/types/api/open-api/privacy.d.ts +99 -0
  46. package/types/api/route/index.d.ts +8 -5
  47. package/types/api/skyline/index.d.ts +59 -0
  48. package/types/api/storage/background-fetch.d.ts +63 -11
  49. package/types/api/storage/cache-manager.d.ts +61 -10
  50. package/types/api/storage/index.d.ts +125 -10
  51. package/types/api/taro.extend.d.ts +9 -3
  52. package/types/api/ui/animation.d.ts +1 -1
  53. package/types/api/ui/fonts.d.ts +4 -3
  54. package/types/api/ui/interaction.d.ts +4 -4
  55. package/types/api/ui/navigation-bar.d.ts +5 -5
  56. package/types/api/ui/pull-down-refresh.d.ts +2 -2
  57. package/types/api/ui/scroll.d.ts +1 -1
  58. package/types/api/ui/tab-bar.d.ts +7 -7
  59. package/types/api/wxml/index.d.ts +4 -4
  60. package/types/compile/compiler.d.ts +7 -4
  61. package/types/compile/config/h5.d.ts +23 -10
  62. package/types/compile/config/harmony.d.ts +77 -0
  63. package/types/compile/config/index.d.ts +1 -0
  64. package/types/compile/config/mini.d.ts +58 -30
  65. package/types/compile/config/plugin.d.ts +34 -0
  66. package/types/compile/config/project.d.ts +26 -13
  67. package/types/compile/config/util.d.ts +22 -8
  68. package/types/compile/viteCompilerContext.d.ts +149 -0
  69. package/types/global.d.ts +1 -0
  70. package/types/index.d.ts +2 -0
  71. package/types/taro.api.d.ts +3 -0
  72. package/types/taro.component.d.ts +2 -1
  73. package/types/taro.config.d.ts +41 -4
@@ -3,7 +3,7 @@ import Taro from '../../index'
3
3
  declare module '../../index' {
4
4
  namespace isVKSupport {
5
5
  /** vision kit 版本 */
6
- interface Version {
6
+ interface IVersion {
7
7
  /** 旧版本 */
8
8
  v1
9
9
  /** v2 版本,目前只有 iOS 基础库 2.22.0 以上支持 */
@@ -12,24 +12,24 @@ declare module '../../index' {
12
12
  }
13
13
  namespace createVKSession {
14
14
  /** vision kit 版本 */
15
- interface Version {
15
+ interface IVersion {
16
16
  /** 旧版本 */
17
17
  v1
18
18
  /** v2 版本,目前只有 iOS 基础库 2.22.0 以上支持 */
19
19
  v2
20
20
  }
21
21
  /** 跟踪配置 */
22
- interface Track {
22
+ interface ITrack {
23
23
  /** 平面跟踪配置 */
24
- plane: Plane
24
+ plane: IPlane
25
25
  }
26
26
  /** 平面跟踪配置 */
27
- interface Plane {
27
+ interface IPlane {
28
28
  /** 平面跟踪配置模式 */
29
- mode: keyof PlaneMode
29
+ mode: keyof IPlaneMode
30
30
  }
31
31
  /** 平面跟踪配置模式合法值 */
32
- interface PlaneMode {
32
+ interface IPlaneMode {
33
33
  /** 检测横向平面 */
34
34
  1
35
35
  /** 检测纵向平面,只有 v2 版本支持 */
@@ -41,33 +41,59 @@ declare module '../../index' {
41
41
 
42
42
  /** anchor 对象,只有 v2 版本支持
43
43
  * @supported weapp
44
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKAnchor.html
44
+ * @ignore
45
45
  */
46
- interface VKAnchor {
46
+ type VKAnchor = VKBodyAnchor | VKDepthAnchor | VKFaceAnchor | VKHandAnchor | VKMarkerAnchor | VKOCRAnchor | VKPlaneAnchor
47
+
48
+ /** 人体 anchor
49
+ * @supported weapp
50
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKBodyAnchor.html
51
+ */
52
+ interface VKBodyAnchor {
47
53
  /** 唯一标识 */
48
54
  id: number
49
55
  /** 类型 */
50
- type: keyof VKAnchor.Type
51
- /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */
52
- transform: Float32Array
53
- /** 尺寸,只有平面 anchor 支持 */
54
- size: VKAnchor.Size
55
- /** 方向,只有平面 anchor 支持 */
56
- alignment: number
56
+ type: keyof VKBodyAnchor.IType
57
+ /** 识别序号 */
58
+ detectId: number
59
+ /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */
60
+ size: VKBodyAnchor.ISize
61
+ /** 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */
62
+ origin: VKBodyAnchor.IOrigin
63
+ /** 关键点的置信度 */
64
+ confidence: number[]
65
+ /** 关键点 */
66
+ points: VKBodyAnchor.IPoint[]
67
+ /** 总体置信值 */
68
+ score: number
57
69
  }
58
- namespace VKAnchor {
59
- /** anchor 对象类型合法值 */
60
- interface Type {
61
- /** 平面 */
62
- 0
70
+ namespace VKBodyAnchor {
71
+ /** 类型 */
72
+ interface IType {
73
+ /** 人体 */
74
+ 5
63
75
  }
64
- /** anchor 对象类型合法值 */
65
- interface Size {
76
+ /** 相对视窗的尺寸*/
77
+ interface ISize {
66
78
  /** 宽度 */
67
79
  width: number
68
80
  /** 高度 */
69
81
  height: number
70
82
  }
83
+ /** 相对视窗的位置信息 */
84
+ interface IOrigin {
85
+ /** 横坐标 */
86
+ x: number
87
+ /** 纵坐标 */
88
+ y: number
89
+ }
90
+ /** 关键点 */
91
+ interface IPoint {
92
+ /** 横坐标 */
93
+ x: number
94
+ /** 纵坐标 */
95
+ y: number
96
+ }
71
97
  }
72
98
 
73
99
  /** 相机对象
@@ -91,6 +117,296 @@ declare module '../../index' {
91
117
  ): Float32Array
92
118
  }
93
119
 
120
+ /** depth anchor
121
+ * @supported weapp
122
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKDepthAnchor.html
123
+ */
124
+ interface VKDepthAnchor {
125
+ /** 唯一标识 */
126
+ id: number
127
+ /** 类型 */
128
+ type: keyof VKDepthAnchor.IType
129
+ /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */
130
+ size: VKDepthAnchor.ISize
131
+ /** 包含深度信息的数组 */
132
+ depthArray: number[]
133
+ }
134
+ namespace VKDepthAnchor {
135
+ /** 类型 */
136
+ interface IType {
137
+ /** DEPTH */
138
+ 8
139
+ }
140
+ /** 相对视窗的尺寸 */
141
+ interface ISize {
142
+ /** 宽度 */
143
+ width: number
144
+ /** 高度 */
145
+ height: number
146
+ }
147
+ }
148
+
149
+ /** 人脸 anchor
150
+ * @supported weapp
151
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFaceAnchor.html
152
+ */
153
+ interface VKFaceAnchor {
154
+ /** 唯一标识 */
155
+ id: number
156
+ /** 类型 */
157
+ type: keyof VKFaceAnchor.IType
158
+ /** 识别序号 */
159
+ detectId: number
160
+ /** 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */
161
+ origin: VKFaceAnchor.IOrigin
162
+ /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */
163
+ size: VKFaceAnchor.ISize
164
+ /** 人脸 106 个关键点的坐标 */
165
+ points: VKFaceAnchor.IPoint[]
166
+ /** 人脸角度信息 */
167
+ angle: number[]
168
+ /** 关键点的置信度 */
169
+ confidence: number
170
+ }
171
+ namespace VKFaceAnchor {
172
+ /** 类型 */
173
+ interface IType {
174
+ /** 人脸 */
175
+ 3
176
+ }
177
+ /** 相对视窗的尺寸*/
178
+ interface ISize {
179
+ /** 宽度 */
180
+ width: number
181
+ /** 高度 */
182
+ height: number
183
+ }
184
+ /** 相对视窗的位置信息 */
185
+ interface IOrigin {
186
+ /** 横坐标 */
187
+ x: number
188
+ /** 纵坐标 */
189
+ y: number
190
+ }
191
+ /** 关键点 */
192
+ interface IPoint {
193
+ /** 横坐标 */
194
+ x: number
195
+ /** 纵坐标 */
196
+ y: number
197
+ }
198
+ }
199
+
200
+ /** 手势 anchor
201
+ * @supported weapp
202
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKHandAnchor.html
203
+ */
204
+ interface VKHandAnchor {
205
+ /** 唯一标识 */
206
+ id: number
207
+ /** 类型 */
208
+ type: keyof VKHandAnchor.IType
209
+ /** 识别序号 */
210
+ detectId: number
211
+ /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */
212
+ size: VKHandAnchor.ISize
213
+ /** 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */
214
+ origin: VKHandAnchor.IOrigin
215
+ /** 关键点的置信度 */
216
+ confidence: number[]
217
+ /** 关键点 */
218
+ points: VKHandAnchor.IPoint[]
219
+ /** 总体置信值 */
220
+ score: number
221
+ /** 手势分类, 返回整数 -1 到 18, -1 表示无效手势 */
222
+ gesture: keyof VKHandAnchor.IGesture | -1
223
+ }
224
+ namespace VKHandAnchor {
225
+ /** 类型 */
226
+ interface IType {
227
+ /** 手势 */
228
+ 7
229
+ }
230
+ /** 相对视窗的尺寸*/
231
+ interface ISize {
232
+ /** 宽度 */
233
+ width: number
234
+ /** 高度 */
235
+ height: number
236
+ }
237
+ /** 相对视窗的位置信息 */
238
+ interface IOrigin {
239
+ /** 横坐标 */
240
+ x: number
241
+ /** 纵坐标 */
242
+ y: number
243
+ }
244
+ /** 关键点 */
245
+ interface IPoint {
246
+ /** 横坐标 */
247
+ x: number
248
+ /** 纵坐标 */
249
+ y: number
250
+ }
251
+ /** 手势分类 */
252
+ interface IGesture {
253
+ /**单手比心 */
254
+ 0
255
+ /** 布(数字5)*/
256
+ 1
257
+ /** 剪刀(数字2) */
258
+ 2
259
+ /** 握拳 */
260
+ 3
261
+ /** 数字1 */
262
+ 4
263
+ /** 热爱 */
264
+ 5
265
+ /** 点赞 */
266
+ 6
267
+ /** 数字3 */
268
+ 7
269
+ /** 摇滚 */
270
+ 8
271
+ /** 数字6 */
272
+ 9
273
+ /** 数字8 */
274
+ 10
275
+ /** 双手抱拳(恭喜发财) */
276
+ 11
277
+ /** 数字4 */
278
+ 12
279
+ /** 比ok */
280
+ 13
281
+ /** 不喜欢(踩) */
282
+ 14
283
+ /** 双手比心 */
284
+ 15
285
+ /** 祈祷(双手合十) */
286
+ 16
287
+ /** 双手抱拳 */
288
+ 17
289
+ /** 无手势动作 */
290
+ 18
291
+ }
292
+ }
293
+
294
+ /** marker anchor
295
+ * @supported weapp
296
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKMarkerAnchor.html
297
+ */
298
+ interface VKMarkerAnchor {
299
+ /** 唯一标识 */
300
+ id: number
301
+ /** 类型 */
302
+ type: keyof VKMarkerAnchor.IType
303
+ /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */
304
+ transform: Float32Array
305
+ /** marker id */
306
+ markerId: number
307
+ /** 图片路径 */
308
+ path: string
309
+ }
310
+ namespace VKMarkerAnchor {
311
+ /** 类型 */
312
+ interface IType {
313
+ /** marker */
314
+ 1
315
+ }
316
+ }
317
+
318
+ /** OCR anchor
319
+ * @supported weapp
320
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKOCRAnchor.html
321
+ */
322
+ interface VKOCRAnchor {
323
+ /** 唯一标识 */
324
+ id: number
325
+ /** 类型 */
326
+ type: keyof VKOCRAnchor.IType
327
+ /** 识别的文字结果 */
328
+ text: string
329
+ }
330
+ namespace VKOCRAnchor {
331
+ /** 类型 */
332
+ interface IType {
333
+ /** OCR */
334
+ 6
335
+ }
336
+ }
337
+
338
+ /** OSD anchor
339
+ * @supported weapp
340
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKOSDAnchor.html
341
+ */
342
+ interface VKOSDAnchor {
343
+ /** 唯一标识 */
344
+ id: number
345
+ /** 类型 */
346
+ type: keyof VKOSDAnchor.IType
347
+ /** marker id */
348
+ markerId: number
349
+ /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘*/
350
+ size: VKOSDAnchor.ISize
351
+ /** 图片路径 */
352
+ path: string
353
+ /** 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */
354
+ origin: VKOSDAnchor.IOrigin
355
+ }
356
+ namespace VKOSDAnchor {
357
+ /** 类型 */
358
+ interface IType {
359
+ /** OSD */
360
+ 2
361
+ }
362
+ /** 相对视窗的尺寸*/
363
+ interface ISize {
364
+ /** 宽度 */
365
+ width: number
366
+ /** 高度 */
367
+ height: number
368
+ }
369
+ /** 相对视窗的位置信息 */
370
+ interface IOrigin {
371
+ /** 横坐标 */
372
+ x: number
373
+ /** 纵坐标 */
374
+ y: number
375
+ }
376
+ }
377
+
378
+ /** 平面 anchor,只有 v2 版本支持
379
+ * @supported weapp
380
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKPlaneAnchor.html
381
+ */
382
+ interface VKPlaneAnchor {
383
+ /** 唯一标识 */
384
+ id: number
385
+ /** 类型 */
386
+ type: keyof VKPlaneAnchor.IType
387
+ /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */
388
+ transform: Float32Array
389
+ /** 尺寸 */
390
+ size: VKPlaneAnchor.ISize
391
+ /** 方向 */
392
+ alignment: number
393
+ }
394
+
395
+ namespace VKPlaneAnchor {
396
+ /** 类型 */
397
+ interface IType {
398
+ /** 平面 */
399
+ 0
400
+ }
401
+ /** 相对视窗的尺寸*/
402
+ interface ISize {
403
+ /** 宽度 */
404
+ width: number
405
+ /** 高度 */
406
+ height: number
407
+ }
408
+ }
409
+
94
410
  /** vision kit 会话对象
95
411
  * @supported weapp
96
412
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.html
@@ -104,7 +420,14 @@ declare module '../../index' {
104
420
  * @supported weapp
105
421
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getCameraTexture.html
106
422
  */
107
- getCameraTexture(ctx: WebGLRenderingContext): VKFrame.getCameraTextureResult
423
+ getCameraTexture(ctx: WebGLRenderingContext): VKFrame.IGetCameraTextureResult
424
+ /** 获取当前帧 rgba buffer。iOS 端微信在 v8.0.20 开始支持,安卓端微信在 v8.0.30 开始支持。
425
+ * 按 aspect-fill 规则裁剪,此接口要求在创建 VKSession 对象时必须传入 gl 参数。
426
+ * 此接口仅建议拿来做帧分析使用,上屏请使用 getCameraTexture 来代替。
427
+ * @supported weapp
428
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getCameraBuffer.html
429
+ */
430
+ getCameraBuffer(widht: number, height: number): ArrayBuffer
108
431
  /** 获取纹理调整矩阵。默认获取到的纹理是未经裁剪调整的纹理,此矩阵可用于在着色器中根据帧对象尺寸对纹理进行裁剪
109
432
  * @supported weapp
110
433
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getDisplayTransform.html
@@ -114,7 +437,7 @@ declare module '../../index' {
114
437
 
115
438
  namespace VKFrame {
116
439
  /** 帧纹理对象 */
117
- interface getCameraTextureResult {
440
+ interface IGetCameraTextureResult {
118
441
  /** Y 分量纹理 */
119
442
  yTexture: WebGLTexture
120
443
  /** UV 分量纹理 */
@@ -128,11 +451,27 @@ declare module '../../index' {
128
451
  */
129
452
  interface VKSession {
130
453
  /** 会话状态 */
131
- state: keyof VKSession.State
454
+ state: keyof VKSession.IState
132
455
  /** 会话配置 */
133
- config: VKSession.Config
456
+ config: VKSession.IConfig
134
457
  /** 相机尺寸 */
135
- cameraSize: VKSession.Size
458
+ cameraSize: VKSession.ISize
459
+ /** 添加一个 marker,要求调 Taro.createVKSession 时传入的 track.marker 为 true
460
+ * @supported weapp
461
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.addMarker.html
462
+ */
463
+ addMarker(
464
+ /** 图片路径,目前只支持本地用户图片 */
465
+ path: string
466
+ ): number
467
+ /** 添加一个 OSD marker(one-shot detection marker),要求调 Taro.createVKSession 时传入的 track.OSD 为 true
468
+ * @supported weapp
469
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.addOSDMarker.html
470
+ */
471
+ addOSDMarker(
472
+ /** 图片路径,目前只支持本地用户图片 */
473
+ path: string
474
+ ): number
136
475
  /** 取消由 requestAnimationFrame 添加到计划中的动画帧请求
137
476
  * @supported weapp
138
477
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.cancelAnimationFrame.html
@@ -143,6 +482,36 @@ declare module '../../index' {
143
482
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.destroy.html
144
483
  */
145
484
  destroy(): void
485
+ /** 静态图像人体关键点检测。当 Taro.createVKSession 参数传入 {track: {body: {mode: 2} } } 时可用。
486
+ * @supported weapp
487
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectBody.html
488
+ */
489
+ detectBody(option: VKSession.IDetectBodyOption): void
490
+ /** 深度识别。当 Taro.createVKSession 参数传入 {track: {depth: {mode: 2} } } 时可用。
491
+ * @supported weapp
492
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectDepth.html
493
+ */
494
+ detectDepth(option: VKSession.IDetectDepthOption): void
495
+ /** 静态图像人脸关键点检测。当 Taro.createVKSession 参数传入 {track: {face: {mode: 2} } } 时可用。安卓微信8.0.25开始支持,iOS微信8.0.24开始支持。
496
+ * @supported weapp
497
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectFace.html
498
+ */
499
+ detectFace(option: VKSession.IDetectFaceOption): void
500
+ /** 静态图像手势关键点检测。当 Taro.createVKSession 参数传入 {track: {hand: {mode: 2} } } 时可用。
501
+ * @supported weapp
502
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectHand.html
503
+ */
504
+ detectHand(option: VKSession.IDetectHandOption): void
505
+ /** 获取所有 marker,要求调 Taro.createVKSession 时传入的 track.marker 为 true
506
+ * @supported weapp
507
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.getAllMarker.html
508
+ */
509
+ getAllMarker(): VKSession.IMarker[]
510
+ /** 获取所有 OSD marker,要求调 Taro.createVKSession 时传入的 track.OSD 为 true
511
+ * @supported weapp
512
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.getAllOSDMarker.html
513
+ */
514
+ getAllOSDMarker(): VKSession.IOSDMarker[]
146
515
  /** 获取帧对象,每调用一次都会触发一次帧分析过程
147
516
  * @supported weapp
148
517
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.getVKFrame.html
@@ -166,7 +535,7 @@ declare module '../../index' {
166
535
  y: number,
167
536
  /** 是否需要重新识别其他平面,v2 版本不再需要此参数 */
168
537
  reset?: boolean
169
- ): VKSession.hitTestResult[]
538
+ ): VKSession.IHitTestResult[]
170
539
  /** 取消监听会话事件。
171
540
  * @supported weapp
172
541
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.off.html
@@ -175,7 +544,7 @@ declare module '../../index' {
175
544
  /** 事件名称 */
176
545
  eventName: string,
177
546
  /** 事件监听函数 */
178
- fn: Function
547
+ fn: TaroGeneral.EventCallback
179
548
  ): void
180
549
  /** 监听会话事件。
181
550
  * @supported weapp
@@ -183,68 +552,125 @@ declare module '../../index' {
183
552
  */
184
553
  on(
185
554
  /** 事件名称 */
186
- eventName: string,
555
+ eventName: 'resize' | 'addAnchors' | 'updateAnchors' | 'removeAnchors' | string,
187
556
  /** 事件监听函数 */
188
- fn: Function
557
+ fn: TaroGeneral.EventCallback
189
558
  ): void
559
+ /** 删除一个 marker,要求调 Taro.createVKSession 时传入的 track.marker 为 true
560
+ * @supported weapp
561
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.removeMarker.html
562
+ */
563
+ removeMarker(
564
+ /** marker id */
565
+ markerId: number
566
+ ): number
567
+ /** 删除一个 OSD marker,要求调 Taro.createVKSession 时传入的 track.OSD 为 true
568
+ * @supported weapp
569
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.removeOSDMarker.html
570
+ */
571
+ removeOSDMarker(
572
+ /** marker id */
573
+ markerId: number
574
+ ): number
190
575
  /** 在下次进行重绘时执行。
191
576
  * @supported weapp
192
577
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.requestAnimationFrame.html
193
578
  */
194
579
  requestAnimationFrame(
195
- /** 执行函数 */
196
- callback: Function
580
+ /** 执行函数 */
581
+ callback: TaroGeneral.TFunc
197
582
  ): number
583
+ /** 静态图像 OCR 检测。当 Taro.createVKSession 参数传入 {track: {OCR: {mode: 2} } } 时可用。
584
+ * @supported weapp
585
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.runOCR.html
586
+ */
587
+ runOCR(option: VKSession.IRunOCROption): void
198
588
  /** 开启会话。
199
589
  * @supported weapp
200
590
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.start.html
201
591
  */
202
592
  start(
203
- /** 开启会话回调 */
204
- callback: (status: keyof VKSession.StartStatus) => void
593
+ /** 开启会话回调 */
594
+ callback: (status: keyof VKSession.IStartStatus) => void
205
595
  ): void
206
596
  /** 停止会话。
207
597
  * @supported weapp
208
598
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.stop.html
209
599
  */
210
- stop(): void
600
+ stop(): void
601
+ /** 开启 3D 模式
602
+ * @supported weapp
603
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.update3DMode.html
604
+ */
605
+ update3DMode(
606
+ /** 是否开启 */
607
+ open3d: boolean
608
+ ): void
609
+ /** 更新 OSD 识别精确度,要求调 Taro.createVKSession 时传入的 track.OSD 为 true
610
+ * @supported weapp
611
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.updateOSDThreshold.html
612
+ */
613
+ updateOSDThreshold(
614
+ /** 阈值 */
615
+ threshold: number
616
+ ): void
211
617
  }
212
618
  namespace VKSession {
213
619
  /** state 的合法值 */
214
- interface State {
620
+ interface IState {
215
621
  /** 不可用 */
216
622
  0
217
623
  /** 运行中 */
218
624
  1
219
625
  /** 暂停中 */
220
626
  2
627
+ /** 初始化中 */
628
+ 3
221
629
  }
222
630
  /** 会话配置 */
223
- interface Config {
631
+ interface IConfig {
224
632
  /** 不可用 */
225
- version: keyof version
633
+ version: keyof IVersion
226
634
  /** 运行中 */
227
- track: track
635
+ track: ITrack
636
+ /** marker 跟踪配置,基础库(3.0.0)开始允许同时支持v2的水平面检测能力 */
637
+ marker: boolean
638
+ /** OSD 跟踪配置 */
639
+ OSD: boolean
640
+ /** 深度识别配置 */
641
+ depth: IDepth
642
+ /** 人脸检测配置。安卓微信8.0.25开始支持,iOS微信8.0.24开始支持。 */
643
+ face: IFace
644
+ /** OCR 检测配置。 */
645
+ OCR: IOCR
646
+ /** 人体检测配置。 */
647
+ body: IBody
648
+ /** 手势检测配置。 */
649
+ hand: IHand
650
+ /** 提供基础AR功能,输出相机旋转的3个自由度的位姿,利用手机陀螺仪传感器,实现快速稳定的AR定位能力,适用于简单AR场景。 */
651
+ threeDof: boolean
652
+ /** 绑定的 WebGLRenderingContext 对象 */
653
+ gl: WebGLRenderingContext
228
654
  }
229
655
  /** vision kit 版本 */
230
- interface version {
656
+ interface IVersion {
231
657
  /** 旧版本 */
232
658
  v1
233
659
  /** v2 版本,目前只有 iOS 基础库 2.22.0 以上支持 */
234
660
  v2
235
661
  }
236
662
  /** 跟踪配置 */
237
- interface track {
663
+ interface ITrack {
238
664
  /** 平面跟踪配置 */
239
- plane: plane
665
+ plane: IPlane
240
666
  }
241
667
  /** 平面跟踪配置 */
242
- interface plane {
668
+ interface IPlane {
243
669
  /** 平面跟踪配置模式 */
244
- mode: keyof PlaneMode
670
+ mode: keyof IPlaneMode
245
671
  }
246
672
  /** 平面跟踪配置模式合法值 */
247
- interface PlaneMode {
673
+ interface IPlaneMode {
248
674
  /** 检测横向平面 */
249
675
  1
250
676
  /** 检测纵向平面,只有 v2 版本支持 */
@@ -252,22 +678,167 @@ declare module '../../index' {
252
678
  /** 检测横向和纵向平面,只有 v2 版本支持 */
253
679
  3
254
680
  }
681
+ /** 深度识别配置 */
682
+ interface IDepth {
683
+ mode: keyof IDepthMode
684
+ }
685
+ /** 深度识别模式 */
686
+ interface IDepthMode {
687
+ /** 通过摄像头实时检测 */
688
+ 1
689
+ /** 静态图片检测 */
690
+ 2
691
+ }
692
+ /** 人脸检测模式 */
693
+ interface IFace {
694
+ mode: keyof IFaceMode
695
+ }
696
+ /** 人脸检测模式 */
697
+ interface IFaceMode {
698
+ /** 通过摄像头实时检测 */
699
+ 1
700
+ /** 静态图片检测 */
701
+ 2
702
+ }
703
+ /** OCR 检测配置 */
704
+ interface IOCR {
705
+ mode: keyof IOCRMode
706
+ }
707
+ /** OCR 检测模式 */
708
+ interface IOCRMode {
709
+ /** 通过摄像头实时检测 */
710
+ 1
711
+ /** 静态图片检测 */
712
+ 2
713
+ }
714
+ /** 人体检测模式 */
715
+ interface IBody {
716
+ mode: keyof IBodyMode
717
+ }
718
+ /** 人体检测模式 */
719
+ interface IBodyMode {
720
+ /** 通过摄像头实时检测 */
721
+ 1
722
+ /** 静态图片检测 */
723
+ 2
724
+ }
725
+ /** 手势检测配置 */
726
+ interface IHand {
727
+ mode: keyof IHandMode
728
+ }
729
+ /** 手势检测模式 */
730
+ interface IHandMode {
731
+ /** 通过摄像头实时检测 */
732
+ 1
733
+ /** 静态图片检测 */
734
+ 2
735
+ }
255
736
  /** 相机尺寸 */
256
- interface Size {
737
+ interface ISize {
257
738
  /** 宽度 */
258
739
  width: number
259
740
  /** 高度 */
260
741
  height: number
261
742
  }
262
-
743
+ interface IDetectBodyOption {
744
+ /** 人脸图像像素点数据,每四项表示一个像素点的 RGBA */
745
+ frameBuffer: ArrayBuffer
746
+ /** 图像宽度 */
747
+ width: number
748
+ /** 图像高度 */
749
+ height: number
750
+ /** 评分阈值。正常情况传入 0.8 即可。默认值 0.8 */
751
+ scoreThreshold?: number
752
+ /** 图像源类型。正常情况传入 1 即可。当输入的图片是来自一个连续视频的每一帧图像时,sourceType 传入 0 会得到更优的效果。默认值1 */
753
+ sourceType?: keyof ISourceType
754
+ }
755
+ /** 图像源类型。 */
756
+ interface ISourceType {
757
+ /** 表示输入的图片是随机的图片 */
758
+ 1
759
+ /** 表示输入的图片是来自一个连续视频的每一帧图像 */
760
+ 0
761
+ }
762
+ interface IDetectDepthOption {
763
+ /** 人需要识别深度的图像像素点数据,每四项表示一个像素点的 RGBA */
764
+ frameBuffer: ArrayBuffer
765
+ /** 图像宽度 */
766
+ width: number
767
+ /** 图像高度 */
768
+ height: number
769
+ }
770
+ interface IDetectFaceOption {
771
+ /** 人脸图像像素点数据,每四项表示一个像素点的 RGBA */
772
+ frameBuffer: ArrayBuffer
773
+ /** 图像宽度 */
774
+ width: number
775
+ /** 图像高度 */
776
+ height: number
777
+ /** 评分阈值。正常情况传入 0.8 即可。默认值 0.8 */
778
+ scoreThreshold?: number
779
+ /** 图像源类型。正常情况传入 1 即可。当输入的图片是来自一个连续视频的每一帧图像时,sourceType 传入 0 会得到更优的效果。默认值1 */
780
+ sourceType?: keyof ISourceType
781
+ /** 算法模型类型。正常情况传入 1 即可。0、1、2 分别表示小、中、大模型,模型越大识别准确率越高,但资源占用也越高。建议根据用户设备性能进行选择。 */
782
+ modelModel?: keyof IModelModel
783
+ }
784
+ /** 算法模型类型 */
785
+ interface IModelModel {
786
+ /** 小模型 */
787
+ 0
788
+ /** 中模型 */
789
+ 1
790
+ /** 大模型 */
791
+ 2
792
+ }
793
+ interface IDetectHandOption {
794
+ /** 人脸图像像素点数据,每四项表示一个像素点的 RGBA */
795
+ frameBuffer: ArrayBuffer
796
+ /** 图像宽度 */
797
+ width: number
798
+ /** 图像高度 */
799
+ height: number
800
+ /** 评分阈值。正常情况传入 0.8 即可。默认值0.8 */
801
+ scoreThreshold?: number
802
+ /** 算法检测模式 */
803
+ algoMode?: keyof IAlgoMode
804
+ }
805
+ /** 算法检测模式 */
806
+ interface IAlgoMode {
807
+ /** 检测模式,输出框和点 */
808
+ 0
809
+ /** 手势模式,输出框和手势分类 */
810
+ 1
811
+ /** 结合0和1模式,输出框、点、手势分类 */
812
+ 2
813
+ }
814
+ interface IMarker {
815
+ /** marker id */
816
+ markerId: number
817
+ /** 图片路径 */
818
+ path: string
819
+ }
820
+ /** OSD marker */
821
+ interface IOSDMarker {
822
+ /** marker id */
823
+ markerId: number
824
+ /** 图片路径 */
825
+ path: string
826
+ }
827
+ interface IRunOCROption {
828
+ /** 待识别图像的像素点数据,每四项表示一个像素点的 RGBA */
829
+ frameBuffer: ArrayBuffer
830
+ /** 图像宽度 */
831
+ width: number
832
+ /** 图像高度 */
833
+ height: number
834
+ }
263
835
  /** hitTest 检测结果 */
264
- interface hitTestResult {
836
+ interface IHitTestResult {
265
837
  /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */
266
838
  transform: Float32Array
267
839
  }
268
-
269
840
  /** start status 的合法值 */
270
- interface StartStatus {
841
+ interface IStartStatus {
271
842
  /** 成功 */
272
843
  0
273
844
  /** 系统错误 */
@@ -292,12 +863,12 @@ declare module '../../index' {
292
863
  * @supported weapp
293
864
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.isVKSupport.html
294
865
  */
295
- isVKSupport (version: keyof isVKSupport.Version): boolean /** 是否支持对应版本的 vision kit */
866
+ isVKSupport (version: keyof isVKSupport.IVersion): boolean /** 是否支持对应版本的 vision kit */
296
867
 
297
868
  /** 创建 vision kit 会话对象
298
869
  * @supported weapp
299
870
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html
300
871
  */
301
- createVKSession (version: keyof createVKSession.Version): VKSession /** vision kit 会话对象 */
872
+ createVKSession (version: keyof createVKSession.IVersion): VKSession /** vision kit 会话对象 */
302
873
  }
303
874
  }