assistsx-js 0.0.2046 → 0.0.2048

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
@@ -11,6 +11,11 @@ export declare class Bounds {
11
11
  readonly exactCenterY: number;
12
12
  readonly isEmpty: boolean;
13
13
  constructor(left: number, top: number, right: number, bottom: number, width: number, height: number, centerX: number, centerY: number, exactCenterX: number, exactCenterY: number, isEmpty: boolean);
14
+ /**
15
+ * 判断该 Bounds 是否在屏幕内(满足基本几何有效性)
16
+ * @returns {boolean}
17
+ */
18
+ isInScreen(): boolean;
14
19
  static from(data: {
15
20
  left: number;
16
21
  top: number;
package/dist/Bounds.js CHANGED
@@ -14,6 +14,16 @@ export class Bounds {
14
14
  this.exactCenterY = exactCenterY;
15
15
  this.isEmpty = isEmpty;
16
16
  }
17
+ /**
18
+ * 判断该 Bounds 是否在屏幕内(满足基本几何有效性)
19
+ * @returns {boolean}
20
+ */
21
+ isInScreen() {
22
+ return this.centerX > 0 &&
23
+ this.centerY > 0 &&
24
+ this.height > 0 &&
25
+ this.width > 0;
26
+ }
17
27
  // 从普通对象创建 Bounds 实例
18
28
  static from(data) {
19
29
  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);
package/dist/Node.d.ts CHANGED
@@ -109,7 +109,7 @@ export declare class Node {
109
109
  isSelected: boolean;
110
110
  isVisibleToUser: boolean;
111
111
  drawingOrder: number;
112
- boundsInScreen: Bounds;
112
+ boundsInScreen: Bounds | any;
113
113
  });
114
114
  get async(): NodeAsync;
115
115
  /**
package/dist/Node.js CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * 节点类
3
+ * 表示界面上的一个可交互元素,包含元素的属性和可执行的操作
4
+ */
5
+ import { Bounds } from "./Bounds";
1
6
  import { AssistsX } from "./AssistsX";
2
7
  import { Step } from "./Step";
3
8
  import { NodeAsync } from "./NodeAsync";
@@ -27,7 +32,10 @@ export class Node {
27
32
  this.isSelected = params.isSelected;
28
33
  this.isVisibleToUser = params.isVisibleToUser;
29
34
  this.drawingOrder = params.drawingOrder;
30
- this.boundsInScreen = params.boundsInScreen;
35
+ // 确保 boundsInScreen Bounds 实例,如果不是则转换
36
+ this.boundsInScreen = params.boundsInScreen instanceof Bounds
37
+ ? params.boundsInScreen
38
+ : Bounds.fromData(params.boundsInScreen);
31
39
  }
32
40
  get async() {
33
41
  return new NodeAsync(this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assistsx-js",
3
- "version": "0.0.2046",
3
+ "version": "0.0.2048",
4
4
  "description": "assistsx-js自动化开发SDK",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
package/src/Bounds.ts CHANGED
@@ -1,114 +1,126 @@
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
- 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
- ) {}
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
+ ) { }
17
17
 
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
- }
18
+ /**
19
+ * 判断该 Bounds 是否在屏幕内(满足基本几何有效性)
20
+ * @returns {boolean}
21
+ */
22
+ public isInScreen(): boolean {
23
+ return this.centerX > 0 &&
24
+ this.centerY > 0 &&
25
+ this.height > 0 &&
26
+ this.width > 0;
27
+ }
46
28
 
47
- // 从 JSON 字符串创建实例
48
- static fromJSON(json: string): Bounds {
49
- const data = JSON.parse(json);
50
- return Bounds.from(data);
51
- }
52
29
 
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
- }
30
+ // 从普通对象创建 Bounds 实例
31
+ static from(data: {
32
+ left: number;
33
+ top: number;
34
+ right: number;
35
+ bottom: number;
36
+ width: number;
37
+ height: number;
38
+ centerX: number;
39
+ centerY: number;
40
+ exactCenterX: number;
41
+ exactCenterY: number;
42
+ isEmpty: boolean;
43
+ }): Bounds {
44
+ return new Bounds(
45
+ data.left,
46
+ data.top,
47
+ data.right,
48
+ data.bottom,
49
+ data.width,
50
+ data.height,
51
+ data.centerX,
52
+ data.centerY,
53
+ data.exactCenterX,
54
+ data.exactCenterY,
55
+ data.isEmpty
56
+ );
57
+ }
68
58
 
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
- }
59
+ // 从 JSON 字符串创建实例
60
+ static fromJSON(json: string): Bounds {
61
+ const data = JSON.parse(json);
62
+ return Bounds.from(data);
63
+ }
97
64
 
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
- }
65
+ static fromData(data: any): Bounds {
66
+ return new Bounds(
67
+ data.left,
68
+ data.top,
69
+ data.right,
70
+ data.bottom,
71
+ data.width,
72
+ data.height,
73
+ data.centerX,
74
+ data.centerY,
75
+ data.exactCenterX,
76
+ data.exactCenterY,
77
+ data.isEmpty
78
+ );
79
+ }
80
+
81
+ // 转换为普通对象
82
+ toJSON(): {
83
+ left: number;
84
+ top: number;
85
+ right: number;
86
+ bottom: number;
87
+ width: number;
88
+ height: number;
89
+ centerX: number;
90
+ centerY: number;
91
+ exactCenterX: number;
92
+ exactCenterY: number;
93
+ isEmpty: boolean;
94
+ } {
95
+ return {
96
+ left: this.left,
97
+ top: this.top,
98
+ right: this.right,
99
+ bottom: this.bottom,
100
+ width: this.width,
101
+ height: this.height,
102
+ centerX: this.centerX,
103
+ centerY: this.centerY,
104
+ exactCenterX: this.exactCenterX,
105
+ exactCenterY: this.exactCenterY,
106
+ isEmpty: this.isEmpty,
107
+ };
108
+ }
109
+
110
+ // 克隆方法
111
+ clone(): Bounds {
112
+ return new Bounds(
113
+ this.left,
114
+ this.top,
115
+ this.right,
116
+ this.bottom,
117
+ this.width,
118
+ this.height,
119
+ this.centerX,
120
+ this.centerY,
121
+ this.exactCenterX,
122
+ this.exactCenterY,
123
+ this.isEmpty
124
+ );
125
+ }
114
126
  }