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/dist/AssistsX.d.ts +28 -16
- package/dist/AssistsX.js +144 -52
- package/dist/AssistsXAsync.d.ts +324 -0
- package/dist/AssistsXAsync.js +532 -0
- package/dist/CallMethod.d.ts +1 -0
- package/dist/CallMethod.js +1 -0
- package/dist/Node.d.ts +17 -8
- package/dist/Node.js +75 -20
- package/dist/NodeAsync.d.ts +200 -0
- package/dist/NodeAsync.js +308 -0
- package/dist/Step.d.ts +18 -20
- package/dist/Step.js +75 -44
- package/dist/StepAsync.d.ts +162 -0
- package/dist/StepAsync.js +264 -0
- package/dist/StepError.d.ts +27 -0
- package/dist/StepError.js +15 -0
- package/dist/Utils.d.ts +1 -0
- package/dist/Utils.js +12 -4
- package/dist/index.d.ts +13 -10
- package/dist/index.js +13 -10
- package/package.json +2 -2
- package/src/AssistsX.ts +815 -589
- package/src/AssistsXAsync.ts +723 -0
- package/src/CallMethod.ts +2 -1
- package/src/Node.ts +440 -323
- package/src/NodeAsync.ts +411 -0
- package/src/Step.ts +646 -490
- package/src/StepAsync.ts +365 -0
- package/src/StepError.ts +47 -0
- package/src/Utils.ts +16 -7
- package/src/global.d.ts +12 -9
- package/src/index.ts +13 -10
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { AssistsXAsync } from "./AssistsXAsync";
|
|
2
|
+
import { Step } from "./Step";
|
|
3
|
+
export class StepAsync {
|
|
4
|
+
/**
|
|
5
|
+
* 构造函数
|
|
6
|
+
* @param step Step实例
|
|
7
|
+
*/
|
|
8
|
+
constructor(step) {
|
|
9
|
+
this.step = step;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 对单个节点进行截图
|
|
13
|
+
* @param node 目标节点
|
|
14
|
+
* @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
|
|
15
|
+
* @returns 截图路径
|
|
16
|
+
*/
|
|
17
|
+
async takeScreenshotByNode(node, overlayHiddenScreenshotDelayMillis = 250) {
|
|
18
|
+
Step.assert(this.step.stepId);
|
|
19
|
+
const result = await AssistsXAsync.takeScreenshotNodes([node], overlayHiddenScreenshotDelayMillis);
|
|
20
|
+
Step.assert(this.step.stepId);
|
|
21
|
+
return result[0];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 对多个节点进行截图
|
|
25
|
+
* @param nodes 目标节点数组
|
|
26
|
+
* @param overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒)
|
|
27
|
+
* @returns 截图路径数组
|
|
28
|
+
*/
|
|
29
|
+
async takeScreenshotNodes(nodes, overlayHiddenScreenshotDelayMillis = 250) {
|
|
30
|
+
Step.assert(this.step.stepId);
|
|
31
|
+
const result = await AssistsXAsync.takeScreenshotNodes(nodes, overlayHiddenScreenshotDelayMillis);
|
|
32
|
+
Step.assert(this.step.stepId);
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 获取所有符合条件的节点
|
|
37
|
+
* @param filterClass 类名过滤
|
|
38
|
+
* @param filterViewId 视图ID过滤
|
|
39
|
+
* @param filterDes 描述过滤
|
|
40
|
+
* @param filterText 文本过滤
|
|
41
|
+
* @returns 节点数组
|
|
42
|
+
*/
|
|
43
|
+
async getAllNodes({ filterClass, filterViewId, filterDes, filterText, } = {}) {
|
|
44
|
+
Step.assert(this.step.stepId);
|
|
45
|
+
const nodes = await AssistsXAsync.getAllNodes({
|
|
46
|
+
filterClass,
|
|
47
|
+
filterViewId,
|
|
48
|
+
filterDes,
|
|
49
|
+
filterText,
|
|
50
|
+
});
|
|
51
|
+
Step.assert(this.step.stepId);
|
|
52
|
+
Step.assignIdsToNodes(nodes, this.step.stepId);
|
|
53
|
+
return nodes;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 启动应用
|
|
57
|
+
* @param packageName 应用包名
|
|
58
|
+
* @returns 是否启动成功
|
|
59
|
+
*/
|
|
60
|
+
async launchApp(packageName) {
|
|
61
|
+
Step.assert(this.step.stepId);
|
|
62
|
+
const result = await AssistsXAsync.launchApp(packageName);
|
|
63
|
+
Step.assert(this.step.stepId);
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 获取当前应用包名
|
|
68
|
+
* @returns 包名
|
|
69
|
+
*/
|
|
70
|
+
async getPackageName() {
|
|
71
|
+
Step.assert(this.step.stepId);
|
|
72
|
+
const result = await AssistsXAsync.getPackageName();
|
|
73
|
+
Step.assert(this.step.stepId);
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 通过ID查找节点
|
|
78
|
+
* @param id 节点ID
|
|
79
|
+
* @param filterClass 类名过滤
|
|
80
|
+
* @param filterText 文本过滤
|
|
81
|
+
* @param filterDes 描述过滤
|
|
82
|
+
* @returns 节点数组
|
|
83
|
+
*/
|
|
84
|
+
async findById(id, { filterClass, filterText, filterDes, } = {}) {
|
|
85
|
+
Step.assert(this.step.stepId);
|
|
86
|
+
const nodes = await AssistsXAsync.findById(id, {
|
|
87
|
+
filterClass,
|
|
88
|
+
filterText,
|
|
89
|
+
filterDes,
|
|
90
|
+
});
|
|
91
|
+
Step.assert(this.step.stepId);
|
|
92
|
+
Step.assignIdsToNodes(nodes, this.step.stepId);
|
|
93
|
+
return nodes;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 通过文本查找节点
|
|
97
|
+
* @param text 要查找的文本
|
|
98
|
+
* @param filterClass 类名过滤
|
|
99
|
+
* @param filterViewId 视图ID过滤
|
|
100
|
+
* @param filterDes 描述过滤
|
|
101
|
+
* @returns 节点数组
|
|
102
|
+
*/
|
|
103
|
+
async findByText(text, { filterClass, filterViewId, filterDes, } = {}) {
|
|
104
|
+
Step.assert(this.step.stepId);
|
|
105
|
+
const nodes = await AssistsXAsync.findByText(text, {
|
|
106
|
+
filterClass,
|
|
107
|
+
filterViewId,
|
|
108
|
+
filterDes,
|
|
109
|
+
});
|
|
110
|
+
Step.assert(this.step.stepId);
|
|
111
|
+
Step.assignIdsToNodes(nodes, this.step.stepId);
|
|
112
|
+
return nodes;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 通过标签查找节点
|
|
116
|
+
* @param className 类名
|
|
117
|
+
* @param filterText 文本过滤
|
|
118
|
+
* @param filterViewId 视图ID过滤
|
|
119
|
+
* @param filterDes 描述过滤
|
|
120
|
+
* @returns 节点数组
|
|
121
|
+
*/
|
|
122
|
+
async findByTags(className, { filterText, filterViewId, filterDes, } = {}) {
|
|
123
|
+
Step.assert(this.step.stepId);
|
|
124
|
+
const nodes = await AssistsXAsync.findByTags(className, {
|
|
125
|
+
filterText,
|
|
126
|
+
filterViewId,
|
|
127
|
+
filterDes,
|
|
128
|
+
});
|
|
129
|
+
Step.assert(this.step.stepId);
|
|
130
|
+
Step.assignIdsToNodes(nodes, this.step.stepId);
|
|
131
|
+
return nodes;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 查找所有匹配文本的节点
|
|
135
|
+
* @param text 要查找的文本
|
|
136
|
+
* @returns 节点数组
|
|
137
|
+
*/
|
|
138
|
+
async findByTextAllMatch(text) {
|
|
139
|
+
Step.assert(this.step.stepId);
|
|
140
|
+
const nodes = await AssistsXAsync.findByTextAllMatch(text);
|
|
141
|
+
Step.assert(this.step.stepId);
|
|
142
|
+
Step.assignIdsToNodes(nodes, this.step.stepId);
|
|
143
|
+
return nodes;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* 检查是否包含指定文本
|
|
147
|
+
* @param text 要检查的文本
|
|
148
|
+
* @returns 是否包含
|
|
149
|
+
*/
|
|
150
|
+
async containsText(text) {
|
|
151
|
+
Step.assert(this.step.stepId);
|
|
152
|
+
const result = await AssistsXAsync.containsText(text);
|
|
153
|
+
Step.assert(this.step.stepId);
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* 获取所有文本
|
|
158
|
+
* @returns 文本数组
|
|
159
|
+
*/
|
|
160
|
+
async getAllText() {
|
|
161
|
+
Step.assert(this.step.stepId);
|
|
162
|
+
const texts = await AssistsXAsync.getAllText();
|
|
163
|
+
Step.assert(this.step.stepId);
|
|
164
|
+
return texts;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* 执行点击手势
|
|
168
|
+
* @param x 横坐标
|
|
169
|
+
* @param y 纵坐标
|
|
170
|
+
* @param duration 持续时间(毫秒)
|
|
171
|
+
* @returns 是否成功
|
|
172
|
+
*/
|
|
173
|
+
async clickByGesture(x, y, duration) {
|
|
174
|
+
Step.assert(this.step.stepId);
|
|
175
|
+
const result = await AssistsXAsync.clickByGesture(x, y, duration);
|
|
176
|
+
Step.assert(this.step.stepId);
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
async longPressGestureAutoPaste(point, text, { matchedPackageName, matchedText, timeoutMillis, longPressDuration, } = { matchedText: "粘贴", timeoutMillis: 1500, longPressDuration: 600 }) {
|
|
180
|
+
Step.assert(this.step.stepId);
|
|
181
|
+
const result = await AssistsXAsync.longPressGestureAutoPaste(point, text, {
|
|
182
|
+
matchedPackageName,
|
|
183
|
+
matchedText,
|
|
184
|
+
timeoutMillis,
|
|
185
|
+
longPressDuration,
|
|
186
|
+
});
|
|
187
|
+
Step.assert(this.step.stepId);
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
async getAppInfo(packageName) {
|
|
191
|
+
Step.assert(this.step.stepId);
|
|
192
|
+
const result = await AssistsXAsync.getAppInfo(packageName);
|
|
193
|
+
Step.assert(this.step.stepId);
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
async performLinearGesture(startPoint, endPoint, { duration } = {}) {
|
|
197
|
+
Step.assert(this.step.stepId);
|
|
198
|
+
const result = await AssistsXAsync.performLinearGesture(startPoint, endPoint, {
|
|
199
|
+
duration,
|
|
200
|
+
});
|
|
201
|
+
Step.assert(this.step.stepId);
|
|
202
|
+
return result;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* 返回操作
|
|
206
|
+
* @returns 是否成功
|
|
207
|
+
*/
|
|
208
|
+
async back() {
|
|
209
|
+
Step.assert(this.step.stepId);
|
|
210
|
+
const result = await AssistsXAsync.back();
|
|
211
|
+
Step.assert(this.step.stepId);
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 回到主页
|
|
216
|
+
* @returns 是否成功
|
|
217
|
+
*/
|
|
218
|
+
async home() {
|
|
219
|
+
Step.assert(this.step.stepId);
|
|
220
|
+
const result = await AssistsXAsync.home();
|
|
221
|
+
Step.assert(this.step.stepId);
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 打开通知栏
|
|
226
|
+
* @returns 是否成功
|
|
227
|
+
*/
|
|
228
|
+
async notifications() {
|
|
229
|
+
Step.assert(this.step.stepId);
|
|
230
|
+
const result = await AssistsXAsync.notifications();
|
|
231
|
+
Step.assert(this.step.stepId);
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* 显示最近应用
|
|
236
|
+
* @returns 是否成功
|
|
237
|
+
*/
|
|
238
|
+
async recentApps() {
|
|
239
|
+
Step.assert(this.step.stepId);
|
|
240
|
+
const result = await AssistsXAsync.recentApps();
|
|
241
|
+
Step.assert(this.step.stepId);
|
|
242
|
+
return result;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* 获取屏幕尺寸
|
|
246
|
+
* @returns 屏幕尺寸对象
|
|
247
|
+
*/
|
|
248
|
+
async getScreenSize() {
|
|
249
|
+
Step.assert(this.step.stepId);
|
|
250
|
+
const data = await AssistsXAsync.getScreenSize();
|
|
251
|
+
Step.assert(this.step.stepId);
|
|
252
|
+
return data;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* 获取应用窗口尺寸
|
|
256
|
+
* @returns 应用窗口尺寸对象
|
|
257
|
+
*/
|
|
258
|
+
async getAppScreenSize() {
|
|
259
|
+
Step.assert(this.step.stepId);
|
|
260
|
+
const data = await AssistsXAsync.getAppScreenSize();
|
|
261
|
+
Step.assert(this.step.stepId);
|
|
262
|
+
return data;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 步骤执行错误类
|
|
3
|
+
* 用于携带步骤执行过程中的错误信息和当前步骤对象
|
|
4
|
+
*/
|
|
5
|
+
export declare class StepError extends Error {
|
|
6
|
+
/**
|
|
7
|
+
* 步骤实现函数名
|
|
8
|
+
*/
|
|
9
|
+
readonly impl: string;
|
|
10
|
+
/**
|
|
11
|
+
* 步骤标签
|
|
12
|
+
*/
|
|
13
|
+
readonly tag: string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* 步骤数据
|
|
16
|
+
*/
|
|
17
|
+
readonly data: any | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* 原始错误
|
|
20
|
+
*/
|
|
21
|
+
readonly originalError: any;
|
|
22
|
+
/**
|
|
23
|
+
* 当前步骤对象
|
|
24
|
+
*/
|
|
25
|
+
readonly currentStep: any | undefined;
|
|
26
|
+
constructor(message: string, impl: string, tag: string | undefined, data: any | undefined, originalError: any, currentStep: any | undefined);
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 步骤执行错误类
|
|
3
|
+
* 用于携带步骤执行过程中的错误信息和当前步骤对象
|
|
4
|
+
*/
|
|
5
|
+
export class StepError extends Error {
|
|
6
|
+
constructor(message, impl, tag, data, originalError, currentStep) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "StepError";
|
|
9
|
+
this.impl = impl;
|
|
10
|
+
this.tag = tag;
|
|
11
|
+
this.data = data;
|
|
12
|
+
this.originalError = originalError;
|
|
13
|
+
this.currentStep = currentStep;
|
|
14
|
+
}
|
|
15
|
+
}
|
package/dist/Utils.d.ts
CHANGED
package/dist/Utils.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
// 导出工具函数
|
|
2
2
|
export function sleep(ms) {
|
|
3
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
3
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
4
4
|
}
|
|
5
5
|
// 生成UUID
|
|
6
6
|
export function generateUUID() {
|
|
7
|
-
return
|
|
8
|
-
const r = Math.random() * 16 | 0;
|
|
9
|
-
const v = c ===
|
|
7
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
|
8
|
+
const r = (Math.random() * 16) | 0;
|
|
9
|
+
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
10
10
|
return v.toString(16);
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
+
export function decodeBase64UTF8(base64) {
|
|
14
|
+
const binary = atob(base64);
|
|
15
|
+
const bytes = new Uint8Array(binary.length);
|
|
16
|
+
for (let i = 0; i < binary.length; i++) {
|
|
17
|
+
bytes[i] = binary.charCodeAt(i);
|
|
18
|
+
}
|
|
19
|
+
return new TextDecoder("utf-8").decode(bytes);
|
|
20
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
1
|
+
export * from "./AssistsX";
|
|
2
|
+
export * from "./Node";
|
|
3
|
+
export * from "./CallMethod";
|
|
4
|
+
export * from "./CallResponse";
|
|
5
|
+
export * from "./NodeClassValue";
|
|
6
|
+
export * from "./Utils";
|
|
7
|
+
export * from "./Bounds";
|
|
8
|
+
export * from "./Step";
|
|
9
|
+
export * from "./StepStateStore";
|
|
10
|
+
export * from "./WindowFlags";
|
|
11
|
+
export * from "./NodeAsync";
|
|
12
|
+
export * from "./AssistsXAsync";
|
|
13
|
+
export * from "./StepAsync";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
1
|
+
export * from "./AssistsX";
|
|
2
|
+
export * from "./Node";
|
|
3
|
+
export * from "./CallMethod";
|
|
4
|
+
export * from "./CallResponse";
|
|
5
|
+
export * from "./NodeClassValue";
|
|
6
|
+
export * from "./Utils";
|
|
7
|
+
export * from "./Bounds";
|
|
8
|
+
export * from "./Step";
|
|
9
|
+
export * from "./StepStateStore";
|
|
10
|
+
export * from "./WindowFlags";
|
|
11
|
+
export * from "./NodeAsync";
|
|
12
|
+
export * from "./AssistsXAsync";
|
|
13
|
+
export * from "./StepAsync";
|
package/package.json
CHANGED