assistsx-js 0.2.3 → 0.2.4

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/dist/index.d.mts CHANGED
@@ -1,448 +1,1937 @@
1
- import { N as Node, a as NodeLookupScope, B as Bounds } from './step-DnFA4DEb.mjs';
2
- export { b as NODE_LOOKUP_SCOPE_ACTIVE_WINDOW, c as NODE_LOOKUP_SCOPE_ALL_WINDOWS, d as NodeAsync, S as Step, e as StepAsync, f as StepData, g as StepError, h as StepImpl, i as StepInterceptor, j as StepResult, k as StepStopError } from './step-DnFA4DEb.mjs';
3
1
  import * as pinia from 'pinia';
4
2
 
5
- declare class CallResponse {
6
- readonly code: number;
7
- readonly data: any | null;
8
- readonly callbackId: string | null;
9
- constructor(code: number, data: any | null, callbackId: string | null);
10
- isSuccess(): boolean;
11
- getData(): any | null;
12
- getDataOrNull(): any | null;
13
- getDataOrDefault(defaultValue: any): any;
3
+ /**
4
+ * 与 Android AssistsCore.NodeLookupScope / HTTP scope 查询参数一致的字符串取值。
5
+ */
6
+ type NodeLookupScope = "active_window" | "all_windows";
7
+ /** AssistsCore.NodeLookupScope.ActiveWindow 对应 */
8
+ declare const NODE_LOOKUP_SCOPE_ACTIVE_WINDOW: NodeLookupScope;
9
+ /** AssistsCore.NodeLookupScope.AllWindows 对应 */
10
+ declare const NODE_LOOKUP_SCOPE_ALL_WINDOWS: NodeLookupScope;
11
+
12
+ declare class Bounds {
13
+ readonly left: number;
14
+ readonly top: number;
15
+ readonly right: number;
16
+ readonly bottom: number;
17
+ readonly width: number;
18
+ readonly height: number;
19
+ readonly centerX: number;
20
+ readonly centerY: number;
21
+ readonly exactCenterX: number;
22
+ readonly exactCenterY: number;
23
+ readonly isEmpty: boolean;
24
+ constructor(left: number, top: number, right: number, bottom: number, width: number, height: number, centerX: number, centerY: number, exactCenterX: number, exactCenterY: number, isEmpty: boolean);
25
+ /**
26
+ * 判断该 Bounds 是否在屏幕内(满足基本几何有效性)
27
+ * @returns {boolean}
28
+ */
29
+ isInScreen(): boolean;
30
+ static from(data: {
31
+ left: number;
32
+ top: number;
33
+ right: number;
34
+ bottom: number;
35
+ width: number;
36
+ height: number;
37
+ centerX: number;
38
+ centerY: number;
39
+ exactCenterX: number;
40
+ exactCenterY: number;
41
+ isEmpty: boolean;
42
+ }): Bounds;
43
+ static fromJSON(json: string): Bounds;
44
+ static fromData(data: any): Bounds;
45
+ toJSON(): {
46
+ left: number;
47
+ top: number;
48
+ right: number;
49
+ bottom: number;
50
+ width: number;
51
+ height: number;
52
+ centerX: number;
53
+ centerY: number;
54
+ exactCenterX: number;
55
+ exactCenterY: number;
56
+ isEmpty: boolean;
57
+ };
58
+ clone(): Bounds;
14
59
  }
15
60
 
16
61
  /**
17
- * AccessibilityEvent过滤配置接口
18
- * 用于配置AccessibilityEvent的处理方式和过滤条件
62
+ * 节点类
63
+ * 表示界面上的一个可交互元素,包含元素的属性和可执行的操作
19
64
  */
20
- interface AccessibilityEventFilterConfig {
65
+
66
+ declare class NodeAsync {
67
+ private node;
21
68
  /**
22
- * 包名过滤
23
- * 如果为空或null,则处理所有包的事件
24
- * 如果指定包名,则只处理该包的事件
69
+ * 构造函数
70
+ * @param node Node实例
25
71
  */
26
- packageName?: string | null;
72
+ constructor(node: Node);
27
73
  /**
28
- * 是否在子线程中处理AccessibilityEvent
29
- * true: 在子线程中处理,避免阻塞主线程
30
- * false: 在主线程中处理
74
+ * 查找第一个匹配标签的父节点
75
+ * @param className 类名
76
+ * @returns 父节点
31
77
  */
32
- processInBackground?: boolean;
78
+ findFirstParentByTags(className: string): Promise<Node>;
33
79
  /**
34
- * 是否获取节点信息
35
- * true: 获取并解析AccessibilityNodeInfo节点信息
36
- * false: 不获取节点信息,提高处理性能
80
+ * 对节点执行点击手势
81
+ * @param offsetX X轴偏移
82
+ * @param offsetY Y轴偏移
83
+ * @param switchWindowIntervalDelay 窗口切换延迟
84
+ * @param clickDuration 点击持续时间
85
+ * @returns 是否点击成功
37
86
  */
38
- fetchNodeInfo?: boolean;
87
+ clickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, }?: {
88
+ offsetX?: number;
89
+ offsetY?: number;
90
+ switchWindowIntervalDelay?: number;
91
+ clickDuration?: number;
92
+ }): Promise<boolean>;
39
93
  /**
40
- * 是否启用日志输出
41
- * true: 输出AccessibilityEvent处理日志
42
- * false: 不输出日志
94
+ * 对节点执行双击手势
95
+ * @param offsetX X轴偏移
96
+ * @param offsetY Y轴偏移
97
+ * @param switchWindowIntervalDelay 窗口切换延迟
98
+ * @param clickDuration 点击持续时间
99
+ * @param clickInterval 点击间隔
100
+ * @returns 是否双击成功
43
101
  */
44
- enableLogging?: boolean;
102
+ doubleClickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, }?: {
103
+ offsetX?: number;
104
+ offsetY?: number;
105
+ switchWindowIntervalDelay?: number;
106
+ clickDuration?: number;
107
+ clickInterval?: number;
108
+ }): Promise<boolean>;
109
+ longPressNodeByGestureAutoPaste(text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
110
+ matchedPackageName?: string;
111
+ matchedText?: string;
112
+ timeoutMillis?: number;
113
+ longPressDuration?: number;
114
+ }): Promise<boolean>;
45
115
  /**
46
- * 事件类型过滤
47
- * 如果为空,则处理所有类型的事件
48
- * 如果指定类型,则只处理指定类型的事件
116
+ * 在当前节点范围内通过标签查找节点
117
+ * @param className 类名
118
+ * @param filterText 文本过滤
119
+ * @param filterViewId 视图ID过滤
120
+ * @param filterDes 描述过滤
121
+ * @returns 节点数组
49
122
  */
50
- eventTypes?: number[] | null;
123
+ findByTags(className: string, { filterText, filterViewId, filterDes, }?: {
124
+ filterText?: string;
125
+ filterViewId?: string;
126
+ filterDes?: string;
127
+ }): Promise<Node[]>;
51
128
  /**
52
- * 是否启用事件去重
53
- * true: 启用去重,避免重复处理相同事件
54
- * false: 不启用去重
129
+ * 在当前节点范围内通过ID查找节点
130
+ * @param id 节点ID
131
+ * @param filterClass 类名过滤
132
+ * @param filterText 文本过滤
133
+ * @param filterDes 描述过滤
134
+ * @returns 节点数组
55
135
  */
56
- enableDeduplication?: boolean;
57
- }
58
- /**
59
- * AccessibilityEvent过滤配置类
60
- * 用于配置AccessibilityEvent的处理方式和过滤条件
61
- */
62
- declare class AccessibilityEventFilter {
136
+ findById(id: string, { filterClass, filterText, filterDes, }?: {
137
+ filterClass?: string;
138
+ filterText?: string;
139
+ filterDes?: string;
140
+ }): Promise<Node[]>;
63
141
  /**
64
- * 包名过滤
142
+ * 在当前节点范围内通过文本查找节点
143
+ * @param text 要查找的文本
144
+ * @param filterClass 类名过滤
145
+ * @param filterViewId 视图ID过滤
146
+ * @param filterDes 描述过滤
147
+ * @returns 节点数组
65
148
  */
66
- readonly packageName: string | null;
149
+ findByText(text: string, { filterClass, filterViewId, filterDes, }?: {
150
+ filterClass?: string;
151
+ filterViewId?: string;
152
+ filterDes?: string;
153
+ }): Promise<Node[]>;
67
154
  /**
68
- * 是否在子线程中处理AccessibilityEvent
155
+ * 向前滚动节点
156
+ * @returns 是否滚动成功
69
157
  */
70
- readonly processInBackground: boolean;
158
+ scrollForward(): Promise<boolean>;
71
159
  /**
72
- * 是否获取节点信息
160
+ * 向后滚动节点
161
+ * @returns 是否滚动成功
73
162
  */
74
- readonly fetchNodeInfo: boolean;
163
+ scrollBackward(): Promise<boolean>;
75
164
  /**
76
- * 是否启用日志输出
165
+ * 检查节点是否可见
166
+ * @param compareNode 比较节点
167
+ * @param isFullyByCompareNode 是否完全可见
168
+ * @returns 是否可见
77
169
  */
78
- readonly enableLogging: boolean;
170
+ isVisible({ compareNode, isFullyByCompareNode, }?: {
171
+ compareNode?: Node;
172
+ isFullyByCompareNode?: boolean;
173
+ }): Promise<boolean>;
79
174
  /**
80
- * 事件类型过滤
175
+ * 对节点进行截图
176
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
177
+ * @returns 截图路径
81
178
  */
82
- readonly eventTypes?: number[] | null;
179
+ takeScreenshot(overlayHiddenScreenshotDelayMillis?: number): Promise<string>;
83
180
  /**
84
- * 是否启用事件去重
181
+ * 设置节点文本
182
+ * @param text 要设置的文本
183
+ * @returns 是否设置成功
85
184
  */
86
- readonly enableDeduplication: boolean;
87
- constructor(config?: AccessibilityEventFilterConfig);
185
+ setNodeText(text: string): Promise<boolean>;
186
+ paste(text: string): Promise<boolean>;
187
+ focus(): Promise<boolean>;
88
188
  /**
89
- * 检查是否应该处理指定包的事件
90
- * @param targetPackageName 目标包名
91
- * @returns true表示应该处理,false表示应该过滤
189
+ * 点击节点
190
+ * @returns 是否点击成功
92
191
  */
93
- shouldProcessPackage(targetPackageName: string | null): boolean;
192
+ click(): Promise<boolean>;
94
193
  /**
95
- * 检查是否应该处理指定类型的事件
96
- * @param eventType 事件类型
97
- * @returns true表示应该处理,false表示应该过滤
194
+ * 长按节点
195
+ * @returns 是否长按成功
98
196
  */
99
- shouldProcessEventType(eventType: number): boolean;
197
+ longClick(): Promise<boolean>;
100
198
  /**
101
- * 创建默认的过滤配置
102
- * 所有包名,子线程处理,获取节点信息,启用日志
199
+ * 查找第一个可点击的父节点
200
+ * @returns 可点击的父节点
103
201
  */
104
- static createDefault(): AccessibilityEventFilter;
202
+ findFirstParentClickable(): Promise<Node>;
105
203
  /**
106
- * 创建高性能配置
107
- * 不获取节点信息,不启用日志,启用去重
204
+ * 获取节点在屏幕中的边界
205
+ * @returns 边界对象
108
206
  */
109
- static createHighPerformance(): AccessibilityEventFilter;
207
+ getBoundsInScreen(): Promise<Bounds>;
110
208
  /**
111
- * 创建调试配置
112
- * 启用所有功能,便于调试
209
+ * 获取节点的所有子节点
210
+ * @returns 子节点数组
113
211
  */
114
- static createDebug(): AccessibilityEventFilter;
212
+ getNodes(): Promise<Node[]>;
115
213
  /**
116
- * 创建指定包名的过滤配置
117
- * @param targetPackageName 目标包名
214
+ * 获取节点的直接子节点
215
+ * @returns 子节点数组
118
216
  */
119
- static createForPackage(targetPackageName: string): AccessibilityEventFilter;
217
+ getChildren(): Promise<Node[]>;
218
+ /**
219
+ * 从JSON字符串创建节点实例
220
+ * @param json JSON字符串
221
+ * @returns 节点实例
222
+ */
223
+ static fromJSON(json: string): Node;
224
+ /**
225
+ * 从普通对象创建节点实例
226
+ * @param data 对象数据
227
+ * @returns 节点实例
228
+ */
229
+ static from(data: any): Node;
230
+ /**
231
+ * JSON.parse的reviver函数,用于将解析的JSON对象转换为Node实例
232
+ * @param key 属性键
233
+ * @param value 属性值
234
+ * @returns 转换后的值
235
+ */
236
+ static reviver(key: string, value: any): any;
237
+ /**
238
+ * 创建新的节点实例
239
+ * @param params 节点参数对象
240
+ * @returns 节点实例
241
+ */
242
+ static create(params: {
243
+ nodeId: string;
244
+ text: string;
245
+ des: string;
246
+ viewId: string;
247
+ className: string;
248
+ isScrollable: boolean;
249
+ isClickable: boolean;
250
+ isEnabled: boolean;
251
+ stepId: string | undefined;
252
+ hintText: string;
253
+ isCheckable: boolean;
254
+ isChecked: boolean;
255
+ isFocusable: boolean;
256
+ isFocused: boolean;
257
+ isLongClickable: boolean;
258
+ isPassword: boolean;
259
+ isSelected: boolean;
260
+ isVisibleToUser: boolean;
261
+ drawingOrder: number;
262
+ bounds?: Bounds;
263
+ /** @deprecated 请使用 bounds 替代 */
264
+ boundsInScreen?: Bounds;
265
+ }): Node;
266
+ /**
267
+ * 从JSON数组创建节点数组
268
+ * @param array JSON数组
269
+ * @returns 节点数组
270
+ */
271
+ static fromJSONArray(array: Array<any>): Node[];
120
272
  }
121
273
 
122
274
  /**
123
- * 应用信息实体类
275
+ * 节点类
276
+ * 表示界面上的一个可交互元素,包含元素的属性和可执行的操作
124
277
  */
