M15.1: web build (eframe wasm) + xtask web
- apps/effectcraft-web (L6): eframe web runner booting the shared EffectcraftApp with a browser session: in-memory file table, <input type=file> pickers and drag-and-drop for open/import, downloads for Save and Render Queue outputs (several files as one stored .zip), and the window.effectcraft promise API over the control channel. Demo project on start. - wasm32 runtime fixes: web-time for Instant/SystemTime (render, engine, export, ui-egui); Frames renders queued jobs on the UI thread (Frames::pump) instead of a thread pool; Render Queue runs inline; relative outputs resolve under / ; control PNGs inline. - effectcraft-export: per-job output Sink (files to memory instead of disk); host FileExporter carries it; test that sink exports touch no file. - xtask web [--dev] [--serve PORT] (wasm-bindgen 0.2.129, optional wasm-opt, COOP/COEP server); effectcraft-web in WEB_CRATES. docs/web.md, headless Chrome smoke test, favicon (+attribution). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c925ac8ae8
commit
31f192e2a9
@@ -355,7 +355,9 @@ fn render_frame(app: &EffectcraftApp, p: &Value) -> Outcome {
|
||||
Err(e) => return err(e),
|
||||
};
|
||||
let mut out = json!({"comp": cid.0, "time": t.seconds(), "width": w, "height": h});
|
||||
if p.get("base64").and_then(Value::as_bool) == Some(true) {
|
||||
// (the web has no file system: inline unless a path is given)
|
||||
let inline = p.get("base64").and_then(Value::as_bool).unwrap_or(cfg!(target_arch = "wasm32") && p.get("path").is_none());
|
||||
if inline {
|
||||
out["png"] = json!(base64(&png));
|
||||
return ok(out);
|
||||
}
|
||||
@@ -427,6 +429,13 @@ pub fn save_screenshot(ctx: &egui::Context, image: &egui::ColorImage, path: Opti
|
||||
rgba.extend_from_slice(&[c.r(), c.g(), c.b(), 255]);
|
||||
}
|
||||
}
|
||||
if path.is_none() && cfg!(target_arch = "wasm32") {
|
||||
// no file system on the web: inline PNG
|
||||
return match encode_png(&rgba, cw as u32, ch as u32) {
|
||||
Ok(png) => json!({"ok": true, "result": {"png": base64(&png), "width": cw, "height": ch}}),
|
||||
Err(e) => json!({"ok": false, "error": e}),
|
||||
};
|
||||
}
|
||||
let path = path.map(str::to_string).unwrap_or_else(|| std::env::temp_dir().join("effectcraft-screenshot.png").to_string_lossy().to_string());
|
||||
match encode_png(&rgba, cw as u32, ch as u32) {
|
||||
Ok(png) => match std::fs::write(&path, png) {
|
||||
|
||||
Reference in New Issue
Block a user