assistsx-js 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1196 @@
1
+ /**
2
+ * 与 Android AssistsCore.NodeLookupScope / HTTP scope 查询参数一致的字符串取值。
3
+ */
4
+ type NodeLookupScope = "active_window" | "all_windows";
5
+ /** 与 AssistsCore.NodeLookupScope.ActiveWindow 对应 */
6
+ declare const NODE_LOOKUP_SCOPE_ACTIVE_WINDOW: NodeLookupScope;
7
+ /** 与 AssistsCore.NodeLookupScope.AllWindows 对应 */
8
+ declare const NODE_LOOKUP_SCOPE_ALL_WINDOWS: NodeLookupScope;
9
+
10
+ declare class Bounds {
11
+ readonly left: number;
12
+ readonly top: number;
13
+ readonly right: number;
14
+ readonly bottom: number;
15
+ readonly width: number;
16
+ readonly height: number;
17
+ readonly centerX: number;
18
+ readonly centerY: number;
19
+ readonly exactCenterX: number;
20
+ readonly exactCenterY: number;
21
+ readonly isEmpty: boolean;
22
+ constructor(left: number, top: number, right: number, bottom: number, width: number, height: number, centerX: number, centerY: number, exactCenterX: number, exactCenterY: number, isEmpty: boolean);
23
+ /**
24
+ * 判断该 Bounds 是否在屏幕内(满足基本几何有效性)
25
+ * @returns {boolean}
26
+ */
27
+ isInScreen(): boolean;
28
+ static from(data: {
29
+ left: number;
30
+ top: number;
31
+ right: number;
32
+ bottom: number;
33
+ width: number;
34
+ height: number;
35
+ centerX: number;
36
+ centerY: number;
37
+ exactCenterX: number;
38
+ exactCenterY: number;
39
+ isEmpty: boolean;
40
+ }): Bounds;
41
+ static fromJSON(json: string): Bounds;
42
+ static fromData(data: any): Bounds;
43
+ toJSON(): {
44
+ left: number;
45
+ top: number;
46
+ right: number;
47
+ bottom: number;
48
+ width: number;
49
+ height: number;
50
+ centerX: number;
51
+ centerY: number;
52
+ exactCenterX: number;
53
+ exactCenterY: number;
54
+ isEmpty: boolean;
55
+ };
56
+ clone(): Bounds;
57
+ }
58
+
59
+ /**
60
+ * 节点类
61
+ * 表示界面上的一个可交互元素,包含元素的属性和可执行的操作
62
+ */
63
+
64
+ declare class NodeAsync {
65
+ private node;
66
+ /**
67
+ * 构造函数
68
+ * @param node Node实例
69
+ */
70
+ constructor(node: Node);
71
+ /**
72
+ * 查找第一个匹配标签的父节点
73
+ * @param className 类名
74
+ * @returns 父节点
75
+ */
76
+ findFirstParentByTags(className: string): Promise<Node>;
77
+ /**
78
+ * 对节点执行点击手势
79
+ * @param offsetX X轴偏移
80
+ * @param offsetY Y轴偏移
81
+ * @param switchWindowIntervalDelay 窗口切换延迟
82
+ * @param clickDuration 点击持续时间
83
+ * @returns 是否点击成功
84
+ */
85
+ clickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, }?: {
86
+ offsetX?: number;
87
+ offsetY?: number;
88
+ switchWindowIntervalDelay?: number;
89
+ clickDuration?: number;
90
+ }): Promise<boolean>;
91
+ /**
92
+ * 对节点执行双击手势
93
+ * @param offsetX X轴偏移
94
+ * @param offsetY Y轴偏移
95
+ * @param switchWindowIntervalDelay 窗口切换延迟
96
+ * @param clickDuration 点击持续时间
97
+ * @param clickInterval 点击间隔
98
+ * @returns 是否双击成功
99
+ */
100
+ doubleClickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, }?: {
101
+ offsetX?: number;
102
+ offsetY?: number;
103
+ switchWindowIntervalDelay?: number;
104
+ clickDuration?: number;
105
+ clickInterval?: number;
106
+ }): Promise<boolean>;
107
+ longPressNodeByGestureAutoPaste(text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
108
+ matchedPackageName?: string;
109
+ matchedText?: string;
110
+ timeoutMillis?: number;
111
+ longPressDuration?: number;
112
+ }): Promise<boolean>;
113
+ /**
114
+ * 在当前节点范围内通过标签查找节点
115
+ * @param className 类名
116
+ * @param filterText 文本过滤
117
+ * @param filterViewId 视图ID过滤
118
+ * @param filterDes 描述过滤
119
+ * @returns 节点数组
120
+ */
121
+ findByTags(className: string, { filterText, filterViewId, filterDes, }?: {
122
+ filterText?: string;
123
+ filterViewId?: string;
124
+ filterDes?: string;
125
+ }): Promise<Node[]>;
126
+ /**
127
+ * 在当前节点范围内通过ID查找节点
128
+ * @param id 节点ID
129
+ * @param filterClass 类名过滤
130
+ * @param filterText 文本过滤
131
+ * @param filterDes 描述过滤
132
+ * @returns 节点数组
133
+ */
134
+ findById(id: string, { filterClass, filterText, filterDes, }?: {
135
+ filterClass?: string;
136
+ filterText?: string;
137
+ filterDes?: string;
138
+ }): Promise<Node[]>;
139
+ /**
140
+ * 在当前节点范围内通过文本查找节点
141
+ * @param text 要查找的文本
142
+ * @param filterClass 类名过滤
143
+ * @param filterViewId 视图ID过滤
144
+ * @param filterDes 描述过滤
145
+ * @returns 节点数组
146
+ */
147
+ findByText(text: string, { filterClass, filterViewId, filterDes, }?: {
148
+ filterClass?: string;
149
+ filterViewId?: string;
150
+ filterDes?: string;
151
+ }): Promise<Node[]>;
152
+ /**
153
+ * 向前滚动节点
154
+ * @returns 是否滚动成功
155
+ */
156
+ scrollForward(): Promise<boolean>;
157
+ /**
158
+ * 向后滚动节点
159
+ * @returns 是否滚动成功
160
+ */
161
+ scrollBackward(): Promise<boolean>;
162
+ /**
163
+ * 检查节点是否可见
164
+ * @param compareNode 比较节点
165
+ * @param isFullyByCompareNode 是否完全可见
166
+ * @returns 是否可见
167
+ */
168
+ isVisible({ compareNode, isFullyByCompareNode, }?: {
169
+ compareNode?: Node;
170
+ isFullyByCompareNode?: boolean;
171
+ }): Promise<boolean>;
172
+ /**
173
+ * 对节点进行截图
174
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
175
+ * @returns 截图路径
176
+ */
177
+ takeScreenshot(overlayHiddenScreenshotDelayMillis?: number): Promise<string>;
178
+ /**
179
+ * 设置节点文本
180
+ * @param text 要设置的文本
181
+ * @returns 是否设置成功
182
+ */
183
+ setNodeText(text: string): Promise<boolean>;
184
+ paste(text: string): Promise<boolean>;
185
+ focus(): Promise<boolean>;
186
+ /**
187
+ * 点击节点
188
+ * @returns 是否点击成功
189
+ */
190
+ click(): Promise<boolean>;
191
+ /**
192
+ * 长按节点
193
+ * @returns 是否长按成功
194
+ */
195
+ longClick(): Promise<boolean>;
196
+ /**
197
+ * 查找第一个可点击的父节点
198
+ * @returns 可点击的父节点
199
+ */
200
+ findFirstParentClickable(): Promise<Node>;
201
+ /**
202
+ * 获取节点在屏幕中的边界
203
+ * @returns 边界对象
204
+ */
205
+ getBoundsInScreen(): Promise<Bounds>;
206
+ /**
207
+ * 获取节点的所有子节点
208
+ * @returns 子节点数组
209
+ */
210
+ getNodes(): Promise<Node[]>;
211
+ /**
212
+ * 获取节点的直接子节点
213
+ * @returns 子节点数组
214
+ */
215
+ getChildren(): Promise<Node[]>;
216
+ /**
217
+ * 从JSON字符串创建节点实例
218
+ * @param json JSON字符串
219
+ * @returns 节点实例
220
+ */
221
+ static fromJSON(json: string): Node;
222
+ /**
223
+ * 从普通对象创建节点实例
224
+ * @param data 对象数据
225
+ * @returns 节点实例
226
+ */
227
+ static from(data: any): Node;
228
+ /**
229
+ * JSON.parse的reviver函数,用于将解析的JSON对象转换为Node实例
230
+ * @param key 属性键
231
+ * @param value 属性值
232
+ * @returns 转换后的值
233
+ */
234
+ static reviver(key: string, value: any): any;
235
+ /**
236
+ * 创建新的节点实例
237
+ * @param params 节点参数对象
238
+ * @returns 节点实例
239
+ */
240
+ static create(params: {
241
+ nodeId: string;
242
+ text: string;
243
+ des: string;
244
+ viewId: string;
245
+ className: string;
246
+ isScrollable: boolean;
247
+ isClickable: boolean;
248
+ isEnabled: boolean;
249
+ stepId: string | undefined;
250
+ hintText: string;
251
+ isCheckable: boolean;
252
+ isChecked: boolean;
253
+ isFocusable: boolean;
254
+ isFocused: boolean;
255
+ isLongClickable: boolean;
256
+ isPassword: boolean;
257
+ isSelected: boolean;
258
+ isVisibleToUser: boolean;
259
+ drawingOrder: number;
260
+ bounds?: Bounds;
261
+ /** @deprecated 请使用 bounds 替代 */
262
+ boundsInScreen?: Bounds;
263
+ }): Node;
264
+ /**
265
+ * 从JSON数组创建节点数组
266
+ * @param array JSON数组
267
+ * @returns 节点数组
268
+ */
269
+ static fromJSONArray(array: Array<any>): Node[];
270
+ }
271
+
272
+ /**
273
+ * 节点类
274
+ * 表示界面上的一个可交互元素,包含元素的属性和可执行的操作
275
+ */
276
+
277
+ declare class Node {
278
+ /**
279
+ * 节点唯一标识
280
+ */
281
+ nodeId: string;
282
+ /**
283
+ * 节点文本内容
284
+ */
285
+ text: string;
286
+ /**
287
+ * 节点描述信息
288
+ */
289
+ des: string;
290
+ /**
291
+ * 节点视图ID
292
+ */
293
+ viewId: string;
294
+ /**
295
+ * 节点类名
296
+ */
297
+ className: string;
298
+ /**
299
+ * 是否可滚动
300
+ */
301
+ isScrollable: boolean;
302
+ /**
303
+ * 是否可点击
304
+ */
305
+ isClickable: boolean;
306
+ /**
307
+ * 是否启用
308
+ */
309
+ isEnabled: boolean;
310
+ /**
311
+ * 所属步骤ID
312
+ */
313
+ stepId: string | undefined;
314
+ /**
315
+ * 提示文本
316
+ */
317
+ hintText: string;
318
+ /**
319
+ * 是否可选择
320
+ */
321
+ isCheckable: boolean;
322
+ /**
323
+ * 是否已选中
324
+ */
325
+ isChecked: boolean;
326
+ /**
327
+ * 是否可聚焦
328
+ */
329
+ isFocusable: boolean;
330
+ /**
331
+ * 是否已聚焦
332
+ */
333
+ isFocused: boolean;
334
+ /**
335
+ * 是否可长按
336
+ */
337
+ isLongClickable: boolean;
338
+ /**
339
+ * 是否为密码字段
340
+ */
341
+ isPassword: boolean;
342
+ /**
343
+ * 是否已选中
344
+ */
345
+ isSelected: boolean;
346
+ /**
347
+ * 是否对用户可见
348
+ */
349
+ isVisibleToUser: boolean;
350
+ /**
351
+ * 绘制顺序
352
+ */
353
+ drawingOrder: number;
354
+ /**
355
+ * 节点在屏幕中的边界
356
+ */
357
+ bounds: Bounds;
358
+ /**
359
+ * 节点在屏幕中的边界
360
+ * @deprecated 请使用 bounds 字段替代
361
+ */
362
+ get boundsInScreen(): Bounds;
363
+ /**
364
+ * 构造函数
365
+ * @param params 节点参数对象
366
+ */
367
+ constructor(params: {
368
+ nodeId: string;
369
+ text: string;
370
+ des: string;
371
+ viewId: string;
372
+ className: string;
373
+ isScrollable: boolean;
374
+ isClickable: boolean;
375
+ isEnabled: boolean;
376
+ stepId: string | undefined;
377
+ hintText: string;
378
+ isCheckable: boolean;
379
+ isChecked: boolean;
380
+ isFocusable: boolean;
381
+ isFocused: boolean;
382
+ isLongClickable: boolean;
383
+ isPassword: boolean;
384
+ isSelected: boolean;
385
+ isVisibleToUser: boolean;
386
+ drawingOrder: number;
387
+ /** @deprecated 请使用 bounds 替代 */
388
+ boundsInScreen?: Bounds | any;
389
+ bounds?: Bounds | any;
390
+ });
391
+ get async(): NodeAsync;
392
+ /**
393
+ * 查找第一个匹配标签的父节点
394
+ * @param className 类名
395
+ * @returns 父节点
396
+ */
397
+ findFirstParentByTags(className: string): Node;
398
+ /**
399
+ * 对节点执行点击手势
400
+ * @param offsetX X轴偏移
401
+ * @param offsetY Y轴偏移
402
+ * @param switchWindowIntervalDelay 窗口切换延迟
403
+ * @param clickDuration 点击持续时间
404
+ * @returns 是否点击成功
405
+ */
406
+ clickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, }?: {
407
+ offsetX?: number;
408
+ offsetY?: number;
409
+ switchWindowIntervalDelay?: number;
410
+ clickDuration?: number;
411
+ }): Promise<boolean>;
412
+ /**
413
+ * 对节点执行双击手势
414
+ * @param offsetX X轴偏移
415
+ * @param offsetY Y轴偏移
416
+ * @param switchWindowIntervalDelay 窗口切换延迟
417
+ * @param clickDuration 点击持续时间
418
+ * @param clickInterval 点击间隔
419
+ * @returns 是否双击成功
420
+ */
421
+ doubleClickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, }?: {
422
+ offsetX?: number;
423
+ offsetY?: number;
424
+ switchWindowIntervalDelay?: number;
425
+ clickDuration?: number;
426
+ clickInterval?: number;
427
+ }): Promise<boolean>;
428
+ longPressNodeByGestureAutoPaste(text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
429
+ matchedPackageName?: string;
430
+ matchedText?: string;
431
+ timeoutMillis?: number;
432
+ longPressDuration?: number;
433
+ }): Promise<boolean>;
434
+ /**
435
+ * 在当前节点范围内通过标签查找节点
436
+ * @param className 类名
437
+ * @param filterText 文本过滤
438
+ * @param filterViewId 视图ID过滤
439
+ * @param filterDes 描述过滤
440
+ * @returns 节点数组
441
+ */
442
+ findByTags(className: string, { filterText, filterViewId, filterDes, }?: {
443
+ filterText?: string;
444
+ filterViewId?: string;
445
+ filterDes?: string;
446
+ }): Node[];
447
+ /**
448
+ * 在当前节点范围内通过ID查找节点
449
+ * @param id 节点ID
450
+ * @param filterClass 类名过滤
451
+ * @param filterText 文本过滤
452
+ * @param filterDes 描述过滤
453
+ * @returns 节点数组
454
+ */
455
+ findById(id: string, { filterClass, filterText, filterDes, }?: {
456
+ filterClass?: string;
457
+ filterText?: string;
458
+ filterDes?: string;
459
+ }): Node[];
460
+ /**
461
+ * 在当前节点范围内通过文本查找节点
462
+ * @param text 要查找的文本
463
+ * @param filterClass 类名过滤
464
+ * @param filterViewId 视图ID过滤
465
+ * @param filterDes 描述过滤
466
+ * @returns 节点数组
467
+ */
468
+ findByText(text: string, { filterClass, filterViewId, filterDes, }?: {
469
+ filterClass?: string;
470
+ filterViewId?: string;
471
+ filterDes?: string;
472
+ }): Node[];
473
+ /**
474
+ * 向前滚动节点
475
+ * @returns 是否滚动成功
476
+ */
477
+ scrollForward(): boolean;
478
+ /**
479
+ * 向后滚动节点
480
+ * @returns 是否滚动成功
481
+ */
482
+ scrollBackward(): boolean;
483
+ /**
484
+ * 检查节点是否可见
485
+ * @param compareNode 比较节点
486
+ * @param isFullyByCompareNode 是否完全可见
487
+ * @returns 是否可见
488
+ */
489
+ isVisible({ compareNode, isFullyByCompareNode, }?: {
490
+ compareNode?: Node;
491
+ isFullyByCompareNode?: boolean;
492
+ }): boolean;
493
+ /**
494
+ * 对节点进行截图
495
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
496
+ * @returns 截图路径
497
+ */
498
+ takeScreenshot(overlayHiddenScreenshotDelayMillis?: number): Promise<string>;
499
+ /**
500
+ * 保存节点截图到文件
501
+ * @param options 截图保存选项
502
+ * @param options.filePath 文件路径(可选,不提供则自动生成)
503
+ * @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认为 "PNG"
504
+ * @param options.overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒),默认为 250
505
+ * @returns 保存的文件路径
506
+ */
507
+ takeScreenshotToFile(options?: {
508
+ filePath?: string;
509
+ format?: "PNG" | "JPEG" | "JPG" | "WEBP";
510
+ overlayHiddenScreenshotDelayMillis?: number;
511
+ }): Promise<string>;
512
+ /**
513
+ * 设置节点文本
514
+ * @param text 要设置的文本
515
+ * @returns 是否设置成功
516
+ */
517
+ setNodeText(text: string): boolean;
518
+ paste(text: string): boolean;
519
+ focus(): boolean;
520
+ /**
521
+ * 点击节点
522
+ * @returns 是否点击成功
523
+ */
524
+ click(): boolean;
525
+ /**
526
+ * 长按节点
527
+ * @returns 是否长按成功
528
+ */
529
+ longClick(): boolean;
530
+ /**
531
+ * 查找第一个可点击的父节点
532
+ * @returns 可点击的父节点
533
+ */
534
+ findFirstParentClickable(): Node;
535
+ /**
536
+ * 获取节点在屏幕中的边界
537
+ * @returns 边界对象
538
+ */
539
+ getBoundsInScreen(): Bounds;
540
+ /**
541
+ * 获取节点的所有子节点
542
+ * @returns 子节点数组
543
+ */
544
+ getNodes(): Node[];
545
+ /**
546
+ * 获取节点的直接子节点
547
+ * @returns 子节点数组
548
+ */
549
+ getChildren(): Node[];
550
+ /**
551
+ * 从JSON字符串创建节点实例
552
+ * @param json JSON字符串
553
+ * @returns 节点实例
554
+ */
555
+ static fromJSON(json: string): Node;
556
+ /**
557
+ * 从普通对象创建节点实例
558
+ * @param data 对象数据
559
+ * @returns 节点实例
560
+ */
561
+ static from(data: any): Node;
562
+ /**
563
+ * JSON.parse的reviver函数,用于将解析的JSON对象转换为Node实例
564
+ * @param key 属性键
565
+ * @param value 属性值
566
+ * @returns 转换后的值
567
+ */
568
+ static reviver(key: string, value: any): any;
569
+ /**
570
+ * 创建新的节点实例
571
+ * @param params 节点参数对象
572
+ * @returns 节点实例
573
+ */
574
+ static create(params: {
575
+ nodeId: string;
576
+ text: string;
577
+ des: string;
578
+ viewId: string;
579
+ className: string;
580
+ isScrollable: boolean;
581
+ isClickable: boolean;
582
+ isEnabled: boolean;
583
+ stepId: string | undefined;
584
+ hintText: string;
585
+ isCheckable: boolean;
586
+ isChecked: boolean;
587
+ isFocusable: boolean;
588
+ isFocused: boolean;
589
+ isLongClickable: boolean;
590
+ isPassword: boolean;
591
+ isSelected: boolean;
592
+ isVisibleToUser: boolean;
593
+ drawingOrder: number;
594
+ bounds?: Bounds;
595
+ /** @deprecated 请使用 bounds 替代 */
596
+ boundsInScreen?: Bounds;
597
+ }): Node;
598
+ /**
599
+ * 从JSON数组创建节点数组
600
+ * @param array JSON数组
601
+ * @returns 节点数组
602
+ */
603
+ static fromJSONArray(array: Array<any>): Node[];
604
+ }
605
+
606
+ /**
607
+ * 步骤执行错误类
608
+ * 用于携带步骤执行过程中的错误信息和当前步骤对象
609
+ * 支持传入可选数据:message,data任何类型的数据
610
+ */
611
+ declare class StepError extends Error {
612
+ /**
613
+ * 步骤实现函数名
614
+ */
615
+ readonly impl?: string;
616
+ /**
617
+ * 步骤标签
618
+ */
619
+ readonly tag?: string | undefined;
620
+ /**
621
+ * 步骤数据,可以是任何类型
622
+ */
623
+ readonly data?: any;
624
+ /**
625
+ * 原始错误
626
+ */
627
+ readonly originalError?: any;
628
+ /**
629
+ * 当前步骤对象
630
+ */
631
+ readonly currentStep?: any;
632
+ constructor(message?: string, data?: any, impl?: string, tag?: string | undefined, originalError?: any, currentStep?: any | undefined);
633
+ }
634
+ /**
635
+ * 主动停止异常类
636
+ * 用于表示步骤被主动停止执行
637
+ */
638
+ declare class StepStopError extends StepError {
639
+ constructor(message?: string, data?: any);
640
+ }
641
+
642
+ declare class StepAsync {
643
+ private step;
644
+ /**
645
+ * 构造函数
646
+ * @param step Step实例
647
+ */
648
+ constructor(step: Step);
649
+ /**
650
+ * 对单个节点进行截图
651
+ * @param node 目标节点
652
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
653
+ * @returns 截图路径
654
+ */
655
+ takeScreenshotByNode(node: Node, overlayHiddenScreenshotDelayMillis?: number): Promise<string>;
656
+ /**
657
+ * 对多个节点进行截图
658
+ * @param nodes 目标节点数组
659
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
660
+ * @returns 截图路径数组
661
+ */
662
+ takeScreenshotNodes(nodes: Node[], overlayHiddenScreenshotDelayMillis?: number): Promise<string[]>;
663
+ /**
664
+ * 获取所有符合条件的节点
665
+ * @param filterClass 类名过滤
666
+ * @param filterViewId 视图ID过滤
667
+ * @param filterDes 描述过滤
668
+ * @param filterText 文本过滤
669
+ * @returns 节点数组
670
+ */
671
+ getAllNodes({ filterClass, filterViewId, filterDes, filterText, scope, }?: {
672
+ filterClass?: string;
673
+ filterViewId?: string;
674
+ filterDes?: string;
675
+ filterText?: string;
676
+ scope?: NodeLookupScope;
677
+ }): Promise<Node[]>;
678
+ /**
679
+ * 启动应用
680
+ * @param packageName 应用包名
681
+ * @returns 是否启动成功
682
+ */
683
+ launchApp(packageName: string): Promise<boolean>;
684
+ /**
685
+ * 获取当前应用包名
686
+ * @param timeout 超时时间(秒),默认30秒
687
+ */
688
+ getPackageName(timeout?: number): Promise<string>;
689
+ /**
690
+ * 获取当前应用包名
691
+ * @param options.timeout 超时时间(秒),默认30秒
692
+ * @param options.scope 节点查找范围(可选)
693
+ */
694
+ getPackageName(options: {
695
+ timeout?: number;
696
+ scope?: NodeLookupScope;
697
+ }): Promise<string>;
698
+ /**
699
+ * 通过ID查找节点
700
+ * @param id 节点ID
701
+ * @param filterClass 类名过滤
702
+ * @param filterText 文本过滤
703
+ * @param filterDes 描述过滤
704
+ * @returns 节点数组
705
+ */
706
+ findById(id: string, { filterClass, filterText, filterDes, scope, }?: {
707
+ filterClass?: string;
708
+ filterText?: string;
709
+ filterDes?: string;
710
+ scope?: NodeLookupScope;
711
+ }): Promise<Node[]>;
712
+ /**
713
+ * 通过文本查找节点
714
+ * @param text 要查找的文本
715
+ * @param filterClass 类名过滤
716
+ * @param filterViewId 视图ID过滤
717
+ * @param filterDes 描述过滤
718
+ * @returns 节点数组
719
+ */
720
+ findByText(text: string, { filterClass, filterViewId, filterDes, scope, }?: {
721
+ filterClass?: string;
722
+ filterViewId?: string;
723
+ filterDes?: string;
724
+ scope?: NodeLookupScope;
725
+ }): Promise<Node[]>;
726
+ /**
727
+ * 通过标签查找节点
728
+ * @param className 类名
729
+ * @param filterText 文本过滤
730
+ * @param filterViewId 视图ID过滤
731
+ * @param filterDes 描述过滤
732
+ * @returns 节点数组
733
+ */
734
+ findByTags(className: string, { filterText, filterViewId, filterDes, scope, }?: {
735
+ filterText?: string;
736
+ filterViewId?: string;
737
+ filterDes?: string;
738
+ scope?: NodeLookupScope;
739
+ }): Promise<Node[]>;
740
+ /**
741
+ * 查找所有匹配文本的节点
742
+ * @param text 要查找的文本
743
+ * @param timeout 超时时间(秒),默认30秒
744
+ */
745
+ findByTextAllMatch(text: string, timeout?: number): Promise<Node[]>;
746
+ /**
747
+ * 查找所有匹配文本的节点
748
+ * @param text 要查找的文本
749
+ * @param options.timeout 超时时间(秒),默认30秒
750
+ * @param options.scope 节点查找范围(可选)
751
+ */
752
+ findByTextAllMatch(text: string, options: {
753
+ timeout?: number;
754
+ scope?: NodeLookupScope;
755
+ }): Promise<Node[]>;
756
+ /**
757
+ * 检查是否包含指定文本
758
+ * @param text 要检查的文本
759
+ * @returns 是否包含
760
+ */
761
+ containsText(text: string): Promise<boolean>;
762
+ /**
763
+ * 获取所有文本
764
+ * @returns 文本数组
765
+ */
766
+ getAllText(): Promise<string[]>;
767
+ /**
768
+ * 执行点击手势
769
+ * @param x 横坐标
770
+ * @param y 纵坐标
771
+ * @param duration 持续时间(毫秒)
772
+ * @returns 是否成功
773
+ */
774
+ clickByGesture(x: number, y: number, duration: number): Promise<boolean>;
775
+ longPressGestureAutoPaste(point: {
776
+ x: number;
777
+ y: number;
778
+ }, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
779
+ matchedPackageName?: string;
780
+ matchedText?: string;
781
+ timeoutMillis?: number;
782
+ longPressDuration?: number;
783
+ }): Promise<boolean>;
784
+ getAppInfo(packageName: string): Promise<any>;
785
+ performLinearGesture(startPoint: {
786
+ x: number;
787
+ y: number;
788
+ }, endPoint: {
789
+ x: number;
790
+ y: number;
791
+ }, { duration }?: {
792
+ duration?: number;
793
+ }): Promise<boolean>;
794
+ /**
795
+ * 返回操作
796
+ * @returns 是否成功
797
+ */
798
+ back(): Promise<boolean>;
799
+ /**
800
+ * 回到主页
801
+ * @returns 是否成功
802
+ */
803
+ home(): Promise<boolean>;
804
+ /**
805
+ * 打开通知栏
806
+ * @returns 是否成功
807
+ */
808
+ notifications(): Promise<boolean>;
809
+ /**
810
+ * 显示最近应用
811
+ * @returns 是否成功
812
+ */
813
+ recentApps(): Promise<boolean>;
814
+ /**
815
+ * 获取屏幕尺寸
816
+ * @returns 屏幕尺寸对象
817
+ */
818
+ getScreenSize(): Promise<any>;
819
+ /**
820
+ * 获取应用窗口尺寸
821
+ * @returns 应用窗口尺寸对象
822
+ */
823
+ getAppScreenSize(): Promise<any>;
824
+ }
825
+
826
+ type StepData = Record<string, any>;
827
+ type StepResult = Step | undefined;
828
+ type StepImpl = (step: Step) => Promise<StepResult>;
829
+ type StepInterceptor = (step: Step) => StepResult | Promise<StepResult>;
830
+ declare class Step {
831
+ static delayMsDefault: number;
832
+ static readonly repeatCountInfinite: number;
833
+ static repeatCountMaxDefault: number;
834
+ static showLog: boolean;
835
+ static exceptionRetryCountMaxDefault: number;
836
+ /**
837
+ * 判断步骤数据是否有效(非空且为普通对象)
838
+ */
839
+ private static isValidStepData;
840
+ /**
841
+ * 解析步骤数据:优先使用传入值,否则使用当前值,均无效时返回空对象
842
+ */
843
+ private static resolveStepData;
844
+ /**
845
+ * 当前执行步骤的ID
846
+ */
847
+ private static _stepId;
848
+ /**
849
+ * 步骤拦截器列表
850
+ */
851
+ private static _interceptors;
852
+ /**
853
+ * 步骤异常变量,默认为空
854
+ */
855
+ static exception: StepError | undefined;
856
+ /**
857
+ * 运行步骤实现
858
+ * @param impl 步骤实现函数
859
+ * @param tag 步骤标签
860
+ * @param data 步骤数据
861
+ * @param delayMs 步骤延迟时间(毫秒)
862
+ */
863
+ static run(impl: StepImpl, { stepId, tag, data, delayMs, exceptionRetryCountMax, }?: {
864
+ stepId?: string | undefined;
865
+ tag?: string | undefined;
866
+ data?: StepData;
867
+ delayMs?: number;
868
+ exceptionRetryCountMax?: number;
869
+ }): Promise<Step | undefined>;
870
+ /**
871
+ * 获取当前步骤ID
872
+ */
873
+ static get stepId(): string | undefined;
874
+ /**
875
+ * 验证步骤ID是否匹配,如果不匹配则表示停止
876
+ * @param stepId 要验证的步骤ID
877
+ */
878
+ static assert(stepId: string | undefined): void;
879
+ /**
880
+ * 为节点数组分配步骤ID
881
+ * @param nodes 节点数组
882
+ * @param stepId 步骤ID
883
+ */
884
+ static assignIdsToNodes(nodes: Node[], stepId: string | undefined): void;
885
+ /**
886
+ * 停止当前步骤执行
887
+ * @param exception 可选的异常对象,如果传入则使用该异常,否则使用默认的StepStopError
888
+ */
889
+ static stop(exception?: StepError): void;
890
+ /**
891
+ * 添加步骤拦截器
892
+ * @param interceptor 拦截器函数
893
+ */
894
+ static addInterceptor(interceptor: StepInterceptor): void;
895
+ /**
896
+ * 移除步骤拦截器
897
+ * @param interceptor 要移除的拦截器函数
898
+ * @returns 是否成功删除
899
+ */
900
+ static removeInterceptor(interceptor: StepInterceptor): boolean;
901
+ /**
902
+ * 按索引移除步骤拦截器
903
+ * @param index 要移除的拦截器索引
904
+ * @returns 是否成功删除
905
+ */
906
+ static removeInterceptorByIndex(index: number): boolean;
907
+ /**
908
+ * 移除所有匹配的步骤拦截器
909
+ * @param interceptor 要移除的拦截器函数
910
+ * @returns 删除的拦截器数量
911
+ */
912
+ static removeAllInterceptors(interceptor: StepInterceptor): number;
913
+ /**
914
+ * 按条件移除步骤拦截器
915
+ * @param predicate 判断是否删除的条件函数
916
+ * @returns 删除的拦截器数量
917
+ */
918
+ static removeInterceptorByPredicate(predicate: (interceptor: StepInterceptor, index: number) => boolean): number;
919
+ /**
920
+ * 清空所有拦截器
921
+ */
922
+ static clearInterceptors(): void;
923
+ /**
924
+ * 获取所有拦截器
925
+ * @returns 拦截器数组
926
+ */
927
+ static getInterceptors(): StepInterceptor[];
928
+ /**
929
+ * 步骤ID
930
+ */
931
+ stepId: string;
932
+ /**
933
+ * 步骤重复执行次数
934
+ */
935
+ repeatCount: number;
936
+ /**
937
+ * 步骤重复执行最大次数,默认15次
938
+ */
939
+ repeatCountMax: number;
940
+ /**
941
+ * 异常重试次数
942
+ */
943
+ exceptionRetryCount: number;
944
+ /**
945
+ * 异常重试最大次数,默认3次
946
+ */
947
+ exceptionRetryCountMax: number;
948
+ /**
949
+ * 步骤标签
950
+ */
951
+ tag: string | undefined;
952
+ isEnd: boolean;
953
+ /**
954
+ * 步骤数据
955
+ */
956
+ data: StepData;
957
+ /**
958
+ * 步骤延迟时间(毫秒)
959
+ */
960
+ delayMs: number;
961
+ /**
962
+ * 步骤实现函数
963
+ */
964
+ impl: StepImpl | undefined;
965
+ /**
966
+ * 构造函数
967
+ * @param stepId 步骤ID
968
+ * @param impl 步骤实现函数
969
+ * @param tag 步骤标签
970
+ * @param data 步骤数据
971
+ * @param delayMs 步骤延迟时间(毫秒)
972
+ */
973
+ constructor({ stepId, impl, tag, data, delayMs, repeatCountMax, exceptionRetryCountMax, isEnd, }: {
974
+ stepId: string;
975
+ impl: StepImpl | undefined;
976
+ tag?: string | undefined;
977
+ data?: StepData;
978
+ delayMs?: number;
979
+ repeatCountMax?: number;
980
+ exceptionRetryCountMax?: number;
981
+ isEnd?: boolean;
982
+ });
983
+ get async(): StepAsync;
984
+ /**
985
+ * 创建下一个步骤
986
+ * @param impl 下一步骤实现函数
987
+ * @param tag 步骤标签
988
+ * @param data 步骤数据
989
+ * @param delayMs 步骤延迟时间(毫秒)
990
+ * @returns 新的步骤实例
991
+ */
992
+ next(impl: StepImpl, { tag, data, delayMs, repeatCountMax, exceptionRetryCountMax, }?: {
993
+ tag?: string | undefined;
994
+ data?: StepData;
995
+ delayMs?: number;
996
+ repeatCountMax?: number;
997
+ exceptionRetryCountMax?: number;
998
+ }): Step;
999
+ end({ tag, data, delayMs, repeatCountMax, exceptionRetryCountMax, }?: {
1000
+ tag?: string | undefined;
1001
+ data?: StepData;
1002
+ delayMs?: number;
1003
+ repeatCountMax?: number;
1004
+ exceptionRetryCountMax?: number;
1005
+ }): Step;
1006
+ /**
1007
+ * 重复当前步骤
1008
+ * @param stepId 步骤ID
1009
+ * @param tag 步骤标签
1010
+ * @param data 步骤数据
1011
+ * @param delayMs 步骤延迟时间(毫秒)
1012
+ * @returns 当前步骤实例
1013
+ */
1014
+ repeat({ stepId, tag, data, delayMs, repeatCountMax, exceptionRetryCountMax, }?: {
1015
+ stepId?: string;
1016
+ tag?: string | undefined;
1017
+ data?: StepData;
1018
+ delayMs?: number;
1019
+ repeatCountMax?: number;
1020
+ exceptionRetryCountMax?: number;
1021
+ }): Step;
1022
+ /**
1023
+ * 延迟执行
1024
+ * @param ms 延迟时间(毫秒)
1025
+ * @returns Promise
1026
+ */
1027
+ delay(ms: number): Promise<void>;
1028
+ /**
1029
+ * 等待异步方法执行完成
1030
+ * @param method 异步方法
1031
+ * @returns Promise<T>
1032
+ */
1033
+ await<T>(method: () => Promise<T>): Promise<T>;
1034
+ /**
1035
+ * 对单个节点进行截图
1036
+ * @param node 目标节点
1037
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
1038
+ * @returns 截图路径
1039
+ */
1040
+ takeScreenshotByNode(node: Node, overlayHiddenScreenshotDelayMillis?: number): Promise<string>;
1041
+ /**
1042
+ * 对多个节点进行截图
1043
+ * @param nodes 目标节点数组
1044
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
1045
+ * @returns 截图路径数组
1046
+ */
1047
+ takeScreenshotNodes(nodes: Node[], overlayHiddenScreenshotDelayMillis?: number): Promise<string[]>;
1048
+ /**
1049
+ * 获取所有符合条件的节点
1050
+ * @param filterClass 类名过滤
1051
+ * @param filterViewId 视图ID过滤
1052
+ * @param filterDes 描述过滤
1053
+ * @param filterText 文本过滤
1054
+ * @returns 节点数组
1055
+ */
1056
+ getAllNodes({ filterClass, filterViewId, filterDes, filterText, scope, }?: {
1057
+ filterClass?: string;
1058
+ filterViewId?: string;
1059
+ filterDes?: string;
1060
+ filterText?: string;
1061
+ scope?: NodeLookupScope;
1062
+ }): Node[];
1063
+ /**
1064
+ * 启动应用
1065
+ * @param packageName 应用包名
1066
+ * @returns 是否启动成功
1067
+ */
1068
+ launchApp(packageName: string): boolean;
1069
+ /**
1070
+ * 获取当前应用包名
1071
+ * @param options.scope 节点查找范围(可选)
1072
+ */
1073
+ getPackageName(options?: {
1074
+ scope?: NodeLookupScope;
1075
+ }): string;
1076
+ /**
1077
+ * 通过ID查找节点
1078
+ * @param id 节点ID
1079
+ * @param filterClass 类名过滤
1080
+ * @param filterText 文本过滤
1081
+ * @param filterDes 描述过滤
1082
+ * @returns 节点数组
1083
+ */
1084
+ findById(id: string, { filterClass, filterText, filterDes, scope, }?: {
1085
+ filterClass?: string;
1086
+ filterText?: string;
1087
+ filterDes?: string;
1088
+ scope?: NodeLookupScope;
1089
+ }): Node[];
1090
+ /**
1091
+ * 通过文本查找节点
1092
+ * @param text 要查找的文本
1093
+ * @param filterClass 类名过滤
1094
+ * @param filterViewId 视图ID过滤
1095
+ * @param filterDes 描述过滤
1096
+ * @returns 节点数组
1097
+ */
1098
+ findByText(text: string, { filterClass, filterViewId, filterDes, scope, }?: {
1099
+ filterClass?: string;
1100
+ filterViewId?: string;
1101
+ filterDes?: string;
1102
+ scope?: NodeLookupScope;
1103
+ }): Node[];
1104
+ /**
1105
+ * 通过标签查找节点
1106
+ * @param className 类名
1107
+ * @param filterText 文本过滤
1108
+ * @param filterViewId 视图ID过滤
1109
+ * @param filterDes 描述过滤
1110
+ * @returns 节点数组
1111
+ */
1112
+ findByTags(className: string, { filterText, filterViewId, filterDes, scope, }?: {
1113
+ filterText?: string;
1114
+ filterViewId?: string;
1115
+ filterDes?: string;
1116
+ scope?: NodeLookupScope;
1117
+ }): Node[];
1118
+ /**
1119
+ * 查找所有匹配文本的节点
1120
+ * @param text 要查找的文本
1121
+ * @param options.scope 节点查找范围(可选)
1122
+ */
1123
+ findByTextAllMatch(text: string, { scope }?: {
1124
+ scope?: NodeLookupScope;
1125
+ }): Node[];
1126
+ /**
1127
+ * 检查是否包含指定文本
1128
+ * @param text 要检查的文本
1129
+ * @returns 是否包含
1130
+ */
1131
+ containsText(text: string): boolean;
1132
+ /**
1133
+ * 获取所有文本
1134
+ * @returns 文本数组
1135
+ */
1136
+ getAllText(): string[];
1137
+ /**
1138
+ * 执行点击手势
1139
+ * @param x 横坐标
1140
+ * @param y 纵坐标
1141
+ * @param duration 持续时间(毫秒)
1142
+ * @returns 是否成功
1143
+ */
1144
+ clickByGesture(x: number, y: number, duration: number): Promise<boolean>;
1145
+ longPressGestureAutoPaste(point: {
1146
+ x: number;
1147
+ y: number;
1148
+ }, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
1149
+ matchedPackageName?: string;
1150
+ matchedText?: string;
1151
+ timeoutMillis?: number;
1152
+ longPressDuration?: number;
1153
+ }): Promise<boolean>;
1154
+ getAppInfo(packageName: string): Promise<any>;
1155
+ performLinearGesture(startPoint: {
1156
+ x: number;
1157
+ y: number;
1158
+ }, endPoint: {
1159
+ x: number;
1160
+ y: number;
1161
+ }, { duration }?: {
1162
+ duration?: number;
1163
+ }): Promise<boolean>;
1164
+ /**
1165
+ * 返回操作
1166
+ * @returns 是否成功
1167
+ */
1168
+ back(): boolean;
1169
+ /**
1170
+ * 回到主页
1171
+ * @returns 是否成功
1172
+ */
1173
+ home(): boolean;
1174
+ /**
1175
+ * 打开通知栏
1176
+ * @returns 是否成功
1177
+ */
1178
+ notifications(): boolean;
1179
+ /**
1180
+ * 显示最近应用
1181
+ * @returns 是否成功
1182
+ */
1183
+ recentApps(): boolean;
1184
+ /**
1185
+ * 获取屏幕尺寸
1186
+ * @returns 屏幕尺寸对象
1187
+ */
1188
+ getScreenSize(): any;
1189
+ /**
1190
+ * 获取应用窗口尺寸
1191
+ * @returns 应用窗口尺寸对象
1192
+ */
1193
+ getAppScreenSize(): any;
1194
+ }
1195
+
1196
+ export { Bounds as B, Node as N, Step as S, type NodeLookupScope as a, NODE_LOOKUP_SCOPE_ACTIVE_WINDOW as b, NODE_LOOKUP_SCOPE_ALL_WINDOWS as c, NodeAsync as d, StepAsync as e, type StepData as f, StepError as g, type StepImpl as h, type StepInterceptor as i, type StepResult as j, StepStopError as k };