@@ -9,6 +9,7 @@ import {timeout} from "./util/timeout.function";
99import { Image } from "./image.class" ;
1010import { ProviderRegistry } from "./provider/provider-registry.class" ;
1111import { loadImageResource } from "./imageResources.function" ;
12+ import { FirstArgumentType } from "./typings" ;
1213
1314export type FindHookCallback = ( target : MatchResult ) => Promise < void > ;
1415
@@ -80,7 +81,7 @@ export class ScreenClass {
8081 * @param params {@link LocationParameters } which are used to fine tune search region and / or match confidence
8182 */
8283 public async find (
83- templateImage : string | Image ,
84+ templateImage : string | Image | Promise < Image > ,
8485 params ?: LocationParameters ,
8586 ) : Promise < Region > {
8687 const minMatch = ( params && params . confidence ) || this . config . confidence ;
@@ -92,7 +93,7 @@ export class ScreenClass {
9293 if ( typeof templateImage === "string" ) {
9394 needle = await loadImageResource ( this . providerRegistry , this . config . resourceDirectory , templateImage ) ;
9495 } else {
95- needle = templateImage ;
96+ needle = await templateImage ;
9697 }
9798
9899 const screenImage = await this . providerRegistry . getScreen ( ) . grabScreenRegion ( searchRegion ) ;
@@ -171,7 +172,7 @@ export class ScreenClass {
171172 * @param params {@link LocationParameters } which are used to fine tune search region and / or match confidence
172173 */
173174 public async waitFor (
174- templateImage : string | Image ,
175+ templateImage : FirstArgumentType < typeof ScreenClass . prototype . find > ,
175176 timeoutMs : number = 5000 ,
176177 params ?: LocationParameters ,
177178 ) : Promise < Region > {
0 commit comments