ms-types 0.10.10 → 0.10.12

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 (57) hide show
  1. package/package.json +1 -1
  2. package/types/cryptoUtils.d.ts +50 -36
  3. package/types/dotocr.d.ts +9 -2
  4. package/types/file.d.ts +1 -1
  5. package/types/hid.d.ts +46 -4
  6. package/types/hotUpdate.d.ts +0 -3
  7. package/types/image.d.ts +447 -447
  8. package/types/lua/action.lua +6 -6
  9. package/types/lua/ai.lua +3 -3
  10. package/types/lua/appleocr.lua +3 -3
  11. package/types/lua/cloud.lua +1 -1
  12. package/types/lua/cryptoUtils.lua +7 -7
  13. package/types/lua/cv.lua +142 -142
  14. package/types/lua/dotocr.lua +4 -4
  15. package/types/lua/file.lua +1 -1
  16. package/types/lua/global.lua +9 -7
  17. package/types/lua/hid.lua +22 -22
  18. package/types/lua/hotupdate.lua +7 -8
  19. package/types/lua/http.lua +27 -12
  20. package/types/lua/image.lua +23 -19
  21. package/types/lua/ime.lua +9 -9
  22. package/types/lua/media.lua +9 -9
  23. package/types/lua/mysql.lua +11 -11
  24. package/types/lua/netcard.lua +6 -6
  25. package/types/lua/node.lua +1 -1
  26. package/types/lua/paddleocr.lua +3 -3
  27. package/types/lua/pip.lua +6 -6
  28. package/types/lua/system.lua +23 -23
  29. package/types/lua/tomatoocr.lua +12 -17
  30. package/types/lua/tts.lua +3 -3
  31. package/types/lua/ui.lua +5 -5
  32. package/types/lua/yolo.lua +2 -2
  33. package/types/lua/yolocls.lua +2 -2
  34. package/types/mysql.d.ts +0 -2
  35. package/types/node.d.ts +1 -0
  36. package/types/opencv.d.ts +571 -38
  37. package/types/paddleocr.d.ts +1 -0
  38. package/types/pip.d.ts +11 -0
  39. package/types/system.d.ts +1 -0
  40. package/types/tomatoocr.d.ts +3 -41
  41. package/types/tts.d.ts +1 -1
  42. package/types/ui.d.ts +2 -0
  43. package/types/web.d.ts +16 -0
  44. package/types/yolo.d.ts +1 -1
  45. package/types/yoloCls.d.ts +1 -1
  46. package/types/zh/HID/346/250/241/345/235/227.d.ts +46 -4
  47. package/types/zh/MySql/346/250/241/345/235/227.d.ts +1 -3
  48. package/types/zh/PaddleOCR/346/250/241/345/235/227.d.ts +1 -0
  49. package/types/zh//345/212/250/344/275/234/346/250/241/345/235/227.d.ts +1 -1
  50. package/types/zh//345/233/276/347/211/207/346/250/241/345/235/227.d.ts +447 -447
  51. package/types/zh//346/202/254/346/265/256/347/252/227/346/250/241/345/235/227.d.ts +10 -0
  52. package/types/zh//346/226/207/344/273/266/346/250/241/345/235/227.d.ts +1 -1
  53. package/types/zh//347/202/271/351/230/265OCR/346/250/241/345/235/227.d.ts +9 -2
  54. package/types/zh//347/203/255/346/233/264/346/226/260/346/250/241/345/235/227.d.ts +0 -3
  55. package/types/zh//347/263/273/347/273/237/346/250/241/345/235/227.d.ts +1 -0
  56. package/types/zh//350/212/202/347/202/271/346/250/241/345/235/227.d.ts +1 -0
  57. package/types/zh//350/247/206/345/233/276/346/250/241/345/235/227.d.ts +2 -0
@@ -20,12 +20,12 @@ local _DotOCR = {}
20
20
  --- 从资源路径加载字库并缓存
21
21
  ---@param fontPath string
22
22
  ---@return string|nil 成功返回字库 ID,失败返回 `null`
23
- ---@example dotocr.loadFont(fontPath)
23
+ ---@example dotocr.loadFont("/fonts/default.json")
24
24
  function _DotOCR.loadFont(fontPath) return nil end
25
25
 
26
26
  --- 释放指定字库
27
27
  ---@param fontId string
28
- ---@example dotocr.free(fontId)
28
+ ---@example dotocr.free("fontId")
29
29
  function _DotOCR.free(fontId) end
30
30
 
31
31
  --- 释放全部已加载的点阵字库
@@ -41,7 +41,7 @@ function _DotOCR.freeAll() end
41
41
  ---@param ey integer|nil
