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