FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Web: public set_context for a host that runs its own WebApp
rossaai83501964f60b
diff --git a/apps/filmcraft-web/src/lib.rs b/apps/filmcraft-web/src/lib.rsindex 469d2107a..1286932ec 100644--- a/apps/filmcraft-web/src/lib.rs+++ b/apps/filmcraft-web/src/lib.rs@@ -58,6 +58,13 @@ pub fn repaint() {});}+/// Give a host that builds its own [`WebApp`] the egui context that [`post`] and [`repaint`] wake.+/// [`start`] calls it; an embedding app that runs `WebApp` in its own eframe runner calls it once+/// from its app creator, or posted actions and JS API requests wait for the next input event.+pub fn set_context(ctx: egui::Context) {+ CTX.with(|c| *c.borrow_mut() = Some(ctx));+}+/// Environment facts reported by `filmcraft.info()` (backend, isolation, codecs…).pub fn set_info(key: &str, v: serde_json::Value) {INFO.with(|i| {@@ -150,7 +157,7 @@ pub async fn start(canvas_id: String) -> Result<(), JsValue> {canvas,web_options,Box::new(move |cc| {- CTX.with(|c| *c.borrow_mut() = Some(cc.egui_ctx.clone()));+ set_context(cc.egui_ctx.clone());let ctx = cc.egui_ctx.clone();fs::set_on_data(move || ctx.request_repaint());fs::set_on_write(|path, data| {