42
42
  ---@param confidenceThreshold number|nil 相似度下限;`<=0` 时按 `0.95`;`>0.95` 时要求像素完全一致
43
43
  ---@return OCRChar[]
44
- ---@example dotocr.recognizeAbs(fontId, input, x, y, ex, ey, confidenceThreshold)
44
+ ---@example dotocr.recognizeAbs("fontId", "screen", 100, 100, 200, 200, 0.95)
45
45
  function _DotOCR.recognizeAbs(fontId, input, x, y, ex, ey, confidenceThreshold)
46
46
  ---@type OCRChar[]
47
47
  local ret = {}
@@ -59,7 +59,7 @@ end
59
59
  ---@param confidenceThreshold number|nil
60
60
  ---@param exactMatch boolean|nil
61
61
  ---@return OCRChar[]
62
- ---@example dotocr.findTextAbs(fontId, input, targetTexts, x, y, ex, ey, confidenceThreshold, exactMatch)
62
+ ---@example dotocr.findTextAbs("fontId", "screen", {"开始"}, 100, 100, 200, 200, 0.95, false)
63
63
  function _DotOCR.findTextAbs(fontId, input, targetTexts, x, y, ex, ey, confidenceThreshold, exactMatch)
64
64
  ---@type OCRChar[]
65
65
  local ret = {}
@@ -63,7 +63,7 @@ function _File.getResFile(name) return nil end
63
63
 
64
64
  --- 清理由 getResFile 得到的本地临时文件
65
65
  ---@param path string getResFile 返回的文件路径
66
- ---@example file.cleanupResFile(path)
66
+ ---@example file.cleanupResFile("/path/to/file.png")
67
67
  function _File.cleanupResFile(path) end
68
68
 
69
69
  --- 删除指定行或包含内容的行
@@ -54,11 +54,11 @@ function Exit() end
54
54
  ---@param callback fun(status: string)|nil 停止回调
55
55
  ---@example SetStopCallback(function(status)
56
56
  --- if status == "success" then
57
- --- logi("脚本执行完成")
57
+ --- print("脚本执行完成")
58
58
  --- elseif status == "error" then
59
- --- loge("脚本执行异常")
59
+ --- print("脚本执行异常")
60
60
  --- elseif status == "stopped" then
61
- --- logi("脚本手动停止")
61
+ --- print("脚本手动停止")
62
62
  --- end
63
63
  --- end)
64
64
  function SetStopCallback(callback) end
@@ -66,7 +66,7 @@ function SetStopCallback(callback) end
66
66
  --- 设置异常停止回调。传入非函数则清除
67
67
  ---@param callback fun()|nil 异常停止回调
68
68
  ---@example SetExceptionCallback(function()
69
- --- loge("脚本执行异常")
69
+ --- print("脚本执行异常")
70
70
  --- end)
71
71
  function SetExceptionCallback(callback) end
72
72
 
@@ -83,18 +83,20 @@ function Time() return 0 end
83
83
  --- 将表转为 JSON 字符串
84
84
  ---@param data table<string, any>|any[]
85
85
  ---@return string
86
- ---@example ToJsonString(data)
86
+ ---@example ToJsonString("hello")
87
87
  function ToJsonString(data) return '' end
88
88
 
89
89
  --- 启动协作协程,返回协程名
90
90
  ---@param func function
91
91
  ---@return string
92
- ---@example StartThread(func)
92
+ ---@example StartThread(function()
93
+ --- print("thread")
94
+ --- end)
93
95
  function StartThread(func) return '' end
94
96
 
95
97
  --- 请求停止指定协作协程
96
98
  ---@param threadName string
97
- ---@example StopThread(threadName)
99
+ ---@example StopThread("Safari")
98
100
  function StopThread(threadName) end
99
101
 
100
102
  --- 当前协程是否应退出
package/types/lua/hid.lua CHANGED
@@ -44,26 +44,26 @@ local _HID = {}
44
44
 
45
45
  --- 设置抖动值
46
46
  ---@param value integer 抖动值
47
- ---@example hid.setJitterValue(value)
47
+ ---@example hid.setJitterValue(5)
48
48
  function _HID.setJitterValue(value) end
49
49
 
50
50
  --- 设置连续点击/滑动之间的等待毫秒。不调用时用固件默认(相对 200ms / 绝对 100ms)。
51
51
  ---@param milliseconds integer 0 关闭等待,大于 0 覆盖为指定毫秒,-1 恢复默认
52
52
  ---@return boolean 操作是否成功
53
- ---@example hid.setActionDelay(milliseconds)
53
+ ---@example hid.setActionDelay(100)
54
54
  function _HID.setActionDelay(milliseconds) return true end
