@@ -9,6 +9,7 @@ import {timeout} from "./util/timeout.function";
9
9
import { Image } from "./image.class" ;
10
10
import { ProviderRegistry } from "./provider/provider-registry.class" ;
11
11
import { loadImageResource } from "./imageResources.function" ;
12
+ import { FirstArgumentType } from "./typings" ;
12
13
13
14
export type FindHookCallback = ( target : MatchResult ) => Promise < void > ;
14
15
@@ -80,7 +81,7 @@ export class ScreenClass {
80
81
* @param params {@link LocationParameters } which are used to fine tune search region and / or match confidence
81
82
*/
82
83
public async find (
83
- templateImage : string | Image ,
84
+ templateImage : string | Image | Promise < Image > ,
84
85
params ?: LocationParameters ,
85
86
) : Promise < Region > {
86
87
const minMatch = ( params && params . confidence ) || this . config . confidence ;
@@ -92,7 +93,7 @@ export class ScreenClass {
92
93
if ( typeof templateImage === "string" ) {
93
94
needle = await loadImageResource ( this . providerRegistry , this . config . resourceDirectory , templateImage ) ;
94
95
} else {
95
- needle = templateImage ;
96
+ needle = await templateImage ;
96
97
}
97
98
98
99
const screenImage = await this . providerRegistry . getScreen ( ) . grabScreenRegion ( searchRegion ) ;
@@ -171,7 +172,7 @@ export class ScreenClass {
171
172
* @param params {@link LocationParameters } which are used to fine tune search region and / or match confidence
172
173
*/
173
174
public async waitFor (
174
- templateImage : string | Image ,
175
+ templateImage : FirstArgumentType < typeof ScreenClass . prototype . find > ,
175
176
timeoutMs : number = 5000 ,
176
177
params ?: LocationParameters ,
177
178
) : Promise < Region > {
0 commit comments