From 5a8e6e4894dedb684e7bfc5d1e02df8bf4064566 Mon Sep 17 00:00:00 2001 From: Helen Kwok <107752876+helenkwok@users.noreply.github.com> Date: Thu, 5 Nov 2026 17:16:17 +0800 Subject: [PATCH] wordcraft-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); WordCraft keeps the host save and dirty hooks, the saveAs rule, the open size limit and the author. --- Cargo.lock | 10 ++ apps/wordcraft-web/Cargo.toml | 2 + apps/wordcraft-web/src/host.rs | 255 +++++++---------------------- apps/wordcraft-web/src/hostmode.rs | 22 --- apps/wordcraft-web/src/main.rs | 2 - apps/wordcraft-web/src/web.rs | 10 +- packaging/web/README.md | 4 +- 7 files changed, 74 insertions(+), 231 deletions(-) delete mode 100644 apps/wordcraft-web/src/hostmode.rs diff --git a/Cargo.lock b/Cargo.lock index 64ed59e285..45ddd60ad3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1157,6 +1157,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" @@ -7085,6 +7094,7 @@ dependencies = [ name = "wordcraft-web" version = "0.15.1" dependencies = [ + "craft-web-host", "eframe", "egui", "js-sys", diff --git a/apps/wordcraft-web/Cargo.toml b/apps/wordcraft-web/Cargo.toml index 1d6d8cc344..971daf0cbd 100644 --- a/apps/wordcraft-web/Cargo.toml +++ b/apps/wordcraft-web/Cargo.toml @@ -16,6 +16,8 @@ path = "src/main.rs" [dependencies] wordcraft-engine = { workspace = true } wordcraft-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/wordcraft-web/src/host.rs b/apps/wordcraft-web/src/host.rs index 812114d99f..5977fd80e9 100644 --- a/apps/wordcraft-web/src/host.rs +++ b/apps/wordcraft-web/src/host.rs @@ -1,19 +1,20 @@ //! Host modes: a page that runs WordCraft (as an `