55
55
 
56
56
  --- 设置移动完成后的等待毫秒。不调用时固件默认 40ms。
57
57
  ---@param milliseconds integer 0 关闭等待,大于 0 覆盖为指定毫秒,小于 0 恢复默认
58
58
  ---@return boolean 操作是否成功
59
- ---@example hid.setMoveDelay(milliseconds)
59
+ ---@example hid.setMoveDelay(100)
60
60
  function _HID.setMoveDelay(milliseconds) return true end
61
61
 
62
62
  --- 移动
63
63
  ---@param x integer 移动坐标的X轴
64
64
  ---@param y integer 移动坐标的Y轴
65
65
  ---@return boolean 操作是否成功
66
- ---@example hid.move(x, y)
66
+ ---@example hid.move(100, 100)
67
67
  function _HID.move(x, y) return true end
68
68
 
69
69
  --- 按下鼠标左键(不自动抬起)
@@ -82,7 +82,7 @@ function _HID.mouseUp() return true end
82
82
  ---@param duration integer|nil 点击持续时间(可选,默认值为20毫秒)
83
83
  ---@param jitter boolean|nil 是否添加随机抖动(可选,默认值为false)
84
84
  ---@return boolean 操作是否成功
85
- ---@example hid.click(x, y, duration, jitter)
85
+ ---@example hid.click(100, 100, 20, false)
86
86
  function _HID.click(x, y, duration, jitter) return true end
87
87
 
88
88
  --- 复位坐标到左下角(仅相对鼠标模式需要)
@@ -118,7 +118,7 @@ function _HID.getBLEHIDDeviceName() return '' end
118
118
  --- 设置蓝牙 HID 设备名称
119
119
  ---@param name string 蓝牙 HID 设备名称
120
120
  ---@return boolean 是否设置成功
121
- ---@example hid.setBLEHIDDeviceName(name)
121
+ ---@example hid.setBLEHIDDeviceName("Safari")
122
122
  function _HID.setBLEHIDDeviceName(name) return true end
123
123
 
124
124
  --- 获取 HID 设备 MAC 字符串
@@ -144,7 +144,7 @@ function _HID.restartDevice() return true end
144
144
  --- 开关充电。当前连接的 HID 不支持时返回 false。
145
145
  ---@param on boolean true 打开充电,false 关闭充电
146
146
  ---@return boolean 是否成功发送
147
- ---@example hid.setCharging(on)
147
+ ---@example hid.setCharging(true)
148
148
  function _HID.setCharging(on) return true end
149
149
 
150
150
  --- 随机点击
@@ -154,7 +154,7 @@ function _HID.setCharging(on) return true end
154
154
  ---@param y2 integer 区域右下角y坐标
155
155
  ---@param duration integer|nil 持续时间 默认20ms
156
156
  ---@return boolean 随机点击是否成功
157
- ---@example action.clickRandom(100, 100, 200, 200, 20)
157
+ ---@example hid.clickRandom(100, 100, 200, 200, 20)
158
158
  function _HID.clickRandom(x1, y1, x2, y2, duration) return true end
159
159
 
160
160
  --- 双击
@@ -164,7 +164,7 @@ function _HID.clickRandom(x1, y1, x2, y2, duration) return true end
164
164
  ---@param interval integer|nil 双击间隔时间 默认20ms
165
165
  ---@param jitter boolean|nil 抖动 开启抖动,会在像素范围随机偏移 点击 默认false
166
166
  ---@return boolean 双击是否成功
167
- ---@example action.doubleClick(100, 100, 20, 20, true)
167
+ ---@example hid.doubleClick(100, 100, 20, 20, true)
168
168
  function _HID.doubleClick(x, y, duration, interval, jitter) return true end
169
169
 
170
170
  --- 随机双击
@@ -175,7 +175,7 @@ function _HID.doubleClick(x, y, duration, interval, jitter) return true end
175
175
  ---@param duration integer|nil 持续时间 默认20ms
176
176
  ---@param interval integer|nil 双击间隔时间 默认20ms
177
177
  ---@return boolean 随机双击是否成功
178
- ---@example action.doubleClickRandom(100, 100, 200, 200, 20, 20)
178
+ ---@example hid.doubleClickRandom(100, 100, 200, 200, 20, 20)
179
179
  function _HID.doubleClickRandom(x1, y1, x2, y2, duration, interval) return true end
180
180
 
181
181
  --- 滑动
@@ -186,7 +186,7 @@ function _HID.doubleClickRandom(x1, y1, x2, y2, duration, interval) return true
186
186
  ---@param jitter boolean|nil 是否添加随机抖动(可选,默认值为false)
