assistsx-js 0.0.2040 → 0.0.2042
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/Step.d.ts +11 -3
- package/dist/Step.js +31 -8
- package/package.json +41 -41
- package/src/Step.ts +792 -755
package/dist/Step.d.ts
CHANGED
|
@@ -101,6 +101,7 @@ export declare class Step {
|
|
|
101
101
|
* 步骤标签
|
|
102
102
|
*/
|
|
103
103
|
tag: string | undefined;
|
|
104
|
+
isEnd: boolean;
|
|
104
105
|
/**
|
|
105
106
|
* 步骤数据
|
|
106
107
|
*/
|
|
@@ -112,7 +113,7 @@ export declare class Step {
|
|
|
112
113
|
/**
|
|
113
114
|
* 步骤实现函数
|
|
114
115
|
*/
|
|
115
|
-
impl: StepImpl;
|
|
116
|
+
impl: StepImpl | undefined;
|
|
116
117
|
/**
|
|
117
118
|
* 构造函数
|
|
118
119
|
* @param stepId 步骤ID
|
|
@@ -121,13 +122,14 @@ export declare class Step {
|
|
|
121
122
|
* @param data 步骤数据
|
|
122
123
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
123
124
|
*/
|
|
124
|
-
constructor({ stepId, impl, tag, data, delayMs, repeatCountMax, }: {
|
|
125
|
+
constructor({ stepId, impl, tag, data, delayMs, repeatCountMax, isEnd, }: {
|
|
125
126
|
stepId: string;
|
|
126
|
-
impl: StepImpl;
|
|
127
|
+
impl: StepImpl | undefined;
|
|
127
128
|
tag?: string | undefined;
|
|
128
129
|
data?: any | undefined;
|
|
129
130
|
delayMs?: number;
|
|
130
131
|
repeatCountMax?: number;
|
|
132
|
+
isEnd?: boolean;
|
|
131
133
|
});
|
|
132
134
|
get async(): StepAsync;
|
|
133
135
|
/**
|
|
@@ -144,6 +146,12 @@ export declare class Step {
|
|
|
144
146
|
delayMs?: number;
|
|
145
147
|
repeatCountMax?: number;
|
|
146
148
|
}): Step;
|
|
149
|
+
end({ tag, data, delayMs, repeatCountMax, }?: {
|
|
150
|
+
tag?: string | undefined;
|
|
151
|
+
data?: any | undefined;
|
|
152
|
+
delayMs?: number;
|
|
153
|
+
repeatCountMax?: number;
|
|
154
|
+
}): Step;
|
|
147
155
|
/**
|
|
148
156
|
* 重复当前步骤
|
|
149
157
|
* @param stepId 步骤ID
|
package/dist/Step.js
CHANGED
|
@@ -16,7 +16,7 @@ export class Step {
|
|
|
16
16
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
17
17
|
*/
|
|
18
18
|
static async run(impl, { tag, data, delayMs = Step.delayMsDefault, } = {}) {
|
|
19
|
-
var _a;
|
|
19
|
+
var _a, _b, _c, _d, _e, _f;
|
|
20
20
|
const stepStore = useStepStore();
|
|
21
21
|
let implnName = impl.name;
|
|
22
22
|
let currentStep;
|
|
@@ -41,7 +41,7 @@ export class Step {
|
|
|
41
41
|
Step.assert(currentStep.stepId);
|
|
42
42
|
}
|
|
43
43
|
//执行步骤
|
|
44
|
-
implnName = currentStep.impl.name;
|
|
44
|
+
implnName = (_b = (_a = currentStep.impl) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "undefined";
|
|
45
45
|
if (Step.showLog) {
|
|
46
46
|
console.log(`执行步骤${implnName},重复次数${currentStep.repeatCount}`);
|
|
47
47
|
}
|
|
@@ -78,15 +78,15 @@ export class Step {
|
|
|
78
78
|
Step.assert(stepToExecute.stepId);
|
|
79
79
|
}
|
|
80
80
|
// 打印拦截步骤的执行信息
|
|
81
|
-
const interceptedImplName = stepToExecute.impl.name;
|
|
81
|
+
const interceptedImplName = (_c = stepToExecute.impl) === null || _c === void 0 ? void 0 : _c.name;
|
|
82
82
|
if (Step.showLog) {
|
|
83
83
|
console.log(`执行拦截步骤${interceptedImplName},重复次数${stepToExecute.repeatCount}`);
|
|
84
84
|
}
|
|
85
85
|
// 执行拦截后的步骤
|
|
86
|
-
nextStep = await stepToExecute.impl(stepToExecute);
|
|
86
|
+
nextStep = await ((_d = stepToExecute.impl) === null || _d === void 0 ? void 0 : _d.call(stepToExecute, stepToExecute));
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
89
|
-
nextStep = await currentStep.impl(currentStep);
|
|
89
|
+
nextStep = await ((_e = currentStep.impl) === null || _e === void 0 ? void 0 : _e.call(currentStep, currentStep));
|
|
90
90
|
}
|
|
91
91
|
if (currentStep.repeatCountMax > Step.repeatCountInfinite &&
|
|
92
92
|
currentStep.repeatCount > currentStep.repeatCountMax) {
|
|
@@ -98,6 +98,12 @@ export class Step {
|
|
|
98
98
|
Step.assert(currentStep.stepId);
|
|
99
99
|
if (nextStep) {
|
|
100
100
|
currentStep = nextStep;
|
|
101
|
+
if (currentStep.isEnd) {
|
|
102
|
+
if (Step.showLog) {
|
|
103
|
+
console.log(`步骤${implnName}结束`);
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
101
107
|
}
|
|
102
108
|
else {
|
|
103
109
|
break;
|
|
@@ -111,7 +117,7 @@ export class Step {
|
|
|
111
117
|
impl: implnName,
|
|
112
118
|
tag: tag,
|
|
113
119
|
data: data,
|
|
114
|
-
error: (
|
|
120
|
+
error: (_f = e === null || e === void 0 ? void 0 : e.message) !== null && _f !== void 0 ? _f : String(e),
|
|
115
121
|
});
|
|
116
122
|
stepStore.setError(errorMsg);
|
|
117
123
|
throw new StepError(errorMsg, implnName, tag, data, e, currentStep || undefined);
|
|
@@ -132,6 +138,9 @@ export class Step {
|
|
|
132
138
|
*/
|
|
133
139
|
static assert(stepId) {
|
|
134
140
|
if (stepId && Step.stepId != stepId) {
|
|
141
|
+
if (Step.stepId === "STEP_STOP") {
|
|
142
|
+
throw new Error("主动中断步骤");
|
|
143
|
+
}
|
|
135
144
|
throw new Error("StepId mismatch");
|
|
136
145
|
}
|
|
137
146
|
}
|
|
@@ -151,7 +160,7 @@ export class Step {
|
|
|
151
160
|
* 停止当前步骤执行
|
|
152
161
|
*/
|
|
153
162
|
static stop() {
|
|
154
|
-
this._stepId =
|
|
163
|
+
this._stepId = "STEP_STOP";
|
|
155
164
|
}
|
|
156
165
|
/**
|
|
157
166
|
* 添加步骤拦截器
|
|
@@ -236,7 +245,7 @@ export class Step {
|
|
|
236
245
|
* @param data 步骤数据
|
|
237
246
|
* @param delayMs 步骤延迟时间(毫秒)
|
|
238
247
|
*/
|
|
239
|
-
constructor({ stepId, impl, tag, data, delayMs = Step.delayMsDefault, repeatCountMax = Step.repeatCountMaxDefault, }) {
|
|
248
|
+
constructor({ stepId, impl, tag, data, delayMs = Step.delayMsDefault, repeatCountMax = Step.repeatCountMaxDefault, isEnd = false, }) {
|
|
240
249
|
/**
|
|
241
250
|
* 步骤ID
|
|
242
251
|
*/
|
|
@@ -249,6 +258,7 @@ export class Step {
|
|
|
249
258
|
* 步骤重复执行最大次数,默认不限制
|
|
250
259
|
*/
|
|
251
260
|
this.repeatCountMax = Step.repeatCountMaxDefault;
|
|
261
|
+
this.isEnd = false;
|
|
252
262
|
/**
|
|
253
263
|
* 步骤延迟时间(毫秒)
|
|
254
264
|
*/
|
|
@@ -259,6 +269,7 @@ export class Step {
|
|
|
259
269
|
this.impl = impl;
|
|
260
270
|
this.delayMs = delayMs;
|
|
261
271
|
this.repeatCountMax = repeatCountMax;
|
|
272
|
+
this.isEnd = isEnd;
|
|
262
273
|
}
|
|
263
274
|
get async() {
|
|
264
275
|
return new StepAsync(this);
|
|
@@ -282,6 +293,18 @@ export class Step {
|
|
|
282
293
|
repeatCountMax,
|
|
283
294
|
});
|
|
284
295
|
}
|
|
296
|
+
end({ tag, data, delayMs = Step.delayMsDefault, repeatCountMax = Step.repeatCountMaxDefault, } = {}) {
|
|
297
|
+
Step.assert(this.stepId);
|
|
298
|
+
return new Step({
|
|
299
|
+
stepId: this.stepId,
|
|
300
|
+
impl: undefined,
|
|
301
|
+
tag,
|
|
302
|
+
data: data !== null && data !== void 0 ? data : this.data,
|
|
303
|
+
delayMs,
|
|
304
|
+
repeatCountMax,
|
|
305
|
+
isEnd: true,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
285
308
|
/**
|
|
286
309
|
* 重复当前步骤
|
|
287
310
|
* @param stepId 步骤ID
|
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
"name": "assistsx-js",
|
|
3
|
+
"version": "0.0.2042",
|
|
4
|
+
"description": "assistsx-js自动化开发SDK",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"prepublish": "npm run build",
|
|
25
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"assistsx",
|
|
29
|
+
"assists",
|
|
30
|
+
"android assistsx",
|
|
31
|
+
"assistsx webview",
|
|
32
|
+
"AccessibilityService",
|
|
33
|
+
"dev"
|
|
34
|
+
],
|
|
35
|
+
"author": "Ven",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"typescript": "^5.3.3"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"pinia": "^3.0.3"
|
|
17
42
|
}
|
|
18
|
-
|
|
19
|
-
"publishConfig": {
|
|
20
|
-
"access": "public"
|
|
21
|
-
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsc",
|
|
24
|
-
"prepublish": "npm run build",
|
|
25
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
26
|
-
},
|
|
27
|
-
"keywords": [
|
|
28
|
-
"assistsx",
|
|
29
|
-
"assists",
|
|
30
|
-
"android assistsx",
|
|
31
|
-
"assistsx webview",
|
|
32
|
-
"AccessibilityService",
|
|
33
|
-
"dev"
|
|
34
|
-
],
|
|
35
|
-
"author": "Ven",
|
|
36
|
-
"license": "MIT",
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"typescript": "^5.3.3"
|
|
39
|
-
},
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"pinia": "^3.0.3"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
43
|
+
}
|