@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.
Files changed (109) hide show
  1. package/html.css +50 -14
  2. package/html5.css +167 -64
  3. package/index.js +3 -4
  4. package/package.json +21 -11
  5. package/types/api/ad/index.d.ts +2 -2
  6. package/types/api/ai/face.d.ts +133 -0
  7. package/types/api/ai/visionkit.d.ts +303 -0
  8. package/types/api/base/crypto.d.ts +90 -0
  9. package/types/api/base/debug.d.ts +152 -13
  10. package/types/api/base/env.d.ts +2 -1
  11. package/types/api/base/index.d.ts +11 -3
  12. package/types/api/base/performance.d.ts +195 -0
  13. package/types/api/base/system.d.ts +541 -103
  14. package/types/api/base/update.d.ts +60 -8
  15. package/types/api/base/weapp/app-event.d.ts +99 -37
  16. package/types/api/base/weapp/life-cycle.d.ts +142 -2
  17. package/types/api/canvas/index.d.ts +151 -137
  18. package/types/api/cloud/index.d.ts +17 -2
  19. package/types/api/data-analysis/index.d.ts +1 -1
  20. package/types/api/device/accelerometer.d.ts +6 -6
  21. package/types/api/device/accessibility.d.ts +26 -0
  22. package/types/api/device/battery.d.ts +2 -2
  23. package/types/api/device/{ble.d.ts → bluetooth-ble.d.ts} +228 -62
  24. package/types/api/device/bluetooth-peripheral.d.ts +430 -0
  25. package/types/api/device/bluetooth.d.ts +67 -2
  26. package/types/api/device/calendar.d.ts +88 -0
  27. package/types/api/device/clipboard.d.ts +2 -2
  28. package/types/api/device/compass.d.ts +3 -3
  29. package/types/api/device/contact.d.ts +74 -50
  30. package/types/api/device/gyroscope.d.ts +6 -6
  31. package/types/api/device/iBeacon.d.ts +33 -19
  32. package/types/api/{ui → device}/keyboard.d.ts +1 -1
  33. package/types/api/device/{performance.d.ts → memory.d.ts} +5 -5
  34. package/types/api/device/motion.d.ts +3 -3
  35. package/types/api/device/network.d.ts +56 -15
  36. package/types/api/device/nfc.d.ts +1089 -13
  37. package/types/api/device/phone.d.ts +1 -1
  38. package/types/api/device/scan.d.ts +1 -1
  39. package/types/api/device/screen.d.ts +42 -14
  40. package/types/api/device/vibrate.d.ts +6 -2
  41. package/types/api/device/wifi.d.ts +44 -9
  42. package/types/api/ext/index.d.ts +2 -2
  43. package/types/api/files/index.d.ts +392 -205
  44. package/types/api/framework/index.d.ts +5 -4
  45. package/types/api/location/index.d.ts +156 -53
  46. package/types/api/media/audio.d.ts +629 -38
  47. package/types/api/media/background-audio.d.ts +9 -9
  48. package/types/api/media/camera.d.ts +41 -22
  49. package/types/api/media/editor.d.ts +22 -2
  50. package/types/api/media/image.d.ts +64 -35
  51. package/types/api/media/live.d.ts +66 -6
  52. package/types/api/media/map.d.ts +474 -54
  53. package/types/api/media/media-recorder.d.ts +92 -0
  54. package/types/api/media/recorder.d.ts +21 -21
  55. package/types/api/media/video-decoder.d.ts +117 -0
  56. package/types/api/media/video-processing.d.ts +11 -7
  57. package/types/api/media/video.d.ts +47 -18
  58. package/types/api/media/voip.d.ts +290 -0
  59. package/types/api/{open-api/navigate.d.ts → navigate/index.d.ts} +65 -27
  60. package/types/api/network/download.d.ts +61 -19
  61. package/types/api/network/request.d.ts +129 -41
  62. package/types/api/network/tcp.d.ts +181 -0
  63. package/types/api/network/udp.d.ts +154 -83
  64. package/types/api/network/upload.d.ts +55 -28
  65. package/types/api/network/websocket.d.ts +20 -19
  66. package/types/api/open-api/address.d.ts +1 -1
  67. package/types/api/open-api/authorize.d.ts +42 -3
  68. package/types/api/open-api/channels.d.ts +178 -0
  69. package/types/api/open-api/facial.d.ts +3 -0
  70. package/types/api/open-api/favorites.d.ts +100 -0
  71. package/types/api/open-api/group.d.ts +59 -0
  72. package/types/api/open-api/invoice.d.ts +2 -2
  73. package/types/api/open-api/license-plate.d.ts +27 -0
  74. package/types/api/open-api/login.d.ts +21 -0
  75. package/types/api/open-api/redpackage.d.ts +24 -0
  76. package/types/api/open-api/settings.d.ts +82 -17
  77. package/types/api/open-api/soter.d.ts +2 -2
  78. package/types/api/open-api/subscribe-message.d.ts +89 -4
  79. package/types/api/open-api/user-info.d.ts +56 -19
  80. package/types/api/open-api/werun.d.ts +33 -6
  81. package/types/api/payment/index.d.ts +119 -0
  82. package/types/api/route/index.d.ts +18 -14
  83. package/types/api/share/index.d.ts +192 -9
  84. package/types/api/storage/index.d.ts +38 -92
  85. package/types/api/swan/index.d.ts +1 -1
  86. package/types/api/ui/animation.d.ts +105 -155
  87. package/types/api/ui/background.d.ts +4 -2
  88. package/types/api/ui/custom-component.d.ts +1 -1
  89. package/types/api/ui/fonts.d.ts +27 -31
  90. package/types/api/ui/interaction.d.ts +6 -6
  91. package/types/api/ui/menu.d.ts +1 -1
  92. package/types/api/ui/navigation-bar.d.ts +6 -5
  93. package/types/api/ui/pull-down-refresh.d.ts +2 -2
  94. package/types/api/ui/scroll.d.ts +75 -7
  95. package/types/api/ui/sticky.d.ts +4 -4
  96. package/types/api/ui/tab-bar.d.ts +8 -8
  97. package/types/api/ui/window.d.ts +22 -2
  98. package/types/api/worker/index.d.ts +9 -1
  99. package/types/api/wxml/index.d.ts +116 -112
  100. package/types/compile.d.ts +57 -6
  101. package/types/global.d.ts +142 -111
  102. package/types/taro.api.d.ts +79 -62
  103. package/types/taro.component.d.ts +21 -65
  104. package/types/taro.config.d.ts +31 -0
  105. package/types/taro.extend.d.ts +31 -18
  106. package/types/taro.hooks.d.ts +55 -3
  107. package/types/taro.lifecycle.d.ts +21 -14
  108. package/LICENSE +0 -21
  109. package/types/api/open-api/payment.d.ts +0 -61