187
187
  ---@param steps integer|nil 滑动步骤数(可选,默认值为6)
188
188
  ---@return boolean 操作是否成功
189
- ---@example hid.swipe(startX, startY, endX, endY, jitter, steps)
189
+ ---@example hid.swipe(100, 100, 200, 200, false, 6)
190
190
  function _HID.swipe(startX, startY, endX, endY, jitter, steps) return true end
191
191
 
192
192
  --- 曲线滑动(3点)
@@ -197,7 +197,7 @@ function _HID.swipe(startX, startY, endX, endY, jitter, steps) return true end
197
197
  ---@param endX integer 目标x坐标
198
198
  ---@param endY integer 目标y坐标
199
199
  ---@return boolean 操作是否成功
200
- ---@example hid.swipeCurve(startX, startY, midX, midY, endX, endY)
200
+ ---@example hid.swipeCurve(100, 100, 200, 150, 200, 200)
201
201
  function _HID.swipeCurve(startX, startY, midX, midY, endX, endY) return true end
202
202
 
203
203
  --- 长按并滑动
@@ -209,7 +209,7 @@ function _HID.swipeCurve(startX, startY, midX, midY, endX, endY) return true end
209
209
  ---@param jitter boolean|nil 是否添加随机抖动(可选,默认值为false)
210
210
  ---@param steps integer|nil 滑动步骤数(可选,默认值为6)
211
211
  ---@return boolean 操作是否成功
212
- ---@example hid.pressAndSwipe(startX, startY, endX, endY, duration, jitter, steps)
212
+ ---@example hid.pressAndSwipe(100, 100, 200, 200, 20, false, 6)
213
213
  function _HID.pressAndSwipe(startX, startY, endX, endY, duration, jitter, steps)
214
214
  return true
215
215
  end
@@ -217,19 +217,19 @@ end
217
217
  --- 打开URL
218
218
  ---@param url string URL字符串
219
219
  ---@return boolean 操作是否成功
220
- ---@example hid.openURL(url)
220
+ ---@example hid.openURL("https://example.com")
221
221
  function _HID.openURL(url) return true end
222
222
 
223
223
  --- 打开App
224
224
  ---@param bundle string 应用名称 支持 app name 或 bundleId
225
225
  ---@return boolean 操作是否成功
226
- ---@example hid.openApp(bundle)
226
+ ---@example hid.openApp("Safari")
227
227
  function _HID.openApp(bundle) return true end
228
228
 
229
229
  --- 关闭App(不会关闭当前快点 JS)
230
230
  ---@param name string 应用名称 支持 app name 或 bundleId
231
231
  ---@return boolean 操作是否成功
232
- ---@example hid.closeApp(name)
232
+ ---@example hid.closeApp("Safari")
233
233
  function _HID.closeApp(name) return true end
234
234
 
235
235
  --- 获取剪贴板
@@ -240,7 +240,7 @@ function _HID.getClipboard() return '' end
240
240
  --- 设置剪贴板
241
241
  ---@param s string 要设置的文本
242
242
  ---@return boolean 设置结果
243
- ---@example hid.setClipboard(s)
243
+ ---@example hid.setClipboard("hello")
244
244
  function _HID.setClipboard(s) return true end
245
245
 
246
246
  --- 回到主页
@@ -251,19 +251,19 @@ function _HID.homeScreen() return true end
251
251
  --- 按下系统按钮
252
252
  ---@param name string 按钮 home 按下Home键 volumeup 按下音量上键 volumedown 按下音量下键 mute 按下静音键 playpause 按下播放/暂停键 next 按下下一首键 prev 按下上一首键 eject 显示隐藏键盘 globe 按下globe键 search 按下搜索键 brightnessup 调高屏幕亮度 brightnessdown 调低屏幕亮度 power 电源/锁屏键 snapshot 系统截图键
253
253
  ---@return boolean 按下按钮是否成功
254
- ---@example action.pressButton("home")
254
+ ---@example hid.pressButton("home")
255
255
  function _HID.pressButton(name) return true end
256
256
 
257
257
  --- 输入文本(优先输入法,否则剪贴板粘贴,可输中文)
258
258
  ---@param text string 要输入的文本
259
259
  ---@return boolean 操作是否成功
260
- ---@example hid.input(text)
260
+ ---@example hid.input("hello")
261
261
  function _HID.input(text) return true end
262
262
 
263
263
  --- 简单键盘输入(英文)
264
264
  ---@param data string 要输入的基础文本(建议 ASCII)
265
265
  ---@return boolean 操作是否成功
266
- ---@example hid.inputSimple(data)
266
+ ---@example hid.inputSimple("hello")
267
267
  function _HID.inputSimple(data) return true end
