mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-13 17:31:09 -06:00
A same-origin page that embeds LightCraft in an iframe can now speak to
it over postMessage, with the protocol PdfCraft, GridCraft and DeckCraft
share (deckcraft#983), under lightcraft: message types:
- ready {version} / failed {error} at start-up;
- open {name, bytes} from the page adds a photo, as one dropped on the
window (the name gives the format);
- save {name, bytes} replaces every download: exports, preset and
keyword files, the library backup (handed over as a transferred
ArrayBuffer);
- dirty {dirty} whenever closing the page would start or stop losing
something (a write to browser storage queued or running, or changes
storage refused), so the page can ask before closing a window with
edits;
- cmd {id, params} runs a command like lightcraft.command(..) and is
answered with response {ok, value}.
Only the parent window on the page's own origin is heard or answered.
There is no docClosed: LightCraft has a library, not documents. The
message layer (apps/lightcraft-web/src/host.rs) is plain Rust with
native tests; the postMessage part is wasm32 only.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AbegtYaPuwqZ81pGfELsFK