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 +3 -3
- package/types/dotocr.d.ts +62 -0
- package/types/file.d.ts +137 -133
- package/types/global.d.ts +4 -0
- package/types/index.d.ts +2 -0
- package/types/node.d.ts +1 -1
- package/types/opencv.d.ts +823 -0
- package/types/pip.d.ts +8 -2
- package/types/thread.d.ts +3 -2
- package/types/zh/index.d.ts +1 -0
- package/types/zh//345/205/250/345/261/200/346/250/241/345/235/227.d.ts +4 -0
- package/types/zh//346/202/254/346/265/256/347/252/227/346/250/241/345/235/227.d.ts +3 -2
- package/types/zh//346/226/207/344/273/266/346/250/241/345/235/227.d.ts +138 -134
- package/types/zh//347/202/271/351/230/265OCR/346/250/241/345/235/227.d.ts +64 -0
- package/types/zh//347/272/277/347/250/213/346/250/241/345/235/227.d.ts +3 -2
- package/types/zh//350/212/202/347/202/271/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.9.
|
|
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.
|
|
21
|
-
"wrangler": "^4.
|
|
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
|
-
* @
|
|
17
|
-
* @
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
* @
|
|
24
|
-
* @
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
* @
|
|
38
|
-
* @
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
* @
|
|
45
|
-
* @
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*
|
|
52
|
-
* @
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
*
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
*
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
*
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
*
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
*
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
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" />
|