268
268
 
269
269
  --- 空格键
@@ -274,7 +274,7 @@ function _HID.space() return true end
274
274
  --- 退格键
275
275
  ---@param count integer|nil 删除次数(可选,默认值为1)
276
276
  ---@return boolean 操作是否成功
277
- ---@example hid.backspace(count)
277
+ ---@example hid.backspace(1)
278
278
  function _HID.backspace(count) return true end
279
279
 
280
280
  --- 回车键
@@ -285,7 +285,7 @@ function _HID.enter() return true end
285
285
  --- 发送组合按键(支持字符串和数值)
286
286
  ---@param keys SendHIDKey[] 要发送的按键
287
287
  ---@return boolean 操作是否成功
288
- ---@example hid.sendKey(keys)
288
+ ---@example hid.sendKey({"COMMAND", "c"})
289
289
  function _HID.sendKey(keys) return true end
290
290
 
291
291
  --- 复制
@@ -23,15 +23,14 @@ local _HotUpdate = {}
23
23
 
24
24
  --- 检查更新(无参数)
25
25
  ---@return HotUpdateResult 检查结果
26
- ---@example -- 检查更新
27
- --- local result = hotupdate.checkUpdate()
26
+ ---@example local result = hotupdate.checkUpdate()
28
27
  --- if result.needUpdate then
29
- --- logi('发现新版本')
28
+ --- print('发现新版本')
30
29
  --- -- 手动决定是否更新
31
30
  --- local installResult = hotupdate.downloadAndInstall()
32
- --- logi('安装结果:', installResult)
31
+ --- print('安装结果:', installResult)
33
32
  --- else
34
- --- loge('检查更新失败:', result.error)
33
+ --- print('检查更新失败:', result.error)
35
34
  --- end
36
35
  function _HotUpdate.checkUpdate()
37
36
  ---@type HotUpdateResult
@@ -44,9 +43,9 @@ end
44
43
  --- if checkResult.needUpdate then
45
44
  --- local installResult = hotupdate.downloadAndInstall()
46
45
  --- if installResult.updated then
47
- --- logi('更新安装成功')
46
+ --- print('更新安装成功')
48
47
  --- else
49
- --- loge('更新安装失败:', installResult.error)
48
+ --- print('更新安装失败:', installResult.error)
50
49
  --- end
51
50
  --- end
52
51
  function _HotUpdate.downloadAndInstall()
@@ -57,7 +56,7 @@ end
57
56
  --- 当前版本号;失败返回 0
58
57
  ---@return integer 当前版本号,如果获取失败则返回 0
59
58
  ---@example local version = hotupdate.getCurrentVersion()
60
- --- logi('当前版本:', version); -- 输出: 当前版本: 123
59
+ --- print('当前版本:', version) -- 输出: 当前版本: 123
61
60
  function _HotUpdate.getCurrentVersion() return 0 end
62
61
 
63
62
  ---@type HotUpdate
@@ -93,7 +93,7 @@ local _WebSocket = {}
93
93
  ---@example local ws = http.newWebsocket("ws://www.baidu.com")
94
94
  --- ws.connect()
95
95
  --- ws.onText(function(data)
96
- --- logi(data)
96
+ --- print(data)
97
97
  --- end)
98
98
  --- ws.sendText("hello")
99
99
  --- ws.close()
@@ -106,69 +106,84 @@ end
106
106
  --- 连接
107
107
  ---@example ws.connect()
108
108
  function _WebSocket.connect() end
109
+
109
110
  --- 关闭
110
111
  ---@example ws.close()
111
112
  function _WebSocket.close() end
113
+
112
114
  --- 重置
113
115
  ---@return boolean
114
116
  ---@example ws.reset()
115
117
  function _WebSocket.reset() return true end
118
+
116
119
  --- 是否已关闭
117
120
  ---@return boolean
118
121
  ---@example ws.isClosed()
119
122
  function _WebSocket.isClosed() return true end
123
+
120
124
  --- 是否已连接
121
125
  ---@return boolean
122
126
  ---@example ws.isConnected()
123
127
  function _WebSocket.isConnected() return false end
128
+
124
129
  --- 发送文本
125
130
  ---@param data string
126
- ---@example ws.sendText(data)
131
+ ---@example ws.sendText("hello")
127
132
  function _WebSocket.sendText(data) end
133
+
128
134
  --- 发送二进制(base64 字符串)
129
135
  ---@param data string
130
- ---@example ws.sendBinary(data)
136
+ ---@example ws.sendBinary("hello")
131
137
  function _WebSocket.sendBinary(data) end
