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/device.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- 设备模块
|
|
2
3
|
---@class Device
|
|
3
4
|
local _Device = {}
|
|
4
5
|
|
|
@@ -16,80 +17,97 @@ local _Device = {}
|
|
|
16
17
|
---@field unit string 单位,固定 "GB"
|
|
17
18
|
|
|
18
19
|
--- 获取电池信息
|
|
19
|
-
---@return BatteryInfo
|
|
20
|
+
---@return BatteryInfo 电池信息
|
|
21
|
+
---@example device.getBatteryInfo()
|
|
20
22
|
function _Device.getBatteryInfo()
|
|
21
23
|
return { level = 0, isCharging = false }
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
--- 获取存储空间(GB,十进制)
|
|
25
|
-
---@return StorageSpaceInfo
|
|
27
|
+
---@return StorageSpaceInfo 存储空间状态,包含 total、free、unit
|
|
28
|
+
---@example device.getStorageSpace()
|
|
26
29
|
function _Device.getStorageSpace()
|
|
27
30
|
return { total = 0, free = 0, unit = 'GB' }
|
|
28
31
|
end
|
|
29
32
|
|
|
30
33
|
--- 设备 ID(卸载重装会变)
|
|
31
|
-
---@return string
|
|
34
|
+
---@return string 设备ID
|
|
35
|
+
---@example device.getDeviceID()
|
|
32
36
|
function _Device.getDeviceID() return '' end
|
|
33
37
|
|
|
34
38
|
--- ECID
|
|
35
|
-
---@return string
|
|
39
|
+
---@return string ECID
|
|
40
|
+
---@example device.getECID()
|
|
36
41
|
function _Device.getECID() return '' end
|
|
37
42
|
|
|
38
43
|
--- UDID
|
|
39
|
-
---@return string
|
|
44
|
+
---@return string UDID
|
|
45
|
+
---@example device.getUDID()
|
|
40
46
|
function _Device.getUDID() return '' end
|
|
41
47
|
|
|
42
48
|
--- 设备名
|
|
43
|
-
---@return string
|
|
49
|
+
---@return string 设备名称
|
|
50
|
+
---@example device.getDeviceName()
|
|
44
51
|
function _Device.getDeviceName() return '' end
|
|
45
52
|
|
|
46
53
|
--- 设备型号
|
|
47
|
-
---@return string
|
|
54
|
+
---@return string 设备型号
|
|
55
|
+
---@example device.getDeviceModel()
|
|
48
56
|
function _Device.getDeviceModel() return '' end
|
|
49
57
|
|
|
50
58
|
--- 屏幕实际尺寸
|
|
51
|
-
---@return ScreenSize
|
|
59
|
+
---@return ScreenSize 屏幕实际大小
|
|
60
|
+
---@example device.getScreenRealSize()
|
|
52
61
|
function _Device.getScreenRealSize()
|
|
53
62
|
return { width = 0, height = 0 }
|
|
54
63
|
end
|
|
55
64
|
|
|
56
65
|
--- 屏幕缩放比例
|
|
57
|
-
---@return number
|
|
66
|
+
---@return number 屏幕缩放比例
|
|
67
|
+
---@example device.getScreenScale()
|
|
58
68
|
function _Device.getScreenScale() return 1 end
|
|
59
69
|
|
|
60
70
|
--- 屏幕亮度 0.0-1.0
|
|
61
|
-
---@return number
|
|
71
|
+
---@return number 屏幕亮度,范围 0.0-1.0
|
|
72
|
+
---@example device.getScreenBrightness()
|
|
62
73
|
function _Device.getScreenBrightness() return 0 end
|
|
63
74
|
|
|
64
75
|
--- 设置屏幕亮度 0.0-1.0
|
|
65
|
-
---@param brightness number
|
|
66
|
-
---@return boolean
|
|
76
|
+
---@param brightness number 目标屏幕亮度,范围 0.0-1.0
|
|
77
|
+
---@return boolean 是否设置成功
|
|
78
|
+
---@example device.setScreenBrightness(0.5)
|
|
67
79
|
function _Device.setScreenBrightness(brightness) return true end
|
|
68
80
|
|
|
69
81
|
--- 系统音量 0.0-1.0
|
|
70
|
-
---@return number
|
|
82
|
+
---@return number 系统音量,范围 0.0-1.0
|
|
83
|
+
---@example device.getVolume()
|
|
71
84
|
function _Device.getVolume() return 0 end
|
|
72
85
|
|
|
73
86
|
--- 设置系统音量 0.0-1.0
|
|
74
|
-
---@param volume number
|
|
75
|
-
---@return boolean
|
|
87
|
+
---@param volume number 目标系统音量,范围 0.0-1.0
|
|
88
|
+
---@return boolean 是否设置成功
|
|
89
|
+
---@example device.setVolume(0.5)
|
|
76
90
|
function _Device.setVolume(volume) return true end
|
|
77
91
|
|
|
78
92
|
--- 屏幕方向
|
|
79
|
-
---@return string
|
|
93
|
+
---@return string 设备方向
|
|
94
|
+
---@example device.getOrientation()
|
|
80
95
|
function _Device.getOrientation() return 'PORTRAIT' end
|
|
81
96
|
|
|
82
97
|
--- 系统版本
|
|
83
|
-
---@return string
|
|
98
|
+
---@return string 系统版本
|
|
99
|
+
---@example device.getOSVersion()
|
|
84
100
|
function _Device.getOSVersion() return '' end
|
|
85
101
|
|
|
86
102
|
--- 局域网 IP
|
|
87
|
-
---@return string
|
|
103
|
+
---@return string 局域网IP
|
|
104
|
+
---@example device.getLanIp()
|
|
88
105
|
function _Device.getLanIp() return '' end
|
|
89
106
|
|
|
90
107
|
--- 震动
|
|
91
|
-
---@param duration integer
|
|
92
|
-
---@param intensity number 0.0-1.0
|
|
108
|
+
---@param duration integer 持续时间 单位毫秒
|
|
109
|
+
---@param intensity number 强度 0.0-1.0
|
|
110
|
+
---@example device.vibrate(1000, 0.5)
|
|
93
111
|
function _Device.vibrate(duration, intensity) end
|
|
94
112
|
|
|
95
113
|
---@type Device
|
package/types/lua/dotocr.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- 点阵OCR模块
|
|
2
3
|
---@class DotOCR
|
|
3
4
|
local _DotOCR = {}
|
|
4
5
|
|
|
@@ -18,14 +19,17 @@ local _DotOCR = {}
|
|
|
18
19
|
|
|
19
20
|
--- 从资源路径加载字库并缓存
|
|
20
21
|
---@param fontPath string
|
|
21
|
-
---@return string|nil
|
|
22
|
+
---@return string|nil 成功返回字库 ID,失败返回 `null`
|
|
23
|
+
---@example dotocr.loadFont(fontPath)
|
|
22
24
|
function _DotOCR.loadFont(fontPath) return nil end
|
|
23
25
|
|
|
24
26
|
--- 释放指定字库
|
|
25
27
|
---@param fontId string
|
|
28
|
+
---@example dotocr.free(fontId)
|
|
26
29
|
function _DotOCR.free(fontId) end
|
|
27
30
|
|
|
28
31
|
--- 释放全部已加载的点阵字库
|
|
32
|
+
---@example dotocr.freeAll()
|
|
29
33
|
function _DotOCR.freeAll() end
|
|
30
34
|
|
|
31
35
|
--- 识别文字并返回原图或全屏绝对坐标
|
|
@@ -35,8 +39,9 @@ function _DotOCR.freeAll() end
|
|
|
35
39
|
---@param y integer|nil
|
|
36
40
|
---@param ex integer|nil
|
|
37
41
|
---@param ey integer|nil
|
|
38
|
-
---@param confidenceThreshold number|nil
|
|
42
|
+
---@param confidenceThreshold number|nil 相似度下限;`<=0` 时按 `0.95`;`>0.95` 时要求像素完全一致
|
|
39
43
|
---@return OCRChar[]
|
|
44
|
+
---@example dotocr.recognizeAbs(fontId, input, x, y, ex, ey, confidenceThreshold)
|
|
40
45
|
function _DotOCR.recognizeAbs(fontId, input, x, y, ex, ey, confidenceThreshold)
|
|
41
46
|
---@type OCRChar[]
|
|
42
47
|
local ret = {}
|
|
@@ -54,6 +59,7 @@ end
|
|
|
54
59
|
---@param confidenceThreshold number|nil
|
|
55
60
|
---@param exactMatch boolean|nil
|
|
56
61
|
---@return OCRChar[]
|
|
62
|
+
---@example dotocr.findTextAbs(fontId, input, targetTexts, x, y, ex, ey, confidenceThreshold, exactMatch)
|
|
57
63
|
function _DotOCR.findTextAbs(fontId, input, targetTexts, x, y, ex, ey, confidenceThreshold, exactMatch)
|
|
58
64
|
---@type OCRChar[]
|
|
59
65
|
local ret = {}
|
package/types/lua/file.lua
CHANGED
|
@@ -1,96 +1,117 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- 文件模块
|
|
2
3
|
---@class File
|
|
3
4
|
local _File = {}
|
|
4
5
|
|
|
5
6
|
--- 获取内部目录
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
---@param key string 目录类型
|
|
8
|
+
---@return string 目录路径
|
|
9
|
+
---@example file.getInternalDir("documents")
|
|
8
10
|
function _File.getInternalDir(key) return '' end
|
|
9
11
|
|
|
10
12
|
--- 创建文件
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
---@param path string 文件路径
|
|
14
|
+
---@return boolean 是否创建成功
|
|
15
|
+
---@example file.create("config.json")
|
|
13
16
|
function _File.create(path) return true end
|
|
14
17
|
|
|
15
18
|
--- 创建目录
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
---@param path string 目录路径
|
|
20
|
+
---@return boolean 是否创建成功
|
|
21
|
+
---@example file.mkdirs("config")
|
|
18
22
|
function _File.mkdirs(path) return true end
|
|
19
23
|
|
|
20
24
|
--- 读取文件
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
---@param path string 文件路径
|
|
26
|
+
---@return string 文件内容,如果读取失败返回 null
|
|
27
|
+
---@example file.readFile("config.json")
|
|
23
28
|
function _File.readFile(path) return '' end
|
|
24
29
|
|
|
25
30
|
--- 写入文件
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
---@param path string 文件路径
|
|
32
|
+
---@param content string 文件内容
|
|
33
|
+
---@return boolean 是否写入成功
|
|
34
|
+
---@example file.writeFile("config.json", "name=agent")
|
|
29
35
|
function _File.writeFile(path, content) return true end
|
|
30
36
|
|
|
31
37
|
--- 是否存在
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
---@param path string 文件路径
|
|
39
|
+
---@return boolean 是否存在
|
|
40
|
+
---@example file.exists("config.json")
|
|
34
41
|
function _File.exists(path) return true end
|
|
35
42
|
|
|
36
43
|
--- 删除所有文件/目录
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
---@param path string 文件或目录路径
|
|
45
|
+
---@return boolean 是否删除成功
|
|
46
|
+
---@example file.deleteAllFile("config")
|
|
39
47
|
function _File.deleteAllFile(path) return true end
|
|
40
48
|
|
|
41
49
|
--- 读取资源文件(res 目录)
|
|
42
|
-
|
|
43
|
-
|
|
50
|
+
---@param name string 文件名
|
|
51
|
+
---@return string 文件内容
|
|
52
|
+
---@example file.readResFile("test.txt")
|
|
44
53
|
function _File.readResFile(name) return '' end
|
|
45
54
|
|
|
46
55
|
--- 获取 res 资源的本地文件路径;用完后应调用 cleanupResFile
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
---@param name string 相对 res 目录的资源路径
|
|
57
|
+
---@return string|nil 本地文件绝对路径,失败返回 null
|
|
58
|
+
---@example local path = file.getResFile("model.bin")
|
|
59
|
+
--- if path then
|
|
60
|
+
--- file.cleanupResFile(path)
|
|
61
|
+
--- end
|
|
49
62
|
function _File.getResFile(name) return nil end
|
|
50
63
|
|
|
51
64
|
--- 清理由 getResFile 得到的本地临时文件
|
|
52
|
-
|
|
65
|
+
---@param path string getResFile 返回的文件路径
|
|
66
|
+
---@example file.cleanupResFile(path)
|
|
53
67
|
function _File.cleanupResFile(path) end
|
|
54
68
|
|
|
55
69
|
--- 删除指定行或包含内容的行
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
70
|
+
---@param path string 文件路径
|
|
71
|
+
---@param line integer 行号 如果是-1 代表这个条件不生效
|
|
72
|
+
---@param contains string 包含内容 如果是null 代表这个条件不生效
|
|
73
|
+
---@return boolean 是否删除成功
|
|
74
|
+
---@example file.deleteLine("config.json", 1, nil)
|
|
60
75
|
function _File.deleteLine(path, line, contains) return true end
|
|
61
76
|
|
|
62
77
|
--- 列出目录
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
78
|
+
---@param path string 目录路径
|
|
79
|
+
---@param recursion boolean 是否递归
|
|
80
|
+
---@return string[] 文件路径数组
|
|
81
|
+
---@example file.listDir("config", true)
|
|
66
82
|
function _File.listDir(path, recursion) return {} end
|
|
67
83
|
|
|
68
84
|
--- 追加一行
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
85
|
+
---@param path string 文件路径
|
|
86
|
+
---@param data string 文件内容
|
|
87
|
+
---@return boolean 是否追加成功
|
|
88
|
+
---@example file.appendLine("config.json", "name=agent")
|
|
72
89
|
function _File.appendLine(path, data) return true end
|
|
73
90
|
|
|
74
91
|
--- 读取指定行
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
92
|
+
---@param path string 文件路径
|
|
93
|
+
---@param lineNo integer 行号
|
|
94
|
+
---@return string 行内容,如果读取失败返回 null
|
|
95
|
+
---@example file.readLine("config.json", 1)
|
|
78
96
|
function _File.readLine(path, lineNo) return '' end
|
|
79
97
|
|
|
80
98
|
--- 读取所有行
|
|
81
|
-
|
|
82
|
-
|
|
99
|
+
---@param path string 文件路径
|
|
100
|
+
---@return string[] 行内容数组,如果读取失败返回 null
|
|
101
|
+
---@example file.readAllLines("config.json")
|
|
83
102
|
function _File.readAllLines(path) return {} end
|
|
84
103
|
|
|
85
104
|
--- 复制文件
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
105
|
+
---@param src string 源文件路径
|
|
106
|
+
---@param dest string 目标文件路径
|
|
107
|
+
---@return boolean 是否复制成功
|
|
108
|
+
---@example file.copy("config.json", "config2.json")
|
|
89
109
|
function _File.copy(src, dest) return true end
|
|
90
110
|
|
|
91
111
|
--- 计算文件MD5
|
|
92
|
-
|
|
93
|
-
|
|
112
|
+
---@param path string 文件路径
|
|
113
|
+
---@return string 文件MD5值
|
|
114
|
+
---@example file.fileMD5("config.json")
|
|
94
115
|
function _File.fileMD5(path) return '' end
|
|
95
116
|
|
|
96
117
|
---@type File
|
package/types/lua/global.lua
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---@meta
|
|
2
|
+
--- 全局模块
|
|
2
3
|
--- 是否调试模式
|
|
3
4
|
---@type boolean
|
|
4
5
|
IsDebug = false
|
|
@@ -36,94 +37,129 @@ PackageJson = {}
|
|
|
36
37
|
---@field maxMs integer
|
|
37
38
|
|
|
38
39
|
--- 切入前台
|
|
39
|
-
---@return boolean
|
|
40
|
+
---@return boolean 是否成功切换到前台
|
|
41
|
+
---@example TakeMeToFront()
|
|
40
42
|
function TakeMeToFront() return false end
|
|
41
43
|
|
|
42
44
|
--- 重启脚本;延迟不足 2000ms 时按 2000ms
|
|
43
|
-
---@param delay integer|nil
|
|
45
|
+
---@param delay integer|nil 延迟时间 毫秒
|
|
46
|
+
---@example RestartScript(2000)
|
|
44
47
|
function RestartScript(delay) end
|
|
45
48
|
|
|
46
49
|
--- 退出当前脚本(单 VM,等价于收到停止信号)
|
|
50
|
+
---@example Exit()
|
|
47
51
|
function Exit() end
|
|
48
52
|
|
|
49
53
|
--- 设置停止回调;status 为 "success" | "error" | "stopped"。传入非函数则清除
|
|
50
|
-
---@param callback fun(status: string)|nil
|
|
54
|
+
---@param callback fun(status: string)|nil 停止回调
|
|
55
|
+
---@example SetStopCallback(function(status)
|
|
56
|
+
--- if status == "success" then
|
|
57
|
+
--- logi("脚本执行完成")
|
|
58
|
+
--- elseif status == "error" then
|
|
59
|
+
--- loge("脚本执行异常")
|
|
60
|
+
--- elseif status == "stopped" then
|
|
61
|
+
--- logi("脚本手动停止")
|
|
62
|
+
--- end
|
|
63
|
+
--- end)
|
|
51
64
|
function SetStopCallback(callback) end
|
|
52
65
|
|
|
53
66
|
--- 设置异常停止回调。传入非函数则清除
|
|
54
|
-
---@param callback fun()|nil
|
|
67
|
+
---@param callback fun()|nil 异常停止回调
|
|
68
|
+
---@example SetExceptionCallback(function()
|
|
69
|
+
--- loge("脚本执行异常")
|
|
70
|
+
--- end)
|
|
55
71
|
function SetExceptionCallback(callback) end
|
|
56
72
|
|
|
57
73
|
--- 可中断等待(毫秒);期间调度 StartThread 协程
|
|
58
|
-
---@param ms integer
|
|
74
|
+
---@param ms integer 毫秒
|
|
75
|
+
---@example Sleep(1000)
|
|
59
76
|
function Sleep(ms) end
|
|
60
77
|
|
|
61
78
|
--- 当前时间戳(毫秒)
|
|
62
|
-
---@return integer
|
|
79
|
+
---@return integer 时间戳
|
|
80
|
+
---@example local timestamp = Time()
|
|
63
81
|
function Time() return 0 end
|
|
64
82
|
|
|
65
83
|
--- 将表转为 JSON 字符串
|
|
66
84
|
---@param data table<string, any>|any[]
|
|
67
85
|
---@return string
|
|
86
|
+
---@example ToJsonString(data)
|
|
68
87
|
function ToJsonString(data) return '' end
|
|
69
88
|
|
|
70
89
|
--- 启动协作协程,返回协程名
|
|
71
90
|
---@param func function
|
|
72
91
|
---@return string
|
|
92
|
+
---@example StartThread(func)
|
|
73
93
|
function StartThread(func) return '' end
|
|
74
94
|
|
|
75
95
|
--- 请求停止指定协作协程
|
|
76
96
|
---@param threadName string
|
|
97
|
+
---@example StopThread(threadName)
|
|
77
98
|
function StopThread(threadName) end
|
|
78
99
|
|
|
79
100
|
--- 当前协程是否应退出
|
|
80
101
|
---@return boolean
|
|
102
|
+
---@example ShouldInterruptThread()
|
|
81
103
|
function ShouldInterruptThread() return false end
|
|
82
104
|
|
|
83
105
|
--- 设置 Agent 触控模式:0 标准 / 1 快速 / 2 真实点击
|
|
84
|
-
---@param mode integer
|
|
85
|
-
---@return integer
|
|
106
|
+
---@param mode integer 0 标准 / 1 快速 / 2 真实点击
|
|
107
|
+
---@return integer 实际生效的模式
|
|
108
|
+
---@example local mode = SetAgentTouchMode(1)
|
|
86
109
|
function SetAgentTouchMode(mode) return 1 end
|
|
87
110
|
|
|
88
111
|
--- 获取 Agent 触控模式
|
|
89
|
-
---@return integer
|
|
112
|
+
---@return integer 当前模式(0/1/2)
|
|
113
|
+
---@example local mode = GetAgentTouchMode()
|
|
90
114
|
function GetAgentTouchMode() return 1 end
|
|
91
115
|
|
|
92
116
|
--- 设置 CPU 自动限流
|
|
93
|
-
---@param enabled boolean
|
|
94
|
-
---@return boolean
|
|
117
|
+
---@param enabled boolean 是否开启自动限流
|
|
118
|
+
---@return boolean 实际是否开启自动限流
|
|
119
|
+
---@example local enabled = SetCpuAutoThrottle(true)
|
|
95
120
|
function SetCpuAutoThrottle(enabled) return true end
|
|
96
121
|
|
|
97
122
|
--- 获取 CPU 自动限流
|
|
98
|
-
---@return boolean
|
|
123
|
+
---@return boolean 当前是否开启自动限流
|
|
124
|
+
---@example local enabled = GetCpuAutoThrottle()
|
|
99
125
|
function GetCpuAutoThrottle() return true end
|
|
100
126
|
|
|
101
127
|
--- 设置 CPU 限流延迟范围(毫秒),默认 3 和 30
|
|
102
|
-
---@param minMs integer|nil
|
|
103
|
-
---@param maxMs integer|nil
|
|
104
|
-
---@return CpuThrottleDelay
|
|
128
|
+
---@param minMs integer|nil 最低延迟,默认 3
|
|
129
|
+
---@param maxMs integer|nil 最高延迟,默认 30;小于 minMs 时自动对齐
|
|
130
|
+
---@return CpuThrottleDelay 实际生效的延迟范围
|
|
131
|
+
---@example local delay = SetCpuThrottleDelay(3, 30)
|
|
105
132
|
function SetCpuThrottleDelay(minMs, maxMs)
|
|
106
133
|
return { minMs = 3, maxMs = 30 }
|
|
107
134
|
end
|
|
108
135
|
|
|
109
136
|
--- 获取 CPU 限流延迟范围
|
|
110
|
-
---@return CpuThrottleDelay
|
|
137
|
+
---@return CpuThrottleDelay 当前最低与最高延迟
|
|
138
|
+
---@example local delay = GetCpuThrottleDelay()
|
|
111
139
|
function GetCpuThrottleDelay()
|
|
112
140
|
return { minMs = 3, maxMs = 30 }
|
|
113
141
|
end
|
|
114
142
|
|
|
115
143
|
--- 打印调试日志,等同 `logger.debug(...)`
|
|
116
|
-
---@param ... any
|
|
144
|
+
---@param ... any 日志消息内容
|
|
145
|
+
---@example logd("程序开始执行")
|
|
146
|
+
--- logd("当前用户: " .. username)
|
|
117
147
|
function logd(...) end
|
|
118
148
|
|
|
119
149
|
--- 打印信息日志,等同 `logger.info(...)`
|
|
120
|
-
---@param ... any
|
|
150
|
+
---@param ... any 日志消息内容
|
|
151
|
+
---@example logi("应用程序启动成功")
|
|
152
|
+
--- logi("用户登录成功")
|
|
121
153
|
function logi(...) end
|
|
122
154
|
|
|
123
155
|
--- 打印警告日志,等同 `logger.warn(...)`
|
|
124
|
-
---@param ... any
|
|
156
|
+
---@param ... any 日志消息内容
|
|
157
|
+
---@example logw("电池电量低于 20%")
|
|
158
|
+
--- logw("网络连接不稳定")
|
|
125
159
|
function logw(...) end
|
|
126
160
|
|
|
127
161
|
--- 打印错误日志,等同 `logger.error(...)`
|
|
128
|
-
---@param ... any
|
|
162
|
+
---@param ... any 日志消息内容
|
|
163
|
+
---@example loge("网络请求失败")
|
|
164
|
+
--- loge("文件读取错误")
|
|
129
165
|
function loge(...) end
|