assistsx-js 0.0.1353 → 0.0.2002

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/Node.js CHANGED
@@ -1,5 +1,6 @@
1
- import { AssistsX } from './AssistsX';
2
- import { Step } from './Step';
1
+ import { AssistsX } from "./AssistsX";
2
+ import { Step } from "./Step";
3
+ import { NodeAsync } from "./NodeAsync";
3
4
  // 将接口改造为类
4
5
  export class Node {
5
6
  /**
@@ -17,6 +18,20 @@ export class Node {
17
18
  this.isEnabled = params.isEnabled;
18
19
  this.stepId = params.stepId;
19
20
  }
21
+ get async() {
22
+ return new NodeAsync(this);
23
+ }
24
+ /**
25
+ * 查找第一个匹配标签的父节点
26
+ * @param className 类名
27
+ * @returns 父节点
28
+ */
29
+ findFirstParentByTags(className) {
30
+ Step.assert(this.stepId);
31
+ const node = AssistsX.findFirstParentByTags(this, className);
32
+ Step.assert(this.stepId);
33
+ return node;
34
+ }
20
35
  /**
21
36
  * 对节点执行点击手势
22
37
  * @param offsetX X轴偏移
@@ -25,9 +40,14 @@ export class Node {
25
40
  * @param clickDuration 点击持续时间
26
41
  * @returns 是否点击成功
27
42
  */
28
- async clickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration } = {}) {
43
+ async clickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, } = {}) {
29
44
  Step.assert(this.stepId);
30
- const result = await AssistsX.clickNodeByGesture(this, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration });
45
+ const result = await AssistsX.clickNodeByGesture(this, {
46
+ offsetX,
47
+ offsetY,
48
+ switchWindowIntervalDelay,
49
+ clickDuration,
50
+ });
31
51
  Step.assert(this.stepId);
32
52
  return result;
33
53
  }
@@ -40,15 +60,26 @@ export class Node {
40
60
  * @param clickInterval 点击间隔
41
61
  * @returns 是否双击成功
42
62
  */
43
- async doubleClickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval } = {}) {
63
+ async doubleClickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, } = {}) {
44
64
  Step.assert(this.stepId);
45
- const result = await AssistsX.doubleClickNodeByGesture(this, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval });
65
+ const result = await AssistsX.doubleClickNodeByGesture(this, {
66
+ offsetX,
67
+ offsetY,
68
+ switchWindowIntervalDelay,
69
+ clickDuration,
70
+ clickInterval,
71
+ });
46
72
  Step.assert(this.stepId);
47
73
  return result;
48
74
  }
49
- async longPressNodeByGestureAutoPaste(text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
75
+ async longPressNodeByGestureAutoPaste(text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
50
76
  Step.assert(this.stepId);
51
- const result = await AssistsX.longPressNodeByGestureAutoPaste(this, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration });
77
+ const result = await AssistsX.longPressNodeByGestureAutoPaste(this, text, {
78
+ matchedPackageName,
79
+ matchedText,
80
+ timeoutMillis,
81
+ longPressDuration,
82
+ });
52
83
  Step.assert(this.stepId);
53
84
  return result;
54
85
  }
