@maaxyz/maa-node 2.2.2-post.11-ci.12043306412

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 (105) hide show
  1. package/agent/arm64-v8a/bin/minicap +0 -0
  2. package/agent/arm64-v8a/bin/minicap-nopie +0 -0
  3. package/agent/arm64-v8a/lib/android-21/minicap.so +0 -0
  4. package/agent/arm64-v8a/lib/android-22/minicap.so +0 -0
  5. package/agent/arm64-v8a/lib/android-23/minicap.so +0 -0
  6. package/agent/arm64-v8a/lib/android-24/minicap.so +0 -0
  7. package/agent/arm64-v8a/lib/android-25/minicap.so +0 -0
  8. package/agent/arm64-v8a/lib/android-26/minicap.so +0 -0
  9. package/agent/arm64-v8a/lib/android-27/minicap.so +0 -0
  10. package/agent/arm64-v8a/lib/android-28/minicap.so +0 -0
  11. package/agent/arm64-v8a/lib/android-29/minicap +0 -0
  12. package/agent/arm64-v8a/lib/android-29/minicap-nopie +0 -0
  13. package/agent/arm64-v8a/lib/android-29/minicap.so +0 -0
  14. package/agent/arm64-v8a/lib/android-30/minicap.so +0 -0
  15. package/agent/arm64-v8a/lib/android-31/minicap.so +0 -0
  16. package/agent/arm64-v8a/minitouch +0 -0
  17. package/agent/armeabi/minitouch +0 -0
  18. package/agent/armeabi-v7a/bin/minicap +0 -0
  19. package/agent/armeabi-v7a/bin/minicap-nopie +0 -0
  20. package/agent/armeabi-v7a/lib/android-10/minicap.so +0 -0
  21. package/agent/armeabi-v7a/lib/android-14/minicap.so +0 -0
  22. package/agent/armeabi-v7a/lib/android-15/minicap.so +0 -0
  23. package/agent/armeabi-v7a/lib/android-16/minicap.so +0 -0
  24. package/agent/armeabi-v7a/lib/android-17/minicap.so +0 -0
  25. package/agent/armeabi-v7a/lib/android-18/minicap.so +0 -0
  26. package/agent/armeabi-v7a/lib/android-19/minicap.so +0 -0
  27. package/agent/armeabi-v7a/lib/android-21/minicap.so +0 -0
  28. package/agent/armeabi-v7a/lib/android-22/minicap.so +0 -0
  29. package/agent/armeabi-v7a/lib/android-23/minicap.so +0 -0
  30. package/agent/armeabi-v7a/lib/android-24/minicap.so +0 -0
  31. package/agent/armeabi-v7a/lib/android-25/minicap.so +0 -0
  32. package/agent/armeabi-v7a/lib/android-26/minicap.so +0 -0
  33. package/agent/armeabi-v7a/lib/android-27/minicap.so +0 -0
  34. package/agent/armeabi-v7a/lib/android-28/minicap.so +0 -0
  35. package/agent/armeabi-v7a/lib/android-29/minicap +0 -0
  36. package/agent/armeabi-v7a/lib/android-29/minicap-nopie +0 -0
  37. package/agent/armeabi-v7a/lib/android-29/minicap.so +0 -0
  38. package/agent/armeabi-v7a/lib/android-30/minicap.so +0 -0
  39. package/agent/armeabi-v7a/lib/android-31/minicap.so +0 -0
  40. package/agent/armeabi-v7a/lib/android-9/minicap.so +0 -0
  41. package/agent/armeabi-v7a/minitouch +0 -0
  42. package/agent/universal/maatouch +0 -0
  43. package/agent/x86/bin/minicap +0 -0
  44. package/agent/x86/bin/minicap-nopie +0 -0
  45. package/agent/x86/lib/android-14/minicap.so +0 -0
  46. package/agent/x86/lib/android-15/minicap.so +0 -0
  47. package/agent/x86/lib/android-16/minicap.so +0 -0
  48. package/agent/x86/lib/android-17/minicap.so +0 -0
  49. package/agent/x86/lib/android-18/minicap.so +0 -0
  50. package/agent/x86/lib/android-19/minicap.so +0 -0
  51. package/agent/x86/lib/android-21/minicap.so +0 -0
  52. package/agent/x86/lib/android-22/minicap.so +0 -0
  53. package/agent/x86/lib/android-23/minicap.so +0 -0
  54. package/agent/x86/lib/android-24/minicap.so +0 -0
  55. package/agent/x86/lib/android-25/minicap.so +0 -0
  56. package/agent/x86/lib/android-26/minicap.so +0 -0
  57. package/agent/x86/lib/android-27/minicap.so +0 -0
  58. package/agent/x86/lib/android-28/minicap.so +0 -0
  59. package/agent/x86/lib/android-29/minicap +0 -0
  60. package/agent/x86/lib/android-29/minicap-nopie +0 -0
  61. package/agent/x86/lib/android-29/minicap.so +0 -0
  62. package/agent/x86/lib/android-31/minicap.so +0 -0
  63. package/agent/x86/minitouch +0 -0
  64. package/agent/x86_64/bin/minicap +0 -0
  65. package/agent/x86_64/bin/minicap-nopie +0 -0
  66. package/agent/x86_64/lib/android-21/minicap.so +0 -0
  67. package/agent/x86_64/lib/android-22/minicap.so +0 -0
  68. package/agent/x86_64/lib/android-23/minicap.so +0 -0
  69. package/agent/x86_64/lib/android-24/minicap.so +0 -0
  70. package/agent/x86_64/lib/android-25/minicap.so +0 -0
  71. package/agent/x86_64/lib/android-26/minicap.so +0 -0
  72. package/agent/x86_64/lib/android-27/minicap.so +0 -0
  73. package/agent/x86_64/lib/android-28/minicap.so +0 -0
  74. package/agent/x86_64/lib/android-29/minicap +0 -0
  75. package/agent/x86_64/lib/android-29/minicap-nopie +0 -0
  76. package/agent/x86_64/lib/android-29/minicap.so +0 -0
  77. package/agent/x86_64/lib/android-31/minicap.so +0 -0
  78. package/agent/x86_64/minitouch +0 -0
  79. package/dist/context.d.ts +52 -0
  80. package/dist/controller.d.ts +105 -0
  81. package/dist/global.d.ts +10 -0
  82. package/dist/index.d.ts +9 -0
  83. package/dist/index.js +1021 -0
  84. package/dist/job.d.ts +23 -0
  85. package/dist/maa.d.ts +365 -0
  86. package/dist/pi.d.ts +9 -0
  87. package/dist/pipeline.d.ts +249 -0
  88. package/dist/resource.d.ts +35 -0
  89. package/dist/tasker.d.ts +128 -0
  90. package/dist/types.d.ts +26 -0
  91. package/package.json +25 -0
  92. package/scripts/build.mjs +20 -0
  93. package/src/context.ts +78 -0
  94. package/src/controller.ts +366 -0
  95. package/src/global.ts +49 -0
  96. package/src/index.ts +9 -0
  97. package/src/job.ts +68 -0
  98. package/src/maa.d.ts +365 -0
  99. package/src/maa.js +27 -0
  100. package/src/pi.ts +61 -0
  101. package/src/pipeline.ts +694 -0
  102. package/src/resource.ts +166 -0
  103. package/src/tasker.ts +229 -0
  104. package/src/types.ts +30 -0
  105. package/tsconfig.json +9 -0
