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/src/Node.ts CHANGED
@@ -2,350 +2,467 @@
2
2
  * 节点类
3
3
  * 表示界面上的一个可交互元素,包含元素的属性和可执行的操作
4
4
  */
5
- import { Bounds } from './Bounds';
6
- import { AssistsX } from './AssistsX';
7
- import { Step } from './Step';
5
+ import { Bounds } from "./Bounds";
6
+ import { AssistsX } from "./AssistsX";
7
+ import { Step } from "./Step";
8
+ import { NodeAsync } from "./NodeAsync";
8
9
 
9
10
  // 将接口改造为类
10
11
  export class Node {
11
- /**
12
- * 节点唯一标识
13
- */
14
- nodeId: string;
12
+ /**
13
+ * 节点唯一标识
14
+ */
15
+ nodeId: string;
15
16
 
16
- /**
17
- * 节点文本内容
18
- */
19
- text: string;
17
+ /**
18
+ * 节点文本内容
19
+ */
20
+ text: string;
20
21
 
21
- /**
22
- * 节点描述信息
23
- */
24
- des: string;
22
+ /**
23
+ * 节点描述信息
24
+ */
25
+ des: string;
25
26
 
26
- /**
27
- * 节点视图ID
28
- */
29
- viewId: string;
27
+ /**
28
+ * 节点视图ID
29
+ */
30
+ viewId: string;
30
31
 
31
- /**
32
- * 节点类名
33
- */
34
- className: string;
32
+ /**
33
+ * 节点类名
34
+ */
35
+ className: string;
35
36
 
36
- /**
37
- * 是否可滚动
38
- */
39
- isScrollable: boolean;
37
+ /**
38
+ * 是否可滚动
39
+ */
40
+ isScrollable: boolean;
40
41
 
41
- /**
42
- * 是否可点击
43
- */
44
- isClickable: boolean;
42
+ /**
43
+ * 是否可点击
44
+ */
45
+ isClickable: boolean;
45
46
 
46
- /**
47
- * 是否启用
48
- */
49
- isEnabled: boolean;
47
+ /**
48
+ * 是否启用
49
+ */
50
+ isEnabled: boolean;
51
+
52
+ /**
53
+ * 所属步骤ID
54
+ */
55
+ stepId: string | undefined;
50
56
 
51
- /**
52
- * 所属步骤ID
53
- */
57
+ /**
58
+ * 构造函数
59
+ * @param params 节点参数对象
60
+ */
61
+ constructor(params: {
62
+ nodeId: string;
63
+ text: string;
64
+ des: string;
65
+ viewId: string;
66
+ className: string;
67
+ isScrollable: boolean;
68
+ isClickable: boolean;
69
+ isEnabled: boolean;
54
70
  stepId: string | undefined;
71
+ }) {
72
+ this.nodeId = params.nodeId;
73
+ this.text = params.text;
74
+ this.des = params.des;
75
+ this.viewId = params.viewId;
76
+ this.className = params.className;
77
+ this.isScrollable = params.isScrollable;
78
+ this.isClickable = params.isClickable;
79
+ this.isEnabled = params.isEnabled;
80
+ this.stepId = params.stepId;
81
+ }
82
+
83
+ public get async(): NodeAsync {
84
+ return new NodeAsync(this);
85
+ }
55
86
 
56
- /**
57
- * 构造函数
58
- * @param params 节点参数对象
59
- */
60
- constructor(params: {
61
- nodeId: string;
62
- text: string;
63
- des: string;
64
- viewId: string;
65
- className: string;
66
- isScrollable: boolean;
67
- isClickable: boolean;
68
- isEnabled: boolean;
69
- stepId: string | undefined;
70
- }) {
71
- this.nodeId = params.nodeId;
72
- this.text = params.text;
73
- this.des = params.des;
74
- this.viewId = params.viewId;
75
- this.className = params.className;
76
- this.isScrollable = params.isScrollable;
77
- this.isClickable = params.isClickable;
78
- this.isEnabled = params.isEnabled;
79
- this.stepId = params.stepId;
80
- }
87
+ /**
88
+ * 查找第一个匹配标签的父节点
89
+ * @param className 类名
90
+ * @returns 父节点
91
+ */
92
+ public findFirstParentByTags(className: string): Node {
93
+ Step.assert(this.stepId);
94
+ const node = AssistsX.findFirstParentByTags(this, className);
95
+ Step.assert(this.stepId);
96
+ return node;
97
+ }
81
98
 
82
- /**
83
- * 对节点执行点击手势
84
- * @param offsetX X轴偏移
85
- * @param offsetY Y轴偏移
86
- * @param switchWindowIntervalDelay 窗口切换延迟
87
- * @param clickDuration 点击持续时间
88
- * @returns 是否点击成功
89
- */
90
- public async clickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration }: { offsetX?: number, offsetY?: number, switchWindowIntervalDelay?: number, clickDuration?: number } = {}): Promise<boolean> {
91
- Step.assert(this.stepId);
92
- const result = await AssistsX.clickNodeByGesture(this, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration });
93
- Step.assert(this.stepId);
94
- return result;
95
- }
96
- /**
97
- * 对节点执行双击手势
98
- * @param offsetX X轴偏移
99
- * @param offsetY Y轴偏移
100
- * @param switchWindowIntervalDelay 窗口切换延迟
101
- * @param clickDuration 点击持续时间
102
- * @param clickInterval 点击间隔
103
- * @returns 是否双击成功
104
- */
105
- public async doubleClickNodeByGesture({ offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval }: { offsetX?: number, offsetY?: number, switchWindowIntervalDelay?: number, clickDuration?: number, clickInterval?: number } = {}): Promise<boolean> {
106
- Step.assert(this.stepId);
107
- const result = await AssistsX.doubleClickNodeByGesture(this, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval });
108
- Step.assert(this.stepId);
109
- return result;
110
- }
99
+ /**
100
+ * 对节点执行点击手势
101
+ * @param offsetX X轴偏移
102
+ * @param offsetY Y轴偏移
103
+ * @param switchWindowIntervalDelay 窗口切换延迟
104
+ * @param clickDuration 点击持续时间
105
+ * @returns 是否点击成功
106
+ */
107
+ public async clickNodeByGesture({
108
+ offsetX,
109
+ offsetY,
110
+ switchWindowIntervalDelay,
111
+ clickDuration,
112
+ }: {
113
+ offsetX?: number;
114
+ offsetY?: number;
115
+ switchWindowIntervalDelay?: number;
116
+ clickDuration?: number;
117
+ } = {}): Promise<boolean> {
118
+ Step.assert(this.stepId);
119
+ const result = await AssistsX.clickNodeByGesture(this, {
120
+ offsetX,
121
+ offsetY,
122
+ switchWindowIntervalDelay,
123
+ clickDuration,
124
+ });
125
+ Step.assert(this.stepId);
126
+ return result;
127
+ }
128
+ /**
129
+ * 对节点执行双击手势
130
+ * @param offsetX X轴偏移
131
+ * @param offsetY Y轴偏移
132
+ * @param switchWindowIntervalDelay 窗口切换延迟
133
+ * @param clickDuration 点击持续时间
134
+ * @param clickInterval 点击间隔
135
+ * @returns 是否双击成功
136
+ */
137
+ public async doubleClickNodeByGesture({
138
+ offsetX,
139
+ offsetY,
140
+ switchWindowIntervalDelay,
141
+ clickDuration,
142
+ clickInterval,
143
+ }: {
144
+ offsetX?: number;
145
+ offsetY?: number;
146
+ switchWindowIntervalDelay?: number;
147
+ clickDuration?: number;
148
+ clickInterval?: number;
149
+ } = {}): Promise<boolean> {
150
+ Step.assert(this.stepId);
151
+ const result = await AssistsX.doubleClickNodeByGesture(this, {
152
+ offsetX,
153
+ offsetY,
154
+ switchWindowIntervalDelay,
155
+ clickDuration,
156
+ clickInterval,
157
+ });
158
+ Step.assert(this.stepId);
159
+ return result;
160
+ }
111
161
 
