From 26b25644cfbc894c9940c7e19a9978f5931dd4dc Mon Sep 17 00:00:00 2001
From: ATOM
Date: Tue, 24 Nov 2026 21:54:38 -0600
Subject: [PATCH 1/5] fix(dev): use SVG assets for vector code
---
crates/engine/src/dev/codegen.rs | 32 ++++++++++++++++++++++++++
crates/engine/src/dev/codegen/arkui.rs | 2 +-
crates/engine/src/dev/codegen/html.rs | 10 ++++++++
crates/engine/src/dev/codegen/swift.rs | 4 +++-
docs/dev-mode-parity.md | 4 ++++
5 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/crates/engine/src/dev/codegen.rs b/crates/engine/src/dev/codegen.rs
index 28213e234..152af4136 100644
--- a/crates/engine/src/dev/codegen.rs
+++ b/crates/engine/src/dev/codegen.rs
@@ -384,6 +384,10 @@ fn stroke_color(n: &Node) -> Option {
/// The CSS borders a solid stroke makes: one `border`, or with individual stroke sides a border
/// on each side that has a weight.
fn css_borders(doc: &Document, n: &Node, t: &mut Tokens) -> Vec<(String, String)> {
+ // A vector's stroke belongs to its path, not to a rectangle around its bounding box.
+ if matches!(n.kind, NodeKind::Vector { .. }) {
+ return Vec::new();
+ }
let Some(c) = stroke_color(n) else { return Vec::new() };
let Some(sides) = n.stroke.sides else {
let weight = tok(doc, n, &["strokeWeight"], format!("{}px", num(n.stroke.weight)), t);
@@ -573,6 +577,34 @@ mod tests {
assert!(!css.contains("gradient"), "{css}");
}
+ #[test]
+ fn vector_code_uses_its_svg_asset_not_a_box_border() {
+ let mut s = Session::new();
+ let icon =
+ id_of(&s.execute("frame.create", &json!({"name": "icon", "width": 24, "height": 24, "props": {"fill": "none"}})).unwrap()["id"]).unwrap();
+ s.execute("vector.create", &json!({"path": "M4 12 L10 18 L20 6", "parent": icon, "name": "check", "props": {"fill": "none", "stroke": "#1F3A68", "strokeWeight": 2}})).unwrap();
+ let doc = s.doc().unwrap();
+ let html = code_for(doc, icon, CodeLang::Html);
+ assert!(html.contains("
"), "{html}");
+ assert!(!html.contains("border: 2px solid"), "{html}");
+ for lang in [CodeLang::React, CodeLang::Vue, CodeLang::Leptos, CodeLang::Tailwind] {
+ let code = code_for(doc, icon, lang);
+ assert!(code.contains("
String {
s.replace('&', "&").replace('<', "<").replace('>', ">").replace('\n', "
")
}
+/// A layer name in a quoted markup attribute, with line breaks flattened.
+fn attr_escape(s: &str) -> String {
+ s.replace('&', "&").replace('<', "<").replace('>', ">").replace('"', """).replace(['\n', '\r'], " ")
+}
+
/// Text as JSX children: HTML escapes, braces as expressions, line breaks as `
`.
fn jsx_text(s: &str) -> String {
let mut out = String::new();
@@ -339,6 +344,11 @@ impl<'c, 'a> Markup<'c, 'a> {
}
let open = |tag: &str| format!("{pad}<{tag} {attr}=\"{class}\"{attrs}>");
match &n.kind {
+ NodeKind::Vector { .. } => {
+ // The exported SVG carries the path and its stroke; the class only places it.
+ let alt = attr_escape(&n.name);
+ self.markup.push_str(&format!("{pad}
\n"));
+ }
NodeKind::Text(t) => {
let body = self.text_body(n, t);
self.markup.push_str(&format!("{}{body}
\n", open("p")));
diff --git a/crates/engine/src/dev/codegen/swift.rs b/crates/engine/src/dev/codegen/swift.rs
index 553f4f296..f1b44f006 100644
--- a/crates/engine/src/dev/codegen/swift.rs
+++ b/crates/engine/src/dev/codegen/swift.rs
@@ -192,7 +192,9 @@ fn swift_layer(ctx: &Ctx, n: &Node, depth: usize, out: &mut String, extra: &[Str
mods.push(format!(".frame(width: {w}, height: {h})"));
}
}
- if let Some(c) = stroke_color(n) {
+ if !matches!(n.kind, NodeKind::Vector { .. })
+ && let Some(c) = stroke_color(n)
+ {
mods.push(format!(
".overlay(RoundedRectangle(cornerRadius: {corner}).stroke({}, lineWidth: {}))",
bound(&["stroke"], swift_color(c)),
diff --git a/docs/dev-mode-parity.md b/docs/dev-mode-parity.md
index 0443708c0..14003920b 100644
--- a/docs/dev-mode-parity.md
+++ b/docs/dev-mode-parity.md
@@ -1,6 +1,8 @@
# Dev Mode parity
> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-11-12 · **Change:** patch (SwiftUI, Compose and Flutter code write every visible colour and gradient fill of a frame, group, rectangle or ellipse in paint order, gradients as gradients, instead of one colour per layer (chained `.background` in SwiftUI, chained `Modifier.background` in Compose, a `DecoratedBox` for each fill under the top one in Flutter); CSS code export writes several fills as one layered `background`, top first, as the incumbent does (#2271): a solid above another fill becomes a one-colour gradient, the bottom solid stays a plain colour, Tailwind gets one `[background:...]` class; the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the Inspect tab then opens (never toggles away) with the caret in that layer's new-note field, and the engine never writes the note itself (#1840); the handoff mode reads Developer Mode in the interface, its ids and saved fields unchanged; class names transliterate non-ASCII layer names (#1235); measurements kept on the canvas; a read-only layers panel in Dev Mode; earlier: import lines in generated layer trees; compare with any saved version; Dev Mode behaviour suite: an inspect-only canvas, Changed in the ready list, statuses only on frames and sections; plugin panels from the Inspect tab) · **Target:** Figma Design Dev Mode (desktop app 126.10.7)
+>
+> **2026-11-24 patch:** vector code export uses the SVG asset instead of inventing a box around its bounds: web markup references the SVG, and CSS, SwiftUI and ArkUI no longer draw a rectangle from the path stroke (#2270).
**Breadth ~98%, ready ~78% (estimated).** The inspect surface is broad, components connect
to the code components of a repository (with their imports, also inside generated layer trees),
@@ -10,6 +12,7 @@ repository, third-party integrations. Remaining: 1–2 h.
| Feature | Status | Notes |
|---|---|---|
+| 2026-11-24 | patch | Vector code export drew a path's stroke as a box border around its bounds (#2270). CSS, HTML, React, Vue, Leptos and Tailwind no longer invent that border; the markup targets write an `
` reference to the vector's SVG asset. SwiftUI and ArkUI no longer put a rectangle stroke around their vector image either. Ordinary box and ellipse strokes are unchanged. Test: `dev::codegen::tests::vector_code_uses_its_svg_asset_not_a_box_border`; real CLI exports the referenced SVG with the stroked path |
| 2026-11-12 | patch | SwiftUI, Compose and Flutter code export kept one colour per layer (the bottom visible solid, or a gradient's first stop) and dropped every other fill (#2271). Now each writes every visible solid and gradient fill of a frame, group, rectangle or ellipse, in paint order, and a gradient as a gradient. SwiftUI chains `.background(...)` with the top fill first, since each one goes behind the ones before it (a rectangle or ellipse fills with the bottom paint and lays a copy of the shape over it for each paint above). Compose chains `Modifier.background(...)` with the bottom fill first, since each one draws over the ones before it (a linear gradient snaps to eight directions, radial and angular ones sit at the box's centre). Flutter keeps the top fill in the `Container` and wraps each fill under it in a `DecoratedBox`, the bottom fill outermost and the drop shadow on the outermost box. A layer with one solid fill gives the same code as before; a lone gradient is now a gradient, not its first stop's colour. Still not written: image and pattern fills in the native targets, ArkUI (one background and one gradient per component, so a stack needs extra nodes) and text with several fills. The incumbent's iOS and Android output wasn't measured: the order follows how each platform paints. Percentages and hours unchanged |
| 2026-11-07 | patch | Naming: the handoff mode is called Developer Mode in the interface, its shortcut row, its toasts, the control channel's refusal, the board refusal, the measurement parameter doc, the `.fig` export note, the CLI help and every catalog (24 languages, translations awaiting native review), since Figma holds a US registration for Dev Mode (7574348); command ids (`view.devMode`, `devMode.*`), preference keys and saved-document fields are unchanged, and the Actions palette still finds the command by the old name |
| Dev Mode toggle (Shift+D), Inspect panel | done | the canvas only inspects: presses select, pan and comment but never move, resize, draw or edit text and vectors; menus and shortcuts refuse design edits with a note (Dev Mode's annotations, statuses, dev resources, measurements, code connections and comments still work); a drawing tool chosen in the toolbar goes back to the design. The layers panel only selects and expands (no renaming, reordering, hiding or locking; a double click says why), and the Pages list only opens pages (no adding, renaming, reordering, duplicating or deleting). Files dropped on the canvas aren't imported (a dropped document still opens as a file of its own), and the Assets panel places, swaps and applies nothing, doesn't change Hide when publishing, and doesn't accept library updates or add, remove or swap libraries; each says why |
@@ -30,6 +33,7 @@ repository, third-party integrations. Remaining: 1–2 h.
| Date | Change | Summary |
|---|---|---|
+| 2026-11-24 | patch | Vector code export writes the SVG asset, not a rectangle made from the path's stroke (#2270). Percentages and hours unchanged. |
| 2026-11-13 | patch | Rows that recent merges had duplicated or garbled are merged back into one row each (no behaviour change): Code: CSS, iOS (SwiftUI), Android (Compose), Flutter. |
| 2026-11-12 | patch | CSS code export (#2271): a layer with several fills wrote one `background` per fill, so only the last survived. It now writes one `background` with every visible fill as a layer, top fill first, comma-separated: a solid above another fill is `linear-gradient(0deg, c, c)` (CSS allows a plain colour only as the last layer), the bottom solid stays a plain colour (with its variable), images and patterns keep their `url(...)` layers. Tailwind output carries the layered value as one `[background:...]` class. Text keeps one `color` per fill. Native targets unchanged. Percentages and hours unchanged |
| 2026-11-09 | patch | The Annotation tool (Shift+T, `tool.annotation {id?}`): selects the layer pressed on (or the selection, or `id`) and asks the UI for its note, which the Inspect tab takes in its new-note field; the engine writes nothing itself, and Developer Mode lets the tool through its gates (#1840). Figma's placement, cursor and whether the tool stays selected are unmeasured (Developer Mode is paywalled in the web app); staying selected until V or Escape, like the Comment tool, is inferred, and there is no toolbar button or icon yet |
From ab7c0e22254e9b215c5ab15b3fb4b294f9fb2f81 Mon Sep 17 00:00:00 2001
From: ATOM
Date: Tue, 24 Nov 2026 23:35:42 -0600
Subject: [PATCH 2/5] fix(dev): align vector asset references
---
apps/figcraft-cli/src/files.rs | 30 ++++-------------------
crates/engine/src/cmd/file.rs | 35 +++++++++++++++++++++++++++
crates/engine/src/dev/codegen.rs | 19 ++++++++++++++-
crates/engine/src/dev/codegen/css.rs | 7 +++++-
crates/engine/src/dev/codegen/html.rs | 11 +++++++--
5 files changed, 73 insertions(+), 29 deletions(-)
diff --git a/apps/figcraft-cli/src/files.rs b/apps/figcraft-cli/src/files.rs
index 5f4a006f4..a916e4ecb 100644
--- a/apps/figcraft-cli/src/files.rs
+++ b/apps/figcraft-cli/src/files.rs
@@ -5,6 +5,9 @@ use std::path::Path;
use std::process::ExitCode;
use figcraft_doc::{Document, ExportFormat, ExportSetting, NodeId, NodeKind, PrintSettings, VdCompat};
+use figcraft_engine::cmd::file::ExportNames;
+#[cfg(test)]
+use figcraft_engine::cmd::file::export_file_stem as sanitize;
use figcraft_engine::{BatchScope, BatchStep, Session};
use serde_json::{Value, json};
@@ -236,18 +239,6 @@ pub fn info(path: &str, as_json: bool) -> CliResult {
Ok(ExitCode::SUCCESS)
}
-/// The file name a layer exports to: the app's rule ([`figcraft_engine::cmd::file::safe_file_name`],
-/// so `/` becomes `_` too), without leading or trailing spaces and dots, at most 100 characters
-/// and 200 bytes (file systems allow 255, and a number and the extension still fit).
-fn sanitize(name: &str) -> String {
- let s = figcraft_engine::cmd::file::safe_file_name(name);
- let s = s.trim_matches(|c: char| c == '.' || c.is_whitespace());
- let cap = |s: &str| s.char_indices().take(100).take_while(|(i, c)| i + c.len_utf8() <= 200).map(|(_, c)| c).collect::();
- // Truncation can expose a device name; its escape must still fit the limits.
- let s = figcraft_engine::file_access::escape_device_names(&cap(s));
- if s.is_empty() { "layer".into() } else { cap(&s) }
-}
-
/// What `export` exports and how.
pub struct Target {
pub format: Option,
@@ -313,20 +304,9 @@ pub fn export(file: &str, out: &str, t: &Target) -> CliResult {
if ids.is_empty() {
return Err(CliError::Failed("the page is empty: nothing to export".into()));
}
- let mut used = std::collections::BTreeSet::new();
- let mut next_suffix: std::collections::HashMap = std::collections::HashMap::new();
+ let mut names = ExportNames::default();
for id in ids {
- let base = sanitize(doc.node(id).map(|n| n.name.as_str()).unwrap_or("layer"));
- let base_lower = base.to_lowercase();
- let next = next_suffix.entry(base_lower).or_insert(1);
- let name = loop {
- let k = *next;
- *next += 1;
- let candidate = if k == 1 { base.clone() } else { format!("{base} {k}") };
- if used.insert(candidate.to_lowercase()) {
- break candidate;
- }
- };
+ let name = names.push(doc.node(id).map(|n| n.name.as_str()).unwrap_or("layer"));
let path = Path::new(out).join(format!("{name}.{}", fmt.ext())).to_string_lossy().into_owned();
write(&path, &bytes_of(&[id])?)?;
println!("{path}");
diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs
index 0c84f3458..fe562359a 100644
--- a/crates/engine/src/cmd/file.rs
+++ b/crates/engine/src/cmd/file.rs
@@ -47,6 +47,41 @@ pub use version::MAX_AUTOSAVES;
pub(crate) use version::{add_version, keep_in_history, read_version, unique_id};
use version::{autosave, restore_version, save_version, version_index, version_json, version_list};
+/// The file base a layer exports to, shared by filesystem export and generated asset references.
+/// Preserves case and ordinary spaces, strips leading/trailing dots and whitespace, and caps at
+/// 100 characters and 200 bytes so a number and extension still fit common filesystems.
+pub fn export_file_stem(name: &str) -> String {
+ let s = safe_file_name(name);
+ let s = s.trim_matches(|c: char| c == '.' || c.is_whitespace());
+ let cap = |s: &str| s.char_indices().take(100).take_while(|(i, c)| i + c.len_utf8() <= 200).map(|(_, c)| c).collect::();
+ // Truncation can expose a device name; its escape must still fit the limits.
+ let s = crate::file_access::escape_device_names(&cap(s));
+ if s.is_empty() { "layer".into() } else { cap(&s) }
+}
+
+/// Case-insensitively unique export file bases, using the exporter's `" 2"`, `" 3"` suffixes.
+#[derive(Default)]
+pub struct ExportNames {
+ used: std::collections::BTreeSet,
+ next_suffix: std::collections::HashMap,
+}
+
+impl ExportNames {
+ /// Resolve the next layer name exactly as the filesystem exporter does.
+ pub fn push(&mut self, layer_name: &str) -> String {
+ let base = export_file_stem(layer_name);
+ let next = self.next_suffix.entry(base.to_lowercase()).or_insert(1);
+ loop {
+ let k = *next;
+ *next += 1;
+ let candidate = if k == 1 { base.clone() } else { format!("{base} {k}") };
+ if self.used.insert(candidate.to_lowercase()) {
+ return candidate;
+ }
+ }
+ }
+}
+
/// A new file of `kind` in a tab of its own.
fn new_file(s: &mut Session, p: &Value, kind: FileKind) -> Result {
let name = string(p, "name").unwrap_or_else(|| if kind == FileKind::Board { "Untitled board" } else { "Untitled" }.into());
diff --git a/crates/engine/src/dev/codegen.rs b/crates/engine/src/dev/codegen.rs
index 152af4136..373b1cd7d 100644
--- a/crates/engine/src/dev/codegen.rs
+++ b/crates/engine/src/dev/codegen.rs
@@ -582,11 +582,13 @@ mod tests {
let mut s = Session::new();
let icon =
id_of(&s.execute("frame.create", &json!({"name": "icon", "width": 24, "height": 24, "props": {"fill": "none"}})).unwrap()["id"]).unwrap();
- s.execute("vector.create", &json!({"path": "M4 12 L10 18 L20 6", "parent": icon, "name": "check", "props": {"fill": "none", "stroke": "#1F3A68", "strokeWeight": 2}})).unwrap();
+ let check = id_of(&s.execute("vector.create", &json!({"path": "M4 12 L10 18 L20 6", "parent": icon, "name": "check", "props": {"fill": "none", "stroke": "#1F3A68", "strokeWeight": 2}})).unwrap()["id"]).unwrap();
+ s.doc_mut().unwrap().get_mut(check).unwrap().fills = vec![Paint::solid(Color::WHITE)];
let doc = s.doc().unwrap();
let html = code_for(doc, icon, CodeLang::Html);
assert!(html.contains("
"), "{html}");
assert!(!html.contains("border: 2px solid"), "{html}");
+ assert!(!html.contains("background:"), "the vector's fill belongs to its SVG, not its box: {html}");
for lang in [CodeLang::React, CodeLang::Vue, CodeLang::Leptos, CodeLang::Tailwind] {
let code = code_for(doc, icon, lang);
assert!(code.contains("
= n.fills.iter().enumerate().filter(|(_, p)| p.visible).collect();
+ let visible: Vec<(usize, &figcraft_color::Paint)> = if matches!(n.kind, NodeKind::Vector { .. }) {
+ // The SVG carries the path's fills; an image's box must not get a rectangular one.
+ Vec::new()
+ } else {
+ n.fills.iter().enumerate().filter(|(_, p)| p.visible).collect()
+ };
let layers: Vec = visible
.iter()
.enumerate()
diff --git a/crates/engine/src/dev/codegen/html.rs b/crates/engine/src/dev/codegen/html.rs
index 9ccd99d7e..5b34c4d3c 100644
--- a/crates/engine/src/dev/codegen/html.rs
+++ b/crates/engine/src/dev/codegen/html.rs
@@ -152,6 +152,8 @@ pub(crate) struct Markup<'c, 'a> {
/// With `fluid`, other layers at least this share of the root's width are fluid too (a
/// divider, a banner image); smaller ones (icons) keep their size. Default: none.
pub fluid_leaves: f64,
+ /// SVG asset names, resolved by the same policy as the filesystem exporter.
+ asset_names: crate::cmd::file::ExportNames,
}
/// How `n` sits in its parent: in the flex flow, or placed at its position.
@@ -197,6 +199,7 @@ impl<'c, 'a> Markup<'c, 'a> {
inline: false,
fluid: false,
fluid_leaves: f64::INFINITY,
+ asset_names: Default::default(),
}
}
@@ -346,8 +349,12 @@ impl<'c, 'a> Markup<'c, 'a> {
match &n.kind {
NodeKind::Vector { .. } => {
// The exported SVG carries the path and its stroke; the class only places it.
- let alt = attr_escape(&n.name);
- self.markup.push_str(&format!("{pad}
\n"));
+ let src = self.asset_names.push(&n.name);
+ // Leptos attributes are Rust string literals; the other targets use HTML escaping.
+ let quote = |value: &str| if self.lang == CodeLang::Leptos { format!("{value:?}") } else { format!("\"{}\"", attr_escape(value)) };
+ let src = quote(&format!("{src}.svg"));
+ let alt = quote(&n.name);
+ self.markup.push_str(&format!("{pad}
\n"));
}
NodeKind::Text(t) => {
let body = self.text_body(n, t);
From 91de53c5862e9b2610cd3d9dcbf5705f80c366f8 Mon Sep 17 00:00:00 2001
From: ATOM
Date: Wed, 25 Nov 2026 01:30:37 -0600
Subject: [PATCH 3/5] fix(dev): embed node-local vector assets
---
crates/engine/src/dev/codegen.rs | 36 +++++++++++++++++++++------
crates/engine/src/dev/codegen/html.rs | 29 +++++++++++++++------
docs/dev-mode-parity.md | 6 ++---
3 files changed, 54 insertions(+), 17 deletions(-)
diff --git a/crates/engine/src/dev/codegen.rs b/crates/engine/src/dev/codegen.rs
index 373b1cd7d..c6a732e8f 100644
--- a/crates/engine/src/dev/codegen.rs
+++ b/crates/engine/src/dev/codegen.rs
@@ -577,6 +577,17 @@ mod tests {
assert!(!css.contains("gradient"), "{css}");
}
+ fn embedded_svgs(code: &str) -> Vec {
+ use base64::Engine as _;
+ code.split("data:image/svg+xml;base64,")
+ .skip(1)
+ .map(|rest| {
+ let b64 = rest.split('"').next().unwrap();
+ String::from_utf8(base64::engine::general_purpose::STANDARD.decode(b64).unwrap()).unwrap()
+ })
+ .collect()
+ }
+
#[test]
fn vector_code_uses_its_svg_asset_not_a_box_border() {
let mut s = Session::new();
@@ -586,12 +597,16 @@ mod tests {
s.doc_mut().unwrap().get_mut(check).unwrap().fills = vec![Paint::solid(Color::WHITE)];
let doc = s.doc().unwrap();
let html = code_for(doc, icon, CodeLang::Html);
- assert!(html.contains("
"), "{html}");
+ assert!(html.contains("
String {
s.replace('&', "&").replace('<', "<").replace('>', ">").replace('"', """).replace(['\n', '\r'], " ")
}
+/// A vector as a self-contained SVG asset. CSS owns the node's placement and opacity, so the
+/// embedded geometry is node-local and fully opaque. No filesystem export or URL escaping is
+/// needed, and nested vectors work exactly like top-level ones.
+fn vector_data_uri(doc: &mut Document, n: &Node) -> Option {
+ let node = doc.get_mut(n.id).ok()?;
+ node.parent = None;
+ node.transform = figcraft_geom::Affine::IDENTITY;
+ node.opacity = 1.0;
+ let svg = figcraft_svg::export_svg(doc, &[n.id], &Default::default())?;
+ Some(format!("data:image/svg+xml;base64,{}", base64::engine::general_purpose::STANDARD.encode(svg)))
+}
+
/// Text as JSX children: HTML escapes, braces as expressions, line breaks as `
`.
fn jsx_text(s: &str) -> String {
let mut out = String::new();
@@ -152,8 +166,8 @@ pub(crate) struct Markup<'c, 'a> {
/// With `fluid`, other layers at least this share of the root's width are fluid too (a
/// divider, a banner image); smaller ones (icons) keep their size. Default: none.
pub fluid_leaves: f64,
- /// SVG asset names, resolved by the same policy as the filesystem exporter.
- asset_names: crate::cmd::file::ExportNames,
+ /// Lazily cloned once for node-local SVG assets, not once per vector.
+ asset_doc: Option,
}
/// How `n` sits in its parent: in the flex flow, or placed at its position.
@@ -199,7 +213,7 @@ impl<'c, 'a> Markup<'c, 'a> {
inline: false,
fluid: false,
fluid_leaves: f64::INFINITY,
- asset_names: Default::default(),
+ asset_doc: None,
}
}
@@ -348,13 +362,14 @@ impl<'c, 'a> Markup<'c, 'a> {
let open = |tag: &str| format!("{pad}<{tag} {attr}=\"{class}\"{attrs}>");
match &n.kind {
NodeKind::Vector { .. } => {
- // The exported SVG carries the path and its stroke; the class only places it.
- let src = self.asset_names.push(&n.name);
// Leptos attributes are Rust string literals; the other targets use HTML escaping.
let quote = |value: &str| if self.lang == CodeLang::Leptos { format!("{value:?}") } else { format!("\"{}\"", attr_escape(value)) };
- let src = quote(&format!("{src}.svg"));
+ let root_doc = self.ctx.doc;
+ let src = vector_data_uri(self.asset_doc.get_or_insert_with(|| root_doc.clone()), n)
+ .map(|uri| format!(" src={}", quote(&uri)))
+ .unwrap_or_default();
let alt = quote(&n.name);
- self.markup.push_str(&format!("{pad}
\n"));
+ self.markup.push_str(&format!("{pad}
\n"));
}
NodeKind::Text(t) => {
let body = self.text_body(n, t);
diff --git a/docs/dev-mode-parity.md b/docs/dev-mode-parity.md
index 14003920b..491647eb1 100644
--- a/docs/dev-mode-parity.md
+++ b/docs/dev-mode-parity.md
@@ -2,7 +2,7 @@
> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-11-12 · **Change:** patch (SwiftUI, Compose and Flutter code write every visible colour and gradient fill of a frame, group, rectangle or ellipse in paint order, gradients as gradients, instead of one colour per layer (chained `.background` in SwiftUI, chained `Modifier.background` in Compose, a `DecoratedBox` for each fill under the top one in Flutter); CSS code export writes several fills as one layered `background`, top first, as the incumbent does (#2271): a solid above another fill becomes a one-colour gradient, the bottom solid stays a plain colour, Tailwind gets one `[background:...]` class; the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the Inspect tab then opens (never toggles away) with the caret in that layer's new-note field, and the engine never writes the note itself (#1840); the handoff mode reads Developer Mode in the interface, its ids and saved fields unchanged; class names transliterate non-ASCII layer names (#1235); measurements kept on the canvas; a read-only layers panel in Dev Mode; earlier: import lines in generated layer trees; compare with any saved version; Dev Mode behaviour suite: an inspect-only canvas, Changed in the ready list, statuses only on frames and sections; plugin panels from the Inspect tab) · **Target:** Figma Design Dev Mode (desktop app 126.10.7)
>
-> **2026-11-24 patch:** vector code export uses the SVG asset instead of inventing a box around its bounds: web markup references the SVG, and CSS, SwiftUI and ArkUI no longer draw a rectangle from the path stroke (#2270).
+> **2026-11-24 patch:** vector code export uses a self-contained SVG asset instead of inventing a box around its bounds: web markup embeds the node-local SVG as a data URI, and CSS, SwiftUI and ArkUI no longer draw a rectangle from the path stroke (#2270).
**Breadth ~98%, ready ~78% (estimated).** The inspect surface is broad, components connect
to the code components of a repository (with their imports, also inside generated layer trees),
@@ -12,7 +12,7 @@ repository, third-party integrations. Remaining: 1–2 h.
| Feature | Status | Notes |
|---|---|---|
-| 2026-11-24 | patch | Vector code export drew a path's stroke as a box border around its bounds (#2270). CSS, HTML, React, Vue, Leptos and Tailwind no longer invent that border; the markup targets write an `
` reference to the vector's SVG asset. SwiftUI and ArkUI no longer put a rectangle stroke around their vector image either. Ordinary box and ellipse strokes are unchanged. Test: `dev::codegen::tests::vector_code_uses_its_svg_asset_not_a_box_border`; real CLI exports the referenced SVG with the stroked path |
+| 2026-11-24 | patch | Vector code export drew a path's stroke as a box border around its bounds (#2270). CSS, HTML, React, Vue, Leptos and Tailwind no longer invent that border or a rectangular fill; the markup targets embed node-local SVG data URIs, so nested vectors need no external export and URL fragments cannot break them. CSS alone applies node rotation and opacity. SwiftUI and ArkUI no longer put a rectangle stroke around their vector image either. Ordinary box and ellipse strokes are unchanged. Tests: `dev::codegen::tests::vector_code_uses_its_svg_asset_not_a_box_border`, `dev::codegen::tests::vector_assets_are_self_contained_and_leptos_literals_escape`; real CLI decodes four nested SVGs and checks rotation/opacity |
| 2026-11-12 | patch | SwiftUI, Compose and Flutter code export kept one colour per layer (the bottom visible solid, or a gradient's first stop) and dropped every other fill (#2271). Now each writes every visible solid and gradient fill of a frame, group, rectangle or ellipse, in paint order, and a gradient as a gradient. SwiftUI chains `.background(...)` with the top fill first, since each one goes behind the ones before it (a rectangle or ellipse fills with the bottom paint and lays a copy of the shape over it for each paint above). Compose chains `Modifier.background(...)` with the bottom fill first, since each one draws over the ones before it (a linear gradient snaps to eight directions, radial and angular ones sit at the box's centre). Flutter keeps the top fill in the `Container` and wraps each fill under it in a `DecoratedBox`, the bottom fill outermost and the drop shadow on the outermost box. A layer with one solid fill gives the same code as before; a lone gradient is now a gradient, not its first stop's colour. Still not written: image and pattern fills in the native targets, ArkUI (one background and one gradient per component, so a stack needs extra nodes) and text with several fills. The incumbent's iOS and Android output wasn't measured: the order follows how each platform paints. Percentages and hours unchanged |
| 2026-11-07 | patch | Naming: the handoff mode is called Developer Mode in the interface, its shortcut row, its toasts, the control channel's refusal, the board refusal, the measurement parameter doc, the `.fig` export note, the CLI help and every catalog (24 languages, translations awaiting native review), since Figma holds a US registration for Dev Mode (7574348); command ids (`view.devMode`, `devMode.*`), preference keys and saved-document fields are unchanged, and the Actions palette still finds the command by the old name |
| Dev Mode toggle (Shift+D), Inspect panel | done | the canvas only inspects: presses select, pan and comment but never move, resize, draw or edit text and vectors; menus and shortcuts refuse design edits with a note (Dev Mode's annotations, statuses, dev resources, measurements, code connections and comments still work); a drawing tool chosen in the toolbar goes back to the design. The layers panel only selects and expands (no renaming, reordering, hiding or locking; a double click says why), and the Pages list only opens pages (no adding, renaming, reordering, duplicating or deleting). Files dropped on the canvas aren't imported (a dropped document still opens as a file of its own), and the Assets panel places, swaps and applies nothing, doesn't change Hide when publishing, and doesn't accept library updates or add, remove or swap libraries; each says why |
@@ -33,7 +33,7 @@ repository, third-party integrations. Remaining: 1–2 h.
| Date | Change | Summary |
|---|---|---|
-| 2026-11-24 | patch | Vector code export writes the SVG asset, not a rectangle made from the path's stroke (#2270). Percentages and hours unchanged. |
+| 2026-11-24 | patch | Vector code export embeds a self-contained SVG asset, not a rectangle made from the path's stroke (#2270). Percentages and hours unchanged. |
| 2026-11-13 | patch | Rows that recent merges had duplicated or garbled are merged back into one row each (no behaviour change): Code: CSS, iOS (SwiftUI), Android (Compose), Flutter. |
| 2026-11-12 | patch | CSS code export (#2271): a layer with several fills wrote one `background` per fill, so only the last survived. It now writes one `background` with every visible fill as a layer, top fill first, comma-separated: a solid above another fill is `linear-gradient(0deg, c, c)` (CSS allows a plain colour only as the last layer), the bottom solid stays a plain colour (with its variable), images and patterns keep their `url(...)` layers. Tailwind output carries the layered value as one `[background:...]` class. Text keeps one `color` per fill. Native targets unchanged. Percentages and hours unchanged |
| 2026-11-09 | patch | The Annotation tool (Shift+T, `tool.annotation {id?}`): selects the layer pressed on (or the selection, or `id`) and asks the UI for its note, which the Inspect tab takes in its new-note field; the engine writes nothing itself, and Developer Mode lets the tool through its gates (#1840). Figma's placement, cursor and whether the tool stays selected are unmeasured (Developer Mode is paywalled in the web app); staying selected until V or Escape, like the Comment tool, is inferred, and there is no toolbar button or icon yet |
From 777ccdcc24644621f1fc4c810a521736ccf9f976 Mon Sep 17 00:00:00 2001
From: ATOM
Date: Wed, 25 Nov 2026 09:38:41 -0600
Subject: [PATCH 4/5] fix(dev): preserve vector asset bounds
---
crates/engine/src/dev/codegen.rs | 55 ++++++++++++++++++++++-
crates/engine/src/dev/codegen/css.rs | 20 +++++++--
crates/engine/src/dev/codegen/html.rs | 63 +++++++++++++++++++--------
crates/engine/src/dev/tailwind.rs | 2 +
docs/dev-mode-parity.md | 4 +-
docs/parity-checklist.md | 6 +--
6 files changed, 123 insertions(+), 27 deletions(-)
diff --git a/crates/engine/src/dev/codegen.rs b/crates/engine/src/dev/codegen.rs
index c6a732e8f..2d69e2c7c 100644
--- a/crates/engine/src/dev/codegen.rs
+++ b/crates/engine/src/dev/codegen.rs
@@ -597,7 +597,8 @@ mod tests {
s.doc_mut().unwrap().get_mut(check).unwrap().fills = vec![Paint::solid(Color::WHITE)];
let doc = s.doc().unwrap();
let html = code_for(doc, icon, CodeLang::Html);
- assert!(html.contains("
"), "node wrapper: {html}");
+ assert!(html.contains("
"), "node-sized wrapper: {html}");
+ assert!(html.contains("
String {
/// The CSS declarations for `n`'s own look and size, one per line; `hug` leaves out the width
/// and/or height (they follow the content). Bound variables become `var(--name, value)`.
pub(crate) fn css_decls(doc: &Document, n: &Node, t: &mut Tokens, hug: (bool, bool)) -> String {
+ css_decls_impl(doc, n, t, hug, false)
+}
+
+/// The declarations around an embedded vector image: its SVG owns shadows and layer blur, so
+/// only the markup wrapper omits those. Standalone CSS and ordinary shapes keep them.
+pub(crate) fn css_decls_for_markup(doc: &Document, n: &Node, t: &mut Tokens, hug: (bool, bool)) -> String {
+ css_decls_impl(doc, n, t, hug, true)
+}
+
+fn css_decls_impl(doc: &Document, n: &Node, t: &mut Tokens, hug: (bool, bool), vector_svg: bool) -> String {
let px = |v: f64| format!("{}px", num(v));
let mut out = String::new();
let mut put = |key: &str, value: String| out.push_str(&format!("{key}: {value};\n"));
@@ -222,7 +232,7 @@ pub(crate) fn css_decls(doc: &Document, n: &Node, t: &mut Tokens, hug: (bool, bo
for (key, value) in css_borders(doc, n, t) {
put(&key, value);
}
- effect_decls(n, &mut put);
+ effect_decls(n, &mut put, vector_svg && matches!(n.kind, NodeKind::Vector { .. }));
if let NodeKind::Text(tx) = &n.kind {
text_decls(doc, n, tx, t, &mut put);
}
@@ -279,12 +289,14 @@ fn layout_decls(doc: &Document, n: &Node, l: &figcraft_doc::AutoLayout, t: &mut
}
}
-/// Shadows and blurs of `n`.
-fn effect_decls(n: &Node, put: &mut impl FnMut(&str, String)) {
+/// Shadows and blurs of `n`. `svg_owned` leaves shadows and layer blur to the embedded SVG;
+/// backdrop filters stay in CSS because the self-contained asset has no outer page behind it.
+fn effect_decls(n: &Node, put: &mut impl FnMut(&str, String), svg_owned: bool) {
let shadows: Vec = n
.effects
.iter()
.filter(|e| e.visible)
+ .filter(|e| !(svg_owned && matches!(e.kind, EffectKind::DropShadow(_) | EffectKind::InnerShadow(_))))
.filter_map(|e| match &e.kind {
EffectKind::DropShadow(s) => {
Some(format!("{}px {}px {}px {}px {}", num(s.offset.0), num(s.offset.1), num(s.radius), num(s.spread), s.color.to_css()))
@@ -301,7 +313,7 @@ fn effect_decls(n: &Node, put: &mut impl FnMut(&str, String)) {
for e in n.effects.iter().filter(|e| e.visible) {
match e.kind {
// CSS blurs are uniform: a progressive blur has no CSS equivalent and is left out.
- EffectKind::LayerBlur(ref b) if !b.is_progressive() => put("filter", format!("blur({}px)", num(b.radius / 2.0))),
+ EffectKind::LayerBlur(ref b) if !svg_owned && !b.is_progressive() => put("filter", format!("blur({}px)", num(b.radius / 2.0))),
EffectKind::BackgroundBlur(ref b) if !b.is_progressive() => put("backdrop-filter", format!("blur({}px)", num(b.radius / 2.0))),
// CSS has no refraction: the frost is the nearest.
EffectKind::Glass(ref g) => put("backdrop-filter", format!("blur({}px)", num(g.sanitized().frost / 2.0))),
diff --git a/crates/engine/src/dev/codegen/html.rs b/crates/engine/src/dev/codegen/html.rs
index 6a6c44483..7632a42de 100644
--- a/crates/engine/src/dev/codegen/html.rs
+++ b/crates/engine/src/dev/codegen/html.rs
@@ -1,6 +1,6 @@
use base64::Engine as _;
-use super::css::{Tokens, css_decls};
+use super::css::{Tokens, css_decls_for_markup};
use super::{CodeLang, Ctx, Document, LayoutMode, Node, NodeId, NodeKind, Param, Sizing, indent, num, with_v_if};
// ------------------------------------------------------------------ HTML and React markup
@@ -92,16 +92,17 @@ fn attr_escape(s: &str) -> String {
s.replace('&', "&").replace('<', "<").replace('>', ">").replace('"', """).replace(['\n', '\r'], " ")
}
-/// A vector as a self-contained SVG asset. CSS owns the node's placement and opacity, so the
-/// embedded geometry is node-local and fully opaque. No filesystem export or URL escaping is
-/// needed, and nested vectors work exactly like top-level ones.
-fn vector_data_uri(doc: &mut Document, n: &Node) -> Option {
+/// A vector as a self-contained SVG asset and its local painted bounds. CSS owns the node's
+/// placement and opacity, so the embedded geometry is node-local and fully opaque. No filesystem
+/// export or URL escaping is needed, and nested vectors work exactly like top-level ones.
+fn vector_data_uri(doc: &mut Document, n: &Node) -> Option<(String, figcraft_geom::Rect)> {
let node = doc.get_mut(n.id).ok()?;
node.parent = None;
node.transform = figcraft_geom::Affine::IDENTITY;
node.opacity = 1.0;
+ let bounds = figcraft_render::export_bounds(doc, n.id)?;
let svg = figcraft_svg::export_svg(doc, &[n.id], &Default::default())?;
- Some(format!("data:image/svg+xml;base64,{}", base64::engine::general_purpose::STANDARD.encode(svg)))
+ Some((format!("data:image/svg+xml;base64,{}", base64::engine::general_purpose::STANDARD.encode(svg)), bounds))
}
/// Text as JSX children: HTML escapes, braces as expressions, line breaks as `
`.
@@ -196,6 +197,18 @@ fn placement_decls(n: &Node, parent: Option<&Node>, root: bool, in_flow: bool) -
decls
}
+/// Extra declarations around an embedded vector image. The inner SVG can be larger than the
+/// node box, so the wrapper must establish positioning in flex flow and leave overflow visible.
+fn vector_wrapper_decls(n: &Node, in_flow: bool, own: &mut String) {
+ if !matches!(n.kind, NodeKind::Vector { .. }) {
+ return;
+ }
+ own.push_str("overflow: visible;\n");
+ if in_flow {
+ own.push_str("position: relative;\n");
+ }
+}
+
impl<'c, 'a> Markup<'c, 'a> {
pub fn new(ctx: &'c Ctx<'a>, lang: CodeLang) -> Self {
Markup {
@@ -312,6 +325,30 @@ impl<'c, 'a> Markup<'c, 'a> {
}
}
+ /// A node-sized wrapper and its inner SVG image. The inner rule uses the exported bounds,
+ /// so strokes and effects keep their size and can overflow the wrapper without clipping.
+ fn vector_element(&mut self, n: &Node, depth: usize, path: &str, class: &str, attr: &str, pad: &str, attrs: &str) {
+ let root_doc = self.ctx.doc;
+ let asset = vector_data_uri(self.asset_doc.get_or_insert_with(|| root_doc.clone()), n);
+ let bounds = asset.as_ref().map(|(_, b)| *b).unwrap_or_else(|| n.local_rect());
+ let asset_class = class_name(&format!("{class} asset"), "asset", &mut self.used);
+ let asset_decls = format!(
+ "display: block;\nposition: absolute;\nleft: {}px;\ntop: {}px;\nwidth: {}px;\nheight: {}px;\nmax-width: none;\n",
+ num(bounds.x0),
+ num(bounds.y0),
+ num(bounds.width()),
+ num(bounds.height())
+ );
+ self.rule(&format!("{path}/$svg"), &asset_class, asset_decls);
+ // Leptos attributes are Rust string literals; the other targets use HTML escaping.
+ let lang = self.lang;
+ let quote = |value: &str| if lang == CodeLang::Leptos { format!("{value:?}") } else { format!("\"{}\"", attr_escape(value)) };
+ let src = asset.map(|(uri, _)| format!(" src={}", quote(&uri))).unwrap_or_default();
+ let alt = quote(&n.name);
+ let inner = self.pad(depth + 1);
+ self.markup.push_str(&format!("{pad}\n{inner}
![{alt}]()
\n{pad}
\n"));
+ }
+
fn element(&mut self, n: &Node, parent: Option<&Node>, depth: usize, path: &str) {
let doc = self.ctx.doc;
let root = n.id == self.ctx.root;
@@ -341,7 +378,7 @@ impl<'c, 'a> Markup<'c, 'a> {
}
let hugs = n.layout.is_some() || matches!(n.kind, NodeKind::Text(_));
let hug = (hugs && n.child_layout.sizing_h == Sizing::Hug, hugs && n.child_layout.sizing_v == Sizing::Hug);
- let mut own = css_decls(doc, n, &mut self.tokens, hug);
+ let mut own = css_decls_for_markup(doc, n, &mut self.tokens, hug);
let page = self.ctx.doc.node(self.ctx.root).map_or(f64::INFINITY, |r| r.width);
if self.fluid && (n.layout.is_some() || matches!(n.kind, NodeKind::Text(_)) || (!root && n.width >= page * self.fluid_leaves)) {
// Full width, or sized by the flex row (`flex: 1`): no cap needed.
@@ -350,6 +387,7 @@ impl<'c, 'a> Markup<'c, 'a> {
if n.layout.is_none() && !n.children.is_empty() && !root && in_flow {
own.push_str("position: relative;\n");
}
+ vector_wrapper_decls(n, in_flow, &mut own);
decls.push_str(&own);
self.rule(path, &class, decls);
// The root's variant attributes, and a Vue `v-if` guard, ride on the open tag.
@@ -361,16 +399,7 @@ impl<'c, 'a> Markup<'c, 'a> {
}
let open = |tag: &str| format!("{pad}<{tag} {attr}=\"{class}\"{attrs}>");
match &n.kind {
- NodeKind::Vector { .. } => {
- // Leptos attributes are Rust string literals; the other targets use HTML escaping.
- let quote = |value: &str| if self.lang == CodeLang::Leptos { format!("{value:?}") } else { format!("\"{}\"", attr_escape(value)) };
- let root_doc = self.ctx.doc;
- let src = vector_data_uri(self.asset_doc.get_or_insert_with(|| root_doc.clone()), n)
- .map(|uri| format!(" src={}", quote(&uri)))
- .unwrap_or_default();
- let alt = quote(&n.name);
- self.markup.push_str(&format!("{pad}
\n"));
- }
+ NodeKind::Vector { .. } => self.vector_element(n, depth, path, &class, attr, &pad, &attrs),
NodeKind::Text(t) => {
let body = self.text_body(n, t);
self.markup.push_str(&format!("{}{body}\n", open("p")));
diff --git a/crates/engine/src/dev/tailwind.rs b/crates/engine/src/dev/tailwind.rs
index b8629e6b3..373c96dbd 100644
--- a/crates/engine/src/dev/tailwind.rs
+++ b/crates/engine/src/dev/tailwind.rs
@@ -274,8 +274,10 @@ fn decl(key: &str, value: &str) -> Vec<(String, String)> {
("width", "100%") => kw("w-full"),
("width", v) => one(spacing("w", v)),
("height", v) => one(spacing("h", v)),
+ ("max-width", "none") => kw("max-w-none"),
("max-width", v) => one(format!("max-w-{}", arb(v))),
("min-height", v) => one(format!("min-h-{}", arb(v))),
+ ("overflow", "visible") => kw("overflow-visible"),
("margin-inline", "auto") => kw("mx-auto"),
("gap", v) => one(spacing("gap", v)),
("padding", v) => padding(v),
diff --git a/docs/dev-mode-parity.md b/docs/dev-mode-parity.md
index 491647eb1..3ba24ab7f 100644
--- a/docs/dev-mode-parity.md
+++ b/docs/dev-mode-parity.md
@@ -2,7 +2,7 @@
> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-11-12 · **Change:** patch (SwiftUI, Compose and Flutter code write every visible colour and gradient fill of a frame, group, rectangle or ellipse in paint order, gradients as gradients, instead of one colour per layer (chained `.background` in SwiftUI, chained `Modifier.background` in Compose, a `DecoratedBox` for each fill under the top one in Flutter); CSS code export writes several fills as one layered `background`, top first, as the incumbent does (#2271): a solid above another fill becomes a one-colour gradient, the bottom solid stays a plain colour, Tailwind gets one `[background:...]` class; the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the Inspect tab then opens (never toggles away) with the caret in that layer's new-note field, and the engine never writes the note itself (#1840); the handoff mode reads Developer Mode in the interface, its ids and saved fields unchanged; class names transliterate non-ASCII layer names (#1235); measurements kept on the canvas; a read-only layers panel in Dev Mode; earlier: import lines in generated layer trees; compare with any saved version; Dev Mode behaviour suite: an inspect-only canvas, Changed in the ready list, statuses only on frames and sections; plugin panels from the Inspect tab) · **Target:** Figma Design Dev Mode (desktop app 126.10.7)
>
-> **2026-11-24 patch:** vector code export uses a self-contained SVG asset instead of inventing a box around its bounds: web markup embeds the node-local SVG as a data URI, and CSS, SwiftUI and ArkUI no longer draw a rectangle from the path stroke (#2270).
+> **2026-11-24 patch:** vector code export uses a self-contained SVG asset instead of inventing a box around its bounds: web markup embeds the node-local SVG as a data URI inside a node-sized wrapper with the SVG's painted bounds, and CSS, SwiftUI and ArkUI no longer draw a rectangle from the path stroke (#2270).
**Breadth ~98%, ready ~78% (estimated).** The inspect surface is broad, components connect
to the code components of a repository (with their imports, also inside generated layer trees),
@@ -12,7 +12,7 @@ repository, third-party integrations. Remaining: 1–2 h.
| Feature | Status | Notes |
|---|---|---|
-| 2026-11-24 | patch | Vector code export drew a path's stroke as a box border around its bounds (#2270). CSS, HTML, React, Vue, Leptos and Tailwind no longer invent that border or a rectangular fill; the markup targets embed node-local SVG data URIs, so nested vectors need no external export and URL fragments cannot break them. CSS alone applies node rotation and opacity. SwiftUI and ArkUI no longer put a rectangle stroke around their vector image either. Ordinary box and ellipse strokes are unchanged. Tests: `dev::codegen::tests::vector_code_uses_its_svg_asset_not_a_box_border`, `dev::codegen::tests::vector_assets_are_self_contained_and_leptos_literals_escape`; real CLI decodes four nested SVGs and checks rotation/opacity |
+| 2026-11-24 | patch | Vector code export drew a path's stroke as a box border around its bounds (#2270). CSS, HTML, React, Vue, Leptos and Tailwind no longer invent that border or a rectangular fill; the markup targets embed node-local SVG data URIs, so nested vectors need no external export and URL fragments cannot break them. A node-sized wrapper keeps layout, rotation and opacity, while the inner image uses the SVG's painted bounds with visible overflow. The SVG owns shadows and layer blur, so wrapper CSS does not apply them twice; standalone CSS and ordinary shapes keep theirs. SwiftUI and ArkUI no longer put a rectangle stroke around their vector image either. Ordinary box and ellipse strokes are unchanged. Tests: `dev::codegen::tests::vector_code_uses_its_svg_asset_not_a_box_border`, `dev::codegen::tests::vector_assets_are_self_contained_and_leptos_literals_escape`, `dev::codegen::tests::vector_asset_keeps_stroke_overflow_inside_a_node_sized_wrapper`, `dev::codegen::tests::vector_markup_does_not_duplicate_svg_effects`; real CLI checks nested assets, rotation/opacity, 24→28 stroke bounds and single-application effects |
| 2026-11-12 | patch | SwiftUI, Compose and Flutter code export kept one colour per layer (the bottom visible solid, or a gradient's first stop) and dropped every other fill (#2271). Now each writes every visible solid and gradient fill of a frame, group, rectangle or ellipse, in paint order, and a gradient as a gradient. SwiftUI chains `.background(...)` with the top fill first, since each one goes behind the ones before it (a rectangle or ellipse fills with the bottom paint and lays a copy of the shape over it for each paint above). Compose chains `Modifier.background(...)` with the bottom fill first, since each one draws over the ones before it (a linear gradient snaps to eight directions, radial and angular ones sit at the box's centre). Flutter keeps the top fill in the `Container` and wraps each fill under it in a `DecoratedBox`, the bottom fill outermost and the drop shadow on the outermost box. A layer with one solid fill gives the same code as before; a lone gradient is now a gradient, not its first stop's colour. Still not written: image and pattern fills in the native targets, ArkUI (one background and one gradient per component, so a stack needs extra nodes) and text with several fills. The incumbent's iOS and Android output wasn't measured: the order follows how each platform paints. Percentages and hours unchanged |
| 2026-11-07 | patch | Naming: the handoff mode is called Developer Mode in the interface, its shortcut row, its toasts, the control channel's refusal, the board refusal, the measurement parameter doc, the `.fig` export note, the CLI help and every catalog (24 languages, translations awaiting native review), since Figma holds a US registration for Dev Mode (7574348); command ids (`view.devMode`, `devMode.*`), preference keys and saved-document fields are unchanged, and the Actions palette still finds the command by the old name |
| Dev Mode toggle (Shift+D), Inspect panel | done | the canvas only inspects: presses select, pan and comment but never move, resize, draw or edit text and vectors; menus and shortcuts refuse design edits with a note (Dev Mode's annotations, statuses, dev resources, measurements, code connections and comments still work); a drawing tool chosen in the toolbar goes back to the design. The layers panel only selects and expands (no renaming, reordering, hiding or locking; a double click says why), and the Pages list only opens pages (no adding, renaming, reordering, duplicating or deleting). Files dropped on the canvas aren't imported (a dropped document still opens as a file of its own), and the Assets panel places, swaps and applies nothing, doesn't change Hide when publishing, and doesn't accept library updates or add, remove or swap libraries; each says why |
diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md
index 13fda27c1..27a492d33 100644
--- a/docs/parity-checklist.md
+++ b/docs/parity-checklist.md
@@ -1,10 +1,10 @@
# Parity checklist
-> **Generated:** 2026-10-21 by `cargo xtask parity`. Do not edit by hand.
+> **Generated:** 2026-11-25 by `cargo xtask parity`. Do not edit by hand.
-FigCraft commands registered for the incumbent's main menu and toolbar (575 commands in the engine).
+FigCraft commands registered for the incumbent's main menu and toolbar (652 commands in the engine).
-**212 / 212 menu items (100.0%)**
+**215 / 215 menu items (100.0%)**
Every catalog item has a command.
From e0d3f16477a06736bb80f29f7e17a415f736a232 Mon Sep 17 00:00:00 2001
From: ATOM
Date: Wed, 25 Nov 2026 09:39:40 -0600
Subject: [PATCH 5/5] refactor(dev): drop unused export naming
---
apps/figcraft-cli/src/files.rs | 30 ++++++++++++++++++++++++-----
crates/engine/src/cmd/file.rs | 35 ----------------------------------
2 files changed, 25 insertions(+), 40 deletions(-)
diff --git a/apps/figcraft-cli/src/files.rs b/apps/figcraft-cli/src/files.rs
index a916e4ecb..5f4a006f4 100644
--- a/apps/figcraft-cli/src/files.rs
+++ b/apps/figcraft-cli/src/files.rs
@@ -5,9 +5,6 @@ use std::path::Path;
use std::process::ExitCode;
use figcraft_doc::{Document, ExportFormat, ExportSetting, NodeId, NodeKind, PrintSettings, VdCompat};
-use figcraft_engine::cmd::file::ExportNames;
-#[cfg(test)]
-use figcraft_engine::cmd::file::export_file_stem as sanitize;
use figcraft_engine::{BatchScope, BatchStep, Session};
use serde_json::{Value, json};
@@ -239,6 +236,18 @@ pub fn info(path: &str, as_json: bool) -> CliResult {
Ok(ExitCode::SUCCESS)
}
+/// The file name a layer exports to: the app's rule ([`figcraft_engine::cmd::file::safe_file_name`],
+/// so `/` becomes `_` too), without leading or trailing spaces and dots, at most 100 characters
+/// and 200 bytes (file systems allow 255, and a number and the extension still fit).
+fn sanitize(name: &str) -> String {
+ let s = figcraft_engine::cmd::file::safe_file_name(name);
+ let s = s.trim_matches(|c: char| c == '.' || c.is_whitespace());
+ let cap = |s: &str| s.char_indices().take(100).take_while(|(i, c)| i + c.len_utf8() <= 200).map(|(_, c)| c).collect::();
+ // Truncation can expose a device name; its escape must still fit the limits.
+ let s = figcraft_engine::file_access::escape_device_names(&cap(s));
+ if s.is_empty() { "layer".into() } else { cap(&s) }
+}
+
/// What `export` exports and how.
pub struct Target {
pub format: Option,
@@ -304,9 +313,20 @@ pub fn export(file: &str, out: &str, t: &Target) -> CliResult {
if ids.is_empty() {
return Err(CliError::Failed("the page is empty: nothing to export".into()));
}
- let mut names = ExportNames::default();
+ let mut used = std::collections::BTreeSet::new();
+ let mut next_suffix: std::collections::HashMap = std::collections::HashMap::new();
for id in ids {
- let name = names.push(doc.node(id).map(|n| n.name.as_str()).unwrap_or("layer"));
+ let base = sanitize(doc.node(id).map(|n| n.name.as_str()).unwrap_or("layer"));
+ let base_lower = base.to_lowercase();
+ let next = next_suffix.entry(base_lower).or_insert(1);
+ let name = loop {
+ let k = *next;
+ *next += 1;
+ let candidate = if k == 1 { base.clone() } else { format!("{base} {k}") };
+ if used.insert(candidate.to_lowercase()) {
+ break candidate;
+ }
+ };
let path = Path::new(out).join(format!("{name}.{}", fmt.ext())).to_string_lossy().into_owned();
write(&path, &bytes_of(&[id])?)?;
println!("{path}");
diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs
index fe562359a..0c84f3458 100644
--- a/crates/engine/src/cmd/file.rs
+++ b/crates/engine/src/cmd/file.rs
@@ -47,41 +47,6 @@ pub use version::MAX_AUTOSAVES;
pub(crate) use version::{add_version, keep_in_history, read_version, unique_id};
use version::{autosave, restore_version, save_version, version_index, version_json, version_list};
-/// The file base a layer exports to, shared by filesystem export and generated asset references.
-/// Preserves case and ordinary spaces, strips leading/trailing dots and whitespace, and caps at
-/// 100 characters and 200 bytes so a number and extension still fit common filesystems.
-pub fn export_file_stem(name: &str) -> String {
- let s = safe_file_name(name);
- let s = s.trim_matches(|c: char| c == '.' || c.is_whitespace());
- let cap = |s: &str| s.char_indices().take(100).take_while(|(i, c)| i + c.len_utf8() <= 200).map(|(_, c)| c).collect::();
- // Truncation can expose a device name; its escape must still fit the limits.
- let s = crate::file_access::escape_device_names(&cap(s));
- if s.is_empty() { "layer".into() } else { cap(&s) }
-}
-
-/// Case-insensitively unique export file bases, using the exporter's `" 2"`, `" 3"` suffixes.
-#[derive(Default)]
-pub struct ExportNames {
- used: std::collections::BTreeSet,
- next_suffix: std::collections::HashMap,
-}
-
-impl ExportNames {
- /// Resolve the next layer name exactly as the filesystem exporter does.
- pub fn push(&mut self, layer_name: &str) -> String {
- let base = export_file_stem(layer_name);
- let next = self.next_suffix.entry(base.to_lowercase()).or_insert(1);
- loop {
- let k = *next;
- *next += 1;
- let candidate = if k == 1 { base.clone() } else { format!("{base} {k}") };
- if self.used.insert(candidate.to_lowercase()) {
- return candidate;
- }
- }
- }
-}
-
/// A new file of `kind` in a tab of its own.
fn new_file(s: &mut Session, p: &Value, kind: FileKind) -> Result {
let name = string(p, "name").unwrap_or_else(|| if kind == FileKind::Board { "Untitled board" } else { "Untitled" }.into());