@@ -25,7 +25,7 @@ declare module '../../index' {
25
25
 
26
26
  interface TaroStatic {
27
27
  /** 停止当前页面下拉刷新。
28
- * @supported weapp, h5, rn
28
+ * @supported weapp, h5, rn, tt
29
29
  * @example
30
30
  * ```tsx
31
31
  * onPullDownRefresh: function (){
@@ -37,7 +37,7 @@ declare module '../../index' {
37
37
  stopPullDownRefresh(option?: stopPullDownRefresh.Option): void
38
38
 
39
39
  /** 开始下拉刷新。调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
40
- * @supported weapp, h5, rn
40
+ * @supported weapp, h5, rn, tt
41
41
  * @rn 无动画效果
42
42
  * @example
43
43
  * ```tsx
@@ -13,24 +13,92 @@ declare module '../../index' {
13
13
  scrollTop?: number
14
14
  /** 选择器, css selector */
15
15
  selector?: string
16
+ /** 偏移距离,需要和 selector 参数搭配使用,可以滚动到 selector 加偏移距离的位置,单位 px */
17
+ offsetTop?: number
16
18
  /** 接口调用成功的回调函数 */
17
19
  success?: (res: TaroGeneral.CallbackResult) => void
18
20
  }
19
21
  }
20
22
 
