From 6ca4463a26b7625e2c9917ad89f55048969e07d1 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sat, 8 Aug 2026 03:34:57 +0300 Subject: [PATCH] fix(web): give the browser build a load_file to fail through MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reading a drawing by path is gated off on wasm, and two features added since 0.9.3 call it unconditionally: importing a drawing as a block, and taking layer standards from one. Both compile into the web build, so the web bundle stopped building and the v0.9.4 Pages deploy failed. Neither feature can work in the browser — a file arrives through the page, not from a filesystem the app can open — so the fix is not to make them work but to let them say so. `load_file` now exists on wasm and returns that as its error, which both callers already surface. Keeping the signature means neither has to know that the web has no files, and the next feature that reads a second drawing will not break the bundle either. Co-Authored-By: Claude Opus 5 --- locales/en-US/opencadstudio.ftl | 1 + src/io/mod.rs | 13 +++++++++++++ src/locale_catalog.rs | 1 + 3 files changed, 15 insertions(+) diff --git a/locales/en-US/opencadstudio.ftl b/locales/en-US/opencadstudio.ftl index cc7bb55fe..8763f703a 100644 --- a/locales/en-US/opencadstudio.ftl +++ b/locales/en-US/opencadstudio.ftl @@ -3436,3 +3436,4 @@ catalog-tcount-placement-must-be-overwrite-prefix-or-s-84211d2b75 = TCOUNT: plac catalog-tcount-numbered-n-text-object-s-from-start-by-30588884cc = TCOUNT: numbered __ocs_fmt_0__ text object(s) from __ocs_fmt_1__ by __ocs_fmt_2__ (__ocs_fmt_3__). catalog-prefix-90eceb016c = Prefix catalog-suffix-885db975a3 = Suffix +catalog-opening-a-drawing-by-path-is-not-available-in-be27bd71d4 = Opening a drawing by path is not available in the browser. diff --git a/src/io/mod.rs b/src/io/mod.rs index c272087be..0b8263e00 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -747,6 +747,19 @@ pub fn load_file(path: &Path) -> Result { load_file_with_progress(path, None).map(|outcome| outcome.document) } +/// Opening a drawing by path is a desktop affair. In the browser a file +/// arrives through the page rather than from a filesystem the app can reach, +/// so there is nothing behind a path to open. +/// +/// The function still exists there so the features that read a *second* +/// drawing — importing one as a block, taking layer standards from one — go on +/// compiling and say why they cannot run, instead of each having to know that +/// the web has no files. +#[cfg(target_arch = "wasm32")] +pub fn load_file(_path: &Path) -> Result { + Err(crate::t!("Opening a drawing by path is not available in the browser.").into_owned()) +} + pub(crate) fn load_file_with_progress( path: &Path, _progress: Option>, diff --git a/src/locale_catalog.rs b/src/locale_catalog.rs index d9e16fc8c..a579ad768 100644 --- a/src/locale_catalog.rs +++ b/src/locale_catalog.rs @@ -53,6 +53,7 @@ pub(super) fn message_id(source: &str) -> Option<&'static str> { " ⚠ No closed boundary found." => Some("catalog-no-closed-boundary-found-7a55b25ecb"), " (%{count} objects)" => Some("catalog-count-objects-83518eccc2"), " [Edge: Extend]" => Some("catalog-edge-extend-90a0cb9b4f"), + "Opening a drawing by path is not available in the browser." => Some("catalog-opening-a-drawing-by-path-is-not-available-in-be27bd71d4"), "Prefix" => Some("catalog-prefix-90eceb016c"), "Suffix" => Some("catalog-suffix-885db975a3"), "TCOUNT increment <{increment}>:" => Some("catalog-tcount-increment-increment-79f9ab6108"),