@@ -8,8 +8,7 @@ import {MatchRequest} from "./match-request.class";
88import { MatchResult } from "./match-result.class" ;
99import { Region } from "./region.class" ;
1010import { timeout } from "./util/timeout.function" ;
11- import { Image } from "./image.class" ;
12- import { AbortSignal } from "node-abort-controller" ;
11+ import { Image } from "./image.class" ;
1312
1413export type FindHookCallback = ( target : MatchResult ) => Promise < void > ;
1514
@@ -102,16 +101,16 @@ export class Screen {
102101 ) ;
103102
104103 function validateSearchRegion ( search : Region , screen : Region ) {
105- if ( search . left < 0 || search . top < 0 || search . width < 0 || search . height < 0 ) {
104+ if ( search . left < 0 || search . top < 0 || search . width < 0 || search . height < 0 ) {
106105 throw new Error ( `Negative values in search region ${ search } ` )
107106 }
108- if ( isNaN ( search . left ) || isNaN ( search . top ) || isNaN ( search . width ) || isNaN ( search . height ) ) {
107+ if ( isNaN ( search . left ) || isNaN ( search . top ) || isNaN ( search . width ) || isNaN ( search . height ) ) {
109108 throw new Error ( `NaN values in search region ${ search } ` )
110109 }
111- if ( search . width < 2 || search . height < 2 ) {
110+ if ( search . width < 2 || search . height < 2 ) {
112111 throw new Error ( `Search region ${ search } is not large enough. Must be at least two pixels in both width and height.` )
113112 }
114- if ( search . left + search . width > screen . width || search . top + search . height > screen . height ) {
113+ if ( search . left + search . width > screen . width || search . top + search . height > screen . height ) {
115114 throw new Error ( `Search region ${ search } extends beyond screen boundaries (${ screen . width } x${ screen . height } )` )
116115 }
117116 }
@@ -166,15 +165,13 @@ export class Screen {
166165 * @param templateImageFilename Filename of the template image, relative to {@link Screen.config.resourceDirectory}
167166 * @param timeoutMs Timeout in milliseconds after which {@link waitFor} fails
168167 * @param params {@link LocationParameters } which are used to fine tune search region and / or match confidence
169- * @param abort An {@link AbortSignal} to cancel an ongoing call to `waitFor`
170168 */
171169 public async waitFor (
172170 templateImageFilename : string ,
173171 timeoutMs : number = 5000 ,
174172 params ?: LocationParameters ,
175- abort ?: AbortSignal
176173 ) : Promise < Region > {
177- return timeout ( 500 , timeoutMs , ( ) => this . find ( templateImageFilename , params ) , { signal : abort } ) ;
174+ return timeout ( 500 , timeoutMs , ( ) => this . find ( templateImageFilename , params ) , { signal : params ?. abort } ) ;
178175 }
179176
180177 /**
@@ -242,8 +239,8 @@ export class Screen {
242239 fileName : string ,
243240 fileFormat : FileType ,
244241 filePath : string ,
245- fileNamePrefix : string ,
246- fileNamePostfix : string ) {
242+ fileNamePrefix : string ,
243+ fileNamePostfix : string ) {
247244 const outputPath = generateOutputPath ( fileName , {
248245 path : filePath ,
249246 postfix : fileNamePostfix ,
0 commit comments