@aspiresys/visor 1.3.4 → 1.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.
package/dist/types.d.ts CHANGED
@@ -31,63 +31,79 @@ export declare class Region {
31
31
  constructor(x: number, y: number, width: number, height: number, confidence?: number);
32
32
  private checkConfig;
33
33
  /**
34
- * Returns the center point of the region.
35
- *
36
- * Useful for:
37
- * - mouse movement
38
- * - coordinate calculations
39
- * - custom interactions
40
- */
34
+ * Captures a screenshot of the
35
+ * region and saves it
36
+ * to the specified path.
37
+ *
38
+ * Supported formats depend on
39
+ * the output file extension.
40
+ *
41
+ * @param path Output image path.
42
+ *
43
+ * @example
44
+ * await region.capture(
45
+ * "./screenshots/output.png"
46
+ * );
47
+ */
48
+ capture(path: string): Promise<void>;
49
+ /**
50
+ * Returns the center point of the region.
51
+ *
52
+ * Useful for:
53
+ * - mouse movement
54
+ * - coordinate calculations
55
+ * - custom interactions
56
+ */
41
57
  center(): {
42
58
  x: number;
43
59
  y: number;
44
60
  };
45
61
  /**
46
- * Moves the mouse to the center of the region.
47
- *
48
- * Mouse coordinates are automatically
49
- * adjusted for display scaling.
50
- */
62
+ * Moves the mouse to the center of the region.
63
+ *
64
+ * Mouse coordinates are automatically
65
+ * adjusted for display scaling.
66
+ */
51
67
  move(): Promise<void>;
52
68
  /**
53
- * Performs a left click on the region.
54
- *
55
- * Clicks the center of the region by default.
56
- *
57
- * Optional offset can be supplied to click
58
- * a specific position relative to the center.
59
- */
69
+ * Performs a left click on the region.
70
+ *
71
+ * Clicks the center of the region by default.
72
+ *
73
+ * Optional offset can be supplied to click
74
+ * a specific position relative to the center.
75
+ */
60
76
  click(offset?: Offset): Promise<void>;
61
77
  /**
62
- * Finds an image in the Region using OpenCV
63
- * and performs a left mouse click
64
- * on the matched region.
65
- *
66
- * @param image Optional image filename or path.
67
- *
68
- * @param confidence Match confidence threshold.
69
- *
70
- * Accepted range:
71
- * 0.0 to 1.0
72
- *
73
- * Default:
74
- * 0.8
75
- *
76
- * Recommended values:
77
- * - 0.7 for dynamic UI
78
- * - 0.8 for standard usage
79
- * - 0.9+ for strict matching
80
- *
81
- * Lower confidence increases
82
- * flexibility but may increase
83
- * false positives.
84
- *
85
- * @example
86
- * await region.clickImg("save.png");
87
- *
88
- * @example
89
- * await region.clickImg("./images/save.png", 0.9);
90
- */
78
+ * Finds an image in the Region using OpenCV
79
+ * and performs a left mouse click
80
+ * on the matched region.
81
+ *
82
+ * @param image Optional image filename or path.
83
+ *
84
+ * @param confidence Match confidence threshold.
85
+ *
86
+ * Accepted range:
87
+ * 0.0 to 1.0
88
+ *
89
+ * Default:
90
+ * 0.8
91
+ *
92
+ * Recommended values:
93
+ * - 0.7 for dynamic UI
94
+ * - 0.8 for standard usage
95
+ * - 0.9+ for strict matching
96
+ *
97
+ * Lower confidence increases
98
+ * flexibility but may increase
99
+ * false positives.
100
+ *
101
+ * @example
102
+ * await region.clickImg("save.png");
103
+ *
104
+ * @example
105
+ * await region.clickImg("./images/save.png", 0.9);
106
+ */
91
107
  clickImg(image?: string, confidence?: number, offset?: Offset): Promise<void>;
92
108
  /**
93
109
  * Finds the image in the Region and
@@ -144,144 +160,218 @@ export declare class Region {
144
160
  */
145
161
  doubleClickImg(image?: string, confidence?: number, offset?: Offset): Promise<void>;
146
162
  /**
147
- * Waits until an image appears
148
- * in the Region.
149
- *
150
- * @param image Image filename or path.
151
- *
152
- * @param confidence Match confidence threshold.
153
- *
154
- * Accepted range:
155
- * 0.0 to 1.0
156
- *
157
- * Default:
158
- * 0.8
159
- *
160
- * Recommended values:
161
- * - 0.7 for dynamic UI
162
- * - 0.8 for standard usage
163
- * - 0.9+ for strict matching
164
- *
165
- * @param timeout Timeout duration
166
- * in milliseconds.
167
- *
168
- * Default:
169
- * 5000ms
170
- *
171
- * Recommended range:
172
- * 1000ms to 30000ms
173
- *
174
- * @throws Error if timeout occurs.
175
- *
176
- * @example
177
- * await region.waitImg("loading-done.png");
178
- */
163
+ * Waits until an image appears
164
+ * in the Region.
165
+ *
166
+ * @param image Image filename or path.
167
+ *
168
+ * @param confidence Match confidence threshold.
169
+ *
170
+ * Accepted range:
171
+ * 0.0 to 1.0
172
+ *
173
+ * Default:
174
+ * 0.8
175
+ *
176
+ * Recommended values:
177
+ * - 0.7 for dynamic UI
178
+ * - 0.8 for standard usage
179
+ * - 0.9+ for strict matching
180
+ *
181
+ * @param timeout Timeout duration
182
+ * in milliseconds.
183
+ *
184
+ * Default:
185
+ * 5000ms
186
+ *
187
+ * Recommended range:
188
+ * 1000ms to 30000ms
189
+ *
190
+ * @throws Error if timeout occurs.
191
+ *
192
+ * @example
193
+ * await region.waitImg("loading-done.png");
194
+ */
179
195
  waitImg(image: string, { confidence, timeout }?: {
180
196
  confidence?: number;
181
197
  timeout?: number;
182
198
  }): Promise<boolean>;
183
199
  /**
184
- * Performs a double left click on the region.
185
- *
186
- * Optional offset can be supplied to click
187
- * a specific position relative to the center.
188
- */
200
+ * Waits until any image from
201
+ * a list appears in the Region.
202
+ *
203
+ * Useful for handling:
204
+ * - multiple themes
205
+ * - alternate UI layouts
206
+ * - dynamic application states
207
+ *
208
+ * @param images Array of image
209
+ * filenames or paths.
210
+ *
211
+ * @param confidence Match confidence threshold.
212
+ *
213
+ * Accepted range:
214
+ * 0.0 to 1.0
215
+ *
216
+ * Default:
217
+ * 0.8
218
+ *
219
+ * Recommended values:
220
+ * - 0.7 for dynamic UI
221
+ * - 0.8 for standard usage
222
+ * - 0.9+ for strict matching
223
+ *
224
+ * Lower confidence increases
225
+ * flexibility but may increase
226
+ * false positives.
227
+ *
228
+ * @param timeout Timeout duration
229
+ * in milliseconds.
230
+ *
231
+ * Default:
232
+ * 5000ms
233
+ *
234
+ * Recommended range:
235
+ * 1000ms to 30000ms
236
+ *
237
+ * @throws Error if timeout occurs.
238
+ *
239
+ * @example
240
+ * await visor.waitAnyImg([
241
+ * "home-light.png",
242
+ * "home-dark.png"
243
+ * ]);
244
+ */
245
+ waitAnyImg(images: string[], { confidence, timeout }?: {
246
+ confidence?: number;
247
+ timeout?: number;
248
+ }): Promise<Region>;
249
+ /**
250
+ * Finds the first matching image
251
+ * within the current Region and
252
+ * performs a click.
253
+ *
254
+ * Useful for:
255
+ * - theme variations
256
+ * - alternate UI states
257
+ * - dynamic controls
258
+ *
259
+ * @param images Array of image paths.
260
+ * @param confidence Match confidence.
261
+ * @param offset Optional click offset.
262
+ *
263
+ * @returns Matched Region.
264
+ *
265
+ * @example
266
+ * await region.clickAny([
267
+ * "save-light.png",
268
+ * "save-dark.png"
269
+ * ]);
270
+ */
271
+ clickAny(images: string[], confidence?: number, offset?: Offset): Promise<Region>;
272
+ /**
273
+ * Performs a double left click on the region.
274
+ *
275
+ * Optional offset can be supplied to click
276
+ * a specific position relative to the center.
277
+ */
189
278
  doubleClick(offset?: Offset): Promise<void>;
190
279
  /**
191
- * Performs a right click on the region.
192
- *
193
- * Optional offset can be supplied to click
194
- * a specific position relative to the center.
195
- */
280
+ * Performs a right click on the region.
281
+ *
282
+ * Optional offset can be supplied to click
283
+ * a specific position relative to the center.
284
+ */
196
285
  rightClick(offset?: Offset): Promise<void>;
197
286
  /**
198
- * Checks whether the supplied coordinates
199
- * are located inside this region.
200
- *
201
- * Returns:
202
- * - true if inside
203
- * - false otherwise
204
- */
287
+ * Checks whether the supplied coordinates
288
+ * are located inside this region.
289
+ *
290
+ * Returns:
291
+ * - true if inside
292
+ * - false otherwise
293
+ */
205
294
  contains(x: number, y: number): boolean;
206
295
  /**
207
- * Creates a new Region shifted by the
208
- * supplied x and y offsets.
209
- *
210
- * Original region remains unchanged.
211
- */
296
+ * Creates a new Region shifted by the
297
+ * supplied x and y offsets.
298
+ *
299
+ * Original region remains unchanged.
300
+ */
212
301
  offset(x: number, y: number): Region;
213
302
  /**
214
- * Checks whether this region overlaps
215
- * with another region.
216
- *
217
- * Returns:
218
- * - true if regions intersect
219
- * - false otherwise
220
- */
303
+ * Checks whether this region overlaps
304
+ * with another region.
305
+ *
306
+ * Returns:
307
+ * - true if regions intersect
308
+ * - false otherwise
309
+ */
221
310
  intersects(region: Region): boolean;
222
311
  /**
223
- * Returns the total area of the region
224
- * in pixels.
225
- */
312
+ * Returns the total area of the region
313
+ * in pixels.
314
+ */
226
315
  area(): number;
227
316
  /**
228
- * Extracts OCR text from this region.
229
- *
230
- * Returns full OCR output including:
231
- * - text
232
- * - TSV data
233
- * - HOCR data
234
- * - block information
235
- */
317
+ * Extracts OCR text from this region.
318
+ *
319
+ * Returns full OCR output including:
320
+ * - text
321
+ * - TSV data
322
+ * - HOCR data
323
+ * - block information
324
+ */
236
325
  readText(): Promise<any>;
237
326
  /**
238
- * Searches for text within this region.
239
- *
240
- * Returns the matching text region
241
- * if found, otherwise null.
242
- *
243
- * Supports selecting a specific match
244
- * using the index parameter.
245
- */
327
+ * Searches for text within this region.
328
+ *
329
+ * Returns the matching text region
330
+ * if found, otherwise null.
331
+ *
332
+ * Supports selecting a specific match
333
+ * using the index parameter.
334
+ */
246
335
  findText(text: string, index?: number): Promise<Region>;
247
336
  /**
248
- * Checks whether the supplied text
249
- * exists within this region.
250
- *
251
- * Returns:
252
- * - true if found
253
- * - false otherwise
254
- */
337
+ * Checks whether the supplied text
338
+ * exists within this region.
339
+ *
340
+ * Returns:
341
+ * - true if found
342
+ * - false otherwise
343
+ */
255
344
  existsText(text: string): Promise<boolean>;
256
345
  /**
257
- * Searches for an image within this region.
258
- *
259
- * Matching is performed only inside
260
- * the current region, improving speed
261
- * and reducing false positives.
262
- *
263
- * Returns:
264
- * - matching Region if found
265
- * - null otherwise
266
- */
346
+ * Searches for an image within this region.
347
+ *
348
+ * Matching is performed only inside
349
+ * the current region, improving speed
350
+ * and reducing false positives.
351
+ *
352
+ * Returns:
353
+ * - matching Region if found
354
+ * - null otherwise
355
+ */
267
356
  find(image: string, confidence?: number): Promise<Region>;
357
+ expand(pixels: number): Region;
268
358
  /**
269
- * Finds all image matches within this region.
270
- *
271
- * Matching is performed only inside
272
- * the current region.
273
- *
274
- * Returns an array of matching regions.
275
- */
359
+ * Finds all image matches within this region.
360
+ *
361
+ * Matching is performed only inside
362
+ * the current region.
363
+ *
364
+ * Returns an array of matching regions.
365
+ */
276
366
  findAll(image: string, confidence?: number): Promise<Region[]>;
277
367
  /**
278
- * Checks whether an image exists
279
- * within this region.
280
- *
281
- * Returns:
282
- * - true if found
283
- * - false otherwise
284
- */
368
+ * Checks whether an image exists
369
+ * within this region.
370
+ *
371
+ * Returns:
372
+ * - true if found
373
+ * - false otherwise
374
+ */
285
375
  exists(image: string, confidence?: number): Promise<boolean>;
286
376
  }
287
377
  /**