assistsx-js 0.0.2024 → 0.0.2025

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.
@@ -20,11 +20,17 @@ export class AssistsXAsync {
20
20
  * 执行异步调用
21
21
  * @param method 方法名
22
22
  * @param args 参数对象
23
+ * @param timeout 超时时间(秒),默认30秒
23
24
  * @returns Promise<调用响应>
24
25
  */
25
26
  private static async asyncCall(
26
27
  method: string,
27
- { args, node, nodes }: { args?: any; node?: Node; nodes?: Node[] } = {}
28
+ {
29
+ args,
30
+ node,
31
+ nodes,
32
+ timeout = 30,
33
+ }: { args?: any; node?: Node; nodes?: Node[]; timeout?: number } = {}
28
34
  ): Promise<CallResponse> {
29
35
  const uuid = generateUUID();
30
36
  const params = {
@@ -42,7 +48,7 @@ export class AssistsXAsync {
42
48
  // 超时后删除回调函数
43
49
  callbacks.delete(uuid);
44
50
  resolve(new CallResponse(0, null, uuid));
45
- }, 1000 * 30);
51
+ }, timeout * 1000);
46
52
  });
47
53
  const result = window.assistsxAsync.call(JSON.stringify(params));
48
54
  const promiseResult = await promise;
@@ -61,22 +67,32 @@ export class AssistsXAsync {
61
67
  /**
62
68
  * 设置悬浮窗标志
63
69
  * @param flags 标志
70
+ * @param timeout 超时时间(秒),默认30秒
64
71
  * @returns 是否设置成功
65
72
  */
66
- public static async setOverlayFlags(flags: number): Promise<boolean> {
73
+ public static async setOverlayFlags(
74
+ flags: number,
75
+ timeout?: number
76
+ ): Promise<boolean> {
67
77
  const response = await this.asyncCall(CallMethod.setOverlayFlags, {
68
78
  args: { flags: flags },
79
+ timeout,
69
80
  });
70
81
  return response.getDataOrDefault(false);
71
82
  }
72
83
  /**
73
84
  * 设置悬浮窗标志
74
85
  * @param flags 标志
86
+ * @param timeout 超时时间(秒),默认30秒
75
87
  * @returns 是否设置成功
76
88
  */
77
- public static async setOverlayFlagList(flags: number[]): Promise<boolean> {
89
+ public static async setOverlayFlagList(
90
+ flags: number[],
91
+ timeout?: number
92
+ ): Promise<boolean> {
78
93
  const response = await this.asyncCall(CallMethod.setOverlayFlags, {
79
94
  args: { flags: flags },
95
+ timeout,
80
96
  });
81
97
  return response.getDataOrDefault(false);
82
98
  }
@@ -86,6 +102,7 @@ export class AssistsXAsync {
86
102
  * @param filterViewId 视图ID过滤
87
103
  * @param filterDes 描述过滤
88
104
  * @param filterText 文本过滤
105
+ * @param timeout 超时时间(秒),默认30秒
89
106
  * @returns 节点数组
90
107
  */
91
108
  public static async getAllNodes({
@@ -93,14 +110,17 @@ export class AssistsXAsync {
93
110
  filterViewId,
94
111
  filterDes,
95
112
  filterText,
113
+ timeout,
96
114
  }: {
97
115
  filterClass?: string;
98
116
  filterViewId?: string;
99
117
  filterDes?: string;
100
118
  filterText?: string;
119
+ timeout?: number;
101
120
  } = {}): Promise<Node[]> {
102
121
  const response = await this.asyncCall(CallMethod.getAllNodes, {
103
122
  args: { filterClass, filterViewId, filterDes, filterText },
123
+ timeout,
104
124
  });
105
125
  return Node.fromJSONArray(response.getDataOrDefault("[]"));
106
126
  }
@@ -109,12 +129,18 @@ export class AssistsXAsync {
109
129
  * 设置节点文本
110
130
  * @param node 目标节点
111
131
  * @param text 要设置的文本
132
+ * @param timeout 超时时间(秒),默认30秒
112
133
  * @returns 是否设置成功
113
134
  */
114
- public static async setNodeText(node: Node, text: string): Promise<boolean> {
135
+ public static async setNodeText(
136
+ node: Node,
137
+ text: string,
138
+ timeout?: number
139
+ ): Promise<boolean> {
115
140
  const response = await this.asyncCall(CallMethod.setNodeText, {
116
141
  args: { text },
117
142
  node,
143
+ timeout,
118
144
  });
119
145
  return response.getDataOrDefault(false);
120
146
  }
@@ -123,27 +149,30 @@ export class AssistsXAsync {
123
149
  * 对指定节点进行截图
124
150
  * @param nodes 要截图的节点数组
125
151
  * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
152
+ * @param timeout 超时时间(秒),默认30秒
126
153
  * @returns 截图路径数组
127
154
  */
128
155
  public static async takeScreenshotNodes(
129
156
  nodes: Node[],
130
- overlayHiddenScreenshotDelayMillis: number = 250
157
+ overlayHiddenScreenshotDelayMillis: number = 250,
158
+ timeout?: number
131
159
  ): Promise<string[]> {
132
160
  const response = await this.asyncCall(CallMethod.takeScreenshot, {
133
161
  nodes,
134
162
  args: { overlayHiddenScreenshotDelayMillis },
163
+ timeout,
135
164
  });
136
165
  const data = response.getDataOrDefault("");
137
166
  return data.images;
138
167
  }
139
- public static async scanQR(): Promise<string> {
140
- const response = await this.asyncCall(CallMethod.scanQR);
168
+ public static async scanQR(timeout?: number): Promise<string> {
169
+ const response = await this.asyncCall(CallMethod.scanQR, { timeout });
141
170
  const data = response.getDataOrDefault({ value: "" });
142
171
  return data.value;
143
172
  }
144
173
  public static async loadWebViewOverlay(
145
174
  url: string,
146
- options: WebFloatingWindowOptions = {}
175
+ options: WebFloatingWindowOptions & { timeout?: number } = {}
147
176
  ): Promise<any> {
148
177
  const {
149
178
  initialWidth,
@@ -153,6 +182,7 @@ export class AssistsXAsync {
153
182
  maxWidth,
154
183
  maxHeight,
155
184
  initialCenter,
185
+ timeout,
156
186
  } = options;
157
187
  const response = await this.asyncCall(CallMethod.loadWebViewOverlay, {
158
188
  args: {
@@ -165,6 +195,7 @@ export class AssistsXAsync {
165
195
  maxHeight,
166
196
  initialCenter,
167
197
  },
198
+ timeout,
168
199
  });
169
200
  const data = response.getDataOrDefault({});
170
201
  return data;
@@ -173,41 +204,57 @@ export class AssistsXAsync {
173
204
  /**
174
205
  * 点击节点
175
206
  * @param node 要点击的节点
207
+ * @param timeout 超时时间(秒),默认30秒
176
208
  * @returns 是否点击成功
177
209
  */
178
- public static async click(node: Node): Promise<boolean> {
179
- const response = await this.asyncCall(CallMethod.click, { node });
210
+ public static async click(node: Node, timeout?: number): Promise<boolean> {
211
+ const response = await this.asyncCall(CallMethod.click, { node, timeout });
180
212
  return response.getDataOrDefault(false);
181
213
  }
182
214
 
183
215
  /**
184
216
  * 长按节点
185
217
  * @param node 要长按的节点
218
+ * @param timeout 超时时间(秒),默认30秒
186
219
  * @returns 是否长按成功
187
220
  */
188
- public static async longClick(node: Node): Promise<boolean> {
189
- const response = await this.asyncCall(CallMethod.longClick, { node });
221
+ public static async longClick(
222
+ node: Node,
223
+ timeout?: number
224
+ ): Promise<boolean> {
225
+ const response = await this.asyncCall(CallMethod.longClick, {
226
+ node,
227
+ timeout,
228
+ });
190
229
  return response.getDataOrDefault(false);
191
230
  }
192
231
 
193
232
  /**
194
233
  * 启动应用
195
234
  * @param packageName 应用包名
235
+ * @param timeout 超时时间(秒),默认30秒
196
236
  * @returns 是否启动成功
197
237
  */
198
- public static async launchApp(packageName: string): Promise<boolean> {
238
+ public static async launchApp(
239
+ packageName: string,
240
+ timeout?: number
241
+ ): Promise<boolean> {
199
242
  const response = await this.asyncCall(CallMethod.launchApp, {
200
243
  args: { packageName },
244
+ timeout,
201
245
  });
202
246
  return response.getDataOrDefault(false);
203
247
  }
204
248
 
205
249
  /**
206
250
  * 获取当前应用包名
251
+ * @param timeout 超时时间(秒),默认30秒
207
252
  * @returns 包名
208
253
  */
209
- public static async getPackageName(): Promise<string> {
210
- const response = await this.asyncCall(CallMethod.getPackageName);
254
+ public static async getPackageName(timeout?: number): Promise<string> {
255
+ const response = await this.asyncCall(CallMethod.getPackageName, {
256
+ timeout,
257
+ });
211
258
  return response.getDataOrDefault("");
212
259
  }
213
260
 
@@ -215,14 +262,17 @@ export class AssistsXAsync {
215
262
  * 显示悬浮提示
216
263
  * @param text 提示文本
217
264
  * @param delay 显示时长(毫秒)
265
+ * @param timeout 超时时间(秒),默认30秒
218
266
  * @returns 是否显示成功
219
267
  */
220
268
  public static async overlayToast(
221
269
  text: string,
222
- delay: number = 2000
270
+ delay: number = 2000,
271
+ timeout?: number
223
272
  ): Promise<boolean> {
224
273
  const response = await this.asyncCall(CallMethod.overlayToast, {
225
274
  args: { text, delay },
275
+ timeout,
226
276
  });
227
277
  return response.getDataOrDefault(false);
228
278
  }
@@ -234,6 +284,7 @@ export class AssistsXAsync {
234
284
  * @param filterText 文本过滤
235
285
  * @param filterDes 描述过滤
236
286
  * @param node 父节点范围
287
+ * @param timeout 超时时间(秒),默认30秒
237
288
  * @returns 节点数组
238
289
  */
239
290
  public static async findById(
@@ -243,16 +294,19 @@ export class AssistsXAsync {
243
294
  filterText,
244
295
  filterDes,
245
296
  node,
297
+ timeout,
246
298
  }: {
247
299
  filterClass?: string;
248
300
  filterText?: string;
249
301
  filterDes?: string;
250
302
  node?: Node;
303
+ timeout?: number;
251
304
  } = {}
252
305
  ): Promise<Node[]> {
253
306
  const response = await this.asyncCall(CallMethod.findById, {
254
307
  args: { id, filterClass, filterText, filterDes },
255
308
  node,
309
+ timeout,
256
310
  });
257
311
  return Node.fromJSONArray(response.getDataOrDefault("[]"));
258
312
  }
@@ -264,6 +318,7 @@ export class AssistsXAsync {
264
318
  * @param filterViewId 视图ID过滤
265
319
  * @param filterDes 描述过滤
266
320
  * @param node 父节点范围
321
+ * @param timeout 超时时间(秒),默认30秒
267
322
  * @returns 节点数组
268
323
  */
269
324
  public static async findByText(
@@ -273,16 +328,19 @@ export class AssistsXAsync {
273
328
  filterViewId,
274
329
  filterDes,
275
330
  node,
331
+ timeout,
276
332
  }: {
277
333
  filterClass?: string;
278
334
  filterViewId?: string;
279
335
  filterDes?: string;
280
336
  node?: Node;
337
+ timeout?: number;
281
338
  } = {}
282
339
  ): Promise<Node[]> {
283
340
  const response = await this.asyncCall(CallMethod.findByText, {
284
341
  args: { text, filterClass, filterViewId, filterDes },
285
342
  node,
343
+ timeout,
286
344
  });
287
345
  return Node.fromJSONArray(response.getDataOrDefault("[]"));
288
346
  }
@@ -294,6 +352,7 @@ export class AssistsXAsync {
294
352
  * @param filterViewId 视图ID过滤
295
353
  * @param filterDes 描述过滤
296
354
  * @param node 父节点范围
355
+ * @param timeout 超时时间(秒),默认30秒
297
356
  * @returns 节点数组
298
357
  */
299
358
  public static async findByTags(
@@ -303,16 +362,19 @@ export class AssistsXAsync {
303
362
  filterViewId,
304
363
  filterDes,
305
364
  node,
365
+ timeout,
306
366
  }: {
307
367
  filterText?: string;
308
368
  filterViewId?: string;
309
369
  filterDes?: string;
310
370
  node?: Node;
371
+ timeout?: number;
311
372
  } = {}
312
373
  ): Promise<Node[]> {
313
374
  const response = await this.asyncCall(CallMethod.findByTags, {
314
375
  args: { className, filterText, filterViewId, filterDes },
315
376
  node,
377
+ timeout,
316
378
  });
317
379
  return Node.fromJSONArray(response.getDataOrDefault("[]"));
318
380
  }
@@ -320,11 +382,16 @@ export class AssistsXAsync {
320
382
  /**
321
383
  * 查找所有匹配文本的节点
322
384
  * @param text 要查找的文本
385
+ * @param timeout 超时时间(秒),默认30秒
323
386
  * @returns 节点数组
324
387
  */
325
- public static async findByTextAllMatch(text: string): Promise<Node[]> {
388
+ public static async findByTextAllMatch(
389
+ text: string,
390
+ timeout?: number
391
+ ): Promise<Node[]> {
326
392
  const response = await this.asyncCall(CallMethod.findByTextAllMatch, {
327
393
  args: { text },
394
+ timeout,
328
395
  });
329
396
  return Node.fromJSONArray(response.getDataOrDefault("[]"));
330
397
  }
@@ -332,36 +399,45 @@ export class AssistsXAsync {
332
399
  /**
333
400
  * 检查是否包含指定文本
334
401
  * @param text 要检查的文本
402
+ * @param timeout 超时时间(秒),默认30秒
335
403
  * @returns 是否包含
336
404
  */
337
- public static async containsText(text: string): Promise<boolean> {
405
+ public static async containsText(
406
+ text: string,
407
+ timeout?: number
408
+ ): Promise<boolean> {
338
409
  const response = await this.asyncCall(CallMethod.containsText, {
339
410
  args: { text },
411
+ timeout,
340
412
  });
341
413
  return response.getDataOrDefault(false);
342
414
  }
343
415
 
344
416
  /**
345
417
  * 获取所有文本
418
+ * @param timeout 超时时间(秒),默认30秒
346
419
  * @returns 文本数组
347
420
  */
348
- public static async getAllText(): Promise<string[]> {
349
- const response = await this.asyncCall(CallMethod.getAllText);
421
+ public static async getAllText(timeout?: number): Promise<string[]> {
422
+ const response = await this.asyncCall(CallMethod.getAllText, { timeout });
350
423
  return response.getDataOrDefault("[]");
351
424
  }
352
425
 
353
426
  /**
354
427
  * 查找第一个匹配标签的父节点
355
428
  * @param className 类名
429
+ * @param timeout 超时时间(秒),默认30秒
356
430
  * @returns 父节点
357
431
  */
358
432
  public static async findFirstParentByTags(
359
433
  node: Node,
360
- className: string
434
+ className: string,
435
+ timeout?: number
361
436
  ): Promise<Node> {
362
437
  const response = await this.asyncCall(CallMethod.findFirstParentByTags, {
363
438
  args: { className },
364
439
  node,
440
+ timeout,
365
441
  });
366
442
  return Node.create(response.getDataOrDefault("{}"));
367
443
  }
@@ -369,31 +445,47 @@ export class AssistsXAsync {
369
445
  /**
370
446
  * 获取节点的所有子节点
371
447
  * @param node 父节点
448
+ * @param timeout 超时时间(秒),默认30秒
372
449
  * @returns 子节点数组
373
450
  */
374
- public static async getNodes(node: Node): Promise<Node[]> {
375
- const response = await this.asyncCall(CallMethod.getNodes, { node });
451
+ public static async getNodes(node: Node, timeout?: number): Promise<Node[]> {
452
+ const response = await this.asyncCall(CallMethod.getNodes, {
453
+ node,
454
+ timeout,
455
+ });
376
456
  return Node.fromJSONArray(response.getDataOrDefault("[]"));
377
457
  }
378
458
 
379
459
  /**
380
460
  * 获取节点的直接子节点
381
461
  * @param node 父节点
462
+ * @param timeout 超时时间(秒),默认30秒
382
463
  * @returns 子节点数组
383
464
  */
384
- public static async getChildren(node: Node): Promise<Node[]> {
385
- const response = await this.asyncCall(CallMethod.getChildren, { node });
465
+ public static async getChildren(
466
+ node: Node,
467
+ timeout?: number
468
+ ): Promise<Node[]> {
469
+ const response = await this.asyncCall(CallMethod.getChildren, {
470
+ node,
471
+ timeout,
472
+ });
386
473
  return Node.fromJSONArray(response.getDataOrDefault([]));
387
474
  }
388
475
 
389
476
  /**
390
477
  * 查找第一个可点击的父节点
391
478
  * @param node 起始节点
479
+ * @param timeout 超时时间(秒),默认30秒
392
480
  * @returns 可点击的父节点
393
481
  */
394
- public static async findFirstParentClickable(node: Node): Promise<Node> {
482
+ public static async findFirstParentClickable(
483
+ node: Node,
484
+ timeout?: number
485
+ ): Promise<Node> {
395
486
  const response = await this.asyncCall(CallMethod.findFirstParentClickable, {
396
487
  node,
488
+ timeout,
397
489
  });
398
490
  return Node.create(response.getDataOrDefault("{}"));
399
491
  }
@@ -401,11 +493,16 @@ export class AssistsXAsync {
401
493
  /**
402
494
  * 获取节点在屏幕中的边界
403
495
  * @param node 目标节点
496
+ * @param timeout 超时时间(秒),默认30秒
404
497
  * @returns 边界对象
405
498
  */
406
- public static async getBoundsInScreen(node: Node): Promise<Bounds> {
499
+ public static async getBoundsInScreen(
500
+ node: Node,
501
+ timeout?: number
502
+ ): Promise<Bounds> {
407
503
  const response = await this.asyncCall(CallMethod.getBoundsInScreen, {
408
504
  node,
505
+ timeout,
409
506
  });
410
507
  return Bounds.fromData(response.getDataOrDefault({}));
411
508
  }
@@ -415,6 +512,7 @@ export class AssistsXAsync {
415
512
  * @param node 目标节点
416
513
  * @param compareNode 比较节点
417
514
  * @param isFullyByCompareNode 是否完全可见
515
+ * @param timeout 超时时间(秒),默认30秒
418
516
  * @returns 是否可见
419
517
  */
420
518
  public static async isVisible(
@@ -422,11 +520,17 @@ export class AssistsXAsync {
422
520
  {
423
521
  compareNode,
424
522
  isFullyByCompareNode,
425
- }: { compareNode?: Node; isFullyByCompareNode?: boolean } = {}
523
+ timeout,
524
+ }: {
525
+ compareNode?: Node;
526
+ isFullyByCompareNode?: boolean;
527
+ timeout?: number;
528
+ } = {}
426
529
  ): Promise<boolean> {
427
530
  const response = await this.asyncCall(CallMethod.isVisible, {
428
531
  node,
429
532
  args: { compareNode, isFullyByCompareNode },
533
+ timeout,
430
534
  });
431
535
  return response.getDataOrDefault(false);
432
536
  }
@@ -436,52 +540,61 @@ export class AssistsXAsync {
436
540
  * @param x 横坐标
437
541
  * @param y 纵坐标
438
542
  * @param duration 持续时间
543
+ * @param timeout 超时时间(秒),默认30秒
439
544
  * @returns 是否成功
440
545
  */
441
546
  public static async clickByGesture(
442
547
  x: number,
443
548
  y: number,
444
- duration: number
549
+ duration: number,
550
+ timeout?: number
445
551
  ): Promise<boolean> {
446
552
  const response = await this.asyncCall(CallMethod.clickByGesture, {
447
553
  args: { x, y, duration },
554
+ timeout,
448
555
  });
449
556
  return response.getDataOrDefault(false);
450
557
  }
451
558
 
452
559
  /**
453
560
  * 返回操作
561
+ * @param timeout 超时时间(秒),默认30秒
454
562
  * @returns 是否成功
455
563
  */
456
- public static async back(): Promise<boolean> {
457
- const response = await this.asyncCall(CallMethod.back);
564
+ public static async back(timeout?: number): Promise<boolean> {
565
+ const response = await this.asyncCall(CallMethod.back, { timeout });
458
566
  return response.getDataOrDefault(false);
459
567
  }
460
568
 
461
569
  /**
462
570
  * 回到主页
571
+ * @param timeout 超时时间(秒),默认30秒
463
572
  * @returns 是否成功
464
573
  */
465
- public static async home(): Promise<boolean> {
466
- const response = await this.asyncCall(CallMethod.home);
574
+ public static async home(timeout?: number): Promise<boolean> {
575
+ const response = await this.asyncCall(CallMethod.home, { timeout });
467
576
  return response.getDataOrDefault(false);
468
577
  }
469
578
 
470
579
  /**
471
580
  * 打开通知栏
581
+ * @param timeout 超时时间(秒),默认30秒
472
582
  * @returns 是否成功
473
583
  */
474
- public static async notifications(): Promise<boolean> {
475
- const response = await this.asyncCall(CallMethod.notifications);
584
+ public static async notifications(timeout?: number): Promise<boolean> {
585
+ const response = await this.asyncCall(CallMethod.notifications, {
586
+ timeout,
587
+ });
476
588
  return response.getDataOrDefault(false);
477
589
  }
478
590
 
479
591
  /**
480
592
  * 显示最近应用
593
+ * @param timeout 超时时间(秒),默认30秒
481
594
  * @returns 是否成功
482
595
  */
483
- public static async recentApps(): Promise<boolean> {
484
- const response = await this.asyncCall(CallMethod.recentApps);
596
+ public static async recentApps(timeout?: number): Promise<boolean> {
597
+ const response = await this.asyncCall(CallMethod.recentApps, { timeout });
485
598
  return response.getDataOrDefault(false);
486
599
  }
487
600
 
@@ -489,17 +602,23 @@ export class AssistsXAsync {
489
602
  * 在节点中粘贴文本
490
603
  * @param node 目标节点
491
604
  * @param text 要粘贴的文本
605
+ * @param timeout 超时时间(秒),默认30秒
492
606
  * @returns 是否成功
493
607
  */
494
- public static async paste(node: Node, text: string): Promise<boolean> {
608
+ public static async paste(
609
+ node: Node,
610
+ text: string,
611
+ timeout?: number
612
+ ): Promise<boolean> {
495
613
  const response = await this.asyncCall(CallMethod.paste, {
496
614
  args: { text },
497
615
  node,
616
+ timeout,
498
617
  });
499
618
  return response.getDataOrDefault(false);
500
619
  }
501
- public static async focus(node: Node): Promise<boolean> {
502
- const response = await this.asyncCall(CallMethod.focus, { node });
620
+ public static async focus(node: Node, timeout?: number): Promise<boolean> {
621
+ const response = await this.asyncCall(CallMethod.focus, { node, timeout });
503
622
  return response.getDataOrDefault(false);
504
623
  }
505
624
 
@@ -508,16 +627,19 @@ export class AssistsXAsync {
508
627
  * @param node 目标节点
509
628
  * @param selectionStart 选择起始位置
510
629
  * @param selectionEnd 选择结束位置
630
+ * @param timeout 超时时间(秒),默认30秒
511
631
  * @returns 是否成功
512
632
  */
513
633
  public static async selectionText(
514
634
  node: Node,
515
635
  selectionStart: number,
516
- selectionEnd: number
636
+ selectionEnd: number,
637
+ timeout?: number
517
638
  ): Promise<boolean> {
518
639
  const response = await this.asyncCall(CallMethod.selectionText, {
519
640
  args: { selectionStart, selectionEnd },
520
641
  node,
642
+ timeout,
521
643
  });
522
644
  return response.getDataOrDefault(false);
523
645
  }
@@ -525,11 +647,16 @@ export class AssistsXAsync {
525
647
  /**
526
648
  * 向前滚动
527
649
  * @param node 可滚动节点
650
+ * @param timeout 超时时间(秒),默认30秒
528
651
  * @returns 是否成功
529
652
  */
530
- public static async scrollForward(node: Node): Promise<boolean> {
653
+ public static async scrollForward(
654
+ node: Node,
655
+ timeout?: number
656
+ ): Promise<boolean> {
531
657
  const response = await this.asyncCall(CallMethod.scrollForward, {
532
658
  node,
659
+ timeout,
533
660
  });
534
661
  return response.getDataOrDefault(false);
535
662
  }
@@ -537,11 +664,16 @@ export class AssistsXAsync {
537
664
  /**
538
665
  * 向后滚动
539
666
  * @param node 可滚动节点
667
+ * @param timeout 超时时间(秒),默认30秒
540
668
  * @returns 是否成功
541
669
  */
542
- public static async scrollBackward(node: Node): Promise<boolean> {
670
+ public static async scrollBackward(
671
+ node: Node,
672
+ timeout?: number
673
+ ): Promise<boolean> {
543
674
  const response = await this.asyncCall(CallMethod.scrollBackward, {
544
675
  node,
676
+ timeout,
545
677
  });
546
678
  return response.getDataOrDefault(false);
547
679
  }
@@ -553,6 +685,7 @@ export class AssistsXAsync {
553
685
  * @param offsetY Y轴偏移
554
686
  * @param switchWindowIntervalDelay 窗口切换延迟
555
687
  * @param clickDuration 点击持续时间
688
+ * @param timeout 超时时间(秒),默认30秒
556
689
  * @returns 是否成功
557
690
  */
558
691
  public static async clickNodeByGesture(
@@ -562,16 +695,19 @@ export class AssistsXAsync {
562
695
  offsetY,
563
696
  switchWindowIntervalDelay,
564
697
  clickDuration,
698
+ timeout,
565
699
  }: {
566
700
  offsetX?: number;
567
701
  offsetY?: number;
568
702
  switchWindowIntervalDelay?: number;
569
703
  clickDuration?: number;
704
+ timeout?: number;
570
705
  } = {}
571
706
  ): Promise<boolean> {
572
707
  const response = await this.asyncCall(CallMethod.clickNodeByGesture, {
573
708
  node,
574
709
  args: { offsetX, offsetY, switchWindowIntervalDelay, clickDuration },
710
+ timeout,
575
711
  });
576
712
  return response.getDataOrDefault(false);
577
713
  }
@@ -584,6 +720,7 @@ export class AssistsXAsync {
584
720
  * @param switchWindowIntervalDelay 窗口切换延迟
585
721
  * @param clickDuration 点击持续时间
586
722
  * @param clickInterval 点击间隔
723
+ * @param timeout 超时时间(秒),默认30秒
587
724
  * @returns 是否成功
588
725
  */
589
726
  public static async doubleClickNodeByGesture(
@@ -594,12 +731,14 @@ export class AssistsXAsync {
594
731
  switchWindowIntervalDelay,
595
732
  clickDuration,
596
733
  clickInterval,
734
+ timeout,
597
735
  }: {
598
736
  offsetX?: number;
599
737
  offsetY?: number;
600
738
  switchWindowIntervalDelay?: number;
601
739
  clickDuration?: number;
602
740
  clickInterval?: number;
741
+ timeout?: number;
603
742
  } = {}
604
743
  ): Promise<boolean> {
605
744
  const response = await this.asyncCall(CallMethod.doubleClickNodeByGesture, {
@@ -611,6 +750,7 @@ export class AssistsXAsync {
611
750
  clickDuration,
612
751
  clickInterval,
613
752
  },
753
+ timeout,
614
754
  });
615
755
  return response.getDataOrDefault(false);
616
756
  }
@@ -619,15 +759,17 @@ export class AssistsXAsync {
619
759
  * @param startPoint
620
760
  * @param endPoint
621
761
  * @param param2
762
+ * @param timeout 超时时间(秒),默认30秒
622
763
  * @returns
623
764
  */
624
765
  public static async performLinearGesture(
625
766
  startPoint: { x: number; y: number },
626
767
  endPoint: { x: number; y: number },
627
- { duration }: { duration?: number } = {}
768
+ { duration, timeout }: { duration?: number; timeout?: number } = {}
628
769
  ): Promise<boolean> {
629
770
  const response = await this.asyncCall(CallMethod.performLinearGesture, {
630
771
  args: { startPoint, endPoint, duration },
772
+ timeout,
631
773
  });
632
774
  return response.getDataOrDefault(false);
633
775
  }
@@ -639,11 +781,13 @@ export class AssistsXAsync {
639
781
  matchedText,
640
782
  timeoutMillis,
641
783
  longPressDuration,
784
+ timeout,
642
785
  }: {
643
786
  matchedPackageName?: string;
644
787
  matchedText?: string;
645
788
  timeoutMillis?: number;
646
789
  longPressDuration?: number;
790
+ timeout?: number;
647
791
  } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }
648
792
  ): Promise<boolean> {
649
793
  const response = await this.asyncCall(
@@ -657,6 +801,7 @@ export class AssistsXAsync {
657
801
  timeoutMillis,
658
802
  longPressDuration,
659
803
  },
804
+ timeout,
660
805
  }
661
806
  );
662
807
  return response.getDataOrDefault(false);
@@ -670,11 +815,13 @@ export class AssistsXAsync {
670
815
  matchedText,
671
816
  timeoutMillis,
672
817
  longPressDuration,
818
+ timeout,
673
819
  }: {
674
820
  matchedPackageName?: string;
675
821
  matchedText?: string;
676
822
  timeoutMillis?: number;
677
823
  longPressDuration?: number;
824
+ timeout?: number;
678
825
  } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }
679
826
  ): Promise<boolean> {
680
827
  const response = await this.asyncCall(
@@ -688,48 +835,65 @@ export class AssistsXAsync {
688
835
  timeoutMillis,
689
836
  longPressDuration,
690
837
  },
838
+ timeout,
691
839
  }
692
840
  );
693
841
  return response.getDataOrDefault(false);
694
842
  }
695
- public static async getAppInfo(packageName: string): Promise<any> {
843
+ public static async getAppInfo(
844
+ packageName: string,
845
+ timeout?: number
846
+ ): Promise<any> {
696
847
  const response = await this.asyncCall(CallMethod.getAppInfo, {
697
848
  args: { packageName },
849
+ timeout,
698
850
  });
699
851
  return response.getDataOrDefault({});
700
852
  }
701
- public static async getUniqueDeviceId(): Promise<any> {
702
- const response = await this.asyncCall(CallMethod.getUniqueDeviceId);
853
+ public static async getUniqueDeviceId(timeout?: number): Promise<any> {
854
+ const response = await this.asyncCall(CallMethod.getUniqueDeviceId, {
855
+ timeout,
856
+ });
703
857
  return response.getDataOrDefault("");
704
858
  }
705
- public static async getAndroidID(): Promise<any> {
706
- const response = await this.asyncCall(CallMethod.getAndroidID);
859
+ public static async getAndroidID(timeout?: number): Promise<any> {
860
+ const response = await this.asyncCall(CallMethod.getAndroidID, { timeout });
707
861
  return response.getDataOrDefault("");
708
862
  }
709
- public static async getMacAddress(): Promise<any> {
710
- const response = await this.asyncCall(CallMethod.getMacAddress);
863
+ public static async getMacAddress(timeout?: number): Promise<any> {
864
+ const response = await this.asyncCall(CallMethod.getMacAddress, {
865
+ timeout,
866
+ });
711
867
  return response.getDataOrDefault({});
712
868
  }
713
- public static async getDeviceInfo(): Promise<any> {
714
- const response = await this.asyncCall(CallMethod.getDeviceInfo);
869
+ public static async getDeviceInfo(timeout?: number): Promise<any> {
870
+ const response = await this.asyncCall(CallMethod.getDeviceInfo, {
871
+ timeout,
872
+ });
715
873
  return response.getDataOrDefault({});
716
874
  }
717
875
 
718
876
  /**
719
877
  * 获取屏幕尺寸
878
+ * @param timeout 超时时间(秒),默认30秒
720
879
  * @returns 屏幕尺寸对象
721
880
  */
722
- public static async getScreenSize(): Promise<any> {
723
- const response = await this.asyncCall(CallMethod.getScreenSize);
881
+ public static async getScreenSize(timeout?: number): Promise<any> {
882
+ const response = await this.asyncCall(CallMethod.getScreenSize, {
883
+ timeout,
884
+ });
724
885
  return response.getDataOrDefault("{}");
725
886
  }
726
887
 
727
888
  /**
728
889
  * 获取应用窗口尺寸
890
+ * @param timeout 超时时间(秒),默认30秒
729
891
  * @returns 应用窗口尺寸对象
730
892
  */
731
- public static async getAppScreenSize(): Promise<any> {
732
- const response = await this.asyncCall(CallMethod.getAppScreenSize);
893
+ public static async getAppScreenSize(timeout?: number): Promise<any> {
894
+ const response = await this.asyncCall(CallMethod.getAppScreenSize, {
895
+ timeout,
896
+ });
733
897
  return response.getDataOrDefault("{}");
734
898
  }
735
899