assistsx-js 0.0.1353 → 0.0.2001

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