From 912a2d0b15b873923698126ac8112d1aa4bdbb1a Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 27 Oct 2026 10:08:22 +0100 Subject: wasm: experimental browser spike Proves the gipfel core can run in the browser via WASM. Enabled by the earlier GSL removal: the core is now pure Rust. gipfel-core gains byte-oriented entry points (no filesystem) alongside the existing path-based ones: - hill::load_from_bytes, Panorama::load_data_from_bytes - metadata: load_image_from_bytes, read_jpeg_comment_from_bytes, write_jpeg_comment_to_bytes, save_image_to_bytes (EXIF via Cursor) New crate gipfel-wasm (experimental, not shipped with the app): - wasm-bindgen surface: version() + fit_demo(db_bytes, jpg_bytes) which runs the whole pipeline in memory: parse hill DB, read gipfel JPEG comment / EXIF, synthesize 5 observations from visible hills, perturb, refit (pure-Rust LM), report JSON with reprojection error - demo/index.html: file pickers + result pane (wasm-pack --target web) - build.sh: adds the wasm target, builds with wasm-pack, prints serve cmd - native test runs the same pipeline against gipfel.dat + test.jpg and asserts sub-pixel reprojection error (passes here) To try on a machine with rustup: cd crates/gipfel-wasm && ./build.sh --- crates/gipfel-wasm/build.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 crates/gipfel-wasm/build.sh (limited to 'crates/gipfel-wasm/build.sh') diff --git a/crates/gipfel-wasm/build.sh b/crates/gipfel-wasm/build.sh new file mode 100755 index 0000000..8d1d812 --- /dev/null +++ b/crates/gipfel-wasm/build.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# Build the gipfel WASM spike and serve the demo page. +# Requires: rustup (for the wasm target) and wasm-pack. +set -e +cd "$(dirname "$0")" + +if ! rustup target list --installed 2>/dev/null | grep -q wasm32-unknown-unknown; then + echo "adding wasm32-unknown-unknown target ..." + rustup target add wasm32-unknown-unknown +fi +command -v wasm-pack >/dev/null 2>&1 || { + echo "wasm-pack not found. Install it once with:" + echo " cargo install wasm-pack (or: cargo binstall wasm-pack)" + exit 1 +} + +wasm-pack build --target web + +echo +echo "built. serve the demo with:" +echo " (cd crates/gipfel-wasm && python3 -m http.server 8080)" +echo "then open http://localhost:8080/demo/" -- cgit v1.2.3