From f9bf685cbdf55d01aa2f00a167127724cf2c4959 Mon Sep 17 00:00:00 2001 From: Helen Kwok <107752876+helenkwok@users.noreply.github.com> Date: Fri, 6 Nov 2026 22:25:08 +0800 Subject: [PATCH] vectorcraft-web: window.vectorcraft 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, the screenshot's PNG also in data, and docInspect and uiInspect beside them. A call the page gave up on gives up its request if the app has not started it, so the app skips it. openFile, captureDownloads, files, readFile and inspect stay VectorCraft's own, on the same object. --- Cargo.lock | 12 +++ apps/vectorcraft-web/Cargo.toml | 2 + apps/vectorcraft-web/src/api.rs | 144 +++++++++++++++++++------------- apps/vectorcraft-web/src/web.rs | 2 - docs/control-protocol.md | 8 +- 5 files changed, 104 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32cffe9fd..6f92cb310 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1093,6 +1093,17 @@ dependencies = [ "thiserror 2.0.21", ] +[[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-window" version = "0.1.0" @@ -6594,6 +6605,7 @@ dependencies = [ name = "vectorcraft-web" version = "0.21.0" dependencies = [ + "craft-web-api", "eframe", "egui", "js-sys", diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index 8decb13d8..ff4bcef86 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -16,6 +16,8 @@ path = "src/main.rs" [dependencies] vectorcraft-engine = { workspace = true, features = ["bundled-fonts"] } vectorcraft-ui-egui = { workspace = true } +# The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "fd5e2feff6ea25bed371a99cc732b3968d621505", version = "0.1.0" } vectorcraft-format = { workspace = true } vectorcraft-text = { workspace = true } egui = { workspace = true } diff --git a/apps/vectorcraft-web/src/api.rs b/apps/vectorcraft-web/src/api.rs index 526e56be1..eddd04f1b 100644 --- a/apps/vectorcraft-web/src/api.rs +++ b/apps/vectorcraft-web/src/api.rs @@ -1,14 +1,18 @@ //! `window.vectorcraft`: the control channel for the page, as promises. //! +//! `request`, `execute`, `commands`, `docInspect`, `uiInspect` and `screenshot` come from +//! `craft-web-api` (storytold/craft-libs#413), the same in every Craft app; VectorCraft adds its own +//! functions on the same object. +//! //! The same JSON methods as the desktop control server (`docs/control-protocol.md`), so an agent //! driving VectorCraft in a browser tab (or an `