@maaxyz/maa-node 4.4.0-alpha.3 → 4.4.0-alpha.3-post.7-ci.15747843275
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/dist/context.d.ts +2 -5
- package/dist/pipeline.d.ts +53 -42
- package/dist/resource.d.ts +2 -5
- package/package.json +7 -7
- package/src/context.ts +2 -2
- package/src/pipeline.ts +94 -66
- package/src/resource.ts +2 -2
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as maa from './maa';
|
|
2
|
+
import { DumpTask } from './pipeline';
|
|
2
3
|
import { TaskerBase } from './tasker';
|
|
3
4
|
export declare class Context {
|
|
4
5
|
#private;
|
|
@@ -46,11 +47,7 @@ export declare class Context {
|
|
|
46
47
|
override_pipeline(pipeline_override: Record<string, unknown>): void;
|
|
47
48
|
override_next(node_name: string, next: string[]): void;
|
|
48
49
|
get_node_data(node_name: string): string | null;
|
|
49
|
-
get_node_data_parsed(node_name: string):
|
|
50
|
-
recognition?: {};
|
|
51
|
-
} & {
|
|
52
|
-
action?: {};
|
|
53
|
-
} & import("./pipeline").General) | null;
|
|
50
|
+
get_node_data_parsed(node_name: string): DumpTask | null;
|
|
54
51
|
get task_id(): maa.TaskId;
|
|
55
52
|
get tasker(): TaskerBase;
|
|
56
53
|
clone(): Context;
|
package/dist/pipeline.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { FlatRect } from './maa';
|
|
2
2
|
type NodeName = string;
|
|
3
|
-
type
|
|
3
|
+
type OutputRemove<T, Output> = Output extends true ? never : T;
|
|
4
|
+
type MaybeArray<T, Output> = T[] | OutputRemove<T, Output>;
|
|
4
5
|
type FixedArray<T, K extends number, A extends T[] = []> = A['length'] extends K ? A : FixedArray<T, K, [...A, T]>;
|
|
5
6
|
type OrderByMap = {
|
|
6
7
|
TemplateMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Random';
|
|
@@ -11,22 +12,22 @@ type OrderByMap = {
|
|
|
11
12
|
NeuralNetworkDetect: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random';
|
|
12
13
|
};
|
|
13
14
|
export type RecognitionDirectHit = {};
|
|
14
|
-
export type RecognitionTemplateMatch = {
|
|
15
|
+
export type RecognitionTemplateMatch<Output> = {
|
|
15
16
|
roi?: FlatRect | NodeName;
|
|
16
17
|
roi_offset?: FlatRect;
|
|
17
|
-
template?: MaybeArray<string>;
|
|
18
|
-
template_?: MaybeArray<string>;
|
|
19
|
-
threshold?: MaybeArray<number>;
|
|
18
|
+
template?: MaybeArray<string, Output>;
|
|
19
|
+
template_?: MaybeArray<string, Output>;
|
|
20
|
+
threshold?: MaybeArray<number, Output>;
|
|
20
21
|
order_by?: OrderByMap['TemplateMatch'];
|
|
21
22
|
index?: number;
|
|
22
23
|
method?: 1 | 3 | 5;
|
|
23
24
|
green_mask?: boolean;
|
|
24
25
|
};
|
|
25
|
-
export type RecognitionFeatureMatch = {
|
|
26
|
+
export type RecognitionFeatureMatch<Output> = {
|
|
26
27
|
roi?: FlatRect | NodeName;
|
|
27
28
|
roi_offset?: FlatRect;
|
|
28
|
-
template?: MaybeArray<string>;
|
|
29
|
-
template_?: MaybeArray<string>;
|
|
29
|
+
template?: MaybeArray<string, Output>;
|
|
30
|
+
template_?: MaybeArray<string, Output>;
|
|
30
31
|
count?: number;
|
|
31
32
|
order_by?: OrderByMap['FeatureMatch'];
|
|
32
33
|
index?: number;
|
|
@@ -34,49 +35,49 @@ export type RecognitionFeatureMatch = {
|
|
|
34
35
|
detector?: 'SIFT' | 'KAZE' | 'AKAZE' | 'BRISK' | 'ORB';
|
|
35
36
|
ratio?: number;
|
|
36
37
|
};
|
|
37
|
-
export type RecognitionColorMatch = {
|
|
38
|
+
export type RecognitionColorMatch<Output> = {
|
|
38
39
|
roi?: FlatRect | NodeName;
|
|
39
40
|
roi_offset?: FlatRect;
|
|
40
41
|
} & ({
|
|
41
42
|
method?: 4 | 40;
|
|
42
|
-
lower?: MaybeArray<FixedArray<number, 3
|
|
43
|
-
upper?: MaybeArray<FixedArray<number, 3
|
|
43
|
+
lower?: MaybeArray<FixedArray<number, 3>, Output>;
|
|
44
|
+
upper?: MaybeArray<FixedArray<number, 3>, Output>;
|
|
44
45
|
} | {
|
|
45
46
|
method: 6;
|
|
46
|
-
lower?: MaybeArray<FixedArray<number, 1
|
|
47
|
-
upper?: MaybeArray<FixedArray<number, 1
|
|
47
|
+
lower?: MaybeArray<FixedArray<number, 1>, Output>;
|
|
48
|
+
upper?: MaybeArray<FixedArray<number, 1>, Output>;
|
|
48
49
|
}) & {
|
|
49
50
|
count?: number;
|
|
50
51
|
order_by?: OrderByMap['ColorMatch'];
|
|
51
52
|
index?: number;
|
|
52
53
|
connected?: boolean;
|
|
53
54
|
};
|
|
54
|
-
export type RecognitionOCR = {
|
|
55
|
+
export type RecognitionOCR<Output> = {
|
|
55
56
|
roi?: FlatRect | NodeName;
|
|
56
57
|
roi_offset?: FlatRect;
|
|
57
|
-
expected?: MaybeArray<string>;
|
|
58
|
-
threshold?: MaybeArray<number>;
|
|
59
|
-
replace?: MaybeArray<FixedArray<string, 2
|
|
58
|
+
expected?: MaybeArray<string, Output>;
|
|
59
|
+
threshold?: MaybeArray<number, Output>;
|
|
60
|
+
replace?: MaybeArray<FixedArray<string, 2>, Output>;
|
|
60
61
|
order_by?: OrderByMap['OCR'];
|
|
61
62
|
index?: number;
|
|
62
63
|
only_rec?: boolean;
|
|
63
64
|
model?: string;
|
|
64
65
|
};
|
|
65
|
-
export type RecognitionNeuralNetworkClassify = {
|
|
66
|
+
export type RecognitionNeuralNetworkClassify<Output> = {
|
|
66
67
|
roi?: FlatRect | NodeName;
|
|
67
68
|
roi_offset?: FlatRect;
|
|
68
69
|
labels?: string[];
|
|
69
70
|
model?: string;
|
|
70
|
-
expected?: MaybeArray<number>;
|
|
71
|
+
expected?: MaybeArray<number, Output>;
|
|
71
72
|
order_by?: OrderByMap['NeuralNetworkClassify'];
|
|
72
73
|
index?: number;
|
|
73
74
|
};
|
|
74
|
-
export type RecognitionNeuralNetworkDetect = {
|
|
75
|
+
export type RecognitionNeuralNetworkDetect<Output> = {
|
|
75
76
|
roi?: FlatRect | NodeName;
|
|
76
77
|
roi_offset?: FlatRect;
|
|
77
78
|
labels?: string[];
|
|
78
79
|
model?: string;
|
|
79
|
-
expected?: MaybeArray<number>;
|
|
80
|
+
expected?: MaybeArray<number, Output>;
|
|
80
81
|
threshold?: number;
|
|
81
82
|
order_by?: OrderByMap['NeuralNetworkDetect'];
|
|
82
83
|
index?: number;
|
|
@@ -87,17 +88,20 @@ export type RecognitionCustom = {
|
|
|
87
88
|
custom_recognition?: string;
|
|
88
89
|
custom_recognition_param?: unknown;
|
|
89
90
|
};
|
|
90
|
-
type MixReco<Type extends string, Param> =
|
|
91
|
-
recognition: Type;
|
|
92
|
-
} & Param) | {
|
|
91
|
+
type MixReco<Type extends string, Param, Output> = {
|
|
93
92
|
recognition: {
|
|
94
93
|
type: Type;
|
|
95
94
|
param?: Param;
|
|
96
95
|
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
} | OutputRemove<{
|
|
97
|
+
recognition: Type;
|
|
98
|
+
} & Param, Output>;
|
|
99
|
+
export type Recognition<Output> = OutputRemove<{
|
|
100
|
+
recognition?: {
|
|
101
|
+
type?: never;
|
|
102
|
+
param?: never;
|
|
103
|
+
};
|
|
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>;
|
|
101
105
|
export type ActionDoNothing = {};
|
|
102
106
|
export type ActionClick = {
|
|
103
107
|
target?: true | NodeName | FlatRect;
|
|
@@ -125,8 +129,8 @@ export type ActionMultiSwipe = {
|
|
|
125
129
|
duration?: number;
|
|
126
130
|
}[];
|
|
127
131
|
};
|
|
128
|
-
export type ActionKey = {
|
|
129
|
-
key?: MaybeArray<number>;
|
|
132
|
+
export type ActionKey<Output> = {
|
|
133
|
+
key?: MaybeArray<number, Output>;
|
|
130
134
|
};
|
|
131
135
|
export type ActionInputText = {
|
|
132
136
|
input_text?: string;
|
|
@@ -149,17 +153,20 @@ export type ActionCustom = {
|
|
|
149
153
|
custom_action?: string;
|
|
150
154
|
custom_action_param?: unknown;
|
|
151
155
|
};
|
|
152
|
-
type MixAct<Type extends string, Param> =
|
|
156
|
+
type MixAct<Type extends string, Param, Output> = OutputRemove<{
|
|
153
157
|
action: Type;
|
|
154
|
-
} & Param
|
|
158
|
+
} & Param, Output> | {
|
|
155
159
|
action: {
|
|
156
160
|
type: Type;
|
|
157
161
|
param?: Param;
|
|
158
162
|
};
|
|
159
163
|
};
|
|
160
|
-
export type Action = {
|
|
161
|
-
action?: {
|
|
162
|
-
|
|
164
|
+
export type Action<Output> = OutputRemove<{
|
|
165
|
+
action?: {
|
|
166
|
+
type?: never;
|
|
167
|
+
param?: never;
|
|
168
|
+
};
|
|
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>;
|
|
163
170
|
export type WaitFreeze = {
|
|
164
171
|
time?: number;
|
|
165
172
|
target?: true | NodeName | FlatRect;
|
|
@@ -169,20 +176,24 @@ export type WaitFreeze = {
|
|
|
169
176
|
rate_limit?: number;
|
|
170
177
|
timeout?: number;
|
|
171
178
|
};
|
|
172
|
-
export type General = {
|
|
173
|
-
next?: MaybeArray<NodeName>;
|
|
174
|
-
interrupt?: MaybeArray<NodeName>;
|
|
179
|
+
export type General<Output> = {
|
|
180
|
+
next?: MaybeArray<NodeName, Output>;
|
|
181
|
+
interrupt?: MaybeArray<NodeName, Output>;
|
|
175
182
|
is_sub?: boolean;
|
|
176
183
|
rate_limit?: number;
|
|
177
184
|
timeout?: number;
|
|
178
|
-
on_error?: MaybeArray<string>;
|
|
185
|
+
on_error?: MaybeArray<string, Output>;
|
|
179
186
|
inverse?: boolean;
|
|
180
187
|
enabled?: boolean;
|
|
181
188
|
pre_delay?: boolean;
|
|
182
189
|
post_delay?: boolean;
|
|
183
|
-
pre_wait_freezes?: number | WaitFreeze;
|
|
184
|
-
post_wait_freezes?: number | WaitFreeze;
|
|
190
|
+
pre_wait_freezes?: OutputRemove<number, Output> | WaitFreeze;
|
|
191
|
+
post_wait_freezes?: OutputRemove<number, Output> | WaitFreeze;
|
|
185
192
|
focus?: unknown;
|
|
186
193
|
};
|
|
187
|
-
export type Task = Recognition & Action & General
|
|
194
|
+
export type Task = Recognition<false> & Action<false> & General<false>;
|
|
195
|
+
type RecursiveRequired<T> = T extends Record<string, unknown> ? {
|
|
196
|
+
[key in keyof T]-?: RecursiveRequired<T[key]>;
|
|
197
|
+
} : T;
|
|
198
|
+
export type DumpTask = RecursiveRequired<Recognition<true> & Action<true> & General<true>>;
|
|
188
199
|
export {};
|
package/dist/resource.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Job, JobSource } from './job';
|
|
2
2
|
import maa from './maa';
|
|
3
|
+
import { DumpTask } from './pipeline';
|
|
3
4
|
import { CustomActionCallback, CustomRecognizerCallback } from './types';
|
|
4
5
|
export type ResourceNotify = {
|
|
5
6
|
res_id: maa.ResId;
|
|
@@ -29,11 +30,7 @@ export declare class ResourceBase {
|
|
|
29
30
|
override_pipeline(pipeline_override: string): void;
|
|
30
31
|
override_next(node_name: string, next_list: string[]): void;
|
|
31
32
|
get_node_data(node_name: string): string | null;
|
|
32
|
-
get_node_data_parsed(node_name: string):
|
|
33
|
-
recognition?: {};
|
|
34
|
-
} & {
|
|
35
|
-
action?: {};
|
|
36
|
-
} & import("./pipeline").General) | null;
|
|
33
|
+
get_node_data_parsed(node_name: string): DumpTask | null;
|
|
37
34
|
clear(): void;
|
|
38
35
|
get loaded(): boolean;
|
|
39
36
|
get hash(): string | null;
|
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-alpha.3",
|
|
28
|
+
"version": "4.4.0-alpha.3-post.7-ci.15747843275",
|
|
29
29
|
"optionalDependencies": {
|
|
30
|
-
"@maaxyz/maa-node-darwin-arm64": "4.4.0-alpha.3",
|
|
31
|
-
"@maaxyz/maa-node-darwin-x64": "4.4.0-alpha.3",
|
|
32
|
-
"@maaxyz/maa-node-linux-arm64": "4.4.0-alpha.3",
|
|
33
|
-
"@maaxyz/maa-node-linux-x64": "4.4.0-alpha.3",
|
|
34
|
-
"@maaxyz/maa-node-win32-arm64": "4.4.0-alpha.3",
|
|
35
|
-
"@maaxyz/maa-node-win32-x64": "4.4.0-alpha.3"
|
|
30
|
+
"@maaxyz/maa-node-darwin-arm64": "4.4.0-alpha.3-post.7-ci.15747843275",
|
|
31
|
+
"@maaxyz/maa-node-darwin-x64": "4.4.0-alpha.3-post.7-ci.15747843275",
|
|
32
|
+
"@maaxyz/maa-node-linux-arm64": "4.4.0-alpha.3-post.7-ci.15747843275",
|
|
33
|
+
"@maaxyz/maa-node-linux-x64": "4.4.0-alpha.3-post.7-ci.15747843275",
|
|
34
|
+
"@maaxyz/maa-node-win32-arm64": "4.4.0-alpha.3-post.7-ci.15747843275",
|
|
35
|
+
"@maaxyz/maa-node-win32-x64": "4.4.0-alpha.3-post.7-ci.15747843275"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/context.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as maa from './maa'
|
|
2
|
-
import {
|
|
2
|
+
import { DumpTask } from './pipeline'
|
|
3
3
|
import { TaskerBase } from './tasker'
|
|
4
4
|
|
|
5
5
|
export class Context {
|
|
@@ -68,7 +68,7 @@ export class Context {
|
|
|
68
68
|
get_node_data_parsed(node_name: string) {
|
|
69
69
|
const content = this.get_node_data(node_name)
|
|
70
70
|
if (content) {
|
|
71
|
-
return JSON.parse(content) as
|
|
71
|
+
return JSON.parse(content) as DumpTask
|
|
72
72
|
} else {
|
|
73
73
|
return null
|
|
74
74
|
}
|
package/src/pipeline.ts
CHANGED
|
@@ -2,7 +2,8 @@ import type { FlatRect } from './maa'
|
|
|
2
2
|
|
|
3
3
|
type NodeName = string
|
|
4
4
|
|
|
5
|
-
type
|
|
5
|
+
type OutputRemove<T, Output> = Output extends true ? never : T
|
|
6
|
+
type MaybeArray<T, Output> = T[] | OutputRemove<T, Output>
|
|
6
7
|
type FixedArray<T, K extends number, A extends T[] = []> = A['length'] extends K
|
|
7
8
|
? A
|
|
8
9
|
: FixedArray<T, K, [...A, T]>
|
|
@@ -18,23 +19,23 @@ type OrderByMap = {
|
|
|
18
19
|
|
|
19
20
|
export type RecognitionDirectHit = {}
|
|
20
21
|
|
|
21
|
-
export type RecognitionTemplateMatch = {
|
|
22
|
+
export type RecognitionTemplateMatch<Output> = {
|
|
22
23
|
roi?: FlatRect | NodeName
|
|
23
24
|
roi_offset?: FlatRect
|
|
24
|
-
template?: MaybeArray<string>
|
|
25
|
-
template_?: MaybeArray<string> // 玛丽玛不想写, 所以多了个键
|
|
26
|
-
threshold?: MaybeArray<number>
|
|
25
|
+
template?: MaybeArray<string, Output>
|
|
26
|
+
template_?: MaybeArray<string, Output> // 玛丽玛不想写, 所以多了个键
|
|
27
|
+
threshold?: MaybeArray<number, Output>
|
|
27
28
|
order_by?: OrderByMap['TemplateMatch']
|
|
28
29
|
index?: number
|
|
29
30
|
method?: 1 | 3 | 5
|
|
30
31
|
green_mask?: boolean
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
export type RecognitionFeatureMatch = {
|
|
34
|
+
export type RecognitionFeatureMatch<Output> = {
|
|
34
35
|
roi?: FlatRect | NodeName
|
|
35
36
|
roi_offset?: FlatRect
|
|
36
|
-
template?: MaybeArray<string>
|
|
37
|
-
template_?: MaybeArray<string>
|
|
37
|
+
template?: MaybeArray<string, Output>
|
|
38
|
+
template_?: MaybeArray<string, Output>
|
|
38
39
|
count?: number
|
|
39
40
|
order_by?: OrderByMap['FeatureMatch']
|
|
40
41
|
index?: number
|
|
@@ -43,19 +44,19 @@ export type RecognitionFeatureMatch = {
|
|
|
43
44
|
ratio?: number
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
export type RecognitionColorMatch = {
|
|
47
|
+
export type RecognitionColorMatch<Output> = {
|
|
47
48
|
roi?: FlatRect | NodeName
|
|
48
49
|
roi_offset?: FlatRect
|
|
49
50
|
} & (
|
|
50
51
|
| {
|
|
51
52
|
method?: 4 | 40
|
|
52
|
-
lower?: MaybeArray<FixedArray<number, 3
|
|
53
|
-
upper?: MaybeArray<FixedArray<number, 3
|
|
53
|
+
lower?: MaybeArray<FixedArray<number, 3>, Output>
|
|
54
|
+
upper?: MaybeArray<FixedArray<number, 3>, Output>
|
|
54
55
|
}
|
|
55
56
|
| {
|
|
56
57
|
method: 6
|
|
57
|
-
lower?: MaybeArray<FixedArray<number, 1
|
|
58
|
-
upper?: MaybeArray<FixedArray<number, 1
|
|
58
|
+
lower?: MaybeArray<FixedArray<number, 1>, Output>
|
|
59
|
+
upper?: MaybeArray<FixedArray<number, 1>, Output>
|
|
59
60
|
}
|
|
60
61
|
) & {
|
|
61
62
|
count?: number
|
|
@@ -64,34 +65,34 @@ export type RecognitionColorMatch = {
|
|
|
64
65
|
connected?: boolean
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
export type RecognitionOCR = {
|
|
68
|
+
export type RecognitionOCR<Output> = {
|
|
68
69
|
roi?: FlatRect | NodeName
|
|
69
70
|
roi_offset?: FlatRect
|
|
70
|
-
expected?: MaybeArray<string>
|
|
71
|
-
threshold?: MaybeArray<number>
|
|
72
|
-
replace?: MaybeArray<FixedArray<string, 2
|
|
71
|
+
expected?: MaybeArray<string, Output>
|
|
72
|
+
threshold?: MaybeArray<number, Output>
|
|
73
|
+
replace?: MaybeArray<FixedArray<string, 2>, Output>
|
|
73
74
|
order_by?: OrderByMap['OCR']
|
|
74
75
|
index?: number
|
|
75
76
|
only_rec?: boolean
|
|
76
77
|
model?: string
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
export type RecognitionNeuralNetworkClassify = {
|
|
80
|
+
export type RecognitionNeuralNetworkClassify<Output> = {
|
|
80
81
|
roi?: FlatRect | NodeName
|
|
81
82
|
roi_offset?: FlatRect
|
|
82
83
|
labels?: string[]
|
|
83
84
|
model?: string
|
|
84
|
-
expected?: MaybeArray<number>
|
|
85
|
+
expected?: MaybeArray<number, Output>
|
|
85
86
|
order_by?: OrderByMap['NeuralNetworkClassify']
|
|
86
87
|
index?: number
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
export type RecognitionNeuralNetworkDetect = {
|
|
90
|
+
export type RecognitionNeuralNetworkDetect<Output> = {
|
|
90
91
|
roi?: FlatRect | NodeName
|
|
91
92
|
roi_offset?: FlatRect
|
|
92
93
|
labels?: string[]
|
|
93
94
|
model?: string
|
|
94
|
-
expected?: MaybeArray<number>
|
|
95
|
+
expected?: MaybeArray<number, Output>
|
|
95
96
|
threshold?: number
|
|
96
97
|
order_by?: OrderByMap['NeuralNetworkDetect']
|
|
97
98
|
index?: number
|
|
@@ -104,29 +105,38 @@ export type RecognitionCustom = {
|
|
|
104
105
|
custom_recognition_param?: unknown
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
type MixReco<Type extends string, Param> =
|
|
108
|
-
| ({
|
|
109
|
-
recognition: Type
|
|
110
|
-
} & Param)
|
|
108
|
+
type MixReco<Type extends string, Param, Output> =
|
|
111
109
|
| {
|
|
112
110
|
recognition: {
|
|
113
111
|
type: Type
|
|
114
112
|
param?: Param
|
|
115
113
|
}
|
|
116
114
|
}
|
|
115
|
+
| OutputRemove<
|
|
116
|
+
{
|
|
117
|
+
recognition: Type
|
|
118
|
+
} & Param,
|
|
119
|
+
Output
|
|
120
|
+
>
|
|
117
121
|
|
|
118
|
-
export type Recognition =
|
|
119
|
-
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
| MixReco<'
|
|
129
|
-
| MixReco<'
|
|
122
|
+
export type Recognition<Output> =
|
|
123
|
+
| OutputRemove<
|
|
124
|
+
{
|
|
125
|
+
recognition?: {
|
|
126
|
+
type?: never
|
|
127
|
+
param?: never
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
Output
|
|
131
|
+
>
|
|
132
|
+
| MixReco<'DirectHit', RecognitionDirectHit, Output>
|
|
133
|
+
| MixReco<'TemplateMatch', RecognitionTemplateMatch<Output>, Output>
|
|
134
|
+
| MixReco<'FeatureMatch', RecognitionFeatureMatch<Output>, Output>
|
|
135
|
+
| MixReco<'ColorMatch', RecognitionColorMatch<Output>, Output>
|
|
136
|
+
| MixReco<'OCR', RecognitionOCR<Output>, Output>
|
|
137
|
+
| MixReco<'NeuralNetworkClassify', RecognitionNeuralNetworkClassify<Output>, Output>
|
|
138
|
+
| MixReco<'NeuralNetworkDetect', RecognitionNeuralNetworkDetect<Output>, Output>
|
|
139
|
+
| MixReco<'Custom', RecognitionCustom, Output>
|
|
130
140
|
|
|
131
141
|
export type ActionDoNothing = {}
|
|
132
142
|
|
|
@@ -160,8 +170,8 @@ export type ActionMultiSwipe = {
|
|
|
160
170
|
}[]
|
|
161
171
|
}
|
|
162
172
|
|
|
163
|
-
export type ActionKey = {
|
|
164
|
-
key?: MaybeArray<number>
|
|
173
|
+
export type ActionKey<Output> = {
|
|
174
|
+
key?: MaybeArray<number, Output>
|
|
165
175
|
}
|
|
166
176
|
|
|
167
177
|
export type ActionInputText = {
|
|
@@ -191,10 +201,13 @@ export type ActionCustom = {
|
|
|
191
201
|
custom_action_param?: unknown
|
|
192
202
|
}
|
|
193
203
|
|
|
194
|
-
type MixAct<Type extends string, Param> =
|
|
195
|
-
|
|
|
196
|
-
|
|
197
|
-
|
|
204
|
+
type MixAct<Type extends string, Param, Output> =
|
|
205
|
+
| OutputRemove<
|
|
206
|
+
{
|
|
207
|
+
action: Type
|
|
208
|
+
} & Param,
|
|
209
|
+
Output
|
|
210
|
+
>
|
|
198
211
|
| {
|
|
199
212
|
action: {
|
|
200
213
|
type: Type
|
|
@@ -202,22 +215,28 @@ type MixAct<Type extends string, Param> =
|
|
|
202
215
|
}
|
|
203
216
|
}
|
|
204
217
|
|
|
205
|
-
export type Action =
|
|
206
|
-
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
| MixAct<'
|
|
216
|
-
| MixAct<'
|
|
217
|
-
| MixAct<'
|
|
218
|
-
| MixAct<'
|
|
219
|
-
| MixAct<'
|
|
220
|
-
| MixAct<'
|
|
218
|
+
export type Action<Output> =
|
|
219
|
+
| OutputRemove<
|
|
220
|
+
{
|
|
221
|
+
action?: {
|
|
222
|
+
type?: never
|
|
223
|
+
param?: never
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
Output
|
|
227
|
+
>
|
|
228
|
+
| MixAct<'DoNothing', ActionDoNothing, Output>
|
|
229
|
+
| MixAct<'Click', ActionClick, Output>
|
|
230
|
+
| MixAct<'LongPress', ActionLongPress, Output>
|
|
231
|
+
| MixAct<'Swipe', ActionSwipe, Output>
|
|
232
|
+
| MixAct<'MultiSwipe', ActionMultiSwipe, Output>
|
|
233
|
+
| MixAct<'Key', ActionKey<Output>, Output>
|
|
234
|
+
| MixAct<'InputText', ActionInputText, Output>
|
|
235
|
+
| MixAct<'StartApp', ActionStartApp, Output>
|
|
236
|
+
| MixAct<'StopApp', ActionStopApp, Output>
|
|
237
|
+
| MixAct<'StopTask', ActionStopTask, Output>
|
|
238
|
+
| MixAct<'Command', ActionCommand, Output>
|
|
239
|
+
| MixAct<'Custom', ActionCustom, Output>
|
|
221
240
|
|
|
222
241
|
export type WaitFreeze = {
|
|
223
242
|
time?: number
|
|
@@ -229,20 +248,29 @@ export type WaitFreeze = {
|
|
|
229
248
|
timeout?: number
|
|
230
249
|
}
|
|
231
250
|
|
|
232
|
-
export type General = {
|
|
233
|
-
next?: MaybeArray<NodeName>
|
|
234
|
-
interrupt?: MaybeArray<NodeName>
|
|
251
|
+
export type General<Output> = {
|
|
252
|
+
next?: MaybeArray<NodeName, Output>
|
|
253
|
+
interrupt?: MaybeArray<NodeName, Output>
|
|
235
254
|
is_sub?: boolean
|
|
236
255
|
rate_limit?: number
|
|
237
256
|
timeout?: number
|
|
238
|
-
on_error?: MaybeArray<string>
|
|
257
|
+
on_error?: MaybeArray<string, Output>
|
|
239
258
|
inverse?: boolean
|
|
240
259
|
enabled?: boolean
|
|
241
260
|
pre_delay?: boolean
|
|
242
261
|
post_delay?: boolean
|
|
243
|
-
pre_wait_freezes?: number | WaitFreeze
|
|
244
|
-
post_wait_freezes?: number | WaitFreeze
|
|
262
|
+
pre_wait_freezes?: OutputRemove<number, Output> | WaitFreeze
|
|
263
|
+
post_wait_freezes?: OutputRemove<number, Output> | WaitFreeze
|
|
245
264
|
focus?: unknown
|
|
246
265
|
}
|
|
247
266
|
|
|
248
|
-
export type Task = Recognition & Action & General
|
|
267
|
+
export type Task = Recognition<false> & Action<false> & General<false>
|
|
268
|
+
|
|
269
|
+
type RecursiveRequired<T> =
|
|
270
|
+
T extends Record<string, unknown>
|
|
271
|
+
? {
|
|
272
|
+
[key in keyof T]-?: RecursiveRequired<T[key]>
|
|
273
|
+
}
|
|
274
|
+
: T
|
|
275
|
+
|
|
276
|
+
export type DumpTask = RecursiveRequired<Recognition<true> & Action<true> & General<true>>
|
package/src/resource.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from './context'
|
|
2
2
|
import { Job, JobSource } from './job'
|
|
3
3
|
import maa from './maa'
|
|
4
|
-
import {
|
|
4
|
+
import { DumpTask } from './pipeline'
|
|
5
5
|
import {
|
|
6
6
|
CustomActionCallback,
|
|
7
7
|
CustomActionSelf,
|
|
@@ -159,7 +159,7 @@ export class ResourceBase {
|
|
|
159
159
|
get_node_data_parsed(node_name: string) {
|
|
160
160
|
const content = this.get_node_data(node_name)
|
|
161
161
|
if (content) {
|
|
162
|
-
return JSON.parse(content) as
|
|
162
|
+
return JSON.parse(content) as DumpTask
|
|
163
163
|
} else {
|
|
164
164
|
return null
|
|
165
165
|
}
|