112
- public async longPressNodeByGestureAutoPaste(text: string,
113
- { matchedPackageName, matchedText, timeoutMillis, longPressDuration }:
114
- { matchedPackageName?: string, matchedText?: string, timeoutMillis?: number, longPressDuration?: number } =
115
- { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }
116
- ): Promise<boolean> {
117
- Step.assert(this.stepId);
118
- const result = await AssistsX.longPressNodeByGestureAutoPaste(this, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration });
119
- Step.assert(this.stepId);
120
- return result;
121
- }
162
+ public async longPressNodeByGestureAutoPaste(
163
+ text: string,
164
+ {
165
+ matchedPackageName,
166
+ matchedText,
167
+ timeoutMillis,
168
+ longPressDuration,
169
+ }: {
170
+ matchedPackageName?: string;
171
+ matchedText?: string;
172
+ timeoutMillis?: number;
173
+ longPressDuration?: number;
174
+ } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }
175
+ ): Promise<boolean> {
176
+ Step.assert(this.stepId);
177
+ const result = await AssistsX.longPressNodeByGestureAutoPaste(this, text, {
178
+ matchedPackageName,
179
+ matchedText,
180
+ timeoutMillis,
181
+ longPressDuration,
182
+ });
183
+ Step.assert(this.stepId);
184
+ return result;
185
+ }
122
186
 
