port sync: the web build takes the platform browser file service (L-313, L-317)

This commit is contained in:
Dylan M. Taylor committed 2026-11-22 23:18:14 -05:00
1 parent 003fb88763
commit 3404bf4ac7
2 files changed
+9 -4

No files matched your search

+1 -1
View File
@@ -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" }
+8 -3
View File
@@ -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());