ms-types 0.10.7 → 0.10.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 +2 -2
- package/types/action.d.ts +7 -2
- package/types/ai.d.ts +5 -4
- package/types/appleocr.d.ts +4 -4
- package/types/cloud.d.ts +1 -2
- package/types/config.d.ts +1 -1
- package/types/cryptoUtils.d.ts +5 -2
- package/types/device.d.ts +1 -1
- package/types/dotocr.d.ts +3 -1
- package/types/file.d.ts +2 -2
- package/types/hotUpdate.d.ts +1 -2
- package/types/http.d.ts +6 -6
- package/types/image.d.ts +1 -1
- package/types/ime.d.ts +1 -1
- package/types/logger.d.ts +2 -2
- package/types/lua/action.lua +119 -89
- package/types/lua/ai.lua +34 -16
- package/types/lua/appleocr.lua +35 -22
- package/types/lua/cloud.lua +25 -12
- package/types/lua/config.lua +18 -11
- package/types/lua/cryptoUtils.lua +35 -27
- package/types/lua/cv.lua +173 -25
- package/types/lua/device.lua +38 -20
- package/types/lua/dotocr.lua +8 -2
- package/types/lua/file.lua +61 -40
- package/types/lua/global.lua +56 -20
- package/types/lua/hid.lua +147 -101
- package/types/lua/hotupdate.lua +25 -3
- package/types/lua/http.lua +71 -41
- package/types/lua/image.lua +222 -98
- package/types/lua/ime.lua +37 -13
- package/types/lua/logger.lua +22 -12
- package/types/lua/media.lua +54 -14
- package/types/lua/mysql.lua +61 -12
- package/types/lua/netcard.lua +25 -11
- package/types/lua/node.lua +4 -2
- package/types/lua/paddleocr.lua +35 -21
- package/types/lua/pip.lua +30 -18
- package/types/lua/system.lua +112 -31
- package/types/lua/tomatoocr.lua +73 -26
- package/types/lua/tts.lua +26 -10
- package/types/lua/ui.lua +35 -14
- package/types/lua/utils.lua +27 -17
- package/types/lua/yolo.lua +25 -17
- package/types/lua/yolocls.lua +27 -18
- package/types/media.d.ts +1 -1
- package/types/mysql.d.ts +1 -1
- package/types/netCard.d.ts +3 -0
- package/types/node.d.ts +1 -1
- package/types/paddleocr.d.ts +2 -5
- package/types/pip.d.ts +3 -0
- package/types/system.d.ts +1 -1
- package/types/tomatoocr.d.ts +3 -4
- package/types/tts.d.ts +2 -2
- package/types/ui.d.ts +1 -1
- package/types/utils.d.ts +1 -1
- package/types/web.d.ts +1 -1
- package/types/yolo.d.ts +1 -1
- package/types/yoloCls.d.ts +1 -1
- package/types/zh/HID/346/250/241/345/235/227.d.ts +1 -1
- package/types/zh/HTTP/346/250/241/345/235/227.d.ts +7 -6
- package/types/zh/MySql/346/250/241/345/235/227.d.ts +2 -1
- package/types/zh/PaddleOCR/346/250/241/345/235/227.d.ts +3 -5
- package/types/zh/YOLO/345/210/206/347/261/273/346/250/241/345/235/227.d.ts +1 -1
- package/types/zh/YOLO/346/250/241/345/235/227.d.ts +1 -1
- package/types/zh//344/272/221/346/216/247/346/250/241/345/235/227.d.ts +4 -1
- package/types/zh//345/212/250/344/275/234/346/250/241/345/235/227.d.ts +7 -2
- package/types/zh//345/233/276/347/211/207/346/250/241/345/235/227.d.ts +2 -1
- package/types/zh//345/252/222/344/275/223/346/250/241/345/235/227.d.ts +1 -1
- package/types/zh//345/267/245/345/205/267/346/250/241/345/235/227.d.ts +1 -1
- package/types/zh//346/202/254/346/265/256/347/252/227/346/250/241/345/235/227.d.ts +2 -1
- package/types/zh//346/226/207/344/273/266/346/250/241/345/235/227.d.ts +3 -2
- 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 +3 -2
- package/types/zh//346/227/245/345/277/227/346/250/241/345/235/227.d.ts +2 -2
- package/types/zh//347/202/271/351/230/265OCR/346/250/241/345/235/227.d.ts +3 -1
- package/types/zh//347/263/273/347/273/237/346/250/241/345/235/227.d.ts +2 -1
- package/types/zh//347/272/277/347/250/213/346/250/241/345/235/227.d.ts +1 -0
- package/types/zh//350/212/202/347/202/271/346/250/241/345/235/227.d.ts +1 -1
- package/types/zh//350/213/271/346/236/234OCR.d.ts +4 -4
- package/types/zh//350/247/206/345/233/276/346/250/241/345/235/227.d.ts +2 -2
- package/types/zh//350/256/276/345/244/207/346/250/241/345/235/227.d.ts +2 -1
- package/types/zh//350/276/223/345/205/245/346/263/225/346/250/241/345/235/227.d.ts +2 -1
- package/types/zh//351/205/215/347/275/256/346/250/241/345/235/227.d.ts +1 -1
package/types/lua/mysql.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- MySQL数据库模块
|
|
2
3
|
---@class MySQL
|
|
3
4
|
local _MySQL = {}
|
|
4
5
|
|
|
@@ -20,21 +21,40 @@ local _MySQL = {}
|
|
|
20
21
|
---@field error string|nil 错误信息
|
|
21
22
|
|
|
22
23
|
--- 连接数据库
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
---@param config MySQLConfig 连接配置对象
|
|
25
|
+
---@return boolean 是否连接成功
|
|
26
|
+
---@example local connected = mysql.connect({ host = "localhost", port = 3306, username = "root", password = "password", database = "test_db", charset = "utf8mb4" })
|
|
27
|
+
---
|
|
28
|
+
--- if connected then
|
|
29
|
+
--- logi("数据库连接成功")
|
|
30
|
+
--- end
|
|
25
31
|
function _MySQL.connect(config) return true end
|
|
26
32
|
|
|
27
33
|
--- 断开连接
|
|
34
|
+
---@example mysql.disconnect()
|
|
28
35
|
function _MySQL.disconnect() end
|
|
29
36
|
|
|
30
37
|
--- 是否连接
|
|
31
|
-
|
|
38
|
+
---@return boolean 是否已连接
|
|
39
|
+
---@example if mysql.isConnected() then
|
|
40
|
+
--- logi("数据库已连接")
|
|
41
|
+
--- end
|
|
32
42
|
function _MySQL.isConnected() return false end
|
|
33
43
|
|
|
34
44
|
--- 查询
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
---@param sql string SQL 查询语句
|
|
46
|
+
---@param params any[]|nil 查询参数数组,可选
|
|
47
|
+
---@return MySQLResult 查询结果对象
|
|
48
|
+
---@example local result = mysql.query("SELECT * FROM users")
|
|
49
|
+
--- result = mysql.query("SELECT * FROM users WHERE id = ?", {1})
|
|
50
|
+
--- if result.success then
|
|
51
|
+
--- logi("查询到 " .. #result.rows .. " 条记录")
|
|
52
|
+
--- for _, row in ipairs(result.rows) do
|
|
53
|
+
--- logi(row)
|
|
54
|
+
--- end
|
|
55
|
+
--- else
|
|
56
|
+
--- loge("查询失败: " .. tostring(result.error))
|
|
57
|
+
--- end
|
|
38
58
|
function _MySQL.query(sql, params)
|
|
39
59
|
---@type MySQLResult
|
|
40
60
|
local ret
|
|
@@ -42,9 +62,18 @@ function _MySQL.query(sql, params)
|
|
|
42
62
|
end
|
|
43
63
|
|
|
44
64
|
--- 执行
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
---@param sql string SQL 语句
|
|
66
|
+
---@param params any[]|nil 参数数组,可选
|
|
67
|
+
---@return MySQLResult 执行结果对象
|
|
68
|
+
---@example local result = mysql.execute(
|
|
69
|
+
--- "INSERT INTO users (name, email) VALUES (?, ?)",
|
|
70
|
+
--- {"张三", "zhangsan@example.com"}
|
|
71
|
+
--- )
|
|
72
|
+
--- if result.success then
|
|
73
|
+
--- logi("影响了 " .. tostring(result.affectedRows) .. " 行")
|
|
74
|
+
--- else
|
|
75
|
+
--- loge("执行失败: " .. tostring(result.error))
|
|
76
|
+
--- end
|
|
48
77
|
function _MySQL.execute(sql, params)
|
|
49
78
|
---@type MySQLResult
|
|
50
79
|
local ret
|
|
@@ -52,15 +81,35 @@ function _MySQL.execute(sql, params)
|
|
|
52
81
|
end
|
|
53
82
|
|
|
54
83
|
--- 开始事务
|
|
55
|
-
|
|
84
|
+
---@return boolean 是否成功开始事务
|
|
85
|
+
---@example if mysql.beginTransaction() then
|
|
86
|
+
--- mysql.execute("INSERT INTO users (name) VALUES (?)", {"用户1"})
|
|
87
|
+
--- mysql.execute("INSERT INTO users (name) VALUES (?)", {"用户2"})
|
|
88
|
+
--- if mysql.commit() then
|
|
89
|
+
--- logi("事务提交成功")
|
|
90
|
+
--- else
|
|
91
|
+
--- mysql.rollback()
|
|
92
|
+
--- loge("事务回滚")
|
|
93
|
+
--- end
|
|
94
|
+
--- end
|
|
56
95
|
function _MySQL.beginTransaction() return true end
|
|
57
96
|
|
|
58
97
|
--- 提交
|
|
59
|
-
|
|
98
|
+
---@return boolean 是否成功提交
|
|
99
|
+
---@example mysql.beginTransaction()
|
|
100
|
+
--- mysql.execute("INSERT INTO users (name) VALUES (?)", {"测试用户"})
|
|
101
|
+
--- if mysql.commit() then
|
|
102
|
+
--- logi("事务提交成功")
|
|
103
|
+
--- end
|
|
60
104
|
function _MySQL.commit() return true end
|
|
61
105
|
|
|
62
106
|
--- 回滚
|
|
63
|
-
|
|
107
|
+
---@return boolean 是否成功回滚
|
|
108
|
+
---@example mysql.beginTransaction()
|
|
109
|
+
--- mysql.execute("INSERT INTO users (name) VALUES (?)", {"测试用户"})
|
|
110
|
+
--- if mysql.rollback() then
|
|
111
|
+
--- logi("事务回滚成功")
|
|
112
|
+
--- end
|
|
64
113
|
function _MySQL.rollback() return true end
|
|
65
114
|
|
|
66
115
|
---@type MySQL
|
package/types/lua/netcard.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- 卡密模块
|
|
2
3
|
---@class NetCard
|
|
3
4
|
local _NetCard = {}
|
|
4
5
|
|
|
@@ -10,16 +11,23 @@ local _NetCard = {}
|
|
|
10
11
|
---@field expireTime string 过期时间
|
|
11
12
|
|
|
12
13
|
--- 当前是否为授权卡密模式
|
|
13
|
-
|
|
14
|
+
---@return boolean 当前 App 处于授权卡密模式返回 true,否则返回 false
|
|
15
|
+
---@example if netcard.isAuthCardMode() then
|
|
16
|
+
--- logi("当前为授权卡密模式,不需要重复调用 verify")
|
|
17
|
+
--- end
|
|
14
18
|
function _NetCard.isAuthCardMode() return false end
|
|
15
19
|
|
|
16
20
|
--- 验证
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
---@param cardNo string 卡密
|
|
22
|
+
---@return boolean 是否验证成功
|
|
23
|
+
---@example local isVerified = netcard.verify("1234567890")
|
|
24
|
+
--- logi(isVerified)
|
|
19
25
|
function _NetCard.verify(cardNo) return true end
|
|
20
26
|
|
|
21
27
|
--- 卡信息
|
|
22
|
-
|
|
28
|
+
---@return CardInfo|nil 卡密信息
|
|
29
|
+
---@example local cardInfo = netcard.getCardInfo()
|
|
30
|
+
--- logi(ToJsonString(cardInfo))
|
|
23
31
|
function _NetCard.getCardInfo()
|
|
24
32
|
---@type CardInfo
|
|
25
33
|
local ret
|
|
@@ -27,19 +35,25 @@ function _NetCard.getCardInfo()
|
|
|
27
35
|
end
|
|
28
36
|
|
|
29
37
|
--- 设置备注
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
---@param remark string 备注
|
|
39
|
+
---@return boolean 是否设置成功
|
|
40
|
+
---@example local isSet = netcard.setCardRemark("我的卡密")
|
|
41
|
+
--- logi(isSet)
|
|
32
42
|
function _NetCard.setCardRemark(remark) return true end
|
|
33
43
|
|
|
34
44
|
--- 设置值
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
45
|
+
---@param key string 键
|
|
46
|
+
---@param value string 值
|
|
47
|
+
---@return string 成功返回设置的value,失败返回空字符串
|
|
48
|
+
---@example local value = netcard.setValue("cardNo", "1234567890")
|
|
49
|
+
--- logi(value)
|
|
38
50
|
function _NetCard.setValue(key, value) return '' end
|
|
39
51
|
|
|
40
52
|
--- 获取值
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
---@param key string 键
|
|
54
|
+
---@return string 成功返回值,失败返回空字符串
|
|
55
|
+
---@example local value = netcard.getValue("cardNo")
|
|
56
|
+
--- logi(value)
|
|
43
57
|
function _NetCard.getValue(key) return '' end
|
|
44
58
|
|
|
45
59
|
---@type NetCard
|
package/types/lua/node.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- 节点模块
|
|
2
3
|
---@class Node
|
|
3
4
|
local _Node = {}
|
|
4
5
|
|
|
@@ -74,8 +75,9 @@ local _Node = {}
|
|
|
74
75
|
---@field bounds fun(self: NodeSelector, x: integer, y: integer, width: integer, height: integer): NodeSelector 设置边界
|
|
75
76
|
|
|
76
77
|
--- 创建选择器。可用 `local selector <close> = ...` 自动释放,或用完后 `selector:releaseNode()` 手动释放。
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
---@param params SelectorParams|nil
|
|
79
|
+
---@return NodeSelector 选择器
|
|
80
|
+
---@example node.createNodeSelector(params)
|
|
79
81
|
function _Node.createNodeSelector(params)
|
|
80
82
|
---@type NodeSelector
|
|
81
83
|
local ret
|
package/types/lua/paddleocr.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- PaddleOCR模块
|
|
2
3
|
---@class PaddleOCR
|
|
3
4
|
local _PaddleOCR = {}
|
|
4
5
|
|
|
@@ -17,24 +18,32 @@ local _PaddleOCR = {}
|
|
|
17
18
|
---@field orientation integer 文本方向 (0=水平,1=垂直 等)
|
|
18
19
|
|
|
19
20
|
--- 按内置模型 ID 加载
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
---@param modelId string 模型 ID,必须传入,支持 "ppocr-v6-tiny"、"ppocr-v6-small"、"ppocr-v5"
|
|
22
|
+
---@param useGpu boolean|nil 是否使用GPU,默认false,可不传
|
|
23
|
+
---@return boolean 加载成功或目标模型已加载返回true
|
|
24
|
+
---@example local ok = paddleocr.loadModel("ppocr-v6-small", false)
|
|
25
|
+
--- logi("PaddleOCR 模型加载结果: " .. ok)
|
|
23
26
|
function _PaddleOCR.loadModel(modelId, useGpu) return true end
|
|
24
27
|
|
|
25
28
|
--- 设置检测长边;0 或负数时使用 768
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
---@param maxSideLen integer|nil 最大边长,默认768;传 0 或负数时使用默认值 768
|
|
30
|
+
---@return boolean 设置成功返回true
|
|
31
|
+
---@example paddleocr.setMaxSideLen(960)
|
|
32
|
+
--- local results = paddleocr.recognizeAbs("screen", 0, 0, 0, 0)
|
|
28
33
|
function _PaddleOCR.setMaxSideLen(maxSideLen) return true end
|
|
29
34
|
|
|
30
35
|
--- 识别文本,坐标映射为原图/全屏绝对坐标
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
---@param input string 输入源(imageId、URL字符串、文件路径或"screen","screen"表示使用当前屏幕)
|
|
37
|
+
---@param x integer|nil 裁剪区域左上角 x 坐标,全屏传 0,默认 0
|
|
38
|
+
---@param y integer|nil 裁剪区域左上角 y 坐标,全屏传 0,默认 0
|
|
39
|
+
---@param ex integer|nil 裁剪区域右下角 x 坐标,全屏传 0,默认 0
|
|
40
|
+
---@param ey integer|nil 裁剪区域右下角 y 坐标,全屏传 0,默认 0
|
|
41
|
+
---@param confidenceThreshold number|nil 置信度阈值,默认 0.6
|
|
42
|
+
---@return PaddleOCRResult[] 识别结果数组,坐标为原图/全屏绝对坐标
|
|
43
|
+
---@example local results = paddleocr.recognizeAbs("screen", 100, 100, 500, 300)
|
|
44
|
+
--- if #results > 0 then
|
|
45
|
+
--- action.click(results[0].centerX, results[0].centerY)
|
|
46
|
+
--- end
|
|
38
47
|
function _PaddleOCR.recognizeAbs(input, x, y, ex, ey, confidenceThreshold)
|
|
39
48
|
---@type PaddleOCRResult[]
|
|
40
49
|
local ret = {}
|
|
@@ -42,15 +51,19 @@ function _PaddleOCR.recognizeAbs(input, x, y, ex, ey, confidenceThreshold)
|
|
|
42
51
|
end
|
|
43
52
|
|
|
44
53
|
--- 查找目标文本,坐标映射为原图/全屏绝对坐标
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
---@param input string 输入源(imageId、URL字符串、文件路径或"screen","screen"表示使用当前屏幕)
|
|
55
|
+
---@param targets string[]|string 目标文本数组,例如 ["你好", "确定"]
|
|
56
|
+
---@param x integer|nil 裁剪区域左上角 x 坐标,全屏传 0,默认 0
|
|
57
|
+
---@param y integer|nil 裁剪区域左上角 y 坐标,全屏传 0,默认 0
|
|
58
|
+
---@param ex integer|nil 裁剪区域右下角 x 坐标,全屏传 0,默认 0
|
|
59
|
+
---@param ey integer|nil 裁剪区域右下角 y 坐标,全屏传 0,默认 0
|
|
60
|
+
---@param confidenceThreshold number|nil 置信度阈值,默认 0.6
|
|
61
|
+
---@param exactMatch boolean|nil 是否完整匹配,默认 false 表示包含匹配;传 true 时要求整条 OCR 识别结果文本等于目标文本
|
|
62
|
+
---@return PaddleOCRResult[] 匹配到的子串结果数组,坐标为原图/全屏绝对坐标
|
|
63
|
+
---@example local results = paddleocr.findTextAbs("screen", {"确定"}, 100, 100, 500, 300, 0.6)
|
|
64
|
+
--- if #results > 0 then
|
|
65
|
+
--- action.click(results[0].centerX, results[0].centerY)
|
|
66
|
+
--- end
|
|
54
67
|
function _PaddleOCR.findTextAbs(input, targets, x, y, ex, ey, confidenceThreshold, exactMatch)
|
|
55
68
|
---@type PaddleOCRResult[]
|
|
56
69
|
local ret = {}
|
|
@@ -58,6 +71,7 @@ function _PaddleOCR.findTextAbs(input, targets, x, y, ex, ey, confidenceThreshol
|
|
|
58
71
|
end
|
|
59
72
|
|
|
60
73
|
--- 释放资源
|
|
74
|
+
---@example paddleocr.free()
|
|
61
75
|
function _PaddleOCR.free() end
|
|
62
76
|
|
|
63
77
|
---@type PaddleOCR
|
package/types/lua/pip.lua
CHANGED
|
@@ -1,56 +1,68 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- 悬浮窗模块
|
|
2
3
|
---@class Pip
|
|
3
4
|
local _Pip = {}
|
|
4
5
|
|
|
5
6
|
--- 悬浮窗是否打开
|
|
6
|
-
---@return boolean
|
|
7
|
+
---@return boolean true代表开启了悬浮窗,false代表没有开启
|
|
8
|
+
---@example pip.isPipActive()
|
|
7
9
|
function _Pip.isPipActive() return false end
|
|
8
10
|
|
|
9
11
|
--- 切换到日志模式(首次显示时 App 须在前台)
|
|
10
|
-
---@return boolean
|
|
12
|
+
---@return boolean true代表已提交切换请求
|
|
13
|
+
---@example pip.switchToLogMode()
|
|
11
14
|
function _Pip.switchToLogMode() return true end
|
|
12
15
|
|
|
13
16
|
--- 切换到保活模式(首次显示时 App 须在前台)
|
|
14
|
-
---@return boolean
|
|
17
|
+
---@return boolean true代表已提交切换请求
|
|
18
|
+
---@example pip.switchToKeepAliveMode()
|
|
15
19
|
function _Pip.switchToKeepAliveMode() return true end
|
|
16
20
|
|
|
17
21
|
--- 切换到自定义模式(首次显示时 App 须在前台)
|
|
18
|
-
---@return boolean
|
|
22
|
+
---@return boolean true代表已提交切换请求
|
|
23
|
+
---@example pip.switchToCustomMode()
|
|
19
24
|
function _Pip.switchToCustomMode() return true end
|
|
20
25
|
|
|
21
26
|
--- 关闭悬浮窗
|
|
22
|
-
---@return boolean
|
|
27
|
+
---@return boolean true代表已提交关闭请求
|
|
28
|
+
---@example pip.closeWindow()
|
|
23
29
|
function _Pip.closeWindow() return true end
|
|
24
30
|
|
|
25
31
|
--- 设置日志/自定义模式内容宽高比(不是最终像素)
|
|
26
|
-
---@param width number
|
|
27
|
-
---@param height number
|
|
28
|
-
---@return boolean
|
|
32
|
+
---@param width number 宽度方向比例值(与 height 共同决定宽高比,不是像素)
|
|
33
|
+
---@param height number 高度方向比例值(与 width 共同决定宽高比,不是像素)
|
|
34
|
+
---@return boolean true代表尺寸已提交,false代表当前模式不允许设置或宽高无效
|
|
35
|
+
---@example pip.setContentSize(width, height)
|
|
29
36
|
function _Pip.setContentSize(width, height) return true end
|
|
30
37
|
|
|
31
38
|
--- 设置日志字号;缺省 8
|
|
32
|
-
---@param fontSize number|nil
|
|
33
|
-
---@return boolean
|
|
39
|
+
---@param fontSize number|nil 日志字号,必须是有效数字
|
|
40
|
+
---@return boolean true代表日志文字大小已提交,false代表字号无效
|
|
41
|
+
---@example pip.setLogFontSize(fontSize)
|
|
34
42
|
function _Pip.setLogFontSize(fontSize) return true end
|
|
35
43
|
|
|
36
44
|
--- 设置自定义文本(不自动切模式)
|
|
37
|
-
---@param text string
|
|
38
|
-
---@return boolean
|
|
45
|
+
---@param text string 要显示的文本,支持换行
|
|
46
|
+
---@return boolean true代表文本已提交
|
|
47
|
+
---@example pip.setCustomText(text)
|
|
39
48
|
function _Pip.setCustomText(text) return true end
|
|
40
49
|
|
|
41
50
|
--- 设置自定义文字颜色,支持 RRGGBB / RRGGBBAA
|
|
42
|
-
---@param color string
|
|
43
|
-
---@return boolean
|
|
51
|
+
---@param color string 文字颜色,支持 RRGGBB、RRGGBBAA,可带 # 前缀;末尾 AA 为透明度
|
|
52
|
+
---@return boolean true代表文字颜色已提交
|
|
53
|
+
---@example pip.setCustomTextColor(color)
|
|
44
54
|
function _Pip.setCustomTextColor(color) return true end
|
|
45
55
|
|
|
46
56
|
--- 设置自定义文字大小;缺省 12
|
|
47
|
-
---@param fontSize number|nil
|
|
48
|
-
---@return boolean
|
|
57
|
+
---@param fontSize number|nil 文字字号,必须是有效数字
|
|
58
|
+
---@return boolean true代表文字大小已提交,false代表字号无效
|
|
59
|
+
---@example pip.setCustomTextSize(fontSize)
|
|
49
60
|
function _Pip.setCustomTextSize(fontSize) return true end
|
|
50
61
|
|
|
51
62
|
--- 设置自定义背景色
|
|
52
|
-
---@param color string
|
|
53
|
-
---@return boolean
|
|
63
|
+
---@param color string 背景颜色,支持 RRGGBB、RRGGBBAA,可带 # 前缀;末尾 AA 为透明度
|
|
64
|
+
---@return boolean true代表背景色已提交
|
|
65
|
+
---@example pip.setCustomBackgroundColor(color)
|
|
54
66
|
function _Pip.setCustomBackgroundColor(color) return true end
|
|
55
67
|
|
|
56
68
|
---@type Pip
|
package/types/lua/system.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- 系统模块
|
|
2
3
|
---@class System
|
|
3
4
|
local _System = {}
|
|
4
5
|
|
|
@@ -14,22 +15,38 @@ local _System = {}
|
|
|
14
15
|
---@field usagePercentage integer 使用率(0-100)
|
|
15
16
|
|
|
16
17
|
--- 启动应用
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
---@param bundleId string 应用bundleId
|
|
19
|
+
---@return boolean 是否启动成功
|
|
20
|
+
---@example local started = system.startApp("cn.magicnode.script")
|
|
21
|
+
--- if started then
|
|
22
|
+
--- logi("启动成功")
|
|
23
|
+
--- end
|
|
19
24
|
function _System.startApp(bundleId) return true end
|
|
20
25
|
|
|
21
26
|
--- 停止应用
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
---@param bundleId string 应用bundleId
|
|
28
|
+
---@return boolean 是否关闭成功
|
|
29
|
+
---@example local stopped = system.stopApp("cn.magicnode.script")
|
|
30
|
+
--- if stopped then
|
|
31
|
+
--- logi("关闭成功")
|
|
32
|
+
--- end
|
|
24
33
|
function _System.stopApp(bundleId) return true end
|
|
25
34
|
|
|
26
35
|
--- 激活应用到前台(未启动则启动)
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
---@param bundleId string 应用bundleId
|
|
37
|
+
---@return boolean 是否激活成功
|
|
38
|
+
---@example local activated = system.activateApp("cn.magicnode.script")
|
|
39
|
+
--- if activated then
|
|
40
|
+
--- logi("激活成功")
|
|
41
|
+
--- end
|
|
29
42
|
function _System.activateApp(bundleId) return true end
|
|
30
43
|
|
|
31
44
|
--- 获取当前运行的应用信息(可能为 nil)
|
|
32
|
-
|
|
45
|
+
---@return ActivateAppInfo|nil 当前在前台的应用信息
|
|
46
|
+
---@example local info = system.activateAppInfo()
|
|
47
|
+
--- if info then
|
|
48
|
+
--- logi(info.name)
|
|
49
|
+
--- end
|
|
33
50
|
function _System.activateAppInfo()
|
|
34
51
|
---@type ActivateAppInfo
|
|
35
52
|
local info
|
|
@@ -37,7 +54,8 @@ function _System.activateAppInfo()
|
|
|
37
54
|
end
|
|
38
55
|
|
|
39
56
|
--- 前台运行的应用列表
|
|
40
|
-
|
|
57
|
+
---@return ActivateAppInfo[] 包含应用信息的字典数组,每个字典包含应用的Bundle ID和显示名称
|
|
58
|
+
---@example system.foregroundAppInfos()
|
|
41
59
|
function _System.foregroundAppInfos() return {} end
|
|
42
60
|
|
|
43
61
|
---@class InstalledAppInfo
|
|
@@ -46,51 +64,90 @@ function _System.foregroundAppInfos() return {} end
|
|
|
46
64
|
---@field bundleIdentifier string Bundle ID
|
|
47
65
|
|
|
48
66
|
--- 后台运行的应用列表
|
|
49
|
-
|
|
67
|
+
---@return ActivateAppInfo[] 包含应用信息的字典数组,每个字典包含应用的Bundle ID和显示名称
|
|
68
|
+
---@example local apps = system.backgroundAppInfos()
|
|
69
|
+
--- if #apps > 0 then
|
|
70
|
+
--- logi(apps[0].name)
|
|
71
|
+
--- end
|
|
50
72
|
function _System.backgroundAppInfos() return {} end
|
|
51
73
|
|
|
52
74
|
--- 已安装应用列表
|
|
53
|
-
|
|
75
|
+
---@return InstalledAppInfo[] 包含应用信息的字典数组,每个字典包含应用的Bundle ID和显示名称
|
|
76
|
+
---@example local apps = system.getInstalledAppList()
|
|
77
|
+
--- if #apps > 0 then
|
|
78
|
+
--- logi(apps[0].appName)
|
|
79
|
+
--- end
|
|
54
80
|
function _System.getInstalledAppList() return {} end
|
|
55
81
|
|
|
56
82
|
--- 打开 App 切换器
|
|
57
|
-
|
|
83
|
+
---@return boolean 是否打开成功
|
|
84
|
+
---@example local opened = system.recent()
|
|
85
|
+
--- if opened then
|
|
86
|
+
--- logi("打开成功")
|
|
87
|
+
--- end
|
|
58
88
|
function _System.recent() return true end
|
|
59
89
|
|
|
60
90
|
--- 使用系统浏览器打开 URL
|
|
61
|
-
|
|
62
|
-
|
|
91
|
+
---@param url string URL
|
|
92
|
+
---@return boolean 是否打开成功
|
|
93
|
+
---@example local opened = system.openURL("https://www.baidu.com")
|
|
94
|
+
--- if opened then
|
|
95
|
+
--- logi("打开成功")
|
|
96
|
+
--- end
|
|
63
97
|
function _System.openURL(url) return true end
|
|
64
98
|
|
|
65
99
|
--- 发送系统通知(后台生效)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
100
|
+
---@param msg string 通知内容
|
|
101
|
+
---@param title string|nil 通知标题
|
|
102
|
+
---@param id string|nil 通知id 通知id相同的会被覆盖
|
|
103
|
+
---@example system.notify("通知内容", "通知标题", "1111")
|
|
69
104
|
function _System.notify(msg, title, id) end
|
|
70
105
|
|
|
71
106
|
--- 设置剪贴板文本(仅前台有效)
|
|
72
|
-
|
|
73
|
-
|
|
107
|
+
---@param s string 剪贴板内容
|
|
108
|
+
---@return boolean 是否设置成功
|
|
109
|
+
---@example local set = system.setClipboard("hello")
|
|
110
|
+
--- if set then
|
|
111
|
+
--- logi("设置成功")
|
|
112
|
+
--- end
|
|
74
113
|
function _System.setClipboard(s) return true end
|
|
75
114
|
|
|
76
115
|
--- 获取剪贴板文本(仅前台有效)
|
|
77
|
-
|
|
116
|
+
---@return string 剪贴板内容
|
|
117
|
+
---@example local text = system.getClipboard()
|
|
118
|
+
--- if text then
|
|
119
|
+
--- logi(text)
|
|
120
|
+
--- end
|
|
78
121
|
function _System.getClipboard() return '' end
|
|
79
122
|
|
|
80
123
|
--- 是否锁屏
|
|
81
|
-
|
|
124
|
+
---@return boolean 是否锁屏
|
|
125
|
+
---@example local locked = system.isLocked()
|
|
126
|
+
--- if locked then
|
|
127
|
+
--- logi("锁屏")
|
|
128
|
+
--- end
|
|
82
129
|
function _System.isLocked() return false end
|
|
83
130
|
|
|
84
131
|
--- 锁屏
|
|
85
|
-
|
|
132
|
+
---@return boolean 是否锁屏成功
|
|
133
|
+
---@example local locked = system.lock()
|
|
134
|
+
--- if locked then
|
|
135
|
+
--- logi("锁屏成功")
|
|
136
|
+
--- end
|
|
86
137
|
function _System.lock() return true end
|
|
87
138
|
|
|
88
139
|
--- 解锁
|
|
89
|
-
|
|
140
|
+
---@return boolean 是否解锁成功
|
|
141
|
+
---@example local unlocked = system.unlock()
|
|
142
|
+
--- if unlocked then
|
|
143
|
+
--- logi("解锁成功")
|
|
144
|
+
--- end
|
|
90
145
|
function _System.unlock() return true end
|
|
91
146
|
|
|
92
147
|
--- 获取内存使用信息(MB)
|
|
93
|
-
|
|
148
|
+
---@return MemoryInfo 内存使用信息,包含应用占用、系统可用/总量、系统已用和系统占用率(单位:MB)
|
|
149
|
+
---@example local memInfo = system.getMemoryInfo()
|
|
150
|
+
--- logi("应用: " .. memInfo.used .. "MB, 系统: " .. memInfo.systemUsed .. "/" .. memInfo.total .. "MB, 占用: " .. memInfo.usagePercentage .. "%")
|
|
94
151
|
function _System.getMemoryInfo()
|
|
95
152
|
---@type MemoryInfo
|
|
96
153
|
local ret
|
|
@@ -98,35 +155,59 @@ function _System.getMemoryInfo()
|
|
|
98
155
|
end
|
|
99
156
|
|
|
100
157
|
--- 获取已使用内存(MB)
|
|
101
|
-
|
|
158
|
+
---@return integer 已使用内存大小(单位:MB)
|
|
159
|
+
---@example local usedMemory = system.getUsedMemory()
|
|
160
|
+
--- logi("已使用内存: " .. usedMemory .. "MB")
|
|
102
161
|
function _System.getUsedMemory() return 0 end
|
|
103
162
|
|
|
104
163
|
--- 获取可用内存(MB)
|
|
105
|
-
|
|
164
|
+
---@return integer 可用内存大小(单位:MB)
|
|
165
|
+
---@example local availableMemory = system.getAvailableMemory()
|
|
166
|
+
--- logi("可用内存: " .. availableMemory .. "MB")
|
|
106
167
|
function _System.getAvailableMemory() return 0 end
|
|
107
168
|
|
|
108
169
|
--- 获取系统总内存(MB)
|
|
109
|
-
|
|
170
|
+
---@return integer 系统总内存大小(单位:MB)
|
|
171
|
+
---@example local totalMemory = system.getTotalMemory()
|
|
172
|
+
--- logi("系统总内存: " .. totalMemory .. "MB")
|
|
110
173
|
function _System.getTotalMemory() return 0 end
|
|
111
174
|
|
|
112
175
|
--- 获取系统已用内存(MB)
|
|
113
|
-
|
|
176
|
+
---@return number 系统已用内存大小(单位:MB,物理内存总量减去可用内存)
|
|
177
|
+
---@example local systemUsed = system.getSystemUsedMemory()
|
|
178
|
+
--- logi("系统已用内存: " .. systemUsed .. "MB")
|
|
114
179
|
function _System.getSystemUsedMemory() return 0 end
|
|
115
180
|
|
|
116
181
|
--- 获取 CPU 使用率
|
|
117
|
-
|
|
182
|
+
---@return number 当前应用 CPU 使用率(百分比)
|
|
183
|
+
---@example local cpuUsage = system.getCpuUsage()
|
|
184
|
+
--- logi("CPU 使用率: " .. cpuUsage .. "%")
|
|
118
185
|
function _System.getCpuUsage() return 0 end
|
|
119
186
|
|
|
120
187
|
--- 启动 Agent 服务
|
|
121
|
-
|
|
188
|
+
---@return boolean 是否启动成功
|
|
189
|
+
---@example local started = system.startAgent()
|
|
190
|
+
--- if started then
|
|
191
|
+
--- logi("Agent 启动成功")
|
|
192
|
+
--- end
|
|
122
193
|
function _System.startAgent() return true end
|
|
123
194
|
|
|
124
195
|
--- 获取 Agent 状态(是否正在运行)
|
|
125
|
-
|
|
196
|
+
---@return boolean Agent 是否正在运行
|
|
197
|
+
---@example local isRunning = system.getAgentStatus()
|
|
198
|
+
--- if isRunning then
|
|
199
|
+
--- logi("Agent 服务正在运行")
|
|
200
|
+
--- else
|
|
201
|
+
--- logi("Agent 服务未运行")
|
|
202
|
+
--- end
|
|
126
203
|
function _System.getAgentStatus() return false end
|
|
127
204
|
|
|
128
205
|
--- 停止 Agent 服务
|
|
129
|
-
|
|
206
|
+
---@return boolean 是否关闭成功
|
|
207
|
+
---@example local stopped = system.stopAgent()
|
|
208
|
+
--- if stopped then
|
|
209
|
+
--- logi("Agent 服务关闭成功")
|
|
210
|
+
--- end
|
|
130
211
|
function _System.stopAgent() return true end
|
|
131
212
|
|
|
132
213
|
---@type System
|