@bettergi/utils 0.1.16 → 0.1.17
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/dist/ocr.js +12 -10
- package/package.json +2 -2
package/dist/ocr.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { mouseScrollDownLines } from "./mouse";
|
|
2
2
|
import { waitForAction } from "./workflow";
|
|
3
|
-
const findFirst = (ir, ro, predicate) => {
|
|
4
|
-
const candidates = ir.findMulti(ro);
|
|
5
|
-
for (let i = 0; i < candidates.count; i++) {
|
|
6
|
-
if (predicate(candidates[i]))
|
|
7
|
-
return candidates[i];
|
|
8
|
-
}
|
|
9
|
-
return undefined;
|
|
10
|
-
};
|
|
11
3
|
const directionToBounds = (direction) => {
|
|
12
4
|
const x = direction.includes("east") ? genshin.width / 2 : 0;
|
|
13
5
|
const y = direction.includes("south") ? genshin.height / 2 : 0;
|
|
@@ -35,7 +27,8 @@ export const findImage = (image, config = {}) => {
|
|
|
35
27
|
if (Object.keys(config).length > 0) {
|
|
36
28
|
Object.assign(ro, config) && ro.initTemplate();
|
|
37
29
|
}
|
|
38
|
-
|
|
30
|
+
const region = ir.find(ro);
|
|
31
|
+
return region.isExist() ? region : undefined;
|
|
39
32
|
}
|
|
40
33
|
catch (err) {
|
|
41
34
|
log.warn(`${err.message || err}`);
|
|
@@ -62,7 +55,8 @@ export const findImageWithinBounds = (image, x, y, w, h, config = {}) => {
|
|
|
62
55
|
if (Object.keys(config).length > 0) {
|
|
63
56
|
Object.assign(ro, config) && ro.initTemplate();
|
|
64
57
|
}
|
|
65
|
-
|
|
58
|
+
const region = ir.find(ro);
|
|
59
|
+
return region.isExist() ? region : undefined;
|
|
66
60
|
}
|
|
67
61
|
catch (err) {
|
|
68
62
|
log.warn(`${err.message || err}`);
|
|
@@ -95,6 +89,14 @@ export const findImageInDirection = (image, direction, config = {}) => {
|
|
|
95
89
|
const { x, y, w, h } = directionToBounds(direction);
|
|
96
90
|
return findImageWithinBounds(image, x, y, w, h, config);
|
|
97
91
|
};
|
|
92
|
+
const findFirst = (ir, ro, predicate) => {
|
|
93
|
+
const candidates = ir.findMulti(ro);
|
|
94
|
+
for (let i = 0; i < candidates.count; i++) {
|
|
95
|
+
if (predicate(candidates[i]))
|
|
96
|
+
return candidates[i];
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
};
|
|
98
100
|
/**
|
|
99
101
|
* 在整个画面内搜索文本
|
|
100
102
|
* @param text 待搜索文本
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bettergi/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "开发 BetterGI 脚本常用工具集",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Bread Grocery<https://github.com/breadgrocery>",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"build": "rimraf dist && tsc"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@bettergi/types": "
|
|
36
|
+
"@bettergi/types": "workspace:latest",
|
|
37
37
|
"rimraf": "^6.1.0",
|
|
38
38
|
"typescript": "^5.9.3"
|
|
39
39
|
}
|