fix(web): gate native-only code out of the wasm build

The wasm check broke on the MCP `tools` op, the block library's folder
picker and DWG thumbnails, and the PDF export-window culling helpers.
Gate each one like the code around it; `read_handle` needs no gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-04 20:53:11 +03:00
1 parent 440adec834
commit f14b675ff7
4 files changed
+10 -1

No files matched your search

+1
View File
@@ -528,6 +528,7 @@ impl OpenCADStudio {
Task::none(),
);
}
#[cfg(not(target_arch = "wasm32"))]
if op == "tools" {
return (
json!({
+4
View File
@@ -77,6 +77,10 @@ impl OpenCADStudio {
BlockPaletteMsg::ToggleOptions => {
self.block_palette.options_collapsed ^= true;
}
// Browsers expose no folder picker.
#[cfg(target_arch = "wasm32")]
BlockPaletteMsg::LibraryBrowse => {}
#[cfg(not(target_arch = "wasm32"))]
BlockPaletteMsg::LibraryBrowse => {
return Task::perform(
async {
+5
View File
@@ -945,10 +945,12 @@ fn append_pdf_page(
Ok(())
}
#[cfg(not(target_arch = "wasm32"))]
/// Slack around the export window, in sheet mm, so a stroke whose centreline
/// sits just outside still contributes its width.
const CULL_MARGIN_MM: f64 = 10.0;
#[cfg(not(target_arch = "wasm32"))]
fn sheet_overlaps(b: [f64; 4], window: [f64; 4]) -> bool {
b[0] <= window[2] + CULL_MARGIN_MM
&& b[2] >= window[0] - CULL_MARGIN_MM
@@ -956,6 +958,7 @@ fn sheet_overlaps(b: [f64; 4], window: [f64; 4]) -> bool {
&& b[3] >= window[1] - CULL_MARGIN_MM
}
#[cfg(not(target_arch = "wasm32"))]
fn grow(bounds: &mut Option<[f64; 4]>, x: f64, y: f64) {
if !x.is_finite() || !y.is_finite() {
return;
@@ -967,6 +970,7 @@ fn grow(bounds: &mut Option<[f64; 4]>, x: f64, y: f64) {
b[3] = b[3].max(y);
}
#[cfg(not(target_arch = "wasm32"))]
/// Sheet-mm bounds of everything a wire inks (strokes, glyphs, fills).
fn wire_sheet_bounds(wire: &WireModel, ox: f64, oy: f64, marker_h: f64) -> Option<[f64; 4]> {
let mut bounds = None;
@@ -991,6 +995,7 @@ fn wire_sheet_bounds(wire: &WireModel, ox: f64, oy: f64, marker_h: f64) -> Optio
bounds
}
#[cfg(not(target_arch = "wasm32"))]
/// Sheet-mm bounds of a hatch, resolved the way `emit_hatch` places it.
fn hatch_sheet_bounds(hatch: &HatchModel, ox: f64, oy: f64) -> Option<[f64; 4]> {
let mut bounds = None;
-1
View File
@@ -178,7 +178,6 @@ pub fn extract_to_png(input: &std::path::Path, output: &std::path::Path, size: u
/// Read a DWG's embedded preview and decode it to an iced image handle for the
/// Start page's recent-file thumbnails. `None` for DXF/other files, a missing
/// preview, or an undecodable format (WMF).
#[cfg(not(target_arch = "wasm32"))]
pub fn read_handle(path: &std::path::Path) -> Option<iced::widget::image::Handle> {
let img = dwg_thumbnailer::extract(path, MAX_DIM)?;
let (w, h) = (img.width(), img.height());