forked from 1b-agent/opencadstudio-upstream
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 <[email protected]>
This commit is contained in:
1 parent
3666c7fa69
commit
b2e20c95fe
12 files changed
+123
-20
No files matched your search
+31
@@ -0,0 +1,31 @@
|
||||
// Small platform shims for things the desktop build does natively but the web
|
||||
// (wasm) build must handle differently or skip.
|
||||
|
||||
/// Open a URL in the user's browser. On the desktop this launches the default
|
||||
/// handler; on the web the app already *is* in a browser, so for now this is a
|
||||
/// no-op (a real implementation would call `window.open`).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn open_url(url: &str) {
|
||||
let _ = open::that(url);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn open_url(_url: &str) {
|
||||
// TODO(web): web_sys::window().open_with_url(_url)
|
||||
}
|
||||
|
||||
/// Turn an `rfd` file handle into a `PathBuf` the rest of the app keys on.
|
||||
///
|
||||
/// Desktop returns the real filesystem path. The browser has no path, so we
|
||||
/// synthesize one from the file name — enough for the app to compile and track
|
||||
/// the document name; actual byte I/O on the web reads the handle directly
|
||||
/// (a follow-up).
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn handle_path(h: &rfd::FileHandle) -> std::path::PathBuf {
|
||||
h.path().to_path_buf()
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn handle_path(h: &rfd::FileHandle) -> std::path::PathBuf {
|
||||
std::path::PathBuf::from(h.file_name())
|
||||
}
|
||||
Reference in new issue
Block a user