ms-types 0.9.35 → 0.9.36

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.
@@ -2,22 +2,33 @@
2
2
  ---@class DotOCR
3
3
  local _DotOCR = {}
4
4
 
5
+ ---@class OCRChar
6
+ ---@field text string 识别出的文本;查找结果中为命中的目标字符串
7
+ ---@field confidence number 识别置信度 (0-1)
8
+ ---@field x integer 文本区域左上角 x 坐标
9
+ ---@field y integer 文本区域左上角 y 坐标
10
+ ---@field ex integer 文本区域右下角 x 坐标
11
+ ---@field ey integer 文本区域右下角 y 坐标
12
+ ---@field width integer 文本区域宽度
13
+ ---@field height integer 文本区域高度
14
+ ---@field centerX integer 文本区域中心点 x 坐标
15
+ ---@field centerY integer 文本区域中心点 y 坐标
16
+
5
17
  --- 点阵 OCR;全局 `dotocr`
6
18
 
7
- --- loadFont
19
+ --- 从资源路径加载字库并缓存
8
20
  ---@param fontPath string
9
- ---@return string|nil
21
+ ---@return string|nil 字库 ID,失败返回 nil
10
22
  function _DotOCR.loadFont(fontPath) return nil end
11
23
 
12
- --- free
24
+ --- 释放指定字库
13
25
  ---@param fontId string
14
26
  function _DotOCR.free(fontId) end
15
27
 
16
- --- freeAll
17
-
28
+ --- 释放全部已加载的点阵字库
18
29
  function _DotOCR.freeAll() end
19
30
 
20
- --- recognizeAbs
31
+ --- 识别文字并返回原图或全屏绝对坐标
21
32
  ---@param fontId string
22
33
  ---@param input string
23
34
  ---@param x integer|nil
@@ -25,10 +36,14 @@ function _DotOCR.freeAll() end
25
36
  ---@param ex integer|nil
26
37
  ---@param ey integer|nil
27
38
  ---@param confidenceThreshold number|nil
28
- ---@return table[]
29
- function _DotOCR.recognizeAbs(fontId, input, x, y, ex, ey, confidenceThreshold) return {} end
39
+ ---@return OCRChar[]
40
+ function _DotOCR.recognizeAbs(fontId, input, x, y, ex, ey, confidenceThreshold)
41
+ ---@type OCRChar[]
42
+ local ret = {}
43
+ return ret
44
+ end
30
45
 
31
- --- findTextAbs
46
+ --- 先识别再按行查找目标串,返回命中位置的绝对坐标
32
47
  ---@param fontId string
33
48
  ---@param input string
34
49
  ---@param targetTexts string[]
@@ -38,8 +53,12 @@ function _DotOCR.recognizeAbs(fontId, input, x, y, ex, ey, confidenceThreshold)
38
53
  ---@param ey integer|nil
39
54
  ---@param confidenceThreshold number|nil
40
55
  ---@param exactMatch boolean|nil
41
- ---@return table[]
42
- function _DotOCR.findTextAbs(fontId, input, targetTexts, x, y, ex, ey, confidenceThreshold, exactMatch) return {} end
56
+ ---@return OCRChar[]
57
+ function _DotOCR.findTextAbs(fontId, input, targetTexts, x, y, ex, ey, confidenceThreshold, exactMatch)
58
+ ---@type OCRChar[]
59
+ local ret = {}
60
+ return ret
61
+ end
43
62
 
44
63
  ---@type DotOCR
45
64
  dotocr = _DotOCR
@@ -27,8 +27,8 @@ AppName = ''
27
27
  ---@type string
28
28
  AppBundleId = ''
29
29
 
30
- --- 脚本 package.json 内容(表)
31
- ---@type table
30
+ --- 脚本 package.json 内容(动态键值表)
31
+ ---@type table<string, any>
32
32
  PackageJson = {}
33
33
 
34
34
  ---@class CpuThrottleDelay
@@ -63,7 +63,7 @@ function Sleep(ms) end
63
63
  function Time() return 0 end
64
64
 
65
65
  --- 将表转为 JSON 字符串
66
- ---@param data table
66
+ ---@param data table<string, any>|any[]
67
67
  ---@return string
68
68
  function ToJsonString(data) return '' end
69
69
 
package/types/lua/hid.lua CHANGED
@@ -268,12 +268,14 @@ function _HID.unlock() return true end
268
268
  --- @return boolean 成功
