@maaxyz/maa-node 0.0.1-alpha.2

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/maatouch/universal/maatouch +0 -0
  2. package/agent/minicap/arm64-v8a/bin/minicap +0 -0
  3. package/agent/minicap/arm64-v8a/bin/minicap-nopie +0 -0
  4. package/agent/minicap/arm64-v8a/lib/android-21/minicap.so +0 -0
  5. package/agent/minicap/arm64-v8a/lib/android-22/minicap.so +0 -0
  6. package/agent/minicap/arm64-v8a/lib/android-23/minicap.so +0 -0
  7. package/agent/minicap/arm64-v8a/lib/android-24/minicap.so +0 -0
  8. package/agent/minicap/arm64-v8a/lib/android-25/minicap.so +0 -0
  9. package/agent/minicap/arm64-v8a/lib/android-26/minicap.so +0 -0
  10. package/agent/minicap/arm64-v8a/lib/android-27/minicap.so +0 -0
  11. package/agent/minicap/arm64-v8a/lib/android-28/minicap.so +0 -0
  12. package/agent/minicap/arm64-v8a/lib/android-29/minicap +0 -0
  13. package/agent/minicap/arm64-v8a/lib/android-29/minicap-nopie +0 -0
  14. package/agent/minicap/arm64-v8a/lib/android-29/minicap.so +0 -0
  15. package/agent/minicap/arm64-v8a/lib/android-30/minicap.so +0 -0
  16. package/agent/minicap/arm64-v8a/lib/android-31/minicap.so +0 -0
  17. package/agent/minicap/armeabi-v7a/bin/minicap +0 -0
  18. package/agent/minicap/armeabi-v7a/bin/minicap-nopie +0 -0
  19. package/agent/minicap/armeabi-v7a/lib/android-10/minicap.so +0 -0
  20. package/agent/minicap/armeabi-v7a/lib/android-14/minicap.so +0 -0
  21. package/agent/minicap/armeabi-v7a/lib/android-15/minicap.so +0 -0
  22. package/agent/minicap/armeabi-v7a/lib/android-16/minicap.so +0 -0
  23. package/agent/minicap/armeabi-v7a/lib/android-17/minicap.so +0 -0
  24. package/agent/minicap/armeabi-v7a/lib/android-18/minicap.so +0 -0
  25. package/agent/minicap/armeabi-v7a/lib/android-19/minicap.so +0 -0
  26. package/agent/minicap/armeabi-v7a/lib/android-21/minicap.so +0 -0
  27. package/agent/minicap/armeabi-v7a/lib/android-22/minicap.so +0 -0
  28. package/agent/minicap/armeabi-v7a/lib/android-23/minicap.so +0 -0
  29. package/agent/minicap/armeabi-v7a/lib/android-24/minicap.so +0 -0
  30. package/agent/minicap/armeabi-v7a/lib/android-25/minicap.so +0 -0
  31. package/agent/minicap/armeabi-v7a/lib/android-26/minicap.so +0 -0
  32. package/agent/minicap/armeabi-v7a/lib/android-27/minicap.so +0 -0
  33. package/agent/minicap/armeabi-v7a/lib/android-28/minicap.so +0 -0
  34. package/agent/minicap/armeabi-v7a/lib/android-29/minicap +0 -0
  35. package/agent/minicap/armeabi-v7a/lib/android-29/minicap-nopie +0 -0
  36. package/agent/minicap/armeabi-v7a/lib/android-29/minicap.so +0 -0
  37. package/agent/minicap/armeabi-v7a/lib/android-30/minicap.so +0 -0
  38. package/agent/minicap/armeabi-v7a/lib/android-31/minicap.so +0 -0
  39. package/agent/minicap/armeabi-v7a/lib/android-9/minicap.so +0 -0
  40. package/agent/minicap/x86/bin/minicap +0 -0
  41. package/agent/minicap/x86/bin/minicap-nopie +0 -0
  42. package/agent/minicap/x86/lib/android-14/minicap.so +0 -0
  43. package/agent/minicap/x86/lib/android-15/minicap.so +0 -0
  44. package/agent/minicap/x86/lib/android-16/minicap.so +0 -0
  45. package/agent/minicap/x86/lib/android-17/minicap.so +0 -0
  46. package/agent/minicap/x86/lib/android-18/minicap.so +0 -0
  47. package/agent/minicap/x86/lib/android-19/minicap.so +0 -0
  48. package/agent/minicap/x86/lib/android-21/minicap.so +0 -0
  49. package/agent/minicap/x86/lib/android-22/minicap.so +0 -0
  50. package/agent/minicap/x86/lib/android-23/minicap.so +0 -0
  51. package/agent/minicap/x86/lib/android-24/minicap.so +0 -0
  52. package/agent/minicap/x86/lib/android-25/minicap.so +0 -0
  53. package/agent/minicap/x86/lib/android-26/minicap.so +0 -0
  54. package/agent/minicap/x86/lib/android-27/minicap.so +0 -0
  55. package/agent/minicap/x86/lib/android-28/minicap.so +0 -0
  56. package/agent/minicap/x86/lib/android-29/minicap +0 -0
  57. package/agent/minicap/x86/lib/android-29/minicap-nopie +0 -0
  58. package/agent/minicap/x86/lib/android-29/minicap.so +0 -0
  59. package/agent/minicap/x86/lib/android-31/minicap.so +0 -0
  60. package/agent/minicap/x86_64/bin/minicap +0 -0
  61. package/agent/minicap/x86_64/bin/minicap-nopie +0 -0
  62. package/agent/minicap/x86_64/lib/android-21/minicap.so +0 -0
  63. package/agent/minicap/x86_64/lib/android-22/minicap.so +0 -0
  64. package/agent/minicap/x86_64/lib/android-23/minicap.so +0 -0
  65. package/agent/minicap/x86_64/lib/android-24/minicap.so +0 -0
  66. package/agent/minicap/x86_64/lib/android-25/minicap.so +0 -0
  67. package/agent/minicap/x86_64/lib/android-26/minicap.so +0 -0
  68. package/agent/minicap/x86_64/lib/android-27/minicap.so +0 -0
  69. package/agent/minicap/x86_64/lib/android-28/minicap.so +0 -0
  70. package/agent/minicap/x86_64/lib/android-29/minicap +0 -0
  71. package/agent/minicap/x86_64/lib/android-29/minicap-nopie +0 -0
  72. package/agent/minicap/x86_64/lib/android-29/minicap.so +0 -0
  73. package/agent/minicap/x86_64/lib/android-31/minicap.so +0 -0
  74. package/agent/minitouch/arm64-v8a/minitouch +0 -0
  75. package/agent/minitouch/armeabi/minitouch +0 -0
  76. package/agent/minitouch/armeabi-v7a/minitouch +0 -0
  77. package/agent/minitouch/x86/minitouch +0 -0
  78. package/agent/minitouch/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 +1028 -0
  84. package/dist/job.d.ts +23 -0
  85. package/dist/maa.d.ts +376 -0
  86. package/dist/pi.d.ts +9 -0
  87. package/dist/pipeline.d.ts +249 -0
  88. package/dist/resource.d.ts +36 -0
  89. package/dist/tasker.d.ts +128 -0
  90. package/dist/types.d.ts +27 -0
  91. package/package.json +33 -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 +376 -0
  99. package/src/maa.js +27 -0
  100. package/src/pi.ts +62 -0
  101. package/src/pipeline.ts +694 -0
  102. package/src/resource.ts +173 -0
  103. package/src/tasker.ts +231 -0
  104. package/src/types.ts +31 -0
  105. package/tsconfig.json +9 -0
