From e06b2a7ead198debf4e0a36ebf9ac234e5bc5227 Mon Sep 17 00:00:00 2001 From: Helen Kwok <107752876+helenkwok@users.noreply.github.com> Date: Thu, 5 Nov 2026 17:08:01 +0800 Subject: [PATCH] gridcraft-web: speak the host messages through craft-web-host The transports, the message types and the origin checks come from the shared crate (storytold/craft-libs#420); GridCraft keeps the download hook, the open size limit, the workbook-saved rule and the author. --- Cargo.lock | 10 ++ apps/gridcraft-web/Cargo.toml | 2 + apps/gridcraft-web/src/host.rs | 241 +++++++---------------------- apps/gridcraft-web/src/hostmode.rs | 43 ++--- apps/gridcraft-web/src/web.rs | 18 +-- packaging/web/README.md | 4 +- 6 files changed, 88 insertions(+), 230 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 785493348..dfdde30e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -995,6 +995,15 @@ dependencies = [ "zip 9.1.0", ] +[[package]] +name = "craft-web-host" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=2e2312ddaf21bc3d85cd3395d0955c7d239306f6#2e2312ddaf21bc3d85cd3395d0955c7d239306f6" +dependencies = [ + "wasm-bindgen", + "web-sys", +] + [[package]] name = "craft-window" version = "0.1.0" @@ -2186,6 +2195,7 @@ dependencies = [ name = "gridcraft-web" version = "0.16.0" dependencies = [ + "craft-web-host", "eframe", "egui", "gridcraft-engine", diff --git a/apps/gridcraft-web/Cargo.toml b/apps/gridcraft-web/Cargo.toml index e384ffe09..e5c599bd8 100644 --- a/apps/gridcraft-web/Cargo.toml +++ b/apps/gridcraft-web/Cargo.toml @@ -16,6 +16,8 @@ path = "src/main.rs" [dependencies] gridcraft-engine = { workspace = true } gridcraft-ui-egui = { 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" } egui = { workspace = true } log = { workspace = true } serde_json = { workspace = true } diff --git a/apps/gridcraft-web/src/host.rs b/apps/gridcraft-web/src/host.rs index 0ab4fefbb..4a7193b73 100644 --- a/apps/gridcraft-web/src/host.rs +++ b/apps/gridcraft-web/src/host.rs @@ -1,127 +1,61 @@ //! Host modes: a page that runs GridCraft (as an iframe, or in its own document) opens workbooks -//! in it and stores what it saves instead of the browser downloading. +//! in it and stores what it saves instead of the browser downloading. The messages and the two +//! transports are `craft-web-host`'s (storytold/craft-libs), the same contract as the other Craft +//! apps' bridges, with the `gridcraft:` prefix. This module is GridCraft's part of it. //! -//! ## `?host=parent` — an `