mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-26 03:16:53 -06:00
- Browser client (step 4): the web build joins sessions a desktop app hosts
through the browser's WebSocket API (web-sys, binary frames, the same
message encoding). Its connection logic is a target-independent state
machine (collab-net driver.rs): hello on open, changes and presence held
until the welcome, throttled presence, keep-alive pings, a silent host
counted as dropped, reconnect with backoff, final refusals. Tested natively
against a scripted socket and a real host over loopback. Hosting stays
desktop-only (LiveLink::can_host; collab.peers canHost). https pages are
told up front that they can only reach ws:// sessions on this computer.
- Shared join logic (join.rs: GuestConfig, outcomes, taking in host messages)
and transport limits (limits.rs) used by the native guest and the browser.
- Invite links: `figcraft figcraft://join?...` joins on start (a bad link
opens the Join dialog with it); file:// arguments are paths. Windows
registers a per-user figcraft:// opener (HKCU\Software\Classes\figcraft)
behind a Registry trait (tests use a fake): collab.registerLinks {on?} and a
Preferences checkbox, default on for installed builds, never for builds
from source. macOS Info.plist declares CFBundleURLTypes; the Linux desktop
entry declares x-scheme-handler/figcraft and passes %U.
- Join dialog: Escape closes it and no longer reaches the canvas (selection
kept); its field has the keyboard when it opens.
- Docs: collab-protocol (browser client, links, mixed content), mcp,
control-protocol, README, web hosting notes, collaboration wording in the
progress docs (numbers unchanged).
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.2 KiB
Rust
30 lines
1.2 KiB
Rust
//! FigCraft in the browser.
|
|
//!
|
|
//! Runs the same [`figcraft_ui_egui::FigApp`] as the desktop app through eframe's web runner
|
|
//! (wgpu: WebGPU where available, WebGL2 otherwise). Build with `trunk build --release` from this
|
|
//! directory; the site lands in `dist/web` (see `packaging/web/README.md`).
|
|
//!
|
|
//! Differences from the desktop app:
|
|
//! - no TCP control server (browsers can't listen on sockets);
|
|
//! - no native file dialogs yet: the session starts with one new document;
|
|
//! - links open in a new browser tab;
|
|
//! - live sessions: it joins sessions a desktop app hosts (File ▸ Join live session…) but can't
|
|
//! host one. A page served over `https://` can only reach sessions on the same computer
|
|
//! (browsers block `ws://` from secure pages); serve it over `http://` on a trusted network to
|
|
//! join from other machines.
|
|
//!
|
|
//! URL query flag: `?webgl` forces the WebGL2 backend instead of WebGPU.
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
mod web;
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
fn main() {
|
|
web::start();
|
|
}
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
fn main() {
|
|
eprintln!("figcraft-web only runs in the browser: build it with `trunk build --release` in apps/figcraft-web");
|
|
}
|