ms-types 0.9.18 → 0.9.20

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.18",
3
+ "version": "0.9.20",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "vitepress": "^1.6.4",
20
- "vitepress-theme-teek": "^1.6.0",
21
- "wrangler": "^4.100.0"
20
+ "vitepress-theme-teek": "^1.6.2",
21
+ "wrangler": "^4.118.0"
22
22
  }
23
23
  }
@@ -0,0 +1,62 @@
1
+ /** 固定像素尺寸的点阵 OCR(`kuaijs-dot-font` 字库)。 */
2
+ declare namespace dotOcr {
3
+ interface OCRChar {
4
+ text: string;
5
+ confidence: number;
6
+ x: number;
7
+ y: number;
8
+ ex: number;
9
+ ey: number;
10
+ width: number;
11
+ height: number;
12
+ centerX: number;
13
+ centerY: number;
14
+ }
15
+
16
+ /**
17
+ * 从资源路径加载字库并缓存。
18
+ * 常见路径如 `/fonts/default.json`;运行时会解析 `res` 目录。
19
+ * 字库 JSON 中每个字符自带前景色/偏色(`threshold`),识别时按各字颜色匹配。
20
+ * @returns 成功返回字库 ID,失败返回 `null`
21
+ */
22
+ function loadFont(fontPath: string): string | null;
23
+
24
+ /** 释放指定字库。未加载也视为成功。 */
25
+ function free(fontId: string): void;
26
+
27
+ /** 释放全部已加载的点阵字库。 */
28
+ function freeAll(): void;
29
+
30
+ /**
31
+ * 识别文字并返回原图或全屏绝对坐标。
32
+ * 颜色按字库逐字自带的前景色/偏色匹配,无需额外传色。
33
+ * 结果按行从上到下、同行从左到右排列。
34
+ * @param confidenceThreshold 相似度下限;`<=0` 时按 `0.8`;`>0.95` 时要求像素完全一致
35
+ */
36
+ function recognizeAbs(
37
+ fontId: string,
38
+ input: string,
39
+ x?: number,
40
+ y?: number,
41
+ ex?: number,
42
+ ey?: number,
43
+ confidenceThreshold?: number,
44
+ ): OCRChar[];
45
+
46
+ /**
47
+ * 先识别再按行查找目标串,返回命中位置的绝对坐标。
48
+ * `exactMatch=false`:行内子串包含;`exactMatch=true`:整行文本必须完全等于目标。
49
+ * 每个目标最多返回一次命中(最先匹配到的行)。
50
+ */
51
+ function findTextAbs(
52
+ fontId: string,
53
+ input: string,
54
+ targetTexts: string[],
55
+ x?: number,
56
+ y?: number,
57
+ ex?: number,
58
+ ey?: number,
59
+ confidenceThreshold?: number,
60
+ exactMatch?: boolean,
61
+ ): OCRChar[];
62
+ }
package/types/file.d.ts CHANGED
@@ -1,133 +1,137 @@
1
- /**
2
- * 文件模块 包含文件操作、文件内容读写等功能
3
- */
4
- declare namespace file {
5
- /**
6
- * 获取应用内部目录
7
- * @param type 目录类型
8
- * @returns 目录路径
9
- * @example file.getInternalDir("documents")
10
- */
11
- function getInternalDir(
12
- type: "documents" | "library" | "temp" | "libraryCaches"
13
- ): string;
14
- /**
15
- * 获取应用数据目录
16
- * @returns 目录路径
17
- * @example file.getDataDir()
18
- */
19
- function getDataDir(): string;
20
- /**
21
- * 获取应用数据文件路径
22
- * @param file 文件名
23
- * @returns 文件路径
24
- * @example file.getDataFile("config.json")
25
- */
26
- function getDataFile(file: string): string;
27
- /**
28
- * 创建文件
29
- * @param path 文件路径
30
- * @returns 是否创建成功
31
- * @example file.create("config.json")
32
- */
33
- function create(path: string): boolean;
34
- /**
35
- * 创建目录
36
- * @param path 目录路径
37
- * @returns 是否创建成功
38
- * @example file.mkdirs("config")
39
- */
40
- function mkdirs(path: string): boolean;
41
- /**
42
- * 删除文件或目录
43
- * @param path 文件或目录路径
44
- * @returns 是否删除成功
45
- * @example file.deleteAllFile("config")
46
- */
47
- function deleteAllFile(path: string): boolean;
48
- /**
49
- * 读取文件内容
50
- * @param path 文件路径
51
- * @returns 文件内容,如果读取失败返回 null
52
- * @example file.readFile("config.json")
53
- */
54
- function readFile(path: string): string | null;
55
- /**
56
- * 读取资源文件
57
- * @param fileName 文件名
58
- * @returns 文件内容
59
- * @example
60
- * file.readResFile("test.txt")
61
- */
62
- function readResFile(fileName: string): string | null;
63
- /**
64
- * 删除文件内容
65
- * @param path 文件路径
66
- * @param line 行号 如果是-1 代表这个条件不生效
67
- * @param contains 包含内容 如果是null 代表这个条件不生效
68
- * @returns 是否删除成功
69
- * @example file.deleteLine("config.json", 1, null)
70
- */
71
- function deleteLine(path: string, line: number, contains?: string): boolean;
72
- /**
73
- * 列出目录下所有文件
74
- * @param path 目录路径
75
- * @param recursion 是否递归
76
- * @returns 文件路径数组
77
- * @example file.listDir("config", true)
78
- */
79
- function listDir(path: string, recursion: boolean): string[];
80
- /**
81
- * 写入文件内容
82
- * @param path 文件路径
83
- * @param content 文件内容
84
- * @returns 是否写入成功
85
- * @example file.writeFile("config.json", "name=agent")
86
- */
87
- function writeFile(path: string, content: string): boolean;
88
- /**
89
- * 追加文件内容
90
- * @param path 文件路径
91
- * @param content 文件内容
92
- * @returns 是否追加成功
93
- * @example file.appendLine("config.json", "name=agent")
94
- */
95
- function appendLine(path: string, content: string): boolean;
96
- /**
97
- * 读取文件第N行内容
98
- * @param path 文件路径
99
- * @param lineNo 行号
100
- * @returns 行内容,如果读取失败返回 null
101
- * @example file.readLine("config.json", 1)
102
- */
103
- function readLine(path: string, lineNo: number): string | null;
104
- /**
105
- * 读取文件所有行内容
106
- * @param path 文件路径
107
- * @returns 行内容数组,如果读取失败返回 null
108
- * @example file.readAllLines("config.json")
109
- */
110
- function readAllLines(path: string): string[] | null;
111
- /**
112
- * 文件或者文件夹是否存在
113
- * @param path 文件路径
114
- * @returns 是否存在
115
- * @example file.exists("config.json")
116
- */
117
- function exists(path: string): boolean;
118
- /**
119
- * 复制文件
120
- * @param src 源文件路径
121
- * @param dest 目标文件路径
122
- * @returns 是否复制成功
123
- * @example file.copy("config.json", "config2.json")
124
- */
125
- function copy(src: string, dest: string): boolean;
126
- /**
127
- * 获取文件MD5值
128
- * @param path 文件路径
129
- * @returns 文件MD5值
130
- * @example file.fileMD5("config.json")
131
- */
132
- function fileMD5(path: string): string | null;
133
- }
1
+ /**
2
+ * 文件模块 包含文件操作、文件内容读写等功能
3
+ */
4
+ declare namespace file {
5
+ /**
6
+ * 获取应用内部目录
7
+ * @param type 目录类型
8
+ * @returns 目录路径
9
+ * @example file.getInternalDir("documents")
10
+ */
11
+ function getInternalDir(
12
+ type: "documents" | "library" | "temp" | "libraryCaches"
13
+ ): string;
14
+ /**
15
+ * 创建文件
16
+ * @param path 文件路径
17
+ * @returns 是否创建成功
18
+ * @example file.create("config.json")
19
+ */
20
+ function create(path: string): boolean;
21
+ /**
22
+ * 创建目录
23
+ * @param path 目录路径
24
+ * @returns 是否创建成功
25
+ * @example file.mkdirs("config")
26
+ */
27
+ function mkdirs(path: string): boolean;
28
+ /**
29
+ * 删除文件或目录
30
+ * @param path 文件或目录路径
31
+ * @returns 是否删除成功
32
+ * @example file.deleteAllFile("config")
33
+ */
34
+ function deleteAllFile(path: string): boolean;
35
+ /**
36
+ * 读取文件内容
37
+ * @param path 文件路径
38
+ * @returns 文件内容,如果读取失败返回 null
39
+ * @example file.readFile("config.json")
40
+ */
41
+ function readFile(path: string): string | null;
42
+ /**
43
+ * 读取资源文件
44
+ * @param fileName 文件名
45
+ * @returns 文件内容
46
+ * @example
47
+ * file.readResFile("test.txt")
48
+ */
49
+ function readResFile(fileName: string): string | null;
50
+ /**
51
+ * 获取 res 资源的本地文件路径
52
+ * @param fileName 相对 res 目录的资源路径
53
+ * @returns 本地文件绝对路径,失败返回 null
54
+ * @example
55
+ * const path = file.getResFile("model.bin");
56
+ * if (path) {
57
+ * file.cleanupResFile(path);
58
+ * }
59
+ */
60
+ function getResFile(fileName: string): string | null;
61
+ /**
62
+ * 清理由 getResFile 得到的本地文件
63
+ * @param path getResFile 返回的文件路径
64
+ * @example file.cleanupResFile(path)
65
+ */
66
+ function cleanupResFile(path: string): void;
67
+ /**
68
+ * 删除文件内容
69
+ * @param path 文件路径
70
+ * @param line 行号 如果是-1 代表这个条件不生效
71
+ * @param contains 包含内容 如果是null 代表这个条件不生效
72
+ * @returns 是否删除成功
73
+ * @example file.deleteLine("config.json", 1, null)
74
+ */
75
+ function deleteLine(path: string, line: number, contains?: string): boolean;
76
+ /**
77
+ * 列出目录下所有文件
78
+ * @param path 目录路径
79
+ * @param recursion 是否递归
80
+ * @returns 文件路径数组
81
+ * @example file.listDir("config", true)
82
+ */
83
+ function listDir(path: string, recursion: boolean): string[];
84
+ /**
85
+ * 写入文件内容
86
+ * @param path 文件路径
87
+ * @param content 文件内容
88
+ * @returns 是否写入成功
89
+ * @example file.writeFile("config.json", "name=agent")
90
+ */
91
+ function writeFile(path: string, content: string): boolean;
92
+ /**
93
+ * 追加文件内容
94
+ * @param path 文件路径
95
+ * @param content 文件内容
96
+ * @returns 是否追加成功
97
+ * @example file.appendLine("config.json", "name=agent")
98
+ */
99
+ function appendLine(path: string, content: string): boolean;
100
+ /**
101
+ * 读取文件第N行内容
102
+ * @param path 文件路径
103
+ * @param lineNo 行号
104
+ * @returns 行内容,如果读取失败返回 null
105
+ * @example file.readLine("config.json", 1)
106
+ */
107
+ function readLine(path: string, lineNo: number): string | null;
108
+ /**
109
+ * 读取文件所有行内容
110
+ * @param path 文件路径
111
+ * @returns 行内容数组,如果读取失败返回 null
112
+ * @example file.readAllLines("config.json")
113
+ */
114
+ function readAllLines(path: string): string[] | null;
115
+ /**
116
+ * 文件或者文件夹是否存在
117
+ * @param path 文件路径
118
+ * @returns 是否存在
119
+ * @example file.exists("config.json")
120
+ */
121
+ function exists(path: string): boolean;
122
+ /**
123
+ * 复制文件
124
+ * @param src 源文件路径
125
+ * @param dest 目标文件路径
126
+ * @returns 是否复制成功
127
+ * @example file.copy("config.json", "config2.json")
128
+ */
129
+ function copy(src: string, dest: string): boolean;
130
+ /**
131
+ * 获取文件MD5值
132
+ * @param path 文件路径
133
+ * @returns 文件MD5值
134
+ * @example file.fileMD5("config.json")
135
+ */
136
+ function fileMD5(path: string): string | null;
137
+ }
package/types/global.d.ts CHANGED
@@ -35,6 +35,10 @@ declare const __bundleId__: string;
35
35
  * 当前线程名称
