2.0.0

Migration paths to nut.js 2.0.0

Breaking changes introduced with nut.js version 2.0.0

ImageFinder Providers

@nut-tree/nut-js introduced a plugin system and no longer ships image matching code by default.
To use image matching functionality one will have to install an additional package, providing the actual implementation to perform image comparison.
Otherwise, all functions relying on image matching will throw an error like Error: No ImageFinder registered.

One available option would be @nut-tree/template-matcher:

If you want to keep using your existing setup, install a suitable provider, e.g. above mentioned package.

1npm i @nut-tree/template-matcher

To use this provider package, simply require it in your code, e.g. index.js:

1const { screen } = require("@nut-tree/nut-js");
2require("@nut-tree/template-matcher"); // THIS IS NEW

Screen.find

Template Images

Template images are no longer loaded from screen.config.resourceDirectory by default.
Instead, an Image has to be passed.

If you want to keep using your existing setup, you can wrap the image filename in a call to imageResource.

1// Pre 2.0.0
2const image = await screen.find("file.png");
3
4// 2.0.0
5const image = await screen.find(imageResource("file.png"));

Screen.waitFor

Template Images

Template images are no longer loaded from screen.config.resourceDirectory by default.
Instead, an Image has to be passed.

If you want to keep using your existing setup, you can wrap the image filename in a call to imageResource.

1// Pre 2.0.0
2const image = await screen.waitFor("file.png", 3000);
3
4// 2.0.0
5const image = await screen.waitFor(imageResource("file.png"), 3000);

Configurable interval

The update interval used by waitFor used to be fixed to 500ms.

With release 2.0.0, waitFor received an additional parameter to configure this interval.

If you want to keep using your existing setup, pass an interval of 500ms to waitFor.

1// Pre 2.0.0
2const image = await screen.waitFor("file.png", 3000, {searchRegion: new Region(100, 100, 100, 100)});
3
4// 2.0.0
5const image = await screen.waitFor("file.png", 3000, 500, {searchRegion: new Region(100, 100, 100, 100)});

LocationParameters

The LocationParameters object has been dropped. Please use OptionalSearchParameters instead.


© 2022