@aspiresys/visor 1.1.3 → 1.1.5

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/config.d.ts CHANGED
@@ -2,4 +2,5 @@ export declare const visorConfig: {
2
2
  scaleFactor: number;
3
3
  debug: boolean;
4
4
  imagePath: string;
5
+ outputPath: string;
5
6
  };
package/dist/config.js CHANGED
@@ -4,5 +4,6 @@ exports.visorConfig = void 0;
4
4
  exports.visorConfig = {
5
5
  scaleFactor: 1,
6
6
  debug: true,
7
- imagePath: ""
7
+ imagePath: "",
8
+ outputPath: ""
8
9
  };
package/dist/index.d.ts CHANGED
@@ -215,7 +215,10 @@ export declare class Visor {
215
215
  * @example
216
216
  * await visor.wait("loading-done.png");
217
217
  */
218
- wait(image: string, confidence?: number, timeout?: number): Promise<boolean>;
218
+ wait(image: string, { confidence, timeout }?: {
219
+ confidence?: number;
220
+ timeout?: number;
221
+ }): Promise<boolean>;
219
222
  /**
220
223
  * Waits until an image disappears
221
224
  * from the screen.
@@ -241,7 +244,10 @@ export declare class Visor {
241
244
  * @example
242
245
  * await visor.waitToVanish("spinner.png");
243
246
  */
244
- waitToVanish(image: string, confidence?: number, timeout?: number): Promise<boolean>;
247
+ waitToVanish(image: string, { confidence, timeout }?: {
248
+ confidence?: number;
249
+ timeout?: number;
250
+ }): Promise<boolean>;
245
251
  /**
246
252
  * Waits until specific text appears
247
253
  * on screen using OCR.
@@ -671,6 +677,27 @@ export declare class Visor {
671
677
  */
672
678
  getImagePath(): string;
673
679
  /**
680
+ * Sets the default output path
681
+ * used for visual automation APIs.
682
+ *
683
+ * @param path Output directory path.
684
+ *
685
+ * @example
686
+ * visor.setOutputPath("./images");
687
+ */
688
+ setOutputPath(path: string): void;
689
+ /**
690
+ * Returns the current default
691
+ * Output path.
692
+ *
693
+ * @returns Output path.
694
+ *
695
+ * @example
696
+ * const path =
697
+ * visor.getOutputPath();
698
+ */
699
+ getOutputPath(): string;
700
+ /**
674
701
  * Closes a desktop application
675
702
  * using Windows taskkill.
676
703
  *
@@ -707,6 +734,7 @@ export declare class Visor {
707
734
  loadConfig(config: {
708
735
  scaleFactor?: number;
709
736
  imagePath?: string;
737
+ ssOutputPath?: string;
710
738
  debug?: boolean;
711
739
  }): void;
712
740
  /**
@@ -855,7 +883,10 @@ export declare class Visor {
855
883
  * "home-dark.png"
856
884
  * ]);
857
885
  */
858
- waitAny(images: string[], confidence?: number, timeout?: number): Promise<boolean>;
886
+ waitAny(images: string[], { confidence, timeout }?: {
887
+ confidence?: number;
888
+ timeout?: number;
889
+ }): Promise<boolean>;
859
890
  /**
860
891
  * Terminates shared OCR worker.
861
892
  *
package/dist/index.js CHANGED
@@ -295,9 +295,9 @@ CONF:${m.confidence.toFixed(3)}
295
295
  * @example
296
296
  * await visor.wait("loading-done.png");
297
297
  */
298
- async wait(image, confidence = 0.8, timeout = 5000) {
298
+ async wait(image, { confidence = 0.8, timeout = 5000 } = {}) {
299
299
  const interval = 1000;
300
- const attempts = timeout / interval;
300
+ const attempts = Math.ceil(timeout / interval);
301
301
  for (let i = 0; i < attempts; i++) {
302
302
  if (await this.exists(image, confidence)) {
303
303
  return true;
@@ -331,7 +331,7 @@ CONF:${m.confidence.toFixed(3)}
331
331
  * @example
332
332
  * await visor.waitToVanish("spinner.png");
333
333
  */
334
- async waitToVanish(image, confidence = 0.8, timeout = 5000) {
334
+ async waitToVanish(image, { confidence = 0.8, timeout = 5000 } = {}) {
335
335
  const start = Date.now();
336
336
  while (Date.now() - start < timeout) {
337
337
  if (!(await this.exists(image, confidence))) {
@@ -532,6 +532,7 @@ CONF:${m.confidence.toFixed(3)}
532
532
  * );
533
533
  */
534
534
  async captureScreenshot(path) {
535
+ path = config_1.visorConfig.outputPath + "/" + path;
535
536
  console.log(`[VISOR] Saving screenshot: ${path}`);
536
537
  await (0, screen_1.saveScreenshot)(path);
537
538
  console.log("[VISOR] Screenshot saved");
@@ -837,6 +838,31 @@ CONF:${m.confidence.toFixed(3)}
837
838
  return config_1.visorConfig.imagePath;
838
839
  }
839
840
  /**
841
+ * Sets the default output path
842
+ * used for visual automation APIs.
843
+ *
844
+ * @param path Output directory path.
845
+ *
846
+ * @example
847
+ * visor.setOutputPath("./images");
848
+ */
849
+ setOutputPath(path) {
850
+ config_1.visorConfig.outputPath = path;
851
+ }
852
+ /**
853
+ * Returns the current default
854
+ * Output path.
855
+ *
856
+ * @returns Output path.
857
+ *
858
+ * @example
859
+ * const path =
860
+ * visor.getOutputPath();
861
+ */
862
+ getOutputPath() {
863
+ return config_1.visorConfig.outputPath;
864
+ }
865
+ /**
840
866
  * Closes a desktop application
841
867
  * using Windows taskkill.
842
868
  *
@@ -879,6 +905,9 @@ CONF:${m.confidence.toFixed(3)}
879
905
  if (config.imagePath) {
880
906
  this.setImagePath(config.imagePath);
881
907
  }
908
+ if (config.ssOutputPath) {
909
+ this.setOutputPath(config.ssOutputPath);
910
+ }
882
911
  if (config.debug !== undefined) {
883
912
  this.setDebug(config.debug);
884
913
  }
@@ -1059,9 +1088,9 @@ CONF:${m.confidence.toFixed(3)}
1059
1088
  * "home-dark.png"
1060
1089
  * ]);
1061
1090
  */
1062
- async waitAny(images, confidence = 0.8, timeout = 5000) {
1091
+ async waitAny(images, { confidence = 0.8, timeout = 5000 } = {}) {
1063
1092
  const interval = 1000;
1064
- const attempts = timeout / interval;
1093
+ const attempts = Math.ceil(timeout / interval);
1065
1094
  for (let i = 0; i < attempts; i++) {
1066
1095
  console.log(`[WAITANY] Attempt ${i + 1}`);
1067
1096
  for (const image of images) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aspiresys/visor",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {