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,222 @@
1
+ # 工具模块 (Utils)
2
+
3
+ 工具模块提供了一系列实用的工具函数,包括时间格式化、随机数生成、应用前台切换等常用功能。
4
+
5
+ ## 功能概览
6
+
7
+ - **时间处理**: 时间格式化功能
8
+ - **随机数生成**: 生成指定范围的随机数
9
+ - **应用控制**: 将应用切换到前台
10
+ - **编码转换**: 字符串编码与解码工具
11
+
12
+ ## API 参考
13
+
14
+ ### 时间处理
15
+
16
+ #### timeFormat - 格式化当前时间为指定格式的字符串。
17
+
18
+ ```lua
19
+ ---@param format string
20
+ ---@return string
21
+ function timeFormat(format) end
22
+ ```
23
+
24
+ **参数:**
25
+
26
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
27
+ | -------- | ------ | -------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
28
+ | `format` | string | 是 | | 时间格式化字符串 <br> `yyyy` - 四位年份 <br> `MM` - 两位月份<br> `dd` - 两位日期<br> `HH` - 两位小时(24 小时制)<br> `hh` - 两位小时(12 小时制)<br> `mm` - 两位分钟<br> `ss` - 两位秒数 |
29
+
30
+ **返回值:**
31
+
32
+ | 类型 | 描述 |
33
+ | -------- | -------------------- |
34
+ | `string` | 格式化后的时间字符串 |
35
+
36
+ **示例:**
37
+
38
+ ```lua
39
+ local utils = require("utils")
40
+
41
+ -- 标准日期时间格式
42
+ local dateTime = utils.timeFormat("yyyy-MM-dd HH:mm:ss")
43
+ print(dateTime) -- 输出: 2024-01-15 14:30:25
44
+
45
+ -- 仅日期格式
46
+ local date = utils.timeFormat("yyyy-MM-dd")
47
+ print(date) -- 输出: 2024-01-15
48
+
49
+ -- 仅时间格式
50
+ local time = utils.timeFormat("HH:mm:ss")
51
+ print(time) -- 输出: 14:30:25
52
+
53
+ -- 自定义分隔符
54
+ local customFormat = utils.timeFormat("yyyy/MM/dd HH:mm")
55
+ print(customFormat) -- 输出: 2024/01/15 14:30
56
+
57
+ -- 紧凑格式
58
+ local compact = utils.timeFormat("yyyyMMddHHmmss")
59
+ print(compact) -- 输出: 20240115143025
60
+ ```
61
+
62
+ ### 随机数生成
63
+
64
+ #### random - 生成指定范围内的随机整数。
65
+
66
+ ```lua
67
+ ---@param min number
68
+ ---@param max number
69
+ ---@return number
70
+ function random(min, max) end
71
+ ```
72
+
73
+ **参数:**
74
+
75
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
76
+ | ------ | ------ | -------- | ------ | -------------- |
77
+ | `min` | number | 是 | | 最小值(包含) |
78
+ | `max` | number | 是 | | 最大值(包含) |
79
+
80
+ **返回值:**
81
+
82
+ | 类型 | 描述 |
83
+ | -------- | -------------------- |
84
+ | `number` | 指定范围内的随机整数 |
85
+
86
+ **示例:**
87
+
88
+ ```lua
89
+ local utils = require("utils")
90
+
91
+ -- 生成1-10之间的随机数
92
+ local randomNum = utils.random(1, 10)
93
+ print("随机数: " .. tostring(randomNum))
94
+
95
+ -- 生成0-100之间的随机数
96
+ local percentage = utils.random(0, 100)
97
+ print("随机百分比: " .. tostring(percentage))
98
+
99
+ -- 生成随机延迟时间(毫秒)
100
+ local delay = utils.random(1000, 5000)
101
+ print("随机延迟: " .. tostring(delay) .. " 毫秒")
102
+ Sleep(delay)
103
+
104
+ -- 生成随机索引
105
+ local array = { "apple", "banana", "orange", "grape" }
106
+ local randomIndex = utils.random(1, #array)
107
+ print("随机选择: " .. array[randomIndex])
108
+ ```
109
+
110
+ ### 应用控制
111
+
112
+ #### takeMeToFront - 将快点 JS 应用切换到前台显示。
113
+
114
+ **注意事项**
115
+
116
+ - 此模块仅支持 快点 Agent 模式使用
117
+
118
+ ```lua
119
+ ---@return boolean
120
+ function takeMeToFront() end
121
+ ```
122
+
123
+ **示例:**
124
+
125
+ ```lua
126
+ local utils = require("utils")
127
+
128
+ -- 将应用切换到前台
129
+ utils.takeMeToFront()
130
+ print("应用已切换到前台")
131
+ ```
132
+
133
+ ### 编码转换
134
+
135
+ #### randomUUID - 生成随机 UUID。
136
+
137
+ ```lua
138
+ ---@return string
139
+ function randomUUID() end
140
+ ```
141
+
142
+ **示例:**
143
+
144
+ ```lua
145
+ local utils = require("utils")
146
+ print(utils.randomUUID())
147
+ ```
148
+
149
+ #### hexString - 字符串转 Hex 字符串。
150
+
151
+ ```lua
152
+ ---@param source string
153
+ ---@return string
154
+ function hexString(source) end
155
+ ```
156
+
157
+ **示例:**
158
+
159
+ ```lua
160
+ local utils = require("utils")
161
+ print(utils.hexString("hello"))
162
+ ```
163
+
164
+ #### base64Encoded - 字符串转 Base64。
165
+
166
+ ```lua
167
+ ---@param source string
168
+ ---@return string
169
+ function base64Encoded(source) end
170
+ ```
171
+
172
+ **示例:**
173
+
174
+ ```lua
175
+ local utils = require("utils")
176
+ print(utils.base64Encoded("hello"))
177
+ ```
178
+
179
+ #### base64Decoded - Base64 转字符串。
180
+
181
+ ```lua
182
+ ---@param source string
183
+ ---@return string
184
+ function base64Decoded(source) end
185
+ ```
186
+
187
+ **示例:**
188
+
189
+ ```lua
190
+ local utils = require("utils")
191
+ print(utils.base64Decoded("aGVsbG8="))
192
+ ```
193
+
194
+ #### hexStringBase64Encoded - 16 进制字符串转 Base64。
195
+
196
+ ```lua
197
+ ---@param hexString string
198
+ ---@return string
199
+ function hexStringBase64Encoded(hexString) end
200
+ ```
201
+
202
+ **示例:**
203
+
204
+ ```lua
205
+ local utils = require("utils")
206
+ print(utils.hexStringBase64Encoded("68656c6c6f"))
207
+ ```
208
+
209
+ #### hexStringBase64Decoded - Base64 转 16 进制字符串。
210
+
211
+ ```lua
212
+ ---@param base64HexString string
213
+ ---@return string
214
+ function hexStringBase64Decoded(base64HexString) end
215
+ ```
216
+
217
+ **示例:**
218
+
219
+ ```lua
220
+ local utils = require("utils")
221
+ print(utils.hexStringBase64Decoded("aGVsbG8="))
222
+ ```
@@ -0,0 +1,324 @@
1
+ # YOLO 目标检测模块 (YOLO)
2
+
3
+ YOLO 模块基于 YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能的实时目标检测功能,支持多种输入源和自定义模型,可用于物体识别、位置定位等应用场景。
4
+
5
+ ## 数据标注
6
+
7
+ 查看 [快点 Label](../label/dataAnnotation.md) 了解如何进行数据标注
8
+
9
+ ## 功能概览
10
+
11
+ - **模型管理**: YOLO 模型加载和资源管理
12
+ - **目标检测**: 实时物体检测和位置识别
13
+ - **多源输入**: 支持屏幕截图、图片文件、URL 等多种输入源
14
+ - **结果处理**: 完整的检测结果信息和坐标数据
15
+ - **资源控制**: 完整的模型生命周期管理
16
+
17
+ ## 测试结果
18
+
19
+ | 设备型号 | 模型类型 | 检测耗时 |
20
+ | ---------- | ---------------- | --------- |
21
+ | iPhoneX | yolov8n(80 类别) | 70-100ms |
22
+ | iPhoneX | yolov8s(80 类别) | 160-200ms |
23
+ | iPhone SE3 | yolov8n(80 类别) | 30-50ms |
24
+ | iPhone SE3 | yolov8s(80 类别) | 70-100ms |
25
+
26
+ ## 数据类型
27
+
28
+ ### YoloResult
29
+
30
+ YOLO 检测结果接口,包含检测到的物体的完整信息。
31
+
32
+ ```lua
33
+ ---@class YoloResult
34
+ ---@field x number 检测框的左上角x坐标
35
+ ---@field y number 检测框的左上角y坐标
36
+ ---@field ex number 检测框的右下角x坐标
37
+ ---@field ey number 检测框的右下角y坐标
38
+ ---@field centerX number 检测框的中心点x坐标
39
+ ---@field centerY number 检测框的中心点y坐标
40
+ ---@field width number 检测框的宽度
41
+ ---@field height number 检测框的高度
42
+ ---@field confidence number 检测框的置信度 (0-1)
43
+ ---@field classId number 检测框的类别ID
44
+ ```
45
+
46
+ **字段说明:**
47
+
48
+ | 字段名 | 类型 | 描述 |
49
+ | ------------------ | ------ | ------------------------------------------ |
50
+ | `x, y` | number | 检测框左上角坐标 |
51
+ | `ex, ey` | number | 检测框右下角坐标 |
52
+ | `centerX, centerY` | number | 检测框中心点坐标 |
53
+ | `width, height` | number | 检测框尺寸 |
54
+ | `confidence` | number | 检测置信度,范围 0-1,值越高表示检测越可靠 |
55
+ | `classId` | number | 物体类别 ID,对应训练模型的类别标签 |
56
+
57
+ ## API 参考
58
+
59
+ ### 模型管理
60
+
61
+ #### load - 加载 YOLO 模型(支持版本 8/11/26)。
62
+
63
+ 加载模型是使用目标检测功能的前提。
64
+
65
+ ```lua
66
+ ---@param paramPath string
67
+ ---@param binPath string
68
+ ---@param nc number?
69
+ ---@param version number?
70
+ ---@param useGpu boolean?
71
+ ---@return string|nil
72
+ function load(paramPath, binPath, nc, version, useGpu) end
73
+ ```
74
+
75
+ **参数:**
76
+
77
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
78
+ | ----------- | ------- | -------- | ------ | --------------------------------------------------------------------------- |
79
+ | `paramPath` | string | 是 | | NCNN 模型的 param 文件绝对路径 |
80
+ | `binPath` | string | 是 | | NCNN 模型的 bin 文件绝对路径 |
81
+ | `nc` | number | 否 | 0 | 模型的标签数量;传 `0` 或省略时根据模型输出自动推断,显式传入但不匹配时检测返回空数组 |
82
+ | `version` | number | 否 | 0 | 模型版本;传 `0` 或省略时按 v11 处理,显式传入支持 8/11/26 |
83
+ | `useGpu` | boolean | 否 | false | 是否启用 GPU 加速 |
84
+
85
+ **返回值:**
86
+
87
+ | 类型 | 描述 |
88
+ | --------------- | ----------------------------------------- |
89
+ | `string \| nil` | 加载成功返回模型 ID 字符串,失败返回 nil |
90
+
91
+ **示例:**
92
+
93
+ ```lua
94
+ local yolo = require("yolo")
95
+ local modelId = yolo.load(
96
+ "yolov8n_ncnn_model/model.ncnn.param",
97
+ "yolov8n_ncnn_model/model.ncnn.bin",
98
+ 0,
99
+ 8,
100
+ false
101
+ )
102
+ ```
103
+
104
+ #### loadV11 - 加载 YOLO 模型。
105
+
106
+ 加载模型是使用目标检测功能的前提。兼容 YOLOV8 / YOLO11 的 NCNN 模型。
107
+
108
+ ```lua
109
+ ---@param paramPath string
110
+ ---@param binPath string
111
+ ---@param nc number?
112
+ ---@param useGpu boolean?
113
+ ---@return string|nil
114
+ function loadV11(paramPath, binPath, nc, useGpu) end
115
+ ```
116
+
117
+ **参数:**
118
+
119
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
120
+ | ----------- | ------- | -------- | ------ | --------------------------------------------------------------------------- |
121
+ | `paramPath` | string | 是 | | NCNN 模型的 param 文件绝对路径 |
122
+ | `binPath` | string | 是 | | NCNN 模型的 bin 文件绝对路径 |
123
+ | `nc` | number | 否 | 0 | 模型的标签数量;传 `0` 或省略时根据模型输出自动推断,显式传入但不匹配时检测返回空数组 |
124
+ | `useGpu` | boolean | 否 | false | 是否启用 GPU 加速 |
125
+
126
+ **返回值:**
127
+
128
+ | 类型 | 描述 |
129
+ | --------------- | ----------------------------------------- |
130
+ | `string \| nil` | 加载成功返回模型 ID 字符串,失败返回 nil |
131
+
132
+ **示例:**
133
+
134
+ ```lua
135
+ local yolo = require("yolo")
136
+
137
+ -- 加载 YOLO 模型
138
+ local modelId = yolo.loadV11(
139
+ "yolo11n_ncnn_model/model.ncnn.param",
140
+ "yolo11n_ncnn_model/model.ncnn.bin",
141
+ 0,
142
+ false
143
+ )
144
+ ```
145
+
146
+ ### 目标检测
147
+
148
+ #### detect - 对输入图像执行目标检测。
149
+
150
+ 执行目标检测,识别图像中的物体并返回检测结果。
151
+
152
+ ```lua
153
+ ---@param modelId string
154
+ ---@param img string
155
+ ---@param targetSize number?
156
+ ---@param threshold number?
157
+ ---@param nmsThreshold number?
158
+ ---@return YoloResult[]
159
+ function detect(modelId, img, targetSize, threshold, nmsThreshold) end
160
+ ```
161
+
162
+ **参数:**
163
+
164
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
165
+ | -------------- | ------ | -------- | ------ | ------------------------------------------------------------------ |
166
+ | `modelId` | string | 是 | | 模型 ID,通过 `loadV11` 获取 |
167
+ | `img` | string | 是 | | 图像输入源,支持 `"screen"`、图片文件路径、HTTP 图片地址或 imageId |
168
+ | `targetSize` | number | 否 | 640 | 模型推理输入边长,通常为 640(与模型训练时一致) |
169
+ | `threshold` | number | 否 | 0.4 | 置信度阈值,低于此值的检测结果会被过滤 |
170
+ | `nmsThreshold` | number | 否 | 0.5 | 非极大值抑制阈值,用于去除重叠检测框 |
171
+
172
+ **返回值:**
173
+
174
+ | 类型 | 描述 |
175
+ | -------------- | -------------- |
176
+ | `YoloResult[]` | 检测结果数组 |
177
+
178
+ **示例:**
179
+
180
+ ```lua
181
+ local yolo = require("yolo")
182
+
183
+ -- 首先加载模型
184
+ local modelId = yolo.loadV11(
185
+ "/yolo11n_ncnn_model/model.ncnn.param",
186
+ "/yolo11n_ncnn_model/model.ncnn.bin",
187
+ 0,
188
+ false
189
+ )
190
+
191
+ if not modelId then
192
+ print("模型加载失败")
193
+ return
194
+ end
195
+
196
+ -- 检测当前屏幕
197
+ local screenResults = yolo.detect(modelId, "screen", 640, 0.4, 0.5)
198
+ print("屏幕检测到 " .. tostring(#screenResults) .. " 个物体")
199
+
200
+ for index, result in ipairs(screenResults) do
201
+ print("物体 " .. tostring(index) .. ":")
202
+ print(" 类别ID: " .. tostring(result.classId))
203
+ print(" 置信度: " .. tostring(result.confidence * 100) .. "%")
204
+ print(" 边界框: (" .. tostring(result.x) .. ", " .. tostring(result.y) .. ", " .. tostring(result.ex) .. ", " .. tostring(result.ey) .. ")")
205
+ print(" 中心点: (" .. tostring(result.centerX) .. ", " .. tostring(result.centerY) .. ")")
206
+ print(" 尺寸: " .. tostring(result.width) .. " x " .. tostring(result.height))
207
+ end
208
+
209
+ -- 检测图片文件
210
+ local imageResults = yolo.detect(modelId, "/path/to/test_image.jpg", 640, 0.3, 0.5)
211
+ if #imageResults > 0 then
212
+ print("图片中检测到 " .. tostring(#imageResults) .. " 个物体")
213
+ for _, result in ipairs(imageResults) do
214
+ print("检测到类别 " .. tostring(result.classId) .. ",置信度: " .. tostring(result.confidence))
215
+ end
216
+ else
217
+ print("图片中未检测到任何物体")
218
+ end
219
+
220
+ -- 检测网络图片
221
+ local urlResults = yolo.detect(modelId, "https://example.com/test_image.jpg", 640, 0.5, 0.4)
222
+ print("网络图片检测结果: " .. tostring(#urlResults) .. " 个物体")
223
+
224
+ yolo.free(modelId)
225
+ ```
226
+
227
+ #### detectAbs - 对指定区域执行目标检测,并将结果坐标映射为原图/全屏绝对坐标。
228
+
229
+ 传入裁剪区域时,结果坐标会映射回原图或全屏坐标,可直接用于点击;全屏检测时 `x/y/ex/ey` 传 `0`。
230
+
231
+ ```lua
232
+ ---@param modelId string
233
+ ---@param img string
234
+ ---@param x number
235
+ ---@param y number
236
+ ---@param ex number
237
+ ---@param ey number
238
+ ---@param targetSize number?
239
+ ---@param threshold number?
240
+ ---@param nmsThreshold number?
241
+ ---@return YoloResult[]
242
+ function detectAbs(modelId, img, x, y, ex, ey, targetSize, threshold, nmsThreshold) end
243
+ ```
244
+
245
+ **参数:**
246
+
247
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
248
+ | -------------- | ------ | -------- | ------ | ------------------------------------------------------------------ |
249
+ | `modelId` | string | 是 | | 模型 ID,通过 `load` 或 `loadV11` 获取 |
250
+ | `img` | string | 是 | | 图像输入源,支持 `"screen"`、图片文件路径、HTTP 图片地址或 imageId |
251
+ | `x` | number | 是 | | 裁剪区域左上角 x 坐标;全屏检测传 0 |
252
+ | `y` | number | 是 | | 裁剪区域左上角 y 坐标;全屏检测传 0 |
253
+ | `ex` | number | 是 | | 裁剪区域右下角 x 坐标;全屏检测传 0 |
254
+ | `ey` | number | 是 | | 裁剪区域右下角 y 坐标;全屏检测传 0 |
255
+ | `targetSize` | number | 否 | 640 | 模型推理输入边长,通常为 640(与模型训练时一致) |
256
+ | `threshold` | number | 否 | 0.4 | 置信度阈值,低于此值的检测结果会被过滤 |
257
+ | `nmsThreshold` | number | 否 | 0.5 | 非极大值抑制阈值,用于去除重叠检测框 |
258
+
259
+ **返回值:**
260
+
261
+ | 类型 | 描述 |
262
+ | -------------- | -------------------------------------- |
263
+ | `YoloResult[]` | 检测结果数组,坐标为原图或全屏绝对坐标 |
264
+
265
+ **示例:**
266
+
267
+ ```lua
268
+ local yolo = require("yolo")
269
+ local modelId = yolo.load(
270
+ "/yolo11n_ncnn_model/model.ncnn.param",
271
+ "/yolo11n_ncnn_model/model.ncnn.bin",
272
+ 0,
273
+ 11,
274
+ false
275
+ )
276
+ local results = yolo.detectAbs(modelId, "screen", 0, 0, 0, 0, 640, 0.4, 0.5)
277
+ if #results > 0 then
278
+ print(results[1].classId, results[1].centerX, results[1].centerY)
279
+ end
280
+ yolo.free(modelId)
281
+ ```
282
+
283
+ ### 资源管理
284
+
285
+ #### free - 释放指定模型的资源。
286
+
287
+ ```lua
288
+ ---@param modelId string
289
+ function free(modelId) end
290
+ ```
291
+
292
+ **参数:**
293
+
294
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
295
+ | --------- | ------ | -------- | ------ | --------------- |
296
+ | `modelId` | string | 是 | | 要释放的模型 ID |
297
+
298
+ **示例:**
299
+
300
+ ```lua
301
+ local yolo = require("yolo")
302
+
303
+ -- 释放特定模型
304
+ if modelId then
305
+ yolo.free(modelId)
306
+ print("模型 " .. tostring(modelId) .. " 资源已释放")
307
+ end
308
+ ```
309
+
310
+ #### freeAll - 释放所有已加载模型的资源。
311
+
312
+ ```lua
313
+ function freeAll() end
314
+ ```
315
+
316
+ **示例:**
317
+
318
+ ```lua
319
+ local yolo = require("yolo")
320
+
321
+ -- 释放所有模型资源
322
+ yolo.freeAll()
323
+ print("所有 YOLO 模型资源已释放")
324
+ ```