Skip to content

Commit 2bc9b6a

Browse files
committed
(#341) Remove LocationParameters
1 parent 590e3c1 commit 2bc9b6a

File tree

6 files changed

+18
-28
lines changed

6 files changed

+18
-28
lines changed

index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export {RGBA} from "./lib/rgba.class";
2929
export {Key} from "./lib/key.enum";
3030
export {Button} from "./lib/button.enum";
3131
export {centerOf, randomPointIn} from "./lib/location.function";
32-
export {LocationParameters} from "./lib/locationparameters.class";
3332
export {OptionalSearchParameters} from "./lib/optionalsearchparameters.class";
3433
export {EasingFunction, linear} from "./lib/mouse-movement.function";
3534
export {Point} from "./lib/point.class";

lib/assert.class.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {LocationParameters} from "./locationparameters.class";
21
import {Region} from "./region.class";
32
import {ScreenClass} from "./screen.class";
43
import {FirstArgumentType} from "./typings";
4+
import {OptionalSearchParameters} from "./optionalsearchparameters.class";
55

66
export class AssertClass {
77
constructor(private screen: ScreenClass) {
@@ -13,7 +13,7 @@ export class AssertClass {
1313
try {
1414
await this.screen.find(
1515
needle,
16-
{searchRegion, confidence} as LocationParameters,
16+
{searchRegion, confidence} as OptionalSearchParameters,
1717
);
1818
} catch (err) {
1919
if (searchRegion !== undefined) {
@@ -32,7 +32,7 @@ export class AssertClass {
3232
try {
3333
await this.screen.find(
3434
needle,
35-
{searchRegion, confidence} as LocationParameters,
35+
{searchRegion, confidence} as OptionalSearchParameters,
3636
);
3737
} catch (err) {
3838
return;

lib/expect/matchers/toShow.function.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {LocationParameters} from "../../locationparameters.class";
21
import {ScreenClass} from "../../screen.class";
32
import {FirstArgumentType} from "../../typings";
3+
import {OptionalSearchParameters} from "../../optionalsearchparameters.class";
44

55
export const toShow = async (
66
received: ScreenClass,
@@ -9,7 +9,7 @@ export const toShow = async (
99
) => {
1010
let locationParams;
1111
if (confidence) {
12-
locationParams = new LocationParameters();
12+
locationParams = new OptionalSearchParameters();
1313
locationParams.confidence = confidence;
1414
}
1515
const identifier = (await needle).id;

lib/locationparameters.class.ts

-9
This file was deleted.

lib/screen.class.spec.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {join} from "path";
22
import {cwd} from "process";
33
import {Image} from "./image.class";
4-
import {LocationParameters} from "./locationparameters.class";
54
import {MatchRequest} from "./match-request.class";
65
import {MatchResult} from "./match-result.class";
76
import {Region} from "./region.class";
87
import {ScreenClass} from "./screen.class";
98
import {mockPartial} from "sneer";
109
import {ProviderRegistry} from "./provider/provider-registry.class";
1110
import {ImageFinderInterface, ImageWriter, ScreenProviderInterface} from "./provider";
11+
import {OptionalSearchParameters} from "./optionalsearchparameters.class";
1212

1313
jest.mock('jimp', () => {
1414
});
@@ -165,7 +165,7 @@ describe("Screen.", () => {
165165
const SUT = new ScreenClass(providerRegistryMock);
166166

167167
const needle = new Image(100, 100, Buffer.from([]), 3, "needle_image");
168-
const parameters = new LocationParameters(undefined, minMatch);
168+
const parameters = new OptionalSearchParameters(undefined, minMatch);
169169

170170
// WHEN
171171
const resultRegion = SUT.find(needle, parameters);
@@ -193,7 +193,7 @@ describe("Screen.", () => {
193193
const SUT = new ScreenClass(providerRegistryMock);
194194

195195
const needle = new Image(100, 100, Buffer.from([]), 3, "needle_image");
196-
const parameters = new LocationParameters(customSearchRegion);
196+
const parameters = new OptionalSearchParameters(customSearchRegion);
197197
const expectedMatchRequest = new MatchRequest(
198198
expect.any(Image),
199199
needle,
@@ -218,7 +218,7 @@ describe("Screen.", () => {
218218
const SUT = new ScreenClass(providerRegistryMock);
219219
const needle = new Image(100, 100, Buffer.from([]), 3, "needle_image");
220220

221-
const parameters = new LocationParameters(searchRegion, undefined, false);
221+
const parameters = new OptionalSearchParameters(searchRegion, undefined, false);
222222
const expectedMatchRequest = new MatchRequest(
223223
expect.any(Image),
224224
needle,
@@ -244,7 +244,7 @@ describe("Screen.", () => {
244244

245245
const SUT = new ScreenClass(providerRegistryMock);
246246
const needle = new Image(100, 100, Buffer.from([]), 3, "needle_image");
247-
const parameters = new LocationParameters(customSearchRegion, minMatch);
247+
const parameters = new OptionalSearchParameters(customSearchRegion, minMatch);
248248
const expectedMatchRequest = new MatchRequest(
249249
expect.any(Image),
250250
needle,
@@ -413,7 +413,7 @@ describe("Screen.", () => {
413413
const SUT = new ScreenClass(providerRegistryMock);
414414

415415
const needle = new Image(100, 100, Buffer.from([]), 3, "needle_image");
416-
const parameters = new LocationParameters(undefined, minMatch);
416+
const parameters = new OptionalSearchParameters(undefined, minMatch);
417417

418418
// WHEN
419419
const [resultRegion] = await SUT.findAll(needle, parameters);
@@ -441,7 +441,7 @@ describe("Screen.", () => {
441441
const SUT = new ScreenClass(providerRegistryMock);
442442

443443
const needle = new Image(100, 100, Buffer.from([]), 3, "needle_image");
444-
const parameters = new LocationParameters(customSearchRegion);
444+
const parameters = new OptionalSearchParameters(customSearchRegion);
445445
const expectedMatchRequest = new MatchRequest(
446446
expect.any(Image),
447447
needle,
@@ -466,7 +466,7 @@ describe("Screen.", () => {
466466
const SUT = new ScreenClass(providerRegistryMock);
467467
const needle = new Image(100, 100, Buffer.from([]), 3, "needle_image");
468468

469-
const parameters = new LocationParameters(searchRegion, undefined, false);
469+
const parameters = new OptionalSearchParameters(searchRegion, undefined, false);
470470
const expectedMatchRequest = new MatchRequest(
471471
expect.any(Image),
472472
needle,
@@ -492,7 +492,7 @@ describe("Screen.", () => {
492492

493493
const SUT = new ScreenClass(providerRegistryMock);
494494
const needle = new Image(100, 100, Buffer.from([]), 3, "needle_image");
495-
const parameters = new LocationParameters(customSearchRegion, minMatch);
495+
const parameters = new OptionalSearchParameters(customSearchRegion, minMatch);
496496
const expectedMatchRequest = new MatchRequest(
497497
expect.any(Image),
498498
needle,

lib/screen.class.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {cwd} from "process";
22
import {FileType} from "./file-type.enum";
33
import {generateOutputPath} from "./generate-output-path.function";
4-
import {LocationParameters} from "./locationparameters.class";
54
import {MatchRequest} from "./match-request.class";
65
import {MatchResult} from "./match-result.class";
76
import {Region} from "./region.class";
@@ -10,6 +9,7 @@ import {Image} from "./image.class";
109
import {ProviderRegistry} from "./provider/provider-registry.class";
1110
import {FirstArgumentType} from "./typings";
1211
import {Point} from "./point.class";
12+
import {OptionalSearchParameters} from "./optionalsearchparameters.class";
1313

1414
export type FindHookCallback = (target: MatchResult) => Promise<void>;
1515

@@ -97,7 +97,7 @@ export class ScreenClass {
9797
*/
9898
public async find(
9999
template: Image | Promise<Image>,
100-
params?: LocationParameters,
100+
params?: OptionalSearchParameters,
101101
): Promise<Region> {
102102
const minMatch = (params && params.confidence) || this.config.confidence;
103103
const screenSize = await this.providerRegistry.getScreen().screenSize();
@@ -149,7 +149,7 @@ export class ScreenClass {
149149
*/
150150
public async findAll(
151151
template: FirstArgumentType<typeof ScreenClass.prototype.find>,
152-
params?: LocationParameters,
152+
params?: OptionalSearchParameters,
153153
): Promise<Region[]> {
154154
const minMatch = (params && params.confidence) || this.config.confidence;
155155
const screenSize = await this.providerRegistry.getScreen().screenSize();
@@ -220,7 +220,7 @@ export class ScreenClass {
220220
templateImage: FirstArgumentType<typeof ScreenClass.prototype.find>,
221221
timeoutMs: number = 5000,
222222
updateInterval: number = 500,
223-
params?: LocationParameters,
223+
params?: OptionalSearchParameters,
224224
): Promise<Region> {
225225
return timeout(updateInterval, timeoutMs, () => this.find(templateImage, params), {signal: params?.abort});
226226
}

0 commit comments

Comments
 (0)