125
- declare class AppInfo {
278
+
279
+ declare class Node {
126
280
  /**
127
- * 是否为系统应用
281
+ * 节点唯一标识
128
282
  */
129
- isSystem: boolean;
283
+ nodeId: string;
130
284
  /**
131
- * 最低SDK版本
285
+ * 节点文本内容
132
286
  */
133
- minSdkVersion: number;
287
+ text: string;
134
288
  /**
135
- * 应用名称
289
+ * 节点描述信息
136
290
  */
137
- name: string;
291
+ des: string;
138
292
  /**
139
- * 应用包名
293
+ * 节点视图ID
140
294
  */
141
- packageName: string;
295
+ viewId: string;
142
296
  /**
143
- * 目标SDK版本
297
+ * 节点类名
144
298
  */
145
- targetSdkVersion: number;
299
+ className: string;
146
300
  /**
147
- * 版本号
301
+ * 是否可滚动
148
302
  */
149
- versionCode: number;
303
+ isScrollable: boolean;
150
304
  /**
151
- * 版本名称
305
+ * 是否可点击
152
306
  */
153
- versionName: string;
154
- constructor(isSystem?: boolean, minSdkVersion?: number, name?: string, packageName?: string, targetSdkVersion?: number, versionCode?: number, versionName?: string);
307
+ isClickable: boolean;
155
308
  /**
156
- * 从JSON对象创建AppInfo实例
157
- * @param data JSON对象
158
- * @returns AppInfo实例
309
+ * 是否启用
159
310
  */
160
- static fromJSON(data: any): AppInfo;
311
+ isEnabled: boolean;
161
312
  /**
162
- * 转换为JSON对象
163
- * @returns JSON对象
313
+ * 所属步骤ID
164
314
  */
165
- toJSON(): any;
166
- }
167
-
168
- /**
169
- * 设备信息实体类
170
- */
171
- declare class DeviceInfo {
315
+ stepId: string | undefined;
172
316
  /**
173
- * 设备唯一标识
317
+ * 提示文本
174
318
  */
175
- uniqueDeviceId: string;
319
+ hintText: string;
176
320
  /**
177
- * Android ID
321
+ * 是否可选择
178
322
  */
179
- androidID: string;
323
+ isCheckable: boolean;
180
324
  /**
181
- * MAC地址
325
+ * 是否已选中
182
326
  */
183
- macAddress: string;
327
+ isChecked: boolean;
184
328
  /**
185
- * 是否已Root
329
+ * 是否可聚焦
186
330
  */
187
- isDeviceRooted: boolean;
331
+ isFocusable: boolean;
188
332
  /**
189
- * 制造商
333
+ * 是否已聚焦
190
334
  */
191
- manufacturer: string;
335
+ isFocused: boolean;
192
336
  /**
193
- * 设备型号
337
+ * 是否可长按
194
338
  */
195
- model: string;
339
+ isLongClickable: boolean;
196
340
  /**
197
- * SDK版本号
341
+ * 是否为密码字段
198
342
  */
199
- sdkVersionCode: number;
343
+ isPassword: boolean;
200
344
  /**
201
- * SDK版本名称
345
+ * 是否已选中
202
346
  */
203
- sdkVersionName: string;
347
+ isSelected: boolean;
204
348
  /**
205
- * ABI列表
349
+ * 是否对用户可见
206
350
  */
207
- abiList: string[];
351
+ isVisibleToUser: boolean;
208
352
  /**
209
- * 是否启用ADB调试
353
+ * 绘制顺序
210
354
  */
211
- isAdbEnabled: boolean;
355
+ drawingOrder: number;
212
356
  /**
213
- * 是否启用开发者选项
357
+ * 节点在屏幕中的边界
214
358
  */
215
- isDevelopmentSettingsEnabled: boolean;
359
+ bounds: Bounds;
216
360
  /**
217
- * 是否为模拟器
361
+ * 节点在屏幕中的边界
362
+ * @deprecated 请使用 bounds 字段替代
218
363
  */
219
- isEmulator: boolean;
364
+ get boundsInScreen(): Bounds;
220
365
  /**
221
- * 是否为平板
366
+ * 构造函数
367
+ * @param params 节点参数对象
222
368
  */
223
- isTablet: boolean;
224
- constructor(uniqueDeviceId?: string, androidID?: string, macAddress?: string, isDeviceRooted?: boolean, manufacturer?: string, model?: string, sdkVersionCode?: number, sdkVersionName?: string, abiList?: string[], isAdbEnabled?: boolean, isDevelopmentSettingsEnabled?: boolean, isEmulator?: boolean, isTablet?: boolean);
369
+ constructor(params: {
370
+ nodeId: string;
371
+ text: string;
372
+ des: string;
373
+ viewId: string;
374
+ className: string;
375
+ isScrollable: boolean;
376
+ isClickable: boolean;
377
+ isEnabled: boolean;
378
+ stepId: string | undefined;
379
+ hintText: string;
380
+ isCheckable: boolean;
381
+ isChecked: boolean;
382
+ isFocusable: boolean;
383
+ isFocused: boolean;
384
+ isLongClickable: boolean;
385
+ isPassword: boolean;
386
+ isSelected: boolean;
387
+ isVisibleToUser: boolean;
388
+ drawingOrder: number;
389
+ /** @deprecated 请使用 bounds 替代 */
390
+ boundsInScreen?: Bounds | any;
391
+ bounds?: Bounds | any;
392
+ });
393
+ get async(): NodeAsync;
225
394
  /**
226
- * 从JSON对象创建DeviceInfo实例
227
- * @param data JSON对象
228
- * @returns DeviceInfo实例
395
+ * 查找第一个匹配标签的父节点
396
+ * @param className 类名
397
+ * @returns 父节点
229
398
  */
230
- static fromJSON(data: any): DeviceInfo;
399
+ findFirstParentByTags(className: string): Node;
231
400
  /**
232
- * 转换为JSON对象
233
- * @returns JSON对象
401
+ * 对节点执行点击手势
402
+ * @param offsetX X轴偏移
403
+ * @param offsetY Y轴偏移
404
+ * @param switchWindowIntervalDelay 窗口切换延迟
405
+ * @param clickDuration 点击持续时间
406
+ * @returns 是否点击成功
234
407
  */
235
- toJSON(): any;
236
- }
237
-
238
- /**
239
- * AssistsX 类
240
- * 提供与移动应用程序界面交互的工具类,包括节点查找、手势操作、屏幕操作等功能
241
- */
242
-
243
- /**
244
- * 无障碍事件数据结构
245
- */
246
- interface AccessibilityEventData {
247
- packageName: string;
248
- className: string;
249
- eventType: number;
250
- action: number;
251
- texts: string[];
252
- node: Node | null;
253
- }
408
+ clickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, }?: {
409
+ offsetX?: number;
410
+ offsetY?: number;
411
+ switchWindowIntervalDelay?: number;
412
+ clickDuration?: number;
413
+ }): Promise<boolean>;
414
+ /**
415
+ * 对节点执行双击手势
416
+ * @param offsetX X轴偏移
417
+ * @param offsetY Y轴偏移
418
+ * @param switchWindowIntervalDelay 窗口切换延迟
419
+ * @param clickDuration 点击持续时间
420
+ * @param clickInterval 点击间隔
421
+ * @returns 是否双击成功
422
+ */
423
+ doubleClickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, }?: {
424
+ offsetX?: number;
425
+ offsetY?: number;
426
+ switchWindowIntervalDelay?: number;
427
+ clickDuration?: number;
428
+ clickInterval?: number;
429
+ }): Promise<boolean>;
430
+ longPressNodeByGestureAutoPaste(text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
431
+ matchedPackageName?: string;
432
+ matchedText?: string;
433
+ timeoutMillis?: number;
434
+ longPressDuration?: number;
435
+ }): Promise<boolean>;
436
+ /**
437
+ * 在当前节点范围内通过标签查找节点
438
+ * @param className 类名
439
+ * @param filterText 文本过滤
440
+ * @param filterViewId 视图ID过滤
441
+ * @param filterDes 描述过滤
442
+ * @returns 节点数组
443
+ */
444
+ findByTags(className: string, { filterText, filterViewId, filterDes, }?: {
445
+ filterText?: string;
446
+ filterViewId?: string;
447
+ filterDes?: string;
448
+ }): Node[];
449
+ /**
450
+ * 在当前节点范围内通过ID查找节点
451
+ * @param id 节点ID
452
+ * @param filterClass 类名过滤
453
+ * @param filterText 文本过滤
454
+ * @param filterDes 描述过滤
455
+ * @returns 节点数组
456
+ */
457
+ findById(id: string, { filterClass, filterText, filterDes, }?: {
458
+ filterClass?: string;
459
+ filterText?: string;
460
+ filterDes?: string;
461
+ }): Node[];
462
+ /**
463
+ * 在当前节点范围内通过文本查找节点
464
+ * @param text 要查找的文本
465
+ * @param filterClass 类名过滤
466
+ * @param filterViewId 视图ID过滤
467
+ * @param filterDes 描述过滤
468
+ * @returns 节点数组
469
+ */
470
+ findByText(text: string, { filterClass, filterViewId, filterDes, }?: {
471
+ filterClass?: string;
472
+ filterViewId?: string;
473
+ filterDes?: string;
474
+ }): Node[];
475
+ /**
476
+ * 向前滚动节点
477
+ * @returns 是否滚动成功
478
+ */
479
+ scrollForward(): boolean;
480
+ /**
481
+ * 向后滚动节点
482
+ * @returns 是否滚动成功
483
+ */
484
+ scrollBackward(): boolean;
485
+ /**
486
+ * 检查节点是否可见
487
+ * @param compareNode 比较节点
488
+ * @param isFullyByCompareNode 是否完全可见
489
+ * @returns 是否可见
490
+ */
491
+ isVisible({ compareNode, isFullyByCompareNode, }?: {
492
+ compareNode?: Node;
493
+ isFullyByCompareNode?: boolean;
494
+ }): boolean;
495
+ /**
496
+ * 对节点进行截图
497
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
498
+ * @returns 截图路径
499
+ */
500
+ takeScreenshot(overlayHiddenScreenshotDelayMillis?: number): Promise<string>;
501
+ /**
502
+ * 保存节点截图到文件
503
+ * @param options 截图保存选项
504
+ * @param options.filePath 文件路径(可选,不提供则自动生成)
505
+ * @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认为 "PNG"
506
+ * @param options.overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒),默认为 250
507
+ * @returns 保存的文件路径
508
+ */
509
+ takeScreenshotToFile(options?: {
510
+ filePath?: string;
511
+ format?: "PNG" | "JPEG" | "JPG" | "WEBP";
512
+ overlayHiddenScreenshotDelayMillis?: number;
513
+ }): Promise<string>;
514
+ /**
515
+ * 设置节点文本
516
+ * @param text 要设置的文本
517
+ * @returns 是否设置成功
518
+ */
519
+ setNodeText(text: string): boolean;
520
+ paste(text: string): boolean;
521
+ focus(): boolean;
522
+ /**
523
+ * 点击节点
524
+ * @returns 是否点击成功
525
+ */
526
+ click(): boolean;
527
+ /**
528
+ * 长按节点
529
+ * @returns 是否长按成功
530
+ */
531
+ longClick(): boolean;
532
+ /**
533
+ * 查找第一个可点击的父节点
534
+ * @returns 可点击的父节点
535
+ */
536
+ findFirstParentClickable(): Node;
537
+ /**
538
+ * 获取节点在屏幕中的边界
539
+ * @returns 边界对象
540
+ */
541
+ getBoundsInScreen(): Bounds;
542
+ /**
543
+ * 获取节点的所有子节点
544
+ * @returns 子节点数组
545
+ */
546
+ getNodes(): Node[];
547
+ /**
548
+ * 获取节点的直接子节点
549
+ * @returns 子节点数组
550
+ */
551
+ getChildren(): Node[];
552
+ /**
553
+ * 从JSON字符串创建节点实例
554
+ * @param json JSON字符串
555
+ * @returns 节点实例
556
+ */
557
+ static fromJSON(json: string): Node;
558
+ /**
559
+ * 从普通对象创建节点实例
560
+ * @param data 对象数据
561
+ * @returns 节点实例
562
+ */
563
+ static from(data: any): Node;
564
+ /**
565
+ * JSON.parse的reviver函数,用于将解析的JSON对象转换为Node实例
566
+ * @param key 属性键
567
+ * @param value 属性值
568
+ * @returns 转换后的值
569
+ */
570
+ static reviver(key: string, value: any): any;
571
+ /**
572
+ * 创建新的节点实例
573
+ * @param params 节点参数对象
574
+ * @returns 节点实例
575
+ */
576
+ static create(params: {
577
+ nodeId: string;
578
+ text: string;
579
+ des: string;
580
+ viewId: string;
581
+ className: string;
582
+ isScrollable: boolean;
583
+ isClickable: boolean;
584
+ isEnabled: boolean;
585
+ stepId: string | undefined;
586
+ hintText: string;
587
+ isCheckable: boolean;
588
+ isChecked: boolean;
589
+ isFocusable: boolean;
590
+ isFocused: boolean;
591
+ isLongClickable: boolean;
592
+ isPassword: boolean;
593
+ isSelected: boolean;
594
+ isVisibleToUser: boolean;
595
+ drawingOrder: number;
596
+ bounds?: Bounds;
597
+ /** @deprecated 请使用 bounds 替代 */
598
+ boundsInScreen?: Bounds;
599
+ }): Node;
600
+ /**
601
+ * 从JSON数组创建节点数组
602
+ * @param array JSON数组
603
+ * @returns 节点数组
604
+ */
605
+ static fromJSONArray(array: Array<any>): Node[];
606
+ }
607
+
608
+ declare class CallResponse {
609
+ readonly code: number;
610
+ readonly data: any | null;
611
+ readonly callbackId: string | null;
612
+ constructor(code: number, data: any | null, callbackId: string | null);
613
+ isSuccess(): boolean;
614
+ getData(): any | null;
615
+ getDataOrNull(): any | null;
616
+ getDataOrDefault(defaultValue: any): any;
617
+ }
618
+
254
619
  /**
255
- * 无障碍事件完整结构
620
+ * AccessibilityEvent过滤配置接口
621
+ * 用于配置AccessibilityEvent的处理方式和过滤条件
256
622
  */
