ms-types 0.0.14 → 0.0.16

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.0.14",
3
+ "version": "0.0.16",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Apple OCR模块 使用Apple Vision框架进行文本识别
3
3
  */
4
- declare namespace appleocr {
4
+ declare namespace appleOcr {
5
5
  /**
6
6
  * 执行OCR识别(使用Apple Vision框架)
7
7
  * @param input 输入源(imageId、URL字符串、文件路径或"screen",null表示使用当前屏幕)
@@ -12,7 +12,7 @@ declare namespace appleocr {
12
12
  * @param languages 识别语言数组,默认为["zh-Hans", "en-US"]
13
13
  * @returns 识别结果数组,包含文本、置信度、坐标等信息
14
14
  * @example
15
- * const results = appleocr.recognize("screen", 0, 0, 100, 100, ["zh-Hans", "en-US"])
15
+ * const results = appleOcr.recognize("screen", 0, 0, 100, 100, ["zh-Hans", "en-US"])
16
16
  * results.forEach(result => {
17
17
  * console.log(`文本: ${result.text}, 置信度: ${result.confidence}`)
18
18
  * })
@@ -34,10 +34,12 @@ declare namespace appleocr {
34
34
  * @param ex 边界框右下角x坐标
35
35
  * @param ey 边界框右下角y坐标
36
36
  * @param languages 识别语言数组
37
- * @returns 识别到的文本字符串(多行文本用换行符分隔)
37
+ * @returns 识别到的文本字符串数组
38
38
  * @example
39
- * const text = appleocr.recognizeText("screen", 0, 0, 100, 100)
40
- * console.log("识别到的文本:", text)
39
+ * const texts = appleOcr.recognizeText("screen", 0, 0, 100, 100)
40
+ * for (const text of texts) {
41
+ * logger.info(text)
42
+ * }
41
43
  */
42
44
  function recognizeText(
43
45
  input: string | null,
@@ -46,7 +48,7 @@ declare namespace appleocr {
46
48
  ex: number,
47
49
  ey: number,
48
50
  languages?: string[]
49
- ): string;
51
+ ): string[];
50
52
 
51
53
  /**
52
54
  * OCR识别结果接口
package/types/device.d.ts CHANGED
@@ -23,6 +23,12 @@ declare namespace device {
23
23
  * @example device.getDeviceID()
24
24
  */
25
25
  function getDeviceID(): string;
26
+ /**
27
+ * 获取服务器设备ID
28
+ * @returns 服务器设备ID
29
+ * @example device.getServerDeviceId()
30
+ */
31
+ function getServerDeviceId(): string;
26
32
  /**
27
33
  * 获取设备名称
28
34
  * @returns 设备名称
package/types/http.d.ts CHANGED
@@ -288,7 +288,7 @@ declare namespace http {
288
288
  * const ws = http.newWebsocket("ws://www.baidu.com")
289
289
  * ws.connect()
290
290
  * ws.onText((data) => {
291
- * console.log(data)
291
+ * logger.info(data)
292
292
  * })
293
293
  * ws.sendText("hello")
294
294
  * ws.close()
package/types/image.d.ts CHANGED
@@ -54,7 +54,7 @@ declare namespace image {
54
54
  * @example
55
55
  * const size = image.getSize(imageId)
56
56
  * if (size) {
57
- * console.log(size.width, size.height)
57
+ * logger.info(size.width, size.height)
58
58
  * }
59
59
  */
60
60
  function getSize(imageId: string): { width: number; height: number } | null;
@@ -101,7 +101,7 @@ declare namespace image {
101
101
  * if (imageId) {
102
102
  * const isSame = image.cmpColor(imageId, "1|2|#6DD1E6-#101010", 10, 0, 0, 100, 100)
103
103
  * if (isSame) {
104
- * console.log("颜色相同")
104
+ * logger.info("颜色相同")
105
105
  * }
106
106
  * }
107
107
  */
@@ -131,7 +131,7 @@ declare namespace image {
131
131
  * if (imageId) {
132
132
  * const points = image.findColor(imageId, "0x6DD1E6-0x101010", 10, 0, 0, 100, 100, 1, 1)
133
133
  * if (points.length > 0) {
134
- * console.log("找到颜色")
134
+ * logger.info("找到颜色")
135
135
  * }
136
136
  * }
137
137
  * image.release(imageId)
@@ -165,7 +165,7 @@ declare namespace image {
165
165
  * if (imageId) {
166
166
  * const points = image.findMultiColor(imageId, "0x6DD1E6-0x101010", 10, "1|2|#6DD1E6-#101010", 0, 0, 100, 100, 1, 1)
167
167
  * if (points.length > 0) {
168
- * console.log("找到颜色")
168
+ * logger.info("找到颜色")
169
169
  * }
170
170
  * }
171
171
  * image.release(imageId)
@@ -201,7 +201,7 @@ declare namespace image {
201
201
  * if (templateImageId) {
202
202
  * const points = image.findImage(imageId, templateImageId, 0, 0, 100, 100, 0.8, 1, 0)
203
203
  * if (points.length > 0) {
204
- * console.log("找到图片")
204
+ * logger.info("找到图片")
205
205
  * }
206
206
  * }
207
207
  * image.release(templateImageId)
@@ -238,7 +238,7 @@ declare namespace image {
238
238
  * if (imageId) {
239
239
  * const clipImageId = image.clip(imageId, 0, 0, 100, 100)
240
240
  * if (clipImageId) {
241
- * console.log("裁剪成功")
241
+ * logger.info("裁剪成功")
242
242
  * }
243
243
  * }
244
244
  * image.release(imageId)
@@ -260,7 +260,7 @@ declare namespace image {
260
260
  * const imageId = image.readImage("screen.png")
261
261
  * if (imageId) {
262
262
  * const color = image.pixel(imageId, 0, 0)
263
- * console.log(color)
263
+ * logger.info(color)
264
264
  * }
265
265
  * image.release(imageId)
266
266
  */
@@ -274,7 +274,7 @@ declare namespace image {
274
274
  * const imageId = image.readImage("screen.png")
275
275
  * if (imageId) {
276
276
  * const color = image.pixel(imageId, 0, 0)
277
- * console.log(image.argb(imageId, color))
277
+ * logger.info(image.argb(imageId, color))
278
278
  * }
279
279
  * image.release(imageId)
280
280
  */
@@ -289,7 +289,7 @@ declare namespace image {
289
289
  * if (imageId) {
290
290
  * const binaryzationImageId = image.binaryzation(imageId, 128)
291
291
  * if (binaryzationImageId) {
292
- * console.log("二值化成功")
292
+ * logger.info("二值化成功")
293
293
  * }
294
294
  * }
295
295
  * image.release(imageId)
@@ -304,7 +304,7 @@ declare namespace image {
304
304
  * if (imageId) {
305
305
  * const grayImageId = image.gray(imageId)
306
306
  * if (grayImageId) {
307
- * console.log("灰度化成功")
307
+ * logger.info("灰度化成功")
308
308
  * }
309
309
  * }
310
310
  * image.release(imageId)
@@ -317,7 +317,7 @@ declare namespace image {
317
317
  * @example
318
318
  * const imageId = image.base64ToImage("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P+/HgAFhAJ/wlseKgAAAABJRU5ErkJggg==")
319
319
  * if (imageId) {
320
- * console.log("base64转图片成功")
320
+ * logger.info("base64转图片成功")
321
321
  * }
322
322
  * image.release(imageId)
323
323
  */
@@ -332,7 +332,7 @@ declare namespace image {
332
332
  * const imageId = image.readImage("screen.png")
333
333
  * if (imageId) {
334
334
  * const base64 = image.toBase64Format(imageId, "png", 100)
335
- * console.log(base64)
335
+ * logger.info(base64)
336
336
  * }
337
337
  * image.release(imageId)
338
338
  */
package/types/ime.d.ts CHANGED
@@ -7,7 +7,7 @@ declare namespace ime {
7
7
  * @returns {boolean} 如果输入法键盘是否已弹出返回 true,否则返回 false
8
8
  * @example
9
9
  * if (ime.isOk()) {
10
- * console.log("输入法已启动")
10
+ * logger.info("输入法已启动")
11
11
  * }
12
12
  */
13
13
  function isOk(): boolean;
@@ -16,7 +16,7 @@ declare namespace ime {
16
16
  * @returns {string} 当前输入框的完整文本
17
17
  * @example
18
18
  * const text = ime.getText()
19
- * console.log(text)
19
+ * logger.info(text)
20
20
  */
21
21
  function getText(): string;
22
22
  /**
@@ -31,7 +31,7 @@ declare namespace ime {
31
31
  * @returns {string} 输入后的文本内容 失败返回空字符串
32
32
  * @example
33
33
  * const text = ime.input("hello")
34
- * console.log(text)
34
+ * logger.info(text)
35
35
  */
36
36
  function input(text: string): string;
37
37
  /**
@@ -40,7 +40,7 @@ declare namespace ime {
40
40
  * @returns {string} 粘贴后的文本内容 失败返回空字符串
41
41
  * @example
42
42
  * const text = ime.paste("hello")
43
- * console.log(text)
43
+ * logger.info(text)
44
44
  */
45
45
  function paste(text: string): string;
46
46
  /**
@@ -48,7 +48,7 @@ declare namespace ime {
48
48
  * @returns {string} 如果为空,代表输入框无数据,如果不为空,代表输入框剩余数据
49
49
  * @example
50
50
  * const text = ime.pressDel()
51
- * console.log(text)
51
+ * logger.info(text)
52
52
  */
53
53
  function pressDel(): string;
54
54
  /**
@@ -56,7 +56,7 @@ declare namespace ime {
56
56
  * @returns {boolean} 如果成功返回 true,否则返回 false
57
57
  * @example
58
58
  * if (ime.pressEnter()) {
59
- * console.log("回车键按下")
59
+ * logger.info("回车键按下")
60
60
  * }
61
61
  */
62
62
  function pressEnter(): boolean;
@@ -65,7 +65,7 @@ declare namespace ime {
65
65
  * @returns {boolean} 如果成功返回 true,否则返回 false
66
66
  * @example
67
67
  * if (ime.dismiss()) {
68
- * console.log("键盘已隐藏")
68
+ * logger.info("键盘已隐藏")
69
69
  * }
70
70
  */
71
71
  function dismiss(): boolean;
@@ -74,7 +74,7 @@ declare namespace ime {
74
74
  * @returns {string} 剪贴板内容
75
75
  * @example
76
76
  * const text = ime.getClipboard()
77
- * console.log(text)
77
+ * logger.info(text)
78
78
  */
79
79
  function getClipboard(): string;
80
80
  /**
@@ -83,7 +83,7 @@ declare namespace ime {
83
83
  * @returns {boolean} 如果成功返回 true,否则返回 false
84
84
  * @example
85
85
  * if (ime.setClipboard("hello")) {
86
- * console.log("剪贴板内容已设置")
86
+ * logger.info("剪贴板内容已设置")
87
87
  * }
88
88
  */
89
89
  function setClipboard(text: string): boolean;
@@ -92,7 +92,7 @@ declare namespace ime {
92
92
  * @returns {boolean} 如果成功返回 true,否则返回 false
93
93
  * @example
94
94
  * if (ime.switchKeyboard()) {
95
- * console.log("键盘已切换")
95
+ * logger.info("键盘已切换")
96
96
  * }
97
97
  */
98
98
  function switchKeyboard(): boolean;
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference path="action.d.ts" />
2
- /// <reference path="appleocr.d.ts" />
2
+ /// <reference path="appleOcr.d.ts" />
3
3
  /// <reference path="config.d.ts" />
4
4
  /// <reference path="device.d.ts" />
5
5
  /// <reference path="file.d.ts" />
@@ -9,9 +9,11 @@
9
9
  /// <reference path="ime.d.ts" />
10
10
  /// <reference path="logger.d.ts" />
11
11
  /// <reference path="media.d.ts" />
12
- /// <reference path="paddleocr.d.ts" />
12
+ /// <reference path="mysql.d.ts" />
13
+ /// <reference path="paddleOcr.d.ts" />
13
14
  /// <reference path="system.d.ts" />
14
15
  /// <reference path="thread.d.ts" />
16
+ /// <reference path="tomatoOcr.d.ts" />
15
17
  /// <reference path="ui.d.ts" />
16
18
  /// <reference path="utils.d.ts" />
17
19
  /// <reference path="yolo.d.ts" />
package/types/media.d.ts CHANGED
@@ -11,7 +11,7 @@ declare namespace media {
11
11
  * if (imageId) {
12
12
  * const saved = media.saveImageToAlbum(imageId)
13
13
  * if (saved) {
14
- * console.log("保存成功")
14
+ * logger.info("保存成功")
15
15
  * }
16
16
  * }
17
17
  */
@@ -24,7 +24,7 @@ declare namespace media {
24
24
  * @example
25
25
  * const saved = media.saveVideoToAlbumPath("video.mp4")
26
26
  * if (saved) {
27
- * console.log("保存成功")
27
+ * logger.info("保存成功")
28
28
  * }
29
29
  */
30
30
  function saveVideoToAlbumPath(path: string): boolean;
@@ -35,7 +35,7 @@ declare namespace media {
35
35
  * @example
36
36
  * const deleted = media.deleteAllPhotos()
37
37
  * if (deleted) {
38
- * console.log("删除成功")
38
+ * logger.info("删除成功")
39
39
  * }
40
40
  */
41
41
  function deleteAllPhotos(): boolean;
@@ -46,7 +46,7 @@ declare namespace media {
46
46
  * @example
47
47
  * const deleted = media.deleteAllVideos()
48
48
  * if (deleted) {
49
- * console.log("删除成功")
49
+ * logger.info("删除成功")
50
50
  * }
51
51
  */
52
52
  function deleteAllVideos(): boolean;
@@ -59,7 +59,7 @@ declare namespace media {
59
59
  * @example
60
60
  * const played = media.playMp3("music.mp3", true)
61
61
  * if (played) {
62
- * console.log("播放成功")
62
+ * logger.info("播放成功")
63
63
  * }
64
64
  */
65
65
  function playMp3(path: string, loop: boolean): boolean;
@@ -70,7 +70,7 @@ declare namespace media {
70
70
  * @example
71
71
  * const stopped = media.stopMp3()
72
72
  * if (stopped) {
73
- * console.log("停止成功")
73
+ * logger.info("停止成功")
74
74
  * }
75
75
  */
76
76
  function stopMp3(): boolean;
@@ -83,7 +83,7 @@ declare namespace media {
83
83
  * @example
84
84
  * const played = media.playMp3WaitEnd("music.mp3", true)
85
85
  * if (played) {
86
- * console.log("播放成功")
86
+ * logger.info("播放成功")
87
87
  * }
88
88
  */
89
89
  function playMp3WaitEnd(path: string, loop: boolean): boolean;
@@ -0,0 +1,181 @@
1
+ /**
2
+ * MySQL 数据库模块 - 提供 MySQL 数据库连接和操作功能
3
+ */
4
+ declare namespace mysql {
5
+ /**
6
+ * MySQL 连接配置接口
7
+ */
8
+ interface MySQLConfig {
9
+ /** 数据库主机地址 */
10
+ host: string;
11
+ /** 数据库端口,默认 3306 */
12
+ port?: number;
13
+ /** 用户名 */
14
+ username: string;
15
+ /** 密码 */
16
+ password: string;
17
+ /** 数据库名 */
18
+ database: string;
19
+ /** 字符集,默认 utf8mb4 */
20
+ charset?: string;
21
+ }
22
+
23
+ /**
24
+ * MySQL 查询结果接口
25
+ */
26
+ interface MySQLResult {
27
+ /** 查询结果数据行 */
28
+ rows: Array<Record<string, any>>;
29
+ /** 受影响的行数 */
30
+ affectedRows: number;
31
+ /** 插入ID(仅适用于INSERT操作) */
32
+ insertId?: number;
33
+ /** 查询是否成功 */
34
+ success: boolean;
35
+ /** 错误信息 */
36
+ error?: string;
37
+ }
38
+
39
+ /**
40
+ * 创建全局 MySQL 连接
41
+ * @param config 连接配置对象
42
+ * @returns 是否创建成功
43
+ * @example
44
+ * mysql.createConnection({
45
+ * host: "localhost",
46
+ * port: 3306,
47
+ * username: "root",
48
+ * password: "password",
49
+ * database: "test_db",
50
+ * charset: "utf8mb4"
51
+ * })
52
+ */
53
+ function createConnection(config: MySQLConfig): boolean;
54
+
55
+ /**
56
+ * 连接到数据库
57
+ * @returns 是否连接成功
58
+ * @example
59
+ * const connected = mysql.connect()
60
+ * if (connected) {
61
+ * logger.info("数据库连接成功")
62
+ * }
63
+ */
64
+ function connect(): boolean;
65
+
66
+ /**
67
+ * 断开数据库连接
68
+ * @example
69
+ * mysql.disconnect()
70
+ */
71
+ function disconnect(): void;
72
+
73
+ /**
74
+ * 检查连接状态
75
+ * @returns 是否已连接
76
+ * @example
77
+ * if (mysql.isConnected()) {
78
+ * logger.info("数据库已连接")
79
+ * }
80
+ */
81
+ function isConnected(): boolean;
82
+
83
+ /**
84
+ * 执行查询操作(SELECT)
85
+ * @param sql SQL 查询语句
86
+ * @param params 查询参数数组,可选
87
+ * @returns 查询结果对象
88
+ * @example
89
+ * // 简单查询
90
+ * const result = mysql.query("SELECT * FROM users")
91
+ *
92
+ * // 带参数查询
93
+ * const result = mysql.query("SELECT * FROM users WHERE id = ?", [1])
94
+ *
95
+ * // 处理结果
96
+ * if (result.success) {
97
+ * logger.info("查询到 " + result.rows.length + " 条记录")
98
+ * result.rows.forEach(row => {
99
+ * logger.info(row)
100
+ * })
101
+ * } else {
102
+ * console.error("查询失败: " + result.error)
103
+ * }
104
+ */
105
+ function query(sql: string, params?: any[]): MySQLResult;
106
+
107
+ /**
108
+ * 执行更新操作(INSERT、UPDATE、DELETE)
109
+ * @param sql SQL 语句
110
+ * @param params 参数数组,可选
111
+ * @returns 执行结果对象
112
+ * @example
113
+ * // 插入数据
114
+ * const result = mysql.execute(
115
+ * "INSERT INTO users (name, email) VALUES (?, ?)",
116
+ * ["张三", "zhangsan@example.com"]
117
+ * )
118
+ *
119
+ * // 更新数据
120
+ * const result = mysql.execute(
121
+ * "UPDATE users SET name = ? WHERE id = ?",
122
+ * ["李四", 1]
123
+ * )
124
+ *
125
+ * // 删除数据
126
+ * const result = mysql.execute("DELETE FROM users WHERE id = ?", [1])
127
+ *
128
+ * // 处理结果
129
+ * if (result.success) {
130
+ * logger.info("影响了 " + result.affectedRows + " 行")
131
+ * if (result.insertId) {
132
+ * logger.info("新插入记录的ID: " + result.insertId)
133
+ * }
134
+ * } else {
135
+ * console.error("执行失败: " + result.error)
136
+ * }
137
+ */
138
+ function execute(sql: string, params?: any[]): MySQLResult;
139
+
140
+ /**
141
+ * 开始事务
142
+ * @returns 是否成功开始事务
143
+ * @example
144
+ * if (mysql.beginTransaction()) {
145
+ * try {
146
+ * mysql.execute("INSERT INTO users (name) VALUES (?)", ["用户1"])
147
+ * mysql.execute("INSERT INTO users (name) VALUES (?)", ["用户2"])
148
+ * mysql.commit()
149
+ * logger.info("事务提交成功")
150
+ * } catch (error) {
151
+ * mysql.rollback()
152
+ * console.error("事务回滚")
153
+ * }
154
+ * }
155
+ */
156
+ function beginTransaction(): boolean;
157
+
158
+ /**
159
+ * 提交事务
160
+ * @returns 是否成功提交
161
+ * @example
162
+ * mysql.beginTransaction()
163
+ * mysql.execute("INSERT INTO users (name) VALUES (?)", ["测试用户"])
164
+ * if (mysql.commit()) {
165
+ * logger.info("事务提交成功")
166
+ * }
167
+ */
168
+ function commit(): boolean;
169
+
170
+ /**
171
+ * 回滚事务
172
+ * @returns 是否成功回滚
173
+ * @example
174
+ * mysql.beginTransaction()
175
+ * mysql.execute("INSERT INTO users (name) VALUES (?)", ["测试用户"])
176
+ * if (mysql.rollback()) {
177
+ * logger.info("事务回滚成功")
178
+ * }
179
+ */
180
+ function rollback(): boolean;
181
+ }
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * 飞桨OCR模块 包含OCR识别、OCR模型加载等功能
3
3
  */
4
- declare namespace paddleocr {
4
+ declare namespace paddleOcr {
5
5
  /**
6
6
  * 初始化PP-OCRv5模型
7
7
  * @param useGpu 是否使用GPU,默认false
8
8
  * @returns 初始化是否成功
9
9
  * @example
10
- * const loaded = paddleocr.loadV5(true)
10
+ * const loaded = paddleOcr.loadV5(true)
11
11
  * if (loaded) {
12
12
  * console.log("加载成功")
13
13
  * }
@@ -22,7 +22,7 @@ declare namespace paddleocr {
22
22
  * @param ey 边界框右下角y坐标
23
23
  * @returns 识别结果数组
24
24
  * @example
25
- * const results = paddleocr.recognize("screen", 0, 0, 100, 100)
25
+ * const results = paddleOcr.recognize("screen", 0, 0, 100, 100)
26
26
  * if (results.length > 0) {
27
27
  * console.log("识别到文本")
28
28
  * }
package/types/system.d.ts CHANGED
@@ -11,7 +11,7 @@ declare namespace system {
11
11
  * @example
12
12
  * const started = system.startApp("cn.magicnode.script, [], {})
13
13
  * if (started) {
14
- * console.log("启动成功")
14
+ * logger.info("启动成功")
15
15
  * }
16
16
  */
17
17
  function startApp(
@@ -26,7 +26,7 @@ declare namespace system {
26
26
  * @example
27
27
  * const stopped = system.stopApp("cn.magicnode.script")
28
28
  * if (stopped) {
29
- * console.log("关闭成功")
29
+ * logger.info("关闭成功")
30
30
  * }
31
31
  */
32
32
  function stopApp(bundleId: string): boolean;
@@ -37,7 +37,7 @@ declare namespace system {
37
37
  * @example
38
38
  * const activated = system.activateApp("cn.magicnode.script")
39
39
  * if (activated) {
40
- * console.log("激活成功")
40
+ * logger.info("激活成功")
41
41
  * }
42
42
  */
43
43
  function activateApp(bundleId: string): boolean;
@@ -47,7 +47,7 @@ declare namespace system {
47
47
  * @example
48
48
  * const info = system.activateAppInfo()
49
49
  * if (info) {
50
- * console.log(info.name)
50
+ * logger.info(info.name)
51
51
  * }
52
52
  */
53
53
  function activateAppInfo(): {
@@ -65,7 +65,7 @@ declare namespace system {
65
65
  * @example
66
66
  * const locked = system.isLocked()
67
67
  * if (locked) {
68
- * console.log("锁屏")
68
+ * logger.info("锁屏")
69
69
  * }
70
70
  */
71
71
  function isLocked(): boolean;
@@ -75,7 +75,7 @@ declare namespace system {
75
75
  * @example
76
76
  * const locked = system.lock()
77
77
  * if (locked) {
78
- * console.log("锁屏成功")
78
+ * logger.info("锁屏成功")
79
79
  * }
80
80
  */
81
81
  function lock(): boolean;
@@ -85,7 +85,7 @@ declare namespace system {
85
85
  * @example
86
86
  * const unlocked = system.unlock()
87
87
  * if (unlocked) {
88
- * console.log("解锁成功")
88
+ * logger.info("解锁成功")
89
89
  * }
90
90
  */
91
91
  function unlock(): boolean;
@@ -96,7 +96,7 @@ declare namespace system {
96
96
  * @example
97
97
  * const set = system.setClipboard("hello")
98
98
  * if (set) {
99
- * console.log("设置成功")
99
+ * logger.info("设置成功")
100
100
  * }
101
101
  */
102
102
  function setClipboard(text: string): boolean;
@@ -106,7 +106,7 @@ declare namespace system {
106
106
  * @example
107
107
  * const text = system.getClipboard()
108
108
  * if (text) {
109
- * console.log(text)
109
+ * logger.info(text)
110
110
  * }
111
111
  */
112
112
  function getClipboard(): string | null;
@@ -117,7 +117,7 @@ declare namespace system {
117
117
  * @example
118
118
  * const opened = system.openURL("https://www.baidu.com")
119
119
  * if (opened) {
120
- * console.log("打开成功")
120
+ * logger.info("打开成功")
121
121
  * }
122
122
  */
123
123
  function openURL(url: string): boolean;
@@ -135,7 +135,7 @@ declare namespace system {
135
135
  * @returns 内存使用信息,包含已使用内存、可用内存和总内存(单位:MB)
136
136
  * @example
137
137
  * const memInfo = system.getMemoryInfo()
138
- * console.log(`已使用: ${memInfo.used}MB, 可用: ${memInfo.available}MB, 总计: ${memInfo.total}MB`)
138
+ * logger.info(`已使用: ${memInfo.used}MB, 可用: ${memInfo.available}MB, 总计: ${memInfo.total}MB`)
139
139
  */
140
140
  function getMemoryInfo(): {
141
141
  used: number;
@@ -147,7 +147,7 @@ declare namespace system {
147
147
  * @returns 已使用内存大小(单位:MB)
148
148
  * @example
149
149
  * const usedMemory = system.getUsedMemory()
150
- * console.log(`已使用内存: ${usedMemory}MB`)
150
+ * logger.info(`已使用内存: ${usedMemory}MB`)
151
151
  */
152
152
  function getUsedMemory(): number;
153
153
  /**
@@ -155,7 +155,7 @@ declare namespace system {
155
155
  * @returns 可用内存大小(单位:MB)
156
156
  * @example
157
157
  * const availableMemory = system.getAvailableMemory()
158
- * console.log(`可用内存: ${availableMemory}MB`)
158
+ * logger.info(`可用内存: ${availableMemory}MB`)
159
159
  */
160
160
  function getAvailableMemory(): number;
161
161
  }
package/types/thread.d.ts CHANGED
@@ -10,7 +10,7 @@ declare namespace thread {
10
10
  * @returns 线程名称
11
11
  * @example
12
12
  * thread.execCodeAsync("thread.js", "callback", (data) => {
13
- * console.log(data)
13
+ * logger.info(data)
14
14
  * return "1111"
15
15
  * })
16
16
  *
@@ -19,7 +19,7 @@ declare namespace thread {
19
19
  * // 通知主线程并传递数据
20
20
  * const data = thread.invokeCallback("callback", "hello world")
21
21
  * // 主线程返回数据
22
- * console.log(data)
22
+ * logger.info(data)
23
23
  * sleep(1000)
24
24
  * }
25
25
  */
@@ -35,7 +35,7 @@ declare namespace thread {
35
35
  * @returns 回调返回值
36
36
  * @example
37
37
  * const data = thread.invokeCallback("callback", "hello world")
38
- * console.log(data)
38
+ * logger.info(data)
39
39
  */
40
40
  function invokeCallback(name: string, data?: any): any;
41
41
  /**
@@ -45,7 +45,7 @@ declare namespace thread {
45
45
  * @example
46
46
  * const newThread = thread.newThread("thread.js")
47
47
  * newThread.addCallback("callback", (data) => {
48
- * console.log(data)
48
+ * logger.info(data)
49
49
  * return "1111"
50
50
  * })
51
51
  */
@@ -72,7 +72,7 @@ declare namespace thread {
72
72
  * @example
73
73
  * const newThread = thread.newThread("thread.js")
74
74
  * newThread.addCallback("callback", (data) => {
75
- * console.log(data)
75
+ * logger.info(data)
76
76
  * return "1111"
77
77
  * })
78
78
  * thread.cancelThread(newThread.name)
@@ -85,7 +85,7 @@ declare namespace thread {
85
85
  * @example
86
86
  * const newThread = thread.newThread("thread.js")
87
87
  * newThread.addCallback("callback", (data) => {
88
- * console.log(data)
88
+ * logger.info(data)
89
89
  * return "1111"
90
90
  * })
91
91
  * thread.isCancelled(newThread.name)
@@ -0,0 +1,199 @@
1
+ /**
2
+ * TomatoOCR 模块
3
+ * 提供基于 TomatoOCR 框架的文字识别和 YOLO 目标检测功能
4
+ */
5
+ declare namespace tomatoOcr {
6
+ /**
7
+ * 初始化TomatoOCR并设置基本配置
8
+ * @param mode 运行模式 debug:调试模型;删除或传别的任何值为正式模式
9
+ * @param licenseData 许可证数据
10
+ * @param remark 备注信息(可选)
11
+ * @returns 设置结果
12
+ * @example
13
+ * ```typescript
14
+ * // 不带备注
15
+ * const result1 = tomatoOcr.initializeWithConfig("online", "your_license_data");
16
+ * // 带备注
17
+ * const result2 = tomatoOcr.initializeWithConfig("online", "your_license_data", "测试环境");
18
+ * logger.info(result1, result2);
19
+ * ```
20
+ */
21
+ function initializeWithConfig(
22
+ mode: string,
23
+ licenseData: string,
24
+ remark?: string
25
+ ): {
26
+ deviceId: string;
27
+ expiryTime: string;
28
+ message: string;
29
+ status: string;
30
+ versionName: string;
31
+ } | null;
32
+
33
+ /**
34
+ * 设置 HTTP 请求间隔时间
35
+ * @param second 间隔秒数 设置网络请求间隔时间,非必设置。0-86400
36
+ * @example
37
+ * ```typescript
38
+ * tomatoOcr.setHttpIntervalTime(3600);
39
+ * ```
40
+ */
41
+ function setHttpIntervalTime(second: number): void;
42
+
43
+ /**
44
+ * 设置识别类型
45
+ * @param recType 识别类型 模型类型,默认 ch-3.0,除此之外还有 ch-2.0, ch, cht, japan, korean, number
46
+ * @example
47
+ * ```typescript
48
+ * // 普通中英文识别,3.0版模型
49
+ * tomatoOcr.setRecType("ch-3.0");
50
+ * // 普通中英文识别,2.0版模型
51
+ * tomatoOcr.setRecType("ch-2.0");
52
+ * // 普通中英文识别,1.0版模型
53
+ * tomatoOcr.setRecType("ch");
54
+ * // 繁体
55
+ * tomatoOcr.setRecType("cht");
56
+ * // 日语
57
+ * tomatoOcr.setRecType("japan");
58
+ * // 韩语
59
+ * tomatoOcr.setRecType("korean");
60
+ * // 数字模型
61
+ * tomatoOcr.setRecType("number");
62
+ * ```
63
+ */
64
+ function setRecType(recType: string): void;
65
+
66
+ /**
67
+ * 设置检测框类型
68
+ * @param detBoxType 检测框类型 默认"rect": 由于手机上截图文本均为矩形文本;"quad":可准确检测倾斜文本
69
+ * @example
70
+ * ```typescript
71
+ * // 矩形文本
72
+ * tomatoOcr.setDetBoxType("rect");
73
+ * // 倾斜文本
74
+ * tomatoOcr.setDetBoxType("quad");
75
+ * ```
76
+ */
77
+ function setDetBoxType(detBoxType: string): void;
78
+
79
+ /**
80
+ * 设置检测框展开比例
81
+ * @param detUnclipRatio 设置检测模型框选文本范围大小的参数,非必设置,默认为1.9。值范围1.6-2.5之间,值越大框选范围越大,值越小框选范围越小;当框选到了,但识别得分较低,就可以调整该参数改善准确率。
82
+ * @example
83
+ * ```typescript
84
+ * tomatoOcr.setDetUnclipRatio(1.9);
85
+ * ```
86
+ */
87
+ function setDetUnclipRatio(detUnclipRatio: number): void;
88
+
89
+ /**
90
+ * 设置识别分数阈值
91
+ * @param recScoreThreshold 设置识别模型过滤得分的参数,非必设置,默认0.1。由于返回的识别结果数据太多太乱,可以通过设置该参数,过滤一些得分较低不准的数据,使得结果看起来更加简练。
92
+ * @example
93
+ * ```typescript
94
+ * tomatoOcr.setRecScoreThreshold(0.1);
95
+ * ```
96
+ */
97
+ function setRecScoreThreshold(recScoreThreshold: number): void;
98
+
99
+ /**
100
+ * 设置返回类型
101
+ * @param returnType 设置调用插件识别返回格式的参数,非必设置,默认为json。默认"json": 包含得分、坐标和文字;"text":纯文字;"num":纯数字;自定义输入想要返回的文本:".¥1234567890",仅只返回这些内容
102
+ * @example
103
+ * ```typescript
104
+ * tomatoOcr.setReturnType("json");
105
+ * ```
106
+ */
107
+ function setReturnType(returnType: string): void;
108
+
109
+ /**
110
+ * 设置二值化阈值
111
+ * @param binaryThresh 设置图像二值化的参数,非必设置,默认0,不进行二值化。 二值化设定0-255,常规情况下不需要设置,可配合中调试应用使用。
112
+ * @example
113
+ * ```typescript
114
+ * tomatoOcr.setBinaryThresh(0);
115
+ * ```
116
+ */
117
+ function setBinaryThresh(binaryThresh: number): void;
118
+
119
+ /**
120
+ * 设置运行模式
121
+ * @param runMode 运行模式
122
+ * @example
123
+ * ```typescript
124
+ * tomatoOcr.setRunMode("fast");
125
+ * ```
126
+ */
127
+ function setRunMode(runMode: string): void;
128
+
129
+ /**
130
+ * 设置图像滤色参数,非必设置,默认"",对图片中的文字进行颜色过滤,可以是单色也可以为多色,配合调试工具使用,如下图:
131
+ * @param filterColor 颜色过滤,通过逗号相互连,第一个是颜色值,第二个是负偏色,第三个是正偏色;不同颜色之间以"|"连接
132
+ * @param backgroundColor 滤色后的背景色,传""或black的时候,背景是黑色,传“white”的时候,背景是白色
133
+ * @example
134
+ * ```typescript
135
+ * tomatoOcr.setFilterColor("#41917A,38,38", "black");
136
+ * tomatoOcr.setFilterColor("#41917A,38,38|#E091A8,50,50", "white");
137
+ * ```
138
+ */
139
+ function setFilterColor(filterColor: string, backgroundColor: string): void;
140
+
141
+ /**
142
+ * 对图像执行 OCR 识别
143
+ * @param input 输入源(imageId、URL字符串、文件路径或"screen",null表示使用当前屏幕)
144
+ * @param type 识别类型 默认3: 检测 + 识别;0: 只检测;1: 方向分类+识别;2: 只识别;3: 检测+识别
145
+ * @param x 边界框左上角x坐标
146
+ * @param y 边界框左上角y坐标
147
+ * @param ex 边界框右下角x坐标
148
+ * @param ey 边界框右下角y坐标
149
+ * @returns OCR识别结果JSON字符串
150
+ * @example
151
+ * ```typescript
152
+ * // 识别屏幕
153
+ * const result1 = tomatoOcr.ocrImage(null, 0, 0, 0, 0, 0);
154
+ * logger.info(`识别屏幕结果:${result1}`);
155
+ *
156
+ * // 识别文件
157
+ * const result2 = tomatoOcr.ocrImage("/path/to/image.png", 0);
158
+ * logger.info(`识别文件结果:${result2}`);
159
+ *
160
+ * // 识别指定屏幕区域
161
+ * const result3 = tomatoOcr.ocrImage("screen", 0);
162
+ * logger.info(`识别指定屏幕区域结果:${result3}`);
163
+ * ```
164
+ */
165
+ function ocrImage(
166
+ input: string | null,
167
+ type: number,
168
+ x: number,
169
+ y: number,
170
+ ex: number,
171
+ ey: number
172
+ ): string;
173
+
174
+ /**
175
+ * 查找点击点
176
+ * @param data 要找的文字
177
+ * @returns 找“要找的文字”的中心点 没有找到返回空字符串
178
+ * @example
179
+ * ```typescript
180
+ * const result = tomatoOcr.findTapPoint('{"text": "确定"}');
181
+ * const tapPoint = JSON.parse(result);
182
+ * logger.info(tapPoint);
183
+ * ```
184
+ */
185
+ function findTapPoint(data: string): string;
186
+
187
+ /**
188
+ * 查找多个点击点
189
+ * @param data 要找的文字
190
+ * @returns 找“要找的文字”的所有相匹配的中心点 没有找到返回空字符串
191
+ * @example
192
+ * ```typescript
193
+ * const result = tomatoOcr.findTapPoints('{"texts": ["确定", "取消"]}');
194
+ * const tapPoints = JSON.parse(result);
195
+ * logger.info(tapPoints);
196
+ * ```
197
+ */
198
+ function findTapPoints(data: string): string;
199
+ }
package/types/ui.d.ts CHANGED
@@ -3,14 +3,17 @@
3
3
  * @param name 函数名称
4
4
  * @param func 函数
5
5
  */
6
- declare function registerUIFunc(name: string, func: (data: any) => void): void;
6
+ declare function registerUIFunc(
7
+ name: string,
8
+ func: (data: Record<string, any>) => void
9
+ ): void;
7
10
 
8
11
  /**
9
12
  * 发送事件 网页页面使用 给主进程发送事件
10
13
  * @param event 事件名称
11
14
  * @param data 事件参数
12
15
  */
13
- declare function emitEvent(event: string, data: any): void;
16
+ declare function emitEvent(event: string, data: Record<string, any>): void;
14
17
 
15
18
  /**
16
19
  * UI模块 包含加载html文件、调用js方法等功能
@@ -34,9 +37,11 @@ declare namespace ui {
34
37
  * @param key 方法名
35
38
  * @param data 方法参数
36
39
  * @example
37
- * webview.call("jsMethod", "hello world")
40
+ * webview.call("jsMethod", {
41
+ * name: "magicscript",
42
+ * })
38
43
  */
39
- call(key: string, data: any): void;
44
+ call(key: string, data: Record<string, any>): void;
40
45
  }
41
46
  /**
42
47
  * 创建WebView
@@ -47,21 +52,23 @@ declare namespace ui {
47
52
  * const webview = ui.newWebView("index.html", (event, data) => {
48
53
  * // 接收网页发送的事件
49
54
  * if(event === "page.loaded") {
50
- * console.log("页面加载完成")
55
+ * logger.info("页面加载完成")
51
56
  * } else if(event === "page.close") {
52
- * console.log("页面关闭")
57
+ * logger.info("页面关闭")
53
58
  * } else if(event === "console.log") {
54
- * console.log("网页调用console.log", data)
59
+ * logger.info("网页调用console.log:" + data)
55
60
  * } else {
56
61
  * // 自定义事件
57
- * console.log(event, data)
62
+ * logger.info(event, data)
58
63
  * }
59
64
  * })
60
65
  * webview.show()
61
- * webview.call("jsMethod", "hello world")
66
+ * webview.call("jsMethod", {
67
+ * name: "magicscript",
68
+ * })
62
69
  */
63
70
  function newWebView(
64
71
  file: string,
65
- onEvent: (event: string, data: any) => void
72
+ onEvent: (event: string, data: string | Record<string, any>) => void
66
73
  ): WebView;
67
74
  }