mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-22 18:22:00 +00:00
With a document open in the web app, Place Embedded was disabled because its menu enablement inherited the engine's native-filesystem check, although the menu path reads the picker's bytes and never touches a path. Place Embedded is now enabled whenever a document and a file-dialog service exist; Place Linked keeps the engine's native guard, since the web could only link to a bare file name (caught in #5817 by Higgs32584). An enablement test runs with the native check forced off, and a file-dialog test covers the browser answer shape, cancel, invalid bytes and the Free Transform handoff. Fixes #1209. Fixes #5749.
52 lines
2.2 KiB
Rust
52 lines
2.2 KiB
Rust
//! PhotoCraft in the browser.
|
|
//!
|
|
//! Runs the same [`photocraft_ui_egui::PhotocraftApp`] as the desktop app through eframe's web
|
|
//! runner (wgpu: WebGPU where available, WebGL2 otherwise). Build with `trunk build --release`
|
|
//! from this directory; see `docs/development.md` ("Web build").
|
|
//!
|
|
//! Differences from the desktop app:
|
|
//! - no TCP control server (browsers can't listen on sockets);
|
|
//! - file pickers return browser file contents asynchronously through `Services::file_dialog`;
|
|
//! this includes File → Open and commands such as Place Embedded;
|
|
//! - saving/exporting triggers a browser download;
|
|
//! - dropped files are read asynchronously by `web::WebShell` and delivered through `Services::inbox`.
|
|
//!
|
|
//! URL query flags: `?cpu` forces the CPU canvas path (same as `PHOTOCRAFT_CPU_CANVAS=1`);
|
|
//! `?webgl` forces the WebGL2 backend instead of WebGPU.
|
|
|
|
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
|
|
|
#[cfg(any(target_arch = "wasm32", test))]
|
|
mod preset_bridge;
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
mod indexed_presets;
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
mod web;
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
fn main() {
|
|
web::start();
|
|
}
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
fn main() {
|
|
eprintln!("photocraft-web only runs in the browser: build it with `trunk build --release` in apps/photocraft-web");
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
/// A WebAssembly module that never downloads (or doesn't match the page) runs no Rust, so the
|
|
/// page itself replaces the endless "Loading" with what may have gone wrong and a way to
|
|
/// retry, without a hand-written script.
|
|
#[test]
|
|
fn loading_page_offers_a_reload_when_startup_stalls() {
|
|
let html = include_str!("../index.html");
|
|
let (_, hint) = html.split_once("<p id=\"photocraft_stalled\">").expect("stalled-startup hint in the loading element");
|
|
assert!(hint.contains("failed to") && hint.contains("<a href=\"\">Reload</a>"), "{hint}");
|
|
assert!(html.contains("animation: photocraft-stalled"), "the hint appears after a delay");
|
|
assert!(!html.contains("<script"), "trunk injects the generated loader; the page has no script of its own");
|
|
}
|
|
}
|