Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from robotjs to libnut #86

Closed
s1hofmann opened this issue Sep 25, 2019 · 6 comments
Closed

Switch from robotjs to libnut #86

s1hofmann opened this issue Sep 25, 2019 · 6 comments
Assignees
Labels
DONE Implementation is done, but not yet merged into master enhancement Enhancement to existing features

Comments

@s1hofmann
Copy link
Member

Short overview
Currently nut.js uses octalmage/robotjs, a nan module. For easier support of multiple node versions, our N-API port should be elaborated.

Use case
Easier support for multiple node modules without recompiling the native module.

Detailed description

N-API is an ABI stable C interface provided by Node.js for building native addons. It is independent from the underlying JavaScript runtime (e.g. V8 or ChakraCore) and is maintained as part of Node.js itself. It is intended to insulate native addons from changes in the underlying JavaScript engine and allow modules compiled for one version to run on later versions of Node.js without recompilation.

In @nut-tree/libnut, octalmage/robotjs has been ported to N-API, which allows to use it with any node version >= 10 without having to recompile the native module.

@s1hofmann s1hofmann added enhancement Enhancement to existing features IN PROGRESS labels Sep 25, 2019
@s1hofmann s1hofmann self-assigned this Sep 25, 2019
s1hofmann added a commit that referenced this issue Oct 5, 2019
@s1hofmann s1hofmann added DONE Implementation is done, but not yet merged into master and removed IN PROGRESS labels Oct 7, 2019
@AdrianoFerrari
Copy link

Happy to have found nut.js. Any updates on when this will be merged?
Issues with the robotjs package is the main reason I started looking for alternatives...

@s1hofmann
Copy link
Member Author

Hi @AdrianoFerrari,

with the new LTS version of node (lts/erbium), I'm about to release a new version of nut.js quite soon (next week-ish). I'm just currently finishing up on some other tasks.

For now @nut-tree/libnut is basically an N-API port of robotjs with minor changes from my side. May I ask which issues have you been dealing with?

@s1hofmann
Copy link
Member Author

@AdrianoFerrari I published nut.js v1.3.1 today which closes this issue.

@AdrianoFerrari
Copy link

Thanks, seems to install properly now on Travis for macOS and linux. Sorry I can't pinpoint what the issue was with robotjs vs libnut. Quick reading shows me that it's possible that robotjs was expecting an older JS engine (I remember the errors having something to do with "V8")...

Anyway, installs now 👍

(still having issues getting it to send keyboard commands on macOS on Travis, but that's very likely something I'm doing wrong... will keep at it).

@s1hofmann
Copy link
Member Author

@AdrianoFerrari Happy to hear! 👍

robotjs only provides prebuilt bindings up until node 8, so this might be causing errors in case a manual rebuild fails. libnut relies on N-API bindings which are compatible with any node major version >= 10 without recompiling.

Regarding errors on Travis: You might check which macOS version is used for the build. In recent versions of macOS (not 100% sure, but it might be Sierra and later) you have to explicitly grant accessibility rights to send e.g. keyboard events. On CI this might cause trouble.
Would be interested in your findings, mind updating this issue in case of news?

@AdrianoFerrari
Copy link

AdrianoFerrari commented Nov 4, 2019

You're right, macOS version seems to be the issue.

This build fails, with macOS macOS 10.14 (osx_image: xcode10.2).

This build succeeds, with macOS macOS 10.13 (osx_image: xcode10.1).

I'll post back if I find a workaround for newer macOS versions, but isn't looking promising so far...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DONE Implementation is done, but not yet merged into master enhancement Enhancement to existing features
Projects
None yet
Development

No branches or pull requests

2 participants