ms-types 0.4.7 → 0.4.9
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/package.json +22 -22
- package/types/action.d.ts +296 -296
- package/types/appleocr.d.ts +102 -102
- package/types/config.d.ts +97 -97
- package/types/cryptoUtils.d.ts +59 -59
- package/types/device.d.ts +117 -117
- package/types/global.d.ts +218 -220
- package/types/hid.d.ts +329 -329
- package/types/hotUpdate.d.ts +104 -104
- package/types/http.d.ts +300 -300
- package/types/image.d.ts +14 -9
- package/types/ime.d.ts +99 -99
- package/types/index.d.ts +27 -27
- package/types/media.d.ts +101 -101
- package/types/mysql.d.ts +174 -174
- package/types/netCard.d.ts +77 -77
- package/types/node.d.ts +292 -292
- package/types/paddleocr.d.ts +73 -73
- package/types/pip.d.ts +51 -51
- package/types/system.d.ts +225 -225
- package/types/thread.d.ts +42 -42
- package/types/tomatoocr.d.ts +209 -209
- package/types/tts.d.ts +91 -91
- package/types/ui.d.ts +185 -185
- package/types/utils.d.ts +77 -77
- package/types/yolo.d.ts +114 -114
- package/types/zh/HID/346/250/241/345/235/227.d.ts +333 -333
- package/types/zh/HTTP/346/250/241/345/235/227.d.ts +301 -301
- package/types/zh/MySql/346/250/241/345/235/227.d.ts +175 -175
- package/types/zh/PaddleOCR/346/250/241/345/235/227.d.ts +74 -74
- package/types/zh/YOLO/346/250/241/345/235/227.d.ts +118 -118
- package/types/zh/index.d.ts +24 -24
- package/types/zh//345/205/250/345/261/200/346/250/241/345/235/227.d.ts +186 -186
- package/types/zh//345/212/250/344/275/234/346/250/241/345/235/227.d.ts +298 -298
- package/types/zh//345/215/241/345/257/206/346/250/241/345/235/227.d.ts +90 -90
- package/types/zh//345/233/276/347/211/207/346/250/241/345/235/227.d.ts +13 -8
- package/types/zh//345/252/222/344/275/223/346/250/241/345/235/227.d.ts +102 -102
- package/types/zh//345/267/245/345/205/267/346/250/241/345/235/227.d.ts +77 -77
- package/types/zh//346/202/254/346/265/256/347/252/227/346/250/241/345/235/227.d.ts +55 -55
- package/types/zh//346/226/207/345/255/227/350/275/254/350/257/255/351/237/263/346/250/241/345/235/227.d.ts +92 -92
- package/types/zh//347/203/255/346/233/264/346/226/260/346/250/241/345/235/227.d.ts +105 -105
- package/types/zh//347/263/273/347/273/237/346/250/241/345/235/227.d.ts +225 -225
- package/types/zh//347/272/277/347/250/213/346/250/241/345/235/227.d.ts +43 -43
- package/types/zh//350/212/202/347/202/271/346/250/241/345/235/227.d.ts +290 -290
- package/types/zh//350/213/271/346/236/234OCR.d.ts +104 -104
- package/types/zh//350/247/206/345/233/276/346/250/241/345/235/227.d.ts +90 -90
- package/types/zh//350/256/276/345/244/207/346/250/241/345/235/227.d.ts +118 -118
- package/types/zh//350/276/223/345/205/245/346/263/225/346/250/241/345/235/227.d.ts +100 -100
- package/types/zh//351/205/215/347/275/256/346/250/241/345/235/227.d.ts +99 -99
package/types/http.d.ts
CHANGED
|
@@ -1,300 +1,300 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP模块 包含发送HTTP请求、下载文件等功能、websocket等功能
|
|
3
|
-
*/
|
|
4
|
-
declare namespace http {
|
|
5
|
-
/**
|
|
6
|
-
* 通用发送HTTP请求
|
|
7
|
-
* @param params 请求参数
|
|
8
|
-
* @returns 请求结果
|
|
9
|
-
* @example
|
|
10
|
-
* http.request({
|
|
11
|
-
* url: "https://www.baidu.com",
|
|
12
|
-
* method: "GET",
|
|
13
|
-
* })
|
|
14
|
-
*/
|
|
15
|
-
function request(params: {
|
|
16
|
-
/**
|
|
17
|
-
* 请求地址
|
|
18
|
-
*/
|
|
19
|
-
url: string;
|
|
20
|
-
/**
|
|
21
|
-
* 请求超时时间
|
|
22
|
-
*/
|
|
23
|
-
timeout?: number;
|
|
24
|
-
/**
|
|
25
|
-
* 请求方法 GET POST PUT DELETE PATCH HEAD OPTIONS
|
|
26
|
-
*/
|
|
27
|
-
method?: string;
|
|
28
|
-
/**
|
|
29
|
-
* 代理服务器
|
|
30
|
-
*/
|
|
31
|
-
proxy?: {
|
|
32
|
-
/**
|
|
33
|
-
* 代理服务器地址
|
|
34
|
-
*/
|
|
35
|
-
host: string;
|
|
36
|
-
/**
|
|
37
|
-
* 代理服务器端口
|
|
38
|
-
*/
|
|
39
|
-
port: number;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* 是否跟随重定向
|
|
43
|
-
*/
|
|
44
|
-
followRedirects?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* 请求体 仅在POST方法下有效 json 需要进行JSON.stringify
|
|
47
|
-
*/
|
|
48
|
-
requestBody?: string;
|
|
49
|
-
/**
|
|
50
|
-
* 请求头
|
|
51
|
-
*/
|
|
52
|
-
userAgent?: string;
|
|
53
|
-
/**
|
|
54
|
-
* 是否忽略内容类型
|
|
55
|
-
*/
|
|
56
|
-
ignoreContentType?: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* 是否忽略HTTP错误
|
|
59
|
-
*/
|
|
60
|
-
ignoreHttpErrors?: boolean;
|
|
61
|
-
/**
|
|
62
|
-
* 最大响应体大小 默认 10MB
|
|
63
|
-
*/
|
|
64
|
-
maxBodySize?: number;
|
|
65
|
-
/**
|
|
66
|
-
* 引用来源
|
|
67
|
-
*/
|
|
68
|
-
referrer?: string;
|
|
69
|
-
/**
|
|
70
|
-
* 请求头
|
|
71
|
-
*/
|
|
72
|
-
header?: Record<string, string>;
|
|
73
|
-
/**
|
|
74
|
-
* Cookie
|
|
75
|
-
*/
|
|
76
|
-
cookie?: Record<string, string>;
|
|
77
|
-
/**
|
|
78
|
-
* 请求参数
|
|
79
|
-
*/
|
|
80
|
-
data?: Record<string, any>;
|
|
81
|
-
/**
|
|
82
|
-
* 请求文件
|
|
83
|
-
*/
|
|
84
|
-
file?: Record<string, string>;
|
|
85
|
-
/**
|
|
86
|
-
* 响应字符集
|
|
87
|
-
*/
|
|
88
|
-
responseCharset?: string;
|
|
89
|
-
}): {
|
|
90
|
-
/**
|
|
91
|
-
* 响应头
|
|
92
|
-
*/
|
|
93
|
-
header: Record<string, string>;
|
|
94
|
-
/**
|
|
95
|
-
* 响应Cookie
|
|
96
|
-
*/
|
|
97
|
-
cookie: Record<string, string>;
|
|
98
|
-
/**
|
|
99
|
-
* 响应状态码
|
|
100
|
-
*/
|
|
101
|
-
statusCode: number;
|
|
102
|
-
/**
|
|
103
|
-
* 响应状态消息
|
|
104
|
-
*/
|
|
105
|
-
statusMessage: string;
|
|
106
|
-
/**
|
|
107
|
-
* 响应字符集
|
|
108
|
-
*/
|
|
109
|
-
charset: string;
|
|
110
|
-
/**
|
|
111
|
-
* 响应内容类型
|
|
112
|
-
*/
|
|
113
|
-
contentType: string;
|
|
114
|
-
/**
|
|
115
|
-
* 响应体
|
|
116
|
-
*/
|
|
117
|
-
body: string;
|
|
118
|
-
} | null;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* 下载文件 支持断点续传
|
|
122
|
-
* @param url 请求地址
|
|
123
|
-
* @param file 文件路径
|
|
124
|
-
* @param timeout 超时时间
|
|
125
|
-
* @param headers 请求头
|
|
126
|
-
* @returns 下载是否成功
|
|
127
|
-
* @example
|
|
128
|
-
* http.downloadFile("https://www.baidu.com", "baidu.html")
|
|
129
|
-
*/
|
|
130
|
-
function downloadFile(
|
|
131
|
-
url: string,
|
|
132
|
-
file: string,
|
|
133
|
-
timeout?: number,
|
|
134
|
-
headers?: Record<string, string>
|
|
135
|
-
): boolean;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 发送GET请求
|
|
139
|
-
* @param url 请求地址
|
|
140
|
-
* @param params 请求参数
|
|
141
|
-
* @param timeout 超时时间
|
|
142
|
-
* @param headers 请求头
|
|
143
|
-
* @returns 请求结果
|
|
144
|
-
* @example
|
|
145
|
-
* http.httpGet("https://www.baidu.com")
|
|
146
|
-
*/
|
|
147
|
-
function httpGet(
|
|
148
|
-
url: string,
|
|
149
|
-
params?: Record<string, string>,
|
|
150
|
-
timeout?: number,
|
|
151
|
-
headers?: Record<string, string>
|
|
152
|
-
): string | null;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* 发送POST请求
|
|
156
|
-
* @param url 请求地址
|
|
157
|
-
* @param params 请求参数
|
|
158
|
-
* @param files 请求文件
|
|
159
|
-
* @param timeout 超时时间
|
|
160
|
-
* @param headers 请求头
|
|
161
|
-
* @returns 请求结果
|
|
162
|
-
* @example
|
|
163
|
-
* http.httpPost("https://www.baidu.com")
|
|
164
|
-
*/
|
|
165
|
-
function httpPost(
|
|
166
|
-
url: string,
|
|
167
|
-
params?: Record<string, string>,
|
|
168
|
-
files?: Record<string, string>,
|
|
169
|
-
timeout?: number,
|
|
170
|
-
headers?: Record<string, string>
|
|
171
|
-
): string | null;
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* 发送JSON请求
|
|
175
|
-
* @param url 请求地址
|
|
176
|
-
* @param json 请求JSON数据
|
|
177
|
-
* @param timeout 超时时间
|
|
178
|
-
* @param headers 请求头
|
|
179
|
-
* @returns 请求结果
|
|
180
|
-
* @example
|
|
181
|
-
* http.postJSON("https://www.baidu.com", {
|
|
182
|
-
* "name": "快点JS",
|
|
183
|
-
* "version": "1.0.0"
|
|
184
|
-
* })
|
|
185
|
-
*/
|
|
186
|
-
function postJSON(
|
|
187
|
-
url: string,
|
|
188
|
-
json?: Record<string, any>,
|
|
189
|
-
timeout?: number,
|
|
190
|
-
headers?: Record<string, string>
|
|
191
|
-
): string | null;
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* 创建WebSocket连接
|
|
195
|
-
* @param url 连接地址
|
|
196
|
-
* @param header 连接头
|
|
197
|
-
* @returns WebSocket连接对象
|
|
198
|
-
* @example
|
|
199
|
-
* const ws = http.newWebsocket("ws://www.baidu.com")
|
|
200
|
-
* ws.connect()
|
|
201
|
-
* ws.onText((data) => {
|
|
202
|
-
* logi(data)
|
|
203
|
-
* })
|
|
204
|
-
* ws.sendText("hello")
|
|
205
|
-
* ws.close()
|
|
206
|
-
*/
|
|
207
|
-
function newWebsocket(
|
|
208
|
-
url: string,
|
|
209
|
-
header?: Record<string, string>
|
|
210
|
-
): WebSocket;
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* WebSocket连接
|
|
214
|
-
*/
|
|
215
|
-
interface WebSocket {
|
|
216
|
-
/**
|
|
217
|
-
* 连接WebSocket服务器
|
|
218
|
-
*/
|
|
219
|
-
connect(): void;
|
|
220
|
-
/**
|
|
221
|
-
* 关闭WebSocket连接
|
|
222
|
-
*/
|
|
223
|
-
close(): void;
|
|
224
|
-
/**
|
|
225
|
-
* 重置WebSocket连接
|
|
226
|
-
* @returns 重置是否成功
|
|
227
|
-
*/
|
|
228
|
-
reset(): boolean;
|
|
229
|
-
/**
|
|
230
|
-
* 获取WebSocket是否已关闭
|
|
231
|
-
* @returns 是否已关闭
|
|
232
|
-
*/
|
|
233
|
-
isClosed(): boolean;
|
|
234
|
-
/**
|
|
235
|
-
* 获取WebSocket是否已连接
|
|
236
|
-
* @returns 是否已连接
|
|
237
|
-
*/
|
|
238
|
-
isConnected(): boolean;
|
|
239
|
-
/**
|
|
240
|
-
* 发送文本消息
|
|
241
|
-
* @param data 文本消息内容
|
|
242
|
-
*/
|
|
243
|
-
sendText(data: string): void;
|
|
244
|
-
/**
|
|
245
|
-
* 发送二进制消息
|
|
246
|
-
* @param data 二进制消息内容
|
|
247
|
-
*/
|
|
248
|
-
sendBinary(data: ArrayBuffer): void;
|
|
249
|
-
/**
|
|
250
|
-
* 设置打开回调
|
|
251
|
-
* @param callback 打开回调函数
|
|
252
|
-
*/
|
|
253
|
-
onOpen(callback: () => void): void;
|
|
254
|
-
/**
|
|
255
|
-
* 设置关闭回调
|
|
256
|
-
* @param callback 关闭回调函数
|
|
257
|
-
*/
|
|
258
|
-
onClose(callback: () => void): void;
|
|
259
|
-
/**
|
|
260
|
-
* 设置文本消息回调
|
|
261
|
-
* @param callback 文本消息回调函数
|
|
262
|
-
*/
|
|
263
|
-
onText(callback: (data: string) => void): void;
|
|
264
|
-
/**
|
|
265
|
-
* 设置二进制消息回调
|
|
266
|
-
* @param callback 二进制消息回调函数
|
|
267
|
-
*/
|
|
268
|
-
onBinary(callback: (data: ArrayBuffer) => void): void;
|
|
269
|
-
/**
|
|
270
|
-
* 设置错误回调
|
|
271
|
-
* @param callback 错误回调函数
|
|
272
|
-
*/
|
|
273
|
-
onError(callback: (error: string) => void): void;
|
|
274
|
-
/**
|
|
275
|
-
* 设置连接超时时间
|
|
276
|
-
* @param timeout 超时时间,单位秒
|
|
277
|
-
*/
|
|
278
|
-
setConnectionTimeout(timeout: number): void;
|
|
279
|
-
/**
|
|
280
|
-
* 设置写入超时时间
|
|
281
|
-
* @param timeout 超时时间,单位秒
|
|
282
|
-
*/
|
|
283
|
-
setWriteTimeout(timeout: number): void;
|
|
284
|
-
/**
|
|
285
|
-
* 设置心跳间隔时间
|
|
286
|
-
* @param interval 间隔时间,单位秒
|
|
287
|
-
* @param callback 心跳回调函数
|
|
288
|
-
*/
|
|
289
|
-
startHeartbeatInterval(interval: number, callback: () => string): void;
|
|
290
|
-
/**
|
|
291
|
-
* 停止心跳间隔
|
|
292
|
-
*/
|
|
293
|
-
stopHeartbeatInterval(): void;
|
|
294
|
-
/**
|
|
295
|
-
* 设置自动重连
|
|
296
|
-
* @param autoReconnect 是否自动重连
|
|
297
|
-
*/
|
|
298
|
-
setAutoReconnect(autoReconnect: boolean): void;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* HTTP模块 包含发送HTTP请求、下载文件等功能、websocket等功能
|
|
3
|
+
*/
|
|
4
|
+
declare namespace http {
|
|
5
|
+
/**
|
|
6
|
+
* 通用发送HTTP请求
|
|
7
|
+
* @param params 请求参数
|
|
8
|
+
* @returns 请求结果
|
|
9
|
+
* @example
|
|
10
|
+
* http.request({
|
|
11
|
+
* url: "https://www.baidu.com",
|
|
12
|
+
* method: "GET",
|
|
13
|
+
* })
|
|
14
|
+
*/
|
|
15
|
+
function request(params: {
|
|
16
|
+
/**
|
|
17
|
+
* 请求地址
|
|
18
|
+
*/
|
|
19
|
+
url: string;
|
|
20
|
+
/**
|
|
21
|
+
* 请求超时时间
|
|
22
|
+
*/
|
|
23
|
+
timeout?: number;
|
|
24
|
+
/**
|
|
25
|
+
* 请求方法 GET POST PUT DELETE PATCH HEAD OPTIONS
|
|
26
|
+
*/
|
|
27
|
+
method?: string;
|
|
28
|
+
/**
|
|
29
|
+
* 代理服务器
|
|
30
|
+
*/
|
|
31
|
+
proxy?: {
|
|
32
|
+
/**
|
|
33
|
+
* 代理服务器地址
|
|
34
|
+
*/
|
|
35
|
+
host: string;
|
|
36
|
+
/**
|
|
37
|
+
* 代理服务器端口
|
|
38
|
+
*/
|
|
39
|
+
port: number;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 是否跟随重定向
|
|
43
|
+
*/
|
|
44
|
+
followRedirects?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 请求体 仅在POST方法下有效 json 需要进行JSON.stringify
|
|
47
|
+
*/
|
|
48
|
+
requestBody?: string;
|
|
49
|
+
/**
|
|
50
|
+
* 请求头
|
|
51
|
+
*/
|
|
52
|
+
userAgent?: string;
|
|
53
|
+
/**
|
|
54
|
+
* 是否忽略内容类型
|
|
55
|
+
*/
|
|
56
|
+
ignoreContentType?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 是否忽略HTTP错误
|
|
59
|
+
*/
|
|
60
|
+
ignoreHttpErrors?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* 最大响应体大小 默认 10MB
|
|
63
|
+
*/
|
|
64
|
+
maxBodySize?: number;
|
|
65
|
+
/**
|
|
66
|
+
* 引用来源
|
|
67
|
+
*/
|
|
68
|
+
referrer?: string;
|
|
69
|
+
/**
|
|
70
|
+
* 请求头
|
|
71
|
+
*/
|
|
72
|
+
header?: Record<string, string>;
|
|
73
|
+
/**
|
|
74
|
+
* Cookie
|
|
75
|
+
*/
|
|
76
|
+
cookie?: Record<string, string>;
|
|
77
|
+
/**
|
|
78
|
+
* 请求参数
|
|
79
|
+
*/
|
|
80
|
+
data?: Record<string, any>;
|
|
81
|
+
/**
|
|
82
|
+
* 请求文件
|
|
83
|
+
*/
|
|
84
|
+
file?: Record<string, string>;
|
|
85
|
+
/**
|
|
86
|
+
* 响应字符集
|
|
87
|
+
*/
|
|
88
|
+
responseCharset?: string;
|
|
89
|
+
}): {
|
|
90
|
+
/**
|
|
91
|
+
* 响应头
|
|
92
|
+
*/
|
|
93
|
+
header: Record<string, string>;
|
|
94
|
+
/**
|
|
95
|
+
* 响应Cookie
|
|
96
|
+
*/
|
|
97
|
+
cookie: Record<string, string>;
|
|
98
|
+
/**
|
|
99
|
+
* 响应状态码
|
|
100
|
+
*/
|
|
101
|
+
statusCode: number;
|
|
102
|
+
/**
|
|
103
|
+
* 响应状态消息
|
|
104
|
+
*/
|
|
105
|
+
statusMessage: string;
|
|
106
|
+
/**
|
|
107
|
+
* 响应字符集
|
|
108
|
+
*/
|
|
109
|
+
charset: string;
|
|
110
|
+
/**
|
|
111
|
+
* 响应内容类型
|
|
112
|
+
*/
|
|
113
|
+
contentType: string;
|
|
114
|
+
/**
|
|
115
|
+
* 响应体
|
|
116
|
+
*/
|
|
117
|
+
body: string;
|
|
118
|
+
} | null;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 下载文件 支持断点续传
|
|
122
|
+
* @param url 请求地址
|
|
123
|
+
* @param file 文件路径
|
|
124
|
+
* @param timeout 超时时间
|
|
125
|
+
* @param headers 请求头
|
|
126
|
+
* @returns 下载是否成功
|
|
127
|
+
* @example
|
|
128
|
+
* http.downloadFile("https://www.baidu.com", "baidu.html")
|
|
129
|
+
*/
|
|
130
|
+
function downloadFile(
|
|
131
|
+
url: string,
|
|
132
|
+
file: string,
|
|
133
|
+
timeout?: number,
|
|
134
|
+
headers?: Record<string, string>
|
|
135
|
+
): boolean;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 发送GET请求
|
|
139
|
+
* @param url 请求地址
|
|
140
|
+
* @param params 请求参数
|
|
141
|
+
* @param timeout 超时时间
|
|
142
|
+
* @param headers 请求头
|
|
143
|
+
* @returns 请求结果
|
|
144
|
+
* @example
|
|
145
|
+
* http.httpGet("https://www.baidu.com")
|
|
146
|
+
*/
|
|
147
|
+
function httpGet(
|
|
148
|
+
url: string,
|
|
149
|
+
params?: Record<string, string>,
|
|
150
|
+
timeout?: number,
|
|
151
|
+
headers?: Record<string, string>
|
|
152
|
+
): string | null;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 发送POST请求
|
|
156
|
+
* @param url 请求地址
|
|
157
|
+
* @param params 请求参数
|
|
158
|
+
* @param files 请求文件
|
|
159
|
+
* @param timeout 超时时间
|
|
160
|
+
* @param headers 请求头
|
|
161
|
+
* @returns 请求结果
|
|
162
|
+
* @example
|
|
163
|
+
* http.httpPost("https://www.baidu.com")
|
|
164
|
+
*/
|
|
165
|
+
function httpPost(
|
|
166
|
+
url: string,
|
|
167
|
+
params?: Record<string, string>,
|
|
168
|
+
files?: Record<string, string>,
|
|
169
|
+
timeout?: number,
|
|
170
|
+
headers?: Record<string, string>
|
|
171
|
+
): string | null;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 发送JSON请求
|
|
175
|
+
* @param url 请求地址
|
|
176
|
+
* @param json 请求JSON数据
|
|
177
|
+
* @param timeout 超时时间
|
|
178
|
+
* @param headers 请求头
|
|
179
|
+
* @returns 请求结果
|
|
180
|
+
* @example
|
|
181
|
+
* http.postJSON("https://www.baidu.com", {
|
|
182
|
+
* "name": "快点JS",
|
|
183
|
+
* "version": "1.0.0"
|
|
184
|
+
* })
|
|
185
|
+
*/
|
|
186
|
+
function postJSON(
|
|
187
|
+
url: string,
|
|
188
|
+
json?: Record<string, any>,
|
|
189
|
+
timeout?: number,
|
|
190
|
+
headers?: Record<string, string>
|
|
191
|
+
): string | null;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* 创建WebSocket连接
|
|
195
|
+
* @param url 连接地址
|
|
196
|
+
* @param header 连接头
|
|
197
|
+
* @returns WebSocket连接对象
|
|
198
|
+
* @example
|
|
199
|
+
* const ws = http.newWebsocket("ws://www.baidu.com")
|
|
200
|
+
* ws.connect()
|
|
201
|
+
* ws.onText((data) => {
|
|
202
|
+
* logi(data)
|
|
203
|
+
* })
|
|
204
|
+
* ws.sendText("hello")
|
|
205
|
+
* ws.close()
|
|
206
|
+
*/
|
|
207
|
+
function newWebsocket(
|
|
208
|
+
url: string,
|
|
209
|
+
header?: Record<string, string>
|
|
210
|
+
): WebSocket;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* WebSocket连接
|
|
214
|
+
*/
|
|
215
|
+
interface WebSocket {
|
|
216
|
+
/**
|
|
217
|
+
* 连接WebSocket服务器
|
|
218
|
+
*/
|
|
219
|
+
connect(): void;
|
|
220
|
+
/**
|
|
221
|
+
* 关闭WebSocket连接
|
|
222
|
+
*/
|
|
223
|
+
close(): void;
|
|
224
|
+
/**
|
|
225
|
+
* 重置WebSocket连接
|
|
226
|
+
* @returns 重置是否成功
|
|
227
|
+
*/
|
|
228
|
+
reset(): boolean;
|
|
229
|
+
/**
|
|
230
|
+
* 获取WebSocket是否已关闭
|
|
231
|
+
* @returns 是否已关闭
|
|
232
|
+
*/
|
|
233
|
+
isClosed(): boolean;
|
|
234
|
+
/**
|
|
235
|
+
* 获取WebSocket是否已连接
|
|
236
|
+
* @returns 是否已连接
|
|
237
|
+
*/
|
|
238
|
+
isConnected(): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* 发送文本消息
|
|
241
|
+
* @param data 文本消息内容
|
|
242
|
+
*/
|
|
243
|
+
sendText(data: string): void;
|
|
244
|
+
/**
|
|
245
|
+
* 发送二进制消息
|
|
246
|
+
* @param data 二进制消息内容
|
|
247
|
+
*/
|
|
248
|
+
sendBinary(data: ArrayBuffer): void;
|
|
249
|
+
/**
|
|
250
|
+
* 设置打开回调
|
|
251
|
+
* @param callback 打开回调函数
|
|
252
|
+
*/
|
|
253
|
+
onOpen(callback: () => void): void;
|
|
254
|
+
/**
|
|
255
|
+
* 设置关闭回调
|
|
256
|
+
* @param callback 关闭回调函数
|
|
257
|
+
*/
|
|
258
|
+
onClose(callback: () => void): void;
|
|
259
|
+
/**
|
|
260
|
+
* 设置文本消息回调
|
|
261
|
+
* @param callback 文本消息回调函数
|
|
262
|
+
*/
|
|
263
|
+
onText(callback: (data: string) => void): void;
|
|
264
|
+
/**
|
|
265
|
+
* 设置二进制消息回调
|
|
266
|
+
* @param callback 二进制消息回调函数
|
|
267
|
+
*/
|
|
268
|
+
onBinary(callback: (data: ArrayBuffer) => void): void;
|
|
269
|
+
/**
|
|
270
|
+
* 设置错误回调
|
|
271
|
+
* @param callback 错误回调函数
|
|
272
|
+
*/
|
|
273
|
+
onError(callback: (error: string) => void): void;
|
|
274
|
+
/**
|
|
275
|
+
* 设置连接超时时间
|
|
276
|
+
* @param timeout 超时时间,单位秒
|
|
277
|
+
*/
|
|
278
|
+
setConnectionTimeout(timeout: number): void;
|
|
279
|
+
/**
|
|
280
|
+
* 设置写入超时时间
|
|
281
|
+
* @param timeout 超时时间,单位秒
|
|
282
|
+
*/
|
|
283
|
+
setWriteTimeout(timeout: number): void;
|
|
284
|
+
/**
|
|
285
|
+
* 设置心跳间隔时间
|
|
286
|
+
* @param interval 间隔时间,单位秒
|
|
287
|
+
* @param callback 心跳回调函数
|
|
288
|
+
*/
|
|
289
|
+
startHeartbeatInterval(interval: number, callback: () => string): void;
|
|
290
|
+
/**
|
|
291
|
+
* 停止心跳间隔
|
|
292
|
+
*/
|
|
293
|
+
stopHeartbeatInterval(): void;
|
|
294
|
+
/**
|
|
295
|
+
* 设置自动重连
|
|
296
|
+
* @param autoReconnect 是否自动重连
|
|
297
|
+
*/
|
|
298
|
+
setAutoReconnect(autoReconnect: boolean): void;
|
|
299
|
+
}
|
|
300
|
+
}
|
package/types/image.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ declare namespace image {
|
|
|
29
29
|
x: number,
|
|
30
30
|
y: number,
|
|
31
31
|
ex: number,
|
|
32
|
-
ey: number
|
|
32
|
+
ey: number,
|
|
33
33
|
): string | null;
|
|
34
34
|
/**
|
|
35
35
|
* 保存图片
|
|
@@ -123,7 +123,7 @@ declare namespace image {
|
|
|
123
123
|
function cmpColor(
|
|
124
124
|
imageId: string,
|
|
125
125
|
points: string,
|
|
126
|
-
threshold: number
|
|
126
|
+
threshold: number,
|
|
127
127
|
): boolean;
|
|
128
128
|
/**
|
|
129
129
|
* 查找颜色
|
|
@@ -156,7 +156,7 @@ declare namespace image {
|
|
|
156
156
|
ex: number,
|
|
157
157
|
ey: number,
|
|
158
158
|
limit: number,
|
|
159
|
-
orz: number
|
|
159
|
+
orz: number,
|
|
160
160
|
): { x: number; y: number }[];
|
|
161
161
|
/**
|
|
162
162
|
* 查找多颜色
|
|
@@ -191,7 +191,7 @@ declare namespace image {
|
|
|
191
191
|
ex: number,
|
|
192
192
|
ey: number,
|
|
193
193
|
limit: number,
|
|
194
|
-
orz: number
|
|
194
|
+
orz: number,
|
|
195
195
|
): { x: number; y: number }[];
|
|
196
196
|
/**
|
|
197
197
|
* 统计颜色数量
|
|
@@ -213,7 +213,7 @@ declare namespace image {
|
|
|
213
213
|
x: number,
|
|
214
214
|
y: number,
|
|
215
215
|
ex: number,
|
|
216
|
-
ey: number
|
|
216
|
+
ey: number,
|
|
217
217
|
): number;
|
|
218
218
|
/**
|
|
219
219
|
* 查找图片
|
|
@@ -227,6 +227,8 @@ declare namespace image {
|
|
|
227
227
|
* @param limit 限制数量
|
|
228
228
|
* @param method 方法
|
|
229
229
|
* @param rgb 是否使用RGB找图,默认false
|
|
230
|
+
* @param options 选项
|
|
231
|
+
* @param options.scaleFactors 缩放匹配法缩放因子数组,默认[1.0, 0.9, 1.1, 0.8, 1.2]
|
|
230
232
|
* @returns 图片数组
|
|
231
233
|
* @example
|
|
232
234
|
* const points = image.findImage("screen", "template.jpg", 0, 0, 100, 100, 0.9, 1, 5, false)
|
|
@@ -244,7 +246,10 @@ declare namespace image {
|
|
|
244
246
|
threshold: number,
|
|
245
247
|
limit: number,
|
|
246
248
|
method: number,
|
|
247
|
-
rgb?: boolean
|
|
249
|
+
rgb?: boolean,
|
|
250
|
+
options?: {
|
|
251
|
+
scaleFactors?: number[];
|
|
252
|
+
},
|
|
248
253
|
): {
|
|
249
254
|
index: number;
|
|
250
255
|
x: number;
|
|
@@ -280,7 +285,7 @@ declare namespace image {
|
|
|
280
285
|
x: number,
|
|
281
286
|
y: number,
|
|
282
287
|
ex: number,
|
|
283
|
-
ey: number
|
|
288
|
+
ey: number,
|
|
284
289
|
): string | null;
|
|
285
290
|
/**
|
|
286
291
|
* 获取图片像素
|
|
@@ -370,7 +375,7 @@ declare namespace image {
|
|
|
370
375
|
function toBase64Format(
|
|
371
376
|
imageId: string,
|
|
372
377
|
format: string,
|
|
373
|
-
q: number
|
|
378
|
+
q: number,
|
|
374
379
|
): string | null;
|
|
375
380
|
/**
|
|
376
381
|
* 扫描条码 支持一维码和二维码
|
|
@@ -410,6 +415,6 @@ declare namespace image {
|
|
|
410
415
|
ex: number,
|
|
411
416
|
ey: number,
|
|
412
417
|
color: string,
|
|
413
|
-
thickness: number
|
|
418
|
+
thickness: number,
|
|
414
419
|
): void;
|
|
415
420
|
}
|