assistsx-js 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/index.cjs +439 -356
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +103 -32
- package/dist/index.d.ts +103 -32
- package/dist/index.global.js +9 -13
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +437 -356
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/assistsx-async.ts +83 -8
- package/src/assistsx.ts +54 -11
- package/src/index.ts +1 -0
- package/src/node-lookup-scope.ts +10 -0
- package/src/step-async.ts +71 -9
- package/src/step.ts +45 -13
package/package.json
CHANGED
package/src/assistsx-async.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { Bounds } from "./bounds";
|
|
|
9
9
|
import { generateUUID } from "./utils";
|
|
10
10
|
import { AppInfo } from "./app-info";
|
|
11
11
|
import { DeviceInfo } from "./device-info";
|
|
12
|
+
import type { NodeLookupScope } from "./node-lookup-scope";
|
|
12
13
|
import {
|
|
13
14
|
AssistsX,
|
|
14
15
|
callbacks,
|
|
@@ -156,15 +157,23 @@ export class AssistsXAsync {
|
|
|
156
157
|
filterDes,
|
|
157
158
|
filterText,
|
|
158
159
|
timeout,
|
|
160
|
+
scope,
|
|
159
161
|
}: {
|
|
160
162
|
filterClass?: string;
|
|
161
163
|
filterViewId?: string;
|
|
162
164
|
filterDes?: string;
|
|
163
165
|
filterText?: string;
|
|
164
166
|
timeout?: number;
|
|
167
|
+
scope?: NodeLookupScope;
|
|
165
168
|
} = {}): Promise<Node[]> {
|
|
166
169
|
const response = await this.asyncCall(CallMethod.getAllNodes, {
|
|
167
|
-
args: {
|
|
170
|
+
args: {
|
|
171
|
+
filterClass,
|
|
172
|
+
filterViewId,
|
|
173
|
+
filterDes,
|
|
174
|
+
filterText,
|
|
175
|
+
...(scope !== undefined ? { scope } : {}),
|
|
176
|
+
},
|
|
168
177
|
timeout,
|
|
169
178
|
});
|
|
170
179
|
const data = response.getDataOrDefault([]);
|
|
@@ -448,10 +457,27 @@ export class AssistsXAsync {
|
|
|
448
457
|
/**
|
|
449
458
|
* 获取当前应用包名
|
|
450
459
|
* @param timeout 超时时间(秒),默认30秒
|
|
451
|
-
* @returns 包名
|
|
452
460
|
*/
|
|
453
|
-
public static async getPackageName(timeout?: number): Promise<string
|
|
461
|
+
public static async getPackageName(timeout?: number): Promise<string>;
|
|
462
|
+
/**
|
|
463
|
+
* 获取当前应用包名
|
|
464
|
+
* @param options.timeout 超时时间(秒),默认30秒
|
|
465
|
+
* @param options.scope 节点查找范围(可选)
|
|
466
|
+
*/
|
|
467
|
+
public static async getPackageName(options: {
|
|
468
|
+
timeout?: number;
|
|
469
|
+
scope?: NodeLookupScope;
|
|
470
|
+
}): Promise<string>;
|
|
471
|
+
public static async getPackageName(
|
|
472
|
+
timeoutOrOptions?: number | { timeout?: number; scope?: NodeLookupScope }
|
|
473
|
+
): Promise<string> {
|
|
474
|
+
const normalized =
|
|
475
|
+
typeof timeoutOrOptions === "number"
|
|
476
|
+
? { timeout: timeoutOrOptions as number }
|
|
477
|
+
: (timeoutOrOptions ?? {});
|
|
478
|
+
const { timeout, scope } = normalized;
|
|
454
479
|
const response = await this.asyncCall(CallMethod.getPackageName, {
|
|
480
|
+
args: scope !== undefined ? { scope } : undefined,
|
|
455
481
|
timeout,
|
|
456
482
|
});
|
|
457
483
|
return response.getDataOrDefault("");
|
|
@@ -494,16 +520,24 @@ export class AssistsXAsync {
|
|
|
494
520
|
filterDes,
|
|
495
521
|
node,
|
|
496
522
|
timeout,
|
|
523
|
+
scope,
|
|
497
524
|
}: {
|
|
498
525
|
filterClass?: string;
|
|
499
526
|
filterText?: string;
|
|
500
527
|
filterDes?: string;
|
|
501
528
|
node?: Node;
|
|
502
529
|
timeout?: number;
|
|
530
|
+
scope?: NodeLookupScope;
|
|
503
531
|
} = {}
|
|
504
532
|
): Promise<Node[]> {
|
|
505
533
|
const response = await this.asyncCall(CallMethod.findById, {
|
|
506
|
-
args: {
|
|
534
|
+
args: {
|
|
535
|
+
id,
|
|
536
|
+
filterClass,
|
|
537
|
+
filterText,
|
|
538
|
+
filterDes,
|
|
539
|
+
...(scope !== undefined ? { scope } : {}),
|
|
540
|
+
},
|
|
507
541
|
node,
|
|
508
542
|
timeout,
|
|
509
543
|
});
|
|
@@ -535,16 +569,24 @@ export class AssistsXAsync {
|
|
|
535
569
|
filterDes,
|
|
536
570
|
node,
|
|
537
571
|
timeout,
|
|
572
|
+
scope,
|
|
538
573
|
}: {
|
|
539
574
|
filterClass?: string;
|
|
540
575
|
filterViewId?: string;
|
|
541
576
|
filterDes?: string;
|
|
542
577
|
node?: Node;
|
|
543
578
|
timeout?: number;
|
|
579
|
+
scope?: NodeLookupScope;
|
|
544
580
|
} = {}
|
|
545
581
|
): Promise<Node[]> {
|
|
546
582
|
const response = await this.asyncCall(CallMethod.findByText, {
|
|
547
|
-
args: {
|
|
583
|
+
args: {
|
|
584
|
+
text,
|
|
585
|
+
filterClass,
|
|
586
|
+
filterViewId,
|
|
587
|
+
filterDes,
|
|
588
|
+
...(scope !== undefined ? { scope } : {}),
|
|
589
|
+
},
|
|
548
590
|
node,
|
|
549
591
|
timeout,
|
|
550
592
|
});
|
|
@@ -576,16 +618,24 @@ export class AssistsXAsync {
|
|
|
576
618
|
filterDes,
|
|
577
619
|
node,
|
|
578
620
|
timeout,
|
|
621
|
+
scope,
|
|
579
622
|
}: {
|
|
580
623
|
filterText?: string;
|
|
581
624
|
filterViewId?: string;
|
|
582
625
|
filterDes?: string;
|
|
583
626
|
node?: Node;
|
|
584
627
|
timeout?: number;
|
|
628
|
+
scope?: NodeLookupScope;
|
|
585
629
|
} = {}
|
|
586
630
|
): Promise<Node[]> {
|
|
587
631
|
const response = await this.asyncCall(CallMethod.findByTags, {
|
|
588
|
-
args: {
|
|
632
|
+
args: {
|
|
633
|
+
className,
|
|
634
|
+
filterText,
|
|
635
|
+
filterViewId,
|
|
636
|
+
filterDes,
|
|
637
|
+
...(scope !== undefined ? { scope } : {}),
|
|
638
|
+
},
|
|
589
639
|
node,
|
|
590
640
|
timeout,
|
|
591
641
|
});
|
|
@@ -603,14 +653,35 @@ export class AssistsXAsync {
|
|
|
603
653
|
* 查找所有匹配文本的节点
|
|
604
654
|
* @param text 要查找的文本
|
|
605
655
|
* @param timeout 超时时间(秒),默认30秒
|
|
606
|
-
* @returns 节点数组
|
|
607
656
|
*/
|
|
608
657
|
public static async findByTextAllMatch(
|
|
609
658
|
text: string,
|
|
610
659
|
timeout?: number
|
|
660
|
+
): Promise<Node[]>;
|
|
661
|
+
/**
|
|
662
|
+
* 查找所有匹配文本的节点
|
|
663
|
+
* @param text 要查找的文本
|
|
664
|
+
* @param options.timeout 超时时间(秒),默认30秒
|
|
665
|
+
* @param options.scope 节点查找范围(可选)
|
|
666
|
+
*/
|
|
667
|
+
public static async findByTextAllMatch(
|
|
668
|
+
text: string,
|
|
669
|
+
options: { timeout?: number; scope?: NodeLookupScope }
|
|
670
|
+
): Promise<Node[]>;
|
|
671
|
+
public static async findByTextAllMatch(
|
|
672
|
+
text: string,
|
|
673
|
+
timeoutOrOptions?: number | { timeout?: number; scope?: NodeLookupScope }
|
|
611
674
|
): Promise<Node[]> {
|
|
675
|
+
const normalized =
|
|
676
|
+
typeof timeoutOrOptions === "number"
|
|
677
|
+
? { timeout: timeoutOrOptions as number }
|
|
678
|
+
: (timeoutOrOptions ?? {});
|
|
679
|
+
const { timeout, scope } = normalized;
|
|
612
680
|
const response = await this.asyncCall(CallMethod.findByTextAllMatch, {
|
|
613
|
-
args: {
|
|
681
|
+
args: {
|
|
682
|
+
text,
|
|
683
|
+
...(scope !== undefined ? { scope } : {}),
|
|
684
|
+
},
|
|
614
685
|
timeout,
|
|
615
686
|
});
|
|
616
687
|
const data = response.getDataOrDefault([]);
|
|
@@ -1276,6 +1347,7 @@ export class AssistsXAsync {
|
|
|
1276
1347
|
* @param options.filePath 文件路径(可选,不提供则自动生成)
|
|
1277
1348
|
* @param options.prettyPrint 是否格式化输出,默认为 true
|
|
1278
1349
|
* @param options.timeout 超时时间(秒),默认30秒
|
|
1350
|
+
* @param options.scope 节点查找范围(可选)
|
|
1279
1351
|
* @returns 保存的文件路径
|
|
1280
1352
|
*/
|
|
1281
1353
|
public static async saveRootNodeTreeJson(
|
|
@@ -1283,18 +1355,21 @@ export class AssistsXAsync {
|
|
|
1283
1355
|
filePath?: string;
|
|
1284
1356
|
prettyPrint?: boolean;
|
|
1285
1357
|
timeout?: number;
|
|
1358
|
+
scope?: NodeLookupScope;
|
|
1286
1359
|
} = {}
|
|
1287
1360
|
): Promise<string> {
|
|
1288
1361
|
const {
|
|
1289
1362
|
filePath,
|
|
1290
1363
|
prettyPrint = true,
|
|
1291
1364
|
timeout,
|
|
1365
|
+
scope,
|
|
1292
1366
|
} = options;
|
|
1293
1367
|
|
|
1294
1368
|
const response = await this.asyncCall(CallMethod.saveRootNodeTreeJson, {
|
|
1295
1369
|
args: {
|
|
1296
1370
|
filePath,
|
|
1297
1371
|
prettyPrint,
|
|
1372
|
+
...(scope !== undefined ? { scope } : {}),
|
|
1298
1373
|
},
|
|
1299
1374
|
timeout,
|
|
1300
1375
|
});
|
package/src/assistsx.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { decodeBase64UTF8, generateUUID } from "./utils";
|
|
|
10
10
|
import { AccessibilityEventFilter } from "./accessibility-event-filter";
|
|
11
11
|
import { AppInfo } from "./app-info";
|
|
12
12
|
import { DeviceInfo } from "./device-info";
|
|
13
|
+
import type { NodeLookupScope } from "./node-lookup-scope";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* 无障碍事件数据结构
|
|
@@ -76,7 +77,7 @@ export interface Screen {
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
/** 全局屏幕尺寸,在 assistsxCallback 初始化后自动加载 */
|
|
79
|
-
export let screen: Screen
|
|
80
|
+
export let screen: Screen;
|
|
80
81
|
|
|
81
82
|
// 初始化全局回调函数
|
|
82
83
|
if (typeof window !== "undefined" && !window.assistsxCallback) {
|
|
@@ -246,14 +247,22 @@ export class AssistsX {
|
|
|
246
247
|
filterViewId,
|
|
247
248
|
filterDes,
|
|
248
249
|
filterText,
|
|
250
|
+
scope,
|
|
249
251
|
}: {
|
|
250
252
|
filterClass?: string;
|
|
251
253
|
filterViewId?: string;
|
|
252
254
|
filterDes?: string;
|
|
253
255
|
filterText?: string;
|
|
256
|
+
scope?: NodeLookupScope;
|
|
254
257
|
} = {}): Node[] {
|
|
255
258
|
const response = this.call(CallMethod.getAllNodes, {
|
|
256
|
-
args: {
|
|
259
|
+
args: {
|
|
260
|
+
filterClass,
|
|
261
|
+
filterViewId,
|
|
262
|
+
filterDes,
|
|
263
|
+
filterText,
|
|
264
|
+
...(scope !== undefined ? { scope } : {}),
|
|
265
|
+
},
|
|
257
266
|
});
|
|
258
267
|
const data = response.getDataOrDefault([]);
|
|
259
268
|
if (!Array.isArray(data)) {
|
|
@@ -434,8 +443,12 @@ export class AssistsX {
|
|
|
434
443
|
* 获取当前应用包名
|
|
435
444
|
* @returns 包名
|
|
436
445
|
*/
|
|
437
|
-
public static getPackageName(): string {
|
|
438
|
-
const
|
|
446
|
+
public static getPackageName(options: { scope?: NodeLookupScope } = {}): string {
|
|
447
|
+
const { scope } = options;
|
|
448
|
+
const response = this.call(
|
|
449
|
+
CallMethod.getPackageName,
|
|
450
|
+
scope !== undefined ? { args: { scope } } : {}
|
|
451
|
+
);
|
|
439
452
|
return response.getDataOrDefault("");
|
|
440
453
|
}
|
|
441
454
|
|
|
@@ -468,15 +481,23 @@ export class AssistsX {
|
|
|
468
481
|
filterText,
|
|
469
482
|
filterDes,
|
|
470
483
|
node,
|
|
484
|
+
scope,
|
|
471
485
|
}: {
|
|
472
486
|
filterClass?: string;
|
|
473
487
|
filterText?: string;
|
|
474
488
|
filterDes?: string;
|
|
475
489
|
node?: Node;
|
|
490
|
+
scope?: NodeLookupScope;
|
|
476
491
|
} = {}
|
|
477
492
|
): Node[] {
|
|
478
493
|
const response = this.call(CallMethod.findById, {
|
|
479
|
-
args: {
|
|
494
|
+
args: {
|
|
495
|
+
id,
|
|
496
|
+
filterClass,
|
|
497
|
+
filterText,
|
|
498
|
+
filterDes,
|
|
499
|
+
...(scope !== undefined ? { scope } : {}),
|
|
500
|
+
},
|
|
480
501
|
node,
|
|
481
502
|
});
|
|
482
503
|
const data = response.getDataOrDefault([]);
|
|
@@ -505,15 +526,23 @@ export class AssistsX {
|
|
|
505
526
|
filterViewId,
|
|
506
527
|
filterDes,
|
|
507
528
|
node,
|
|
529
|
+
scope,
|
|
508
530
|
}: {
|
|
509
531
|
filterClass?: string;
|
|
510
532
|
filterViewId?: string;
|
|
511
533
|
filterDes?: string;
|
|
512
534
|
node?: Node;
|
|
535
|
+
scope?: NodeLookupScope;
|
|
513
536
|
} = {}
|
|
514
537
|
): Node[] {
|
|
515
538
|
const response = this.call(CallMethod.findByText, {
|
|
516
|
-
args: {
|
|
539
|
+
args: {
|
|
540
|
+
text,
|
|
541
|
+
filterClass,
|
|
542
|
+
filterViewId,
|
|
543
|
+
filterDes,
|
|
544
|
+
...(scope !== undefined ? { scope } : {}),
|
|
545
|
+
},
|
|
517
546
|
node,
|
|
518
547
|
});
|
|
519
548
|
const data = response.getDataOrDefault([]);
|
|
@@ -542,15 +571,23 @@ export class AssistsX {
|
|
|
542
571
|
filterViewId,
|
|
543
572
|
filterDes,
|
|
544
573
|
node,
|
|
574
|
+
scope,
|
|
545
575
|
}: {
|
|
546
576
|
filterText?: string;
|
|
547
577
|
filterViewId?: string;
|
|
548
578
|
filterDes?: string;
|
|
549
579
|
node?: Node;
|
|
580
|
+
scope?: NodeLookupScope;
|
|
550
581
|
} = {}
|
|
551
582
|
): Node[] {
|
|
552
583
|
const response = this.call(CallMethod.findByTags, {
|
|
553
|
-
args: {
|
|
584
|
+
args: {
|
|
585
|
+
className,
|
|
586
|
+
filterText,
|
|
587
|
+
filterViewId,
|
|
588
|
+
filterDes,
|
|
589
|
+
...(scope !== undefined ? { scope } : {}),
|
|
590
|
+
},
|
|
554
591
|
node,
|
|
555
592
|
});
|
|
556
593
|
const data = response.getDataOrDefault([]);
|
|
@@ -566,11 +603,17 @@ export class AssistsX {
|
|
|
566
603
|
/**
|
|
567
604
|
* 查找所有匹配文本的节点
|
|
568
605
|
* @param text 要查找的文本
|
|
569
|
-
* @
|
|
606
|
+
* @param options.scope 节点查找范围(可选)
|
|
570
607
|
*/
|
|
571
|
-
public static findByTextAllMatch(
|
|
608
|
+
public static findByTextAllMatch(
|
|
609
|
+
text: string,
|
|
610
|
+
{ scope }: { scope?: NodeLookupScope } = {}
|
|
611
|
+
): Node[] {
|
|
572
612
|
const response = this.call(CallMethod.findByTextAllMatch, {
|
|
573
|
-
args: {
|
|
613
|
+
args: {
|
|
614
|
+
text,
|
|
615
|
+
...(scope !== undefined ? { scope } : {}),
|
|
616
|
+
},
|
|
574
617
|
});
|
|
575
618
|
const data = response.getDataOrDefault([]);
|
|
576
619
|
if (!Array.isArray(data)) {
|
|
@@ -1130,7 +1173,7 @@ if (typeof window !== "undefined") {
|
|
|
1130
1173
|
try {
|
|
1131
1174
|
// 检查 assistsx 是否可用,如果可用则初始化屏幕尺寸
|
|
1132
1175
|
if ((window as any).assistsx && typeof (window as any).assistsx.call === "function") {
|
|
1133
|
-
screen = AssistsX.getScreenSize();
|
|
1176
|
+
screen = AssistsX.getScreenSize() ?? { width: 0, height: 0 };
|
|
1134
1177
|
}
|
|
1135
1178
|
} catch (e) {
|
|
1136
1179
|
// 如果初始化失败,screen 保持为 null
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 与 Android AssistsCore.NodeLookupScope / HTTP scope 查询参数一致的字符串取值。
|
|
3
|
+
*/
|
|
4
|
+
export type NodeLookupScope = "active_window" | "all_windows";
|
|
5
|
+
|
|
6
|
+
/** 与 AssistsCore.NodeLookupScope.ActiveWindow 对应 */
|
|
7
|
+
export const NODE_LOOKUP_SCOPE_ACTIVE_WINDOW: NodeLookupScope = "active_window";
|
|
8
|
+
|
|
9
|
+
/** 与 AssistsCore.NodeLookupScope.AllWindows 对应 */
|
|
10
|
+
export const NODE_LOOKUP_SCOPE_ALL_WINDOWS: NodeLookupScope = "all_windows";
|
package/src/step-async.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { generateUUID } from "./utils";
|
|
|
10
10
|
import { StepError } from "./step-error";
|
|
11
11
|
import { AssistsXAsync } from "./assistsx-async";
|
|
12
12
|
import { Step } from "./step";
|
|
13
|
+
import type { NodeLookupScope } from "./node-lookup-scope";
|
|
13
14
|
|
|
14
15
|
export class StepAsync {
|
|
15
16
|
private step: Step;
|
|
@@ -73,11 +74,13 @@ export class StepAsync {
|
|
|
73
74
|
filterViewId,
|
|
74
75
|
filterDes,
|
|
75
76
|
filterText,
|
|
77
|
+
scope,
|
|
76
78
|
}: {
|
|
77
79
|
filterClass?: string;
|
|
78
80
|
filterViewId?: string;
|
|
79
81
|
filterDes?: string;
|
|
80
82
|
filterText?: string;
|
|
83
|
+
scope?: NodeLookupScope;
|
|
81
84
|
} = {}): Promise<Node[]> {
|
|
82
85
|
Step.assert(this.step.stepId);
|
|
83
86
|
const nodes = await AssistsXAsync.getAllNodes({
|
|
@@ -85,6 +88,7 @@ export class StepAsync {
|
|
|
85
88
|
filterViewId,
|
|
86
89
|
filterDes,
|
|
87
90
|
filterText,
|
|
91
|
+
scope,
|
|
88
92
|
});
|
|
89
93
|
Step.assert(this.step.stepId);
|
|
90
94
|
Step.assignIdsToNodes(nodes, this.step.stepId);
|
|
@@ -105,11 +109,26 @@ export class StepAsync {
|
|
|
105
109
|
|
|
106
110
|
/**
|
|
107
111
|
* 获取当前应用包名
|
|
108
|
-
* @
|
|
112
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
109
113
|
*/
|
|
110
|
-
public async getPackageName(): Promise<string
|
|
114
|
+
public async getPackageName(timeout?: number): Promise<string>;
|
|
115
|
+
/**
|
|
116
|
+
* 获取当前应用包名
|
|
117
|
+
* @param options.timeout 超时时间(秒),默认30秒
|
|
118
|
+
* @param options.scope 节点查找范围(可选)
|
|
119
|
+
*/
|
|
120
|
+
public async getPackageName(options: {
|
|
121
|
+
timeout?: number;
|
|
122
|
+
scope?: NodeLookupScope;
|
|
123
|
+
}): Promise<string>;
|
|
124
|
+
public async getPackageName(
|
|
125
|
+
timeoutOrOptions?: number | { timeout?: number; scope?: NodeLookupScope }
|
|
126
|
+
): Promise<string> {
|
|
111
127
|
Step.assert(this.step.stepId);
|
|
112
|
-
const result =
|
|
128
|
+
const result =
|
|
129
|
+
typeof timeoutOrOptions === "number"
|
|
130
|
+
? await AssistsXAsync.getPackageName(timeoutOrOptions)
|
|
131
|
+
: await AssistsXAsync.getPackageName(timeoutOrOptions ?? {});
|
|
113
132
|
Step.assert(this.step.stepId);
|
|
114
133
|
return result;
|
|
115
134
|
}
|
|
@@ -128,13 +147,20 @@ export class StepAsync {
|
|
|
128
147
|
filterClass,
|
|
129
148
|
filterText,
|
|
130
149
|
filterDes,
|
|
131
|
-
|
|
150
|
+
scope,
|
|
151
|
+
}: {
|
|
152
|
+
filterClass?: string;
|
|
153
|
+
filterText?: string;
|
|
154
|
+
filterDes?: string;
|
|
155
|
+
scope?: NodeLookupScope;
|
|
156
|
+
} = {}
|
|
132
157
|
): Promise<Node[]> {
|
|
133
158
|
Step.assert(this.step.stepId);
|
|
134
159
|
const nodes = await AssistsXAsync.findById(id, {
|
|
135
160
|
filterClass,
|
|
136
161
|
filterText,
|
|
137
162
|
filterDes,
|
|
163
|
+
scope,
|
|
138
164
|
});
|
|
139
165
|
Step.assert(this.step.stepId);
|
|
140
166
|
Step.assignIdsToNodes(nodes, this.step.stepId);
|
|
@@ -155,13 +181,20 @@ export class StepAsync {
|
|
|
155
181
|
filterClass,
|
|
156
182
|
filterViewId,
|
|
157
183
|
filterDes,
|
|
158
|
-
|
|
184
|
+
scope,
|
|
185
|
+
}: {
|
|
186
|
+
filterClass?: string;
|
|
187
|
+
filterViewId?: string;
|
|
188
|
+
filterDes?: string;
|
|
189
|
+
scope?: NodeLookupScope;
|
|
190
|
+
} = {}
|
|
159
191
|
): Promise<Node[]> {
|
|
160
192
|
Step.assert(this.step.stepId);
|
|
161
193
|
const nodes = await AssistsXAsync.findByText(text, {
|
|
162
194
|
filterClass,
|
|
163
195
|
filterViewId,
|
|
164
196
|
filterDes,
|
|
197
|
+
scope,
|
|
165
198
|
});
|
|
166
199
|
Step.assert(this.step.stepId);
|
|
167
200
|
Step.assignIdsToNodes(nodes, this.step.stepId);
|
|
@@ -182,13 +215,20 @@ export class StepAsync {
|
|
|
182
215
|
filterText,
|
|
183
216
|
filterViewId,
|
|
184
217
|
filterDes,
|
|
185
|
-
|
|
218
|
+
scope,
|
|
219
|
+
}: {
|
|
220
|
+
filterText?: string;
|
|
221
|
+
filterViewId?: string;
|
|
222
|
+
filterDes?: string;
|
|
223
|
+
scope?: NodeLookupScope;
|
|
224
|
+
} = {}
|
|
186
225
|
): Promise<Node[]> {
|
|
187
226
|
Step.assert(this.step.stepId);
|
|
188
227
|
const nodes = await AssistsXAsync.findByTags(className, {
|
|
189
228
|
filterText,
|
|
190
229
|
filterViewId,
|
|
191
230
|
filterDes,
|
|
231
|
+
scope,
|
|
192
232
|
});
|
|
193
233
|
Step.assert(this.step.stepId);
|
|
194
234
|
Step.assignIdsToNodes(nodes, this.step.stepId);
|
|
@@ -198,11 +238,33 @@ export class StepAsync {
|
|
|
198
238
|
/**
|
|
199
239
|
* 查找所有匹配文本的节点
|
|
200
240
|
* @param text 要查找的文本
|
|
201
|
-
* @
|
|
241
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
202
242
|
*/
|
|
203
|
-
public async findByTextAllMatch(
|
|
243
|
+
public async findByTextAllMatch(
|
|
244
|
+
text: string,
|
|
245
|
+
timeout?: number
|
|
246
|
+
): Promise<Node[]>;
|
|
247
|
+
/**
|
|
248
|
+
* 查找所有匹配文本的节点
|
|
249
|
+
* @param text 要查找的文本
|
|
250
|
+
* @param options.timeout 超时时间(秒),默认30秒
|
|
251
|
+
* @param options.scope 节点查找范围(可选)
|
|
252
|
+
*/
|
|
253
|
+
public async findByTextAllMatch(
|
|
254
|
+
text: string,
|
|
255
|
+
options: { timeout?: number; scope?: NodeLookupScope }
|
|
256
|
+
): Promise<Node[]>;
|
|
257
|
+
public async findByTextAllMatch(
|
|
258
|
+
text: string,
|
|
259
|
+
timeoutOrOptions?: number | { timeout?: number; scope?: NodeLookupScope }
|
|
260
|
+
): Promise<Node[]> {
|
|
204
261
|
Step.assert(this.step.stepId);
|
|
205
|
-
const nodes =
|
|
262
|
+
const nodes =
|
|
263
|
+
typeof timeoutOrOptions === "number"
|
|
264
|
+
? await AssistsXAsync.findByTextAllMatch(text, timeoutOrOptions)
|
|
265
|
+
: timeoutOrOptions !== undefined
|
|
266
|
+
? await AssistsXAsync.findByTextAllMatch(text, timeoutOrOptions)
|
|
267
|
+
: await AssistsXAsync.findByTextAllMatch(text);
|
|
206
268
|
Step.assert(this.step.stepId);
|
|
207
269
|
Step.assignIdsToNodes(nodes, this.step.stepId);
|
|
208
270
|
return nodes;
|