package/dist/job.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import * as maa from './maa';
2
+ export interface JobSource<Id> {
3
+ status(id: Id): maa.Status;
4
+ wait(id: Id): Promise<maa.Status>;
5
+ }
6
+ export declare class Job<Id, Source extends JobSource<Id>> {
7
+ #private;
8
+ source: Source;
9
+ id: Id;
10
+ constructor(source: Source, id: Id);
11
+ get status(): maa.Status;
12
+ wait(): Promise<this> & {
13
+ status: Promise<maa.Status>;
14
+ done: Promise<boolean>;
15
+ succeeded: Promise<boolean>;
16
+ failed: Promise<boolean>;
17
+ };
18
+ get done(): boolean;
19
+ get succeeded(): boolean;
20
+ get failed(): boolean;
21
+ get running(): boolean;
22
+ get pending(): boolean;
23
+ }
package/dist/maa.d.ts ADDED
@@ -0,0 +1,365 @@
1
+ export type ResourceHandle = { __brand: 'ResourceHandle' }
2
+ export type ControllerHandle = { __brand: 'ControllerHandle' }
3
+ export type TaskerHandle = { __brand: 'TaskerHandle' }
4
+ export type ContextHandle = { __brand: 'ContextHandle' }
5
+ export type DesktopHandle = string & { __brand: 'DesktopHandle' }
6
+
7
+ type Uint64 = number | bigint
8
+ type Id = Uint64
9
+ type ScreencapOrInputMethods = Uint64
10
+
11
+ export type ResId = Id & { __brand: 'ResId' }
12
+ export type CtrlId = Id & { __brand: 'CtrlId' }
13
+ export type TaskId = Id & { __brand: 'TaskId' }
14
+ export type RecoId = Id & { __brand: 'RecoId' }
15
+ export type NodeId = Id & { __brand: 'NodeId' }
16
+
17
+ export type Status = number & { __brand: 'Status' }
18
+ export type LoggingLevel = number & { __brand: 'LoggingLevel' }
19
+
20
+ export type ImageData = ArrayBuffer
21
+
22
+ export type Rect = {
23
+ x: number
24
+ y: number
25
+ width: number
26
+ height: number
27
+ }
28
+
29
+ export type FlatRect = [x: number, y: number, width: number, height: number]
30
+
31
+ type MaybePromise<T> = T | Promise<T>
32
+
33
+ export type NotificationCallback = (message: string, details_json: string) => MaybePromise<void>
34
+ export type CustomRecognitionCallback = (
35
+ context: ContextHandle,
36
+ task_id: TaskId,
37
+ current_task_name: string,
38
+ custom_recognition_name: string,
39
+ custom_recognition_param: string,
40
+ image: ImageData,
41
+ roi: Rect
42
+ ) => MaybePromise<[out_box: Rect, out_detail: string] | null>
43
+ export type CustomActionCallback = (
44
+ context: ContextHandle,
45
+ task_id: TaskId,
46
+ current_task_name: string,
47
+ custom_action_name: string,
48
+ custom_action_param: string,
49
+ reco_id: RecoId,
50
+ box: Rect
51
+ ) => MaybePromise<boolean>
52
+
53
+ export type CustomControllerParamResultMap = {
54
+ connect: [[], boolean]
55
+ request_uuid: [[], string | null]
56
+ start_app: [[intent: string], boolean]
57
+ stop_app: [[intent: string], boolean]
58
+ screencap: [[], ImageData | null]
59
+ click: [[x: number, y: number], boolean]
60
+ swipe: [[x1: number, y1: number, x2: number, y2: number, duration: number], boolean]
61
+ touch_down: [[contact: number, x: number, y: number, pressure: number], boolean]
62
+ touch_move: [[contact: number, x: number, y: number, pressure: number], boolean]
63
+ touch_up: [[contact: number], boolean]
64
+ press_key: [[keycode: number], boolean]
65
+ input_text: [[text: string], boolean]
66
+ }
67
+ export type CustomControllerCallback = (
68
+ action: keyof CustomControllerParamResultMap,
69
+ ...param: any[]
70
+ ) => MaybePromise<any>
71
+
72
+ // context.cpp
73
+
74
+ export declare function context_run_pipeline(
75
+ context: ContextHandle,
76
+ entry: string,
77
+ pipeline_override: string
78
+ ): Promise<TaskId>
79
+ export declare function context_run_recognition(
80
+ context: ContextHandle,
81
+ entry: string,
82
+ pipeline_override: string,
83
+ image: ImageData
84
+ ): Promise<RecoId>
85
+ export declare function context_run_action(
86
+ context: ContextHandle,
87
+ entry: string,
88
+ pipeline_override: string,
89
+ box: Rect,
90
+ reco_detail: string
91
+ ): Promise<NodeId>
92
+ export declare function context_override_pipeline(
93
+ context: ContextHandle,
94
+ pipeline_override: string
95
+ ): boolean
96
+ export declare function context_override_next(
97
+ context: ContextHandle,
98
+ name: string,
99
+ next: string[]
100
+ ): boolean
101
+ export declare function context_get_task_id(context: ContextHandle): TaskId
102
+ export declare function context_get_tasker(context: ContextHandle): TaskerHandle
103
+ export declare function context_clone(context: ContextHandle): ContextHandle
104
+
105
+ // controller.cpp
106
+
107
+ export declare function adb_controller_create(
108
+ adb_path: string,
109
+ address: string,
110
+ screencap_methods: ScreencapOrInputMethods,
111
+ input_methods: ScreencapOrInputMethods,
112
+ config: string,
113
+ agent_path: string,
114
+ callback: NotificationCallback | null
115
+ ): ControllerHandle | null
116
+ export declare function win32_controller_create(
117
+ handle: DesktopHandle,
118
+ screencap_methods: ScreencapOrInputMethods,
119
+ input_methods: ScreencapOrInputMethods,
120
+ callback: NotificationCallback | null
121
+ ): ControllerHandle | null
122
+ export declare function custom_controller_create(
123
+ custom_callback: CustomControllerCallback,
124
+ callback: NotificationCallback | null
125
+ ): ControllerHandle | null
126
+ export declare function dbg_controller_create(
127
+ read_path: string,
128
+ write_path: string,
129
+ type: Uint64,
130
+ config: string,
131
+ callback: NotificationCallback | null
132
+ ): ControllerHandle | null
133
+ export declare function controller_destroy(handle: ControllerHandle): void
134
+ export declare function controller_set_option_screenshot_target_long_side(
135
+ handle: ControllerHandle,
136
+ value: number
137
+ ): boolean
138
+ export declare function controller_set_option_screenshot_target_short_side(
139
+ handle: ControllerHandle,
140
+ value: number
141
+ ): boolean
142
+ export declare function controller_set_option_screenshot_use_raw_size(
143
+ handle: ControllerHandle,
144
+ value: boolean
145
+ ): boolean
146
+ export declare function controller_set_option_recording(
147
+ handle: ControllerHandle,
148
+ value: boolean
149
+ ): boolean
150
+ export declare function controller_post_connection(handle: ControllerHandle): CtrlId
151
+ export declare function controller_post_click(
152
+ handle: ControllerHandle,
153
+ x: number,
154
+ y: number
155
+ ): CtrlId
156
+ export declare function controller_post_swipe(
157
+ handle: ControllerHandle,
158
+ x1: number,
159
+ y1: number,
160
+ x2: number,
161
+ y2: number,
162
+ duration: number
163
+ ): CtrlId
164
+ export declare function controller_post_press_key(handle: ControllerHandle, keycode: number): CtrlId
165
+ export declare function controller_post_input_text(handle: ControllerHandle, text: string): CtrlId
166
+ export declare function controller_post_start_app(handle: ControllerHandle, intent: string): CtrlId
167
+ export declare function controller_post_stop_app(handle: ControllerHandle, intent: string): CtrlId
168
+ export declare function controller_post_touch_down(
169
+ handle: ControllerHandle,
170
+ contact: number,
171
+ x: number,
172
+ y: number,
173
+ pressure: number
174
+ ): CtrlId
175
+ export declare function controller_post_touch_move(
176
+ handle: ControllerHandle,
177
+ contact: number,
178
+ x: number,
179
+ y: number,
180
+ pressure: number
181
+ ): CtrlId
182
+ export declare function controller_post_touch_up(handle: ControllerHandle, contact: number): CtrlId
183
+ export declare function controller_post_screencap(handle: ControllerHandle): CtrlId
184
+ export declare function controller_status(handle: ControllerHandle, ctrl_id: CtrlId): Status
185
+ export declare function controller_wait(handle: ControllerHandle, ctrl_id: CtrlId): Promise<Status>
186
+ export declare function controller_connected(handle: ControllerHandle): boolean
187
+ export declare function controller_cached_image(handle: ControllerHandle): ImageData | null
188
+ export declare function controller_get_uuid(handle: ControllerHandle): string | null
189
+
190
+ // resource.cpp
191
+
192
+ export declare function resource_create(
193
+ callback: NotificationCallback | null
194
+ ): ResourceHandle | null
195
+ export declare function resource_destroy(handle: ResourceHandle): void
196
+ export declare function resource_set_option_inference_device(
197
+ handle: ResourceHandle,
198
+ id: number
199
+ ): boolean
200
+ export declare function resource_register_custom_recognition(
201
+ handle: ResourceHandle,
202
+ name: string,
203
+ recognizer: CustomRecognitionCallback
204
+ ): boolean
205
+ export declare function resource_unregister_custom_recognition(
206
+ handle: ResourceHandle,
207
+ name: string
208
+ ): boolean
209
+ export declare function resource_clear_custom_recognition(handle: ResourceHandle): boolean
210
+ export declare function resource_register_custom_action(
211
+ handle: ResourceHandle,
212
+ name: string,
213
+ action: CustomActionCallback
214
+ ): boolean
215
+ export declare function resource_unregister_custom_action(
216
+ handle: ResourceHandle,
217
+ name: string
218
+ ): boolean
219
+ export declare function resource_clear_custom_action(handle: ResourceHandle): boolean
220
+ export declare function resource_post_path(handle: ResourceHandle, path: string): ResId
221
+ export declare function resource_clear(handle: ResourceHandle): boolean
222
+ export declare function resource_status(handle: ResourceHandle, res_id: ResId): Status
223
+ export declare function resource_wait(handle: ResourceHandle, res_id: ResId): Promise<Status>
224
+ export declare function resource_loaded(handle: ResourceHandle): boolean
225
+ export declare function resource_get_hash(handle: ResourceHandle): string | null
226
+ export declare function resource_get_task_list(handle: ResourceHandle): string[] | null
227
+
228
+ // tasker.cpp
229
+
230
+ export declare function tasker_create(callback: NotificationCallback | null): TaskerHandle | null
231
+ export declare function tasker_destroy(handle: TaskerHandle): void
232
+ export declare function tasker_bind_resource(
233
+ handle: TaskerHandle,
234
+ resource: ResourceHandle | null
235
+ ): boolean
236
+ export declare function tasker_bind_controller(
237
+ handle: TaskerHandle,
238
+ controller: ControllerHandle | null
239
+ ): boolean
240
+ export declare function tasker_inited(handle: TaskerHandle): boolean
241
+ export declare function tasker_post_pipeline(
242
+ handle: TaskerHandle,
243
+ entry: string,
244
+ pipeline_override: string
245
+ ): TaskId
246
+ export declare function tasker_status(handle: TaskerHandle, task_id: TaskId): Status
247
+ export declare function tasker_wait(handle: TaskerHandle, task_id: TaskId): Promise<Status>
248
+ export declare function tasker_running(handle: TaskerHandle): boolean
249
+ export declare function tasker_post_stop(handle: TaskerHandle): boolean
250
+ export declare function tasker_get_resource(handle: TaskerHandle): ResourceHandle | null
251
+ export declare function tasker_get_controller(handle: TaskerHandle): ControllerHandle | null
252
+ export declare function tasker_clear_cache(handle: TaskerHandle): boolean
253
+ export declare function tasker_get_recognition_detail(
254
+ handle: TaskerHandle,
255
+ reco_id: RecoId
256
+ ):
257
+ | [
258
+ name: string,
259
+ algorithm: string,
260
+ hit: boolean,
261
+ box: Rect,
262
+ detail: string,
263
+ raw: ImageData,
264
+ draws: ImageData[]
265
+ ]
266
+ | null
267
+ export declare function tasker_get_node_detail(
268
+ handle: TaskerHandle,
269
+ node_id: NodeId
270
+ ): [name: string, reco_id: RecoId, completed: boolean] | null
271
+ export declare function tasker_get_task_detail(
272
+ handle: TaskerHandle,
273
+ task_id: TaskId
274
+ ): [entry: string, node_ids: NodeId[], status: Status] | null
275
+ export declare function tasker_get_latest_node(
276
+ handle: TaskerHandle,
277
+ task_name: string
278
+ ): NodeId | null
279
+
280
+ // config.cpp
281
+
282
+ export declare function config_init_option(user_path: string, default_json: string): boolean
283
+
284
+ // find.cpp
285
+
286
+ export declare function find_adb(
287
+ adb_path: string | null
288
+ ): Promise<
289
+ | [
290
+ name: string,
291
+ adb_path: string,
292
+ address: string,
293
+ screencap_methods: ScreencapOrInputMethods,
294
+ input_methods: ScreencapOrInputMethods,
295
+ config: string
296
+ ][]
297
+ | null
298
+ >
299
+ export declare function find_desktop(): Promise<
300
+ [handle: DesktopHandle, class_name: string, window_name: string][] | null
301
+ >
302
+
303
+ // utility.cpp
304
+
305
+ export declare function version(): string
306
+ export declare function set_global_option_log_dir(value: string): boolean
307
+ export declare function set_global_option_save_draw(value: boolean): boolean
308
+ export declare function set_global_option_recording(value: boolean): boolean
309
+ export declare function set_global_option_stdout_level(value: LoggingLevel): boolean
310
+ export declare function set_global_option_show_hit_draw(value: boolean): boolean
311
+ export declare function set_global_option_debug_mode(value: boolean): boolean
312
+
313
+ // pi.cpp
314
+
315
+ export declare function pi_register_custom_recognizer(
316
+ id: Id,
317
+ name: string,
318
+ recognizer: CustomRecognitionCallback
319
+ ): void
320
+ export declare function pi_register_custom_action(
321
+ id: Id,
322
+ name: string,
323
+ action: CustomActionCallback
324
+ ): void
325
+ export declare function pi_run_cli(
326
+ id: Id,
327
+ resource_path: string,
328
+ user_path: string,
329
+ directly: boolean,
330
+ callback: NotificationCallback | null
331
+ ): Promise<boolean>
332
+
333
+ // export declare function unwrap_window_hwnd(hwnd: Win32Hwnd): string
334
+ // export declare function wrap_window_hwnd(hwnd: string): Win32Hwnd | null
335
+
336
+ export declare const Status: Record<
337
+ 'Invalid' | 'Pending' | 'Running' | 'Succeeded' | 'Failed',
338
+ Status
339
+ >
340
+ export declare const LoggingLevel: Record<
341
+ 'Off' | 'Fatal' | 'Error' | 'Warn' | 'Info' | 'Debug' | 'Trace' | 'All',
342
+ LoggingLevel
343
+ >
344
+ export declare const AdbScreencapMethod: Record<
345
+ | 'EncodeToFileAndPull'
346
+ | 'Encode'
347
+ | 'RawWithGzip'
348
+ | 'RawByNetcat'
349
+ | 'MinicapDirect'
350
+ | 'MinicapStream'
351
+ | 'EmulatorExtras'
352
+ | 'All'
353
+ | 'Default',
354
+ ScreencapOrInputMethods
355
+ >
356
+ export declare const AdbInputMethod: Record<
357
+ 'AdbShell' | 'MinitouchAndAdbKey' | 'Maatouch' | 'EmulatorExtras' | 'All' | 'Default',
358
+ ScreencapOrInputMethods
359
+ >
360
+ export declare const Win32ScreencapMethod: Record<
361
+ 'GDI' | 'FramePool' | 'DXGI_DesktopDup',
362
+ ScreencapOrInputMethods
363
+ >
364
+ export declare const Win32InputMethod: Record<'Seize' | 'SendMessage', ScreencapOrInputMethods>
365
+ export declare const DbgControllerType: Record<'CarouselImage' | 'ReplayRecording', Uint64>
package/dist/pi.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import * as maa from './maa';
2
+ import { CustomActionCallback, CustomRecognizerCallback } from './types';
3
+ export declare const Pi: {
4
+ __running: boolean;
5
+ notify(message: string, details_json: string): maa.MaybePromise<void>;
6
+ register_custom_recognizer(id: maa.Id, name: string, func: CustomRecognizerCallback): void;
7
+ register_custom_action(id: maa.Id, name: string, func: CustomActionCallback): void;
8
+ run_cli(id: maa.Id, resource_path: string, user_path: string, directly: boolean): Promise<boolean>;
9
+ };
@@ -0,0 +1,249 @@
1
+ type RecoType = 'DirectHit' | 'TemplateMatch' | 'FeatureMatch' | 'ColorMatch' | 'OCR' | 'NeuralNetworkClassify' | 'NeuralNetworkDetect' | 'Custom';
2
+ type ActType = 'DoNothing' | 'Click' | 'Swipe' | 'Key' | 'Text' | 'StartApp' | 'StopApp' | 'StopTask' | 'Custom';
3
+ type OrderByMap = {
4
+ TemplateMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Random';
5
+ FeatureMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random';
6
+ ColorMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random';
7
+ OCR: 'Horizontal' | 'Vertical' | 'Area' | 'Length' | 'Random';
8
+ NeuralNetworkClassify: 'Horizontal' | 'Vertical' | 'Score' | 'Random';
9
+ NeuralNetworkDetect: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random';
10
+ };
11
+ type PipelineBuilderState<Json = {}> = {
12
+ done: Json;
13
+ } & ('recognition' extends keyof Json ? {} : {
14
+ recognition<R extends RecoType>(reco: R): PipelineRecognitionBuilderState<Json & {
15
+ recognition: R;
16
+ }, R>;
17
+ }) & ('action' extends keyof Json ? {} : {
18
+ action<A extends ActType>(act: A): PipelineActionBuilderState<Json & {
19
+ action: A;
20
+ }, A>;
21
+ }) & ('next' extends keyof Json ? {} : {
22
+ next<N extends string[]>(...nxt: [...N]): PipelineBuilderState<Json & {
23
+ next: N;
24
+ }>;
25
+ }) & ('interrupt' extends keyof Json ? {} : {
26
+ interrupt<I extends string[]>(...int: [...I]): PipelineBuilderState<Json & {
27
+ interrupt: I;
28
+ }>;
29
+ }) & ('rate_limit' extends keyof Json ? {} : {
30
+ rate_limit<R extends number>(rate: R): PipelineBuilderState<Json & {
31
+ rate_limit: R;
32
+ }>;
33
+ }) & ('timeout' extends keyof Json ? {} : {
34
+ timeout<R extends number>(time: R): PipelineBuilderState<Json & {
35
+ timeout: R;
36
+ }>;
37
+ }) & ('on_error' extends keyof Json ? {} : {
38
+ on_error<O extends string[]>(...err: [...O]): PipelineBuilderState<Json & {
39
+ on_error: O;
40
+ }>;
41
+ }) & ('inverse' extends keyof Json ? {} : {
42
+ inverse<I extends boolean>(inv: I): PipelineBuilderState<Json & {
43
+ inverse: I;
44
+ }>;
45
+ }) & ('enabled' extends keyof Json ? {} : {
46
+ enabled<E extends boolean>(en: E): PipelineBuilderState<Json & {
47
+ enabled: E;
48
+ }>;
49
+ }) & ('pre_delay' extends keyof Json ? {} : {
50
+ pre_delay<P extends number>(pre: P): PipelineBuilderState<Json & {
51
+ pre_delay: P;
52
+ }>;
53
+ }) & ('post_delay' extends keyof Json ? {} : {
54
+ post_delay<P extends number>(post: P): PipelineBuilderState<Json & {
55
+ post_delay: P;
56
+ }>;
57
+ }) & ('pre_wait_freezes' extends keyof Json ? {} : {
58
+ pre_wait_freezes: PipelineWaitFreezeBuilderState<Json, 'pre_wait_freezes'>;
59
+ }) & ('post_wait_freezes' extends keyof Json ? {} : {
60
+ post_wait_freezes: PipelineWaitFreezeBuilderState<Json, 'post_wait_freezes'>;
61
+ }) & ('focus' extends keyof Json ? {} : {
62
+ focus<F extends boolean>(focus: F): PipelineBuilderState<Json & {
63
+ focus: F;
64
+ }>;
65
+ });
66
+ type PipelineRecognitionBuilderState<PBJson, Reco extends RecoType, Json = {}> = {
67
+ done: PipelineBuilderState<PBJson & Json>;
68
+ } & (Reco extends 'DirectHit' ? {} : ('roi' extends keyof Json ? {} : {
69
+ roi<R extends [string] | [number, number, number, number]>(...roi: R): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
70
+ roi: R extends [number, number, number, number] ? R : R[0];
71
+ }>;
72
+ }) & ('roi_offset' extends keyof Json ? {} : {
73
+ roi_offset<R extends [number, number, number, number]>(...roi: R): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
74
+ roi_offset: R;
75
+ }>;
76
+ })) & (Reco extends 'TemplateMatch' | 'FeatureMatch' ? 'template' extends keyof Json ? {} : {
77
+ template<T extends string[]>(...templ: [...T]): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
78
+ template: T;
79
+ }>;
80
+ } : {}) & (Reco extends 'TemplateMatch' | 'NeuralNetworkDetect' ? 'threshold' extends keyof Json ? {} : {
81
+ threshold<T extends number[]>(...thres: [...T]): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
82
+ threshold: T;
83
+ }>;
84
+ threshold$<T extends number>(thres: T): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
85
+ threshold: T;
86
+ }>;
87
+ } : {}) & (Reco extends keyof OrderByMap ? 'order_by' extends keyof Json ? {} : {
88
+ order_by<O extends OrderByMap[Reco]>(order: O): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
89
+ order_by: O;
90
+ }>;
91
+ } : {}) & (Reco extends keyof OrderByMap ? 'index' extends keyof Json ? {} : {
92
+ index<T extends number>(idx: T): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
93
+ index: T;
94
+ }>;
95
+ } : {}) & (Reco extends 'TemplateMatch' ? 'method' extends keyof Json ? {} : {
96
+ method<M extends 1 | 3 | 5>(method: M): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
97
+ method: M;
98
+ }>;
99
+ } : {}) & (Reco extends 'ColorMatch' ? 'method' extends keyof Json ? {} : {
100
+ method<M extends 4 | 40 | 6>(method: M): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
101
+ method: M;
102
+ }>;
103
+ } : {}) & (Reco extends 'TemplateMatch' | 'FeatureMatch' ? 'green_mask' extends keyof Json ? {} : {
104
+ green_mask<G extends boolean>(mask: G): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
105
+ green_mask: G;
106
+ }>;
107
+ } : {}) & (Reco extends 'FeatureMatch' | 'ColorMatch' ? 'count' extends keyof Json ? {} : {
108
+ count<C extends number>(count: C): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
109
+ count: C;
110
+ }>;
111
+ } : {}) & (Reco extends 'FeatureMatch' ? 'detector' extends keyof Json ? {} : {
112
+ detector<D extends 'SIFT' | 'KAZE' | 'AKAZE' | 'BRISK' | 'ORB'>(det: D): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
113
+ detector: D;
114
+ }>;
115
+ } : {}) & (Reco extends 'FeatureMatch' ? 'ratio' extends keyof Json ? {} : {
116
+ ratio<R extends number>(ratio: R): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
117
+ ratio: R;
118
+ }>;
119
+ } : {}) & (Reco extends 'ColorMatch' ? 'method' extends keyof Json ? ('lower' extends keyof Json ? {} : Json['method'] extends 4 | 40 ? {
120
+ lower<L extends [number, number, number][]>(...lower: [...L]): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
121
+ lower: L;
122
+ }>;
123
+ } : {
124
+ lower<L extends [number][]>(...lower: [...L]): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
125
+ lower: L;
126
+ }>;
127
+ }) & ('upper' extends keyof Json ? {} : Json['method'] extends 4 | 40 ? {
128
+ upper<L extends [number, number, number][]>(...upper: [...L]): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
129
+ upper: L;
130
+ }>;
131
+ } : {
132
+ upper<U extends [number][]>(...upper: [...U]): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
133
+ upper: U;
134
+ }>;
135
+ }) : {} : {}) & (Reco extends 'ColorMatch' ? 'connected' extends keyof Json ? {} : {
136
+ connected<C extends boolean>(conn: C): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
137
+ connected: C;
138
+ }>;
139
+ } : {}) & (Reco extends 'OCR' ? 'expected' extends keyof Json ? {} : {
140
+ expected<E extends string[]>(...exp: [...E]): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
141
+ expected: E;
142
+ }>;
143
+ } : {}) & (Reco extends 'NeuralNetworkClassify' | 'NeuralNetworkDetect' ? 'expected' extends keyof Json ? {} : {
144
+ expected<E extends number[]>(...exp: [...E]): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
145
+ expected: E;
146
+ }>;
147
+ } : {}) & (Reco extends 'OCR' ? 'replace' extends keyof Json ? {} : {
148
+ replace<R extends [string, string][]>(...exp: [...R]): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
149
+ replace: R;
150
+ }>;
151
+ } : {}) & (Reco extends 'OCR' ? 'only_rec' extends keyof Json ? {} : {
152
+ only_rec<O extends boolean>(rec: O): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
153
+ only_rec: O;
154
+ }>;
155
+ } : {}) & (Reco extends 'OCR' | 'NeuralNetworkClassify' | 'NeuralNetworkDetect' ? 'model' extends keyof Json ? {} : {
156
+ model<M extends string>(model: M): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
157
+ model: M;
158
+ }>;
159
+ } : {}) & (Reco extends 'NeuralNetworkClassify' | 'NeuralNetworkDetect' ? 'labels' extends keyof Json ? {} : {
160
+ labels<L extends string[]>(...label: [...L]): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
161
+ labels: L;
162
+ }>;
163
+ } : {}) & (Reco extends 'Custom' ? 'custom_recognition' extends keyof Json ? {} : {
164
+ custom_recognition<C extends string>(reco: C): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
165
+ custom_recognition: C;
166
+ }>;
167
+ } : {}) & (Reco extends 'Custom' ? 'custom_recognition_param' extends keyof Json ? {} : {
168
+ custom_recognition_param<C extends Record<string, unknown>>(param: C): PipelineRecognitionBuilderState<PBJson, Reco, Json & {
169
+ custom_recognition_param: C;
170
+ }>;
171
+ } : {});
172
+ type PipelineActionBuilderState<PBJson, Act extends ActType, Json = {}> = {
173
+ done: PipelineBuilderState<PBJson & Json>;
174
+ } & (Act extends 'Click' | 'Custom' ? 'target' extends keyof Json ? {} : {
175
+ target<T extends [true] | [string] | [number, number, number, number]>(...target: T): PipelineActionBuilderState<PBJson, Act, Json & {
176
+ target: T extends [number, number, number, number] ? T : T[0];
177
+ }>;
178
+ } : {}) & (Act extends 'Click' | 'Custom' ? 'target_offset' extends keyof Json ? {} : {
179
+ target_offset<O extends [number, number, number, number]>(...offset: O): PipelineActionBuilderState<PBJson, Act, Json & {
180
+ target_offset: O;
181
+ }>;
182
+ } : {}) & (Act extends 'Swipe' ? 'begin' extends keyof Json ? {} : {
183
+ begin<B extends [true] | [string] | [number, number, number, number]>(...begin: B): PipelineActionBuilderState<PBJson, Act, Json & {
184
+ begin: B extends [number, number, number, number] ? B : B[0];
185
+ }>;
186
+ } : {}) & (Act extends 'Swipe' ? 'begin_offset' extends keyof Json ? {} : {
187
+ begin_offset<B extends [number, number, number, number]>(...offset: B): PipelineActionBuilderState<PBJson, Act, Json & {
188
+ begin_offset: B;
189
+ }>;
190
+ } : {}) & (Act extends 'Swipe' ? 'end' extends keyof Json ? {} : {
191
+ end<E extends [true] | [string] | [number, number, number, number]>(...end: E): PipelineActionBuilderState<PBJson, Act, Json & {
192
+ end: E extends [number, number, number, number] ? E : E[0];
193
+ }>;
194
+ } : {}) & (Act extends 'Swipe' ? 'end_offset' extends keyof Json ? {} : {
195
+ end_offset<E extends [number, number, number, number]>(...offset: E): PipelineActionBuilderState<PBJson, Act, Json & {
196
+ end_offset: E;
197
+ }>;
198
+ } : {}) & (Act extends 'Key' ? 'key' extends keyof Json ? {} : {
199
+ key<K extends number[]>(...key: [...K]): PipelineActionBuilderState<PBJson, Act, Json & {
200
+ key: K;
201
+ }>;
202
+ } : {}) & (Act extends 'InputText' ? 'input_text' extends keyof Json ? {} : {
203
+ input_text<T extends string>(text: T): PipelineActionBuilderState<PBJson, Act, Json & {
204
+ input_text: T;
205
+ }>;
206
+ } : {}) & (Act extends 'StartApp' | 'StopApp' ? 'package' extends keyof Json ? {} : {
207
+ package<P extends string>(pkg: P): PipelineActionBuilderState<PBJson, Act, Json & {
208
+ package: P;
209
+ }>;
210
+ } : {}) & (Act extends 'Custom' ? 'custom_action' extends keyof Json ? {} : {
211
+ custom_action<C extends string>(act: C): PipelineActionBuilderState<PBJson, Act, Json & {
212
+ custom_action: C;
213
+ }>;
214
+ } : {}) & (Act extends 'Custom' ? 'custom_action_param' extends keyof Json ? {} : {
215
+ custom_action_param<C extends Record<string, unknown>>(param: C): PipelineActionBuilderState<PBJson, Act, Json & {
216
+ custom_action_param: C;
217
+ }>;
218
+ } : {});
219
+ type PipelineWaitFreezeBuilderState<PBJson, Key extends 'pre_wait_freezes' | 'post_wait_freezes', Json = {}> = {
220
+ done: PipelineBuilderState<PBJson & {
221
+ [key in Key]: Json;
222
+ }>;
223
+ } & ('time' extends keyof Json ? {} : {
224
+ time<T extends number>(time: T): PipelineWaitFreezeBuilderState<PBJson, Key, Json & {
225
+ time: T;
226
+ }>;
227
+ }) & ('target' extends keyof Json ? {} : {
228
+ target<T extends [true] | [string] | [number, number, number, number]>(...target: T): PipelineWaitFreezeBuilderState<PBJson, Key, Json & {
229
+ target: T extends [number, number, number, number] ? T : T[0];
230
+ }>;
231
+ }) & ('target_offset' extends keyof Json ? {} : {
232
+ target_offset<O extends [number, number, number, number]>(...offset: O): PipelineWaitFreezeBuilderState<PBJson, Key, Json & {
233
+ target_offset: O;
234
+ }>;
235
+ }) & ('threshold' extends keyof Json ? {} : {
236
+ threshold<T extends number>(thres: T): PipelineWaitFreezeBuilderState<PBJson, Key, Json & {
237
+ threshold: T;
238
+ }>;
239
+ }) & ('method' extends keyof Json ? {} : {
240
+ method<M extends 1 | 3 | 5>(met: M): PipelineWaitFreezeBuilderState<PBJson, Key, Json & {
241
+ method: M;
242
+ }>;
243
+ }) & ('rate_limit' extends keyof Json ? {} : {
244
+ rate_limit<R extends number>(rate: R): PipelineWaitFreezeBuilderState<PBJson, Key, Json & {
245
+ rate_limit: R;
246
+ }>;
247
+ });
248
+ export declare function pp(): PipelineBuilderState;
249
+ export {};
@@ -0,0 +1,35 @@
1
+ import { Job, JobSource } from './job';
2
+ import maa from './maa';
3
+ import { CustomActionCallback, CustomRecognizerCallback } from './types';
4
+ export type ResourceNotify = {
5
+ res_id: maa.ResId;
6
+ path: string;
7
+ } & ({
8
+ msg: 'StartLoading';
9
+ } | {
10
+ msg: 'LoadingCompleted' | 'LoadingFailed';
11
+ hash: string;
12
+ });
13
+ export declare class ResourceBase {
14
+ #private;
15
+ handle: maa.ResourceHandle;
16
+ notify(message: string, details_json: string): maa.MaybePromise<void>;
17
+ set parsed_notify(cb: (msg: ResourceNotify) => maa.MaybePromise<void>);
18
+ constructor(handle: maa.ResourceHandle);
19
+ destroy(): void;
20
+ set inference_device(id: 'cpu' | 'auto' | number);
21
+ register_custom_recognizer(name: string, func: CustomRecognizerCallback): void;
22
+ unregister_custom_recognizer(name: string): void;
23
+ clear_custom_recognizer(): void;
24
+ register_custom_action(name: string, func: CustomActionCallback): void;
25
+ unregister_custom_action(name: string): void;
26
+ clear_custom_action(): void;
27
+ post_path(path: string): Job<maa.ResId, JobSource<maa.ResId>>;
28
+ clear(): void;
29
+ get loaded(): boolean;
30
+ get hash(): string | null;
31
+ get task_list(): string[] | null;
32
+ }
33
+ export declare class Resource extends ResourceBase {
34
+ constructor();
35
+ }