assistsx-js 0.0.2040 → 0.0.2041

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 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
  */
@@ -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
127
  impl: StepImpl;
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(impl: StepImpl, { 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
@@ -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;
@@ -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 = undefined;
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(impl, { tag, data, delayMs = Step.delayMsDefault, repeatCountMax = Step.repeatCountMaxDefault, } = {}) {
297
+ Step.assert(this.stepId);
298
+ return new Step({
299
+ stepId: this.stepId,
300
+ impl,
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
- "name": "assistsx-js",
3
- "version": "0.0.2040",
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"
2
+ "name": "assistsx-js",
3
+ "version": "0.0.2041",
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
+ }