assistsx-js 0.0.2010 → 0.0.2012

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/Bounds.d.ts CHANGED
@@ -3,12 +3,26 @@ export declare class Bounds {
3
3
  readonly top: number;
4
4
  readonly right: number;
5
5
  readonly bottom: number;
6
- constructor(left: number, top: number, right: number, bottom: number);
6
+ readonly width: number;
7
+ readonly height: number;
8
+ readonly centerX: number;
9
+ readonly centerY: number;
10
+ readonly exactCenterX: number;
11
+ readonly exactCenterY: number;
12
+ readonly isEmpty: boolean;
13
+ constructor(left: number, top: number, right: number, bottom: number, width: number, height: number, centerX: number, centerY: number, exactCenterX: number, exactCenterY: number, isEmpty: boolean);
7
14
  static from(data: {
8
15
  left: number;
9
16
  top: number;
10
17
  right: number;
11
18
  bottom: number;
19
+ width: number;
20
+ height: number;
21
+ centerX: number;
22
+ centerY: number;
23
+ exactCenterX: number;
24
+ exactCenterY: number;
25
+ isEmpty: boolean;
12
26
  }): Bounds;
13
27
  static fromJSON(json: string): Bounds;
14
28
  static fromData(data: any): Bounds;
@@ -17,6 +31,13 @@ export declare class Bounds {
17
31
  top: number;
18
32
  right: number;
19
33
  bottom: number;
34
+ width: number;
35
+ height: number;
36
+ centerX: number;
37
+ centerY: number;
38
+ exactCenterX: number;
39
+ exactCenterY: number;
40
+ isEmpty: boolean;
20
41
  };
21
42
  clone(): Bounds;
22
43
  }
package/dist/Bounds.js CHANGED
@@ -1,15 +1,22 @@
1
1
  // Bounds 类,对应 Kotlin 的 data class
