assistsx-js 0.0.2024 → 0.0.2025
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/AssistsX.d.ts +28 -14
- package/dist/AssistsX.js +40 -19
- package/dist/AssistsXAsync.d.ts +95 -46
- package/dist/AssistsXAsync.js +154 -66
- package/package.json +1 -1
- package/src/AssistsX.ts +55 -15
- package/src/AssistsXAsync.ts +222 -58
package/dist/AssistsXAsync.js
CHANGED
|
@@ -13,9 +13,10 @@ export class AssistsXAsync {
|
|
|
13
13
|
* 执行异步调用
|
|
14
14
|
* @param method 方法名
|
|
15
15
|
* @param args 参数对象
|
|
16
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
16
17
|
* @returns Promise<调用响应>
|
|
17
18
|
*/
|
|
18
|
-
static async asyncCall(method, { args, node, nodes } = {}) {
|
|
19
|
+
static async asyncCall(method, { args, node, nodes, timeout = 30, } = {}) {
|
|
19
20
|
const uuid = generateUUID();
|
|
20
21
|
const params = {
|
|
21
22
|
method,
|
|
@@ -32,7 +33,7 @@ export class AssistsXAsync {
|
|
|
32
33
|
// 超时后删除回调函数
|
|
33
34
|
callbacks.delete(uuid);
|
|
34
35
|
resolve(new CallResponse(0, null, uuid));
|
|
35
|
-
},
|
|
36
|
+
}, timeout * 1000);
|
|
36
37
|
});
|
|
37
38
|
const result = window.assistsxAsync.call(JSON.stringify(params));
|
|
38
39
|
const promiseResult = await promise;
|
|
@@ -46,22 +47,26 @@ export class AssistsXAsync {
|
|
|
46
47
|
/**
|
|
47
48
|
* 设置悬浮窗标志
|
|
48
49
|
* @param flags 标志
|
|
50
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
49
51
|
* @returns 是否设置成功
|
|
50
52
|
*/
|
|
51
|
-
static async setOverlayFlags(flags) {
|
|
53
|
+
static async setOverlayFlags(flags, timeout) {
|
|
52
54
|
const response = await this.asyncCall(CallMethod.setOverlayFlags, {
|
|
53
55
|
args: { flags: flags },
|
|
56
|
+
timeout,
|
|
54
57
|
});
|
|
55
58
|
return response.getDataOrDefault(false);
|
|
56
59
|
}
|
|
57
60
|
/**
|
|
58
61
|
* 设置悬浮窗标志
|
|
59
62
|
* @param flags 标志
|
|
63
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
60
64
|
* @returns 是否设置成功
|
|
61
65
|
*/
|
|
62
|
-
static async setOverlayFlagList(flags) {
|
|
66
|
+
static async setOverlayFlagList(flags, timeout) {
|
|
63
67
|
const response = await this.asyncCall(CallMethod.setOverlayFlags, {
|
|
64
68
|
args: { flags: flags },
|
|
69
|
+
timeout,
|
|
65
70
|
});
|
|
66
71
|
return response.getDataOrDefault(false);
|
|
67
72
|
}
|
|
@@ -71,11 +76,13 @@ export class AssistsXAsync {
|
|
|
71
76
|
* @param filterViewId 视图ID过滤
|
|
72
77
|
* @param filterDes 描述过滤
|
|
73
78
|
* @param filterText 文本过滤
|
|
79
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
74
80
|
* @returns 节点数组
|
|
75
81
|
*/
|
|
76
|
-
static async getAllNodes({ filterClass, filterViewId, filterDes, filterText, } = {}) {
|
|
82
|
+
static async getAllNodes({ filterClass, filterViewId, filterDes, filterText, timeout, } = {}) {
|
|
77
83
|
const response = await this.asyncCall(CallMethod.getAllNodes, {
|
|
78
84
|
args: { filterClass, filterViewId, filterDes, filterText },
|
|
85
|
+
timeout,
|
|
79
86
|
});
|
|
80
87
|
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
81
88
|
}
|
|
@@ -83,12 +90,14 @@ export class AssistsXAsync {
|
|
|
83
90
|
* 设置节点文本
|
|
84
91
|
* @param node 目标节点
|
|
85
92
|
* @param text 要设置的文本
|
|
93
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
86
94
|
* @returns 是否设置成功
|
|
87
95
|
*/
|
|
88
|
-
static async setNodeText(node, text) {
|
|
96
|
+
static async setNodeText(node, text, timeout) {
|
|
89
97
|
const response = await this.asyncCall(CallMethod.setNodeText, {
|
|
90
98
|
args: { text },
|
|
91
99
|
node,
|
|
100
|
+
timeout,
|
|
92
101
|
});
|
|
93
102
|
return response.getDataOrDefault(false);
|
|
94
103
|
}
|
|
@@ -96,23 +105,25 @@ export class AssistsXAsync {
|
|
|
96
105
|
* 对指定节点进行截图
|
|
97
106
|
* @param nodes 要截图的节点数组
|
|
98
107
|
* @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
|
|
108
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
99
109
|
* @returns 截图路径数组
|
|
100
110
|
*/
|
|
101
|
-
static async takeScreenshotNodes(nodes, overlayHiddenScreenshotDelayMillis = 250) {
|
|
111
|
+
static async takeScreenshotNodes(nodes, overlayHiddenScreenshotDelayMillis = 250, timeout) {
|
|
102
112
|
const response = await this.asyncCall(CallMethod.takeScreenshot, {
|
|
103
113
|
nodes,
|
|
104
114
|
args: { overlayHiddenScreenshotDelayMillis },
|
|
115
|
+
timeout,
|
|
105
116
|
});
|
|
106
117
|
const data = response.getDataOrDefault("");
|
|
107
118
|
return data.images;
|
|
108
119
|
}
|
|
109
|
-
static async scanQR() {
|
|
110
|
-
const response = await this.asyncCall(CallMethod.scanQR);
|
|
120
|
+
static async scanQR(timeout) {
|
|
121
|
+
const response = await this.asyncCall(CallMethod.scanQR, { timeout });
|
|
111
122
|
const data = response.getDataOrDefault({ value: "" });
|
|
112
123
|
return data.value;
|
|
113
124
|
}
|
|
114
125
|
static async loadWebViewOverlay(url, options = {}) {
|
|
115
|
-
const { initialWidth, initialHeight, minWidth, minHeight, maxWidth, maxHeight, initialCenter, } = options;
|
|
126
|
+
const { initialWidth, initialHeight, minWidth, minHeight, maxWidth, maxHeight, initialCenter, timeout, } = options;
|
|
116
127
|
const response = await this.asyncCall(CallMethod.loadWebViewOverlay, {
|
|
117
128
|
args: {
|
|
118
129
|
url,
|
|
@@ -124,6 +135,7 @@ export class AssistsXAsync {
|
|
|
124
135
|
maxHeight,
|
|
125
136
|
initialCenter,
|
|
126
137
|
},
|
|
138
|
+
timeout,
|
|
127
139
|
});
|
|
128
140
|
const data = response.getDataOrDefault({});
|
|
129
141
|
return data;
|
|
@@ -131,49 +143,61 @@ export class AssistsXAsync {
|
|
|
131
143
|
/**
|
|
132
144
|
* 点击节点
|
|
133
145
|
* @param node 要点击的节点
|
|
146
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
134
147
|
* @returns 是否点击成功
|
|
135
148
|
*/
|
|
136
|
-
static async click(node) {
|
|
137
|
-
const response = await this.asyncCall(CallMethod.click, { node });
|
|
149
|
+
static async click(node, timeout) {
|
|
150
|
+
const response = await this.asyncCall(CallMethod.click, { node, timeout });
|
|
138
151
|
return response.getDataOrDefault(false);
|
|
139
152
|
}
|
|
140
153
|
/**
|
|
141
154
|
* 长按节点
|
|
142
155
|
* @param node 要长按的节点
|
|
156
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
143
157
|
* @returns 是否长按成功
|
|
144
158
|
*/
|
|
145
|
-
static async longClick(node) {
|
|
146
|
-
const response = await this.asyncCall(CallMethod.longClick, {
|
|
159
|
+
static async longClick(node, timeout) {
|
|
160
|
+
const response = await this.asyncCall(CallMethod.longClick, {
|
|
161
|
+
node,
|
|
162
|
+
timeout,
|
|
163
|
+
});
|
|
147
164
|
return response.getDataOrDefault(false);
|
|
148
165
|
}
|
|
149
166
|
/**
|
|
150
167
|
* 启动应用
|
|
151
168
|
* @param packageName 应用包名
|
|
169
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
152
170
|
* @returns 是否启动成功
|
|
153
171
|
*/
|
|
154
|
-
static async launchApp(packageName) {
|
|
172
|
+
static async launchApp(packageName, timeout) {
|
|
155
173
|
const response = await this.asyncCall(CallMethod.launchApp, {
|
|
156
174
|
args: { packageName },
|
|
175
|
+
timeout,
|
|
157
176
|
});
|
|
158
177
|
return response.getDataOrDefault(false);
|
|
159
178
|
}
|
|
160
179
|
/**
|
|
161
180
|
* 获取当前应用包名
|
|
181
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
162
182
|
* @returns 包名
|
|
163
183
|
*/
|
|
164
|
-
static async getPackageName() {
|
|
165
|
-
const response = await this.asyncCall(CallMethod.getPackageName
|
|
184
|
+
static async getPackageName(timeout) {
|
|
185
|
+
const response = await this.asyncCall(CallMethod.getPackageName, {
|
|
186
|
+
timeout,
|
|
187
|
+
});
|
|
166
188
|
return response.getDataOrDefault("");
|
|
167
189
|
}
|
|
168
190
|
/**
|
|
169
191
|
* 显示悬浮提示
|
|
170
192
|
* @param text 提示文本
|
|
171
193
|
* @param delay 显示时长(毫秒)
|
|
194
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
172
195
|
* @returns 是否显示成功
|
|
173
196
|
*/
|
|
174
|
-
static async overlayToast(text, delay = 2000) {
|
|
197
|
+
static async overlayToast(text, delay = 2000, timeout) {
|
|
175
198
|
const response = await this.asyncCall(CallMethod.overlayToast, {
|
|
176
199
|
args: { text, delay },
|
|
200
|
+
timeout,
|
|
177
201
|
});
|
|
178
202
|
return response.getDataOrDefault(false);
|
|
179
203
|
}
|
|
@@ -184,12 +208,14 @@ export class AssistsXAsync {
|
|
|
184
208
|
* @param filterText 文本过滤
|
|
185
209
|
* @param filterDes 描述过滤
|
|
186
210
|
* @param node 父节点范围
|
|
211
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
187
212
|
* @returns 节点数组
|
|
188
213
|
*/
|
|
189
|
-
static async findById(id, { filterClass, filterText, filterDes, node, } = {}) {
|
|
214
|
+
static async findById(id, { filterClass, filterText, filterDes, node, timeout, } = {}) {
|
|
190
215
|
const response = await this.asyncCall(CallMethod.findById, {
|
|
191
216
|
args: { id, filterClass, filterText, filterDes },
|
|
192
217
|
node,
|
|
218
|
+
timeout,
|
|
193
219
|
});
|
|
194
220
|
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
195
221
|
}
|
|
@@ -200,12 +226,14 @@ export class AssistsXAsync {
|
|
|
200
226
|
* @param filterViewId 视图ID过滤
|
|
201
227
|
* @param filterDes 描述过滤
|
|
202
228
|
* @param node 父节点范围
|
|
229
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
203
230
|
* @returns 节点数组
|
|
204
231
|
*/
|
|
205
|
-
static async findByText(text, { filterClass, filterViewId, filterDes, node, } = {}) {
|
|
232
|
+
static async findByText(text, { filterClass, filterViewId, filterDes, node, timeout, } = {}) {
|
|
206
233
|
const response = await this.asyncCall(CallMethod.findByText, {
|
|
207
234
|
args: { text, filterClass, filterViewId, filterDes },
|
|
208
235
|
node,
|
|
236
|
+
timeout,
|
|
209
237
|
});
|
|
210
238
|
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
211
239
|
}
|
|
@@ -216,94 +244,115 @@ export class AssistsXAsync {
|
|
|
216
244
|
* @param filterViewId 视图ID过滤
|
|
217
245
|
* @param filterDes 描述过滤
|
|
218
246
|
* @param node 父节点范围
|
|
247
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
219
248
|
* @returns 节点数组
|
|
220
249
|
*/
|
|
221
|
-
static async findByTags(className, { filterText, filterViewId, filterDes, node, } = {}) {
|
|
250
|
+
static async findByTags(className, { filterText, filterViewId, filterDes, node, timeout, } = {}) {
|
|
222
251
|
const response = await this.asyncCall(CallMethod.findByTags, {
|
|
223
252
|
args: { className, filterText, filterViewId, filterDes },
|
|
224
253
|
node,
|
|
254
|
+
timeout,
|
|
225
255
|
});
|
|
226
256
|
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
227
257
|
}
|
|
228
258
|
/**
|
|
229
259
|
* 查找所有匹配文本的节点
|
|
230
260
|
* @param text 要查找的文本
|
|
261
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
231
262
|
* @returns 节点数组
|
|
232
263
|
*/
|
|
233
|
-
static async findByTextAllMatch(text) {
|
|
264
|
+
static async findByTextAllMatch(text, timeout) {
|
|
234
265
|
const response = await this.asyncCall(CallMethod.findByTextAllMatch, {
|
|
235
266
|
args: { text },
|
|
267
|
+
timeout,
|
|
236
268
|
});
|
|
237
269
|
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
238
270
|
}
|
|
239
271
|
/**
|
|
240
272
|
* 检查是否包含指定文本
|
|
241
273
|
* @param text 要检查的文本
|
|
274
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
242
275
|
* @returns 是否包含
|
|
243
276
|
*/
|
|
244
|
-
static async containsText(text) {
|
|
277
|
+
static async containsText(text, timeout) {
|
|
245
278
|
const response = await this.asyncCall(CallMethod.containsText, {
|
|
246
279
|
args: { text },
|
|
280
|
+
timeout,
|
|
247
281
|
});
|
|
248
282
|
return response.getDataOrDefault(false);
|
|
249
283
|
}
|
|
250
284
|
/**
|
|
251
285
|
* 获取所有文本
|
|
286
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
252
287
|
* @returns 文本数组
|
|
253
288
|
*/
|
|
254
|
-
static async getAllText() {
|
|
255
|
-
const response = await this.asyncCall(CallMethod.getAllText);
|
|
289
|
+
static async getAllText(timeout) {
|
|
290
|
+
const response = await this.asyncCall(CallMethod.getAllText, { timeout });
|
|
256
291
|
return response.getDataOrDefault("[]");
|
|
257
292
|
}
|
|
258
293
|
/**
|
|
259
294
|
* 查找第一个匹配标签的父节点
|
|
260
295
|
* @param className 类名
|
|
296
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
261
297
|
* @returns 父节点
|
|
262
298
|
*/
|
|
263
|
-
static async findFirstParentByTags(node, className) {
|
|
299
|
+
static async findFirstParentByTags(node, className, timeout) {
|
|
264
300
|
const response = await this.asyncCall(CallMethod.findFirstParentByTags, {
|
|
265
301
|
args: { className },
|
|
266
302
|
node,
|
|
303
|
+
timeout,
|
|
267
304
|
});
|
|
268
305
|
return Node.create(response.getDataOrDefault("{}"));
|
|
269
306
|
}
|
|
270
307
|
/**
|
|
271
308
|
* 获取节点的所有子节点
|
|
272
309
|
* @param node 父节点
|
|
310
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
273
311
|
* @returns 子节点数组
|
|
274
312
|
*/
|
|
275
|
-
static async getNodes(node) {
|
|
276
|
-
const response = await this.asyncCall(CallMethod.getNodes, {
|
|
313
|
+
static async getNodes(node, timeout) {
|
|
314
|
+
const response = await this.asyncCall(CallMethod.getNodes, {
|
|
315
|
+
node,
|
|
316
|
+
timeout,
|
|
317
|
+
});
|
|
277
318
|
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
278
319
|
}
|
|
279
320
|
/**
|
|
280
321
|
* 获取节点的直接子节点
|
|
281
322
|
* @param node 父节点
|
|
323
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
282
324
|
* @returns 子节点数组
|
|
283
325
|
*/
|
|
284
|
-
static async getChildren(node) {
|
|
285
|
-
const response = await this.asyncCall(CallMethod.getChildren, {
|
|
326
|
+
static async getChildren(node, timeout) {
|
|
327
|
+
const response = await this.asyncCall(CallMethod.getChildren, {
|
|
328
|
+
node,
|
|
329
|
+
timeout,
|
|
330
|
+
});
|
|
286
331
|
return Node.fromJSONArray(response.getDataOrDefault([]));
|
|
287
332
|
}
|
|
288
333
|
/**
|
|
289
334
|
* 查找第一个可点击的父节点
|
|
290
335
|
* @param node 起始节点
|
|
336
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
291
337
|
* @returns 可点击的父节点
|
|
292
338
|
*/
|
|
293
|
-
static async findFirstParentClickable(node) {
|
|
339
|
+
static async findFirstParentClickable(node, timeout) {
|
|
294
340
|
const response = await this.asyncCall(CallMethod.findFirstParentClickable, {
|
|
295
341
|
node,
|
|
342
|
+
timeout,
|
|
296
343
|
});
|
|
297
344
|
return Node.create(response.getDataOrDefault("{}"));
|
|
298
345
|
}
|
|
299
346
|
/**
|
|
300
347
|
* 获取节点在屏幕中的边界
|
|
301
348
|
* @param node 目标节点
|
|
349
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
302
350
|
* @returns 边界对象
|
|
303
351
|
*/
|
|
304
|
-
static async getBoundsInScreen(node) {
|
|
352
|
+
static async getBoundsInScreen(node, timeout) {
|
|
305
353
|
const response = await this.asyncCall(CallMethod.getBoundsInScreen, {
|
|
306
354
|
node,
|
|
355
|
+
timeout,
|
|
307
356
|
});
|
|
308
357
|
return Bounds.fromData(response.getDataOrDefault({}));
|
|
309
358
|
}
|
|
@@ -312,12 +361,14 @@ export class AssistsXAsync {
|
|
|
312
361
|
* @param node 目标节点
|
|
313
362
|
* @param compareNode 比较节点
|
|
314
363
|
* @param isFullyByCompareNode 是否完全可见
|
|
364
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
315
365
|
* @returns 是否可见
|
|
316
366
|
*/
|
|
317
|
-
static async isVisible(node, { compareNode, isFullyByCompareNode, } = {}) {
|
|
367
|
+
static async isVisible(node, { compareNode, isFullyByCompareNode, timeout, } = {}) {
|
|
318
368
|
const response = await this.asyncCall(CallMethod.isVisible, {
|
|
319
369
|
node,
|
|
320
370
|
args: { compareNode, isFullyByCompareNode },
|
|
371
|
+
timeout,
|
|
321
372
|
});
|
|
322
373
|
return response.getDataOrDefault(false);
|
|
323
374
|
}
|
|
@@ -326,61 +377,71 @@ export class AssistsXAsync {
|
|
|
326
377
|
* @param x 横坐标
|
|
327
378
|
* @param y 纵坐标
|
|
328
379
|
* @param duration 持续时间
|
|
380
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
329
381
|
* @returns 是否成功
|
|
330
382
|
*/
|
|
331
|
-
static async clickByGesture(x, y, duration) {
|
|
383
|
+
static async clickByGesture(x, y, duration, timeout) {
|
|
332
384
|
const response = await this.asyncCall(CallMethod.clickByGesture, {
|
|
333
385
|
args: { x, y, duration },
|
|
386
|
+
timeout,
|
|
334
387
|
});
|
|
335
388
|
return response.getDataOrDefault(false);
|
|
336
389
|
}
|
|
337
390
|
/**
|
|
338
391
|
* 返回操作
|
|
392
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
339
393
|
* @returns 是否成功
|
|
340
394
|
*/
|
|
341
|
-
static async back() {
|
|
342
|
-
const response = await this.asyncCall(CallMethod.back);
|
|
395
|
+
static async back(timeout) {
|
|
396
|
+
const response = await this.asyncCall(CallMethod.back, { timeout });
|
|
343
397
|
return response.getDataOrDefault(false);
|
|
344
398
|
}
|
|
345
399
|
/**
|
|
346
400
|
* 回到主页
|
|
401
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
347
402
|
* @returns 是否成功
|
|
348
403
|
*/
|
|
349
|
-
static async home() {
|
|
350
|
-
const response = await this.asyncCall(CallMethod.home);
|
|
404
|
+
static async home(timeout) {
|
|
405
|
+
const response = await this.asyncCall(CallMethod.home, { timeout });
|
|
351
406
|
return response.getDataOrDefault(false);
|
|
352
407
|
}
|
|
353
408
|
/**
|
|
354
409
|
* 打开通知栏
|
|
410
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
355
411
|
* @returns 是否成功
|
|
356
412
|
*/
|
|
357
|
-
static async notifications() {
|
|
358
|
-
const response = await this.asyncCall(CallMethod.notifications
|
|
413
|
+
static async notifications(timeout) {
|
|
414
|
+
const response = await this.asyncCall(CallMethod.notifications, {
|
|
415
|
+
timeout,
|
|
416
|
+
});
|
|
359
417
|
return response.getDataOrDefault(false);
|
|
360
418
|
}
|
|
361
419
|
/**
|
|
362
420
|
* 显示最近应用
|
|
421
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
363
422
|
* @returns 是否成功
|
|
364
423
|
*/
|
|
365
|
-
static async recentApps() {
|
|
366
|
-
const response = await this.asyncCall(CallMethod.recentApps);
|
|
424
|
+
static async recentApps(timeout) {
|
|
425
|
+
const response = await this.asyncCall(CallMethod.recentApps, { timeout });
|
|
367
426
|
return response.getDataOrDefault(false);
|
|
368
427
|
}
|
|
369
428
|
/**
|
|
370
429
|
* 在节点中粘贴文本
|
|
371
430
|
* @param node 目标节点
|
|
372
431
|
* @param text 要粘贴的文本
|
|
432
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
373
433
|
* @returns 是否成功
|
|
374
434
|
*/
|
|
375
|
-
static async paste(node, text) {
|
|
435
|
+
static async paste(node, text, timeout) {
|
|
376
436
|
const response = await this.asyncCall(CallMethod.paste, {
|
|
377
437
|
args: { text },
|
|
378
438
|
node,
|
|
439
|
+
timeout,
|
|
379
440
|
});
|
|
380
441
|
return response.getDataOrDefault(false);
|
|
381
442
|
}
|
|
382
|
-
static async focus(node) {
|
|
383
|
-
const response = await this.asyncCall(CallMethod.focus, { node });
|
|
443
|
+
static async focus(node, timeout) {
|
|
444
|
+
const response = await this.asyncCall(CallMethod.focus, { node, timeout });
|
|
384
445
|
return response.getDataOrDefault(false);
|
|
385
446
|
}
|
|
386
447
|
/**
|
|
@@ -388,34 +449,40 @@ export class AssistsXAsync {
|
|
|
388
449
|
* @param node 目标节点
|
|
389
450
|
* @param selectionStart 选择起始位置
|
|
390
451
|
* @param selectionEnd 选择结束位置
|
|
452
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
391
453
|
* @returns 是否成功
|
|
392
454
|
*/
|
|
393
|
-
static async selectionText(node, selectionStart, selectionEnd) {
|
|
455
|
+
static async selectionText(node, selectionStart, selectionEnd, timeout) {
|
|
394
456
|
const response = await this.asyncCall(CallMethod.selectionText, {
|
|
395
457
|
args: { selectionStart, selectionEnd },
|
|
396
458
|
node,
|
|
459
|
+
timeout,
|
|
397
460
|
});
|
|
398
461
|
return response.getDataOrDefault(false);
|
|
399
462
|
}
|
|
400
463
|
/**
|
|
401
464
|
* 向前滚动
|
|
402
465
|
* @param node 可滚动节点
|
|
466
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
403
467
|
* @returns 是否成功
|
|
404
468
|
*/
|
|
405
|
-
static async scrollForward(node) {
|
|
469
|
+
static async scrollForward(node, timeout) {
|
|
406
470
|
const response = await this.asyncCall(CallMethod.scrollForward, {
|
|
407
471
|
node,
|
|
472
|
+
timeout,
|
|
408
473
|
});
|
|
409
474
|
return response.getDataOrDefault(false);
|
|
410
475
|
}
|
|
411
476
|
/**
|
|
412
477
|
* 向后滚动
|
|
413
478
|
* @param node 可滚动节点
|
|
479
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
414
480
|
* @returns 是否成功
|
|
415
481
|
*/
|
|
416
|
-
static async scrollBackward(node) {
|
|
482
|
+
static async scrollBackward(node, timeout) {
|
|
417
483
|
const response = await this.asyncCall(CallMethod.scrollBackward, {
|
|
418
484
|
node,
|
|
485
|
+
timeout,
|
|
419
486
|
});
|
|
420
487
|
return response.getDataOrDefault(false);
|
|
421
488
|
}
|
|
@@ -426,12 +493,14 @@ export class AssistsXAsync {
|
|
|
426
493
|
* @param offsetY Y轴偏移
|
|
427
494
|
* @param switchWindowIntervalDelay 窗口切换延迟
|
|
428
495
|
* @param clickDuration 点击持续时间
|
|
496
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
429
497
|
* @returns 是否成功
|
|
430
498
|
*/
|
|
431
|
-
static async clickNodeByGesture(node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, } = {}) {
|
|
499
|
+
static async clickNodeByGesture(node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, timeout, } = {}) {
|
|
432
500
|
const response = await this.asyncCall(CallMethod.clickNodeByGesture, {
|
|
433
501
|
node,
|
|
434
502
|
args: { offsetX, offsetY, switchWindowIntervalDelay, clickDuration },
|
|
503
|
+
timeout,
|
|
435
504
|
});
|
|
436
505
|
return response.getDataOrDefault(false);
|
|
437
506
|
}
|
|
@@ -443,9 +512,10 @@ export class AssistsXAsync {
|
|
|
443
512
|
* @param switchWindowIntervalDelay 窗口切换延迟
|
|
444
513
|
* @param clickDuration 点击持续时间
|
|
445
514
|
* @param clickInterval 点击间隔
|
|
515
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
446
516
|
* @returns 是否成功
|
|
447
517
|
*/
|
|
448
|
-
static async doubleClickNodeByGesture(node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, } = {}) {
|
|
518
|
+
static async doubleClickNodeByGesture(node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, timeout, } = {}) {
|
|
449
519
|
const response = await this.asyncCall(CallMethod.doubleClickNodeByGesture, {
|
|
450
520
|
node,
|
|
451
521
|
args: {
|
|
@@ -455,6 +525,7 @@ export class AssistsXAsync {
|
|
|
455
525
|
clickDuration,
|
|
456
526
|
clickInterval,
|
|
457
527
|
},
|
|
528
|
+
timeout,
|
|
458
529
|
});
|
|
459
530
|
return response.getDataOrDefault(false);
|
|
460
531
|
}
|
|
@@ -463,15 +534,17 @@ export class AssistsXAsync {
|
|
|
463
534
|
* @param startPoint
|
|
464
535
|
* @param endPoint
|
|
465
536
|
* @param param2
|
|
537
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
466
538
|
* @returns
|
|
467
539
|
*/
|
|
468
|
-
static async performLinearGesture(startPoint, endPoint, { duration } = {}) {
|
|
540
|
+
static async performLinearGesture(startPoint, endPoint, { duration, timeout } = {}) {
|
|
469
541
|
const response = await this.asyncCall(CallMethod.performLinearGesture, {
|
|
470
542
|
args: { startPoint, endPoint, duration },
|
|
543
|
+
timeout,
|
|
471
544
|
});
|
|
472
545
|
return response.getDataOrDefault(false);
|
|
473
546
|
}
|
|
474
|
-
static async longPressNodeByGestureAutoPaste(node, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
547
|
+
static async longPressNodeByGestureAutoPaste(node, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, timeout, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
475
548
|
const response = await this.asyncCall(CallMethod.longPressGestureAutoPaste, {
|
|
476
549
|
node,
|
|
477
550
|
args: {
|
|
@@ -481,10 +554,11 @@ export class AssistsXAsync {
|
|
|
481
554
|
timeoutMillis,
|
|
482
555
|
longPressDuration,
|
|
483
556
|
},
|
|
557
|
+
timeout,
|
|
484
558
|
});
|
|
485
559
|
return response.getDataOrDefault(false);
|
|
486
560
|
}
|
|
487
|
-
static async longPressGestureAutoPaste(point, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
561
|
+
static async longPressGestureAutoPaste(point, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, timeout, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
488
562
|
const response = await this.asyncCall(CallMethod.longPressGestureAutoPaste, {
|
|
489
563
|
args: {
|
|
490
564
|
point,
|
|
@@ -494,45 +568,59 @@ export class AssistsXAsync {
|
|
|
494
568
|
timeoutMillis,
|
|
495
569
|
longPressDuration,
|
|
496
570
|
},
|
|
571
|
+
timeout,
|
|
497
572
|
});
|
|
498
573
|
return response.getDataOrDefault(false);
|
|
499
574
|
}
|
|
500
|
-
static async getAppInfo(packageName) {
|
|
575
|
+
static async getAppInfo(packageName, timeout) {
|
|
501
576
|
const response = await this.asyncCall(CallMethod.getAppInfo, {
|
|
502
577
|
args: { packageName },
|
|
578
|
+
timeout,
|
|
503
579
|
});
|
|
504
580
|
return response.getDataOrDefault({});
|
|
505
581
|
}
|
|
506
|
-
static async getUniqueDeviceId() {
|
|
507
|
-
const response = await this.asyncCall(CallMethod.getUniqueDeviceId
|
|
582
|
+
static async getUniqueDeviceId(timeout) {
|
|
583
|
+
const response = await this.asyncCall(CallMethod.getUniqueDeviceId, {
|
|
584
|
+
timeout,
|
|
585
|
+
});
|
|
508
586
|
return response.getDataOrDefault("");
|
|
509
587
|
}
|
|
510
|
-
static async getAndroidID() {
|
|
511
|
-
const response = await this.asyncCall(CallMethod.getAndroidID);
|
|
588
|
+
static async getAndroidID(timeout) {
|
|
589
|
+
const response = await this.asyncCall(CallMethod.getAndroidID, { timeout });
|
|
512
590
|
return response.getDataOrDefault("");
|
|
513
591
|
}
|
|
514
|
-
static async getMacAddress() {
|
|
515
|
-
const response = await this.asyncCall(CallMethod.getMacAddress
|
|
592
|
+
static async getMacAddress(timeout) {
|
|
593
|
+
const response = await this.asyncCall(CallMethod.getMacAddress, {
|
|
594
|
+
timeout,
|
|
595
|
+
});
|
|
516
596
|
return response.getDataOrDefault({});
|
|
517
597
|
}
|
|
518
|
-
static async getDeviceInfo() {
|
|
519
|
-
const response = await this.asyncCall(CallMethod.getDeviceInfo
|
|
598
|
+
static async getDeviceInfo(timeout) {
|
|
599
|
+
const response = await this.asyncCall(CallMethod.getDeviceInfo, {
|
|
600
|
+
timeout,
|
|
601
|
+
});
|
|
520
602
|
return response.getDataOrDefault({});
|
|
521
603
|
}
|
|
522
604
|
/**
|
|
523
605
|
* 获取屏幕尺寸
|
|
606
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
524
607
|
* @returns 屏幕尺寸对象
|
|
525
608
|
*/
|
|
526
|
-
static async getScreenSize() {
|
|
527
|
-
const response = await this.asyncCall(CallMethod.getScreenSize
|
|
609
|
+
static async getScreenSize(timeout) {
|
|
610
|
+
const response = await this.asyncCall(CallMethod.getScreenSize, {
|
|
611
|
+
timeout,
|
|
612
|
+
});
|
|
528
613
|
return response.getDataOrDefault("{}");
|
|
529
614
|
}
|
|
530
615
|
/**
|
|
531
616
|
* 获取应用窗口尺寸
|
|
617
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
532
618
|
* @returns 应用窗口尺寸对象
|
|
533
619
|
*/
|
|
534
|
-
static async getAppScreenSize() {
|
|
535
|
-
const response = await this.asyncCall(CallMethod.getAppScreenSize
|
|
620
|
+
static async getAppScreenSize(timeout) {
|
|
621
|
+
const response = await this.asyncCall(CallMethod.getAppScreenSize, {
|
|
622
|
+
timeout,
|
|
623
|
+
});
|
|
536
624
|
return response.getDataOrDefault("{}");
|
|
537
625
|
}
|
|
538
626
|
}
|