rust-port/wifi-densepose-rs/crates/wifi-densepose-wasm/README.md
WebAssembly bindings for running WiFi-DensePose directly in the browser.
wifi-densepose-wasm compiles the WiFi-DensePose stack to wasm32-unknown-unknown and exposes a
JavaScript API via wasm-bindgen. The primary export is
MatDashboard -- a fully client-side disaster response dashboard that manages scan zones, tracks
survivors, generates triage alerts, and renders to an HTML Canvas element.
The crate also provides utility functions (init, getVersion, isMatEnabled, getTimestamp) and
a logging bridge that routes Rust log output to the browser console.
onSurvivorDetected and
onAlertGenerated events, called from the Rust event loop.CanvasRenderingContext2d.web-sys WebSocket
bindings.console_error_panic_hook provides human-readable stack traces in the browser
console on panic.-O4 wasm-opt with mutable globals for minimal binary
size.| Flag | Default | Description |
|---|---|---|
console_error_panic_hook | yes | Better panic messages in the browser console |
mat | no | Enable MAT disaster detection dashboard |
# Build with wasm-pack (recommended)
wasm-pack build --target web --features mat
# Or with cargo directly
cargo build --target wasm32-unknown-unknown --features mat
import init, {
MatDashboard,
initLogging,
getVersion,
isMatEnabled,
} from './wifi_densepose_wasm.js';
async function main() {
await init();
initLogging('info');
console.log('Version:', getVersion());
console.log('MAT enabled:', isMatEnabled());
const dashboard = new MatDashboard();
// Create a disaster event
const eventId = dashboard.createEvent(
'earthquake', 37.7749, -122.4194, 'Bay Area Earthquake'
);
// Add scan zones
dashboard.addRectangleZone('Building A', 50, 50, 200, 150);
dashboard.addCircleZone('Search Area B', 400, 200, 80);
// Subscribe to real-time events
dashboard.onSurvivorDetected((survivor) => {
console.log('Survivor:', survivor);
});
dashboard.onAlertGenerated((alert) => {
console.log('Alert:', alert);
});
// Render to canvas
const canvas = document.getElementById('map');
const ctx = canvas.getContext('2d');
function render() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
dashboard.renderZones(ctx);
dashboard.renderSurvivors(ctx);
requestAnimationFrame(render);
}
render();
}
main();
| Export | Kind | Description |
|---|---|---|
init() | Function | Initialise the WASM module (called automatically via wasm_bindgen(start)) |
initLogging(level) | Function | Set log level: trace, debug, info, warn, error |
getVersion() | Function | Return the crate version string |
isMatEnabled() | Function | Check whether the MAT feature is compiled in |
getTimestamp() | Function | High-resolution timestamp via Performance.now() |
MatDashboard | Class | Disaster response dashboard (zones, survivors, alerts, rendering) |
| Crate | Role |
|---|---|
wifi-densepose-mat | MAT engine (linked when mat feature enabled) |
wifi-densepose-core | Shared types and traits |
wifi-densepose-cli | Terminal-based MAT interface |
wifi-densepose-sensing-server | Backend sensing server for WebSocket data |
MIT OR Apache-2.0