138
+
132
139
  --- 设置连接超时
133
140
  ---@param timeout number
134
- ---@example ws.setConnectionTimeout(timeout)
141
+ ---@example ws.setConnectionTimeout(10)
135
142
  function _WebSocket.setConnectionTimeout(timeout) end
143
+
136
144
  --- 设置写入超时
137
145
  ---@param timeout number
138
- ---@example ws.setWriteTimeout(timeout)
146
+ ---@example ws.setWriteTimeout(10)
139
147
  function _WebSocket.setWriteTimeout(timeout) end
148
+
140
149
  --- 启动心跳(可选回调返回心跳文本)
141
150
  ---@param interval number
142
151
  ---@param fn fun() :string|nil
143
- ---@example ws.startHeartbeatInterval(interval, fn)
152
+ ---@example ws.startHeartbeatInterval(30, function() return "ping" end)
144
153
  function _WebSocket.startHeartbeatInterval(interval, fn) end
154
+
145
155
  --- 停止心跳
146
156
  ---@example ws.stopHeartbeatInterval()
147
157
  function _WebSocket.stopHeartbeatInterval() end
158
+
148
159
  --- 自动重连
149
160
  ---@param autoReconnect boolean
150
- ---@example ws.setAutoReconnect(autoReconnect)
161
+ ---@example ws.setAutoReconnect(true)
151
162
  function _WebSocket.setAutoReconnect(autoReconnect) end
152
163
 
153
164
  --- 监听打开
154
165
  ---@param fn fun()
155
- ---@example ws.onOpen(fn)
166
+ ---@example ws.onOpen(function() end)
156
167
  function _WebSocket.onOpen(fn) end
168
+
157
169
  --- 监听关闭
158
170
  ---@param fn fun()
159
- ---@example ws.onClose(fn)
171
+ ---@example ws.onClose(function() end)
160
172
  function _WebSocket.onClose(fn) end
173
+
161
174
  --- 监听文本
162
175
  ---@param fn fun(text:string)
163
- ---@example ws.onText(fn)
176
+ ---@example ws.onText(function(text) print(text) end)
164
177
  function _WebSocket.onText(fn) end
178
+
165
179
  --- 监听二进制(base64 字符串)
166
180
  ---@param fn fun(data:string)
167
- ---@example ws.onBinary(fn)
181
+ ---@example ws.onBinary(function(data) end)
168
182
  function _WebSocket.onBinary(fn) end
183
+
169
184
  --- 监听错误
170
185
  ---@param fn fun(error:string)
171
- ---@example ws.onError(fn)
186
+ ---@example ws.onError(function(err) print(err) end)
172
187
  function _WebSocket.onError(fn) end
173
188
 
174
189
  ---@type Http
@@ -63,7 +63,7 @@ function _Image.readImage(path) return '' end
63
63
  --- if imageId then
64
64
  --- local clipImageId = image.clip(imageId, 0, 0, 100, 100)
65
65
  --- if clipImageId then
66
- --- logi("裁剪成功")
66
+ --- print("裁剪成功")
67
67
  --- end
68
68
  --- end
69
69
  --- image.release(imageId)
@@ -72,9 +72,9 @@ function _Image.clip(id, x, y, ex, ey) return '' end
72
72
  --- 获取尺寸
73
73
  ---@param id string 图片id
74
74
  ---@return Size 图片大小 {width: number, height: number}
75
- ---@example local size = image.getSize(imageId)
75
+ ---@example local size = image.getSize("screen")
76
76
  --- if size then
77
- --- logi(size.width, size.height)
77
+ --- print(size.width, size.height)
78
78
  --- end
79
79
  function _Image.getSize(id)
80
80
  ---@type Size
@@ -90,7 +90,7 @@ end
90
90
  ---@example local imageId = image.readImage("screen.jpg")
91
91
  --- if imageId then
92
92
  --- local base64 = image.toBase64Format(imageId, "jpg", 100)
93
- --- logi(base64)
93
+ --- print(base64)
94
94
  --- end
95
95
  --- image.release(imageId)
96
96
  function _Image.toBase64Format(id, format, quality) return '' end
@@ -100,7 +100,7 @@ function _Image.toBase64Format(id, format, quality) return '' end
100
100
  ---@return string 图片id
101
101
  ---@example local imageId = image.base64ToImage("data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P+/HgAFhAJ/wlseKgAAAABJRU5ErkJggg==")
102
102
  --- if imageId then
103
- --- logi("base64转图片成功")
103
+ --- print("base64转图片成功")
104
104
  --- end
105
105
  --- image.release(imageId)
106
106
  function _Image.base64ToImage(s) return '' end
