add wasm-backend using HTML canvas element#741
Conversation
* add wasm-backend * add wasm configuration and replace sleep * add wasm-backend
* add wasm-backend * add wasm configuration and replace sleep * add wasm-backend * fix busy_waiting * fix busy waiting * add buffer to print * add js module * change passing parameter as pointer
christoph-heiss
left a comment
There was a problem hiding this comment.
Just a shallow, quick review; currently breaks builds due to changing default features.
thank you for taking a look:) I addressed what you mentioned |
christoph-heiss
left a comment
There was a problem hiding this comment.
Apart from two more comments, looks pretty good overall!
Can also confirm that builds and tests now run through again without a problem.
|
Thanks for the work! My main concern is that the
To avoid these two points, I'd be open to a major bump for API changes if needed, maybe even making async the default way to run the loop (or an option regardless of backend). |
|
@gyscos I made run as async. Could you have another look? |
|
(I'm finally back from a family trip and have at last some time to look at this PR in more depth.) Thanks for the updates and reactivity! Looking at the code more, I think we can actually avoid breaking changes by adding a parallel code-path for async (rather than replacing the existing one). The current "sync" API could be defined as simply calling The "bare minimum" would be to have EDIT: I tried to do that in a We could then, later, add the convenient equivalent. It also looks like the As a side-question, I'm wondering if this wasm backend would work in a non-browser wasm environment (like wasmtime?). I suspect not, so I'd favor calling it Also, would it be possible to add a very simple example using this backend? I haven't found how to use wasm-pack with an example, so maybe a dedicated "example" crate would be simpler. (I'm really sorry for the back-and-forth.) |
|
@gyscos thank you for your time and effort to review this PR.
regarding test, I'll make a simple project and let you know in a week |
|
@gyscos I made a simple project(https://github.com/genieCS/hello-wasm) for tests.
|
|
@gyscos canvas is for browser but it would not be hard to make other wasm backends work. regarding |
Add WebAssembly (WASM) backend to Cursive library
This PR adds a new backend to the Cursive library that allows it to be used in WebAssembly (WASM) environments. The new backend is implemented using the
web-sys,js-syscrates and provides a way to run Cursive-based applications in the browser.To use the new backend, simply enable the
wasm-backendfeature in yourCargo.tomlfile:I made sample project using this backend, so you can see how to use this new backend.
repo link: https://github.com/genieCS/wretris
project link: https://geniecs.github.io