@@ -60,9 +91,14 @@ export class Node {
60
91
  * @param filterDes 描述过滤
61
92
  * @returns 节点数组
62
93
  */
63
- findByTags(className, { filterText, filterViewId, filterDes } = {}) {
64
- Step.assert(this.stepId);
65
- const result = AssistsX.findByTags(className, { filterText, filterViewId, filterDes, node: this });
94
+ findByTags(className, { filterText, filterViewId, filterDes, } = {}) {
95
+ Step.assert(this.stepId);
96
+ const result = AssistsX.findByTags(className, {
97
+ filterText,
98
+ filterViewId,
99
+ filterDes,
100
+ node: this,
101
+ });
66
102
  Step.assignIdsToNodes(result, this.stepId);
67
103
  Step.assert(this.stepId);
68
104
  return result;
@@ -75,9 +111,14 @@ export class Node {
75
111
  * @param filterDes 描述过滤
76
112
  * @returns 节点数组
77
113
  */
78
- findById(id, { filterClass, filterText, filterDes } = {}) {
79
- Step.assert(this.stepId);
80
- const result = AssistsX.findById(id, { filterClass, filterText, filterDes, node: this });
114
+ findById(id, { filterClass, filterText, filterDes, } = {}) {
115
+ Step.assert(this.stepId);
116
+ const result = AssistsX.findById(id, {
117
+ filterClass,
118
+ filterText,
119
+ filterDes,
120
+ node: this,
121
+ });
81
122
  Step.assignIdsToNodes(result, this.stepId);
82
123
  Step.assert(this.stepId);
83
124
  return result;
@@ -90,9 +131,14 @@ export class Node {
90
131
  * @param filterDes 描述过滤
91
132
  * @returns 节点数组
92
133
  */
93
- findByText(text, { filterClass, filterViewId, filterDes } = {}) {
94
- Step.assert(this.stepId);
95
- const result = AssistsX.findByText(text, { filterClass, filterViewId, filterDes, node: this });
134
+ findByText(text, { filterClass, filterViewId, filterDes, } = {}) {
135
+ Step.assert(this.stepId);
136
+ const result = AssistsX.findByText(text, {
137
+ filterClass,
138
+ filterViewId,
139
+ filterDes,
140
+ node: this,
141
+ });
96
142
  Step.assignIdsToNodes(result, this.stepId);
97
143
  Step.assert(this.stepId);
98
144
  return result;
@@ -123,9 +169,12 @@ export class Node {
123
169
  * @param isFullyByCompareNode 是否完全可见
124
170
  * @returns 是否可见
125
171
  */
126
- isVisible({ compareNode, isFullyByCompareNode } = {}) {
172
+ isVisible({ compareNode, isFullyByCompareNode, } = {}) {
127
173
  Step.assert(this.stepId);
128
- const response = AssistsX.isVisible(this, { compareNode, isFullyByCompareNode });
174
+ const response = AssistsX.isVisible(this, {
175
+ compareNode,
176
+ isFullyByCompareNode,
177
+ });
129
178
  Step.assert(this.stepId);
130
179
  return response;
131
180
  }
@@ -157,6 +206,12 @@ export class Node {
157
206
  Step.assert(this.stepId);
158
207
  return result;
159
208
  }
209
+ focus() {
210
+ Step.assert(this.stepId);
211
+ const result = AssistsX.focus(this);
212
+ Step.assert(this.stepId);
213
+ return result;
214
+ }
160
215
  /**
161
216
  * 点击节点
162
217
  * @returns 是否点击成功
@@ -260,6 +315,6 @@ export class Node {
260
315
  * @returns 节点数组
261
316
  */
262
317
  static fromJSONArray(array) {
263
- return array.map(data => new Node(data));
318
+ return array.map((data) => new Node(data));
264
319
  }
265
320
  }
@@ -0,0 +1,200 @@
1
+ /**
2
+ * 节点类
3
+ * 表示界面上的一个可交互元素,包含元素的属性和可执行的操作
4
+ */
5
+ import { Bounds } from "./Bounds";
6
+ import { Node } from "./Node";
7
+ export declare class NodeAsync {
8
+ private node;
9
+ /**
10
+ * 构造函数
11
+ * @param node Node实例
12
+ */
13
+ constructor(node: Node);
14
+ /**
15
+ * 查找第一个匹配标签的父节点
16
+ * @param className 类名
17
+ * @returns 父节点
18
+ */
19
+ findFirstParentByTags(className: string): Promise<Node>;
20
+ /**
21
+ * 对节点执行点击手势
22
+ * @param offsetX X轴偏移
23
+ * @param offsetY Y轴偏移
24
+ * @param switchWindowIntervalDelay 窗口切换延迟
25
+ * @param clickDuration 点击持续时间
26
+ * @returns 是否点击成功
27
+ */
28
+ clickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, }?: {
29
+ offsetX?: number;
30
+ offsetY?: number;
31
+ switchWindowIntervalDelay?: number;
32
+ clickDuration?: number;
33
+ }): Promise<boolean>;
34
+ /**
35
+ * 对节点执行双击手势
36
+ * @param offsetX X轴偏移
37
+ * @param offsetY Y轴偏移
38
+ * @param switchWindowIntervalDelay 窗口切换延迟
39
+ * @param clickDuration 点击持续时间
40
+ * @param clickInterval 点击间隔
41
+ * @returns 是否双击成功
42
+ */
43
+ doubleClickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, }?: {
44
+ offsetX?: number;
45
+ offsetY?: number;
46
+ switchWindowIntervalDelay?: number;
47
+ clickDuration?: number;
48
+ clickInterval?: number;
49
+ }): Promise<boolean>;
50
+ longPressNodeByGestureAutoPaste(text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
51
+ matchedPackageName?: string;
52
+ matchedText?: string;
53
+ timeoutMillis?: number;
54
+ longPressDuration?: number;
55
+ }): Promise<boolean>;
56
+ /**
57
+ * 在当前节点范围内通过标签查找节点
58
+ * @param className 类名
59
+ * @param filterText 文本过滤
60
+ * @param filterViewId 视图ID过滤
61
+ * @param filterDes 描述过滤
62
+ * @returns 节点数组
63
+ */
64
+ findByTags(className: string, { filterText, filterViewId, filterDes, }?: {
65
+ filterText?: string;
66
+ filterViewId?: string;
67
+ filterDes?: string;
68
+ }): Promise<Node[]>;
69
+ /**
70
+ * 在当前节点范围内通过ID查找节点
71
+ * @param id 节点ID
72
+ * @param filterClass 类名过滤
73
+ * @param filterText 文本过滤
74
+ * @param filterDes 描述过滤
75
+ * @returns 节点数组
76
+ */
77
+ findById(id: string, { filterClass, filterText, filterDes, }?: {
78
+ filterClass?: string;
79
+ filterText?: string;
80
+ filterDes?: string;
81
+ }): Promise<Node[]>;
82
+ /**
83
+ * 在当前节点范围内通过文本查找节点
84
+ * @param text 要查找的文本
85
+ * @param filterClass 类名过滤
86
+ * @param filterViewId 视图ID过滤
87
+ * @param filterDes 描述过滤
88
+ * @returns 节点数组
89
+ */
90
+ findByText(text: string, { filterClass, filterViewId, filterDes, }?: {
91
+ filterClass?: string;
92
+ filterViewId?: string;
93
+ filterDes?: string;
94
+ }): Promise<Node[]>;
95
+ /**
96
+ * 向前滚动节点
97
+ * @returns 是否滚动成功
98
+ */
99
+ scrollForward(): Promise<boolean>;
100
+ /**
101
+ * 向后滚动节点
102
+ * @returns 是否滚动成功
103
+ */
104
+ scrollBackward(): Promise<boolean>;
105
+ /**
106
+ * 检查节点是否可见
107
+ * @param compareNode 比较节点
108
+ * @param isFullyByCompareNode 是否完全可见
109
+ * @returns 是否可见
110
+ */
111
+ isVisible({ compareNode, isFullyByCompareNode, }?: {
112
+ compareNode?: Node;
113
+ isFullyByCompareNode?: boolean;
114
+ }): Promise<boolean>;
115
+ /**
116
+ * 对节点进行截图
117
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
118
+ * @returns 截图路径
119
+ */
120
+ takeScreenshot(overlayHiddenScreenshotDelayMillis?: number): Promise<string>;
121
+ /**
122
+ * 设置节点文本
123
+ * @param text 要设置的文本
124
+ * @returns 是否设置成功
125
+ */
126
+ setNodeText(text: string): Promise<boolean>;
127
+ paste(text: string): Promise<boolean>;
128
+ focus(): Promise<boolean>;
129
+ /**
130
+ * 点击节点
131
+ * @returns 是否点击成功
132
+ */
133
+ click(): Promise<boolean>;
134
+ /**
135
+ * 长按节点
136
+ * @returns 是否长按成功
137
+ */
138
+ longClick(): Promise<boolean>;
139
+ /**
140
+ * 查找第一个可点击的父节点
141
+ * @returns 可点击的父节点
142
+ */
143
+ findFirstParentClickable(): Promise<Node>;
144
+ /**
145
+ * 获取节点在屏幕中的边界
146
+ * @returns 边界对象
147
+ */
148
+ getBoundsInScreen(): Promise<Bounds>;
149
+ /**
150
+ * 获取节点的所有子节点
151
+ * @returns 子节点数组
152
+ */
153
+ getNodes(): Promise<Node[]>;
154
+ /**
155
+ * 获取节点的直接子节点
156
+ * @returns 子节点数组
157
+ */
158
+ getChildren(): Promise<Node[]>;
159
+ /**
160
+ * 从JSON字符串创建节点实例
161
+ * @param json JSON字符串
162
+ * @returns 节点实例
163
+ */
164
+ static fromJSON(json: string): Node;
165
+ /**
166
+ * 从普通对象创建节点实例
167
+ * @param data 对象数据
168
+ * @returns 节点实例
169
+ */
170
+ static from(data: any): Node;
171
+ /**
172
+ * JSON.parse的reviver函数,用于将解析的JSON对象转换为Node实例
173
+ * @param key 属性键
174
+ * @param value 属性值
175
+ * @returns 转换后的值
176
+ */
177
+ static reviver(key: string, value: any): any;
178
+ /**
179
+ * 创建新的节点实例
180
+ * @param params 节点参数对象
181
+ * @returns 节点实例
182
+ */
183
+ static create(params: {
184
+ nodeId: string;
185
+ text: string;
186
+ des: string;
187
+ viewId: string;
188
+ className: string;
189
+ isScrollable: boolean;
190
+ isClickable: boolean;
191
+ isEnabled: boolean;
192
+ stepId: string | undefined;
193
+ }): Node;
194
+ /**
195
+ * 从JSON数组创建节点数组
196
+ * @param array JSON数组
197
+ * @returns 节点数组
198
+ */
199
+ static fromJSONArray(array: Array<any>): Node[];
200
+ }
@@ -0,0 +1,308 @@
1
+ import { Step } from "./Step";
2
+ import { AssistsXAsync } from "./AssistsXAsync";
3
+ import { Node } from "./Node";
4
+ export class NodeAsync {
5
+ /**
6
+ * 构造函数
7
+ * @param node Node实例
8
+ */
9
+ constructor(node) {
10
+ this.node = node;
11
+ }
12
+ /**
13
+ * 查找第一个匹配标签的父节点
14
+ * @param className 类名
15
+ * @returns 父节点
16
+ */
17
+ async findFirstParentByTags(className) {
18
+ Step.assert(this.node.stepId);
19
+ const node = await AssistsXAsync.findFirstParentByTags(this.node, className);
20
+ Step.assert(this.node.stepId);
21
+ return node;
22
+ }
23
+ /**
24
+ * 对节点执行点击手势
25
+ * @param offsetX X轴偏移
26
+ * @param offsetY Y轴偏移
27
+ * @param switchWindowIntervalDelay 窗口切换延迟
28
+ * @param clickDuration 点击持续时间
29
+ * @returns 是否点击成功
30
+ */
31
+ async clickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, } = {}) {
32
+ Step.assert(this.node.stepId);
33
+ const result = await AssistsXAsync.clickNodeByGesture(this.node, {
34
+ offsetX,
35
+ offsetY,
36
+ switchWindowIntervalDelay,
37
+ clickDuration,
38
+ });
39
+ Step.assert(this.node.stepId);
40
+ return result;
41
+ }
42
+ /**
43
+ * 对节点执行双击手势
44
+ * @param offsetX X轴偏移
45
+ * @param offsetY Y轴偏移
46
+ * @param switchWindowIntervalDelay 窗口切换延迟
47
+ * @param clickDuration 点击持续时间
48
+ * @param clickInterval 点击间隔
49
+ * @returns 是否双击成功
50
+ */
51
+ async doubleClickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, } = {}) {
52
+ Step.assert(this.node.stepId);
53
+ const result = await AssistsXAsync.doubleClickNodeByGesture(this.node, {
54
+ offsetX,
55
+ offsetY,
56
+ switchWindowIntervalDelay,
57
+ clickDuration,
58
+ clickInterval,
59
+ });
60
+ Step.assert(this.node.stepId);
61
+ return result;
62
+ }
63
+ async longPressNodeByGestureAutoPaste(text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
64
+ Step.assert(this.node.stepId);
65
+ const result = await AssistsXAsync.longPressNodeByGestureAutoPaste(this.node, text, {
66
+ matchedPackageName,
67
+ matchedText,
68
+ timeoutMillis,
69
+ longPressDuration,
70
+ });
71
+ Step.assert(this.node.stepId);
72
+ return result;
73
+ }
74
+ /**
75
+ * 在当前节点范围内通过标签查找节点
76
+ * @param className 类名
77
+ * @param filterText 文本过滤
78
+ * @param filterViewId 视图ID过滤
79
+ * @param filterDes 描述过滤
80
+ * @returns 节点数组
81
+ */
82
+ async findByTags(className, { filterText, filterViewId, filterDes, } = {}) {
83
+ Step.assert(this.node.stepId);
84
+ const result = await AssistsXAsync.findByTags(className, {
85
+ filterText,
86
+ filterViewId,
87
+ filterDes,
88
+ node: this.node,
89
+ });
90
+ Step.assignIdsToNodes(result, this.node.stepId);
91
+ Step.assert(this.node.stepId);
92
+ return result;
93
+ }
94
+ /**
95
+ * 在当前节点范围内通过ID查找节点
96
+ * @param id 节点ID
97
+ * @param filterClass 类名过滤
98
+ * @param filterText 文本过滤
99
+ * @param filterDes 描述过滤
100
+ * @returns 节点数组
101
+ */
102
+ async findById(id, { filterClass, filterText, filterDes, } = {}) {
103
+ Step.assert(this.node.stepId);
104
+ const result = await AssistsXAsync.findById(id, {
105
+ filterClass,
106
+ filterText,
107
+ filterDes,
108
+ node: this.node,
109
+ });
110
+ Step.assignIdsToNodes(result, this.node.stepId);
111
+ Step.assert(this.node.stepId);
112
+ return result;
113
+ }
114
+ /**
115
+ * 在当前节点范围内通过文本查找节点
116
+ * @param text 要查找的文本
117
+ * @param filterClass 类名过滤
118
+ * @param filterViewId 视图ID过滤
119
+ * @param filterDes 描述过滤
120
+ * @returns 节点数组
121
+ */
122
+ async findByText(text, { filterClass, filterViewId, filterDes, } = {}) {
123
+ Step.assert(this.node.stepId);
124
+ const result = await AssistsXAsync.findByText(text, {
125
+ filterClass,
126
+ filterViewId,
127
+ filterDes,
128
+ node: this.node,
129
+ });
130
+ Step.assignIdsToNodes(result, this.node.stepId);
131
+ Step.assert(this.node.stepId);
132
+ return result;
133
+ }
134
+ /**
135
+ * 向前滚动节点
136
+ * @returns 是否滚动成功
137
+ */
138
+ async scrollForward() {
139
+ Step.assert(this.node.stepId);
140
+ const response = await AssistsXAsync.scrollForward(this.node);
141
+ Step.assert(this.node.stepId);
142
+ return response;
143
+ }
144
+ /**
145
+ * 向后滚动节点
146
+ * @returns 是否滚动成功
147
+ */
148
+ async scrollBackward() {
149
+ Step.assert(this.node.stepId);
150
+ const response = await AssistsXAsync.scrollBackward(this.node);
151
+ Step.assert(this.node.stepId);
152
+ return response;
153
+ }
154
+ /**
155
+ * 检查节点是否可见
156
+ * @param compareNode 比较节点
157
+ * @param isFullyByCompareNode 是否完全可见
158
+ * @returns 是否可见
159
+ */
160
+ async isVisible({ compareNode, isFullyByCompareNode, } = {}) {
161
+ Step.assert(this.node.stepId);
162
+ const response = await AssistsXAsync.isVisible(this.node, {
163
+ compareNode,
164
+ isFullyByCompareNode,
165
+ });
166
+ Step.assert(this.node.stepId);
167
+ return response;
168
+ }
169
+ /**
170
+ * 对节点进行截图
171
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
172
+ * @returns 截图路径
173
+ */
174
+ async takeScreenshot(overlayHiddenScreenshotDelayMillis = 250) {
175
+ Step.assert(this.node.stepId);
176
+ const result = await AssistsXAsync.takeScreenshotNodes([this.node], overlayHiddenScreenshotDelayMillis);
177
+ Step.assert(this.node.stepId);
178
+ return result[0];
179
+ }
180
+ /**
181
+ * 设置节点文本
182
+ * @param text 要设置的文本
183
+ * @returns 是否设置成功
184
+ */
185
+ async setNodeText(text) {
186
+ Step.assert(this.node.stepId);
187
+ const result = await AssistsXAsync.setNodeText(this.node, text);
188
+ Step.assert(this.node.stepId);
189
+ return result;
190
+ }
191
+ async paste(text) {
192
+ Step.assert(this.node.stepId);
193
+ const result = await AssistsXAsync.paste(this.node, text);
194
+ Step.assert(this.node.stepId);
195
+ return result;
196
+ }
197
+ async focus() {
198
+ Step.assert(this.node.stepId);
199
+ const result = await AssistsXAsync.focus(this.node);
200
+ Step.assert(this.node.stepId);
201
+ return result;
202
+ }
203
+ /**
204
+ * 点击节点
205
+ * @returns 是否点击成功
206
+ */
207
+ async click() {
208
+ Step.assert(this.node.stepId);
209
+ const result = await AssistsXAsync.click(this.node);
210
+ Step.assert(this.node.stepId);
211
+ return result;
212
+ }
213
+ /**
214
+ * 长按节点
215
+ * @returns 是否长按成功
216
+ */
217
+ async longClick() {
218
+ Step.assert(this.node.stepId);
219
+ const result = await AssistsXAsync.longClick(this.node);
220
+ Step.assert(this.node.stepId);
221
+ return result;
222
+ }
223
+ /**
224
+ * 查找第一个可点击的父节点
225
+ * @returns 可点击的父节点
226
+ */
227
+ async findFirstParentClickable() {
228
+ Step.assert(this.node.stepId);
229
+ const result = await AssistsXAsync.findFirstParentClickable(this.node);
230
+ Step.assert(this.node.stepId);
231
+ Step.assignIdsToNodes([result], this.node.stepId);
232
+ return result;
233
+ }
234
+ /**
235
+ * 获取节点在屏幕中的边界
236
+ * @returns 边界对象
237
+ */
238
+ async getBoundsInScreen() {
239
+ Step.assert(this.node.stepId);
240
+ const result = await AssistsXAsync.getBoundsInScreen(this.node);
241
+ Step.assert(this.node.stepId);
242
+ return result;
243
+ }
244
+ /**
245
+ * 获取节点的所有子节点
246
+ * @returns 子节点数组
247
+ */
248
+ async getNodes() {
249
+ Step.assert(this.node.stepId);
250
+ const result = await AssistsXAsync.getNodes(this.node);
251
+ Step.assert(this.node.stepId);
252
+ Step.assignIdsToNodes(result, this.node.stepId);
253
+ return result;
254
+ }
255
+ /**
256
+ * 获取节点的直接子节点
257
+ * @returns 子节点数组
258
+ */
259
+ async getChildren() {
260
+ Step.assert(this.node.stepId);
261
+ const result = await AssistsXAsync.getChildren(this.node);
262
+ Step.assert(this.node.stepId);
263
+ Step.assignIdsToNodes(result, this.node.stepId);
264
+ return result;
265
+ }
266
+ /**
267
+ * 从JSON字符串创建节点实例
268
+ * @param json JSON字符串
269
+ * @returns 节点实例
270
+ */
271
+ static fromJSON(json) {
272
+ const data = JSON.parse(json);
273
+ return new Node(data);
274
+ }
275
+ /**
276
+ * 从普通对象创建节点实例
277
+ * @param data 对象数据
278
+ * @returns 节点实例
279
+ */
280
+ static from(data) {
281
+ return new Node(data);
282
+ }
283
+ /**
284
+ * JSON.parse的reviver函数,用于将解析的JSON对象转换为Node实例
285
+ * @param key 属性键
286
+ * @param value 属性值
287
+ * @returns 转换后的值
288
+ */
289
+ static reviver(key, value) {
290
+ return key === "" ? new Node(value) : value;
291
+ }
292
+ /**
293
+ * 创建新的节点实例
294
+ * @param params 节点参数对象
295
+ * @returns 节点实例
296
+ */
297
+ static create(params) {
298
+ return new Node(params);
299
+ }
300
+ /**
301
+ * 从JSON数组创建节点数组
302
+ * @param array JSON数组
303
+ * @returns 节点数组
304
+ */
305
+ static fromJSONArray(array) {
306
+ return array.map((data) => new Node(data));
307
+ }
308
+ }