@bettergi/types 0.1.14 → 0.1.16

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.
Files changed (37) hide show
  1. package/bindings/RealtimeTimer.d.ts +1 -1
  2. package/bindings/getAvatars.d.ts +3 -2
  3. package/bindings/htmlMask.d.ts +5 -0
  4. package/bindings/htmlMask.webview.d.ts +92 -0
  5. package/package.json +7 -1
  6. package/types/BetterGenshinImpact/Core/BgiVision/BvLocator.d.ts +16 -21
  7. package/types/BetterGenshinImpact/Core/Script/Dependence/Dispatcher.d.ts +4 -3
  8. package/types/BetterGenshinImpact/Core/Script/Dependence/Genshin.d.ts +20 -9
  9. package/types/BetterGenshinImpact/Core/Script/Dependence/Http.d.ts +1 -0
  10. package/types/BetterGenshinImpact/Core/Script/Dependence/KeyMouseHook.d.ts +11 -7
  11. package/types/BetterGenshinImpact/Core/Script/Dependence/LimitedFile.d.ts +12 -5
  12. package/types/BetterGenshinImpact/Core/Script/Dependence/Model/RealtimeTimer.d.ts +63 -8
  13. package/types/BetterGenshinImpact/Core/Script/Dependence/Model/SoloTask.d.ts +93 -21
  14. package/types/BetterGenshinImpact/GameTask/AutoBoss/AutoBossConfig.d.ts +62 -3
  15. package/types/BetterGenshinImpact/GameTask/AutoBoss/AutoBossParam.d.ts +6 -4
  16. package/types/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainParam.d.ts +11 -9
  17. package/types/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.d.ts +61 -0
  18. package/types/BetterGenshinImpact/GameTask/AutoFight/AutoFightConfig.d.ts +28 -2
  19. package/types/BetterGenshinImpact/GameTask/AutoFight/AutoFightParam.d.ts +13 -6
  20. package/types/BetterGenshinImpact/GameTask/AutoFight/Config/CombatAvatar.d.ts +153 -5
  21. package/types/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.d.ts +137 -7
  22. package/types/BetterGenshinImpact/GameTask/AutoFight/Model/CombatScenes.d.ts +13 -13
  23. package/types/BetterGenshinImpact/GameTask/AutoFight/Script/CombatCommand.d.ts +3 -3
  24. package/types/BetterGenshinImpact/GameTask/AutoFight/Script/CombatScript.d.ts +3 -2
  25. package/types/BetterGenshinImpact/GameTask/AutoFight/Script/Method.d.ts +63 -3
  26. package/types/BetterGenshinImpact/GameTask/AutoLeyLineOutcrop/AutoLeyLineOutcropFightConfig.d.ts +4 -3
  27. package/types/BetterGenshinImpact/GameTask/AutoLeyLineOutcrop/AutoLeyLineOutcropParam.d.ts +1 -0
  28. package/types/BetterGenshinImpact/GameTask/AutoPathing/PathingScriptNames.d.ts +50 -0
  29. package/types/BetterGenshinImpact/GameTask/AutoSkip/AutoSkipConfig.d.ts +2 -0
  30. package/types/BetterGenshinImpact/GameTask/AutoStygianOnslaught/AutoStygianOnslaughtConfig.d.ts +5 -3
  31. package/types/BetterGenshinImpact/GameTask/AutoStygianOnslaught/AutoStygianOnslaughtParam.d.ts +6 -4
  32. package/types/BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.d.ts +19 -2
  33. package/types/BetterGenshinImpact/GameTask/Common/Map/MapScriptNames.d.ts +9 -0
  34. package/types/BetterGenshinImpact/GameTask/Model/Area/GameCaptureRegion.d.ts +6 -7
  35. package/types/BetterGenshinImpact/GameTask/Model/Area/ImageRegion.d.ts +18 -15
  36. package/types/BetterGenshinImpact/Helpers/User32Helper.d.ts +7 -0
  37. package/types/System/Windows/Forms/Keys.d.ts +195 -0