@@ -0,0 +1,694 @@
1
+ type RecoType =
2
+ | 'DirectHit'
3
+ | 'TemplateMatch'
4
+ | 'FeatureMatch'
5
+ | 'ColorMatch'
6
+ | 'OCR'
7
+ | 'NeuralNetworkClassify'
8
+ | 'NeuralNetworkDetect'
9
+ | 'Custom'
10
+
11
+ type ActType =
12
+ | 'DoNothing'
13
+ | 'Click'
14
+ | 'Swipe'
15
+ | 'Key'
16
+ | 'Text'
17
+ | 'StartApp'
18
+ | 'StopApp'
19
+ | 'StopTask'
20
+ | 'Custom'
21
+
22
+ type OrderByMap = {
23
+ TemplateMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Random'
24
+ FeatureMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random'
25
+ ColorMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random'
26
+ OCR: 'Horizontal' | 'Vertical' | 'Area' | 'Length' | 'Random'
27
+ NeuralNetworkClassify: 'Horizontal' | 'Vertical' | 'Score' | 'Random'
28
+ NeuralNetworkDetect: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random'
29
+ }
30
+
31
+ type PipelineBuilderState<Json = {}> = {
32
+ done: Json
33
+ } & ('recognition' extends keyof Json
34
+ ? {}
35
+ : {
36
+ recognition<R extends RecoType>(
37
+ reco: R
38
+ ): PipelineRecognitionBuilderState<
39
+ Json & {
40
+ recognition: R
41
+ },
42
+ R
43
+ >
44
+ }) &
45
+ ('action' extends keyof Json
46
+ ? {}
47
+ : {
48
+ action<A extends ActType>(
49
+ act: A
50
+ ): PipelineActionBuilderState<
51
+ Json & {
52
+ action: A
53
+ },
54
+ A
55
+ >
56
+ }) &
57
+ ('next' extends keyof Json
58
+ ? {}
59
+ : {
60
+ next<N extends string[]>(...nxt: [...N]): PipelineBuilderState<Json & { next: N }>
61
+ }) &
62
+ ('interrupt' extends keyof Json
63
+ ? {}
64
+ : {
65
+ interrupt<I extends string[]>(
66
+ ...int: [...I]
67
+ ): PipelineBuilderState<Json & { interrupt: I }>
68
+ }) &
69
+ ('rate_limit' extends keyof Json
70
+ ? {}
71
+ : {
72
+ rate_limit<R extends number>(rate: R): PipelineBuilderState<Json & { rate_limit: R }>
73
+ }) &
74
+ ('timeout' extends keyof Json
75
+ ? {}
76
+ : {
77
+ timeout<R extends number>(time: R): PipelineBuilderState<Json & { timeout: R }>
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
+ })
121
+
122
+ type PipelineRecognitionBuilderState<PBJson, Reco extends RecoType, Json = {}> = {
123
+ done: PipelineBuilderState<PBJson & Json>
124
+ } & (Reco extends 'DirectHit'
125
+ ? {}
126
+ : ('roi' extends keyof Json
127
+ ? {}
128
+ : {
129
+ roi<R extends [string] | [number, number, number, number]>(
130
+ ...roi: R
131
+ ): PipelineRecognitionBuilderState<
132
+ PBJson,
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 }>
160
+
161
+ threshold$<T extends number>(
162
+ thres: T
163
+ ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { threshold: T }>
164
+ }
165
+ : {}) &
166
+ (Reco extends keyof OrderByMap
167
+ ? 'order_by' extends keyof Json
168
+ ? {}
169
+ : {
170
+ order_by<O extends OrderByMap[Reco]>(
171
+ order: O
172
+ ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { order_by: O }>
173
+ }
174
+ : {}) &
175
+ (Reco extends keyof OrderByMap
176
+ ? 'index' extends keyof Json
177
+ ? {}
178
+ : {
179
+ index<T extends number>(
180
+ idx: T
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
+ : {})
353
+
354
+ type PipelineActionBuilderState<PBJson, Act extends ActType, Json = {}> = {
355
+ done: PipelineBuilderState<PBJson & Json>
356
+ } & (Act extends 'Click' | 'Custom'
357
+ ? 'target' extends keyof Json
358
+ ? {}
359
+ : {
360
+ target<T extends [true] | [string] | [number, number, number, number]>(
361
+ ...target: T
362
+ ): PipelineActionBuilderState<
363
+ PBJson,
364
+ Act,
365
+ Json & { target: T extends [number, number, number, number] ? T : T[0] }
366
+ >
367
+ }
368
+ : {}) &
369
+ (Act extends 'Click' | 'Custom'
370
+ ? 'target_offset' extends keyof Json
371
+ ? {}
372
+ : {
373
+ target_offset<O extends [number, number, number, number]>(
374
+ ...offset: O
375
+ ): PipelineActionBuilderState<PBJson, Act, Json & { target_offset: O }>
376
+ }
377
+ : {}) &
378
+ (Act extends 'Swipe'
379
+ ? 'begin' extends keyof Json
380
+ ? {}
381
+ : {
382
+ begin<B extends [true] | [string] | [number, number, number, number]>(
383
+ ...begin: B
384
+ ): PipelineActionBuilderState<
385
+ PBJson,
386
+ Act,
387
+ Json & { begin: B extends [number, number, number, number] ? B : B[0] }
388
+ >
389
+ }
390
+ : {}) &
391
+ (Act extends 'Swipe'
392
+ ? 'begin_offset' extends keyof Json
393
+ ? {}
394
+ : {
395
+ begin_offset<B extends [number, number, number, number]>(
396
+ ...offset: B
397
+ ): PipelineActionBuilderState<PBJson, Act, Json & { begin_offset: B }>
398
+ }
399
+ : {}) &
400
+ (Act extends 'Swipe'
401
+ ? 'end' extends keyof Json
402
+ ? {}
403
+ : {
404
+ end<E extends [true] | [string] | [number, number, number, number]>(
405
+ ...end: E
406
+ ): PipelineActionBuilderState<
407
+ PBJson,
408
+ Act,
409
+ Json & { end: E extends [number, number, number, number] ? E : E[0] }
410
+ >
411
+ }
412
+ : {}) &
413
+ (Act extends 'Swipe'
414
+ ? 'end_offset' extends keyof Json
415
+ ? {}
416
+ : {
417
+ end_offset<E extends [number, number, number, number]>(
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
+ : {})
467
+
468
+ type PipelineWaitFreezeBuilderState<
469
+ PBJson,
470
+ Key extends 'pre_wait_freezes' | 'post_wait_freezes',
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
+ })
524
+
525
+ export function pp(): PipelineBuilderState {
526
+ const self: any = new Proxy(
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
538
+
539
+ const sub_self: any = new Proxy(
540
+ { __json: {} },
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
593
+
594
+ const sub_self: any = new Proxy(
595
+ { __json: {} },
596
+ {
597
+ get(sub_target: { __json: any }, sub_key: string) {
598
+ switch (sub_key) {
599
+ case 'done':
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
694
+ }