269
269
  function _HID.takeMeToFront() return true end
270
270
 
271
- --- 当前打开应用信息(iOS18+)
272
- --- @return {name: string, bundleId: string} 信息;无前台应用时为空表
271
+ ---@class HidCurrentAppInfo
272
+ ---@field name string 应用名称
273
+ ---@field bundleId string 应用 Bundle ID
274
+
275
+ --- 当前打开应用信息(iOS18+);无前台应用时为 nil
276
+ --- @return HidCurrentAppInfo|nil
273
277
  function _HID.currentAppInfo()
274
- ---@type table
275
- local ret
276
- return ret
278
+ return nil
277
279
  end
278
280
 
279
281
  ---@type HID
@@ -2,22 +2,40 @@
2
2
  ---@class HotUpdate
3
3
  local _HotUpdate = {}
4
4
 
5
- --- 检查更新
6
- --- @param options {url: string|nil, version: integer|nil, timeout: integer|nil}|nil
7
- --- @return {needUpdate: boolean, data?: table, error?: string} 结果
8
- function _HotUpdate.checkUpdate(options)
9
- return {
10
- needUpdate = true,
11
- data = {version = 1, url = "https://example.com/update.zip"}
12
- }
5
+ ---@class HotUpdateResponse
6
+ ---@field download_url string 新包下载地址
7
+ ---@field version integer 新包版本号
8
+ ---@field download_timeout integer 下载超时(秒)
9
+ ---@field dialog boolean 是否用对话框展示
10
+ ---@field msg string 对话框消息
11
+ ---@field force boolean 对话框模式下是否强制更新
12
+ ---@field md5 string|nil 更新包 MD5
13
+
14
+ ---@class HotUpdateResult
15
+ ---@field needUpdate boolean 是否需要更新
16
+ ---@field error string|nil 检查失败时的错误
17
+ ---@field data HotUpdateResponse|nil 需要更新时的服务器数据
18
+
19
+ ---@class HotUpdateInstallResult
20
+ ---@field updated boolean 是否已安装
21
+ ---@field error string|nil 安装失败时的错误
22
+
23
+ --- 检查更新(无参数)
24
+ ---@return HotUpdateResult
25
+ function _HotUpdate.checkUpdate()
26
+ ---@type HotUpdateResult
27
+ return { needUpdate = false }
13
28
  end
14
29
 
15
- --- 下载并安装
16
- --- @return {updated: boolean, error?: string} 结果
17
- function _HotUpdate.downloadAndInstall() return {updated = true, error = nil} end
30
+ --- 下载并安装;成功后会自动重启脚本
31
+ ---@return HotUpdateInstallResult
32
+ function _HotUpdate.downloadAndInstall()
33
+ ---@type HotUpdateInstallResult
34
+ return { updated = false }
35
+ end
18
36
 
19
- --- 当前版本
20
- --- @return integer 版本号
37
+ --- 当前版本号;失败返回 0
38
+ ---@return integer
21
39
  function _HotUpdate.getCurrentVersion() return 0 end
22
40
 
23
41
  ---@type HotUpdate
@@ -21,6 +21,12 @@ local _Image = {}
21
21
  ---@field centerY integer 中心y坐标
22
22
  ---@field ex integer 右下角x坐标
23
23
  ---@field ey integer 右下角y坐标
24
+ ---@field scaleX number|nil 仅 method=99:命中时模板横向缩放
25
+ ---@field scaleY number|nil 仅 method=99:命中时模板纵向缩放
26
+
27
+ ---@class FindImageOptions
28
+ ---@field scaleFactors number[]|nil 仅 method=99:模板缩放比例列表
29
+ ---@field orz integer|nil 查找方向 1-8,与 findColor 相同
24
30
 
25
31
  --- 截取屏幕;坐标缺省 0 表示全屏
26
32
  --- @param x integer|nil 左上角 x
@@ -133,7 +139,7 @@ function _Image.cmpColor(id, points, threshold) return true end
133
139
  --- @param limit integer|nil 限制个数
134
140
  --- @param method integer|nil 匹配方法 0|1|3|5|99
135
141
  --- @param rgb boolean|nil 是否使用RGB
136
- --- @param options table|nil 选项。scaleFactors 仅 method=99;orz 为查找方向 1-8(与 findColor 相同)
142
+ --- @param options FindImageOptions|nil 选项。scaleFactors 仅 method=99;orz 为查找方向 1-8
137
143
  --- @return Rect[] 结果矩形列表
