gasm-host 0.2.0

Native host for gasm games (a portable game runtime on WebAssembly): wasmtime, WebGPU via wgpu, audio, gamepads, WebSocket networking and storage. Includes the gasm-run runner and gasm-relay
Documentation

gasm-host

Native host for gasm games. A game is one .wasm file, and this crate runs it: wasmtime for the module, wgpu (Metal, Vulkan, D3D12) for gasm:gfx, cpal audio, gilrs gamepads, WebSocket networking (ws:///wss://, rustls) and per-game storage.

It ships two binaries:

cargo install gasm-host
gasm-run game.wasm                       # play in a window
gasm-run game.wasm --headless 600        # CI: run 600 frames, print video/audio hashes
gasm-run game.wasm --compile game.cwasm  # ahead-of-time compile (no JIT at load)
gasm-relay 0.0.0.0:9000                  # WebSocket room relay for online play

And a library, for embedding games in your own app or building a runner for another platform:

use std::collections::HashMap;
use gasm_host::{gfx::Gfx, host::{Game, Host}, net::Net, storage::Storage};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let host = Host::new(HashMap::new(), HashMap::new(), None, Gfx::null(), Net::new(false), Storage::memory());
    let mut game = Game::load(&std::fs::read("game.wasm")?, host)?;
    for _ in 0..600 {
        game.frame()?;                    // call at game.host().frame_rate Hz
    }
    let h = game.host();
    println!("{}x{}, video hash {:08x}", h.width, h.height, h.video_hash.0);
    Ok(())
}

Guests are sandboxed: they see only their own memory and the ABI. Every pointer and handle is checked. There's no filesystem, network is opt-in, and the storage namespace is chosen by the host.

On Linux, building needs libasound2-dev libudev-dev pkg-config. MIT licensed.