Add support for compiling WebAssembly wasm32-unknown-unknown target (#92)
Note this only is the first step in web support, although the project compiles, it doesn't run!
Merging now to avoid branch divergence, until dependencies can be updated for wasm support.
* Add instructions to build for wasm32-unknown-unknown with wasm-pack in www/
* Update to rust-clipboard fork to compile with emscripten
https://github.com/aweinstock314/rust-clipboard/pull/62
* Exclude reqwest dependency in wasm32
* Exclude compiling clipboard pasting on wasm32
* Exclude reqwest-using code from wasm32
* Install wasm target with rustup in Travis CI
* Update to collision 0.19.0
Fixes wasm incompatibility in deprecated rustc-serialize crate: https://github.com/rustgd/collision-rs/issues/106
error[E0046]: not all trait items implemented, missing: `encode`
--> github.com-1ecc6299db9ec823/rustc-serialize-0.3.24/src/serialize.rs:1358:1
* Increase travis_wait time even further, try 120 minutes
* Set RUST_BACKTRACE=1 in main
* Remove unused unneeded bzip2 features in zip crate
To fix wasm32-unknown-unknown target compile error:
error[E0432]: unresolved imports `libc::c_int`, `libc::c_uint`, `libc::c_void`, `libc::c_char`
--> src/github.com-1ecc6299db9ec823/bzip2-sys-0.1.7/lib.rs:5:12
|
5 | use libc::{c_int, c_uint, c_void, c_char};
| ^^^^^ ^^^^^^ ^^^^^^ ^^^^^^ no `c_char` in the root
| | | |
| | | no `c_void` in the root
| | no `c_uint` in the root
| no `c_int` in the root
* flate2 use Rust backend
* Add console_error_panic_hook module for wasm backtraces
* Build using wasm-pack, wasm-bindgen, run with wasm-app
* Update to miniz_oxide 0.2.1, remove patch for https://github.com/Frommi/miniz_oxide/issues/42
* Update to official clipboard crate since https://github.com/aweinstock314/rust-clipboard/pull/62 was merged, but git revision pending release
* Update to branch of glutin attempting to build for wasm
https://github.com/iceiix/glutin/pull/1
* Update winit dependency of glutin to git master
https://github.com/iceiix/winit/pull/2
* Update to glutin branch with working (compiles, doesn't run) wasm_stub
* Add app name in title on web page
* Add wasm to Travis-CI test matrix
* Update glutin to fix Windows EGL compilation on AppVeyor
97797352b5
This commit is contained in:
parent
13fbbaa80a
commit
2f2f35848a
|
@ -1,6 +1,8 @@
|
|||
target/
|
||||
.rust/
|
||||
working/
|
||||
*.log
|
||||
pkg
|
||||
|
||||
# IntelliJ
|
||||
.idea
|
||||
|
|
18
.travis.yml
18
.travis.yml
|
@ -8,7 +8,12 @@ matrix:
|
|||
allow_failures:
|
||||
- rust: nightly
|
||||
fast_finish: true
|
||||
cache: cargo
|
||||
include:
|
||||
- env: WASM=true
|
||||
- env: WASM=false
|
||||
cache:
|
||||
cargo: true
|
||||
timeout: 1000
|
||||
before_install:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo chown root:wheel /usr/local/bin/brew ; fi
|
||||
|
@ -16,8 +21,15 @@ before_install:
|
|||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y gcc libegl1-mesa-dev libgles2-mesa-dev ; fi
|
||||
script:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib" ; fi
|
||||
- travis_wait 30 cargo build --verbose
|
||||
- cargo test --verbose
|
||||
- if [[ "$WASM" == "true" ]]; then
|
||||
rustup target add wasm32-unknown-unknown;
|
||||
cargo install wasm-bindgen-cli;
|
||||
cargo install wasm-pack;
|
||||
travis_wait 120 wasm-pack build;
|
||||
else
|
||||
travis_wait 30 cargo build --verbose;
|
||||
cargo test --verbose;
|
||||
fi
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
|
|
@ -240,7 +240,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "clipboard"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
source = "git+https://github.com/aweinstock314/rust-clipboard?rev=07d080be58a361a5bbdb548fafe9449843d968be#07d080be58a361a5bbdb548fafe9449843d968be"
|
||||
dependencies = [
|
||||
"clipboard-win 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"objc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -297,6 +297,15 @@ name = "color_quant"
|
|||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "console_error_panic_hook"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation"
|
||||
version = "0.5.1"
|
||||
|
@ -604,7 +613,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "glutin"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/tomaka/glutin?rev=23b3b101e554e521f38c1179f90d3d2f278b857c#23b3b101e554e521f38c1179f90d3d2f278b857c"
|
||||
source = "git+https://github.com/iceiix/glutin?rev=bb8ce243c8725411509b6ba359357530a26247e9#bb8ce243c8725411509b6ba359357530a26247e9"
|
||||
dependencies = [
|
||||
"android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cgl 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -620,7 +629,7 @@ dependencies = [
|
|||
"shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wayland-client 0.21.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winit 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winit 0.18.1 (git+http://github.com/iceiix/winit?branch=wasm_stub)",
|
||||
"x11-dl 2.18.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1693,11 +1702,13 @@ dependencies = [
|
|||
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfb8 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cgmath 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clipboard 0.5.0 (git+https://github.com/aweinstock314/rust-clipboard?rev=07d080be58a361a5bbdb548fafe9449843d968be)",
|
||||
"collision 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"glutin 0.19.0 (git+https://github.com/tomaka/glutin?rev=23b3b101e554e521f38c1179f90d3d2f278b857c)",
|
||||
"glutin 0.19.0 (git+https://github.com/iceiix/glutin?rev=bb8ce243c8725411509b6ba359357530a26247e9)",
|
||||
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"image 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1712,6 +1723,7 @@ dependencies = [
|
|||
"steven_gl 0.0.1",
|
||||
"steven_resources 0.1.0",
|
||||
"steven_shared 0.0.1",
|
||||
"wasm-bindgen 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"zip 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -1983,6 +1995,53 @@ dependencies = [
|
|||
"try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"wasm-bindgen-macro 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-shared 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-macro-support 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-backend 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-shared 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "wayland-client"
|
||||
version = "0.21.11"
|
||||
|
@ -2077,10 +2136,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
[[package]]
|
||||
name = "winit"
|
||||
version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
source = "git+http://github.com/iceiix/winit?branch=wasm_stub#dad2ea4d13e3a43fb1ff135c0fdc1c79919d4c8e"
|
||||
dependencies = [
|
||||
"android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cocoa 0.18.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2192,12 +2252,13 @@ dependencies = [
|
|||
"checksum cgl 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "55e7ec0b74fe5897894cbc207092c577e87c52f8a59e8ca8d97ef37551f60a49"
|
||||
"checksum cgmath 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "64a4b57c8f4e3a2e9ac07e0f6abc9c24b6fc9e1b54c3478cfb598f3d0023e51c"
|
||||
"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
|
||||
"checksum clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "25a904646c0340239dcf7c51677b33928bf24fdf424b79a57909c0109075b2e7"
|
||||
"checksum clipboard 0.5.0 (git+https://github.com/aweinstock314/rust-clipboard?rev=07d080be58a361a5bbdb548fafe9449843d968be)" = "<none>"
|
||||
"checksum clipboard-win 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "289da2fc09ab964a4948a63287c94fcb4698fa823c46da84c3792928c9d36110"
|
||||
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
|
||||
"checksum cocoa 0.18.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cf79daa4e11e5def06e55306aa3601b87de6b5149671529318da048f67cdd77b"
|
||||
"checksum collision 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f2a7f3c1279555e955d10ae466cc9c9c73b5618191379ec64fc65072d456136"
|
||||
"checksum color_quant 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbb57365263e881e805dc77d94697c9118fd94d8da011240555aa7b23445bd"
|
||||
"checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
|
||||
"checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980"
|
||||
"checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887"
|
||||
"checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa"
|
||||
|
@ -2235,7 +2296,7 @@ dependencies = [
|
|||
"checksum gl_generator 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0ffaf173cf76c73a73e080366bf556b4776ece104b06961766ff11449f38604"
|
||||
"checksum gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a795170cbd85b5a7baa58d6d7525cae6a03e486859860c220f7ebbbdd379d0a"
|
||||
"checksum gleam 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "4b47f5b15742aee359c7895ab98cf2cceecc89bb4feb6f4e42f802d7899877da"
|
||||
"checksum glutin 0.19.0 (git+https://github.com/tomaka/glutin?rev=23b3b101e554e521f38c1179f90d3d2f278b857c)" = "<none>"
|
||||
"checksum glutin 0.19.0 (git+https://github.com/iceiix/glutin?rev=bb8ce243c8725411509b6ba359357530a26247e9)" = "<none>"
|
||||
"checksum h2 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "ddb2b25a33e231484694267af28fec74ac63b5ccf51ee2065a5e313b834d836e"
|
||||
"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
|
||||
"checksum http 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "1a10e5b573b9a0146545010f50772b9e8b1dd0a256564cc4307694c68832a2f5"
|
||||
|
@ -2380,6 +2441,11 @@ dependencies = [
|
|||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
"checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1"
|
||||
"checksum want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "797464475f30ddb8830cc529aaaae648d581f99e2036a928877dfde027ddf6b3"
|
||||
"checksum wasm-bindgen 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)" = "2d85ba4917abb23ee7788330797a7cb5ac7e5e997cdc67fde6f2c8d02cc08db3"
|
||||
"checksum wasm-bindgen-backend 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)" = "51f9c26bd7d30f21ce334785ec10c5ce10cba28313979d793b8dddede19da3a4"
|
||||
"checksum wasm-bindgen-macro 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)" = "316e6e568644bfa2009698217cec8f612a4e2cd7460b127f52573991c7ad9f53"
|
||||
"checksum wasm-bindgen-macro-support 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)" = "29982ea76a7a35b5c3c052b6035abe9b84d8b6422d8881b68bd3472270a53eec"
|
||||
"checksum wasm-bindgen-shared 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)" = "59305c5b959d51437636db05bac82de2b52da2c05157e38e018c0bd54cfd9bbf"
|
||||
"checksum wayland-client 0.21.11 (registry+https://github.com/rust-lang/crates.io-index)" = "96041810afa07e7953867d46f8f03c41cbca49ebd1e840eef6abefde8b458b30"
|
||||
"checksum wayland-commons 0.21.11 (registry+https://github.com/rust-lang/crates.io-index)" = "92af0c5dc724c049e9bd927f8563d9a6abaa94893c5305ef0a6d2805e661f3d3"
|
||||
"checksum wayland-protocols 0.21.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fd94211387fa8ff50df1e4ff7a5529b5a9aebe68ba88acc48e5b7f5fd98f6eef"
|
||||
|
@ -2391,7 +2457,7 @@ dependencies = [
|
|||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
"checksum winit 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c57c15bd4c0ef18dff33e263e452abe32d00e2e05771cacaa410a14cc1c0776"
|
||||
"checksum winit 0.18.1 (git+http://github.com/iceiix/winit?branch=wasm_stub)" = "<none>"
|
||||
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
|
||||
"checksum x11-clipboard 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d8617c6185c96e5fcf57ff156496d73c9c82b7f09a5fea21b518dd32c10e2e05"
|
||||
"checksum x11-dl 2.18.3 (registry+https://github.com/rust-lang/crates.io-index)" = "940586acb859ea05c53971ac231685799a7ec1dee66ac0bccc0e6ad96e06b4e3"
|
||||
|
|
17
Cargo.toml
17
Cargo.toml
|
@ -7,6 +7,10 @@ description = "Multi-protocol multi-platform Minecraft-compatible client"
|
|||
repository = "https://github.com/iceiix/stevenarella"
|
||||
license = "(MIT OR Apache-2.0)"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
path = "src/main.rs"
|
||||
|
||||
[profile.dev]
|
||||
# Steven runs horrendously slow with no optimizations, and often freezes.
|
||||
# However, building with full -O3 optimizations takes too long for a debug build.
|
||||
|
@ -14,10 +18,11 @@ license = "(MIT OR Apache-2.0)"
|
|||
opt-level = 1
|
||||
|
||||
[dependencies]
|
||||
cfg-if = "0.1.2"
|
||||
wasm-bindgen = "0.2.33"
|
||||
sha-1 = "0.8.1"
|
||||
glutin = { git = "https://github.com/tomaka/glutin", rev = "23b3b101e554e521f38c1179f90d3d2f278b857c" }
|
||||
glutin = { git = "https://github.com/iceiix/glutin", rev = "97797352b5242436cb82d8ecfb44242b69766e4c" }
|
||||
byteorder = "1.2.7"
|
||||
reqwest = "0.9.10"
|
||||
serde = "1.0.89"
|
||||
serde_json = "1.0.39"
|
||||
flate2 = { version = "1.0.6", features = ["rust_backend"], default-features = false }
|
||||
|
@ -33,9 +38,15 @@ collision = "0.19.0"
|
|||
aes = "0.3.2"
|
||||
cfb8 = "0.3.1"
|
||||
rsa_public_encrypt_pkcs1 = "0.2.0"
|
||||
clipboard = "0.5.0"
|
||||
clipboard = { git = "https://github.com/aweinstock314/rust-clipboard", rev = "07d080be58a361a5bbdb548fafe9449843d968be" }
|
||||
# clippy = "*"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
reqwest = "0.9.10"
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
console_error_panic_hook = "0.1.1"
|
||||
|
||||
[dependencies.steven_gl]
|
||||
path = "./gl"
|
||||
version = "0"
|
||||
|
|
|
@ -69,6 +69,8 @@ Just compile:
|
|||
cargo build --release
|
||||
```
|
||||
|
||||
For progress on web support, see [www/](./www).
|
||||
|
||||
## Running
|
||||
|
||||
### Standalone
|
||||
|
|
28
src/main.rs
28
src/main.rs
|
@ -41,6 +41,8 @@ pub mod auth;
|
|||
pub mod model;
|
||||
pub mod entity;
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use std::sync::{Arc, RwLock, Mutex};
|
||||
use std::rc::Rc;
|
||||
use std::marker::PhantomData;
|
||||
|
@ -166,7 +168,21 @@ impl Game {
|
|||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
cfg_if! {
|
||||
if #[cfg(target_arch = "wasm32")] {
|
||||
extern crate console_error_panic_hook;
|
||||
pub use console_error_panic_hook::set_once as set_panic_hook;
|
||||
} else {
|
||||
#[inline]
|
||||
pub fn set_panic_hook() {}
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn main() {
|
||||
set_panic_hook();
|
||||
std::env::set_var("RUST_BACKTRACE", "1");
|
||||
|
||||
let con = Arc::new(Mutex::new(console::Console::new()));
|
||||
let (vars, vsync) = {
|
||||
let mut vars = console::Vars::new();
|
||||
|
@ -215,7 +231,15 @@ fn main() {
|
|||
let frame_time = 1e9f64 / 60.0;
|
||||
|
||||
let mut screen_sys = screen::ScreenSystem::new();
|
||||
screen_sys.add_screen(Box::new(screen::Login::new(vars.clone())));
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
screen_sys.add_screen(Box::new(screen::Login::new(vars.clone())));
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
screen_sys.add_screen(Box::new(screen::ServerList::new(None)));
|
||||
}
|
||||
|
||||
let textures = renderer.get_textures();
|
||||
let dpi_factor = window.get_current_monitor().get_hidpi_factor();
|
||||
|
|
|
@ -19,6 +19,7 @@ use aes::Aes128;
|
|||
use cfb8::Cfb8;
|
||||
use cfb8::stream_cipher::{NewStreamCipher, StreamCipher};
|
||||
use serde_json;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use reqwest;
|
||||
|
||||
pub mod mojang;
|
||||
|
@ -764,6 +765,7 @@ pub enum Error {
|
|||
Disconnect(format::Component),
|
||||
IOError(io::Error),
|
||||
Json(serde_json::Error),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
Reqwest(reqwest::Error),
|
||||
}
|
||||
|
||||
|
@ -779,6 +781,7 @@ impl convert::From<serde_json::Error> for Error {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl convert::From<reqwest::Error> for Error {
|
||||
fn from(e: reqwest::Error) -> Error {
|
||||
Error::Reqwest(e)
|
||||
|
@ -792,6 +795,7 @@ impl ::std::error::Error for Error {
|
|||
Error::Disconnect(_) => "Disconnect",
|
||||
Error::IOError(ref e) => e.description(),
|
||||
Error::Json(ref e) => e.description(),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
Error::Reqwest(ref e) => e.description(),
|
||||
}
|
||||
}
|
||||
|
@ -804,6 +808,7 @@ impl ::std::fmt::Display for Error {
|
|||
Error::Disconnect(ref val) => write!(f, "{}", val),
|
||||
Error::IOError(ref e) => e.fmt(f),
|
||||
Error::Json(ref e) => e.fmt(f),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
Error::Reqwest(ref e) => e.fmt(f),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
use sha1::{self, Digest};
|
||||
use serde_json::json;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use reqwest;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -28,6 +29,7 @@ const LOGIN_URL: &str = "https://authserver.mojang.com/authenticate";
|
|||
const REFRESH_URL: &str = "https://authserver.mojang.com/refresh";
|
||||
const VALIDATE_URL: &str = "https://authserver.mojang.com/validate";
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl Profile {
|
||||
pub fn login(username: &str, password: &str, token: &str) -> Result<Profile, super::Error> {
|
||||
let req_msg = json!({
|
||||
|
|
|
@ -837,6 +837,11 @@ impl TextureManager {
|
|||
]);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn process_skins(recv: mpsc::Receiver<String>, reply: mpsc::Sender<(String, Option<image::DynamicImage>)>) {
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn process_skins(recv: mpsc::Receiver<String>, reply: mpsc::Sender<(String, Option<image::DynamicImage>)>) {
|
||||
use reqwest;
|
||||
let client = reqwest::Client::new();
|
||||
|
@ -857,6 +862,7 @@ impl TextureManager {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn obtain_skin(client: &::reqwest::Client, hash: &str) -> Result<image::DynamicImage, ::std::io::Error> {
|
||||
use std::io::Read;
|
||||
use std::fs;
|
||||
|
|
|
@ -24,6 +24,7 @@ use std::collections::HashMap;
|
|||
use std::hash::BuildHasherDefault;
|
||||
use serde_json;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use reqwest;
|
||||
use zip;
|
||||
|
||||
|
@ -89,8 +90,11 @@ impl Manager {
|
|||
})),
|
||||
};
|
||||
m.add_pack(Box::new(InternalPack));
|
||||
m.download_vanilla();
|
||||
m.download_assets();
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
m.download_vanilla();
|
||||
m.download_assets();
|
||||
}
|
||||
(m, ManagerUI { progress_ui: vec!{}, num_tasks: 0 })
|
||||
}
|
||||
|
||||
|
@ -274,6 +278,7 @@ impl Manager {
|
|||
self.version += 1;
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn download_assets(&mut self) {
|
||||
let loc = format!("./index/{}.json", ASSET_VERSION);
|
||||
let location = path::Path::new(&loc).to_owned();
|
||||
|
@ -342,6 +347,7 @@ impl Manager {
|
|||
});
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn download_vanilla(&mut self) {
|
||||
let loc = format!("./resources-{}", RESOURCES_VERSION);
|
||||
let location = path::Path::new(&loc);
|
||||
|
|
|
@ -54,6 +54,7 @@ impl Login {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
impl super::Screen for Login {
|
||||
fn on_active(&mut self, renderer: &mut render::Renderer, ui_container: &mut ui::Container) {
|
||||
let logo = ui::logo::Logo::new(renderer.resources.clone(), ui_container);
|
||||
|
|
|
@ -161,7 +161,10 @@ impl Server {
|
|||
let shared_e = rsa_public_encrypt_pkcs1::encrypt(&public_key, &shared).unwrap();
|
||||
let token_e = rsa_public_encrypt_pkcs1::encrypt(&public_key, &verify_token).unwrap();
|
||||
|
||||
profile.join_server(&server_id, &shared, &public_key)?;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
profile.join_server(&server_id, &shared, &public_key)?;
|
||||
}
|
||||
|
||||
if protocol_version >= 47 {
|
||||
conn.write_packet(protocol::packet::login::serverbound::EncryptionResponse {
|
||||
|
|
|
@ -19,6 +19,7 @@ use std::cell::{RefCell, RefMut};
|
|||
use crate::render;
|
||||
use crate::format;
|
||||
use glutin::VirtualKeyCode;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use clipboard::{ClipboardProvider, ClipboardContext};
|
||||
|
||||
const SCALED_WIDTH: f64 = 854.0;
|
||||
|
@ -1322,6 +1323,8 @@ impl UIElement for TextBox {
|
|||
}
|
||||
self.submit_funcs.append(&mut temp);
|
||||
},
|
||||
// TODO: wasm clipboard pasting, Clipboard API: https://www.w3.org/TR/clipboard-apis/
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
(VirtualKeyCode::V, true) => {
|
||||
if ctrl_pressed {
|
||||
let mut clipboard: ClipboardContext = ClipboardProvider::new().unwrap();
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
dist
|
|
@ -0,0 +1,42 @@
|
|||
# stevenarella-web
|
||||
|
||||
Web app for running Stevenarella as WebAssembly
|
||||
|
||||
Status: very incomplete. It currently compiles, but **does not run** due to
|
||||
missing web support from critical dependencies, at least:
|
||||
|
||||
* [glutin](https://github.com/tomaka/glutin) (temporary stub: [#1](https://github.com/iceiix/glutin/pull/1))
|
||||
* [winit](https://github.com/tomaka/winit), watch for [stdweb suoort](https://github.com/tomaka/winit/pull/797) (temporary stub: [#2](https://github.com/iceiix/winit/pull/2))
|
||||
|
||||
## Building
|
||||
|
||||
To build for wasm32-unknown-unknown, run in the top-level directory (not www):
|
||||
|
||||
```sh
|
||||
rustup target add wasm32-unknown-unknown
|
||||
cargo install wasm-bindgen-cli
|
||||
wasm-pack build
|
||||
```
|
||||
|
||||
## Running
|
||||
|
||||
After building the Rust app, run the NodeJS web server as follows:
|
||||
|
||||
```sh
|
||||
cd pkg
|
||||
npm link
|
||||
cd ..
|
||||
cd www
|
||||
npm link stevenarella
|
||||
npm install
|
||||
npm start
|
||||
open http://localhost:8080/
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
Based on `[rustwasm/create-wasm-app](https://github.com/rustwasm/create-wasm-app)`:
|
||||
|
||||
> An `npm init` template for kick starting a project that uses NPM packages
|
||||
> containing Rust-generated WebAssembly and bundles them with Webpack.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
// A dependency graph that contains any wasm must all be imported
|
||||
// asynchronously. This `bootstrap.js` file does the single async import, so
|
||||
// that no one else needs to worry about it again.
|
||||
import("./index.js")
|
||||
.catch(e => console.error("Error importing `index.js`:", e));
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Stevenarella</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="./bootstrap.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,3 @@
|
|||
import * as wasm from "stevenarella";
|
||||
|
||||
wasm.main();
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "stevenarella-web",
|
||||
"version": "0.0.1",
|
||||
"description": "Multi-protocol Minecraft-compatible client, web-based version",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "webpack --config webpack.config.js",
|
||||
"start": "webpack-dev-server"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/iceiix/stevenarella.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "iceiix <ice_ix@protonmail.ch>",
|
||||
"license": "(MIT OR Apache-2.0)",
|
||||
"bugs": {
|
||||
"url": "https://github.com/iceiix/stevenarella/issues"
|
||||
},
|
||||
"homepage": "https://github.com/rustwasm/create-wasm-app#readme",
|
||||
"devDependencies": {
|
||||
"webpack": "^4.29.6",
|
||||
"webpack-cli": "^3.2.3",
|
||||
"webpack-dev-server": "^3.2.1",
|
||||
"copy-webpack-plugin": "^5.0.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
entry: "./bootstrap.js",
|
||||
output: {
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
filename: "bootstrap.js",
|
||||
},
|
||||
mode: "development",
|
||||
plugins: [
|
||||
new CopyWebpackPlugin(['index.html'])
|
||||
],
|
||||
};
|
Loading…
Reference in New Issue