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.
Files changed (83) hide show
  1. package/package.json +2 -2
  2. package/types/action.d.ts +7 -2
  3. package/types/ai.d.ts +5 -4
  4. package/types/appleocr.d.ts +4 -4
  5. package/types/cloud.d.ts +1 -2
  6. package/types/config.d.ts +1 -1
  7. package/types/cryptoUtils.d.ts +5 -2
  8. package/types/device.d.ts +1 -1
  9. package/types/dotocr.d.ts +3 -1
  10. package/types/file.d.ts +2 -2
  11. package/types/hotUpdate.d.ts +1 -2
  12. package/types/http.d.ts +6 -6
  13. package/types/image.d.ts +1 -1
  14. package/types/ime.d.ts +1 -1
  15. package/types/logger.d.ts +2 -2
  16. package/types/lua/action.lua +119 -89
  17. package/types/lua/ai.lua +34 -16
  18. package/types/lua/appleocr.lua +35 -22
  19. package/types/lua/cloud.lua +25 -12
  20. package/types/lua/config.lua +18 -11
  21. package/types/lua/cryptoUtils.lua +35 -27
  22. package/types/lua/cv.lua +173 -25
  23. package/types/lua/device.lua +38 -20
  24. package/types/lua/dotocr.lua +8 -2
  25. package/types/lua/file.lua +61 -40
  26. package/types/lua/global.lua +56 -20
  27. package/types/lua/hid.lua +147 -101
  28. package/types/lua/hotupdate.lua +25 -3
  29. package/types/lua/http.lua +71 -41
  30. package/types/lua/image.lua +222 -98
  31. package/types/lua/ime.lua +37 -13
  32. package/types/lua/logger.lua +22 -12
  33. package/types/lua/media.lua +54 -14
  34. package/types/lua/mysql.lua +61 -12
  35. package/types/lua/netcard.lua +25 -11
  36. package/types/lua/node.lua +4 -2
  37. package/types/lua/paddleocr.lua +35 -21
  38. package/types/lua/pip.lua +30 -18
  39. package/types/lua/system.lua +112 -31
  40. package/types/lua/tomatoocr.lua +73 -26
  41. package/types/lua/tts.lua +26 -10
  42. package/types/lua/ui.lua +35 -14
  43. package/types/lua/utils.lua +27 -17
  44. package/types/lua/yolo.lua +25 -17
  45. package/types/lua/yolocls.lua +27 -18
  46. package/types/media.d.ts +1 -1
  47. package/types/mysql.d.ts +1 -1
  48. package/types/netCard.d.ts +3 -0
  49. package/types/node.d.ts +1 -1
  50. package/types/paddleocr.d.ts +2 -5
  51. package/types/pip.d.ts +3 -0
  52. package/types/system.d.ts +1 -1
  53. package/types/tomatoocr.d.ts +3 -4
  54. package/types/tts.d.ts +2 -2
  55. package/types/ui.d.ts +1 -1
  56. package/types/utils.d.ts +1 -1
  57. package/types/web.d.ts +1 -1
  58. package/types/yolo.d.ts +1 -1
  59. package/types/yoloCls.d.ts +1 -1
  60. package/types/zh/HID/346/250/241/345/235/227.d.ts +1 -1
  61. package/types/zh/HTTP/346/250/241/345/235/227.d.ts +7 -6
  62. package/types/zh/MySql/346/250/241/345/235/227.d.ts +2 -1
  63. package/types/zh/PaddleOCR/346/250/241/345/235/227.d.ts +3 -5
  64. package/types/zh/YOLO/345/210/206/347/261/273/346/250/241/345/235/227.d.ts +1 -1
  65. package/types/zh/YOLO/346/250/241/345/235/227.d.ts +1 -1
  66. package/types/zh//344/272/221/346/216/247/346/250/241/345/235/227.d.ts +4 -1
  67. package/types/zh//345/212/250/344/275/234/346/250/241/345/235/227.d.ts +7 -2
  68. package/types/zh//345/233/276/347/211/207/346/250/241/345/235/227.d.ts +2 -1
  69. package/types/zh//345/252/222/344/275/223/346/250/241/345/235/227.d.ts +1 -1
  70. package/types/zh//345/267/245/345/205/267/346/250/241/345/235/227.d.ts +1 -1
  71. package/types/zh//346/202/254/346/265/256/347/252/227/346/250/241/345/235/227.d.ts +2 -1
  72. package/types/zh//346/226/207/344/273/266/346/250/241/345/235/227.d.ts +3 -2
  73. 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
  74. package/types/zh//346/227/245/345/277/227/346/250/241/345/235/227.d.ts +2 -2
  75. package/types/zh//347/202/271/351/230/265OCR/346/250/241/345/235/227.d.ts +3 -1
  76. package/types/zh//347/263/273/347/273/237/346/250/241/345/235/227.d.ts +2 -1
  77. package/types/zh//347/272/277/347/250/213/346/250/241/345/235/227.d.ts +1 -0
  78. package/types/zh//350/212/202/347/202/271/346/250/241/345/235/227.d.ts +1 -1
  79. package/types/zh//350/213/271/346/236/234OCR.d.ts +4 -4
  80. package/types/zh//350/247/206/345/233/276/346/250/241/345/235/227.d.ts +2 -2
  81. package/types/zh//350/256/276/345/244/207/346/250/241/345/235/227.d.ts +2 -1
  82. package/types/zh//350/276/223/345/205/245/346/263/225/346/250/241/345/235/227.d.ts +2 -1
  83. package/types/zh//351/205/215/347/275/256/346/250/241/345/235/227.d.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-types",
