From 78502eea6a1452b2fd1c70ac35730f4f7720f733 Mon Sep 17 00:00:00 2001 From: Helen Kwok <107752876+helenkwok@users.noreply.github.com> Date: Fri, 6 Nov 2026 09:09:24 +0800 Subject: [PATCH] figcraft-web: window.figcraft takes its request functions from craft-web-api request, execute, commands and screenshot move onto the shared crate (storytold/craft-libs#413): a timeout on every call, one data field for the screenshot's PNG, and docInspect and uiInspect beside them. A call the page gave up on cancels its request if the app has not started it, so the app skips it. openFile, captureDownloads, files, readFile and inspect stay FigCraft's own, on the same object. --- Cargo.lock | 14 ++- apps/figcraft-web/Cargo.toml | 4 +- apps/figcraft-web/src/api.rs | 166 ++++++++++++++++++++++------------- apps/figcraft-web/src/web.rs | 1 - docs/control-protocol.md | 8 +- 5 files changed, 125 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 36bd121b6..5fdb9e27b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1157,10 +1157,21 @@ dependencies = [ "zip 9.1.1", ] +[[package]] +name = "craft-web-api" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=fd5e2feff6ea25bed371a99cc732b3968d621505#fd5e2feff6ea25bed371a99cc732b3968d621505" +dependencies = [ + "js-sys", + "serde_json", + "wasm-bindgen", + "wasm-bindgen-futures", +] + [[package]] name = "craft-web-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=2e2312ddaf21bc3d85cd3395d0955c7d239306f6#2e2312ddaf21bc3d85cd3395d0955c7d239306f6" +source = "git+https://github.com/storytold/craft-libs?rev=fd5e2feff6ea25bed371a99cc732b3968d621505#fd5e2feff6ea25bed371a99cc732b3968d621505" dependencies = [ "wasm-bindgen", "web-sys", @@ -2130,6 +2141,7 @@ name = "figcraft-web" version = "0.15.0" dependencies = [ "base64 0.22.1", + "craft-web-api", "craft-web-host", "eframe", "egui", diff --git a/apps/figcraft-web/Cargo.toml b/apps/figcraft-web/Cargo.toml index 7f0b4ded5..c37663258 100644 --- a/apps/figcraft-web/Cargo.toml +++ b/apps/figcraft-web/Cargo.toml @@ -20,7 +20,9 @@ figcraft-ui-egui = { workspace = true } figcraft-collab-net = { workspace = true } figcraft-text = { workspace = true } # The host messages (storytold/craft-libs): one contract and one bridge for the web builds. -craft-web-host = { git = "https://github.com/storytold/craft-libs", rev = "2e2312ddaf21bc3d85cd3395d0955c7d239306f6", version = "0.1.0" } +# The page command API (storytold/craft-libs#413): the request plumbing behind window.figcraft. +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "fd5e2feff6ea25bed371a99cc732b3968d621505", version = "0.1.0" } +craft-web-host = { git = "https://github.com/storytold/craft-libs", rev = "fd5e2feff6ea25bed371a99cc732b3968d621505", version = "0.1.0" } base64 = { workspace = true } egui = { workspace = true } log = { workspace = true } diff --git a/apps/figcraft-web/src/api.rs b/apps/figcraft-web/src/api.rs index 7f6a0ec4d..167ea7687 100644 --- a/apps/figcraft-web/src/api.rs +++ b/apps/figcraft-web/src/api.rs @@ -1,36 +1,54 @@ -//! `window.figcraft`: the control channel for the page, as promises. +//! `window.figcraft`: the page command API (`craft-web-api`, storytold/craft-libs#413) plus FigCraft's +//! own file functions. //! -//! The same JSON methods as the desktop control server (`docs/control-protocol.md`), so an agent -//! driving FigCraft in a browser tab (or an `