257
- interface AccessibilityEvent {
258
- callbackId: string;
259
- code: number;
260
- data: AccessibilityEventData;
261
- message: string;
623
+ interface AccessibilityEventFilterConfig {
624
+ /**
625
+ * 包名过滤
626
+ * 如果为空或null,则处理所有包的事件
627
+ * 如果指定包名,则只处理该包的事件
628
+ */
629
+ packageName?: string | null;
630
+ /**
631
+ * 是否在子线程中处理AccessibilityEvent
632
+ * true: 在子线程中处理,避免阻塞主线程
633
+ * false: 在主线程中处理
634
+ */
635
+ processInBackground?: boolean;
636
+ /**
637
+ * 是否获取节点信息
638
+ * true: 获取并解析AccessibilityNodeInfo节点信息
639
+ * false: 不获取节点信息,提高处理性能
640
+ */
641
+ fetchNodeInfo?: boolean;
642
+ /**
643
+ * 是否启用日志输出
644
+ * true: 输出AccessibilityEvent处理日志
645
+ * false: 不输出日志
646
+ */
647
+ enableLogging?: boolean;
648
+ /**
649
+ * 事件类型过滤
650
+ * 如果为空,则处理所有类型的事件
651
+ * 如果指定类型,则只处理指定类型的事件
652
+ */
653
+ eventTypes?: number[] | null;
654
+ /**
655
+ * 是否启用事件去重
656
+ * true: 启用去重,避免重复处理相同事件
657
+ * false: 不启用去重
658
+ */
659
+ enableDeduplication?: boolean;
660
+ }
661
+ /**
662
+ * AccessibilityEvent过滤配置类
663
+ * 用于配置AccessibilityEvent的处理方式和过滤条件
664
+ */
665
+ declare class AccessibilityEventFilter {
666
+ /**
667
+ * 包名过滤
668
+ */
669
+ readonly packageName: string | null;
670
+ /**
671
+ * 是否在子线程中处理AccessibilityEvent
672
+ */
673
+ readonly processInBackground: boolean;
674
+ /**
675
+ * 是否获取节点信息
676
+ */
677
+ readonly fetchNodeInfo: boolean;
678
+ /**
679
+ * 是否启用日志输出
680
+ */
681
+ readonly enableLogging: boolean;
682
+ /**
683
+ * 事件类型过滤
684
+ */
685
+ readonly eventTypes?: number[] | null;
686
+ /**
687
+ * 是否启用事件去重
688
+ */
689
+ readonly enableDeduplication: boolean;
690
+ constructor(config?: AccessibilityEventFilterConfig);
691
+ /**
692
+ * 检查是否应该处理指定包的事件
693
+ * @param targetPackageName 目标包名
694
+ * @returns true表示应该处理,false表示应该过滤
695
+ */
696
+ shouldProcessPackage(targetPackageName: string | null): boolean;
697
+ /**
698
+ * 检查是否应该处理指定类型的事件
699
+ * @param eventType 事件类型
700
+ * @returns true表示应该处理,false表示应该过滤
701
+ */
702
+ shouldProcessEventType(eventType: number): boolean;
703
+ /**
704
+ * 创建默认的过滤配置
705
+ * 所有包名,子线程处理,获取节点信息,启用日志
706
+ */
707
+ static createDefault(): AccessibilityEventFilter;
708
+ /**
709
+ * 创建高性能配置
710
+ * 不获取节点信息,不启用日志,启用去重
711
+ */
712
+ static createHighPerformance(): AccessibilityEventFilter;
713
+ /**
714
+ * 创建调试配置
715
+ * 启用所有功能,便于调试
716
+ */
717
+ static createDebug(): AccessibilityEventFilter;
718
+ /**
719
+ * 创建指定包名的过滤配置
720
+ * @param targetPackageName 目标包名
721
+ */
722
+ static createForPackage(targetPackageName: string): AccessibilityEventFilter;
262
723
  }
724
+
725
+ /**
726
+ * 应用信息实体类
727
+ */
728
+ declare class AppInfo {
729
+ /**
730
+ * 是否为系统应用
731
+ */
732
+ isSystem: boolean;
733
+ /**
734
+ * 最低SDK版本
735
+ */
736
+ minSdkVersion: number;
737
+ /**
738
+ * 应用名称
739
+ */
740
+ name: string;
741
+ /**
742
+ * 应用包名
743
+ */
744
+ packageName: string;
745
+ /**
746
+ * 目标SDK版本
747
+ */
748
+ targetSdkVersion: number;
749
+ /**
750
+ * 版本号
751
+ */
752
+ versionCode: number;
753
+ /**
754
+ * 版本名称
755
+ */
756
+ versionName: string;
757
+ constructor(isSystem?: boolean, minSdkVersion?: number, name?: string, packageName?: string, targetSdkVersion?: number, versionCode?: number, versionName?: string);
758
+ /**
759
+ * 从JSON对象创建AppInfo实例
760
+ * @param data JSON对象
761
+ * @returns AppInfo实例
762
+ */
763
+ static fromJSON(data: any): AppInfo;
764
+ /**
765
+ * 转换为JSON对象
766
+ * @returns JSON对象
767
+ */
768
+ toJSON(): any;
769
+ }
770
+
771
+ /**
772
+ * AssistsX 当前运行插件信息(由宿主拦截 getCurrentPlugin 返回)
773
+ */
774
+ declare class PluginInfo {
775
+ id: string;
776
+ name: string;
777
+ packageName: string;
778
+ versionName: string;
779
+ versionCode: number;
780
+ description: string;
781
+ path: string;
782
+ index: string;
783
+ port: number;
784
+ needScreenCapture: boolean;
785
+ constructor(id?: string, name?: string, packageName?: string, versionName?: string, versionCode?: number, description?: string, path?: string, index?: string, port?: number, needScreenCapture?: boolean);
786
+ static fromJSON(data: unknown): PluginInfo;
787
+ toJSON(): Record<string, unknown>;
788
+ }
789
+
790
+ /**
791
+ * 设备信息实体类
792
+ */
793
+ declare class DeviceInfo {
794
+ /**
795
+ * 设备唯一标识
796
+ */
797
+ uniqueDeviceId: string;
798
+ /**
799
+ * Android ID
800
+ */
801
+ androidID: string;
802
+ /**
803
+ * MAC地址
804
+ */
805
+ macAddress: string;
806
+ /**
807
+ * 是否已Root
808
+ */
809
+ isDeviceRooted: boolean;
810
+ /**
811
+ * 制造商
812
+ */
813
+ manufacturer: string;
814
+ /**
815
+ * 设备型号
816
+ */
817
+ model: string;
818
+ /**
819
+ * SDK版本号
820
+ */
821
+ sdkVersionCode: number;
822
+ /**
823
+ * SDK版本名称
824
+ */
825
+ sdkVersionName: string;
826
+ /**
827
+ * ABI列表
828
+ */
829
+ abiList: string[];
830
+ /**
831
+ * 是否启用ADB调试
832
+ */
833
+ isAdbEnabled: boolean;
834
+ /**
835
+ * 是否启用开发者选项
836
+ */
837
+ isDevelopmentSettingsEnabled: boolean;
838
+ /**
839
+ * 是否为模拟器
840
+ */
841
+ isEmulator: boolean;
842
+ /**
843
+ * 是否为平板
844
+ */
845
+ isTablet: boolean;
846
+ constructor(uniqueDeviceId?: string, androidID?: string, macAddress?: string, isDeviceRooted?: boolean, manufacturer?: string, model?: string, sdkVersionCode?: number, sdkVersionName?: string, abiList?: string[], isAdbEnabled?: boolean, isDevelopmentSettingsEnabled?: boolean, isEmulator?: boolean, isTablet?: boolean);
847
+ /**
848
+ * 从JSON对象创建DeviceInfo实例
849
+ * @param data JSON对象
850
+ * @returns DeviceInfo实例
851
+ */
852
+ static fromJSON(data: any): DeviceInfo;
853
+ /**
854
+ * 转换为JSON对象
855
+ * @returns JSON对象
856
+ */
857
+ toJSON(): any;
858
+ }
859
+
860
+ /**
861
+ * AssistsX 类
862
+ * 提供与移动应用程序界面交互的工具类,包括节点查找、手势操作、屏幕操作等功能
863
+ */
864
+
865
+ /**
866
+ * 无障碍事件数据结构
867
+ */
868
+ interface AccessibilityEventData {
869
+ packageName: string;
870
+ className: string;
871
+ eventType: number;
872
+ action: number;
873
+ texts: string[];
874
+ node: Node | null;
875
+ }
876
+ /**
877
+ * 无障碍事件完整结构
878
+ */
879
+ interface AccessibilityEvent {
880
+ callbackId: string;
881
+ code: number;
882
+ data: AccessibilityEventData;
883
+ message: string;
884
+ }
885
+ /**
886
+ * 无障碍事件监听器类型
887
+ */
888
+ type AccessibilityEventListener = (event: AccessibilityEvent) => void;
889
+ /**
890
+ * Web浮动窗口选项接口定义
891
+ */
892
+ interface WebFloatingWindowOptions {
893
+ initialWidth?: number;
894
+ initialHeight?: number;
895
+ /** Initial window X position (default 0) */
896
+ initialX?: number;
897
+ /** Initial window Y position (default 0) */
898
+ initialY?: number;
899
+ minWidth?: number;
900
+ minHeight?: number;
901
+ maxWidth?: number;
902
+ maxHeight?: number;
903
+ initialCenter?: boolean;
904
+ /** Whether to show top operation area (title bar, close button, etc.) */
905
+ showTopOperationArea?: boolean;
906
+ /** Whether to show bottom operation area (zoom, back/forward/refresh, etc.) */
907
+ showBottomOperationArea?: boolean;
908
+ /** Background color: hex string (e.g. "#ffffff") or Android color int */
909
+ backgroundColor?: string | number;
910
+ }
911
+ declare const callbacks: Map<string, (data: string) => void>;
912
+ declare const accessibilityEventListeners: AccessibilityEventListener[];
913
+ /**
914
+ * 屏幕尺寸类型(width/height 为整型像素值)
915
+ */
916
+ interface Screen {
917
+ width: number;
918
+ height: number;
919
+ }
920
+ /** 全局屏幕尺寸,在 assistsxCallback 初始化后自动加载 */
921
+ declare let screen: Screen;
922
+ declare class AssistsX {
923
+ /**
924
+ * 屏幕尺寸(与全局变量 screen 同源)
925
+ * @deprecated 已过时,请使用全局变量 {@link screen}
926
+ */
927
+ static get screenSize(): any;
928
+ /**
929
+ * 执行同步调用
930
+ * @param method 方法名
931
+ * @param args 参数对象
932
+ * @returns 调用响应
933
+ */
934
+ static call(method: string, { args, node }?: {
935
+ args?: any;
936
+ node?: Node;
937
+ }): CallResponse;
938
+ /**
939
+ * 执行异步调用
940
+ * @param method 方法名
941
+ * @param args 参数对象
942
+ * @param timeout 超时时间(秒),默认30秒
943
+ * @returns Promise<调用响应>
944
+ */
945
+ static asyncCall(method: string, { args, node, nodes, timeout, }?: {
946
+ args?: any;
947
+ node?: Node;
948
+ nodes?: Node[];
949
+ timeout?: number;
950
+ }): Promise<CallResponse>;
951
+ /**
952
+ * 设置悬浮窗标志
953
+ * @param flags 标志
954
+ * @returns 是否设置成功
955
+ */
956
+ static setOverlayFlags(flags: number): boolean;
957
+ /**
958
+ * 设置悬浮窗标志
959
+ * @param flags 标志
960
+ * @returns 是否设置成功
961
+ */
962
+ static setOverlayFlagList(flags: number[]): boolean;
963
+ /**
964
+ * 设置悬浮窗可获取焦点(WebView 内输入框 focus 时调用)
965
+ * @returns 是否设置成功
966
+ */
967
+ static setOverlayInputFocus(): boolean;
968
+ /**
969
+ * 取消悬浮窗焦点(WebView 内输入框 blur 时调用)
970
+ * @returns 是否设置成功
971
+ */
972
+ static clearOverlayInputFocus(): boolean;
973
+ /**
974
+ * 获取所有符合条件的节点
975
+ * @param filterClass 类名过滤
976
+ * @param filterViewId 视图ID过滤
977
+ * @param filterDes 描述过滤
978
+ * @param filterText 文本过滤
979
+ * @returns 节点数组
980
+ */
981
+ static getAllNodes({ filterClass, filterViewId, filterDes, filterText, scope, }?: {
982
+ filterClass?: string;
983
+ filterViewId?: string;
984
+ filterDes?: string;
985
+ filterText?: string;
986
+ scope?: NodeLookupScope;
987
+ }): Node[];
988
+ /**
989
+ * 设置节点文本
990
+ * @param node 目标节点
991
+ * @param text 要设置的文本
992
+ * @returns 是否设置成功
993
+ */
994
+ static setNodeText(node: Node, text: string): boolean;
995
+ /**
996
+ * 获取剪贴板最新文本
997
+ * @returns 剪贴板最新文本
998
+ */
999
+ static getClipboardLatestText(): any;
1000
+ /**
1001
+ * 获取剪贴板文本内容(异步)
1002
+ * @param timeout 超时时间(秒),默认30秒
1003
+ * @returns 剪贴板文本内容,如果获取失败则返回空字符串
1004
+ */
1005
+ static getClipboardText(timeout?: number): Promise<string>;
1006
+ /**
1007
+ * 在浏览器中打开URL
1008
+ * @param url 要打开的URL
1009
+ * @returns 是否成功打开
1010
+ */
1011
+ static openUrlInBrowser(url: string): boolean;
1012
+ /**
1013
+ * 保持屏幕常亮
1014
+ * @param tip 提示文本
1015
+ * @returns 是否保持屏幕常亮成功
1016
+ */
1017
+ static keepScreenOn(tip?: string): boolean;
1018
+ static clearKeepScreenOn(): boolean;
1019
+ static isAppInstalled(packageName: string): boolean;
1020
+ /**
1021
+ * 对指定节点进行截图
1022
+ * @param nodes 要截图的节点数组
1023
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
1024
+ * @param timeout 超时时间(秒),默认30秒
1025
+ * @returns 截图路径数组
1026
+ */
1027
+ static takeScreenshotNodes(nodes: Node[], overlayHiddenScreenshotDelayMillis?: number, timeout?: number): Promise<string[]>;
1028
+ static scanQR(timeout?: number): Promise<string>;
1029
+ static loadWebViewOverlay(url: string, options?: WebFloatingWindowOptions & {
1030
+ timeout?: number;
1031
+ }): Promise<any>;
1032
+ /**
1033
+ * 点击节点
1034
+ * @param node 要点击的节点
1035
+ * @returns 是否点击成功
1036
+ */
1037
+ static click(node: Node): boolean;
1038
+ /**
1039
+ * 长按节点
1040
+ * @param node 要长按的节点
1041
+ * @returns 是否长按成功
1042
+ */
1043
+ static longClick(node: Node): boolean;
1044
+ /**
1045
+ * 启动应用
1046
+ * @param packageName 应用包名
1047
+ * @returns 是否启动成功
1048
+ */
1049
+ static launchApp(packageName: string): boolean;
1050
+ /**
1051
+ * 获取当前应用包名
1052
+ * @returns 包名
1053
+ */
1054
+ static getPackageName(options?: {
1055
+ scope?: NodeLookupScope;
1056
+ }): string;
1057
+ /**
1058
+ * 显示悬浮提示
1059
+ * @param text 提示文本
1060
+ * @param delay 显示时长(毫秒)
1061
+ * @returns 是否显示成功
1062
+ */
1063
+ static overlayToast(text: string, delay?: number): boolean;
1064
+ /**
1065
+ * 通过ID查找节点
1066
+ * @param id 节点ID
1067
+ * @param filterClass 类名过滤
1068
+ * @param filterText 文本过滤
1069
+ * @param filterDes 描述过滤
1070
+ * @param node 父节点范围
1071
+ * @returns 节点数组
1072
+ */
1073
+ static findById(id: string, { filterClass, filterText, filterDes, node, scope, }?: {
1074
+ filterClass?: string;
1075
+ filterText?: string;
1076
+ filterDes?: string;
1077
+ node?: Node;
1078
+ scope?: NodeLookupScope;
1079
+ }): Node[];
1080
+ /**
1081
+ * 通过文本查找节点
1082
+ * @param text 要查找的文本
1083
+ * @param filterClass 类名过滤
1084
+ * @param filterViewId 视图ID过滤
1085
+ * @param filterDes 描述过滤
1086
+ * @param node 父节点范围
1087
+ * @returns 节点数组
1088
+ */
1089
+ static findByText(text: string, { filterClass, filterViewId, filterDes, node, scope, }?: {
1090
+ filterClass?: string;
1091
+ filterViewId?: string;
1092
+ filterDes?: string;
1093
+ node?: Node;
1094
+ scope?: NodeLookupScope;
1095
+ }): Node[];
1096
+ /**
1097
+ * 通过标签查找节点
1098
+ * @param className 类名
1099
+ * @param filterText 文本过滤
1100
+ * @param filterViewId 视图ID过滤
1101
+ * @param filterDes 描述过滤
1102
+ * @param node 父节点范围
1103
+ * @returns 节点数组
1104
+ */
1105
+ static findByTags(className: string, { filterText, filterViewId, filterDes, node, scope, }?: {
1106
+ filterText?: string;
1107
+ filterViewId?: string;
1108
+ filterDes?: string;
1109
+ node?: Node;
1110
+ scope?: NodeLookupScope;
1111
+ }): Node[];
1112
+ /**
1113
+ * 查找所有匹配文本的节点
1114
+ * @param text 要查找的文本
1115
+ * @param options.scope 节点查找范围(可选)
1116
+ */
1117
+ static findByTextAllMatch(text: string, { scope }?: {
1118
+ scope?: NodeLookupScope;
1119
+ }): Node[];
1120
+ /**
1121
+ * 检查是否包含指定文本
1122
+ * @param text 要检查的文本
1123
+ * @returns 是否包含
1124
+ */
1125
+ static containsText(text: string): boolean;
1126
+ /**
1127
+ * 获取所有文本
1128
+ * @returns 文本数组
1129
+ */
1130
+ static getAllText(): string[];
1131
+ /**
1132
+ * 查找第一个匹配标签的父节点
1133
+ * @param className 类名
1134
+ * @returns 父节点
1135
+ */
1136
+ static findFirstParentByTags(node: Node, className: string): Node;
1137
+ /**
1138
+ * 获取节点的所有子节点
1139
+ * @param node 父节点
1140
+ * @returns 子节点数组
1141
+ */
1142
+ static getNodes(node: Node): Node[];
1143
+ /**
1144
+ * 获取节点的直接子节点
1145
+ * @param node 父节点
1146
+ * @returns 子节点数组
1147
+ */
1148
+ static getChildren(node: Node): Node[];
1149
+ /**
1150
+ * 查找第一个可点击的父节点
1151
+ * @param node 起始节点
1152
+ * @returns 可点击的父节点
1153
+ */
1154
+ static findFirstParentClickable(node: Node): Node;
1155
+ /**
1156
+ * 获取节点在屏幕中的边界
1157
+ * @param node 目标节点
1158
+ * @returns 边界对象
1159
+ */
1160
+ static getBoundsInScreen(node: Node): Bounds;
1161
+ /**
1162
+ * 检查节点是否可见
1163
+ * @param node 目标节点
1164
+ * @param compareNode 比较节点
1165
+ * @param isFullyByCompareNode 是否完全可见
1166
+ * @returns 是否可见
1167
+ */
1168
+ static isVisible(node: Node, { compareNode, isFullyByCompareNode, }?: {
1169
+ compareNode?: Node;
1170
+ isFullyByCompareNode?: boolean;
1171
+ }): boolean;
1172
+ /**
1173
+ * 执行点击手势
1174
+ * @param x 横坐标
1175
+ * @param y 纵坐标
1176
+ * @param duration 持续时间
1177
+ * @param timeout 超时时间(秒),默认30秒
1178
+ * @returns 是否成功
1179
+ */
1180
+ static clickByGesture(x: number, y: number, duration: number, timeout?: number): Promise<boolean>;
1181
+ /**
1182
+ * 返回操作
1183
+ * @returns 是否成功
1184
+ */
1185
+ static back(): boolean;
1186
+ /**
1187
+ * 回到主页
1188
+ * @returns 是否成功
1189
+ */
1190
+ static home(): boolean;
1191
+ /**
1192
+ * 打开通知栏
1193
+ * @returns 是否成功
1194
+ */
1195
+ static notifications(): boolean;
1196
+ /**
1197
+ * 显示最近应用
1198
+ * @returns 是否成功
1199
+ */
1200
+ static recentApps(): boolean;
1201
+ /**
1202
+ * 在节点中粘贴文本
1203
+ * @param node 目标节点
1204
+ * @param text 要粘贴的文本
1205
+ * @returns 是否成功
1206
+ */
1207
+ static paste(node: Node, text: string): boolean;
1208
+ static focus(node: Node): boolean;
1209
+ /**
1210
+ * 选择文本
1211
+ * @param node 目标节点
1212
+ * @param selectionStart 选择起始位置
1213
+ * @param selectionEnd 选择结束位置
1214
+ * @returns 是否成功
1215
+ */
1216
+ static selectionText(node: Node, selectionStart: number, selectionEnd: number): boolean;
1217
+ /**
1218
+ * 向前滚动
1219
+ * @param node 可滚动节点
1220
+ * @returns 是否成功
1221
+ */
1222
+ static scrollForward(node: Node): boolean;
1223
+ /**
1224
+ * 向后滚动
1225
+ * @param node 可滚动节点
1226
+ * @returns 是否成功
1227
+ */
1228
+ static scrollBackward(node: Node): boolean;
1229
+ /**
1230
+ * 对节点执行点击手势
1231
+ * @param node 目标节点
1232
+ * @param offsetX X轴偏移
1233
+ * @param offsetY Y轴偏移
1234
+ * @param switchWindowIntervalDelay 窗口切换延迟
1235
+ * @param clickDuration 点击持续时间
1236
+ * @param timeout 超时时间(秒),默认30秒
1237
+ * @returns 是否成功
1238
+ */
1239
+ static clickNodeByGesture(node: Node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, timeout, }?: {
1240
+ offsetX?: number;
1241
+ offsetY?: number;
1242
+ switchWindowIntervalDelay?: number;
1243
+ clickDuration?: number;
1244
+ timeout?: number;
1245
+ }): Promise<boolean>;
1246
+ /**
1247
+ * 对节点执行双击手势
1248
+ * @param node 目标节点
1249
+ * @param offsetX X轴偏移
1250
+ * @param offsetY Y轴偏移
1251
+ * @param switchWindowIntervalDelay 窗口切换延迟
1252
+ * @param clickDuration 点击持续时间
1253
+ * @param clickInterval 点击间隔
1254
+ * @param timeout 超时时间(秒),默认30秒
1255
+ * @returns 是否成功
1256
+ */
1257
+ static doubleClickNodeByGesture(node: Node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, timeout, }?: {
1258
+ offsetX?: number;
1259
+ offsetY?: number;
1260
+ switchWindowIntervalDelay?: number;
1261
+ clickDuration?: number;
1262
+ clickInterval?: number;
1263
+ timeout?: number;
1264
+ }): Promise<boolean>;
1265
+ /**
1266
+ * 执行线型手势
1267
+ * @param startPoint
1268
+ * @param endPoint
1269
+ * @param param2
1270
+ * @param timeout 超时时间(秒),默认30秒
1271
+ * @returns
1272
+ */
1273
+ static performLinearGesture(startPoint: {
1274
+ x: number;
1275
+ y: number;
1276
+ }, endPoint: {
1277
+ x: number;
1278
+ y: number;
1279
+ }, { duration, timeout }?: {
1280
+ duration?: number;
1281
+ timeout?: number;
1282
+ }): Promise<boolean>;
1283
+ static longPressNodeByGestureAutoPaste(node: Node, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, timeout, }?: {
1284
+ matchedPackageName?: string;
1285
+ matchedText?: string;
1286
+ timeoutMillis?: number;
1287
+ longPressDuration?: number;
1288
+ timeout?: number;
1289
+ }): Promise<boolean>;
1290
+ static longPressGestureAutoPaste(point: {
1291
+ x: number;
1292
+ y: number;
1293
+ }, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, timeout, }?: {
1294
+ matchedPackageName?: string;
1295
+ matchedText?: string;
1296
+ timeoutMillis?: number;
1297
+ longPressDuration?: number;
1298
+ timeout?: number;
1299
+ }): Promise<boolean>;
1300
+ static getAppInfo(packageName: string, timeout?: number): Promise<AppInfo>;
1301
+ /**
1302
+ * 获取当前运行的 AssistsX 插件信息(仅 AssistsX 宿主有效,否则返回 null)
1303
+ */
1304
+ static getCurrentPlugin(): PluginInfo | null;
1305
+ static getUniqueDeviceId(): any;
1306
+ static getAndroidID(): any;
1307
+ static getMacAddress(timeout?: number): Promise<any>;
1308
+ static getDeviceInfo(timeout?: number): Promise<DeviceInfo>;
1309
+ static getNetworkType(timeout?: number): Promise<any>;
1310
+ /**
1311
+ * 播放系统电话铃声
1312
+ * @param timeout 超时时间(秒),默认30秒
1313
+ * @returns 播放结果消息
1314
+ */
1315
+ static audioPlayRingtone(timeout?: number): Promise<string>;
1316
+ /**
1317
+ * 停止播放系统电话铃声
1318
+ * @param timeout 超时时间(秒),默认30秒
1319
+ * @returns 停止结果消息
1320
+ */
1321
+ static audioStopRingtone(timeout?: number): Promise<string>;
1322
+ static setAccessibilityEventFilters(value: AccessibilityEventFilter[]): Promise<any>;
1323
+ static addAccessibilityEventFilter(value: AccessibilityEventFilter): Promise<any>;
1324
+ /**
1325
+ * 获取屏幕尺寸
1326
+ * @returns 屏幕尺寸对象(width, height)
1327
+ */
1328
+ static getScreenSize(): Screen | null;
1329
+ /**
1330
+ * 获取应用窗口尺寸
1331
+ * @returns 应用窗口尺寸对象
1332
+ */
1333
+ static getAppScreenSize(): any;
1334
+ /**
1335
+ * 添加无障碍事件监听器
1336
+ * @param listener 监听器函数
1337
+ */
1338
+ static addAccessibilityEventListener(listener: AccessibilityEventListener): void;
1339
+ /**
1340
+ * 判断是否包含无障碍事件监听器
1341
+ * @param listener 监听器函数
1342
+ * @returns 是否包含
1343
+ */
1344
+ static containsAccessibilityEventListener(listener: AccessibilityEventListener): boolean;
1345
+ /**
1346
+ * 移除无障碍事件监听器
1347
+ * @param listener 要移除的监听器函数
1348
+ * @returns 是否移除成功
1349
+ */
1350
+ static removeAccessibilityEventListener(listener: AccessibilityEventListener): boolean;
1351
+ /**
1352
+ * 移除所有无障碍事件监听器
1353
+ */
1354
+ static removeAllAccessibilityEventListeners(): void;
1355
+ /**
1356
+ * 获取当前注册的无障碍事件监听器数量
1357
+ * @returns 监听器数量
1358
+ */
1359
+ static getAccessibilityEventListenerCount(): number;
1360
+ }
1361
+
1362
+ declare const CallMethod: {
1363
+ readonly takeScreenshot: "takeScreenshot";
1364
+ readonly takeScreenshotSave: "takeScreenshotSave";
1365
+ readonly takeScreenshotToFile: "takeScreenshotToFile";
1366
+ readonly overlayToast: "overlayToast";
1367
+ readonly setNodeText: "setNodeText";
1368
+ readonly findByTags: "findByTags";
1369
+ readonly findById: "findById";
1370
+ readonly findByText: "findByText";
1371
+ readonly findByTextAllMatch: "findByTextAllMatch";
1372
+ readonly containsText: "containsText";
1373
+ readonly getAllText: "getAllText";
1374
+ readonly findFirstParentByTags: "findFirstParentByTags";
1375
+ readonly getAllNodes: "getAllNodes";
1376
+ readonly getNodes: "getNodes";
1377
+ readonly findFirstParentClickable: "findFirstParentClickable";
1378
+ readonly getChildren: "getChildren";
1379
+ readonly getBoundsInScreen: "getBoundsInScreen";
1380
+ readonly isVisible: "isVisible";
1381
+ readonly click: "click";
1382
+ readonly longClick: "longClick";
1383
+ readonly back: "back";
1384
+ readonly home: "home";
1385
+ readonly notifications: "notifications";
1386
+ readonly recentApps: "recentApps";
1387
+ readonly paste: "paste";
1388
+ readonly focus: "focus";
1389
+ readonly selectionText: "selectionText";
1390
+ readonly scrollForward: "scrollForward";
1391
+ readonly launchApp: "launchApp";
1392
+ readonly getPackageName: "getPackageName";
1393
+ readonly getScreenSize: "getScreenSize";
1394
+ readonly getAppScreenSize: "getAppScreenSize";
1395
+ readonly scrollBackward: "scrollBackward";
1396
+ readonly setOverlayFlags: "setOverlayFlags";
1397
+ readonly scanQR: "scanQR";
1398
+ readonly loadWebViewOverlay: "loadWebViewOverlay";
1399
+ readonly closeOverlay: "closeOverlay";
1400
+ readonly recognizeTextInScreenshot: "recognizeTextInScreenshot";
1401
+ readonly clickByGesture: "clickByGesture";
1402
+ readonly clickNodeByGesture: "clickNodeByGesture";
1403
+ readonly doubleClickNodeByGesture: "doubleClickNodeByGesture";
1404
+ readonly performLinearGesture: "performLinearGesture";
1405
+ readonly longPressGestureAutoPaste: "longPressGestureAutoPaste";
1406
+ readonly getAppInfo: "getAppInfo";
1407
+ readonly getCurrentPlugin: "getCurrentPlugin";
1408
+ readonly getMacAddress: "getMacAddress";
1409
+ readonly getAndroidID: "getAndroidID";
1410
+ readonly getUniqueDeviceId: "getUniqueDeviceId";
1411
+ readonly addAccessibilityEventFilter: "addAccessibilityEventFilter";
1412
+ readonly setAccessibilityEventFilters: "setAccessibilityEventFilters";
1413
+ readonly httpRequest: "httpRequest";
1414
+ readonly getDeviceInfo: "getDeviceInfo";
1415
+ readonly getNetworkType: "getNetworkType";
1416
+ readonly isAppInstalled: "isAppInstalled";
1417
+ readonly getClipboardLatestText: "getClipboardLatestText";
1418
+ readonly getClipboardText: "getClipboardText";
1419
+ readonly openUrlInBrowser: "openUrlInBrowser";
1420
+ readonly keepScreenOn: "keepScreenOn";
1421
+ readonly clearKeepScreenOn: "clearKeepScreenOn";
1422
+ readonly download: "download";
1423
+ readonly audioPlayFromFile: "audioPlayFromFile";
1424
+ readonly audioStop: "audioStop";
1425
+ readonly audioPlayRingtone: "audioPlayRingtone";
1426
+ readonly audioStopRingtone: "audioStopRingtone";
1427
+ readonly addContact: "addContact";
1428
+ readonly getAllContacts: "getAllContacts";
1429
+ readonly saveRootNodeTreeJson: "saveRootNodeTreeJson";
1430
+ };
1431
+ type CallMethodType = (typeof CallMethod)[keyof typeof CallMethod];
1432
+
263
1433
  /**
264
- * 无障碍事件监听器类型
1434
+ * Android 视图类型常量
265
1435
  */
