@bettergi/utils 0.0.7 → 0.0.8

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/README.md CHANGED
@@ -142,10 +142,12 @@ try {
142
142
  > 对网络请求的简易封装。
143
143
 
144
144
  ```ts
145
- import { getForBody } from "@bettergi/utils";
145
+ import { getForBody, postForBody } from "@bettergi/utils";
146
146
 
147
147
  // 发送 GET 请求获取响应体内容
148
148
  // 提示:需要在 `manifest.json` 文件中配置 `http_allowed_urls`,并在 调度器 -> 修改通用配置 中启用
149
- const body = await getForBody("https://example.com/", undefined, { "User-Agent": "BetterGI" });
150
- log.info(`响应体内容${body}`);
149
+ const body1 = await getForBody("https://example.com/", null, { "User-Agent": "BetterGI" });
150
+ const body2 = await postForBody("https://example.com/", null, { "User-Agent": "BetterGI" });
151
+ log.info(`GET 请求响应体内容${body1}`);
152
+ log.info(`POST 请求响应体内容${body2}`);
151
153
  ```
package/dist/game.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import "@bettergi/types/csharp/BetterGenshinImpact/GameTask/Model/Area/Region";
1
2
  /**
2
3
  * 打开派蒙菜单
3
4
  */
package/dist/game.js CHANGED
@@ -1,3 +1,4 @@
1
+ import "@bettergi/types/csharp/BetterGenshinImpact/GameTask/Model/Area/Region";
1
2
  import { waitUntil } from "./flow";
2
3
  import { mouseSlide } from "./mouse";
3
4
  import { findTextInDirection, findTextWithinBounds, findTextWithinListView } from "./ocr";
package/dist/http.d.ts CHANGED
@@ -22,8 +22,4 @@ export declare const getForBody: (url: string, body?: string, headers?: Record<s
22
22
  * @param headers 请求头
23
23
  * @returns 响应体内容
24
24
  */
25
- export declare const postForBody: (url: string, body?: string, headers?: Record<string, any>) => Promise<{
26
- status_code: number;
27
- headers: Record<string, string>;
28
- body: string;
29
- }>;
25
+ export declare const postForBody: (url: string, body?: string, headers?: Record<string, any>) => Promise<string>;
package/dist/http.js CHANGED
@@ -33,5 +33,5 @@ export const getForBody = async (url, body, headers) => {
33
33
  * @returns 响应体内容
34
34
  */
35
35
  export const postForBody = (url, body, headers) => {
36
- return http.request("POST", url, body, headers ? JSON.stringify(headers) : undefined);
36
+ return requestForBody("POST", url, body, headers);
37
37
  };
package/dist/ocr.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { type Region } from "@bettergi/types/csharp/BetterGenshinImpact/GameTask/Model/Area/Region";
1
+ import "@bettergi/types/csharp/BetterGenshinImpact/GameTask/Model/Area/ImageRegion";
2
+ import "@bettergi/types/csharp/BetterGenshinImpact/GameTask/Model/Area/Region";
2
3
  type Direction = "north" | "north-east" | "east" | "south-east" | "south" | "south-west" | "west" | "north-west";
3
4
  /**
4
5
  * 在整个画面内搜索图片
5
6
  * @param path 图片路径
6
7
  * @returns 如果找到匹配的图片区域,则返回该区域,否则返回 undefined
7
8
  */
8
- export declare const findImage: (path: string) => Region | undefined;
9
+ export declare const findImage: (path: string) => globalThis.Region | undefined;
9
10
  /**
10
11
  * 在指定区域内搜索图片
11
12
  * @param path 图片路径
@@ -15,14 +16,14 @@ export declare const findImage: (path: string) => Region | undefined;
15
16
  * @param h 高度
16
17
  * @returns 如果找到匹配的图片区域,则返回该区域,否则返回 undefined
17
18
  */
18
- export declare const findImageWithinBounds: (path: string, x: number, y: number, w: number, h: number) => Region | undefined;
19
+ export declare const findImageWithinBounds: (path: string, x: number, y: number, w: number, h: number) => globalThis.Region | undefined;
19
20
  /**
20
21
  * 在指定方向上搜索图片
21
22
  * @param path 图片路径
22
23
  * @param direction 搜索方向
23
24
  * @returns 如果找到匹配的图片区域,则返回该区域,否则返回 undefined
24
25
  */
25
- export declare const findImageInDirection: (path: string, direction: Direction) => Region | undefined;
26
+ export declare const findImageInDirection: (path: string, direction: Direction) => globalThis.Region | undefined;
26
27
  /**
27
28
  * 在整个画面内搜索文本
28
29
  * @param text 待搜索文本
@@ -30,7 +31,7 @@ export declare const findImageInDirection: (path: string, direction: Direction)
30
31
  * @param ignoreCase 是否忽略大小写
31
32
  * @returns 如果找到匹配的文本区域,则返回该区域,否则返回 undefined
32
33
  */
33
- export declare const findText: (text: string, contains: boolean, ignoreCase: boolean) => Region | undefined;
34
+ export declare const findText: (text: string, contains: boolean, ignoreCase: boolean) => globalThis.Region | undefined;
34
35
  /**
35
36
  * 在指定区域内搜索文本
36
37
  * @param text 待搜索文本
@@ -43,7 +44,7 @@ export declare const findText: (text: string, contains: boolean, ignoreCase: boo
43
44
  * @param h 高度
44
45
  * @returns 如果找到匹配的文本区域,则返回该区域,否则返回 undefined
45
46
  */
46
- export declare const findTextWithinBounds: (text: string, contains: boolean, ignoreCase: boolean, x: number, y: number, w: number, h: number) => Region | undefined;
47
+ export declare const findTextWithinBounds: (text: string, contains: boolean, ignoreCase: boolean, x: number, y: number, w: number, h: number) => globalThis.Region | undefined;
47
48
  /**
48
49
  * 在指定方向上搜索文本
49
50
  * @param text 待搜索文本
@@ -52,7 +53,7 @@ export declare const findTextWithinBounds: (text: string, contains: boolean, ign
52
53
  * @param direction 搜索方向
53
54
  * @returns 如果找到匹配的文本区域,则返回该区域,否则返回 undefined
54
55
  */
55
- export declare const findTextInDirection: (text: string, contains: boolean, ignoreCase: boolean, direction: Direction) => Region | undefined;
56
+ export declare const findTextInDirection: (text: string, contains: boolean, ignoreCase: boolean, direction: Direction) => globalThis.Region | undefined;
56
57
  /**
57
58
  * 在列表视图中滚动搜索文本
58
59
  * @param text 待搜索文本
@@ -70,5 +71,5 @@ export declare const findTextWithinListView: (text: string, contains: boolean, i
70
71
  maxListItems: number;
71
72
  lineHeight: number;
72
73
  padding?: number;
73
- }, timeout?: number) => Promise<Region | undefined>;
74
+ }, timeout?: number) => Promise<globalThis.Region | undefined>;
74
75
  export {};
package/dist/ocr.js CHANGED
@@ -1,3 +1,5 @@
1
+ import "@bettergi/types/csharp/BetterGenshinImpact/GameTask/Model/Area/ImageRegion";
2
+ import "@bettergi/types/csharp/BetterGenshinImpact/GameTask/Model/Area/Region";
1
3
  import { waitUntil } from "./flow";
2
4
  import { mouseScrollDownLines } from "./mouse";
3
5
  const findFirst = (ir, ro, predicate) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bettergi/utils",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Utils for BetterGI JavaScript Development",
5
5
  "type": "module",
6
6
  "author": "Bread Grocery<https://github.com/breadgrocery>",
@@ -33,7 +33,7 @@
33
33
  "build": "tsc"
34
34
  },
35
35
  "devDependencies": {
36
- "@bettergi/types": "^0.0.11",
36
+ "@bettergi/types": "^0.0.12",
37
37
  "typescript": "5.6.3"
38
38
  }
39
39
  }