feat(wasm): clawhdf5-wasm, the reader for JavaScript via wasm-bindgen

open(bytes) -> H5File with kind/list/info/attrs/attrErrors/read/
readHyperslab. Numeric data comes back in the typed array of the
stored width (Int16Array for i16, BigInt64Array for i64, Float32Array
for f32/f16, ...), strings and enum names as string arrays, array
datatypes flattened with their dims appended to the shape. Compound,
reference, opaque and VL-sequence datasets are refused with an error
naming the type; nothing is returned as reinterpreted bytes.

The logic is in a plain-Rust core module, tested natively: unit tests,
and h5py_interop, which compares every dataset, hyperslab, listing and
attribute of an h5py- and a netCDF4-written file with what libhdf5
reads back (generator shared with the Node test of the built package).

No mmap, no threads; lz4 is on, zstd/szip (C) are not. A
wasm-release profile (opt-level s, LTO) serves the browser build.
ci-test.sh lints the crate for wasm32 and checks it builds no C.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
osobh
2026-09-26 00:00:46 -05:00
co-authored by Claude Opus 5.5
parent 74f9f50086
commit a42b646689
9 changed files with 1337 additions and 5 deletions
+30
View File
@@ -0,0 +1,30 @@
[package]
name = "clawhdf5-wasm"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "Read HDF5 and NetCDF-4 files in the browser: clawhdf5's reader compiled to WebAssembly"
license.workspace = true
repository.workspace = true
keywords = ["hdf5", "netcdf", "wasm", "browser"]
categories = ["wasm", "parser-implementations", "science"]
# Distributed as the wasm-bindgen package built by examples/wasm-viewer/build.sh.
publish = false
[lib]
# cdylib for wasm-bindgen; rlib so the pure-Rust core is tested natively.
crate-type = ["cdylib", "rlib"]
[dependencies]
# No mmap (there is no file system) and no `parallel` (no threads on
# wasm32-unknown-unknown). lz4 is pure Rust; zstd and szip link C and are
# left out, so such datasets fail with a clear filter error.
clawhdf5 = { path = "../clawhdf5", version = "2.7.0", default-features = false, features = ["lz4"] }
clawhdf5-format = { path = "../clawhdf5-format", version = "2.7.0" }
# Must match the wasm-bindgen CLI exactly; build.sh checks.
wasm-bindgen = "0.2.129"
js-sys = "0.3.106"
[dev-dependencies]
serde_json = "1"
tempfile = { workspace = true }