cargo-html 0.1.5

create self-contained HTML programs
cargo-html-0.1.5 is not a library.

cargo html

create self-contained HTML programs

GitHub crates.io rust: stable License Build Status

Want to run basic console programs in the browser? Too lazy to configure CORS properly to fetch/share WASM? Hate firing up a webserver when you'd rather just double click an HTML file? Easily confused by advanced concepts such as "I have multiple files"?

cargo html solves all of this, by generating .html files which embed and encode their javascript, WASM, and WASI implementations directly into said HTML. No CORS, no --allow-file-access-from-files flags, no sidecar files, 100% self contained.

# install

cargo install cargo-html


# create a project

cargo new hello-world

cd hello-world


# build a project

cargo html


# view/run said project in the browser

start "" target/wasm32-wasi/debug/hello-world.html

rust-mini-games

Game Issues
asylum
guess
knights #6 File I/O not implemented (panic on exit)
lord #7 Colors not supported (some terminal escape garbage)
rps
tictactoe

To reproduce the gh-pages of my fork of that repository from scratch:

# init

cargo install cargo-html

git clone --branch cargo-html-demo https://github.com/MaulingMonkey/rust-mini-games

cd rust-mini-games


# build

cargo html --release

robocopy /S target/wasm32-wasi/release . *.html


# create branch

git checkout -b gh-pages

git add -A .

git commit -m "Updated examples"

Requires wasm, async-functions, promises, textencoder, and being generally awesome.

Browser Supported Version
Chrome ✅ 57+
Chrome for Android ✅ 88+
Firefox ✅ 53+
Firefox for Android ✔️ 83+
Opera ✔️ 44+
Opera Mobile ✔️ 59+
Opera Mini ❌ None (missing WASM, Async Functions, TextEncoder)
Safari ✔️ 11+
iOS Safari ✔️ 11+
Edge ✅ 79+
IE ❌ None (missing WASM, Async Functions, TextEncoder)
Android Browser ✔️ 81+
UC Browser for Android ❌ None (missing WASM)
Samsung Internet ✅ 7.2+
QQ Browser ✔️ 10.4+
Baidu Browser ❌ None (missing WASM, Async Functions)
KaiOS Browser ❌ None (missing WASM, Async Functions)
Build OS x86_64 x86 AArch64 ARM Other
Windows ✔️ ❌ [...]
Linux ✔️ ✔️ ✔️ ❌ [...]
OS X ✔️ ❌ [...]
? Legend
Tested
✔️ Should work
Broken (Browsers could probably be fixed via polyfills and different codegen?)

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.