@@ -133,14 +133,14 @@ function _Image.isRelease(id) return false end
133
133
 
134
134
  --- 释放图片
135
135
  ---@param id string 图片id
136
- ---@example image.release(imageId)
136
+ ---@example image.release("screen")
137
137
  function _Image.release(id) end
138
138
 
139
139
  --- 保存图片到路径
140
140
  ---@param id string 图片id 路径 http地址或者 screen 实时截屏
141
141
  ---@param path string 保存路径
142
142
  ---@return boolean 成功
143
- ---@example image.saveTo(imageId, "screen.jpg")
143
+ ---@example image.saveTo("screen", "screen.jpg")
144
144
  function _Image.saveTo(id, path) return true end
145
145
 
146
146
  --- 查找颜色
@@ -158,7 +158,7 @@ function _Image.saveTo(id, path) return true end
158
158
  --- if imageId then
159
159
  --- local points = image.findColor(imageId, "#6DD1E6-#101010", 0.9, 0, 0, 100, 100, 1, 1)
160
160
  --- if #points > 0 then
161
- --- logi("找到颜色")
161
+ --- print("找到颜色")
162
162
  --- end
163
163
  --- end
164
164
  --- image.release(imageId)
@@ -175,7 +175,7 @@ end
175
175
  --- if imageId then
176
176
  --- local isSame = image.cmpColor(imageId, "1|2|#6DD1E6-#101010", 0.9)
177
177
  --- if isSame then
178
- --- logi("颜色相同")
178
+ --- print("颜色相同")
179
179
  --- end
180
180
  --- end
181
181
  function _Image.cmpColor(id, points, threshold) return true end
@@ -195,10 +195,12 @@ function _Image.cmpColor(id, points, threshold) return true end
195
195
  ---@return Rect[] 图片数组;method=99 时结果额外含 scaleX/scaleY
196
196
  ---@example local points = image.findImage("screen", "template.jpg", 0, 0, 100, 100, 0.9, 1, 5, false)
197
197
  --- if #points > 0 then
198
- --- logi("找到图片")
198
+ --- print("找到图片")
199
199
  --- end
200
200
  function _Image.findImage(id, templateImageId, x, y, ex, ey, threshold, limit,
201
- method, rgb, options) return {} end
201
+ method, rgb, options)
202
+ return {}
203
+ end
202
204
 
203
205
  --- 按 kjst 模板找图
204
206
  ---@param id string 图片id,通常为 `"screen"`
@@ -206,7 +208,7 @@ function _Image.findImage(id, templateImageId, x, y, ex, ey, threshold, limit,
206
208
  ---@return Rect[] 矩形数组,坐标已换算到传入图片(`screen` 即屏幕)像素,可直接 click;OCR 命中额外含 `text`
207
209
  ---@example local hits = image.findImageEx("screen", "login.kjst")
208
210
  --- if #hits > 0 then
209
- --- logi(hits[0].x, hits[0].y)
211
+ --- print(hits[1].x, hits[1].y)
210
212
  --- end
211
213
  function _Image.findImageEx(id, kjstPath) return {} end
212
214
 
@@ -226,12 +228,14 @@ function _Image.findImageEx(id, kjstPath) return {} end
226
228
  --- if imageId then
227
229
  --- local points = image.findMultiColor(imageId, "#6DD1E6-#101010", 0.9, "1|2|#6DD1E6-#101010", 0, 0, 100, 100, 1, 1)
228
230
  --- if #points > 0 then
229
- --- logi("找到颜色")
231
+ --- print("找到颜色")
230
232
  --- end
231
233
  --- end
232
234
  --- image.release(imageId)
233
235
  function _Image.findMultiColor(id, firstColor, threshold, points, x, y, ex, ey,
234
- limit, orz) return {} end
236
+ limit, orz)
237
+ return {}
238
+ end
235
239
 
236
240
  --- 统计颜色数量
237
241
  ---@param id string 图片id
@@ -253,7 +257,7 @@ function _Image.countColor(id, colors, threshold, x, y, ex, ey) return 0 end
253
257
  ---@example local imageId = image.readImage("screen.jpg")
254
258
  --- if imageId then
255
259
  --- local color = image.pixel(imageId, 0, 0)
256
- --- logi(color)
260
+ --- print(color)
257
261
  --- end
258
262
  --- image.release(imageId)
259
263
  function _Image.pixel(id, x, y) return 0 end
@@ -264,7 +268,7 @@ function _Image.pixel(id, x, y) return 0 end
264
268
  ---@example local imageId = image.readImage("screen.jpg")
265
269
  --- if imageId then
266
270
  --- local color = image.pixel(imageId, 0, 0)
