ms-vite-plugin 1.4.49 → 1.4.51

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.
Files changed (42) hide show
  1. package/dist/build.js +1 -1
  2. package/dist/cli.js +1 -1
  3. package/dist/mcp/doc-tools.js +1 -1
  4. package/dist/mcp/docs-service.js +1 -1
  5. package/dist/mcp/types.d.ts +1 -1
  6. package/dist/mcp/types.js +1 -1
  7. package/dist/project.js +1 -1
  8. package/docs/AGENTS.md +3 -2
  9. package/docs/SKILL.md +2 -1
  10. package/docs/apilua/action.md +1013 -0
  11. package/docs/apilua/appleocr.md +281 -0
  12. package/docs/apilua/cloud.md +183 -0
  13. package/docs/apilua/config.md +181 -0
  14. package/docs/apilua/cryptoUtils.md +253 -0
  15. package/docs/apilua/device.md +485 -0
  16. package/docs/apilua/dotocr.md +230 -0
  17. package/docs/apilua/file.md +554 -0
  18. package/docs/apilua/global.md +654 -0
  19. package/docs/apilua/hid.md +1126 -0
  20. package/docs/apilua/hotUpdate.md +167 -0
  21. package/docs/apilua/http.md +427 -0
  22. package/docs/apilua/image.md +1177 -0
  23. package/docs/apilua/ime.md +283 -0
  24. package/docs/apilua/logger.md +294 -0
  25. package/docs/apilua/media.md +283 -0
  26. package/docs/apilua/mysql.md +445 -0
  27. package/docs/apilua/netCard.md +224 -0
  28. package/docs/apilua/node.md +264 -0
  29. package/docs/apilua/opencv.md +870 -0
  30. package/docs/apilua/paddleocr.md +324 -0
  31. package/docs/apilua/pip.md +359 -0
  32. package/docs/apilua/system.md +686 -0
  33. package/docs/apilua/tomatoocr.md +461 -0
  34. package/docs/apilua/tts.md +330 -0
  35. package/docs/apilua/ui.md +1033 -0
  36. package/docs/apilua/utils.md +222 -0
  37. package/docs/apilua/yolo.md +324 -0
  38. package/docs/apilua/yolocls.md +276 -0
  39. package/docs/mcp-agent-description.md +5 -4
  40. package/docs/quick/vscode/createProject.md +84 -0
  41. package/docs/quick/vscode/packProject.md +17 -0
  42. package/package.json +2 -1