138
144
  function _Image.findImage(id, templateImageId, x, y, ex, ey, threshold, limit,
139
145
  method, rgb, options) return {} end
@@ -9,9 +9,11 @@ local _MySQL = {}
9
9
  ---@field password string 密码
10
10
  ---@field database string 数据库名
11
11
  ---@field charset string|nil 字符集
12
+ ---@field connectTimeout integer|nil 连接超时(毫秒),默认 5000
13
+ ---@field queryTimeout integer|nil 查询超时(毫秒),默认 30000
12
14
 
13
15
  ---@class MySQLResult
14
- ---@field rows table[] 结果集
16
+ ---@field rows table<string, any>[] 结果集行
15
17
  ---@field affectedRows integer 受影响的行数
16
18
  ---@field success boolean 是否成功
17
19
  ---@field insertId integer|nil 插入ID
@@ -2,7 +2,14 @@
2
2
  ---@class YoloCls
3
3
  local _YoloCls = {}
4
4
 
5
- --- load
5
+ ---@class YoloClsProbs
6
+ ---@field data number[] 所有类别概率;Lua 下标从 1 起,类别 0 对应 data[1]
7
+ ---@field top1 integer|nil 概率最高的类别 ID;分类失败时为 nil
8
+ ---@field top5 integer[] 概率最高的 5 个类别 ID,按概率从高到低排序
9
+ ---@field top1conf number|nil top1 对应的概率;分类失败时为 nil
10
+ ---@field top5conf number[] top5 对应的概率,顺序与 top5 一致
11
+
12
+ --- 加载 YOLO 分类模型
6
13
  ---@param paramPath string
7
14
  ---@param binPath string
8
15
  ---@param nc integer|nil
@@ -10,14 +17,17 @@ local _YoloCls = {}
10
17
  ---@return string|nil
11
18
  function _YoloCls.load(paramPath, binPath, nc, useGpu) return nil end
12
19
 
13
- --- classify
20
+ --- 图像分类
14
21
  ---@param modelId string
15
22
  ---@param img string
16
23
  ---@param targetSize integer|nil
17
- ---@return table
18
- function _YoloCls.classify(modelId, img, targetSize) return { data = {}, top1 = nil, top5 = {}, top1conf = nil, top5conf = {} } end
24
+ ---@return YoloClsProbs
25
+ function _YoloCls.classify(modelId, img, targetSize)
26
+ ---@type YoloClsProbs
27
+ return { data = {}, top1 = nil, top5 = {}, top1conf = nil, top5conf = {} }
28
+ end
19
29
 
20
- --- classifyRegion
30
+ --- 对指定区域执行图像分类
21
31
  ---@param modelId string
22
32
  ---@param img string
23
33
  ---@param x integer|nil
@@ -25,15 +35,17 @@ function _YoloCls.classify(modelId, img, targetSize) return { data = {}, top1 =
25
35
  ---@param ex integer|nil
26
36
  ---@param ey integer|nil
27
37
  ---@param targetSize integer|nil
28
- ---@return table
29
- function _YoloCls.classifyRegion(modelId, img, x, y, ex, ey, targetSize) return { data = {}, top1 = nil, top5 = {}, top1conf = nil, top5conf = {} } end
38
+ ---@return YoloClsProbs
39
+ function _YoloCls.classifyRegion(modelId, img, x, y, ex, ey, targetSize)
40
+ ---@type YoloClsProbs
41
+ return { data = {}, top1 = nil, top5 = {}, top1conf = nil, top5conf = {} }
42
+ end
30
43
 
31
- --- free
44
+ --- 释放指定模型
32
45
  ---@param modelId string
33
46
  function _YoloCls.free(modelId) end
34
47
 
35
- --- freeAll
36
-
48
+ --- 释放全部模型
37
49
  function _YoloCls.freeAll() end
38
50
 
39
51
  ---@type YoloCls
package/types/opencv.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @example
6
6
  * const src = cv.capture()
7
- * const gray = cv.cvtColor(src, { code: cv.COLOR_BGR2GRAY })
7
+ * const gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
8
8
  * const edges = cv.Canny(gray, { threshold1: 100, threshold2: 200 })
9
9
  * cv.imwrite('/tmp/e.png', edges)
10
10
  * cv.release(src); cv.release(gray); cv.release(edges)