mirror of
https://github.com/ruvnet/RuView.git
synced 2026-04-28 05:59:32 +00:00
The Rust port lived two directories deep (rust-port/wifi-densepose-rs/) without any sibling under rust-port/ that warranted the extra level. Move the whole workspace up to v2/ to match v1/ (Python) at the same depth and shorten every cd / build command across the repo. git mv preserves history for all tracked files. 60 files updated for path references (CI workflows, ADRs, docs, scripts, READMEs, internal .claude-flow state). Two manual fixes for relative-cd paths in CLAUDE.md and ADR-043 that became wrong after the depth change (cd ../.. → cd ..). Validated: - cargo check --workspace --no-default-features → clean (after target/ nuke; the gitignored target/ was carried by the OS rename and had hard-coded old paths in build scripts) - cargo test --workspace --no-default-features → 1,539 passed, 0 failed, 8 ignored (same totals as pre-rename) - ESP32-S3 on COM7 → still streaming live CSI (cb #40300, RSSI -64 dBm) After-merge follow-up: contributors should `rm -rf v2/target` once and let cargo regenerate from the new path. |
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.toml | ||
| README.md | ||
wifi-densepose-wasm
WebAssembly bindings for running WiFi-DensePose directly in the browser.
Overview
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.
Features
- MatDashboard -- Create disaster events, add rectangular and circular scan zones, subscribe to survivor-detected and alert-generated callbacks, and render zone/survivor overlays on Canvas.
- Real-time callbacks -- Register JavaScript closures for
onSurvivorDetectedandonAlertGeneratedevents, called from the Rust event loop. - Canvas rendering -- Draw zone boundaries, survivor markers (colour-coded by triage status),
and alert indicators directly to a
CanvasRenderingContext2d. - WebSocket integration -- Connect to a sensing server for live CSI data via
web-sysWebSocket bindings. - Panic hook --
console_error_panic_hookprovides human-readable stack traces in the browser console on panic. - Optimised WASM -- Release profile uses
-O4wasm-opt with mutable globals for minimal binary size.
Feature flags
| Flag | Default | Description |
|---|---|---|
console_error_panic_hook |
yes | Better panic messages in the browser console |
mat |
no | Enable MAT disaster detection dashboard |
Quick Start
Build
# Build with wasm-pack (recommended)
wasm-pack build --target web --features mat
# Or with cargo directly
cargo build --target wasm32-unknown-unknown --features mat
JavaScript Usage
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();
Exported API
| 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) |
Related Crates
| 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 |
License
MIT OR Apache-2.0