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

Add Node.js Support via npm for Rust Library #3

Open
x-ror opened this issue May 21, 2024 · 2 comments
Open

Add Node.js Support via npm for Rust Library #3

x-ror opened this issue May 21, 2024 · 2 comments
Assignees

Comments

@x-ror
Copy link

x-ror commented May 21, 2024

I would like to request the addition of Node.js support for this Rust library. This can be achieved by creating an npm package that allows Node.js developers to easily install and use the Rust library in their JavaScript/TypeScript projects.

@snoopy3476
Copy link
Owner

Thanks for your comment.

As the existing wasm implementation can't be ported directly to a public wasm library, I'll check what can be done at this point to port the library to a wasm version nicely.

I couldn't write it because it was not simple to convert data types between Rust and JS (except for some hacky ways), but it seems possible now.

@snoopy3476 snoopy3476 self-assigned this May 23, 2024
@snoopy3476
Copy link
Owner

I'm working on this, but it looks like the "optimal (minimal-sized)" version of wasm library (for JS/TS) is currently not available yet. 1

But if you don't mind occupying your disk a little bit more (about +100KB 2), you can use the eth-blockies@0.0.1-dev.2 package (temporary dev version) in your Node.js projects for now. 3
This dev version 0.0.1-dev.2 will remain forever, even after optimized versions are published.

Footnotes

  1. The current Rust implementation only supports const size for identicon outputs, so an output size to use must be specified before compiling a Rust code.
    This isn't much of a problem when using the library directly on Rust since library users can specify their size before compiling.
    However, a wasm file is a compiled output, so wasm codes for all size candidates must be generated and compiled into a single wasm file so that library users can choose a size they want.
    I'm thinking of adding support for runtime-sized blockies to Rust implementation first, then replacing constant functions in the JS/TS wrapper library with the new runtime ones to make the wasm file smaller.

  2. Estimated file size to be decreased after optimization

  3. It's marked as temporary version but it should make the same outputs with ones from the Rust version. "Temporary" here is mainly for JS/TS wrapper function signature (e.g. arguments or returned data type of wrapper functions can be changed dramatically on later versions), not for implementation of generator Rust functions itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants