ms-types 0.9.39 → 0.9.41

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-types",
3
- "version": "0.9.39",
3
+ "version": "0.9.41",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
package/types/hid.d.ts CHANGED
@@ -93,7 +93,7 @@ declare namespace hid {
93
93
  function getDeviceVersion(): string;
94
94
 
95
95
  /**
96
- * 复位坐标到左上角 只有相对鼠标需要
96
+ * 复位坐标到左下角 只有相对鼠标需要
97
97
  * @returns 操作是否成功
98
98
  */
99
99
  function resetPosition(): boolean;
@@ -104,6 +104,13 @@ declare namespace hid {
104
104
  */
105
105
  function restartDevice(): boolean;
106
106
 
107
+ /**
108
+ * 开关充电。当前连接的 HID 不支持时返回 false。
109
+ * @param on true 打开充电,false 关闭充电
110
+ * @returns 是否成功发送
111
+ */
112
+ function setCharging(on: boolean): boolean;
113
+
107
114
  /**
108
115
  * 设置动作抖动值
109
116
  * @param value 抖动值
package/types/image.d.ts CHANGED
@@ -293,6 +293,33 @@ declare namespace image {
293
293
  /** 仅 method=99 返回:命中时模板的纵向缩放比例 */
294
294
  scaleY?: number;
295
295
  }[];
296
+ /**
297
+ * 按 kjst 模板找图
298
+ * @param imageId 图片id,通常为 `"screen"`
299
+ * @param kjstPath res 下的 kjst 文件名,不要带 `res/` 前缀
300
+ * @returns 矩形数组,坐标已换算到传入图片(`screen` 即屏幕)像素,可直接 click;OCR 命中额外含 `text`
301
+ * @example
302
+ * const hits = image.findImageEx("screen", "login.kjst")
303
+ * if (hits.length > 0) {
304
+ * logi(hits[0].x, hits[0].y)
305
+ * }
306
+ */
307
+ function findImageEx(
308
+ imageId: string,
309
+ kjstPath: string,
310
+ ): {
311
+ index: number;
312
+ x: number;
313
+ y: number;
314
+ width: number;
315
+ height: number;
316
+ confidence: number;
317
+ centerX: number;
318
+ centerY: number;
319
+ ex: number;
320
+ ey: number;
321
+ text?: string;
322
+ }[];
296
323
  /**
297
324
  * 裁剪图片
298
325
  * @param imageId 图片id
package/types/lua/hid.lua CHANGED
@@ -77,7 +77,7 @@ function _HID.mouseUp() return true end
77
77
  --- @return boolean 成功
78
78
  function _HID.click(x, y, duration, jitter) return true end
79
79
 
80
- --- 复位坐标到左上角(仅相对鼠标模式需要)
80
+ --- 复位坐标到左下角(仅相对鼠标模式需要)
81
81
  --- @return boolean 成功
82
82
  function _HID.resetPosition() return true end
83
83
 
@@ -122,6 +122,11 @@ function _HID.getDeviceVersion() return '' end
122
122
  --- @return boolean 成功
123
123
  function _HID.restartDevice() return true end
124
124
 
125
+ --- 开关充电。当前连接的 HID 不支持时返回 false。
126
+ --- @param on boolean true 打开充电,false 关闭充电
127
+ --- @return boolean 成功
128
+ function _HID.setCharging(on) return true end
129
+
125
130
  --- 随机点击
126
131
  --- @param x1 integer
127
132
  --- @param y1 integer
@@ -23,6 +23,7 @@ local _Image = {}
23
23
  ---@field ey integer 右下角y坐标
24
24
  ---@field scaleX number|nil 仅 method=99:命中时模板横向缩放
25
25
  ---@field scaleY number|nil 仅 method=99:命中时模板纵向缩放
26
+ ---@field text string|nil OCR 命中文字
26
27
 
27
28
  ---@class FindImageOptions
28
29
  ---@field scaleFactors number[]|nil 仅 method=99:模板缩放比例列表
@@ -144,6 +145,12 @@ function _Image.cmpColor(id, points, threshold) return true end
144
145
  function _Image.findImage(id, templateImageId, x, y, ex, ey, threshold, limit,
145
146
  method, rgb, options) return {} end
146
147
 
148
+ --- 按 kjst 模板找图
149
+ --- @param id string 图片ID,通常为 screen
150
+ --- @param kjstPath string res 下的 kjst 文件名
151
+ --- @return Rect[] 结果矩形,坐标已换算到传入图(screen 即屏幕)像素,可直接 click;OCR 命中含 text
152
+ function _Image.findImageEx(id, kjstPath) return {} end
153
+
147
154
  --- 多点找色
148
155
  --- @param id string 图片ID
149
156
  --- @param firstColor string 首色 "#RRGGBB" 或 "#RRGGBB"
@@ -14,11 +14,11 @@ local _Yolo = {}
14
14
  ---@field confidence number 置信度
15
15
  ---@field classId integer 类别 ID
16
16
 
17
- --- 加载 YOLO 模型(版本 8/11/26)
17
+ --- 加载 YOLO 模型(版本 5/8/11/26)
18
18
  --- @param paramPath string ncnn param 路径
19
19
  --- @param binPath string ncnn bin 路径
20
20
  --- @param nc integer|nil 标签数量;传 0 或省略时按模型输出推断
21
- --- @param version integer|nil 模型版本,缺省 0 按 v11 处理
21
+ --- @param version integer|nil 模型版本,缺省 0 按 v11 处理;5 为官方 YOLOv5 6.0/6.2/7.0,兼容官方 export 单输出和三头原始特征
22
22
  --- @param useGpu boolean|nil 是否启用 GPU,默认 false
23
23
  --- @return string|nil 模型ID(失败返回 nil)
24
24
  function _Yolo.load(paramPath, binPath, nc, version, useGpu) return nil end
package/types/yolo.d.ts CHANGED
@@ -52,7 +52,7 @@ declare namespace yolo {
52
52
  * @param paramPath ncnn模型的param文件的绝对路径
53
53
  * @param binPath ncnn模型的bin文件绝对路径
54
54
  * @param nc 模型的标签数量;传 0 或省略时根据模型输出自动推断,显式传入但不匹配时检测返回空数组
55
- * @param version 模型版本,默认11, 支持 8 11 26
55
+ * @param version 模型版本,默认11, 支持 5 8 11 26。5 为官方 YOLOv5 6.0/6.2/7.0,兼容官方 export 单输出和三头原始特征
56
56
  * @param useGpu 是否使用 GPU 加载
57
57
  * @returns 加载成功返回模型ID字符串,失败返回null
58
58
  * @example
@@ -95,7 +95,7 @@ declare namespace $HID {
95
95
  function 获取设备版本(): 字符串;
96
96
 
97
97
  /**
98
- * 复位坐标到左上角 只有相对鼠标需要
98
+ * 复位坐标到左下角 只有相对鼠标需要
99
99
  * @returns 操作是否成功
100
100
  */
101
101
  function 复位坐标(): 布尔值;
@@ -106,6 +106,13 @@ declare namespace $HID {
106
106
  */
107
107
  function 重启设备(): 布尔值;
108
108
 
109
+ /**
110
+ * 开关充电。当前连接的 HID 不支持时返回 false。
111
+ * @param 打开 true 打开充电,false 关闭充电
112
+ * @returns 是否成功发送
113
+ */
114
+ function 设置充电(打开: 布尔值): 布尔值;
115
+
109
116
  /**
110
117
  * 设置动作抖动值
111
118
  * @param 抖动值
@@ -55,7 +55,7 @@ declare namespace $YOLO {
55
55
  * @param ncnn模型的param文件路径 ncnn模型的param文件的绝对路径
56
56
  * @param ncnn模型的bin文件路径 ncnn模型的bin文件绝对路径
57
57
  * @param 标签数量 模型的标签数量;传 0 或省略时根据模型输出自动推断,显式传入但不匹配时检测返回空数组
58
- * @param 模型版本 模型版本,默认11, 支持 8 11 26
58
+ * @param 模型版本 模型版本,默认11, 支持 5 8 11 26。5 为官方 YOLOv5 6.0/6.2/7.0,兼容官方 export 单输出和三头原始特征
59
59
  * @param useGpu 是否使用 GPU 加载
60
60
  * @returns 加载成功返回模型ID字符串,失败返回null
61
61
  * @example
@@ -291,6 +291,33 @@ declare namespace $图片 {
291
291
  /** 仅方法=99 返回:命中时模板的纵向缩放比例 */
292
292
  scaleY?: 数字;
293
293
  }[];
294
+ /**
295
+ * 按 kjst 模板找图
296
+ * @param 图片ID 图片id,通常为 `"screen"`
297
+ * @param kjst路径 res 下的 kjst 文件名,不要带 `res/` 前缀
298
+ * @returns 矩形数组,坐标已换算到传入图片(`screen` 即屏幕)像素,可直接点击;OCR 命中额外含 `text`
299
+ * @example
300
+ * const 命中 = $图片.找图Ex("screen", "login.kjst")
301
+ * if (命中.length > 0) {
302
+ * $打印信息日志(命中[0].x, 命中[0].y)
303
+ * }
304
+ */
305
+ function 找图Ex(
306
+ 图片ID: 字符串,
307
+ kjst路径: 字符串,
308
+ ): {
309
+ index: 数字;
310
+ x: 数字;
311
+ y: 数字;
312
+ width: 数字;
313
+ height: 数字;
314
+ confidence: 数字;
315
+ centerX: 数字;
316
+ centerY: 数字;
317
+ ex: 数字;
318
+ ey: 数字;
319
+ text?: 字符串;
320
+ }[];
294
321
  /**
295
322
  * 裁剪图片
296
323
  * @param 图片ID