From 929911326873116404a2d85e00d5fa0ac5326989 Mon Sep 17 00:00:00 2001 From: Helen Kwok <107752876+helenkwok@users.noreply.github.com> Date: Thu, 5 Nov 2026 17:34:20 +0800 Subject: [PATCH] deckcraft-web: speak the host messages through craft-web-host, and add page host mode The transports, the message types and the origin checks come from the shared crate (storytold/craft-libs#420). `data-host="page"` on the canvas now hosts DeckCraft in a page's own document, as in the other apps; the parent bridge keeps its behaviour. --- Cargo.lock | 10 ++ apps/deckcraft-web/Cargo.toml | 2 + apps/deckcraft-web/src/host.rs | 163 +++++++++++---------------------- apps/deckcraft-web/src/web.rs | 12 ++- packaging/web/README.md | 4 +- 5 files changed, 74 insertions(+), 117 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89aaa91aa..b4059e689 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -935,6 +935,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 = "crc32fast" version = "1.5.2" @@ -1322,6 +1331,7 @@ dependencies = [ name = "deckcraft-web" version = "0.15.0" dependencies = [ + "craft-web-host", "deckcraft-engine", "deckcraft-ui-egui", "eframe", diff --git a/apps/deckcraft-web/Cargo.toml b/apps/deckcraft-web/Cargo.toml index ca04d5be9..58e8657a4 100644 --- a/apps/deckcraft-web/Cargo.toml +++ b/apps/deckcraft-web/Cargo.toml @@ -16,6 +16,8 @@ path = "src/main.rs" [dependencies] deckcraft-engine = { workspace = true } deckcraft-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/deckcraft-web/src/host.rs b/apps/deckcraft-web/src/host.rs index 85c357a12..5cf4b0399 100644 --- a/apps/deckcraft-web/src/host.rs +++ b/apps/deckcraft-web/src/host.rs @@ -1,17 +1,21 @@ -//! The `postMessage` bridge to a same-origin parent page (`?host=parent`), for pages that embed -//! DeckCraft in an `