assistsx-js 0.0.2023 → 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/dist/CallMethod.d.ts +1 -1
- package/dist/CallMethod.js +1 -1
- package/package.json +1 -1
- package/src/AssistsX.ts +55 -15
- package/src/AssistsXAsync.ts +222 -58
- package/src/CallMethod.ts +1 -1
package/dist/AssistsX.d.ts
CHANGED
|
@@ -78,12 +78,14 @@ export declare class AssistsX {
|
|
|
78
78
|
* 执行异步调用
|
|
79
79
|
* @param method 方法名
|
|
80
80
|
* @param args 参数对象
|
|
81
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
81
82
|
* @returns Promise<调用响应>
|
|
82
83
|
*/
|
|
83
|
-
static asyncCall(method: string, { args, node, nodes }?: {
|
|
84
|
+
static asyncCall(method: string, { args, node, nodes, timeout, }?: {
|
|
84
85
|
args?: any;
|
|
85
86
|
node?: Node;
|
|
86
87
|
nodes?: Node[];
|
|
88
|
+
timeout?: number;
|
|
87
89
|
}): Promise<CallResponse>;
|
|
88
90
|
/**
|
|
89
91
|
* 设置悬浮窗标志
|
|
@@ -122,11 +124,14 @@ export declare class AssistsX {
|
|
|
122
124
|
* 对指定节点进行截图
|
|
123
125
|
* @param nodes 要截图的节点数组
|
|
124
126
|
* @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
|
|
127
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
125
128
|
* @returns 截图路径数组
|
|
126
129
|
*/
|
|
127
|
-
static takeScreenshotNodes(nodes: Node[], overlayHiddenScreenshotDelayMillis?: number): Promise<string[]>;
|
|
128
|
-
static scanQR(): Promise<string>;
|
|
129
|
-
static loadWebViewOverlay(url: string, options?: WebFloatingWindowOptions
|
|
130
|
+
static takeScreenshotNodes(nodes: Node[], overlayHiddenScreenshotDelayMillis?: number, timeout?: number): Promise<string[]>;
|
|
131
|
+
static scanQR(timeout?: number): Promise<string>;
|
|
132
|
+
static loadWebViewOverlay(url: string, options?: WebFloatingWindowOptions & {
|
|
133
|
+
timeout?: number;
|
|
134
|
+
}): Promise<any>;
|
|
130
135
|
/**
|
|
131
136
|
* 点击节点
|
|
132
137
|
* @param node 要点击的节点
|
|
@@ -265,9 +270,10 @@ export declare class AssistsX {
|
|
|
265
270
|
* @param x 横坐标
|
|
266
271
|
* @param y 纵坐标
|
|
267
272
|
* @param duration 持续时间
|
|
273
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
268
274
|
* @returns 是否成功
|
|
269
275
|
*/
|
|
270
|
-
static clickByGesture(x: number, y: number, duration: number): Promise<boolean>;
|
|
276
|
+
static clickByGesture(x: number, y: number, duration: number, timeout?: number): Promise<boolean>;
|
|
271
277
|
/**
|
|
272
278
|
* 返回操作
|
|
273
279
|
* @returns 是否成功
|
|
@@ -323,13 +329,15 @@ export declare class AssistsX {
|
|
|
323
329
|
* @param offsetY Y轴偏移
|
|
324
330
|
* @param switchWindowIntervalDelay 窗口切换延迟
|
|
325
331
|
* @param clickDuration 点击持续时间
|
|
332
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
326
333
|
* @returns 是否成功
|
|
327
334
|
*/
|
|
328
|
-
static clickNodeByGesture(node: Node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, }?: {
|
|
335
|
+
static clickNodeByGesture(node: Node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, timeout, }?: {
|
|
329
336
|
offsetX?: number;
|
|
330
337
|
offsetY?: number;
|
|
331
338
|
switchWindowIntervalDelay?: number;
|
|
332
339
|
clickDuration?: number;
|
|
340
|
+
timeout?: number;
|
|
333
341
|
}): Promise<boolean>;
|
|
334
342
|
/**
|
|
335
343
|
* 对节点执行双击手势
|
|
@@ -339,20 +347,23 @@ export declare class AssistsX {
|
|
|
339
347
|
* @param switchWindowIntervalDelay 窗口切换延迟
|
|
340
348
|
* @param clickDuration 点击持续时间
|
|
341
349
|
* @param clickInterval 点击间隔
|
|
350
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
342
351
|
* @returns 是否成功
|
|
343
352
|
*/
|
|
344
|
-
static doubleClickNodeByGesture(node: Node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, }?: {
|
|
353
|
+
static doubleClickNodeByGesture(node: Node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, timeout, }?: {
|
|
345
354
|
offsetX?: number;
|
|
346
355
|
offsetY?: number;
|
|
347
356
|
switchWindowIntervalDelay?: number;
|
|
348
357
|
clickDuration?: number;
|
|
349
358
|
clickInterval?: number;
|
|
359
|
+
timeout?: number;
|
|
350
360
|
}): Promise<boolean>;
|
|
351
361
|
/**
|
|
352
362
|
* 执行线型手势
|
|
353
363
|
* @param startPoint
|
|
354
364
|
* @param endPoint
|
|
355
365
|
* @param param2
|
|
366
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
356
367
|
* @returns
|
|
357
368
|
*/
|
|
358
369
|
static performLinearGesture(startPoint: {
|
|
@@ -361,30 +372,33 @@ export declare class AssistsX {
|
|
|
361
372
|
}, endPoint: {
|
|
362
373
|
x: number;
|
|
363
374
|
y: number;
|
|
364
|
-
}, { duration }?: {
|
|
375
|
+
}, { duration, timeout }?: {
|
|
365
376
|
duration?: number;
|
|
377
|
+
timeout?: number;
|
|
366
378
|
}): Promise<boolean>;
|
|
367
|
-
static longPressNodeByGestureAutoPaste(node: Node, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
|
|
379
|
+
static longPressNodeByGestureAutoPaste(node: Node, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, timeout, }?: {
|
|
368
380
|
matchedPackageName?: string;
|
|
369
381
|
matchedText?: string;
|
|
370
382
|
timeoutMillis?: number;
|
|
371
383
|
longPressDuration?: number;
|
|
384
|
+
timeout?: number;
|
|
372
385
|
}): Promise<boolean>;
|
|
373
386
|
static longPressGestureAutoPaste(point: {
|
|
374
387
|
x: number;
|
|
375
388
|
y: number;
|
|
376
|
-
}, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
|
|
389
|
+
}, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, timeout, }?: {
|
|
377
390
|
matchedPackageName?: string;
|
|
378
391
|
matchedText?: string;
|
|
379
392
|
timeoutMillis?: number;
|
|
380
393
|
longPressDuration?: number;
|
|
394
|
+
timeout?: number;
|
|
381
395
|
}): Promise<boolean>;
|
|
382
|
-
static getAppInfo(packageName: string): Promise<any>;
|
|
396
|
+
static getAppInfo(packageName: string, timeout?: number): Promise<any>;
|
|
383
397
|
static getUniqueDeviceId(): any;
|
|
384
398
|
static getAndroidID(): any;
|
|
385
|
-
static getMacAddress(): Promise<any>;
|
|
386
|
-
static getDeviceInfo(): Promise<any>;
|
|
387
|
-
static
|
|
399
|
+
static getMacAddress(timeout?: number): Promise<any>;
|
|
400
|
+
static getDeviceInfo(timeout?: number): Promise<any>;
|
|
401
|
+
static getNetworkType(timeout?: number): Promise<any>;
|
|
388
402
|
static setAccessibilityEventFilters(value: AccessibilityEventFilter[]): Promise<any>;
|
|
389
403
|
static addAccessibilityEventFilter(value: AccessibilityEventFilter): Promise<any>;
|
|
390
404
|
/**
|
package/dist/AssistsX.js
CHANGED
|
@@ -79,9 +79,10 @@ export class AssistsX {
|
|
|
79
79
|
* 执行异步调用
|
|
80
80
|
* @param method 方法名
|
|
81
81
|
* @param args 参数对象
|
|
82
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
82
83
|
* @returns Promise<调用响应>
|
|
83
84
|
*/
|
|
84
|
-
static async asyncCall(method, { args, node, nodes } = {}) {
|
|
85
|
+
static async asyncCall(method, { args, node, nodes, timeout = 30, } = {}) {
|
|
85
86
|
const uuid = generateUUID();
|
|
86
87
|
const params = {
|
|
87
88
|
method,
|
|
@@ -98,7 +99,7 @@ export class AssistsX {
|
|
|
98
99
|
// 超时后删除回调函数
|
|
99
100
|
callbacks.delete(uuid);
|
|
100
101
|
resolve(new CallResponse(0, null, uuid));
|
|
101
|
-
},
|
|
102
|
+
}, timeout * 1000);
|
|
102
103
|
});
|
|
103
104
|
const result = window.assistsx.call(JSON.stringify(params));
|
|
104
105
|
const promiseResult = await promise;
|
|
@@ -162,23 +163,25 @@ export class AssistsX {
|
|
|
162
163
|
* 对指定节点进行截图
|
|
163
164
|
* @param nodes 要截图的节点数组
|
|
164
165
|
* @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
|
|
166
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
165
167
|
* @returns 截图路径数组
|
|
166
168
|
*/
|
|
167
|
-
static async takeScreenshotNodes(nodes, overlayHiddenScreenshotDelayMillis = 250) {
|
|
169
|
+
static async takeScreenshotNodes(nodes, overlayHiddenScreenshotDelayMillis = 250, timeout) {
|
|
168
170
|
const response = await this.asyncCall(CallMethod.takeScreenshot, {
|
|
169
171
|
nodes,
|
|
170
172
|
args: { overlayHiddenScreenshotDelayMillis },
|
|
173
|
+
timeout,
|
|
171
174
|
});
|
|
172
175
|
const data = response.getDataOrDefault("");
|
|
173
176
|
return data.images;
|
|
174
177
|
}
|
|
175
|
-
static async scanQR() {
|
|
176
|
-
const response = await this.asyncCall(CallMethod.scanQR);
|
|
178
|
+
static async scanQR(timeout) {
|
|
179
|
+
const response = await this.asyncCall(CallMethod.scanQR, { timeout });
|
|
177
180
|
const data = response.getDataOrDefault({ value: "" });
|
|
178
181
|
return data.value;
|
|
179
182
|
}
|
|
180
183
|
static async loadWebViewOverlay(url, options = {}) {
|
|
181
|
-
const { initialWidth, initialHeight, minWidth, minHeight, maxWidth, maxHeight, initialCenter, } = options;
|
|
184
|
+
const { initialWidth, initialHeight, minWidth, minHeight, maxWidth, maxHeight, initialCenter, timeout, } = options;
|
|
182
185
|
const response = await this.asyncCall(CallMethod.loadWebViewOverlay, {
|
|
183
186
|
args: {
|
|
184
187
|
url,
|
|
@@ -190,6 +193,7 @@ export class AssistsX {
|
|
|
190
193
|
maxHeight,
|
|
191
194
|
initialCenter,
|
|
192
195
|
},
|
|
196
|
+
timeout,
|
|
193
197
|
});
|
|
194
198
|
const data = response.getDataOrDefault({});
|
|
195
199
|
return data;
|
|
@@ -384,11 +388,13 @@ export class AssistsX {
|
|
|
384
388
|
* @param x 横坐标
|
|
385
389
|
* @param y 纵坐标
|
|
386
390
|
* @param duration 持续时间
|
|
391
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
387
392
|
* @returns 是否成功
|
|
388
393
|
*/
|
|
389
|
-
static async clickByGesture(x, y, duration) {
|
|
394
|
+
static async clickByGesture(x, y, duration, timeout) {
|
|
390
395
|
const response = await this.asyncCall(CallMethod.clickByGesture, {
|
|
391
396
|
args: { x, y, duration },
|
|
397
|
+
timeout,
|
|
392
398
|
});
|
|
393
399
|
return response.getDataOrDefault(false);
|
|
394
400
|
}
|
|
@@ -477,12 +483,14 @@ export class AssistsX {
|
|
|
477
483
|
* @param offsetY Y轴偏移
|
|
478
484
|
* @param switchWindowIntervalDelay 窗口切换延迟
|
|
479
485
|
* @param clickDuration 点击持续时间
|
|
486
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
480
487
|
* @returns 是否成功
|
|
481
488
|
*/
|
|
482
|
-
static async clickNodeByGesture(node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, } = {}) {
|
|
489
|
+
static async clickNodeByGesture(node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, timeout, } = {}) {
|
|
483
490
|
const response = await this.asyncCall(CallMethod.clickNodeByGesture, {
|
|
484
491
|
node,
|
|
485
492
|
args: { offsetX, offsetY, switchWindowIntervalDelay, clickDuration },
|
|
493
|
+
timeout,
|
|
486
494
|
});
|
|
487
495
|
return response.getDataOrDefault(false);
|
|
488
496
|
}
|
|
@@ -494,9 +502,10 @@ export class AssistsX {
|
|
|
494
502
|
* @param switchWindowIntervalDelay 窗口切换延迟
|
|
495
503
|
* @param clickDuration 点击持续时间
|
|
496
504
|
* @param clickInterval 点击间隔
|
|
505
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
497
506
|
* @returns 是否成功
|
|
498
507
|
*/
|
|
499
|
-
static async doubleClickNodeByGesture(node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, } = {}) {
|
|
508
|
+
static async doubleClickNodeByGesture(node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, timeout, } = {}) {
|
|
500
509
|
const response = await this.asyncCall(CallMethod.doubleClickNodeByGesture, {
|
|
501
510
|
node,
|
|
502
511
|
args: {
|
|
@@ -506,6 +515,7 @@ export class AssistsX {
|
|
|
506
515
|
clickDuration,
|
|
507
516
|
clickInterval,
|
|
508
517
|
},
|
|
518
|
+
timeout,
|
|
509
519
|
});
|
|
510
520
|
return response.getDataOrDefault(false);
|
|
511
521
|
}
|
|
@@ -514,15 +524,17 @@ export class AssistsX {
|
|
|
514
524
|
* @param startPoint
|
|
515
525
|
* @param endPoint
|
|
516
526
|
* @param param2
|
|
527
|
+
* @param timeout 超时时间(秒),默认30秒
|
|
517
528
|
* @returns
|
|
518
529
|
*/
|
|
519
|
-
static async performLinearGesture(startPoint, endPoint, { duration } = {}) {
|
|
530
|
+
static async performLinearGesture(startPoint, endPoint, { duration, timeout } = {}) {
|
|
520
531
|
const response = await this.asyncCall(CallMethod.performLinearGesture, {
|
|
521
532
|
args: { startPoint, endPoint, duration },
|
|
533
|
+
timeout,
|
|
522
534
|
});
|
|
523
535
|
return response.getDataOrDefault(false);
|
|
524
536
|
}
|
|
525
|
-
static async longPressNodeByGestureAutoPaste(node, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
537
|
+
static async longPressNodeByGestureAutoPaste(node, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, timeout, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
526
538
|
const response = await this.asyncCall(CallMethod.longPressGestureAutoPaste, {
|
|
527
539
|
node,
|
|
528
540
|
args: {
|
|
@@ -532,10 +544,11 @@ export class AssistsX {
|
|
|
532
544
|
timeoutMillis,
|
|
533
545
|
longPressDuration,
|
|
534
546
|
},
|
|
547
|
+
timeout,
|
|
535
548
|
});
|
|
536
549
|
return response.getDataOrDefault(false);
|
|
537
550
|
}
|
|
538
|
-
static async longPressGestureAutoPaste(point, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
551
|
+
static async longPressGestureAutoPaste(point, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, timeout, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
539
552
|
const response = await this.asyncCall(CallMethod.longPressGestureAutoPaste, {
|
|
540
553
|
args: {
|
|
541
554
|
point,
|
|
@@ -545,12 +558,14 @@ export class AssistsX {
|
|
|
545
558
|
timeoutMillis,
|
|
546
559
|
longPressDuration,
|
|
547
560
|
},
|
|
561
|
+
timeout,
|
|
548
562
|
});
|
|
549
563
|
return response.getDataOrDefault(false);
|
|
550
564
|
}
|
|
551
|
-
static async getAppInfo(packageName) {
|
|
565
|
+
static async getAppInfo(packageName, timeout) {
|
|
552
566
|
const response = await this.asyncCall(CallMethod.getAppInfo, {
|
|
553
567
|
args: { packageName },
|
|
568
|
+
timeout,
|
|
554
569
|
});
|
|
555
570
|
return response.getDataOrDefault({});
|
|
556
571
|
}
|
|
@@ -562,16 +577,22 @@ export class AssistsX {
|
|
|
562
577
|
const response = this.call(CallMethod.getAndroidID);
|
|
563
578
|
return response.getDataOrDefault("");
|
|
564
579
|
}
|
|
565
|
-
static async getMacAddress() {
|
|
566
|
-
const response = await this.asyncCall(CallMethod.getMacAddress
|
|
580
|
+
static async getMacAddress(timeout) {
|
|
581
|
+
const response = await this.asyncCall(CallMethod.getMacAddress, {
|
|
582
|
+
timeout,
|
|
583
|
+
});
|
|
567
584
|
return response.getDataOrDefault({});
|
|
568
585
|
}
|
|
569
|
-
static async getDeviceInfo() {
|
|
570
|
-
const response = await this.asyncCall(CallMethod.getDeviceInfo
|
|
586
|
+
static async getDeviceInfo(timeout) {
|
|
587
|
+
const response = await this.asyncCall(CallMethod.getDeviceInfo, {
|
|
588
|
+
timeout,
|
|
589
|
+
});
|
|
571
590
|
return response.getDataOrDefault({});
|
|
572
591
|
}
|
|
573
|
-
static async
|
|
574
|
-
const response = await this.asyncCall(CallMethod.
|
|
592
|
+
static async getNetworkType(timeout) {
|
|
593
|
+
const response = await this.asyncCall(CallMethod.getNetworkType, {
|
|
594
|
+
timeout,
|
|
595
|
+
});
|
|
575
596
|
return response.getDataOrDefault({});
|
|
576
597
|
}
|
|
577
598
|
static async setAccessibilityEventFilters(value) {
|