ms-types 0.9.32 → 0.9.34

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-types",
3
- "version": "0.9.32",
3
+ "version": "0.9.34",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -10,4 +10,4 @@
10
10
  }
11
11
  ```
12
12
 
13
- 不要把本目录复制进脚本项目根目录。每个模块文件用 `---@meta <require名>` 和 `package.loaded['<require名>']` 对齐运行时 `require`,例如 `require("cv")`、`require("dotocr")`、`require("yolocls")`。`Sleep`、`HidKey`、`logd` / `logi` / `logw` / `loge` 等裸全局会随 library 自动加载。
13
+ 不要把本目录复制进脚本项目根目录。每个模块文件声明对应的全局表(如 `device`、`cv`、`dotocr`),不要 `require` 宿主模块。`Sleep`、`HidKey`、`logd` / `logi` / `logw` / `loge` 等裸全局会随 library 自动加载。用户自己的 `scripts/foo.lua` 仍用 `require("foo")`。
@@ -1,4 +1,4 @@
1
- ---@meta action
1
+ ---@meta
2
2
  ---@class Action
3
3
  local _Action = {}
4
4
 
@@ -229,5 +229,5 @@ function _Action.createBuilder()
229
229
  return ret
230
230
  end
231
231
 
232
- package.loaded['action'] = _Action
233
- return _Action
232
+ ---@type Action
233
+ action = _Action
@@ -1,4 +1,4 @@
1
- ---@meta appleocr
1
+ ---@meta
2
2
  ---@class AppleOCR
3
3
  local _AppleOCR = {}
4
4
 
@@ -14,7 +14,8 @@ local _AppleOCR = {}
14
14
  ---@field centerX integer 文本区域中心点 x 坐标
15
15
  ---@field centerY integer 文本区域中心点 y 坐标
16
16
 
17
- --- 识别文本
17
+ --- 识别文本(兼容旧接口,请改用 recognizeAbs)
18
+ --- @deprecated 请改用 recognizeAbs,避免裁剪区域坐标和全屏坐标混用。
18
19
  --- @param input string 图像ID或路径
19
20
  --- @param x integer|nil 区域X,默认0
20
21
  --- @param y integer|nil 区域Y,默认0
@@ -46,7 +47,8 @@ function _AppleOCR.recognizeAbs(input, x, y, ex, ey, langs)
46
47
  return ret
47
48
  end
48
49
 
49
- --- 识别数字
50
+ --- 识别数字(兼容旧接口,请改用 recognizeNumbersAbs)
51
+ --- @deprecated 请改用 recognizeNumbersAbs,避免裁剪区域坐标和全屏坐标混用。
50
52
  --- @param input string 图像ID或路径
51
53
  --- @param x integer|nil 区域X,默认0
52
54
  --- @param y integer|nil 区域Y,默认0
@@ -76,7 +78,8 @@ function _AppleOCR.recognizeNumbersAbs(input, x, y, ex, ey)
76
78
  return ret
77
79
  end
78
80
 
79
- --- 查找文本
81
+ --- 查找文本(兼容旧接口,请改用 findTextAbs)
82
+ --- @deprecated 请改用 findTextAbs,避免裁剪区域坐标和全屏坐标混用。
80
83
  --- @param input string 图像ID或路径
81
84
  --- @param targets string[]|string 目标文本数组或逗号分隔字符串
82
85
  --- @param x integer|nil 区域X,默认0
@@ -112,5 +115,5 @@ function _AppleOCR.findTextAbs(input, targets, x, y, ex, ey, langs, exactMatch)
112
115
  return ret
113
116
  end
114
117
 
115
- package.loaded['appleocr'] = _AppleOCR
116
- return _AppleOCR
118
+ ---@type AppleOCR
119
+ appleocr = _AppleOCR
@@ -1,4 +1,4 @@
1
- ---@meta cloud
1
+ ---@meta
2
2
  ---@class Cloud
3
3
  local _Cloud = {}
4
4
 
@@ -28,5 +28,5 @@ function _Cloud.report(event, data) return false end
28
28
  ---@param callback fun(event:string, data:table)|nil
29
29
  function _Cloud.onEvent(callback) end
30
30
 
31
- package.loaded['cloud'] = _Cloud
32
- return _Cloud
31
+ ---@type Cloud
32
+ cloud = _Cloud
@@ -1,4 +1,4 @@
1
- ---@meta config
1
+ ---@meta
2
2
  ---@class Config
3
3
  local _Config = {}
4
4
 
@@ -31,5 +31,5 @@ function _Config.getKuiConfig() return {} end
31
31
  ---@return boolean
32
32
  function _Config.remove(key) return true end
33
33
 
34
- package.loaded['config'] = _Config
35
- return _Config
34
+ ---@type Config
35
+ config = _Config
@@ -1,4 +1,4 @@
1
- ---@meta cryptoUtils
1
+ ---@meta
2
2
  ---@class CryptoUtils
3
3
  local _CryptoUtils = {}
4
4
 
@@ -43,5 +43,5 @@ function _CryptoUtils.sha1(data) return "" end
43
43
  ---@return string
44
44
  function _CryptoUtils.sha256(data) return "" end
45
45
 
46
- package.loaded['cryptoUtils'] = _CryptoUtils
47
- return _CryptoUtils
46
+ ---@type CryptoUtils
47
+ cryptoUtils = _CryptoUtils
package/types/lua/cv.lua CHANGED
@@ -1,8 +1,8 @@
1
- ---@meta cv
1
+ ---@meta
2
2
  ---@class OpenCV
3
3
  local _OpenCV = {}
4
4
 
5
- --- OpenCV Mat 句柄模块;require("cv")。方法与常量对齐 JS `cv` 运行时导出。
5
+ --- OpenCV Mat 句柄模块;全局 `cv`。方法与常量对齐 JS `cv` 运行时导出。
6
6
 
7
7
  --- absdiff
8
8
  ---@param ... any
@@ -724,5 +724,5 @@ function _OpenCV.warpPerspective(...) return nil end
724
724
  ---@return any
725
725
  function _OpenCV.zeros(...) return nil end
726
726
 
727
- package.loaded['cv'] = _OpenCV
728
- return _OpenCV
727
+ ---@type OpenCV
728
+ cv = _OpenCV
@@ -1,4 +1,4 @@
1
- ---@meta device
1
+ ---@meta
2
2
  ---@class Device
3
3
  local _Device = {}
4
4
 
@@ -102,5 +102,5 @@ function _Device.getLanIp() return '' end
102
102
  ---@param intensity number 0.0-1.0
103
103
  function _Device.vibrate(duration, intensity) end
104
104
 
105
- package.loaded['device'] = _Device
106
- return _Device
105
+ ---@type Device
106
+ device = _Device
@@ -1,8 +1,8 @@
1
- ---@meta dotocr
1
+ ---@meta
2
2
  ---@class DotOCR
3
3
  local _DotOCR = {}
4
4
 
5
- --- 点阵 OCR;require("dotocr")
5
+ --- 点阵 OCR;全局 `dotocr`
6
6
 
7
7
  --- loadFont
8
8
  ---@param fontPath string
@@ -41,5 +41,5 @@ function _DotOCR.recognizeAbs(fontId, input, x, y, ex, ey, confidenceThreshold)
41
41
  ---@return table[]
42
42
  function _DotOCR.findTextAbs(fontId, input, targetTexts, x, y, ex, ey, confidenceThreshold, exactMatch) return {} end
43
43
 
44
- package.loaded['dotocr'] = _DotOCR
45
- return _DotOCR
44
+ ---@type DotOCR
45
+ dotocr = _DotOCR
@@ -1,4 +1,4 @@
1
- ---@meta file
1
+ ---@meta
2
2
  ---@class File
3
3
  local _File = {}
4
4
 
@@ -93,5 +93,5 @@ function _File.copy(src, dest) return true end
93
93
  --- @return string|nil MD5值
94
94
  function _File.fileMD5(path) return '' end
95
95
 
96
- package.loaded['file'] = _File
97
- return _File
96
+ ---@type File
97
+ file = _File
package/types/lua/hid.lua CHANGED
@@ -1,4 +1,4 @@
1
- ---@meta hid
1
+ ---@meta
2
2
  ---@type table<string, integer>
3
3
  HidKey = {
4
4
  COMMAND = 0x83,
@@ -271,5 +271,5 @@ function _HID.currentAppInfo()
271
271
  return ret
272
272
  end
273
273
 
274
- package.loaded['hid'] = _HID
275
- return _HID
274
+ ---@type HID
275
+ hid = _HID
@@ -1,4 +1,4 @@
1
- ---@meta hotupdate
1
+ ---@meta
2
2
  ---@class HotUpdate
3
3
  local _HotUpdate = {}
4
4
 
@@ -20,5 +20,5 @@ function _HotUpdate.downloadAndInstall() return {updated = true, error = nil} en
20
20
  --- @return integer 版本号
21
21
  function _HotUpdate.getCurrentVersion() return 0 end
22
22
 
23
- package.loaded['hotupdate'] = _HotUpdate
24
- return _HotUpdate
23
+ ---@type HotUpdate
24
+ hotupdate = _HotUpdate
@@ -1,4 +1,4 @@
1
- ---@meta http
1
+ ---@meta
2
2
  ---@class Http
3
3
  local _Http = {}
4
4
 
@@ -141,5 +141,5 @@ function _WebSocket.onBinary(fn) end
141
141
  --- @param fn fun(error:string)
142
142
  function _WebSocket.onError(fn) end
143
143
 
144
- package.loaded['http'] = _Http
145
- return _Http
144
+ ---@type Http
145
+ http = _Http
@@ -1,4 +1,4 @@
1
- ---@meta image
1
+ ---@meta
2
2
  ---@class Image
3
3
  local _Image = {}
4
4
 
@@ -30,11 +30,13 @@ local _Image = {}
30
30
  --- @return string|nil 图片ID
31
31
  function _Image.captureScreen(x, y, ex, ey) return '' end
32
32
 
33
- --- 全屏截屏
33
+ --- 全屏截屏(兼容旧接口,请改用 captureScreen)
34
+ --- @deprecated 请改用 captureScreen()。
34
35
  --- @return string|nil 图片ID
35
36
  function _Image.captureFullScreen() return '' end
36
37
 
37
- --- 区域截屏
38
+ --- 区域截屏(兼容旧接口,请改用 captureScreen)
39
+ --- @deprecated 请改用 captureScreen(x, y, ex, ey)。
38
40
  --- @param x integer|nil
39
41
  --- @param y integer|nil
40
42
  --- @param ex integer|nil 右下角x
@@ -203,5 +205,5 @@ function _Image.drawRect(id, x, y, ex, ey, color, thickness) end
203
205
  --- 释放所有图片
204
206
  function _Image.releaseAll() end
205
207
 
206
- package.loaded['image'] = _Image
207
- return _Image
208
+ ---@type Image
209
+ image = _Image
package/types/lua/ime.lua CHANGED
@@ -1,4 +1,4 @@
1
- ---@meta ime
1
+ ---@meta
2
2
  ---@class Ime
3
3
  local _Ime = {}
4
4
 
@@ -45,5 +45,5 @@ function _Ime.getClipboard() return '' end
45
45
  --- @return boolean 成功
46
46
  function _Ime.setClipboard(text) return true end
47
47
 
48
- package.loaded['ime'] = _Ime
49
- return _Ime
48
+ ---@type Ime
49
+ ime = _Ime
@@ -1,4 +1,4 @@
1
- ---@meta logger
1
+ ---@meta
2
2
  ---@class Logger
3
3
  local _Logger = {}
4
4
 
@@ -45,5 +45,5 @@ function _Logger.warn(...) end
45
45
  --- @return nil
46
46
  function _Logger.error(...) end
47
47
 
48
- package.loaded['logger'] = _Logger
49
- return _Logger
48
+ ---@type Logger
49
+ logger = _Logger
@@ -1,4 +1,4 @@
1
- ---@meta media
1
+ ---@meta
2
2
  ---@class Media
3
3
  local _Media = {}
4
4
 
@@ -43,5 +43,5 @@ function _Media.deleteAllVideos() return true end
43
43
  --- @return boolean 成功
44
44
  function _Media.deleteAllScreenshots() return true end
45
45
 
46
- package.loaded['media'] = _Media
47
- return _Media
46
+ ---@type Media
47
+ media = _Media
@@ -1,4 +1,4 @@
1
- ---@meta mysql
1
+ ---@meta
2
2
  ---@class MySQL
3
3
  local _MySQL = {}
4
4
 
@@ -61,5 +61,5 @@ function _MySQL.commit() return true end
61
61
  --- @return boolean 成功
62
62
  function _MySQL.rollback() return true end
63
63
 
64
- package.loaded['mysql'] = _MySQL
65
- return _MySQL
64
+ ---@type MySQL
65
+ mysql = _MySQL
@@ -1,4 +1,4 @@
1
- ---@meta netcard
1
+ ---@meta
2
2
  ---@class NetCard
3
3
  local _NetCard = {}
4
4
 
@@ -42,5 +42,5 @@ function _NetCard.setValue(key, value) return '' end
42
42
  --- @return string 值
43
43
  function _NetCard.getValue(key) return '' end
44
44
 
45
- package.loaded['netcard'] = _NetCard
46
- return _NetCard
45
+ ---@type NetCard
46
+ netcard = _NetCard
@@ -1,4 +1,4 @@
1
- ---@meta node
1
+ ---@meta
2
2
  ---@class Node
3
3
  local _Node = {}
4
4
 
@@ -82,5 +82,5 @@ function _Node.createNodeSelector(params)
82
82
  return ret
83
83
  end
84
84
 
85
- package.loaded['node'] = _Node
86
- return _Node
85
+ ---@type Node
86
+ node = _Node
@@ -1,4 +1,4 @@
1
- ---@meta paddleocr
1
+ ---@meta
2
2
  ---@class PaddleOCR
3
3
  local _PaddleOCR = {}
4
4
 
@@ -16,7 +16,8 @@ local _PaddleOCR = {}
16
16
  ---@field angle number 文本旋转角度 (度)
17
17
  ---@field orientation integer 文本方向 (0=水平,1=垂直 等)
18
18
 
19
- --- 加载 V5 模型
19
+ --- 加载 V5 模型(兼容旧接口,请改用 loadModel)
20
+ --- @deprecated 请改用 loadModel("ppocr-v5", useGpu);检测长边请使用 setMaxSideLen 单独设置。
20
21
  --- @param maxSideLen integer|nil 目标边长,默认 640
21
22
  --- @param useGpu boolean|nil 是否启用 GPU,默认 false
22
23
  --- @return boolean 成功
@@ -33,7 +34,8 @@ function _PaddleOCR.loadModel(modelId, useGpu) return true end
33
34
  --- @return boolean 成功
34
35
  function _PaddleOCR.setMaxSideLen(maxSideLen) return true end
35
36
 
36
- --- 识别文本
37
+ --- 识别文本(兼容旧接口,请改用 recognizeAbs)
38
+ --- @deprecated 请改用 recognizeAbs,避免裁剪区域坐标和全屏坐标混用。
37
39
  --- @param input string 图像ID或路径
38
40
  --- @param x integer|nil 默认0
39
41
  --- @param y integer|nil 默认0
@@ -61,7 +63,8 @@ function _PaddleOCR.recognizeAbs(input, x, y, ex, ey, confidenceThreshold)
61
63
  return ret
62
64
  end
63
65
 
64
- --- 查找目标文本
66
+ --- 查找目标文本(兼容旧接口,请改用 findTextAbs)
67
+ --- @deprecated 请改用 findTextAbs,避免裁剪区域坐标和全屏坐标混用。
65
68
  --- @param input string 图像ID或路径
66
69
  --- @param targets string[]|string 目标文本数组或逗号分隔字符串
67
70
  --- @param x integer|nil 默认0
@@ -96,5 +99,5 @@ end
96
99
  --- 释放资源
97
100
  function _PaddleOCR.free() end
98
101
 
99
- package.loaded['paddleocr'] = _PaddleOCR
100
- return _PaddleOCR
102
+ ---@type PaddleOCR
103
+ paddleocr = _PaddleOCR
package/types/lua/pip.lua CHANGED
@@ -1,4 +1,4 @@
1
- ---@meta pip
1
+ ---@meta
2
2
  ---@class Pip
3
3
  local _Pip = {}
4
4
 
@@ -53,5 +53,5 @@ function _Pip.setCustomTextSize(fontSize) return true end
53
53
  ---@return boolean
54
54
  function _Pip.setCustomBackgroundColor(color) return true end
55
55
 
56
- package.loaded['pip'] = _Pip
57
- return _Pip
56
+ ---@type Pip
57
+ pip = _Pip
@@ -1,4 +1,4 @@
1
- ---@meta system
1
+ ---@meta
2
2
  ---@class System
3
3
  local _System = {}
4
4
 
@@ -136,5 +136,5 @@ function _System.getAgentStatus() return false end
136
136
  --- @return boolean 成功
137
137
  function _System.stopAgent() return true end
138
138
 
139
- package.loaded['system'] = _System
140
- return _System
139
+ ---@type System
140
+ system = _System
@@ -1,4 +1,4 @@
1
- ---@meta tomatoocr
1
+ ---@meta
2
2
  ---@class TomatoOCR
3
3
  local _TomatoOCR = {}
4
4
 
@@ -80,5 +80,5 @@ function _TomatoOCR.findTapPoints(js) return '' end
80
80
  --- 释放已加载的 OCR 模型和内部资源
81
81
  function _TomatoOCR.release() end
82
82
 
83
- package.loaded['tomatoocr'] = _TomatoOCR
84
- return _TomatoOCR
83
+ ---@type TomatoOCR
84
+ tomatoocr = _TomatoOCR
package/types/lua/tts.lua CHANGED
@@ -1,4 +1,4 @@
1
- ---@meta tts
1
+ ---@meta
2
2
  ---@class TTS
3
3
  local _TTS = {}
4
4
 
@@ -39,5 +39,5 @@ function _TTS.getAvailableVoices() return {} end
39
39
  --- 释放 TTS 资源
40
40
  function _TTS.free() end
41
41
 
42
- package.loaded['tts'] = _TTS
43
- return _TTS
42
+ ---@type TTS
43
+ tts = _TTS
package/types/lua/ui.lua CHANGED
@@ -1,4 +1,4 @@
1
- ---@meta ui
1
+ ---@meta
2
2
  ---@class UI
3
3
  local _UI = {}
4
4
 
@@ -43,5 +43,5 @@ function _UI.call(key, data) end
43
43
  --- @param code string 代码
44
44
  function _UI.eval(code) end
45
45
 
46
- package.loaded['ui'] = _UI
47
- return _UI
46
+ ---@type UI
47
+ ui = _UI
@@ -1,4 +1,4 @@
1
- ---@meta utils
1
+ ---@meta
2
2
  ---@class Utils
3
3
  local _Utils = {}
4
4
 
@@ -46,5 +46,5 @@ function _Utils.hexStringBase64Encoded(hexString) return '' end
46
46
  --- @return string hex
47
47
  function _Utils.hexStringBase64Decoded(base64HexString) return '' end
48
48
 
49
- package.loaded['utils'] = _Utils
50
- return _Utils
49
+ ---@type Utils
50
+ utils = _Utils
@@ -1,4 +1,4 @@
1
- ---@meta yolo
1
+ ---@meta
2
2
  ---@class Yolo
3
3
  local _Yolo = {}
4
4
 
@@ -23,7 +23,8 @@ local _Yolo = {}
23
23
  --- @return string|nil 模型ID(失败返回 nil)
24
24
  function _Yolo.load(paramPath, binPath, nc, version, useGpu) return nil end
25
25
 
26
- --- 加载 YOLOv11 模型
26
+ --- 加载 YOLOv11 模型(兼容旧接口,请改用 load)
27
+ --- @deprecated 请改用 load(paramPath, binPath, nc, 11, useGpu)。
27
28
  --- @param paramPath string ncnn param 路径
28
29
  --- @param binPath string ncnn bin 路径
29
30
  --- @param nc integer|nil 标签数量;传 0 或省略时按模型输出推断
@@ -31,7 +32,8 @@ function _Yolo.load(paramPath, binPath, nc, version, useGpu) return nil end
31
32
  --- @return string|nil 模型ID(失败返回 nil)
32
33
  function _Yolo.loadV11(paramPath, binPath, nc, useGpu) return nil end
33
34
 
34
- --- 检测
35
+ --- 检测(兼容旧接口,请改用 detectAbs)
36
+ --- @deprecated 请改用 detectAbs,避免裁剪区域坐标和全屏坐标混用。
35
37
  --- @param id string 模型ID
36
38
  --- @param input string 图像ID或路径
37
39
  --- @param target integer 目标边长(默认 640)
@@ -60,5 +62,5 @@ function _Yolo.free(id) end
60
62
  --- 释放全部模型
61
63
  function _Yolo.freeAll() end
62
64
 
63
- package.loaded['yolo'] = _Yolo
64
- return _Yolo
65
+ ---@type Yolo
66
+ yolo = _Yolo
@@ -1,4 +1,4 @@
1
- ---@meta yolocls
1
+ ---@meta
2
2
  ---@class YoloCls
3
3
  local _YoloCls = {}
4
4
 
@@ -36,5 +36,5 @@ function _YoloCls.free(modelId) end
36
36
 
37
37
  function _YoloCls.freeAll() end
38
38
 
39
- package.loaded['yolocls'] = _YoloCls
40
- return _YoloCls
39
+ ---@type YoloCls
40
+ yolocls = _YoloCls
package/types/system.d.ts CHANGED
@@ -58,6 +58,11 @@ declare namespace system {
58
58
  * }
59
59
  */
60
60
  function activateAppInfo(): AppInfo;
61
+ /**
62
+ * 获取前台运行的应用列表
63
+ * @returns 包含应用信息的字典数组,每个字典包含应用的Bundle ID和显示名称
64
+ */
65
+ function foregroundAppInfos(): AppInfo[];
61
66
  /**
62
67
  * 获取后台运行的应用列表
63
68
  * @returns 包含应用信息的字典数组,每个字典包含应用的Bundle ID和显示名称
package/types/ui.d.ts CHANGED
@@ -116,6 +116,11 @@ declare namespace ui {
116
116
  */
117
117
  function show(): void;
118
118
 
119
+ /**
120
+ * 隐藏WebView
121
+ */
122
+ function hide(): void;
123
+
119
124
  /**
120
125
  * 设置事件回调函数(仅主线程调用,不能在线程脚本中调用)
121
126
  * @param onEvent 事件回调函数,传入 null 会取消监听
@@ -58,6 +58,11 @@ declare namespace $系统 {
58
58
  * }
59
59
  */
60
60
  function 获取当前运行的应用(): APP信息;
61
+ /**
62
+ * 获取前台运行的应用列表
63
+ * @returns 包含应用信息的字典数组,每个字典包含应用的Bundle ID和显示名称
64
+ */
65
+ function 获取前台运行的应用列表(): APP信息[];
61
66
  /**
62
67
  * 获取后台运行的应用列表
63
68
  * @returns 包含应用信息的字典数组,每个字典包含应用的Bundle ID和显示名称
@@ -9,6 +9,11 @@ declare namespace $视图 {
9
9
  */
10
10
  function 显示(): 无返回值;
11
11
 
12
+ /**
13
+ * 隐藏WebView
14
+ */
15
+ function 隐藏(): 无返回值;
16
+
12
17
  /**
13
18
  * 设置事件回调函数(仅主线程调用,不能在线程脚本中调用)
14
19
  * @param onEvent 事件回调函数,传入 null 会取消监听