23
+ /** 增强 ScrollView 实例,可通过 [Taro.createSelectorQuery](/docs/apis/wxml/createSelectorQuery) 的 [NodesRef.node](/docs/apis/wxml/NodesRef#node) 方法获取。 仅在 `scroll-view` 组件开启 `enhanced` 属性后生效。
24
+ * @supported weapp
25
+ * @example
26
+ * ```tsx
27
+ * Taro.createSelectorQuery()
28
+ * .select('#scrollview')
29
+ * .node()
30
+ * .exec((res) => {
31
+ * const scrollView = res[0].node;
32
+ * scrollView.scrollEnabled = false;
33
+ * })
34
+ * ```
35
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/scroll/ScrollViewContext.html
36
+ */
37
+ interface ScrollViewContext {
38
+ /** 滚动开关 */
39
+ scrollEnabled: boolean
40
+
41
+ /** 设置滚动边界弹性 (仅在 iOS 下生效) */
42
+ bounces: boolean
43
+
44
+ /** 设置是否显示滚动条 */
45
+ showScrollbar: boolean
46
+
47
+ /** 分页滑动开关 */
48
+ pagingEnabled: boolean
49
+
50
+ /** 设置滚动减速速率 */
51
+ fastDeceleration: boolean
52
+
53
+ /** 取消滚动惯性 (仅在 iOS 下生效) */
54
+ decelerationDisabled: boolean
55
+
56
+ /** 滚动至指定位置
57
+ * @supported weapp
58
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/scroll/ScrollViewContext.scrollTo.html
59
+ */
60
+ scrollTo(object: ScrollViewContext.scrollTo.Option): void
61
+
62
+ /** 滚动至指定位置
63
+ * @supported weapp, tt
64
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/scroll/ScrollViewContext.scrollIntoView.html
65
+ */
66
+ scrollIntoView(
67
+ /** 元素选择器 */
68
+ selector: string
69
+ ): void
70
+ }
71
+
72
+ namespace ScrollViewContext {
73
+ namespace scrollTo {
74
+ interface Option {
75
+ /** 顶部距离 */
76
+ top?: number
77
+ /** 左边界距离 */
78
+ left?: number
79
+ /** 初始速度 */
80
+ velocity?: number
81
+ /** 滚动动画时长 */
82
+ duration?: number
83
+ /** 是否启用滚动动画 */
84
+ animated?: boolean
85
+ }
86
+ }
87
+ }
88
+
21
89
  interface TaroStatic {
22
90
  /** 将页面滚动到目标位置,支持选择器和滚动距离两种方式定位
23
91
  *
24
92
  * **selector 语法**
25
93
  * selector类似于 CSS 的选择器,但仅支持下列语法。
26
94
  *
27
- * + ID选择器:#the-id
28
- * + class选择器(可以连续指定多个):.a-class.another-class
29
- * + 子元素选择器:.the-parent > .the-child
30
- * + 后代选择器:.the-ancestor .the-descendant
31
- * + 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
32
- * + 多选择器的并集:#a-node, .some-other-nodes
33
- * @supported weapp, h5
95
+ * - ID选择器:#the-id
96
+ * - class选择器(可以连续指定多个):.a-class.another-class
97
+ * - 子元素选择器:.the-parent > .the-child
98
+ * - 后代选择器:.the-ancestor .the-descendant
99
+ * - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
100
+ * - 多选择器的并集:#a-node, .some-other-nodes
101
+ * @supported weapp, h5, rn, tt
34
102
  * @example
35
103
  * ```tsx
36
104
  * Taro.pageScrollTo({
@@ -5,12 +5,12 @@ declare module '../../index' {
5
5
  interface Option {
6
6
  /** 置顶栏文字 */
7
7
  text: string
8
- /** 接口调用结束的回调函数(调用成功、失败都会执行) */
9
- complete?: (res: TaroGeneral.CallbackResult) => void
10
- /** 接口调用失败的回调函数 */
11
- fail?: (res: TaroGeneral.CallbackResult) => void
12
8
  /** 接口调用成功的回调函数 */
13
9
  success?: (res: TaroGeneral.CallbackResult) => void
10
+ /** 接口调用失败的回调函数 */
11
+ fail?: (res: TaroGeneral.CallbackResult) => void
12
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
13
+ complete?: (res: TaroGeneral.CallbackResult) => void
14
14
  }
