packaging/web: document what page host mode trusts, the limits on host files, and the stable event names

This commit is contained in:
Helen Kwok committed 2026-11-05 16:43:01 +08:00
1 parent 3acb629e19
commit 845e34dfeb
1 file changed
+6
+6
View File
@@ -197,6 +197,12 @@ await init({ module_or_path: "./figcraft-web-<hash>_bg.wasm" });
present it takes precedence, so a same-origin framed page uses the parent bridge, while an
unframed or cross-origin page gets no bridge and keeps normal downloads.
### Trust and limits
- **Who is trusted.** In page host mode the page and FigCraft share one document, so any script on the page can drive the app: open files in it and receive what it saves. Use this mode only for a page you control. The iframe mode (`?host=parent`) answers only the parent window, on the page's own origin.
- **Files from the host are untrusted input.** An opened file goes through the same reading as one picked with File ▸ Open or dropped on the window, with the same format limits; before it is copied into the app's memory, its size is checked against the host open limit (512 MB) and a larger file is refused, and a name is cut to 255 characters.
- **The event and message names are the interface.** `figcraft:ready`, `figcraft:open`, `figcraft:save`, `figcraft:dirty` and `figcraft:failed`, and the fields they carry (the same as the `?host=parent` messages), stay stable; changing one is a breaking change.
## Renderer selection and fallback flags
FigCraft renders with wgpu. It uses **WebGPU** when the browser has it and falls back to