assistsx-js 0.0.3009 → 0.1.2
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/AssistsXAsync.d.ts +15 -0
- package/dist/AssistsXAsync.js +22 -0
- package/dist/CallMethod.d.ts +1 -0
- package/dist/CallMethod.js +1 -0
- package/dist/network/http.d.ts +33 -7
- package/dist/network/http.js +34 -8
- package/package.json +1 -1
- package/src/AssistsXAsync.ts +37 -0
- package/src/CallMethod.ts +1 -0
- package/src/network/http.ts +47 -11
package/dist/AssistsXAsync.d.ts
CHANGED
|
@@ -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 识别参数
|
package/dist/AssistsXAsync.js
CHANGED
|
@@ -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 识别参数
|
package/dist/CallMethod.d.ts
CHANGED
package/dist/CallMethod.js
CHANGED
package/dist/network/http.d.ts
CHANGED
|
@@ -25,6 +25,15 @@ export interface HttpDownloadResponse {
|
|
|
25
25
|
fileSize: number;
|
|
26
26
|
headers: Record<string, string>;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* 文件上传信息接口定义
|
|
30
|
+
*/
|
|
31
|
+
export interface FileUploadInfo {
|
|
32
|
+
filePath: string;
|
|
33
|
+
fieldName?: string;
|
|
34
|
+
fileName?: string;
|
|
35
|
+
contentType?: string;
|
|
36
|
+
}
|
|
28
37
|
export declare class Http {
|
|
29
38
|
/**
|
|
30
39
|
* 执行异步调用
|
|
@@ -53,16 +62,33 @@ export declare class Http {
|
|
|
53
62
|
httpPost(url: string, body: string, headers?: Record<string, string>, timeout?: number): Promise<HttpResponse>;
|
|
54
63
|
/**
|
|
55
64
|
* 执行文件上传 POST 请求
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
60
|
-
*
|
|
61
|
-
*
|
|
65
|
+
* 支持单个文件和多文件上传,同时支持多个表单字段
|
|
66
|
+
*
|
|
67
|
+
* @param url 请求 URL(必需)
|
|
68
|
+
* @param files 文件数组(必需),每个文件对象包含:
|
|
69
|
+
* - filePath: 文件路径(必需)
|
|
70
|
+
* - fieldName: 字段名(可选,默认 "file")
|
|
71
|
+
* - fileName: 文件名(可选,默认使用文件原名)
|
|
72
|
+
* - contentType: 文件类型(可选,默认 "application/octet-stream")
|
|
73
|
+
* @param formData 表单字段(可选),支持字符串值或字符串数组(同名字段多个值)
|
|
74
|
+
* @param headers 请求头(可选)
|
|
62
75
|
* @param timeout 超时时间(秒),默认30秒
|
|
63
76
|
* @returns Promise<HTTP响应>
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* // 单文件上传
|
|
80
|
+
* await http.httpPostFile("https://example.com/upload", [
|
|
81
|
+
* { filePath: "/path/to/file.jpg", fieldName: "file" }
|
|
82
|
+
* ]);
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* // 多文件上传
|
|
86
|
+
* await http.httpPostFile("https://example.com/upload", [
|
|
87
|
+
* { filePath: "/path/to/file1.jpg", fieldName: "file1" },
|
|
88
|
+
* { filePath: "/path/to/file2.jpg", fieldName: "file2" }
|
|
89
|
+
* ], { description: "My files" });
|
|
64
90
|
*/
|
|
65
|
-
httpPostFile(url: string,
|
|
91
|
+
httpPostFile(url: string, files: FileUploadInfo[], formData?: Record<string, string | string[]>, headers?: Record<string, string>, timeout?: number): Promise<HttpResponse>;
|
|
66
92
|
/**
|
|
67
93
|
* 下载文件
|
|
68
94
|
* @param url 下载 URL
|
package/dist/network/http.js
CHANGED
|
@@ -96,18 +96,44 @@ export class Http {
|
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* 执行文件上传 POST 请求
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* @param
|
|
102
|
-
* @param
|
|
103
|
-
*
|
|
104
|
-
*
|
|
99
|
+
* 支持单个文件和多文件上传,同时支持多个表单字段
|
|
100
|
+
*
|
|
101
|
+
* @param url 请求 URL(必需)
|
|
102
|
+
* @param files 文件数组(必需),每个文件对象包含:
|
|
103
|
+
* - filePath: 文件路径(必需)
|
|
104
|
+
* - fieldName: 字段名(可选,默认 "file")
|
|
105
|
+
* - fileName: 文件名(可选,默认使用文件原名)
|
|
106
|
+
* - contentType: 文件类型(可选,默认 "application/octet-stream")
|
|
107
|
+
* @param formData 表单字段(可选),支持字符串值或字符串数组(同名字段多个值)
|
|
108
|
+
* @param headers 请求头(可选)
|
|
105
109
|
* @param timeout 超时时间(秒),默认30秒
|
|
106
110
|
* @returns Promise<HTTP响应>
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* // 单文件上传
|
|
114
|
+
* await http.httpPostFile("https://example.com/upload", [
|
|
115
|
+
* { filePath: "/path/to/file.jpg", fieldName: "file" }
|
|
116
|
+
* ]);
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* // 多文件上传
|
|
120
|
+
* await http.httpPostFile("https://example.com/upload", [
|
|
121
|
+
* { filePath: "/path/to/file1.jpg", fieldName: "file1" },
|
|
122
|
+
* { filePath: "/path/to/file2.jpg", fieldName: "file2" }
|
|
123
|
+
* ], { description: "My files" });
|
|
107
124
|
*/
|
|
108
|
-
async httpPostFile(url,
|
|
125
|
+
async httpPostFile(url, files, formData, headers, timeout) {
|
|
109
126
|
var _a;
|
|
110
|
-
|
|
127
|
+
if (!files || files.length === 0) {
|
|
128
|
+
throw new Error("files参数不能为空,至少需要上传一个文件");
|
|
129
|
+
}
|
|
130
|
+
// 验证每个文件对象
|
|
131
|
+
for (const file of files) {
|
|
132
|
+
if (!file.filePath) {
|
|
133
|
+
throw new Error("files数组中的filePath参数不能为空");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const response = await this.asyncCall("httpPostFile", { url, files, formData, headers }, timeout);
|
|
111
137
|
if (!response.isSuccess()) {
|
|
112
138
|
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "HTTP POST file request failed");
|
|
113
139
|
}
|
package/package.json
CHANGED
package/src/AssistsXAsync.ts
CHANGED
|
@@ -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
package/src/network/http.ts
CHANGED
|
@@ -35,6 +35,16 @@ export interface HttpDownloadResponse {
|
|
|
35
35
|
headers: Record<string, string>;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* 文件上传信息接口定义
|
|
40
|
+
*/
|
|
41
|
+
export interface FileUploadInfo {
|
|
42
|
+
filePath: string;
|
|
43
|
+
fieldName?: string;
|
|
44
|
+
fileName?: string;
|
|
45
|
+
contentType?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
// 回调函数存储对象
|
|
39
49
|
const callbacks: Map<string, (data: string) => void> = new Map();
|
|
40
50
|
|
|
@@ -153,27 +163,53 @@ export class Http {
|
|
|
153
163
|
|
|
154
164
|
/**
|
|
155
165
|
* 执行文件上传 POST 请求
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* @param
|
|
159
|
-
* @param
|
|
160
|
-
*
|
|
161
|
-
*
|
|
166
|
+
* 支持单个文件和多文件上传,同时支持多个表单字段
|
|
167
|
+
*
|
|
168
|
+
* @param url 请求 URL(必需)
|
|
169
|
+
* @param files 文件数组(必需),每个文件对象包含:
|
|
170
|
+
* - filePath: 文件路径(必需)
|
|
171
|
+
* - fieldName: 字段名(可选,默认 "file")
|
|
172
|
+
* - fileName: 文件名(可选,默认使用文件原名)
|
|
173
|
+
* - contentType: 文件类型(可选,默认 "application/octet-stream")
|
|
174
|
+
* @param formData 表单字段(可选),支持字符串值或字符串数组(同名字段多个值)
|
|
175
|
+
* @param headers 请求头(可选)
|
|
162
176
|
* @param timeout 超时时间(秒),默认30秒
|
|
163
177
|
* @returns Promise<HTTP响应>
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* // 单文件上传
|
|
181
|
+
* await http.httpPostFile("https://example.com/upload", [
|
|
182
|
+
* { filePath: "/path/to/file.jpg", fieldName: "file" }
|
|
183
|
+
* ]);
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* // 多文件上传
|
|
187
|
+
* await http.httpPostFile("https://example.com/upload", [
|
|
188
|
+
* { filePath: "/path/to/file1.jpg", fieldName: "file1" },
|
|
189
|
+
* { filePath: "/path/to/file2.jpg", fieldName: "file2" }
|
|
190
|
+
* ], { description: "My files" });
|
|
164
191
|
*/
|
|
165
192
|
async httpPostFile(
|
|
166
193
|
url: string,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
fileName?: string,
|
|
170
|
-
formData?: Record<string, string>,
|
|
194
|
+
files: FileUploadInfo[],
|
|
195
|
+
formData?: Record<string, string | string[]>,
|
|
171
196
|
headers?: Record<string, string>,
|
|
172
197
|
timeout?: number
|
|
173
198
|
): Promise<HttpResponse> {
|
|
199
|
+
if (!files || files.length === 0) {
|
|
200
|
+
throw new Error("files参数不能为空,至少需要上传一个文件");
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// 验证每个文件对象
|
|
204
|
+
for (const file of files) {
|
|
205
|
+
if (!file.filePath) {
|
|
206
|
+
throw new Error("files数组中的filePath参数不能为空");
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
174
210
|
const response = await this.asyncCall(
|
|
175
211
|
"httpPostFile",
|
|
176
|
-
{ url,
|
|
212
|
+
{ url, files, formData, headers },
|
|
177
213
|
timeout
|
|
178
214
|
);
|
|
179
215
|
if (!response.isSuccess()) {
|