15
15
  }
16
16
  interface TaroStatic {
@@ -121,19 +121,19 @@ declare module '../../index' {
121
121
 
122
122
  interface TaroStatic {
123
123
  /** 显示 tabBar 某一项的右上角的红点
124
- * @supported weapp, h5
124
+ * @supported weapp, h5, rn, tt
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
130
+ * @supported weapp, h5, rn, tt
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>
134
134
 
135
135
  /** 动态设置 tabBar 的整体样式
136
- * @supported weapp, h5
136
+ * @supported weapp, h5, rn, tt
137
137
  * @example
138
138
  * ```tsx
139
139
  * Taro.setTabBarStyle({
@@ -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
151
+ * @supported weapp, h5, rn, tt
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
166
+ * @supported weapp, h5, rn, tt
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
179
+ * @supported weapp, h5, rn, tt
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
185
+ * @supported weapp, h5, rn, tt
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
191
+ * @supported weapp, h5, rn, tt
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>
@@ -1,6 +1,20 @@
1
1
  import Taro from '../../index'
2
2
 
3
3
  declare module '../../index' {
4
+ namespace setWindowSize {
5
+ interface Option {
6
+ /** 窗口宽度,以像素为单位 */
7
+ width: string
8
+ /** 窗口高度,以像素为单位 */
9
+ height: string
10
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
11
+ complete?: (res: TaroGeneral.CallbackResult) => void
12
+ /** 接口调用失败的回调函数 */
13
+ fail?: (res: TaroGeneral.CallbackResult) => void
14
+ /** 接口调用成功的回调函数 */
15
+ success?: (res: TaroGeneral.CallbackResult) => void
16
+ }
17
+ }
4
18
  namespace onWindowResize {
5
19
  /** 窗口尺寸变化事件的回调函数 */
6
20
  type Callback = (result: CallbackResult) => void
@@ -23,8 +37,14 @@ declare module '../../index' {
23
37
  }
24
38
 
25
39
  interface TaroStatic {
40
+ /** 设置窗口大小,该接口仅适用于 PC 平台,使用细则请参见指南
41
+ * @supported weapp
42
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/window/wx.setWindowSize.html
43
+ */
44
+ setWindowSize(option: setWindowSize.Option): Promise<TaroGeneral.CallbackResult>
45
+
26
46
  /** 监听窗口尺寸变化事件
27
- * @supported weapp, h5
47
+ * @supported weapp, h5, rn
28
48
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/window/wx.onWindowResize.html
29
49
  */
30
50
  onWindowResize(
@@ -33,7 +53,7 @@ declare module '../../index' {
33
53
  ): void
34
54
 
35
55
  /** 取消监听窗口尺寸变化事件
36
- * @supported weapp, h5
56
+ * @supported weapp, h5, rn
37
57
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/window/wx.offWindowResize.html
38
58
  */
39
59
  offWindowResize(
@@ -19,6 +19,14 @@ declare module '../../index' {
19
19
  /** 主线程/Worker 线程向当前线程发送的消息的事件的回调函数 */
20
20
  callback: Worker.OnMessageCallback,
21
21
  ): void
22
+ /** 监听 worker 线程被系统回收事件(当 iOS 系统资源紧张时,worker 线程存在被系统回收的可能,开发者可监听此事件并重新创建一个 worker)
23
+ * @supported weapp
24
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.onProcessKilled.html
25
+ */
26
+ onProcessKilled(
27
+ /** worker 线程被系统回收事件的回调函数 */
28
+ callback: Worker.OnMessageCallback,
29
+ ): void
22
30
  /** 向主线程/Worker 线程发送的消息。
23
31
  * @supported weapp
24
32
  * @example
@@ -52,7 +60,7 @@ declare module '../../index' {
52
60
  }
53
61
 
54
62
  interface TaroStatic {
55
- /** 创建一个 Worker 线程。目前限制最多只能创建一个 Worker,创建下一个 Worker 前请先调用 [Worker.terminate](https://developers.weixin.qq.com/miniprogram/dev/api/worker/Worker.terminate.html)
63
+ /** 创建一个 Worker 线程。目前限制最多只能创建一个 Worker,创建下一个 Worker 前请先调用 [Worker.terminate](/docs/apis/worker/#terminate)
56
64
  * @supported weapp
57
65
  * @example
58
66
  * ```tsx
@@ -18,10 +18,12 @@ declare module '../../index' {
18
18
  */
19
19
  interface IntersectionObserver {
20
20
  /** 停止监听。回调函数将不再触发
21
+ * @supported weapp, tt
21
22
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.disconnect.html
22
23
  */
23
24
  disconnect(): void
24
25
  /** 指定目标节点并开始监听相交状态变化情况
26
+ * @supported weapp, tt
25
27
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.observe.html
26
28
  */
27
29
  observe(
@@ -31,6 +33,7 @@ declare module '../../index' {
31
33
  callback: IntersectionObserver.ObserveCallback,
32
34
  ): void
33
35
  /** 使用选择器指定一个节点,作为参照区域之一。
36
+ * @supported weapp, tt
34
37
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.relativeTo.html
35
38
  */
36
39
  relativeTo(
@@ -40,6 +43,7 @@ declare module '../../index' {
40
43
  margins?: IntersectionObserver.RelativeToMargins,
41
44
  ): IntersectionObserver
42
45
  /** 指定页面显示区域作为参照区域之一
46
+ * @supported weapp, tt
43
47
  * @example
44
48
  * 下面的示例代码中,如果目标节点(用选择器 .target-class 指定)进入显示区域以下 100px 时,就会触发回调函数。
45
49
  *
@@ -175,115 +179,12 @@ declare module '../../index' {
175
179
  }) => void
176
180
  }
177
181
 
178
- /** 查询节点信息的对象
179
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.html
180
- */
181
- interface SelectorQuery {
182
- /** 执行所有的请求。请求结果按请求次序构成数组,在callback的第一个参数中返回。
183
- * @supported weapp, h5
184
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.exec.html
185
- */
186
- exec(
187
- /** 回调函数 */
188
- callback?: (...args: any[]) => any,
189
- ): NodesRef
190
- /** 在当前页面下选择第一个匹配选择器 `selector` 的节点。返回一个 `NodesRef` 对象实例,可以用于获取节点信息。
191
- *
192
- * **selector 语法**
193
- *
194
- *
195
- * selector类似于 CSS 的选择器,但仅支持下列语法。
196
- *
197
- * - ID选择器:#the-id
198
- * - class选择器(可以连续指定多个):.a-class.another-class
199
- * - 子元素选择器:.the-parent > .the-child
200
- * - 后代选择器:.the-ancestor .the-descendant
201
- * - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
202
- * - 多选择器的并集:#a-node, .some-other-nodes
203
- * @supported weapp, h5
204
- * @example
205
- * ```tsx
206
- * Taro.createSelectorQuery().select('#the-id').fields({
207
- * dataset: true,
208
- * size: true,
209
- * scrollOffset: true,
210
- * properties: ['scrollX', 'scrollY']
211
- * }, function (res){
212
- * res.dataset // 节点的dataset
213
- * res.width // 节点的宽度
214
- * res.height // 节点的高度
215
- * res.scrollLeft // 节点的水平滚动位置
216
- * res.scrollTop // 节点的竖直滚动位置
217
- * res.scrollX // 节点 scroll-x 属性的当前值
218
- * res.scrollY // 节点 scroll-x 属性的当前值
219
- * }).exec()
220
- * ```
221
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.select.html
222
- */
223
- select(
224
- /** 选择器 */
225
- selector: string,
226
- ): NodesRef
227
- /** 在当前页面下选择匹配选择器 selector 的所有节点。
228
- *
229
- * **selector 语法**
230
- *
231
- * selector类似于 CSS 的选择器,但仅支持下列语法。
232
- *
233
- * - ID选择器:#the-id
234
- * - class选择器(可以连续指定多个):.a-class.another-class
235
- * - 子元素选择器:.the-parent > .the-child
236
- * - 后代选择器:.the-ancestor .the-descendant
237
- * - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
238
- * - 多选择器的并集:#a-node, .some-other-nodes
239
- * @supported weapp, h5
240
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.selectAll.html
241
- */
242
- selectAll(
243
- /** 选择器 */
244
- selector: string,
245
- ): NodesRef
246
- /** 选择显示区域。可用于获取显示区域的尺寸、滚动位置等信息。
247
- * @supported weapp, h5
248
- * @example
249
- * ```tsx
250
- * Taro.createSelectorQuery().selectViewport().scrollOffset(function (res) {
251
- * res.id // 节点的ID
252
- * res.dataset // 节点的dataset
253
- * res.scrollLeft // 节点的水平滚动位置
254
- * res.scrollTop // 节点的竖直滚动位置
255
- * }).exec()
256
- * ```
257
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.selectViewport.html
258
- */
259
- selectViewport(): NodesRef
260
- /** 将选择器的选取范围更改为自定义组件 `component` 内。(初始时,选择器仅选取页面范围的节点,不会选取任何自定义组件中的节点)。
261
- * @supported weapp, h5
262
- * @example
263
- * ```tsx
264
- * Component({
265
- * queryMultipleNodes () {
266
- * const query = Taro.createSelectorQuery().in(this)
267
- * query.select('#the-id').boundingClientRect(function(res){
268
- * res.top // 这个组件内 #the-id 节点的上边界坐标
269
- * }).exec()
270
- * }
271
- * })
272
- * ```
273
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.in.html
274
- */
275
- in(
276
- /** 自定义组件实例 */
277
- component: TaroGeneral.IAnyObject,
278
- ): SelectorQuery
279
- }
280
-
281
182
  /** 用于获取 `WXML` 节点信息的对象
282
183
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/NodesRef.html
283
184
  */
284
185
  interface NodesRef {
285
186
  /** 添加节点的布局位置的查询请求。相对于显示区域,以像素为单位。其功能类似于 DOM 的 `getBoundingClientRect`。返回 `NodesRef` 对应的 `SelectorQuery`。
286
- * @supported weapp, h5
187
+ * @supported weapp, h5, tt
287
188
  * @example
288
189
  * ```tsx
289
190
  * Taro.createSelectorQuery().select('#the-id').boundingClientRect(function(rect){
@@ -318,8 +219,8 @@ declare module '../../index' {
318
219
  /** 回调函数,在执行 `SelectorQuery.exec` 方法后,节点信息会在 `callback` 中返回。 */
319
220
  callback?: NodesRef.BoundingClientRectCallback,
320
221
  ): SelectorQuery
321
- /** 添加节点的 Context 对象查询请求。目前支持 [VideoContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.html)、[CanvasContext](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.html)、[LivePlayerContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.html)、[EditorContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/editor/EditorContext.html)和 [MapContext](https://developers.weixin.qq.com/miniprogram/dev/api/media/map/MapContext.html) 的获取。
322
- * @supported weapp
222
+ /** 添加节点的 Context 对象查询请求。目前支持 [VideoContext](/docs/apis/media/video/VideoContext)、[CanvasContext](/docs/apis/canvas/CanvasContext)、[LivePlayerContext](/docs/apis/media/live/LivePlayerContext)、[EditorContext](/docs/apis/media/editor/EditorContext)和 [MapContext](/docs/apis/media/map/MapContext) 的获取。
223
+ * @supported weapp, h5, tt
323
224
  * @example
324
225
  * ```tsx
325
226
  * Taro.createSelectorQuery().select('.the-video-class').context(function (res) {
@@ -336,7 +237,7 @@ declare module '../../index' {
336
237
  *
337
238
  * **注意**
338
239
  * computedStyle 的优先级高于 size,当同时在 computedStyle 里指定了 width/height 和传入了 size: true,则优先返回 computedStyle 获取到的 width/height。
339
- * @supported weapp, h5
240
+ * @supported weapp, h5, tt
340
241
  * @example
341
242
  * ```tsx
342
243
  * Taro.createSelectorQuery().select('#the-id').fields({
@@ -367,8 +268,8 @@ declare module '../../index' {
367
268
  /** 回调函数 */
368
269
  callback?: NodesRef.FieldsCallback,
369
270
  ): SelectorQuery
370
- /** 获取 Node 节点实例。目前支持 [Canvas](https://developers.weixin.qq.com/miniprogram/dev/component/canvas.html) 的获取。
371
- * @supported weapp
271
+ /** 获取 Node 节点实例。目前支持 [Canvas](/docs/components/canvas) 的获取。
272
+ * @supported weapp, h5, tt
372
273
  * @example
373
274
  * ```tsx
374
275
  * Taro.createSelectorQuery().select('.canvas').node(function(res){
@@ -382,7 +283,7 @@ declare module '../../index' {
382
283
  callback?: NodesRef.NodeCallback,
383
284
  ): SelectorQuery
384
285
  /** 添加节点的滚动位置查询请求。以像素为单位。节点必须是 `scroll-view` 或者 `viewport`,返回 `NodesRef` 对应的 `SelectorQuery`。
385
- * @supported weapp, h5
286
+ * @supported weapp, h5, tt
386
287
  * @example
387
288
  * ```tsx
388
289
  * Taro.createSelectorQuery().selectViewport().scrollOffset(function(res){
@@ -478,9 +379,112 @@ declare module '../../index' {
478
379
  }
479
380
  }
480
381
 
382
+ /** 查询节点信息的对象
383
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.html
384
+ */
385
+ interface SelectorQuery {
386
+ /** 执行所有的请求。请求结果按请求次序构成数组,在callback的第一个参数中返回。
387
+ * @supported weapp, h5, tt
388
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.exec.html
389
+ */
390
+ exec(
391
+ /** 回调函数 */
392
+ callback?: (...args: any[]) => any,
393
+ ): NodesRef
394
+ /** 将选择器的选取范围更改为自定义组件 `component` 内。(初始时,选择器仅选取页面范围的节点,不会选取任何自定义组件中的节点)。
395
+ * @supported weapp, h5, tt
396
+ * @example
397
+ * ```tsx
398
+ * Component({
399
+ * queryMultipleNodes () {
400
+ * const query = Taro.createSelectorQuery().in(this)
401
+ * query.select('#the-id').boundingClientRect(function(res){
402
+ * res.top // 这个组件内 #the-id 节点的上边界坐标
403
+ * }).exec()
404
+ * }
405
+ * })
406
+ * ```
407
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.in.html
408
+ */
409
+ in(
410
+ /** 自定义组件实例 */
411
+ component: TaroGeneral.IAnyObject,
412
+ ): SelectorQuery
413
+ /** 在当前页面下选择第一个匹配选择器 `selector` 的节点。返回一个 `NodesRef` 对象实例,可以用于获取节点信息。
414
+ *
415
+ * **selector 语法**
416
+ *
417
+ *
418
+ * selector类似于 CSS 的选择器,但仅支持下列语法。
419
+ *
420
+ * - ID选择器:#the-id
421
+ * - class选择器(可以连续指定多个):.a-class.another-class
422
+ * - 子元素选择器:.the-parent > .the-child
423
+ * - 后代选择器:.the-ancestor .the-descendant
424
+ * - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
425
+ * - 多选择器的并集:#a-node, .some-other-nodes
426
+ * @supported weapp, h5, tt
427
+ * @example
428
+ * ```tsx
429
+ * Taro.createSelectorQuery().select('#the-id').fields({
430
+ * dataset: true,
431
+ * size: true,
432
+ * scrollOffset: true,
433
+ * properties: ['scrollX', 'scrollY']
434
+ * }, function (res){
435
+ * res.dataset // 节点的dataset
436
+ * res.width // 节点的宽度
437
+ * res.height // 节点的高度
438
+ * res.scrollLeft // 节点的水平滚动位置
439
+ * res.scrollTop // 节点的竖直滚动位置
440
+ * res.scrollX // 节点 scroll-x 属性的当前值
441
+ * res.scrollY // 节点 scroll-x 属性的当前值
442
+ * }).exec()
443
+ * ```
444
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.select.html
445
+ */
446
+ select(
447
+ /** 选择器 */
448
+ selector: string,
449
+ ): NodesRef
450
+ /** 在当前页面下选择匹配选择器 selector 的所有节点。
451
+ *
452
+ * **selector 语法**
453
+ *
454
+ * selector类似于 CSS 的选择器,但仅支持下列语法。
455
+ *
456
+ * - ID选择器:#the-id
457
+ * - class选择器(可以连续指定多个):.a-class.another-class
458
+ * - 子元素选择器:.the-parent > .the-child
459
+ * - 后代选择器:.the-ancestor .the-descendant
460
+ * - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
461
+ * - 多选择器的并集:#a-node, .some-other-nodes
462
+ * @supported weapp, h5, tt
463
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.selectAll.html
464
+ */
465
+ selectAll(
466
+ /** 选择器 */
467
+ selector: string,
468
+ ): NodesRef
469
+ /** 选择显示区域。可用于获取显示区域的尺寸、滚动位置等信息。
470
+ * @supported weapp, h5, tt
471
+ * @example
472
+ * ```tsx
473
+ * Taro.createSelectorQuery().selectViewport().scrollOffset(function (res) {
474
+ * res.id // 节点的ID
475
+ * res.dataset // 节点的dataset
476
+ * res.scrollLeft // 节点的水平滚动位置
477
+ * res.scrollTop // 节点的竖直滚动位置
478
+ * }).exec()
479
+ * ```
480
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.selectViewport.html
481
+ */
482
+ selectViewport(): NodesRef
483
+ }
484
+
481
485
  interface TaroStatic {
482
486
  /** 返回一个 SelectorQuery 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createSelectorQuery()` 来代替。
483
- * @supported weapp, h5
487
+ * @supported weapp, h5, tt
484
488
  * @example
485
489
  * ```tsx
486
490
  * const query = Taro.createSelectorQuery()
@@ -496,7 +500,7 @@ declare module '../../index' {
496
500
  createSelectorQuery(): SelectorQuery
497
501
 
498
502
  /** 创建并返回一个 IntersectionObserver 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createIntersectionObserver([options])` 来代替。
499
- * @supported weapp
503
+ * @supported weapp, tt
500
504
  * @example
501
505
  * ```tsx
502
506
  * const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true })