Drop a file (or pass ?file=<url>&path=<object>), browse the tree lazily, see a dataset's type, shape, max shape and attributes, and page through its values as 50x12 hyperslab windows (leading dims of 3-D+ data held at chosen indices). build.sh produces pkg/ (not committed) with wasm-bindgen --target web and checks the CLI matches the crate version. test/run.sh builds it and runs test.mjs under Node against the h5py/ netCDF4 fixture (250 checks: every dataset whole and as a strided hyperslab, listings, attributes, error paths, the page's DOM-free helpers), then browser.sh renders the page in headless Chromium for eight objects and checks the DOM. The fixture gains LZ4 (read) and Zstd (refused: links C) datasets and a compound attribute (value null plus its type). ci-test.sh runs it when node and wasm-bindgen exist; the CI container has neither, so CI relies on the native h5py_interop test. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
40 lines
1.5 KiB
Bash
Executable File
40 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build the clawhdf5-wasm package the viewer loads, into examples/wasm-viewer/pkg/.
|
|
#
|
|
# Needs the wasm32-unknown-unknown target and the wasm-bindgen CLI at the
|
|
# exact version cargo resolves for the wasm-bindgen crate:
|
|
# rustup target add wasm32-unknown-unknown
|
|
# cargo install wasm-bindgen-cli --version <that version>
|
|
#
|
|
# Then serve this directory over HTTP (browsers do not load wasm modules from
|
|
# file://) and open it:
|
|
# python3 -m http.server -d examples/wasm-viewer 8000
|
|
set -euo pipefail
|
|
|
|
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
ROOT="$(cd "$HERE/../.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
# The resolved crate version (Cargo.lock is not committed, so ask cargo).
|
|
want=$(cargo pkgid wasm-bindgen | sed 's/.*[@#]//')
|
|
if ! command -v wasm-bindgen >/dev/null; then
|
|
echo "wasm-bindgen CLI not found: cargo install wasm-bindgen-cli --version $want" >&2
|
|
exit 1
|
|
fi
|
|
have=$(wasm-bindgen --version | awk '{print $2}')
|
|
if [ "$want" != "$have" ]; then
|
|
echo "wasm-bindgen CLI is $have but the crate is $want:" >&2
|
|
echo " cargo install wasm-bindgen-cli --version $want" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cargo build -p clawhdf5-wasm --target wasm32-unknown-unknown --profile wasm-release
|
|
|
|
target_dir=$(cargo metadata --format-version 1 --no-deps \
|
|
| sed -n 's/.*"target_directory":"\([^"]*\)".*/\1/p')
|
|
wasm="$target_dir/wasm32-unknown-unknown/wasm-release/clawhdf5_wasm.wasm"
|
|
|
|
rm -rf "$HERE/pkg"
|
|
wasm-bindgen --target web --out-dir "$HERE/pkg" "$wasm"
|
|
echo "built $HERE/pkg ($(wc -c < "$HERE/pkg/clawhdf5_wasm_bg.wasm") bytes of wasm)"
|