@maaxyz/maa-node 4.4.0-alpha.1 → 4.4.0-alpha.3
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/client.d.ts +2 -0
- package/dist/context.d.ts +7 -1
- package/dist/index-client.js +34 -171
- package/dist/index-server.js +26 -171
- package/dist/maa.d.ts +11 -1
- package/dist/pipeline.d.ts +179 -240
- package/dist/resource.d.ts +6 -0
- package/package.json +7 -7
- package/src/client.ts +10 -0
- package/src/context.ts +16 -2
- package/src/maa.d.ts +11 -1
- package/src/pipeline.ts +228 -674
- package/src/resource.ts +14 -0
package/src/pipeline.ts
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
type
|
|
2
|
-
| 'DirectHit'
|
|
3
|
-
| 'TemplateMatch'
|
|
4
|
-
| 'FeatureMatch'
|
|
5
|
-
| 'ColorMatch'
|
|
6
|
-
| 'OCR'
|
|
7
|
-
| 'NeuralNetworkClassify'
|
|
8
|
-
| 'NeuralNetworkDetect'
|
|
9
|
-
| 'Custom'
|
|
1
|
+
import type { FlatRect } from './maa'
|
|
10
2
|
|
|
11
|
-
type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
| 'StartApp'
|
|
18
|
-
| 'StopApp'
|
|
19
|
-
| 'StopTask'
|
|
20
|
-
| 'Custom'
|
|
3
|
+
type NodeName = string
|
|
4
|
+
|
|
5
|
+
type MaybeArray<T> = T | T[]
|
|
6
|
+
type FixedArray<T, K extends number, A extends T[] = []> = A['length'] extends K
|
|
7
|
+
? A
|
|
8
|
+
: FixedArray<T, K, [...A, T]>
|
|
21
9
|
|
|
22
10
|
type OrderByMap = {
|
|
23
11
|
TemplateMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Random'
|
|
@@ -28,667 +16,233 @@ type OrderByMap = {
|
|
|
28
16
|
NeuralNetworkDetect: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random'
|
|
29
17
|
}
|
|
30
18
|
|
|
31
|
-
type
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}) &
|
|
79
|
-
('on_error' extends keyof Json
|
|
80
|
-
? {}
|
|
81
|
-
: {
|
|
82
|
-
on_error<O extends string[]>(
|
|
83
|
-
...err: [...O]
|
|
84
|
-
): PipelineBuilderState<Json & { on_error: O }>
|
|
85
|
-
}) &
|
|
86
|
-
('inverse' extends keyof Json
|
|
87
|
-
? {}
|
|
88
|
-
: {
|
|
89
|
-
inverse<I extends boolean>(inv: I): PipelineBuilderState<Json & { inverse: I }>
|
|
90
|
-
}) &
|
|
91
|
-
('enabled' extends keyof Json
|
|
92
|
-
? {}
|
|
93
|
-
: {
|
|
94
|
-
enabled<E extends boolean>(en: E): PipelineBuilderState<Json & { enabled: E }>
|
|
95
|
-
}) &
|
|
96
|
-
('pre_delay' extends keyof Json
|
|
97
|
-
? {}
|
|
98
|
-
: {
|
|
99
|
-
pre_delay<P extends number>(pre: P): PipelineBuilderState<Json & { pre_delay: P }>
|
|
100
|
-
}) &
|
|
101
|
-
('post_delay' extends keyof Json
|
|
102
|
-
? {}
|
|
103
|
-
: {
|
|
104
|
-
post_delay<P extends number>(post: P): PipelineBuilderState<Json & { post_delay: P }>
|
|
105
|
-
}) &
|
|
106
|
-
('pre_wait_freezes' extends keyof Json
|
|
107
|
-
? {}
|
|
108
|
-
: {
|
|
109
|
-
pre_wait_freezes: PipelineWaitFreezeBuilderState<Json, 'pre_wait_freezes'>
|
|
110
|
-
}) &
|
|
111
|
-
('post_wait_freezes' extends keyof Json
|
|
112
|
-
? {}
|
|
113
|
-
: {
|
|
114
|
-
post_wait_freezes: PipelineWaitFreezeBuilderState<Json, 'post_wait_freezes'>
|
|
115
|
-
}) &
|
|
116
|
-
('focus' extends keyof Json
|
|
117
|
-
? {}
|
|
118
|
-
: {
|
|
119
|
-
focus<F extends boolean>(focus: F): PipelineBuilderState<Json & { focus: F }>
|
|
120
|
-
})
|
|
19
|
+
export type RecognitionDirectHit = {}
|
|
20
|
+
|
|
21
|
+
export type RecognitionTemplateMatch = {
|
|
22
|
+
roi?: FlatRect | NodeName
|
|
23
|
+
roi_offset?: FlatRect
|
|
24
|
+
template?: MaybeArray<string>
|
|
25
|
+
template_?: MaybeArray<string> // 玛丽玛不想写, 所以多了个键
|
|
26
|
+
threshold?: MaybeArray<number>
|
|
27
|
+
order_by?: OrderByMap['TemplateMatch']
|
|
28
|
+
index?: number
|
|
29
|
+
method?: 1 | 3 | 5
|
|
30
|
+
green_mask?: boolean
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type RecognitionFeatureMatch = {
|
|
34
|
+
roi?: FlatRect | NodeName
|
|
35
|
+
roi_offset?: FlatRect
|
|
36
|
+
template?: MaybeArray<string>
|
|
37
|
+
template_?: MaybeArray<string>
|
|
38
|
+
count?: number
|
|
39
|
+
order_by?: OrderByMap['FeatureMatch']
|
|
40
|
+
index?: number
|
|
41
|
+
green_mask?: boolean
|
|
42
|
+
detector?: 'SIFT' | 'KAZE' | 'AKAZE' | 'BRISK' | 'ORB'
|
|
43
|
+
ratio?: number
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type RecognitionColorMatch = {
|
|
47
|
+
roi?: FlatRect | NodeName
|
|
48
|
+
roi_offset?: FlatRect
|
|
49
|
+
} & (
|
|
50
|
+
| {
|
|
51
|
+
method?: 4 | 40
|
|
52
|
+
lower?: MaybeArray<FixedArray<number, 3>>
|
|
53
|
+
upper?: MaybeArray<FixedArray<number, 3>>
|
|
54
|
+
}
|
|
55
|
+
| {
|
|
56
|
+
method: 6
|
|
57
|
+
lower?: MaybeArray<FixedArray<number, 1>>
|
|
58
|
+
upper?: MaybeArray<FixedArray<number, 1>>
|
|
59
|
+
}
|
|
60
|
+
) & {
|
|
61
|
+
count?: number
|
|
62
|
+
order_by?: OrderByMap['ColorMatch']
|
|
63
|
+
index?: number
|
|
64
|
+
connected?: boolean
|
|
65
|
+
}
|
|
121
66
|
|
|
122
|
-
type
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
Reco,
|
|
134
|
-
Json & { roi: R extends [number, number, number, number] ? R : R[0] }
|
|
135
|
-
>
|
|
136
|
-
}) &
|
|
137
|
-
('roi_offset' extends keyof Json
|
|
138
|
-
? {}
|
|
139
|
-
: {
|
|
140
|
-
roi_offset<R extends [number, number, number, number]>(
|
|
141
|
-
...roi: R
|
|
142
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { roi_offset: R }>
|
|
143
|
-
})) &
|
|
144
|
-
(Reco extends 'TemplateMatch' | 'FeatureMatch'
|
|
145
|
-
? 'template' extends keyof Json
|
|
146
|
-
? {}
|
|
147
|
-
: {
|
|
148
|
-
template<T extends string[]>(
|
|
149
|
-
...templ: [...T]
|
|
150
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { template: T }>
|
|
151
|
-
}
|
|
152
|
-
: {}) &
|
|
153
|
-
(Reco extends 'TemplateMatch' | 'NeuralNetworkDetect'
|
|
154
|
-
? 'threshold' extends keyof Json
|
|
155
|
-
? {}
|
|
156
|
-
: {
|
|
157
|
-
threshold<T extends number[]>(
|
|
158
|
-
...thres: [...T]
|
|
159
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { threshold: T }>
|
|
67
|
+
export type RecognitionOCR = {
|
|
68
|
+
roi?: FlatRect | NodeName
|
|
69
|
+
roi_offset?: FlatRect
|
|
70
|
+
expected?: MaybeArray<string>
|
|
71
|
+
threshold?: MaybeArray<number>
|
|
72
|
+
replace?: MaybeArray<FixedArray<string, 2>>
|
|
73
|
+
order_by?: OrderByMap['OCR']
|
|
74
|
+
index?: number
|
|
75
|
+
only_rec?: boolean
|
|
76
|
+
model?: string
|
|
77
|
+
}
|
|
160
78
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { index: T }>
|
|
182
|
-
}
|
|
183
|
-
: {}) &
|
|
184
|
-
(Reco extends 'TemplateMatch'
|
|
185
|
-
? 'method' extends keyof Json
|
|
186
|
-
? {}
|
|
187
|
-
: {
|
|
188
|
-
method<M extends 1 | 3 | 5>(
|
|
189
|
-
method: M
|
|
190
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { method: M }>
|
|
191
|
-
}
|
|
192
|
-
: {}) &
|
|
193
|
-
(Reco extends 'ColorMatch'
|
|
194
|
-
? 'method' extends keyof Json
|
|
195
|
-
? {}
|
|
196
|
-
: {
|
|
197
|
-
method<M extends 4 | 40 | 6>(
|
|
198
|
-
method: M
|
|
199
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { method: M }>
|
|
200
|
-
}
|
|
201
|
-
: {}) &
|
|
202
|
-
(Reco extends 'TemplateMatch' | 'FeatureMatch'
|
|
203
|
-
? 'green_mask' extends keyof Json
|
|
204
|
-
? {}
|
|
205
|
-
: {
|
|
206
|
-
green_mask<G extends boolean>(
|
|
207
|
-
mask: G
|
|
208
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { green_mask: G }>
|
|
209
|
-
}
|
|
210
|
-
: {}) &
|
|
211
|
-
(Reco extends 'FeatureMatch' | 'ColorMatch'
|
|
212
|
-
? 'count' extends keyof Json
|
|
213
|
-
? {}
|
|
214
|
-
: {
|
|
215
|
-
count<C extends number>(
|
|
216
|
-
count: C
|
|
217
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { count: C }>
|
|
218
|
-
}
|
|
219
|
-
: {}) &
|
|
220
|
-
(Reco extends 'FeatureMatch'
|
|
221
|
-
? 'detector' extends keyof Json
|
|
222
|
-
? {}
|
|
223
|
-
: {
|
|
224
|
-
detector<D extends 'SIFT' | 'KAZE' | 'AKAZE' | 'BRISK' | 'ORB'>(
|
|
225
|
-
det: D
|
|
226
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { detector: D }>
|
|
227
|
-
}
|
|
228
|
-
: {}) &
|
|
229
|
-
(Reco extends 'FeatureMatch'
|
|
230
|
-
? 'ratio' extends keyof Json
|
|
231
|
-
? {}
|
|
232
|
-
: {
|
|
233
|
-
ratio<R extends number>(
|
|
234
|
-
ratio: R
|
|
235
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { ratio: R }>
|
|
236
|
-
}
|
|
237
|
-
: {}) &
|
|
238
|
-
(Reco extends 'ColorMatch'
|
|
239
|
-
? 'method' extends keyof Json
|
|
240
|
-
? ('lower' extends keyof Json
|
|
241
|
-
? {}
|
|
242
|
-
: Json['method'] extends 4 | 40
|
|
243
|
-
? {
|
|
244
|
-
lower<L extends [number, number, number][]>(
|
|
245
|
-
...lower: [...L]
|
|
246
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { lower: L }>
|
|
247
|
-
}
|
|
248
|
-
: {
|
|
249
|
-
lower<L extends [number][]>(
|
|
250
|
-
...lower: [...L]
|
|
251
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { lower: L }>
|
|
252
|
-
}) &
|
|
253
|
-
('upper' extends keyof Json
|
|
254
|
-
? {}
|
|
255
|
-
: Json['method'] extends 4 | 40
|
|
256
|
-
? {
|
|
257
|
-
upper<L extends [number, number, number][]>(
|
|
258
|
-
...upper: [...L]
|
|
259
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { upper: L }>
|
|
260
|
-
}
|
|
261
|
-
: {
|
|
262
|
-
upper<U extends [number][]>(
|
|
263
|
-
...upper: [...U]
|
|
264
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { upper: U }>
|
|
265
|
-
})
|
|
266
|
-
: {}
|
|
267
|
-
: {}) &
|
|
268
|
-
(Reco extends 'ColorMatch'
|
|
269
|
-
? 'connected' extends keyof Json
|
|
270
|
-
? {}
|
|
271
|
-
: {
|
|
272
|
-
connected<C extends boolean>(
|
|
273
|
-
conn: C
|
|
274
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { connected: C }>
|
|
275
|
-
}
|
|
276
|
-
: {}) &
|
|
277
|
-
(Reco extends 'OCR'
|
|
278
|
-
? 'expected' extends keyof Json
|
|
279
|
-
? {}
|
|
280
|
-
: {
|
|
281
|
-
expected<E extends string[]>(
|
|
282
|
-
...exp: [...E]
|
|
283
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { expected: E }>
|
|
284
|
-
}
|
|
285
|
-
: {}) &
|
|
286
|
-
(Reco extends 'NeuralNetworkClassify' | 'NeuralNetworkDetect'
|
|
287
|
-
? 'expected' extends keyof Json
|
|
288
|
-
? {}
|
|
289
|
-
: {
|
|
290
|
-
expected<E extends number[]>(
|
|
291
|
-
...exp: [...E]
|
|
292
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { expected: E }>
|
|
293
|
-
}
|
|
294
|
-
: {}) &
|
|
295
|
-
(Reco extends 'OCR'
|
|
296
|
-
? 'replace' extends keyof Json
|
|
297
|
-
? {}
|
|
298
|
-
: {
|
|
299
|
-
replace<R extends [string, string][]>(
|
|
300
|
-
...exp: [...R]
|
|
301
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { replace: R }>
|
|
302
|
-
}
|
|
303
|
-
: {}) &
|
|
304
|
-
(Reco extends 'OCR'
|
|
305
|
-
? 'only_rec' extends keyof Json
|
|
306
|
-
? {}
|
|
307
|
-
: {
|
|
308
|
-
only_rec<O extends boolean>(
|
|
309
|
-
rec: O
|
|
310
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { only_rec: O }>
|
|
311
|
-
}
|
|
312
|
-
: {}) &
|
|
313
|
-
(Reco extends 'OCR' | 'NeuralNetworkClassify' | 'NeuralNetworkDetect'
|
|
314
|
-
? 'model' extends keyof Json
|
|
315
|
-
? {}
|
|
316
|
-
: {
|
|
317
|
-
model<M extends string>(
|
|
318
|
-
model: M
|
|
319
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { model: M }>
|
|
320
|
-
}
|
|
321
|
-
: {}) &
|
|
322
|
-
(Reco extends 'NeuralNetworkClassify' | 'NeuralNetworkDetect'
|
|
323
|
-
? 'labels' extends keyof Json
|
|
324
|
-
? {}
|
|
325
|
-
: {
|
|
326
|
-
labels<L extends string[]>(
|
|
327
|
-
...label: [...L]
|
|
328
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { labels: L }>
|
|
329
|
-
}
|
|
330
|
-
: {}) &
|
|
331
|
-
(Reco extends 'Custom'
|
|
332
|
-
? 'custom_recognition' extends keyof Json
|
|
333
|
-
? {}
|
|
334
|
-
: {
|
|
335
|
-
custom_recognition<C extends string>(
|
|
336
|
-
reco: C
|
|
337
|
-
): PipelineRecognitionBuilderState<PBJson, Reco, Json & { custom_recognition: C }>
|
|
338
|
-
}
|
|
339
|
-
: {}) &
|
|
340
|
-
(Reco extends 'Custom'
|
|
341
|
-
? 'custom_recognition_param' extends keyof Json
|
|
342
|
-
? {}
|
|
343
|
-
: {
|
|
344
|
-
custom_recognition_param<C extends Record<string, unknown>>(
|
|
345
|
-
param: C
|
|
346
|
-
): PipelineRecognitionBuilderState<
|
|
347
|
-
PBJson,
|
|
348
|
-
Reco,
|
|
349
|
-
Json & { custom_recognition_param: C }
|
|
350
|
-
>
|
|
351
|
-
}
|
|
352
|
-
: {})
|
|
79
|
+
export type RecognitionNeuralNetworkClassify = {
|
|
80
|
+
roi?: FlatRect | NodeName
|
|
81
|
+
roi_offset?: FlatRect
|
|
82
|
+
labels?: string[]
|
|
83
|
+
model?: string
|
|
84
|
+
expected?: MaybeArray<number>
|
|
85
|
+
order_by?: OrderByMap['NeuralNetworkClassify']
|
|
86
|
+
index?: number
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type RecognitionNeuralNetworkDetect = {
|
|
90
|
+
roi?: FlatRect | NodeName
|
|
91
|
+
roi_offset?: FlatRect
|
|
92
|
+
labels?: string[]
|
|
93
|
+
model?: string
|
|
94
|
+
expected?: MaybeArray<number>
|
|
95
|
+
threshold?: number
|
|
96
|
+
order_by?: OrderByMap['NeuralNetworkDetect']
|
|
97
|
+
index?: number
|
|
98
|
+
}
|
|
353
99
|
|
|
354
|
-
type
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
100
|
+
export type RecognitionCustom = {
|
|
101
|
+
roi?: FlatRect | NodeName
|
|
102
|
+
roi_offset?: FlatRect
|
|
103
|
+
custom_recognition?: string
|
|
104
|
+
custom_recognition_param?: unknown
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type MixReco<Type extends string, Param> =
|
|
108
|
+
| ({
|
|
109
|
+
recognition: Type
|
|
110
|
+
} & Param)
|
|
111
|
+
| {
|
|
112
|
+
recognition: {
|
|
113
|
+
type: Type
|
|
114
|
+
param?: Param
|
|
367
115
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
...offset: E
|
|
419
|
-
): PipelineActionBuilderState<PBJson, Act, Json & { end_offset: E }>
|
|
420
|
-
}
|
|
421
|
-
: {}) &
|
|
422
|
-
(Act extends 'Key'
|
|
423
|
-
? 'key' extends keyof Json
|
|
424
|
-
? {}
|
|
425
|
-
: {
|
|
426
|
-
key<K extends number[]>(
|
|
427
|
-
...key: [...K]
|
|
428
|
-
): PipelineActionBuilderState<PBJson, Act, Json & { key: K }>
|
|
429
|
-
}
|
|
430
|
-
: {}) &
|
|
431
|
-
(Act extends 'InputText'
|
|
432
|
-
? 'input_text' extends keyof Json
|
|
433
|
-
? {}
|
|
434
|
-
: {
|
|
435
|
-
input_text<T extends string>(
|
|
436
|
-
text: T
|
|
437
|
-
): PipelineActionBuilderState<PBJson, Act, Json & { input_text: T }>
|
|
438
|
-
}
|
|
439
|
-
: {}) &
|
|
440
|
-
(Act extends 'StartApp' | 'StopApp'
|
|
441
|
-
? 'package' extends keyof Json
|
|
442
|
-
? {}
|
|
443
|
-
: {
|
|
444
|
-
package<P extends string>(
|
|
445
|
-
pkg: P
|
|
446
|
-
): PipelineActionBuilderState<PBJson, Act, Json & { package: P }>
|
|
447
|
-
}
|
|
448
|
-
: {}) &
|
|
449
|
-
(Act extends 'Custom'
|
|
450
|
-
? 'custom_action' extends keyof Json
|
|
451
|
-
? {}
|
|
452
|
-
: {
|
|
453
|
-
custom_action<C extends string>(
|
|
454
|
-
act: C
|
|
455
|
-
): PipelineActionBuilderState<PBJson, Act, Json & { custom_action: C }>
|
|
456
|
-
}
|
|
457
|
-
: {}) &
|
|
458
|
-
(Act extends 'Custom'
|
|
459
|
-
? 'custom_action_param' extends keyof Json
|
|
460
|
-
? {}
|
|
461
|
-
: {
|
|
462
|
-
custom_action_param<C extends Record<string, unknown>>(
|
|
463
|
-
param: C
|
|
464
|
-
): PipelineActionBuilderState<PBJson, Act, Json & { custom_action_param: C }>
|
|
465
|
-
}
|
|
466
|
-
: {})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type Recognition =
|
|
119
|
+
| {
|
|
120
|
+
recognition?: {}
|
|
121
|
+
}
|
|
122
|
+
| MixReco<'DirectHit', RecognitionDirectHit>
|
|
123
|
+
| MixReco<'TemplateMatch', RecognitionTemplateMatch>
|
|
124
|
+
| MixReco<'FeatureMatch', RecognitionFeatureMatch>
|
|
125
|
+
| MixReco<'ColorMatch', RecognitionColorMatch>
|
|
126
|
+
| MixReco<'OCR', RecognitionOCR>
|
|
127
|
+
| MixReco<'NeuralNetworkClassify', RecognitionNeuralNetworkClassify>
|
|
128
|
+
| MixReco<'NeuralNetworkDetect', RecognitionNeuralNetworkDetect>
|
|
129
|
+
| MixReco<'Custom', RecognitionCustom>
|
|
130
|
+
|
|
131
|
+
export type ActionDoNothing = {}
|
|
132
|
+
|
|
133
|
+
export type ActionClick = {
|
|
134
|
+
target?: true | NodeName | FlatRect
|
|
135
|
+
target_offset?: FlatRect
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export type ActionLongPress = {
|
|
139
|
+
target?: true | NodeName | FlatRect
|
|
140
|
+
target_offset?: FlatRect
|
|
141
|
+
duration?: number
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export type ActionSwipe = {
|
|
145
|
+
begin?: true | NodeName | FlatRect
|
|
146
|
+
begin_offset?: FlatRect
|
|
147
|
+
end?: true | NodeName | FlatRect
|
|
148
|
+
end_offset?: FlatRect
|
|
149
|
+
duration?: number
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export type ActionMultiSwipe = {
|
|
153
|
+
swipes?: {
|
|
154
|
+
starting?: number
|
|
155
|
+
begin?: true | NodeName | FlatRect
|
|
156
|
+
begin_offset?: FlatRect
|
|
157
|
+
end?: true | NodeName | FlatRect
|
|
158
|
+
end_offset?: FlatRect
|
|
159
|
+
duration?: number
|
|
160
|
+
}[]
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export type ActionKey = {
|
|
164
|
+
key?: MaybeArray<number>
|
|
165
|
+
}
|
|
467
166
|
|
|
468
|
-
type
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
Json = {}
|
|
472
|
-
> = {
|
|
473
|
-
done: PipelineBuilderState<
|
|
474
|
-
PBJson & {
|
|
475
|
-
[key in Key]: Json
|
|
476
|
-
}
|
|
477
|
-
>
|
|
478
|
-
} & ('time' extends keyof Json
|
|
479
|
-
? {}
|
|
480
|
-
: {
|
|
481
|
-
time<T extends number>(
|
|
482
|
-
time: T
|
|
483
|
-
): PipelineWaitFreezeBuilderState<PBJson, Key, Json & { time: T }>
|
|
484
|
-
}) &
|
|
485
|
-
('target' extends keyof Json
|
|
486
|
-
? {}
|
|
487
|
-
: {
|
|
488
|
-
target<T extends [true] | [string] | [number, number, number, number]>(
|
|
489
|
-
...target: T
|
|
490
|
-
): PipelineWaitFreezeBuilderState<
|
|
491
|
-
PBJson,
|
|
492
|
-
Key,
|
|
493
|
-
Json & { target: T extends [number, number, number, number] ? T : T[0] }
|
|
494
|
-
>
|
|
495
|
-
}) &
|
|
496
|
-
('target_offset' extends keyof Json
|
|
497
|
-
? {}
|
|
498
|
-
: {
|
|
499
|
-
target_offset<O extends [number, number, number, number]>(
|
|
500
|
-
...offset: O
|
|
501
|
-
): PipelineWaitFreezeBuilderState<PBJson, Key, Json & { target_offset: O }>
|
|
502
|
-
}) &
|
|
503
|
-
('threshold' extends keyof Json
|
|
504
|
-
? {}
|
|
505
|
-
: {
|
|
506
|
-
threshold<T extends number>(
|
|
507
|
-
thres: T
|
|
508
|
-
): PipelineWaitFreezeBuilderState<PBJson, Key, Json & { threshold: T }>
|
|
509
|
-
}) &
|
|
510
|
-
('method' extends keyof Json
|
|
511
|
-
? {}
|
|
512
|
-
: {
|
|
513
|
-
method<M extends 1 | 3 | 5>(
|
|
514
|
-
met: M
|
|
515
|
-
): PipelineWaitFreezeBuilderState<PBJson, Key, Json & { method: M }>
|
|
516
|
-
}) &
|
|
517
|
-
('rate_limit' extends keyof Json
|
|
518
|
-
? {}
|
|
519
|
-
: {
|
|
520
|
-
rate_limit<R extends number>(
|
|
521
|
-
rate: R
|
|
522
|
-
): PipelineWaitFreezeBuilderState<PBJson, Key, Json & { rate_limit: R }>
|
|
523
|
-
})
|
|
167
|
+
export type ActionInputText = {
|
|
168
|
+
input_text?: string
|
|
169
|
+
}
|
|
524
170
|
|
|
525
|
-
export
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
__json: {}
|
|
529
|
-
},
|
|
530
|
-
{
|
|
531
|
-
get(target: { __json: any }, key: string) {
|
|
532
|
-
switch (key) {
|
|
533
|
-
case 'done':
|
|
534
|
-
return target.__json
|
|
535
|
-
case 'recognition':
|
|
536
|
-
return (val: unknown) => {
|
|
537
|
-
target.__json[key] = val
|
|
171
|
+
export type ActionStartApp = {
|
|
172
|
+
package?: string
|
|
173
|
+
}
|
|
538
174
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
get(sub_target: { __json: any }, sub_key: string) {
|
|
543
|
-
switch (sub_key) {
|
|
544
|
-
case 'done':
|
|
545
|
-
Object.assign(target.__json, sub_target.__json)
|
|
546
|
-
// target.__json[key] = sub_target.__json
|
|
547
|
-
return self
|
|
548
|
-
case 'threshold$':
|
|
549
|
-
case 'order_by':
|
|
550
|
-
case 'index':
|
|
551
|
-
case 'method':
|
|
552
|
-
case 'green_mask':
|
|
553
|
-
case 'count':
|
|
554
|
-
case 'detector':
|
|
555
|
-
case 'ratio':
|
|
556
|
-
case 'connected':
|
|
557
|
-
case 'only_rec':
|
|
558
|
-
case 'model':
|
|
559
|
-
case 'custom_recognition':
|
|
560
|
-
case 'custom_recognition_param':
|
|
561
|
-
return (val: unknown) => {
|
|
562
|
-
sub_target.__json[sub_key] = val
|
|
563
|
-
return sub_self
|
|
564
|
-
}
|
|
565
|
-
case 'roi':
|
|
566
|
-
return (...val: unknown[]) => {
|
|
567
|
-
sub_target.__json[sub_key] =
|
|
568
|
-
val.length === 4 ? val : val[0]
|
|
569
|
-
return sub_self
|
|
570
|
-
}
|
|
571
|
-
case 'roi_offset':
|
|
572
|
-
case 'template':
|
|
573
|
-
case 'threshold':
|
|
574
|
-
case 'lower':
|
|
575
|
-
case 'upper':
|
|
576
|
-
case 'expected':
|
|
577
|
-
case 'replace':
|
|
578
|
-
case 'labels':
|
|
579
|
-
return (...val: unknown[]) => {
|
|
580
|
-
sub_target.__json[sub_key] = val
|
|
581
|
-
return sub_self
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
return null
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
)
|
|
588
|
-
return sub_self
|
|
589
|
-
}
|
|
590
|
-
case 'action':
|
|
591
|
-
return (val: unknown) => {
|
|
592
|
-
target.__json[key] = val
|
|
175
|
+
export type ActionStopApp = {
|
|
176
|
+
package?: string
|
|
177
|
+
}
|
|
593
178
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
Object.assign(target.__json, sub_target.__json)
|
|
601
|
-
// target.__json[key] = sub_target.__json
|
|
602
|
-
return self
|
|
603
|
-
case 'key':
|
|
604
|
-
case 'input_text':
|
|
605
|
-
case 'package':
|
|
606
|
-
case 'custom_action':
|
|
607
|
-
case 'custom_action_param':
|
|
608
|
-
return (val: unknown) => {
|
|
609
|
-
sub_target.__json[sub_key] = val
|
|
610
|
-
return sub_self
|
|
611
|
-
}
|
|
612
|
-
case 'target':
|
|
613
|
-
case 'begin_target':
|
|
614
|
-
case 'end_target':
|
|
615
|
-
return (...val: unknown[]) => {
|
|
616
|
-
sub_target.__json[sub_key] =
|
|
617
|
-
val.length === 4 ? val : val[0]
|
|
618
|
-
return sub_self
|
|
619
|
-
}
|
|
620
|
-
case 'target_offset':
|
|
621
|
-
case 'begin_offset':
|
|
622
|
-
case 'end_offset':
|
|
623
|
-
return (...val: unknown[]) => {
|
|
624
|
-
sub_target.__json[sub_key] = val
|
|
625
|
-
return sub_self
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
return null
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
)
|
|
632
|
-
return sub_self
|
|
633
|
-
}
|
|
634
|
-
case 'rate_limit':
|
|
635
|
-
case 'timeout':
|
|
636
|
-
case 'inverse':
|
|
637
|
-
case 'enabled':
|
|
638
|
-
case 'pre_delay':
|
|
639
|
-
case 'post_delay':
|
|
640
|
-
case 'focus':
|
|
641
|
-
return (val: unknown) => {
|
|
642
|
-
target.__json[key] = val
|
|
643
|
-
return self
|
|
644
|
-
}
|
|
645
|
-
case 'next':
|
|
646
|
-
case 'interrupt':
|
|
647
|
-
case 'on_error':
|
|
648
|
-
return (...val: string[]) => {
|
|
649
|
-
target.__json[key] = val
|
|
650
|
-
return self
|
|
651
|
-
}
|
|
652
|
-
case 'pre_wait_freezes':
|
|
653
|
-
case 'post_wait_freezes': {
|
|
654
|
-
const sub_self: any = new Proxy(
|
|
655
|
-
{ __json: {} },
|
|
656
|
-
{
|
|
657
|
-
get(sub_target: { __json: any }, sub_key: string) {
|
|
658
|
-
switch (sub_key) {
|
|
659
|
-
case 'done':
|
|
660
|
-
target.__json[key] = sub_target.__json
|
|
661
|
-
return self
|
|
662
|
-
case 'time':
|
|
663
|
-
case 'threshold':
|
|
664
|
-
case 'method':
|
|
665
|
-
case 'rate_limit':
|
|
666
|
-
return (val: unknown) => {
|
|
667
|
-
sub_target.__json[sub_key] = val
|
|
668
|
-
return sub_self
|
|
669
|
-
}
|
|
670
|
-
case 'target':
|
|
671
|
-
return (...val: unknown[]) => {
|
|
672
|
-
sub_target.__json[sub_key] =
|
|
673
|
-
val.length === 4 ? val : val[0]
|
|
674
|
-
return sub_self
|
|
675
|
-
}
|
|
676
|
-
case 'target_offset':
|
|
677
|
-
return (...val: unknown[]) => {
|
|
678
|
-
sub_target.__json[sub_key] = val
|
|
679
|
-
return sub_self
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
return null
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
)
|
|
686
|
-
return sub_self
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
return null
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
)
|
|
693
|
-
return self
|
|
179
|
+
export type ActionStopTask = {}
|
|
180
|
+
|
|
181
|
+
export type ActionCommand = {
|
|
182
|
+
exec?: string
|
|
183
|
+
args?: string[]
|
|
184
|
+
detach?: boolean
|
|
694
185
|
}
|
|
186
|
+
|
|
187
|
+
export type ActionCustom = {
|
|
188
|
+
target?: true | NodeName | FlatRect
|
|
189
|
+
target_offset?: FlatRect
|
|
190
|
+
custom_action?: string
|
|
191
|
+
custom_action_param?: unknown
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
type MixAct<Type extends string, Param> =
|
|
195
|
+
| ({
|
|
196
|
+
action: Type
|
|
197
|
+
} & Param)
|
|
198
|
+
| {
|
|
199
|
+
action: {
|
|
200
|
+
type: Type
|
|
201
|
+
param?: Param
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export type Action =
|
|
206
|
+
| {
|
|
207
|
+
action?: {}
|
|
208
|
+
}
|
|
209
|
+
| MixAct<'DoNothing', ActionDoNothing>
|
|
210
|
+
| MixAct<'Click', ActionClick>
|
|
211
|
+
| MixAct<'LongPress', ActionLongPress>
|
|
212
|
+
| MixAct<'Swipe', ActionSwipe>
|
|
213
|
+
| MixAct<'MultiSwipe', ActionMultiSwipe>
|
|
214
|
+
| MixAct<'Key', ActionKey>
|
|
215
|
+
| MixAct<'InputText', ActionInputText>
|
|
216
|
+
| MixAct<'StartApp', ActionStartApp>
|
|
217
|
+
| MixAct<'StopApp', ActionStopApp>
|
|
218
|
+
| MixAct<'StopTask', ActionStopTask>
|
|
219
|
+
| MixAct<'Command', ActionCommand>
|
|
220
|
+
| MixAct<'Custom', ActionCustom>
|
|
221
|
+
|
|
222
|
+
export type WaitFreeze = {
|
|
223
|
+
time?: number
|
|
224
|
+
target?: true | NodeName | FlatRect
|
|
225
|
+
target_offset?: FlatRect
|
|
226
|
+
threshold?: number
|
|
227
|
+
method?: 1 | 3 | 5
|
|
228
|
+
rate_limit?: number
|
|
229
|
+
timeout?: number
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export type General = {
|
|
233
|
+
next?: MaybeArray<NodeName>
|
|
234
|
+
interrupt?: MaybeArray<NodeName>
|
|
235
|
+
is_sub?: boolean
|
|
236
|
+
rate_limit?: number
|
|
237
|
+
timeout?: number
|
|
238
|
+
on_error?: MaybeArray<string>
|
|
239
|
+
inverse?: boolean
|
|
240
|
+
enabled?: boolean
|
|
241
|
+
pre_delay?: boolean
|
|
242
|
+
post_delay?: boolean
|
|
243
|
+
pre_wait_freezes?: number | WaitFreeze
|
|
244
|
+
post_wait_freezes?: number | WaitFreeze
|
|
245
|
+
focus?: unknown
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export type Task = Recognition & Action & General
|