2
2
  export class Bounds {
3
3
  // 构造函数
4
- constructor(left, top, right, bottom) {
4
+ constructor(left, top, right, bottom, width, height, centerX, centerY, exactCenterX, exactCenterY, isEmpty) {
5
5
  this.left = left;
6
6
  this.top = top;
7
7
  this.right = right;
8
8
  this.bottom = bottom;
9
+ this.width = width;
10
+ this.height = height;
11
+ this.centerX = centerX;
12
+ this.centerY = centerY;
13
+ this.exactCenterX = exactCenterX;
14
+ this.exactCenterY = exactCenterY;
15
+ this.isEmpty = isEmpty;
9
16
  }
10
17
  // 从普通对象创建 Bounds 实例
11
18
  static from(data) {
12
- return new Bounds(data.left, data.top, data.right, data.bottom);
19
+ return new Bounds(data.left, data.top, data.right, data.bottom, data.width, data.height, data.centerX, data.centerY, data.exactCenterX, data.exactCenterY, data.isEmpty);
13
20
  }
14
21
  // 从 JSON 字符串创建实例
15
22
  static fromJSON(json) {
@@ -17,7 +24,7 @@ export class Bounds {
17
24
  return Bounds.from(data);
18
25
  }
19
26
  static fromData(data) {
20
- return new Bounds(data.left, data.top, data.right, data.bottom);
27
+ return new Bounds(data.left, data.top, data.right, data.bottom, data.width, data.height, data.centerX, data.centerY, data.exactCenterX, data.exactCenterY, data.isEmpty);
21
28
  }
22
29
  // 转换为普通对象
23
30
  toJSON() {
@@ -25,11 +32,18 @@ export class Bounds {
25
32
  left: this.left,
26
33
  top: this.top,
27
34
  right: this.right,
28
- bottom: this.bottom
35
+ bottom: this.bottom,
36
+ width: this.width,
37
+ height: this.height,
38
+ centerX: this.centerX,
39
+ centerY: this.centerY,
40
+ exactCenterX: this.exactCenterX,
41
+ exactCenterY: this.exactCenterY,
42
+ isEmpty: this.isEmpty,
29
43
  };
30
44
  }
31
45
  // 克隆方法
32
46
  clone() {
33
- return new Bounds(this.left, this.top, this.right, this.bottom);
47
+ return new Bounds(this.left, this.top, this.right, this.bottom, this.width, this.height, this.centerX, this.centerY, this.exactCenterX, this.exactCenterY, this.isEmpty);
34
48
  }
35
49
  }
package/dist/Node.d.ts CHANGED
@@ -81,6 +81,10 @@ export declare class Node {
81
81
  * 绘制顺序
82
82
  */
83
83
  drawingOrder: number;
84
+ /**
85
+ * 节点在屏幕中的边界
86
+ */
87
+ boundsInScreen: Bounds;
84
88
  /**
85
89
  * 构造函数
86
90
  * @param params 节点参数对象
@@ -105,6 +109,7 @@ export declare class Node {
105
109
  isSelected: boolean;
106
110
  isVisibleToUser: boolean;
107
111
  drawingOrder: number;
112
+ boundsInScreen: Bounds;
108
113
  });
109
114
  get async(): NodeAsync;
110
115
  /**
@@ -296,6 +301,7 @@ export declare class Node {
296
301
  isSelected: boolean;
297
302
  isVisibleToUser: boolean;
298
303
  drawingOrder: number;
304
+ boundsInScreen: Bounds;
299
305
  }): Node;
300
306
  /**
301
307
  * 从JSON数组创建节点数组
package/dist/Node.js CHANGED
@@ -27,6 +27,7 @@ export class Node {
27
27
  this.isSelected = params.isSelected;
28
28
  this.isVisibleToUser = params.isVisibleToUser;
29
29
  this.drawingOrder = params.drawingOrder;
30
+ this.boundsInScreen = params.boundsInScreen;
30
31
  }
31
32
  get async() {
32
33
  return new NodeAsync(this);
@@ -200,6 +200,7 @@ export declare class NodeAsync {
200
200
  isSelected: boolean;
201
201
  isVisibleToUser: boolean;
202
202
  drawingOrder: number;
203
+ boundsInScreen: Bounds;
203
204
  }): Node;
204
205
  /**
205
206
  * 从JSON数组创建节点数组
package/dist/Step.d.ts CHANGED
@@ -55,8 +55,27 @@ export declare class Step {
55
55
  /**
56
56
  * 移除步骤拦截器
57
57
  * @param interceptor 要移除的拦截器函数
58
+ * @returns 是否成功删除
58
59
  */
59
- static removeInterceptor(interceptor: StepInterceptor): void;
60
+ static removeInterceptor(interceptor: StepInterceptor): boolean;
61
+ /**
62
+ * 按索引移除步骤拦截器
63
+ * @param index 要移除的拦截器索引
64
+ * @returns 是否成功删除
65
+ */
66
+ static removeInterceptorByIndex(index: number): boolean;
67
+ /**
68
+ * 移除所有匹配的步骤拦截器
69
+ * @param interceptor 要移除的拦截器函数
70
+ * @returns 删除的拦截器数量
71
+ */
72
+ static removeAllInterceptors(interceptor: StepInterceptor): number;
73
+ /**
74
+ * 按条件移除步骤拦截器
75
+ * @param predicate 判断是否删除的条件函数
76
+ * @returns 删除的拦截器数量
77
+ */
78
+ static removeInterceptorByPredicate(predicate: (interceptor: StepInterceptor, index: number) => boolean): number;
60
79
  /**
61
80
  * 清空所有拦截器
62
81
  */
package/dist/Step.js CHANGED
@@ -50,7 +50,7 @@ export class Step {
50
50
  for (const interceptor of this._interceptors) {
51
51
  try {
52
52
  const result = await interceptor(currentStep);
53
- if (result !== undefined) {
53
+ if (result) {
54
54
  interceptedStep = result;
55
55
  if (Step.showLog) {
56
56
  console.log(`步骤${implnName}被拦截器拦截,执行拦截后的步骤`);
@@ -165,12 +165,57 @@ export class Step {
165
165
  /**
166
166
  * 移除步骤拦截器
167
167
  * @param interceptor 要移除的拦截器函数
168
+ * @returns 是否成功删除
168
169
  */
169
170
  static removeInterceptor(interceptor) {
170
171
  const index = this._interceptors.indexOf(interceptor);
171
172
  if (index > -1) {
172
173
  this._interceptors.splice(index, 1);
174
+ return true;
173
175
  }
176
+ return false;
177
+ }
178
+ /**
179
+ * 按索引移除步骤拦截器
180
+ * @param index 要移除的拦截器索引
181
+ * @returns 是否成功删除
182
+ */
183
+ static removeInterceptorByIndex(index) {
184
+ if (index >= 0 && index < this._interceptors.length) {
185
+ this._interceptors.splice(index, 1);
186
+ return true;
187
+ }
188
+ return false;
189
+ }
190
+ /**
191
+ * 移除所有匹配的步骤拦截器
192
+ * @param interceptor 要移除的拦截器函数
193
+ * @returns 删除的拦截器数量
194
+ */
195
+ static removeAllInterceptors(interceptor) {
196
+ let removedCount = 0;
197
+ for (let i = this._interceptors.length - 1; i >= 0; i--) {
198
+ if (this._interceptors[i] === interceptor) {
199
+ this._interceptors.splice(i, 1);
200
+ removedCount++;
201
+ }
202
+ }
203
+ return removedCount;
204
+ }
205
+ /**
206
+ * 按条件移除步骤拦截器
207
+ * @param predicate 判断是否删除的条件函数
208
+ * @returns 删除的拦截器数量
209
+ */
210
+ static removeInterceptorByPredicate(predicate) {
211
+ let removedCount = 0;
212
+ for (let i = this._interceptors.length - 1; i >= 0; i--) {
213
+ if (predicate(this._interceptors[i], i)) {
214
+ this._interceptors.splice(i, 1);
215
+ removedCount++;
216
+ }
217
+ }
218
+ return removedCount;
174
219
  }
175
220
  /**
176
221
  * 清空所有拦截器
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assistsx-js",
3
- "version": "0.0.2010",
3
+ "version": "0.0.2012",
4
4
  "description": "assistsx-js自动化开发SDK",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/Bounds.ts CHANGED
@@ -1,40 +1,114 @@
1
1
  // Bounds 类,对应 Kotlin 的 data class
2
2
  export class Bounds {
3
- // 构造函数
4
- constructor(
5
- public readonly left: number,
6
- public readonly top: number,
7
- public readonly right: number,
8
- public readonly bottom: number
9
- ) { }
3
+ // 构造函数
4
+ constructor(
5
+ public readonly left: number,
6
+ public readonly top: number,
7
+ public readonly right: number,
8
+ public readonly bottom: number,
9
+ public readonly width: number,
10
+ public readonly height: number,
11
+ public readonly centerX: number,
12
+ public readonly centerY: number,
13
+ public readonly exactCenterX: number,
14
+ public readonly exactCenterY: number,
15
+ public readonly isEmpty: boolean
16
+ ) {}
10
17
 
11
- // 从普通对象创建 Bounds 实例
12
- static from(data: { left: number; top: number; right: number; bottom: number }): Bounds {
13
- return new Bounds(data.left, data.top, data.right, data.bottom);
14
- }
18
+ // 从普通对象创建 Bounds 实例
19
+ static from(data: {
20
+ left: number;
21
+ top: number;
22
+ right: number;
23
+ bottom: number;
24
+ width: number;
25
+ height: number;
26
+ centerX: number;
27
+ centerY: number;
28
+ exactCenterX: number;
29
+ exactCenterY: number;
30
+ isEmpty: boolean;
31
+ }): Bounds {
32
+ return new Bounds(
33
+ data.left,
34
+ data.top,
35
+ data.right,
36
+ data.bottom,
37
+ data.width,
38
+ data.height,
39
+ data.centerX,
40
+ data.centerY,
41
+ data.exactCenterX,
42
+ data.exactCenterY,
43
+ data.isEmpty
44
+ );
45
+ }
15
46
 
16
- // 从 JSON 字符串创建实例
17
- static fromJSON(json: string): Bounds {
18
- const data = JSON.parse(json);
19
- return Bounds.from(data);
20
- }
47
+ // 从 JSON 字符串创建实例
48
+ static fromJSON(json: string): Bounds {
49
+ const data = JSON.parse(json);
50
+ return Bounds.from(data);
51
+ }
21
52
 
22
- static fromData(data: any): Bounds {
23
- return new Bounds(data.left, data.top, data.right, data.bottom);
24
- }
53
+ static fromData(data: any): Bounds {
54
+ return new Bounds(
55
+ data.left,
56
+ data.top,
57
+ data.right,
58
+ data.bottom,
59
+ data.width,
60
+ data.height,
61
+ data.centerX,
62
+ data.centerY,
63
+ data.exactCenterX,
64
+ data.exactCenterY,
65
+ data.isEmpty
66
+ );
67
+ }
25
68
 
26
- // 转换为普通对象
27
- toJSON(): { left: number; top: number; right: number; bottom: number } {
28
- return {
29
- left: this.left,
30
- top: this.top,
31
- right: this.right,
32
- bottom: this.bottom
33
- };
34
- }
69
+ // 转换为普通对象
70
+ toJSON(): {
71
+ left: number;
72
+ top: number;
73
+ right: number;
74
+ bottom: number;
75
+ width: number;
76
+ height: number;
77
+ centerX: number;
78
+ centerY: number;
79
+ exactCenterX: number;
80
+ exactCenterY: number;
81
+ isEmpty: boolean;
82
+ } {
83
+ return {
84
+ left: this.left,
85
+ top: this.top,
86
+ right: this.right,
87
+ bottom: this.bottom,
88
+ width: this.width,
89
+ height: this.height,
90
+ centerX: this.centerX,
91
+ centerY: this.centerY,
92
+ exactCenterX: this.exactCenterX,
93
+ exactCenterY: this.exactCenterY,
94
+ isEmpty: this.isEmpty,
95
+ };
96
+ }
35
97
 
36
- // 克隆方法
37
- clone(): Bounds {
38
- return new Bounds(this.left, this.top, this.right, this.bottom);
39
- }
40
- }
98
+ // 克隆方法
99
+ clone(): Bounds {
100
+ return new Bounds(
101
+ this.left,
102
+ this.top,
103
+ this.right,
104
+ this.bottom,
105
+ this.width,
106
+ this.height,
107
+ this.centerX,
108
+ this.centerY,
109
+ this.exactCenterX,
110
+ this.exactCenterY,
111
+ this.isEmpty
112
+ );
113
+ }
114
+ }
package/src/Node.ts CHANGED
@@ -104,6 +104,11 @@ export class Node {
104
104
  */
105
105
  drawingOrder: number;
106
106
 
107
+ /**
108
+ * 节点在屏幕中的边界
109
+ */
110
+ boundsInScreen: Bounds;
111
+
107
112
  /**
108
113
  * 构造函数
109
114
  * @param params 节点参数对象
@@ -128,6 +133,7 @@ export class Node {
128
133
  isSelected: boolean;
129
134
  isVisibleToUser: boolean;
130
135
  drawingOrder: number;
136
+ boundsInScreen: Bounds;
131
137
  }) {
132
138
  this.nodeId = params.nodeId;
133
139
  this.text = params.text;
@@ -148,6 +154,7 @@ export class Node {
148
154
  this.isSelected = params.isSelected;
149
155
  this.isVisibleToUser = params.isVisibleToUser;
150
156
  this.drawingOrder = params.drawingOrder;
157
+ this.boundsInScreen = params.boundsInScreen;
151
158
  }
152
159
 
153
160
  public get async(): NodeAsync {
@@ -533,6 +540,7 @@ export class Node {
533
540
  isSelected: boolean;
534
541
  isVisibleToUser: boolean;
535
542
  drawingOrder: number;
543
+ boundsInScreen: Bounds;
536
544
  }): Node {
537
545
  return new Node(params);
538
546
  }
package/src/NodeAsync.ts CHANGED
@@ -406,6 +406,7 @@ export class NodeAsync {
406
406
  isSelected: boolean;
407
407
  isVisibleToUser: boolean;
408
408
  drawingOrder: number;
409
+ boundsInScreen: Bounds;
409
410
  }): Node {
410
411
  return new Node(params);
411
412
  }
package/src/Step.ts CHANGED
@@ -91,7 +91,7 @@ export class Step {
91
91
  for (const interceptor of this._interceptors) {
92
92
  try {
93
93
  const result = await interceptor(currentStep);
94
- if (result !== undefined) {
94
+ if (result) {
95
95
  interceptedStep = result;
96
96
  if (Step.showLog) {
97
97
  console.log(`步骤${implnName}被拦截器拦截,执行拦截后的步骤`);
@@ -226,12 +226,62 @@ export class Step {
226
226
  /**
227
227
  * 移除步骤拦截器
228
228
  * @param interceptor 要移除的拦截器函数
229
+ * @returns 是否成功删除
229
230
  */
230
- static removeInterceptor(interceptor: StepInterceptor): void {
231
+ static removeInterceptor(interceptor: StepInterceptor): boolean {
231
232
  const index = this._interceptors.indexOf(interceptor);
232
233
  if (index > -1) {
233
234
  this._interceptors.splice(index, 1);
235
+ return true;
234
236
  }
237
+ return false;
238
+ }
239
+
240
+ /**
241
+ * 按索引移除步骤拦截器
242
+ * @param index 要移除的拦截器索引
243
+ * @returns 是否成功删除
244
+ */
245
+ static removeInterceptorByIndex(index: number): boolean {
246
+ if (index >= 0 && index < this._interceptors.length) {
247
+ this._interceptors.splice(index, 1);
248
+ return true;
249
+ }
250
+ return false;
251
+ }
252
+
253
+ /**
254
+ * 移除所有匹配的步骤拦截器
255
+ * @param interceptor 要移除的拦截器函数
256
+ * @returns 删除的拦截器数量
257
+ */
258
+ static removeAllInterceptors(interceptor: StepInterceptor): number {
259
+ let removedCount = 0;
260
+ for (let i = this._interceptors.length - 1; i >= 0; i--) {
261
+ if (this._interceptors[i] === interceptor) {
262
+ this._interceptors.splice(i, 1);
263
+ removedCount++;
264
+ }
265
+ }
266
+ return removedCount;
267
+ }
268
+
269
+ /**
270
+ * 按条件移除步骤拦截器
271
+ * @param predicate 判断是否删除的条件函数
272
+ * @returns 删除的拦截器数量
273
+ */
274
+ static removeInterceptorByPredicate(
275
+ predicate: (interceptor: StepInterceptor, index: number) => boolean
276
+ ): number {
277
+ let removedCount = 0;
278
+ for (let i = this._interceptors.length - 1; i >= 0; i--) {
279
+ if (predicate(this._interceptors[i], i)) {
280
+ this._interceptors.splice(i, 1);
281
+ removedCount++;
282
+ }
283
+ }
284
+ return removedCount;
235
285
  }
236
286
 
237
287
  /**