The module binding code compile to wasm failed.
I try to use Dioxus and SpacetimeDB together. Dioxus compile rust code to wasm and run in browser. The module binding code compile failed, because of the openssl crate can't compile to wasm.
a lot of errors like this:
[cargo] error[E0412]: cannot find type `c_int` in this scope
--> /Users/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/openssl-sys-0.9.107/src/./obj_mac.rs:752:33
|
752 | pub const NID_setct_CapReqTBSX: c_int = 545;
| ^^^^^ not found in this scope
|
help: consider importing one of these type aliases
I found the pr about wasm: https://github.com/clockworklabs/SpacetimeDB/pull/1700 Does it means that I have to wait the pr be merged, or any other way?
Hi @lydiandy, we don't currently have experience with using Dioxus with SpacetimeDB in this way. As you say, there's already a PR to remove the openssl dependency, so I don't think we have other suggestions for you.
Could you tell us a bit more about your use case? Are you trying to run the SpacetimeDB server itself in a browser?
@bfops, I just try to use Dioxus as client, SpacetimeDB still as backend. The errors are raised when compile the code of the module bindings in Dioxus. Dioxus try to compile the module bindings to wasm which run in browser, but openssl crate can't generate wasm. rustls should can. as more and more rust code try to compile to wasm, rustls is better than openssl . @mamcx what do you think about it ?
@lydiandy We do have a TypeScript SDK for running in the browser - would that work for your use case?
While learning and trying SpacetimeDB out this week, I ran into the same issue when building a demo with bevy for the web, which led me to try enabling the Rust SDK on the web.
You can check the progress of my attempt on my fork over here: https://github.com/thlsrms/SpacetimeDB/tree/master/crates/sdk
Although it’s still rough around the edges, the implementation works surprisingly well. You can check a demo I made here: https://github.com/thlsrms/tictactoe-stdb-bevy
In that demo I process the messages with frame_tick but I suspect that run_async would work as well. While I've not touched run_threaded yet, I thought of "faking" it by wrapping advance_one_message_async in a loop inside wasm_bindgen_futures::spawn_local.
For the credentials I replaced the File struct with another that should facilitate the interaction with the browser storage. I haven’t explored alternatives to replace the with_token connection yet.
@lydiandy feel free to try it out.
I was planning on trying it with leptos and perhaps a different WebSocket client before proposing a web feature flag for the SDK, but I won't be able to revisit this for at least a week.
Hey any update on this ?
Hey @corentinlange, there are some related PRs open but not yet merged (most notably #1700 and #2704). Are you also trying to use the Rust SDK from within Dioxus?
Hey @bfops, Nop I'm trying to have a spacetimedb client on a bevy game on a wasm target. I'm trying on javascript bindings right now to avoid this issue