From d16285bca9cae6e87d831ba9c0b44070583cc96c Mon Sep 17 00:00:00 2001 From: Helen Kwok <107752876+helenkwok@users.noreply.github.com> Date: Mon, 2 Nov 2026 09:01:56 +0800 Subject: [PATCH] feat(web): page host mode, so a page can host LightCraft in its own document (#2270) data-host="page" on the canvas turns it on. The bridge gets a Transport (Parent or Page) with one send: in page mode the same messages travel as non-bubbling CustomEvents on the canvas, and the page sends lightcraft:open and lightcraft:cmd the same way. Parent mode is unchanged. --- apps/lightcraft-web/Cargo.toml | 4 + apps/lightcraft-web/src/host.rs | 254 ++++++++++++++++++++++++++------ apps/lightcraft-web/src/lib.rs | 4 +- apps/lightcraft-web/src/web.rs | 80 ++++++++-- docs/web.md | 9 ++ docs/whats-new.md | 2 + 6 files changed, 292 insertions(+), 61 deletions(-) diff --git a/apps/lightcraft-web/Cargo.toml b/apps/lightcraft-web/Cargo.toml index d4ae0f6674..28a21307a0 100644 --- a/apps/lightcraft-web/Cargo.toml +++ b/apps/lightcraft-web/Cargo.toml @@ -32,10 +32,14 @@ js-sys = { workspace = true } web-sys = { workspace = true, features = [ "Blob", "BlobPropertyBag", + "CustomEvent", + "CustomEventInit", + "CssStyleDeclaration", "DedicatedWorkerGlobalScope", "Document", "DomStringList", "Element", + "Event", "EventTarget", "File", "FileList", diff --git a/apps/lightcraft-web/src/host.rs b/apps/lightcraft-web/src/host.rs index 05248b21d3..f8d38c3cb7 100644 --- a/apps/lightcraft-web/src/host.rs +++ b/apps/lightcraft-web/src/host.rs @@ -1,6 +1,6 @@ -//! The `postMessage` bridge to a same-origin parent page (`?host=parent`), for pages that embed -//! LightCraft in an `