@@ -1,4 +1,4 @@
1
- import type { RealtimeTimerHostType } from "../types/BetterGenshinImpact/Core/Script/Dependence/Model/RealTimeTimer";
1
+ import type { RealtimeTimerHostType } from "../types/BetterGenshinImpact/Core/Script/Dependence/Model/RealtimeTimer";
2
2
 
3
3
  declare global {
4
4
  /**
@@ -1,8 +1,9 @@
1
+ import type { AvatarName } from "../types/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar";
1
2
  import type { HostArray, HostDelegate } from "../types/Microsoft/ClearScript/HostType";
2
3
 
3
4
  interface getAvatarsHostDelegate extends HostDelegate {
4
- (): HostArray<string>;
5
- invoke(): HostArray<string>;
5
+ (): HostArray<AvatarName>;
6
+ invoke(): HostArray<AvatarName>;
6
7
  }
7
8
 
8
9
  declare global {
@@ -1,3 +1,8 @@
1
+ /**
2
+ * 脚本侧 HTML 遮罩全局(ClearScript 宿主对象)。
3
+ * 启用:`import "@bettergi/types/htmlMask/host"` 或整包 `@bettergi/types`。
4
+ * 遮罩页(WebView)侧见 `@bettergi/types/htmlMask/webview`。
5
+ */
1
6
  import "../types/BetterGenshinImpact/Core/Script/Dependence/HtmlMask";
2
7
 
3
8
  declare global {
@@ -0,0 +1,92 @@
1
+ /**
2
+ * HTML 遮罩页(WebView2)侧通信桥类型。
3
+ * 对应宿主 `HtmlMaskWindow` 在 DocumentCreated 时注入的 helper,
4
+ * 与脚本侧 `@bettergi/types/htmlMask/host`(ClearScript `htmlMask` 全局)相对。
5
+ *
6
+ * 启用:`import "@bettergi/types/htmlMask/webview"` 或
7
+ * `/// <reference types="@bettergi/types/htmlMask/webview" />`
8
+ *
9
+ * @see BetterGenshinImpact.View.HtmlMaskWindow
10
+ * @since 0.61.0
11
+ */
12
+
13
+ /**
14
+ * 遮罩页与脚本之间的消息信封
15
+ * 宿主 JSON 使用 camelCase(url / data / requestId)
16
+ * @since 0.61.0
17
+ */
18
+ export interface HtmlMaskWebViewMessage {
19
+ /** 消息路径;页→脚本的 request 与脚本→页的推送均使用 */
20
+ url?: string;
21
+ /** 业务载荷;解析失败时可能不存在 */
22
+ data?: unknown;
23
+ /**
24
+ * 请求-应答关联 ID
25
+ * - 页发起 request 时由注入脚本生成(`__req_*`)
26
+ * - 脚本发起 request 时由宿主生成;页 onMessage 若返回值非 undefined 则自动回传
27
+ */
28
+ requestId?: string;
29
+ }
30
+
31
+ /**
32
+ * 注入到遮罩页的 `window.htmlMask` 助手
33
+ * 内部还含 `_callbacks` / `_seq` / `_dispatch`,属实现细节,不纳入公开类型
34
+ * @since 0.61.0
35
+ */
36
+ export interface HtmlMaskWebView {
37
+ /**
38
+ * 向脚本侧发起请求并等待响应
39
+ * 经 `chrome.webview.postMessage` 送出 `{ url, data, requestId }`;
40
+ * 匹配到带同一 requestId 的入站消息后 resolve 整包对象
41
+ * @param url 消息路径
42
+ * @param data 载荷,省略时按 `{}` 发送
43
+ * @since 0.61.0
44
+ */
45
+ request(url: string, data?: unknown): Promise<HtmlMaskWebViewMessage>;
46
+
47
+ /**
48
+ * 脚本推送到页的消息回调
49
+ * - 入站 JSON 解析成功:参数为消息对象
50
+ * - 解析失败:参数为原始字符串,且仍调用本回调
51
+ * - 若消息带 `requestId` 且返回值不是 `undefined`,助手会将结果
52
+ * (支持 Promise)以 `{ requestId, url: "/__response__", data }` 回传脚本
53
+ * @since 0.61.0
54
+ */
55
+ onMessage: ((msg: HtmlMaskWebViewMessage | string) => unknown) | null;
56
+ }
57
+
58
+ /**
59
+ * WebView2 提供的 `chrome.webview` 子集(遮罩页实际使用的面)
60
+ * @since 0.61.0
61
+ */
62
+ export interface ChromeWebView {
63
+ /**
64
+ * 向宿主发送字符串消息(须为 JSON 文本)
65
+ * @since 0.61.0
66
+ */
67
+ postMessage(message: string): void;
68
+ /**
69
+ * 监听宿主 `PostWebMessageAsString` 推送
70
+ * @since 0.61.0
71
+ */
72
+ addEventListener(type: "message", listener: (event: { data: string }) => void): void;
73
+ }
74
+
75
+ declare global {
76
+ interface Window {
77
+ /**
78
+ * HTML 遮罩页通信桥(宿主注入;非宿主环境可能不存在)
79
+ * @since 0.61.0
80
+ */
81
+ htmlMask?: HtmlMaskWebView;
82
+ /**
83
+ * WebView2 宿主对象;仅 WebView 内可用
84
+ * @since 0.61.0
85
+ */
86
+ chrome?: {
87
+ webview?: ChromeWebView;
88
+ };
89
+ }
90
+ }
91
+
92
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bettergi/types",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "BetterGI TypeScript 类型定义",
5
5
  "type": "module",
6
6
  "author": "Bread Grocery<https://github.com/breadgrocery>",
@@ -18,6 +18,12 @@
18
18
  "exports": {
19
19
  ".": {
20
20
  "types": "./index.d.ts"
21
+ },
22
+ "./htmlMask/host": {
23
+ "types": "./bindings/htmlMask.d.ts"
24
+ },
25
+ "./htmlMask/webview": {
26
+ "types": "./bindings/htmlMask.webview.d.ts"
21
27
  }
22
28
  },
23
29
  "files": [
@@ -6,14 +6,20 @@ import type {
6
6
  StrongNumeric
7
7
  } from "../../../Microsoft/ClearScript/HostType";
8
8
  import "../../../OpenCvSharp/Rect";
9
- import "../../../System/Action";
10
9
  import "../../../System/Collections/Generic/List";
11
- import "../../../System/Func";
12
10
  import "../../../System/Nullable";
13
11
  import "../../../System/Threading/CancellationToken";
14
12
  import "../../GameTask/Model/Area/Region";
15
13
  import "../Recognition/RecognitionObject";
16
14
 
15
+ /**
16
+ * 重试前回调:收到当前匹配区域列表;可为同步或返回 Promise 的异步脚本函数
17
+ * @since 0.61.0
18
+ */
19
+ export type BvLocatorRetryAction = (
20
+ regions: System.Collections.Generic.List<BetterGenshinImpact.GameTask.Model.Area.Region>
21
+ ) => void | Promise<void>;
22
+
17
23
  /**
18
24
  * BgiVision 定位器,按识别配置查找并操作匹配区域
19
25
  * @since 0.57.0
@@ -27,13 +33,10 @@ export interface BvLocator extends ClrHostValue {
27
33
  */
28
34
  readonly recognitionObject: BetterGenshinImpact.Core.Recognition.RecognitionObject;
29
35
  /**
30
- * 每次重试前执行的回调
36
+ * 每次重试前执行的回调;脚本侧可直接赋函数,`null` 清除
31
37
  * @since 0.57.0
32
38
  */
33
- retryAction: System.Func<
34
- System.Collections.Generic.List<BetterGenshinImpact.GameTask.Model.Area.Region>,
35
- Promise<void>
36
- >;
39
+ retryAction: BvLocatorRetryAction | null;
37
40
  /**
38
41
  * 按当前识别配置查找全部匹配区域;不建议脚本直接调用
39
42
  * @returns 匹配到的区域列表
@@ -118,12 +121,12 @@ export interface BvLocator extends ClrHostValue {
118
121
  tryWaitForDisappear(timeout: number | StrongNumeric<Int32Host> | null | null): Promise<void>;
119
122
  /**
120
123
  * 设置感兴趣区域(ROI),覆盖识别配置中的 RegionOfInterest
121
- * @param deltaFunc 由当前最大 1080P 捕获矩形计算 ROI 的回调
124
+ * @param deltaFunc 由当前最大 1080P 捕获矩形计算 ROI 的脚本回调
122
125
  * @returns 当前定位器,便于链式调用
123
126
  * @since 0.57.0
124
127
  */
125
128
  withRoi(
126
- deltaFunc: System.Func<OpenCvSharp.Rect, OpenCvSharp.Rect>
129
+ deltaFunc: (captureRect: OpenCvSharp.Rect) => OpenCvSharp.Rect
127
130
  ): BetterGenshinImpact.Core.BgiVision.BvLocator;
128
131
  /**
129
132
  * 设置感兴趣区域(ROI),覆盖识别配置中的 RegionOfInterest
@@ -151,28 +154,20 @@ export interface BvLocator extends ClrHostValue {
151
154
  retryInterval: number | StrongNumeric<Int32Host>
152
155
  ): BetterGenshinImpact.Core.BgiVision.BvLocator;
153
156
  /**
154
- * 设置每次重试前执行的回调;支持同步与异步脚本函数
155
- * @param action 收到当前匹配区域列表时调用的回调;传入 null 清除回调
157
+ * 设置每次重试前执行的回调;支持同步与异步脚本函数(对应上游 `Action` 与 `dynamic` 重载)
158
+ * @param action 收到当前匹配区域列表时调用的脚本回调;传入 null 清除回调
156
159
  * @returns 当前定位器,便于链式调用
157
160
  * @since 0.61.0
158
161
  */
159
162
  withRetryAction(
160
- action: System.Action<
161
- System.Collections.Generic.List<BetterGenshinImpact.GameTask.Model.Area.Region>
162
- > | null
163
+ action: BvLocatorRetryAction | null
163
164
  ): BetterGenshinImpact.Core.BgiVision.BvLocator;
164
- /**
165
- * 设置每次重试前执行的回调;供脚本传入无法隐式转为 Action 的函数
166
- * @param action 脚本回调;可为同步函数或返回 Promise 的异步函数
167
- * @returns 当前定位器,便于链式调用
168
- * @since 0.61.0
169
- */
170
- withRetryAction(action: unknown): BetterGenshinImpact.Core.BgiVision.BvLocator;
171
165
  }
172
166
 
173
167
  declare global {
174
168
  namespace BetterGenshinImpact.Core.BgiVision {
175
169
  type BvLocator = import("./BvLocator").BvLocator;
170
+ type BvLocatorRetryAction = import("./BvLocator").BvLocatorRetryAction;
176
171
  }
177
172
  }
178
173
 
@@ -11,10 +11,11 @@ import "../../../../System/Threading/CancellationTokenSource";
11
11
  import "../../../GameTask/AutoBoss/AutoBossParam";
12
12
  import "../../../GameTask/AutoDomain/AutoDomainParam";
13
13
  import "../../../GameTask/AutoFight/AutoFightParam";
14
+ import type { AvatarName } from "../../../GameTask/AutoFight/Model/Avatar";
14
15
  import "../../../GameTask/AutoLeyLineOutcrop/AutoLeyLineOutcropParam";
15
16
  import "../../../GameTask/AutoStygianOnslaught/AutoStygianOnslaughtParam";
16
17
  import "../../../GameTask/Common/Job/CountInventoryItemParam";
17
- import "./Model/RealTimeTimer";
18
+ import "./Model/RealtimeTimer";
18
19
  import "./Model/SoloTask";
19
20
 
20
21
  /**
@@ -135,10 +136,10 @@ export interface Dispatcher extends ClrHostValue {
135
136
  * @since unreleased
136
137
  */
137
138
  runCombatScript(script: string): Promise<void>;
138
- runCombatScript(script: string, avatarName: string | null): Promise<void>;
139
+ runCombatScript(script: string, avatarName: AvatarName | null): Promise<void>;
139
140
  runCombatScript(
140
141
  script: string,
141
- avatarName: string | null,
142
+ avatarName: AvatarName | null,
142
143
  customCt: System.Threading.CancellationToken | null | null
143
144
  ): Promise<void>;
144
145
  /**
@@ -12,8 +12,10 @@ import type { VoidResult } from "../../../../Microsoft/ClearScript/VoidResult";
12
12
  import "../../../../OpenCvSharp/Point2f";
13
13
  import "../../../../System/Lazy";
14
14
  import "../../../../System/Nullable";
15
+ import type { AvatarName } from "../../../GameTask/AutoFight/Model/Avatar";
15
16
  import "../../../GameTask/AutoPathing/NavigationInstance";
16
17
  import "../../../GameTask/Common/Job/CraftMaterialTask";
18
+ import type { CraftMaterialType } from "../../../GameTask/Common/Job/CraftMaterialTask";
17
19
  import type {
18
20
  Area,
19
21
  CountryName,
@@ -281,18 +283,27 @@ export interface Genshin extends ClrHostValue {
281
283
  * 按槽位重组当前队伍角色
282
284
  * 未传入或空字符串的槽位跳过;重组队伍槽位角色,不是按数字键切换当前出战角色
283
285
  * 示例:`await genshin.switchCharacter("胡桃", "夜兰", "", "钟离")`
284
- * @param slot1 1 号位角色名
285
- * @param slot2 2 号位角色名
286
- * @param slot3 3 号位角色名
287
- * @param slot4 4 号位角色名
286
+ * @param slot1 1 号位角色名,空字符串表示跳过
287
+ * @param slot2 2 号位角色名,空字符串表示跳过
288
+ * @param slot3 3 号位角色名,空字符串表示跳过
289
+ * @param slot4 4 号位角色名,空字符串表示跳过
288
290
  * @returns 在任务完成后兑现是否成功的 Promise;完成保存并返回主界面为 true,参数无效、目标角色未找到或流程失败为 false
289
291
  * @since unreleased
290
292
  */
291
293
  switchCharacter(): Promise<boolean>;
292
- switchCharacter(slot1: string): Promise<boolean>;
293
- switchCharacter(slot1: string, slot2: string): Promise<boolean>;
294
- switchCharacter(slot1: string, slot2: string, slot3: string): Promise<boolean>;
295
- switchCharacter(slot1: string, slot2: string, slot3: string, slot4: string): Promise<boolean>;
294
+ switchCharacter(slot1: "" | AvatarName): Promise<boolean>;
295
+ switchCharacter(slot1: "" | AvatarName, slot2: "" | AvatarName): Promise<boolean>;
296
+ switchCharacter(
297
+ slot1: "" | AvatarName,
298
+ slot2: "" | AvatarName,
299
+ slot3: "" | AvatarName
300
+ ): Promise<boolean>;
301
+ switchCharacter(
302
+ slot1: "" | AvatarName,
303
+ slot2: "" | AvatarName,
304
+ slot3: "" | AvatarName,
305
+ slot4: "" | AvatarName
306
+ ): Promise<boolean>;
296
307
  /**
297
308
  * 清除当前调度器的队伍缓存
298
309
  * @returns ClearScript 宿主空结果
@@ -361,7 +372,7 @@ export interface Genshin extends ClrHostValue {
361
372
  craftMaterial(
362
373
  materialName: string,
363
374
  quantity: number | StrongNumeric<Int32Host>,
364
- materialType: string | null
375
+ materialType: CraftMaterialType | null
365
376
  ): Promise<BetterGenshinImpact.GameTask.Common.Job.CraftMaterialResult>;
366
377
  /**
367
378
  * 返回主界面
@@ -84,6 +84,7 @@ declare global {
84
84
  declare global {
85
85
  namespace BetterGenshinImpact.Core.Script.Dependence {
86
86
  type Http = import("./Http").Http;
87
+ type HttpMethod = import("./Http").HttpMethod;
87
88
  }
88
89
  }
89
90
 
@@ -6,15 +6,16 @@ import type {
6
6
  ReferenceTypeTrait,
7
7
  StrongNumeric
8
8
  } from "../../../../Microsoft/ClearScript/HostType";
9
- import "../../../../Microsoft/ClearScript/ScriptObject";
10
9
  import type { VoidResult } from "../../../../Microsoft/ClearScript/VoidResult";
11
10
  import "../../../../System/IDisposable";
11
+ import type { Keys } from "../../../../System/Windows/Forms/Keys";
12
12
 
13
13
  /**
14
14
  * 钩子回报的鼠标按键
15
15
  * @since 0.55.0
16
16
  */
17
17
  export type MouseButton =
18
+ | "None"
18
19
  | "Left" // 左键
19
20
  | "Right" // 右键
20
21
  | "Middle" // 中键
@@ -36,8 +37,9 @@ export interface KeyMouseHook extends ClrHostValue, System.IDisposableInput {
36
37
  * @returns ClearScript 宿主空结果
37
38
  * @since 0.55.0
38
39
  */
39
- onKeyDown(callback: Microsoft.ClearScript.ScriptObject): VoidResult;
40
- onKeyDown(callback: Microsoft.ClearScript.ScriptObject, useCodeOnly: boolean): VoidResult;
40
+ onKeyDown(callback: (keyCode: Keys) => void): VoidResult;
41
+ onKeyDown(callback: (keyCode: Keys) => void, useCodeOnly: true): VoidResult;
42
+ onKeyDown(callback: string, useCodeOnly: false): VoidResult;
41
43
  /**
42
44
  * 注册键盘释放事件回调
43
45
  * @param callback 回调函数
@@ -45,22 +47,23 @@ export interface KeyMouseHook extends ClrHostValue, System.IDisposableInput {
45
47
  * @returns ClearScript 宿主空结果
46
48
  * @since 0.55.0
47
49
  */
48
- onKeyUp(callback: Microsoft.ClearScript.ScriptObject): VoidResult;
49
- onKeyUp(callback: Microsoft.ClearScript.ScriptObject, useCodeOnly: boolean): VoidResult;
50
+ onKeyUp(callback: (keyCode: Keys) => void): VoidResult;
51
+ onKeyUp(callback: (keyCode: Keys) => void, useCodeOnly: true): VoidResult;
52
+ onKeyUp(callback: string, useCodeOnly: false): VoidResult;
50
53
  /**
51
54
  * 注册鼠标按下事件回调
52
55
  * @param callback 回调,参数为按键名与游戏窗口局部坐标
53
56
  * @returns ClearScript 宿主空结果
54
57
  * @since 0.55.0
55
58
  */
56
- onMouseDown(callback: (button: MouseButton, x: number, y: number) => void): VoidResult;
59
+ onMouseDown(callback: (button: MouseButton, localX: number, localY: number) => void): VoidResult;
57
60
  /**
58
61
  * 注册鼠标抬起事件回调
59
62
  * @param callback 回调,参数为按键名与游戏窗口局部坐标
60
63
  * @returns ClearScript 宿主空结果
61
64
  * @since 0.55.0
62
65
  */
63
- onMouseUp(callback: (button: MouseButton, x: number, y: number) => void): VoidResult;
66
+ onMouseUp(callback: (button: MouseButton, localX: number, localY: number) => void): VoidResult;
64
67
  /**
65
68
  * 注册鼠标移动事件回调
66
69
  * @param callback 回调函数
@@ -97,6 +100,7 @@ export interface KeyMouseHook extends ClrHostValue, System.IDisposableInput {
97
100
  declare global {
98
101
  namespace BetterGenshinImpact.Core.Script.Dependence {
99
102
  type KeyMouseHook = import("./KeyMouseHook").KeyMouseHook;
103
+ type MouseButton = import("./KeyMouseHook").MouseButton;
100
104
  }
101
105
  }
102
106
 
@@ -64,11 +64,14 @@ export interface LimitedFile extends ClrHostValue {
64
64
  * 异步读取文件全部文本
65
65
  * 读取失败时通过回调传入错误并返回空字符串
66
66
  * @param path 相对工作区的文件路径
67
- * @param callbackFunc 回调函数,签名为 (error, text)
67
+ * @param callbackFunc 脚本回调 `(error, text)`;成功时 `error` 为 null,失败时 `text` 为 null
68
68
  * @returns 在任务完成后兑现文件文本的 Promise
69
69
  * @since 0.43.1
70
70
  */
71
- readText(path: string, callbackFunc: unknown): Promise<string>;
71
+ readText(
72
+ path: string,
73
+ callbackFunc: (error: string | null, text: string | null) => void
74
+ ): Promise<string>;
72
75
  /**
73
76
  * 异步读取文件全部文本
74
77
  * 读取失败时返回空字符串
@@ -130,17 +133,21 @@ export interface LimitedFile extends ClrHostValue {
130
133
  * 异步写入文本到文件并触发回调
131
134
  * @param path 相对工作区的文件路径
132
135
  * @param content 要写入的内容
133
- * @param callbackFunc 回调函数,签名为 (error, success)
136
+ * @param callbackFunc 脚本回调 `(error, success)`;成功时 `error` 为 null,失败时 `success` 为 null
134
137
  * @param append 是否追加到文件末尾,默认为 false(覆盖)
135
138
  * @returns 在任务完成后兑现是否写入成功的 Promise
136
139
  * @since 0.44.4
137
140
  */
138
- writeText(path: string, content: string, callbackFunc: unknown): Promise<boolean>;
141
+ writeText(
142
+ path: string,
143
+ content: string,
144
+ callbackFunc: (error: string | null, success: boolean | null) => void
145
+ ): Promise<boolean>;
139
146
  writeText(path: string, content: string, append: boolean): Promise<boolean>;
140
147
  writeText(
141
148
  path: string,
142
149
  content: string,
143
- callbackFunc: unknown,
150
+ callbackFunc: (error: string | null, success: boolean | null) => void,
144
151
  append: boolean
145
152
  ): Promise<boolean>;
146
153
  /**
@@ -4,6 +4,48 @@ import type {
4
4
  PublicDefaultConstructorTrait,
5
5
  ReferenceTypeTrait
6
6
  } from "../../../../../Microsoft/ClearScript/HostType";
7
+ import "../../../../GameTask/AutoSkip/AutoSkipConfig";
8
+
9
+ /**
10
+ * 实时触发器名 → RealtimeTimer.Config(唯一真源;配置一律 inline,无额外 type 名)
11
+ * 与 `GameTaskManager.AddTrigger` / `RealtimeTimer` 构造对齐
12
+ * @since 0.43.1
13
+ */
14
+ export type RealtimeTriggerConfigMap = {
15
+ /**
16
+ * 自动拾取
17
+ * 对应上游 `AutoPickExternalConfig`
18
+ */
19
+ AutoPick: {
20
+ /** 需要 F 的文本(对话、拾取) */
21
+ textList?: string[];
22
+ /** 无视文本和图标,遇到 F 就点击;默认 false */
23
+ forceInteraction?: boolean;
24
+ };
25
+ /**
26
+ * 自动跳过剧情
27
+ * 构造侧要求传入 `AutoSkipConfig` 实例
28
+ */
29
+ AutoSkip: BetterGenshinImpact.GameTask.AutoSkip.AutoSkipConfig;
30
+ /**
31
+ * 自动吃药;`AddTrigger` 可按名添加,构造不解析专用 config
32
+ */
33
+ AutoEat: void;
34
+ };
35
+
36
+ /**
37
+ * 实时触发器注册名 = map key;`(string & {})` 保留未知扩展
38
+ * @see GameTaskManager.AddTrigger
39
+ * @since 0.43.1
40
+ */
41
+ export type RealtimeTriggerName = keyof RealtimeTriggerConfigMap | (string & {});
42
+
43
+ export type RealtimeTriggerConfigForName<TName extends RealtimeTriggerName> =
44
+ TName extends keyof RealtimeTriggerConfigMap
45
+ ? RealtimeTriggerConfigMap[TName] extends void
46
+ ? undefined
47
+ : RealtimeTriggerConfigMap[TName]
48
+ : Record<string, unknown>;
7
49
 
8
50
  /**
9
51
  * 实时任务触发器
@@ -16,22 +58,30 @@ export interface RealtimeTimer extends ClrHostValue {
16
58
  * 实时任务触发器名称
17
59
  * @since 0.43.1
18
60
  */
19
- name: string;
61
+ name: RealtimeTriggerName;
20
62
  /**
21
63
  * 实时任务触发间隔,单位毫秒,默认 50
22
64
  * @since 0.43.1
23
65
  */
24
66
  interval: number;
25
67
  /**
26
- * 实时任务配置
68
+ * 实时任务配置(CLR 存 `object?`,JS 侧 plain object 或宿主配置实例)
27
69
  * @since 0.43.1
28
70
  */
29
- config: unknown;
71
+ config:
72
+ | Exclude<RealtimeTriggerConfigMap[keyof RealtimeTriggerConfigMap], void>
73
+ | Record<string, unknown>
74
+ | null
75
+ | undefined;
30
76
  }
31
77
 
32
78
  declare global {
33
79
  namespace BetterGenshinImpact.Core.Script.Dependence.Model {
34
- type RealtimeTimer = import("./RealTimeTimer").RealtimeTimer;
80
+ type RealtimeTimer = import("./RealtimeTimer").RealtimeTimer;
81
+ type RealtimeTriggerConfigForName<TName extends RealtimeTriggerName> =
82
+ import("./RealtimeTimer").RealtimeTriggerConfigForName<TName>;
83
+ type RealtimeTriggerConfigMap = import("./RealtimeTimer").RealtimeTriggerConfigMap;
84
+ type RealtimeTriggerName = import("./RealtimeTimer").RealtimeTriggerName;
35
85
  }
36
86
  }
37
87
 
@@ -45,18 +95,23 @@ export interface RealtimeTimerHostType extends HostType<
45
95
  */
46
96
  new (): RealtimeTimer;
47
97
  /**
48
- * 构造实例
98
+ * 仅名称
49
99
  * @param name 实时任务触发器名称
50
100
  * @since 0.43.1
51
101
  */
52
- new (name: string): RealtimeTimer;
102
+ new (name: RealtimeTriggerName): RealtimeTimer;
53
103
  /**
54
- * 构造实例
104
+ * 名称 + 配置(按触发器名收窄)
55
105
  * @param name 实时任务触发器名称
56
106
  * @param config 实时任务配置
57
107
  * @since 0.43.1
58
108
  */
59
- new (name: string, config: unknown): RealtimeTimer;
109
+ new <TName extends RealtimeTriggerName>(
110
+ name: TName,
111
+ config: RealtimeTriggerConfigForName<TName> extends undefined
112
+ ? Record<string, unknown> | undefined
113
+ : RealtimeTriggerConfigForName<TName>
114
+ ): RealtimeTimer;
60
115
  }
61
116
 
62
117
  export {};