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/AssistsX.d.ts +27 -15
- package/dist/AssistsX.js +131 -47
- package/dist/AssistsXAsync.d.ts +324 -0
- package/dist/AssistsXAsync.js +531 -0
- package/dist/CallMethod.d.ts +1 -0
- package/dist/CallMethod.js +1 -0
- package/dist/Node.d.ts +11 -8
- package/dist/Node.js +64 -20
- package/dist/NodeAsync.d.ts +194 -0
- package/dist/NodeAsync.js +297 -0
- package/dist/Step.d.ts +32 -12
- package/dist/Step.js +79 -33
- package/dist/StepAsync.d.ts +168 -0
- package/dist/StepAsync.js +275 -0
- package/dist/StepError.d.ts +27 -0
- package/dist/StepError.js +15 -0
- package/dist/index.d.ts +13 -10
- package/dist/index.js +13 -10
- package/package.json +2 -2
- package/src/AssistsX.ts +808 -589
- package/src/AssistsXAsync.ts +719 -0
- package/src/CallMethod.ts +2 -1
- package/src/Node.ts +428 -323
- package/src/NodeAsync.ts +398 -0
- package/src/Step.ts +680 -491
- package/src/StepAsync.ts +377 -0
- package/src/StepError.ts +47 -0
- package/src/global.d.ts +12 -9
- package/src/index.ts +13 -10
package/dist/AssistsX.d.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* AssistsX 类
|
|
3
3
|
* 提供与移动应用程序界面交互的工具类,包括节点查找、手势操作、屏幕操作等功能
|
|
4
4
|
*/
|
|
5
|
-
import { Node } from
|
|
6
|
-
import {
|
|
5
|
+
import { Node } from "./Node";
|
|
6
|
+
import { CallResponse } from "./CallResponse";
|
|
7
|
+
import { Bounds } from "./Bounds";
|
|
7
8
|
/**
|
|
8
9
|
* Web浮动窗口选项接口定义
|
|
9
10
|
*/
|
|
10
|
-
interface WebFloatingWindowOptions {
|
|
11
|
+
export interface WebFloatingWindowOptions {
|
|
11
12
|
initialWidth?: number;
|
|
12
13
|
initialHeight?: number;
|
|
13
14
|
minWidth?: number;
|
|
@@ -16,6 +17,10 @@ interface WebFloatingWindowOptions {
|
|
|
16
17
|
maxHeight?: number;
|
|
17
18
|
initialCenter?: boolean;
|
|
18
19
|
}
|
|
20
|
+
export declare const callbacks: {
|
|
21
|
+
[key: string]: (data: any) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare const accessibilityEventListeners: ((event: any) => void)[];
|
|
19
24
|
export declare class AssistsX {
|
|
20
25
|
/**
|
|
21
26
|
* 执行同步调用
|
|
@@ -23,14 +28,21 @@ export declare class AssistsX {
|
|
|
23
28
|
* @param args 参数对象
|
|
24
29
|
* @returns 调用响应
|
|
25
30
|
*/
|
|
26
|
-
|
|
31
|
+
static call(method: string, { args, node }?: {
|
|
32
|
+
args?: any;
|
|
33
|
+
node?: Node;
|
|
34
|
+
}): CallResponse;
|
|
27
35
|
/**
|
|
28
36
|
* 执行异步调用
|
|
29
37
|
* @param method 方法名
|
|
30
38
|
* @param args 参数对象
|
|
31
39
|
* @returns Promise<调用响应>
|
|
32
40
|
*/
|
|
33
|
-
|
|
41
|
+
static asyncCall(method: string, { args, node, nodes }?: {
|
|
42
|
+
args?: any;
|
|
43
|
+
node?: Node;
|
|
44
|
+
nodes?: Node[];
|
|
45
|
+
}): Promise<CallResponse>;
|
|
34
46
|
/**
|
|
35
47
|
* 设置悬浮窗标志
|
|
36
48
|
* @param flags 标志
|
|
@@ -51,7 +63,7 @@ export declare class AssistsX {
|
|
|
51
63
|
* @param filterText 文本过滤
|
|
52
64
|
* @returns 节点数组
|
|
53
65
|
*/
|
|
54
|
-
static getAllNodes({ filterClass, filterViewId, filterDes, filterText }?: {
|
|
66
|
+
static getAllNodes({ filterClass, filterViewId, filterDes, filterText, }?: {
|
|
55
67
|
filterClass?: string;
|
|
56
68
|
filterViewId?: string;
|
|
57
69
|
filterDes?: string;
|
|
@@ -112,7 +124,7 @@ export declare class AssistsX {
|
|
|
112
124
|
* @param node 父节点范围
|
|
113
125
|
* @returns 节点数组
|
|
114
126
|
*/
|
|
115
|
-
static findById(id: string, { filterClass, filterText, filterDes, node }?: {
|
|
127
|
+
static findById(id: string, { filterClass, filterText, filterDes, node, }?: {
|
|
116
128
|
filterClass?: string;
|
|
117
129
|
filterText?: string;
|
|
118
130
|
filterDes?: string;
|
|
@@ -127,7 +139,7 @@ export declare class AssistsX {
|
|
|
127
139
|
* @param node 父节点范围
|
|
128
140
|
* @returns 节点数组
|
|
129
141
|
*/
|
|
130
|
-
static findByText(text: string, { filterClass, filterViewId, filterDes, node }?: {
|
|
142
|
+
static findByText(text: string, { filterClass, filterViewId, filterDes, node, }?: {
|
|
131
143
|
filterClass?: string;
|
|
132
144
|
filterViewId?: string;
|
|
133
145
|
filterDes?: string;
|
|
@@ -142,7 +154,7 @@ export declare class AssistsX {
|
|
|
142
154
|
* @param node 父节点范围
|
|
143
155
|
* @returns 节点数组
|
|
144
156
|
*/
|
|
145
|
-
static findByTags(className: string, { filterText, filterViewId, filterDes, node }?: {
|
|
157
|
+
static findByTags(className: string, { filterText, filterViewId, filterDes, node, }?: {
|
|
146
158
|
filterText?: string;
|
|
147
159
|
filterViewId?: string;
|
|
148
160
|
filterDes?: string;
|
|
@@ -202,7 +214,7 @@ export declare class AssistsX {
|
|
|
202
214
|
* @param isFullyByCompareNode 是否完全可见
|
|
203
215
|
* @returns 是否可见
|
|
204
216
|
*/
|
|
205
|
-
static isVisible(node: Node, { compareNode, isFullyByCompareNode }?: {
|
|
217
|
+
static isVisible(node: Node, { compareNode, isFullyByCompareNode, }?: {
|
|
206
218
|
compareNode?: Node;
|
|
207
219
|
isFullyByCompareNode?: boolean;
|
|
208
220
|
}): boolean;
|
|
@@ -241,6 +253,7 @@ export declare class AssistsX {
|
|
|
241
253
|
* @returns 是否成功
|
|
242
254
|
*/
|
|
243
255
|
static paste(node: Node, text: string): boolean;
|
|
256
|
+
static focus(node: Node): boolean;
|
|
244
257
|
/**
|
|
245
258
|
* 选择文本
|
|
246
259
|
* @param node 目标节点
|
|
@@ -270,7 +283,7 @@ export declare class AssistsX {
|
|
|
270
283
|
* @param clickDuration 点击持续时间
|
|
271
284
|
* @returns 是否成功
|
|
272
285
|
*/
|
|
273
|
-
static clickNodeByGesture(node: Node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration }?: {
|
|
286
|
+
static clickNodeByGesture(node: Node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, }?: {
|
|
274
287
|
offsetX?: number;
|
|
275
288
|
offsetY?: number;
|
|
276
289
|
switchWindowIntervalDelay?: number;
|
|
@@ -286,7 +299,7 @@ export declare class AssistsX {
|
|
|
286
299
|
* @param clickInterval 点击间隔
|
|
287
300
|
* @returns 是否成功
|
|
288
301
|
*/
|
|
289
|
-
static doubleClickNodeByGesture(node: Node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval }?: {
|
|
302
|
+
static doubleClickNodeByGesture(node: Node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, }?: {
|
|
290
303
|
offsetX?: number;
|
|
291
304
|
offsetY?: number;
|
|
292
305
|
switchWindowIntervalDelay?: number;
|
|
@@ -309,7 +322,7 @@ export declare class AssistsX {
|
|
|
309
322
|
}, { duration }?: {
|
|
310
323
|
duration?: number;
|
|
311
324
|
}): Promise<boolean>;
|
|
312
|
-
static longPressNodeByGestureAutoPaste(node: Node, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration }?: {
|
|
325
|
+
static longPressNodeByGestureAutoPaste(node: Node, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
|
|
313
326
|
matchedPackageName?: string;
|
|
314
327
|
matchedText?: string;
|
|
315
328
|
timeoutMillis?: number;
|
|
@@ -318,7 +331,7 @@ export declare class AssistsX {
|
|
|
318
331
|
static longPressGestureAutoPaste(point: {
|
|
319
332
|
x: number;
|
|
320
333
|
y: number;
|
|
321
|
-
}, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration }?: {
|
|
334
|
+
}, text: string, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, }?: {
|
|
322
335
|
matchedPackageName?: string;
|
|
323
336
|
matchedText?: string;
|
|
324
337
|
timeoutMillis?: number;
|
|
@@ -360,4 +373,3 @@ export declare class AssistsX {
|
|
|
360
373
|
*/
|
|
361
374
|
static getAccessibilityEventListenerCount(): number;
|
|
362
375
|
}
|
|
363
|
-
export {};
|
package/dist/AssistsX.js
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* AssistsX 类
|
|
3
3
|
* 提供与移动应用程序界面交互的工具类,包括节点查找、手势操作、屏幕操作等功能
|
|
4
4
|
*/
|
|
5
|
-
import { Node } from
|
|
6
|
-
import { CallMethod } from
|
|
7
|
-
import { CallResponse } from
|
|
8
|
-
import { Bounds } from
|
|
9
|
-
import { generateUUID } from
|
|
5
|
+
import { Node } from "./Node";
|
|
6
|
+
import { CallMethod } from "./CallMethod";
|
|
7
|
+
import { CallResponse } from "./CallResponse";
|
|
8
|
+
import { Bounds } from "./Bounds";
|
|
9
|
+
import { generateUUID } from "./Utils";
|
|
10
10
|
// 回调函数存储对象
|
|
11
|
-
const callbacks = {};
|
|
11
|
+
export const callbacks = {};
|
|
12
12
|
// 无障碍事件监听器存储
|
|
13
|
-
const accessibilityEventListeners = [];
|
|
13
|
+
export const accessibilityEventListeners = [];
|
|
14
14
|
// 初始化全局回调函数
|
|
15
|
-
if (typeof window !==
|
|
15
|
+
if (typeof window !== "undefined" && !window.assistsxCallback) {
|
|
16
16
|
window.assistsxCallback = (data) => {
|
|
17
17
|
const response = JSON.parse(data);
|
|
18
18
|
const callback = callbacks[response.callbackId];
|
|
@@ -22,15 +22,15 @@ if (typeof window !== 'undefined' && !window.assistsxCallback) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
// 初始化全局无障碍事件函数
|
|
25
|
-
if (typeof window !==
|
|
25
|
+
if (typeof window !== "undefined" && !window.onAccessibilityEvent) {
|
|
26
26
|
window.onAccessibilityEvent = (event) => {
|
|
27
27
|
// 通知所有注册的监听器
|
|
28
|
-
accessibilityEventListeners.forEach(listener => {
|
|
28
|
+
accessibilityEventListeners.forEach((listener) => {
|
|
29
29
|
try {
|
|
30
30
|
listener(event);
|
|
31
31
|
}
|
|
32
32
|
catch (error) {
|
|
33
|
-
console.error(
|
|
33
|
+
console.error("Accessibility event listener error:", error);
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
};
|
|
@@ -49,12 +49,12 @@ export class AssistsX {
|
|
|
49
49
|
node: node ? node : undefined,
|
|
50
50
|
};
|
|
51
51
|
const result = window.assistsx.call(JSON.stringify(params));
|
|
52
|
-
if (typeof result ===
|
|
52
|
+
if (typeof result === "string") {
|
|
53
53
|
const responseData = JSON.parse(result);
|
|
54
54
|
const response = new CallResponse(responseData.code, responseData.data, responseData.callbackId);
|
|
55
55
|
return response;
|
|
56
56
|
}
|
|
57
|
-
throw new Error(
|
|
57
|
+
throw new Error("Call failed");
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* 执行异步调用
|
|
@@ -81,12 +81,12 @@ export class AssistsX {
|
|
|
81
81
|
});
|
|
82
82
|
const result = window.assistsx.call(JSON.stringify(params));
|
|
83
83
|
const promiseResult = await promise;
|
|
84
|
-
if (typeof promiseResult ===
|
|
84
|
+
if (typeof promiseResult === "string") {
|
|
85
85
|
const responseData = JSON.parse(promiseResult);
|
|
86
86
|
const response = new CallResponse(responseData.code, responseData.data, responseData.callbackId);
|
|
87
87
|
return response;
|
|
88
88
|
}
|
|
89
|
-
throw new Error(
|
|
89
|
+
throw new Error("Call failed");
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* 设置悬浮窗标志
|
|
@@ -94,7 +94,9 @@ export class AssistsX {
|
|
|
94
94
|
* @returns 是否设置成功
|
|
95
95
|
*/
|
|
96
96
|
static setOverlayFlags(flags) {
|
|
97
|
-
const response = this.call(CallMethod.setOverlayFlags, {
|
|
97
|
+
const response = this.call(CallMethod.setOverlayFlags, {
|
|
98
|
+
args: { flags: flags },
|
|
99
|
+
});
|
|
98
100
|
return response.getDataOrDefault(false);
|
|
99
101
|
}
|
|
100
102
|
/**
|
|
@@ -103,7 +105,9 @@ export class AssistsX {
|
|
|
103
105
|
* @returns 是否设置成功
|
|
104
106
|
*/
|
|
105
107
|
static setOverlayFlagList(flags) {
|
|
106
|
-
const response = this.call(CallMethod.setOverlayFlags, {
|
|
108
|
+
const response = this.call(CallMethod.setOverlayFlags, {
|
|
109
|
+
args: { flags: flags },
|
|
110
|
+
});
|
|
107
111
|
return response.getDataOrDefault(false);
|
|
108
112
|
}
|
|
109
113
|
/**
|
|
@@ -114,8 +118,10 @@ export class AssistsX {
|
|
|
114
118
|
* @param filterText 文本过滤
|
|
115
119
|
* @returns 节点数组
|
|
116
120
|
*/
|
|
117
|
-
static getAllNodes({ filterClass, filterViewId, filterDes, filterText } = {}) {
|
|
118
|
-
const response = this.call(CallMethod.getAllNodes, {
|
|
121
|
+
static getAllNodes({ filterClass, filterViewId, filterDes, filterText, } = {}) {
|
|
122
|
+
const response = this.call(CallMethod.getAllNodes, {
|
|
123
|
+
args: { filterClass, filterViewId, filterDes, filterText },
|
|
124
|
+
});
|
|
119
125
|
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
120
126
|
}
|
|
121
127
|
/**
|
|
@@ -125,7 +131,10 @@ export class AssistsX {
|
|
|
125
131
|
* @returns 是否设置成功
|
|
126
132
|
*/
|
|
127
133
|
static setNodeText(node, text) {
|
|
128
|
-
const response = this.call(CallMethod.setNodeText, {
|
|
134
|
+
const response = this.call(CallMethod.setNodeText, {
|
|
135
|
+
args: { text },
|
|
136
|
+
node,
|
|
137
|
+
});
|
|
129
138
|
return response.getDataOrDefault(false);
|
|
130
139
|
}
|
|
131
140
|
/**
|
|
@@ -135,7 +144,10 @@ export class AssistsX {
|
|
|
135
144
|
* @returns 截图路径数组
|
|
136
145
|
*/
|
|
137
146
|
static async takeScreenshotNodes(nodes, overlayHiddenScreenshotDelayMillis = 250) {
|
|
138
|
-
const response = await this.asyncCall(CallMethod.takeScreenshot, {
|
|
147
|
+
const response = await this.asyncCall(CallMethod.takeScreenshot, {
|
|
148
|
+
nodes,
|
|
149
|
+
args: { overlayHiddenScreenshotDelayMillis },
|
|
150
|
+
});
|
|
139
151
|
const data = response.getDataOrDefault("");
|
|
140
152
|
return data.images;
|
|
141
153
|
}
|
|
@@ -145,8 +157,19 @@ export class AssistsX {
|
|
|
145
157
|
return data.value;
|
|
146
158
|
}
|
|
147
159
|
static async loadWebViewOverlay(url, options = {}) {
|
|
148
|
-
const { initialWidth, initialHeight, minWidth, minHeight, maxWidth, maxHeight, initialCenter } = options;
|
|
149
|
-
const response = await this.asyncCall(CallMethod.loadWebViewOverlay, {
|
|
160
|
+
const { initialWidth, initialHeight, minWidth, minHeight, maxWidth, maxHeight, initialCenter, } = options;
|
|
161
|
+
const response = await this.asyncCall(CallMethod.loadWebViewOverlay, {
|
|
162
|
+
args: {
|
|
163
|
+
url,
|
|
164
|
+
initialWidth,
|
|
165
|
+
initialHeight,
|
|
166
|
+
minWidth,
|
|
167
|
+
minHeight,
|
|
168
|
+
maxWidth,
|
|
169
|
+
maxHeight,
|
|
170
|
+
initialCenter,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
150
173
|
const data = response.getDataOrDefault({});
|
|
151
174
|
return data;
|
|
152
175
|
}
|
|
@@ -192,7 +215,9 @@ export class AssistsX {
|
|
|
192
215
|
* @returns 是否显示成功
|
|
193
216
|
*/
|
|
194
217
|
static overlayToast(text, delay = 2000) {
|
|
195
|
-
const response = this.call(CallMethod.overlayToast, {
|
|
218
|
+
const response = this.call(CallMethod.overlayToast, {
|
|
219
|
+
args: { text, delay },
|
|
220
|
+
});
|
|
196
221
|
return response.getDataOrDefault(false);
|
|
197
222
|
}
|
|
198
223
|
/**
|
|
@@ -204,8 +229,11 @@ export class AssistsX {
|
|
|
204
229
|
* @param node 父节点范围
|
|
205
230
|
* @returns 节点数组
|
|
206
231
|
*/
|
|
207
|
-
static findById(id, { filterClass, filterText, filterDes, node } = {}) {
|
|
208
|
-
const response = this.call(CallMethod.findById, {
|
|
232
|
+
static findById(id, { filterClass, filterText, filterDes, node, } = {}) {
|
|
233
|
+
const response = this.call(CallMethod.findById, {
|
|
234
|
+
args: { id, filterClass, filterText, filterDes },
|
|
235
|
+
node,
|
|
236
|
+
});
|
|
209
237
|
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
210
238
|
}
|
|
211
239
|
/**
|
|
@@ -217,8 +245,11 @@ export class AssistsX {
|
|
|
217
245
|
* @param node 父节点范围
|
|
218
246
|
* @returns 节点数组
|
|
219
247
|
*/
|
|
220
|
-
static findByText(text, { filterClass, filterViewId, filterDes, node } = {}) {
|
|
221
|
-
const response = this.call(CallMethod.findByText, {
|
|
248
|
+
static findByText(text, { filterClass, filterViewId, filterDes, node, } = {}) {
|
|
249
|
+
const response = this.call(CallMethod.findByText, {
|
|
250
|
+
args: { text, filterClass, filterViewId, filterDes },
|
|
251
|
+
node,
|
|
252
|
+
});
|
|
222
253
|
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
223
254
|
}
|
|
224
255
|
/**
|
|
@@ -230,8 +261,11 @@ export class AssistsX {
|
|
|
230
261
|
* @param node 父节点范围
|
|
231
262
|
* @returns 节点数组
|
|
232
263
|
*/
|
|
233
|
-
static findByTags(className, { filterText, filterViewId, filterDes, node } = {}) {
|
|
234
|
-
const response = this.call(CallMethod.findByTags, {
|
|
264
|
+
static findByTags(className, { filterText, filterViewId, filterDes, node, } = {}) {
|
|
265
|
+
const response = this.call(CallMethod.findByTags, {
|
|
266
|
+
args: { className, filterText, filterViewId, filterDes },
|
|
267
|
+
node,
|
|
268
|
+
});
|
|
235
269
|
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
236
270
|
}
|
|
237
271
|
/**
|
|
@@ -240,7 +274,9 @@ export class AssistsX {
|
|
|
240
274
|
* @returns 节点数组
|
|
241
275
|
*/
|
|
242
276
|
static findByTextAllMatch(text) {
|
|
243
|
-
const response = this.call(CallMethod.findByTextAllMatch, {
|
|
277
|
+
const response = this.call(CallMethod.findByTextAllMatch, {
|
|
278
|
+
args: { text },
|
|
279
|
+
});
|
|
244
280
|
return Node.fromJSONArray(response.getDataOrDefault("[]"));
|
|
245
281
|
}
|
|
246
282
|
/**
|
|
@@ -266,7 +302,9 @@ export class AssistsX {
|
|
|
266
302
|
* @returns 父节点
|
|
267
303
|
*/
|
|
268
304
|
static findFirstParentByTags(className) {
|
|
269
|
-
const response = this.call(CallMethod.findFirstParentByTags, {
|
|
305
|
+
const response = this.call(CallMethod.findFirstParentByTags, {
|
|
306
|
+
args: { className },
|
|
307
|
+
});
|
|
270
308
|
return Node.create(response.getDataOrDefault("{}"));
|
|
271
309
|
}
|
|
272
310
|
/**
|
|
@@ -312,8 +350,11 @@ export class AssistsX {
|
|
|
312
350
|
* @param isFullyByCompareNode 是否完全可见
|
|
313
351
|
* @returns 是否可见
|
|
314
352
|
*/
|
|
315
|
-
static isVisible(node, { compareNode, isFullyByCompareNode } = {}) {
|
|
316
|
-
const response = this.call(CallMethod.isVisible, {
|
|
353
|
+
static isVisible(node, { compareNode, isFullyByCompareNode, } = {}) {
|
|
354
|
+
const response = this.call(CallMethod.isVisible, {
|
|
355
|
+
node,
|
|
356
|
+
args: { compareNode, isFullyByCompareNode },
|
|
357
|
+
});
|
|
317
358
|
return response.getDataOrDefault(false);
|
|
318
359
|
}
|
|
319
360
|
/**
|
|
@@ -324,7 +365,9 @@ export class AssistsX {
|
|
|
324
365
|
* @returns 是否成功
|
|
325
366
|
*/
|
|
326
367
|
static async clickByGesture(x, y, duration) {
|
|
327
|
-
const response = await this.asyncCall(CallMethod.clickByGesture, {
|
|
368
|
+
const response = await this.asyncCall(CallMethod.clickByGesture, {
|
|
369
|
+
args: { x, y, duration },
|
|
370
|
+
});
|
|
328
371
|
return response.getDataOrDefault(false);
|
|
329
372
|
}
|
|
330
373
|
/**
|
|
@@ -369,6 +412,10 @@ export class AssistsX {
|
|
|
369
412
|
const response = this.call(CallMethod.paste, { args: { text }, node });
|
|
370
413
|
return response.getDataOrDefault(false);
|
|
371
414
|
}
|
|
415
|
+
static focus(node) {
|
|
416
|
+
const response = this.call(CallMethod.focus, { node });
|
|
417
|
+
return response.getDataOrDefault(false);
|
|
418
|
+
}
|
|
372
419
|
/**
|
|
373
420
|
* 选择文本
|
|
374
421
|
* @param node 目标节点
|
|
@@ -377,7 +424,10 @@ export class AssistsX {
|
|
|
377
424
|
* @returns 是否成功
|
|
378
425
|
*/
|
|
379
426
|
static selectionText(node, selectionStart, selectionEnd) {
|
|
380
|
-
const response = this.call(CallMethod.selectionText, {
|
|
427
|
+
const response = this.call(CallMethod.selectionText, {
|
|
428
|
+
args: { selectionStart, selectionEnd },
|
|
429
|
+
node,
|
|
430
|
+
});
|
|
381
431
|
return response.getDataOrDefault(false);
|
|
382
432
|
}
|
|
383
433
|
/**
|
|
@@ -407,8 +457,11 @@ export class AssistsX {
|
|
|
407
457
|
* @param clickDuration 点击持续时间
|
|
408
458
|
* @returns 是否成功
|
|
409
459
|
*/
|
|
410
|
-
static async clickNodeByGesture(node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration } = {}) {
|
|
411
|
-
const response = await this.asyncCall(CallMethod.clickNodeByGesture, {
|
|
460
|
+
static async clickNodeByGesture(node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, } = {}) {
|
|
461
|
+
const response = await this.asyncCall(CallMethod.clickNodeByGesture, {
|
|
462
|
+
node,
|
|
463
|
+
args: { offsetX, offsetY, switchWindowIntervalDelay, clickDuration },
|
|
464
|
+
});
|
|
412
465
|
return response.getDataOrDefault(false);
|
|
413
466
|
}
|
|
414
467
|
/**
|
|
@@ -421,8 +474,17 @@ export class AssistsX {
|
|
|
421
474
|
* @param clickInterval 点击间隔
|
|
422
475
|
* @returns 是否成功
|
|
423
476
|
*/
|
|
424
|
-
static async doubleClickNodeByGesture(node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval } = {}) {
|
|
425
|
-
const response = await this.asyncCall(CallMethod.doubleClickNodeByGesture, {
|
|
477
|
+
static async doubleClickNodeByGesture(node, { offsetX, offsetY, switchWindowIntervalDelay, clickDuration, clickInterval, } = {}) {
|
|
478
|
+
const response = await this.asyncCall(CallMethod.doubleClickNodeByGesture, {
|
|
479
|
+
node,
|
|
480
|
+
args: {
|
|
481
|
+
offsetX,
|
|
482
|
+
offsetY,
|
|
483
|
+
switchWindowIntervalDelay,
|
|
484
|
+
clickDuration,
|
|
485
|
+
clickInterval,
|
|
486
|
+
},
|
|
487
|
+
});
|
|
426
488
|
return response.getDataOrDefault(false);
|
|
427
489
|
}
|
|
428
490
|
/**
|
|
@@ -433,19 +495,41 @@ export class AssistsX {
|
|
|
433
495
|
* @returns
|
|
434
496
|
*/
|
|
435
497
|
static async performLinearGesture(startPoint, endPoint, { duration } = {}) {
|
|
436
|
-
const response = await this.asyncCall(CallMethod.performLinearGesture, {
|
|
498
|
+
const response = await this.asyncCall(CallMethod.performLinearGesture, {
|
|
499
|
+
args: { startPoint, endPoint, duration },
|
|
500
|
+
});
|
|
437
501
|
return response.getDataOrDefault(false);
|
|
438
502
|
}
|
|
439
|
-
static async longPressNodeByGestureAutoPaste(node, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
440
|
-
const response = await this.asyncCall(CallMethod.longPressGestureAutoPaste, {
|
|
503
|
+
static async longPressNodeByGestureAutoPaste(node, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
504
|
+
const response = await this.asyncCall(CallMethod.longPressGestureAutoPaste, {
|
|
505
|
+
node,
|
|
506
|
+
args: {
|
|
507
|
+
text,
|
|
508
|
+
matchedPackageName,
|
|
509
|
+
matchedText,
|
|
510
|
+
timeoutMillis,
|
|
511
|
+
longPressDuration,
|
|
512
|
+
},
|
|
513
|
+
});
|
|
441
514
|
return response.getDataOrDefault(false);
|
|
442
515
|
}
|
|
443
|
-
static async longPressGestureAutoPaste(point, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
444
|
-
const response = await this.asyncCall(CallMethod.longPressGestureAutoPaste, {
|
|
516
|
+
static async longPressGestureAutoPaste(point, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
517
|
+
const response = await this.asyncCall(CallMethod.longPressGestureAutoPaste, {
|
|
518
|
+
args: {
|
|
519
|
+
point,
|
|
520
|
+
text,
|
|
521
|
+
matchedPackageName,
|
|
522
|
+
matchedText,
|
|
523
|
+
timeoutMillis,
|
|
524
|
+
longPressDuration,
|
|
525
|
+
},
|
|
526
|
+
});
|
|
445
527
|
return response.getDataOrDefault(false);
|
|
446
528
|
}
|
|
447
529
|
static async getAppInfo(packageName) {
|
|
448
|
-
const response = await this.asyncCall(CallMethod.getAppInfo, {
|
|
530
|
+
const response = await this.asyncCall(CallMethod.getAppInfo, {
|
|
531
|
+
args: { packageName },
|
|
532
|
+
});
|
|
449
533
|
return response.getDataOrDefault({});
|
|
450
534
|
}
|
|
451
535
|
static getUniqueDeviceId() {
|
|
@@ -488,7 +572,7 @@ export class AssistsX {
|
|
|
488
572
|
listener(event);
|
|
489
573
|
}
|
|
490
574
|
catch (error) {
|
|
491
|
-
console.error(
|
|
575
|
+
console.error("Accessibility event listener error:", error);
|
|
492
576
|
}
|
|
493
577
|
};
|
|
494
578
|
// 将监听器包装并存储,使用ID作为键
|