@maaxyz/maa-node 4.4.0-beta.1 → 4.4.0

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.
@@ -1,5 +1,7 @@
1
1
  import { Job, JobSource } from './job';
2
2
  import maa, { ImageData } from './maa';
3
+ import { ChainNotifyType } from './types';
4
+ import { chain_notify_impl } from './utils';
3
5
  declare class ImageJob extends Job<maa.CtrlId, JobSource<maa.CtrlId>> {
4
6
  #private;
5
7
  constructor(ctrl: ControllerBase, source: JobSource<maa.CtrlId>, id: maa.CtrlId);
@@ -13,23 +15,9 @@ declare class ImageJob extends Job<maa.CtrlId, JobSource<maa.CtrlId>> {
13
15
  get: () => Promise<ArrayBuffer | null>;
14
16
  };
15
17
  }
16
- export type ControllerNotify = ({
17
- adb: string;
18
- address: string;
19
- } & ({
20
- msg: 'UUIDGot';
21
- uuid: string;
22
- } | {
23
- msg: 'UUIDGetFailed';
24
- } | {
25
- msg: 'ConnectSuccess';
26
- } | {
27
- msg: 'ConnectFailed';
28
- why: 'ConnectFailed' | 'UUIDGetFailed';
29
- } | {
30
- msg: 'ScreencapInited' | 'ScreencapInitFailed' | 'TouchinputInited' | 'TouchinputInitFailed';
31
- })) | {
32
- msg: 'Action.Started' | 'Action.Completed' | 'Action.Failed';
18
+ export type ControllerNotify = {
19
+ msg: 'Action.Starting' | 'Action.Succeeded' | 'Action.Failed';
20
+ action: 'connect' | 'click' | 'swipe' | 'touch_down' | 'touch_move' | 'touch_up' | 'press_key' | 'input_text' | 'screencap' | 'start_app' | 'stop_app';
33
21
  ctrl_id: maa.CtrlId;
34
22
  uuid: string;
35
23
  };
@@ -37,7 +25,8 @@ export declare class ControllerBase {
37
25
  #private;
38
26
  handle: maa.ControllerHandle;
39
27
  notify(message: string, details_json: string): maa.MaybePromise<void>;
40
- set parsed_notify(cb: (msg: ControllerNotify) => maa.MaybePromise<void>);
28
+ chain_notify: typeof chain_notify_impl;
29
+ chain_parsed_notify(cb: (msg: ControllerNotify) => maa.MaybePromise<void>, order?: ChainNotifyType): void;
41
30
  constructor(handle: maa.ControllerHandle);
42
31
  destroy(): void;
43
32
  set screenshot_target_long_side(value: number);
@@ -150,6 +150,42 @@ var Job = class {
150
150
 
151
151
  // src/controller.ts
152
152
  var import_maa = __toESM(require_maa());
153
+
154
+ // src/utils.ts
155
+ function chain_notify_impl(cb, order = "after") {
156
+ const old = this.notify;
157
+ switch (order) {
158
+ case "before":
159
+ this.notify = async (msg, details) => {
160
+ await cb(msg, details);
161
+ await old.call(this, msg, details);
162
+ };
163
+ break;
164
+ case "after":
165
+ this.notify = async (msg, details) => {
166
+ await old.call(this, msg, details);
167
+ await cb(msg, details);
168
+ };
169
+ break;
170
+ case "before-no-wait":
171
+ this.notify = async (msg, details) => {
172
+ cb(msg, details);
173
+ await old.call(this, msg, details);
174
+ };
175
+ break;
176
+ case "after-no-wait":
177
+ this.notify = async (msg, details) => {
178
+ await old.call(this, msg, details);
179
+ cb(msg, details);
180
+ };
181
+ break;
182
+ case "replace":
183
+ this.notify = cb;
184
+ break;
185
+ }
186
+ }
187
+
188
+ // src/controller.ts
153
189
  var ImageJob = class extends Job {
154
190
  #ctrl;
155
191
  constructor(ctrl, source, id) {
@@ -181,13 +217,14 @@ var ControllerBase = class {
181
217
  #source;
182
218
  notify(message, details_json) {
183
219
  }
184
- set parsed_notify(cb) {
185
- this.notify = (msg, details) => {
220
+ chain_notify = chain_notify_impl;
221
+ chain_parsed_notify(cb, order = "after") {
222
+ this.chain_notify((msg, details) => {
186
223
  return cb({
187
224
  msg: msg.replace(/^Controller\./, ""),
188
225
  ...JSON.parse(details)
189
226
  });
190
- };
227
+ }, order);
191
228
  }
192
229
  constructor(handle) {
193
230
  this.handle = handle;
@@ -433,13 +470,14 @@ var TaskerBase = class {
433
470
  #source;
434
471
  notify(message, details_json) {
435
472
  }
436
- set parsed_notify(cb) {
437
- this.notify = (msg, details) => {
473
+ chain_notify = chain_notify_impl;
474
+ chain_parsed_notify(cb, order = "after") {
475
+ this.chain_notify((msg, details) => {
438
476
  return cb({
439
477
  msg: msg.replace(/^(?:Tasker|Node)?\./, ""),
440
478
  ...JSON.parse(details)
441
479
  });
442
- };
480
+ }, order);
443
481
  }
444
482
  constructor(handle) {
445
483
  this.handle = handle;
@@ -636,13 +674,14 @@ var ResourceBase = class {
636
674
  #source;
637
675
  notify(message, details_json) {
638
676
  }
639
- set parsed_notify(cb) {
640
- this.notify = (msg, details) => {
677
+ chain_notify = chain_notify_impl;
678
+ chain_parsed_notify(cb, order = "after") {
679
+ this.chain_notify((msg, details) => {
641
680
  return cb({
642
681
  msg: msg.replace(/^Resource\./, ""),
643
682
  ...JSON.parse(details)
644
683
  });
645
- };
684
+ }, order);
646
685
  }
647
686
  constructor(handle) {
648
687
  this.handle = handle;
@@ -150,6 +150,42 @@ var Job = class {
150
150
 
151
151
  // src/controller.ts
152
152
  var import_maa = __toESM(require_maa());
153
+
154
+ // src/utils.ts
155
+ function chain_notify_impl(cb, order = "after") {
156
+ const old = this.notify;
157
+ switch (order) {
158
+ case "before":
159
+ this.notify = async (msg, details) => {
160
+ await cb(msg, details);
161
+ await old.call(this, msg, details);
162
+ };
163
+ break;
164
+ case "after":
165
+ this.notify = async (msg, details) => {
166
+ await old.call(this, msg, details);
167
+ await cb(msg, details);
168
+ };
169
+ break;
170
+ case "before-no-wait":
171
+ this.notify = async (msg, details) => {
172
+ cb(msg, details);
173
+ await old.call(this, msg, details);
174
+ };
175
+ break;
176
+ case "after-no-wait":
177
+ this.notify = async (msg, details) => {
178
+ await old.call(this, msg, details);
179
+ cb(msg, details);
180
+ };
181
+ break;
182
+ case "replace":
183
+ this.notify = cb;
184
+ break;
185
+ }
186
+ }
187
+
188
+ // src/controller.ts
153
189
  var ImageJob = class extends Job {
154
190
  #ctrl;
155
191
  constructor(ctrl, source, id) {
@@ -181,13 +217,14 @@ var ControllerBase = class {
181
217
  #source;
182
218
  notify(message, details_json) {
183
219
  }
184
- set parsed_notify(cb) {
185
- this.notify = (msg, details) => {
220
+ chain_notify = chain_notify_impl;
221
+ chain_parsed_notify(cb, order = "after") {
222
+ this.chain_notify((msg, details) => {
186
223
  return cb({
187
224
  msg: msg.replace(/^Controller\./, ""),
188
225
  ...JSON.parse(details)
189
226
  });
190
- };
227
+ }, order);
191
228
  }
192
229
  constructor(handle) {
193
230
  this.handle = handle;
@@ -433,13 +470,14 @@ var TaskerBase = class {
433
470
  #source;
434
471
  notify(message, details_json) {
435
472
  }
436
- set parsed_notify(cb) {
437
- this.notify = (msg, details) => {
473
+ chain_notify = chain_notify_impl;
474
+ chain_parsed_notify(cb, order = "after") {
475
+ this.chain_notify((msg, details) => {
438
476
  return cb({
439
477
  msg: msg.replace(/^(?:Tasker|Node)?\./, ""),
440
478
  ...JSON.parse(details)
441
479
  });
442
- };
480
+ }, order);
443
481
  }
444
482
  constructor(handle) {
445
483
  this.handle = handle;
@@ -636,13 +674,14 @@ var ResourceBase = class {
636
674
  #source;
637
675
  notify(message, details_json) {
638
676
  }
639
- set parsed_notify(cb) {
640
- this.notify = (msg, details) => {
677
+ chain_notify = chain_notify_impl;
678
+ chain_parsed_notify(cb, order = "after") {
679
+ this.chain_notify((msg, details) => {
641
680
  return cb({
642
681
  msg: msg.replace(/^Resource\./, ""),
643
682
  ...JSON.parse(details)
644
683
  });
645
- };
684
+ }, order);
646
685
  }
647
686
  constructor(handle) {
648
687
  this.handle = handle;
@@ -1,8 +1,17 @@
1
1
  import type { FlatRect } from './maa';
2
2
  type NodeName = string;
3
- type OutputRemove<T, Output> = Output extends true ? never : T;
4
- type MaybeArray<T, Output> = T[] | OutputRemove<T, Output>;
3
+ export type ModeFragment = 0;
4
+ export type ModeStrict = 1;
5
+ export type ModeDump = 2;
6
+ type RemoveIfDump<T, Mode> = Mode extends ModeDump ? never : T;
7
+ type MaybeArray<T, Mode> = T[] | RemoveIfDump<T, Mode>;
5
8
  type FixedArray<T, K extends number, A extends T[] = []> = A['length'] extends K ? A : FixedArray<T, K, [...A, T]>;
9
+ type RequiredIfStrict<T, Keys, Mode> = Mode extends ModeStrict ? RequiredKeys<T, Keys> : T;
10
+ type RequiredKeys<T, Keys> = {
11
+ [key in keyof T & Keys]: NonNullable<T[key]>;
12
+ } & {
13
+ [key in Exclude<keyof T, Keys>]: T[key];
14
+ };
6
15
  type OrderByMap = {
7
16
  TemplateMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Random';
8
17
  FeatureMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random';
@@ -12,96 +21,94 @@ type OrderByMap = {
12
21
  NeuralNetworkDetect: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random';
13
22
  };
14
23
  export type RecognitionDirectHit = {};
15
- export type RecognitionTemplateMatch<Output> = {
24
+ export type RecognitionTemplateMatch<Mode> = RequiredIfStrict<{
16
25
  roi?: FlatRect | NodeName;
17
26
  roi_offset?: FlatRect;
18
- template?: MaybeArray<string, Output>;
19
- template_?: MaybeArray<string, Output>;
20
- threshold?: MaybeArray<number, Output>;
27
+ template?: MaybeArray<string, Mode>;
28
+ threshold?: MaybeArray<number, Mode>;
21
29
  order_by?: OrderByMap['TemplateMatch'];
22
30
  index?: number;
23
31
  method?: 1 | 3 | 5;
24
32
  green_mask?: boolean;
25
- };
26
- export type RecognitionFeatureMatch<Output> = {
33
+ }, 'template', Mode>;
34
+ export type RecognitionFeatureMatch<Mode> = RequiredIfStrict<{
27
35
  roi?: FlatRect | NodeName;
28
36
  roi_offset?: FlatRect;
29
- template?: MaybeArray<string, Output>;
30
- template_?: MaybeArray<string, Output>;
37
+ template?: MaybeArray<string, Mode>;
31
38
  count?: number;
32
39
  order_by?: OrderByMap['FeatureMatch'];
33
40
  index?: number;
34
41
  green_mask?: boolean;
35
42
  detector?: 'SIFT' | 'KAZE' | 'AKAZE' | 'BRISK' | 'ORB';
36
43
  ratio?: number;
37
- };
38
- export type RecognitionColorMatch<Output> = {
44
+ }, 'template', Mode>;
45
+ export type RecognitionColorMatch<Mode> = {
39
46
  roi?: FlatRect | NodeName;
40
47
  roi_offset?: FlatRect;
41
- } & ({
48
+ } & RequiredIfStrict<{
42
49
  method?: 4 | 40;
43
- lower?: MaybeArray<FixedArray<number, 3>, Output>;
44
- upper?: MaybeArray<FixedArray<number, 3>, Output>;
50
+ lower?: MaybeArray<FixedArray<number, 3>, Mode>;
51
+ upper?: MaybeArray<FixedArray<number, 3>, Mode>;
45
52
  } | {
46
53
  method: 6;
47
- lower?: MaybeArray<FixedArray<number, 1>, Output>;
48
- upper?: MaybeArray<FixedArray<number, 1>, Output>;
49
- }) & {
54
+ lower?: MaybeArray<FixedArray<number, 1>, Mode>;
55
+ upper?: MaybeArray<FixedArray<number, 1>, Mode>;
56
+ }, 'lower' | 'upper', Mode> & {
50
57
  count?: number;
51
58
  order_by?: OrderByMap['ColorMatch'];
52
59
  index?: number;
53
60
  connected?: boolean;
54
61
  };
55
- export type RecognitionOCR<Output> = {
62
+ export type RecognitionOCR<Mode> = RequiredIfStrict<{
56
63
  roi?: FlatRect | NodeName;
57
64
  roi_offset?: FlatRect;
58
- expected?: MaybeArray<string, Output>;
59
- threshold?: MaybeArray<number, Output>;
60
- replace?: MaybeArray<FixedArray<string, 2>, Output>;
65
+ expected?: MaybeArray<string, Mode>;
66
+ threshold?: MaybeArray<number, Mode>;
67
+ replace?: MaybeArray<FixedArray<string, 2>, Mode>;
61
68
  order_by?: OrderByMap['OCR'];
62
69
  index?: number;
63
70
  only_rec?: boolean;
64
71
  model?: string;
65
- };
66
- export type RecognitionNeuralNetworkClassify<Output> = {
72
+ }, 'expected', Mode>;
73
+ export type RecognitionNeuralNetworkClassify<Mode> = RequiredIfStrict<{
67
74
  roi?: FlatRect | NodeName;
68
75
  roi_offset?: FlatRect;
69
76
  labels?: string[];
70
77
  model?: string;
71
- expected?: MaybeArray<number, Output>;
78
+ expected?: MaybeArray<number, Mode>;
72
79
  order_by?: OrderByMap['NeuralNetworkClassify'];
73
80
  index?: number;
74
- };
75
- export type RecognitionNeuralNetworkDetect<Output> = {
81
+ }, 'model', Mode>;
82
+ export type RecognitionNeuralNetworkDetect<Mode> = RequiredIfStrict<{
76
83
  roi?: FlatRect | NodeName;
77
84
  roi_offset?: FlatRect;
78
85
  labels?: string[];
79
86
  model?: string;
80
- expected?: MaybeArray<number, Output>;
87
+ expected?: MaybeArray<number, Mode>;
81
88
  threshold?: number;
82
89
  order_by?: OrderByMap['NeuralNetworkDetect'];
83
90
  index?: number;
84
- };
85
- export type RecognitionCustom = {
91
+ }, 'model', Mode>;
92
+ export type RecognitionCustom<Mode> = RequiredIfStrict<{
86
93
  roi?: FlatRect | NodeName;
87
94
  roi_offset?: FlatRect;
88
95
  custom_recognition?: string;
89
96
  custom_recognition_param?: unknown;
90
- };
91
- type MixReco<Type extends string, Param, Output> = {
97
+ }, 'custom_recognition', Mode>;
98
+ type MixReco<Type extends string, Param, Mode> = {
92
99
  recognition: {
93
100
  type: Type;
94
101
  param?: Param;
95
102
  };
96
- } | OutputRemove<{
103
+ } | RemoveIfDump<{
97
104
  recognition: Type;
98
- } & Param, Output>;
99
- export type Recognition<Output> = OutputRemove<{
105
+ } & Param, Mode>;
106
+ export type Recognition<Mode> = RemoveIfDump<{
100
107
  recognition?: {
101
108
  type?: never;
102
109
  param?: never;
103
110
  };
104
- }, Output> | MixReco<'DirectHit', RecognitionDirectHit, Output> | MixReco<'TemplateMatch', RecognitionTemplateMatch<Output>, Output> | MixReco<'FeatureMatch', RecognitionFeatureMatch<Output>, Output> | MixReco<'ColorMatch', RecognitionColorMatch<Output>, Output> | MixReco<'OCR', RecognitionOCR<Output>, Output> | MixReco<'NeuralNetworkClassify', RecognitionNeuralNetworkClassify<Output>, Output> | MixReco<'NeuralNetworkDetect', RecognitionNeuralNetworkDetect<Output>, Output> | MixReco<'Custom', RecognitionCustom, Output>;
111
+ }, Mode> | MixReco<'DirectHit', RecognitionDirectHit, Mode> | MixReco<'TemplateMatch', RecognitionTemplateMatch<Mode>, Mode> | MixReco<'FeatureMatch', RecognitionFeatureMatch<Mode>, Mode> | MixReco<'ColorMatch', RecognitionColorMatch<Mode>, Mode> | MixReco<'OCR', RecognitionOCR<Mode>, Mode> | MixReco<'NeuralNetworkClassify', RecognitionNeuralNetworkClassify<Mode>, Mode> | MixReco<'NeuralNetworkDetect', RecognitionNeuralNetworkDetect<Mode>, Mode> | MixReco<'Custom', RecognitionCustom<Mode>, Mode>;
105
112
  export type ActionDoNothing = {};
106
113
  export type ActionClick = {
107
114
  target?: true | NodeName | FlatRect;
@@ -119,7 +126,7 @@ export type ActionSwipe = {
119
126
  end_offset?: FlatRect;
120
127
  duration?: number;
121
128
  };
122
- export type ActionMultiSwipe = {
129
+ export type ActionMultiSwipe<Mode> = RequiredIfStrict<{
123
130
  swipes?: {
124
131
  starting?: number;
125
132
  begin?: true | NodeName | FlatRect;
@@ -128,45 +135,45 @@ export type ActionMultiSwipe = {
128
135
  end_offset?: FlatRect;
129
136
  duration?: number;
130
137
  }[];
131
- };
132
- export type ActionKey<Output> = {
133
- key?: MaybeArray<number, Output>;
134
- };
135
- export type ActionInputText = {
138
+ }, 'swipes', Mode>;
139
+ export type ActionKey<Mode> = RequiredIfStrict<{
140
+ key?: MaybeArray<number, Mode>;
141
+ }, 'key', Mode>;
142
+ export type ActionInputText<Mode> = RequiredIfStrict<{
136
143
  input_text?: string;
137
- };
138
- export type ActionStartApp = {
144
+ }, 'input_text', Mode>;
145
+ export type ActionStartApp<Mode> = RequiredIfStrict<{
139
146
  package?: string;
140
- };
141
- export type ActionStopApp = {
147
+ }, 'package', Mode>;
148
+ export type ActionStopApp<Mode> = RequiredIfStrict<{
142
149
  package?: string;
143
- };
150
+ }, 'package', Mode>;
144
151
  export type ActionStopTask = {};
145
- export type ActionCommand = {
152
+ export type ActionCommand<Mode> = RequiredIfStrict<{
146
153
  exec?: string;
147
154
  args?: string[];
148
155
  detach?: boolean;
149
- };
150
- export type ActionCustom = {
156
+ }, 'exec', Mode>;
157
+ export type ActionCustom<Mode> = RequiredIfStrict<{
151
158
  target?: true | NodeName | FlatRect;
152
159
  target_offset?: FlatRect;
153
160
  custom_action?: string;
154
161
  custom_action_param?: unknown;
155
- };
156
- type MixAct<Type extends string, Param, Output> = OutputRemove<{
162
+ }, 'custom_action', Mode>;
163
+ type MixAct<Type extends string, Param, Mode> = RemoveIfDump<{
157
164
  action: Type;
158
- } & Param, Output> | {
165
+ } & Param, Mode> | {
159
166
  action: {
160
167
  type: Type;
161
168
  param?: Param;
162
169
  };
163
170
  };
164
- export type Action<Output> = OutputRemove<{
171
+ export type Action<Mode> = RemoveIfDump<{
165
172
  action?: {
166
173
  type?: never;
167
174
  param?: never;
168
175
  };
169
- }, Output> | MixAct<'DoNothing', ActionDoNothing, Output> | MixAct<'Click', ActionClick, Output> | MixAct<'LongPress', ActionLongPress, Output> | MixAct<'Swipe', ActionSwipe, Output> | MixAct<'MultiSwipe', ActionMultiSwipe, Output> | MixAct<'Key', ActionKey<Output>, Output> | MixAct<'InputText', ActionInputText, Output> | MixAct<'StartApp', ActionStartApp, Output> | MixAct<'StopApp', ActionStopApp, Output> | MixAct<'StopTask', ActionStopTask, Output> | MixAct<'Command', ActionCommand, Output> | MixAct<'Custom', ActionCustom, Output>;
176
+ }, Mode> | MixAct<'DoNothing', ActionDoNothing, Mode> | MixAct<'Click', ActionClick, Mode> | MixAct<'LongPress', ActionLongPress, Mode> | MixAct<'Swipe', ActionSwipe, Mode> | MixAct<'MultiSwipe', ActionMultiSwipe<Mode>, Mode> | MixAct<'Key', ActionKey<Mode>, Mode> | MixAct<'InputText', ActionInputText<Mode>, Mode> | MixAct<'StartApp', ActionStartApp<Mode>, Mode> | MixAct<'StopApp', ActionStopApp<Mode>, Mode> | MixAct<'StopTask', ActionStopTask, Mode> | MixAct<'Command', ActionCommand<Mode>, Mode> | MixAct<'Custom', ActionCustom<Mode>, Mode>;
170
177
  export type WaitFreeze = {
171
178
  time?: number;
172
179
  target?: true | NodeName | FlatRect;
@@ -176,24 +183,25 @@ export type WaitFreeze = {
176
183
  rate_limit?: number;
177
184
  timeout?: number;
178
185
  };
179
- export type General<Output> = {
180
- next?: MaybeArray<NodeName, Output>;
181
- interrupt?: MaybeArray<NodeName, Output>;
186
+ export type General<Mode> = {
187
+ next?: MaybeArray<NodeName, Mode>;
188
+ interrupt?: MaybeArray<NodeName, Mode>;
182
189
  is_sub?: boolean;
183
190
  rate_limit?: number;
184
191
  timeout?: number;
185
- on_error?: MaybeArray<string, Output>;
192
+ on_error?: MaybeArray<string, Mode>;
186
193
  inverse?: boolean;
187
194
  enabled?: boolean;
188
195
  pre_delay?: boolean;
189
196
  post_delay?: boolean;
190
- pre_wait_freezes?: OutputRemove<number, Output> | WaitFreeze;
191
- post_wait_freezes?: OutputRemove<number, Output> | WaitFreeze;
197
+ pre_wait_freezes?: RemoveIfDump<number, Mode> | WaitFreeze;
198
+ post_wait_freezes?: RemoveIfDump<number, Mode> | WaitFreeze;
192
199
  focus?: unknown;
193
200
  };
194
- export type Task = Recognition<false> & Action<false> & General<false>;
201
+ export type Task = Recognition<ModeFragment> & Action<ModeFragment> & General<ModeFragment>;
202
+ export type StrictTask = Recognition<ModeStrict> & Action<ModeStrict> & General<ModeStrict>;
195
203
  type RecursiveRequired<T> = T extends Record<string, unknown> ? {
196
- [key in keyof T]-?: RecursiveRequired<T[key]>;
204
+ [key in keyof T]: NonNullable<RecursiveRequired<T[key]>>;
197
205
  } : T;
198
- export type DumpTask = RecursiveRequired<Recognition<true> & Action<true> & General<true>>;
206
+ export type DumpTask = RecursiveRequired<Recognition<ModeDump> & Action<ModeDump> & General<ModeDump>>;
199
207
  export {};
@@ -1,21 +1,20 @@
1
1
  import { Job, JobSource } from './job';
2
2
  import maa from './maa';
3
3
  import { DumpTask } from './pipeline';
4
- import { CustomActionCallback, CustomRecognizerCallback } from './types';
4
+ import { ChainNotifyType, CustomActionCallback, CustomRecognizerCallback } from './types';
5
+ import { chain_notify_impl } from './utils';
5
6
  export type ResourceNotify = {
7
+ msg: 'Loading.Starting' | 'Loading.Succeeded' | 'Loading.Failed';
6
8
  res_id: maa.ResId;
7
9
  path: string;
8
- } & ({
9
- msg: 'StartLoading';
10
- } | {
11
- msg: 'LoadingCompleted' | 'LoadingFailed';
12
10
  hash: string;
13
- });
11
+ };
14
12
  export declare class ResourceBase {
15
13
  #private;
16
14
  handle: maa.ResourceHandle;
17
15
  notify(message: string, details_json: string): maa.MaybePromise<void>;
18
- set parsed_notify(cb: (msg: ResourceNotify) => maa.MaybePromise<void>);
16
+ chain_notify: typeof chain_notify_impl;
17
+ chain_parsed_notify(cb: (msg: ResourceNotify) => maa.MaybePromise<void>, order?: ChainNotifyType): void;
19
18
  constructor(handle: maa.ResourceHandle);
20
19
  destroy(): void;
21
20
  set inference_device(id: keyof typeof maa.InferenceDevice | number);
package/dist/tasker.d.ts CHANGED
@@ -2,6 +2,8 @@ import { ControllerBase } from './controller';
2
2
  import { Job, JobSource } from './job';
3
3
  import maa from './maa';
4
4
  import { ResourceBase } from './resource';
5
+ import { ChainNotifyType } from './types';
6
+ import { chain_notify_impl } from './utils';
5
7
  type TaskDetail = ReturnType<TaskerBase['task_detail']>;
6
8
  type RecoDetailEntry = {
7
9
  box: maa.FlatRect;
@@ -47,36 +49,36 @@ declare class TaskJob extends Job<maa.TaskId, JobSource<maa.TaskId>> {
47
49
  };
48
50
  }
49
51
  export type TaskerNotify = {
52
+ msg: 'Task.Started' | 'Task.Completed' | 'Task.Failed';
50
53
  task_id: maa.TaskId;
51
54
  entry: string;
52
- hash: string;
53
55
  uuid: string;
54
- } & ({
55
- msg: 'Task.Started' | 'Task.Completed' | 'Task.Failed';
56
+ hash: string;
56
57
  } | {
57
58
  msg: 'NextList.Starting' | 'NextList.Succeeded' | 'NextList.Failed';
58
- task_id: number;
59
+ task_id: maa.TaskId;
59
60
  name: string;
60
61
  list: string[];
61
62
  focus: unknown;
62
63
  } | {
63
64
  msg: 'Recognition.Starting' | 'Recognition.Succeeded' | 'Recognition.Failed';
64
- task_id: number;
65
- reco_id: number;
65
+ task_id: maa.TaskId;
66
+ reco_id: maa.RecoId;
66
67
  name: string;
67
68
  focus: unknown;
68
69
  } | {
69
70
  msg: 'Action.Starting' | 'Action.Succeeded' | 'Action.Failed';
70
- task_id: number;
71
- node_id: number;
71
+ task_id: maa.TaskId;
72
+ node_id: maa.NodeId;
72
73
  name: string;
73
74
  focus: unknown;
74
- });
75
+ };
75
76
  export declare class TaskerBase {
76
77
  #private;
77
78
  handle: maa.TaskerHandle;
78
79
  notify(message: string, details_json: string): maa.MaybePromise<void>;
79
- set parsed_notify(cb: (msg: TaskerNotify) => maa.MaybePromise<void>);
80
+ chain_notify: typeof chain_notify_impl;
81
+ chain_parsed_notify(cb: (msg: TaskerNotify) => maa.MaybePromise<void>, order?: ChainNotifyType): void;
80
82
  constructor(handle: maa.TaskerHandle);
81
83
  destroy(): void;
82
84
  bind(slave: ControllerBase | ResourceBase): void;
package/dist/types.d.ts CHANGED
@@ -24,4 +24,5 @@ export type CustomRecognizerCallback = CustomCallback<CustomRecognizerSelf, [
24
24
  out_detail: string
25
25
  ] | null>;
26
26
  export type CustomActionCallback = CustomCallback<CustomActionSelf, boolean>;
27
+ export type ChainNotifyType = 'before' | 'after' | 'before-no-wait' | 'after-no-wait' | 'replace';
27
28
  export {};
@@ -0,0 +1,5 @@
1
+ import maa from './maa';
2
+ import { ChainNotifyType } from './types';
3
+ export declare function chain_notify_impl(this: {
4
+ notify: maa.NotificationCallback;
5
+ }, cb: maa.NotificationCallback, order?: ChainNotifyType): void;
package/package.json CHANGED
@@ -25,13 +25,13 @@
25
25
  "prettier": "^3.5.2",
26
26
  "typescript": "^5.8.2"
27
27
  },
28
- "version": "4.4.0-beta.1",
28
+ "version": "4.4.0",
29
29
  "optionalDependencies": {
30
- "@maaxyz/maa-node-darwin-arm64": "4.4.0-beta.1",
31
- "@maaxyz/maa-node-darwin-x64": "4.4.0-beta.1",
32
- "@maaxyz/maa-node-linux-arm64": "4.4.0-beta.1",
33
- "@maaxyz/maa-node-linux-x64": "4.4.0-beta.1",
34
- "@maaxyz/maa-node-win32-arm64": "4.4.0-beta.1",
35
- "@maaxyz/maa-node-win32-x64": "4.4.0-beta.1"
30
+ "@maaxyz/maa-node-darwin-arm64": "4.4.0",
31
+ "@maaxyz/maa-node-darwin-x64": "4.4.0",
32
+ "@maaxyz/maa-node-linux-arm64": "4.4.0",
33
+ "@maaxyz/maa-node-linux-x64": "4.4.0",
34
+ "@maaxyz/maa-node-win32-arm64": "4.4.0",
35
+ "@maaxyz/maa-node-win32-x64": "4.4.0"
36
36
  }
37
37
  }