@@ -0,0 +1,167 @@
1
+ # 热更新模块 (HotUpdate)
2
+
3
+ 热更新模块提供了完整的应用热更新功能,支持检查更新、下载更新包、MD5 校验、对话框展示等核心功能。
4
+
5
+ ## 自动检查更新
6
+
7
+ 以下 api 功能给脚本启动时调用,检查是否有更新,有更新则下载更新包,下载完成后重启应用。
8
+
9
+ 即使脚本没有调用,程序仍会在启动时自动检查更新。
10
+
11
+ ## 类型定义
12
+
13
+ ### HotUpdateResult
14
+
15
+ 热更新检查结果接口。
16
+
17
+ ```lua
18
+ ---@class HotUpdateResult
19
+ ---@field needUpdate boolean
20
+ ---@field error string
21
+ ---@field data HotUpdateResponse
22
+ ```
23
+
24
+ **参数说明**
25
+
26
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
27
+ | ------------ | ----------------- | -------- | ------ | ------------------------------------------------ |
28
+ | `needUpdate` | boolean | 是 | - | 是否需要更新 |
29
+ | `error` | string | 否 | - | 错误信息(当检查失败时) |
30
+ | `data` | HotUpdateResponse | 否 | - | 服务器返回的更新数据(当 needUpdate 为 true 时) |
31
+
32
+ ### HotUpdateResponse
33
+
34
+ 服务器响应数据结构。
35
+
36
+ ```lua
37
+ ---@class HotUpdateResponse
38
+ ---@field download_url string
39
+ ---@field version number
40
+ ---@field download_timeout number
41
+ ---@field dialog boolean
42
+ ---@field msg string
43
+ ---@field force boolean
44
+ ---@field md5 string
45
+ ```
46
+
47
+ **参数说明**
48
+
49
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
50
+ | ------------------ | ------- | -------- | ------ | --------------------- |
51
+ | `download_url` | string | 是 | - | 新包的下载地址 |
52
+ | `version` | number | 是 | - | 新包的版本号 |
53
+ | `download_timeout` | number | 是 | - | 下载超时时间(秒) |
54
+ | `dialog` | boolean | 是 | - | 是否用对话框展示 |
55
+ | `msg` | string | 是 | - | 对话框消息 |
56
+ | `force` | boolean | 是 | - | 是否强制更新 |
57
+ | `md5` | string | 否 | - | 更新包 MD5 值(可选) |
58
+
59
+ ## API 参考
60
+
61
+ - 只有你需要代码检查更新,才需要调用 `checkUpdate` 方法
62
+
63
+ ### 更新管理
64
+
65
+ #### checkUpdate - 检查更新
66
+
67
+ ```lua
68
+ ---@return HotUpdateResult
69
+ function checkUpdate() end
70
+ ```
71
+
72
+ **返回值:**
73
+
74
+ | 类型 | 描述 |
75
+ | --------------- | ------------ |
76
+ | HotUpdateResult | 检查结果对象 |
77
+
78
+ **示例:**
79
+
80
+ ```lua
81
+ local hotupdate = require("hotupdate")
82
+ -- 检查更新
83
+ local result = hotupdate.checkUpdate()
84
+
85
+ if result.needUpdate then
86
+ print("发现新版本:", result.data.version)
87
+ print("更新消息:", result.data.msg)
88
+ local installResult = hotupdate.downloadAndInstall()
89
+ if installResult.updated then
90
+ print("更新安装成功")
91
+ else
92
+ print("更新安装失败:", installResult.error)
93
+ end
94
+ } else if result.error then
95
+ print("检查更新失败:", result.error)
96
+ else
97
+ print("已是最新版本")
98
+ end
99
+ ```
100
+
101
+ #### downloadAndInstall - 下载并安装更新
102
+
103
+ 下载并安装更新,安装完成后自动重启脚本。
104
+
105
+ ```lua
106
+ ---@return any
107
+ function downloadAndInstall() end
108
+ ```
109
+
110
+ **参数:**
111
+
112
+ - 无需参数,自动使用上次 `checkUpdate` 的结果
113
+
114
+ **返回值:**
115
+
116
+ | 参数名 | 类型 | 描述 |
117
+ | --------- | ------- | -------------------- |
118
+ | `updated` | boolean | 是否安装成功 |
119
+ | `error` | string | 安装失败时的错误信息 |
120
+
121
+ **示例:**
122
+
123
+ ```lua
124
+ local hotupdate = require("hotupdate")
125
+ -- 先检查更新,再手动下载安装
126
+ local result = hotupdate.checkUpdate()
127
+
128
+ if result.needUpdate then
129
+ local installResult = hotupdate.downloadAndInstall()
130
+ if installResult.updated then
131
+ print("更新安装成功,自动重启应用")
132
+ else
133
+ print("更新失败: " + installResult.error)
134
+ end
135
+ else
136
+ print("已是最新版本")
137
+ end
138
+ ```
139
+
140
+ ### 版本信息
141
+
142
+ #### getCurrentVersion - 获取当前版本号
143
+
144
+ ```lua
145
+ ---@return number
146
+ function getCurrentVersion() end
147
+ ```
148
+
149
+ **返回值:**
150
+
151
+ | 参数名 | 类型 | 描述 |
152
+ | --------- | ------ | ---------------------------------- |
153
+ | `version` | number | 当前应用版本号(仅支持整数版本号) |
154
+
155
+ **版本获取逻辑:**
156
+
157
+ - 从 `package.json` 文件读取 `appVersion` 字段
158
+ - 支持数字类型的 `appVersion`
159
+ - 如果获取不到则返回 0
160
+
161
+ **示例:**
162
+
163
+ ```lua
164
+ local hotupdate = require("hotupdate")
165
+ local version = hotupdate.getCurrentVersion()
166
+ print("当前版本:", version)
167
+ ```
@@ -0,0 +1,427 @@
1
+ # HTTP 模块 (HTTP)
2
+
3
+ HTTP 模块提供了完整的网络请求功能,包括 HTTP 请求、文件下载、WebSocket 连接等。
4
+
5
+ ## 通用 HTTP 请求
6
+
7
+ ### request - 发送通用 HTTP 请求,支持所有 HTTP 方法和完整的配置选项。
8
+
9
+ ```lua
10
+ ---@param params table
11
+ ---@return any
12
+ function request(params) end
13
+ ```
14
+
15
+ **参数:**
16
+
17
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
18
+ | ------------------- | ------- | -------- | -------- | --------------------------- |
19
+ | `url` | string | 是 | - | 请求地址 |
20
+ | `timeout` | number | 否 | 10000 | 请求超时时间(毫秒) |
21
+ | `method` | string | 否 | GET | 请求方法(GET、POST 等) |
22
+ | `proxy` | table | 否 | - | 代理服务器配置 |
23
+ | `followRedirects` | boolean | 否 | true | 是否跟随重定向 |
24
+ | `requestBody` | string \| string | 否 | - | 请求体,JSON 对象需先 ToJsonString |
25
+ | `userAgent` | string | 否 | - | 用户代理字符串 |
26
+ | `ignoreContentType` | boolean | 否 | false | 是否忽略内容类型 |
27
+ | `ignoreHttpErrors` | boolean | 否 | false | 是否忽略 HTTP 错误 |
28
+ | `maxBodySize` | number | 否 | 10485760 | 最大响应体大小(默认 10MB) |
29
+ | `referrer` | string | 否 | - | 引用来源 |
30
+ | `header` | table | 否 | - | 请求头 |
31
+ | `cookie` | table | 否 | - | Cookie |
32
+ | `data` | table | 否 | - | 请求参数 |
33
+ | `file` | table | 否 | - | 请求文件 |
34
+ | `responseCharset` | string | 否 | - | 响应字符集 |
35
+
36
+ **返回值:**
37
+
38
+ | 字段名 | 类型 | 描述 |
39
+ | --------------- | ------ | ------------- |
40
+ | `header` | table | 响应头 |
41
+ | `cookie` | table | 响应 Cookie |
42
+ | `statusCode` | number | HTTP 状态码 |
43
+ | `statusMessage` | string | HTTP 状态消息 |
44
+ | `charset` | string | 响应字符集 |
45
+ | `contentType` | string | 响应内容类型 |
46
+ | `body` | string | 响应体内容 |
47
+
48
+ **示例:**
49
+
50
+ ```lua
51
+ local http = require("http")
52
+ -- GET 请求
53
+ local response = http.request({
54
+ url = "https://api.example.com/users",
55
+ method = "GET",
56
+ timeout = 5000,
57
+ header = {
58
+ Authorization = "Bearer token123",
59
+ Accept = "application/json",
60
+ },
61
+ })
62
+
63
+ print("状态码: " .. tostring(response.statusCode))
64
+ print("响应体: " .. tostring(response.body))
65
+ -- POST 请求发送 JSON 数据
66
+ local postResponse = http.request({
67
+ url = "https://api.example.com/users",
68
+ method = "POST",
69
+ header = {
70
+ ["Content-Type"] = "application/json",
71
+ Authorization = "Bearer token123",
72
+ },
73
+ requestBody = ToJsonString({
74
+ name = "张三",
75
+ email = "zhangsan@example.com",
76
+ }),
77
+ })
78
+ -- 使用代理
79
+ local proxyResponse = http.request({
80
+ url = "https://api.example.com/data",
81
+ method = "GET",
82
+ proxy = {
83
+ host = "proxy.example.com",
84
+ port = 8080,
85
+ },
86
+ })
87
+ ```
88
+
89
+ ## 简化 HTTP 方法
90
+
91
+ ### httpGet - 发送 GET 请求的简化方法。
92
+
93
+ ```lua
94
+ ---@param url string
95
+ ---@param params table?
96
+ ---@param timeout number?
97
+ ---@param headers table?
98
+ ---@return string | nil
99
+ function httpGet(url, params, timeout, headers) end
100
+ ```
101
+
102
+ **参数:**
103
+
104
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
105
+ | --------- | ---------------------- | -------- | ------ | ---------------- |
106
+ | `url` | string | 是 | - | 请求地址 |
107
+ | `params` | table | 否 | - | URL 查询参数 |
108
+ | `timeout` | number | 否 | 10000 | 超时时间(毫秒) |
109
+ | `headers` | table | 否 | - | 请求头 |
110
+
111
+ **返回值:**
112
+
113
+ | 类型 | 描述 |
114
+ | -------- | ---------- |
115
+ | `string` | 响应体内容 |
116
+
117
+ **示例:**
118
+
119
+ ```lua
120
+ local http = require("http")
121
+ -- 简单 GET 请求
122
+ local html = http.httpGet("https://www.example.com")
123
+ print(html)
124
+ -- 带参数的 GET 请求
125
+ local result = http.httpGet(
126
+ "https://api.example.com/search",
127
+ { q = "快点JS", limit = "10" },
128
+ 5000,
129
+ { ["User-Agent"] = "快点JS/1.0" },
130
+ )
131
+ print("搜索结果: " .. tostring(result))
132
+ ```
133
+
134
+ ### httpPost - 发送 POST 请求的简化方法。
135
+
136
+ ```lua
137
+ ---@param url string
138
+ ---@param params table?
139
+ ---@param files table?
140
+ ---@param timeout number?
141
+ ---@param headers table?
142
+ ---@return string | nil
143
+ function httpPost(url, params, files, timeout, headers) end
144
+ ```
145
+
146
+ **参数:**
147
+
148
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
149
+ | --------- | ---------------------- | -------- | ------ | ---------------- |
150
+ | `url` | string | 是 | - | 请求地址 |
151
+ | `params` | table | 否 | - | 表单参数 |
152
+ | `files` | table | 否 | - | 文件参数 |
153
+ | `timeout` | number | 否 | 10000 | 超时时间(毫秒) |
154
+ | `headers` | table | 否 | - | 请求头 |
155
+
156
+ **返回值:**
157
+
158
+ | 类型 | 描述 |
159
+ | -------- | ---------- |
160
+ | `string` | 响应体内容 |
161
+
162
+ **示例:**
163
+
164
+ ```lua
165
+ local http = require("http")
166
+ -- 发送表单数据
167
+ local response = http.httpPost("https://api.example.com/submit", {
168
+ username = "admin",
169
+ password = "123456",
170
+ action = "login",
171
+ })
172
+ -- 上传文件
173
+ local uploadResponse = http.httpPost(
174
+ "https://api.example.com/upload",
175
+ { description = "测试文件" },
176
+ { file: "/path/to/file.txt" },
177
+ 10000,
178
+ )
179
+
180
+ print("上传结果: " .. tostring(ToJsonString(uploadResponse)))
181
+ ```
182
+
183
+ ### postJSON - 发送 JSON 数据的 POST 请求。
184
+
185
+ ```lua
186
+ ---@param url string
187
+ ---@param json table?
188
+ ---@param timeout number?
189
+ ---@param headers table?
190
+ ---@return string | nil
191
+ function postJSON(url, json, timeout, headers) end
192
+ ```
193
+
194
+ **参数:**
195
+
196
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
197
+ | --------- | ---------------------- | -------- | ------ | ---------------- |
198
+ | `url` | string | 是 | - | 请求地址 |
199
+ | `json` | table | 否 | - | JSON 数据 |
200
+ | `timeout` | number | 否 | 10000 | 超时时间(毫秒) |
201
+ | `headers` | table | 否 | - | 请求头 |
202
+
203
+ **返回值:**
204
+
205
+ | 类型 | 描述 |
206
+ | ------ | ---------- |
207
+ | string | 响应体内容 |
208
+
209
+ **示例:**
210
+
211
+ ```lua
212
+ local http = require("http")
213
+ -- 发送 JSON 数据
214
+ local response = http.postJSON(
215
+ "https://api.example.com/api/users",
216
+ {
217
+ name = "快点JS",
218
+ version = "1.0.0",
219
+ platform = "iOS",
220
+ },
221
+ 5000,
222
+ { Authorization = "Bearer token123" },
223
+ )
224
+ print("响应: " .. tostring(response))
225
+ ```
226
+
227
+ ## 文件下载
228
+
229
+ ### downloadFile - 下载文件到本地,支持断点续传。
230
+
231
+ ```lua
232
+ ---@param url string
233
+ ---@param file string
234
+ ---@param timeout number?
235
+ ---@param headers table?
236
+ ---@return boolean
237
+ function downloadFile(url, file, timeout, headers) end
238
+ ```
239
+
240
+ **参数:**
241
+
242
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
243
+ | --------- | ---------------------- | -------- | ------ | -------------------- |
244
+ | `url` | string | 是 | - | 文件下载地址 |
245
+ | `file` | string | 是 | - | 本地保存路径 |
246
+ | `timeout` | number | 否 | 10000 | 下载超时时间(毫秒) |
247
+ | `headers` | table | 否 | - | 请求头 |
248
+
249
+ **返回值:**
250
+
251
+ | 类型 | 描述 |
252
+ | --------- | ------------ |
253
+ | `boolean` | 下载是否成功 |
254
+
255
+ **示例:**
256
+
257
+ ```lua
258
+ local http = require("http")
259
+ local file = require("file")
260
+ local documentsDir = file.getInternalDir("documents")
261
+ -- 下载文件
262
+ local success = http.downloadFile(
263
+ "https://example.com/files/document.pdf",
264
+ documentsDir .. "/document.pdf",
265
+ 30000,
266
+ { ["User-Agent"] = "快点JS Downloader" }
267
+ )
268
+
269
+ if success then
270
+ print("文件下载成功")
271
+ else
272
+ print("文件下载失败")
273
+ end
274
+
275
+ -- 下载大文件
276
+ local function downloadLargeFile(url, filename)
277
+ print("开始下载: " .. tostring(filename))
278
+ local documentsDir = file.getInternalDir("documents")
279
+ local ok = http.downloadFile(url, documentsDir .. "/" .. filename, 60000)
280
+ if ok then
281
+ print("下载完成: " .. tostring(filename))
282
+ return true
283
+ end
284
+ print("下载失败: " .. tostring(filename))
285
+ return false
286
+ end
287
+
288
+ local files = {
289
+ { url = "https://example.com/file1.zip", name = "file1.zip" },
290
+ { url = "https://example.com/file2.zip", name = "file2.zip" },
291
+ }
292
+ for _, item in ipairs(files) do
293
+ downloadLargeFile(item.url, item.name)
294
+ end
295
+ ```
296
+
297
+ ## WebSocket 连接
298
+
299
+ ### newWebsocket - 创建 WebSocket 连接。
300
+
301
+ ```lua
302
+ ---@param url string
303
+ ---@param header table?
304
+ ---@return WebSocket
305
+ function newWebsocket(url, header) end
306
+ ```
307
+
308
+ **参数:**
309
+
310
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
311
+ | -------- | ------ | -------- | ------ | -------------------- |
312
+ | `url` | string | 是 | - | WebSocket 服务器地址 |
313
+ | `header` | table | 否 | - | 连接头 |
314
+
315
+ **返回值:**
316
+
317
+ | 类型 | 描述 |
318
+ | ----------- | ------------------ |
319
+ | `WebSocket` | WebSocket 连接对象 |
320
+
321
+ 对象方法用冒号调用,例如 `ws:connect()`。二进制收发使用 Base64 字符串。
322
+
323
+ ### WebSocket 接口方法
324
+
325
+ #### 连接管理
326
+
327
+ ```lua
328
+ ---@return nil
329
+ function connect() end
330
+ ---@return nil
331
+ function close() end
332
+ ---@return boolean
333
+ function reset() end
334
+ ---@return boolean
335
+ function isClosed() end
336
+ ---@return boolean
337
+ function isConnected() end
338
+ ```
339
+
340
+ #### 消息发送
341
+
342
+ ```lua
343
+ ---@param data string
344
+ function sendText(data) end
345
+ ---@param data string
346
+ function sendBinary(data) end
347
+ ```
348
+
349
+ #### 事件回调
350
+
351
+ ```lua
352
+ ---@param callback function
353
+ function onOpen(callback) end
354
+ ---@param callback function
355
+ function onClose(callback) end
356
+ ---@param callback function
357
+ function onText(callback) end
358
+ ---@param callback function
359
+ function onBinary(callback) end
360
+ ---@param callback function
361
+ function onError(callback) end
362
+ ```
363
+
364
+ #### 配置选项
365
+
366
+ ```lua
367
+ ---@param timeout number
368
+ function setConnectionTimeout(timeout) end
369
+ ---@param timeout number
370
+ function setWriteTimeout(timeout) end
371
+ ---@param autoReconnect boolean
372
+ function setAutoReconnect(autoReconnect) end
373
+ ---@param interval number
374
+ ---@param callback function?
375
+ function startHeartbeatInterval(interval, callback) end
376
+ function stopHeartbeatInterval() end
377
+ ```
378
+
379
+ **WebSocket 完整示例:**
380
+
381
+ ```lua
382
+ local http = require("http")
383
+
384
+ local function createWebSocketConnection()
385
+ local ws = http.newWebsocket("wss://echo.websocket.org", {
386
+ ["User-Agent"] = "快点JS/1.0",
387
+ })
388
+
389
+ ws:setConnectionTimeout(10)
390
+ ws:setWriteTimeout(5)
391
+ ws:setAutoReconnect(true)
392
+
393
+ ws:onOpen(function()
394
+ print("WebSocket 连接已打开")
395
+ ws:sendText(ToJsonString({
396
+ type = "greeting",
397
+ message = "Hello from 快点JS!",
398
+ timestamp = Time(),
399
+ }))
400
+ end)
401
+
402
+ ws:onText(function(data)
403
+ print("收到文本消息: " .. tostring(data))
404
+ end)
405
+
406
+ ws:onBinary(function(data)
407
+ print("收到二进制消息: " .. tostring(data))
408
+ end)
409
+
410
+ ws:onClose(function()
411
+ print("WebSocket 连接已关闭")
412
+ end)
413
+
414
+ ws:onError(function(error)
415
+ print("WebSocket 错误: " .. tostring(error))
416
+ end)
417
+
418
+ ws:startHeartbeatInterval(30, function()
419
+ return ToJsonString({ type = "ping", timestamp = Time() })
420
+ end)
421
+
422
+ ws:connect()
423
+ return ws
424
+ end
425
+
426
+ local websocket = createWebSocketConnection()
427
+ ```