@spcsn/taro 0.1.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/README.md +12 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/index.js +9 -0
- package/package.json +86 -0
- package/types/api/ad/index.d.ts +197 -0
- package/types/api/ai/face.d.ts +133 -0
- package/types/api/ai/inference.d.ts +129 -0
- package/types/api/ai/visionkit.d.ts +874 -0
- package/types/api/alipay/index.d.ts +69 -0
- package/types/api/base/crypto.d.ts +104 -0
- package/types/api/base/debug.d.ts +329 -0
- package/types/api/base/env.d.ts +19 -0
- package/types/api/base/index.d.ts +102 -0
- package/types/api/base/performance.d.ts +258 -0
- package/types/api/base/system.d.ts +742 -0
- package/types/api/base/update.d.ts +130 -0
- package/types/api/base/weapp/app-event.d.ts +265 -0
- package/types/api/base/weapp/life-cycle.d.ts +155 -0
- package/types/api/canvas/index.d.ts +2162 -0
- package/types/api/cloud/index.d.ts +2622 -0
- package/types/api/data-analysis/index.d.ts +122 -0
- package/types/api/device/accelerometer.d.ts +102 -0
- package/types/api/device/accessibility.d.ts +26 -0
- package/types/api/device/battery.d.ts +46 -0
- package/types/api/device/bluetooth-ble.d.ts +601 -0
- package/types/api/device/bluetooth-peripheral.d.ts +430 -0
- package/types/api/device/bluetooth.d.ts +463 -0
- package/types/api/device/calendar.d.ts +98 -0
- package/types/api/device/clipboard.d.ts +81 -0
- package/types/api/device/compass.d.ts +105 -0
- package/types/api/device/contact.d.ts +110 -0
- package/types/api/device/gyroscope.d.ts +85 -0
- package/types/api/device/iBeacon.d.ts +168 -0
- package/types/api/device/keyboard.d.ts +97 -0
- package/types/api/device/memory.d.ts +52 -0
- package/types/api/device/motion.d.ts +88 -0
- package/types/api/device/network.d.ts +172 -0
- package/types/api/device/nfc.d.ts +1238 -0
- package/types/api/device/phone.d.ts +30 -0
- package/types/api/device/scan.d.ts +111 -0
- package/types/api/device/screen.d.ts +217 -0
- package/types/api/device/sms.d.ts +26 -0
- package/types/api/device/vibrate.d.ts +51 -0
- package/types/api/device/wifi.d.ts +301 -0
- package/types/api/ext/index.d.ts +64 -0
- package/types/api/files/index.d.ts +1472 -0
- package/types/api/framework/index.d.ts +51 -0
- package/types/api/location/index.d.ts +517 -0
- package/types/api/media/audio.d.ts +1013 -0
- package/types/api/media/background-audio.d.ts +291 -0
- package/types/api/media/camera.d.ts +207 -0
- package/types/api/media/editor.d.ts +239 -0
- package/types/api/media/image.d.ts +469 -0
- package/types/api/media/live.d.ts +461 -0
- package/types/api/media/map.d.ts +638 -0
- package/types/api/media/media-recorder.d.ts +117 -0
- package/types/api/media/recorder.d.ts +317 -0
- package/types/api/media/video-decoder.d.ts +117 -0
- package/types/api/media/video-processing.d.ts +84 -0
- package/types/api/media/video.d.ts +527 -0
- package/types/api/media/voip.d.ts +393 -0
- package/types/api/navigate/index.d.ts +327 -0
- package/types/api/network/download.d.ts +173 -0
- package/types/api/network/mdns.d.ts +191 -0
- package/types/api/network/request.d.ts +480 -0
- package/types/api/network/tcp.d.ts +181 -0
- package/types/api/network/udp.d.ts +218 -0
- package/types/api/network/upload.d.ts +201 -0
- package/types/api/network/websocket.d.ts +383 -0
- package/types/api/open-api/account.d.ts +51 -0
- package/types/api/open-api/address.d.ts +68 -0
- package/types/api/open-api/authorize.d.ts +80 -0
- package/types/api/open-api/card.d.ts +110 -0
- package/types/api/open-api/channels.d.ts +225 -0
- package/types/api/open-api/customer-service.d.ts +45 -0
- package/types/api/open-api/device-voip.d.ts +103 -0
- package/types/api/open-api/facial.d.ts +98 -0
- package/types/api/open-api/favorites.d.ts +101 -0
- package/types/api/open-api/group.d.ts +59 -0
- package/types/api/open-api/invoice.d.ts +87 -0
- package/types/api/open-api/license-plate.d.ts +27 -0
- package/types/api/open-api/login.d.ts +115 -0
- package/types/api/open-api/my-miniprogram.d.ts +28 -0
- package/types/api/open-api/privacy.d.ts +107 -0
- package/types/api/open-api/redpackage.d.ts +24 -0
- package/types/api/open-api/settings.d.ts +174 -0
- package/types/api/open-api/soter.d.ts +184 -0
- package/types/api/open-api/sticker.d.ts +83 -0
- package/types/api/open-api/subscribe-message.d.ts +305 -0
- package/types/api/open-api/user-info.d.ts +182 -0
- package/types/api/open-api/werun.d.ts +101 -0
- package/types/api/payment/index.d.ts +119 -0
- package/types/api/qq/index.d.ts +354 -0
- package/types/api/route/index.d.ts +324 -0
- package/types/api/share/index.d.ts +354 -0
- package/types/api/skyline/index.d.ts +345 -0
- package/types/api/storage/background-fetch.d.ts +131 -0
- package/types/api/storage/cache-manager.d.ts +249 -0
- package/types/api/storage/index.d.ts +405 -0
- package/types/api/swan/bookshelf.d.ts +307 -0
- package/types/api/swan/download-package.d.ts +80 -0
- package/types/api/swan/index.d.ts +251 -0
- package/types/api/swan/pay.d.ts +139 -0
- package/types/api/taro.extend.d.ts +233 -0
- package/types/api/taro.hooks.d.ts +148 -0
- package/types/api/ui/animation.d.ts +427 -0
- package/types/api/ui/background.d.ts +69 -0
- package/types/api/ui/custom-component.d.ts +23 -0
- package/types/api/ui/fonts.d.ts +77 -0
- package/types/api/ui/interaction.d.ts +281 -0
- package/types/api/ui/menu.d.ts +29 -0
- package/types/api/ui/navigation-bar.d.ts +130 -0
- package/types/api/ui/pull-down-refresh.d.ts +50 -0
- package/types/api/ui/scroll.d.ts +114 -0
- package/types/api/ui/sticky.d.ts +32 -0
- package/types/api/ui/tab-bar.d.ts +196 -0
- package/types/api/ui/window.d.ts +71 -0
- package/types/api/worker/index.d.ts +83 -0
- package/types/api/wxml/index.d.ts +540 -0
- package/types/compile/compiler.d.ts +32 -0
- package/types/compile/config/h5.d.ts +134 -0
- package/types/compile/config/harmony.d.ts +118 -0
- package/types/compile/config/index.d.ts +8 -0
- package/types/compile/config/manifest.d.ts +155 -0
- package/types/compile/config/mini.d.ts +118 -0
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/project.d.ts +338 -0
- package/types/compile/config/rn.d.ts +85 -0
- package/types/compile/config/util.d.ts +179 -0
- package/types/compile/hooks.d.ts +13 -0
- package/types/compile/index.d.ts +11 -0
- package/types/compile/viteCompilerContext.d.ts +167 -0
- package/types/global.d.ts +428 -0
- package/types/index.d.ts +190 -0
- package/types/taro.api.d.ts +130 -0
- package/types/taro.component.d.ts +168 -0
- package/types/taro.config.d.ts +712 -0
- package/types/taro.lifecycle.d.ts +220 -0
- package/types/taro.runtime.d.ts +9 -0
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
4
|
+
namespace createIntersectionObserver {
|
|
5
|
+
/** 选项 */
|
|
6
|
+
interface Option {
|
|
7
|
+
/** 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数。 */
|
|
8
|
+
initialRatio?: number
|
|
9
|
+
/** 是否同时观测多个目标节点(而非一个),如果设为 true ,observe 的 targetSelector 将选中多个节点(注意:同时选中过多节点将影响渲染性能) */
|
|
10
|
+
observeAll?: boolean
|
|
11
|
+
/** 一个数值数组,包含所有阈值。 */
|
|
12
|
+
thresholds?: number[]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** `IntersectionObserver` 对象,用于推断某些节点是否可以被用户看见、有多大比例可以被用户看见。
|
|
17
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.html
|
|
18
|
+
*/
|
|
19
|
+
interface IntersectionObserver {
|
|
20
|
+
/** 停止监听。回调函数将不再触发
|
|
21
|
+
* @supported weapp, tt, h5, harmony_hybrid
|
|
22
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.disconnect.html
|
|
23
|
+
*/
|
|
24
|
+
disconnect(): void
|
|
25
|
+
/** 指定目标节点并开始监听相交状态变化情况
|
|
26
|
+
* @supported weapp, tt, h5, harmony_hybrid
|
|
27
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.observe.html
|
|
28
|
+
*/
|
|
29
|
+
observe(
|
|
30
|
+
/** 选择器 */
|
|
31
|
+
targetSelector: string,
|
|
32
|
+
/** 监听相交状态变化的回调函数 */
|
|
33
|
+
callback: IntersectionObserver.ObserveCallback,
|
|
34
|
+
): void
|
|
35
|
+
/** 使用选择器指定一个节点,作为参照区域之一。
|
|
36
|
+
* @supported weapp, tt, h5, harmony_hybrid
|
|
37
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.relativeTo.html
|
|
38
|
+
*/
|
|
39
|
+
relativeTo(
|
|
40
|
+
/** 选择器 */
|
|
41
|
+
selector: string,
|
|
42
|
+
/** 用来扩展(或收缩)参照节点布局区域的边界 */
|
|
43
|
+
margins?: IntersectionObserver.RelativeToMargins,
|
|
44
|
+
): IntersectionObserver
|
|
45
|
+
/** 指定页面显示区域作为参照区域之一
|
|
46
|
+
* @supported weapp, tt, h5, harmony_hybrid
|
|
47
|
+
* @example
|
|
48
|
+
* 下面的示例代码中,如果目标节点(用选择器 .target-class 指定)进入显示区域以下 100px 时,就会触发回调函数。
|
|
49
|
+
*
|
|
50
|
+
* ```tsx
|
|
51
|
+
* Taro.createIntersectionObserver().relativeToViewport({bottom: 100}).observe('.target-class', (res) => {
|
|
52
|
+
* res.intersectionRatio // 相交区域占目标节点的布局区域的比例
|
|
53
|
+
* res.intersectionRect // 相交区域
|
|
54
|
+
* res.intersectionRect.left // 相交区域的左边界坐标
|
|
55
|
+
* res.intersectionRect.top // 相交区域的上边界坐标
|
|
56
|
+
* res.intersectionRect.width // 相交区域的宽度
|
|
57
|
+
* res.intersectionRect.height // 相交区域的高度
|
|
58
|
+
* })
|
|
59
|
+
* ```
|
|
60
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.relativeToViewport.html
|
|
61
|
+
*/
|
|
62
|
+
relativeToViewport(
|
|
63
|
+
/** 用来扩展(或收缩)参照节点布局区域的边界 */
|
|
64
|
+
margins?: IntersectionObserver.RelativeToViewportMargins,
|
|
65
|
+
): IntersectionObserver
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
namespace IntersectionObserver {
|
|
69
|
+
/** 监听相交状态变化的回调函数
|
|
70
|
+
* @description Harmony 找不到对应元素时,回调会返回一个 Error 对象
|
|
71
|
+
*/
|
|
72
|
+
type ObserveCallback = (result: ObserveCallbackResult) => void
|
|
73
|
+
interface ObserveCallbackResult extends TaroGeneral.CallbackResult {
|
|
74
|
+
/** 错误信息,会在找不到对应元素时返回
|
|
75
|
+
* @supported harmony
|
|
76
|
+
*/
|
|
77
|
+
errMsg?: string
|
|
78
|
+
/** 目标边界 */
|
|
79
|
+
boundingClientRect?: BoundingClientRectResult
|
|
80
|
+
/** 相交比例 */
|
|
81
|
+
intersectionRatio?: number
|
|
82
|
+
/** 相交区域的边界 */
|
|
83
|
+
intersectionRect?: IntersectionRectResult
|
|
84
|
+
/** 参照区域的边界 */
|
|
85
|
+
relativeRect?: RelativeRectResult
|
|
86
|
+
/** 相交检测时的时间戳 */
|
|
87
|
+
time?: number
|
|
88
|
+
}
|
|
89
|
+
/** 参照区域的边界 */
|
|
90
|
+
interface RelativeRectResult {
|
|
91
|
+
/** 下边界 */
|
|
92
|
+
bottom: number
|
|
93
|
+
/** 左边界 */
|
|
94
|
+
left: number
|
|
95
|
+
/** 右边界 */
|
|
96
|
+
right: number
|
|
97
|
+
/** 上边界 */
|
|
98
|
+
top: number
|
|
99
|
+
}
|
|
100
|
+
/** 相交区域的边界 */
|
|
101
|
+
interface IntersectionRectResult {
|
|
102
|
+
/** 下边界 */
|
|
103
|
+
bottom: number
|
|
104
|
+
/** 高度 */
|
|
105
|
+
height: number
|
|
106
|
+
/** 左边界 */
|
|
107
|
+
left: number
|
|
108
|
+
/** 右边界 */
|
|
109
|
+
right: number
|
|
110
|
+
/** 上边界 */
|
|
111
|
+
top: number
|
|
112
|
+
/** 宽度 */
|
|
113
|
+
width: number
|
|
114
|
+
}
|
|
115
|
+
/** 目标边界 */
|
|
116
|
+
interface BoundingClientRectResult {
|
|
117
|
+
/** 下边界 */
|
|
118
|
+
bottom: number
|
|
119
|
+
/** 高度 */
|
|
120
|
+
height: number
|
|
121
|
+
/** 左边界 */
|
|
122
|
+
left: number
|
|
123
|
+
/** 右边界 */
|
|
124
|
+
right: number
|
|
125
|
+
/** 上边界 */
|
|
126
|
+
top: number
|
|
127
|
+
/** 宽度 */
|
|
128
|
+
width: number
|
|
129
|
+
}
|
|
130
|
+
/** 用来扩展(或收缩)参照节点布局区域的边界 */
|
|
131
|
+
interface RelativeToMargins {
|
|
132
|
+
/** 节点布局区域的下边界 */
|
|
133
|
+
bottom?: number
|
|
134
|
+
/** 节点布局区域的左边界 */
|
|
135
|
+
left?: number
|
|
136
|
+
/** 节点布局区域的右边界 */
|
|
137
|
+
right?: number
|
|
138
|
+
/** 节点布局区域的上边界 */
|
|
139
|
+
top?: number
|
|
140
|
+
}
|
|
141
|
+
/** 用来扩展(或收缩)参照节点布局区域的边界 */
|
|
142
|
+
interface RelativeToViewportMargins {
|
|
143
|
+
/** 节点布局区域的下边界 */
|
|
144
|
+
bottom?: number
|
|
145
|
+
/** 节点布局区域的左边界 */
|
|
146
|
+
left?: number
|
|
147
|
+
/** 节点布局区域的右边界 */
|
|
148
|
+
right?: number
|
|
149
|
+
/** 节点布局区域的上边界 */
|
|
150
|
+
top?: number
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** `MediaQueryObserver` 对象,用于监听页面 media query 状态的变化,如界面的长宽是不是在某个指定的范围内。 */
|
|
155
|
+
interface MediaQueryObserver {
|
|
156
|
+
/** 开始监听页面 media query 变化情况 */
|
|
157
|
+
observe(descriptor: MediaQueryObserver.descriptor, callback: MediaQueryObserver.observeCallback): void
|
|
158
|
+
/** 停止监听。回调函数将不再触发 */
|
|
159
|
+
disconnect(): void
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
namespace MediaQueryObserver {
|
|
163
|
+
/** media query 描述符 */
|
|
164
|
+
interface descriptor {
|
|
165
|
+
/** 页面最小宽度 (单位: px) */
|
|
166
|
+
minWidth: number
|
|
167
|
+
/** 页面最大宽度 (单位: px) */
|
|
168
|
+
maxWidth: number
|
|
169
|
+
/** 页面宽度 (单位: px) */
|
|
170
|
+
width: number
|
|
171
|
+
/** 页面最小高度 (单位: px) */
|
|
172
|
+
minHeight: number
|
|
173
|
+
/** 页面最大高度(px 为单位) */
|
|
174
|
+
maxHeight: number
|
|
175
|
+
/** 页面高度(px 为单位) */
|
|
176
|
+
height: number
|
|
177
|
+
/** 屏幕方向 */
|
|
178
|
+
orientation: 'landscape' | 'portrait'
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** 监听 media query 状态变化的回调函数 */
|
|
182
|
+
type observeCallback = (res: {
|
|
183
|
+
/** 页面的当前状态是否满足所指定的 media query */
|
|
184
|
+
matches: boolean
|
|
185
|
+
}) => void
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** 用于获取 `WXML` 节点信息的对象
|
|
189
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/NodesRef.html
|
|
190
|
+
*/
|
|
191
|
+
interface NodesRef {
|
|
192
|
+
/** 添加节点的布局位置的查询请求。相对于显示区域,以像素为单位。其功能类似于 DOM 的 `getBoundingClientRect`。返回 `NodesRef` 对应的 `SelectorQuery`。
|
|
193
|
+
* @supported weapp, h5, tt, harmony_hybrid
|
|
194
|
+
* @example
|
|
195
|
+
* ```tsx
|
|
196
|
+
* Taro.createSelectorQuery().select('#the-id').boundingClientRect(function(rect){
|
|
197
|
+
* rect.id // 节点的ID
|
|
198
|
+
* rect.dataset // 节点的dataset
|
|
199
|
+
* rect.left // 节点的左边界坐标
|
|
200
|
+
* rect.right // 节点的右边界坐标
|
|
201
|
+
* rect.top // 节点的上边界坐标
|
|
202
|
+
* rect.bottom // 节点的下边界坐标
|
|
203
|
+
* rect.width // 节点的宽度
|
|
204
|
+
* rect.height // 节点的高度
|
|
205
|
+
* }).exec()
|
|
206
|
+
* @example
|
|
207
|
+
* ```
|
|
208
|
+
* ```tsx
|
|
209
|
+
* Taro.createSelectorQuery().selectAll('.a-class').boundingClientRect(function(rects){
|
|
210
|
+
* rects.forEach(function(rect){
|
|
211
|
+
* rect.id // 节点的ID
|
|
212
|
+
* rect.dataset // 节点的dataset
|
|
213
|
+
* rect.left // 节点的左边界坐标
|
|
214
|
+
* rect.right // 节点的右边界坐标
|
|
215
|
+
* rect.top // 节点的上边界坐标
|
|
216
|
+
* rect.bottom // 节点的下边界坐标
|
|
217
|
+
* rect.width // 节点的宽度
|
|
218
|
+
* rect.height // 节点的高度
|
|
219
|
+
* })
|
|
220
|
+
* }).exec()
|
|
221
|
+
* ```
|
|
222
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/NodesRef.boundingClientRect.html
|
|
223
|
+
*/
|
|
224
|
+
boundingClientRect(
|
|
225
|
+
/** 回调函数,在执行 `SelectorQuery.exec` 方法后,节点信息会在 `callback` 中返回。 */
|
|
226
|
+
callback?: NodesRef.BoundingClientRectCallback,
|
|
227
|
+
): SelectorQuery
|
|
228
|
+
/** 添加节点的 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) 的获取。
|
|
229
|
+
* @supported weapp, h5, tt, harmony_hybrid
|
|
230
|
+
* @example
|
|
231
|
+
* ```tsx
|
|
232
|
+
* Taro.createSelectorQuery().select('.the-video-class').context(function (res) {
|
|
233
|
+
* console.log(res.context) // 节点对应的 Context 对象。如:选中的节点是 <video> 组件,那么此处即返回 VideoContext 对象
|
|
234
|
+
* }).exec()
|
|
235
|
+
* ```
|
|
236
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/NodesRef.context.html
|
|
237
|
+
*/
|
|
238
|
+
context(
|
|
239
|
+
/** 回调函数,在执行 `SelectorQuery.exec` 方法后,返回节点信息。 */
|
|
240
|
+
callback?: NodesRef.ContextCallback,
|
|
241
|
+
): SelectorQuery
|
|
242
|
+
/** 获取节点的相关信息。需要获取的字段在fields中指定。返回值是 `nodesRef` 对应的 `selectorQuery`
|
|
243
|
+
*
|
|
244
|
+
* **注意**
|
|
245
|
+
* computedStyle 的优先级高于 size,当同时在 computedStyle 里指定了 width/height 和传入了 size: true,则优先返回 computedStyle 获取到的 width/height。
|
|
246
|
+
* @supported weapp, h5, tt, harmony_hybrid
|
|
247
|
+
* @example
|
|
248
|
+
* ```tsx
|
|
249
|
+
* Taro.createSelectorQuery().select('#the-id').fields({
|
|
250
|
+
* dataset: true,
|
|
251
|
+
* size: true,
|
|
252
|
+
* scrollOffset: true,
|
|
253
|
+
* properties: ['scrollX', 'scrollY'],
|
|
254
|
+
* computedStyle: ['margin', 'backgroundColor'],
|
|
255
|
+
* context: true,
|
|
256
|
+
* }, function (res) {
|
|
257
|
+
* res.dataset // 节点的dataset
|
|
258
|
+
* res.width // 节点的宽度
|
|
259
|
+
* res.height // 节点的高度
|
|
260
|
+
* res.scrollLeft // 节点的水平滚动位置
|
|
261
|
+
* res.scrollTop // 节点的竖直滚动位置
|
|
262
|
+
* res.scrollX // 节点 scroll-x 属性的当前值
|
|
263
|
+
* res.scrollY // 节点 scroll-y 属性的当前值
|
|
264
|
+
* // 此处返回指定要返回的样式名
|
|
265
|
+
* res.margin
|
|
266
|
+
* res.backgroundColor
|
|
267
|
+
* res.context // 节点对应的 Context 对象
|
|
268
|
+
* }).exec()
|
|
269
|
+
* ```
|
|
270
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/NodesRef.fields.html
|
|
271
|
+
*/
|
|
272
|
+
fields(
|
|
273
|
+
fields: NodesRef.Fields,
|
|
274
|
+
/** 回调函数 */
|
|
275
|
+
callback?: NodesRef.FieldsCallback,
|
|
276
|
+
): SelectorQuery
|
|
277
|
+
/** 获取 Node 节点实例。目前支持 [Canvas](/docs/components/canvas) 的获取。
|
|
278
|
+
* @supported weapp, h5, tt, harmony_hybrid
|
|
279
|
+
* @example
|
|
280
|
+
* ```tsx
|
|
281
|
+
* Taro.createSelectorQuery().select('.canvas').node(function(res){
|
|
282
|
+
* console.log(res.node) // 节点对应的 Canvas 实例。
|
|
283
|
+
* }).exec()
|
|
284
|
+
* ```
|
|
285
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/NodesRef.node.html
|
|
286
|
+
*/
|
|
287
|
+
node(
|
|
288
|
+
/** 回调函数,在执行 `SelectorQuery.exec` 方法后,返回节点信息。 */
|
|
289
|
+
callback?: NodesRef.NodeCallback,
|
|
290
|
+
): SelectorQuery
|
|
291
|
+
/** 添加节点的滚动位置查询请求。以像素为单位。节点必须是 `scroll-view` 或者 `viewport`,返回 `NodesRef` 对应的 `SelectorQuery`。
|
|
292
|
+
* @supported weapp, h5, tt, harmony_hybrid
|
|
293
|
+
* @example
|
|
294
|
+
* ```tsx
|
|
295
|
+
* Taro.createSelectorQuery().selectViewport().scrollOffset(function(res){
|
|
296
|
+
* res.id // 节点的ID
|
|
297
|
+
* res.dataset // 节点的dataset
|
|
298
|
+
* res.scrollLeft // 节点的水平滚动位置
|
|
299
|
+
* res.scrollTop // 节点的竖直滚动位置
|
|
300
|
+
* }).exec()
|
|
301
|
+
* ```
|
|
302
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/NodesRef.scrollOffset.html
|
|
303
|
+
*/
|
|
304
|
+
scrollOffset(
|
|
305
|
+
/** 回调函数,在执行 `SelectorQuery.exec` 方法后,节点信息会在 `callback` 中返回。 */
|
|
306
|
+
callback?: NodesRef.ScrollOffsetCallback,
|
|
307
|
+
): SelectorQuery
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
namespace NodesRef {
|
|
311
|
+
/** 回调函数,在执行 `SelectorQuery.exec` 方法后,节点信息会在 `callback` 中返回。 */
|
|
312
|
+
type BoundingClientRectCallback = (
|
|
313
|
+
result: BoundingClientRectCallbackResult | BoundingClientRectCallbackResult[],
|
|
314
|
+
) => void
|
|
315
|
+
interface BoundingClientRectCallbackResult {
|
|
316
|
+
/** 节点的下边界坐标 */
|
|
317
|
+
bottom: number
|
|
318
|
+
/** 节点的 dataset */
|
|
319
|
+
dataset: TaroGeneral.IAnyObject
|
|
320
|
+
/** 节点的高度 */
|
|
321
|
+
height: number
|
|
322
|
+
/** 节点的 ID */
|
|
323
|
+
id: string
|
|
324
|
+
/** 节点的左边界坐标 */
|
|
325
|
+
left: number
|
|
326
|
+
/** 节点的右边界坐标 */
|
|
327
|
+
right: number
|
|
328
|
+
/** 节点的上边界坐标 */
|
|
329
|
+
top: number
|
|
330
|
+
/** 节点的宽度 */
|
|
331
|
+
width: number
|
|
332
|
+
}
|
|
333
|
+
/** 回调函数,在执行 `SelectorQuery.exec` 方法后,返回节点信息。 */
|
|
334
|
+
type ContextCallback = (result: ContextCallbackResult) => void
|
|
335
|
+
interface ContextCallbackResult {
|
|
336
|
+
/** 节点对应的 Context 对象 */
|
|
337
|
+
context: TaroGeneral.IAnyObject
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
interface Fields {
|
|
341
|
+
/** 指定样式名列表,返回节点对应样式名的当前值 */
|
|
342
|
+
computedStyle?: string[]
|
|
343
|
+
/** 是否返回节点对应的 Context 对象 */
|
|
344
|
+
context?: boolean
|
|
345
|
+
/** 是否返回节点 dataset */
|
|
346
|
+
dataset?: boolean
|
|
347
|
+
/** 是否返回节点 id */
|
|
348
|
+
id?: boolean
|
|
349
|
+
/** 是否返回节点 mark */
|
|
350
|
+
mark?: boolean
|
|
351
|
+
/** 是否返回节点对应的 Node 实例 */
|
|
352
|
+
node?: boolean
|
|
353
|
+
/** 指定属性名列表,返回节点对应属性名的当前属性值(只能获得组件文档中标注的常规属性值,id class style 和事件绑定的属性值不可获取) */
|
|
354
|
+
properties?: string[]
|
|
355
|
+
/** 是否返回节点布局位置(`left` `right` `top` `bottom`) */
|
|
356
|
+
rect?: boolean
|
|
357
|
+
/** 否 是否返回节点的 `scrollLeft` `scrollTop`,节点必须是 `scroll-view` 或者 `viewport` */
|
|
358
|
+
scrollOffset?: boolean
|
|
359
|
+
/** 是否返回节点尺寸(`width` `height`) */
|
|
360
|
+
size?: boolean
|
|
361
|
+
}
|
|
362
|
+
/** 回调函数 */
|
|
363
|
+
type FieldsCallback = (
|
|
364
|
+
/** 节点的相关信息 */
|
|
365
|
+
res: TaroGeneral.IAnyObject,
|
|
366
|
+
) => void
|
|
367
|
+
/** 回调函数,在执行 `SelectorQuery.exec` 方法后,返回节点信息。 */
|
|
368
|
+
type NodeCallback = (result: NodeCallbackResult) => void
|
|
369
|
+
/** 回调函数 */
|
|
370
|
+
interface NodeCallbackResult {
|
|
371
|
+
/** 节点对应的 Node 实例 */
|
|
372
|
+
node: TaroGeneral.IAnyObject
|
|
373
|
+
}
|
|
374
|
+
/** 回调函数,在执行 `SelectorQuery.exec` 方法后,节点信息会在 `callback` 中返回。 */
|
|
375
|
+
type ScrollOffsetCallback = (result: ScrollOffsetCallbackResult) => void
|
|
376
|
+
interface ScrollOffsetCallbackResult {
|
|
377
|
+
/** 节点的 dataset */
|
|
378
|
+
dataset: TaroGeneral.IAnyObject
|
|
379
|
+
/** 节点的 ID */
|
|
380
|
+
id: string
|
|
381
|
+
/** 节点的水平滚动位置 */
|
|
382
|
+
scrollLeft: number
|
|
383
|
+
/** 节点的竖直滚动位置 */
|
|
384
|
+
scrollTop: number
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** 查询节点信息的对象
|
|
389
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.html
|
|
390
|
+
*/
|
|
391
|
+
interface SelectorQuery {
|
|
392
|
+
/** 执行所有的请求。请求结果按请求次序构成数组,在callback的第一个参数中返回。
|
|
393
|
+
* @supported weapp, h5, tt, harmony_hybrid
|
|
394
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.exec.html
|
|
395
|
+
*/
|
|
396
|
+
exec(
|
|
397
|
+
/** 回调函数 */
|
|
398
|
+
callback?: (...args: any[]) => any,
|
|
399
|
+
): NodesRef
|
|
400
|
+
/** 将选择器的选取范围更改为自定义组件 `component` 内。(初始时,选择器仅选取页面范围的节点,不会选取任何自定义组件中的节点)。
|
|
401
|
+
* @supported weapp, h5, tt, harmony_hybrid
|
|
402
|
+
* @example
|
|
403
|
+
* ```tsx
|
|
404
|
+
* Component({
|
|
405
|
+
* queryMultipleNodes () {
|
|
406
|
+
* const query = Taro.createSelectorQuery().in(this)
|
|
407
|
+
* query.select('#the-id').boundingClientRect(function(res){
|
|
408
|
+
* res.top // 这个组件内 #the-id 节点的上边界坐标
|
|
409
|
+
* }).exec()
|
|
410
|
+
* }
|
|
411
|
+
* })
|
|
412
|
+
* ```
|
|
413
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.in.html
|
|
414
|
+
*/
|
|
415
|
+
in(
|
|
416
|
+
/** 自定义组件实例 */
|
|
417
|
+
component: TaroGeneral.IAnyObject,
|
|
418
|
+
): SelectorQuery
|
|
419
|
+
/** 在当前页面下选择第一个匹配选择器 `selector` 的节点。返回一个 `NodesRef` 对象实例,可以用于获取节点信息。
|
|
420
|
+
*
|
|
421
|
+
* **selector 语法**
|
|
422
|
+
*
|
|
423
|
+
*
|
|
424
|
+
* selector类似于 CSS 的选择器,但仅支持下列语法。
|
|
425
|
+
*
|
|
426
|
+
* - ID选择器:#the-id
|
|
427
|
+
* - class选择器(可以连续指定多个):.a-class.another-class
|
|
428
|
+
* - 子元素选择器:.the-parent > .the-child
|
|
429
|
+
* - 后代选择器:.the-ancestor .the-descendant
|
|
430
|
+
* - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
|
|
431
|
+
* - 多选择器的并集:#a-node, .some-other-nodes
|
|
432
|
+
* @supported weapp, h5, tt, harmony_hybrid
|
|
433
|
+
* @example
|
|
434
|
+
* ```tsx
|
|
435
|
+
* Taro.createSelectorQuery().select('#the-id').fields({
|
|
436
|
+
* dataset: true,
|
|
437
|
+
* size: true,
|
|
438
|
+
* scrollOffset: true,
|
|
439
|
+
* properties: ['scrollX', 'scrollY']
|
|
440
|
+
* }, function (res){
|
|
441
|
+
* res.dataset // 节点的dataset
|
|
442
|
+
* res.width // 节点的宽度
|
|
443
|
+
* res.height // 节点的高度
|
|
444
|
+
* res.scrollLeft // 节点的水平滚动位置
|
|
445
|
+
* res.scrollTop // 节点的竖直滚动位置
|
|
446
|
+
* res.scrollX // 节点 scroll-x 属性的当前值
|
|
447
|
+
* res.scrollY // 节点 scroll-x 属性的当前值
|
|
448
|
+
* }).exec()
|
|
449
|
+
* ```
|
|
450
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.select.html
|
|
451
|
+
*/
|
|
452
|
+
select(
|
|
453
|
+
/** 选择器 */
|
|
454
|
+
selector: string,
|
|
455
|
+
): NodesRef
|
|
456
|
+
/** 在当前页面下选择匹配选择器 selector 的所有节点。
|
|
457
|
+
*
|
|
458
|
+
* **selector 语法**
|
|
459
|
+
*
|
|
460
|
+
* selector类似于 CSS 的选择器,但仅支持下列语法。
|
|
461
|
+
*
|
|
462
|
+
* - ID选择器:#the-id
|
|
463
|
+
* - class选择器(可以连续指定多个):.a-class.another-class
|
|
464
|
+
* - 子元素选择器:.the-parent > .the-child
|
|
465
|
+
* - 后代选择器:.the-ancestor .the-descendant
|
|
466
|
+
* - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
|
|
467
|
+
* - 多选择器的并集:#a-node, .some-other-nodes
|
|
468
|
+
* @supported weapp, h5, tt, harmony_hybrid
|
|
469
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.selectAll.html
|
|
470
|
+
*/
|
|
471
|
+
selectAll(
|
|
472
|
+
/** 选择器 */
|
|
473
|
+
selector: string,
|
|
474
|
+
): NodesRef
|
|
475
|
+
/** 选择显示区域。可用于获取显示区域的尺寸、滚动位置等信息。
|
|
476
|
+
* @supported weapp, h5, tt, harmony_hybrid
|
|
477
|
+
* @example
|
|
478
|
+
* ```tsx
|
|
479
|
+
* Taro.createSelectorQuery().selectViewport().scrollOffset(function (res) {
|
|
480
|
+
* res.id // 节点的ID
|
|
481
|
+
* res.dataset // 节点的dataset
|
|
482
|
+
* res.scrollLeft // 节点的水平滚动位置
|
|
483
|
+
* res.scrollTop // 节点的竖直滚动位置
|
|
484
|
+
* }).exec()
|
|
485
|
+
* ```
|
|
486
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.selectViewport.html
|
|
487
|
+
*/
|
|
488
|
+
selectViewport(): NodesRef
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
interface TaroStatic {
|
|
492
|
+
/** 返回一个 SelectorQuery 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createSelectorQuery()` 来代替。
|
|
493
|
+
* @supported weapp, h5, tt, harmony, harmony_hybrid
|
|
494
|
+
* @example
|
|
495
|
+
* ```tsx
|
|
496
|
+
* const query = Taro.createSelectorQuery()
|
|
497
|
+
* query.select('#the-id').boundingClientRect()
|
|
498
|
+
* query.selectViewport().scrollOffset()
|
|
499
|
+
* query.exec(function(res){
|
|
500
|
+
* res[0].top // #the-id节点的上边界坐标
|
|
501
|
+
* res[1].scrollTop // 显示区域的竖直滚动位置
|
|
502
|
+
* })
|
|
503
|
+
* ```
|
|
504
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createSelectorQuery.html
|
|
505
|
+
*/
|
|
506
|
+
createSelectorQuery(): SelectorQuery
|
|
507
|
+
|
|
508
|
+
/** 创建并返回一个 IntersectionObserver 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createIntersectionObserver([options])` 来代替。
|
|
509
|
+
* @supported weapp, h5, tt, harmony, harmony_hybrid
|
|
510
|
+
* @example
|
|
511
|
+
* ```tsx
|
|
512
|
+
* const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true })
|
|
513
|
+
* ```
|
|
514
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createIntersectionObserver.html
|
|
515
|
+
*/
|
|
516
|
+
createIntersectionObserver(
|
|
517
|
+
/** 自定义组件实例 */
|
|
518
|
+
component: TaroGeneral.IAnyObject,
|
|
519
|
+
/** 选项 */
|
|
520
|
+
options?: createIntersectionObserver.Option,
|
|
521
|
+
): IntersectionObserver
|
|
522
|
+
|
|
523
|
+
/** 创建并返回一个 MediaQueryObserver 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createMediaQueryObserver()` 来代替。
|
|
524
|
+
* @supported h5, harmony_hybrid
|
|
525
|
+
* @example
|
|
526
|
+
* ```tsx
|
|
527
|
+
* let createMediaQueryObserver
|
|
528
|
+
* if (process.env.TARO_ENV === 'weapp') {
|
|
529
|
+
* // 小程序没有组件实例,只能获取Page级组件实例
|
|
530
|
+
* createMediaQueryObserver = Taro.getCurrentInstance().page.createMediaQueryObserver
|
|
531
|
+
* } else if (process.env.TARO_ENV === 'h5') {
|
|
532
|
+
* createMediaQueryObserver= Taro.createMediaQueryObserver
|
|
533
|
+
* }
|
|
534
|
+
* const mediaQueryObserver = createMediaQueryObserver()
|
|
535
|
+
* ```
|
|
536
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/view/resizable.html#Media%20Query
|
|
537
|
+
*/
|
|
538
|
+
createMediaQueryObserver(): MediaQueryObserver
|
|
539
|
+
}
|
|
540
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { swc } from '@spcsn/taro-helper'
|
|
2
|
+
import type Webpack from 'webpack'
|
|
3
|
+
|
|
4
|
+
export type CompilerViteTypes = 'vite'
|
|
5
|
+
|
|
6
|
+
export type CompilerWebpackTypes = 'webpack5'
|
|
7
|
+
|
|
8
|
+
export type CompilerTypes = CompilerWebpackTypes | CompilerViteTypes
|
|
9
|
+
|
|
10
|
+
interface IPrebundle {
|
|
11
|
+
enable?: boolean
|
|
12
|
+
timings?: boolean
|
|
13
|
+
cacheDir?: string
|
|
14
|
+
force?: boolean
|
|
15
|
+
include?: string[]
|
|
16
|
+
exclude?: string[]
|
|
17
|
+
esbuild?: Record<string, any>
|
|
18
|
+
swc?: swc.Config
|
|
19
|
+
webpack?: Webpack.Configuration & {
|
|
20
|
+
provide?: any[]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ICompiler<T> {
|
|
25
|
+
type: T
|
|
26
|
+
prebundle?: IPrebundle
|
|
27
|
+
vitePlugins?: any
|
|
28
|
+
/** 错误处理级别。可选值:0、1 */
|
|
29
|
+
errorLevel?: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type Compiler<T extends CompilerTypes = CompilerWebpackTypes> = T | ICompiler<T>
|