From 6e2caa9f865a91cb6843493941ce87e53430305e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 10 Oct 2026 22:51:34 -0400 Subject: [PATCH] Web: opt-in embedding bridge for host pages (?host=parent) A page that frames GridCraft on the same origin can now open workbooks in it and store what it saves, through postMessage, instead of Save and Export becoming browser downloads. Built for a Nextcloud integration, but nothing in it is host-specific. Only the web shell changes: - gridcraft:open from the parent goes through the inbox, like a picked or dropped file - Services::download sends the bytes to the parent (gridcraft:save); an .xlsx workbook handed over counts as saved under that name - gridcraft:dirty reports unsaved changes; gridcraft:ready and gridcraft:failed report start-up - in host mode no sample opens, and ?author= names the user for notes and comments Enabled only by ?host=parent inside a frame; only the parent window on the page's own origin is heard or answered. Without it nothing changes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G6GtUCaPiCMEQCN4QcdQnp --- apps/gridcraft-web/Cargo.toml | 2 +- apps/gridcraft-web/src/host.rs | 166 +++++++++++++++++++++++++++++++++ apps/gridcraft-web/src/main.rs | 7 +- apps/gridcraft-web/src/web.rs | 32 ++++++- 4 files changed, 202 insertions(+), 5 deletions(-) create mode 100644 apps/gridcraft-web/src/host.rs diff --git a/apps/gridcraft-web/Cargo.toml b/apps/gridcraft-web/Cargo.toml index 0f69e38..eac6c13 100644 --- a/apps/gridcraft-web/Cargo.toml +++ b/apps/gridcraft-web/Cargo.toml @@ -26,4 +26,4 @@ rfd = { workspace = true } wasm-bindgen = "0.2" wasm-bindgen-futures = "0.4" js-sys = "0.3" -web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlElement", "HtmlCanvasElement", "HtmlAnchorElement", "HtmlIFrameElement", "Blob", "BlobPropertyBag", "Url", "Location", "CssStyleDeclaration", "Clipboard", "ClipboardItem", "Navigator"] } +web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlElement", "HtmlCanvasElement", "HtmlAnchorElement", "HtmlIFrameElement", "Blob", "BlobPropertyBag", "Url", "Location", "CssStyleDeclaration", "Clipboard", "ClipboardItem", "Navigator", "MessageEvent", "UrlSearchParams"] } diff --git a/apps/gridcraft-web/src/host.rs b/apps/gridcraft-web/src/host.rs new file mode 100644 index 0000000..2286023 --- /dev/null +++ b/apps/gridcraft-web/src/host.rs @@ -0,0 +1,166 @@ +//! The `postMessage` bridge to a same-origin parent page (`?host=parent`), for pages that embed +//! GridCraft in an `