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/src/step.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { useStepStore } from "./step-state-store";
|
|
|
9
9
|
import { generateUUID } from "./utils";
|
|
10
10
|
import { StepError, StepStopError } from "./step-error";
|
|
11
11
|
import { StepAsync } from "./step-async";
|
|
12
|
+
import type { NodeLookupScope } from "./node-lookup-scope";
|
|
12
13
|
|
|
13
14
|
// 步骤结果类型,可以是Step实例或undefined
|
|
14
15
|
export type StepResult = Step | undefined;
|
|
@@ -22,7 +23,7 @@ export type StepInterceptor = (step: Step) => StepResult | Promise<StepResult>;
|
|
|
22
23
|
export class Step {
|
|
23
24
|
static delayMsDefault: number = 1000;
|
|
24
25
|
static readonly repeatCountInfinite: number = -1;
|
|
25
|
-
static repeatCountMaxDefault: number =
|
|
26
|
+
static repeatCountMaxDefault: number = 15;
|
|
26
27
|
static showLog: boolean = false;
|
|
27
28
|
static exceptionRetryCountMaxDefault: number = 3;
|
|
28
29
|
|
|
@@ -161,7 +162,7 @@ export class Step {
|
|
|
161
162
|
nextStep = await currentStep.impl?.(currentStep);
|
|
162
163
|
}
|
|
163
164
|
if (
|
|
164
|
-
currentStep.repeatCountMax
|
|
165
|
+
currentStep.repeatCountMax > Step.repeatCountInfinite &&
|
|
165
166
|
currentStep.repeatCount >= currentStep.repeatCountMax
|
|
166
167
|
) {
|
|
167
168
|
if (Step.showLog) {
|
|
@@ -378,7 +379,7 @@ export class Step {
|
|
|
378
379
|
repeatCount: number = 0;
|
|
379
380
|
|
|
380
381
|
/**
|
|
381
|
-
*
|
|
382
|
+
* 步骤重复执行最大次数,默认15次
|
|
382
383
|
*/
|
|
383
384
|
repeatCountMax: number = Step.repeatCountMaxDefault;
|
|
384
385
|
|
|
@@ -631,11 +632,13 @@ export class Step {
|
|
|
631
632
|
filterViewId,
|
|
632
633
|
filterDes,
|
|
633
634
|
filterText,
|
|
635
|
+
scope,
|
|
634
636
|
}: {
|
|
635
637
|
filterClass?: string;
|
|
636
638
|
filterViewId?: string;
|
|
637
639
|
filterDes?: string;
|
|
638
640
|
filterText?: string;
|
|
641
|
+
scope?: NodeLookupScope;
|
|
639
642
|
} = {}): Node[] {
|
|
640
643
|
Step.assert(this.stepId);
|
|
641
644
|
const nodes = AssistsX.getAllNodes({
|
|
@@ -643,6 +646,7 @@ export class Step {
|
|
|
643
646
|
filterViewId,
|
|
644
647
|
filterDes,
|
|
645
648
|
filterText,
|
|
649
|
+
scope,
|
|
646
650
|
});
|
|
647
651
|
Step.assert(this.stepId);
|
|
648
652
|
Step.assignIdsToNodes(nodes, this.stepId);
|
|
@@ -663,11 +667,11 @@ export class Step {
|
|
|
663
667
|
|
|
664
668
|
/**
|
|
665
669
|
* 获取当前应用包名
|
|
666
|
-
* @
|
|
670
|
+
* @param options.scope 节点查找范围(可选)
|
|
667
671
|
*/
|
|
668
|
-
public getPackageName(): string {
|
|
672
|
+
public getPackageName(options: { scope?: NodeLookupScope } = {}): string {
|
|
669
673
|
Step.assert(this.stepId);
|
|
670
|
-
const result = AssistsX.getPackageName();
|
|
674
|
+
const result = AssistsX.getPackageName(options);
|
|
671
675
|
Step.assert(this.stepId);
|
|
672
676
|
return result;
|
|
673
677
|
}
|
|
@@ -686,10 +690,21 @@ export class Step {
|
|
|
686
690
|
filterClass,
|
|
687
691
|
filterText,
|
|
688
692
|
filterDes,
|
|
689
|
-
|
|
693
|
+
scope,
|
|
694
|
+
}: {
|
|
695
|
+
filterClass?: string;
|
|
696
|
+
filterText?: string;
|
|
697
|
+
filterDes?: string;
|
|
698
|
+
scope?: NodeLookupScope;
|
|
699
|
+
} = {}
|
|
690
700
|
): Node[] {
|
|
691
701
|
Step.assert(this.stepId);
|
|
692
|
-
const nodes = AssistsX.findById(id, {
|
|
702
|
+
const nodes = AssistsX.findById(id, {
|
|
703
|
+
filterClass,
|
|
704
|
+
filterText,
|
|
705
|
+
filterDes,
|
|
706
|
+
scope,
|
|
707
|
+
});
|
|
693
708
|
Step.assert(this.stepId);
|
|
694
709
|
Step.assignIdsToNodes(nodes, this.stepId);
|
|
695
710
|
return nodes;
|
|
@@ -709,13 +724,20 @@ export class Step {
|
|
|
709
724
|
filterClass,
|
|
710
725
|
filterViewId,
|
|
711
726
|
filterDes,
|
|
712
|
-
|
|
727
|
+
scope,
|
|
728
|
+
}: {
|
|
729
|
+
filterClass?: string;
|
|
730
|
+
filterViewId?: string;
|
|
731
|
+
filterDes?: string;
|
|
732
|
+
scope?: NodeLookupScope;
|
|
733
|
+
} = {}
|
|
713
734
|
): Node[] {
|
|
714
735
|
Step.assert(this.stepId);
|
|
715
736
|
const nodes = AssistsX.findByText(text, {
|
|
716
737
|
filterClass,
|
|
717
738
|
filterViewId,
|
|
718
739
|
filterDes,
|
|
740
|
+
scope,
|
|
719
741
|
});
|
|
720
742
|
Step.assert(this.stepId);
|
|
721
743
|
Step.assignIdsToNodes(nodes, this.stepId);
|
|
@@ -736,13 +758,20 @@ export class Step {
|
|
|
736
758
|
filterText,
|
|
737
759
|
filterViewId,
|
|
738
760
|
filterDes,
|
|
739
|
-
|
|
761
|
+
scope,
|
|
762
|
+
}: {
|
|
763
|
+
filterText?: string;
|
|
764
|
+
filterViewId?: string;
|
|
765
|
+
filterDes?: string;
|
|
766
|
+
scope?: NodeLookupScope;
|
|
767
|
+
} = {}
|
|
740
768
|
): Node[] {
|
|
741
769
|
Step.assert(this.stepId);
|
|
742
770
|
const nodes = AssistsX.findByTags(className, {
|
|
743
771
|
filterText,
|
|
744
772
|
filterViewId,
|
|
745
773
|
filterDes,
|
|
774
|
+
scope,
|
|
746
775
|
});
|
|
747
776
|
Step.assert(this.stepId);
|
|
748
777
|
Step.assignIdsToNodes(nodes, this.stepId);
|
|
@@ -752,11 +781,14 @@ export class Step {
|
|
|
752
781
|
/**
|
|
753
782
|
* 查找所有匹配文本的节点
|
|
754
783
|
* @param text 要查找的文本
|
|
755
|
-
* @
|
|
784
|
+
* @param options.scope 节点查找范围(可选)
|
|
756
785
|
*/
|
|
757
|
-
public findByTextAllMatch(
|
|
786
|
+
public findByTextAllMatch(
|
|
787
|
+
text: string,
|
|
788
|
+
{ scope }: { scope?: NodeLookupScope } = {}
|
|
789
|
+
): Node[] {
|
|
758
790
|
Step.assert(this.stepId);
|
|
759
|
-
const nodes = AssistsX.findByTextAllMatch(text);
|
|
791
|
+
const nodes = AssistsX.findByTextAllMatch(text, { scope });
|
|
760
792
|
Step.assert(this.stepId);
|
|
761
793
|
Step.assignIdsToNodes(nodes, this.stepId);
|
|
762
794
|
return nodes;
|