assistsx-js 0.1.41 → 0.2.0
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/README.md +32 -0
- package/dist/index.cjs +7957 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +4231 -0
- package/dist/index.d.ts +4231 -30
- package/dist/index.global.js +46 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +7879 -30
- package/dist/index.js.map +1 -0
- package/package.json +11 -5
- package/src/{AssistsXAsync.ts → assistsx-async.ts} +8 -8
- package/src/{AssistsX.ts → assistsx.ts} +8 -8
- package/src/barutils/bar-utils.ts +3 -3
- package/src/filesystem/fileio/file-io.ts +2 -2
- package/src/filesystem/fileutils/file-utils.ts +2 -2
- package/src/filesystem/path.ts +2 -2
- package/src/floatingwindow/float.ts +4 -4
- package/src/gallery/gallery.ts +2 -2
- package/src/global.d.ts +6 -1
- package/src/imageutils/image-utils.ts +2 -2
- package/src/ime/ime.ts +2 -2
- package/src/index.ts +21 -20
- package/src/log/log-call-method.ts +28 -0
- package/src/log/log.ts +445 -0
- package/src/mlkit/mlkit.ts +3 -3
- package/src/network/http.ts +2 -2
- package/src/{NodeAsync.ts → node-async.ts} +5 -5
- package/src/{Node.ts → node.ts} +5 -5
- package/src/{StepAsync.ts → step-async.ts} +8 -8
- package/src/{Step.ts → step.ts} +7 -7
- package/dist/AccessibilityEventFilter.d.ts +0 -105
- package/dist/AccessibilityEventFilter.js +0 -89
- package/dist/AppInfo.d.ts +0 -45
- package/dist/AppInfo.js +0 -38
- package/dist/AssistsX.d.ts +0 -484
- package/dist/AssistsX.js +0 -828
- package/dist/AssistsXAsync.d.ts +0 -532
- package/dist/AssistsXAsync.js +0 -874
- package/dist/Bounds.d.ts +0 -48
- package/dist/Bounds.js +0 -68
- package/dist/CallMethod.d.ts +0 -69
- package/dist/CallMethod.js +0 -71
- package/dist/CallResponse.d.ts +0 -10
- package/dist/CallResponse.js +0 -28
- package/dist/DeviceInfo.d.ts +0 -69
- package/dist/DeviceInfo.js +0 -50
- package/dist/Node.d.ts +0 -334
- package/dist/Node.js +0 -369
- package/dist/NodeAsync.d.ts +0 -213
- package/dist/NodeAsync.js +0 -313
- package/dist/NodeClassValue.d.ts +0 -15
- package/dist/NodeClassValue.js +0 -15
- package/dist/Step.d.ts +0 -355
- package/dist/Step.js +0 -689
- package/dist/StepAsync.d.ts +0 -162
- package/dist/StepAsync.js +0 -264
- package/dist/StepError.d.ts +0 -35
- package/dist/StepError.js +0 -26
- package/dist/StepStateStore.d.ts +0 -14
- package/dist/StepStateStore.js +0 -37
- package/dist/Utils.d.ts +0 -3
- package/dist/Utils.js +0 -20
- package/dist/WindowFlags.d.ts +0 -75
- package/dist/WindowFlags.js +0 -97
- package/dist/barutils/BarUtilsCallMethod.d.ts +0 -24
- package/dist/barutils/BarUtilsCallMethod.js +0 -26
- package/dist/barutils/bar-utils.d.ts +0 -41
- package/dist/barutils/bar-utils.js +0 -205
- package/dist/filesystem/fileio/file-io.d.ts +0 -101
- package/dist/filesystem/fileio/file-io.js +0 -235
- package/dist/filesystem/fileutils/file-utils.d.ts +0 -242
- package/dist/filesystem/fileutils/file-utils.js +0 -493
- package/dist/filesystem/path.d.ts +0 -252
- package/dist/filesystem/path.js +0 -589
- package/dist/floatingwindow/FloatCallMethod.d.ts +0 -19
- package/dist/floatingwindow/FloatCallMethod.js +0 -18
- package/dist/floatingwindow/float.d.ts +0 -29
- package/dist/floatingwindow/float.js +0 -149
- package/dist/gallery/gallery.d.ts +0 -60
- package/dist/gallery/gallery.js +0 -142
- package/dist/imageutils/image-utils.d.ts +0 -442
- package/dist/imageutils/image-utils.js +0 -543
- package/dist/ime/ime.d.ts +0 -80
- package/dist/ime/ime.js +0 -141
- package/dist/mlkit/MlkitCallMethod.d.ts +0 -27
- package/dist/mlkit/MlkitCallMethod.js +0 -26
- package/dist/mlkit/mlkit.d.ts +0 -86
- package/dist/mlkit/mlkit.js +0 -169
- package/dist/network/http.d.ts +0 -127
- package/dist/network/http.js +0 -202
- /package/src/{AccessibilityEventFilter.ts → accessibility-event-filter.ts} +0 -0
- /package/src/{AppInfo.ts → app-info.ts} +0 -0
- /package/src/barutils/{BarUtilsCallMethod.ts → bar-utils-call-method.ts} +0 -0
- /package/src/{Bounds.ts → bounds.ts} +0 -0
- /package/src/{CallMethod.ts → call-method.ts} +0 -0
- /package/src/{CallResponse.ts → call-response.ts} +0 -0
- /package/src/{DeviceInfo.ts → device-info.ts} +0 -0
- /package/src/floatingwindow/{FloatCallMethod.ts → float-call-method.ts} +0 -0
- /package/src/mlkit/{MlkitCallMethod.ts → mlkit-call-method.ts} +0 -0
- /package/src/{NodeClassValue.ts → node-class-value.ts} +0 -0
- /package/src/{StepError.ts → step-error.ts} +0 -0
- /package/src/{StepStateStore.ts → step-state-store.ts} +0 -0
- /package/src/{Utils.ts → utils.ts} +0 -0
- /package/src/{WindowFlags.ts → window-flags.ts} +0 -0
package/dist/network/http.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP 请求相关功能
|
|
3
|
-
* 提供 HTTP 请求相关的功能,包括 GET、POST、文件上传和下载
|
|
4
|
-
*/
|
|
5
|
-
import { CallResponse } from "../CallResponse";
|
|
6
|
-
import { decodeBase64UTF8, generateUUID } from "../Utils";
|
|
7
|
-
// 回调函数存储对象
|
|
8
|
-
const callbacks = new Map();
|
|
9
|
-
// 初始化全局回调函数
|
|
10
|
-
if (typeof window !== "undefined" && !window.assistsxHttpCallback) {
|
|
11
|
-
window.assistsxHttpCallback = (data) => {
|
|
12
|
-
let callbackId;
|
|
13
|
-
try {
|
|
14
|
-
const json = decodeBase64UTF8(data);
|
|
15
|
-
const response = JSON.parse(json);
|
|
16
|
-
callbackId = response.callbackId;
|
|
17
|
-
if (callbackId) {
|
|
18
|
-
const callback = callbacks.get(callbackId);
|
|
19
|
-
if (callback) {
|
|
20
|
-
callback(json);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
catch (e) {
|
|
25
|
-
console.error("Http callback error:", e);
|
|
26
|
-
}
|
|
27
|
-
finally {
|
|
28
|
-
if (callbackId) {
|
|
29
|
-
callbacks.delete(callbackId);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export class Http {
|
|
35
|
-
/**
|
|
36
|
-
* 执行异步调用
|
|
37
|
-
* @param method 方法名
|
|
38
|
-
* @param args 参数对象
|
|
39
|
-
* @param timeout 超时时间(秒),默认30秒
|
|
40
|
-
* @returns Promise<调用响应>
|
|
41
|
-
*/
|
|
42
|
-
async asyncCall(method, args, timeout = 30) {
|
|
43
|
-
const uuid = generateUUID();
|
|
44
|
-
const params = {
|
|
45
|
-
method,
|
|
46
|
-
arguments: args ? args : undefined,
|
|
47
|
-
callbackId: uuid,
|
|
48
|
-
};
|
|
49
|
-
const promise = new Promise((resolve) => {
|
|
50
|
-
callbacks.set(uuid, (data) => {
|
|
51
|
-
resolve(data);
|
|
52
|
-
});
|
|
53
|
-
setTimeout(() => {
|
|
54
|
-
callbacks.delete(uuid);
|
|
55
|
-
resolve(JSON.stringify(new CallResponse(0, null, uuid)));
|
|
56
|
-
}, timeout * 1000);
|
|
57
|
-
});
|
|
58
|
-
const result = window.assistsxHttp.call(JSON.stringify(params));
|
|
59
|
-
const promiseResult = await promise;
|
|
60
|
-
if (typeof promiseResult === "string") {
|
|
61
|
-
const responseData = JSON.parse(promiseResult);
|
|
62
|
-
return new CallResponse(responseData.code, responseData.data, responseData.callbackId);
|
|
63
|
-
}
|
|
64
|
-
throw new Error("Call failed");
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* 执行 GET 请求
|
|
68
|
-
* @param url 请求 URL
|
|
69
|
-
* @param headers 请求头
|
|
70
|
-
* @param timeout 超时时间(秒),默认30秒
|
|
71
|
-
* @returns Promise<HTTP响应>
|
|
72
|
-
*/
|
|
73
|
-
async httpGet(url, headers, timeout) {
|
|
74
|
-
var _a;
|
|
75
|
-
const response = await this.asyncCall("httpGet", { url, headers }, timeout);
|
|
76
|
-
if (!response.isSuccess()) {
|
|
77
|
-
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "HTTP GET request failed");
|
|
78
|
-
}
|
|
79
|
-
return response.data;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* 执行 POST 请求
|
|
83
|
-
* @param url 请求 URL
|
|
84
|
-
* @param body 请求体
|
|
85
|
-
* @param headers 请求头
|
|
86
|
-
* @param timeout 超时时间(秒),默认30秒
|
|
87
|
-
* @returns Promise<HTTP响应>
|
|
88
|
-
*/
|
|
89
|
-
async httpPost(url, body, headers, timeout) {
|
|
90
|
-
var _a;
|
|
91
|
-
const response = await this.asyncCall("httpPost", { url, body, headers }, timeout);
|
|
92
|
-
if (!response.isSuccess()) {
|
|
93
|
-
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "HTTP POST request failed");
|
|
94
|
-
}
|
|
95
|
-
return response.data;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* 执行文件上传 POST 请求
|
|
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 请求头(可选)
|
|
109
|
-
* @param timeout 超时时间(秒),默认30秒
|
|
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" });
|
|
124
|
-
*/
|
|
125
|
-
async httpPostFile(url, files, formData, headers, timeout) {
|
|
126
|
-
var _a;
|
|
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);
|
|
137
|
-
if (!response.isSuccess()) {
|
|
138
|
-
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "HTTP POST file request failed");
|
|
139
|
-
}
|
|
140
|
-
return response.data;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* 下载文件
|
|
144
|
-
* @param url 下载 URL
|
|
145
|
-
* @param savePath 保存路径
|
|
146
|
-
* @param headers 请求头
|
|
147
|
-
* @param saveToGallery 是否保存到系统相册(仅支持图片和视频文件),默认 false
|
|
148
|
-
* @param displayName 保存到相册时的显示名称(可选,默认使用文件名)
|
|
149
|
-
* @param timeout 超时时间(秒),默认30秒
|
|
150
|
-
* @returns Promise<下载响应>
|
|
151
|
-
*/
|
|
152
|
-
async httpDownload(url, savePath, headers, saveToGallery, displayName, timeout) {
|
|
153
|
-
var _a;
|
|
154
|
-
const response = await this.asyncCall("httpDownload", { url, savePath, headers, saveToGallery, displayName }, timeout);
|
|
155
|
-
if (!response.isSuccess()) {
|
|
156
|
-
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "HTTP download failed");
|
|
157
|
-
}
|
|
158
|
-
return response.data;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* 配置 OkHttpClient
|
|
162
|
-
* @param config 配置选项
|
|
163
|
-
* @param timeout 超时时间(秒),默认30秒
|
|
164
|
-
* @returns Promise<配置信息>
|
|
165
|
-
*/
|
|
166
|
-
async httpConfigure(config, timeout) {
|
|
167
|
-
var _a;
|
|
168
|
-
const response = await this.asyncCall("httpConfigure", config, timeout);
|
|
169
|
-
if (!response.isSuccess()) {
|
|
170
|
-
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "HTTP configure failed");
|
|
171
|
-
}
|
|
172
|
-
return response.data;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* 重置 OkHttpClient 配置
|
|
176
|
-
* @param timeout 超时时间(秒),默认30秒
|
|
177
|
-
* @returns Promise<配置信息>
|
|
178
|
-
*/
|
|
179
|
-
async httpReset(timeout) {
|
|
180
|
-
var _a;
|
|
181
|
-
const response = await this.asyncCall("httpReset", undefined, timeout);
|
|
182
|
-
if (!response.isSuccess()) {
|
|
183
|
-
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "HTTP reset failed");
|
|
184
|
-
}
|
|
185
|
-
return response.data;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* 获取当前配置信息
|
|
189
|
-
* @param timeout 超时时间(秒),默认30秒
|
|
190
|
-
* @returns Promise<配置信息>
|
|
191
|
-
*/
|
|
192
|
-
async httpGetConfig(timeout) {
|
|
193
|
-
var _a;
|
|
194
|
-
const response = await this.asyncCall("httpGetConfig", undefined, timeout);
|
|
195
|
-
if (!response.isSuccess()) {
|
|
196
|
-
throw new Error(((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) || "Get HTTP config failed");
|
|
197
|
-
}
|
|
198
|
-
return response.data;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
// 导出常量实例
|
|
202
|
-
export const http = new Http();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|