diff --git a/Cargo.lock b/Cargo.lock index 24536ff9..f9ddf78e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1860,6 +1860,7 @@ dependencies = [ name = "figcraft-web" version = "0.11.2" dependencies = [ + "base64 0.22.1", "eframe", "egui", "figcraft-collab-net", @@ -1867,6 +1868,7 @@ dependencies = [ "figcraft-ui-egui", "js-sys", "log", + "serde_json", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", diff --git a/apps/figcraft-web/Cargo.toml b/apps/figcraft-web/Cargo.toml index ffd44f3b..aa0fdffb 100644 --- a/apps/figcraft-web/Cargo.toml +++ b/apps/figcraft-web/Cargo.toml @@ -24,6 +24,8 @@ log = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } wasm-bindgen = "0.2" +base64 = { workspace = true } +serde_json = { workspace = true } js-sys = "0.3" wasm-bindgen-futures = "0.4" web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlCanvasElement", "HtmlElement", "HtmlAnchorElement", "Node", "Blob", "BlobPropertyBag", "File", "FileList", "HtmlInputElement", "EventTarget", "Url", "Location", "MediaQueryList", "Navigator", "Gamepad", "GamepadButton", "GamepadMappingType"] } diff --git a/apps/figcraft-web/src/api.rs b/apps/figcraft-web/src/api.rs new file mode 100644 index 00000000..621925cf --- /dev/null +++ b/apps/figcraft-web/src/api.rs @@ -0,0 +1,172 @@ +//! `window.figcraft`: the control channel for the page, as promises. +//! +//! The same JSON methods as the desktop control server (`docs/control-protocol.md`), so an agent +//! driving FigCraft in a browser tab (or an `