123
- /**
124
- * 在当前节点范围内通过标签查找节点
125
- * @param className 类名
126
- * @param filterText 文本过滤
127
- * @param filterViewId 视图ID过滤
128
- * @param filterDes 描述过滤
129
- * @returns 节点数组
130
- */
131
- public findByTags(className: string, { filterText, filterViewId, filterDes }: { filterText?: string, filterViewId?: string, filterDes?: string, } = {}): Node[] {
132
- Step.assert(this.stepId);
133
- const result = AssistsX.findByTags(className, { filterText, filterViewId, filterDes, node: this });
134
- Step.assignIdsToNodes(result, this.stepId);
135
- Step.assert(this.stepId);
136
- return result;
137
- }
138
- /**
139
- * 在当前节点范围内通过ID查找节点
140
- * @param id 节点ID
141
- * @param filterClass 类名过滤
142
- * @param filterText 文本过滤
143
- * @param filterDes 描述过滤
144
- * @returns 节点数组
145
- */
146
- public findById(id: string, { filterClass, filterText, filterDes }: { filterClass?: string, filterText?: string, filterDes?: string } = {}): Node[] {
147
- Step.assert(this.stepId);
148
- const result = AssistsX.findById(id, { filterClass, filterText, filterDes, node: this });
149
- Step.assignIdsToNodes(result, this.stepId);
150
- Step.assert(this.stepId);
151
- return result;
152
- }
153
- /**
154
- * 在当前节点范围内通过文本查找节点
155
- * @param text 要查找的文本
156
- * @param filterClass 类名过滤
157
- * @param filterViewId 视图ID过滤
158
- * @param filterDes 描述过滤
159
- * @returns 节点数组
160
- */
161
- public findByText(text: string, { filterClass, filterViewId, filterDes }: { filterClass?: string, filterViewId?: string, filterDes?: string } = {}): Node[] {
162
- Step.assert(this.stepId);
163
- const result = AssistsX.findByText(text, { filterClass, filterViewId, filterDes, node: this });
164
- Step.assignIdsToNodes(result, this.stepId);
165
- Step.assert(this.stepId);
166
- return result;
167
- }
187
+ /**
188
+ * 在当前节点范围内通过标签查找节点
189
+ * @param className 类名
190
+ * @param filterText 文本过滤
191
+ * @param filterViewId 视图ID过滤
192
+ * @param filterDes 描述过滤
193
+ * @returns 节点数组
194
+ */
195
+ public findByTags(
196
+ className: string,
197
+ {
198
+ filterText,
199
+ filterViewId,
200
+ filterDes,
201
+ }: { filterText?: string; filterViewId?: string; filterDes?: string } = {}
202
+ ): Node[] {
203
+ Step.assert(this.stepId);
204
+ const result = AssistsX.findByTags(className, {
205
+ filterText,
206
+ filterViewId,
207
+ filterDes,
208
+ node: this,
209
+ });
210
+ Step.assignIdsToNodes(result, this.stepId);
211
+ Step.assert(this.stepId);
212
+ return result;
213
+ }
214
+ /**
215
+ * 在当前节点范围内通过ID查找节点
216
+ * @param id 节点ID
217
+ * @param filterClass 类名过滤
218
+ * @param filterText 文本过滤
219
+ * @param filterDes 描述过滤
220
+ * @returns 节点数组
221
+ */
222
+ public findById(
223
+ id: string,
224
+ {
225
+ filterClass,
226
+ filterText,
227
+ filterDes,
228
+ }: { filterClass?: string; filterText?: string; filterDes?: string } = {}
229
+ ): Node[] {
230
+ Step.assert(this.stepId);
231
+ const result = AssistsX.findById(id, {
232
+ filterClass,
233
+ filterText,
234
+ filterDes,
235
+ node: this,
236
+ });
237
+ Step.assignIdsToNodes(result, this.stepId);
238
+ Step.assert(this.stepId);
239
+ return result;
240
+ }
241
+ /**
242
+ * 在当前节点范围内通过文本查找节点
243
+ * @param text 要查找的文本
244
+ * @param filterClass 类名过滤
245
+ * @param filterViewId 视图ID过滤
246
+ * @param filterDes 描述过滤
247
+ * @returns 节点数组
248
+ */
249
+ public findByText(
250
+ text: string,
251
+ {
252
+ filterClass,
253
+ filterViewId,
254
+ filterDes,
255
+ }: { filterClass?: string; filterViewId?: string; filterDes?: string } = {}
256
+ ): Node[] {
257
+ Step.assert(this.stepId);
258
+ const result = AssistsX.findByText(text, {
259
+ filterClass,
260
+ filterViewId,
261
+ filterDes,
262
+ node: this,
263
+ });
264
+ Step.assignIdsToNodes(result, this.stepId);
265
+ Step.assert(this.stepId);
266
+ return result;
267
+ }
168
268
 