3
- "version": "0.10.7",
3
+ "version": "0.10.9",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -18,6 +18,6 @@
18
18
  "devDependencies": {
19
19
  "vitepress": "^1.6.4",
20
20
  "vitepress-theme-teek": "^1.6.2",
21
- "wrangler": "^4.130.0"
21
+ "wrangler": "^4.131.0"
22
22
  }
23
23
  }
package/types/action.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 动作模块 包含点击、滑动、长按滑动、返回首页等动作
2
+ * 动作模块
3
3
  */
4
4
  declare namespace action {
5
5
  /**
@@ -196,7 +196,12 @@ declare namespace action {
196
196
  * @example action.pressButton("home")
197
197
  */
198
198
  function pressButton(
199
- button: "home" | "volumeup" | "volumedown" | "brightnessup" | "brightnessdown",
199
+ button:
200
+ | "home"
201
+ | "volumeup"
202
+ | "volumedown"
203
+ | "brightnessup"
204
+ | "brightnessdown",
200
205
  ): boolean;
201
206
 
202
207
  /**
package/types/ai.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  /**
2
- * AI 模块 让脚本直接在手机上调用大模型:看图回答、是非判断、提取结构化数据、多轮对话。
3
- * 支持 openai 兼容 / anthropic / gemini 三种协议;模型配置写在脚本里,脚本开头 ai.setProvider 一次即可。
4
- * 所有方法同步阻塞,失败返回 null / false,原因用 ai.lastError() 查看。
2
+ * AI模块
5
3
  */
6
4
  declare namespace ai {
7
5
  /**
@@ -160,7 +158,10 @@ declare namespace ai {
160
158
  * @example
161
159
  * ai.chat([{ role: "system", content: "你是助手" }, { role: "user", content: "看下这是哪个页面", image: "screen" }])
162
160
  */
163
- function chat(messages: (AiMessage | string)[], options?: AiOptions): string | null;
161
+ function chat(
162
+ messages: (AiMessage | string)[],
163
+ options?: AiOptions,
164
+ ): string | null;
164
165
  /**
165
166
  * 从模型文本里解析 JSON,自动剥掉 Markdown 代码块和前后解释
166
167
  * @param text 模型输出
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Apple OCR模块 使用Apple Vision框架进行文本识别
2
+ * AppleOCR模块
3
3
  */
4
4
  declare namespace appleOcr {
5
5
  /**
@@ -49,7 +49,7 @@ declare namespace appleOcr {
49
49
  y?: number,
50
50
  ex?: number,
51
51
  ey?: number,
52
- languages?: string[]
52
+ languages?: string[],
53
53
  ): OCRResult[];
54
54
 
55
55
  /**
@@ -71,7 +71,7 @@ declare namespace appleOcr {
71
71
  x?: number,
72
72
  y?: number,
73
73
  ex?: number,
74
- ey?: number
74
+ ey?: number,
75
75
  ): OCRResult[];
76
76
 
77
77
  /**
@@ -99,6 +99,6 @@ declare namespace appleOcr {
99
99
  ex?: number,
100
100
  ey?: number,
101
101
  languages?: string[],
102
- exactMatch?: boolean
102
+ exactMatch?: boolean,
103
103
  ): OCRResult[];
104
104
  }
package/types/cloud.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /**
2
- * 云控模块类型定义
3
- * 提供主脚本侧连接云控、断开连接、判断连接状态、上报 Object 数据和监听服务端事件的能力。
2
+ * 云控模块
4
3
  */
5
4
  declare namespace cloud {
6
5
  /**
package/types/config.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 配置模块 包含读取配置、更新配置、删除配置等功能
2
+ * 配置模块
3
3
  */
4
4
  declare namespace config {
5
5
  /**
@@ -1,3 +1,6 @@
1
+ /**
2
+ * 加密工具模块
3
+ */
1
4
  declare namespace cryptoUtils {
2
5
  /// 使用AES ECB模式加密数据 默认使用PKCS7填充
3
6
  /// - Parameters:
@@ -8,7 +11,7 @@ declare namespace cryptoUtils {
8
11
  function encryptWithAES_ECB(
9
12
  data: string,
10
13
  aesKey: string,
11
- noPadding?: boolean
14
+ noPadding?: boolean,
12
15
  ): string;
13
16
 
14
17
  /// 使用AES ECB模式解密数据 默认使用PKCS7填充
@@ -20,7 +23,7 @@ declare namespace cryptoUtils {
20
23
  function decryptWithAES_ECB(
21
24
  data: string,
22
25
  aesKey: string,
23
- noPadding?: boolean
26
+ noPadding?: boolean,
24
27
  ): string;
25
28
 
26
29
  /// 使用RSA公钥加密数据 默认使用PKCS1填充
package/types/device.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 设备模块 包含获取设备信息、设备操作等功能
2
+ * 设备模块
3
3
  */
4
4
  declare namespace device {
5
5
  /**
package/types/dotocr.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- /** 固定像素尺寸的点阵 OCR(`kuaijs-dot-font` 字库)。 */
1
+ /**
2
+ * 点阵OCR模块
3
+ */
2
4
  declare namespace dotOcr {
3
5
  interface OCRChar {
4
6
  text: string;
package/types/file.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 文件模块 包含文件操作、文件内容读写等功能
2
+ * 文件模块
3
3
  */
4
4
  declare namespace file {
5
5
  /**
@@ -9,7 +9,7 @@ declare namespace file {
9
9
  * @example file.getInternalDir("documents")
10
10
  */
11
11
  function getInternalDir(
12
- type: "documents" | "library" | "temp" | "libraryCaches"
12
+ type: "documents" | "library" | "temp" | "libraryCaches",
13
13
  ): string;
14
14
  /**
15
15
  * 创建文件
@@ -1,6 +1,5 @@
1
1
  /**
2
- * 热更新模块类型定义
3
- * 提供应用热更新功能,包括检查更新、下载更新包、MD5校验等
2
+ * 热更新模块
4
3
  */
5
4
  declare namespace hotUpdate {
6
5
  /**
package/types/http.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * HTTP模块 包含发送HTTP请求、下载文件等功能、websocket等功能
2
+ * HTTP模块
3
3
  */
4
4
  declare namespace http {
5
5
  /**
@@ -131,7 +131,7 @@ declare namespace http {
131
131
  url: string,
132
132
  file: string,
133
133
  timeout?: number,
134
- headers?: Record<string, string>
134
+ headers?: Record<string, string>,
135
135
  ): boolean;
136
136
 
137
137
  /**
@@ -148,7 +148,7 @@ declare namespace http {
148
148
  url: string,
149
149
  params?: Record<string, string>,
150
150
  timeout?: number,
151
- headers?: Record<string, string>
151
+ headers?: Record<string, string>,
152
152
  ): string | null;
153
153
 
154
154
  /**
@@ -167,7 +167,7 @@ declare namespace http {
167
167
  params?: Record<string, string>,
168
168
  files?: Record<string, string>,
169
169
  timeout?: number,
170
- headers?: Record<string, string>
170
+ headers?: Record<string, string>,
171
171
  ): string | null;
172
172
 
173
173
  /**
@@ -187,7 +187,7 @@ declare namespace http {
187
187
  url: string,
188
188
  json?: Record<string, any>,
189
189
  timeout?: number,
190
- headers?: Record<string, string>
190
+ headers?: Record<string, string>,
191
191
  ): string | null;
192
192
 
193
193
  /**
@@ -206,7 +206,7 @@ declare namespace http {
206
206
  */
207
207
  function newWebsocket(
208
208
  url: string,
209
- header?: Record<string, string>
209
+ header?: Record<string, string>,
210
210
  ): WebSocket;
211
211
 
212
212
  /**
package/types/image.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 图片模块 包含图片操作、图片内容读写等功能
2
+ * 图片模块
3
3
  */
4
4
  declare namespace image {
5
5
  /**
package/types/ime.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 输入法模块 包含输入法操作、输入法内容读写等功能
2
+ * 输入法模块
3
3
  */
4
4
  declare namespace ime {
5
5
  /**
package/types/logger.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 日志模块 包含日志输出、日志等级设置等功能
2
+ * 日志模块
3
3
  */
4
4
  declare namespace logger {
5
5
  /**
@@ -9,7 +9,7 @@ declare namespace logger {
9
9
  * logger.setLoggerLevel("info");
10
10
  */
11
11
  function setLoggerLevel(
12
- level: "error" | "warn" | "debug" | "info" | "off"
12
+ level: "error" | "warn" | "debug" | "info" | "off",
13
13
  ): void;
14
14
  /**
15
15
  * 设置是否输出到文件 默认开启
@@ -1,128 +1,147 @@
1
1
  ---@meta
2
+ --- 动作模块
2
3
  ---@class Action
3
4
  local _Action = {}
4
5
 
5
6
  --- 设置动作抖动值
6
- --- @param value integer 抖动值
7
+ ---@param value integer 抖动值
8
+ ---@example action.setJitterValue(5)
7
9
  function _Action.setJitterValue(value) end
8
10
 
9
11
  --- 点击
10
- --- @param x integer
11
- --- @param y integer
12
- --- @param duration integer|nil 按下持续时间,默认20ms
13
- --- @param jitter boolean|nil 是否抖动,默认false
14
- --- @return boolean 成功与否
12
+ ---@param x integer 坐标x
13
+ ---@param y integer 坐标y
14
+ ---@param duration integer|nil 持续时间 默认20ms
15
+ ---@param jitter boolean|nil 抖动 开启抖动,会在像素范围随机偏移 点击 默认false
16
+ ---@return boolean 点击是否成功
17
+ ---@example action.click(100, 100, 20, true)
15
18
  function _Action.click(x, y, duration, jitter) return true end
16
19
 
17
20
  --- 随机点击
18
- --- @param x1 integer
19
- --- @param y1 integer
20
- --- @param x2 integer
21
- --- @param y2 integer
22
- --- @param duration integer|nil 按下持续时间
23
- --- @return boolean 成功与否
21
+ ---@param x1 integer 区域左上角x坐标
22
+ ---@param y1 integer 区域左上角y坐标
23
+ ---@param x2 integer 区域右下角x坐标
24
+ ---@param y2 integer 区域右下角y坐标
25
+ ---@param duration integer|nil 持续时间 默认20ms
26
+ ---@return boolean 随机点击是否成功
27
+ ---@example action.clickRandom(100, 100, 200, 200, 20)
24
28
  function _Action.clickRandom(x1, y1, x2, y2, duration) return true end
25
29
 
26
30
  --- 双击
27
- --- @param x integer
28
- --- @param y integer
29
- --- @param duration integer|nil 按下持续时间,默认20ms
30
- --- @param interval integer|nil 双击间隔,默认20ms
31
- --- @param jitter boolean|nil 是否抖动
32
- --- @return boolean 成功与否
31
+ ---@param x integer 坐标x
32
+ ---@param y integer 坐标y
33
+ ---@param duration integer|nil 持续时间 默认20ms
34
+ ---@param interval integer|nil 双击间隔时间 默认20ms
35
+ ---@param jitter boolean|nil 抖动 开启抖动,会在像素范围随机偏移 点击 默认false
36
+ ---@return boolean 双击是否成功
37
+ ---@example action.doubleClick(100, 100, 20, 20, true)
33
38
  function _Action.doubleClick(x, y, duration, interval, jitter) return true end
34
39
 
35
40
  --- 随机双击
36
- --- @param x1 integer
37
- --- @param y1 integer
38
- --- @param x2 integer
39
- --- @param y2 integer
40
- --- @param duration integer|nil 持续时间
41
- --- @param interval integer|nil 间隔时间
42
- --- @return boolean 成功与否
41
+ ---@param x1 integer 区域左上角x坐标
42
+ ---@param y1 integer 区域左上角y坐标
43
+ ---@param x2 integer 区域右下角x坐标
44
+ ---@param y2 integer 区域右下角y坐标
45
+ ---@param duration integer|nil 持续时间 默认20ms
46
+ ---@param interval integer|nil 双击间隔时间 默认20ms
47
+ ---@return boolean 随机双击是否成功
48
+ ---@example action.doubleClickRandom(100, 100, 200, 200, 20, 20)
43
49
  function _Action.doubleClickRandom(x1, y1, x2, y2, duration, interval)
44
50
  return true
45
51
  end
46
52
 
47
53
  --- 直线滑动
48
- --- @param startX integer
49
- --- @param startY integer
50
- --- @param endX integer
51
- --- @param endY integer
52
- --- @param duration integer|nil 总持续时间
53
- --- @param jitter boolean|nil 是否抖动
54
- --- @param steps integer|nil 步数
55
- --- @return boolean 成功与否
54
+ ---@param startX integer 起始坐标x
55
+ ---@param startY integer 起始坐标y
56
+ ---@param endX integer 结束坐标x
57
+ ---@param endY integer 结束坐标y
58
+ ---@param duration integer|nil 持续时间 默认 100ms
59
+ ---@param jitter boolean|nil 抖动 开启抖动,会在像素范围随机偏移 滑动 默认false
60
+ ---@param steps integer|nil 步数 生成抖动点数量 默认6
61
+ ---@return boolean 滑动是否成功
62
+ ---@example action.swipe(100, 100, 200, 200, 500, true, 10)
56
63
  function _Action.swipe(startX, startY, endX, endY, duration, jitter, steps)
57
64
  return true
58
65
  end
59
66
 
60
67
  --- 长按并滑动
61
- --- @param startX integer
62
- --- @param startY integer
63
- --- @param endX integer
64
- --- @param endY integer
65
- --- @param touchDown integer|nil 按下时长
66
- --- @param touchMove integer|nil 移动时长
67
- --- @param touchUp integer|nil 抬起时长
68
- --- @param jitter boolean|nil 是否抖动
69
- --- @param steps integer|nil 步数
70
- --- @return boolean 成功与否
68
+ ---@param startX integer 起始坐标x
69
+ ---@param startY integer 起始坐标y
70
+ ---@param endX integer 结束坐标x
71
+ ---@param endY integer 结束坐标y
72
+ ---@param touchDown integer|nil 按下持续时间 默认500ms
73
+ ---@param touchMove integer|nil 移动持续时间 默认1000ms
74
+ ---@param touchUp integer|nil 松开持续时间 默认500ms
75
+ ---@param jitter boolean|nil 抖动 开启抖动,会在像素范围随机偏移 长按滑动 默认false
76
+ ---@param steps integer|nil 步数 生成抖动点数量 默认6
77
+ ---@return boolean 长按滑动是否成功
78
+ ---@example action.pressAndSwipe(100, 100, 200, 200, 500, 500, 500, true, 10)
71
79
  function _Action.pressAndSwipe(startX, startY, endX, endY, touchDown, touchMove,
72
80
  touchUp, jitter, steps) return true end
73
81
 
74
82
  --- 曲线滑动
75
- --- @param startX integer
76
- --- @param startY integer
77
- --- @param midX integer
78
- --- @param midY integer
79
- --- @param endX integer
80
- --- @param endY integer
81
- --- @param duration integer 总时长
82
- --- @return boolean 成功与否
83
+ ---@param startX integer 起始x坐标
84
+ ---@param startY integer 起始y坐标
85
+ ---@param midX integer 中间点x坐标(控制曲线弯曲程度)
86
+ ---@param midY integer 中间点y坐标(控制曲线弯曲程度)
87
+ ---@param endX integer 目标x坐标
88
+ ---@param endY integer 目标y坐标
89
+ ---@param duration integer 总持续时间(毫秒),默认1000ms,实际执行时间会有随机变化
90
+ ---@return boolean 曲线滑动是否成功
91
+ ---@example action.swipeCurve(100, 100, 200, 150, 300, 200, 1000)
83
92
  function _Action.swipeCurve(startX, startY, midX, midY, endX, endY, duration)
84
93
  return true
85
94
  end
86
95
 
87
96
  --- 输入文本
88
- --- @param text string 文本
89
- --- @return boolean 成功与否
97
+ ---@param text string 文本内容
98
+ ---@return boolean 输入文本是否成功
99
+ ---@example action.input("123456")
90
100
  function _Action.input(text) return true end
91
101
 
92
102
  --- 基础文本输入(不支持中文,走键盘按键)
93
- --- @param text string ASCII 文本
94
- --- @return boolean 成功与否
103
+ ---@param text string 文本内容
104
+ ---@return boolean 输入是否成功
105
+ ---@example action.inputSimple("hello_123")
95
106
  function _Action.inputSimple(text) return true end
96
107
 
97
108
  --- 删除文本
98
- --- @param count integer|nil 删除数量,默认1
99
- --- @return boolean 成功与否
109
+ ---@param count integer|nil 删除数量 默认为1
110
+ ---@return boolean 删除文本是否成功
111
+ ---@example action.backspace(1)
100
112
  function _Action.backspace(count) return true end
101
113
 
102
114
  --- 回车
103
- --- @return boolean 成功与否
115
+ ---@return boolean 调用回车是否成功
116
+ ---@example action.enter()
104
117
  function _Action.enter() return true end
105
118
 
106
119
  --- 回到主页
107
- --- @return boolean 成功与否
120
+ ---@return boolean 返回首页是否成功
121
+ ---@example action.homeScreen()
108
122
  function _Action.homeScreen() return true end
109
123
 
110
124
  --- 按键
111
- --- @param name string 按键名称
112
- --- @return boolean 成功与否
125
+ ---@param name string 按钮 home 按下home键 volumeup 按下音量上键 volumedown 按下音量下键 brightnessup 调高屏幕亮度 brightnessdown 调低屏幕亮度
126
+ ---@return boolean 按下按钮是否成功
127
+ ---@example action.pressButton("home")
113
128
  function _Action.pressButton(name) return true end
114
129
 
115
130
  --- 发送键盘组合键(标准 USB HID usage)
116
- --- @param keys (string|integer)[] 按键数组
117
- --- @return boolean 成功与否
131
+ ---@param keys (string|integer)[] 要发送的按键数组
132
+ ---@return boolean 发送是否成功
133
+ ---@example action.sendKey({"COMMAND", "c"})
134
+ ---@example action.sendKey({0xe3, 0x06})
135
+ ---@example action.sendKey({HidKey.COMMAND, "v"})
118
136
  function _Action.sendKey(keys) return true end
119
137
 
120
138
  ---@class W3CActionsJson
121
139
  ---@field actions table<string, any>[] W3C action 序列
122
140
 
123
141
  --- 执行 W3C Actions JSON
124
- --- @param json W3CActionsJson W3C Actions 请求体
125
- --- @return boolean 成功与否
142
+ ---@param json W3CActionsJson W3C Actions 请求体,例如 { actions: [...] }
143
+ ---@return boolean 执行是否成功
144
+ ---@example action.w3cActions({ actions = { { type = "pointer", id = "finger1" } } })
126
145
  function _Action.w3cActions(json) return true end
127
146
 
128
147
  ---@class TapPoint
@@ -133,8 +152,9 @@ function _Action.w3cActions(json) return true end
133
152
  local _ActionBuilder = {}
134
153
 
135
154
  --- 添加手指
136
- --- @param id integer 指针编号
137
- --- @return Pointer 返回指针对象
155
+ ---@param id integer 指针编号
156
+ ---@return Pointer 返回指针对象
157
+ ---@example builder:addPointer(id)
138
158
  function _ActionBuilder:addPointer(id)
139
159
  ---@type Pointer
140
160
  local ret
@@ -142,10 +162,11 @@ function _ActionBuilder:addPointer(id)
142
162
  end
143
163
 
144
164
  --- 单指点击
145
- --- @param x integer
146
- --- @param y integer
147
- --- @param duration integer|nil 按下持续时间,默认20ms
148
- --- @return ActionBuilder self
165
+ ---@param x integer
166
+ ---@param y integer
167
+ ---@param duration integer|nil 按下持续时间,默认20ms
168
+ ---@return ActionBuilder self
169
+ ---@example builder:singleTap(x, y, duration)
149
170
  function _ActionBuilder:singleTap(x, y, duration)
150
171
  ---@type ActionBuilder
151
172
  local ret
@@ -153,9 +174,10 @@ function _ActionBuilder:singleTap(x, y, duration)
153
174
  end
154
175
 
155
176
  --- 多指同时点击
156
- --- @param points TapPoint[] 坐标数组
157
- --- @param duration integer|nil 按下持续时间,默认20ms
158
- --- @return ActionBuilder self
177
+ ---@param points TapPoint[] 坐标数组
178
+ ---@param duration integer|nil 按下持续时间,默认20ms
179
+ ---@return ActionBuilder self
180
+ ---@example builder:multiTap(points, duration)
159
181
  function _ActionBuilder:multiTap(points, duration)
160
182
  ---@type ActionBuilder
161
183
  local ret
@@ -163,17 +185,19 @@ function _ActionBuilder:multiTap(points, duration)
163
185
  end
164
186
 
165
187
  --- 执行动作
166
- --- @return boolean 成功与否
188
+ ---@return boolean 成功与否
189
+ ---@example builder:execute()
167
190
  function _ActionBuilder:execute() return true end
168
191
 
169
192
  ---@class Pointer
170
193
  local _Pointer = {}
171
194
 
172
195
  --- 移动到
173
- --- @param x integer
174
- --- @param y integer
175
- --- @param duration integer|nil 持续时间
176
- --- @return Pointer self
196
+ ---@param x integer
197
+ ---@param y integer
198
+ ---@param duration integer|nil 持续时间
199
+ ---@return Pointer self
200
+ ---@example pointer:moveTo(x, y, duration)
177
201
  function _Pointer:moveTo(x, y, duration)
178
202
  ---@type Pointer
179
203
  local ret
@@ -181,7 +205,8 @@ function _Pointer:moveTo(x, y, duration)
181
205
  end
182
206
 
183
207
  --- 按下
184
- --- @return Pointer self
208
+ ---@return Pointer self
209
+ ---@example pointer:down()
185
210
  function _Pointer:down()
186
211
  ---@type Pointer
187
212
  local ret
@@ -189,7 +214,8 @@ function _Pointer:down()
189
214
  end
190
215
 
191
216
  --- 抬起
192
- --- @return Pointer self
217
+ ---@return Pointer self
218
+ ---@example pointer:up()
193
219
  function _Pointer:up()
194
220
  ---@type Pointer
195
221
  local ret
@@ -197,8 +223,9 @@ function _Pointer:up()
197
223
  end
198
224
 
199
225
  --- 停留
200
- --- @param duration integer 停留时间,默认20ms
201
- --- @return Pointer self
226
+ ---@param duration integer 停留时间,默认20ms
227
+ ---@return Pointer self
228
+ ---@example pointer:stay(duration)
202
229
  function _Pointer:stay(duration)
203
230
  ---@type Pointer
204
231
  local ret
@@ -206,10 +233,11 @@ function _Pointer:stay(duration)
206
233
  end
207
234
 
208
235
  --- 点击
209
- --- @param x integer
210
- --- @param y integer
211
- --- @param duration integer|nil 按下持续时间,默认20ms
212
- --- @return Pointer self
236
+ ---@param x integer
237
+ ---@param y integer
238
+ ---@param duration integer|nil 按下持续时间,默认20ms
239
+ ---@return Pointer self
240
+ ---@example pointer:tap(x, y, duration)
213
241
  function _Pointer:tap(x, y, duration)
214
242
  ---@type Pointer
215
243
  local ret
@@ -217,7 +245,8 @@ function _Pointer:tap(x, y, duration)
217
245
  end
218
246
 
219
247
  --- 完成,返回构建器
220
- --- @return ActionBuilder builder
248
+ ---@return ActionBuilder builder
249
+ ---@example pointer:done()
221
250
  function _Pointer:done()
222
251
  ---@type ActionBuilder
223
252
  local ret
@@ -225,7 +254,8 @@ function _Pointer:done()
225
254
  end
226
255
 
227
256
  --- 创建构建器
228
- --- @return ActionBuilder builder
257
+ ---@return ActionBuilder ActionBuilder 实例
258
+ ---@example local builder = action.createBuilder()
229
259
  function _Action.createBuilder()
230
260
  ---@type ActionBuilder
231
261
  local ret