36
36
  */
37
37
  declare const __threadName__: string;
38
+ /**
39
+ * 子线程启动参数;仅在线程脚本中可用,未传参数时为空对象
40
+ */
41
+ declare const __threadParams__: Record<string, any>;
38
42
  /**
39
43
  * 脚本信息
40
44
  */
package/types/index.d.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  /// <reference path="config.d.ts" />
5
5
  /// <reference path="cryptoUtils.d.ts" />
6
6
  /// <reference path="device.d.ts" />
7
+ /// <reference path="dotocr.d.ts" />
7
8
  /// <reference path="file.d.ts" />
8
9
  /// <reference path="global.d.ts" />
9
10
  /// <reference path="hid.d.ts" />
@@ -16,6 +17,7 @@
16
17
  /// <reference path="mysql.d.ts" />
17
18
  /// <reference path="netCard.d.ts" />
18
19
  /// <reference path="node.d.ts" />
20
+ /// <reference path="opencv.d.ts" />
19
21
  /// <reference path="paddleocr.d.ts" />
20
22
  /// <reference path="pip.d.ts" />
21
23
  /// <reference path="system.d.ts" />
package/types/node.d.ts CHANGED
@@ -7,7 +7,7 @@ declare function createNodeSelector(params?: {
7
7
  */
8
8
  maxDepth?: number;
9
9
  /**
10
- * 抓取模式:模式 1、模式 2,默认模式 1
10
+ * 抓取模式:模式 1、模式 2、模式 3,默认模式 1
11
11
  */
12
12
  mode?: number;
13
13
  }): NodeSelector;