From 3404bf4ac772cb30d7d5b73fa87f6a862064b263 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 22 Nov 2026 23:18:14 -0500 Subject: [PATCH] port sync: the web build takes the platform browser file service (L-313, L-317) --- apps/pdfcraft-web/Cargo.toml | 2 +- apps/pdfcraft-web/src/main.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/pdfcraft-web/Cargo.toml b/apps/pdfcraft-web/Cargo.toml index 8388b8e903..fff803b3ca 100644 --- a/apps/pdfcraft-web/Cargo.toml +++ b/apps/pdfcraft-web/Cargo.toml @@ -12,7 +12,7 @@ workspace = true [dependencies] pdfcraft-ui-egui = { workspace = true } # The framework, through its facade (contract head), with the UI runtime the canvas is installed with. -craft = { workspace = true, features = ["automation", "ui", "window"] } +craft = { workspace = true, features = ["automation", "platform-browser", "ui", "window"] } # The host messages (storytold/craft-libs): one contract and one bridge for the web builds. # The page command API (storytold/craft-libs#413): window.pdfcraft over the UI control channel. craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "527c2750e37fb8bf576dc9a9e07ffc60b9d63717", version = "0.1.0" } diff --git a/apps/pdfcraft-web/src/main.rs b/apps/pdfcraft-web/src/main.rs index 1ef3ae644e..0dad4605b9 100644 --- a/apps/pdfcraft-web/src/main.rs +++ b/apps/pdfcraft-web/src/main.rs @@ -22,15 +22,20 @@ fn main() { canvas, options, Box::new(|cc| { - // PLAN: assumed pdfcraft_ui_egui::settings::open() -> Store over craft::settings::BrowserFiles on wasm32, with the former PrintCraft key migrated (pdf-shell-w9, SH-C29, L-117). + // `settings::open()` is a store over `craft::settings::LocalStorageFiles` on wasm32, with the former PrintCraft key migrated. let settings = pdfcraft_ui_egui::settings::open(); install_runtime(cc, startup_lang(settings.get().behavior.language.as_deref()))?; let ctx = cc.egui_ctx.clone(); let wake = craft::host::Wake::new(move || ctx.request_repaint()); // Files to open: a `?file=` download, the embedding page's `pdfcraft:open`, a drop. let (intake, opens) = craft::platform::open::FileIntake::new(wake.clone()); - // Picks read the browser's files; saves download, or go to the embedding page. - let files = craft::web_host::files::BrowserFiles::new(wake, host::MAX_OPEN_BYTES); + // Picks read the browser's files, holding at most `MAX_OPEN_BYTES` until they are taken; saves go + // through the browser's save picker or download. + let limits = craft::platform::browser_files::PickLimits { + pending_bytes: usize::try_from(host::MAX_OPEN_BYTES).unwrap_or(usize::MAX), + ..craft::platform::browser_files::PickLimits::DEFAULT + }; + let files = craft::platform::browser_files::BrowserFiles::new(move || wake.wake()).limits(limits); let app_host = craft::host::Host::builder(pdfcraft_ui_egui::APP_INFO).files(Arc::new(files)).build(); let mut app = PdfCraftApp::with_host(Arc::new(app_host), AppServices::system(&cc.egui_ctx, intake)); app.apply_settings(&settings.get());