@@ -8,8 +8,7 @@ import {MatchRequest} from "./match-request.class";
8
8
import { MatchResult } from "./match-result.class" ;
9
9
import { Region } from "./region.class" ;
10
10
import { timeout } from "./util/timeout.function" ;
11
- import { Image } from "./image.class" ;
12
- import { AbortSignal } from "node-abort-controller" ;
11
+ import { Image } from "./image.class" ;
13
12
14
13
export type FindHookCallback = ( target : MatchResult ) => Promise < void > ;
15
14
@@ -102,16 +101,16 @@ export class Screen {
102
101
) ;
103
102
104
103
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 ) {
106
105
throw new Error ( `Negative values in search region ${ search } ` )
107
106
}
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 ) ) {
109
108
throw new Error ( `NaN values in search region ${ search } ` )
110
109
}
111
- if ( search . width < 2 || search . height < 2 ) {
110
+ if ( search . width < 2 || search . height < 2 ) {
112
111
throw new Error ( `Search region ${ search } is not large enough. Must be at least two pixels in both width and height.` )
113
112
}
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 ) {
115
114
throw new Error ( `Search region ${ search } extends beyond screen boundaries (${ screen . width } x${ screen . height } )` )
116
115
}
117
116
}
@@ -166,15 +165,13 @@ export class Screen {
166
165
* @param templateImageFilename Filename of the template image, relative to {@link Screen.config.resourceDirectory}
167
166
* @param timeoutMs Timeout in milliseconds after which {@link waitFor} fails
168
167
* @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`
170
168
*/
171
169
public async waitFor (
172
170
templateImageFilename : string ,
173
171
timeoutMs : number = 5000 ,
174
172
params ?: LocationParameters ,
175
- abort ?: AbortSignal
176
173
) : 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 } ) ;
178
175
}
179
176
180
177
/**
@@ -242,8 +239,8 @@ export class Screen {
242
239
fileName : string ,
243
240
fileFormat : FileType ,
244
241
filePath : string ,
245
- fileNamePrefix : string ,
246
- fileNamePostfix : string ) {
242
+ fileNamePrefix : string ,
243
+ fileNamePostfix : string ) {
247
244
const outputPath = generateOutputPath ( fileName , {
248
245
path : filePath ,
249
246
postfix : fileNamePostfix ,
0 commit comments