ms-types 0.10.11 → 0.10.13
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 +8 -2
- package/types/hotUpdate.d.ts +0 -3
- package/types/image.d.ts +2 -2
- package/types/lua/ai.lua +3 -3
- package/types/lua/appleocr.lua +3 -3
- package/types/lua/cloud.lua +1 -1
- package/types/lua/global.lua +5 -5
- package/types/lua/hotupdate.lua +7 -8
- package/types/lua/http.lua +3 -3
- package/types/lua/image.lua +14 -14
- package/types/lua/ime.lua +9 -9
- package/types/lua/media.lua +9 -9
- package/types/lua/mysql.lua +11 -11
- package/types/lua/netcard.lua +6 -6
- package/types/lua/paddleocr.lua +3 -3
- package/types/lua/system.lua +23 -23
- package/types/lua/tomatoocr.lua +12 -17
- package/types/lua/tts.lua +3 -3
- package/types/lua/ui.lua +5 -5
- package/types/lua/yolo.lua +1 -1
- package/types/lua/yolocls.lua +1 -1
- package/types/mysql.d.ts +0 -2
- package/types/tomatoocr.d.ts +3 -41
- package/types/yolo.d.ts +1 -1
- package/types/yoloCls.d.ts +1 -1
- package/types/zh/MySql/346/250/241/345/235/227.d.ts +1 -3
- package/types/zh//345/233/276/347/211/207/346/250/241/345/235/227.d.ts +447 -447
- package/types/zh//347/203/255/346/233/264/346/226/260/346/250/241/345/235/227.d.ts +0 -3
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ms-types",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"types": "./types/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./types/index.d.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
6
12
|
"publishConfig": {
|
|
7
13
|
"access": "public"
|
|
8
14
|
},
|
|
@@ -10,7 +16,7 @@
|
|
|
10
16
|
"types"
|
|
11
17
|
],
|
|
12
18
|
"scripts": {
|
|
13
|
-
"docs:dev": "vitepress dev docs",
|
|
19
|
+
"docs:dev": "vitepress dev docs --host",
|
|
14
20
|
"docs:build": "vitepress build docs",
|
|
15
21
|
"docs:preview": "vitepress preview docs",
|
|
16
22
|
"deploy": "wrangler deploy"
|
package/types/hotUpdate.d.ts
CHANGED
|
@@ -39,7 +39,6 @@ declare namespace hotUpdate {
|
|
|
39
39
|
* @returns 检查结果
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
42
|
-
* // 检查更新
|
|
43
42
|
* const result = hotUpdate.checkUpdate();
|
|
44
43
|
*
|
|
45
44
|
* if (result.needUpdate) {
|
|
@@ -57,7 +56,6 @@ declare namespace hotUpdate {
|
|
|
57
56
|
* 手动下载并安装更新, 执行成功后会自动重启脚本
|
|
58
57
|
* @returns 安装结果
|
|
59
58
|
* @example
|
|
60
|
-
* ```javascript
|
|
61
59
|
* const checkResult = hotUpdate.checkUpdate();
|
|
62
60
|
* if (checkResult.needUpdate) {
|
|
63
61
|
* const installResult = hotUpdate.downloadAndInstall();
|
|
@@ -67,7 +65,6 @@ declare namespace hotUpdate {
|
|
|
67
65
|
* loge('更新安装失败:', installResult.error);
|
|
68
66
|
* }
|
|
69
67
|
* }
|
|
70
|
-
* ```
|
|
71
68
|
*/
|
|
72
69
|
function downloadAndInstall(): {
|
|
73
70
|
updated: boolean;
|
package/types/image.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ declare namespace image {
|
|
|
26
26
|
* @param imageId 图片id 路径 http地址或者 screen 实时截屏
|
|
27
27
|
* @param filePath 保存路径
|
|
28
28
|
* @example
|
|
29
|
-
* image.saveTo(
|
|
29
|
+
* image.saveTo("screen", "screen.jpg")
|
|
30
30
|
*/
|
|
31
31
|
function saveTo(imageId: string, filePath: string): boolean;
|
|
32
32
|
/**
|
|
@@ -47,7 +47,7 @@ declare namespace image {
|
|
|
47
47
|
* 释放图片
|
|
48
48
|
* @param imageId 图片id
|
|
49
49
|
* @example
|
|
50
|
-
* image.release(
|
|
50
|
+
* image.release("screen")
|
|
51
51
|
*/
|
|
52
52
|
function release(imageId: string): void;
|
|
53
53
|
/**
|
package/types/lua/ai.lua
CHANGED
|
@@ -53,7 +53,7 @@ function _Ai.setProvider(config) return nil end
|
|
|
53
53
|
--- 列出已登记的供应商,默认项排在最前
|
|
54
54
|
---@return AiProvider[]
|
|
55
55
|
---@example for _, p in ipairs(ai.getProviders()) do
|
|
56
|
-
---
|
|
56
|
+
--- print(p.name)
|
|
57
57
|
--- end
|
|
58
58
|
function _Ai.getProviders() return {} end
|
|
59
59
|
|
|
@@ -96,7 +96,7 @@ function _Ai.judge(question, options) return false end
|
|
|
96
96
|
---@param options AiOptions|nil 同 ask,另支持 schema
|
|
97
97
|
---@return table|nil 解析后的对象或数组;没有合法 JSON 或请求失败返回 null
|
|
98
98
|
---@example local d = ai.extract("提取验证码", { image = "screen", x = 100, y = 800, ex = 600, ey = 900, schema = { code = "string" } })
|
|
99
|
-
--- if d then
|
|
99
|
+
--- if d then print(d.code) end
|
|
100
100
|
function _Ai.extract(prompt, options) return nil end
|
|
101
101
|
|
|
102
102
|
--- 多轮对话:自己维护完整消息数组,每次整表传入。失败返回 nil,不要把空回复推进历史。
|
|
@@ -114,7 +114,7 @@ function _Ai.parseJson(text) return nil end
|
|
|
114
114
|
|
|
115
115
|
--- 最近一次调用失败的原因;上一次调用成功时返回 nil
|
|
116
116
|
---@return string|nil 错误文案;上一次调用成功时返回 null
|
|
117
|
-
---@example if ai.ask("你好") == nil then
|
|
117
|
+
---@example if ai.ask("你好") == nil then print(ai.lastError()) end
|
|
118
118
|
function _Ai.lastError() return nil end
|
|
119
119
|
|
|
120
120
|
---@type Ai
|
package/types/lua/appleocr.lua
CHANGED
|
@@ -25,7 +25,7 @@ local _AppleOCR = {}
|
|
|
25
25
|
---@return AppleOCRResult[] 识别结果数组,坐标为原图/全屏绝对坐标
|
|
26
26
|
---@example local results = appleocr.recognizeAbs("screen", 100, 100, 500, 300)
|
|
27
27
|
--- if #results > 0 then
|
|
28
|
-
--- action.click(results[
|
|
28
|
+
--- action.click(results[1].centerX, results[1].centerY)
|
|
29
29
|
--- end
|
|
30
30
|
function _AppleOCR.recognizeAbs(input, x, y, ex, ey, langs)
|
|
31
31
|
---@type AppleOCRResult[]
|
|
@@ -42,7 +42,7 @@ end
|
|
|
42
42
|
---@return AppleOCRResult[] 识别结果数组,坐标为原图/全屏绝对坐标
|
|
43
43
|
---@example local results = appleocr.recognizeNumbersAbs("screen", 100, 100, 500, 300)
|
|
44
44
|
--- if #results > 0 then
|
|
45
|
-
--- action.click(results[
|
|
45
|
+
--- action.click(results[1].centerX, results[1].centerY)
|
|
46
46
|
--- end
|
|
47
47
|
function _AppleOCR.recognizeNumbersAbs(input, x, y, ex, ey)
|
|
48
48
|
---@type AppleOCRResult[]
|
|
@@ -62,7 +62,7 @@ end
|
|
|
62
62
|
---@return AppleOCRResult[] 命中子串的识别结果数组,坐标为原图/全屏绝对坐标
|
|
63
63
|
---@example local results = appleocr.findTextAbs("screen", {"开始"}, 100, 100, 500, 400)
|
|
64
64
|
--- if #results > 0 then
|
|
65
|
-
--- action.click(results[
|
|
65
|
+
--- action.click(results[1].centerX, results[1].centerY)
|
|
66
66
|
--- end
|
|
67
67
|
function _AppleOCR.findTextAbs(input, targets, x, y, ex, ey, langs, exactMatch)
|
|
68
68
|
---@type AppleOCRResult[]
|
package/types/lua/cloud.lua
CHANGED
|
@@ -37,7 +37,7 @@ function _Cloud.report(event, data) return false end
|
|
|
37
37
|
--- 监听服务端下发的 scriptEvent 事件(仅主线程调用,不能在线程脚本中调用)。
|
|
38
38
|
---@param callback fun(event: string, data: table<string, any>)|nil 主脚本回调函数;传入 null 可取消监听。
|
|
39
39
|
---@example cloud.onEvent(function(event, data)
|
|
40
|
-
---
|
|
40
|
+
--- print("server event:", event, data)
|
|
41
41
|
--- end)
|
|
42
42
|
function _Cloud.onEvent(callback) end
|
|
43
43
|
|
package/types/lua/global.lua
CHANGED
|
@@ -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
|
-
---
|
|
57
|
+
--- print("脚本执行完成")
|
|
58
58
|
--- elseif status == "error" then
|
|
59
|
-
---
|
|
59
|
+
--- print("脚本执行异常")
|
|
60
60
|
--- elseif status == "stopped" then
|
|
61
|
-
---
|
|
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
|
-
---
|
|
69
|
+
--- print("脚本执行异常")
|
|
70
70
|
--- end)
|
|
71
71
|
function SetExceptionCallback(callback) end
|
|
72
72
|
|
|
@@ -90,7 +90,7 @@ function ToJsonString(data) return '' end
|
|
|
90
90
|
---@param func function
|
|
91
91
|
---@return string
|
|
92
92
|
---@example StartThread(function()
|
|
93
|
-
---
|
|
93
|
+
--- print("thread")
|
|
94
94
|
--- end)
|
|
95
95
|
function StartThread(func) return '' end
|
|
96
96
|
|
package/types/lua/hotupdate.lua
CHANGED
|
@@ -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
|
-
---
|
|
28
|
+
--- print('发现新版本')
|
|
30
29
|
--- -- 手动决定是否更新
|
|
31
30
|
--- local installResult = hotupdate.downloadAndInstall()
|
|
32
|
-
---
|
|
31
|
+
--- print('安装结果:', installResult)
|
|
33
32
|
--- else
|
|
34
|
-
---
|
|
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
|
-
---
|
|
46
|
+
--- print('更新安装成功')
|
|
48
47
|
--- else
|
|
49
|
-
---
|
|
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
|
-
---
|
|
59
|
+
--- print('当前版本:', version) -- 输出: 当前版本: 123
|
|
61
60
|
function _HotUpdate.getCurrentVersion() return 0 end
|
|
62
61
|
|
|
63
62
|
---@type HotUpdate
|
package/types/lua/http.lua
CHANGED
|
@@ -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
|
-
---
|
|
96
|
+
--- print(data)
|
|
97
97
|
--- end)
|
|
98
98
|
--- ws.sendText("hello")
|
|
99
99
|
--- ws.close()
|
|
@@ -173,7 +173,7 @@ function _WebSocket.onClose(fn) end
|
|
|
173
173
|
|
|
174
174
|
--- 监听文本
|
|
175
175
|
---@param fn fun(text:string)
|
|
176
|
-
---@example ws.onText(function(text)
|
|
176
|
+
---@example ws.onText(function(text) print(text) end)
|
|
177
177
|
function _WebSocket.onText(fn) end
|
|
178
178
|
|
|
179
179
|
--- 监听二进制(base64 字符串)
|
|
@@ -183,7 +183,7 @@ function _WebSocket.onBinary(fn) end
|
|
|
183
183
|
|
|
184
184
|
--- 监听错误
|
|
185
185
|
---@param fn fun(error:string)
|
|
186
|
-
---@example ws.onError(function(err)
|
|
186
|
+
---@example ws.onError(function(err) print(err) end)
|
|
187
187
|
function _WebSocket.onError(fn) end
|
|
188
188
|
|
|
189
189
|
---@type Http
|
package/types/lua/image.lua
CHANGED
|
@@ -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
|
-
---
|
|
66
|
+
--- print("裁剪成功")
|
|
67
67
|
--- end
|
|
68
68
|
--- end
|
|
69
69
|
--- image.release(imageId)
|
|
@@ -74,7 +74,7 @@ function _Image.clip(id, x, y, ex, ey) return '' end
|
|
|
74
74
|
---@return Size 图片大小 {width: number, height: number}
|
|
75
75
|
---@example local size = image.getSize("screen")
|
|
76
76
|
--- if size then
|
|
77
|
-
---
|
|
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
|
-
---
|
|
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
|
-
---
|
|
103
|
+
--- print("base64转图片成功")
|
|
104
104
|
--- end
|
|
105
105
|
--- image.release(imageId)
|
|
106
106
|
function _Image.base64ToImage(s) return '' end
|
|
@@ -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
|
-
---
|
|
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
|
-
---
|
|
178
|
+
--- print("颜色相同")
|
|
179
179
|
--- end
|
|
180
180
|
--- end
|
|
181
181
|
function _Image.cmpColor(id, points, threshold) return true end
|
|
@@ -195,7 +195,7 @@ 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
|
-
---
|
|
198
|
+
--- print("找到图片")
|
|
199
199
|
--- end
|
|
200
200
|
function _Image.findImage(id, templateImageId, x, y, ex, ey, threshold, limit,
|
|
201
201
|
method, rgb, options)
|
|
@@ -208,7 +208,7 @@ end
|
|
|
208
208
|
---@return Rect[] 矩形数组,坐标已换算到传入图片(`screen` 即屏幕)像素,可直接 click;OCR 命中额外含 `text`
|
|
209
209
|
---@example local hits = image.findImageEx("screen", "login.kjst")
|
|
210
210
|
--- if #hits > 0 then
|
|
211
|
-
---
|
|
211
|
+
--- print(hits[1].x, hits[1].y)
|
|
212
212
|
--- end
|
|
213
213
|
function _Image.findImageEx(id, kjstPath) return {} end
|
|
214
214
|
|
|
@@ -228,7 +228,7 @@ function _Image.findImageEx(id, kjstPath) return {} end
|
|
|
228
228
|
--- if imageId then
|
|
229
229
|
--- local points = image.findMultiColor(imageId, "#6DD1E6-#101010", 0.9, "1|2|#6DD1E6-#101010", 0, 0, 100, 100, 1, 1)
|
|
230
230
|
--- if #points > 0 then
|
|
231
|
-
---
|
|
231
|
+
--- print("找到颜色")
|
|
232
232
|
--- end
|
|
233
233
|
--- end
|
|
234
234
|
--- image.release(imageId)
|
|
@@ -257,7 +257,7 @@ function _Image.countColor(id, colors, threshold, x, y, ex, ey) return 0 end
|
|
|
257
257
|
---@example local imageId = image.readImage("screen.jpg")
|
|
258
258
|
--- if imageId then
|
|
259
259
|
--- local color = image.pixel(imageId, 0, 0)
|
|
260
|
-
---
|
|
260
|
+
--- print(color)
|
|
261
261
|
--- end
|
|
262
262
|
--- image.release(imageId)
|
|
263
263
|
function _Image.pixel(id, x, y) return 0 end
|
|
@@ -268,7 +268,7 @@ function _Image.pixel(id, x, y) return 0 end
|
|
|
268
268
|
---@example local imageId = image.readImage("screen.jpg")
|
|
269
269
|
--- if imageId then
|
|
270
270
|
--- local color = image.pixel(imageId, 0, 0)
|
|
271
|
-
---
|
|
271
|
+
--- print(image.argb(color))
|
|
272
272
|
--- end
|
|
273
273
|
--- image.release(imageId)
|
|
274
274
|
function _Image.argb(color) return '' end
|
|
@@ -281,7 +281,7 @@ function _Image.argb(color) return '' end
|
|
|
281
281
|
--- if imageId then
|
|
282
282
|
--- local binaryzationImageId = image.binaryzation(imageId, 128)
|
|
283
283
|
--- if binaryzationImageId then
|
|
284
|
-
---
|
|
284
|
+
--- print("二值化成功")
|
|
285
285
|
--- end
|
|
286
286
|
--- end
|
|
287
287
|
--- image.release(imageId)
|
|
@@ -294,7 +294,7 @@ function _Image.binaryzation(id, threshold) return '' end
|
|
|
294
294
|
--- if imageId then
|
|
295
295
|
--- local grayImageId = image.gray(imageId)
|
|
296
296
|
--- if grayImageId then
|
|
297
|
-
---
|
|
297
|
+
--- print("灰度化成功")
|
|
298
298
|
--- end
|
|
299
299
|
--- end
|
|
300
300
|
--- image.release(imageId)
|
|
@@ -307,7 +307,7 @@ function _Image.gray(id) return '' end
|
|
|
307
307
|
--- if imageId then
|
|
308
308
|
--- local code = image.scanCode(imageId)
|
|
309
309
|
--- if code then
|
|
310
|
-
---
|
|
310
|
+
--- print(code)
|
|
311
311
|
--- end
|
|
312
312
|
--- end
|
|
313
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
|
-
---
|
|
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
|
-
---
|
|
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
|
-
---
|
|
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
|
-
---
|
|
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
|
-
---
|
|
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
|
-
---
|
|
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
|
-
---
|
|
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
|
-
---
|
|
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
|
-
---
|
|
68
|
+
--- print("剪贴板内容已设置")
|
|
69
69
|
--- end
|
|
70
70
|
function _Ime.setClipboard(text) return true end
|
|
71
71
|
|
package/types/lua/media.lua
CHANGED
|
@@ -9,7 +9,7 @@ local _Media = {}
|
|
|
9
9
|
---@return boolean 是否播放成功
|
|
10
10
|
---@example local played = media.playMp3("music.mp3", true)
|
|
11
11
|
--- if played then
|
|
12
|
-
---
|
|
12
|
+
--- print("播放成功")
|
|
13
13
|
--- end
|
|
14
14
|
function _Media.playMp3(file, loop) return true end
|
|
15
15
|
|
|
@@ -17,7 +17,7 @@ function _Media.playMp3(file, loop) return true end
|
|
|
17
17
|
---@return boolean 是否停止成功
|
|
18
18
|
---@example local stopped = media.stopMp3()
|
|
19
19
|
--- if stopped then
|
|
20
|
-
---
|
|
20
|
+
--- print("停止成功")
|
|
21
21
|
--- end
|
|
22
22
|
function _Media.stopMp3() return true end
|
|
23
23
|
|
|
@@ -26,7 +26,7 @@ function _Media.stopMp3() return true end
|
|
|
26
26
|
---@return boolean 是否正常播放到结尾
|
|
27
27
|
---@example local played = media.playMp3WaitEnd("music.mp3")
|
|
28
28
|
--- if played then
|
|
29
|
-
---
|
|
29
|
+
--- print("播放成功")
|
|
30
30
|
--- end
|
|
31
31
|
function _Media.playMp3WaitEnd(file) return true end
|
|
32
32
|
|
|
@@ -34,7 +34,7 @@ function _Media.playMp3WaitEnd(file) return true end
|
|
|
34
34
|
---@return boolean 是否正在播放
|
|
35
35
|
---@example local playing = media.isMp3Playing()
|
|
36
36
|
--- if playing then
|
|
37
|
-
---
|
|
37
|
+
--- print("正在播放")
|
|
38
38
|
--- end
|
|
39
39
|
function _Media.isMp3Playing() return true end
|
|
40
40
|
|
|
@@ -45,7 +45,7 @@ function _Media.isMp3Playing() return true end
|
|
|
45
45
|
--- if imageId then
|
|
46
46
|
--- local saved = media.saveImageToAlbum(imageId)
|
|
47
47
|
--- if saved then
|
|
48
|
-
---
|
|
48
|
+
--- print("保存成功")
|
|
49
49
|
--- end
|
|
50
50
|
--- end
|
|
51
51
|
function _Media.saveImageToAlbum(imageId) return true end
|
|
@@ -55,7 +55,7 @@ function _Media.saveImageToAlbum(imageId) return true end
|
|
|
55
55
|
---@return boolean 是否保存成功
|
|
56
56
|
---@example local saved = media.saveVideoToAlbumPath("video.mp4")
|
|
57
57
|
--- if saved then
|
|
58
|
-
---
|
|
58
|
+
--- print("保存成功")
|
|
59
59
|
--- end
|
|
60
60
|
function _Media.saveVideoToAlbumPath(path) return true end
|
|
61
61
|
|
|
@@ -63,7 +63,7 @@ function _Media.saveVideoToAlbumPath(path) return true end
|
|
|
63
63
|
---@return boolean 是否删除成功
|
|
64
64
|
---@example local deleted = media.deleteAllPhotos()
|
|
65
65
|
--- if deleted then
|
|
66
|
-
---
|
|
66
|
+
--- print("删除成功")
|
|
67
67
|
--- end
|
|
68
68
|
function _Media.deleteAllPhotos() return true end
|
|
69
69
|
|
|
@@ -71,7 +71,7 @@ function _Media.deleteAllPhotos() return true end
|
|
|
71
71
|
---@return boolean 是否删除成功
|
|
72
72
|
---@example local deleted = media.deleteAllVideos()
|
|
73
73
|
--- if deleted then
|
|
74
|
-
---
|
|
74
|
+
--- print("删除成功")
|
|
75
75
|
--- end
|
|
76
76
|
function _Media.deleteAllVideos() return true end
|
|
77
77
|
|
|
@@ -79,7 +79,7 @@ function _Media.deleteAllVideos() return true end
|
|
|
79
79
|
---@return boolean 是否删除成功
|
|
80
80
|
---@example local deleted = media.deleteAllScreenshots()
|
|
81
81
|
--- if deleted then
|
|
82
|
-
---
|
|
82
|
+
--- print("删除成功")
|
|
83
83
|
--- end
|
|
84
84
|
function _Media.deleteAllScreenshots() return true end
|
|
85
85
|
|
package/types/lua/mysql.lua
CHANGED
|
@@ -26,7 +26,7 @@ local _MySQL = {}
|
|
|
26
26
|
---@example local connected = mysql.connect({ host = "localhost", port = 3306, username = "root", password = "password", database = "test_db", charset = "utf8mb4" })
|
|
27
27
|
---
|
|
28
28
|
--- if connected then
|
|
29
|
-
---
|
|
29
|
+
--- print("数据库连接成功")
|
|
30
30
|
--- end
|
|
31
31
|
function _MySQL.connect(config) return true end
|
|
32
32
|
|
|
@@ -37,7 +37,7 @@ function _MySQL.disconnect() end
|
|
|
37
37
|
--- 是否连接
|
|
38
38
|
---@return boolean 是否已连接
|
|
39
39
|
---@example if mysql.isConnected() then
|
|
40
|
-
---
|
|
40
|
+
--- print("数据库已连接")
|
|
41
41
|
--- end
|
|
42
42
|
function _MySQL.isConnected() return false end
|
|
43
43
|
|
|
@@ -48,12 +48,12 @@ function _MySQL.isConnected() return false end
|
|
|
48
48
|
---@example local result = mysql.query("SELECT * FROM users")
|
|
49
49
|
--- result = mysql.query("SELECT * FROM users WHERE id = ?", {1})
|
|
50
50
|
--- if result.success then
|
|
51
|
-
---
|
|
51
|
+
--- print("查询到 " .. #result.rows .. " 条记录")
|
|
52
52
|
--- for _, row in ipairs(result.rows) do
|
|
53
|
-
---
|
|
53
|
+
--- print(row)
|
|
54
54
|
--- end
|
|
55
55
|
--- else
|
|
56
|
-
---
|
|
56
|
+
--- print("查询失败: " .. tostring(result.error))
|
|
57
57
|
--- end
|
|
58
58
|
function _MySQL.query(sql, params)
|
|
59
59
|
---@type MySQLResult
|
|
@@ -70,9 +70,9 @@ end
|
|
|
70
70
|
--- {"张三", "zhangsan@example.com"}
|
|
71
71
|
--- )
|
|
72
72
|
--- if result.success then
|
|
73
|
-
---
|
|
73
|
+
--- print("影响了 " .. tostring(result.affectedRows) .. " 行")
|
|
74
74
|
--- else
|
|
75
|
-
---
|
|
75
|
+
--- print("执行失败: " .. tostring(result.error))
|
|
76
76
|
--- end
|
|
77
77
|
function _MySQL.execute(sql, params)
|
|
78
78
|
---@type MySQLResult
|
|
@@ -86,10 +86,10 @@ end
|
|
|
86
86
|
--- mysql.execute("INSERT INTO users (name) VALUES (?)", {"用户1"})
|
|
87
87
|
--- mysql.execute("INSERT INTO users (name) VALUES (?)", {"用户2"})
|
|
88
88
|
--- if mysql.commit() then
|
|
89
|
-
---
|
|
89
|
+
--- print("事务提交成功")
|
|
90
90
|
--- else
|
|
91
91
|
--- mysql.rollback()
|
|
92
|
-
---
|
|
92
|
+
--- print("事务回滚")
|
|
93
93
|
--- end
|
|
94
94
|
--- end
|
|
95
95
|
function _MySQL.beginTransaction() return true end
|
|
@@ -99,7 +99,7 @@ function _MySQL.beginTransaction() return true end
|
|
|
99
99
|
---@example mysql.beginTransaction()
|
|
100
100
|
--- mysql.execute("INSERT INTO users (name) VALUES (?)", {"测试用户"})
|
|
101
101
|
--- if mysql.commit() then
|
|
102
|
-
---
|
|
102
|
+
--- print("事务提交成功")
|
|
103
103
|
--- end
|
|
104
104
|
function _MySQL.commit() return true end
|
|
105
105
|
|
|
@@ -108,7 +108,7 @@ function _MySQL.commit() return true end
|
|
|
108
108
|
---@example mysql.beginTransaction()
|
|
109
109
|
--- mysql.execute("INSERT INTO users (name) VALUES (?)", {"测试用户"})
|
|
110
110
|
--- if mysql.rollback() then
|
|
111
|
-
---
|
|
111
|
+
--- print("事务回滚成功")
|
|
112
112
|
--- end
|
|
113
113
|
function _MySQL.rollback() return true end
|
|
114
114
|
|
package/types/lua/netcard.lua
CHANGED
|
@@ -13,7 +13,7 @@ local _NetCard = {}
|
|
|
13
13
|
--- 当前是否为授权卡密模式
|
|
14
14
|
---@return boolean 当前 App 处于授权卡密模式返回 true,否则返回 false
|
|
15
15
|
---@example if netcard.isAuthCardMode() then
|
|
16
|
-
---
|
|
16
|
+
--- print("当前为授权卡密模式,不需要重复调用 verify")
|
|
17
17
|
--- end
|
|
18
18
|
function _NetCard.isAuthCardMode() return false end
|
|
19
19
|
|
|
@@ -21,13 +21,13 @@ function _NetCard.isAuthCardMode() return false end
|
|
|
21
21
|
---@param cardNo string 卡密
|
|
22
22
|
---@return boolean 是否验证成功
|
|
23
23
|
---@example local isVerified = netcard.verify("1234567890")
|
|
24
|
-
---
|
|
24
|
+
--- print(isVerified)
|
|
25
25
|
function _NetCard.verify(cardNo) return true end
|
|
26
26
|
|
|
27
27
|
--- 卡信息
|
|
28
28
|
---@return CardInfo|nil 卡密信息
|
|
29
29
|
---@example local cardInfo = netcard.getCardInfo()
|
|
30
|
-
---
|
|
30
|
+
--- print(ToJsonString(cardInfo))
|
|
31
31
|
function _NetCard.getCardInfo()
|
|
32
32
|
---@type CardInfo
|
|
33
33
|
local ret
|
|
@@ -38,7 +38,7 @@ end
|
|
|
38
38
|
---@param remark string 备注
|
|
39
39
|
---@return boolean 是否设置成功
|
|
40
40
|
---@example local isSet = netcard.setCardRemark("我的卡密")
|
|
41
|
-
---
|
|
41
|
+
--- print(isSet)
|
|
42
42
|
function _NetCard.setCardRemark(remark) return true end
|
|
43
43
|
|
|
44
44
|
--- 设置值
|
|
@@ -46,14 +46,14 @@ function _NetCard.setCardRemark(remark) return true end
|
|
|
46
46
|
---@param value string 值
|
|
47
47
|
---@return string 成功返回设置的value,失败返回空字符串
|
|
48
48
|
---@example local value = netcard.setValue("cardNo", "1234567890")
|
|
49
|
-
---
|
|
49
|
+
--- print(value)
|
|
50
50
|
function _NetCard.setValue(key, value) return '' end
|
|
51
51
|
|
|
52
52
|
--- 获取值
|
|
53
53
|
---@param key string 键
|
|
54
54
|
---@return string 成功返回值,失败返回空字符串
|
|
55
55
|
---@example local value = netcard.getValue("cardNo")
|
|
56
|
-
---
|
|
56
|
+
--- print(value)
|
|
57
57
|
function _NetCard.getValue(key) return '' end
|
|
58
58
|
|
|
59
59
|
---@type NetCard
|
package/types/lua/paddleocr.lua
CHANGED
|
@@ -22,7 +22,7 @@ local _PaddleOCR = {}
|
|
|
22
22
|
---@param useGpu boolean|nil 是否使用GPU,默认false,可不传
|
|
23
23
|
---@return boolean 加载成功或目标模型已加载返回true
|
|
24
24
|
---@example local ok = paddleocr.loadModel("ppocr-v6-small", false)
|
|
25
|
-
---
|
|
25
|
+
--- print("PaddleOCR 模型加载结果: " .. ok)
|
|
26
26
|
function _PaddleOCR.loadModel(modelId, useGpu) return true end
|
|
27
27
|
|
|
28
28
|
--- 设置检测长边;0 或负数时使用 768
|
|
@@ -42,7 +42,7 @@ function _PaddleOCR.setMaxSideLen(maxSideLen) return true end
|
|
|
42
42
|
---@return PaddleOCRResult[] 识别结果数组,坐标为原图/全屏绝对坐标
|
|
43
43
|
---@example local results = paddleocr.recognizeAbs("screen", 100, 100, 500, 300)
|
|
44
44
|
--- if #results > 0 then
|
|
45
|
-
--- action.click(results[
|
|
45
|
+
--- action.click(results[1].centerX, results[1].centerY)
|
|
46
46
|
--- end
|
|
47
47
|
function _PaddleOCR.recognizeAbs(input, x, y, ex, ey, confidenceThreshold)
|
|
48
48
|
---@type PaddleOCRResult[]
|
|
@@ -62,7 +62,7 @@ end
|
|
|
62
62
|
---@return PaddleOCRResult[] 匹配到的子串结果数组,坐标为原图/全屏绝对坐标
|
|
63
63
|
---@example local results = paddleocr.findTextAbs("screen", {"确定"}, 100, 100, 500, 300, 0.6)
|
|
64
64
|
--- if #results > 0 then
|
|
65
|
-
--- action.click(results[
|
|
65
|
+
--- action.click(results[1].centerX, results[1].centerY)
|
|
66
66
|
--- end
|
|
67
67
|
function _PaddleOCR.findTextAbs(input, targets, x, y, ex, ey, confidenceThreshold, exactMatch)
|
|
68
68
|
---@type PaddleOCRResult[]
|