266
- type AccessibilityEventListener = (event: AccessibilityEvent) => void;
1436
+ declare const NodeClassValue: {
1437
+ readonly ImageView: "android.widget.ImageView";
1438
+ readonly TextView: "android.widget.TextView";
1439
+ readonly LinearLayout: "android.widget.LinearLayout";
1440
+ readonly RelativeLayout: "android.widget.RelativeLayout";
1441
+ readonly Button: "android.widget.Button";
1442
+ readonly ImageButton: "android.widget.ImageButton";
1443
+ readonly EditText: "android.widget.EditText";
1444
+ readonly View: "android.view.View";
1445
+ readonly ViewGroup: "android.view.ViewGroup";
1446
+ readonly FrameLayout: "android.widget.FrameLayout";
1447
+ };
1448
+
1449
+ declare function sleep(ms: number): Promise<void>;
1450
+ declare function generateUUID(): string;
1451
+ declare function decodeBase64UTF8(base64: string): string;
1452
+
267
1453
  /**
268
- * Web浮动窗口选项接口定义
1454
+ * 步骤执行错误类
1455
+ * 用于携带步骤执行过程中的错误信息和当前步骤对象
1456
+ * 支持传入可选数据:message,data任何类型的数据
269
1457
  */
270
- interface WebFloatingWindowOptions {
271
- initialWidth?: number;
272
- initialHeight?: number;
273
- /** Initial window X position (default 0) */
274
- initialX?: number;
275
- /** Initial window Y position (default 0) */
276
- initialY?: number;
277
- minWidth?: number;
278
- minHeight?: number;
279
- maxWidth?: number;
280
- maxHeight?: number;
281
- initialCenter?: boolean;
282
- /** Whether to show top operation area (title bar, close button, etc.) */
283
- showTopOperationArea?: boolean;
284
- /** Whether to show bottom operation area (zoom, back/forward/refresh, etc.) */
285
- showBottomOperationArea?: boolean;
286
- /** Background color: hex string (e.g. "#ffffff") or Android color int */
287
- backgroundColor?: string | number;
1458
+ declare class StepError extends Error {
1459
+ /**
1460
+ * 步骤实现函数名
1461
+ */
1462
+ readonly impl?: string;
1463
+ /**
1464
+ * 步骤标签
1465
+ */
1466
+ readonly tag?: string | undefined;
1467
+ /**
1468
+ * 步骤数据,可以是任何类型
1469
+ */
1470
+ readonly data?: any;
1471
+ /**
1472
+ * 原始错误
1473
+ */
1474
+ readonly originalError?: any;
1475
+ /**
1476
+ * 当前步骤对象
1477
+ */
1478
+ readonly currentStep?: any;
1479
+ constructor(message?: string, data?: any, impl?: string, tag?: string | undefined, originalError?: any, currentStep?: any | undefined);
288
1480
  }
289
- declare const callbacks: Map<string, (data: string) => void>;
290
- declare const accessibilityEventListeners: AccessibilityEventListener[];
291
1481
  /**
292
- * 屏幕尺寸类型(width/height 为整型像素值)
1482
+ * 主动停止异常类
1483
+ * 用于表示步骤被主动停止执行
293
1484
  */
294
- interface Screen {
295
- width: number;
296
- height: number;
1485
+ declare class StepStopError extends StepError {
1486
+ constructor(message?: string, data?: any);
297
1487
  }
298
- /** 全局屏幕尺寸,在 assistsxCallback 初始化后自动加载 */
299
- declare let screen: Screen;
300
- declare class AssistsX {
1488
+
1489
+ declare class StepAsync {
1490
+ private step;
1491
+ /**
1492
+ * 构造函数
1493
+ * @param step Step实例
1494
+ */
1495
+ constructor(step: Step);
1496
+ /**
1497
+ * 对单个节点进行截图
1498
+ * @param node 目标节点
1499
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
1500
+ * @returns 截图路径
1501
+ */
1502
+ takeScreenshotByNode(node: Node, overlayHiddenScreenshotDelayMillis?: number): Promise<string>;
1503
+ /**
1504
+ * 对多个节点进行截图
1505
+ * @param nodes 目标节点数组
1506
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
1507
+ * @returns 截图路径数组
1508
+ */
1509
+ takeScreenshotNodes(nodes: Node[], overlayHiddenScreenshotDelayMillis?: number): Promise<string[]>;
1510
+ /**
1511
+ * 获取所有符合条件的节点
1512
+ * @param filterClass 类名过滤
1513
+ * @param filterViewId 视图ID过滤
1514
+ * @param filterDes 描述过滤
1515
+ * @param filterText 文本过滤
1516
+ * @returns 节点数组
1517
+ */
1518
+ getAllNodes({ filterClass, filterViewId, filterDes, filterText, scope, }?: {
1519
+ filterClass?: string;
1520
+ filterViewId?: string;
1521
+ filterDes?: string;
1522
+ filterText?: string;
1523
+ scope?: NodeLookupScope;
1524
+ }): Promise<Node[]>;
1525
+ /**
1526
+ * 启动应用
1527
+ * @param packageName 应用包名
1528
+ * @returns 是否启动成功
1529
+ */
1530
+ launchApp(packageName: string): Promise<boolean>;
1531
+ /**
1532
+ * 获取当前应用包名
1533
+ * @param timeout 超时时间(秒),默认30秒
1534
+ */
1535
+ getPackageName(timeout?: number): Promise<string>;
1536
+ /**
1537
+ * 获取当前应用包名
1538
+ * @param options.timeout 超时时间(秒),默认30秒
1539
+ * @param options.scope 节点查找范围(可选)
1540
+ */
1541
+ getPackageName(options: {
1542
+ timeout?: number;
1543
+ scope?: NodeLookupScope;
1544
+ }): Promise<string>;
1545
+ /**
1546
+ * 通过ID查找节点
1547
+ * @param id 节点ID
1548
+ * @param filterClass 类名过滤
1549
+ * @param filterText 文本过滤
1550
+ * @param filterDes 描述过滤
1551
+ * @returns 节点数组
1552
+ */
1553
+ findById(id: string, { filterClass, filterText, filterDes, scope, }?: {
1554
+ filterClass?: string;
1555
+ filterText?: string;
1556
+ filterDes?: string;
1557
+ scope?: NodeLookupScope;
1558
+ }): Promise<Node[]>;
1559
+ /**
1560
+ * 通过文本查找节点
1561
+ * @param text 要查找的文本
1562
+ * @param filterClass 类名过滤
1563
+ * @param filterViewId 视图ID过滤
1564
+ * @param filterDes 描述过滤
1565
+ * @returns 节点数组
1566
+ */
1567
+ findByText(text: string, { filterClass, filterViewId, filterDes, scope, }?: {
1568
+ filterClass?: string;
1569
+ filterViewId?: string;
1570
+ filterDes?: string;
1571
+ scope?: NodeLookupScope;
1572
+ }): Promise<Node[]>;
1573
+ /**
1574
+ * 通过标签查找节点
1575
+ * @param className 类名
1576
+ * @param filterText 文本过滤
1577
+ * @param filterViewId 视图ID过滤
1578
+ * @param filterDes 描述过滤
1579
+ * @returns 节点数组
1580
+ */
1581
+ findByTags(className: string, { filterText, filterViewId, filterDes, scope, }?: {
1582
+ filterText?: string;
1583
+ filterViewId?: string;
1584
+ filterDes?: string;
1585
+ scope?: NodeLookupScope;
1586
+ }): Promise<Node[]>;
1587
+ /**
1588
+ * 查找所有匹配文本的节点
1589
+ * @param text 要查找的文本
1590
+ * @param timeout 超时时间(秒),默认30秒
1591
+ */
1592
+ findByTextAllMatch(text: string, timeout?: number): Promise<Node[]>;
1593
+ /**
1594
+ * 查找所有匹配文本的节点
1595
+ * @param text 要查找的文本
1596
+ * @param options.timeout 超时时间(秒),默认30秒
1597
+ * @param options.scope 节点查找范围(可选)
1598
+ */
1599
+ findByTextAllMatch(text: string, options: {
1600
+ timeout?: number;
1601
+ scope?: NodeLookupScope;
1602
+ }): Promise<Node[]>;
1603
+ /**
1604
+ * 检查是否包含指定文本
1605
+ * @param text 要检查的文本
1606
+ * @returns 是否包含
1607
+ */
1608
+ containsText(text: string): Promise<boolean>;
1609
+ /**
1610
+ * 获取所有文本
1611
+ * @returns 文本数组
1612
+ */
1613
+ getAllText(): Promise<string[]>;
1614
+ /**
1615
+ * 执行点击手势
1616
+ * @param x 横坐标
1617
+ * @param y 纵坐标
1618
+ * @param duration 持续时间(毫秒)
1619
+ * @returns 是否成功
1620
+ */
1621
+ clickByGesture(x: number, y: number, duration: number): Promise<boolean>;
1622
+ longPressGestureAutoPaste(point: {
1623
+ x: number;
1624
+ y: number;
1625
+ }, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
1626
+ matchedPackageName?: string;
1627
+ matchedText?: string;
1628
+ timeoutMillis?: number;
1629
+ longPressDuration?: number;
1630
+ }): Promise<boolean>;
1631
+ getAppInfo(packageName: string): Promise<any>;
1632
+ performLinearGesture(startPoint: {
1633
+ x: number;
1634
+ y: number;
1635
+ }, endPoint: {
1636
+ x: number;
1637
+ y: number;
1638
+ }, { duration }?: {
1639
+ duration?: number;
1640
+ }): Promise<boolean>;
1641
+ /**
1642
+ * 返回操作
1643
+ * @returns 是否成功
1644
+ */
1645
+ back(): Promise<boolean>;
1646
+ /**
1647
+ * 回到主页
1648
+ * @returns 是否成功
1649
+ */
1650
+ home(): Promise<boolean>;
1651
+ /**
1652
+ * 打开通知栏
1653
+ * @returns 是否成功
1654
+ */
1655
+ notifications(): Promise<boolean>;
1656
+ /**
1657
+ * 显示最近应用
1658
+ * @returns 是否成功
1659
+ */
1660
+ recentApps(): Promise<boolean>;
1661
+ /**
1662
+ * 获取屏幕尺寸
1663
+ * @returns 屏幕尺寸对象
1664
+ */
1665
+ getScreenSize(): Promise<any>;
1666
+ /**
1667
+ * 获取应用窗口尺寸
1668
+ * @returns 应用窗口尺寸对象
1669
+ */
1670
+ getAppScreenSize(): Promise<any>;
1671
+ }
1672
+
1673
+ type StepData = Record<string, any>;
1674
+ type StepResult = Step | undefined;
1675
+ type StepImpl = (step: Step) => Promise<StepResult>;
1676
+ type StepInterceptor = (step: Step) => StepResult | Promise<StepResult>;
1677
+ declare class Step {
1678
+ static delayMsDefault: number;
1679
+ static readonly repeatCountInfinite: number;
1680
+ static repeatCountMaxDefault: number;
1681
+ static showLog: boolean;
1682
+ static exceptionRetryCountMaxDefault: number;
1683
+ /**
1684
+ * 判断步骤数据是否有效(非空且为普通对象)
1685
+ */
1686
+ private static isValidStepData;
1687
+ /**
1688
+ * 解析步骤数据:优先使用传入值,否则使用当前值,均无效时返回空对象
1689
+ */
1690
+ private static resolveStepData;
1691
+ /**
1692
+ * 当前执行步骤的ID
1693
+ */
1694
+ private static _stepId;
1695
+ /**
1696
+ * 步骤拦截器列表
1697
+ */
1698
+ private static _interceptors;
1699
+ /**
1700
+ * 步骤异常变量,默认为空
1701
+ */
1702
+ static exception: StepError | undefined;
1703
+ /**
1704
+ * 运行步骤实现
1705
+ * @param impl 步骤实现函数
1706
+ * @param tag 步骤标签
1707
+ * @param data 步骤数据
1708
+ * @param delayMs 步骤延迟时间(毫秒)
1709
+ */
1710
+ static run(impl: StepImpl, { stepId, tag, data, delayMs, exceptionRetryCountMax, }?: {
1711
+ stepId?: string | undefined;
1712
+ tag?: string | undefined;
1713
+ data?: StepData;
1714
+ delayMs?: number;
1715
+ exceptionRetryCountMax?: number;
1716
+ }): Promise<Step | undefined>;
1717
+ /**
1718
+ * 获取当前步骤ID
1719
+ */
1720
+ static get stepId(): string | undefined;
1721
+ /**
1722
+ * 验证步骤ID是否匹配,如果不匹配则表示停止
1723
+ * @param stepId 要验证的步骤ID
1724
+ */
1725
+ static assert(stepId: string | undefined): void;
1726
+ /**
1727
+ * 为节点数组分配步骤ID
1728
+ * @param nodes 节点数组
1729
+ * @param stepId 步骤ID
1730
+ */
1731
+ static assignIdsToNodes(nodes: Node[], stepId: string | undefined): void;
1732
+ /**
1733
+ * 停止当前步骤执行
1734
+ * @param exception 可选的异常对象,如果传入则使用该异常,否则使用默认的StepStopError
1735
+ */
1736
+ static stop(exception?: StepError): void;
1737
+ /**
1738
+ * 添加步骤拦截器
1739
+ * @param interceptor 拦截器函数
1740
+ */
1741
+ static addInterceptor(interceptor: StepInterceptor): void;
1742
+ /**
1743
+ * 移除步骤拦截器
1744
+ * @param interceptor 要移除的拦截器函数
1745
+ * @returns 是否成功删除
1746
+ */
1747
+ static removeInterceptor(interceptor: StepInterceptor): boolean;
1748
+ /**
1749
+ * 按索引移除步骤拦截器
1750
+ * @param index 要移除的拦截器索引
1751
+ * @returns 是否成功删除
1752
+ */
1753
+ static removeInterceptorByIndex(index: number): boolean;
1754
+ /**
1755
+ * 移除所有匹配的步骤拦截器
1756
+ * @param interceptor 要移除的拦截器函数
1757
+ * @returns 删除的拦截器数量
1758
+ */
1759
+ static removeAllInterceptors(interceptor: StepInterceptor): number;
1760
+ /**
1761
+ * 按条件移除步骤拦截器
1762
+ * @param predicate 判断是否删除的条件函数
1763
+ * @returns 删除的拦截器数量
1764
+ */
1765
+ static removeInterceptorByPredicate(predicate: (interceptor: StepInterceptor, index: number) => boolean): number;
1766
+ /**
1767
+ * 清空所有拦截器
1768
+ */
1769
+ static clearInterceptors(): void;
1770
+ /**
1771
+ * 获取所有拦截器
1772
+ * @returns 拦截器数组
1773
+ */
1774
+ static getInterceptors(): StepInterceptor[];
1775
+ /**
1776
+ * 步骤ID
1777
+ */
1778
+ stepId: string;
1779
+ /**
1780
+ * 步骤重复执行次数
1781
+ */
1782
+ repeatCount: number;
301
1783
  /**
302
- * 屏幕尺寸(与全局变量 screen 同源)
303
- * @deprecated 已过时,请使用全局变量 {@link screen}
1784
+ * 步骤重复执行最大次数,默认15次
304
1785
  */
305
- static get screenSize(): any;
1786
+ repeatCountMax: number;
306
1787
  /**
307
- * 执行同步调用
308
- * @param method 方法名
309
- * @param args 参数对象
310
- * @returns 调用响应
1788
+ * 异常重试次数
311
1789
  */
312
- static call(method: string, { args, node }?: {
313
- args?: any;
314
- node?: Node;
315
- }): CallResponse;
1790
+ exceptionRetryCount: number;
316
1791
  /**
317
- * 执行异步调用
318
- * @param method 方法名
319
- * @param args 参数对象
320
- * @param timeout 超时时间(秒),默认30秒
321
- * @returns Promise<调用响应>
1792
+ * 异常重试最大次数,默认3次
322
1793
  */
323
- static asyncCall(method: string, { args, node, nodes, timeout, }?: {
324
- args?: any;
325
- node?: Node;
326
- nodes?: Node[];
327
- timeout?: number;
328
- }): Promise<CallResponse>;
1794
+ exceptionRetryCountMax: number;
329
1795
  /**
330
- * 设置悬浮窗标志
331
- * @param flags 标志
332
- * @returns 是否设置成功
1796
+ * 步骤标签
333
1797
  */
334
- static setOverlayFlags(flags: number): boolean;
1798
+ tag: string | undefined;
1799
+ isEnd: boolean;
335
1800
  /**
336
- * 设置悬浮窗标志
337
- * @param flags 标志
338
- * @returns 是否设置成功
1801
+ * 步骤数据
339
1802
  */
340
- static setOverlayFlagList(flags: number[]): boolean;
1803
+ data: StepData;
341
1804
  /**
342
- * 获取所有符合条件的节点
343
- * @param filterClass 类名过滤
344
- * @param filterViewId 视图ID过滤
345
- * @param filterDes 描述过滤
346
- * @param filterText 文本过滤
347
- * @returns 节点数组
1805
+ * 步骤延迟时间(毫秒)
348
1806
  */
349
- static getAllNodes({ filterClass, filterViewId, filterDes, filterText, scope, }?: {
350
- filterClass?: string;
351
- filterViewId?: string;
352
- filterDes?: string;
353
- filterText?: string;
354
- scope?: NodeLookupScope;
355
- }): Node[];
1807
+ delayMs: number;
356
1808
  /**
357
- * 设置节点文本
358
- * @param node 目标节点
359
- * @param text 要设置的文本
360
- * @returns 是否设置成功
1809
+ * 步骤实现函数
361
1810
  */
362
- static setNodeText(node: Node, text: string): boolean;
1811
+ impl: StepImpl | undefined;
363
1812
  /**
364
- * 获取剪贴板最新文本
365
- * @returns 剪贴板最新文本
1813
+ * 构造函数
1814
+ * @param stepId 步骤ID
1815
+ * @param impl 步骤实现函数
1816
+ * @param tag 步骤标签
1817
+ * @param data 步骤数据
1818
+ * @param delayMs 步骤延迟时间(毫秒)
366
1819
  */
367
- static getClipboardLatestText(): any;
1820
+ constructor({ stepId, impl, tag, data, delayMs, repeatCountMax, exceptionRetryCountMax, isEnd, }: {
1821
+ stepId: string;
1822
+ impl: StepImpl | undefined;
1823
+ tag?: string | undefined;
1824
+ data?: StepData;
1825
+ delayMs?: number;
1826
+ repeatCountMax?: number;
1827
+ exceptionRetryCountMax?: number;
1828
+ isEnd?: boolean;
1829
+ });
1830
+ get async(): StepAsync;
368
1831
  /**
369
- * 获取剪贴板文本内容(异步)
370
- * @param timeout 超时时间(秒),默认30秒
371
- * @returns 剪贴板文本内容,如果获取失败则返回空字符串
1832
+ * 创建下一个步骤
1833
+ * @param impl 下一步骤实现函数
1834
+ * @param tag 步骤标签
1835
+ * @param data 步骤数据
1836
+ * @param delayMs 步骤延迟时间(毫秒)
1837
+ * @returns 新的步骤实例
372
1838
  */
373
- static getClipboardText(timeout?: number): Promise<string>;
1839
+ next(impl: StepImpl, { tag, data, delayMs, repeatCountMax, exceptionRetryCountMax, }?: {
1840
+ tag?: string | undefined;
1841
+ data?: StepData;
1842
+ delayMs?: number;
1843
+ repeatCountMax?: number;
1844
+ exceptionRetryCountMax?: number;
1845
+ }): Step;
1846
+ end({ tag, data, delayMs, repeatCountMax, exceptionRetryCountMax, }?: {
1847
+ tag?: string | undefined;
1848
+ data?: StepData;
1849
+ delayMs?: number;
1850
+ repeatCountMax?: number;
1851
+ exceptionRetryCountMax?: number;
1852
+ }): Step;
374
1853
  /**
375
- * 在浏览器中打开URL
376
- * @param url 要打开的URL
377
- * @returns 是否成功打开
1854
+ * 重复当前步骤
1855
+ * @param stepId 步骤ID
1856
+ * @param tag 步骤标签
1857
+ * @param data 步骤数据
1858
+ * @param delayMs 步骤延迟时间(毫秒)
1859
+ * @returns 当前步骤实例
378
1860
  */
379
- static openUrlInBrowser(url: string): boolean;
1861
+ repeat({ stepId, tag, data, delayMs, repeatCountMax, exceptionRetryCountMax, }?: {
1862
+ stepId?: string;
1863
+ tag?: string | undefined;
1864
+ data?: StepData;
1865
+ delayMs?: number;
1866
+ repeatCountMax?: number;
1867
+ exceptionRetryCountMax?: number;
1868
+ }): Step;
380
1869
  /**
381
- * 保持屏幕常亮
382
- * @param tip 提示文本
383
- * @returns 是否保持屏幕常亮成功
1870
+ * 延迟执行
1871
+ * @param ms 延迟时间(毫秒)
1872
+ * @returns Promise
384
1873
  */
385
- static keepScreenOn(tip?: string): boolean;
386
- static clearKeepScreenOn(): boolean;
387
- static isAppInstalled(packageName: string): boolean;
1874
+ delay(ms: number): Promise<void>;
388
1875
  /**
389
- * 对指定节点进行截图
390
- * @param nodes 要截图的节点数组
1876
+ * 等待异步方法执行完成
1877
+ * @param method 异步方法
1878
+ * @returns Promise<T>
1879
+ */
1880
+ await<T>(method: () => Promise<T>): Promise<T>;
1881
+ /**
1882
+ * 对单个节点进行截图
1883
+ * @param node 目标节点
391
1884
  * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
392
- * @param timeout 超时时间(秒),默认30秒
393
- * @returns 截图路径数组
1885
+ * @returns 截图路径
394
1886
  */
395
- static takeScreenshotNodes(nodes: Node[], overlayHiddenScreenshotDelayMillis?: number, timeout?: number): Promise<string[]>;
396
- static scanQR(timeout?: number): Promise<string>;
397
- static loadWebViewOverlay(url: string, options?: WebFloatingWindowOptions & {
398
- timeout?: number;
399
- }): Promise<any>;
1887
+ takeScreenshotByNode(node: Node, overlayHiddenScreenshotDelayMillis?: number): Promise<string>;
400
1888
  /**
401
- * 点击节点
402
- * @param node 要点击的节点
403
- * @returns 是否点击成功
1889
+ * 对多个节点进行截图
1890
+ * @param nodes 目标节点数组
1891
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
1892
+ * @returns 截图路径数组
404
1893
  */
405
- static click(node: Node): boolean;
1894
+ takeScreenshotNodes(nodes: Node[], overlayHiddenScreenshotDelayMillis?: number): Promise<string[]>;
406
1895
  /**
407
- * 长按节点
408
- * @param node 要长按的节点
409
- * @returns 是否长按成功
1896
+ * 获取所有符合条件的节点
1897
+ * @param filterClass 类名过滤
1898
+ * @param filterViewId 视图ID过滤
1899
+ * @param filterDes 描述过滤
1900
+ * @param filterText 文本过滤
1901
+ * @returns 节点数组
410
1902
  */
411
- static longClick(node: Node): boolean;
1903
+ getAllNodes({ filterClass, filterViewId, filterDes, filterText, scope, }?: {
1904
+ filterClass?: string;
1905
+ filterViewId?: string;
1906
+ filterDes?: string;
1907
+ filterText?: string;
1908
+ scope?: NodeLookupScope;
1909
+ }): Node[];
412
1910
  /**
413
1911
  * 启动应用
414
1912
  * @param packageName 应用包名
415
1913
  * @returns 是否启动成功
416
1914
  */
417
- static launchApp(packageName: string): boolean;
1915
+ launchApp(packageName: string): boolean;
418
1916
  /**
419
1917
  * 获取当前应用包名
420
- * @returns 包名
1918
+ * @param options.scope 节点查找范围(可选)
421
1919
  */
422
- static getPackageName(options?: {
1920
+ getPackageName(options?: {
423
1921
  scope?: NodeLookupScope;
424
1922
  }): string;
425
- /**
426
- * 显示悬浮提示
427
- * @param text 提示文本
428
- * @param delay 显示时长(毫秒)
429
- * @returns 是否显示成功
430
- */
431
- static overlayToast(text: string, delay?: number): boolean;
432
1923
  /**
433
1924
  * 通过ID查找节点
434
1925
  * @param id 节点ID
435
1926
  * @param filterClass 类名过滤
436
1927
  * @param filterText 文本过滤
437
1928
  * @param filterDes 描述过滤
438
- * @param node 父节点范围
439
1929
  * @returns 节点数组
440
1930
  */
441
- static findById(id: string, { filterClass, filterText, filterDes, node, scope, }?: {
1931
+ findById(id: string, { filterClass, filterText, filterDes, scope, }?: {
442
1932
  filterClass?: string;
443
1933
  filterText?: string;
444
1934
  filterDes?: string;
445
- node?: Node;
446
1935
  scope?: NodeLookupScope;
447
1936
  }): Node[];
448
1937
  /**
@@ -451,14 +1940,12 @@ declare class AssistsX {
451
1940
  * @param filterClass 类名过滤
452
1941
  * @param filterViewId 视图ID过滤
453
1942
  * @param filterDes 描述过滤
454
- * @param node 父节点范围
455
1943
  * @returns 节点数组
456
1944
  */
457
- static findByText(text: string, { filterClass, filterViewId, filterDes, node, scope, }?: {
1945
+ findByText(text: string, { filterClass, filterViewId, filterDes, scope, }?: {
458
1946
  filterClass?: string;
459
1947
  filterViewId?: string;
460
1948
  filterDes?: string;
461
- node?: Node;
462
1949
  scope?: NodeLookupScope;
463
1950
  }): Node[];
464
1951
  /**
@@ -467,14 +1954,12 @@ declare class AssistsX {
467
1954
  * @param filterText 文本过滤
468
1955
  * @param filterViewId 视图ID过滤
469
1956
  * @param filterDes 描述过滤
470
- * @param node 父节点范围
471
1957
  * @returns 节点数组
472
1958
  */
473
- static findByTags(className: string, { filterText, filterViewId, filterDes, node, scope, }?: {
1959
+ findByTags(className: string, { filterText, filterViewId, filterDes, scope, }?: {
474
1960
  filterText?: string;
475
1961
  filterViewId?: string;
476
1962
  filterDes?: string;
477
- node?: Node;
478
1963
  scope?: NodeLookupScope;
479
1964
  }): Node[];
480
1965
  /**
@@ -482,337 +1967,79 @@ declare class AssistsX {
482
1967
  * @param text 要查找的文本
483
1968
  * @param options.scope 节点查找范围(可选)
484
1969
  */
485
- static findByTextAllMatch(text: string, { scope }?: {
1970
+ findByTextAllMatch(text: string, { scope }?: {
486
1971
  scope?: NodeLookupScope;
487
1972
  }): Node[];
488
- /**
489
- * 检查是否包含指定文本
490
- * @param text 要检查的文本
491
- * @returns 是否包含
492
- */
493
- static containsText(text: string): boolean;
494
- /**
495
- * 获取所有文本
496
- * @returns 文本数组
497
- */
498
- static getAllText(): string[];
499
- /**
500
- * 查找第一个匹配标签的父节点
501
- * @param className 类名
502
- * @returns 父节点
503
- */
504
- static findFirstParentByTags(node: Node, className: string): Node;
505
- /**
506
- * 获取节点的所有子节点
507
- * @param node 父节点
508
- * @returns 子节点数组
509
- */
510
- static getNodes(node: Node): Node[];
511
- /**
512
- * 获取节点的直接子节点
513
- * @param node 父节点
514
- * @returns 子节点数组
515
- */
516
- static getChildren(node: Node): Node[];
517
- /**
518
- * 查找第一个可点击的父节点
519
- * @param node 起始节点
520
- * @returns 可点击的父节点
521
- */
522
- static findFirstParentClickable(node: Node): Node;
523
- /**
524
- * 获取节点在屏幕中的边界
525
- * @param node 目标节点
526
- * @returns 边界对象
527
- */
528
- static getBoundsInScreen(node: Node): Bounds;
529
- /**
530
- * 检查节点是否可见
531
- * @param node 目标节点
532
- * @param compareNode 比较节点
533
- * @param isFullyByCompareNode 是否完全可见
534
- * @returns 是否可见
535
- */
536
- static isVisible(node: Node, { compareNode, isFullyByCompareNode, }?: {
537
- compareNode?: Node;
538
- isFullyByCompareNode?: boolean;
539
- }): boolean;
540
- /**
541
- * 执行点击手势
542
- * @param x 横坐标
543
- * @param y 纵坐标
544
- * @param duration 持续时间
545
- * @param timeout 超时时间(秒),默认30秒
546
- * @returns 是否成功
547
- */
548
- static clickByGesture(x: number, y: number, duration: number, timeout?: number): Promise<boolean>;
549
- /**
550
- * 返回操作
551
- * @returns 是否成功
552
- */
553
- static back(): boolean;
554
- /**
555
- * 回到主页
556
- * @returns 是否成功
557
- */
558
- static home(): boolean;
559
- /**
560
- * 打开通知栏
561
- * @returns 是否成功
562
- */
563
- static notifications(): boolean;
564
- /**
565
- * 显示最近应用
566
- * @returns 是否成功
567
- */
568
- static recentApps(): boolean;
569
- /**
570
- * 在节点中粘贴文本
571
- * @param node 目标节点
572
- * @param text 要粘贴的文本
573
- * @returns 是否成功
574
- */
575
- static paste(node: Node, text: string): boolean;
576
- static focus(node: Node): boolean;
577
- /**
578
- * 选择文本
579
- * @param node 目标节点
580
- * @param selectionStart 选择起始位置
581
- * @param selectionEnd 选择结束位置
582
- * @returns 是否成功
583
- */
584
- static selectionText(node: Node, selectionStart: number, selectionEnd: number): boolean;
585
- /**
586
- * 向前滚动
587
- * @param node 可滚动节点
588
- * @returns 是否成功
589
- */
590
- static scrollForward(node: Node): boolean;
591
- /**
592
- * 向后滚动
593
- * @param node 可滚动节点
594
- * @returns 是否成功
595
- */
596
- static scrollBackward(node: Node): boolean;
597
- /**
598
- * 对节点执行点击手势
599
- * @param node 目标节点
600
- * @param offsetX X轴偏移
601
- * @param offsetY Y轴偏移
602
- * @param switchWindowIntervalDelay 窗口切换延迟
603
- * @param clickDuration 点击持续时间
604
- * @param timeout 超时时间(秒),默认30秒
605
- * @returns 是否成功
606
- */
607
- static clickNodeByGesture(node: Node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, timeout, }?: {
608
- offsetX?: number;
609
- offsetY?: number;
610
- switchWindowIntervalDelay?: number;
611
- clickDuration?: number;
612
- timeout?: number;
613
- }): Promise<boolean>;
614
- /**
615
- * 对节点执行双击手势
616
- * @param node 目标节点
617
- * @param offsetX X轴偏移
618
- * @param offsetY Y轴偏移
619
- * @param switchWindowIntervalDelay 窗口切换延迟
620
- * @param clickDuration 点击持续时间
621
- * @param clickInterval 点击间隔
622
- * @param timeout 超时时间(秒),默认30秒
623
- * @returns 是否成功
1973
+ /**
1974
+ * 检查是否包含指定文本
1975
+ * @param text 要检查的文本
1976
+ * @returns 是否包含
624
1977
  */
625
- static doubleClickNodeByGesture(node: Node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, timeout, }?: {
626
- offsetX?: number;
627
- offsetY?: number;
628
- switchWindowIntervalDelay?: number;
629
- clickDuration?: number;
630
- clickInterval?: number;
631
- timeout?: number;
632
- }): Promise<boolean>;
1978
+ containsText(text: string): boolean;
633
1979
  /**
634
- * 执行线型手势
635
- * @param startPoint
636
- * @param endPoint
637
- * @param param2
638
- * @param timeout 超时时间(秒),默认30秒
639
- * @returns
1980
+ * 获取所有文本
1981
+ * @returns 文本数组
640
1982
  */
641
- static performLinearGesture(startPoint: {
642
- x: number;
643
- y: number;
644
- }, endPoint: {
1983
+ getAllText(): string[];
1984
+ /**
1985
+ * 执行点击手势
1986
+ * @param x 横坐标
1987
+ * @param y 纵坐标
1988
+ * @param duration 持续时间(毫秒)
1989
+ * @returns 是否成功
1990
+ */
1991
+ clickByGesture(x: number, y: number, duration: number): Promise<boolean>;
1992
+ longPressGestureAutoPaste(point: {
645
1993
  x: number;
646
1994
  y: number;
647
- }, { duration, timeout }?: {
648
- duration?: number;
649
- timeout?: number;
650
- }): Promise<boolean>;
651
- static longPressNodeByGestureAutoPaste(node: Node, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, timeout, }?: {
1995
+ }, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
652
1996
  matchedPackageName?: string;
653
1997
  matchedText?: string;
654
1998
  timeoutMillis?: number;
655
1999
  longPressDuration?: number;
656
- timeout?: number;
657
2000
  }): Promise<boolean>;
658
- static longPressGestureAutoPaste(point: {
2001
+ getAppInfo(packageName: string): Promise<any>;
2002
+ performLinearGesture(startPoint: {
659
2003
  x: number;
660
2004
  y: number;
661
- }, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, timeout, }?: {
662
- matchedPackageName?: string;
663
- matchedText?: string;
664
- timeoutMillis?: number;
665
- longPressDuration?: number;
666
- timeout?: number;
2005
+ }, endPoint: {
2006
+ x: number;
2007
+ y: number;
2008
+ }, { duration }?: {
2009
+ duration?: number;
667
2010
  }): Promise<boolean>;
668
- static getAppInfo(packageName: string, timeout?: number): Promise<AppInfo>;
669
- static getUniqueDeviceId(): any;
670
- static getAndroidID(): any;
671
- static getMacAddress(timeout?: number): Promise<any>;
672
- static getDeviceInfo(timeout?: number): Promise<DeviceInfo>;
673
- static getNetworkType(timeout?: number): Promise<any>;
674
- /**
675
- * 播放系统电话铃声
676
- * @param timeout 超时时间(秒),默认30秒
677
- * @returns 播放结果消息
678
- */
679
- static audioPlayRingtone(timeout?: number): Promise<string>;
680
- /**
681
- * 停止播放系统电话铃声
682
- * @param timeout 超时时间(秒),默认30秒
683
- * @returns 停止结果消息
684
- */
685
- static audioStopRingtone(timeout?: number): Promise<string>;
686
- static setAccessibilityEventFilters(value: AccessibilityEventFilter[]): Promise<any>;
687
- static addAccessibilityEventFilter(value: AccessibilityEventFilter): Promise<any>;
688
- /**
689
- * 获取屏幕尺寸
690
- * @returns 屏幕尺寸对象(width, height)
691
- */
692
- static getScreenSize(): Screen | null;
693
2011
  /**
694
- * 获取应用窗口尺寸
695
- * @returns 应用窗口尺寸对象
2012
+ * 返回操作
2013
+ * @returns 是否成功
696
2014
  */
697
- static getAppScreenSize(): any;
2015
+ back(): boolean;
698
2016
  /**
699
- * 添加无障碍事件监听器
700
- * @param listener 监听器函数
2017
+ * 回到主页
2018
+ * @returns 是否成功
701
2019
  */
702
- static addAccessibilityEventListener(listener: AccessibilityEventListener): void;
2020
+ home(): boolean;
703
2021
  /**
704
- * 判断是否包含无障碍事件监听器
705
- * @param listener 监听器函数
706
- * @returns 是否包含
2022
+ * 打开通知栏
2023
+ * @returns 是否成功
707
2024
  */
708
- static containsAccessibilityEventListener(listener: AccessibilityEventListener): boolean;
2025
+ notifications(): boolean;
709
2026
  /**
710
- * 移除无障碍事件监听器
711
- * @param listener 要移除的监听器函数
712
- * @returns 是否移除成功
2027
+ * 显示最近应用
2028
+ * @returns 是否成功
713
2029
  */
714
- static removeAccessibilityEventListener(listener: AccessibilityEventListener): boolean;
2030
+ recentApps(): boolean;
715
2031
  /**
716
- * 移除所有无障碍事件监听器
2032
+ * 获取屏幕尺寸
2033
+ * @returns 屏幕尺寸对象
717
2034
  */
718
- static removeAllAccessibilityEventListeners(): void;
2035
+ getScreenSize(): any;
719
2036
  /**
720
- * 获取当前注册的无障碍事件监听器数量
721
- * @returns 监听器数量
2037
+ * 获取应用窗口尺寸
2038
+ * @returns 应用窗口尺寸对象
722
2039
  */
723
- static getAccessibilityEventListenerCount(): number;
2040
+ getAppScreenSize(): any;
724
2041
  }
725
2042
 
726
- declare const CallMethod: {
727
- readonly takeScreenshot: "takeScreenshot";
728
- readonly takeScreenshotSave: "takeScreenshotSave";
729
- readonly takeScreenshotToFile: "takeScreenshotToFile";
730
- readonly overlayToast: "overlayToast";
731
- readonly setNodeText: "setNodeText";
732
- readonly findByTags: "findByTags";
733
- readonly findById: "findById";
734
- readonly findByText: "findByText";
735
- readonly findByTextAllMatch: "findByTextAllMatch";
736
- readonly containsText: "containsText";
737
- readonly getAllText: "getAllText";
738
- readonly findFirstParentByTags: "findFirstParentByTags";
739
- readonly getAllNodes: "getAllNodes";
740
- readonly getNodes: "getNodes";
741
- readonly findFirstParentClickable: "findFirstParentClickable";
742
- readonly getChildren: "getChildren";
743
- readonly getBoundsInScreen: "getBoundsInScreen";
744
- readonly isVisible: "isVisible";
745
- readonly click: "click";
746
- readonly longClick: "longClick";
747
- readonly back: "back";
748
- readonly home: "home";
749
- readonly notifications: "notifications";
750
- readonly recentApps: "recentApps";
751
- readonly paste: "paste";
752
- readonly focus: "focus";
753
- readonly selectionText: "selectionText";
754
- readonly scrollForward: "scrollForward";
755
- readonly launchApp: "launchApp";
756
- readonly getPackageName: "getPackageName";
757
- readonly getScreenSize: "getScreenSize";
758
- readonly getAppScreenSize: "getAppScreenSize";
759
- readonly scrollBackward: "scrollBackward";
760
- readonly setOverlayFlags: "setOverlayFlags";
761
- readonly scanQR: "scanQR";
762
- readonly loadWebViewOverlay: "loadWebViewOverlay";
763
- readonly closeOverlay: "closeOverlay";
764
- readonly recognizeTextInScreenshot: "recognizeTextInScreenshot";
765
- readonly clickByGesture: "clickByGesture";
766
- readonly clickNodeByGesture: "clickNodeByGesture";
767
- readonly doubleClickNodeByGesture: "doubleClickNodeByGesture";
768
- readonly performLinearGesture: "performLinearGesture";
769
- readonly longPressGestureAutoPaste: "longPressGestureAutoPaste";
770
- readonly getAppInfo: "getAppInfo";
771
- readonly getMacAddress: "getMacAddress";
772
- readonly getAndroidID: "getAndroidID";
773
- readonly getUniqueDeviceId: "getUniqueDeviceId";
774
- readonly addAccessibilityEventFilter: "addAccessibilityEventFilter";
775
- readonly setAccessibilityEventFilters: "setAccessibilityEventFilters";
776
- readonly httpRequest: "httpRequest";
777
- readonly getDeviceInfo: "getDeviceInfo";
778
- readonly getNetworkType: "getNetworkType";
779
- readonly isAppInstalled: "isAppInstalled";
780
- readonly getClipboardLatestText: "getClipboardLatestText";
781
- readonly getClipboardText: "getClipboardText";
782
- readonly openUrlInBrowser: "openUrlInBrowser";
783
- readonly keepScreenOn: "keepScreenOn";
784
- readonly clearKeepScreenOn: "clearKeepScreenOn";
785
- readonly download: "download";
786
- readonly audioPlayFromFile: "audioPlayFromFile";
787
- readonly audioStop: "audioStop";
788
- readonly audioPlayRingtone: "audioPlayRingtone";
789
- readonly audioStopRingtone: "audioStopRingtone";
790
- readonly addContact: "addContact";
791
- readonly getAllContacts: "getAllContacts";
792
- readonly saveRootNodeTreeJson: "saveRootNodeTreeJson";
793
- };
794
- type CallMethodType = (typeof CallMethod)[keyof typeof CallMethod];
795
-
796
- /**
797
- * Android 视图类型常量
798
- */
799
- declare const NodeClassValue: {
800
- readonly ImageView: "android.widget.ImageView";
801
- readonly TextView: "android.widget.TextView";
802
- readonly LinearLayout: "android.widget.LinearLayout";
803
- readonly RelativeLayout: "android.widget.RelativeLayout";
804
- readonly Button: "android.widget.Button";
805
- readonly ImageButton: "android.widget.ImageButton";
806
- readonly EditText: "android.widget.EditText";
807
- readonly View: "android.view.View";
808
- readonly ViewGroup: "android.view.ViewGroup";
809
- readonly FrameLayout: "android.widget.FrameLayout";
810
- };
811
-
812
- declare function sleep(ms: number): Promise<void>;
813
- declare function generateUUID(): string;
814
- declare function decodeBase64UTF8(base64: string): string;
815
-
816
2043
  type StepStatus = 'idle' | 'running' | 'completed' | 'error';
817
2044
  interface StepState {
818
2045
  status: StepStatus;
@@ -894,6 +2121,10 @@ declare class WindowFlags {
894
2121
  * @returns 新的标志位组合
895
2122
  */
896
2123
  static removeFlag(flags: number, flag: number): number;
2124
+ /** 输入框获取焦点时使用的悬浮窗 flag 组合(不含 FLAG_NOT_FOCUSABLE) */
2125
+ static getOverlayInputFocusFlagList(): number[];
2126
+ /** 输入框失去焦点时使用的悬浮窗 flag 组合(含 FLAG_NOT_FOCUSABLE) */
2127
+ static getOverlayInputBlurFlagList(): number[];
897
2128
  /**
898
2129
  * 获取所有标志位的描述信息
899
2130
  * @returns 标志位描述对象数组
@@ -975,6 +2206,14 @@ declare class AssistsXAsync {
975
2206
  * @returns 是否设置成功
976
2207
  */
977
2208
  static setOverlayFlagList(flags: number[], timeout?: number): Promise<boolean>;
2209
+ /**
2210
+ * 设置悬浮窗可获取焦点(WebView 内输入框 focus 时调用)
2211
+ */
2212
+ static setOverlayInputFocus(timeout?: number): Promise<boolean>;
2213
+ /**
2214
+ * 取消悬浮窗焦点(WebView 内输入框 blur 时调用)
2215
+ */
2216
+ static clearOverlayInputFocus(timeout?: number): Promise<boolean>;
978
2217
  /**
979
2218
  * 获取所有符合条件的节点
980
2219
  * @param filterClass 类名过滤
@@ -1373,6 +2612,10 @@ declare class AssistsXAsync {
1373
2612
  timeout?: number;
1374
2613
  }): Promise<boolean>;
1375
2614
  static getAppInfo(packageName: string, timeout?: number): Promise<AppInfo>;
2615
+ /**
2616
+ * 获取当前运行的 AssistsX 插件信息(仅 AssistsX 宿主有效,否则返回 null)
2617
+ */
2618
+ static getCurrentPlugin(timeout?: number): Promise<PluginInfo | null>;
1376
2619
  static getUniqueDeviceId(timeout?: number): Promise<any>;
1377
2620
  static getAndroidID(timeout?: number): Promise<any>;
1378
2621
  static getMacAddress(timeout?: number): Promise<any>;
@@ -2884,6 +4127,134 @@ declare const MlkitCallMethod: {
2884
4127
  };
2885
4128
  type MlkitCallMethodType = (typeof MlkitCallMethod)[keyof typeof MlkitCallMethod];
2886
4129
 
4130
+ type ScreenshotImageFormat = "PNG" | "JPEG" | "JPG" | "WEBP";
4131
+ /** takeScreenshotBase64 / takeNodeScreenshotBase64 返回数据 */
4132
+ interface ScreenshotBase64Data {
4133
+ base64: string;
4134
+ dataUrl: string;
4135
+ mimeType: string;
4136
+ }
4137
+ interface TakeScreenshotBase64Options {
4138
+ overlayHiddenScreenshotDelayMillis?: number;
4139
+ format?: ScreenshotImageFormat;
4140
+ withDataUrlPrefix?: boolean;
4141
+ timeout?: number;
4142
+ }
4143
+ interface TakeScreenshotNodesBase64Options extends TakeScreenshotBase64Options {
4144
+ }
4145
+ declare class Screenshot {
4146
+ /**
4147
+ * 执行异步调用
4148
+ */
4149
+ private asyncCall;
4150
+ private buildScreenshotArgs;
4151
+ /**
4152
+ * 截取全屏并返回 Base64
4153
+ */
4154
+ takeScreenshotBase64(options?: TakeScreenshotBase64Options): Promise<ScreenshotBase64Data | null>;
4155
+ /**
4156
+ * 截取指定节点区域并返回 Base64
4157
+ */
4158
+ takeNodeScreenshotBase64(nodeId: string, options?: TakeScreenshotBase64Options): Promise<ScreenshotBase64Data | null>;
4159
+ /**
4160
+ * 批量截取节点区域;nodeIds 为空时返回全屏截图
4161
+ */
4162
+ takeScreenshotNodesBase64(nodeIds?: string[], options?: TakeScreenshotNodesBase64Options): Promise<string[]>;
4163
+ }
4164
+ declare const screenshot: Screenshot;
4165
+
4166
+ /**
4167
+ * 截图相关的 JavascriptInterface 方法常量
4168
+ */
4169
+ declare const ScreenshotCallMethod: {
4170
+ /** 截取全屏并返回 Base64 */
4171
+ readonly takeScreenshotBase64: "takeScreenshotBase64";
4172
+ /** 截取指定节点区域并返回 Base64,需传 node.nodeId */
4173
+ readonly takeNodeScreenshotBase64: "takeNodeScreenshotBase64";
4174
+ /** 批量截取节点区域并返回 Base64 数组,nodes 为空时返回全屏 */
4175
+ readonly takeScreenshotNodesBase64: "takeScreenshotNodesBase64";
4176
+ };
4177
+ type ScreenshotCallMethodType = (typeof ScreenshotCallMethod)[keyof typeof ScreenshotCallMethod];
4178
+
4179
+ /** 数据库定位,dbPath 与 dbName 二选一 */
4180
+ interface DbTarget {
4181
+ dbPath?: string;
4182
+ dbName?: string;
4183
+ }
4184
+ /** exec 成功返回 */
4185
+ interface DbExecResult {
4186
+ rowsAffected: number;
4187
+ lastInsertRowId: number;
4188
+ }
4189
+ /** query 单行记录;BLOB 字段为 Base64 字符串 */
4190
+ type DbRow = Record<string, string | number | null>;
4191
+ /** query 成功返回 */
4192
+ interface DbQueryResult {
4193
+ columns: string[];
4194
+ rows: DbRow[];
4195
+ rowCount: number;
4196
+ }
4197
+ /** execBatch 单条结果 */
4198
+ interface DbBatchItemResult {
4199
+ rowsAffected: number;
4200
+ lastInsertRowId: number;
4201
+ }
4202
+ /** execBatch 成功返回 */
4203
+ interface DbExecBatchResult {
4204
+ count: number;
4205
+ results: DbBatchItemResult[];
4206
+ }
4207
+ /** 公共调用选项 */
4208
+ interface DbCallOptions extends DbTarget {
4209
+ bindArgs?: (string | number | boolean | null)[];
4210
+ /** 超时时间(秒),默认 30 */
4211
+ timeout?: number;
4212
+ }
4213
+ interface DbExecBatchOptions extends DbTarget {
4214
+ /** 超时时间(秒),默认 30 */
4215
+ timeout?: number;
4216
+ }
4217
+ declare class Db {
4218
+ /**
4219
+ * 执行异步调用
4220
+ */
4221
+ private asyncCall;
4222
+ /**
4223
+ * 将 query 结果中的 Base64 BLOB 字段解码为 Uint8Array
4224
+ */
4225
+ decodeBlobBase64(base64: string): Uint8Array;
4226
+ /**
4227
+ * 执行非查询 SQL
4228
+ */
4229
+ exec(sql: string, options: DbCallOptions): Promise<DbExecResult>;
4230
+ /**
4231
+ * 执行查询 SQL
4232
+ */
4233
+ query(sql: string, options: DbCallOptions): Promise<DbQueryResult>;
4234
+ /**
4235
+ * 事务内批量执行多条 SQL
4236
+ */
4237
+ execBatch(statements: string[], options: DbExecBatchOptions): Promise<DbExecBatchResult>;
4238
+ /**
4239
+ * 关闭并释放指定数据库连接
4240
+ */
4241
+ close(options: DbTarget & {
4242
+ timeout?: number;
4243
+ }): Promise<void>;
4244
+ }
4245
+ declare const db: Db;
4246
+
4247
+ /**
4248
+ * SQLite 数据库桥接方法名常量
4249
+ */
4250
+ declare const DbCallMethod: {
4251
+ readonly exec: "exec";
4252
+ readonly query: "query";
4253
+ readonly execBatch: "execBatch";
4254
+ readonly close: "close";
4255
+ };
4256
+ type DbCallMethodType = (typeof DbCallMethod)[keyof typeof DbCallMethod];
4257
+
2887
4258
  declare class BarUtils {
2888
4259
  private asyncCall;
2889
4260
  private errorMessage;
@@ -3015,6 +4386,8 @@ declare const LogCallMethod: {
3015
4386
  readonly uploadLogs: "uploadLogs";
3016
4387
  /** 获取日志服务当前域名(origin,无路径;与上传、管理后台同源),对应 AssistsLogDiagnostics.adminWebBaseUrl() */
3017
4388
  readonly getLogServiceBaseUrl: "getLogServiceBaseUrl";
4389
+ /** 解析日志文件绝对路径(不创建文件) */
4390
+ readonly resolveLogPath: "resolveLogPath";
3018
4391
  };
3019
4392
  /** 与 ASWebView / AssistsLogJavascriptInterface companion 对齐 */
3020
4393
  declare const LogStream: {
@@ -3024,6 +4397,15 @@ declare const LogStream: {
3024
4397
  type LogStreamType = (typeof LogStream)[keyof typeof LogStream];
3025
4398
  type LogCallMethodType = (typeof LogCallMethod)[keyof typeof LogCallMethod];
3026
4399
 
4400
+ /** 日志文件定位:dirPath 为绝对路径目录,fileName 不含 .txt 后缀 */
4401
+ interface LogTarget {
4402
+ dirPath?: string;
4403
+ fileName?: string;
4404
+ }
4405
+ interface LogCallOptions extends LogTarget {
4406
+ /** 超时时间(秒),默认 30 */
4407
+ timeout?: number;
4408
+ }
3027
4409
  /**
3028
4410
  * onAssistsLogUpdate 推送的监听器列表(与 accessibilityEventListeners 风格一致)。
3029
4411
  * 在页面加载本模块后,向此数组 push,或使用 log.addLogUpdateListener。
@@ -3031,7 +4413,7 @@ type LogCallMethodType = (typeof LogCallMethod)[keyof typeof LogCallMethod];
3031
4413
  */
3032
4414
  declare const logUpdateListeners: Array<(payload: LogUpdateEvent) => void>;
3033
4415
  /**
3034
- * Base64 解码后的 CallResponse,data 含 stream / text
4416
+ * Base64 解码后的 CallResponse,data 含 stream / text / logFilePath
3035
4417
  */
3036
4418
  interface LogUpdateEvent {
3037
4419
  code: number;
@@ -3042,13 +4424,15 @@ interface LogUpdateEvent {
3042
4424
  interface LogUpdateData {
3043
4425
  stream: LogStreamType;
3044
4426
  text: string;
4427
+ logFilePath?: string;
3045
4428
  }
3046
4429
  interface LogSubscribeUpdatePayload {
3047
4430
  text: string;
3048
4431
  stream: string;
3049
4432
  subscriptionId: string;
4433
+ logFilePath?: string;
3050
4434
  }
3051
- interface LogUploadOptions {
4435
+ interface LogUploadOptions extends LogTarget {
3052
4436
  baseUrl?: string;
3053
4437
  /** PNG(默认)| JPEG | JPG | WEBP */
3054
4438
  format?: "PNG" | "JPEG" | "JPG" | "WEBP" | string;
@@ -3073,39 +4457,45 @@ declare class Log {
3073
4457
  private getBridge;
3074
4458
  private asyncCall;
3075
4459
  /** 读取当前日志全文 */
3076
- readAllText(timeout?: number): Promise<string>;
4460
+ readAllText(timeoutOrOptions?: number | LogCallOptions): Promise<string>;
3077
4461
  /**
3078
4462
  * 获取日志服务当前域名(origin,无路径;与上传、管理后台同源)。
3079
4463
  * 与 Kotlin getLogServiceBaseUrl / adminWebBaseUrl 对齐。
3080
4464
  */
3081
4465
  getLogServiceBaseUrl(timeout?: number): Promise<string>;
4466
+ /**
4467
+ * 解析日志文件绝对路径(不创建文件)。
4468
+ * AssistsX 插件环境下会经原生拦截追加 log-{packageName} 子目录。
4469
+ */
4470
+ resolveLogPath(targetOrOptions?: LogTarget | LogCallOptions): Promise<string>;
3082
4471
  /** 清空日志 */
3083
- clear(timeout?: number): Promise<boolean>;
4472
+ clear(timeoutOrOptions?: number | LogCallOptions): Promise<boolean>;
3084
4473
  /** 从文件重新加载到内存 Flow */
3085
- refreshFromFile(timeout?: number): Promise<boolean>;
4474
+ refreshFromFile(timeoutOrOptions?: number | LogCallOptions): Promise<boolean>;
3086
4475
  /** 追加一行 */
3087
- appendLine(line: string, maxLength?: number, timeout?: number): Promise<boolean>;
4476
+ appendLine(line: string, maxLengthOrOptions?: number | (LogTarget & {
4477
+ maxLength?: number;
4478
+ timeout?: number;
4479
+ }), timeout?: number): Promise<boolean>;
3088
4480
  /** 追加带时间戳的条目 */
3089
- appendTimestampedEntry(message: string, timeout?: number): Promise<boolean>;
4481
+ appendTimestampedEntry(message: string, timeoutOrOptions?: number | LogCallOptions): Promise<boolean>;
3090
4482
  /**
3091
4483
  * 追加日志(appendTimestampedEntry / appendLine 简写)。
3092
4484
  * 默认带时间戳;`timestamped: false` 时走 appendLine。
3093
4485
  */
3094
- append(text: string, options?: {
4486
+ append(text: string, options?: LogTarget & {
3095
4487
  /** @default true */
3096
4488
  timestamped?: boolean;
3097
4489
  maxLength?: number;
3098
4490
  timeout?: number;
3099
4491
  }): Promise<boolean>;
3100
4492
  /** 替换全部内容 */
3101
- replaceAll(content: string, timeout?: number): Promise<boolean>;
4493
+ replaceAll(content: string, timeoutOrOptions?: number | LogCallOptions): Promise<boolean>;
3102
4494
  /**
3103
4495
  * 订阅 Flow:先收到 subscribed,再多次 update。
3104
4496
  * resolve 后请保留 dispose 或调用 unsubscribe(subscriptionId) 以释放原生协程与 JS 回调。
3105
4497
  */
3106
- subscribe(stream: LogStreamType, onUpdate: (payload: LogSubscribeUpdatePayload) => void, options?: {
3107
- timeout?: number;
3108
- }): Promise<{
4498
+ subscribe(stream: LogStreamType, onUpdate: (payload: LogSubscribeUpdatePayload) => void, options?: LogCallOptions): Promise<{
3109
4499
  subscriptionId: string;
3110
4500
  dispose: () => Promise<void>;
3111
4501
  }>;
@@ -3127,4 +4517,4 @@ declare class Log {
3127
4517
  /** 默认单例,用法与 floatingwindow 模块导出的 float 一致 */
3128
4518
  declare const log: Log;
3129
4519
 
3130
- export { type AccessibilityEvent, type AccessibilityEventData, AccessibilityEventFilter, type AccessibilityEventFilterConfig, type AccessibilityEventListener, AppInfo, AssistsX, AssistsXAsync, BarUtils, BarUtilsCallMethod, type BarUtilsCallMethodType, Bounds, CallMethod, type CallMethodType, CallResponse, type Contact, DeviceInfo, FileIO, type FileInfo, type FileListItem, type FileUploadInfo, FileUtils, Float, FloatCallMethod, type FloatCallMethodType, Gallery, type GalleryDeleteResponse, type GalleryResponse, Http, type HttpConfig, type HttpDownloadResponse, type HttpResponse, type ImageProcessResult, type ImageRotateDegree, type ImageSaveResult, type ImageSize, type ImageType, ImageUtils, Ime, ImeAction, type IsCurrentInputMethodResponse, type IsInputMethodEnabledResponse, Log, LogCallMethod, type LogCallMethodType, LogStream, type LogStreamType, type LogSubscribeUpdatePayload, type LogUpdateData, type LogUpdateEvent, type LogUploadOptions, type LogUploadResult, Mlkit, MlkitCallMethod, type MlkitCallMethodType, type MlkitRegion, Node, NodeClassValue, NodeLookupScope, type OpenInputMethodSettingsResponse, Path, type PerformEditorActionResponse, type RecognizeTextInScreenshotPosition, type RecognizeTextInScreenshotResult, type RecognizeTextRegion, type Screen, type ScreenTextJsonResult, type ScreenTextRecognitionResult, type StepState, type StepStatus, type TextPosition, type WebFloatingWindowOptions, WindowFlags, accessibilityEventListeners, barUtils, callbacks, decodeBase64UTF8, ensureAssistsXPinia, fileIO, fileUtils, float, gallery, generateUUID, http, imageUtils, ime, log, logUpdateListeners, mlkit, pathUtils, screen, sleep, useStepStore };
4520
+ export { type AccessibilityEvent, type AccessibilityEventData, AccessibilityEventFilter, type AccessibilityEventFilterConfig, type AccessibilityEventListener, AppInfo, AssistsX, AssistsXAsync, BarUtils, BarUtilsCallMethod, type BarUtilsCallMethodType, Bounds, CallMethod, type CallMethodType, CallResponse, type Contact, Db, type DbBatchItemResult, DbCallMethod, type DbCallMethodType, type DbCallOptions, type DbExecBatchOptions, type DbExecBatchResult, type DbExecResult, type DbQueryResult, type DbRow, type DbTarget, DeviceInfo, FileIO, type FileInfo, type FileListItem, type FileUploadInfo, FileUtils, Float, FloatCallMethod, type FloatCallMethodType, Gallery, type GalleryDeleteResponse, type GalleryResponse, Http, type HttpConfig, type HttpDownloadResponse, type HttpResponse, type ImageProcessResult, type ImageRotateDegree, type ImageSaveResult, type ImageSize, type ImageType, ImageUtils, Ime, ImeAction, type IsCurrentInputMethodResponse, type IsInputMethodEnabledResponse, Log, LogCallMethod, type LogCallMethodType, type LogCallOptions, LogStream, type LogStreamType, type LogSubscribeUpdatePayload, type LogTarget, type LogUpdateData, type LogUpdateEvent, type LogUploadOptions, type LogUploadResult, Mlkit, MlkitCallMethod, type MlkitCallMethodType, type MlkitRegion, NODE_LOOKUP_SCOPE_ACTIVE_WINDOW, NODE_LOOKUP_SCOPE_ALL_WINDOWS, Node, NodeAsync, NodeClassValue, type NodeLookupScope, type OpenInputMethodSettingsResponse, Path, type PerformEditorActionResponse, PluginInfo, type RecognizeTextInScreenshotPosition, type RecognizeTextInScreenshotResult, type RecognizeTextRegion, type Screen, type ScreenTextJsonResult, type ScreenTextRecognitionResult, Screenshot, type ScreenshotBase64Data, ScreenshotCallMethod, type ScreenshotCallMethodType, type ScreenshotImageFormat, Step, StepAsync, type StepData, StepError, type StepImpl, type StepInterceptor, type StepResult, type StepState, type StepStatus, StepStopError, type TakeScreenshotBase64Options, type TakeScreenshotNodesBase64Options, type TextPosition, type WebFloatingWindowOptions, WindowFlags, accessibilityEventListeners, barUtils, callbacks, db, decodeBase64UTF8, ensureAssistsXPinia, fileIO, fileUtils, float, gallery, generateUUID, http, imageUtils, ime, log, logUpdateListeners, mlkit, pathUtils, screen, screenshot, sleep, useStepStore };