buttplugio / buttplug-rs-ffi

FFI from buttplug-rs to Java and other languages
Other
89 stars 22 forks source link

Add node native bindings and prebuild #83

Open itsame-luigi opened 3 years ago

itsame-luigi commented 3 years ago

This adds native bindings for NodeJS, instead of depending on a WASM build. The WASM build is still used for the browser. I also added a script to run on npm install that will fetch a specific release build (configured in package.json as "ffi-version").

Also, it is no longer necessary to invoke buttplugInit() in NodeJS (though it is still necessary in the browser).

There are a few things that still need to be worked out and tested:

itsame-luigi commented 3 years ago

I've made some progress on this, and done some additional cleanup on the js side. I've removed the parts of modularize.cjs that dealt with WASM functionality in NodeJS that I added in #80, since WASM is no longer used for NodeJS. I've also changed the browser-specific build outputs back to ./dist/web/... to keep the URL consistent for anyone loading via CDN.

I've also reorganized the scripts in package.json to break things down by build task, and added some clean tasks to make it easier to get back to a clean JS environment.

With these changes, the web output should be mostly unchanged from what it was prior to #80, except for a minor source path change as I moved src/buttplug-rs-ffi to src/web/buttplug-rs-ffi to keep the "node"- and "web"-specific components isolated from each other.

I need to run a few more tests in NodeJS by installing the package on various OSes (probably by packing it into a tarball to avoid needing to publish to npm), but the overall design should be fairly solid now.

itsame-luigi commented 3 years ago

Also, it seems the "Core Library + Nuget" builds are failing though I haven't made any changes that should be causing those errors. I'm not sure if its just because its a PR from a forked repository, or if there's some other reason for the failure.

It does look like the CI setup needs to include a scenario for building/testing JS.

itsame-luigi commented 3 years ago

@qdot, I think this is as ready as I can make it, if you're able to review.

I can't test the new Nodejs bindings on MacOS, but I've tested it on Windows. I can try and see if it works on Linux via WSL, but I don't have any physical hardware with Linux+Bluetooth aside from WSL.

qdot commented 3 years ago

Great, thanks for letting me know! Right now I'm neck deep in trying to release buttplug v5, but once that's done I'm hoping to take a look at this. I've got all 3 platforms running on dedicated hardware so I can test those too.