267
- --- logi(image.argb(color))
271
+ --- print(image.argb(color))
268
272
  --- end
269
273
  --- image.release(imageId)
270
274
  function _Image.argb(color) return '' end
@@ -277,7 +281,7 @@ function _Image.argb(color) return '' end
277
281
  --- if imageId then
278
282
  --- local binaryzationImageId = image.binaryzation(imageId, 128)
279
283
  --- if binaryzationImageId then
280
- --- logi("二值化成功")
284
+ --- print("二值化成功")
281
285
  --- end
282
286
  --- end
283
287
  --- image.release(imageId)
@@ -290,7 +294,7 @@ function _Image.binaryzation(id, threshold) return '' end
290
294
  --- if imageId then
291
295
  --- local grayImageId = image.gray(imageId)
292
296
  --- if grayImageId then
293
- --- logi("灰度化成功")
297
+ --- print("灰度化成功")
294
298
  --- end
295
299
  --- end
296
300
  --- image.release(imageId)
@@ -303,7 +307,7 @@ function _Image.gray(id) return '' end
303
307
  --- if imageId then
304
308
  --- local code = image.scanCode(imageId)
305
309
  --- if code then
306
- --- logi(code)
310
+ --- print(code)
307
311
  --- end
308
312
  --- end
309
313
  function _Image.scanCode(id) return '' end
package/types/lua/ime.lua CHANGED
@@ -6,14 +6,14 @@ local _Ime = {}
6
6
  --- 输入法是否可用(键盘是否已弹出)
7
7
  ---@return boolean 如果输入法键盘是否已弹出返回 true,否则返回 false
8
8
  ---@example if ime.isOk() then
9
- --- logi("输入法已启动")
9
+ --- print("输入法已启动")
10
10
  --- end
11
11
  function _Ime.isOk() return false end
12
12
 
13
13
  --- 获取当前输入框文本
14
14
  ---@return string 当前输入框的完整文本
15
15
  ---@example local text = ime.getText()
16
- --- logi(text)
16
+ --- print(text)
17
17
  function _Ime.getText() return '' end
18
18
 
19
19
  --- 清空输入框文本
@@ -25,47 +25,47 @@ function _Ime.clearText() return true end
25
25
  ---@param text string 要输入的文本
26
26
  ---@return string 输入后的文本内容 失败返回空字符串
27
27
  ---@example local text = ime.input("hello")
28
- --- logi(text)
28
+ --- print(text)
29
29
  function _Ime.input(text) return '' end
30
30
 
31
31
  --- 粘贴文本(content 为空时使用剪贴板)
32
32
  ---@param text string|nil 要粘贴的文本
33
33
  ---@return string 粘贴后的文本内容 失败返回空字符串
34
34
  ---@example local text = ime.paste("hello")
35
- --- logi(text)
35
+ --- print(text)
36
36
  function _Ime.paste(text) return '' end
37
37
 
38
38
  --- 删除一个字符(返回剩余文本;空表示无数据)
39
39
  ---@return string 如果为空,代表输入框无数据,如果不为空,代表输入框剩余数据
40
40
  ---@example local text = ime.pressDel()
41
- --- logi(text)
41
+ --- print(text)
42
42
  function _Ime.pressDel() return '' end
43
43
 
44
44
  --- 回车键
45
45
  ---@return boolean 如果成功返回 true,否则返回 false
46
46
  ---@example if ime.pressEnter() then
47
- --- logi("回车键按下")
47
+ --- print("回车键按下")
48
48
  --- end
49
49
  function _Ime.pressEnter() return true end
50
50
 
51
51
  --- 隐藏键盘
52
52
  ---@return boolean 如果成功返回 true,否则返回 false
53
53
  ---@example if ime.dismiss() then
54
- --- logi("键盘已隐藏")
54
+ --- print("键盘已隐藏")
55
55
  --- end
56
56
  function _Ime.dismiss() return true end
57
57
 
58
58
  --- 获取剪贴板
59
59
  ---@return string 剪贴板内容
60
60
  ---@example local text = ime.getClipboard()
61
- --- logi(text)
61
+ --- print(text)
62
62
  function _Ime.getClipboard() return '' end
63
63
 
64
64
  --- 设置剪贴板(键盘显示时)
65
65
  ---@param text string 要设置的剪贴板内容 键盘显示时才能设置
66
66
  ---@return boolean 如果成功返回 true,否则返回 false
67
67
  ---@example if ime.setClipboard("hello") then
68
- --- logi("剪贴板内容已设置")
68
+ --- print("剪贴板内容已设置")
69
69
  --- end
70
70
  function _Ime.setClipboard(text) return true end
71
71