169
- /**
170
- * 向前滚动节点
171
- * @returns 是否滚动成功
172
- */
173
- public scrollForward(): boolean {
174
- Step.assert(this.stepId);
175
- const response = AssistsX.scrollForward(this);
176
- Step.assert(this.stepId);
177
- return response;
178
- }
269
+ /**
270
+ * 向前滚动节点
271
+ * @returns 是否滚动成功
272
+ */
273
+ public scrollForward(): boolean {
274
+ Step.assert(this.stepId);
275
+ const response = AssistsX.scrollForward(this);
276
+ Step.assert(this.stepId);
277
+ return response;
278
+ }
179
279
 
180
- /**
181
- * 向后滚动节点
182
- * @returns 是否滚动成功
183
- */
184
- public scrollBackward(): boolean {
185
- Step.assert(this.stepId);
186
- const response = AssistsX.scrollBackward(this);
187
- Step.assert(this.stepId);
188
- return response;
189
- }
190
- /**
191
- * 检查节点是否可见
192
- * @param compareNode 比较节点
193
- * @param isFullyByCompareNode 是否完全可见
194
- * @returns 是否可见
195
- */
196
- public isVisible({ compareNode, isFullyByCompareNode }: { compareNode?: Node, isFullyByCompareNode?: boolean } = {}): boolean {
197
- Step.assert(this.stepId);
198
- const response = AssistsX.isVisible(this, { compareNode, isFullyByCompareNode });
199
- Step.assert(this.stepId);
200
- return response;
201
- }
202
- /**
203
- * 对节点进行截图
204
- * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
205
- * @returns 截图路径
206
- */
207
- public async takeScreenshot(overlayHiddenScreenshotDelayMillis: number = 250): Promise<string> {
208
- Step.assert(this.stepId);
209
- const result = await AssistsX.takeScreenshotNodes([this], overlayHiddenScreenshotDelayMillis);
210
- Step.assert(this.stepId);
211
- return result[0];
212
- }
213
- /**
214
- * 设置节点文本
215
- * @param text 要设置的文本
216
- * @returns 是否设置成功
217
- */
218
- public setNodeText(text: string): boolean {
219
- Step.assert(this.stepId);
220
- const result = AssistsX.setNodeText(this, text);
221
- Step.assert(this.stepId);
222
- return result;
223
- }
224
- public paste(text: string): boolean {
225
- Step.assert(this.stepId);
226
- const result = AssistsX.paste(this, text);
227
- Step.assert(this.stepId);
228
- return result;
229
- }
280
+ /**
281
+ * 向后滚动节点
282
+ * @returns 是否滚动成功
283
+ */
284
+ public scrollBackward(): boolean {
285
+ Step.assert(this.stepId);
286
+ const response = AssistsX.scrollBackward(this);
287
+ Step.assert(this.stepId);
288
+ return response;
289
+ }
290
+ /**
291
+ * 检查节点是否可见
292
+ * @param compareNode 比较节点
293
+ * @param isFullyByCompareNode 是否完全可见
294
+ * @returns 是否可见
295
+ */
296
+ public isVisible({
297
+ compareNode,
298
+ isFullyByCompareNode,
299
+ }: { compareNode?: Node; isFullyByCompareNode?: boolean } = {}): boolean {
300
+ Step.assert(this.stepId);
301
+ const response = AssistsX.isVisible(this, {
302
+ compareNode,
303
+ isFullyByCompareNode,
304
+ });
305
+ Step.assert(this.stepId);
306
+ return response;
307
+ }
308
+ /**
309
+ * 对节点进行截图
310
+ * @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
311
+ * @returns 截图路径
312
+ */
313
+ public async takeScreenshot(
314
+ overlayHiddenScreenshotDelayMillis: number = 250
315
+ ): Promise<string> {
316
+ Step.assert(this.stepId);
317
+ const result = await AssistsX.takeScreenshotNodes(
318
+ [this],
319
+ overlayHiddenScreenshotDelayMillis
320
+ );
321
+ Step.assert(this.stepId);
322
+ return result[0];
323
+ }
324
+ /**
325
+ * 设置节点文本
326
+ * @param text 要设置的文本
327
+ * @returns 是否设置成功
328
+ */
329
+ public setNodeText(text: string): boolean {
330
+ Step.assert(this.stepId);
331
+ const result = AssistsX.setNodeText(this, text);
332
+ Step.assert(this.stepId);
333
+ return result;
334
+ }
335
+ public paste(text: string): boolean {
336
+ Step.assert(this.stepId);
337
+ const result = AssistsX.paste(this, text);
338
+ Step.assert(this.stepId);
339
+ return result;
340
+ }
341
+ public focus(): boolean {
342
+ Step.assert(this.stepId);
343
+ const result = AssistsX.focus(this);
344
+ Step.assert(this.stepId);
345
+ return result;
346
+ }
230
347
 
