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

WebAssembly Bindings #42

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

WebAssembly Bindings #42

wants to merge 6 commits into from

Conversation

Michael-F-Bryan
Copy link

This PR fixes #39 by introducing a wasm crate which exposes a simplified version of similar's API to WebAssembly. The simplified API is defined in wasm/similar.wit and can be used by wit-bindgen to generate bindings for various other languages.

The code is fairly straightforward, although we needed to pull in ouroboros so the text being diffed and its results could be stored in the same 'static struct (TextDiff).

For now, I've published the package to wapm.dev under Michael-F-Bryan/similar, but that can be changed by updating the namespace = "..." bit in wasm/Cargo.toml.

I also added a CI job to automatically publish a new version to WAPM whenever a tagged commit is pushed to this repo. It might be useful if forgetting to publish to WAPM is a concern, otherwise we can easily remove .github/workflows/releases.yml.

@mitsuhiko
Copy link
Owner

Thank you! I will have a look at this over the weekend. The package itself and the code changes are fine, I'm super unsure about how to best publish this. I think if this ends up in the package I might as well bite the bullet and publish this to wapm.

@Michael-F-Bryan
Copy link
Author

I'm super unsure about how to best publish this

The easiest way to publish Rust packages to WAPM is with the cargo wapm subcommand. It's a thin wrapper around the wapm CLI which uses information from your Cargo.toml to figure out how to build your crate and generate the wapm.toml file.

Otherwise, you can publish to WAPM directly by following these instructions.

I also wrote up an explanatory blog post about how publishing to WAPM via the wapm CLI and cargo wapm works.

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

Successfully merging this pull request may close these issues.

WIT Bindings + WAPM
2 participants