feat(wasm): compile the library for wasm32 (issue #45 groundwork)

First step toward a web build: the library now compiles for
wasm32-unknown-unknown with --no-default-features.

- Add a `solid3d` feature (default on) gating truck-meshalgo /
  truck-shapeops / lzma-sys. These pull vtkio → xz2 → lzma-sys (C),
  which cannot cross-compile to wasm. Without the feature the 3-D
  solid path (tessellation, booleans, ACIS import) becomes no-ops;
  2-D CAD is unaffected. Native builds keep the feature by default.
- Move native-only crates (ureq, open) to non-wasm target deps and
  add cfg shims: update-check is a no-op on wasm, and a new `sys`
  module provides open_url + handle_path (rfd FileHandle → PathBuf;
  synthesizes a name-based path on the web).

Native build + all 75 tests unchanged. Browser runtime wiring
(entry point, trunk, real file I/O) is a follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-16 13:01:19 +03:00
commit b2e20c95fe
12 changed files with 123 additions and 20 deletions

View file

@ -40,7 +40,7 @@ pub async fn pick_open_path() -> Option<(PathBuf, u64)> {
.add_filter("All Files", &["*"])
.pick_file()
.await?;
let path = handle.path().to_path_buf();
let path = crate::sys::handle_path(&handle);
let size = std::fs::metadata(&path).map(|m| m.len()).unwrap_or(0);
Some((path, size))
}
@ -250,7 +250,7 @@ pub async fn pick_plot_style() -> Option<plot_style::PlotStyleTable> {
.add_filter("All Files", &["*"])
.pick_file()
.await?;
plot_style::PlotStyleTable::load(handle.path()).ok()
plot_style::PlotStyleTable::load(&crate::sys::handle_path(&handle)).ok()
}
// ── Image file picker ─────────────────────────────────────────────────────
@ -267,7 +267,7 @@ pub async fn pick_image_file() -> Result<(PathBuf, u32, u32), String> {
.pick_file()
.await
.ok_or_else(|| "Cancelled".to_string())?;
let path = handle.path().to_path_buf();
let path = crate::sys::handle_path(&handle);
let img = image::open(&path).map_err(|e| e.to_string())?;
let (w, h) = image::GenericImageView::dimensions(&img);
Ok((path, w, h))