assistsx-js 0.0.3008 → 0.1.1

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.
@@ -103,6 +103,21 @@ export declare class AssistsXAsync {
103
103
  * @returns 截图路径数组
104
104
  */
105
105
  static takeScreenshotNodes(nodes: Node[], overlayHiddenScreenshotDelayMillis?: number, timeout?: number): Promise<string[]>;
106
+ /**
107
+ * 保存全屏截图到文件
108
+ * @param options 截图保存选项
109
+ * @param options.filePath 文件路径(可选,不提供则自动生成)
110
+ * @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认为 "PNG"
111
+ * @param options.overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒),默认为 250
112
+ * @param options.timeout 超时时间(秒),默认30秒
113
+ * @returns 保存的文件路径
114
+ */
115
+ static takeScreenshotSave(options?: {
116
+ filePath?: string;
117
+ format?: "PNG" | "JPEG" | "JPG" | "WEBP";
118
+ overlayHiddenScreenshotDelayMillis?: number;
119
+ timeout?: number;
120
+ }): Promise<string>;
106
121
  /**
107
122
  * 截图识别文本
108
123
  * @param param0 识别参数
@@ -124,6 +124,28 @@ export class AssistsXAsync {
124
124
  const data = response.getDataOrDefault({ images: [] });
125
125
  return data.images;
126
126
  }
127
+ /**
128
+ * 保存全屏截图到文件
129
+ * @param options 截图保存选项
130
+ * @param options.filePath 文件路径(可选,不提供则自动生成)
131
+ * @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认为 "PNG"
132
+ * @param options.overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒),默认为 250
133
+ * @param options.timeout 超时时间(秒),默认30秒
134
+ * @returns 保存的文件路径
135
+ */
136
+ static async takeScreenshotSave(options = {}) {
137
+ const { filePath, format = "PNG", overlayHiddenScreenshotDelayMillis = 250, timeout, } = options;
138
+ const response = await this.asyncCall(CallMethod.takeScreenshotSave, {
139
+ args: {
140
+ filePath,
141
+ format,
142
+ overlayHiddenScreenshotDelayMillis,
143
+ },
144
+ timeout,
145
+ });
146
+ const data = response.getDataOrDefault({ file: "" });
147
+ return data.file;
148
+ }
127
149
  /**
128
150
  * 截图识别文本
129
151
  * @param param0 识别参数
@@ -1,5 +1,6 @@
1
1
  export declare const CallMethod: {
2
2
  readonly takeScreenshot: "takeScreenshot";
3
+ readonly takeScreenshotSave: "takeScreenshotSave";
3
4
  readonly overlayToast: "overlayToast";
4
5
  readonly setNodeText: "setNodeText";
5
6
  readonly findByTags: "findByTags";
@@ -1,6 +1,7 @@
1
1
  // CallMethod 常量对象
2
2
  export const CallMethod = {
3
3
  takeScreenshot: "takeScreenshot",
4
+ takeScreenshotSave: "takeScreenshotSave",
4
5
  overlayToast: "overlayToast",
5
6
  setNodeText: "setNodeText",
6
7
  findByTags: "findByTags",
@@ -48,10 +48,11 @@ export declare class FileIO {
48
48
  * @param filePath 文件路径
49
49
  * @param content 文件内容
50
50
  * @param append 是否追加,默认为 false
51
+ * @param threadSafe 是否线程安全写入,默认为 false
51
52
  * @param timeout 超时时间(秒),默认30秒
52
53
  * @returns Promise<是否成功>
53
54
  */
54
- writeFileFromString(filePath: string, content: string, append?: boolean, timeout?: number): Promise<boolean>;
55
+ writeFileFromString(filePath: string, content: string, append?: boolean, threadSafe?: boolean, timeout?: number): Promise<boolean>;
55
56
  /**
56
57
  * 读取文件为字符串列表
57
58
  * @param filePath 文件路径
@@ -132,12 +132,13 @@ export class FileIO {
132
132
  * @param filePath 文件路径
133
133
  * @param content 文件内容
134
134
  * @param append 是否追加,默认为 false
135
+ * @param threadSafe 是否线程安全写入,默认为 false
135
136
  * @param timeout 超时时间(秒),默认30秒
136
137
  * @returns Promise<是否成功>
137
138
  */
138
- async writeFileFromString(filePath, content, append = false, timeout) {
139
+ async writeFileFromString(filePath, content, append = false, threadSafe = false, timeout) {
139
140
  var _a;
140
- const response = await this.asyncCall("writeFileFromString", { filePath, content, append }, timeout);
141
+ const response = await this.asyncCall("writeFileFromString", { filePath, content, append, threadSafe }, timeout);
141
142
  if (!response.isSuccess()) {
142
143
  throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "Write file from string failed");
143
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assistsx-js",
3
- "version": "0.0.3008",
3
+ "version": "0.1.01",
4
4
  "description": "assistsx-js自动化开发SDK",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -217,6 +217,43 @@ export class AssistsXAsync {
217
217
  const data = response.getDataOrDefault({ images: [] });
218
218
  return data.images;
219
219
  }
220
+
221
+ /**
222
+ * 保存全屏截图到文件
223
+ * @param options 截图保存选项
224
+ * @param options.filePath 文件路径(可选,不提供则自动生成)
225
+ * @param options.format 图片格式,支持 "PNG"、"JPEG"、"JPG"、"WEBP",默认为 "PNG"
226
+ * @param options.overlayHiddenScreenshotDelayMillis 截图延迟时间(毫秒),默认为 250
227
+ * @param options.timeout 超时时间(秒),默认30秒
228
+ * @returns 保存的文件路径
229
+ */
230
+ public static async takeScreenshotSave(
231
+ options: {
232
+ filePath?: string;
233
+ format?: "PNG" | "JPEG" | "JPG" | "WEBP";
234
+ overlayHiddenScreenshotDelayMillis?: number;
235
+ timeout?: number;
236
+ } = {}
237
+ ): Promise<string> {
238
+ const {
239
+ filePath,
240
+ format = "PNG",
241
+ overlayHiddenScreenshotDelayMillis = 250,
242
+ timeout,
243
+ } = options;
244
+
245
+ const response = await this.asyncCall(CallMethod.takeScreenshotSave, {
246
+ args: {
247
+ filePath,
248
+ format,
249
+ overlayHiddenScreenshotDelayMillis,
250
+ },
251
+ timeout,
252
+ });
253
+ const data = response.getDataOrDefault({ file: "" });
254
+ return data.file;
255
+ }
256
+
220
257
  /**
221
258
  * 截图识别文本
222
259
  * @param param0 识别参数
package/src/CallMethod.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // CallMethod 常量对象
2
2
  export const CallMethod = {
3
3
  takeScreenshot: "takeScreenshot",
4
+ takeScreenshotSave: "takeScreenshotSave",
4
5
  overlayToast: "overlayToast",
5
6
  setNodeText: "setNodeText",
6
7
  findByTags: "findByTags",
@@ -177,6 +177,7 @@ export class FileIO {
177
177
  * @param filePath 文件路径
178
178
  * @param content 文件内容
179
179
  * @param append 是否追加,默认为 false
180
+ * @param threadSafe 是否线程安全写入,默认为 false
180
181
  * @param timeout 超时时间(秒),默认30秒
181
182
  * @returns Promise<是否成功>
182
183
  */
@@ -184,11 +185,12 @@ export class FileIO {
184
185
  filePath: string,
185
186
  content: string,
186
187
  append: boolean = false,
188
+ threadSafe: boolean = false,
187
189
  timeout?: number
188
190
  ): Promise<boolean> {
189
191
  const response = await this.asyncCall(
190
192
  "writeFileFromString",
191
- { filePath, content, append },
193
+ { filePath, content, append, threadSafe },
192
194
  timeout
193
195
  );
194
196
  if (!response.isSuccess()) {