231
- /**
232
- * 点击节点
233
- * @returns 是否点击成功
234
- */
235
- public click(): boolean {
236
- Step.assert(this.stepId);
237
- const result = AssistsX.click(this);
238
- Step.assert(this.stepId);
239
- return result;
240
- }
241
- /**
242
- * 长按节点
243
- * @returns 是否长按成功
244
- */
245
- public longClick(): boolean {
246
- Step.assert(this.stepId);
247
- const result = AssistsX.longClick(this);
248
- Step.assert(this.stepId);
249
- return result;
250
- }
251
- /**
252
- * 查找第一个可点击的父节点
253
- * @returns 可点击的父节点
254
- */
255
- public findFirstParentClickable(): Node {
256
- Step.assert(this.stepId);
257
- const result = AssistsX.findFirstParentClickable(this);
258
- Step.assert(this.stepId);
259
- Step.assignIdsToNodes([result], this.stepId);
260
- return result;
261
- }
262
- /**
263
- * 获取节点在屏幕中的边界
264
- * @returns 边界对象
265
- */
266
- public getBoundsInScreen(): Bounds {
267
- Step.assert(this.stepId);
268
- const result = AssistsX.getBoundsInScreen(this);
269
- Step.assert(this.stepId);
270
- return result;
271
- }
272
- /**
273
- * 获取节点的所有子节点
274
- * @returns 子节点数组
275
- */
276
- public getNodes(): Node[] {
277
- Step.assert(this.stepId);
278
- const result = AssistsX.getNodes(this);
279
- Step.assert(this.stepId);
280
- Step.assignIdsToNodes(result, this.stepId);
281
- return result;
282
- }
283
- /**
284
- * 获取节点的直接子节点
285
- * @returns 子节点数组
286
- */
287
- public getChildren(): Node[] {
288
- Step.assert(this.stepId);
289
- const result = AssistsX.getChildren(this);
290
- Step.assert(this.stepId);
291
- Step.assignIdsToNodes(result, this.stepId);
292
- return result;
293
- }
348
+ /**
349
+ * 点击节点
350
+ * @returns 是否点击成功
351
+ */
352
+ public click(): boolean {
353
+ Step.assert(this.stepId);
354
+ const result = AssistsX.click(this);
355
+ Step.assert(this.stepId);
356
+ return result;
357
+ }
358
+ /**
359
+ * 长按节点
360
+ * @returns 是否长按成功
361
+ */
362
+ public longClick(): boolean {
363
+ Step.assert(this.stepId);
364
+ const result = AssistsX.longClick(this);
365
+ Step.assert(this.stepId);
366
+ return result;
367
+ }
368
+ /**
369
+ * 查找第一个可点击的父节点
370
+ * @returns 可点击的父节点
371
+ */
372
+ public findFirstParentClickable(): Node {
373
+ Step.assert(this.stepId);
374
+ const result = AssistsX.findFirstParentClickable(this);
375
+ Step.assert(this.stepId);
376
+ Step.assignIdsToNodes([result], this.stepId);
377
+ return result;
378
+ }
379
+ /**
380
+ * 获取节点在屏幕中的边界
381
+ * @returns 边界对象
382
+ */
383
+ public getBoundsInScreen(): Bounds {
384
+ Step.assert(this.stepId);
385
+ const result = AssistsX.getBoundsInScreen(this);
386
+ Step.assert(this.stepId);
387
+ return result;
388
+ }
389
+ /**
390
+ * 获取节点的所有子节点
391
+ * @returns 子节点数组
392
+ */
393
+ public getNodes(): Node[] {
394
+ Step.assert(this.stepId);
395
+ const result = AssistsX.getNodes(this);
396
+ Step.assert(this.stepId);
397
+ Step.assignIdsToNodes(result, this.stepId);
398
+ return result;
399
+ }
400
+ /**
401
+ * 获取节点的直接子节点
402
+ * @returns 子节点数组
403
+ */
404
+ public getChildren(): Node[] {
405
+ Step.assert(this.stepId);
406
+ const result = AssistsX.getChildren(this);
407
+ Step.assert(this.stepId);
408
+ Step.assignIdsToNodes(result, this.stepId);
409
+ return result;
410
+ }
294
411
 
