Open JacobLinCool opened 3 weeks ago
It doesn't seem that easy to support WASM.
It's simple to find out the flag set. The following seems to be working:
[features]
default = ["tokio/rt-multi-thread"]
wasm = ["getrandom/js", "tokio/time", "tokio/io-util"]
[dependencies]
# others
getrandom = { version = "0.2.15", optional = true }
tokio = { version = "1.38.1", features = ["macros", "rt"] }
Then there are 2 problems to resolve. The first is that reqwest does not support cookies in WASM. (There are some PRs for that: https://github.com/seanmonstar/reqwest/pull/2360, https://github.com/seanmonstar/reqwest/pull/1753, and https://github.com/seanmonstar/reqwest/pull/1449.) The second is that we need to provide a new method to upload files from memory since WASM does not have a filesystem.
There is an experimental branch (PR) that can be compiled to the wasm32-unknow-unknown
target using cargo build --no-default-features -F wasm --target wasm32-unknown-unknown
: https://github.com/JacobLinCool/gradio-rs/pull/4
I think it's possible, but I may need to figure out the right feature flags for Tokio and Reqwest.
Some references: