@bettergi/utils 0.1.24 → 0.1.25
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/misc.d.ts +5 -0
- package/dist/misc.js +7 -0
- package/dist/ocr.js +9 -8
- package/package.json +9 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Bread Grocery
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
package/dist/misc.d.ts
CHANGED
|
@@ -15,3 +15,8 @@ export declare const shuffleArray: <T>(array: T[]) => T[];
|
|
|
15
15
|
* @returns 合并后的对象副本
|
|
16
16
|
*/
|
|
17
17
|
export declare const deepMerge: (...objects: any[]) => any;
|
|
18
|
+
/**
|
|
19
|
+
* 同步休眠执行指定时长
|
|
20
|
+
* @param duration - 休眠时长(毫秒)
|
|
21
|
+
*/
|
|
22
|
+
export declare const sleepSync: (duration: number) => void;
|
package/dist/misc.js
CHANGED
|
@@ -39,3 +39,10 @@ export const deepMerge = (...objects) => {
|
|
|
39
39
|
}, result);
|
|
40
40
|
}, {});
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* 同步休眠执行指定时长
|
|
44
|
+
* @param duration - 休眠时长(毫秒)
|
|
45
|
+
*/
|
|
46
|
+
export const sleepSync = (duration) => {
|
|
47
|
+
duration > 0 && Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, duration);
|
|
48
|
+
};
|
package/dist/ocr.js
CHANGED
|
@@ -235,18 +235,19 @@ export const findWithinListView = async (condition, listView, retryOptions, samp
|
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
237
|
})();
|
|
238
|
-
|
|
238
|
+
let targetRegion;
|
|
239
|
+
await waitForAction(() => {
|
|
240
|
+
targetRegion = condition(captureListViewRegion());
|
|
241
|
+
return targetRegion?.isExist() || isReachedBottom();
|
|
242
|
+
}, async () => {
|
|
239
243
|
moveMouseTo(x + w - paddingX, y + paddingY); // 移动到滚动条附近
|
|
240
244
|
await sleep(50);
|
|
241
245
|
await mouseScrollDownLines(scrollLines, lineHeight); // 滚动指定行数
|
|
242
246
|
}, { maxAttempts, retryInterval });
|
|
243
|
-
if (
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
Object.assign(targetRegion, { x: item1, y: item2 });
|
|
248
|
-
return targetRegion;
|
|
249
|
-
}
|
|
247
|
+
if (targetRegion?.isExist()) {
|
|
248
|
+
const { item1, item2 } = targetRegion.convertPositionToGameCaptureRegion(0, 0);
|
|
249
|
+
Object.assign(targetRegion, { x: item1, y: item2 });
|
|
250
|
+
return targetRegion;
|
|
250
251
|
}
|
|
251
252
|
};
|
|
252
253
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bettergi/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"description": "开发 BetterGI 脚本常用工具集",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Bread Grocery<https://github.com/breadgrocery>",
|
|
@@ -28,13 +28,16 @@
|
|
|
28
28
|
"bettergi",
|
|
29
29
|
"utils"
|
|
30
30
|
],
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"build": "rimraf dist && tsc"
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@bettergi/types": "^0.1.7"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
|
-
"@bettergi/types": "workspace:^",
|
|
37
35
|
"rimraf": "^6.1.2",
|
|
38
36
|
"typescript": "^5.9.3"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"dev": "tsc --watch",
|
|
40
|
+
"build": "rimraf dist && tsc",
|
|
41
|
+
"release": "pnpm build && pnpm publish --access public"
|
|
39
42
|
}
|
|
40
|
-
}
|
|
43
|
+
}
|