mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-27 01:08:31 +00:00
M9: the browser build uses team libraries and plugin directories on a server
The browser's requests to a server now open library and plugin directory connections, so the panels work there as on the desktop. A plugin installed in the browser lasts as long as the page.
This commit is contained in:
+2
-1
File diff suppressed because one or more lines are too long
@@ -7,11 +7,17 @@
|
||||
//! Publishing ([`publish`]) uploads the document, makes the links and codes others join with when
|
||||
//! it shares, then joins the new file with its edit link; [`background`] sends the hosting and
|
||||
//! sharing requests the engine sends in the background (asking a server about its hosting,
|
||||
//! starting and stopping a share).
|
||||
//! starting and stopping a share) and those about team libraries and plugin directories;
|
||||
//! [`libraries`] the checks of a file's team libraries.
|
||||
|
||||
use std::collections::VecDeque;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use figcraft_collab::message::{self, Admin, AdminReply, ClientMsg, HostInfo, Manage, OpenHosting, PROTOCOL, ServerMsg};
|
||||
use figcraft_collab::message::{
|
||||
self, Admin, AdminReply, ClientMsg, HostInfo, LibraryReply, LibraryReq, Manage, OpenHosting, OpenLibrary, OpenPlugins, PROTOCOL, PluginReply,
|
||||
PluginReq, ServerMsg,
|
||||
};
|
||||
use figcraft_engine::live::{Event, NetReply, NetRequest, Shared, Status};
|
||||
|
||||
use crate::invite::{Endpoint, Invite};
|
||||
@@ -21,7 +27,7 @@ use crate::requests::{self, Publish, REFUSED};
|
||||
pub(crate) struct Exchange {
|
||||
pub(crate) server: Endpoint,
|
||||
open: ClientMsg,
|
||||
requests: VecDeque<Admin>,
|
||||
requests: VecDeque<ClientMsg>,
|
||||
answers: Answers,
|
||||
/// The server let the connection in (its first answer came).
|
||||
ready: bool,
|
||||
@@ -35,6 +41,9 @@ pub(crate) struct Exchange {
|
||||
pub(crate) struct Answers {
|
||||
pub(crate) hosting: Option<HostInfo>,
|
||||
pub(crate) replies: Vec<AdminReply>,
|
||||
/// The answer on a library or plugin directory connection.
|
||||
pub(crate) library: Option<LibraryReply>,
|
||||
pub(crate) plugins: Option<PluginReply>,
|
||||
}
|
||||
|
||||
/// What follows an exchange's answers (or why it failed).
|
||||
@@ -61,7 +70,23 @@ impl Exchange {
|
||||
owner: owner.to_string(),
|
||||
}),
|
||||
};
|
||||
Self { server, open, requests: requests.into(), answers: Answers::default(), ready: false, asked: false }
|
||||
Self::opened(server, open, requests.into_iter().map(ClientMsg::Admin).collect())
|
||||
}
|
||||
|
||||
/// Ask the library of the file behind `invite` one thing.
|
||||
pub(crate) fn library(invite: Invite, req: LibraryReq) -> Self {
|
||||
let open = OpenLibrary { protocol: PROTOCOL, file: invite.file, token: invite.token, client_version: message::client_version() };
|
||||
Self::opened(invite.server, ClientMsg::OpenLibrary(open), VecDeque::from([ClientMsg::Library(req)]))
|
||||
}
|
||||
|
||||
/// Ask the plugin directory of `server` one thing, with its `key` (empty: only browsing).
|
||||
pub(crate) fn plugins(server: Endpoint, key: String, req: PluginReq) -> Self {
|
||||
let open = OpenPlugins { protocol: PROTOCOL, key, client_version: message::client_version() };
|
||||
Self::opened(server, ClientMsg::OpenPlugins(open), VecDeque::from([ClientMsg::Plugins(req)]))
|
||||
}
|
||||
|
||||
fn opened(server: Endpoint, open: ClientMsg, requests: VecDeque<ClientMsg>) -> Self {
|
||||
Self { server, open, requests, answers: Answers::default(), ready: false, asked: false }
|
||||
}
|
||||
|
||||
/// The connection's first message.
|
||||
@@ -81,7 +106,11 @@ impl Exchange {
|
||||
/// Why the exchange failed with `e`, as the app says it: a server older than open hosting
|
||||
/// can't read the opening.
|
||||
pub(crate) fn failed(&self, e: String) -> String {
|
||||
if self.ready || !matches!(self.open, ClientMsg::OpenHosting(_)) { e } else { requests::hosting_error(&self.server, e) }
|
||||
match self.open {
|
||||
ClientMsg::OpenHosting(_) if !self.ready => requests::hosting_error(&self.server, e),
|
||||
ClientMsg::OpenPlugins(_) if !self.ready => requests::directory_error(&self.server, e),
|
||||
_ => e,
|
||||
}
|
||||
}
|
||||
|
||||
/// Take in one message from the server: the next request to send, if one is due; an error
|
||||
@@ -99,13 +128,22 @@ impl Exchange {
|
||||
self.ready = true;
|
||||
self.answers.hosting = Some(*info);
|
||||
}
|
||||
ServerMsg::Library(r) if self.asked => self.answers.library = Some(*r),
|
||||
ServerMsg::Library(r) if !self.ready => match *r {
|
||||
LibraryReply::Ready { .. } => self.ready = true,
|
||||
other => return Err(format!("the server answered {other:?} instead of opening the library")),
|
||||
},
|
||||
ServerMsg::Plugins(r) if self.asked => self.answers.plugins = Some(*r),
|
||||
ServerMsg::Plugins(r) if !self.ready => match *r {
|
||||
PluginReply::Ready { .. } => self.ready = true,
|
||||
other => return Err(format!("the server answered {other:?} instead of opening its plugin directory")),
|
||||
},
|
||||
_ => return Err("the server sent something other than an answer".into()),
|
||||
}
|
||||
self.asked = false;
|
||||
Ok(self.requests.pop_front().map(|r| {
|
||||
self.asked = true;
|
||||
ClientMsg::Admin(r)
|
||||
}))
|
||||
let next = self.requests.pop_front();
|
||||
self.asked = next.is_some();
|
||||
Ok(next)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,9 +242,42 @@ fn codes(s: Sharing, links: requests::Links, then: LinksThen) -> Next {
|
||||
)
|
||||
}
|
||||
|
||||
/// The answer to a library request, from what its exchange got.
|
||||
fn library_reply(answers: Result<Answers, String>) -> Result<LibraryReply, String> {
|
||||
answers.and_then(|a| a.library.ok_or_else(|| "the server didn't answer".to_string()))
|
||||
}
|
||||
|
||||
/// Ask about the team libraries `jobs` `(link, request)`, in order, each on a connection of its
|
||||
/// own: the events their fetches end in, with the others' answers left out (a report's says
|
||||
/// nothing, and an older server refuses it). `fetching` goes down at the end.
|
||||
pub(crate) fn libraries(mut jobs: VecDeque<(String, LibraryReq)>, mut events: Vec<Event>, fetching: Arc<AtomicBool>) -> Next {
|
||||
let Some((link, req)) = jobs.pop_front() else {
|
||||
fetching.store(false, Ordering::SeqCst);
|
||||
return Next::Done(events, None);
|
||||
};
|
||||
let fetch = matches!(req, LibraryReq::Fetch { .. });
|
||||
match Invite::parse(&link) {
|
||||
Err(reply) => {
|
||||
if fetch {
|
||||
events.push(Event::Library { link, reply: Err(reply) });
|
||||
}
|
||||
libraries(jobs, events, fetching)
|
||||
}
|
||||
Ok(invite) => Next::Ask(
|
||||
Box::new(Exchange::library(invite, req)),
|
||||
Box::new(move |answers| {
|
||||
if fetch {
|
||||
events.push(Event::Library { link, reply: library_reply(answers) });
|
||||
}
|
||||
libraries(jobs, events, fetching)
|
||||
}),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Background request `req` (answered as [`Event::Net`] with `job`), for the requests the
|
||||
/// browser sends: about a server's hosting, and changing who else gets into a file. `None` for
|
||||
/// the others.
|
||||
/// browser sends: about a server's hosting, changing who else gets into a file, its team libraries
|
||||
/// and its plugin directory. `None` for the others.
|
||||
pub(crate) fn background(job: u64, req: NetRequest) -> Option<Next> {
|
||||
let answer = move |reply: NetReply| Next::Done(vec![Event::Net { job, reply: Box::new(reply) }], None);
|
||||
Some(match req {
|
||||
@@ -231,6 +302,21 @@ pub(crate) fn background(job: u64, req: NetRequest) -> Option<Next> {
|
||||
share_links(Sharing { server, key, file, owner, revoke, create }, Box::new(move |r| answer(NetReply::Share(r))))
|
||||
}
|
||||
},
|
||||
NetRequest::Plugins { .. } | NetRequest::Library { .. } | NetRequest::Upload(_) => return None,
|
||||
NetRequest::Library { link, req } => match Invite::parse(&link) {
|
||||
Err(e) => answer(NetReply::Library(Err(e))),
|
||||
Ok(invite) => Next::Ask(Box::new(Exchange::library(invite, req)), Box::new(move |a| answer(NetReply::Library(library_reply(a))))),
|
||||
},
|
||||
NetRequest::Plugins { server, req } => match Endpoint::parse(&server) {
|
||||
Err(e) => answer(NetReply::Plugins(Err(e))),
|
||||
Ok((server, query)) => {
|
||||
let key = query.into_iter().find(|(k, _)| k == "key").map(|(_, v)| v).unwrap_or_default();
|
||||
let ex = Exchange::plugins(server, key.trim().to_string(), req);
|
||||
Next::Ask(
|
||||
Box::new(ex),
|
||||
Box::new(move |a| answer(NetReply::Plugins(a.and_then(|a| a.plugins.ok_or_else(|| "the server didn't answer".to_string()))))),
|
||||
)
|
||||
}
|
||||
},
|
||||
NetRequest::Upload(_) => return None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,9 +4,13 @@
|
||||
//! background requests the browser can send.
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use figcraft_collab::message::{self, Access, Admin, AdminReply, ClientMsg, FileInfo, HostInfo, LinkInfo, NewLink, Presence, ServerMsg};
|
||||
use figcraft_collab::message::{
|
||||
self, Access, Admin, AdminReply, ClientMsg, Detached, FileInfo, HostInfo, LibraryReply, LibraryReq, LinkInfo, NewLink, PluginReply, PluginReq,
|
||||
Presence, ServerMsg,
|
||||
};
|
||||
use figcraft_doc::{Document, NodeId};
|
||||
use figcraft_engine::live::{Event, NetReply, NetRequest, Shared, Status};
|
||||
|
||||
@@ -344,6 +348,84 @@ fn background_requests_ask_about_hosting_and_sharing() {
|
||||
let Some(Next::Done(events, None)) = exchange::background(1, bad) else { panic!("not answered at once") };
|
||||
assert!(matches!(events.as_slice(), [Event::Net { reply, .. }] if matches!(**reply, NetReply::Hosting(Err(_)) | NetReply::Share(Err(_)))));
|
||||
}
|
||||
let plugins = NetRequest::Plugins { server: SERVER.into(), req: figcraft_collab::message::PluginReq::List { query: String::new() } };
|
||||
assert!(exchange::background(1, plugins).is_none());
|
||||
}
|
||||
|
||||
fn library(r: LibraryReply) -> ServerMsg {
|
||||
ServerMsg::Library(Box::new(r))
|
||||
}
|
||||
|
||||
fn directory(r: PluginReply) -> ServerMsg {
|
||||
ServerMsg::Plugins(Box::new(r))
|
||||
}
|
||||
|
||||
fn link() -> String {
|
||||
format!("figcraft://join?host=127.0.0.1:47910&file={FILE}&token={TOKEN}")
|
||||
}
|
||||
|
||||
/// The browser opens a team library, asks, and takes the answer; failures come back as answers.
|
||||
#[test]
|
||||
fn background_requests_ask_a_team_library() {
|
||||
let ready = library(LibraryReply::Ready { access: Access::View });
|
||||
let req = |req| NetRequest::Library { link: link(), req };
|
||||
let (reply, sent) = background(req(LibraryReq::Usage), &[ready.clone(), library(LibraryReply::Usage(Vec::new()))]);
|
||||
assert!(matches!(reply, NetReply::Library(Ok(LibraryReply::Usage(u))) if u.is_empty()));
|
||||
assert!(matches!(sent.as_slice(), [ClientMsg::OpenLibrary(o), ClientMsg::Library(LibraryReq::Usage)] if o.file == FILE && o.token == TOKEN));
|
||||
// A refusal, and a link that isn't one.
|
||||
let (reply, _) = background(req(LibraryReq::Usage), &[ServerMsg::Refused { reason: "that link was revoked".into() }]);
|
||||
assert!(matches!(reply, NetReply::Library(Err(e)) if e.contains("revoked")));
|
||||
let bad = NetRequest::Library { link: "nope".into(), req: LibraryReq::Usage };
|
||||
let Some(Next::Done(events, None)) = exchange::background(1, bad) else { panic!("not answered at once") };
|
||||
assert!(matches!(events.as_slice(), [Event::Net { reply, .. }] if matches!(**reply, NetReply::Library(Err(_)))));
|
||||
// Anything but the opening's answer first is no answer.
|
||||
let (reply, _) = background(req(LibraryReq::Usage), &[library(LibraryReply::Empty)]);
|
||||
assert!(matches!(reply, NetReply::Library(Err(e)) if e.contains("instead of opening the library")));
|
||||
}
|
||||
|
||||
/// The browser asks a plugin directory, with the address's key when it has one.
|
||||
#[test]
|
||||
fn background_requests_ask_a_plugin_directory() {
|
||||
let ready = directory(PluginReply::Ready { publisher: true });
|
||||
let req = PluginReq::List { query: String::new() };
|
||||
let ask = NetRequest::Plugins { server: format!("{SERVER}?key=k3y"), req: req.clone() };
|
||||
let (reply, sent) = background(ask, &[ready, directory(PluginReply::List(Vec::new()))]);
|
||||
assert!(matches!(reply, NetReply::Plugins(Ok(PluginReply::List(entries))) if entries.is_empty()));
|
||||
assert!(matches!(sent.as_slice(), [ClientMsg::OpenPlugins(o), ClientMsg::Plugins(_)] if o.key == "k3y"));
|
||||
// A server from before directories can't read the opening.
|
||||
let older = NetRequest::Plugins { server: SERVER.into(), req };
|
||||
let (reply, _) = background(older, &[ServerMsg::Refused { reason: "that couldn't be read".into() }]);
|
||||
assert!(matches!(reply, NetReply::Plugins(Err(e)) if e.contains("has no plugin directory")));
|
||||
let bad = NetRequest::Plugins { server: "nope".into(), req: PluginReq::List { query: String::new() } };
|
||||
assert!(matches!(exchange::background(1, bad), Some(Next::Done(..))));
|
||||
}
|
||||
|
||||
/// A file's check of its team libraries runs its requests in order, each on a connection of its
|
||||
/// own; only fetches come back, whatever a report's answer, and a bad link doesn't stop the rest.
|
||||
#[test]
|
||||
fn a_library_check_runs_in_order_and_answers_only_its_fetches() {
|
||||
let fetch = LibraryReq::Fetch { have: None, usage: None };
|
||||
let jobs = vec![
|
||||
("nope".to_string(), fetch.clone()),
|
||||
(link(), fetch),
|
||||
(link(), LibraryReq::ReportDetached(Detached::default())),
|
||||
(link(), LibraryReq::ReportInserted(Detached::default())),
|
||||
];
|
||||
let fetching = Arc::new(AtomicBool::new(true));
|
||||
let t0 = Instant::now();
|
||||
let (mut d, inbox) = run(exchange::libraries(jobs.into(), Vec::new(), fetching.clone()), t0);
|
||||
let ready = library(LibraryReply::Ready { access: Access::View });
|
||||
d.opened(t0);
|
||||
say(&mut d, &ready, t0);
|
||||
say(&mut d, &library(LibraryReply::Empty), t0);
|
||||
d.opened(t0);
|
||||
say(&mut d, &ready, t0);
|
||||
// An older server refuses the report: the check goes on.
|
||||
say(&mut d, &library(LibraryReply::Failed { reason: "no".into() }), t0);
|
||||
d.opened(t0);
|
||||
say(&mut d, &ServerMsg::Refused { reason: "couldn't be read".into() }, t0);
|
||||
assert!(!fetching.load(Ordering::SeqCst), "the next check may start");
|
||||
let events = inbox.drain();
|
||||
let replies: Vec<_> = events.iter().filter_map(|e| if let Event::Library { reply, .. } = e { Some(reply) } else { None }).collect();
|
||||
assert_eq!(replies.len(), 2, "{events:#?}");
|
||||
assert!(replies[0].is_err());
|
||||
assert!(matches!(replies[1], Ok(LibraryReply::Empty)));
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
//! engine's `collab.*` commands drive it and the UI reads the engine's live state. Network
|
||||
//! threads wake the UI through a [`Waker`] only when something arrives; nothing polls.
|
||||
//!
|
||||
//! The browser build's [`NetLink`] joins sessions and publishes files to servers through the
|
||||
//! browser's WebSocket API (`web-sys`); hosting a session needs the desktop app. Its connection
|
||||
//! The browser build's [`NetLink`] joins sessions, publishes files to servers and asks them about
|
||||
//! team libraries and plugin directories through the browser's WebSocket API (`web-sys`); hosting
|
||||
//! a session needs the desktop app. Its connection
|
||||
//! logic (`driver.rs`, `exchange.rs`) is target-independent and tested natively.
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ use crate::invite::{Endpoint, Invite, Lookup};
|
||||
use crate::join::ask;
|
||||
use crate::net::{Duplex, NetLimits, config, open};
|
||||
pub(crate) use crate::requests::REFUSED;
|
||||
use crate::requests::{code_requests, comment_request, hosting_error, link_requests, made_comment, made_links, shared};
|
||||
use crate::requests::{code_requests, comment_request, directory_error, hosting_error, link_requests, made_comment, made_links, shared};
|
||||
|
||||
type Ws = WebSocket<Duplex>;
|
||||
|
||||
@@ -165,8 +165,7 @@ pub fn plugins(server: &Endpoint, key: &str, req: PluginReq, limits: &NetLimits,
|
||||
match reply(&mut ws, limits, pick) {
|
||||
Ok(PluginReply::Ready { .. }) => {}
|
||||
// An older server can't read the request at all.
|
||||
Err(e) if e.contains("couldn't be read") => return Err(format!("{} has no plugin directory (update the server)", server.display())),
|
||||
Err(e) => return Err(e),
|
||||
Err(e) => return Err(directory_error(server, e)),
|
||||
Ok(other) => return Err(format!("the server answered {other:?} instead of opening its plugin directory")),
|
||||
}
|
||||
send(&mut ws, &ClientMsg::Plugins(req))?;
|
||||
|
||||
@@ -34,6 +34,12 @@ pub(crate) fn server_key(given: Option<String>, query: Vec<(String, String)>) ->
|
||||
|
||||
/// Why asking `server` about its hosting failed with `e`: a server older than open hosting can't
|
||||
/// read the question.
|
||||
/// Why opening `server`'s plugin directory failed with `e`: a server from before directories can't
|
||||
/// read the opening.
|
||||
pub(crate) fn directory_error(server: &Endpoint, e: String) -> String {
|
||||
if e.contains("couldn't be read") { format!("{} has no plugin directory (update the server)", server.display()) } else { e }
|
||||
}
|
||||
|
||||
pub(crate) fn hosting_error(server: &Endpoint, e: String) -> String {
|
||||
if e.contains("couldn't be read") {
|
||||
format!("{} takes files only with its key (it is older than this app): add ?key=… to the address", server.display())
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::BTreeMap;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use figcraft_collab::message::{ClientMsg, Presence};
|
||||
use figcraft_collab::message::{ClientMsg, LibraryReq, Presence};
|
||||
use figcraft_engine::live::{Event, HostOptions, LiveLink, NO_SESSION, NetRequest, PublishOptions, SessionId, SessionInfo};
|
||||
use wasm_bindgen::JsCast as _;
|
||||
use wasm_bindgen::closure::Closure;
|
||||
@@ -163,19 +165,29 @@ fn socket() -> (u64, BrowserSocket) {
|
||||
(id, BrowserSocket { id, ws: None })
|
||||
}
|
||||
|
||||
/// The browser's [`LiveLink`]: joins sessions and publishes files to servers; hosting a session
|
||||
/// needs the desktop app.
|
||||
/// The browser's [`LiveLink`]: joins sessions, publishes files to servers and asks them about team
|
||||
/// libraries and plugin directories; hosting a session needs the desktop app.
|
||||
pub struct NetLink {
|
||||
/// Each session's number in the thread-local table.
|
||||
sessions: Sessions<u64>,
|
||||
/// Answers to requests sent in the background (outlives sessions).
|
||||
background: Inbox,
|
||||
/// A check of the team libraries is out.
|
||||
fetching: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl NetLink {
|
||||
/// `wake` is called whenever something arrives for the UI (egui's `request_repaint`).
|
||||
pub fn new(wake: Waker) -> Self {
|
||||
Self { background: Inbox::new(wake.clone()), sessions: Sessions::new(wake) }
|
||||
Self { background: Inbox::new(wake.clone()), sessions: Sessions::new(wake), fetching: Arc::default() }
|
||||
}
|
||||
|
||||
/// Run `next` on a connection of its own, its answers for the background.
|
||||
fn ask(&self, next: exchange::Next) {
|
||||
let (id, sock) = socket();
|
||||
// The exchanges name their own servers.
|
||||
let cfg = GuestConfig::new(Invite::new("", "", ""), String::new());
|
||||
run(id, Driver::asking(sock, cfg, next, self.background.clone(), Instant::now()));
|
||||
}
|
||||
|
||||
/// Session `session` runs on connection `id` now (the one it had ends).
|
||||
@@ -229,13 +241,16 @@ impl LiveLink for NetLink {
|
||||
|
||||
fn background(&mut self, job: u64, req: NetRequest) -> bool {
|
||||
let Some(next) = exchange::background(job, req) else { return false };
|
||||
let (id, sock) = socket();
|
||||
// The exchanges name their own servers.
|
||||
let cfg = GuestConfig::new(Invite::new("", "", ""), String::new());
|
||||
run(id, Driver::asking(sock, cfg, next, self.background.clone(), Instant::now()));
|
||||
self.ask(next);
|
||||
true
|
||||
}
|
||||
|
||||
fn library_background(&mut self, jobs: Vec<(String, LibraryReq)>) {
|
||||
if !jobs.is_empty() && !self.fetching.swap(true, Ordering::SeqCst) {
|
||||
self.ask(exchange::libraries(jobs.into(), Vec::new(), self.fetching.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
fn leave(&mut self, session: SessionId) {
|
||||
if let Some(id) = self.sessions.remove(session) {
|
||||
with_driver(id, |d, now| d.leave(now));
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
# Where FigCraft falls short of Figma
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-31 · **Change:** minor (gap 10: library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; gap 6: widgets draw lines and SVG pictures (plugin API 6); gap 7: text reads only the fallback fonts it draws with; a board connector's path can be reshaped by dragging its path handles (#1710); gap 10: library analytics count insertions and show insertions and detachments over time; gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; gap 14: a collection of this file extends, following its edits at once; colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; gap 6: plugin widgets have hover styles; gap 7: the browser draws a zoom's full render a band at a time; `.fig` import keeps the file's saved line breaks while the text and its box are unedited (#1236); FigJam outer shape outlines and sticky body fallback beside author text (#1341, #1397); Arabic draft catalog; gap 7: the browser refines a zoom's preview once the zoom has paused; gap 17: branches in live sessions, branch history entries, the list-merge rows brought up to date; gap 6: plugin widgets take text input and a property menu (plugin API 4); gap 24: board templates and tables; gap 24: a shared timer and voting sessions; gap 24: the board dot grid, connector ends dragged to re-attach, curved connectors; egui/eframe 0.37 verified for gap 18; known gaps from the #1311 review in gaps 4, 14, 15 and 16; gap 16: measurements kept on the canvas, a read-only layers panel in Dev Mode; gap 24: boards and their tail; Dev Mode tail: import lines in layer trees, compare with versions, an inspect-only canvas; gap 5: reviewed Turkish, Czech and Indonesian drafts, the Japanese draft completed; reviewed Russian catalog and integer plurals; `.fig` export: instance sizes, variables with modes, shared styles, variable-width strokes; sharing with a join code; text box sizes measured against documents re-saved by other software; live sessions per document; .fig export checked by opening written files in other software; experimental .fig export; keyboard shortcut parity suite and bindings; Simplified Chinese draft catalog; Latin American Spanish overlay; prototyping tail: gamepad triggers, widgets in prototypes, mode lookups; plugin directory on figcraft-server; Japanese and Korean draft catalogs and CJK UI fonts; plugin widgets and the plugin panel tail; French, German and Brazilian Portuguese draft catalogs; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and edit tail; dev resources links; extended collections tail; branch version history and finer list merges; comments and version history behaviour suite and fixes; canvas navigation, guides and grids behaviour suite and fixes; `.fig` import: editable vector networks, more layer kinds, variable prototype actions; `.fig` import, best effort: gap 1 down to its tail; Windows QA pass: everyday workflows on Windows 11, eight fixes incl. unsaved work kept after a crash or a forced quit; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; localization layer with a draft Spanish catalog; hosting figcraft-server: wss in the desktop app, server releases, deployment guide; plugin panels and settings; canvas fixes: boolean hit testing on the result, group drags, frame outlines and slices; code connect; stretch and scatter brushes, pen pressure; text on a path and pattern fills; team libraries on the server and swap library; branches: create, update from main, review and merge; animated GIF fills and TIFF images; Open recent, outlines for the selection and mask outlines: menu breadth 100%; extended collections, variables import/export, gradient stop and variant bindings: gap 14 down to its tail; the 2026-10-17 landings: `.fig` import fidelity, budgets for large files, the import report, a `.fig` copy from Save as and paste from another design app (gap 1); menus, the Actions palette, editor fixes, Selection colors and smart-selection spacing (gap 4); catalog counts re-measured (gap 5); bounded canvas pan overscan) · **Target:** Figma Design (desktop app 126.10.7)
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-31 · **Change:** minor (gap 6: the browser build uses team libraries and plugin directories on a server; gap 10: library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; gap 6: widgets draw lines and SVG pictures (plugin API 6); gap 7: text reads only the fallback fonts it draws with; a board connector's path can be reshaped by dragging its path handles (#1710); gap 10: library analytics count insertions and show insertions and detachments over time; gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; gap 14: a collection of this file extends, following its edits at once; colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; gap 6: plugin widgets have hover styles; gap 7: the browser draws a zoom's full render a band at a time; `.fig` import keeps the file's saved line breaks while the text and its box are unedited (#1236); FigJam outer shape outlines and sticky body fallback beside author text (#1341, #1397); Arabic draft catalog; gap 7: the browser refines a zoom's preview once the zoom has paused; gap 17: branches in live sessions, branch history entries, the list-merge rows brought up to date; gap 6: plugin widgets take text input and a property menu (plugin API 4); gap 24: board templates and tables; gap 24: a shared timer and voting sessions; gap 24: the board dot grid, connector ends dragged to re-attach, curved connectors; egui/eframe 0.37 verified for gap 18; known gaps from the #1311 review in gaps 4, 14, 15 and 16; gap 16: measurements kept on the canvas, a read-only layers panel in Dev Mode; gap 24: boards and their tail; Dev Mode tail: import lines in layer trees, compare with versions, an inspect-only canvas; gap 5: reviewed Turkish, Czech and Indonesian drafts, the Japanese draft completed; reviewed Russian catalog and integer plurals; `.fig` export: instance sizes, variables with modes, shared styles, variable-width strokes; sharing with a join code; text box sizes measured against documents re-saved by other software; live sessions per document; .fig export checked by opening written files in other software; experimental .fig export; keyboard shortcut parity suite and bindings; Simplified Chinese draft catalog; Latin American Spanish overlay; prototyping tail: gamepad triggers, widgets in prototypes, mode lookups; plugin directory on figcraft-server; Japanese and Korean draft catalogs and CJK UI fonts; plugin widgets and the plugin panel tail; French, German and Brazilian Portuguese draft catalogs; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and edit tail; dev resources links; extended collections tail; branch version history and finer list merges; comments and version history behaviour suite and fixes; canvas navigation, guides and grids behaviour suite and fixes; `.fig` import: editable vector networks, more layer kinds, variable prototype actions; `.fig` import, best effort: gap 1 down to its tail; Windows QA pass: everyday workflows on Windows 11, eight fixes incl. unsaved work kept after a crash or a forced quit; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; localization layer with a draft Spanish catalog; hosting figcraft-server: wss in the desktop app, server releases, deployment guide; plugin panels and settings; canvas fixes: boolean hit testing on the result, group drags, frame outlines and slices; code connect; stretch and scatter brushes, pen pressure; text on a path and pattern fills; team libraries on the server and swap library; branches: create, update from main, review and merge; animated GIF fills and TIFF images; Open recent, outlines for the selection and mask outlines: menu breadth 100%; extended collections, variables import/export, gradient stop and variant bindings: gap 14 down to its tail; the 2026-10-17 landings: `.fig` import fidelity, budgets for large files, the import report, a `.fig` copy from Save as and paste from another design app (gap 1); menus, the Actions palette, editor fixes, Selection colors and smart-selection spacing (gap 4); catalog counts re-measured (gap 5); bounded canvas pan overscan) · **Target:** Figma Design (desktop app 126.10.7)
|
||||
|
||||
Every known shortfall against Figma, one entry each, ranked by how much it stops a Figma user from
|
||||
doing real work in FigCraft. Agents: pick work from the top unless the owner says otherwise. The
|
||||
@@ -268,7 +268,8 @@ No alpha blockers: the alpha gate in [`roadmap.md`](roadmap.md#alpha-gate) passe
|
||||
Lines and SVG (plugin API 6, 2026-10-31): a widget layer can be a `line` or an `svg`, whose
|
||||
picture comes in as locked layers, scaled to fit a size.
|
||||
- **Missing:** a public catalogue and Community files, publisher accounts and signatures, ratings
|
||||
and install counts, background update checks, the directory in the browser build; widgets have no
|
||||
and install counts, background update checks, keeping plugins installed in the browser past the
|
||||
page (the directory works there since 2026-10-31); widgets have no
|
||||
timers. Figma's own plugins are JavaScript against
|
||||
Figma's plugin API and don't run.
|
||||
- **Impact:** teams that depend on specific Figma plugins (icons, content, accessibility checks)
|
||||
@@ -589,6 +590,7 @@ No alpha blockers: the alpha gate in [`roadmap.md`](roadmap.md#alpha-gate) passe
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-31 | minor | Gap 6: the plugin directory works in the browser build, so that item leaves the missing list; what's installed there lasts as long as the page. Team libraries on a server work there too. |
|
||||
| 2026-10-31 | minor | Gap 10: library analytics list the layers and files using each style and variable; their insertions, detachments and modes stay on the missing list. |
|
||||
| 2026-10-31 | minor | Gap 15: the Controller menu names buttons as PlayStation and Switch controllers do; that item leaves the missing list. Estimate unchanged. Test: `present::tail_tests`. |
|
||||
| 2026-10-30 | minor | Gap 7: text reads only the fallback fonts it draws with: a face per fallback family and style, a file's bytes shared between families, the faces worked out once per style (first text laid out: 41 font files and 265 MiB read down to 3 files and 20 MiB on a Linux machine with Noto Sans CJK). Numbers unchanged |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Hardware and platform parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (images copied in other apps paste in the browser (#492); text reads only the fallback fonts it draws with; `doc.list` gives AI agents and plugins the open files' names, not their paths (#1117); a batch keeps one undo snapshot, not one per step (#1099); one depth cap bounds a whole render, pattern sources included, and render threads get 8 MiB stacks (#1082); in the browser an internal error that stops the page keeps its unsaved files, which open again on reload (#1123); the portable Windows zip keeps its settings, recovery copies and plugins in `config\` beside the executable, starting with an installed copy's preferences; the window starts on other graphics when its first ones fail before the first frame: Direct3D 12 compiles with FXC and no device compiles wgpu's indirect-validation shaders, then Vulkan, OpenGL and lower requirements on the power-saving GPU (#965, #1438); large images on the canvas draw from a smaller copy, so two 16k images no longer lag (#1483); macOS: the Quit menu and ⌘Q ask about unsaved changes (#857); egui/eframe 0.37 dependency migration; hidden-window screenshot deadlines; zoom previews; hidden windows answer control requests; macOS file opening, the Windows start-up message, Linux packaging; copy and paste in the browser; Windows QA pass; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; pen pressure for the Pencil and brushes on Windows and from browser styluses; macOS: quitting ends the process once everything is kept, avoiding the Touch Bar teardown crash (#781); Linux and BSD clipboard: images under Wayland, reads time out; minimised windows under Wayland; window controls on Wayland without server decorations; canvas textures on device pixels) · **Target:** Figma Design (desktop app 126.10.7)
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-31 · **Change:** minor (the browser build uses team libraries and plugin directories on a server; images copied in other apps paste in the browser (#492); text reads only the fallback fonts it draws with; `doc.list` gives AI agents and plugins the open files' names, not their paths (#1117); a batch keeps one undo snapshot, not one per step (#1099); one depth cap bounds a whole render, pattern sources included, and render threads get 8 MiB stacks (#1082); in the browser an internal error that stops the page keeps its unsaved files, which open again on reload (#1123); the portable Windows zip keeps its settings, recovery copies and plugins in `config\` beside the executable, starting with an installed copy's preferences; the window starts on other graphics when its first ones fail before the first frame: Direct3D 12 compiles with FXC and no device compiles wgpu's indirect-validation shaders, then Vulkan, OpenGL and lower requirements on the power-saving GPU (#965, #1438); large images on the canvas draw from a smaller copy, so two 16k images no longer lag (#1483); macOS: the Quit menu and ⌘Q ask about unsaved changes (#857); egui/eframe 0.37 dependency migration; hidden-window screenshot deadlines; zoom previews; hidden windows answer control requests; macOS file opening, the Windows start-up message, Linux packaging; copy and paste in the browser; Windows QA pass; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; pen pressure for the Pencil and brushes on Windows and from browser styluses; macOS: quitting ends the process once everything is kept, avoiding the Touch Bar teardown crash (#781); Linux and BSD clipboard: images under Wayland, reads time out; minimised windows under Wayland; window controls on Wayland without server decorations; canvas textures on device pixels) · **Target:** Figma Design (desktop app 126.10.7)
|
||||
|
||||
How FigCraft uses hardware and which platforms it runs on, against Figma. Figma's desktop app is
|
||||
Electron with a GPU helper process; its canvas renders on the GPU (WebGL, with WebGPU rolling out
|
||||
@@ -50,6 +50,7 @@ Nothing has been timed against Figma on the same document (needs `.fig` import).
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-31 | minor | M9, gap 6: the browser build uses team libraries and plugin directories on a server, through its WebSocket requests: adding a library by its link, its styles and components, publishing to it, Show usage and the reports a file sends; browsing a directory and installing from it, for the page only. Scripts through `window.figcraft` still can't, as commands there don't wait for the server. Numbers unchanged. Tests: `exchange_tests`. |
|
||||
| 2026-10-31 | minor | M1, #492: Web row: the browser pastes images copied in other apps, read from the paste event under the same limits as the desktop. Numbers unchanged. |
|
||||
| 2026-10-30 | minor | M8: text reads only the fallback fonts it draws with. Each fallback family reads the face nearest a run's style, not all of them (Noto Sans CJK is seven files of 16–20 MB); families naming the faces of one file share its bytes; and the faces are worked out once per style until fonts change, not for every text laid out. First text laid out on a Linux machine with Noto Sans CJK, DejaVu Sans and Inter: 41 files (265 MiB, kept in memory) and 41 faces parsed → 3 files (20 MiB) and 4 faces; fallback lookups per text laid out ~45 µs → 0.2 µs. Tests: `fontdb_fallback_tests`. Numbers unchanged |
|
||||
| 2026-10-30 | minor | M8, #1117: AI agents and plugins no longer learn where the open files are on disk from `doc.list`. Numbers unchanged. |
|
||||
|
||||
+5
-4
@@ -214,9 +214,10 @@ whole bundle before keeping it, refuses a version that isn't newer than the one
|
||||
the new version at once. `plugin.directory.unpublish` (or the operator's `figcraft-server plugins
|
||||
remove`) takes a version, or the whole plugin, down; installed copies keep working.
|
||||
|
||||
**In the browser** the directory isn't available yet: the browser build's network link has no
|
||||
plugin directory requests (`plugin.directory.*` says so). Import plugins with `plugin.import
|
||||
{manifest, wasm}` there.
|
||||
**In the browser** Manage plugins browses a directory and installs from it as the desktop app
|
||||
does, but there is no folder to keep a plugin in, so it lasts as long as the page. Scripts through
|
||||
`window.figcraft` can't reach a directory (commands there don't wait for the server, and
|
||||
`plugin.directory.*` says so): import plugins with `plugin.import {manifest, wasm}` there.
|
||||
|
||||
## The manifest: `figcraft-plugin.json`
|
||||
|
||||
@@ -548,7 +549,7 @@ import what you need from `figcraft`.
|
||||
- Distribution: directories live on your own `figcraft-server`; there is no public catalogue,
|
||||
no publisher accounts or signatures (the server's key is the publisher), no ratings, reviews or
|
||||
install counts, and updates are found when you browse, not in the background. The browser build
|
||||
can't use a directory yet.
|
||||
keeps what it installs only as long as the page.
|
||||
- Plugins written for other apps (JavaScript plugins) don't run.
|
||||
- Widgets: clicks, field edits and menu items are their only events (no hover or timers), a field
|
||||
is plain text (no placeholder, length or single-line setting), and their layers are frames, text, rectangles, ellipses and images only (no
|
||||
|
||||
+2
-1
File diff suppressed because one or more lines are too long
+4
-1
@@ -268,7 +268,10 @@ send their requests on a thread of their own, show that they're on their way (wi
|
||||
finish when the answer arrives, acting on the file they started in. Scripts, the CLI and the MCP
|
||||
server run the same commands and wait for the answer.
|
||||
|
||||
The browser build can't use team libraries yet (it has no library support of its own).
|
||||
The browser build uses team libraries through the same panel: adding one by its link, its styles
|
||||
and components, publishing a file that is on the server, Show usage and the reports a file sends.
|
||||
A browser can't keep a library file, and scripts through `window.figcraft` can't reach a server
|
||||
(commands there don't wait for it), so those stay with the desktop app, the CLI and MCP.
|
||||
|
||||
## Plugin directory
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user