mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-25 19:26:50 -06:00
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G6GtUCaPiCMEQCN4QcdQnp
31 lines
1.2 KiB
Rust
31 lines
1.2 KiB
Rust
//! GridCraft in the browser.
|
|
//!
|
|
//! Runs the same [`gridcraft_ui_egui::SheetApp`] as the desktop app through eframe's web runner
|
|
//! (wgpu: WebGPU where available, WebGL2 otherwise). Build with `trunk build --release` from
|
|
//! this directory (output in `dist/web`).
|
|
//!
|
|
//! Differences from the desktop app: no TCP control channel; Open uses the browser file picker
|
|
//! (bytes arrive asynchronously through `Services::inbox`); Save downloads the file; dropped
|
|
//! files are read asynchronously.
|
|
//!
|
|
//! URL query flags: `?webgl` forces WebGL2; `?sample=sales|budget|grades` opens a sample;
|
|
//! `?host=parent` (inside an `<iframe>`) talks to a same-origin parent page instead: it sends the
|
|
//! workbook to open and stores what GridCraft saves (`host`), and `&author=` names the user for
|
|
//! notes and comments.
|
|
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
mod host;
|
|
#[cfg(target_arch = "wasm32")]
|
|
mod web;
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
fn main() {
|
|
web::start();
|
|
}
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
fn main() {
|
|
eprintln!("gridcraft-web only runs in the browser: build it with `trunk build --release` in apps/gridcraft-web");
|
|
}
|