295
- /**
296
- * 从JSON字符串创建节点实例
297
- * @param json JSON字符串
298
- * @returns 节点实例
299
- */
300
- static fromJSON(json: string): Node {
301
- const data = JSON.parse(json);
302
- return new Node(data);
303
- }
412
+ /**
413
+ * 从JSON字符串创建节点实例
414
+ * @param json JSON字符串
415
+ * @returns 节点实例
416
+ */
417
+ static fromJSON(json: string): Node {
418
+ const data = JSON.parse(json);
419
+ return new Node(data);
420
+ }
304
421
 
305
- /**
306
- * 从普通对象创建节点实例
307
- * @param data 对象数据
308
- * @returns 节点实例
309
- */
310
- static from(data: any): Node {
311
- return new Node(data);
312
- }
422
+ /**
423
+ * 从普通对象创建节点实例
424
+ * @param data 对象数据
425
+ * @returns 节点实例
426
+ */
427
+ static from(data: any): Node {
428
+ return new Node(data);
429
+ }
313
430
 
314
- /**
315
- * JSON.parse的reviver函数,用于将解析的JSON对象转换为Node实例
316
- * @param key 属性键
317
- * @param value 属性值
318
- * @returns 转换后的值
319
- */
320
- static reviver(key: string, value: any): any {
321
- return key === "" ? new Node(value) : value;
322
- }
431
+ /**
432
+ * JSON.parse的reviver函数,用于将解析的JSON对象转换为Node实例
433
+ * @param key 属性键
434
+ * @param value 属性值
435
+ * @returns 转换后的值
436
+ */
437
+ static reviver(key: string, value: any): any {
438
+ return key === "" ? new Node(value) : value;
439
+ }
323
440
 
324
- /**
325
- * 创建新的节点实例
326
- * @param params 节点参数对象
327
- * @returns 节点实例
328
- */
329
- static create(params: {
330
- nodeId: string;
331
- text: string;
332
- des: string;
333
- viewId: string;
334
- className: string;
335
- isScrollable: boolean;
336
- isClickable: boolean;
337
- isEnabled: boolean;
338
- stepId: string | undefined;
339
- }): Node {
340
- return new Node(params);
341
- }
441
+ /**
442
+ * 创建新的节点实例
443
+ * @param params 节点参数对象
444
+ * @returns 节点实例
445
+ */
446
+ static create(params: {
447
+ nodeId: string;
448
+ text: string;
449
+ des: string;
450
+ viewId: string;
451
+ className: string;
452
+ isScrollable: boolean;
453
+ isClickable: boolean;
454
+ isEnabled: boolean;
455
+ stepId: string | undefined;
456
+ }): Node {
457
+ return new Node(params);
458
+ }
342
459
 
343
- /**
344
- * 从JSON数组创建节点数组
345
- * @param array JSON数组
346
- * @returns 节点数组
347
- */
348
- static fromJSONArray(array: Array<any>): Node[] {
349
- return array.map(data => new Node(data));
350
- }
351
- }
460
+ /**
461
+ * 从JSON数组创建节点数组
462
+ * @param array JSON数组
463
+ * @returns 节点数组
464
+ */
465
+ static fromJSONArray(array: Array<any>): Node[] {
466
+ return array.map((data) => new Node(data));
467
+ }
468
+ }