diff --git a/src/app/document.rs b/src/app/document.rs index 9196c4cc2..42da78413 100644 --- a/src/app/document.rs +++ b/src/app/document.rs @@ -159,6 +159,7 @@ pub(super) struct DocumentTab { /// rest of the code can treat it as a normal tab when reading. pub(super) is_start: bool, /// Per-plugin document state (`plugin::BuiltinPlugin` manifest id → state). + #[cfg_attr(target_arch = "wasm32", allow(dead_code))] pub(super) plugin_state: HashMap<&'static str, Box>, pub(super) suspended_cmd: Option>, } diff --git a/src/app/helpers.rs b/src/app/helpers.rs index b86dad5d6..2cd10a909 100644 --- a/src/app/helpers.rs +++ b/src/app/helpers.rs @@ -286,6 +286,7 @@ pub(super) fn title_case_word(value: &str) -> String { // ── Window icon ──────────────────────────────────────────────────────────── /// Builds a 32×32 RGBA icon: red background with OCS drawn in white pixels. +#[cfg(not(target_arch = "wasm32"))] pub(super) fn build_window_icon() -> Vec { const W: usize = 32; const SZ: usize = W * W * 4; diff --git a/src/app/mod.rs b/src/app/mod.rs index 5c195be22..32fd79687 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -11,6 +11,7 @@ mod history; mod layers; mod model_ops; mod mtext_editor; +#[cfg(not(target_arch = "wasm32"))] pub mod plugin_host; mod properties; mod settings; @@ -819,6 +820,7 @@ pub enum ModalKind { DimStyle, Unsaved, SaveDialog, + #[cfg_attr(target_arch = "wasm32", allow(dead_code))] AssocPrompt, PointStyle, } @@ -2020,6 +2022,7 @@ impl OpenCADStudio { /// open. Secondary manager windows are unavailable on the web for now. #[cfg(target_arch = "wasm32")] fn boot_web() -> (Self, Task) { + #[cfg_attr(target_arch = "wasm32", allow(unused_mut))] let mut s = Self::new(); let focus = s.focus_cmd_input(); (s, focus) diff --git a/src/app/update.rs b/src/app/update.rs index 9bb502015..e0607017f 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -238,6 +238,7 @@ impl OpenCADStudio { /// Snapshot of disabled plugin ids — lets the registry skip them while it /// holds a `&mut` borrow of the app via `HostSession`. + #[cfg(not(target_arch = "wasm32"))] pub(crate) fn disabled_plugin_ids(&self) -> rustc_hash::FxHashSet { self.disabled_plugins.clone() } diff --git a/src/app/view.rs b/src/app/view.rs index 5b7e6d04b..7cf6ffd87 100644 --- a/src/app/view.rs +++ b/src/app/view.rs @@ -38,6 +38,7 @@ impl std::fmt::Display for RenderModeChoice { } impl OpenCADStudio { + #[cfg(not(target_arch = "wasm32"))] pub fn view(&self, window_id: window::Id) -> Element<'_, Message> { // ── Floating panel windows ───────────────────────────────────────── // All dialogs are in-canvas modals now (Plan B); view_main stacks the @@ -3893,6 +3894,7 @@ pub(super) fn start_page_view<'a>() -> Element<'a, Message> { .spacing(12) .align_y(iced::Center); + #[cfg_attr(target_arch = "wasm32", allow(unused_mut))] let mut secondary_row = row![ outline_btn( "Send Feedback", diff --git a/src/io/file_association.rs b/src/io/file_association.rs index caeba946a..4aff996ed 100644 --- a/src/io/file_association.rs +++ b/src/io/file_association.rs @@ -37,6 +37,7 @@ const APP_ID: &str = "io.github.HakanSeven12.OpenCadStudio"; /// Idempotent and best-effort; safe to call on every launch. Runs synchronously /// (registry / small file writes), so callers should invoke it off the UI /// thread. +#[cfg(not(target_arch = "wasm32"))] pub fn register_as_handler() -> Result<(), String> { #[cfg(target_os = "windows")] { diff --git a/src/io/mod.rs b/src/io/mod.rs index da1f9a4c0..1e8872376 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -31,6 +31,7 @@ const PHASE_FINALIZING: u8 = 3; /// Show the file picker and return the chosen path plus its size in bytes. /// Returning size up-front lets the loading overlay display "47.3 MB" before /// the parser thread starts. +#[cfg(not(target_arch = "wasm32"))] pub async fn pick_open_path() -> Option<(PathBuf, u64)> { let handle = rfd::AsyncFileDialog::new() .set_title("Open CAD file") diff --git a/src/plugin/external.rs b/src/plugin/external.rs index b98a77b98..f3417fac1 100644 --- a/src/plugin/external.rs +++ b/src/plugin/external.rs @@ -79,6 +79,7 @@ pub fn plugins_dir() -> Option { /// Delete an installed package's folder. It stays loaded for the current /// session (the library is resident); the removal takes effect on next start. +#[cfg(not(target_arch = "wasm32"))] pub fn uninstall(id: &str) -> Result<(), String> { let dir = plugins_dir().ok_or("cannot locate the plugins folder")?.join(id); if dir.is_dir() { diff --git a/src/plugin/host.rs b/src/plugin/host.rs index fa85313c8..4cfd3dcac 100644 --- a/src/plugin/host.rs +++ b/src/plugin/host.rs @@ -4,4 +4,5 @@ // The session adapter the registry wraps `app` in to dispatch to plugins. The // plugin-facing contract — `BuiltinPlugin` + `HostApi` — lives in // `ocs_plugin_api`; external cdylibs target it directly. +#[cfg(not(target_arch = "wasm32"))] pub(crate) use crate::app::plugin_host::HostSession; \ No newline at end of file diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs index c850649a0..5964f7132 100644 --- a/src/plugin/mod.rs +++ b/src/plugin/mod.rs @@ -16,6 +16,7 @@ pub(crate) use registry::try_dispatch; /// the cdylib boundary — it does NOT contain genuine UB (a plugin that /// segfaults or violates memory safety via `unsafe` can still crash the host; /// only out-of-process isolation would). (#145) +#[cfg(not(target_arch = "wasm32"))] pub(crate) fn guard(what: &str, f: impl FnOnce() -> T) -> Option { match std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)) { Ok(v) => Some(v), @@ -38,12 +39,14 @@ pub(crate) fn guard(what: &str, f: impl FnOnce() -> T) -> Option { /// Process-wide queue of plugin-guard errors waiting to surface in the host's /// command-line history. Flushed by [`drain_errors`] from the app loop. +#[cfg(not(target_arch = "wasm32"))] fn errors() -> &'static std::sync::Mutex> { static E: std::sync::OnceLock>> = std::sync::OnceLock::new(); E.get_or_init(|| std::sync::Mutex::new(Vec::new())) } /// Take and return every queued plugin-guard error since the last drain. +#[cfg(not(target_arch = "wasm32"))] pub(crate) fn drain_errors() -> Vec { std::mem::take(&mut *errors().lock().unwrap()) } diff --git a/src/plugin/registry.rs b/src/plugin/registry.rs index 2fd02678a..4a7e74fcb 100644 --- a/src/plugin/registry.rs +++ b/src/plugin/registry.rs @@ -15,6 +15,7 @@ pub fn all_ribbon_modules() -> Vec> { pub fn ribbon_modules_enabled( disabled: &rustc_hash::FxHashSet, ) -> Vec> { + #[cfg_attr(target_arch = "wasm32", allow(unused_mut))] let mut core = core_registry::all_modules(); // Dynamically-loaded external plugins contribute tabs (their libraries stay // resident for the session, so these vtables remain valid). diff --git a/src/scene/convert/solid3d_tess.rs b/src/scene/convert/solid3d_tess.rs index 202644d42..140578d58 100644 --- a/src/scene/convert/solid3d_tess.rs +++ b/src/scene/convert/solid3d_tess.rs @@ -385,6 +385,7 @@ pub(crate) fn collect_loop_polygon( /// All loops of a face: the outer boundary first, then any inner hole loops. /// Each loop is returned as an ordered 3-D polygon (≥ 3 points). +#[cfg(feature = "solid3d")] pub(crate) fn collect_face_loops( sat: &SatDocument, face: &SatFace, diff --git a/src/scene/convert/truck_tess.rs b/src/scene/convert/truck_tess.rs index 0757c6da8..af8c6fa64 100644 --- a/src/scene/convert/truck_tess.rs +++ b/src/scene/convert/truck_tess.rs @@ -19,6 +19,7 @@ use truck_polymesh::PolygonMesh; // Chord-height tolerance used for adaptive curve sampling (world units). const CURVE_TOL: f64 = 0.005; // Triangle mesh tolerance (world units). +#[allow(dead_code)] pub const MESH_TOL: f64 = 0.01; // ── Zoom-adaptive curve tolerance override ──────────────────────────────── diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 7468248f3..329c25382 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -2429,6 +2429,7 @@ impl Scene { /// Pick a meshed 3D solid by clicking on its shaded body (face), not just /// its thin projected edges. Returns the front-most mesh under `cursor`. + #[allow(dead_code)] pub fn mesh_click_hit( &self, cursor: iced::Point, diff --git a/src/scene/pipeline/hatch_batched_gpu.rs b/src/scene/pipeline/hatch_batched_gpu.rs index 086008ec2..51981b920 100644 --- a/src/scene/pipeline/hatch_batched_gpu.rs +++ b/src/scene/pipeline/hatch_batched_gpu.rs @@ -106,6 +106,7 @@ pub struct HatchBatchedVertex { } impl HatchBatchedVertex { + #[allow(dead_code)] pub fn layout<'a>() -> wgpu::VertexBufferLayout<'a> { wgpu::VertexBufferLayout { array_stride: std::mem::size_of::() as u64, @@ -450,6 +451,7 @@ impl HatchBatchedGpu { /// constructed once at startup. All four bindings are read-only /// storage and visible to both VS (AABB+visibility lookup) and FS /// (boundary / family / dash sampling). + #[allow(dead_code)] pub fn bind_group_layout(device: &wgpu::Device) -> wgpu::BindGroupLayout { let entry = |binding: u32| wgpu::BindGroupLayoutEntry { binding, diff --git a/src/scene/pipeline/mod.rs b/src/scene/pipeline/mod.rs index cca865d74..19b4c397c 100644 --- a/src/scene/pipeline/mod.rs +++ b/src/scene/pipeline/mod.rs @@ -1001,7 +1001,7 @@ impl Pipeline { // O(highlighted), no per-wire string parse. Selection recolours blue, // hover orange. Drawn on top (depth-compare Always) over the base pass. let mut out: Vec = Vec::new(); - let mut push = |handle_val: u64, color: [f32; 4], wires: &[WireModel], out: &mut Vec| { + let push = |handle_val: u64, color: [f32; 4], wires: &[WireModel], out: &mut Vec| { if let Some(idxs) = self.wire_handle_index.get(&handle_val) { let mut slots = idxs.clone(); slots.sort_unstable(); diff --git a/src/scene/pipeline/wire_gpu.rs b/src/scene/pipeline/wire_gpu.rs index 0215e0c84..90da71bfb 100644 --- a/src/scene/pipeline/wire_gpu.rs +++ b/src/scene/pipeline/wire_gpu.rs @@ -24,6 +24,7 @@ use crate::scene::model::wire_model::WireModel; use iced::wgpu; +#[cfg(not(target_arch = "wasm32"))] use crate::par::prelude::*; /// Allocate a VERTEX buffer with `mapped_at_creation` and write `data` directly diff --git a/src/scene/text/ttf_glyph.rs b/src/scene/text/ttf_glyph.rs index 1203c1347..c17b10a60 100644 --- a/src/scene/text/ttf_glyph.rs +++ b/src/scene/text/ttf_glyph.rs @@ -205,6 +205,7 @@ fn shape_cache() -> &'static Mutex { /// Pixel font size the layout runs at. Positions and outlines are normalized /// out of pixel space afterwards, so the exact value only affects rounding. +#[allow(dead_code)] const SHAPE_FS: f32 = 1000.0; /// Shared cosmic-text layout engine, loaded once with the system fonts. Held diff --git a/src/scene/text/web_font.rs b/src/scene/text/web_font.rs index b75054196..db765c909 100644 --- a/src/scene/text/web_font.rs +++ b/src/scene/text/web_font.rs @@ -57,6 +57,7 @@ impl Script { /// 2 = Korean. Set from the active document's code page. static CJK_LANG: AtomicU8 = AtomicU8::new(0); +#[cfg(target_arch = "wasm32")] fn cjk_lang() -> Script { match CJK_LANG.load(Ordering::Relaxed) { 1 => Script::Japanese, @@ -83,6 +84,7 @@ pub fn set_cjk_lang_from_codepage(code_page: &str) -> bool { /// The script font that covers `ch`, or `None` for control / uncovered code /// points. Ranges mirror the subset unicode ranges in `web/fonts/generate.sh`. +#[cfg(target_arch = "wasm32")] pub fn script_of(ch: char) -> Option